
/* ---------------------------------------------------------------
   Barnes on Acts — reader
   Same design family as bridges.marozian.com: a book, not a
   webpage. One column, generous measure, high contrast between
   the biblical text and the exposition so the eye always knows
   which register it's in.
   --------------------------------------------------------------- */

:root {
  --paper:      #faf8f4;
  --ink:        #22201c;
  --ink-soft:   #55504a;
  --ink-faint:  #8a837a;
  --rule:       #e2ddd4;
  --accent:     #7a5c3e;   /* scripture block */
  --scripture-bg: #f3eee4;

  --measure: 38rem;   /* ~70-72 characters — near the top of the classic 45-75ch readable range */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino,
           "Charter", "Georgia", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  --size: 1.1875rem;       /* ~19px base — book-sized, not web-sized */
  --leading: 1.72;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:    #161513;
    --ink:      #e6e1d8;
    --ink-soft: #b0a89c;
    --ink-faint:#7d766c;
    --rule:     #302d28;
    --accent:   #c9a778;
    --scripture-bg: #1f1d19;
  }
}

/* Explicit user choice (data-theme, set by the toggle button + localStorage)
   wins over the system prefers-color-scheme above — an attribute selector
   on :root outranks a bare :root in specificity regardless of source order. */
:root[data-theme="dark"] {
  --paper:    #161513;
  --ink:      #e6e1d8;
  --ink-soft: #b0a89c;
  --ink-faint:#7d766c;
  --rule:     #302d28;
  --accent:   #c9a778;
  --scripture-bg: #1f1d19;
}

:root[data-theme="light"] {
  --paper:      #faf8f4;
  --ink:        #22201c;
  --ink-soft:   #55504a;
  --ink-faint:  #8a837a;
  --rule:       #e2ddd4;
  --accent:     #7a5c3e;
  --scripture-bg: #f3eee4;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--size);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
}

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3.5rem 1.5rem 8rem;
}

/* ---------- Title page ---------- */

.title-page {
  text-align: center;
  padding: 3rem 0 3.5rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.5rem;
}
.title-page .kicker {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 0.75rem;
}
.title-page h1 {
  font-size: 3rem;
  font-weight: 400;
  letter-spacing: -0.015em;
  margin: 0 0 1.5rem;
  line-height: 1.05;
}
.title-page .byline {
  font-size: 1.25rem;
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 0.35rem;
}
.title-page .imprint {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--ink-faint);
  margin: 0;
}

/* ---------- Table of contents ---------- */

.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { border-bottom: 1px solid var(--rule); }
.toc li:first-child { border-top: 1px solid var(--rule); }

.toc a {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.95rem 0.5rem;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.12s ease;
}
.toc a:hover { background: var(--scripture-bg); }
.toc .num {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.toc .label { font-size: 1.0625rem; }
.toc .meta {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--ink-faint);
}
.toc .front-link .label { font-style: italic; }

.colophon {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--ink-faint);
}
.colophon p { margin: 0; }

/* ---------- Chapter head ---------- */

.chapter-head {
  padding-bottom: 2rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--rule);
}
.eyebrow {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 1.25rem;
}
.eyebrow a { color: var(--ink-faint); text-decoration: none; }
.eyebrow a:hover { color: var(--ink); }
.chapter-head h1 {
  font-size: 2.25rem;
  font-weight: 400;
  margin: 0;
  letter-spacing: -0.01em;
}

/* ---------- The unit: scripture + exposition ---------- */

.unit { margin: 0 0 4rem; }
.unit:last-child { margin-bottom: 2rem; }

.scripture {
  background: var(--scripture-bg);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  padding: 1.25rem 1.5rem 1.35rem;
  margin: 0 0 1.75rem;
  scroll-margin-top: 1.5rem;
}

.ref-label {
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.verse {
  margin: 0 0 0.6rem;
  font-size: 1.0625rem;
  line-height: 1.62;
  color: var(--ink);
}
.verse:last-child { margin-bottom: 0; }

.vn {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--accent);
  vertical-align: 0.35em;
  margin-right: 0.4em;
  font-variant-numeric: tabular-nums;
}

.exposition p {
  margin: 0 0 calc(1.15rem + 5px);
  text-align: left;       /* not justified — no hyphenation engine, ragged is cleaner */
  hyphens: auto;
}
.exposition p:last-child { margin-bottom: 0; }

/* First line of each exposition block gets a small opening flourish */
.exposition > p:first-child::first-letter {
  font-size: 1.05em;
}

/* The <i> runs are Barnes' lemma phrases — the exact words from the verse
   he's currently glossing. Bold + italic so they stand out from his own
   commentary prose at a glance, not just a subtle style shift. */
.exposition i {
  font-weight: 700;
}

.ref {
  color: var(--ink-faint);
  font-size: 0.9em;
  cursor: pointer;
  border-bottom: 1px dotted var(--ink-faint);
}
.ref:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* Front matter (introduction) — running prose, headed sections */
.front h2 {
  font-size: 1.25rem;
  font-weight: 400;
  font-style: italic;
  margin: 2.5rem 0 1rem;
  color: var(--ink);
}
.front h2:first-child { margin-top: 0; }

/* ---------- Pager ---------- */

.pager {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem max(1.5rem, calc(50vw - var(--measure) / 2));
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  /* Fully opaque and visibly distinct from the page, not a frosted-glass
     tint of it — also means no scrolled content can show through beneath
     the bar the way the old translucent + blurred version allowed. */
  background: color-mix(in srgb, var(--ink) 8%, var(--paper));
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.8125rem;
}
.pager a { color: var(--ink-soft); text-decoration: none; padding: 0.35rem 0; }
.pager a:hover { color: var(--ink); }
.pager .home { color: var(--ink-faint); }

/* ---------- Theme toggle ---------- */

.theme-toggle {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 20;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: color-mix(in srgb, var(--paper) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--ink); background: var(--scripture-bg); }

/* ---------- ESV cross-reference popup ---------- */

.esv-popup {
  position: absolute;
  z-index: 30;
  width: min(22rem, calc(100vw - 2rem));
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 1rem 1.1rem;
  font-family: var(--sans);
}
.esv-popup-ref {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.5rem;
  font-weight: 600;
}
.esv-popup-text {
  font-family: var(--serif);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
}
.esv-popup-link {
  display: inline-block;
  margin-top: 0.7rem;
  font-size: 0.75rem;
  color: var(--ink-faint);
  text-decoration: none;
}
.esv-popup-link:hover { color: var(--accent); }
.esv-popup-status { font-size: 0.8125rem; color: var(--ink-soft); margin: 0; line-height: 1.5; }
.esv-popup-error { color: #b5453a; }
@media (prefers-color-scheme: dark) { .esv-popup-error { color: #e08a7d; } }
:root[data-theme="dark"] .esv-popup-error { color: #e08a7d; }
:root[data-theme="light"] .esv-popup-error { color: #b5453a; }

/* ---------- Wider screens: give it air, keep the measure ---------- */

@media (min-width: 48rem) {
  :root { --size: 1.25rem; --measure: 40rem; }
  main { padding-top: 5rem; }
  .title-page h1 { font-size: 3.75rem; }
}

/* ---------- Print ---------- */

@media print {
  .pager, .eyebrow, .theme-toggle, .esv-popup { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  main { max-width: none; padding: 0; }
  .unit { page-break-inside: avoid; }
  .scripture { background: #f4f4f4; border-left: 2px solid #999; }
}
