
:root {
  /* Type */
  --serif: 'Literata', Georgia, 'Times New Roman', serif;
  --ui: 'Archivo', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  --heb: 'Frank Ruhl Libre', 'Literata', Georgia, serif;

  /* Set opsz explicitly alongside font-variation-settings, which overrides automatic optical sizing. */
  --lit-normal:  'opsz' 12;
  --lit-mid:     'opsz' 28;
  --lit-display: 'opsz' 60;


  /* Paper and ink */
  --paper: #F1EDE4;
  --ink: #191510;
  /* Check text contrast on the darkest day stock (#EBE6E1). */
  --ink-soft: #5C5449;
  --ink-faint: #6B6459;
  --rule: rgba(25, 21, 16, .14);
  --rule-strong: rgba(25, 21, 16, .28);
  /* Control borders need 3:1 contrast against both the paper and the control wash. */
  --control-edge: rgba(25, 21, 16, .50);
  --control-wash: rgba(25, 21, 16, .03);
  --accent: #32638F;

  /* Literata lacks true small caps. Use tracked uppercase for small labels. */
  --ap-sm: .72rem;   /* Tracked uppercase labels only. */
  --ap-md: .80rem;
  --ap-lg: .90rem;
  --ap-xl: .95rem;

  /* Reading measure */
  --measure: 62ch;
  --step: clamp(14px, 1.7vw, 26px);
  --edge: clamp(20px, 4vw, 64px);
  --shell: 1440px;

  /* The body size cap keeps the 62ch measure within the desktop reading columns. */
  --body-size: clamp(1.14rem, .5vw + 1.03rem, 1.32rem);
  --body-leading: 1.68;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur-fast: 140ms;
  --dur-med: 320ms;
  --dur-slow: 620ms;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
/* Keep smooth scrolling for short hops. js/ui.js jumps long anchors to avoid laying out every chapter along the way. */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
/* Reserve space for the fixed nav and player when the browser scrolls a focused link or button into view. */
html { scroll-padding-top: var(--nav-h, 59px); scroll-padding-bottom: var(--player-h, 134px); }
body, h1, h2, h3, p, figure, blockquote, dl, dd { margin: 0; }
img, svg { display: block; max-width: 100%; }
/* Flatten picture wrappers so the plate image can size directly against its frame. */
picture { display: contents; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

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

/* Base styles */
html, body { min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-variation-settings: var(--lit-normal);
  font-weight: 400;
  font-size: var(--body-size);
  line-height: var(--body-leading);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* js/motion.js updates the background as you scroll. A CSS transition would lag behind. */
  transition: color var(--dur-med) var(--ease);
}

.skip-link {
  position: fixed; top: -100px; left: var(--edge); z-index: 1000;
  background: var(--ink); color: var(--paper);
  padding: .7em 1.1em;
  display: inline-flex; align-items: center; min-height: 44px;
  font-family: var(--ui); font-size: var(--ap-md); font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus { top: 1rem; }

/* Page grid */
.row, .section {
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--edge);
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--step);
}
/* Desktop ranges are margin 1 / 3, text 3 / 9, aside 10 / 13, and wide 3 / 12.
   Use 1 / 7 for those ranges on the six-column grid. */

@media (max-width: 900px) {
  .row, .section { grid-template-columns: repeat(6, 1fr); }
}

/* Flatten render.js’s section wrapper so its children participate in the page grid. */
main { position: relative; }
.section { position: relative; padding-block: clamp(3rem, 7vh, 6rem); scroll-margin-top: 84px; }

/* Refresh intrinsic height estimates after text or layout changes. First anchor jumps use them before sections render. */
/* Render the hero for first paint and keep the ending available to its reveal observer. */
.section[data-ch]:not([data-ch="0"]):not([data-ch="fw"]),
#lexicon, #thread, #scripture, #names, #sources {
  content-visibility: auto;
}
.section[data-ch="1"] { contain-intrinsic-size: auto 16100px; }
.section[data-ch="2"] { contain-intrinsic-size: auto 20800px; }
.section[data-ch="3"] { contain-intrinsic-size: auto 19500px; }
.section[data-ch="4"] { contain-intrinsic-size: auto 15500px; }
.section[data-ch="5"] { contain-intrinsic-size: auto 26000px; }
.section[data-ch="6"] { contain-intrinsic-size: auto 20600px; }
.section[data-ch="7"] { contain-intrinsic-size: auto 30100px; }
.section[data-ch="8"] { contain-intrinsic-size: auto 26600px; }
.section[data-ch="9"] { contain-intrinsic-size: auto 24800px; }
.section[data-ch="10"] { contain-intrinsic-size: auto 41300px; }
#lexicon { contain-intrinsic-size: auto 1300px; }
#thread { contain-intrinsic-size: auto 1400px; }
#scripture { contain-intrinsic-size: auto 1700px; }
#names { contain-intrinsic-size: auto 4100px; }
#sources { contain-intrinsic-size: auto 2500px; }
/* Measure Spanish separately because its verse notes are hidden. */
.section[lang="es"][data-ch="1"] { contain-intrinsic-size: auto 16300px; }
.section[lang="es"][data-ch="2"] { contain-intrinsic-size: auto 20000px; }
.section[lang="es"][data-ch="3"] { contain-intrinsic-size: auto 19500px; }
.section[lang="es"][data-ch="4"] { contain-intrinsic-size: auto 15500px; }
.section[lang="es"][data-ch="5"] { contain-intrinsic-size: auto 25600px; }
.section[lang="es"][data-ch="6"] { contain-intrinsic-size: auto 20100px; }
.section[lang="es"][data-ch="7"] { contain-intrinsic-size: auto 29600px; }
.section[lang="es"][data-ch="8"] { contain-intrinsic-size: auto 25800px; }
.section[lang="es"][data-ch="9"] { contain-intrinsic-size: auto 25100px; }
.section[lang="es"][data-ch="10"] { contain-intrinsic-size: auto 41600px; }

@media (max-width: 900px) {
  .section[data-ch="1"] { contain-intrinsic-size: auto 18700px; }
  .section[data-ch="2"] { contain-intrinsic-size: auto 25800px; }
  .section[data-ch="3"] { contain-intrinsic-size: auto 23400px; }
  .section[data-ch="4"] { contain-intrinsic-size: auto 19200px; }
  .section[data-ch="5"] { contain-intrinsic-size: auto 32000px; }
  .section[data-ch="6"] { contain-intrinsic-size: auto 24600px; }
  .section[data-ch="7"] { contain-intrinsic-size: auto 35800px; }
  .section[data-ch="8"] { contain-intrinsic-size: auto 30800px; }
  .section[data-ch="9"] { contain-intrinsic-size: auto 30100px; }
  .section[data-ch="10"] { contain-intrinsic-size: auto 50000px; }
  #lexicon { contain-intrinsic-size: auto 2000px; }
  #thread { contain-intrinsic-size: auto 1700px; }
  #scripture { contain-intrinsic-size: auto 3600px; }
  #names { contain-intrinsic-size: auto 7400px; }
  #sources { contain-intrinsic-size: auto 2800px; }
  .section[lang="es"][data-ch="1"] { contain-intrinsic-size: auto 18800px; }
  .section[lang="es"][data-ch="2"] { contain-intrinsic-size: auto 22400px; }
  .section[lang="es"][data-ch="3"] { contain-intrinsic-size: auto 22300px; }
  .section[lang="es"][data-ch="4"] { contain-intrinsic-size: auto 18300px; }
  .section[lang="es"][data-ch="5"] { contain-intrinsic-size: auto 29600px; }
  .section[lang="es"][data-ch="6"] { contain-intrinsic-size: auto 22900px; }
  .section[lang="es"][data-ch="7"] { contain-intrinsic-size: auto 33600px; }
  .section[lang="es"][data-ch="8"] { contain-intrinsic-size: auto 28500px; }
  .section[lang="es"][data-ch="9"] { contain-intrinsic-size: auto 29200px; }
  .section[lang="es"][data-ch="10"] { contain-intrinsic-size: auto 48100px; }
}
.section-inner { display: contents; }

.section > .block-p,
.section-inner > .block-p { grid-column: 3 / 9; }
@media (max-width: 900px) {
  .section > .block-p, .section-inner > .block-p { grid-column: 1 / 7; }
}

/* Keep the day chapter palette in sync with TOKENS in js/motion.js. */
.section[data-ch="0"]   { --paper:#EFEBE1; --ink:#191510; --accent:#32638F; }
.section[data-ch="1"]   { --paper:#EDE9DF; --ink:#191510; --accent:#32638F; }
.section[data-ch="2"]   { --paper:#E7E7E4; --ink:#16181A; --accent:#32638F; }
.section[data-ch="3"]   { --paper:#EDE6DB; --ink:#1A1510; --accent:#32638F; }
.section[data-ch="4"]   { --paper:#E6E8EA; --ink:#15181B; --accent:#32638F; }
.section[data-ch="5"]   { --paper:#F0E9DC; --ink:#1A1510; --accent:#A8391B; }
.section[data-ch="6"]   { --paper:#F2ECE0; --ink:#1A1610; --accent:#A8391B; }
.section[data-ch="7"]   { --paper:#E9E9E7; --ink:#17191B; --accent:#A8391B; }
.section[data-ch="8"]   { --paper:#EBE6E1; --ink:#181412; --accent:#A8391B; }
.section[data-ch="9"]   { --paper:#F4EEE1; --ink:#1A1610; --accent:#7E5A20; }
.section[data-ch="10"]  { --paper:#FBF7EE; --ink:#1A1712; --accent:#7E5A20; }
.section[data-ch="fw"] { --paper:#FDFAF3; --ink:#1A1712; --accent:#7E5A20; }

/* Chapter headings */
.block-p, .prose {
  margin: 0 0 1.15em;
  max-width: var(--measure);
  text-wrap: pretty;
}
.block-p em, .prose em { font-style: italic; }
.block-p:last-child { margin-bottom: 0; }

.chapter-title, .hero-title, .fivewords-text {
  font-variation-settings: var(--lit-display);
  font-weight: 400;
  letter-spacing: -.018em;
  line-height: 1.03;
  text-wrap: balance;
}

.chapter-title { font-size: clamp(2.1rem, 4.6vw, 3.7rem); }

.chapter-num {
  font-family: var(--ui);
  font-size: var(--ap-sm); font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent);
  padding-top: .95em;   /* Align the numeral optically with the title’s cap height. */
}

.chapter-hook {
  font-family: var(--serif);
  font-variation-settings: var(--lit-normal);
  font-style: normal;
  font-weight: 450;
  color: var(--ink-soft);
  margin: 1.1em 0 0;
  font-size: var(--body-size);
  line-height: 1.55;
  letter-spacing: 0;
  max-width: 58ch;
}


/* Glossary links */
.gloss-term {
  border-bottom: 1px dotted var(--accent);
  cursor: help;
  text-underline-offset: 3px;
}

/* Reveals and dividers */
.reveal { opacity: 1; transform: none; }
.plate.reveal, .fivewords-text .fw-word, .fivewords-ref {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}
.plate.reveal.is-visible { opacity: 1; transform: none; }

.hairline {
  grid-column: 3 / 9;
  height: 1px; width: 0;
  background: var(--rule-strong);
  margin: 2.2rem 0;
  transition: width var(--dur-slow) var(--ease);
}
.hairline.is-drawn { width: 5rem; }

.divider-beat  { grid-column: 3 / 9; margin: 2.2rem 0; }
.divider-swell { grid-column: 3 / 9; margin: 3.8rem 0; }
/* A desktop range like 3 / 9 creates implicit tracks on the six-column grid.
   Full-width items using 1 / -1 still stop at the last explicit track. */
@media (max-width: 900px) {
  .divider-beat, .divider-swell { grid-column: 1 / 7; }
}
.divider-swell.is-drawn { width: 9rem; }

/* Match the specificity of the reveal rules so the plates honor reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .reveal,
  .plate.reveal, .plate.reveal.is-visible,
  .fivewords-text .fw-word, .fivewords-ref { opacity: 1; transform: none; transition: none; }
  .hairline { width: 5rem; transition: none; }
}

/* js/motion.js still reads the veil hooks. */
.veil-lift::after, .veil-boundary { display: none !important; }


/* Audio sample */
.hero-sample {
  /* Align the sample with the plate caption above it. */
  grid-column: 1 / 8;
  display: block;
  max-width: 35rem;
  margin: clamp(1.4rem, 2.6vw, 2.1rem) 0 0;
  padding: clamp(.9rem, 1.5vw, 1.15rem) clamp(1rem, 1.7vw, 1.35rem)
           clamp(.9rem, 1.5vw, 1.15rem) clamp(1.15rem, 2vw, 1.6rem);
  border: 0;
  border-left: 3px solid var(--accent);
  background: none;
  color: var(--ink);
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease);
}
.hero-sample:hover, .hero-sample:focus-visible {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}
.hero-sample:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.hs-eyebrow {
  display: block;
  font-family: var(--ui); font-size: var(--ap-lg);
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .7em;
}
.hs-eyebrow i, .hs-title i { font-style: normal; opacity: .55; padding-inline: .25em; }
.hero-sample.is-heard .hs-eyebrow { color: var(--ink-soft); }

.hs-quote { margin: 0; }
.hs-quote p {
  margin: 0;
  font-variation-settings: var(--lit-mid);
  font-weight: 350;
  font-size: clamp(1.28rem, 1.95vw, 1.7rem);
  line-height: 1.24; letter-spacing: -.012em;
  color: var(--ink);
  text-wrap: balance;
}

.hs-holds {
  display: block;
  margin-top: .9em;
  /* The sample card supplies the width cap. A nested cap would narrow the copy inside it. */
  font-family: var(--serif);
  font-variation-settings: var(--lit-normal);
  font-weight: 400;
  font-size: clamp(.98rem, 1.18vw, 1.06rem);
  line-height: 1.5; letter-spacing: 0;
  color: var(--ink-soft);
}

.hs-act {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: .85rem;
  margin-top: 1.15em;
}
.hs-glyph { display: block; width: 46px; height: 46px; }
.hs-glyph svg { display: block; width: 100%; height: 100%; overflow: visible; }
.hs-ring {
  fill: color-mix(in srgb, var(--accent) 14%, transparent);
  stroke: var(--accent);
  stroke-width: 1.5;
  /* Match the dash length and hs-draw start to the circle circumference in js/render.js. */
  stroke-dasharray: 128.81;
  stroke-dashoffset: 0;
  transform: rotate(-90deg);
  transform-origin: 22px 22px;
  transition: fill var(--dur-fast) var(--ease);
}
.hs-tri {
  fill: var(--accent);
  /* The same-color stroke rounds the triangle corners. */
  stroke: var(--accent); stroke-width: 3; stroke-linejoin: round;
  transition: fill var(--dur-fast) var(--ease), stroke var(--dur-fast) var(--ease);
}

/* js/ui.js adds .is-arrived once for the entrance animation. */
@keyframes hs-draw {
  from { stroke-dashoffset: 128.81; }
  to   { stroke-dashoffset: 0; }
}
@keyframes hs-lift {
  0%   { transform: scale(.82); opacity: .35; }
  55%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.hero-sample.is-arrived .hs-ring {
  animation: hs-draw var(--dur-slow) var(--ease) 180ms both;
}
.hero-sample.is-arrived .hs-tri {
  transform-origin: 22px 22px;
  animation: hs-lift var(--dur-med) var(--ease) 480ms both;
}
@media (prefers-reduced-motion: reduce) {
  .hero-sample.is-arrived .hs-ring,
  .hero-sample.is-arrived .hs-tri { animation: none; }
}
.hero-sample:hover .hs-ring,
.hero-sample:focus-visible .hs-ring {
  stroke: var(--accent);
  fill: color-mix(in srgb, var(--accent) 26%, transparent);
}
.hero-sample:hover .hs-tri,
.hero-sample:focus-visible .hs-tri { fill: var(--accent); }


.hs-title {
  display: block; min-width: 0;
  font-variation-settings: var(--lit-mid);
  font-weight: 400;
  font-size: clamp(1.08rem, 1.35vw, 1.22rem);
  line-height: 1.22; letter-spacing: -.005em;
  color: var(--ink);
  text-wrap: balance;
}

/* Tap-to-listen hint */
.hero-sample-note {
  display: none;
  grid-column: 3 / 9;
  max-width: 34rem;
  margin: 1.1rem 0 0;
  font-family: var(--ui);
  font-weight: 400;
  font-size: var(--ap-xl);
  line-height: 1.5; letter-spacing: 0;
  color: var(--ink-soft);
}
.can-tap-to-listen .hero-sample-note { display: block; }
.hsn-verb { display: none; }
.hsn-tap { display: inline; }
@media (hover: hover) {
  .hsn-tap { display: none; }
  .hsn-click { display: inline; }
}

@media (max-width: 900px) {
  .hero-sample { grid-column: 1 / 7; max-width: none; }
  .hero-sample-note { grid-column: 1 / 7; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hs-ring { animation: none; stroke-dashoffset: 0; }
  .hero-sample { transition: none; }
  .hs-tri { transition: none; }
}

/* Keep the night chapter palette in sync with TOKENS_NIGHT in js/motion.js.
   Check text contrast on the lightest night stock (#201B15). */
html[data-theme="night"] {
  --paper: #121110;
  --ink: #EFE9DE;
  --ink-soft: #B6ADA1;
  --ink-faint: #968D82;
  --rule: rgba(239, 233, 222, .14);
  --rule-strong: rgba(239, 233, 222, .26);
  --control-edge: rgba(239, 233, 222, .36);
  --control-wash: rgba(239, 233, 222, .05);
  --accent: #8FB4D8;
  color-scheme: dark;
}
html[data-theme="night"] .section[data-ch="0"]  { --paper:#141311; --ink:#EFE9DE; --accent:#8FB4D8; }
html[data-theme="night"] .section[data-ch="1"]  { --paper:#121110; --ink:#EFE9DE; --accent:#8FB4D8; }
html[data-theme="night"] .section[data-ch="2"]  { --paper:#111315; --ink:#EAEBEE; --accent:#8FB4D8; }
html[data-theme="night"] .section[data-ch="3"]  { --paper:#151211; --ink:#F0E9DD; --accent:#8FB4D8; }
html[data-theme="night"] .section[data-ch="4"]  { --paper:#101215; --ink:#E9ECEF; --accent:#8FB4D8; }
html[data-theme="night"] .section[data-ch="5"]  { --paper:#17130F; --ink:#F2EADC; --accent:#E58156; }
html[data-theme="night"] .section[data-ch="6"]  { --paper:#191410; --ink:#F3EBDD; --accent:#E58156; }
html[data-theme="night"] .section[data-ch="7"]  { --paper:#131415; --ink:#ECEDEE; --accent:#E58156; }
html[data-theme="night"] .section[data-ch="8"]  { --paper:#151312; --ink:#EFEAE4; --accent:#E58156; }
html[data-theme="night"] .section[data-ch="9"]  { --paper:#1A1510; --ink:#F4EDDF; --accent:#DCAA51; }
html[data-theme="night"] .section[data-ch="10"] { --paper:#1E1913; --ink:#F7F1E5; --accent:#DCAA51; }
html[data-theme="night"] .section[data-ch="fw"] { --paper:#201B15; --ink:#F8F2E7; --accent:#DCAA51; }

html[data-theme="night"] .plate-frame img,
html[data-theme="night"] .pl-frame img,
html[data-theme="night"] .img-slot img { filter: brightness(.86) contrast(1.03); }
/* Combine the night filter with the unlit plate filter because filter declarations replace each other. */
html[data-theme="night"] .pl-plate:not(.is-lit) .pl-frame img {
  filter: brightness(.86) saturate(.62) contrast(1.05);
}

.theme-sun { display: none; }
html[data-theme="night"] .theme-moon { display: none; }
html[data-theme="night"] .theme-sun { display: block; }
