/* ============================================================
   freescripture.org — design system
   Inherits parchment palette and typographic restraint from
   the sister project Fablepixels. Adds tradition accents,
   RTL hooks, and chapter-reading optimizations.
   ============================================================ */

/* ---- Design tokens ---- */
:root {
  /* Core parchment palette */
  --paper:        #f4ecd8;
  --paper-warm:   #ede2c8;
  --paper-deep:   #e3d4ad;
  --ink:          #2a1f15;
  --ink-soft:     #4a3a28;
  --ink-faded:    #7a6648;
  --rule:         #c9b88a;
  --rule-soft:    #d8c89c;

  /* Tradition accents (sparing use only) */
  --accent-christian: #8B6914;
  --accent-islamic:   #0F6E56;
  --accent-lds:       #185FA5;
  --accent-jewish:    #3C3489;
  --accent-buddhist:  #BA7517;
  --accent-hindu:     #993C1D;
  --accent-sikh:      #854F0B;

  /* Default tradition (Christian for KJV) */
  --tradition-accent: var(--accent-christian);

  /* Typography */
  --font-display: 'Cormorant Garamond', 'EB Garamond', Georgia, serif;
  --font-body:    'Crimson Pro', 'Crimson Text', Georgia, serif;
  --font-mono:    'DM Mono', 'IBM Plex Mono', ui-monospace, monospace;

  /* Reading measure */
  --measure:      640px;
  --measure-narrow: 580px;

  /* Verse anchor highlight */
  --verse-highlight: #f6dc8a;
}

/* ---- Reset and base ---- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(ellipse at top, rgba(255,255,255,0.4) 0%, transparent 50%),
    radial-gradient(ellipse at bottom, rgba(0,0,0,0.03) 0%, transparent 60%);
  min-height: 100vh;
  position: relative;
}

/* Subtle paper noise overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.165 0 0 0 0 0.122 0 0 0 0 0.082 0 0 0 0.08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

main, header, footer, nav { position: relative; z-index: 2; }

/* ---- Skip link ---- */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1rem;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  z-index: 100;
}
.skip-link:focus { top: 0; }

/* ---- Focus-visible ---- */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---- Headings ---- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
  margin: 0 0 0.5em;
}

h1 {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-style: italic;
  letter-spacing: -0.01em;
}

h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.35rem; }

/* ---- Site header ---- */
.site-header {
  border-bottom: 1px solid var(--rule);
  padding: 1.25rem 1.5rem;
  background: rgba(244, 236, 216, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.site-mark {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.35rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.site-mark:hover { color: var(--ink-soft); }

.site-nav {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.site-nav a {
  color: var(--ink-faded);
  text-decoration: none;
  padding: 0.5rem 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.site-nav a:hover, .site-nav a:focus { color: var(--ink); }

@media (max-width: 600px) {
  .site-header__inner { flex-direction: column; gap: 0.75rem; }
  .site-nav { gap: 1rem; font-size: 0.72rem; }
}

/* ---- Main content wrapper ---- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.reading-column {
  max-width: var(--measure);
  margin: 0 auto;
}

.reading-column--narrow {
  max-width: var(--measure-narrow);
  margin: 0 auto;
}

/* ---- Tradition accent stripe (for chapter pages) ---- */
.tradition-stripe {
  height: 3px;
  background: var(--tradition-accent);
  width: 100%;
}

/* ---- Homepage hero ---- */
.hero {
  text-align: center;
  padding: 4rem 1rem 3rem;
  max-width: 760px;
  margin: 0 auto;
}

.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-faded);
  margin-bottom: 1.25rem;
}

.hero__title {
  font-style: italic;
  margin-bottom: 1rem;
}

.hero__lede {
  font-size: 1.2rem;
  color: var(--ink-soft);
  max-width: 560px;
  margin: 0 auto 2rem;
}

.hero__rule {
  width: 60px;
  height: 1px;
  background: var(--rule);
  margin: 2rem auto;
  border: 0;
}

.hero__steward {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-faded);
  letter-spacing: 0.05em;
  margin-top: 1.5rem;
}

.hero__steward a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px dotted var(--rule);
  padding-bottom: 1px;
}

.hero__steward a:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* ---- Search bar (homepage and search page) ---- */
.search-bar {
  max-width: 580px;
  margin: 2rem auto 0;
  position: relative;
}

.search-bar input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1.1rem;
  padding: 0.95rem 1.2rem 0.95rem 3rem;
  background: rgba(255, 252, 244, 0.7);
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--ink);
  min-height: 44px;
}

.search-bar input::placeholder {
  color: var(--ink-faded);
  font-style: italic;
}

.search-bar input:focus {
  background: #fffaf0;
  border-color: var(--ink);
  outline: none;
}

.search-bar__icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faded);
  pointer-events: none;
}

.search-bar__hint {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faded);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  margin-top: 0.75rem;
}

/* ---- Tradition cards (homepage) ---- */
.tradition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  margin: 4rem auto 0;
  max-width: 980px;
}

.tradition-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 252, 244, 0.55);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--tradition, var(--rule));
  padding: 1.75rem 1.5rem;
  border-radius: 2px;
  transition: transform 380ms ease, background 380ms ease, box-shadow 380ms ease;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.tradition-card:hover, .tradition-card:focus {
  background: rgba(255, 252, 244, 0.85);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(42, 31, 21, 0.08);
}

.tradition-card[data-tradition="christian"]    { --tradition: var(--accent-christian); }
.tradition-card[data-tradition="islamic"]      { --tradition: var(--accent-islamic); }
.tradition-card[data-tradition="lds"]          { --tradition: var(--accent-lds); }
.tradition-card[data-tradition="jewish"]       { --tradition: var(--accent-jewish); }
.tradition-card[data-tradition="buddhist"]     { --tradition: var(--accent-buddhist); }
.tradition-card[data-tradition="hindu"]        { --tradition: var(--accent-hindu); }
.tradition-card[data-tradition="sikh"]         { --tradition: var(--accent-sikh); }

.tradition-card__label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faded);
  margin-bottom: 0.5rem;
}

.tradition-card__title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.6rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
  line-height: 1.15;
}

.tradition-card__desc {
  font-size: 0.95rem;
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 0;
  flex-grow: 1;
}

.tradition-card__meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-faded);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dotted var(--rule);
}

.tradition-card--placeholder {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

/* ---- Section headers ---- */
.section-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-faded);
  text-align: center;
  margin: 5rem 0 0.5rem;
}

.section-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 2rem;
  text-align: center;
  margin-bottom: 0.75rem;
}

.section-rule {
  width: 60px;
  height: 1px;
  background: var(--rule);
  margin: 1rem auto 2rem;
  border: 0;
}

/* ---- Book/chapter index pages ---- */
.book-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem 1.5rem;
  margin: 2rem 0;
}

.book-list a {
  display: block;
  padding: 0.65rem 0.5rem;
  color: var(--ink-soft);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.1rem;
  border-bottom: 1px dotted transparent;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.book-list a:hover, .book-list a:focus {
  color: var(--ink);
  border-bottom-color: var(--rule);
}

.book-section-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-faded);
  margin: 2.5rem 0 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.chapter-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 0.4rem;
  margin: 1.5rem 0;
  max-width: 720px;
}

.chapter-list a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.5rem;
  background: rgba(255, 252, 244, 0.5);
  border: 1px solid var(--rule-soft);
  color: var(--ink-soft);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  border-radius: 2px;
  transition: background 240ms ease, border-color 240ms ease;
}

.chapter-list a:hover, .chapter-list a:focus {
  background: var(--paper-warm);
  border-color: var(--ink-soft);
  color: var(--ink);
}

/* ---- Chapter reading page ---- */
.chapter-nav {
  border-bottom: 1px solid var(--rule);
  padding: 1rem 0;
  margin-bottom: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chapter-nav a, .chapter-nav button {
  color: var(--ink-soft);
  text-decoration: none;
  background: none;
  border: 1px solid var(--rule);
  padding: 0.5rem 0.85rem;
  font-family: inherit;
  font-size: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  border-radius: 2px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 200ms ease, border-color 200ms ease;
}

.chapter-nav a:hover, .chapter-nav button:hover,
.chapter-nav a:focus, .chapter-nav button:focus {
  background: var(--paper-warm);
  border-color: var(--ink-soft);
  color: var(--ink);
}

.chapter-nav__group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chapter-nav__current {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  text-align: center;
  flex: 1;
}

.chapter-translation-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-faded);
  text-align: center;
  margin-bottom: 0.5rem;
}

.chapter-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  text-align: center;
  margin: 0 0 0.5rem;
  line-height: 1.05;
}

.chapter-subtitle {
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-faded);
  font-size: 1.1rem;
  margin-bottom: 2.5rem;
}

.chapter-text {
  font-size: 1.18rem;
  line-height: 1.85;
  color: var(--ink);
  hyphens: auto;
}

.chapter-text p {
  margin: 0 0 1.4rem;
  text-indent: 0;
}

.verse {
  scroll-margin-top: 6rem;
  transition: background-color 1800ms ease;
  border-radius: 3px;
  padding: 0 2px;
}

.verse--highlight {
  background-color: var(--verse-highlight);
}

.verse__num {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65em;
  vertical-align: super;
  color: var(--ink-faded);
  margin-right: 0.2em;
  font-weight: 500;
  user-select: none;
  text-decoration: none;
}

.verse__num:hover { color: var(--tradition-accent); }

/* RTL text support */
.chapter-text[dir="rtl"] {
  font-family: 'Amiri', 'Noto Naskh Arabic', serif;
  text-align: right;
}

.chapter-text[dir="rtl"] .verse__num {
  margin-right: 0;
  margin-left: 0.2em;
}

/* ---- Action bar (TTS, copy link) ---- */
.chapter-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 2.5rem 0;
  padding: 1.25rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  background: rgba(255, 252, 244, 0.5);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: 2px;
  min-height: 44px;
  transition: all 240ms ease;
}

.action-btn:hover, .action-btn:focus {
  background: var(--paper-warm);
  border-color: var(--ink-soft);
  color: var(--ink);
}

.action-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.action-btn__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---- Chapter footer (prev/next, attribution) ---- */
.chapter-foot {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}

.chapter-foot__nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.chapter-foot__nav a {
  display: block;
  padding: 1.25rem;
  background: rgba(255, 252, 244, 0.55);
  border: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
  border-radius: 2px;
  min-height: 80px;
  transition: background 240ms ease, border-color 240ms ease;
}

.chapter-foot__nav a:hover, .chapter-foot__nav a:focus {
  background: var(--paper-warm);
  border-color: var(--ink-soft);
}

.chapter-foot__nav .next { text-align: right; }
.chapter-foot__nav .placeholder { opacity: 0.4; pointer-events: none; }

.chapter-foot__nav .arrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faded);
  display: block;
  margin-bottom: 0.4rem;
}

.chapter-foot__nav .label {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--ink);
}

.attribution {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faded);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  margin: 2rem 0 1rem;
  line-height: 1.7;
}

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--rule);
  background: var(--paper-warm);
  padding: 3rem 1.5rem 2rem;
  margin-top: 4rem;
}

.site-footer__inner {
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.site-footer__col h4 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faded);
  margin-bottom: 1rem;
}

.site-footer__col ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-footer__col li {
  margin-bottom: 0.4rem;
}

.site-footer__col a {
  color: var(--ink-soft);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.site-footer__col a:hover { color: var(--ink); }

.site-footer__col p {
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
  line-height: 1.6;
}

.site-footer__col strong { color: var(--ink); font-weight: 600; }

.trust-row {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faded);
  border-top: 1px solid var(--rule-soft);
  padding-top: 1.5rem;
}

.trust-row__items {
  display: inline-flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.trust-row__items span::before {
  content: "·";
  margin-right: 1.5rem;
  color: var(--rule);
}

.trust-row__items span:first-child::before { content: ""; margin: 0; }

.trust-row__steward {
  margin-top: 1rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-soft);
}

/* ---- Search results ---- */
.search-results {
  margin-top: 2.5rem;
}

.search-result {
  padding: 1.25rem 0;
  border-bottom: 1px dotted var(--rule);
}

.search-result__ref {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--tradition-accent);
  margin-bottom: 0.4rem;
}

.search-result__ref a {
  color: inherit;
  text-decoration: none;
}

.search-result__ref a:hover { text-decoration: underline; }

.search-result__text {
  font-size: 1.08rem;
  color: var(--ink);
  line-height: 1.6;
}

.search-result mark {
  background: var(--verse-highlight);
  color: var(--ink);
  padding: 0 2px;
  border-radius: 2px;
}

.search-empty {
  text-align: center;
  font-style: italic;
  color: var(--ink-faded);
  padding: 3rem 1rem;
}

/* ---- Loading and helper ---- */
.muted { color: var(--ink-faded); }

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--tradition-accent);
  background: rgba(139, 105, 20, 0.06);
  padding: 0.25rem 0.55rem;
  border-radius: 2px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  body { font-size: 1.05rem; }
  main { padding: 2rem 1.25rem 3rem; }
  .chapter-text { font-size: 1.1rem; line-height: 1.8; }
  .chapter-foot__nav { grid-template-columns: 1fr; }
  .chapter-foot__nav .next { text-align: left; }
  .chapter-actions { gap: 0.5rem; }
  .action-btn { font-size: 0.72rem; padding: 0.55rem 0.85rem; }
  .hero { padding: 2.5rem 0.5rem 2rem; }
}

/* Print styles — for those who still print scripture */
@media print {
  body::before, .site-header, .chapter-nav, .chapter-actions,
  .chapter-foot__nav, .site-footer { display: none; }
  body { background: white; color: black; }
  .chapter-text { font-size: 12pt; line-height: 1.5; }
}

/* ==========================================================================
   Translation switcher
   ========================================================================== */
.trans-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0 1.5rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: rgba(201, 184, 138, 0.06);
}

.trans-switch__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-right: 0.25rem;
}

.trans-switch__btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding: 0.4rem 0.85rem;
  text-decoration: none;
  border-radius: 2px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--rule);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  cursor: pointer;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}

.trans-switch__btn:hover:not(.trans-switch__btn--current):not(.trans-switch__btn--disabled) {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.trans-switch__btn--current {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  cursor: default;
}

.trans-switch__btn--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
}

@media (max-width: 600px) {
  .trans-switch { padding: 0.5rem 0.75rem; gap: 0.35rem; }
  .trans-switch__btn { padding: 0.35rem 0.65rem; font-size: 0.72rem; }
  .trans-switch__label { font-size: 0.65rem; }
}

/* ==========================================================================
   Reading preferences
   These are opt-in toggles applied via data attributes on the html element,
   set by chapter.js based on localStorage values. All default off / "default".
   ========================================================================== */

/* OpenDyslexic — only fetched when the dyslexic font is selected.
   Source: https://github.com/antijingoist/open-dyslexic via jsDelivr CDN.
   Licensed under SIL OFL / Creative Commons Attribution 3.0 Unported. */
@font-face {
  font-family: 'OpenDyslexic';
  src: url('https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@master/compiled/OpenDyslexic-Regular.woff2') format('woff2'),
       url('https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@master/compiled/OpenDyslexic-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Lexend — accessibility-focused sans-serif from Google Fonts.
   Loaded via the Google Fonts <link> in head; this @font-face is just
   a fallback declaration for the named family. */

/* --- Reading font --- */
html[data-fs-font="sans"] .chapter-text {
  font-family: 'Lexend', 'Open Sans', -apple-system, 'Segoe UI', sans-serif;
}
html[data-fs-font="sans"] .chapter-text p,
html[data-fs-font="sans"] .verse {
  letter-spacing: 0.01em;
}

html[data-fs-font="dyslexic"] .chapter-text {
  font-family: 'OpenDyslexic', 'Lexend', 'Open Sans', sans-serif;
  letter-spacing: 0.02em;
}

/* --- Text size scale (applies only inside the chapter text) --- */
html[data-fs-size="smaller"] .chapter-text { font-size: 1.05rem; }
html[data-fs-size="larger"] .chapter-text  { font-size: 1.35rem; }
html[data-fs-size="largest"] .chapter-text { font-size: 1.55rem; }

/* --- Line spacing --- */
html[data-fs-leading="generous"] .chapter-text { line-height: 1.9; }
html[data-fs-leading="roomy"]    .chapter-text { line-height: 2.3; }

/* --- Per-verse layout: each verse on its own line --- */
html[data-fs-layout="verse-per-line"] .chapter-text .verse {
  display: block;
  text-indent: 0;
  margin: 0.4em 0;
  padding-left: 2.4em;
  position: relative;
}
html[data-fs-layout="verse-per-line"] .chapter-text .verse__num {
  position: absolute;
  left: 0;
  top: 0.3em;
  font-size: 0.85em;
  width: 2em;
  text-align: right;
  padding-right: 0.4em;
}
html[data-fs-layout="verse-per-line"] .chapter-text p {
  text-align: left;
}

/* --- Hide italics from translator-added words --- */
html[data-fs-italics="off"] .chapter-text i {
  font-style: normal;
}

/* --- The settings button --- */
.reading-prefs-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 90;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--rule);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  box-shadow: 0 2px 8px rgba(42, 31, 21, 0.12);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.reading-prefs-btn:hover, .reading-prefs-btn:focus-visible {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.reading-prefs-btn svg { width: 22px; height: 22px; }

@media (max-width: 600px) {
  .reading-prefs-btn { bottom: 1rem; right: 1rem; width: 44px; height: 44px; }
}

/* --- The settings panel --- */
.reading-prefs-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1.5rem;
  width: 320px;
  max-width: calc(100vw - 2rem);
  box-shadow: 0 6px 24px rgba(42, 31, 21, 0.18);
  font-family: var(--font-body);
  display: none;
}

.reading-prefs-panel--open {
  display: block;
}

.reading-prefs-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: -0.25rem 0 1rem;
}

.reading-prefs-panel__title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}

.reading-prefs-panel__close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  color: var(--ink-soft);
  line-height: 1;
  padding: 0 0.4rem;
}
.reading-prefs-panel__close:hover { color: var(--ink); }

.reading-prefs-group {
  margin-bottom: 1.1rem;
}
.reading-prefs-group:last-child { margin-bottom: 0; }

.reading-prefs-group__label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.45rem;
}

.reading-prefs-group__btns {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.reading-prefs-pill {
  flex: 1 1 auto;
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  cursor: pointer;
  color: var(--ink-soft);
  min-height: 32px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.reading-prefs-pill:hover {
  background: rgba(201, 184, 138, 0.15);
}

.reading-prefs-pill[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.reading-prefs-pill--font-dyslexic { font-family: 'OpenDyslexic', sans-serif; }
.reading-prefs-pill--font-sans { font-family: 'Lexend', sans-serif; }

.reading-prefs-reset {
  display: block;
  margin-top: 0.85rem;
  width: 100%;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--rule);
}
.reading-prefs-reset:hover { color: var(--ink); }

/* Hide the floating button on print */
@media print {
  .reading-prefs-btn, .reading-prefs-panel { display: none !important; }
}

/* ==========================================================================
   Logo mark
   ========================================================================== */
.site-mark {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.site-mark__icon {
  width: 32px;
  height: 22px;
  color: var(--accent-christian, #6e4e0e);
  flex-shrink: 0;
}
.site-mark__text {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.25rem;
}

/* ==========================================================================
   Homepage — genre cards layout
   ========================================================================== */
.home-hero {
  text-align: center;
  padding: 2.5rem 1.5rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.home-hero__title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.6rem;
  color: var(--ink);
  margin-bottom: 0.3rem;
}
.home-hero__sub {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-bottom: 1.2rem;
}
.home-hero__search {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.5rem 0.8rem;
  width: 100%;
  max-width: 380px;
  min-height: 42px;
}
.home-hero__search:focus-within { border-color: var(--accent-christian, #6e4e0e); }
.home-hero__search-icon {
  display: flex;
  color: var(--ink-soft);
  margin-right: 0.5rem;
}
.home-hero__search input {
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  width: 100%;
  outline: none;
}
.home-hero__search input::placeholder { color: var(--ink-soft); opacity: 0.7; }
.home-hero__steward {
  margin-top: 0.8rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.home-hero__steward a { color: var(--ink-soft); }

.home-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.genre-section {
  padding: 2.5rem 0 1.5rem;
}
.genre-section + .genre-section {
  border-top: 1px solid var(--rule);
}
.genre-section__title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.45rem;
  color: var(--ink);
  margin-bottom: 0.15rem;
}
.genre-section__desc {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin-bottom: 0.2rem;
}
.genre-section__count {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 1.5rem;
}

.genre-callout {
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-style: italic;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  border-left: 3px solid var(--accent-christian, #6e4e0e);
  background: rgba(201, 184, 138, 0.06);
  border-radius: 0 4px 4px 0;
}

.genre-apoc-divider {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-christian, #6e4e0e);
  margin-top: 1rem;
  margin-bottom: 0.8rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--rule);
}

.book-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.book-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.1rem 1.2rem;
  min-height: 120px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.book-card:hover {
  border-color: var(--accent-christian, #6e4e0e);
  box-shadow: 0 3px 12px rgba(42, 31, 21, 0.06);
  transform: translateY(-1px);
}
.book-card--featured {
  background: rgba(201, 184, 138, 0.08);
  border-color: #c9b88a;
}

.book-card__name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.15rem;
  color: var(--ink);
  margin-bottom: 0.35rem;
  line-height: 1.3;
}
.book-card__desc {
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.55;
  flex: 1;
}
.book-card__meta {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-top: 0.6rem;
}

@media (prefers-reduced-motion: reduce) {
  .book-card:hover { transform: none; }
}
@media (max-width: 500px) {
  .book-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
  .book-cards { grid-template-columns: 1fr; }
}
