/* === DESIGN TOKENS === */
:root, [data-theme="light"] {
  /* Type scale (fluid) */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.375rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.4rem + 2.4vw, 3.25rem);
  --text-3xl: clamp(2.5rem, 1.6rem + 3.5vw, 4.25rem);
  --text-hero: clamp(2.75rem, 1rem + 5.5vw, 5.5rem);

  /* 4px spacing system */
  --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;

  /* COLOR — Editorial / Institutional Research Firm */
  /* Surfaces: warm off-white, cream */
  --color-bg: #f8f6f1;          /* warm cream background */
  --color-surface: #ffffff;
  --color-surface-2: #fbfaf6;
  --color-surface-offset: #f1eee6;
  --color-surface-offset-2: #e9e5db;
  --color-divider: #d9d4c5;
  --color-border: #c5bfae;

  /* Text */
  --color-text: #1c1f2e;        /* deep navy-black */
  --color-text-muted: #5a5f70;
  --color-text-faint: #8e93a3;
  --color-text-inverse: #f8f6f1;

  /* Primary — deep navy */
  --color-primary: #1e3a5f;
  --color-primary-hover: #15294a;
  --color-primary-active: #0d1d36;
  --color-primary-highlight: #d6dde6;

  /* Accent — burnt sienna for editorial pull-quotes / micro-accents */
  --color-accent: #b54a2c;
  --color-accent-hover: #9a3d22;

  /* Data viz palette (for charts only) */
  --color-data-1: #1e3a5f;  /* primary navy */
  --color-data-2: #b54a2c;  /* sienna */
  --color-data-3: #4a7c5e;  /* sage green */
  --color-data-4: #c19a3a;  /* mustard */
  --color-data-5: #6b5b8c;  /* dusty plum */

  --color-success: #4a7c5e;
  --color-warning: #c19a3a;
  --color-error:   #b54a2c;

  /* Radius — minimal, editorial */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 8px;
  --radius-full: 9999px;

  /* Shadows — subtle, paper-like */
  --shadow-sm: 0 1px 2px rgb(28 31 46 / 0.06);
  --shadow-md: 0 4px 16px rgb(28 31 46 / 0.08);
  --shadow-lg: 0 16px 40px rgb(28 31 46 / 0.12);

  --transition-interactive: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  --content-narrow: 640px;
  --content-default: 920px;
  --content-wide: 1180px;

  --font-display: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

[data-theme="dark"] {
  --color-bg: #14161e;
  --color-surface: #1a1d27;
  --color-surface-2: #20232f;
  --color-surface-offset: #1c1f29;
  --color-surface-offset-2: #25283a;
  --color-divider: #2a2e3d;
  --color-border: #3b3f50;

  --color-text: #e8e6df;
  --color-text-muted: #a3a5b0;
  --color-text-faint: #6c6f7c;
  --color-text-inverse: #14161e;

  --color-primary: #6b9fd6;
  --color-primary-hover: #88b4e0;
  --color-primary-active: #a3c5e8;
  --color-primary-highlight: #2a3850;

  --color-accent: #d97a5a;
  --color-accent-hover: #e89274;

  --color-data-1: #6b9fd6;
  --color-data-2: #d97a5a;
  --color-data-3: #7fb592;
  --color-data-4: #d4b566;
  --color-data-5: #a08bbe;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 16px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 16px 40px rgb(0 0 0 / 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #14161e;
    --color-surface: #1a1d27;
    --color-surface-2: #20232f;
    --color-surface-offset: #1c1f29;
    --color-surface-offset-2: #25283a;
    --color-divider: #2a2e3d;
    --color-border: #3b3f50;
    --color-text: #e8e6df;
    --color-text-muted: #a3a5b0;
    --color-text-faint: #6c6f7c;
    --color-text-inverse: #14161e;
    --color-primary: #6b9fd6;
    --color-primary-hover: #88b4e0;
    --color-primary-active: #a3c5e8;
    --color-primary-highlight: #2a3850;
    --color-accent: #d97a5a;
    --color-accent-hover: #e89274;
    --color-data-1: #6b9fd6;
    --color-data-2: #d97a5a;
    --color-data-3: #7fb592;
    --color-data-4: #d4b566;
    --color-data-5: #a08bbe;
  }
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
       text-rendering: optimizeLegibility; scroll-behavior: smooth; scroll-padding-top: var(--space-20); }
body { min-height: 100dvh; line-height: 1.6; font-family: var(--font-body); font-size: var(--text-base);
       color: var(--color-text); background-color: var(--color-bg);
       font-feature-settings: 'ss01' on, 'cv11' on; }
img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
ul[role="list"], ol[role="list"] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }

h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; text-wrap: balance; letter-spacing: -0.015em; }
p, li, figcaption { text-wrap: pretty; }
a { color: var(--color-primary); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
    text-decoration-color: rgb(30 58 95 / 0.3); }
[data-theme="dark"] a { text-decoration-color: rgb(107 159 214 / 0.4); }
a:hover { text-decoration-color: currentColor; }

::selection { background: var(--color-primary); color: var(--color-text-inverse); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; border-radius: var(--radius-sm); }

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

a, button, [role="button"], input, textarea, select {
  transition: color var(--transition-interactive), background var(--transition-interactive),
              border-color var(--transition-interactive), box-shadow var(--transition-interactive),
              transform var(--transition-interactive);
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
           clip: rect(0,0,0,0); white-space: nowrap; border-width: 0; }

/* Tabular numbers for data */
.tabular { font-variant-numeric: tabular-nums; }
