/* ==========================================================================
   THEME ARCHITECTURE (CSS VARIABLE REGISTRY)
   ========================================================================== */
:root {
    /* --- THEME 1: SLATE LIGHT (DEFAULT) --- */
    --bg-body: #fce5cd;
    --bg-container: #fce5cd;
    --bg-surface: #fce5cd;
    --bg-card: #fce5cd;
    --bg-card-hover: #e9d5bf;
    --bg-card-active: #e9d5bf;
    --border-color: #000000;
    --border-card: #e9d5bf;
    --text-main: #18181b;
    --text-muted: #71717a;
    --accent-color: #dac2a7;
    --accent-orange: #d97706;
    --code-color: #166534;
    --inline-code-color: #9a3412;
    --btn-bg: #fce5cd;
    --btn-disabled: #fce5cd;

    /* Light mode board palette */
    --board-light: #f0d9b5;
    --board-dark: #b58863;
}

/* ==========================================================================
   BOARD STYLES (lots is done in the cm-chessboard css files)
   ========================================================================== */

/* Direct Injection hooks into the cm-chessboard graphic tree elements */
.chessboard .board .light {
    fill: var(--board-light) !important;
    transition: fill 0.2s;
}

.chessboard .board .dark {
    fill: var(--board-dark) !important;
    transition: fill 0.2s;
}

/* Latest move */
.cm-chessboard .markers .marker.marker-square {
    fill: green;
    opacity: 0.3;
}

/* Right-click: blue */
.cm-chessboard .markers .marker.marker-circle-success {
    stroke: blue;
    opacity: 0.5;
}

.cm-chessboard .arrow-success .arrow-head {
    fill: blue;
}

.cm-chessboard .arrow-success .arrow-line {
    stroke: blue;
}

/* Alt + right-click: green */
.cm-chessboard .markers .marker.marker-circle-info {
    stroke: green;
}

.cm-chessboard .arrow-info .arrow-head {
    fill: green;
}

.cm-chessboard .arrow-info .arrow-line {
    stroke: green;
}

/* Keep arrows slightly thinner */
.cm-chessboard .arrow-line {
    stroke-width: 8px;
}

/* ==========================================================================
   LAYOUT STYLESHEET CORE
   ========================================================================== */
*,
*:before,
*:after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-body);
    color: var(--text-main);
    font-family: sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    transition: background 0.2s, color 0.2s;
}

.app-container {
    display: flex;
    gap: 30px;
    background: var(--bg-container);
    padding: 20px;
    border-radius: 8px;
    max-width: 1150px;
    width: 100%;
    transition: background 0.2s;
}

/* --- SIDEBAR GAME LIST --- */
.sidebar {
    display: flex;
    flex-direction: column;
    width: 280px;
    border-right: 0px solid var(--border-color);
    padding-right: 20px;
}

.filter-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    padding: 8px;
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.search-input:focus {
    border-color: var(--text-muted);
}

.game-scroll-container {
    height: 310px;
    overflow-y: auto;
    padding-right: 5px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.game-scroll-container::-webkit-scrollbar {
    width: 4px;
}

.game-scroll-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.game-card {
    padding: 8px 10px;
    background: var(--bg-card);
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.game-card:last-child {
    margin-bottom: 0;
}

.card-title {
    font-size: 13px;
    line-height: 16px;
    font-weight: bold;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    line-height: 14px;
    color: var(--text-muted);
}

.game-card:hover {
    background: var(--bg-card-hover);
}

.game-card.active-game {
    background: var(--bg-card-active);
    /* border-left-color: var(--accent-color); */
}

.card-title {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}

/* --- CENTER COLUMN (BOARD + README) --- */
.center-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 500px;
}

.board-wrapper {
    width: 500px;
    height: 500px;
}

/* --- CONTROL DASHBOARD --- */

.selected-game-card {
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 10px;
}

.selected-game-title {
    color: var(--text-main);
    font-size: 13px;
    font-weight: bold;
    line-height: 16px;
    margin-bottom: 4px;
}

.selected-game-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 14px;
    letter-spacing: 0.5px;
}

.controls {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    width: 250px;
}

.controls h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-main);
}

.move-list {
    background: var(--bg-surface);
    padding: 15px;
    border-radius: 4px;
    height: 365px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 14px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    transition: background 0.2s;
}

/* Firefox */
@supports (-moz-appearance: none) {
    .move-list {
        scrollbar-color: #333 transparent;
        scrollbar-width: auto;
    }
}

/* Chrome / Brave */
.move-list::-webkit-scrollbar {
    width: 4px;
}

.move-list::-webkit-scrollbar-track {
    background: transparent;
}

.move-list::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 4px;
}

.move-list::-webkit-scrollbar-thumb:hover {
    background: #000;
}

.move-list::-webkit-scrollbar-thumb:active {
    background: #000;
}

.move-row {
    display: flex;
    padding: 4px 0;
    border-bottom: 0px solid var(--border-color);
}

.move-number {
    width: 40px;
    padding: 2px 0;
    color: var(--text-muted);
}

.move-ply {
    flex: 1;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    color: var(--text-main);
}

.move-ply:hover {
    background: var(--bg-card-hover);
}

.active-move {
    background: var(--bg-card-active);
    font-weight: bold;
    color: var(--text-main);
    outline: 1px solid var(--border-card);
}

.btn-group {
    display: flex;
    gap: 8px;
}

#copy-pgn-btn {
    flex: none;
    align-self: center;
    width: 82px;
    margin-top: 10px;
    padding: 7px 12px;
    font-size: 11px;
}

button {
    flex: 1;
    padding: 12px 4px;
    background: var(--btn-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    text-align: center;
    /* transition: opacity 0.15s, background 0.15s; */
}

button:hover:not(:disabled) {
    /* opacity: 0.9; */
    background: var(--bg-card-hover);
}

button:disabled {
    background: var(--btn-disabled);
    color: var(--text-muted);
    cursor: default;
    border-color: var(--text-muted);
}
