/* PeptideScope: design tokens (v4, "simpler, faster, for teens").
   ui-ux-pro-max "Minimalism & Swiss": spacious, light-first, one violet accent, amber and red only
   for warnings. Never green, never neon. Fonts: Nunito (headings, rounded) + DM Sans (body/UI).
   Light is the default; prefers-color-scheme: dark switches unless <html data-theme="light">, and
   <html data-theme="light|dark"> always wins. `.force-dark` / `.force-light` pin a subtree.
   Motion: prefers-reduced-motion or <html data-motion="reduce"> collapse durations;
   <html data-motion="full"> is the visitor explicitly opting back in.

   The colour table in docs/ARCHITECTURE.md (v4) is used verbatim. Every other colour token below is
   mixed only from those values (the derived block at the end), so nothing off-palette creeps in.
   Older token names (--accent, --accent-2, --gold-fill …) stay as aliases so every module keeps
   working without edits. */

/* Nunito (OFL 1.1, Vernon Adams / The Nunito Project Authors): wght 600–900, Latin subset. */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 600 900;
  font-display: swap;
  src: url("../assets/fonts/Nunito-latin.woff2") format("woff2-variations"),
       url("../assets/fonts/Nunito-latin.woff2") format("woff2");
}
/* DM Sans (OFL 1.1, The DM Sans Project Authors): wght 400–700 at the 14 pt optical size, Latin subset. */
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../assets/fonts/DMSans-latin.woff2") format("woff2-variations"),
       url("../assets/fonts/DMSans-latin.woff2") format("woff2");
}

:root {
  /* ---------- type ---------- */
  --font-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Nunito", ui-rounded, "SF Pro Rounded", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  /* `--font-mono` and `--font-label` keep their names for the modules that use them: plain DM Sans. */
  --font-mono: var(--font-sans);
  --font-label: var(--font-sans);
  --font-code: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --font-features: "kern", "calt";
  --label-features: "kern", "tnum";

  /* base 17 px; fixed steps for body sizes, fluid only for headings */
  --step--2: 0.8125rem;                                   /* 13 */
  --step--1: 0.9375rem;                                   /* 15 */
  --step-0: 1.0625rem;                                    /* 17 */
  --step-1: 1.25rem;                                      /* 20 */
  --step-2: clamp(1.5rem, 1.38rem + 0.5vw, 1.75rem);      /* 24 → 28 */
  --step-3: clamp(1.875rem, 1.6rem + 1.1vw, 2.5rem);      /* 30 → 40 */
  --step-4: clamp(2.25rem, 1.8rem + 1.9vw, 3.25rem);      /* 36 → 52 */
  --step-5: clamp(2.75rem, 2rem + 3.2vw, 4.5rem);         /* 44 → 72 */

  --leading-tight: 1.1;
  --leading-snug: 1.25;
  --leading: 1.55;
  --leading-loose: 1.7;
  --tracking-tight: -0.02em;
  --tracking-display: -0.015em;
  --tracking-caps: 0.08em;
  --tracking-label: 0.04em;
  --measure: 62ch;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-display: 800;
  --weight-black: 900;

  /* ---------- space (spacious scale: 8 · 12 · 16 · 24 · 32 · 48 · 64 · 96) ---------- */
  --space-3xs: 0.25rem;  /* 4 */
  --space-2xs: 0.5rem;   /* 8 */
  --space-xs: 0.75rem;   /* 12 */
  --space-s: 1rem;       /* 16 */
  --space-m: 1.5rem;     /* 24 */
  --space-l: 2rem;       /* 32 */
  --space-xl: 3rem;      /* 48 */
  --space-2xl: 4rem;     /* 64 */
  --space-3xl: 6rem;     /* 96 */
  --space-fluid-s: clamp(1rem, 0.75rem + 1vw, 1.5rem);
  --space-fluid-m: clamp(1.5rem, 1rem + 2vw, 3rem);
  --section-pad: clamp(4rem, 2.5rem + 5vw, 6rem);
  --gutter: clamp(1rem, 0.4rem + 2.6vw, 2.5rem);           /* 16 px on phones */
  --container: 1200px;
  --container-wide: 1360px;

  /* ---------- shape (16 / 24, pill buttons) ---------- */
  --radius-xs: 8px;
  --radius-s: 12px;
  --radius-m: 16px;
  --radius-l: 24px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --radius-card: 24px;
  --radius-control: 16px;
  --hairline-w: 1px;

  /* ---------- layers ---------- */
  --z-below: -1;
  --z-base: 0;
  --z-stage-canvas: 1;
  --z-stage-hud: 2;
  --z-callouts: 3;
  --z-stage-overlay: 4;
  --z-sticky: 20;
  --z-header: 50;
  --z-disclaimer: 90;
  --z-intro: 100;
  --z-preloader: 105;
  --z-disclaimer-top: 110;
  --z-toast: 120;

  /* ---------- motion (subtle: 150–400 ms, no bounce) ---------- */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --dur-1: 150ms;
  --dur-2: 250ms;
  --dur-3: 400ms;
  --dur-4: 600ms;
  --dur-fade: 200ms;

  /* ---------- layout metrics (main.js refines these from the real header and bar) ---------- */
  --header-h: 72px;
  --disclaimer-h: 40px;
  --stage-h: min(70vh, 760px);

  /* ---------- colour: light (default) — ARCHITECTURE.md v4 table ---------- */
  color-scheme: light;
  --bg: #F7F6FB;
  --surface: #FFFFFF;
  --surface-2: #F0EEF8;
  --line: #E4E1F0;
  --text: #17142B;
  --muted: #5B5873;
  --primary: #6246EA;
  --on-primary: #FFFFFF;
  --primary-soft: #ECE8FF;
  --info: #2563EB;
  --warn: #B45309;
  --warn-bg: #FFF4E5;
  --danger: #D92D20;
  --danger-bg: #FDECEA;
  --artery: #E5484D;
  --vein: #3E63DD;
  --drug: #6246EA;
  --focus: #6246EA;
  /* shadows: soft, ink-tinted, never glowing */
  --shadow-ink: 23 20 43;
  --shadow-1: 0 1px 2px rgb(var(--shadow-ink) / 0.06);
  --shadow-2: 0 1px 2px rgb(var(--shadow-ink) / 0.05), 0 8px 24px -12px rgb(var(--shadow-ink) / 0.16);
  --shadow-3: 0 2px 4px rgb(var(--shadow-ink) / 0.05), 0 24px 56px -24px rgb(var(--shadow-ink) / 0.28);
  --scrim: rgb(23 20 43 / 0.48);
}

/* ---------- colour: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0F0E17;
    --surface: #17162A;
    --surface-2: #1F1D35;
    --line: #2C2A45;
    --text: #F3F2FA;
    --muted: #A9A6C4;
    --primary: #9D8CFF;
    --on-primary: #17142B;
    --primary-soft: #2A2550;
    --info: #7AA2FF;
    --warn: #F5B454;
    --warn-bg: #3A2A12;
    --danger: #FF7A70;
    --danger-bg: #3D1714;
    --artery: #FF6369;
    --vein: #7B93FF;
    --drug: #B3A4FF;
    --focus: #B3A4FF;
    --shadow-ink: 0 0 0;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 1px 2px rgb(0 0 0 / 0.35), 0 10px 28px -14px rgb(0 0 0 / 0.6);
    --shadow-3: 0 2px 4px rgb(0 0 0 / 0.35), 0 28px 64px -28px rgb(0 0 0 / 0.75);
    --scrim: rgb(5 4 10 / 0.66);
  }
}
:root[data-theme="dark"],
.force-dark {
  color-scheme: dark;
  --bg: #0F0E17;
  --surface: #17162A;
  --surface-2: #1F1D35;
  --line: #2C2A45;
  --text: #F3F2FA;
  --muted: #A9A6C4;
  --primary: #9D8CFF;
  --on-primary: #17142B;
  --primary-soft: #2A2550;
  --info: #7AA2FF;
  --warn: #F5B454;
  --warn-bg: #3A2A12;
  --danger: #FF7A70;
  --danger-bg: #3D1714;
  --artery: #FF6369;
  --vein: #7B93FF;
  --drug: #B3A4FF;
  --focus: #B3A4FF;
  --shadow-ink: 0 0 0;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-2: 0 1px 2px rgb(0 0 0 / 0.35), 0 10px 28px -14px rgb(0 0 0 / 0.6);
  --shadow-3: 0 2px 4px rgb(0 0 0 / 0.35), 0 28px 64px -28px rgb(0 0 0 / 0.75);
  --scrim: rgb(5 4 10 / 0.66);
}
.force-light {
  color-scheme: light;
  --bg: #F7F6FB;
  --surface: #FFFFFF;
  --surface-2: #F0EEF8;
  --line: #E4E1F0;
  --text: #17142B;
  --muted: #5B5873;
  --primary: #6246EA;
  --on-primary: #FFFFFF;
  --primary-soft: #ECE8FF;
  --info: #2563EB;
  --warn: #B45309;
  --warn-bg: #FFF4E5;
  --danger: #D92D20;
  --danger-bg: #FDECEA;
  --artery: #E5484D;
  --vein: #3E63DD;
  --drug: #6246EA;
  --focus: #6246EA;
  --shadow-ink: 23 20 43;
  --shadow-1: 0 1px 2px rgb(var(--shadow-ink) / 0.06);
  --shadow-2: 0 1px 2px rgb(var(--shadow-ink) / 0.05), 0 8px 24px -12px rgb(var(--shadow-ink) / 0.16);
  --shadow-3: 0 2px 4px rgb(var(--shadow-ink) / 0.05), 0 24px 56px -24px rgb(var(--shadow-ink) / 0.28);
  --scrim: rgb(23 20 43 / 0.48);
}

/* ---------- derived tokens and aliases (declared wherever a palette is, so subtrees pinned with
   .force-dark / .force-light derive from their own base colours) ---------- */
:root,
.force-dark,
.force-light {
  --bg-2: var(--surface-2);
  --surface-3: color-mix(in srgb, var(--surface-2) 55%, var(--line));
  --surface-glass: color-mix(in srgb, var(--surface) 90%, transparent);
  --line-strong: color-mix(in srgb, var(--line) 55%, var(--muted));
  --line-faint: color-mix(in srgb, var(--line) 55%, transparent);
  --text-2: color-mix(in srgb, var(--text) 80%, var(--muted));
  --primary-hover: color-mix(in srgb, var(--primary) 88%, var(--text));
  --primary-line: color-mix(in srgb, var(--primary) 38%, transparent);
  --warn-soft: var(--warn-bg);
  --warn-line: color-mix(in srgb, var(--warn) 40%, transparent);
  --danger-soft: var(--danger-bg);
  --danger-line: color-mix(in srgb, var(--danger) 40%, transparent);
  --info-soft: color-mix(in srgb, var(--info) 12%, var(--surface));
  --info-line: color-mix(in srgb, var(--info) 38%, transparent);
  /* text-safe inks: in the light theme --danger (4.2:1 on --danger-bg) and --warn (4.4:1 on
     --surface-2) are a touch light for small text, so small text uses these (≥ 5.2:1 everywhere). */
  --danger-ink: color-mix(in srgb, var(--danger) 85%, var(--text));
  --warn-ink: color-mix(in srgb, var(--warn) 85%, var(--text));
  --info-ink: color-mix(in srgb, var(--info) 85%, var(--text));
  --neutral: var(--muted);
  --neutral-soft: var(--surface-2);
  --neutral-line: var(--line);
  --focus-halo: color-mix(in srgb, var(--focus) 24%, transparent);

  /* aliases kept for modules written against the earlier palettes */
  --accent: var(--primary);
  --accent-2: color-mix(in srgb, var(--primary) 70%, var(--surface));
  --accent-ink: var(--on-primary);
  --accent-soft: var(--primary-soft);
  --accent-line: var(--primary-line);
  --gold-fill: var(--primary);
  --gold-fill-hover: var(--primary-hover);
  --gold-rule: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent);
  --sheen: transparent;
  --glow-accent: 0 0 0 1px var(--primary-line);
  --glow-soft: var(--shadow-2);
  --glow-text: none;

  /* status (never green): approved = calm blue, in trials = violet, research chemical = amber */
  --status-approved: var(--info);
  --status-approved-soft: var(--info-soft);
  --status-approved-line: var(--info-line);
  --status-trials: var(--primary);
  --status-trials-soft: var(--primary-soft);
  --status-trials-line: var(--primary-line);
  --status-research: var(--warn);
  --status-research-soft: var(--warn-bg);
  --status-research-line: var(--warn-line);

  --stage-bg:
    radial-gradient(70% 60% at 50% 42%, var(--surface) 0%, transparent 72%),
    linear-gradient(180deg, var(--surface-2) 0%, var(--bg) 100%);
  --grid-line: var(--line-faint);
  --skeleton-a: var(--surface-2);
  --skeleton-b: color-mix(in srgb, var(--surface-2) 50%, var(--line));
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) {
    --dur-1: 1ms;
    --dur-2: 1ms;
    --dur-3: 1ms;
    --dur-4: 1ms;
    --dur-fade: 100ms;
  }
}
:root[data-motion="reduce"] {
  --dur-1: 1ms;
  --dur-2: 1ms;
  --dur-3: 1ms;
  --dur-4: 1ms;
  --dur-fade: 100ms;
}
