/*
 * Game Review — Stockfish review in the browser.
 * Built on the shared Pawn Patrol tokens (--pp-*) so it matches the hub.
 */

:root {
    --gr-best: #1a7f37;
    --gr-excellent: #2da44e;
    --gr-good: #636363;
    --gr-inaccuracy: #b7791f;
    --gr-mistake: #d97706;
    --gr-blunder: #c94f5c;
    --gr-square-light: #eef0e9;
    --gr-square-dark: #8ba283;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--pp-fog);
    color: var(--pp-midnight);
    font-family: var(--pp-font-body);
    letter-spacing: -0.01em;
}

.gr {
    width: min(1200px, calc(100% - 40px));
    margin: 0 auto;
    padding: 28px 0 80px;
}

/* ── Hero ─────────────────────────────────────────────────────────────── */

.gr__hero {
    margin-bottom: 28px;
}

.gr__pill {
    display: inline-block;
    border-radius: 100px;
    padding: 6px 12px;
    background: var(--pp-snow);
    color: var(--pp-graphite);
    font-size: 12px;
    font-weight: 500;
}

.gr h1 {
    margin: 14px 0 12px;
    color: var(--pp-carbon);
    font-family: var(--pp-font-heading);
    font-size: clamp(38px, 6vw, 70px);
    font-weight: 300;
    line-height: 1.06;
    letter-spacing: -0.01em;
}

.gr__lede {
    max-width: 660px;
    margin: 0;
    color: var(--pp-stone);
    font-size: 17px;
    line-height: 1.55;
}

/* While a game is on screen the hero shrinks to a page title. */
.gr--reviewing .gr__hero {
    margin-bottom: 10px;
}

.gr--reviewing .gr__pill,
.gr--reviewing .gr__lede {
    display: none;
}

.gr--reviewing h1 {
    margin: 0 0 8px;
    font-size: 32px;
}

/* ── Shared bits ──────────────────────────────────────────────────────── */

.card {
    border-radius: 24px;
    background: var(--pp-snow);
    box-shadow: var(--pp-shadow);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    border: 0;
    border-radius: 28px;
    padding: 12px 22px;
    background: var(--pp-accent);
    color: var(--pp-carbon);
    box-shadow: rgba(0, 0, 0, 0.04) 0 1px 2px, rgba(0, 0, 0, 0.02) 0 2px 4px;
    cursor: pointer;
    font-family: var(--pp-font-body);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.02em;
    transition: transform 160ms ease, background-color 160ms ease;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:focus-visible,
.select:focus-visible,
.navbtn:focus-visible,
.mv:focus-visible {
    outline: 2px solid var(--pp-midnight);
    outline-offset: 3px;
}

.btn--ghost {
    background: var(--pp-fog);
    color: var(--pp-midnight);
    box-shadow: none;
}

.btn--small {
    min-height: 36px;
    padding: 8px 16px;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.45;
    cursor: default;
    transform: none;
}

/* ── Setup ────────────────────────────────────────────────────────────── */

.setup {
    padding: 20px;
}

.setup__label {
    display: block;
    margin-bottom: 8px;
    color: var(--pp-graphite);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.setup textarea {
    display: block;
    width: 100%;
    min-height: 150px;
    resize: vertical;
    border: 1px solid rgba(24, 24, 37, 0.14);
    border-radius: 0;
    padding: 14px 16px;
    background: #fbfbfa;
    color: var(--pp-midnight);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
}

.setup textarea:focus {
    outline: 2px solid var(--pp-midnight);
    outline-offset: 1px;
}

.setup__hint {
    margin: 8px 0 0;
    color: var(--pp-pebble);
    font-size: 12px;
}

.setup__hint code {
    font-size: 12px;
}

.setup__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.setup__error {
    margin: 14px 0 0;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(201, 79, 92, 0.1);
    color: #a13a47;
    font-size: 13px;
    line-height: 1.45;
}

.filebtn {
    cursor: pointer;
}

.selectwrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selectwrap__label {
    color: var(--pp-stone);
    font-size: 13px;
}

.select {
    min-height: 44px;
    border: 1px solid rgba(24, 24, 37, 0.14);
    border-radius: 0;
    padding: 10px 12px;
    background: var(--pp-snow);
    color: var(--pp-midnight);
    font-family: var(--pp-font-body);
    font-size: 13px;
}

/* ── Review layout ────────────────────────────────────────────────────── */

.reviewer__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 4px 0 16px;
}

.reviewer__headline {
    color: var(--pp-stone);
    font-size: 14px;
}

.reviewer__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 24px;
    align-items: start;
}

.boardcol {
    width: 100%;
    max-width: 680px;
    min-width: 0;
    margin: 0 auto;
}

.boardhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.boardhead__side {
    color: var(--pp-stone);
    font-size: 14px;
}

.evalchip {
    border-radius: 100px;
    padding: 6px 12px;
    background: var(--pp-snow);
    box-shadow: var(--pp-shadow);
    color: var(--pp-midnight);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.boardwrap {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.evalbar {
    position: relative;
    flex: 0 0 14px;
    overflow: hidden;
    border-radius: 100px;
    background: var(--pp-slate);
}

.evalbar__fill {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 50%;
    background: var(--pp-snow);
    transition: height 220ms ease;
}

.board {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    min-width: 0;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: var(--pp-shadow);
    user-select: none;
}

.sq {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

.sq--last::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(63, 185, 80, 0.38);
}

.sq img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    padding: 5%;
    object-fit: contain;
    pointer-events: none;
}

.sq__coord {
    position: absolute;
    z-index: 2;
    color: rgba(24, 24, 37, 0.5);
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
    pointer-events: none;
}

.sq--dark .sq__coord {
    color: rgba(255, 255, 255, 0.72);
}

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

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

.boardnav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.navbtn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 100px;
    background: var(--pp-snow);
    box-shadow: var(--pp-shadow);
    color: var(--pp-midnight);
    font-size: 14px;
    cursor: pointer;
}

.boardnav__ply {
    margin-left: 4px;
    color: var(--pp-stone);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.boardnav .btn {
    margin-left: auto;
}

.graphcard {
    position: relative;
    margin-top: 16px;
    padding: 10px 10px 22px;
}

#graph {
    display: block;
    width: 100%;
    height: 150px;
    cursor: pointer;
}

.graphcard__hint {
    position: absolute;
    bottom: 6px;
    left: 12px;
    color: var(--pp-pebble);
    font-size: 11px;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */

.side {
    padding: 16px;
}

.status__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.status__text {
    color: var(--pp-graphite);
    font-size: 13px;
    font-weight: 500;
}

.bar {
    height: 4px;
    overflow: hidden;
    border-radius: 100px;
    background: var(--pp-fog);
}

.bar i {
    display: block;
    width: 0;
    height: 100%;
    background: var(--pp-accent);
    transition: width 180ms ease;
}

.players {
    display: grid;
    gap: 4px;
    margin: 16px 0 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--pp-line);
}

.pl {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 6px 4px;
}

.pl__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--pp-midnight);
}

.pl__dot--w {
    border: 1px solid rgba(24, 24, 37, 0.35);
    background: var(--pp-snow);
}

.pl__name {
    overflow: hidden;
    font-size: 14px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pl__acc {
    color: var(--pp-midnight);
    font-size: 18px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.pl__counts {
    grid-column: 2 / 4;
    color: var(--pp-pebble);
    font-size: 11.5px;
    line-height: 1.5;
}

.pl__counts b {
    font-weight: 500;
}

.pl__counts .c-blunder {
    color: var(--gr-blunder);
}

.pl__counts .c-mistake {
    color: var(--gr-mistake);
}

.pl__counts .c-inaccuracy {
    color: var(--gr-inaccuracy);
}

.moves {
    position: relative;
    max-height: 470px;
    overflow-y: auto;
    margin: 0 -4px;
    padding: 2px 4px;
    scrollbar-width: thin;
}

.moverow {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr);
    gap: 2px;
    align-items: center;
}

.movenum {
    padding-left: 6px;
    color: var(--pp-pebble);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.mv {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    border: 0;
    border-radius: 8px;
    padding: 6px 7px;
    background: transparent;
    color: var(--pp-midnight);
    font-family: var(--pp-font-body);
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}

.mv:hover {
    background: var(--pp-fog);
}

.mv--current {
    background: rgba(63, 185, 80, 0.16);
}

.mv__san {
    overflow: hidden;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mv__eval {
    margin-left: auto;
    color: var(--pp-pebble);
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
}

.mv__mark {
    flex: none;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.mv__mark--best,
.mv__mark--excellent {
    color: var(--gr-excellent);
}

.mv__mark--inaccuracy {
    color: var(--gr-inaccuracy);
}

.mv__mark--mistake {
    color: var(--gr-mistake);
}

.mv__mark--blunder {
    color: var(--gr-blunder);
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media screen and (max-width: 980px) {
    .reviewer__grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .moves {
        max-height: 340px;
    }
}

@media screen and (max-width: 700px) {
    .gr {
        width: calc(100% - 24px);
        padding-top: 16px;
    }

    .reviewer__grid {
        gap: 16px;
    }

    .setup {
        padding: 16px;
    }

    .evalbar {
        flex-basis: 10px;
    }

    .board {
        border-radius: 8px;
    }

    .sq__coord {
        font-size: 8px;
    }

    .navbtn {
        width: 38px;
        height: 38px;
    }

    .boardnav__ply {
        font-size: 12px;
    }
}
