/* Wave 3 reading pages. Local files, no external fonts.
   Tokens match rehanvaid-ai/assets/tokens.css light theme. */

:root {
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --sans: "Segoe UI", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, Consolas, "Courier New", monospace;
  --bg: #f4f0e6;
  --header-bg: rgba(244, 240, 230, 0.97);
  --surface: #fbf8f2;
  --ink: #1c2618;
  --muted: #3d4e36;
  --line: #d2cbb8;
  --brass: #6a4e16;
  --brass-ink: #fbf8f2;
  --focus: #6a4e16;
  --selection-bg: #cfd8b9;
  --selection-ink: #283625;
  --caret: #405a33;
  --scrollbar: #8a9a72;
  --shell: 74rem;
  --measure: 68ch;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  color-scheme: light;
}

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

html { scroll-behavior: smooth; scrollbar-color: var(--scrollbar) var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.125rem/1.65 var(--serif);
  overflow-wrap: break-word;
  caret-color: var(--caret);
}

::selection { background: var(--selection-bg); color: var(--selection-ink); }

[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  transform: translateY(-150%);
  z-index: 40;
  background: var(--brass);
  color: var(--brass-ink);
  padding: 0.55rem 0.8rem;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

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

.skip:focus { transform: none; }

.wrap {
  width: min(var(--shell), calc(100% - 2rem));
  margin-inline: auto;
}

/* Canonical site header. Same structure, text and metrics on every surface. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
}

.site-header-inner {
  width: min(var(--shell), calc(100% - 2rem));
  margin-inline: auto;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0 24px;
}

.site-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
}

.site-monogram { font: italic 400 30px/1 var(--serif); letter-spacing: -0.04em; color: var(--brass); }
.site-name { display: flex; flex-direction: column; font: 400 15px/1.2 var(--sans); letter-spacing: 0.02em; }

.site-nav { display: flex; flex-wrap: wrap; gap: 0 24px; }

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
  font: 400 12px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-nav a:hover { color: var(--brass); }
.site-nav a[aria-current="page"] { text-decoration: underline 1px var(--brass); text-underline-offset: 6px; }

main { padding: var(--space-4) 0 4rem; }

h1, h2, h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.12;
  text-wrap: balance;
}

h1 { font-size: clamp(2.4rem, 5vw, 4.2rem); max-width: 18ch; margin-bottom: 1rem; }

h2 { font-size: clamp(1.7rem, 3vw, 2.3rem); letter-spacing: -0.02em; margin: 2.2rem 0 0.8rem; }

h3 { font-size: 1.35rem; letter-spacing: -0.02em; margin: 1.4rem 0 0.4rem; }

.lede, .prose p, .prose li, .abstract, .variant p {
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.7;
  text-wrap: pretty;
}


p, .prose, .variant, .abstract, .meta, .catalog {
  max-width: var(--measure);
}

.prose p, .variant p, .abstract { margin: 0 0 var(--space-2); }
.prose figure { max-width: 100%; margin: 0 0 var(--space-2); }
.prose svg { display: block; width: 100%; max-width: 100%; height: auto; }
.prose .scale-figure svg { max-width: 30rem; }

.abstract {
  padding: 1rem 0 0.2rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.4rem;
}

.meta {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.35rem 1rem;
  margin: 1.25rem 0 1.5rem;
  padding: 0;
}

.meta div { display: contents; }

.meta dt {
  margin: 0;
  color: var(--muted);
  font: 12px/1.9 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.meta dd { margin: 0; font: 1rem/1.55 var(--serif); font-variant-numeric: tabular-nums lining-nums; }

time { font-variant-numeric: tabular-nums lining-nums; }

.stage, .chip {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--line);
  font: 12px/1.6 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stage-seedling { color: #6b3d28; }
.stage-budding { color: #6a4e16; }
.stage-evergreen { color: #245c32; }

a { color: var(--brass); }

.prose a, .variant a, .references a, .lede a { text-underline-offset: 0.18em; }

.references { padding-left: 1.4rem; max-width: 70ch; }

.references li { margin: 0 0 0.85rem; font: 1rem/1.55 var(--serif); }
.references a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }

.catalog {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.catalog li {
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
}

.catalog a {
  font-family: var(--serif);
  font-size: 1.35rem;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
}
.catalog a:hover { text-decoration: underline; }
.catalog p { margin: 0.25rem 0 0; color: var(--muted); }
.catalog .catalog-more { margin: 0; }
.catalog .note-date { font: 400 13px/1.5 var(--mono); font-variant-numeric: tabular-nums lining-nums; letter-spacing: 0.02em; }
.catalog .catalog-more a { font-size: 1rem; color: var(--brass); text-decoration: underline; text-underline-offset: 0.18em; }

.need-from-rehan {
  display: block;
  margin: 0.8rem 0;
  padding: 0.75rem 0.9rem;
  border: 1px dashed var(--brass);
  background: #fff8e8;
  color: #1c2618;
  font: 0.95rem/1.5 var(--sans);
}

.portrait-empty {
  width: min(12rem, 100%);
  aspect-ratio: 4 / 5;
  border: 1px dashed var(--brass);
  background:
    linear-gradient(#d2cbb8, #d2cbb8) center/100% 1px no-repeat,
    linear-gradient(#d2cbb8, #d2cbb8) center/1px 100% no-repeat,
    var(--surface);
}

figure { margin: 1rem 0; }

/* Canonical site footer. 12px mono, every link a 44px target. */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.25rem max(1rem, calc((100% - var(--shell)) / 2)) 2.5rem;
  color: var(--muted);
  font: 400 12px/1.6 var(--mono);
}

.site-footer p { margin: 0; max-width: 70ch; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.site-footer-stamp { margin-bottom: 0.25rem; }
.site-footer-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 20px; }

/* Every page renders public: unfilled slots and draft-only material never show. */
html[data-render="public"] .need-from-rehan,
html[data-render="public"] .draft-only,
html[data-render="public"] [data-slot="unfilled"] {
  display: none !important;
}

@media (max-width: 680px) {
  .site-header-inner { flex-direction: column; align-items: stretch; padding: 8px 0 4px; }
  .site-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
  .site-nav a { justify-content: flex-start; }
}

@media (max-width: 720px) {
  h1 { max-width: none; }
  .meta { grid-template-columns: 1fr; gap: 0 1rem; }
  .meta dd { margin-bottom: 0.5rem; }
}

pre { max-width: 100%; overflow-x: auto; white-space: pre-wrap; scrollbar-width: thin; }

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101410;
    --header-bg: rgba(16, 20, 16, 0.97);
    --surface: #1a211b;
    --ink: #f4f0e4;
    --muted: #c5ceb8;
    --line: #3e4c3c;
    --brass: #f0d48a;
    --brass-ink: #1a160c;
    --focus: #f0d48a;
    --selection-bg: #d8c797;
    --selection-ink: #171c18;
    --caret: #f0d48a;
    --scrollbar: #5f6b4f;
  }
  .stage-seedling { color: #f0c2a8; }
  .stage-budding { color: #f0d48a; }
  .stage-evergreen { color: #b7e0c2; }
  .need-from-rehan { background: #2a2418; color: #f4f0e4; }
}

svg text { fill: currentColor; }

@media print {
  @page { margin: 16mm; }
  :root {
    color-scheme: light;
    --bg: #fff;
    --surface: #fff;
    --ink: #111;
    --muted: #222;
    --line: #bbb;
    --brass: #111;
    --brass-ink: #fff;
    --focus: #111;
  }
  body { background: #fff; color: #111; }
  .site-header, nav, .draft-only, .skip, .site-footer { display: none !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; }
}

.recording-empty {
  width: min(28rem, 100%);
  aspect-ratio: 16 / 9;
  border: 1px dashed var(--brass);
  background:
    linear-gradient(#d2cbb8, #d2cbb8) center/100% 1px no-repeat,
    linear-gradient(#d2cbb8, #d2cbb8) center/1px 100% no-repeat,
    var(--surface);
}

.entry a, a.jump {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
/* A jump link inside running text keeps the line box: the padding gives the target its height. */
.prose p > a.jump, .lede > a.jump { display: inline; padding-block: 0.7em; }

@media (prefers-reduced-motion: no-preference) {
  .catalog a, .site-nav a { transition: color 120ms ease; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
