/* =============================================================================
   WARCABY / CHECKERS — game-specific styles
   Loaded together with games.css via $extraCss. Uses site design tokens.
   Mobile-first; board caps at 520px on wide screens.
   ============================================================================= */

/* ---------------- Captured counters ---------------- */

.wc-captures {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin: 0.5rem 0 0.75rem;
    font-size: 0.9rem;
    color: var(--color-gray-600);
}

/* ---------------- Board ---------------- */

.wc-board-wrap {
    /* Cap to the VIEWPORT, not just the parent: on phones the page can be a
       touch wider than the screen, and a parent-relative 100% board then
       overflows off-screen (reported on iPhone). 1.5rem ≈ page side padding. */
    max-width: min(520px, calc(100vw - 1.5rem));
    margin: 0 auto;
}

.wc-board {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: repeat(8, minmax(0, 1fr));
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 4px solid var(--color-gray-800);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.wc-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    border: none;
    /* NO percentage padding here: WebKit (iOS Safari/Chrome) resolves %-padding
       of grid items against the BOARD width, inflating every cell by ~2×29px —
       the grid grew past the wrapper and overflow:hidden clipped the 8th row
       and column on iPhones. The piece is inset via its own % width instead. */
    padding: 0;
    min-width: 0;
    min-height: 0;
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    cursor: default;
    -webkit-tap-highlight-color: transparent;
}

.wc-cell--light {
    background: #f0d9b5;
}

.wc-cell--dark {
    background: #946f51;
    cursor: pointer;
}

/* ---------------- Highlights ---------------- */

.wc-cell--dark.is-selected {
    background: #5b7f3f;
    box-shadow: inset 0 0 0 3px #d6e8a0;
}

.wc-cell--dark.is-target {
    background: #6f8a4a;
}

.wc-cell--dark.is-target::after {
    content: '';
    width: 32%;
    height: 32%;
    border-radius: 50%;
    background: rgba(230, 240, 200, 0.85);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* Capture landing squares get a ring instead of a dot — reads as "jump here". */
.wc-cell--dark.is-target-capture {
    background: #a8563e;
}

.wc-cell--dark.is-target-capture::after {
    width: 58%;
    height: 58%;
    background: transparent;
    border: 4px solid rgba(255, 226, 130, 0.95);
    box-shadow: none;
}

/* Mandatory-capture indicator: pieces that CAN capture (the only ones the
   player may move) pulse gently. */
.wc-cell--dark.is-must {
    box-shadow: inset 0 0 0 3px #ffd35c;
    animation: wc-must-pulse 1.1s ease-in-out infinite;
}

@keyframes wc-must-pulse {
    0%, 100% { box-shadow: inset 0 0 0 3px rgba(255, 211, 92, 0.95); }
    50%      { box-shadow: inset 0 0 0 5px rgba(255, 211, 92, 0.55); }
}

/* ---------------- Pieces ---------------- */

.wc-piece {
    display: flex;
    align-items: center;
    justify-content: center;
    /* 88% ≈ the old look (100% inside 6% padding), without WebKit's %-padding bug. */
    width: 88%;
    height: 88%;
    border-radius: 50%;
    font-size: clamp(1rem, 4.4vw, 1.7rem);
    line-height: 1;
    pointer-events: none;
}

.wc-piece--white {
    background: radial-gradient(circle at 32% 30%, #ffffff 0%, #e8e2d4 45%, #b9b2a0 100%);
    border: 2px solid #8f887a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35), inset 0 -3px 5px rgba(0, 0, 0, 0.18);
    color: #6b5518;
}

.wc-piece--black {
    background: radial-gradient(circle at 32% 30%, #6a6a72 0%, #35353c 45%, #17171c 100%);
    border: 2px solid #000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45), inset 0 -3px 5px rgba(0, 0, 0, 0.4);
    color: #ffd35c;
}

/* Damka: crown glyph + golden ring. */
.wc-piece--king {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 0 0 3px #e3b53a,
                inset 0 -3px 5px rgba(0, 0, 0, 0.25);
    font-weight: 700;
}

/* Jumped-but-not-yet-removed pieces during a multi-capture sequence. */
.wc-piece--ghost {
    opacity: 0.4;
    filter: grayscale(0.6);
}

/* ---------------- Stats modal extras ---------------- */

.wc-best-title {
    margin: 0.75rem 0 0.25rem;
    font-weight: 600;
    color: var(--color-gray-700);
}

.wc-best-list {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--color-gray-700);
}

/* ---------------- Small screens ---------------- */

@media (max-width: 420px) {
    .wc-piece {
        width: 92%;
        height: 92%;
    }

    .wc-captures {
        font-size: 0.82rem;
    }
}
