/* ==========================================================================
   The Kretzmann Project — Modernized Reader Stylesheet (Phase 3)
   Legacy #F9F5E1 parchment + #0B2C6B navy Scripture color scheme paired with
   self-hosted Crimson Pro & Inter typography and book-like paper layout.
   Strict CSP compliant: zero external CDNs, zero inline styles required.
   ========================================================================== */

@font-face {
  font-family: "Crimson Pro";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/crimson-pro-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Crimson Pro";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/crimson-pro-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/inter-normal.woff2") format("woff2");
}

:root,
html[data-theme="sepia"] {
  --bg: #f9f5e1;
  --paper: #fdfbf2;
  --surface-alt: #efe8ca;
  --header-bg: #163063;
  --header-fg: #f4e9c1;
  --header-fg-hover: #ffffff;
  --header-border: #0e2044;
  --header-accent: #e4d693;
  --fg: #1f1b16;
  --muted: #5c5346;
  --border: #d6cca3;
  --accent: #163a7a;
  --accent-hover: #0c2554;
  --scripture: #0b2c6b;
  --mark-bg: #f2dc7e;
  --mark-fg: #1f1b16;
  --mark-current-bg: #f5b82e;
  --target-bg: #fff0ad;
  --shadow: 0 4px 18px rgba(31, 27, 22, 0.1);
  --font-book: "Crimson Pro", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-ui: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --reader-font-size: 1.18rem;
  --z-header: 200;
  --z-hl-bar: 220;
  --z-drawer-backdrop: 240;
  --z-drawer: 260;
  --z-popover: 400;
  --z-skip-link: 1000;
}

html[data-theme="light"] {
  --bg: #f0ece0;
  --paper: #ffffff;
  --surface-alt: #f3f4f6;
  --header-bg: #163063;
  --header-fg: #f4e9c1;
  --header-fg-hover: #ffffff;
  --header-border: #0e2044;
  --header-accent: #e4d693;
  --fg: #1b1f23;
  --muted: #57606a;
  --border: #d8d4c8;
  --accent: #163a7a;
  --accent-hover: #0c2554;
  --scripture: #0b2c6b;
  --mark-bg: #fff1a8;
  --mark-fg: #1b1f23;
  --mark-current-bg: #ffcf4d;
  --target-bg: #fff6c2;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

html[data-theme="dark"] {
  --bg: #151310;
  --paper: #1f1c18;
  --surface-alt: #2a2620;
  --header-bg: #101a30;
  --header-fg: #e6d8a8;
  --header-fg-hover: #ffffff;
  --header-border: #2a3550;
  --header-accent: #e4d693;
  --fg: #e8e2d5;
  --muted: #b0a695;
  --border: #3b352c;
  --accent: #7fb2f0;
  --accent-hover: #a9cefa;
  --scripture: #9cc5f8;
  --mark-bg: #5c4c18;
  --mark-fg: #fff8dc;
  --mark-current-bg: #8f6f14;
  --target-bg: #403513;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

/* Text Size Scale (M = 1.18rem default, tuned for Crimson Pro x-height) */
html[data-size="s"] { --reader-font-size: 1.05rem; }
html[data-size="m"] { --reader-font-size: 1.18rem; }
html[data-size="l"] { --reader-font-size: 1.34rem; }
html[data-size="xl"] { --reader-font-size: 1.52rem; }

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-underline-offset: 0.16em;
}

a:hover,
a:focus-visible {
  color: var(--accent-hover);
}

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

img {
  max-width: 100%;
  height: auto;
}

/* Skip Link (Accessibility) */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: var(--z-skip-link);
  background: var(--header-accent);
  color: var(--header-bg);
  padding: 0.6rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  left: 0.75rem;
  top: 0.75rem;
  color: var(--header-bg);
}

/* ==========================================================================
   Sticky Top Header (Classic Navy + Warm Gold + Luther Seal)
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--header-bg);
  color: var(--header-fg);
  border-bottom: 2px solid var(--header-border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
  padding: 0.6rem 1.25rem;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
}

.header-brand-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--header-fg);
  text-decoration: none;
}

.brand-link:hover,
.brand-link:focus-visible {
  color: var(--header-fg-hover);
}

.brand-seal {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-book);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

.brand-subtitle {
  font-size: 0.72rem;
  opacity: 0.85;
  line-height: 1.2;
}

/* Hamburger Menu Button (Mobile) */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(244, 233, 193, 0.35);
  border-radius: 5px;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--header-fg);
  border-radius: 1px;
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.header-search {
  display: flex;
  align-items: center;
}

.header-search input[type="search"] {
  width: 13.5rem;
  max-width: 52vw;
  padding: 0.38rem 0.6rem;
  border: 1px solid var(--header-border);
  border-right: none;
  border-radius: 4px 0 0 4px;
  background: var(--paper);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 0.84rem;
}

.header-search button {
  padding: 0.38rem 0.75rem;
  border: 1px solid var(--header-accent);
  border-radius: 0 4px 4px 0;
  background: var(--header-accent);
  color: var(--header-bg);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.header-search button:hover {
  background: var(--header-fg-hover);
  border-color: var(--header-fg-hover);
}

.btn {
  display: inline-block;
  padding: 0.42rem 0.85rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover,
.btn:focus-visible {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

/* Reader Appearance Controls (Theme & Text Size — hidden when JS is disabled, P3-PE-01) */
.reader-prefs {
  display: none;
  align-items: center;
  gap: 0.4rem;
}

html.js-enabled .reader-prefs {
  display: inline-flex;
}

.pref-group {
  display: inline-flex;
  border: 1px solid rgba(244, 233, 193, 0.35);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.16);
}

.pref-btn {
  border: none;
  border-right: 1px solid rgba(244, 233, 193, 0.25);
  background: transparent;
  color: var(--header-fg);
  padding: 0.26rem 0.46rem;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.pref-btn:last-child {
  border-right: none;
}

.pref-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.pref-btn[aria-pressed="true"] {
  background: var(--header-accent);
  color: var(--header-bg);
}

/* Mobile-only preferences inside the hamburger drawer */
.mobile-reader-prefs {
  display: none;
  margin-bottom: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.mobile-reader-prefs .pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.mobile-reader-prefs .pref-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.mobile-reader-prefs .pref-group {
  border-color: var(--border);
  background: var(--bg);
}

.mobile-reader-prefs .pref-btn {
  color: var(--fg);
  border-right-color: var(--border);
}

.mobile-reader-prefs .pref-btn:hover {
  background: var(--surface-alt);
}

.mobile-reader-prefs .pref-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #ffffff;
}

/* ==========================================================================
   Main Layout: Elevated Sidebar + Elevated Paper Reading Sheet
   ========================================================================== */
.layout {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 1.75rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 4.85rem;
  max-height: calc(100vh - 5.75rem);
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 1.05rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.86rem;
}

.sidebar-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 0.45rem;
}

.sidebar-heading-spaced {
  margin-top: 1.05rem;
}

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

.sidebar-nav-list li {
  margin: 0.15rem 0;
}

.sidebar a {
  display: block;
  padding: 0.24rem 0.45rem;
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
}

.sidebar a:hover {
  background: var(--surface-alt);
  color: var(--accent);
}

.sidebar a[aria-current="page"] {
  background: var(--surface-alt);
  color: var(--accent);
  font-weight: 700;
}

.sidebar details {
  border-top: 1px solid var(--border);
  padding: 0.4rem 0;
}

.sidebar summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--fg);
  padding: 0.2rem 0.25rem;
  list-style-position: inside;
}

.sidebar summary:hover {
  color: var(--accent);
}

.sidebar details ul {
  list-style: none;
  padding: 0.25rem 0 0.25rem 0.5rem;
  margin: 0;
}

.sidebar details li {
  margin: 0.08rem 0;
}

.book-pending {
  display: block;
  padding: 0.2rem 0.45rem;
  color: var(--muted);
}

.drawer-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  font-family: var(--font-book);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fg);
}

.drawer-close {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 4px;
  padding: 0.25rem 0.65rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.drawer-close:hover {
  background: var(--surface-alt);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: var(--z-drawer-backdrop);
}

body.drawer-open {
  overflow: hidden;
}

/* Elevated Paper Reading Sheet */
.content {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 2.25rem 3.5rem;
}

.breadcrumbs {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1.1rem;
}

.breadcrumbs ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.breadcrumbs li + li::before {
  content: "/";
  margin-right: 0.35rem;
  color: var(--muted);
}

.breadcrumbs a {
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

/* Book-Style Typography (Crimson Pro) */
.doc-header {
  text-align: center;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0 0 0.4rem;
  font-family: var(--font-book);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--fg);
}

h2 {
  margin: 1.85rem 0 0.85rem;
  font-family: var(--font-book);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.28;
  text-align: center;
  color: var(--fg);
}

h3 {
  margin: 1.45rem 0 0.6rem;
  font-family: var(--font-book);
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1.32;
  color: var(--fg);
}

.subtitle {
  margin: 0;
  font-family: var(--font-book);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--muted);
}

.doc-header-actions {
  margin: 0.85rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.85rem;
}

.commentary-body,
.reader-prose {
  font-family: var(--font-book);
  font-size: var(--reader-font-size);
  line-height: 1.72;
  max-width: 66ch;
  margin: 0 auto;
}

.commentary-body p,
.reader-prose p {
  margin: 0 0 1.2em;
}

/* Bold Scripture quotations in classic Kretzmann deep navy */
.commentary-body strong {
  color: var(--scripture);
  font-weight: 700;
}

.commentary-body blockquote,
.reader-prose blockquote {
  margin: 1.25rem 0 1.25rem 1rem;
  padding: 0.45rem 0 0.45rem 1.1rem;
  border-left: 4px solid var(--border);
  font-style: italic;
  color: var(--muted);
}

.commentary-body table,
.reader-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.35rem 0;
  font-size: 0.94em;
  background: var(--bg);
}

.commentary-body th,
.commentary-body td,
.reader-prose th,
.reader-prose td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.commentary-body th,
.reader-prose th {
  background: var(--surface-alt);
  font-weight: 700;
}

/* Verse Anchors & Target Highlighting */
.verse-anchor {
  scroll-margin-top: 5.5rem;
}

.verse-anchor:target + strong,
.verse-anchor:target {
  background: var(--target-bg);
  border-radius: 3px;
}

/* Prev / Next Chapter Navigation */
.chapter-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem auto;
  max-width: 66ch;
  padding: 0.6rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
}

.chapter-nav a {
  text-decoration: none;
  font-weight: 600;
}

.chapter-nav a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Footnotes & Accessible Inline Popover
   ========================================================================== */
sup.footnote-ref a {
  font-family: var(--font-ui);
  font-size: 0.74em;
  font-weight: 700;
  padding: 0.05em 0.2em;
  text-decoration: none;
  border-radius: 3px;
}

sup.footnote-ref a:hover {
  background: var(--surface-alt);
}

.footnotes {
  margin: 2.25rem auto 0;
  max-width: 66ch;
  border-top: 2px solid var(--border);
  padding-top: 1rem;
  font-family: var(--font-book);
  font-size: 1.04rem;
  line-height: 1.62;
  color: var(--muted);
}

.footnotes-sep {
  display: none;
}

.footnotes-list {
  padding-left: 1.4rem;
}

.footnotes-list li {
  margin-bottom: 0.55rem;
  scroll-margin-top: 5.5rem;
}

.footnotes-list li:target {
  background: var(--target-bg);
  color: var(--fg);
  padding: 0.25rem 0.45rem;
  border-radius: 4px;
}

.footnote-backref {
  margin-left: 0.35rem;
  text-decoration: none;
  font-family: var(--font-ui);
}

.fn-popover {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  width: min(36rem, calc(100vw - 2rem));
  max-height: 45vh;
  overflow-y: auto;
  z-index: var(--z-popover);
  background: var(--paper);
  color: var(--fg);
  border: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  padding: 0.9rem 1.1rem;
}

.fn-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.84rem;
}

.fn-popover-close {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 4px;
  padding: 0.18rem 0.55rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.fn-popover-close:hover {
  background: var(--surface-alt);
}

.fn-popover-body {
  font-family: var(--font-book);
  font-size: 1.02rem;
  line-height: 1.55;
}

.fn-popover-body p {
  margin: 0 0 0.5rem;
}

.fn-popover-footer {
  margin-top: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
}

/* ==========================================================================
   Home, Directory, Book Chapter Grid, Articles, Maps & Search
   ========================================================================== */
.home-hero {
  text-align: center;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.home-search-card {
  max-width: 66ch;
  margin: 1.5rem auto 2rem;
  padding: 1rem 1.15rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.home-search-card form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.home-search-card input[type="search"] {
  flex: 1 1 16rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 0.92rem;
}

/* Whole-card clickable volume links */
.volume-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.75rem;
}

.volume-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.05rem 1.15rem;
  text-decoration: none;
  color: var(--fg);
}

.volume-card:hover,
.volume-card:focus-visible {
  background: var(--surface-alt);
  border-color: var(--accent);
  color: var(--fg);
  transform: translateY(-1px);
}

.volume-card-title {
  display: block;
  font-family: var(--font-book);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.volume-card-desc {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.84rem;
  color: var(--muted);
}

.book-list-grid {
  list-style: none;
  padding: 0;
  margin: 0.85rem 0 1.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 0.55rem;
}

.book-list-grid li {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.book-list-grid a {
  text-decoration: none;
  font-weight: 600;
}

.book-list-grid a:hover {
  text-decoration: underline;
}

.chap-meta {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Book Overview: Intro Callout & Compact Chapter Number Grid */
.intro-callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.05rem;
  margin: 1.25rem 0 1.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 5px;
}

.intro-callout-title {
  font-family: var(--font-book);
  font-size: 1.15rem;
  font-weight: 700;
}

.intro-callout-desc {
  font-size: 0.84rem;
  color: var(--muted);
}

.chapter-grid {
  list-style: none;
  padding: 0;
  margin: 0.9rem 0 1.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.2rem, 1fr));
  gap: 0.45rem;
}

.chapter-grid a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.55rem;
  padding: 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}

.chapter-grid a:hover,
.chapter-grid a:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.related-articles {
  margin: 2rem auto 0;
  max-width: 66ch;
  padding: 1rem 1.2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.related-articles h2 {
  margin-top: 0;
  font-size: 1.25rem;
  text-align: left;
}

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

.article-list li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem 0.8rem;
}

.article-list a {
  font-family: var(--font-book);
  font-size: 1.12rem;
  font-weight: 600;
  text-decoration: none;
}

.article-list a:hover {
  text-decoration: underline;
}

.article-book-badge {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
}

/* Maps Gallery */
.maps-body {
  max-width: 66ch;
  margin: 0 auto;
  font-family: var(--font-book);
  font-size: var(--reader-font-size);
}

.maps-body h3 {
  margin-top: 1.75rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.maps-body img {
  display: block;
  margin: 0.85rem auto;
  padding: 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Search Page */
.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.95rem 1rem;
  margin: 1rem 0 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.search-form input[type="search"] {
  flex: 1 1 16rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 0.92rem;
}

.search-form select {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 0.86rem;
}

.search-notices {
  list-style: none;
  padding: 0.65rem 0.9rem;
  margin: 0.75rem 0 1rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.86rem;
}

.search-tips {
  margin: 0 0 1.25rem;
  padding: 0.65rem 0.95rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.86rem;
}

.search-tips summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}

.search-tips ul {
  margin: 0.65rem 0 0.2rem;
  padding-left: 1.25rem;
}

.search-tips li {
  margin-bottom: 0.35rem;
}

.search-tips code {
  background: var(--surface-alt);
  padding: 0.08rem 0.3rem;
  border-radius: 3px;
  font-size: 0.84em;
}

.citation-jump-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  margin: 0 0 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
}

.citation-jump-kicker {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
}

.citation-jump-title {
  font-family: var(--font-book);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--fg);
}

.search-meta {
  font-size: 0.9rem;
  color: var(--muted);
}

.search-elapsed {
  font-size: 0.84rem;
}

.search-results {
  padding-left: 1.35rem;
}

.search-results li {
  margin-bottom: 1.15rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.search-results p {
  font-family: var(--font-book);
  font-size: 1.04rem;
  margin: 0.35rem 0 0;
}

mark {
  background: var(--mark-bg);
  color: var(--fg);
  padding: 0.05em 0.18em;
  border-radius: 2px;
}

/* Footer */
.site-footer {
  background: var(--header-bg);
  color: var(--header-fg);
  border-top: 2px solid var(--header-border);
  padding: 1.1rem 1.25rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.25rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
}

.footer-links a {
  color: var(--header-fg);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--header-fg-hover);
  text-decoration: underline;
}

/* ==========================================================================
   Responsive Breakpoints (Tablet & Mobile)
   ========================================================================== */
@media (max-width: 960px) {
  .layout {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 1.25rem;
  }

  .content {
    padding: 1.75rem 2rem;
  }
}

@media (max-width: 768px) {
  html.js-enabled .menu-toggle {
    display: inline-flex;
  }

  html.js-enabled .header-prefs-desktop,
  .header-prefs-desktop {
    display: none;
  }

  html.js-enabled .mobile-reader-prefs {
    display: block;
  }

  html.js-enabled .drawer-header {
    display: flex;
  }

  .brand-subtitle {
    display: none;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 1rem 0.75rem 2rem;
  }

  /* Without JS, sidebar renders cleanly below <main> so all links remain reachable (P3-PE-01) */
  .sidebar {
    position: static;
    max-height: none;
    order: 2;
  }

  .content {
    order: 1;
    padding: 1.35rem 1.15rem;
  }

  html.js-enabled .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    max-height: 100vh;
    z-index: var(--z-drawer);
    border-radius: 0;
    order: 0;
    transform: translateX(-105%);
  }

  html.js-enabled .sidebar.is-open {
    transform: translateX(0);
  }

  .commentary-body table,
  .reader-prose table {
    display: block;
    overflow-x: auto;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .volume-card {
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
  }

  html.js-enabled .sidebar {
    transition: transform 0.2s ease;
  }
}

/* ==========================================================================
   Floating Search Term Highlight Bar (?hl=) (P4-SM-01)
   ========================================================================== */
body.has-hl-bar {
  padding-bottom: 5.5rem;
}

@media (max-width: 640px) {
  body.has-hl-bar {
    padding-bottom: 6.75rem;
  }
}

.hl-bar {
  position: fixed;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  z-index: var(--z-hl-bar);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  width: min(36rem, calc(100vw - 1.5rem));
  padding: 0.6rem 0.9rem;
  background: var(--paper);
  border: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.24);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  color: var(--fg);
}

.hl-bar[hidden] {
  display: none;
}

.hl-bar-status {
  font-weight: 600;
}

.hl-bar-actions {
  display: inline-flex;
  gap: 0.35rem;
}

.hl-bar-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--fg);
  border-radius: 4px;
  padding: 0.28rem 0.65rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.hl-bar-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hl-bar-clear {
  margin-left: 0.2rem;
}

mark.search-hl {
  background: var(--mark-bg);
  color: var(--mark-fg);
  padding: 0.04em 0.16em;
  border-radius: 3px;
  scroll-margin-top: 6rem;
}

mark.search-hl.is-current {
  background: var(--mark-current-bg);
  color: var(--mark-fg);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ==========================================================================
   Print Stylesheet (Sermon Prep & Bible Study Handouts)
   ========================================================================== */
@media print {
  :root,
  html[data-theme="sepia"],
  html[data-theme="light"],
  html[data-theme="dark"] {
    --bg: #ffffff;
    --paper: #ffffff;
    --surface-alt: #ffffff;
    --fg: #000000;
    --muted: #333333;
    --border: #999999;
    --accent: #000000;
    --scripture: #000000;
  }

  body {
    background: #ffffff;
    color: #000000;
    font-size: 11pt;
    line-height: 1.5;
  }

  .skip-link,
  .site-header,
  .sidebar,
  .drawer-backdrop,
  .chapter-nav,
  .hl-bar,
  .fn-popover,
  .site-footer,
  .reader-prefs,
  .menu-toggle {
    display: none !important;
  }

  mark.search-hl {
    background: transparent !important;
    color: inherit !important;
    outline: none !important;
    padding: 0;
  }

  .layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  .content {
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: none;
  }

  .commentary-body,
  .reader-prose {
    max-width: none;
  }

  h1,
  h2,
  h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  a {
    color: #000000;
    text-decoration: none;
  }

  .footnotes {
    max-width: none;
    border-top: 1pt solid #666666;
    font-size: 9.5pt;
  }

  .footnote-backref {
    display: none;
  }
}
