/* ==========================================================================
   LookLoud design tokens
   --------------------------------------------------------------------------
   Layer 1  Primitives  raw values. Change brand colours here.
   Layer 2  Semantic    what a value is FOR. Components only use these.
   Layer 3  Tones       colour themes a section or card can opt into.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* ---------- 1. Primitives: colour scales ---------- */

  /* Brand yellow (app icon background) */
  --yellow-50:  #FFF9EB;
  --yellow-100: #FFF0C7;
  --yellow-200: #FFE296;
  --yellow-300: #FFCF5C;
  --yellow-400: #FFB627; /* brand */
  --yellow-500: #F29D00;
  --yellow-600: #C27C00;

  /* Brand navy (eyes and waves) */
  --navy-50:  #EEF0FA;
  --navy-100: #DADEF3;
  --navy-200: #B3BAE4;
  --navy-300: #8490CE;
  --navy-400: #5361AD;
  --navy-500: #34418C;
  --navy-600: #1F2A6B; /* brand */
  --navy-700: #182157;
  --navy-800: #111842;
  --navy-900: #0B102C;

  /* Supporting accents for sections, cards and illustrations */
  --coral-100: #FFE4DB;
  --coral-300: #FFA68A;
  --coral-400: #FF7F5C;
  --coral-700: #8A2A12;

  --sky-100: #DFEEFF;
  --sky-300: #93C4FF;
  --sky-400: #5AA2FF;
  --sky-700: #0F4A8A;

  --mint-100: #DCF5EA;
  --mint-300: #82D9B4;
  --mint-400: #44C08F;
  --mint-700: #145C40;

  --lilac-100: #EEE8FF;
  --lilac-300: #BCA9FF;
  --lilac-400: #9479F6;
  --lilac-700: #47309E;

  /* Neutrals (warm, very light) */
  --white:     #FFFFFF;
  --stone-50:  #FBF9F6;
  --stone-100: #F4F0EA;
  --stone-200: #E6E0D6;
  --stone-500: #6F6A62;

  /* ---------- 1. Primitives: type ---------- */
  /* Lexend was designed to reduce visual stress when reading.
     Atkinson Hyperlegible was designed for low-vision readers. */
  --font-display: "Lexend", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Verdana", system-ui, sans-serif;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Body starts at 18px: larger than usual on purpose. */
  --text-xs:   0.875rem;
  --text-sm:   1rem;
  --text-base: 1.125rem;
  --text-lg:   1.25rem;
  --text-xl:   clamp(1.375rem, 1.2rem + 0.6vw, 1.625rem);
  --text-2xl:  clamp(1.75rem, 1.45rem + 1.2vw, 2.25rem);
  --text-3xl:  clamp(2.125rem, 1.6rem + 2.2vw, 3.25rem);
  --text-4xl:  clamp(2.5rem, 1.7rem + 3.6vw, 4.5rem);

  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-body: 1.6;
  --tracking-tight: -0.02em;
  --tracking-wide: 0.06em;

  /* ---------- 1. Primitives: space, shape, depth, motion ---------- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  --radius-sm: 0.5rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;
  --radius-xl: 2.5rem;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgb(17 24 66 / 0.08);
  --shadow-md: 0 6px 20px rgb(17 24 66 / 0.10);
  --shadow-lg: 0 18px 48px rgb(17 24 66 / 0.14);

  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 500ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  --container: 76rem;
  --container-narrow: 46rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --section-y: clamp(4rem, 3rem + 5vw, 7.5rem);

  /* ---------- 2. Semantic tokens ---------- */
  --color-brand: var(--yellow-400);
  --color-brand-strong: var(--yellow-500);
  --color-brand-soft: var(--yellow-100);
  --color-ink: var(--navy-600);        /* strong UI colour: logo, outlines, dark buttons */
  --color-ink-strong: var(--navy-800);
  --color-on-ink: var(--white);         /* text placed on --color-ink */

  --color-bg: var(--white);
  --color-bg-soft: var(--stone-50);
  --color-bg-muted: var(--stone-100);
  --color-bg-inverse: var(--navy-600);

  --color-text: var(--navy-800);
  --color-text-muted: #3F4566;
  --color-text-inverse: var(--white);
  --color-text-on-brand: var(--navy-800);

  --color-border: var(--stone-200);
  --color-border-strong: var(--navy-200);
  --color-focus: var(--navy-600);
  --color-focus-halo: var(--yellow-300);

  --color-link: var(--navy-500);
  --color-link-hover: var(--navy-700);
  --color-highlight: var(--yellow-200); /* the sentence being read aloud */

  /* Component-level defaults */
  --button-height: 3.25rem;
  --button-height-sm: 2.5rem;
  --button-height-lg: 3.75rem;
  --tap-target: 2.75rem; /* 44px minimum */

  /* ---------- 3. Default tone (overridden by [data-tone]) ---------- */
  --tone-bg: var(--color-bg);
  --tone-surface: var(--color-bg-soft);
  --tone-text: var(--color-text);
  --tone-accent: var(--color-brand);
}

/* ---------- 3. Tones ----------
   Put data-tone="sky" (etc.) on a section or card to recolour it.
   Every pairing keeps text contrast at 7:1 or better. */
[data-tone="yellow"] { --tone-bg: var(--yellow-100); --tone-surface: var(--yellow-50);  --tone-text: var(--navy-800); --tone-accent: var(--yellow-400); }
[data-tone="sky"]    { --tone-bg: var(--sky-100);    --tone-surface: #F0F7FF;           --tone-text: var(--navy-800); --tone-accent: var(--sky-400); }
[data-tone="mint"]   { --tone-bg: var(--mint-100);   --tone-surface: #F0FBF6;           --tone-text: var(--navy-800); --tone-accent: var(--mint-400); }
[data-tone="coral"]  { --tone-bg: var(--coral-100);  --tone-surface: #FFF4F0;           --tone-text: var(--navy-800); --tone-accent: var(--coral-400); }
[data-tone="lilac"]  { --tone-bg: var(--lilac-100);  --tone-surface: #F7F4FF;           --tone-text: var(--navy-800); --tone-accent: var(--lilac-400); }
[data-tone="stone"]  { --tone-bg: var(--stone-100);  --tone-surface: var(--stone-50);   --tone-text: var(--navy-800); --tone-accent: var(--navy-600); }
[data-tone="navy"]   { --tone-bg: var(--navy-600);   --tone-surface: var(--navy-500);   --tone-text: var(--white);    --tone-accent: var(--yellow-400); }

/* ==========================================================================
   Dark theme
   Follows the phone or computer setting, unless the visitor picks
   Light or Dark in Reading options (html[data-theme]).
   light-dark() picks the first value in light mode and the second in dark.
   Browsers without light-dark() keep the light theme above.
   ========================================================================== */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

@supports (color: light-dark(#000, #fff)) {
  :root {
    --color-bg:           light-dark(var(--white),     #0D1130);
    --color-bg-soft:      light-dark(var(--stone-50),  #131839);
    --color-bg-muted:     light-dark(var(--stone-100), #1C2250);
    --color-bg-inverse:   light-dark(var(--navy-600),  #1C2250);
    --color-text:         light-dark(var(--navy-800),  #F4F1EA);
    --color-text-muted:   light-dark(#3F4566,          #C6CAE4);
    --color-ink:          light-dark(var(--navy-600),  #F4F1EA);
    --color-ink-strong:   light-dark(var(--navy-800),  var(--white));
    --color-on-ink:       light-dark(var(--white),     var(--navy-900));
    --color-border:       light-dark(var(--stone-200), #2D346B);
    --color-border-strong:light-dark(var(--navy-200),  #5A64A8);
    --color-focus:        light-dark(var(--navy-600),  var(--yellow-300));
    --color-focus-halo:   light-dark(var(--yellow-300), rgb(255 207 92 / 0.3));
    --color-link:         light-dark(var(--navy-500),  var(--sky-300));
    --color-link-hover:   light-dark(var(--navy-700),  var(--sky-100));
    --color-highlight:    light-dark(var(--yellow-200), #5A4510);
    --shadow-md: 0 6px 20px light-dark(rgb(17 24 66 / 0.10), rgb(0 0 0 / 0.45));
  }

  [data-tone="yellow"] { --tone-bg: light-dark(var(--yellow-100), #392C08); --tone-surface: light-dark(var(--yellow-50), #2A2106); --tone-text: light-dark(var(--navy-800), var(--yellow-50)); }
  [data-tone="sky"]    { --tone-bg: light-dark(var(--sky-100), #0E2747);    --tone-surface: light-dark(#F0F7FF, #0A1D36);           --tone-text: light-dark(var(--navy-800), #F0F7FF); }
  [data-tone="mint"]   { --tone-bg: light-dark(var(--mint-100), #0C3022);   --tone-surface: light-dark(#F0FBF6, #08241A);           --tone-text: light-dark(var(--navy-800), #F0FBF6); }
  [data-tone="coral"]  { --tone-bg: light-dark(var(--coral-100), #3F170D);  --tone-surface: light-dark(#FFF4F0, #2F1009);           --tone-text: light-dark(var(--navy-800), #FFF4F0); }
  [data-tone="lilac"]  { --tone-bg: light-dark(var(--lilac-100), #241A52);  --tone-surface: light-dark(#F7F4FF, #1A133D);           --tone-text: light-dark(var(--navy-800), #F7F4FF); }
  [data-tone="stone"]  { --tone-bg: light-dark(var(--stone-100), #131839);  --tone-surface: light-dark(var(--stone-50), #0D1130);   --tone-text: light-dark(var(--navy-800), #F4F1EA); --tone-accent: light-dark(var(--navy-600), var(--yellow-400)); }
  [data-tone="navy"]   { --tone-bg: light-dark(var(--navy-600), #161C4A);   --tone-surface: light-dark(var(--navy-500), #1C2250); }
}

/* ==========================================================================
   More contrast: follows the system setting (Increase contrast).
   ========================================================================== */
@media (prefers-contrast: more) {
  :root {
    --color-text-muted: var(--color-text);
    --color-border: var(--color-border-strong);
  }
}

/* ==========================================================================
   Reading options set by the visitor (see design-system/prefs.js)
   ========================================================================== */
:root[data-text="2"] { font-size: 112.5%; }
:root[data-text="3"] { font-size: 125%; }
:root[data-text="4"] { font-size: 150%; }

@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="on"]) {
    --duration-fast: 0ms;
    --duration-base: 0ms;
    --duration-slow: 0ms;
  }
}
:root[data-motion="off"] {
  --duration-fast: 0ms;
  --duration-base: 0ms;
  --duration-slow: 0ms;
}
