/**
 * VECTOR Game v2.0 - Board Styles
 * Board rendering, squares, and influence overlay
 */

/* ============================================
   BOARD CONTAINER
   ============================================ */
.board {
    display: grid;
    grid-template-columns: repeat(9, var(--square-size));
    grid-template-rows: repeat(9, var(--square-size));
    gap: 1px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-accent);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    position: relative;
}

/* ============================================
   SQUARES
   ============================================ */
.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--square-size);
    height: var(--square-size);
    cursor: pointer;
    transition: background var(--transition-fast);
}

/* Light squares */
.square.light {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.08) 0%, 
        rgba(255, 255, 255, 0.04) 100%);
}

/* Dark squares */
.square.dark {
    background: linear-gradient(135deg, 
        rgba(0, 0, 0, 0.15) 0%, 
        rgba(0, 0, 0, 0.08) 100%);
}

/* Square hover effect */
.square:hover {
    background: var(--surface-hover);
}

/* Square labels (coordinates) */
.square-label {
    position: absolute;
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--text-muted);
    pointer-events: none;
    user-select: none;
}

.square-label.file {
    top: 2px;
    right: 4px;
}

.square-label.rank {
    bottom: 2px;
    left: 4px;
}

/* ============================================
   NEXUS SQUARE (CENTER)
   ============================================ */
.square.nexus {
    background: linear-gradient(135deg,
        rgba(255, 200, 87, 0.15) 0%,
        rgba(255, 200, 87, 0.08) 100%);
    position: relative;
}

.square.nexus::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid var(--accent-gold);
    border-radius: 4px;
    pointer-events: none;
    box-shadow: inset 0 0 20px rgba(255, 200, 87, 0.2);
    animation: nexusPulse 3s ease-in-out infinite;
}

@keyframes nexusPulse {
    0%, 100% {
        box-shadow: inset 0 0 20px rgba(255, 200, 87, 0.2);
    }
    50% {
        box-shadow: inset 0 0 30px rgba(255, 200, 87, 0.35);
    }
}

/* Nexus icon */
.nexus-icon {
    position: absolute;
    width: 20px;
    height: 20px;
    opacity: 0.6;
    pointer-events: none;
}

.nexus-icon svg {
    width: 100%;
    height: 100%;
    fill: var(--accent-gold);
}

/* ============================================
   LEGAL MOVE HIGHLIGHTS
   ============================================ */
.square.legal-move {
    cursor: pointer;
}

.square.legal-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: var(--accent-green);
    border-radius: 50%;
    opacity: 0.7;
    animation: pulseLegal 1.5s ease-in-out infinite;
    pointer-events: none;
}

/* Legal move for occupied squares (capture) */
.square.legal-move.has-enemy::after {
    width: 90%;
    height: 90%;
    background: transparent;
    border: 3px solid var(--accent-green);
    border-radius: var(--radius-sm);
    opacity: 0.8;
}

@keyframes pulseLegal {
    0%, 100% {
        transform: scale(1);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.9;
    }
}

/* ============================================
   SELECTED SQUARE
   ============================================ */
.square.selected {
    background: var(--surface-active);
}

.square.selected::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid var(--accent-blue);
    border-radius: 4px;
    pointer-events: none;
    box-shadow: var(--shadow-glow-blue);
}

/* ============================================
   LAST MOVE HIGHLIGHT
   ============================================ */
.square.last-move-from,
.square.last-move-to {
    position: relative;
}

.square.last-move-from::before,
.square.last-move-to::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 200, 87, 0.15);
    pointer-events: none;
}

/* ============================================
   INFLUENCE OVERLAY
   ============================================ */
.influence-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(9, var(--square-size));
    grid-template-rows: repeat(9, var(--square-size));
    gap: 1px;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.influence-overlay.visible {
    opacity: 1;
}

.influence-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* White influence */
.influence-cell.white-influence {
    background: rgba(74, 158, 255, 0.25);
}

.influence-cell.white-influence-strong {
    background: rgba(74, 158, 255, 0.4);
}

/* Black influence */
.influence-cell.black-influence {
    background: rgba(255, 107, 107, 0.25);
}

.influence-cell.black-influence-strong {
    background: rgba(255, 107, 107, 0.4);
}

/* Contested */
.influence-cell.contested {
    background: linear-gradient(135deg,
        rgba(74, 158, 255, 0.2) 0%,
        rgba(255, 107, 107, 0.2) 100%);
}

/* ============================================
   COLLAPSE INDICATOR
   ============================================ */
.square.collapse-threat {
    position: relative;
}

.square.collapse-threat::after {
    content: '!';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-red);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 50%;
    animation: pulseWarning 1s ease-in-out infinite;
}

@keyframes pulseWarning {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ============================================
   BOARD EDGE COORDINATES
   ============================================ */
.board-wrapper {
    position: relative;
    padding: 20px;
}

.board-edge-labels {
    position: absolute;
    display: flex;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.board-edge-labels.files {
    bottom: 4px;
    left: 20px;
    right: 20px;
    justify-content: space-around;
}

.board-edge-labels.ranks {
    top: 20px;
    bottom: 20px;
    left: 4px;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
}

.board-edge-labels span {
    width: var(--square-size);
    text-align: center;
}

/* ============================================
   RESPONSIVE BOARD SIZING
   ============================================ */
@media (max-width: 900px) {
    :root {
        --board-size: min(450px, calc(100vw - 380px));
    }
}

@media (max-width: 768px) {
    :root {
        --board-size: min(400px, calc(100vw - 48px));
    }
    
    .square-label {
        font-size: 0.5rem;
    }
}

@media (max-width: 480px) {
    :root {
        --board-size: min(340px, calc(100vw - 32px));
    }
    
    .square-label {
        display: none;
    }
}