:root {
  --bg: #000000;
  --ink: #efe9dd;
  --ink-soft: rgba(239, 233, 221, 0.55);
  --ink-faint: rgba(239, 233, 221, 0.22);
  --gold: #e7c98a;
  --gold-glow: rgba(231, 201, 138, 0.55);
  --ease-out-soft: cubic-bezier(0.22, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.stage {
  max-width: 760px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 4vh 1.5rem 6vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}

/* ---------- Book switch (slide between Proverbs / Ecclesiastes) ---------- */
.book-toggle-wrap[hidden] {
  display: none !important;
}

.book-toggle-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.book-toggle {
  --toggle-pad: 4px;
  position: relative;
  display: flex;
  width: min(100%, 380px);
  padding: var(--toggle-pad);
  border-radius: 999px;
  border: 1px solid var(--ink-faint);
  background: rgba(239, 233, 221, 0.04);
}

.book-toggle-thumb {
  position: absolute;
  top: var(--toggle-pad);
  bottom: var(--toggle-pad);
  left: var(--toggle-pad);
  width: calc(50% - 1.5 * var(--toggle-pad));
  border-radius: 999px;
  background: linear-gradient(
    135deg,
    rgba(231, 201, 138, 0.22),
    rgba(231, 201, 138, 0.08)
  );
  border: 1px solid rgba(231, 201, 138, 0.28);
  box-shadow: 0 0 20px rgba(231, 201, 138, 0.08);
  transition:
    transform 0.35s var(--ease-out-soft),
    background 0.35s ease;
  pointer-events: none;
  z-index: 0;
}

.book-toggle.is-ecclesiastes .book-toggle-thumb {
  transform: translateX(calc(100% + var(--toggle-pad)));
}

.book-toggle-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: "Inter", sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.65rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s ease;
}

.book-toggle-btn:hover {
  color: var(--ink);
}

.book-toggle-btn[aria-selected="true"] {
  color: var(--gold);
}

.title {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-weight: 400;
  font-size: clamp(2.4rem, 5.5vw, 3.8rem);
  letter-spacing: 0.04em;
}

.play-btn {
  appearance: none;
  border: 1px solid var(--ink-faint);
  background: transparent;
  color: var(--ink);
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  padding: 0.8rem 2.6rem;
  border-radius: 999px;
  cursor: pointer;
  transition:
    color 0.3s ease,
    border-color 0.3s ease,
    background 0.3s ease,
    transform 0.3s ease;
}

.play-btn:hover {
  color: var(--gold);
  border-color: var(--gold);
  transform: translateY(-1px);
}

.play-btn.is-playing {
  border-color: var(--ink-faint);
  color: var(--ink-soft);
}

/* ---------- Chapter selector ---------- */
.chapter-strip {
  width: 100%;
  max-width: min(100%, 680px);
}

.chapter-list {
  display: flex;
  flex-direction: row;
  gap: 0.45rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.15rem 0.25rem 0.35rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(231, 201, 138, 0.25) transparent;
}

.chapter-list::-webkit-scrollbar {
  height: 4px;
}

.chapter-list::-webkit-scrollbar-thumb {
  background: rgba(231, 201, 138, 0.25);
  border-radius: 999px;
}

.chapter-btn {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid var(--ink-faint);
  background: rgba(239, 233, 221, 0.03);
  color: var(--ink-soft);
  font-family: "Inter", sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  white-space: nowrap;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition:
    color 0.22s ease,
    border-color 0.22s ease,
    background 0.22s ease;
}

.chapter-btn:hover {
  color: var(--ink);
  border-color: rgba(231, 201, 138, 0.35);
}

.chapter-btn[aria-selected="true"] {
  color: var(--gold);
  border-color: rgba(231, 201, 138, 0.45);
  background: rgba(231, 201, 138, 0.1);
}

.reader-panel {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* ---------- Verse flow: three-slot stage ----------
   Fixed viewport: only previous / current / next line are mounted. */
.verse-flow {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 320px;
  max-height: min(52vh, 560px);
  margin-top: 0.25rem;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.verse-line {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  max-width: 40ch;
  margin: 0;
  padding: 0 1rem;
  text-align: center;
  font-family: "Cormorant Garamond", serif;
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink-faint);
  opacity: 0;
  font-size: clamp(1.7rem, 3.6vw, 2.6rem);
  transform: translate(-50%, calc(-50% + 12rem)) scale(0.6);
  will-change: transform, opacity, color, filter;
  transition:
    transform 0.9s var(--ease-out-soft),
    opacity 0.9s var(--ease-out-soft),
    color 0.6s ease,
    filter 0.6s ease;
}

.verse-line.slot-prev {
  transform: translate(-50%, calc(-50% - 10rem)) scale(0.46);
  color: var(--ink-faint);
  opacity: 0.5;
  filter: blur(0.4px);
}

.verse-line.slot-current {
  transform: translate(-50%, -50%) scale(1);
  color: var(--ink);
  opacity: 1;
  filter: none;
  animation: line-breath 5.5s ease-in-out infinite;
}

.verse-line.slot-next {
  transform: translate(-50%, calc(-50% + 10rem)) scale(0.55);
  color: var(--ink-soft);
  opacity: 0.55;
  filter: blur(0.2px);
}

.verse-line.slot-exit {
  transform: translate(-50%, calc(-50% - 18rem)) scale(0.4);
  opacity: 0;
  filter: blur(3px);
}

@keyframes line-breath {
  0%,
  100% {
    text-shadow: 0 0 0 transparent;
  }
  50% {
    text-shadow: 0 0 28px rgba(239, 233, 221, 0.12);
  }
}

/* ---------- Words & letters ---------- */
.word {
  display: inline-block;
}

.letter {
  display: inline-block;
}

.verse-line.slot-current .letter {
  opacity: 1;
}

/* ---------- Emphasized words ---------- */
.word.word-emph {
  padding: 0 0.12em;
}

.word-emph .word-inner {
  display: inline-block;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.005em;
}

.site-footer {
  position: fixed;
  bottom: 0.75rem;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: rgba(239, 233, 221, 0.18);
  pointer-events: none;
  user-select: none;
}

@media (prefers-reduced-motion: reduce) {
  .verse-line,
  .book-toggle-thumb {
    transition-duration: 0.001ms !important;
    animation: none !important;
  }
}
