/* ----------------------------------------------------------------------
 * Project chrome — tokens, header, footer, about panel, document styles
 * for /help /404 /profile (TASK-26-34).
 *
 * The canvas page already ships a working dark theme built on a small
 * palette (#1a1a1a page, #2a2a2a panels, #fff text, #555 borders,
 * #6cf links, #ffd400 focus, #ff6b6b error). The tokens below extract
 * those values into named variables so chrome and the new static
 * pages share one source of truth instead of re-stating the hex. The
 * values are intentionally identical to what the canvas rules
 * already use — this file changes the styling of nothing in the
 * existing canvas, only what the new chrome adds.
 *
 * Layout numbers follow the same discipline the rest of the project
 * uses (no raw px outside this block unless a canvas overlay genuinely
 * needs it). One type scale, one spacing scale, one radius. */

:root {
    /* UA form-control/scrollbar scheme hint — follows the browser
     * preference via the @media block below. */
    color-scheme: light dark;

    /* Palette — drawn from the canvas page, not invented. */
    --bg-page:    #1a1a1a;
    --bg-panel:   #2a2a2a;
    --bg-panel-strong: rgba(42, 42, 42, 0.92);
    --bg-panel-soft:   rgba(42, 42, 42, 0.85);
    --fg-text:    #ffffff;
    --fg-muted:   #aaaaaa;
    --fg-dim:     #cccccc;
    --border-soft:#333333;
    --border-mid: #555555;
    --border-hard:#888888;
    --link:       #66ccff;
    --focus:      #ffd400;
    --error:      #ff6b6b;

    /* Type — monospace matches the existing canvas chrome. */
    --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas,
                 "Liberation Mono", monospace;

    /* Spacing — 4 px base. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Radii — match what the canvas already uses. */
    --radius-sm: 3px;
    --radius-md: 6px;
    --radius-lg: 8px;
}

/* Universal focus ring. The canvas already has #focus for keyboard
 * cell navigation; this rule covers every other focusable surface on
 * the page so a tab through header / footer / form controls is
 * visible. Uses the project's own --focus token (gold) so the ring
 * matches the rest of the chrome. */
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* Accessible helper: visually hidden but reachable by screen readers.
 * The canvas page uses this for the <img alt> decoration, the help
 * page uses it for screen-reader-only labels. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ----------------------------------------------------------------------
 * Document chrome for non-canvas static documents (help, 404,
 * profile). The canvas page does NOT use these rules — its body is
 * overflow:hidden so the chrome would either collapse to a sliver or
 * push the canvas off-screen. The `.sitePage` opt-in class is added
 * by each page that wants the document-style chrome. */
body.sitePage {
    overflow: auto;
    background-color: var(--bg-page);
    color: var(--fg-text);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}
.sitePage main {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--space-7) var(--space-5) var(--space-7);
}
.sitePage h1 {
    font-size: 1.4em;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-3);
}
.sitePage h2 {
    font-size: 1.05em;
    color: var(--link);
    margin: var(--space-5) 0 var(--space-2);
    letter-spacing: 0.04em;
}
.sitePage h3 {
    font-size: 0.95em;
    color: var(--fg-dim);
    margin: var(--space-4) 0 var(--space-1);
}
.sitePage p {
    margin: 0 0 var(--space-3);
    color: var(--fg-dim);
}
.sitePage p strong {
    color: var(--fg-text);
}
.sitePage a {
    color: var(--link);
    text-decoration: none;
}
.sitePage a:hover,
.sitePage a:focus-visible {
    text-decoration: underline;
}
.sitePage code,
.sitePage pre {
    font-family: var(--font-mono);
    background-color: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-sm);
    padding: 1px 4px;
    color: var(--fg-text);
}
.sitePage pre {
    display: block;
    padding: var(--space-3);
    overflow-x: auto;
    line-height: 1.45;
    white-space: pre;
}
.sitePage pre code {
    border: none;
    background: none;
    padding: 0;
}
.sitePage section {
    background-color: var(--bg-panel-soft);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}
.sitePage section h2 {
    margin-top: 0;
}
.sitePage ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sitePage li {
    padding: 2px 0;
    color: var(--fg-dim);
}
.sitePage li strong {
    color: var(--fg-text);
}
.sitePage .screenshot {
    display: block;
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    margin: var(--space-3) 0;
}
.sitePage .callout {
    border: 1px solid var(--border-hard);
    border-radius: var(--radius-md);
    background-color: rgba(0, 0, 0, 0.35);
    padding: var(--space-3) var(--space-4);
    margin: var(--space-4) 0;
    color: var(--fg-dim);
}
.sitePage .callout p:last-child {
    margin-bottom: 0;
}

/* ----------------------------------------------------------------------
 * Site header and footer (TASK-26-34).
 *
 * Both are page chrome — a slim wordmark, a few links, and a one-line
 * factual caption. They MUST NOT sit on top of any canvas input: every
 * element of #siteHeader / #siteFooter has pointer-events:none on the
 * container and pointer-events:auto on the actual <a> / <button>
 * children, so a tap on the empty header strip still falls through to
 * the canvas underneath.
 *
 * Z-index ordering mirrors the existing canvas chrome:
 *
 *   #game / canvas overlays  2 - 200
 *   header / footer chrome   450   <-- below the action buttons
 *                                       (500) and the connection-status
 *                                       overlay (1000), but above the
 *                                       gridOverlay (200) and stats (50)
 *                                       so the wordmark stays legible
 *                                       against the canvas.
 *
 * The header is a fixed strip across the top of the page; the footer
 * is a fixed strip across the bottom. Both sit BELOW the top-right
 * action buttons (z=500) and the connection-status overlay (z=1000).
 *
 * On screens narrower than 720 px the header collapses to the
 * wordmark + tagline; the nav links move to a small menu row that
 * sits below the wordmark so they never collide with the action
 * buttons in the top-right control strip. */
#siteHeader,
#siteFooter {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 450;
    pointer-events: none;
    color: var(--fg-text);
    font-family: var(--font-mono);
    font-size: 0.9em;
}
#siteHeader {
    top: 0;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    background: linear-gradient(
        to bottom,
        rgba(26, 26, 26, 0.92) 0%,
        rgba(26, 26, 26, 0) 100%
    );
}
#siteFooter {
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    background: linear-gradient(
        to top,
        rgba(26, 26, 26, 0.92) 0%,
        rgba(26, 26, 26, 0) 100%
    );
    font-size: 0.85em;
    color: var(--fg-muted);
}
/* Only the actual interactive children absorb pointer events. */
#siteHeader a,
#siteHeader button,
#siteFooter a,
#siteFooter button {
    pointer-events: auto;
}
#siteHeader .wordmark {
    color: var(--fg-text);
    font-weight: bold;
    letter-spacing: 0.06em;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}
#siteHeader .wordmark:hover,
#siteHeader .wordmark:focus-visible {
    text-decoration: underline;
}
#siteHeader .wordmark svg {
    width: 18px;
    height: 18px;
    display: block;
}
#siteHeader .tagline {
    color: var(--fg-muted);
    margin-right: auto;
}
#siteHeader nav {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}
#siteHeader nav a,
#siteFooter a {
    color: var(--link);
}
#siteHeader nav a:hover,
#siteHeader nav a:focus-visible,
#siteFooter a:hover,
#siteFooter a:focus-visible {
    text-decoration: underline;
}
#siteFooter .caption {
    color: var(--fg-muted);
}
/* On narrow screens the top-right action-button strip is wider and
 * the header has to give way: the tagline drops, the nav row wraps
 * below the wordmark, and the footer stacks its links vertically so
 * nothing collides with the canvas chrome (the minimap at bottom-left,
 * stats at bottom-right). */
@media (max-width: 720px) {
    #siteHeader {
        flex-wrap: wrap;
        padding-right: calc(5px + 7 * 0.7em);
    }
    #siteHeader .tagline {
        display: none;
    }
    #siteHeader nav {
        flex-basis: 100%;
        margin-top: var(--space-1);
        font-size: 0.85em;
    }
    #siteFooter {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
}
/* When the page chrome sits over a content-shaped document (help,
 * 404, profile) rather than the canvas, the gradient backgrounds are
 * pointless and a solid panel reads cleaner. The .sitePage class on
 * <body> triggers that variant. */
body.sitePage #siteHeader,
body.sitePage #siteFooter {
    position: static;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border-mid);
    padding: var(--space-3) var(--space-5);
    gap: var(--space-3);
}
body.sitePage #siteFooter {
    border-top: 1px solid var(--border-mid);
    border-bottom: none;
    margin-top: var(--space-7);
}
body.sitePage #siteHeader .tagline {
    display: inline;
}

/* ----------------------------------------------------------------------
 * About panel on the canvas page (TASK-26-34).
 *
 * The about panel is a fixed card in the top-centre of the canvas.
 * It is page chrome — pointer-events:none on the card body,
 * pointer-events:auto on the close button — so it does not intercept
 * clicks on the canvas underneath, and the painter can dismiss it
 * with one tap. z-index 450 matches the header / footer chrome band.
 *
 * On narrow screens the panel becomes the full-width top strip so the
 * painter's thumb does not have to reach across the action buttons. */
#about {
    position: fixed;
    top: 36px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 450;
    pointer-events: none;
    width: min(560px, calc(100vw - 280px));
    background-color: var(--bg-panel-strong);
    color: var(--fg-text);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-mono);
    font-size: 0.85em;
    line-height: 1.45;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
#about h2 {
    font-size: 0.9em;
    color: var(--link);
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
}
#about p {
    margin: 0 0 var(--space-2);
    color: var(--fg-dim);
}
#about p:last-of-type {
    margin-bottom: 0;
}
#about .actions {
    margin-top: var(--space-2);
    display: flex;
    gap: var(--space-3);
    pointer-events: auto;
}
#about .actions a {
    color: var(--link);
    text-decoration: none;
}
#about .actions a:hover,
#about .actions a:focus-visible {
    text-decoration: underline;
}
#about button.close {
    pointer-events: auto;
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: var(--fg-muted);
    font-family: var(--font-mono);
    font-size: 1em;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}
#about button.close:hover,
#about button.close:focus-visible {
    color: var(--fg-text);
    background-color: rgba(255, 255, 255, 0.06);
}
@media (max-width: 720px) {
    #about {
        top: 64px;
        width: calc(100vw - 16px);
        font-size: 0.8em;
    }
}
#about[hidden] {
    display: none;
}

/* ----------------------------------------------------------------------
 * Light colour scheme (TASK-2A-422).
 *
 * Re-declares every scheme-dependent chrome token under
 * `prefers-color-scheme: light` so the document chrome (header, footer,
 * .sitePage, #about, links, focus ring) stays readable on a white
 * background. The dark tokens above remain unchanged, so a dark-preferring
 * browser still sees today's chrome verbatim.
 *
 * The two header/footer gradients are hard-coded `rgba(26,26,26,*)` in
 * the base rules (see the #siteHeader / #siteFooter blocks above) and
 * have to be re-declared here; the same goes for the #about box-shadow.
 * The :root, #siteHeader, #siteFooter, #about rules inside this @media
 * block are equal or stronger than the base rules, so this block wins
 * when the preference matches. */
@media (prefers-color-scheme: light) {
    :root {
        --bg-page:      #ffffff;
        --bg-panel:     #f2f2f2;
        --bg-panel-strong: rgba(242, 242, 242, 0.92);
        --bg-panel-soft:   rgba(242, 242, 242, 0.85);
        --fg-text:      #1a1a1a;
        --fg-muted:     #5a5a5a;
        --fg-dim:       #444444;
        --border-soft:  #e0e0e0;
        --border-mid:   #b8b8b8;
        --border-hard:  #9a9a9a;
        --link:         #0057b8;
        --focus:        #8a6400;
        --error:        #c0392b;
    }
    #siteHeader {
        background: linear-gradient(
            to bottom,
            rgba(255, 255, 255, 0.92) 0%,
            rgba(255, 255, 255, 0) 100%
        );
    }
    #siteFooter {
        background: linear-gradient(
            to top,
            rgba(255, 255, 255, 0.92) 0%,
            rgba(255, 255, 255, 0) 100%
        );
    }
    #about {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    }
}