/* Practice — Salt n' Fork
 * Design system: Excalidraw/Notion hybrid — hand-drawn feel, modern execution
 */

:root {
    /* Light mode palette */
    --bg: #fbf9f3;
    --bg-soft: #f3efe3;
    --surface: #ffffff;
    --text: #1f1f1f;
    --text-secondary: #5a5a5a;
    --text-muted: #8a8a8a;
    --border: #e6e1d3;
    --border-strong: #c7c0ac;
    --primary: #2e8b7a;
    --primary-hover: #247062;
    --accent: #e9a845;
    --danger: #c14b43;
    --success: #2e8b7a;

    /* Category colors — used for card accents, category tags, hover states */
    --cat-money: #2e8b7a;
    --cat-money-bg: #e2f1ec;
    --cat-math: #3a7bb8;
    --cat-math-bg: #e3edf7;
    --cat-measure: #5a5fb8;
    --cat-measure-bg: #e9e9f4;
    --cat-memory: #8a5fa8;
    --cat-memory-bg: #f1e9f4;
    --cat-car: #d47a3c;
    --cat-car-bg: #fbe9d9;
    --cat-home: #c86a7a;
    --cat-home-bg: #f7e1e5;
    --cat-strategy: #4a5567;
    --cat-strategy-bg: #e5e8ec;

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-hand: 'Caveat', 'Comic Sans MS', cursive;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Monaco, Menlo, monospace;

    /* Spacing */
    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 18px;

    /* Layout */
    --max-width: 980px;
    --page-padding: 1.25rem;
}

/* Dark mode — applies when the user manually selected it,
 * OR when the system prefers dark and the user hasn't chosen light. */
:root[data-theme="dark"] {
    --bg: #15161a;
    --bg-soft: #1e2024;
    --surface: #21232a;
    --text: #ebe8e1;
    --text-secondary: #b4b0a5;
    --text-muted: #80796d;
    --border: #32343a;
    --border-strong: #4e5159;
    --primary: #4cbba6;
    --primary-hover: #63d0bc;
    --accent: #f2b857;
    --danger: #e07571;

    --cat-money: #4cbba6;
    --cat-money-bg: #1e3a34;
    --cat-math: #6aa6df;
    --cat-math-bg: #223245;
    --cat-measure: #8b8fda;
    --cat-measure-bg: #292c47;
    --cat-memory: #b288c8;
    --cat-memory-bg: #3a2c44;
    --cat-car: #eb9d5b;
    --cat-car-bg: #402e1d;
    --cat-home: #dc8c98;
    --cat-home-bg: #3d272d;
    --cat-strategy: #9aa4b5;
    --cat-strategy-bg: #2a2f38;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --bg: #15161a;
        --bg-soft: #1e2024;
        --surface: #21232a;
        --text: #ebe8e1;
        --text-secondary: #b4b0a5;
        --text-muted: #80796d;
        --border: #32343a;
        --border-strong: #4e5159;
        --primary: #4cbba6;
        --primary-hover: #63d0bc;
        --accent: #f2b857;
        --danger: #e07571;

        --cat-money: #4cbba6;
        --cat-money-bg: #1e3a34;
        --cat-math: #6aa6df;
        --cat-math-bg: #223245;
        --cat-measure: #8b8fda;
        --cat-measure-bg: #292c47;
        --cat-memory: #b288c8;
        --cat-memory-bg: #3a2c44;
        --cat-car: #eb9d5b;
        --cat-car-bg: #402e1d;
        --cat-home: #dc8c98;
        --cat-home-bg: #3d272d;
        --cat-strategy: #9aa4b5;
        --cat-strategy-bg: #2a2f38;
    }
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    html {
        scroll-behavior: auto;
    }
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--page-padding);
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(251, 249, 243, 0.85);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
}

:root[data-theme="dark"] .site-header {
    background: rgba(21, 22, 26, 0.85);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) .site-header {
        background: rgba(21, 22, 26, 0.85);
    }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.brand {
    font-family: var(--font-hand);
    font-size: 1.9rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    line-height: 1;
    border: none;
}

.brand:hover {
    color: var(--primary);
    border: none;
}

.brand::after {
    content: ".";
    color: var(--accent);
}

.panic-btn {
    display: none; /* Shown only on desktop via JS */
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-hand);
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.panic-btn:hover {
    color: var(--text);
    background: var(--bg-soft);
}

.panic-btn kbd {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    opacity: 0.7;
    background: none;
    border: none;
    padding: 0;
}

/* Theme toggle button — matches Salt n' Fork Budget app pattern */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
}

.theme-toggle:hover {
    color: var(--text);
    background: var(--bg-soft);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    display: none;
}

/* Moon icon shown by default (light mode — click to go dark) */
.theme-toggle .moon-icon { display: block; }
.theme-toggle .sun-icon { display: none; }

/* In explicit dark mode, show sun (click to go light) */
:root[data-theme="dark"] .theme-toggle .moon-icon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun-icon { display: block; }

/* In system dark mode with no manual override, show sun */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) .theme-toggle .moon-icon { display: none; }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .theme-toggle .sun-icon { display: block; }
}

/* Typography */
h1, h2, h3, h4 {
    line-height: 1.25;
    font-weight: 600;
    margin: 1.5em 0 0.5em;
    color: var(--text);
}

h1 {
    font-size: 2.25rem;
    margin-top: 0.5em;
}

h2 {
    font-size: 1.6rem;
    font-family: var(--font-hand);
    font-weight: 600;
    letter-spacing: 0.01em;
    display: inline-block;
    position: relative;
    padding-bottom: 0.1em;
}

h2::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -0.05em;
    height: 6px;
    background: var(--accent);
    opacity: 0.55;
    border-radius: 999px;
    transform: rotate(-0.5deg);
    z-index: -1;
}

p {
    margin: 0 0 1rem;
}

a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dashed var(--primary);
    transition: color 0.15s, border-color 0.15s;
}

a:hover {
    color: var(--primary-hover);
    border-bottom-style: solid;
}

/* Intro — plain text, no box, tight spacing */
.intro {
    padding: 2.25rem 0 0.5rem;
    text-align: center;
}

.intro-doodles {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    margin: 0 auto 1rem;
    opacity: 0.95;
}

.intro-doodles .doodle {
    width: 36px;
    height: 36px;
    transform: rotate(var(--rot, 0deg));
    transition: transform 0.25s ease;
}

.intro-doodles .doodle-money   { color: var(--cat-money);    --rot: -4deg; }
.intro-doodles .doodle-measure { color: var(--cat-measure);  --rot:  3deg; }
.intro-doodles .doodle-math    { color: var(--cat-math);     --rot: -2deg; }
.intro-doodles .doodle-car     { color: var(--cat-car);      --rot:  4deg; }
.intro-doodles .doodle-memory  { color: var(--cat-memory);   --rot: -3deg; }

.intro-doodles .doodle:hover {
    transform: rotate(var(--rot, 0deg)) translateY(-2px) scale(1.08);
}

@media (max-width: 500px) {
    .intro-doodles { gap: 0.7rem; }
    .intro-doodles .doodle { width: 30px; height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
    .intro-doodles .doodle:hover { transform: rotate(var(--rot, 0deg)); }
}

.intro h1 {
    font-size: 2.1rem;
    margin: 0 0 0.35rem;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.intro h1 .hand-accent {
    font-family: var(--font-hand);
    color: var(--primary);
    font-size: 1.2em;
    font-weight: 600;
}

.intro .tagline {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto;
}

/* Section heading wrapper — absorbs h2 to get consistent top spacing */
.section-heading {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-top: 2.5rem;
    margin-bottom: 0.25rem;
}

.section-heading h2 {
    margin: 0;
}

.section-heading .section-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Game grid */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    padding: 1.25rem 0 0.5rem;
}

.game-card {
    display: block;
    position: relative;
    padding: 1.25rem 1.25rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    overflow: hidden;
}

.game-card:hover {
    border-color: var(--cat-color, var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.18);
}

.game-card.coming-soon {
    opacity: 0.65;
    cursor: default;
    pointer-events: none;
}

.game-card.coming-soon .game-card-soon {
    position: absolute;
    top: 0.75rem;
    right: 0.85rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.game-card h3 {
    margin: 0.15rem 0 0.35rem;
    font-size: 1.15rem;
}

.game-card .meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.game-card .category {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--cat-bg, var(--bg-soft));
    color: var(--cat-color, var(--primary));
    margin-bottom: 0.55rem;
}

/* Category colors */
.game-card[data-cat="money"]     { --cat-color: var(--cat-money);    --cat-bg: var(--cat-money-bg); }
.game-card[data-cat="math"]      { --cat-color: var(--cat-math);     --cat-bg: var(--cat-math-bg); }
.game-card[data-cat="measure"]   { --cat-color: var(--cat-measure);  --cat-bg: var(--cat-measure-bg); }
.game-card[data-cat="memory"]    { --cat-color: var(--cat-memory);   --cat-bg: var(--cat-memory-bg); }
.game-card[data-cat="car"]       { --cat-color: var(--cat-car);      --cat-bg: var(--cat-car-bg); }
.game-card[data-cat="home"]      { --cat-color: var(--cat-home);     --cat-bg: var(--cat-home-bg); }
.game-card[data-cat="strategy"]  { --cat-color: var(--cat-strategy); --cat-bg: var(--cat-strategy-bg); }

/* Featured card — identical gradient treatment to others */

/* Footer — matches Salt n' Fork ecosystem convention */
.footer {
    text-align: center;
    padding: 1.25rem 1rem 1.5rem;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: none;
}

.footer a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.footer-credit {
    margin-top: 0.5rem;
    line-height: 1.8;
}

/* Panic overlay (fake spreadsheet) */
#panic-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #ffffff;
    color: #000000;
    font-family: Arial, sans-serif;
    overflow: auto;
}

#panic-overlay.active {
    display: block;
}

/* Exit button inside the panic overlay — matches the primary-button
 * aesthetic (hand-font pill, offset shadow, slight rotation). Uses
 * `--cat-math` as the accent by default; a game page can override by
 * setting `--panic-accent` on the root to match its own category color. */
#panic-overlay .panic-exit {
    --panic-accent: var(--cat-math, #3a7bb8);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 1.1rem;
    font-family: var(--font-hand);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border: 2px solid var(--panic-accent);
    border-radius: 999px;
    background: var(--panic-accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 3px 4px 0 rgba(58, 123, 184, 0.28);
    transform: rotate(-0.8deg);
    transition: transform 0.18s, box-shadow 0.15s, filter 0.15s;
}
#panic-overlay .panic-exit:hover {
    filter: brightness(0.96);
    transform: rotate(0) translate(-1px, -1px);
    box-shadow: 4px 5px 0 rgba(58, 123, 184, 0.32);
}
#panic-overlay .panic-exit:active {
    transform: rotate(0) translate(2px, 2px);
    box-shadow: 1px 1px 0 rgba(58, 123, 184, 0.25);
}
#panic-overlay .panic-exit:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* Utility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Legal pages (about, privacy, terms, faq) — narrower reading width */
.legal-page {
    max-width: 680px;
    padding-top: 2rem;
    padding-bottom: 3rem;
}

.legal-page h2 {
    font-family: var(--font-sans);
    font-size: 1.25rem;
}

.legal-page h2::after {
    display: none;
}

/* ===========================================================
 * Jump-to-top / Jump-to-bottom floating buttons.
 * Each game page sets --jump-accent to its category color.
 * =========================================================== */
.jump-nav {
    position: fixed;
    right: 0.9rem;
    bottom: 1.1rem;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    pointer-events: none;
}
.jump-nav button {
    pointer-events: auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-family: var(--font-hand);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.18s, opacity 0.25s, background 0.15s, border-color 0.15s;
    box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.12);
}
.jump-nav .jump-top {
    background: var(--jump-accent, var(--cat-math));
    border: 2px solid var(--jump-accent, var(--cat-math));
    color: #fff;
    transform: rotate(-3deg);
}
.jump-nav .jump-top:hover {
    transform: rotate(0) translate(-1px, -1px);
    filter: brightness(0.95);
}
.jump-nav .jump-bottom {
    background: var(--surface);
    border: 1.5px dashed var(--border-strong);
    color: var(--text-secondary);
    transform: rotate(3deg);
}
.jump-nav .jump-bottom:hover {
    transform: rotate(0) translate(-1px, -1px);
    border-style: solid;
    border-color: var(--jump-accent, var(--cat-math));
    color: var(--jump-accent, var(--cat-math));
}
.jump-nav button:focus-visible {
    outline: 2px solid var(--jump-accent, var(--cat-math));
    outline-offset: 3px;
}
.jump-nav.hide-top .jump-top,
.jump-nav.hide-bottom .jump-bottom {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}
@media (prefers-reduced-motion: reduce) {
    .jump-nav button { transform: none; transition: opacity 0.2s; }
    .jump-nav button:hover { transform: none; }
}
@media (max-width: 560px) {
    .jump-nav { right: 0.6rem; bottom: 0.7rem; gap: 0.45rem; }
    .jump-nav button { width: 40px; height: 40px; font-size: 1.2rem; }
}

/* ===========================================================
 * FAQ table-of-contents — sits at the top of a long FAQ so
 * readers can see what's there before scrolling.
 * =========================================================== */
.faq-toc {
    background: var(--bg-soft);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem 0.9rem;
    margin: 0.75rem 0 1.5rem;
}
.faq-toc-label {
    font-family: var(--font-hand);
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    color: var(--text);
}
.faq-toc ol {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: toc;
    display: grid;
    gap: 0.25rem 1rem;
}
@media (min-width: 720px) {
    .faq-toc ol { grid-template-columns: 1fr 1fr; }
}
.faq-toc li {
    counter-increment: toc;
    position: relative;
    padding-left: 1.6rem;
    font-size: 0.95rem;
    line-height: 1.45;
}
.faq-toc li::before {
    content: counter(toc) ".";
    position: absolute;
    left: 0;
    top: 0;
    font-family: var(--font-hand);
    font-weight: 700;
    color: var(--text-muted);
}
.faq-toc a {
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px dotted var(--border-strong);
}
.faq-toc a:hover,
.faq-toc a:focus-visible {
    color: var(--text);
    border-bottom-style: solid;
    border-bottom-color: currentColor;
}

/* ===========================================================
 * Summary recap — "show the working" list on the round-over
 * summary. Scrollable so long rounds don't dominate the page.
 * =========================================================== */
.summary-recap {
    margin: 1.25rem auto 0.5rem;
    text-align: left;
    max-width: 640px;
}
.summary-recap-head {
    font-family: var(--font-hand);
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--text);
    text-align: center;
}
.summary-recap-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
}
.summary-recap-list li {
    padding: 0.6rem 0.85rem;
    border-bottom: 1px dashed var(--border);
    display: grid;
    gap: 0.15rem;
}
.summary-recap-list li:last-child { border-bottom: none; }
.summary-recap-list .recap-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-family: var(--font-hand);
    font-size: 1.1rem;
}
.summary-recap-list .recap-mark {
    font-weight: 700;
    width: 1.3em;
    display: inline-block;
}
.summary-recap-list li.correct .recap-mark { color: #2a7a52; }
.summary-recap-list li.wrong .recap-mark { color: #b04141; }
.summary-recap-list li.skip .recap-mark { color: var(--text-muted); }
.summary-recap-list .recap-q { flex: 1; color: var(--text); }
.summary-recap-list .recap-ans { font-weight: 700; color: var(--text); }
.summary-recap-list li.wrong .recap-ans { color: #b04141; text-decoration: line-through; }
.summary-recap-list .recap-correct {
    color: #2a7a52;
    font-weight: 700;
    margin-left: 0.15em;
}
.summary-recap-list .recap-how {
    font-family: var(--font-sans);
    font-size: 0.86rem;
    color: var(--text-secondary);
    line-height: 1.45;
    padding-left: 1.8em;
}
.summary-recap-empty {
    padding: 0.75rem;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

/* ===========================================================
 * No-JavaScript banner. Shown only when JS is disabled.
 * =========================================================== */
.noscript-banner {
    background: #ffefef;
    color: #7a2a2a;
    border-bottom: 1px solid #e9b3b3;
    padding: 0.85rem 1rem;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 500;
}
:root[data-theme="dark"] .noscript-banner {
    background: #3a1f1f;
    color: #ffc2c2;
    border-bottom-color: #5a2a2a;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .noscript-banner {
        background: #3a1f1f;
        color: #ffc2c2;
        border-bottom-color: #5a2a2a;
    }
}

