/* Aptly Games web tokens: DESIGN FILE, reference implementation for SEO & Content.
   Layer 1  app tokens   --ag-<tokens.json name>   (traceable 1:1 to daily_mind_design_v1/tokens.json v1)
   Layer 2  brand        --ag-brand-*              (brand/README.md; decorative: logo + illustration only, never text)
   Layer 3  web-only     --ag-space-*, --ag-step-*, --ag-w-*, --ag-elev-*, --ag-dur-* ...
   Layer 4  semantic     --ag-c-*  (the ONLY colour names components use). Studio sets them on :root;
            a game theme re-points them inside [data-game="..."]; a puzzle sub-theme inside [data-puzzle="..."].
   Dark: prefers-color-scheme, overridable with [data-theme] on <html>. Values = tokens.colors.dark. */

@font-face {
  font-family: "Newsreader";
  src: url("../fonts/Newsreader-latin-wght.woff2") format("woff2");
  font-weight: 400 600; font-style: normal; font-display: swap; /* OFL 1.1, subset latin, opsz pinned 24 */
}

:root {
  color-scheme: light dark;

  /* ---- Layer 1: app colour tokens (tokens.colors.light) ---- */
  --ag-background: #F6F5F0;  /* colors.light.background */
  --ag-surface:    #FFFFFF;  /* colors.light.surface */
  --ag-text:       #242C30;  /* colors.light.text */
  --ag-muted:      #58666C;  /* colors.light.muted */
  --ag-border:     #DEDFD9;  /* colors.light.border (decorative dividers only: 1.3:1) */
  --ag-dm:      #19786F; --ag-dm-tint: #E2F2ED;  /* Double Meaning */
  --ag-tl:      #385E92; --ag-tl-tint: #E7EEF8;  /* Timeline */
  --ag-lu:      #76538E; --ag-lu-tint: #EEE8F5;  /* Lineup */
  --ag-ll:      #8A5A10; --ag-ll-tint: #FAEDCF;  /* Letter Ladder */
  --ag-success: #24754E; --ag-assisted: #88600E; --ag-error: #B24846;
  /* colors.marks + colors.lineup are theme-independent in tokens.json */
  --ag-mark-good: #24754E; --ag-mark-assist: #B28522; --ag-mark-bad: #B24846; --ag-mark-none: #647278;
  --ag-lineup-red: #B94B61; --ag-lineup-blue: #426EA7; --ag-lineup-green: #24826C;
  --ag-lineup-yellow: #D6A344; --ag-lineup-purple: #8753A8; --ag-lineup-orange: #CB6B36;

  /* ---- Layer 2: brand palette (brand/README.md). Logo + illustration ONLY. ---- */
  --ag-brand-ivory: #F8F6EF; --ag-brand-ink: #263238;
  --ag-brand-teal: #117B6B; --ag-brand-blue: #385E92; --ag-brand-plum: #76538E; --ag-brand-amber: #C58A24; /* amber 2.76:1 on ivory: never text */

  /* ---- Layer 3: web-only ---- */
  --ag-border-strong: #7A878C;  /* web-only: control/input boundaries, 3.39:1 on background (WCAG 1.4.11) */
  --ag-studio-tint:   #ECE9DF;  /* web-only: neutral studio panel, text 11.7:1 */

  /* spacing: tokens.spacing.base = 4 → 4px grid, expressed in rem so it grows with text */
  --ag-space-1: .25rem; --ag-space-2: .5rem; --ag-space-3: .75rem; --ag-space-4: 1rem; --ag-space-5: 1.25rem;
  --ag-space-6: 1.5rem; --ag-space-8: 2rem; --ag-space-10: 2.5rem; --ag-space-12: 3rem; --ag-space-16: 4rem; --ag-space-20: 5rem; --ag-space-24: 6rem;
  --ag-card-padding: 1rem;      /* spacing.cardPadding 16 (web cards grow to --ag-space-6 at ≥768) */
  --ag-grid-gap: .75rem;        /* spacing.gridGap 12 (→ 1.5rem at ≥1280) */
  --ag-section-gap: clamp(3rem, 2rem + 4vw, 6rem); /* spacing.sectionGap 22 is an in-app value; web sections breathe more */
  --ag-gutter: clamp(1.25rem, .6rem + 3.2vw, 2.5rem); /* spacing.screenHorizontal 20 at 320–390 */
  --ag-touch-min: 44px;         /* spacing.minimumTouchTarget (px on purpose: never shrinks) */
  --ag-touch-pref: 48px;        /* spacing.androidPreferredTouchTarget, used for primary CTAs */

  /* radii: tokens.radii */
  --ag-radius-card: 20px; --ag-radius-control: 13px; --ag-radius-tile: 9px; --ag-radius-sheet: 22px; --ag-radius-circle: 999px;
  --ag-radius-panel: 28px; /* web-only: full-bleed feature panels at ≥768 */

  /* type: tokens.typography.family = system → UI stays system; one OFL serif (Newsreader) for display + long-form prose */
  --ag-font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ag-font-serif: "Newsreader", "Iowan Old Style", Charter, "Palatino Linotype", Georgia, serif;
  /* fluid scale: rem + vw so browser text zoom (rem) still scales every step (WCAG 1.4.4) */
  --ag-step--1: .8125rem;                                   /* caption 13 */
  --ag-step-0:  1rem;                                       /* body 16 / 23 */
  --ag-step-1:  clamp(1.125rem, 1.08rem + .2vw, 1.25rem);   /* lede / prose 18–20 */
  --ag-step-2:  clamp(1.25rem, 1.15rem + .45vw, 1.5rem);    /* h3 / section (tokens.section 20) */
  --ag-step-3:  clamp(1.625rem, 1.4rem + 1vw, 2.25rem);     /* h2 */
  --ag-step-4:  clamp(2rem, 1.62rem + 1.9vw, 3.25rem);      /* h1 inner pages (tokens.hero 32 at 320) */
  --ag-step-5:  clamp(2.375rem, 1.6rem + 3.9vw, 4.75rem);   /* display, home heroes only */
  --ag-eyebrow: .75rem;                                     /* tokens.eyebrow 11 → 12 on web for legibility */
  --ag-lh-tight: 1.08; --ag-lh-heading: 1.18; --ag-lh-body: 1.45 /* 23/16 */; --ag-lh-prose: 1.6;
  --ag-tracking-eyebrow: .1em; /* eyebrow letterSpacing 1.3 / 13 */

  /* layout widths */
  --ag-w-prose: 40rem;   /* ~68ch body measure */
  --ag-w-narrow: 46rem;  /* daily-hint column */
  --ag-w-content: 75rem; /* 1200 max content */
  --ag-header-h: 4rem;

  /* elevation (light). Dark uses borders, not shadows (tokens: dark shadow none) */
  --ag-elev-1: 0 1px 2px rgb(23 43 40 / .06);
  --ag-elev-2: 0 4px 18px rgb(23 43 40 / .0625);   /* app --shadow 0 4px 18px #172b2810 */
  --ag-elev-3: 0 12px 40px rgb(23 43 40 / .14);    /* menus / popovers */

  /* motion: tokens.motionMs */
  --ag-dur-fast: 120ms;  /* timelineWrongFlash / tap feedback */
  --ag-dur-base: 180ms;  /* swap */
  --ag-dur-slow: 220ms;  /* screen / tileReveal */
  --ag-ease: cubic-bezier(.2, 0, 0, 1); /* ease-out, no bounce (DESIGN_SPEC motion table) */

}

/* Layer 4 is declared on :root AND on any [data-theme] wrapper, so a nested light/dark island re-resolves
   its var() references (custom properties resolve where they are declared, then inherit as values). */
:root, [data-theme] {
  /* ---- Layer 4: semantic, STUDIO theme (neutral: ivory + ink, four-colour mark is the only colour) ---- */
  --ag-c-bg: var(--ag-background);
  --ag-c-surface: var(--ag-surface);
  --ag-c-panel: var(--ag-studio-tint);
  --ag-c-text: var(--ag-text);
  --ag-c-muted: var(--ag-muted);
  --ag-c-divider: var(--ag-border);
  --ag-c-control-border: var(--ag-border-strong);
  --ag-c-accent: var(--ag-text);          /* studio accent is ink: buttons, current-nav marker */
  --ag-c-accent-tint: var(--ag-studio-tint);
  --ag-c-on-accent: var(--ag-background);
  --ag-c-link: var(--ag-text);
  --ag-c-link-underline: var(--ag-tl);    /* colour lives in the underline, text stays 13:1 */
  --ag-c-focus: var(--ag-tl);             /* app focus = 3px blue outline */
  --ag-illus-1: var(--ag-brand-teal); --ag-illus-2: var(--ag-brand-blue); --ag-illus-3: var(--ag-brand-plum); --ag-illus-4: var(--ag-brand-amber);
}

/* ---- Dark (tokens.colors.dark) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ag-background: #161B1E; --ag-surface: #222A2E; --ag-text: #F2F4F2; --ag-muted: #A9B6BA; --ag-border: #3A464C;
    --ag-dm: #87D5C6; --ag-dm-tint: #173E39; --ag-tl: #A4C7FA; --ag-tl-tint: #263A54;
    --ag-lu: #D4B7EB; --ag-lu-tint: #392E48; --ag-ll: #F0CA80; --ag-ll-tint: #40341E;
    --ag-success: #8AD6AC; --ag-assisted: #F0CA80; --ag-error: #F4A2A0;
    --ag-border-strong: #76858B; --ag-studio-tint: #2A3337;
    --ag-elev-1: none; --ag-elev-2: none; --ag-elev-3: 0 12px 40px rgb(0 0 0 / .5);
  }
}
[data-theme="dark"] {
  --ag-background: #161B1E; --ag-surface: #222A2E; --ag-text: #F2F4F2; --ag-muted: #A9B6BA; --ag-border: #3A464C;
  --ag-dm: #87D5C6; --ag-dm-tint: #173E39; --ag-tl: #A4C7FA; --ag-tl-tint: #263A54;
  --ag-lu: #D4B7EB; --ag-lu-tint: #392E48; --ag-ll: #F0CA80; --ag-ll-tint: #40341E;
  --ag-success: #8AD6AC; --ag-assisted: #F0CA80; --ag-error: #F4A2A0;
  --ag-border-strong: #76858B; --ag-studio-tint: #2A3337;
  --ag-elev-1: none; --ag-elev-2: none; --ag-elev-3: 0 12px 40px rgb(0 0 0 / .5);
}
/* light island inside a dark page (or html[data-theme=light] on a dark OS) */
[data-theme="light"] {
  --ag-background: #F6F5F0; --ag-surface: #FFFFFF; --ag-text: #242C30; --ag-muted: #58666C; --ag-border: #DEDFD9;
  --ag-dm: #19786F; --ag-dm-tint: #E2F2ED; --ag-tl: #385E92; --ag-tl-tint: #E7EEF8;
  --ag-lu: #76538E; --ag-lu-tint: #EEE8F5; --ag-ll: #8A5A10; --ag-ll-tint: #FAEDCF;
  --ag-success: #24754E; --ag-assisted: #88600E; --ag-error: #B24846;
  --ag-border-strong: #7A878C; --ag-studio-tint: #ECE9DF;
  --ag-elev-1: 0 1px 2px rgb(23 43 40 / .06); --ag-elev-2: 0 4px 18px rgb(23 43 40 / .0625); --ag-elev-3: 0 12px 40px rgb(23 43 40 / .14);
}
[data-theme="light"] { color-scheme: light; }
[data-theme="dark"]  { color-scheme: dark; }

/* ================= GAME THEME LAYER =================
   A game theme only re-points Layer-4 semantic tokens. Components never change.
   Put data-game on <body> (whole section) or on any wrapper (one card). */

/* Daily Puzzles hub (daily_mind_design_v1). Section accent = Double Meaning teal (the hub's progress/primary colour). */
[data-game="puzzles"] {
  --ag-c-accent: var(--ag-dm);
  --ag-c-accent-tint: var(--ag-dm-tint);
  --ag-c-on-accent: var(--ag-surface);    /* white on #19786F 5.31:1; dark: #222A2E on #87D5C6 8.59:1 */
  --ag-c-panel: var(--ag-dm-tint);
  --ag-c-link-underline: var(--ag-dm);
  --ag-c-focus: var(--ag-tl);
  --ag-illus-1: var(--ag-dm); --ag-illus-2: var(--ag-tl); --ag-illus-3: var(--ag-lu); --ag-illus-4: var(--ag-ll);
}
/* Puzzle sub-themes: inside the puzzles section, one per daily game (tokens dm/tl/lu/ll). */
[data-puzzle="double-meaning"] { --ag-c-accent: var(--ag-dm); --ag-c-accent-tint: var(--ag-dm-tint); --ag-c-panel: var(--ag-dm-tint); --ag-c-link-underline: var(--ag-dm); }
[data-puzzle="timeline"]       { --ag-c-accent: var(--ag-tl); --ag-c-accent-tint: var(--ag-tl-tint); --ag-c-panel: var(--ag-tl-tint); --ag-c-link-underline: var(--ag-tl); }
[data-puzzle="lineup"]         { --ag-c-accent: var(--ag-lu); --ag-c-accent-tint: var(--ag-lu-tint); --ag-c-panel: var(--ag-lu-tint); --ag-c-link-underline: var(--ag-lu); }
[data-puzzle="letter-ladder"]  { --ag-c-accent: var(--ag-ll); --ag-c-accent-tint: var(--ag-ll-tint); --ag-c-panel: var(--ag-ll-tint); --ag-c-link-underline: var(--ag-ll); }
[data-puzzle] { --ag-c-on-accent: var(--ag-surface); }

/* Evolution (/evolution/): RESERVED SLOT, intentionally empty. Not designed.
   When its design exists, add ONLY Layer-4 overrides here (accent, accent-tint, on-accent, panel,
   link-underline, illus-1..4), each with a contrast row in contrast-table.md. Until then it inherits the studio theme. */
[data-game="evolution"] { }

/* generated from data/site.json design switches (decided Nov 28, 2026: neutral + serif + Games).
   The teal alternative is unused; if ever re-enabled it must use app tokens (--ag-dm), not brand/README colours. */
html[data-display-font="system"] { --ag-font-serif: var(--ag-font-sans); }
html[data-studio-theme="teal"] {
  --ag-c-accent: var(--ag-dm);
  --ag-c-accent-tint: var(--ag-dm-tint);
  --ag-c-on-accent: var(--ag-surface);
  --ag-c-link-underline: var(--ag-dm);
}
