/* =========================================================================
   3D PROTAGON PUZZLES — DESIGN TOKENS  ("PLAYFIELD" v3)
   -------------------------------------------------------------------------
   The 2026-11 de-purple retheme. The old violet-undertone ink, electric
   indigo accent and lavender dark chrome read as machine-generated design,
   so the whole hue system was rotated onto a deliberate, print-heritage
   axis: "the game hall".

   Direction:  "PAPER ARCADE ON THE GREEN"
     • Paper     warm off-white stock, faint dot texture, never pure white.
     • Ink       warm near-black charcoal (no violet cast) for type/rules.
     • Colour    a deep pine-emerald primary with print-family supporting
                 hues: marigold (word), cobalt (logic), aqua (spatial),
                 plus tomato, pink and sky accents.
     • Dark      a botanical near-black — green-cast, never grey — with a
                 mint-jade accent so dark mode feels like felt under brass
                 lamps rather than a generic AI night.
     • Shape     generous radii, thick 2px outlines and hard offset shadows —
                 the page should feel like a screen-printed game box.
     • Motion    springy, quick and purposeful. Nothing decorative that
                 competes with a puzzle.

   Legacy variable names (--bg-0, --text, --brand, --panel, --line, --ok,
   --radius, --shadow-*) are all preserved, so the thousands of existing rules
   inherit the new system without a per-file rewrite. New UI uses the --pf-*
   aliases.
   ========================================================================= */

/* ───────────────────────────────────────────────────────────────────────
   1. TYPE
   ─────────────────────────────────────────────────────────────────────── */
:root {
    --font-display: 'Figtree', 'Figtree Fallback', system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-body:    'Figtree', 'Figtree Fallback', system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-accent:  'Fraunces', 'Fraunces Fallback', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
    --font-mono:    'JetBrains Mono', 'JetBrains Mono Fallback', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

/* ───────────────────────────────────────────────────────────────────────
   2. LIGHT THEME — "Paper Arcade on the Green"
   ─────────────────────────────────────────────────────────────────────── */
:root,
html[data-theme="light"] {
    color-scheme: light;

    /* Surfaces */
    --bg-0: #F7F2E7;                        /* warm paper stock */
    --bg-1: #FFFDF7;                        /* raised card */
    --bg-2: #EDE5D3;                        /* inset / divider */
    --panel: #FFFDF7;
    --panel-soft: rgba(255, 253, 247, 0.86);
    --line: rgba(38, 32, 23, 0.16);
    --line-strong: #262019;

    /* Text — measured against --bg-0 and --bg-2 */
    --text: #2A231A;
    --text-strong: #171208;
    --text-muted: #6C6353;                  /* 6.3:1 on --bg-0 */

    /* Primary action: deep pine emerald. White text = 6.9:1. */
    --accent: #076A4A;
    --accent-hover: #05563B;
    --accent-contrast: #FFFFFF;
    --brand: var(--accent);
    --brand-2: #FF5C35;                     /* tomato counterpoint */
    --link: #076247;
    --link-hover: #054D37;

    /* Semantic */
    --ok: #16794C;
    --warn: #9A5B00;
    --danger: #C2341B;

    /* Category text colours (safe on paper) */
    --cat-word: #9A3412;
    --cat-logic: #2B49C8;
    --cat-spatial: #0B7585;

    --on-accent: var(--accent-contrast);

    /* Playful surfaces — used by the new UI. */
    --pf-paper: #F7F2E7;
    --pf-card: #FFFDF7;
    --pf-ink: #262019;
    --pf-ink-soft: rgba(38, 32, 23, 0.62);
    --pf-pine: #076A4A;
    --pf-pine-deep: #054F38;
    --pf-sun: #FFC53D;
    --pf-sun-soft: #FFF0B8;
    --pf-word: #FFB020;
    --pf-word-soft: #FFF1D6;
    --pf-word-ink: #2D1C00;
    --pf-logic: #3D5BEA;
    --pf-logic-soft: #D3E3FA;              /* pale cobalt-sky; never reads lavender */
    --pf-logic-ink: #FFFFFF;
    --pf-spatial: #17B2C9;
    --pf-spatial-soft: #DDF5FA;
    --pf-spatial-ink: #04262B;
    --pf-tomato: #FF5C35;
    --pf-tomato-soft: #FFE5DD;
    --pf-pink: #FF7BAC;
    --pf-pink-soft: #FFE8F1;
    --pf-sky: #63BDFF;
    --pf-sky-soft: #E3F4FF;
    --pf-lime: #C8F15B;
    --pf-night: #1A1610;
    --pf-footer: #262019;

    /* Chrome */
    --nav-bg: rgba(247, 242, 231, 0.88);
    --nav-border: rgba(38, 32, 23, 0.14);
    --nav-text: var(--text);
    --nav-muted: var(--text-muted);
    --nav-hover-bg: rgba(7, 106, 74, 0.08);
    --nav-active-bg: rgba(7, 106, 74, 0.12);
    --nav-active-text: var(--accent);
    --nav-highlight: var(--accent);

    --paper: var(--text);
    --ink: var(--bg-0);
    --rule: var(--line);

    /* ── Space ──────────────────────────────────────────────────────── */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2rem;
    --space-6: 3rem;
    --space-7: 4rem;

    /* ── Radius ─────────────────────────────────────────────────────── */
    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 24px;
    --radius-xl: 34px;
    --radius-pill: 999px;

    /* ── Elevation — soft by default, hard edges in new components ───── */
    --shadow-sm: 0 1px 2px rgba(38, 32, 23, 0.08);
    --shadow-md: 0 10px 24px rgba(38, 32, 23, 0.10);
    --shadow-lg: 0 24px 60px rgba(38, 32, 23, 0.16);
    --shadow-hard: 0 5px 0 var(--pf-ink);
    --shadow-hard-lg: 0 9px 0 var(--pf-ink);
    --surface-grad: linear-gradient(180deg, rgba(255, 253, 247, 0.7), rgba(255, 253, 247, 0));
    --edge-glow: 0 0 0 1px var(--line);

    /* ── Type scale ─────────────────────────────────────────────────── */
    --fs-display: clamp(3.1rem, 8.2vw, 7.4rem);
    --fs-h1:      clamp(2.3rem, 4.6vw, 3.5rem);
    --fs-h2:      clamp(2rem, 3.6vw, 2.9rem);
    --fs-h3:      1.45rem;
    --fs-body-lg: 1.1875rem;
    --fs-body:    1.0625rem;
    --fs-sm:      0.875rem;
    --fs-eyebrow: 0.75rem;

    /* ── Motion ─────────────────────────────────────────────────────── */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast: 0.16s;
    --dur: 0.24s;
    --dur-slow: 0.45s;

    --grid-texture:
        radial-gradient(rgba(38, 32, 23, 0.16) 1px, transparent 1px);
    --grid-size: 22px;

    --focus-ring: 0 0 0 3px rgba(7, 106, 74, 0.45);
    --pf-header-h: 80px;
}

/* ───────────────────────────────────────────────────────────────────────
   3. DARK THEME — "Botanical Arcade"
   ─────────────────────────────────────────────────────────────────────── */
html[data-theme="dark"] {
    color-scheme: dark;

    --bg-0: #0D1411;
    --bg-1: #14211B;
    --bg-2: #1F2F27;
    --panel: #14211B;
    --panel-soft: rgba(20, 33, 27, 0.88);
    --line: rgba(247, 242, 231, 0.16);
    --line-strong: #F7F2E7;

    --text: #ECEFE2;
    --text-strong: #FBFDF6;
    --text-muted: #A9B8A7;

    --accent: #7CE6B4;
    --accent-hover: #9BEFCB;
    --accent-contrast: #0B2418;
    --brand: var(--accent);
    --brand-2: #FF8A6B;
    --link: #8FE9C0;
    --link-hover: #AFF3D4;

    --ok: #5BD99A;
    --warn: #FFC866;
    --danger: #FF7C63;

    --cat-word: #FFB84D;
    --cat-logic: #9EBDFF;
    --cat-spatial: #6CD9EA;

    --on-accent: var(--accent-contrast);

    --pf-paper: #0D1411;
    --pf-card: #14211B;
    --pf-ink: #F7F2E7;
    --pf-ink-soft: rgba(247, 242, 231, 0.62);
    --pf-pine: #7CE6B4;
    --pf-pine-deep: #5CD69E;
    --pf-sun: #FFD25F;
    --pf-sun-soft: rgba(255, 197, 61, 0.14);
    --pf-word: #FFB84D;
    --pf-word-soft: rgba(255, 184, 77, 0.14);
    --pf-word-ink: #2D1C00;
    --pf-logic: #9EBDFF;
    --pf-logic-soft: rgba(126, 146, 255, 0.16);   /* lands ≈#25313F on the pine ground — cobalt family, not teal */
    --pf-logic-ink: #1D2749;
    --pf-spatial: #6CD9EA;
    --pf-spatial-soft: rgba(108, 217, 234, 0.12);
    --pf-spatial-ink: #06262B;
    --pf-tomato: #FF8A6B;
    --pf-tomato-soft: rgba(255, 138, 107, 0.14);
    --pf-pink: #FF9CC4;
    --pf-pink-soft: rgba(255, 156, 196, 0.13);
    --pf-sky: #8FD3FF;
    --pf-sky-soft: rgba(143, 211, 255, 0.13);
    --pf-lime: #D3F77A;
    --pf-night: #070D0A;
    --pf-footer: #070D0A;

    --nav-bg: rgba(13, 20, 17, 0.86);
    --nav-border: rgba(247, 242, 231, 0.14);
    --nav-text: var(--text);
    --nav-muted: var(--text-muted);
    --nav-hover-bg: rgba(124, 230, 180, 0.12);
    --nav-active-bg: rgba(124, 230, 180, 0.18);
    --nav-active-text: var(--accent);
    --nav-highlight: var(--accent);

    --paper: var(--text);
    --ink: var(--bg-0);
    --rule: var(--line);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.42);
    --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.55);
    --shadow-hard: 0 5px 0 rgba(0, 0, 0, 0.55);
    --shadow-hard-lg: 0 9px 0 rgba(0, 0, 0, 0.55);
    --surface-grad: linear-gradient(180deg, rgba(247, 242, 231, 0.04), rgba(247, 242, 231, 0));
    --edge-glow: 0 0 0 1px var(--line);

    --focus-ring: 0 0 0 3px rgba(124, 230, 180, 0.55);
}

/* ───────────────────────────────────────────────────────────────────────
   4. BASE ELEMENTS
   ─────────────────────────────────────────────────────────────────────── */
html,
body {
    background-color: var(--bg-0);
}

html[data-theme="light"] body,
html[data-theme="dark"] body,
body {
    background-image: none;
    background-attachment: scroll;
}

body {
    font-family: var(--font-body);
    font-feature-settings: 'kern' 1, 'liga' 1, 'tnum' 1;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-weight: 800;
    letter-spacing: -0.035em;
    color: var(--text-strong);
    line-height: 1.04;
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

html {
    scroll-padding-top: calc(var(--pf-header-h) + 18px);
}

.puzzle-grid,
.grid-cell,
.cell,
[class*="sudoku"],
[class*="crossword"] {
    font-variant-numeric: tabular-nums;
}

a {
    color: var(--link);
}
a:hover {
    color: var(--link-hover);
}

::selection {
    background: color-mix(in srgb, var(--accent) 32%, transparent);
    color: var(--text-strong);
}

/* ───────────────────────────────────────────────────────────────────────
   5. ACCESSIBILITY
   ─────────────────────────────────────────────────────────────────────── */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-xs);
}

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