﻿/* -- board.css -- Verdict Alpha -- */
/* Board Panel */
.board-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.board-outer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.board-row {
    display: flex;
    gap: 4px;
    align-items: stretch;
    justify-content: center;
    width: 100%;
}

.coord-ranks {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    font-size: 0.75rem;
    color: var(--text-dark);
    width: 20px;
    text-align: right;
    padding-right: 4px;
}

.coord-files {
    display: flex;
    justify-content: space-around;
    font-size: 0.75rem;
    color: var(--text-dark);
    width: calc(100% - 24px);
    margin-left: 24px;
    padding-left: 0;
}

.board-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
    aspect-ratio: 1 / 1;
    touch-action: none; /* Prevents scroll while interacting with board */
}

#chessboard {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid var(--border);
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: background 0.1s;
}

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

.square.selected {
    background: var(--square-selected) !important;
}
.square.last-move {
    box-shadow: inset 0 0 0 3px rgba(0, 217, 165, 0.4);
}
.square.valid-target::after {
    content: "";
    position: absolute;
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
}
.square.valid-target.light::after {
    background: rgba(0, 0, 0, 0.2);
}
.square.valid-target.dark::after {
    background: rgba(255, 255, 255, 0.3);
}
.square.valid-target.capture::after {
    width: 100%;
    height: 100%;
    border-radius: 0;
    background: transparent;
    box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.2);
}

/* Piece rendering via CSS classes */
.piece {
    width: 92%;
    height: 92%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* CBurnett piece set (Lichess standard, served locally) */
.piece-white-king {
    background-image: url("../pieces/cburnett/wK.svg");
}
.piece-white-queen {
    background-image: url("../pieces/cburnett/wQ.svg");
}
.piece-white-rook {
    background-image: url("../pieces/cburnett/wR.svg");
}
.piece-white-bishop {
    background-image: url("../pieces/cburnett/wB.svg");
}
.piece-white-knight {
    background-image: url("../pieces/cburnett/wN.svg");
}
.piece-white-pawn {
    background-image: url("../pieces/cburnett/wP.svg");
}

.piece-black-king {
    background-image: url("../pieces/cburnett/bK.svg");
}
.piece-black-queen {
    background-image: url("../pieces/cburnett/bQ.svg");
}
.piece-black-rook {
    background-image: url("../pieces/cburnett/bR.svg");
}
.piece-black-bishop {
    background-image: url("../pieces/cburnett/bB.svg");
}
.piece-black-knight {
    background-image: url("../pieces/cburnett/bN.svg");
}
.piece-black-pawn {
    background-image: url("../pieces/cburnett/bP.svg");
}

/* Board Controls */
.board-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.btn-icon {
    background: var(--bg-light);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}
.btn-icon:hover {
    background: var(--bg-lighter);
}
.move-display {
    flex: 1;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-dim);
}

/* Engine Toggle & Difficulty */
.engine-toggle {
    display: flex;
    justify-content: center;
    padding: 4px 0;
}
.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
}
.toggle-label input {
    display: none;
}
.toggle-slider {
    width: 40px;
    height: 22px;
    background: var(--bg-lighter);
    border-radius: 11px;
    position: relative;
    transition: background 0.3s;
    border: 1px solid var(--border);
}
.toggle-slider::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    background: var(--text);
    border-radius: 50%;
    top: 1px;
    left: 1px;
    transition: transform 0.3s;
}
.toggle-label input:checked + .toggle-slider {
    background: var(--accent-green);
}
.toggle-label input:checked + .toggle-slider::after {
    transform: translateX(18px);
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}
.difficulty-selector label {
    font-size: 0.85rem;
    color: var(--text-dim);
}
.difficulty-selector select {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--text);
    font-size: 0.85rem;
}

/* Eval Bar */
.eval-bar {
    position: relative;
    height: 24px;
    background: var(--bg-lighter);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
}
.eval-white {
    background: #e8e8f0;
    transition: width 0.5s ease;
}
.eval-black {
    flex: 1;
    background: #1a1a1a;
}
.eval-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-green);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* FEN Display */
.fen-display {
    font-family: "SF Mono", monospace;
    font-size: 0.75rem;
    color: var(--text-dark);
    background: var(--bg-light);
    padding: 8px 12px;
    border-radius: 6px;
    word-break: break-all;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}
.fen-display:hover {
    border-color: var(--accent);
}

/* Captured Pieces — horizontal rows above/below the board */
.captured-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
    min-height: 20px;
    /* indent to align with the board (coord-ranks 20px + gap 4px) */
    padding-left: 24px;
}
.captured-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    align-items: center;
}
.captured-piece {
    width: 16px;
    height: 16px;
    background-size: contain;
}
.cap-piece {
    display: inline-block;
    width: 18px;
    height: 18px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.captured-score {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-green);
    white-space: nowrap;
}
