/* ===== DESIGN TOKENS ===== */

:root {
  /* Fluid type scale */
  --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.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);

  /* Spacing */
  --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;

  /* Radii, transitions */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --transition-interactive: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Widths */
  --content-narrow: 640px;
  --content-default: 780px;
  --content-wide: 1180px;

  /* Fonts */
  --font-body: 'Source Serif 4', 'Iowan Old Style', Georgia, serif;
  --font-display: 'Cabinet Grotesk', 'General Sans', 'Inter', system-ui, sans-serif;
  --font-ui: 'General Sans', 'Inter', system-ui, -apple-system, sans-serif;
}

/* ===== COLOR — cool clinical off-white, deep ink, restrained accent ===== */

:root,
[data-theme='light'] {
  --color-bg: #f5f4ef;
  --color-surface: #fbfaf6;
  --color-surface-2: #f0eee7;
  --color-surface-offset: #ebe8df;
  --color-divider: #d9d5c9;
  --color-border: #c6c2b4;

  --color-text: #1a1c22;
  --color-text-muted: #5b5f6b;
  --color-text-faint: #9a9ea9;
  --color-text-inverse: #f7f5ee;

  /* Deep ink / oxblood accent — clinical, editorial */
  --color-primary: #6a1f2a;
  --color-primary-hover: #8a2733;
  --color-primary-tint: rgba(106, 31, 42, 0.08);

  /* Evidence tier colors */
  --color-strong: #3a5a3e;
  --color-strong-bg: rgba(58, 90, 62, 0.1);
  --color-moderate: #7a5a1a;
  --color-moderate-bg: rgba(122, 90, 26, 0.1);
  --color-emerging: #8a5a2a;
  --color-emerging-bg: rgba(138, 90, 42, 0.1);
  --color-gap: #6b6b6b;
  --color-gap-bg: rgba(107, 107, 107, 0.1);

  --shadow-sm: 0 1px 2px rgba(30, 25, 20, 0.06);
  --shadow-md: 0 6px 18px rgba(30, 25, 20, 0.08);
  --shadow-lg: 0 20px 40px rgba(30, 25, 20, 0.12);
}

[data-theme='dark'] {
  --color-bg: #14161a;
  --color-surface: #1a1d23;
  --color-surface-2: #1f232a;
  --color-surface-offset: #23272e;
  --color-divider: #2c313a;
  --color-border: #3a4049;

  --color-text: #e4e2db;
  --color-text-muted: #9a9ea9;
  --color-text-faint: #676b76;
  --color-text-inverse: #14161a;

  --color-primary: #d4808c;
  --color-primary-hover: #e8969f;
  --color-primary-tint: rgba(212, 128, 140, 0.12);

  --color-strong: #7fb082;
  --color-strong-bg: rgba(127, 176, 130, 0.14);
  --color-moderate: #d4b06a;
  --color-moderate-bg: rgba(212, 176, 106, 0.14);
  --color-emerging: #d4a074;
  --color-emerging-bg: rgba(212, 160, 116, 0.14);
  --color-gap: #9a9ea9;
  --color-gap-bg: rgba(154, 158, 169, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #14161a;
    --color-surface: #1a1d23;
    --color-surface-2: #1f232a;
    --color-surface-offset: #23272e;
    --color-divider: #2c313a;
    --color-border: #3a4049;
    --color-text: #e4e2db;
    --color-text-muted: #9a9ea9;
    --color-text-faint: #676b76;
    --color-text-inverse: #14161a;
    --color-primary: #d4808c;
    --color-primary-hover: #e8969f;
    --color-primary-tint: rgba(212, 128, 140, 0.12);
    --color-strong: #7fb082;
    --color-strong-bg: rgba(127, 176, 130, 0.14);
    --color-moderate: #d4b06a;
    --color-moderate-bg: rgba(212, 176, 106, 0.14);
    --color-emerging: #d4a074;
    --color-emerging-bg: rgba(212, 160, 116, 0.14);
    --color-gap: #9a9ea9;
    --color-gap-bg: rgba(154, 158, 169, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
  }
}

/* ===== RESET ===== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: none;
  -moz-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-16);
}

body {
  min-height: 100dvh;
  line-height: 1.65;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  font-feature-settings: 'kern', 'liga', 'onum';
}

img,
picture,
svg,
canvas,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
  line-height: 1.15;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
}

p,
li,
figcaption {
  text-wrap: pretty;
}

::selection {
  background: var(--color-primary-tint);
  color: var(--color-text);
}

: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;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

button {
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
}

a,
button,
[role='button'] {
  transition: color var(--transition-interactive),
    background var(--transition-interactive),
    border-color var(--transition-interactive),
    opacity var(--transition-interactive);
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--color-text);
  color: var(--color-bg);
  text-decoration: none;
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus {
  top: var(--space-2);
}
