/* Atelier Cthulhu design tokens: "archive and abyss".
   Every text/background pair is at least 4.5:1, borders and focus at least 3:1.
   design-system/atelier-cthulhu/MASTER.md lists the measured ratios. */

:root {
  color-scheme: light dark;

  /* Color: archive paper (light) */
  --color-bg: #F3ECDD;
  --color-surface: #FBF7EE;
  --color-surface-sunken: #EAE0CB;
  --color-ink: #1F2421;
  --color-muted: #5B615A;
  --color-line: #D9CDB5;
  --color-line-strong: #857F70;
  --color-primary: #1F4F4A;
  --color-primary-hover: #173D39;
  --color-primary-soft: #DCE7E0;
  --color-on-primary: #FBF7EE;
  --color-accent: #8A5A12;
  --color-accent-strong: #6E470B;
  --color-accent-soft: #F2E3C4;
  --color-danger: #8C2F2A;
  --color-danger-hover: #72241F;
  --color-danger-soft: #F4DDD8;
  --color-on-danger: #FBF7EE;
  --color-focus: #8A5A12;
  /* Paper grain: a 160px SVG noise tile, ink-colored at low alpha. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .12 0 0 0 0 .12 0 0 0 0 .12 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  /* Typography */
  --font-display: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1.0625rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: clamp(1.75rem, 1.45rem + 1.3vw, 2.25rem);
  --text-3xl: clamp(2.25rem, 1.7rem + 2.4vw, 3.25rem);
  --text-display: clamp(2.5rem, 1.6rem + 4.2vw, 4.5rem);
  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-body: 1.6;
  --tracking-caps: 0.08em;
  --measure: 68ch;

  /* Spacing (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --gutter: clamp(1rem, 0.6rem + 2vw, 2.5rem);
  --page-max: 76rem;

  /* Radius */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 8px;
  --radius-pill: 999px;

  /* Shadow: paper resting on paper */
  --shadow-sm: 0 1px 0 rgb(31 36 33 / 0.06), 0 1px 3px rgb(31 36 33 / 0.06);
  --shadow-md: 0 1px 0 rgb(31 36 33 / 0.05), 0 8px 24px -8px rgb(31 36 33 / 0.18);

  /* Motion */
  --duration-instant: 80ms;
  --duration-fast: 140ms;
  --duration-base: 220ms;
  --duration-slow: 360ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Sizing */
  --touch-target: 44px;
  --focus-ring: 3px solid var(--color-focus);
  --focus-offset: 3px;
}

/* Color: abyss (dark), screen only so print stays on white paper */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0E1513;
    --color-surface: #16201D;
    --color-surface-sunken: #111A17;
    --color-ink: #E9E2D0;
    --color-muted: #A9AFA4;
    --color-line: #26332E;
    --color-line-strong: #6F7E77;
    --color-primary: #7FB8A8;
    --color-primary-hover: #9CCABD;
    --color-primary-soft: #1A302B;
    --color-on-primary: #0E1513;
    --color-accent: #D9A84E;
    --color-accent-strong: #D9A84E;
    --color-accent-soft: #2F2512;
    --color-danger: #E8968A;
    --color-danger-hover: #F0ADA3;
    --color-danger-soft: #36201C;
    --color-on-danger: #0E1513;
    --color-focus: #D9A84E;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .91 0 0 0 0 .91 0 0 0 0 .91 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --shadow-sm: 0 1px 0 rgb(0 0 0 / 0.4);
    --shadow-md: 0 1px 0 rgb(0 0 0 / 0.4), 0 10px 30px -10px rgb(0 0 0 / 0.6);
  }
}
