/* ============================================================================
   Biblia Sacra Vulgata — classical Latin Bible skin (Greb edition).

   Scope: everything is gated under html[data-course="biblia"] so it never
   bleeds into the Jung Collected Works (which shares the .cw-page engine) or
   any other course. The .bib-* classes (cover / title / divider / TOC) are
   unique to this book and styled directly.

   Palette (mirrors bible/theme.cljs):
     ink    #231a12   paper  #efe6d2   page  #f5eedd
     oxblood#3a0d0d   gold   #e8c66a   rubric#8a1f1f
   ============================================================================ */

html[data-course="biblia"] {
  --bib-ink:    #231a12;
  --bib-paper:  #efe6d2;
  --bib-page:   #f5eedd;
  --bib-oxblood:#3a0d0d;
  --bib-gold:   #b6892f;
  --bib-gold-lt:#e8c66a;
  --bib-rubric: #8a1f1f;
  --bib-serif:  "EB Garamond", "Sabon", "Hoefler Text", Georgia, serif;
  --bib-caps:   "Cinzel", "Trajan Pro", "Hoefler Text", Georgia, serif;
  /* Verse leading — ONE course-level value. The runtime paginator (cw-flow)
     measures off-screen at boot, BEFORE per-spread book-leading-* classes are
     applied; a per-spread override would therefore measure tighter than it
     renders and overflow the page (extra columns / cut verses). Keeping a single
     value means measurement == render, so every chapter fits. Tune it here (it
     re-paginates on reload); the value is intentionally tight for a dense,
     one-page-per-chapter Bible setting. */
  --bib-leading: 1.16;
}

/* Single-column verse bodies (not a CSS multicol container). column-count:1 is
   still multicol — it spawns "overflow columns" to the right and corrupts the
   paginator's block measurement (offsetTop resets per column). A plain block
   makes the paginator measure true single-column stacking AND renders one clean
   column. Pairs with cw-flow's measured page-height target so pages pack to fit. */
html[data-course="biblia"] .cw-body:not([data-cols="2"]):not([data-cols="3"]) {
  columns: unset !important;
  column-count: auto !important;
  column-width: auto !important;
}

/* Inline NOTE images are floated into verses AFTER pagination, so the paginator
   can't plan for them. On a verse page, force a right-floated margin illustration
   (whatever mode the note carries): the verses wrap to its LEFT so it adds almost
   no block height. A full-width block image would instead push the verses below
   it past the fixed page edge and clip them ("no se ve bien"). Bounded width +
   height keep it from ever dominating the page. */
html[data-course="biblia"] .cw-body .note-inline-fig {
  float: right !important;
  clear: none !important;
  width: 44% !important;
  max-width: 44% !important;
  max-height: 34% !important;
  margin: 0.15em 0 0.35em 0.85em !important;
  shape-outside: margin-box;
}
html[data-course="biblia"] .cw-body .note-inline-fig img {
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

/* The verse an image was generated from stays highlighted (blue) as an
   annotation linking it to the picture — make it clearly readable on the warm
   Bible paper: a touch more saturated than the shared default, with a soft
   underline wash so it reads as a deliberate mark, not an accident. */
html[data-course="biblia"] mark.note-mark.note-blue {
  background: rgba(120, 170, 246, .34);
  box-shadow: inset 0 -0.42em 0 rgba(96, 150, 235, .18);
}

/* ── Uniform trim — every Vulgate leaf fills the same .page box and clips ──
   overflow, so the cover / title / dividers never render taller than the
   flowed cw verse pages (which already force height:100%). */
html[data-course="biblia"] .bib-cover,
html[data-course="biblia"] .bib-title,
html[data-course="biblia"] .bib-book-divider {
  height: 100%;
  min-height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* ── Verse pages (.cw-page text engine, re-skinned) ───────────────────────── */

html[data-course="biblia"] .cw-page {
  background:
    radial-gradient(120% 90% at 50% 0%, #f8f1e1 0%, var(--bib-page) 55%, #efe5cf 100%);
  color: var(--bib-ink);
}

html[data-course="biblia"] .cw-body {
  font-family: var(--bib-serif);
  font-size: 1.02em;
  line-height: var(--bib-leading, 1.2);
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-rendering: optimizeLegibility;
  font-feature-settings: "liga" 1, "onum" 1, "kern" 1;
}

html[data-course="biblia"] .cw-running-head {
  font-family: var(--bib-caps);
  letter-spacing: 0.18em;
  color: var(--bib-oxblood);
}
html[data-course="biblia"] .cw-running-head-title { font-weight: 500; }

/* Chapter heads ("Caput N") — centred rubric with side ornaments. */
html[data-course="biblia"] .cw-h2 {
  font-family: var(--bib-caps);
  font-weight: 600;
  font-size: 0.92em;
  letter-spacing: 0.16em;
  text-align: center;
  text-transform: uppercase;
  color: var(--bib-rubric);
  margin: 1.1em 0 0.55em;
  border: none;
}
html[data-course="biblia"] .cw-h2::before,
html[data-course="biblia"] .cw-h2::after {
  content: "❦";
  color: var(--bib-gold);
  font-size: 0.8em;
  margin: 0 0.6em;
  vertical-align: 0.05em;
}

/* Verse paragraphs: continuous, lightly indented; verse number as a small
   raised rubric numeral inline at the start (overrides Jung's margin gutter). */
html[data-course="biblia"] .cw-para {
  margin: 0;
  text-indent: 1.1em;
}
html[data-course="biblia"] .cw-para[data-section] { position: static; }
html[data-course="biblia"] .cw-para[data-section]::before {
  content: attr(data-section);
  position: static;
  display: inline;
  font-family: var(--bib-serif);
  font-weight: 600;
  font-size: 0.62em;
  vertical-align: super;
  line-height: 0;
  color: var(--bib-rubric);
  margin-right: 0.3em;
  width: auto;
}

/* First verse after a chapter head: drop its "1" and set a versal drop-cap. */
html[data-course="biblia"] .cw-h2 + .cw-para { text-indent: 0; }
html[data-course="biblia"] .cw-h2 + .cw-para[data-section]::before { content: none; }
html[data-course="biblia"] .cw-h2 + .cw-para::first-letter {
  font-family: var(--bib-caps);
  font-weight: 700;
  float: left;
  font-size: 3.1em;
  line-height: 0.82;
  padding: 0.04em 0.1em 0 0;
  color: var(--bib-oxblood);
}

html[data-course="biblia"] .cw-sep-icon { color: var(--bib-gold); }
html[data-course="biblia"] .cw-page-footer-title,
html[data-course="biblia"] .page-num { color: var(--bib-oxblood); }

/* ── Front board (.bib-cover) ─────────────────────────────────────────────── */

.bib-cover {
  background:
    radial-gradient(130% 100% at 50% 18%, #5a1717 0%, var(--bib-oxblood, #3a0d0d) 60%, #240707 100%);
  color: var(--bib-gold-lt, #e8c66a);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bib-cover-frame {
  width: 78%;
  height: 84%;
  border: 1.5px solid rgba(232,198,106,0.55);
  outline: 1px solid rgba(232,198,106,0.25);
  outline-offset: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 7% 6%;
  text-align: center;
}
.bib-cover-rule { width: 38%; height: 1px; background: rgba(232,198,106,0.5); }
.bib-cover-head { margin-top: 8%; }
.bib-cover-title {
  font-family: "Cinzel", "Trajan Pro", Georgia, serif;
  font-weight: 700;
  font-size: 2.0rem;
  letter-spacing: 0.12em;
  line-height: 1.2;
  margin: 0;
}
.bib-cover-sub {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: 0.45em;
  margin-top: 0.6em;
  padding-left: 0.45em;
  color: #f0dca0;
}
.bib-cover-cross { font-size: 2.6rem; color: rgba(232,198,106,0.92); }
.bib-cover-colophon { margin-bottom: 6%; }
.bib-cover-edition {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 0.28em;
  font-size: 0.78rem;
}
.bib-cover-publisher {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 0.3em;
  font-size: 0.7rem;
  margin-top: 0.8em;
  color: rgba(232,198,106,0.7);
}

/* ── Inner title page (.bib-title) ────────────────────────────────────────── */

.bib-title {
  background: var(--bib-page, #f5eedd);
  color: var(--bib-ink, #231a12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bib-title-frame {
  text-align: center;
  padding: 10% 9%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4em;
}
.bib-title-cross { font-size: 2rem; color: var(--bib-rubric, #8a1f1f); margin-bottom: 0.6em; }
.bib-title-main {
  font-family: "Cinzel", "Trajan Pro", Georgia, serif;
  font-weight: 700;
  font-size: 1.7rem;
  letter-spacing: 0.09em;
  line-height: 1.25;
  margin: 0;
  color: var(--bib-oxblood, #3a0d0d);
}
.bib-title-rule { width: 46%; height: 1px; background: var(--bib-gold, #b6892f); margin: 0.9em 0; }
.bib-title-sub {
  font-family: "EB Garamond", Georgia, serif;
  font-style: italic;
  font-size: 1.05rem;
}
.bib-title-note {
  font-family: "EB Garamond", Georgia, serif;
  font-size: 0.85rem;
  color: #5a4a36;
  max-width: 22em;
  margin-top: 0.4em;
}
.bib-title-imprint {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 0.3em;
  font-size: 0.72rem;
  margin-top: 2.4em;
  color: var(--bib-oxblood, #3a0d0d);
}

/* ── Book half-title (.bib-book-divider) ──────────────────────────────────── */

.bib-book-divider {
  background:
    radial-gradient(120% 90% at 50% 0%, #f8f1e1 0%, var(--bib-page, #f5eedd) 60%, #efe5cf 100%);
  color: var(--bib-ink, #231a12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bib-divider-frame {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5em;
  padding: 0 10%;
}
.bib-divider-eyebrow {
  font-family: "EB Garamond", Georgia, serif;
  font-style: italic;
  letter-spacing: 0.16em;
  font-size: 0.82rem;
  color: var(--bib-rubric, #8a1f1f);
}
.bib-divider-cross { font-size: 1.5rem; color: var(--bib-gold, #b6892f); }
.bib-divider-title {
  font-family: "Cinzel", "Trajan Pro", Georgia, serif;
  font-weight: 700;
  font-size: 2.1rem;
  letter-spacing: 0.07em;
  line-height: 1.12;
  margin: 0.1em 0;
  color: var(--bib-oxblood, #3a0d0d);
}
.bib-divider-rule { width: 34%; height: 1px; background: var(--bib-gold, #b6892f); margin-top: 0.6em; }

/* ── Index Librorum (.bib-toc, on .cw-page) ───────────────────────────────── */

html[data-course="biblia"] .bib-toc-title {
  font-family: var(--bib-caps);
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--bib-oxblood);
  margin: 0 0 1em;
}
html[data-course="biblia"] .bib-toc-section { margin-bottom: 1.05em; break-inside: avoid; }
html[data-course="biblia"] .bib-toc-section-head {
  font-family: var(--bib-caps);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-align: center;
  color: var(--bib-rubric);
  margin-bottom: 0.4em;
}
html[data-course="biblia"] .bib-toc-row {
  display: flex;
  align-items: baseline;
  font-family: var(--bib-serif);
  font-size: 0.98rem;
  color: var(--bib-ink);
  text-decoration: none;
  padding: 0.06em 0;
}
html[data-course="biblia"] .bib-toc-row:hover { color: var(--bib-rubric); }
html[data-course="biblia"] .bib-toc-label { white-space: nowrap; }
html[data-course="biblia"] .bib-toc-leader {
  flex: 1;
  margin: 0 0.4em;
  border-bottom: 1px dotted rgba(58,13,13,0.35);
  transform: translateY(-0.18em);
}

@media (max-width: 840px) {
  /* The desktop pocket-book inset is almost half the usable width on phones.
     Keep a real printed margin, but let the Latin line use the screen. */
  html[data-course="biblia"] .cw-page {
    --cw-margin-x: clamp(16px, 4.5vw, 24px);
    --cw-gutter: 0.75em;
    --cw-folio-outdent: 0;
  }

  html[data-course="biblia"] .cw-page > .cw-text-scale-root {
    min-height: max-content;
  }

  html[data-course="biblia"] .cw-page .cw-running-head {
    padding-top: 1.25rem;
    padding-bottom: 0.65rem;
  }

  html[data-course="biblia"] .cw-page .cw-body {
    padding-top: 0.5rem;
    padding-bottom: 0.75rem;
    overflow: visible;
  }

  /* Generated illustrations are read-only, centered blocks on mobile.
     Saved desktop float/free coordinates remain untouched for larger screens. */
  html[data-course="biblia"] .cw-body .note-inline-fig,
  html[data-course="biblia"] .cw-page > .note-inline-fig {
    position: relative !important;
    inset: auto !important;
    float: none !important;
    clear: both !important;
    display: block !important;
    width: min(100%, 320px) !important;
    max-width: 100% !important;
    max-height: none !important;
    margin: 0.75rem auto 1rem !important;
    padding: 0 !important;
    transform: none !important;
    shape-outside: none !important;
    box-shadow: none !important;
    cursor: zoom-in !important;
  }

  html[data-course="biblia"] .note-inline-fig .nif-ctrls {
    display: none !important;
    pointer-events: none !important;
  }

  html[data-course="biblia"] .cw-body .note-inline-fig img,
  html[data-course="biblia"] .cw-page > .note-inline-fig img {
    width: 100% !important;
    max-height: 55vh !important;
    object-fit: contain !important;
  }

  /* Keep the printed footer/folio visible after pages switch to natural height. */
  html[data-course="biblia"] .cw-page footer.page-footer.cw-page-footer {
    display: grid !important;
    visibility: visible !important;
    padding: 0.65rem var(--cw-margin-x) 1rem;
  }
}

/* ═════════════════════════════════════════════════════════════════════════
   Facing edition readability (Genesis & the other bilingual books).
   The shared República facing styles (book/12-republica-facing.css) are tuned
   tight — 0.78rem prose, faint-gold verse numbers, a small corner LA·ES toggle.
   Scripture wants larger, higher-contrast type and an obvious translation
   switch. Scoped to the Bible (data-course="biblia") so República is untouched.
   ═════════════════════════════════════════════════════════════════════════ */

/* Prose: a touch larger + roomier leading on both columns (Latin and Spanish). */
html[data-course="biblia"] .fb-es,
html[data-course="biblia"] .fb-la,
html[data-course="biblia"] .fb-en {
  font-size: 0.92rem;
  line-height: 1.36;
  color: var(--bib-ink, #231a12);
}

/* Verse numbers: legible oxblood instead of faint gold. */
html[data-course="biblia"] .fb-sec,
html[data-course="biblia"] .fb-sec-float {
  color: var(--bib-rubric, #8a1f1f);
}

/* Running head (book name) + folio range: darken so they actually read. */
html[data-course="biblia"] .fb-head-title,
html[data-course="biblia"] .fb-footer-range {
  color: var(--bib-oxblood, #3a0d0d);
}

/* Translation toggle: make the LA·ES picker unmissable — Scripture readers go
   looking for the other language, so give it weight + a swap glyph. */
html[data-course="biblia"] .fb-mode-btn {
  min-width: 88px;
  padding: 10px 15px;
  font-size: 15px;
  background: var(--bib-oxblood, #3a0d0d);
  color: var(--bib-gold-lt, #e8c66a);
  border: 1px solid rgba(232, 198, 106, 0.45);
}
html[data-course="biblia"] .fb-mode-btn::before {
  content: "⇄\00a0";
  opacity: 0.85;
}

/* Facing dual-column follow: while a verse is narrated, BOTH its columns (the
   spoken Spanish + the matching Latin, same data-sec) get a soft gold wash so
   the reader can follow Latin and Spanish together. The audiobook adds
   .fb-verse-reading to every cell sharing the playing verse's data-sec. */
html[data-course="biblia"] .fb-cell.fb-verse-reading {
  background: linear-gradient(rgba(182, 137, 47, 0.13), rgba(182, 137, 47, 0.13));
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(182, 137, 47, 0.10);
  transition: background-color 0.18s ease;
}
