/* ============================================================
   base.css — design tokens, reset, typography
   The look-and-feel knobs live here. Per-chapter mood files in
   /css/<chapter-id>.css override the CSS variables to shift
   palette, pacing, and grain without touching component CSS.
   ============================================================ */

:root {
  /* ---- palette (default — calm/warm cinematic) ---- */
  --ink: #ece7da;                 /* warm off-white text */
  --paper: #0a0908;               /* deep warm ink black */
  --paper-soft: #15110d;          /* one step up from paper */
  --paper-edge: #1f1a13;          /* card / chapter edge */
  --accent: #c9a777;              /* warm gold/clay */
  --mute: rgba(236, 231, 218, 0.55);
  --rule: rgba(236, 231, 218, 0.15);

  /* ---- atmosphere ---- */
  --grain-opacity: 0.045;
  --vignette-strength: 0.35;

  /* ---- typography ---- */
  --font-display: 'Fraunces', 'Charter', 'Cambria', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --tracking-eyebrow: 0.18em;
  --tracking-display: -0.015em;

  /* ---- motion ---- */
  --reveal-distance: 28px;
  --reveal-duration: 900ms;
  --reveal-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --hover-ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- layout ---- */
  --container: min(1280px, 100% - 4rem);
  --container-narrow: min(680px, 100% - 4rem);
  --container-wide: min(1600px, 100% - 2rem);
  --rhythm: clamp(2rem, 5vw, 4rem);
}

/* ---- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, picture, video { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }

/* ---- root surface ---- */
html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  min-height: 100dvh;
  background: var(--paper);
  overflow-x: hidden;
  position: relative;
}

/* film-grain overlay covers the whole page; per-day files can dial intensity */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.7'/></svg>");
  background-size: 240px 240px;
}

/* ---- typography primitives ---- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--accent);
  display: inline-block;
}

.display {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: normal;
  letter-spacing: var(--tracking-display);
  line-height: 0.98;
  color: var(--ink);
  margin: 0;
}

.display--xl   { font-size: clamp(3rem, 9vw, 7.5rem); }
.display--lg   { font-size: clamp(2.4rem, 6vw, 5rem); }
.display--md   { font-size: clamp(1.8rem, 4vw, 3rem); }

.dek {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.2rem, 1.8vw, 1.6rem);
  line-height: 1.4;
  color: var(--mute);
  max-width: 30ch;
}

.prose {
  font-family: var(--font-body);
  font-weight: 350;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink);
  max-width: 38ch;
}

.caption {
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 350;
  line-height: 1.45;
  color: var(--mute);
  letter-spacing: 0.005em;
}

.timestamp {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--mute);
}

/* ---- selection ---- */
::selection {
  background: var(--accent);
  color: var(--paper);
}

/* ---- containers ---- */
.container        { width: var(--container); margin-inline: auto; }
.container-narrow { width: var(--container-narrow); margin-inline: auto; }
.container-wide   { width: var(--container-wide); margin-inline: auto; }

/* ---- screen reader only ---- */
.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;
}
