/* base.css — design tokens + reset */
:root {
  /* 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);
  --text-hero: clamp(3rem, 0.5rem + 7vw, 7.5rem);

  /* Spacing 4px base */
  --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 */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;

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

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 1040px;
  --content-wide: 1240px;

  /* Fonts — Fraunces (serif display) + Inter (body) + JetBrains Mono (label) */
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* LIGHT — warm paper, deep ink, olive accent */
:root,
[data-theme='light'] {
  --color-bg: #f5f1e8;
  --color-surface: #faf6ec;
  --color-surface-2: #fdfaf2;
  --color-surface-offset: #ece6d4;
  --color-divider: #d9d2bd;
  --color-border: #c8c0a7;

  --color-text: #1c1a14;
  --color-text-muted: #6b6450;
  --color-text-faint: #a8a18a;
  --color-text-inverse: #faf6ec;

  --color-primary: #4a5d23;          /* olive — "nutritious" */
  --color-primary-hover: #3a4a1b;
  --color-primary-active: #2c3815;
  --color-primary-highlight: #d8dcc4;

  --color-accent: #b84a1d;           /* warning paprika for "junk media" */
  --color-accent-highlight: #efd7c8;

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

  --noise-opacity: 0.04;
}

[data-theme='dark'] {
  --color-bg: #14130f;
  --color-surface: #1b1a16;
  --color-surface-2: #211f1a;
  --color-surface-offset: #26241e;
  --color-divider: #2f2c25;
  --color-border: #3d3930;

  --color-text: #ece5cf;
  --color-text-muted: #8a836f;
  --color-text-faint: #5a5546;
  --color-text-inverse: #14130f;

  --color-primary: #a3b977;
  --color-primary-hover: #b9cf8b;
  --color-primary-active: #c8de9c;
  --color-primary-highlight: #2c3719;

  --color-accent: #e08658;
  --color-accent-highlight: #3a261b;

  --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 18px 40px rgba(0, 0, 0, 0.55);

  --noise-opacity: 0.06;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #14130f;
    --color-surface: #1b1a16;
    --color-surface-2: #211f1a;
    --color-surface-offset: #26241e;
    --color-divider: #2f2c25;
    --color-border: #3d3930;
    --color-text: #ece5cf;
    --color-text-muted: #8a836f;
    --color-text-faint: #5a5546;
    --color-text-inverse: #14130f;
    --color-primary: #a3b977;
    --color-primary-hover: #b9cf8b;
    --color-primary-active: #c8de9c;
    --color-primary-highlight: #2c3719;
    --color-accent: #e08658;
    --color-accent-highlight: #3a261b;
  }
}

/* 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-16);
}

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", "cv11";
  transition: background-color 400ms ease, color 400ms ease;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }

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

p, li, figcaption { text-wrap: pretty; }
p { max-width: 64ch; }

a { color: inherit; text-decoration: none; }

::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);
}

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

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

@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;
  }
}

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

/* Paper grain overlay — gives the page a calm tactile feel */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.6'/></svg>");
  mix-blend-mode: multiply;
}
[data-theme='dark'] body::before { mix-blend-mode: screen; }
