/* NIRV — Gospel Library inspired styling */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --ink: #1c1c1e;
  --ink-soft: #6e6e73;
  --hairline: #e4e3e0;
  --navy: #123a5e;
  --navy-deep: #0d2c49;
  --gold: #d9b96c;
  --chip: #f1f0ee;
  --serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --topbar-h: 64px;
}

html { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 30;
  background: linear-gradient(to bottom, var(--bg) 65%, rgba(246,245,243,0));
}
.circle-btn {
  width: 44px; height: 44px;
  flex: 0 0 44px;
  border: none;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.circle-btn:active { transform: scale(.94); }
.topbar-title { min-width: 0; }
.topbar-main {
  font-size: 20px; font-weight: 700; letter-spacing: -.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-sub { font-size: 13px; color: var(--ink-soft); margin-top: 1px; }

/* ---------- Screens ---------- */
.screen {
  max-width: 44rem;
  margin: 0 auto;
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 8px) 20px 120px;
  animation: fadeIn .22s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Home ---------- */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  border-radius: 28px;
  color: #fff;
  padding: 28px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 12px 30px rgba(13,44,73,.25);
}
.hero h1 { font-size: 27px; font-weight: 800; letter-spacing: -.3px; line-height: 1.15; }
.hero p { margin-top: 8px; font-size: 13px; color: rgba(255,255,255,.75); max-width: 24ch; }
.hero-mark {
  flex: 0 0 92px; height: 92px;
  border-radius: 20px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-size: 46px;
  color: var(--gold);
}

.shelf {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px 18px;
}
@media (min-width: 560px) { .shelf { grid-template-columns: repeat(3, 1fr); } }

.volume { text-decoration: none; color: inherit; display: block; }
.cover {
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  padding: 16% 12%;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 10px 22px rgba(0,0,0,.22), inset 0 0 0 1px rgba(255,255,255,.06);
  background: linear-gradient(160deg, #1d1d1f 0%, #0d0d0e 100%);
  position: relative;
  transition: transform .15s ease, box-shadow .15s ease;
}
.cover.blue { background: linear-gradient(160deg, #17456e 0%, #0d2c49 100%); }
.cover.brown { background: linear-gradient(160deg, #4e3520 0%, #2b1c10 100%); }
.cover.green { background: linear-gradient(160deg, #23422e 0%, #122218 100%); }
.cover-abbrev {
  font-family: var(--serif);
  font-size: clamp(20px, 6vw, 30px);
  letter-spacing: .06em;
}
.shelf-testaments { margin-top: 8px; }
.volume:active .cover, .volume:hover .cover { transform: translateY(-3px); box-shadow: 0 14px 28px rgba(0,0,0,.28); }
.cover-rule { width: 78%; height: 1px; background: var(--gold); opacity: .9; }
.cover-title {
  font-family: var(--serif);
  color: var(--gold);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: clamp(13px, 3.4vw, 17px);
  line-height: 1.5;
  margin: 12px 0;
}
@media (min-width: 560px) { .cover-title { font-size: 15px; } }
.volume-label {
  text-align: center;
  font-size: 15px;
  margin-top: 12px;
  color: var(--ink);
  line-height: 1.3;
}

/* ---------- Book list ---------- */
.booklist { background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,.05); }
.bookrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 18px;
  text-decoration: none;
  color: var(--ink);
  font-size: 17px;
  border-bottom: 1px solid var(--hairline);
}
.bookrow:last-child { border-bottom: none; }
.bookrow:active { background: var(--chip); }
.bookrow svg { color: #c5c4c2; flex: 0 0 auto; }

/* ---------- Chapter grid ---------- */
.book-summary {
  font-family: var(--serif);
  font-style: italic;
  color: #3a3a3c;
  font-size: 16px;
  line-height: 1.65;
  margin: 4px 2px 24px;
}
.chapters {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
@media (min-width: 560px) { .chapters { grid-template-columns: repeat(8, 1fr); } }
.chap {
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--chip);
  border: 1px solid #e8e7e5;
  border-radius: 12px;
  font-size: 19px;
  color: var(--ink);
  text-decoration: none;
  transition: background .12s ease, transform .12s ease;
}
.chap:active, .chap:hover { background: #e7e6e4; transform: scale(.97); }

/* ---------- Reader (paged track) ---------- */
body.reading { overflow: hidden; }
body.reading .screen { padding: 0; max-width: none; animation: none; }
.reader-viewport {
  position: fixed;
  top: calc(var(--topbar-h) + env(safe-area-inset-top));
  left: 0; right: 0; bottom: 0;
  overflow: hidden;
  touch-action: pan-y;
}
.reader-track {
  display: flex;
  height: 100%;
  will-change: transform;
}
.reader-page {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.page-inner {
  max-width: 44rem;
  margin: 0 auto;
  padding: 4px 20px 140px;
}
.chapter-summary {
  font-family: var(--serif);
  font-style: italic;
  color: #3a3a3c;
  font-size: 15.5px;
  line-height: 1.65;
  margin: 0 0 22px;
}

.chapter-heading {
  font-family: var(--serif);
  text-align: center;
  font-size: 26px;
  letter-spacing: .28em;
  text-indent: .28em;
  font-weight: 400;
  margin: 26px 0 24px;
  color: var(--ink);
  text-transform: uppercase;
}
.psalm-header {
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
  color: #3a3a3c;
  font-size: 15.5px;
  line-height: 1.6;
  margin: 0 0 18px;
}
.verse {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.72;
  margin-bottom: 14px;
  color: #111;
}
.verse .vnum {
  font-weight: 700;
  font-size: 16px;
  margin-right: 7px;
  color: var(--ink);
}
.section-header {
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
  color: #3a3a3c;
  font-size: 15.5px;
  margin: 22px 0 16px;
}
.reader-footer {
  margin: 44px 0 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.pill-btn {
  border: none;
  background: var(--chip);
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--sans);
}
.pill-btn:disabled { opacity: 0; pointer-events: none; }
.pill-btn:active { background: #e7e6e4; }

/* ---------- Desktop edge arrows ---------- */
.edge-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  color: var(--ink);
  cursor: pointer;
  z-index: 25;
  display: none;
  align-items: center;
  justify-content: center;
}
.edge-arrow:hover { background: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.edge-arrow:active { transform: translateY(-50%) scale(.94); }
.edge-left { left: max(18px, calc(50vw - 26rem - 70px)); }
.edge-right { right: max(18px, calc(50vw - 26rem - 70px)); }
@media (min-width: 900px) and (hover: hover) {
  .edge-arrow:not([hidden]) { display: flex; }
}

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
  display: flex;
  gap: 8px;
  padding: 8px 14px;
  z-index: 30;
}
.nav-btn {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  color: #3a3a3c;
  border-radius: 50%;
}
.nav-btn.active { color: var(--navy); background: var(--chip); }
.nav-btn:active { background: var(--chip); }

.loading { text-align: center; color: var(--ink-soft); padding: 60px 0; font-size: 15px; }

.footnote-line {
  margin-top: 40px;
  text-align: center;
  font-size: 12.5px;
  color: #a9a8a6;
}
