/**
 * board.css — Board grid, pieces, highlights, move history panel
 */

/* ── Board Container ────────────────────────────────────────────────────────── */
.board-container {
    position: relative;
    width: 600px;
    max-width: 100%;
    background: var(--ch-board-dark);
    border: 3px solid var(--ch-board-border);
    border-radius: 4px;
    box-shadow: 
        0 0 20px var(--ch-player-glow),
        inset 0 0 20px rgba(0,0,0,0.5);
    overflow: hidden;
}

/* ── Board Grid ─────────────────────────────────────────────────────────────── */
.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    aspect-ratio: 1;
}

/* ── Squares ────────────────────────────────────────────────────────────────── */
.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
}

.square.light {
    background: var(--ch-board-light);
}

.square.dark {
    background: var(--ch-board-dark);
}

.square.selected {
    background: rgba(255, 255, 255, 0.2);
}

.square.highlighted {
    background: rgba(57, 255, 110, 0.3);
}

.square.highlighted::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: var(--ch-highlight);
    border-radius: 50%;
    opacity: 0.6;
}

.square.highlighted-capture {
    background: rgba(255, 224, 58, 0.2);
}

.square.highlighted-capture::after {
    content: '';
    position: absolute;
    width: 90%;
    height: 90%;
    border: 3px solid var(--ch-last-move);
    border-radius: 50%;
    opacity: 0.6;
}

.square.last-move {
    background: rgba(255, 224, 58, 0.15);
}

.square.in-check {
    background: rgba(255, 61, 61, 0.3);
    box-shadow: inset 0 0 15px var(--ch-check-glow);
}

/* ── Square Labels ──────────────────────────────────────────────────────────── */
.square-label {
    position: absolute;
    font-size: 7px;
    color: var(--ch-text-dim);
    opacity: 0.5;
    pointer-events: none;
}

.square-label.file {
    bottom: 2px;
    right: 3px;
}

.square-label.rank {
    top: 2px;
    left: 3px;
}

/* ── Pieces ─────────────────────────────────────────────────────────────────── */
.piece {
    position: relative;
    width: 85%;
    height: 85%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    z-index: 2;
    image-rendering: pixelated;
}

.piece canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.piece.selected {
    transform: scale(1.1);
    filter: drop-shadow(0 0 8px var(--ch-selected-glow));
}

/* ── Piece Counts ───────────────────────────────────────────────────────────── */
.piece-counts {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.piece-count {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid var(--ch-text-dim);
}

.piece-count-label {
    font-size: 8px;
    color: var(--ch-text-dim);
}

.piece-count-value {
    font-size: 12px;
    font-weight: bold;
}

.piece-count.player .piece-count-value {
    color: var(--ch-player);
    text-shadow: 0 0 8px var(--ch-player-glow);
}

.piece-count.ai .piece-count-value {
    color: var(--ch-ai);
    text-shadow: 0 0 8px var(--ch-ai-glow);
}

/* ── Move History Panel ─────────────────────────────────────────────────────── */
.move-history-panel {
    background: var(--ch-board-dark);
    border: 2px solid var(--ch-board-border);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    max-height: 480px;
}

.move-history-header {
    padding: 8px 12px;
    font-size: 8px;
    color: var(--ch-player);
    border-bottom: 1px solid var(--ch-text-dim);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.move-history-toggle {
    background: none;
    border: none;
    color: var(--ch-text-dim);
    font-size: 10px;
    cursor: pointer;
    padding: 2px 6px;
}

.move-history-toggle:hover {
    color: var(--ch-player);
}

.move-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.move-pair {
    display: flex;
    gap: 8px;
    font-size: 8px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.move-number {
    color: var(--ch-text-dim);
    min-width: 25px;
}

.move-white {
    color: var(--ch-player);
    min-width: 60px;
}

.move-black {
    color: var(--ch-ai);
    min-width: 60px;
}

.move-pair:last-child .move-white,
.move-pair:last-child .move-black {
    text-decoration: underline;
}

/* ── Scrollbar Styling ──────────────────────────────────────────────────────── */
.move-history-list::-webkit-scrollbar {
    width: 6px;
}

.move-history-list::-webkit-scrollbar-track {
    background: var(--ch-bg);
}

.move-history-list::-webkit-scrollbar-thumb {
    background: var(--ch-text-dim);
    border-radius: 3px;
}

.move-history-list::-webkit-scrollbar-thumb:hover {
    background: var(--ch-player);
}
