/*
 * biscuits-chess.css
 *
 * Purpose: All styling related to chess board rendering, game viewers,
 *          score sheets, and chess-specific UI components.
 *
 * Scope:
 * - Dynamic game viewers (chess25-*.php files)
 * - Chess diagrams and square colours
 * - Score sheet / move list styling
 * - Chess game navigation controls
 *
 * Note: This file lives in /css/core/ so it is auto-loaded.
 * Only chess-related rules should be added here.
 * Different board themes should use explicit class names
 * (e.g. .chess-board-green) to avoid confusion with other themes.
 */

/* ============================================
   CHESS BOARD SQUARE COLOURS + SIZING
   ============================================ */

/* Green theme squares (used in dynamic game viewer) */
.chess-white-square {
    background-color: #e8f5e9;
}

.chess-black-square {
    background-color: #6a9063;
}

/* ============================================
   FORCE SQUARE BOARD + EQUAL FILES
   (fixes empty-column collapse after e.g. 18…exd5)
   ============================================ */

/* Table itself – fixed layout so empty files keep their share of width */
table.chess-magazine {
    table-layout: fixed;
    width: 480px;          /* 8 × 60 px – easy to change later */
    border-collapse: collapse;
    border-spacing: 0;
}

/* Every square cell – force equal width + square shape */
table.chess-magazine td.chess-white-square,
table.chess-magazine td.chess-black-square {
    width: 12.5%;          /* exactly 1/8 of the table */
    height: 60px;          /* matches the intended square size */
    min-width: 60px;
    min-height: 60px;
    padding: 0;
    margin: 0;
    vertical-align: middle;
    aspect-ratio: 1 / 1;   /* modern browsers – perfect square */
    box-sizing: border-box;
}

/* Images (including the hidden blank.gif) now fill the forced square */
table.chess-magazine td.chess-white-square img,
table.chess-magazine td.chess-black-square img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    display: block;
}

/* Make images fill the square, but handle blank.gif gracefully */
td.chess-white-square img,
td.chess-black-square img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Hide truly empty images (no src or blank.gif) so they don't show broken placeholders */
td.chess-white-square img[src=""],
td.chess-black-square img[src=""],
td.chess-white-square img[src*="blank.gif"],
td.chess-black-square img[src*="blank.gif"] {
    visibility: hidden;   /* or opacity: 0; */
}

/* Optional hover effect on squares */
.chess-square:hover {
    filter: brightness(1.1);
}

/* ============================================
   MAGAZINE-STYLE GAME LAYOUT
   ============================================ */

.chess-game.magazine-style {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 15px;
}

.game-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.chess-game.magazine-style .game-diagram-top {
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
}

/* Scrollable score sheet area */
.game-score-scroll {
    max-height: 520px;
    overflow-y: auto;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 10px;
    background-color: #fafafa;
    margin-bottom: 20px;
}

.game-score-scroll::-webkit-scrollbar {
    width: 8px;
}
.game-score-scroll::-webkit-scrollbar-thumb {
    background-color: #aaa;
    border-radius: 4px;
}
.game-score-scroll::-webkit-scrollbar-thumb:hover {
    background-color: #888;
}

/* SCORE SHEET moves etc., */
/* Make moves look clickable */
.game-score.magazine .chess-move {
    cursor: pointer;
}

.game-score.magazine .move-list {
    font-size: 18px;
    line-height: 1.5;
}

.game-score.magazine .move-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 8px 4px;
    border-bottom: 1px solid #e8e8e8;
    align-items: flex-start;
}

.game-score.magazine .move-num {
    width: 32px;
    font-weight: 600;
    color: #333;
    flex-shrink: 0;
}

.game-score.magazine .move-side {
    flex: 1;
    min-width: 140px;
    padding: 2px 6px;
}

/* White side column */
.game-score.magazine .move-side.move-white {
    color: #1e3a5f;
}

/* Black side column */
.game-score.magazine .move-side.move-black {
    color: #1f2937;
}

.game-score.magazine .move-side .chess-move {
    font-weight: 600;
    color: inherit;
    
}

/* Comments / Annotations */
.game-score.magazine .chess-annotation {
    font-style: italic;
    font-size: 1.05em;
    color: #006400;
    margin-top: 4px;
    line-height: 1.45;
    padding-left: 4px;
}

/* ============================================
   CHESS NAVIGATION BUTTONS
   ============================================ */

.chess-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
    align-items: center;
}

.chess-nav .nav-btn {
    font-size: 18px;
    line-height: 1;
    padding: 8px 12px;
    min-width: 42px;
    min-height: 38px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: #f8f9fa;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chess-nav .nav-btn:hover {
    background-color: #e9ecef;
    border-color: #999;
}

.chess-nav .nav-btn:active {
    background-color: #dee2e6;
    transform: translateY(1px);
}
