/* ==========================================
   SalmasFlix — Games · Chess
   Extracted from games.css in Phase 7.9 (2026-04-23).
   Originally at lines 4476-5097 of the monolith.

   Chess board + pieces + clocks + captured row + time picker +
   side picker + promotion dialog.

   Kept in shared games.css (NOT extracted here):
   - `.game-clock*` — also used by TTT / CF turn indicators
   - `.game-board-confirm-*` — also used by H&S hide-confirm overlay
   - `@keyframes clockPulse` — also used by H&S low-time flash
   ========================================== */

@layer features {


.chess-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(2px, 0.5dvh, 6px);
    padding: 52px clamp(2px, 0.3dvh, 6px) clamp(2px, 0.3dvh, 6px);
    height: 100%;
    overflow: hidden;
}

.chess-board-outer {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    flex-shrink: 1;
    min-height: 0;
}

.chess-board-wrapper {
    position: relative;
    width: min(88vw, 48dvh, 420px);
    max-width: min(88vw, 48dvh, 420px);
    aspect-ratio: 1;
    flex-shrink: 1;
}

.chess-captured {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    min-height: 1.2em;
    padding: 0 2px;
}

.chess-captured-side {
    flex-direction: column;
    width: 2.6em;
    min-width: 2.6em;
    max-height: min(88vw, 48dvh, 420px);
    overflow: hidden;
    align-items: center;
    justify-content: flex-start;
}

.chess-captured-piece {
    font-size: clamp(1.3rem, 4vw, 2rem);
    line-height: 1;
    filter: drop-shadow(0 0 3px rgba(var(--primary-rgb),0.5));
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
    border: 2px solid var(--accent-primary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(var(--secondary-alt-rgb),0.2);
}

.chess-sq {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background 0.15s;
    aspect-ratio: 1;
}

.chess-sq-light { background: #e8dcc8; }
.chess-sq-dark { background: #8b6f47; }

/* Phase 7.7: !important stripped — these highlight classes come after
   .chess-sq-light/-dark in source order at the same specificity, so
   they win naturally. */
.chess-sq-selected { background: rgba(var(--secondary-alt-rgb),0.5); }
.chess-sq-last-move { background: rgba(var(--primary-rgb),0.35); }
.chess-sq-check { background: rgba(231, 76, 60, 0.5); }

.chess-sq-legal::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: rgba(var(--secondary-alt-rgb),0.4);
    pointer-events: none;
}

.chess-sq-capture::after {
    width: 85%;
    height: 85%;
    background: transparent;
    border: 4px solid rgba(var(--secondary-alt-rgb),0.5);
    border-radius: 50%;
}

.chess-sq:hover:not(.chess-sq-selected) {
    filter: brightness(1.1);
}

.chess-piece {
    font-size: clamp(1.5rem, 6vw, 3rem);
    line-height: 1;
    user-select: none;
    pointer-events: none;
}

.chess-piece-white {
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    -webkit-text-stroke: 0.5px rgba(0,0,0,0.3);
}

.chess-piece-black {
    color: #1a1a2e;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    -webkit-text-stroke: 0.5px rgba(0,0,0,0.15);
}

.chess-label {
    position: absolute;
    font-size: 0.55rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0.7;
}

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

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

.chess-sq-light .chess-label { color: #8b6f47; }
.chess-sq-dark .chess-label { color: #e8dcc8; }

.chess-increment-flash {
    position: absolute;
    right: -2px;
    top: -8px;
    font-size: 0.65rem;
    font-weight: 800;
    color: #2ecc71;
    text-shadow: 0 0 6px rgba(46, 204, 113, 0.6);
    animation: incrementPop 1.2s ease-out forwards;
    pointer-events: none;
    z-index: 5;
}

@keyframes incrementPop {
    0% { opacity: 0; transform: translateY(4px) scale(0.7); }
    20% { opacity: 1; transform: translateY(-2px) scale(1.1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-10px) scale(0.9); }
}

/* Chess: both clocks always visible (live countdown, not turn-based hide/show).
   Phase 7.7: !important stripped — chess scoreboard's ancestor class is
   .chess-scores-live; the sibling TTT rule uses .ttt-scores-vertical and
   never overlaps. No competing rule to beat. */
.chess-scores-live .score-card .game-clock {
    display: inline-block;
}

/* Chess: white/black card glow to indicate piece color */
.chess-card-white {
    border-color: rgba(255, 255, 255, 0.6) !important;
    box-shadow: 0 0 14px rgba(255, 255, 255, 0.25), 0 0 4px rgba(255, 255, 255, 0.4), inset 0 0 10px rgba(255, 255, 255, 0.06);
    transition: box-shadow 0.3s, border-color 0.3s, opacity 0.3s;
}

.chess-card-black {
    border-color: rgba(30, 30, 30, 0.9) !important;
    box-shadow: 0 0 16px rgba(0, 0, 0, 0.7), 0 0 6px rgba(0, 0, 0, 0.9), inset 0 0 12px rgba(0, 0, 0, 0.4);
    transition: box-shadow 0.3s, border-color 0.3s, opacity 0.3s;
}

/* Dim glow when it's NOT your turn (card is not active).
   Phase 7.7: !important stripped — the :not(.score-card-active) guard
   ensures this rule NEVER overlaps with .score-card.active, so there's
   no higher-specificity sibling to beat. */
.chess-card-white:not(.score-card-active) {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.08), inset 0 0 4px rgba(255, 255, 255, 0.02);
}

.chess-card-black:not(.score-card-active) {
    border-color: rgba(20, 20, 20, 0.5);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.4), inset 0 0 6px rgba(0, 0, 0, 0.2);
}

/* Chess resign button — gameplay style */
.chess-resign-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    font-size: clamp(0.7rem, 1.3dvh, 0.82rem);
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: rgba(255, 255, 255, 0.65);
    background: rgba(231, 76, 60, 0.15);
    border: 1.5px solid rgba(231, 76, 60, 0.35);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, filter 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
    margin-bottom: 4px;
}

.chess-resign-btn:hover {
    background: rgba(231, 76, 60, 0.3);
    border-color: rgba(231, 76, 60, 0.6);
    color: #ff6b6b;
}

.chess-game-btns {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 4px;
}

.chess-draw-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    font-size: clamp(0.7rem, 1.3dvh, 0.82rem);
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: rgba(255, 255, 255, 0.65);
    background: rgba(var(--secondary-rgb),0.15);
    border: 1.5px solid rgba(var(--secondary-rgb),0.35);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, filter 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.chess-draw-btn:hover {
    background: rgba(var(--secondary-rgb),0.3);
    border-color: rgba(var(--secondary-rgb),0.6);
    color: var(--secondary-soft);
}

.chess-draw-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Time control picker overlay — hovers over the board */
.chess-time-picker-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 8, 20, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 8px;
    z-index: 10;
}

.chess-time-picker {
    text-align: center;
    padding: 1.5rem 1rem;
}

.chess-picker-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.5rem;
}

.chess-waiting-sub {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.chess-time-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.chess-time-btn {
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    border: 2px solid rgba(var(--secondary-alt-rgb),0.3);
    background: rgba(var(--secondary-alt-rgb),0.1);
    color: var(--secondary-soft);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, background-color 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s, filter 0.2s, opacity 0.2s, transform 0.2s;
}

.chess-time-btn:hover {
    background: rgba(var(--secondary-alt-rgb),0.3);
    border-color: var(--accent-primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.chess-time-unit {
    font-size: 0.7em;
    opacity: 0.6;
    margin-left: 1px;
}

/* Phase 7.7: !important stripped — source order beats earlier
   .chess-time-btn at same specificity. */
.chess-custom-toggle {
    font-size: 1.2rem;
    padding: 0.75rem 1rem;
}

.chess-custom-time {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 0.75rem;
}

.chess-custom-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 600;
}

.chess-custom-plus {
    font-size: 1rem;
    color: rgba(var(--secondary-alt-rgb),0.6);
    font-weight: 700;
}

.chess-time-input {
    width: 52px;
    padding: 0.5rem;
    border-radius: 10px;
    border: 1.5px solid rgba(var(--secondary-alt-rgb),0.3);
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
    text-align: center;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* Phase 7.7: !important stripped — same reasoning as chess-custom-toggle. */
.chess-custom-go {
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
}

/* Chess side picker */
.chess-side-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.chess-side-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0.8rem 1.2rem;
    border-radius: 14px;
    border: 2px solid rgba(var(--secondary-alt-rgb),0.3);
    background: rgba(var(--secondary-alt-rgb),0.08);
    cursor: pointer;
    transition: background 0.2s, background-color 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s, filter 0.2s, opacity 0.2s, transform 0.2s;
}

.chess-side-btn:hover {
    background: rgba(var(--secondary-alt-rgb),0.25);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.chess-side-label {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--secondary-soft);
}

.chess-side-random-pieces {
    display: flex;
    gap: 2px;
}

.chess-side-random-pieces svg {
    width: 30px;
    height: 47px;
}

/* Promotion dialog */
.chess-promotion-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    border-radius: 12px;
}

.chess-promotion-dialog {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    border: 2px solid var(--accent-primary);
}

.chess-promotion-dialog p {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 1rem;
}

.chess-promotion-options {
    display: flex;
    gap: 0.5rem;
}

.chess-promotion-btn {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    border: 2px solid rgba(var(--secondary-alt-rgb),0.3);
    background: rgba(var(--secondary-alt-rgb),0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, background-color 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s, filter 0.2s, opacity 0.2s, transform 0.2s;
}

.chess-promotion-btn:hover {
    background: rgba(var(--secondary-alt-rgb),0.3);
    border-color: var(--accent-primary);
}

.chess-promotion-btn .chess-piece {
    font-size: 2rem;
}

.chess-area {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

.chess-area > * {
    pointer-events: auto;
}

/* breakpoint snap 600px -> 768px (Phase 7.6 ladder) */
@media (max-width: 768px) {
    .chess-container {
        overflow: visible;
        gap: clamp(4px, 1dvh, 10px);
    }
    .chess-board-outer {
        margin-bottom: clamp(4px, 1dvh, 8px);
    }
    .chess-board-wrapper {
        width: min(80vw, 36dvh, 320px);
        max-width: min(80vw, 36dvh, 320px);
        flex-shrink: 0;
    }
    .chess-captured-side {
        width: 2.2em;
        min-width: 2.2em;
        max-height: min(80vw, 36dvh, 320px);
    }
    .chess-captured-piece { font-size: clamp(1.1rem, 3.5vw, 1.5rem); }
    .chess-piece { font-size: clamp(0.9rem, 7vw, 1.8rem); }
    .chess-promotion-btn { width: 48px; height: 48px; }
    .chess-promotion-btn .chess-piece { font-size: 1.5rem; }
    .chess-time-picker { padding: 0.75rem 0.5rem; }
    .chess-picker-title { font-size: 1.1rem; margin-bottom: 0.75rem; }
    .chess-time-btn { padding: 0.5rem 0.75rem; font-size: 0.85rem; }
    .chess-side-options { gap: 0.4rem; }
    .chess-side-btn { padding: 0.4rem 0.6rem; gap: 3px; border-radius: 10px; }
    .chess-side-btn svg { width: 24px; height: 38px; }
    .chess-side-label { font-size: 0.65rem; }
    .chess-side-random-pieces svg { width: 20px; height: 32px; }
}


/* Chess resign/draw buttons inside the VS area.
   Moved from games.css in Wave 6 (was a stray block after
   .game-action-btn, lines 745-765 of the monolith).
   The #e74c3c red is the red error/danger color — not a theme accent —
   so it stays literal. */
.chess-vs-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: clamp(0.6rem, 1.2dvh, 0.72rem);
    font-family: inherit;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid rgba(var(--secondary-rgb),0.3);
    background: rgba(var(--secondary-rgb),0.12);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: background 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, filter 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}
.chess-vs-btn svg { width: 11px; height: 11px; flex-shrink: 0; }
.chess-resign-btn:hover { color: #e74c3c; border-color: rgba(231, 76, 60, 0.5); background: rgba(231, 76, 60, 0.12); }
.chess-draw-btn:hover { color: var(--primary); border-color: rgba(var(--primary-rgb),0.5); background: rgba(var(--primary-rgb),0.12); }
.chess-vs-btn:disabled { opacity: 0.4; cursor: default; }


} /* end @layer features */
