/* ELV — a scholar's edition brought to the web.
   Scripture in Source Sans; titles in Libre Franklin. Rubric red, manuscript
   blue, and a restrained gilt accent on the signature moments. */
@font-face {
  font-family: "Source Sans 3"; font-style: normal; font-weight: 200 900;
  font-display: swap; src: url("/static/fonts/source-sans-3-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2013-2014, U+2018-201A,
    U+201C-201E, U+2026, U+2039-203A;
}
@font-face {
  font-family: "Source Sans 3"; font-style: italic; font-weight: 200 900;
  font-display: swap; src: url("/static/fonts/source-sans-3-latin-wght-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2013-2014, U+2018-201A,
    U+201C-201E, U+2026, U+2039-203A;
}
@font-face {
  font-family: "Source Sans 3"; font-style: normal; font-weight: 200 900;
  font-display: swap; src: url("/static/fonts/source-sans-3-greek-wght-normal.woff2") format("woff2");
  unicode-range: U+0370-03FF, U+1F00-1FFF;
}
@font-face {
  font-family: "Source Sans 3"; font-style: italic; font-weight: 200 900;
  font-display: swap; src: url("/static/fonts/source-sans-3-greek-wght-italic.woff2") format("woff2");
  unicode-range: U+0370-03FF, U+1F00-1FFF;
}
/* Libre Franklin — display face for titles, hero, and structural labels. */
@font-face {
  font-family: "Libre Franklin"; font-style: normal; font-weight: 400;
  font-display: swap; src: url("/static/fonts/libre-franklin-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Libre Franklin"; font-style: normal; font-weight: 600;
  font-display: swap; src: url("/static/fonts/libre-franklin-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Libre Franklin"; font-style: normal; font-weight: 700;
  font-display: swap; src: url("/static/fonts/libre-franklin-latin-700-normal.woff2") format("woff2");
}

:root {
  --paper: #fbf9f4;      /* clean warm vellum */
  --paper-2: #f1ece1;    /* raised panels */
  --ink: #1e1b16;        /* iron-gall near-black */
  --ink-soft: #6b6355;
  --accent: #9e2b25;     /* rubric red */
  --rule: #e4dcc9;
  --rule-strong: #d6ccb4;
  --highlight: #f3e7c8;
  --woc: #b01812;        /* words of Christ (print uses #c00000) */
  --num: #2e5e7e;        /* verse/chapter numbers — manuscript blue */
  --fnmark: #7a4fa3;     /* footnote sigla — purple, distinct from the red text */
  --gold: #b08637;       /* illumination — used only on signature moments */
  --sans: "Source Sans 3", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --display: "Libre Franklin", "Source Sans 3", "Segoe UI", Arial, sans-serif;
}
[data-theme="sepia"] {
  --paper: #f1e7cf; --paper-2: #e8dbbe; --ink: #3b3022; --ink-soft: #6e6046;
  --accent: #8a2b1e; --rule: #d8c6a0; --rule-strong: #c9b083; --highlight: #e7d3a4;
  --woc: #9c1f14; --num: #3f6483; --fnmark: #6d478f; --gold: #9c7a2e;
}
[data-theme="dark"] {
  --paper: #17150f; --paper-2: #201d15; --ink: #e8e2d4; --ink-soft: #a39a87;
  --accent: #d98873; --rule: #38332a; --rule-strong: #4a4234; --highlight: #3d3524;
  --woc: #e58a7c; --num: #7fb0d6; --fnmark: #b79ce6; --gold: #c9a24b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* beats display:flex/grid below */
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 1.0625rem; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px;
  border-radius: 2px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  gap: 1rem; padding: 0.5rem 1rem; background: var(--paper);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 2px 0 var(--gold), 0 3px 8px -6px rgba(0,0,0,0.4);
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  color: var(--gold); font-size: 1.4rem; line-height: 1;
  transform: translateY(-1px);
}
.brand-text {
  font-family: var(--display); font-weight: 700; letter-spacing: 0.14em;
  font-size: 1.25rem; line-height: 1.1;
}
.brand-text small {
  display: block; font-family: var(--sans); font-size: 0.66rem; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-soft);
}
@media (max-width: 560px) { .brand-text small { display: none; } }
.tools { margin-left: auto; display: flex; gap: 0.5rem; }
.tools button {
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  color: var(--ink); background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 4px; padding: 0.3rem 0.75rem;
}
.tools button:hover { border-color: var(--gold); }

.settings-menu {
  position: fixed; top: 3.2rem; right: 1rem; z-index: 30;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 8px;
  padding: 0.8rem 1rem; box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  display: grid; gap: 0.6rem;
}
.settings-menu .setting { display: flex; align-items: center; gap: 0.5rem;
  justify-content: space-between; }
.settings-menu button { font: inherit; font-size: 0.85rem; cursor: pointer;
  background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 4px; padding: 0.2rem 0.6rem; }
.settings-menu button:hover { border-color: var(--gold); }

/* ---- reading layout ---- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr);
  max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem 6rem;
}
@media (min-width: 1100px) {
  .layout {
    grid-template-columns: minmax(0, 58rem) 19rem;
    gap: 2.5rem; padding-bottom: 3rem;
  }
}
.scripture { max-width: 58rem; }
.scripture .verbatim { max-width: 80ch; }

.book-title {
  font-family: var(--display); font-size: clamp(1.9rem, 4vw, 2.4rem);
  font-weight: 700; letter-spacing: -0.01em; line-height: 1.1;
  margin: 0.8rem 0 1rem; padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.book-title::after {
  content: ""; position: absolute; left: 0; bottom: -1px;
  width: 3.5rem; height: 3px; background: var(--gold);
}
.book-title.small { font-size: 1.3rem; color: var(--ink-soft); }
.book-title .fnref a { font-size: 0.8rem; }

.section-head {
  font-family: var(--display); font-size: 0.82rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft);
  margin: 2rem 0 0.5rem;
}
/* print-parity paragraph model: the book runs paragraphs tight and
   left-aligned, separating prose with first-line indents (.pind), real
   gaps only where the master has them (.gap), poem/quote lines (.vline)
   flush with tab-stop indents restored via .tab spans. */
.para { margin: 0 0 0.2rem; text-align: left; }
.para.pind { text-indent: 1.4em; }
.para.gap { margin-bottom: 0.9rem; }
.para.vline { text-indent: 0; }
.tab { display: inline-block; overflow: hidden; white-space: pre;
  text-indent: 0; }

.para.chapter-start { text-indent: 0; }  /* layout hook only; drop cap lives in .cn */
/* illuminated numeral — the chapter number set as a gilt drop cap */
.cn {
  float: left; font-family: var(--display); font-size: 3.1rem;
  line-height: 0.82; font-weight: 700; color: var(--gold);
  padding: 0.08em 0.14em 0 0; font-style: normal;
}
.vn {
  font-size: 0.66em; vertical-align: super; line-height: 0;
  color: var(--num); font-weight: 700; padding: 0 0.15em 0 0.05em;
}
.woc { color: var(--woc); }
.vn.vhang { display: inline-block; vertical-align: baseline; font-size: 0.72em;
  padding-right: 0; }
.fnref { line-height: 0; }
.fnref a {
  font-size: 0.72em; font-weight: 700; color: var(--fnmark);
  padding: 0 0.1em;
}
.flash { background: var(--highlight); transition: background 1.2s ease; }

.chapter-nav {
  display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem;
  padding-top: 1rem; border-top: 1px solid var(--rule); font-size: 0.95rem;
}
.chapter-nav a { font-family: var(--display); font-weight: 600;
  font-size: 0.9rem; }

/* ---- apparatus (footnote) pane: desktop margin ---- */
.fnpane { font-size: 0.88rem; }
.fnpane-head {
  display: flex; align-items: center; gap: 0.5rem; font-family: var(--display);
  font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  font-size: 0.72rem; color: var(--ink-soft);
  border-bottom: 1px solid var(--rule); padding-bottom: 0.45rem;
  margin-bottom: 0.6rem;
}
.fnpane-head::before {
  content: "\2020"; color: var(--gold); font-size: 0.95rem;
  transform: translateY(1px);
}
#fnpane-toggle { display: none; }
.fnitem { display: none; padding: 0.45rem 0.55rem; border-radius: 6px;
  cursor: pointer; border-left: 2px solid transparent; }
.fnitem.inview, .fnitem.active { display: block; }
.fnitem.active { background: var(--highlight); border-left-color: var(--gold); }
.fnitem:hover { background: var(--paper-2); }
.fnmark { font-weight: 700; font-style: italic; color: var(--num);
  margin-right: 0.15em; }
.fntext { color: var(--ink); }
.fnempty { color: var(--ink-soft); font-style: italic; }
@media (min-width: 1100px) {
  .fnpane {
    position: sticky; top: 3.9rem; align-self: start;
    max-height: calc(100vh - 5rem); overflow-y: auto;
    padding: 0.1rem 0.3rem 0 1.4rem; border-left: 1px solid var(--rule);
  }
}

/* ---- apparatus pane: mobile bottom sheet ---- */
@media (max-width: 1099px) {
  .fnpane {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: var(--paper); border-top: 2px solid var(--gold);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.14);
    padding: 0.5rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
    transform: translateY(calc(100% - 2.4rem));
    transition: transform 0.25s ease;
  }
  .fnpane.open { transform: translateY(0); }
  .fnpane-head { margin-bottom: 0.4rem; border-bottom: none; cursor: pointer; }
  #fnpane-toggle {
    display: block; margin-left: auto; width: 2.6rem; height: 1.1rem;
    border: none; cursor: pointer; background:
      linear-gradient(var(--ink-soft), var(--ink-soft)) center / 2rem 3px
      no-repeat, transparent;
    border-radius: 3px;
  }
  .fnlist { max-height: 40vh; overflow-y: auto; }
  .fnpane:not(.has-visible) { display: none; }
}

/* ---- home ---- */
.home { max-width: 48rem; margin: 0 auto; padding: 1rem 1rem 4rem; }
.hero { text-align: center; margin: 2.5rem 0 3.5rem; }
.hero-mark { color: var(--gold); font-size: 1.6rem; line-height: 1; }
.hero-kicker {
  font-family: var(--display); font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.28em; text-transform: uppercase; color: var(--accent);
  margin: 1rem 0 0.6rem;
}
.hero-title {
  font-family: var(--display); font-weight: 700; letter-spacing: -0.02em;
  font-size: clamp(1.9rem, 5.5vw, 3rem); line-height: 1.08;
  margin: 0 0 1.4rem;
}
.hero-greek {
  font-size: clamp(1.5rem, 4.5vw, 2.2rem); color: var(--ink);
  margin: 0.2rem 0 0.2rem; line-height: 1.3;
}
.hero-english {
  font-style: italic; color: var(--ink-soft); font-size: 1.05rem;
  margin: 0.2rem 0 0;
}
.hero-english .ref { font-style: normal; font-size: 0.82rem;
  letter-spacing: 0.04em; color: var(--gold); }
.hero-rule { width: 5rem; height: 1px; background: var(--gold);
  margin: 1.6rem auto; }
.hero-meta {
  font-family: var(--display); font-size: 0.74rem; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-soft);
  margin: 0 0 1.6rem;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }
.cta {
  display: inline-block; font-family: var(--display); font-weight: 600;
  font-size: 0.9rem; letter-spacing: 0.01em; color: var(--paper);
  background: var(--accent); padding: 0.6rem 1.4rem; border-radius: 5px;
  border: 1px solid var(--accent);
}
.cta:hover { text-decoration: none; filter: brightness(1.08); }
.cta.ghost { background: transparent; color: var(--ink);
  border-color: var(--rule-strong); }
.cta.ghost:hover { border-color: var(--gold); filter: none; }

.book-group h2 {
  font-family: var(--display); font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent);
  border-bottom: 1px solid var(--rule); padding-bottom: 0.35rem;
  margin: 2.2rem 0 0.8rem;
}
.book-list { list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.15rem 1.5rem; }
.book-list li { display: flex; justify-content: space-between;
  padding: 0.32rem 0.4rem; border-radius: 4px;
  border-left: 2px solid transparent; }
.book-list li:hover { background: var(--paper-2);
  border-left-color: var(--gold); }
.book-list a { color: var(--ink); font-weight: 500; }
.book-list a:hover { text-decoration: none; color: var(--accent); }
.chcount { color: var(--ink-soft); font-size: 0.8rem; }

/* ---- prose pages ---- */
.prose { max-width: 46rem; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.prose h1 { font-family: var(--display); font-weight: 700;
  font-size: clamp(1.9rem, 4vw, 2.3rem); letter-spacing: -0.01em;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--rule);
  position: relative; }
.prose h1::after { content: ""; position: absolute; left: 0; bottom: -1px;
  width: 3.5rem; height: 3px; background: var(--gold); }
.prose h2 { font-family: var(--display); font-weight: 600; font-size: 1.25rem;
  margin-top: 2.2rem; }
.prose h3 { font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.prose .verbatim p { margin: 0 0 0.9rem; }
.fm-table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.fm-table td { border: 1px solid var(--rule); padding: 0.6rem 0.8rem;
  vertical-align: top; }
.placeholder { color: var(--ink-soft); font-style: italic; }

/* ---- footer ---- */
.footer { border-top: 1px solid var(--rule); color: var(--ink-soft);
  font-size: 0.85rem; text-align: center; padding: 1.5rem 1rem 2.5rem;
  margin-top: 2rem; }
.footer a { color: var(--ink-soft); }
.footer a:hover { color: var(--accent); }

/* ---- search overlay ---- */
.search-overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(20, 16, 8, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 1rem 0;
}
.search-box { width: 100%; max-width: 34rem; background: var(--paper);
  border: 1px solid var(--rule); border-radius: 10px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3); }
#search-input { width: 100%; font: inherit; font-size: 1.05rem;
  color: var(--ink); background: transparent; border: none; outline: none;
  padding: 0.9rem 1rem; border-bottom: 1px solid var(--rule); }
#search-results { max-height: 50vh; overflow-y: auto; }
#search-results .result { display: block; padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--rule); color: var(--ink); }
#search-results .result:hover { background: var(--paper-2);
  text-decoration: none; }
#search-results .result.ref { font-family: var(--display); font-weight: 600; }
#search-results .result span { display: block; font-size: 0.85rem;
  color: var(--ink-soft); }
#search-results .result mark { background: var(--highlight);
  color: inherit; }

/* ---- about page ---- */
.buy-button {
  display: inline-block; font-family: var(--display); background: var(--accent);
  color: var(--paper); font-weight: 600; padding: 0.6rem 1.4rem;
  border-radius: 6px;
}
.buy-button:hover { text-decoration: none; filter: brightness(1.1); }
.buy-button.is-disabled {
  background: transparent; color: var(--ink-soft); cursor: default;
  border: 1px dashed var(--rule, #d8d0bf); font-weight: 500;
}
.buy-button.is-disabled:hover { filter: none; }
.fineprint { color: var(--ink-soft); font-size: 0.85rem; margin-top: 2rem; }

/* ---- verse spans, underline, chapter sections ---- */
.vtext { border-radius: 3px; }
u { text-decoration-color: var(--accent); text-underline-offset: 3px;
  text-decoration-thickness: 1px; }
section.chapter { margin-bottom: 1.6rem; }
section.chapter { scroll-margin-top: 4rem; }

/* ---- table of contents pane ---- */
.page { display: grid; grid-template-columns: minmax(0, 1fr); }
#toc-btn {
  font: inherit; font-size: 1.15rem; cursor: pointer; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 4px; padding: 0.25rem 0.7rem; line-height: 1;
}
#toc-btn:hover { border-color: var(--gold); }
.toc { padding: 1.2rem 1rem 2rem 1.4rem; font-size: 0.95rem; }
.toc-group h3 {
  font-family: var(--display); font-size: 0.74rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
  border-bottom: 1px solid var(--rule); padding-bottom: 0.25rem;
  margin: 1.3rem 0 0.4rem;
}
.toc-group:first-child h3 { margin-top: 0; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc ul a {
  display: block; color: var(--ink); padding: 0.14rem 0.4rem;
  border-radius: 4px; border-left: 2px solid transparent;
}
.toc ul a:hover { background: var(--paper-2); text-decoration: none; }
.toc ul a.current {
  color: var(--accent); font-weight: 700;
  border-left-color: var(--gold); background: var(--paper-2);
}
.toc-chapters {
  list-style: none; margin: 0.25rem 0 0.5rem; padding: 0 0 0 0.5rem;
  display: flex; flex-wrap: wrap; gap: 2px;
}
.toc-chapters a {
  display: block; min-width: 1.9rem; text-align: center;
  padding: 0.1rem 0.25rem; border-radius: 4px; font-size: 0.85rem;
  color: var(--ink-soft);
}
.toc-chapters a:hover { background: var(--paper-2); color: var(--accent);
  text-decoration: none; }
.toc-chapters a.here {
  background: var(--gold); color: var(--paper); font-weight: 700;
}
.toc-chapters a.here:hover { background: var(--gold); color: var(--paper); }
@media (min-width: 1400px) {
  .page { grid-template-columns: 16rem minmax(0, 1fr); }
  .toc {
    position: sticky; top: 3.9rem; height: calc(100vh - 3.9rem);
    overflow-y: auto; border-right: 1px solid var(--rule);
  }
  #toc-btn { display: none; }
}
@media (max-width: 1399px) {
  .toc {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: 18rem;
    background: var(--paper); overflow-y: auto;
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    transform: translateX(-105%); transition: transform 0.22s ease;
  }
  .toc.open { transform: none; }
}
