/* ==========================================================================
   Bible Navigator - Modern UI layer
   Loaded after style.css. Refreshes design tokens, type, and the shared
   components (nav, breadcrumbs, buttons, chips, inputs, cards, footer,
   floating controls) so every page picks up the same modern system.
   Scripture text keeps the serif reading face; interface text uses Inter.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  --color-bg: #faf8f4;
  --color-bg-alt: #f3efe7;
  --color-surface: #ffffff;
  --color-surface-raised: #ffffff;
  --color-text: #1c1915;
  --color-text-muted: #675e53;
  --color-text-subtle: #73685c;
  --color-primary: #2b231c;
  --color-primary-light: #4a3d31;
  --color-primary-dark: #1c1915;
  --color-accent: #856113;
  --color-accent-light: #a27a1f;
  --color-accent-soft: rgba(138, 101, 22, 0.09);
  --color-border: #e6dfd2;
  --color-border-light: #eee8de;
  --color-border-strong: #d6ccbb;
  --color-link: #7a5a13;
  --color-link-hover: #5c430d;
  --color-nav-bg: rgba(250, 248, 244, 0.82);
  --color-nav-text: #1c1915;
  --color-nav-active: #8a6516;
  --color-verse-num: #9a8f80;
  --color-hover: rgba(28, 25, 21, 0.05);
  --color-ink: #1c1915;
  --color-on-ink: #faf8f4;

  --nav-h: 60px;

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 9999px;

  --shadow-subtle: 0 1px 2px rgba(28, 22, 14, 0.04);
  --shadow: 0 1px 2px rgba(28, 22, 14, 0.04), 0 2px 8px rgba(28, 22, 14, 0.04);
  --shadow-card: 0 1px 2px rgba(28, 22, 14, 0.04), 0 2px 10px -2px rgba(28, 22, 14, 0.05);
  --shadow-hover: 0 2px 4px rgba(28, 22, 14, 0.04), 0 14px 32px -10px rgba(28, 22, 14, 0.18);
  --shadow-pop: 0 4px 8px rgba(28, 22, 14, 0.05), 0 24px 48px -12px rgba(28, 22, 14, 0.22);

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --transition: 0.18s var(--ease);
  --transition-slow: 0.32s var(--ease);

  --max-width: 1080px;
}

html.dark-mode {
  --color-bg: #0f0e0c;
  --color-bg-alt: #161411;
  --color-surface: #1b1916;
  --color-surface-raised: #23201c;
  --color-text: #f1ebe0;
  --color-text-muted: #a99f90;
  --color-text-subtle: #958a7b;
  --color-primary: #d6b26c;
  --color-primary-light: #e3c486;
  --color-primary-dark: #f1ebe0;
  --color-accent: #d6b26c;
  --color-accent-light: #e3c486;
  --color-accent-soft: rgba(214, 178, 108, 0.11);
  --color-border: #2c2823;
  --color-border-light: #25221e;
  --color-border-strong: #3b352e;
  --color-link: #dcbb78;
  --color-link-hover: #ecd19b;
  --color-nav-bg: rgba(15, 14, 12, 0.78);
  --color-nav-text: #f1ebe0;
  --color-nav-active: #d6b26c;
  --color-verse-num: #8d8372;
  --color-hover: rgba(241, 235, 224, 0.06);
  --color-ink: #d6b26c;
  --color-on-ink: #17140f;

  --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.3), 0 16px 36px -12px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 4px 8px rgba(0, 0, 0, 0.3), 0 24px 48px -12px rgba(0, 0, 0, 0.7);
}

/* ---------- 2. Base ---------- */
body {
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.6;
  background: var(--color-bg);
  background-image: none;
  color: var(--color-text);
  font-feature-settings: "cv11", "ss01";
  text-rendering: optimizeLegibility;
}
html.dark-mode body { background-image: none; }

main { animation: none; }

::selection { background: var(--color-accent-soft); color: inherit; }
html.dark-mode ::selection { background: rgba(214, 178, 108, 0.28); }

h1, h2, h3, h4, h5, h6 {
  color: var(--color-text);
  font-feature-settings: normal;
}
h1 {
  font-family: var(--font-reading-display);
  font-weight: 500;
  font-size: clamp(2.1rem, 1.5rem + 2vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.015em;
}
h2 { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
h3 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; }
h4 { font-size: 0.95rem; font-weight: 600; }

a { transition: color var(--transition), background-color var(--transition), border-color var(--transition); }
a:hover, a:focus { text-decoration: none; }
p a:hover, li > a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

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

/* Scripture and long-form reading keep the serif reading face */
.chapter-text, .verse, .verse-text, .verse-first, .character-bio p, .votd-text, .votd-quote,
.event-intro-quote, blockquote, .passage-text, .seo-passage-text, .harmony-column-text,
.commentary-transcript, .commentary-section-text, .devotional-reflection {
  font-family: var(--font-reading);
}

.container { max-width: var(--max-width); padding-top: 2.5rem; }

/* ---------- 3. Navigation ---------- */
.navbar {
  min-height: var(--nav-h);
  background-color: var(--color-nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--color-border);
  box-shadow: none;
  gap: 0.25rem;
}
html.dark-mode .navbar { border-bottom-color: var(--color-border); box-shadow: none; }

.navbar-brand { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.02em; color: var(--color-text); }
.navbar-brand:hover { color: var(--color-text); }
.brand-icon { font-size: 1.1rem; color: var(--color-accent); }

.navbar-nav { gap: 0.15rem; }
.navbar-nav > li > a,
.nav-dropdown-toggle {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-pill);
}
.navbar-nav > li > a::after { display: none; }
.navbar-nav > li > a:hover,
.nav-dropdown-toggle:hover,
.nav-dropdown--mega:focus-within > .nav-dropdown-toggle {
  color: var(--color-text);
  background-color: var(--color-hover);
}
.navbar-nav > li > a.active {
  color: var(--color-text);
  font-weight: 600;
  background-color: var(--color-hover);
}
.navbar-nav > li > a.nav-search-link { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; }

.nav-dark-toggle {
  color: var(--color-text-muted);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.nav-dark-toggle:hover { background-color: var(--color-hover); color: var(--color-text); }
.nav-toggle:hover { background-color: var(--color-hover); }
.nav-toggle-bar { background-color: var(--color-text); }

.nav-audio-controls { gap: 0.25rem; margin-left: 0.5rem; padding-left: 0.75rem; border-left: 1px solid var(--color-border); }
.nav-autoplay-slider { background: var(--color-border-strong); }
.nav-play-btn { opacity: 1; }
.nav-animate-btn {
  background: var(--color-ink);
  color: var(--color-on-ink);
  box-shadow: none;
  font-weight: 600;
  padding: 0.38rem 0.85rem;
  margin-left: 0.25rem;
}
.nav-animate-btn:hover { background: var(--color-ink); color: var(--color-on-ink); opacity: 0.9; box-shadow: none; }

/* Mega menu: floating panel */
.nav-mega-menu {
  top: calc(100% + 8px);
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: min(1040px, calc(100vw - 2rem));
  background-color: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 1.75rem 2rem;
  gap: 1.5rem;
}
.nav-mega-menu::before { top: -12px; height: 12px; }
.mega-heading {
  color: var(--color-text-subtle);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0.5rem;
}
.mega-col a {
  color: var(--color-text-muted) !important;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  padding: 0.3rem 0.55rem;
  margin: 0 -0.55rem;
  border-radius: var(--radius-xs);
}
.mega-col a:hover { color: var(--color-text) !important; background-color: var(--color-hover); text-decoration: none; }
.mega-col a[href="/beginners"] { color: var(--color-accent) !important; font-weight: 600; }

/* ---------- 4. Breadcrumbs ---------- */
.breadcrumbs {
  position: static;
  background: transparent;
  border-bottom: none;
  padding-top: 1.1rem;
  padding-bottom: 0;
}
.breadcrumbs ol { max-width: var(--max-width); margin: 0 auto; font-size: 0.8125rem; color: var(--color-text-subtle); }
.breadcrumbs a { color: var(--color-text-muted); }
.breadcrumbs a:hover { color: var(--color-text); text-decoration: none; }
.breadcrumbs li[aria-current="page"] { color: var(--color-text); }
html.dark-mode .breadcrumbs { background: transparent; }

/* Reader sticky toolbar now sits directly under the nav */
.chapter-sticky-bar {
  top: var(--nav-h);
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-top: 0.5rem;
}
html.dark-mode .chapter-sticky-bar { background: color-mix(in srgb, var(--color-surface) 90%, transparent); border-color: var(--color-border); }

/* ---------- 5. Buttons ---------- */
.dimension-hero-cta, .hero-btn-primary, .cta-primary, .hero-cta, .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1.35rem;
  border-radius: var(--radius-pill);
  background: var(--color-ink);
  background-image: none;
  color: var(--color-on-ink);
  border: 1px solid transparent;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-subtle);
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}
.dimension-hero-cta:hover, .hero-btn-primary:hover, .cta-primary:hover, .hero-cta:hover, .btn-primary:hover {
  color: var(--color-on-ink);
  background: var(--color-ink);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
  text-decoration: none;
}
.hero-btn-secondary, .cta-secondary, .hero-btn:not(.hero-btn-primary) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 1.35rem;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-subtle);
  text-decoration: none;
}
.hero-btn-secondary:hover, .cta-secondary:hover, .hero-btn:not(.hero-btn-primary):hover {
  color: var(--color-text);
  border-color: var(--color-border-strong);
  background: var(--color-surface);
  text-decoration: none;
}
.dimension-hero-secondary { color: var(--color-text-muted); font-weight: 500; font-size: 0.9375rem; }
.dimension-hero-secondary:hover { color: var(--color-text); text-decoration: none; }

/* ---------- 6. Chips and filters ---------- */
.filter-pill, .search-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 32px;
  padding: 0 0.85rem;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  box-shadow: none;
  transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}
.filter-pill:hover:not(.active), .search-chip:hover:not(.active) {
  color: var(--color-text);
  border-color: var(--color-border-strong);
  background: var(--color-surface);
}
.filter-pill.active, .search-chip.active {
  background: var(--color-ink);
  border-color: var(--color-ink);
  color: var(--color-on-ink);
}
html.dark-mode .filter-pill, html.dark-mode .search-chip { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text-muted); }
html.dark-mode .filter-pill.active, html.dark-mode .search-chip.active { background: var(--color-ink); border-color: var(--color-ink); color: var(--color-on-ink); }
.filter-pills { gap: 0.4rem; }
.filter-label {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
}
.filter-count {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  color: var(--color-text-subtle);
  background: transparent;
  border: none;
}

/* ---------- 7. Inputs ---------- */
.filter-bar input,
input[type="search"], input[type="text"].search-input, .books-page-search, .home-search-input,
.search-page input[type="text"], .character-list-page input[type="text"], .character-list-page input[type="search"] {
  font-family: var(--font-ui) !important;
  font-size: 0.9375rem !important;
  min-height: 44px;
  padding: 0.65rem 1rem !important;
  border-radius: var(--radius) !important;
  border: 1px solid var(--color-border) !important;
  background: var(--color-surface) !important;
  color: var(--color-text) !important;
  box-shadow: var(--shadow-subtle) !important;
}
.filter-bar input:focus,
input[type="search"]:focus, input[type="text"].search-input:focus, .books-page-search:focus, .home-search-input:focus,
.character-list-page input[type="text"]:focus, .character-list-page input[type="search"]:focus {
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 0 4px var(--color-accent-soft) !important;
  outline: none !important;
}
input::placeholder { color: var(--color-text-subtle); opacity: 1; }
select {
  font-family: var(--font-ui);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background-color: var(--color-surface);
  color: var(--color-text);
}

/* ---------- 8. Surfaces and cards ---------- */
.bio-card, .character-bio, .chapter-facts-section, .key-chapters-section, .about-book-section,
.related-section, .passage-section, .next-chapter-card, .beginners-card, .tip-card, .plan-card,
.beginners-start-card, .storyline-card, .reading-plan-card, .book-tile, .timeline-event-item,
.character-list .character-item, .character-list > li, .key-chapter-card, .dim-card, .chapter-fact {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.chapter-fact, .key-chapter-card, .dim-card { border-radius: var(--radius); }
.character-bio { border-left-width: 1px; }

/* Interactive cards lift on hover */
.character-list .character-item, .character-list > li, .key-chapter-card, .dim-card, .book-tile,
.timeline-event-item, .reading-plan-card, .beginners-start-card, .storyline-card, .plan-card {
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
@media (hover: hover) and (pointer: fine) {
  .character-list .character-item:hover, .character-list > li:hover, .key-chapter-card:hover, .dim-card:hover,
  .book-tile:hover, .timeline-event-item:hover, .reading-plan-card:hover, .beginners-start-card:hover,
  .storyline-card:hover, .plan-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-hover);
  }
}
html.dark-mode .bio-card, html.dark-mode .passage-section, html.dark-mode .next-chapter-card,
html.dark-mode .character-list li, html.dark-mode .timeline-event-item {
  background-color: var(--color-surface);
  border-color: var(--color-border);
}

/* Card typography: names as UI headings, descriptions as quiet body text */
.character-name {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.015em;
  color: var(--color-text);
}
.character-description, .passage-summary, .book-tile-meta, .books-group-desc, .key-chapter-meta {
  font-family: var(--font-ui);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.55;
}

/* Section headings inside detail pages */
.bio-card h2, .chapter-facts-section h2, .key-chapters-section h2, .related-section h2,
.character-list-page h2, .books-section-title, .search-section-title {
  font-family: var(--font-ui);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

/* Eyebrow labels (all-caps meta) */
.passage-label, .key-chapter-meta, .feature-eyebrow, .home-kicker {
  letter-spacing: 0.08em;
}

/* ---------- 9. Dimension heroes (list-page headers) ---------- */
.dimension-hero {
  background: linear-gradient(180deg, var(--color-accent-soft), transparent 75%), var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: clamp(1.5rem, 1rem + 2.5vw, 2.75rem);
}
html.dark-mode .dimension-hero { box-shadow: var(--shadow-card); }
.dimension-hero h1 {
  font-family: var(--font-reading-display);
  font-weight: 500;
  font-size: clamp(2rem, 1.5rem + 1.8vw, 2.75rem);
  letter-spacing: -0.015em;
  color: var(--color-text);
}
.dimension-hero .dimension-icon { display: none; }
.dimension-hero-sub {
  font-family: var(--font-ui);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--color-text-muted);
  max-width: 34rem;
}

/* ---------- 10. Page headers ---------- */
.character-list-page > h1, .books-page-header h1, .beginners-page h1, .character-detail-page > h1 {
  margin-bottom: 0.75rem;
}
.books-page-header p, .beginners-intro {
  font-family: var(--font-ui);
  color: var(--color-text-muted);
}

/* ---------- 11. Footer ---------- */
.site-footer {
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  text-align: left;
  padding: 3rem 2rem calc(3rem + env(safe-area-inset-bottom, 0px));
  margin-top: 5rem;
}
html.dark-mode .site-footer { background: var(--color-bg-alt); }
.footer-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 2rem 3rem;
  align-items: start;
}
.footer-brand { color: var(--color-text); font-size: 1rem; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 0.5rem; }
.footer-brand::before { content: "\2726  "; color: var(--color-accent); white-space: pre; }
.footer-domain { color: var(--color-text-subtle); opacity: 1; }
.footer-text { color: var(--color-text-muted); font-size: 0.8125rem; line-height: 1.6; }
.footer-legal { color: var(--color-text-subtle); font-size: 0.75rem; }
.footer-text a, .footer-legal a { color: var(--color-text-muted); text-decoration: underline; text-underline-offset: 2px; }
.footer-meta { grid-column: 1; }
.footer-links {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem 1.5rem;
  margin: 0;
  justify-content: stretch;
}
.footer-links a {
  color: var(--color-text-muted);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  margin: 0;
  padding: 0;
}
.footer-links a:hover { color: var(--color-text); text-decoration: none; }
@media (max-width: 768px) {
  .site-footer { padding: 2.5rem 1.25rem calc(6rem + env(safe-area-inset-bottom, 0px)); }
  .footer-content { grid-template-columns: 1fr; }
  .footer-links { grid-column: 1; grid-row: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 12. Floating controls ---------- */
.dimensions-fab-bar { bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)) !important; }
.dimensions-fab {
  height: 40px;
  background: var(--color-ink) !important;
  color: var(--color-on-ink) !important;
  border: 1px solid transparent !important;
  box-shadow: var(--shadow-pop);
  font-size: 0.8125rem;
  letter-spacing: -0.005em;
  opacity: 0.96;
}
html.dark-mode .dimensions-fab { background: var(--color-surface-raised) !important; color: var(--color-text) !important; border-color: var(--color-border-strong) !important; }

.back-to-reading {
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  left: calc(1.25rem + env(safe-area-inset-left, 0px));
  max-width: min(320px, calc(50vw - 5rem));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 1rem;
  height: 40px;
  line-height: 40px;
  background: color-mix(in srgb, var(--color-surface-raised) 92%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-hover);
  font-size: 0.8125rem;
  font-weight: 500;
}
.back-to-reading::before { content: "\2190  "; white-space: pre; color: var(--color-accent); }
.back-to-reading:hover { color: var(--color-text); }

.back-to-top {
  width: 40px;
  height: 40px;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  right: calc(1.25rem + env(safe-area-inset-right, 0px));
  background: var(--color-surface-raised);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-hover);
  font-size: 1rem;
}

@media (max-width: 768px) {
  /* Phone: keep the bottom edge to one row of controls */
  .back-to-reading {
    left: calc(0.75rem + env(safe-area-inset-left, 0px));
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }
  .back-to-reading { max-width: calc(100vw - 11rem); }
  .dimensions-fab-bar {
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)) !important;
    left: auto !important;
    right: calc(0.75rem + env(safe-area-inset-right, 0px)) !important;
    transform: none !important;
    max-width: calc(100vw - 1.5rem);
  }
  .back-to-top { bottom: calc(4rem + env(safe-area-inset-bottom, 0px)); right: calc(0.75rem + env(safe-area-inset-right, 0px)); }
}

/* Desktop: phone-only icons stay hidden; search becomes a compact field-style button */
@media (min-width: 769px) {
  .nav-dark-mobile, .nav-search-mobile { display: none !important; }
  .navbar-nav > li > a.nav-search-button {
    width: 200px;
    height: 36px;
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 0 0.6rem 0 0.8rem !important;
    margin: 0 0.35rem;
    background-color: var(--color-hover);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    color: var(--color-text-subtle);
  }
  .navbar-nav > li > a.nav-search-button::after {
    content: "Search the Bible";
    display: block;
    position: static;
    height: auto;
    background: none;
    flex: 1;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--color-text-subtle);
  }
  .navbar-nav > li > a.nav-search-button::before {
    content: "\2318K";
    order: 2;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-subtle);
    background: var(--color-surface);
  }
  .navbar-nav > li > a.nav-search-button:hover {
    background-color: var(--color-hover);
    border-color: var(--color-border-strong);
    color: var(--color-text-muted);
  }
}
@media (min-width: 769px) and (max-width: 1100px) {
  .navbar-nav > li > a.nav-search-button { width: 36px; padding: 0 !important; justify-content: center; }
  .navbar-nav > li > a.nav-search-button::after, .navbar-nav > li > a.nav-search-button::before { display: none; }
}

/* ---------- 13. Phone navigation: one compact row ---------- */
@media (max-width: 768px) {
  :root { --nav-h: 56px; }
  .navbar {
    min-height: var(--nav-h);
    padding-top: calc(0.5rem + env(safe-area-inset-top, 0px));
    padding-bottom: 0.5rem;
    column-gap: 0.15rem;
  }
  .navbar-brand { order: 0; flex: 1 1 auto; min-width: 0; font-size: 1rem; }
  .brand-text { overflow: hidden; text-overflow: ellipsis; }
  .nav-audio-controls { order: 1; margin: 0; padding: 0 0.35rem 0 0; border-left: none; }
  .nav-search-mobile { order: 2; margin: 0; display: inline-flex; }
  /* Theme toggle lives in the menu on phones to keep the top row uncluttered */
  .nav-dark-mobile { display: none !important; }
  .nav-toggle { order: 3; margin-left: 0; width: 40px; height: 40px; padding: 11px; }
  .navbar button, .navbar .nav-search-mobile { min-width: 0 !important; min-height: 0 !important; }
  .nav-audio-controls .nav-play-btn, .nav-search-mobile { width: 40px !important; height: 40px !important; }
  .nav-audio-controls .nav-autoplay-btn { width: 36px !important; height: 40px !important; justify-content: center; }
  .nav-animate-btn { width: 36px; height: 32px; padding: 0 !important; justify-content: center; margin-left: 0; }
  .nav-animate-text { display: none; }
  .navbar-nav { order: 4; }

  .navbar-nav.nav-open {
    padding: 0.5rem 0 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--color-border);
  }
  .navbar-nav > li > a, .nav-dropdown-toggle {
    font-size: 0.9375rem;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--color-text);
  }
  .navbar-nav > li > a.nav-search-link { width: auto; height: auto; justify-content: flex-start; padding: 0.7rem 0.85rem; }
  .navbar-nav #dark-mode-toggle { width: auto; height: auto; padding: 0.7rem 0.85rem; border-radius: var(--radius-sm); gap: 0.6rem; color: var(--color-text); }
  .navbar-nav #dark-mode-toggle::after { content: "Dark mode"; font-family: var(--font-ui); font-size: 0.9375rem; font-weight: 500; }
  html.dark-mode .navbar-nav #dark-mode-toggle::after { content: "Light mode"; }
  .navbar-nav > li > a.nav-search-link[href="/search"]::after { content: "Search"; position: static; display: inline; background: none; height: auto; margin-left: 0.6rem; font-size: 0.9375rem; font-weight: 500; }
  .navbar-nav > li > a.nav-search-link[href="/collections"]::after { content: "My collections"; position: static; display: inline; background: none; height: auto; margin-left: 0.6rem; font-size: 0.9375rem; font-weight: 500; }
  .navbar-nav > li > a.nav-search-link[href="/"]::after { content: "Home"; position: static; display: inline; background: none; height: auto; margin-left: 0.6rem; font-size: 0.9375rem; font-weight: 500; }

  .nav-mega-menu {
    position: static;
    transform: none;
    width: auto;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0.5rem 0.85rem 0.25rem;
  }

  .container { padding-top: 1.75rem; }
  .breadcrumbs { padding-top: 0.85rem; }
}
@media (max-width: 374px) {
  .brand-text { display: none; }
}

/* ---------- 14. Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .character-list .character-item:hover, .character-list > li:hover, .key-chapter-card:hover, .dim-card:hover,
  .book-tile:hover, .timeline-event-item:hover, .reading-plan-card:hover,
  .dimension-hero-cta:hover, .hero-btn-primary:hover, .cta-primary:hover { transform: none; }
}

/* ---------- 15. Home ---------- */
.home-search {
  max-width: 620px;
  padding: 6px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-hover);
  align-items: center;
}
.home-search:focus-within { border-color: var(--color-accent); box-shadow: 0 0 0 4px var(--color-accent-soft), var(--shadow-hover); }
.home-search input,
.home-search input[type="search"] {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  min-height: 0;
  padding: 0.65rem 0.75rem !important;
  font-size: 1rem !important;
}
.home-search input:focus { box-shadow: none !important; }
.home-search button {
  align-self: stretch;
  border-radius: var(--radius-pill);
  background: var(--color-ink);
  color: var(--color-on-ink);
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 0 1.4rem;
}
.home-search button:hover { background: var(--color-ink); opacity: 0.9; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.75rem 1.5rem; max-width: 560px; }
@media (min-width: 900px) {
  .hero-stats { grid-template-columns: repeat(6, auto); justify-content: center; column-gap: 2.75rem; max-width: none; }
}
.feature-sections { max-width: 1000px; }
@media (min-width: 700px) {
  .feature-sections { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.feature-section {
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}
/* Buttons that sit on the dark banner stay light in both themes */
.home-cta-banner .cta-primary { background: #f4ead8; color: #1c1915; }
.home-cta-banner .cta-primary:hover { background: #f4ead8; color: #1c1915; }
.home-cta-banner .cta-secondary-light { background: transparent; box-shadow: none; }

/* ---------- 16. Era timeline bar (Eras page) ---------- */
.era-timeline-bar {
  gap: 4px;
  padding: 4px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  overflow-x: auto;
  scrollbar-width: none;
}
.era-timeline-bar::-webkit-scrollbar { display: none; }
.era-segment, .era-segment:nth-child(odd) {
  min-width: max-content;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text-muted);
  text-align: center;
  border: none;
}
.era-segment:hover { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-subtle); text-decoration: none; }
.era-segment-label { font-family: var(--font-ui); font-size: 0.75rem; font-weight: 500; color: inherit; }

/* ---------- 17. Reader toolbar on phones: never wider than the screen ---------- */
@media (max-width: 768px) {
  .chapter-nav-bar { min-width: 0; gap: 0.35rem; }
  .nav-bar-prev, .nav-bar-next { flex: 0 0 auto; min-width: 32px; text-align: center; }
  .nav-bar-prev .nav-bar-label, .nav-bar-next .nav-bar-label { display: none; }
  .nav-bar-center { flex: 1 1 auto; min-width: 0; display: flex; gap: 0.35rem; }
  .ch-jump-select { flex: 1 1 0; min-width: 0; width: auto; max-width: none; text-overflow: ellipsis; }
  #ch-jump-book { flex-grow: 1.5; }
}

/* Scroll-position verse badge floats in the toolbar corner instead of taking row space */
.ch-verse-indicator { position: absolute; top: 8px; right: 12px; pointer-events: none; background: var(--color-bg-alt); border: 1px solid var(--color-border); }

/* ---------- 18. Phone menu: one consistent left-aligned list ---------- */
@media (max-width: 768px) {
  .navbar-nav.nav-open { align-items: stretch; text-align: left; gap: 2px; }
  .navbar-nav.nav-open > li { width: 100%; text-align: left; }
  .navbar-nav.nav-open > li > a,
  .navbar-nav.nav-open .nav-dropdown-toggle,
  .navbar-nav.nav-open #dark-mode-toggle {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 0.75rem;
    width: 100% !important;
    text-align: left;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
  }
  .navbar-nav.nav-open > li > a::after { margin-left: 0 !important; }
  .navbar-nav.nav-open > li > a.active,
  .navbar-nav.nav-open > li > a:hover,
  .navbar-nav.nav-open .nav-dropdown-toggle:hover,
  .navbar-nav.nav-open #dark-mode-toggle:hover { background: var(--color-hover); }
  .navbar-nav.nav-open > li > a svg, .navbar-nav.nav-open #dark-mode-toggle svg { flex: 0 0 auto; color: var(--color-text-muted); }
  .navbar-nav.nav-open > li > a[href="/books"]::before {
    content: "";
    width: 17px; height: 17px; flex: 0 0 auto;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 4h6a4 4 0 0 1 4 4v13a3 3 0 0 0-3-3H2z'/%3E%3Cpath d='M22 4h-6a4 4 0 0 0-4 4v13a3 3 0 0 1 3-3h7z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 4h6a4 4 0 0 1 4 4v13a3 3 0 0 0-3-3H2z'/%3E%3Cpath d='M22 4h-6a4 4 0 0 0-4 4v13a3 3 0 0 1 3-3h7z'/%3E%3C/svg%3E") center / contain no-repeat;
    opacity: 0.7;
  }
  .navbar-nav.nav-open .nav-dropdown-toggle { font-weight: 500; }
  .navbar-nav.nav-open .nav-mega-menu { grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; padding: 0.25rem 0.85rem 0.75rem; }
  .navbar-nav.nav-open .mega-col a { margin: 0; padding: 0.35rem 0; font-size: 0.9375rem; }
}

/* ---------- 19. Honest Questions cards (index and "More honest questions") ---------- */
.questions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.65rem; }
.questions-card {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.9rem 1.05rem;
  box-shadow: var(--shadow-card);
  text-decoration: none;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.questions-card:hover { color: var(--color-text); border-color: var(--color-border-strong); box-shadow: var(--shadow-hover); text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .questions-card:hover { transform: translateY(-2px); } }

/* ---------- 20. Accessibility pass (axe WCAG 2.1 AA findings) ---------- */
/* Floating Graph Navigator button: it used the nav text color, which is now
   dark on the light nav, against its own dark background - an invisible label. */
.gnav-fab { background: var(--color-ink); color: var(--color-on-ink); border: 1px solid transparent; box-shadow: var(--shadow-pop); }
.gnav-fab svg { color: currentColor; }
.gnav-fab:hover { border-color: transparent; }
/* Faint text that an inherited opacity pushed below 4.5:1 */
.site-footer .footer-text, .site-footer .footer-text.footer-legal, .site-footer .footer-text a { opacity: 1 !important; }
.verse-number { color: var(--color-text-subtle); opacity: 1; }
.home-search-hints a { color: var(--color-text-muted); opacity: 1; }
.keyboard-hint { color: var(--color-text-subtle); opacity: 1; }
.filter-pill > span[style] { opacity: 0.92 !important; }
.next-chapter-card .next-label { color: var(--color-accent); }
.ask-conv-list .ask-conv-empty, .ask-composer .ask-legal-notice, .ask-composer .ask-legal-notice a { color: var(--color-text-muted); opacity: 1; }
html.dark-mode .books-filter.active { color: var(--color-on-ink); }
/* Timeline certainty badges: the dark-mode greens, oranges and purples were
   unreadable (as low as 1.8:1) */
.certainty-badge.certainty-confirmed { color: #2e6b30; }
.certainty-badge.certainty-approximate { color: #a8430a; }
html.dark-mode .certainty-badge.certainty-confirmed { color: #8fd694; }
html.dark-mode .certainty-badge.certainty-approximate { color: #ffb870; }
html.dark-mode .certainty-badge.certainty-traditional { color: #d9a6e6; }
/* Connections chips that float over chapter text */
.dimensions-fab-chip { background: var(--color-surface-raised) !important; color: var(--color-text) !important; border: 1px solid var(--color-border) !important; box-shadow: var(--shadow-hover); opacity: 1 !important; }
.dimensions-fab-chip .dimensions-fab-chip-text { color: var(--color-text) !important; opacity: 1 !important; }
/* A link inside running text must not rely on color alone */
.questions-ask-cta a { text-decoration: underline; text-underline-offset: 3px; }

/* Explore menu feature cards (built for the old dark menu): subtitles were
   translucent white on the light panel, and titles were cut off mid-word. */
.mega-feature-card { background: var(--color-bg-alt); border-color: var(--color-border-light); align-items: flex-start; }
.mega-feature-card:hover { background: var(--color-surface); border-color: var(--color-border-strong); }
.mega-feature-icon { background: var(--color-accent-soft); color: var(--color-accent); }
.mega-feature-text strong { color: var(--color-text); white-space: normal; overflow: visible; }
.mega-feature-text small { color: var(--color-text-muted); white-space: normal; overflow: visible; }
