/* ReSurge Academy: the academic layer. Loads last. Paper, ink, a serif voice, marginalia.
   Fraunces carries titles, Newsreader carries reading, Inter carries the interface, Geist Mono carries readings. */

/* ---------- paper ---------- */
body {
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .25  0 0 0 0 .15  0 0 0 .05 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  font-feature-settings: "ss01", "cv11";
}
::selection { background: var(--selection-bg); color: var(--selection-ink); }

/* ---------- the serif voice ---------- */
h1, h2, .t-display, .page-head h1, .chapter h1, .quiz-result__h, .auth-deep__head, .deck-slide__title, .deck-cover__title {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 50;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.t-display { font-weight: 650; letter-spacing: -0.025em; }
h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.005em; }
h1 em, h2 em, .t-display em { font-style: italic; font-weight: 500; color: var(--brand-ink); }

/* reading column: a book face, slightly larger, old-style figures in prose only */
.prose, .chapter-analogy__text, .chapter-sec p, .chapter-sec li, .chapter-head__tag, .page-head__lede, .learn-pane__blurb, .home-next__tag, .auth-deep__lede {
  font-family: var(--font-serif);
  font-optical-sizing: auto;
}
.prose, .chapter-sec { font-size: 1.125rem; line-height: 1.7; font-variant-numeric: oldstyle-nums proportional-nums; }
.chapter-head__tag, .page-head__lede, .auth-deep__lede { font-style: italic; font-size: 1.1875rem; }
.chapter-head__tag, .page-head__lede { color: var(--ink-2); }
.auth-deep .auth-deep__lede { color: var(--on-deep-2); }

/* labels set like a journal: small caps, tracked */
th, .chapter-crumb, .chapter-head__meta, .learn-modrow__n, .home-next__meta, .quiz-progress__text, .chip {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
}
th { font-size: var(--fs-14); text-transform: none; }
.num, .chapter-head__idx, .learn-ladder__idx, .quiz-review__n, .chapter-pearls__n, .chapter-answer__n { font-variant-caps: normal; font-variant-numeric: tabular-nums lining-nums slashed-zero; }

/* ---------- running head and rules ---------- */
.page-head, .chapter-head__meta + h1 { position: relative; }
.page-head { padding-bottom: var(--sp-6); border-bottom: 1px solid var(--line); }
.page-head::after {
  content: ""; position: absolute; left: 0; bottom: -4px; width: 100%;
  border-bottom: 1px solid var(--line);
}
.chapter-head__idx {
  font-family: var(--font-display); font-weight: 400; font-style: italic;
  color: var(--brand); font-size: 1.5rem; line-height: 1;
}

/* section headings numbered in the margin, like a monograph */
.chapter__main { counter-reset: sec; }
.chapter-sec { counter-increment: sec; position: relative; }
.chapter-sec > h2, .chapter-sec > h3 { position: relative; }
.chapter-sec > h2::before, .chapter-sec > h3::before {
  content: "\00A7\00A0" counter(sec);
  display: block; margin-bottom: var(--sp-1);
  font-family: var(--font-mono); font-size: var(--fs-12); font-weight: 500; letter-spacing: 0.08em;
  color: var(--brand); font-style: normal;
}
@media (min-width: 1200px) {
  .chapter-sec > h2::before, .chapter-sec > h3::before {
    position: absolute; right: calc(100% + var(--sp-6)); top: 0.45em; margin: 0; white-space: nowrap;
  }
}

/* the analogy reads as a set-off epigraph with a drop cap */
.chapter-analogy { border-left: 4px solid var(--brand); border-radius: var(--r-2) var(--r-5) var(--r-5) var(--r-2); }
.chapter-analogy__text p:first-of-type::first-letter {
  float: left; font-family: var(--font-display); font-weight: 600; font-variation-settings: "SOFT" 100;
  font-size: 3.4em; line-height: 0.82; padding: 0.06em 0.1em 0 0; color: var(--deep-accent);
}

/* pearls as footnote-style marginalia */
.chapter-pearls__n { font-family: var(--font-display); font-style: italic; color: var(--brand); }
.chapter-refs { font-family: var(--font-serif); font-size: var(--fs-14); }

/* ---------- cards on paper ---------- */
.card, .home-next, .quiz-result {
  box-shadow: 0 1px 0 var(--line), 0 10px 30px -18px rgba(45, 30, 18, 0.22);
}
.home-next { border-top: 3px solid var(--brand); }

/* ---------- quiz options as exam-paper choices ---------- */
.quiz-option__l { font-family: var(--font-display); font-style: italic; font-weight: 600; }
.quiz-result__score, .quiz-result__big { font-family: var(--font-display); font-variant-numeric: lining-nums; font-weight: 700; letter-spacing: -0.03em; }

/* ---------- the deep (ink) field: letterpress feel ---------- */
.auth-deep {
  background-image:
    radial-gradient(1200px 500px at 110% -10%, rgba(221, 70, 63, 0.22), transparent 60%),
    radial-gradient(800px 400px at -20% 120%, rgba(221, 70, 63, 0.10), transparent 60%);
}
.auth-deep__head em { color: var(--deep-accent); }

/* ---------- deck: paper slides, ink cover ---------- */
.deck-slide { background: #FDFAF4; }
.deck-slide__title, .deck-cover__title { font-weight: 600; }
.deck-list, .deck-analogy__text p { font-family: var(--font-serif); }

/* ---------- motion respect ---------- */
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* ---------- dark: warm ink, grain softer ---------- */
:root[data-theme="dark"] body { background-blend-mode: soft-light; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body { background-blend-mode: soft-light; } }

/* headings receive focus on route change for screen readers; no ring needed */
h1[tabindex="-1"]:focus, h1[tabindex="-1"]:focus-visible, h2[tabindex="-1"]:focus-visible { outline: none; box-shadow: none; }

/* rail carries the full mark, large enough to read */
.rail__logo .logo__img { height: 68px; }
.rail__logo .logo { gap: 12px; }
.logo__word { font-family: var(--font-display); font-style: italic; font-weight: 500; font-size: 20px; letter-spacing: 0; }

/* one-liner set as a pull quote */
.home-line .quote, .quote {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: clamp(1.375rem, 2.2vw, 1.75rem); line-height: 1.3; letter-spacing: -0.01em; max-width: 30ch;
}
.home-line .quote::before { content: "\201C"; color: var(--brand); margin-right: 0.05em; }
.home-line .quote::after { content: "\201D"; color: var(--brand); margin-left: 0.02em; }
