/* ═══════════════════════════════════════════════════════════════
   THE HOLY BIBLE — 1611 King James Version
   ═══════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'KJV1611';
  src: url('fonts/KJV1611.woff2') format('woff2'),
       url('fonts/KJV1611.woff') format('woff'),
       url('fonts/KJV1611.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #FFFFFF;
  --text: #2B2318;
  --muted: #6B5E50;
  --accent: #7C3028;
  --rule: #D4CABC;
  --hover: #5A1A15;
  --font-roman: 'EB Garamond', 'Cormorant Garamond', Georgia, serif;
  --font-blackletter: 'KJV1611', Georgia, serif;
}

* {
  box-sizing: border-box;
}

::selection {
  background: rgba(124, 48, 40, 0.15);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-roman);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

body.blackletter {
  font-family: var(--font-blackletter);
}

a {
  outline: none;
}

/* ── Fade transition ────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.4s ease;
}

/* ── Container ──────────────────────────────────────────── */

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 60px 24px 120px;
}

.container--wide {
  max-width: 960px;
}

/* ── Font toggle ────────────────────────────────────────── */

#font-toggle {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  padding: 14px 20px;
  z-index: 100;
  pointer-events: none;
}

#font-toggle button {
  pointer-events: auto;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 5px 14px;
  font-family: var(--font-roman);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.25s ease;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
}

#font-toggle button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Title page ─────────────────────────────────────────── */

.title-block {
  font-family: var(--font-roman);
  text-align: center;
  padding: 80px 0 60px;
  max-width: 480px;
  margin: 0 auto;
}

.blackletter .title-block,
.blackletter .title-block * {
  font-family: var(--font-roman);
}

.title-the {
  font-size: 1.2rem;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0 0 4px;
  font-weight: 400;
}

.title-main {
  font-size: 5.4rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  margin: 0 0 20px;
  line-height: 1.0;

}

.title-sub {
  font-size: 1.28rem;
  color: var(--text);
  line-height: 1.65;
  margin: 0 auto;
}

.title-and {
  display: block;
  font-size: 0.92rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 6px;
}

.title-rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 28px auto;
  max-width: 320px;
}

.colophon {
  font-size: 0.95rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.75;
  margin: 0 auto;
  max-width: 380px;
}

.colophon-date {
  font-style: normal;
  letter-spacing: 0.14em;
  display: block;
  margin-top: 16px;
  color: var(--text);
  font-size: 0.9rem;
}

/* ── Section headers ────────────────────────────────────── */

.section-header {
  font-family: var(--font-roman);
  font-size: 1.05rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text);
  margin-top: 56px;
  margin-bottom: 20px;
  font-weight: 400;
}

.rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 0 0 24px;
}

/* ── TOC grid ───────────────────────────────────────────── */

.toc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 36px;
  margin-top: 56px;
  align-items: start;
}

@media (max-width: 700px) {
  .toc-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Book list ──────────────────────────────────────────── */

.book-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.book-list li {
  margin-bottom: 2px;
}

.book-link {
  display: inline-block;
  padding: 6px 0;
  color: var(--text);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  text-decoration-color: rgba(43, 35, 24, 0.35);
  font-size: 1.05rem;
  cursor: pointer;
  transition: text-decoration-color 0.2s ease, text-decoration-style 0.2s ease;
}

.blackletter .book-link {
  font-size: 1.15rem;
  word-spacing: -0.12em;
}

.book-link:hover {
  text-decoration-style: solid;
  text-decoration-color: var(--text);
}

.book-link--unavailable {
  display: inline-block;
  padding: 6px 0;
  color: var(--muted);
  font-size: 1.05rem;
  opacity: 0.55;
}

.blackletter .book-link--unavailable {
  font-size: 1.15rem;
  word-spacing: -0.12em;
}

/* ── Book page (chapter grid) ───────────────────────────── */

.book-title {
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-align: center;
  margin: 0 0 8px;
}

.blackletter .book-title {
  font-size: 2.2rem;
  word-spacing: -0.12em;
}

.chapter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 36px;
}

.chapter-num {
  font-family: var(--font-roman);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
  border: 1px solid var(--rule);
  text-decoration: none;
  transition: all 0.2s ease;
}

.chapter-num:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chapter-num--unavailable {
  font-family: var(--font-roman);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--muted);
  opacity: 0.4;
  border: 1px solid var(--rule);
}

/* ── Chapter page ───────────────────────────────────────── */

.chapter-header {
  text-align: center;
  margin-bottom: 48px;
}

.chapter-book-name {
  font-family: var(--font-roman);
  font-size: 0.9rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}

.chapter-number {
  font-family: var(--font-roman);
  font-size: 4.5rem;
  font-weight: 400;
  line-height: 1.1;
  color: var(--text);
  margin: 8px 0 12px;
}

.chapter-summary {
  font-size: 1.0rem;
  font-style: italic;
  color: var(--muted);
  line-height: 1.4;
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

.blackletter .chapter-summary {
  font-family: var(--font-roman);
  font-size: 1.0rem;
  line-height: 1.4;
  word-spacing: normal;
}

/* ── Book full title (chapter 1 only) ───────────────────── */

.book-full-title {
  font-family: var(--font-roman);
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--rule);
}

.blackletter .book-full-title {
  font-family: var(--font-roman);
}

.bft-line1 {
  display: block;
  font-size: 0.95rem;
  letter-spacing: 0.25em;
  color: var(--text);
  margin-bottom: 6px;
}

.bft-line2 {
  display: block;
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-style: italic;
}

/* ── Verse text ─────────────────────────────────────────── */

.verse-block {
  font-size: 1.325rem;
  line-height: 1.3;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

body:not(.blackletter) .container--chapter {
  max-width: 740px;
}

.blackletter .verse-block {
  font-size: 1.3rem;
  line-height: 1.7;
  word-spacing: 0.05em;
}

.verse-block p {
  margin: 0 0 20px 0;
}

.verse-num {
  font-family: var(--font-roman);
  font-size: 0.72em;
  color: var(--accent);
  font-weight: 400;
  vertical-align: super;
  margin-right: 3px;
  line-height: 0;
}

.pilcrow {
  font-family: var(--font-roman);
  color: var(--accent);
  margin-right: 2px;
}

/* ── Navigation ─────────────────────────────────────────── */

.back-wrap {
  display: inline-block;
  position: relative;
  padding-left: 1.1em;
  margin-bottom: 32px;
}

.nav-arrow {
  position: absolute;
  left: 0;
  color: var(--muted);
}

.nav-item--next .nav-arrow {
  left: auto;
  right: 0;
}

.back-link {
  font-family: var(--font-roman);
  font-size: 0.95rem;
  color: var(--muted);
  display: inline-block;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  text-decoration-color: rgba(43, 35, 24, 0.35);
  cursor: pointer;
  transition: text-decoration-color 0.2s ease, text-decoration-style 0.2s ease;
}

.back-link:hover {
  text-decoration-style: solid;
  text-decoration-color: var(--muted);
}

.nav {
  font-family: var(--font-roman);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-size: 1.0rem;
}

.nav-item {
  position: relative;
  padding-left: 1.1em;
}

.nav-item--next {
  padding-left: 0;
  padding-right: 1.1em;
}

.nav-link {
  color: var(--muted);
  display: inline-block;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  text-decoration-color: rgba(43, 35, 24, 0.35);
  cursor: pointer;
  transition: text-decoration-color 0.2s ease, text-decoration-style 0.2s ease;
}

.nav-link:hover {
  text-decoration-style: solid;
  text-decoration-color: var(--muted);
}

/* ── Drop cap ────────────────────────────────────────────── */

.verse--drop {
  display: inline; /* flows with paragraph text in Roman mode */
}

.drop-cap {
  float: left;
  font-size: 4em;
  line-height: 0.76;
  padding-right: 0.07em;
  color: var(--accent);
}

body.blackletter .verse-block > p > span.verse--drop {
  display: block;
  overflow: hidden; /* contains the float in blackletter block layout */
  padding-left: 0;
  text-indent: 0;
}

/* ── Loading state ───────────────────────────────────────── */

.loading {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 60px 0;
}

/* ── Blackletter verse layout ───────────────────────────── */

body.blackletter .verse-block > p {
  margin-bottom: 0;
}

body.blackletter .verse-block > p > span {
  display: block;
  padding-left: 2.8em;
  text-indent: -2.8em;
  margin-bottom: 0.75em;
  line-height: 1.45;
}

body.blackletter .pilcrow {
  font-family: var(--font-roman);
  opacity: 1;
  margin-right: 0.2em;
}

body.blackletter .verse-num {
  font-size: 1em;
  vertical-align: baseline;
  line-height: inherit;
  margin-right: 0.45em;
}

/* ── Supplied words ──────────────────────────────────────── */

/* Roman mode: no special styling — supplied words blend with surrounding text */

body.blackletter .supplied {
  font-family: var(--font-roman);
  font-variant: small-caps;
  font-size: 0.95em;
  letter-spacing: 0.04em;
  vertical-align: 0.12em;
  font-weight: bold;
}

/* ── TOC footer link ─────────────────────────────────────── */

.toc-about {
  font-family: var(--font-roman);
  text-align: center;
  margin-top: 72px;
  margin-bottom: 0;
}

.toc-about-link {
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  text-decoration-color: rgba(43, 35, 24, 0.3);
  display: inline-block;
  transition: text-decoration-color 0.2s ease, text-decoration-style 0.2s ease;
}

.toc-about-link:hover {
  text-decoration-style: solid;
  text-decoration-color: var(--muted);
}

/* ── About page ──────────────────────────────────────────── */

.about-block {
  font-family: var(--font-roman);
  max-width: 520px;
  margin: 48px auto 0;
}

.blackletter .about-block,
.blackletter .about-block * {
  font-family: var(--font-roman);
  word-spacing: normal;
}

.about-title {
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0 0 32px;
}

.about-body {
  font-size: 1.0rem;
  line-height: 1.75;
  color: var(--text);
  margin: 0 0 20px;
}

.about-ext-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  text-decoration-color: rgba(124, 48, 40, 0.45);
  transition: text-decoration-color 0.2s ease, text-decoration-style 0.2s ease;
}

.about-ext-link:hover {
  text-decoration-style: solid;
  text-decoration-color: var(--accent);
}
