/* ═══════════════════════════════════════════════════════════════════════
   Bookshelf reader — distraction-free reading experience
   ═══════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables (theme / font / size tokens) ──────────────────────── */
:root {
  --rd-bg: #ffffff;
  --rd-fg: #18181b;
  --rd-muted: #71717a;
  --rd-border: #e4e4e7;
  --rd-surface: #f4f4f5;
  --rd-accent: #5b7fa6;
  --rd-bar-bg: rgba(255, 255, 255, 0.92);
  --rd-font: "Newsreader", Georgia, serif;
  --rd-size: 18px;
  --rd-lh: 1.85;
  --rd-bar-h: 50px;
  --rd-max-w: 700px;
  --rd-transition: background 0.25s ease, color 0.25s ease;
}

html[data-rd-theme="dark"] {
  --rd-bg: #18181b;
  --rd-fg: #f1f1f3;
  --rd-muted: #a1a1aa;
  --rd-border: #3f3f46;
  --rd-surface: #27272a;
  --rd-bar-bg: rgba(24, 24, 27, 0.93);
}

html[data-rd-theme="sepia"] {
  --rd-bg: #f5ecd7;
  --rd-fg: #3d2b1f;
  --rd-muted: #8b6f5e;
  --rd-border: #d4b896;
  --rd-surface: #ede0c8;
  --rd-bar-bg: rgba(245, 236, 215, 0.93);
  --rd-accent: #8b5e3c;
}

/* ── Base ────────────────────────────────────────────────────────────── */
html.reader-html {
  font-size: 16px;
}

body.reader-body {
  background: var(--rd-bg);
  color: var(--rd-fg);
  font-family: var(--rd-font);
  font-size: var(--rd-size);
  line-height: var(--rd-lh);
  transition: var(--rd-transition);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Top Bar ─────────────────────────────────────────────────────────── */
.rd-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--rd-bar-h);
  background: var(--rd-bar-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rd-border);
  z-index: 1040;
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  gap: 0.5rem;
  transition: var(--rd-transition);
}

.rd-bar-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0 0.4rem;
  text-decoration: none;
}

.rd-logo-img {
  height: 20px;
  width: auto;
  display: block;
  transition: opacity 0.15s;
}

html[data-rd-theme="dark"] .rd-logo-img {
  filter: invert(1);
}

.rd-bar-logo:hover .rd-logo-img {
  opacity: 0.7;
}

.rd-bar-divider {
  width: 1px;
  height: 22px;
  background: var(--rd-border);
  flex-shrink: 0;
  margin: 0 0.25rem;
}

.rd-bar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: none;
  border: none;
  color: var(--rd-fg);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: "Public Sans", sans-serif;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
  text-decoration: none;
}

.rd-bar-btn:hover {
  background: var(--rd-surface);
  color: var(--rd-fg);
}

.rd-bar-btn i {
  font-size: 1rem;
}

.rd-bar-back {
  font-size: 0.78rem;
  gap: 0.3rem;
}

.rd-bar-title {
  flex: 1;
  text-align: center;
  font-family: "Public Sans", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--rd-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 0.5rem;
  letter-spacing: 0.01em;
}

/* ── Settings Panel ──────────────────────────────────────────────────── */
.rd-settings {
  position: fixed;
  top: var(--rd-bar-h);
  right: 0;
  width: min(340px, 100vw);
  background: var(--rd-bg);
  border: 1px solid var(--rd-border);
  border-top: none;
  border-right: none;
  border-bottom-left-radius: 12px;
  padding: 1.25rem 1.25rem 1rem;
  z-index: 1039;
  box-shadow: -4px 4px 20px rgba(0, 0, 0, 0.12);
  display: none;
  transition: var(--rd-transition);
}

.rd-settings.open {
  display: block;
}

.rd-settings-label {
  font-family: "Public Sans", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rd-muted);
  margin-bottom: 0.5rem;
  margin-top: 0.75rem;
}

.rd-settings-label:first-child {
  margin-top: 0;
}

/* Theme swatches */
.rd-theme-row {
  display: flex;
  gap: 0.5rem;
}

.rd-theme-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem;
  border-radius: 7px;
  border: 2px solid var(--rd-border);
  cursor: pointer;
  font-family: "Public Sans", sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  transition: border-color 0.15s;
}

.rd-theme-btn.active {
  border-color: var(--rd-accent);
}

.rd-theme-btn[data-theme="light"] {
  background: #fff;
  color: #18181b;
}
.rd-theme-btn[data-theme="sepia"] {
  background: #f5ecd7;
  color: #3d2b1f;
}
.rd-theme-btn[data-theme="dark"] {
  background: #18181b;
  color: #f1f1f3;
}

/* Font family row */
.rd-font-row {
  display: flex;
  gap: 0.5rem;
}

.rd-font-btn {
  flex: 1;
  padding: 0.45rem 0.25rem;
  border-radius: 7px;
  border: 2px solid var(--rd-border);
  background: var(--rd-bg);
  color: var(--rd-fg);
  cursor: pointer;
  font-size: 0.9rem;
  text-align: center;
  transition: border-color 0.15s;
}

.rd-font-btn.active {
  border-color: var(--rd-accent);
}
.rd-font-btn[data-font="newsreader"] {
  font-family: "Newsreader", serif;
}
.rd-font-btn[data-font="baskerville"] {
  font-family: "Libre Baskerville", serif;
}
.rd-font-btn[data-font="sans"] {
  font-family: "Public Sans", sans-serif;
}

/* Font size row */
.rd-size-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rd-size-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 2px solid var(--rd-border);
  background: var(--rd-bg);
  color: var(--rd-fg);
  cursor: pointer;
  font-family: "Public Sans", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  transition:
    border-color 0.15s,
    background 0.15s;
  flex-shrink: 0;
}

.rd-size-btn:hover {
  background: var(--rd-surface);
}

.rd-size-display {
  flex: 1;
  text-align: center;
  font-family: "Public Sans", sans-serif;
  font-size: 0.82rem;
  color: var(--rd-muted);
}

/* ── Main Reading Content ────────────────────────────────────────────── */
.rd-main {
  padding-top: calc(var(--rd-bar-h) + 2.5rem);
  padding-bottom: 5rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.rd-content {
  max-width: var(--rd-max-w);
  margin: 0 auto;
}

/* Chapter heading */
.rd-chapter-title {
  font-family: "Public Sans", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rd-muted);
  margin-bottom: 0.5rem;
}

.rd-chapter-heading {
  font-family: var(--rd-font);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--rd-fg);
  margin-bottom: 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rd-border);
}

/* Section subheading */
.rd-section {
  scroll-margin-top: calc(var(--rd-bar-h) + 1rem);
  margin-top: 2.5rem;
  padding-top: 0.25rem;
}

.rd-section-heading {
  font-family: "Public Sans", sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--rd-accent);
  margin-bottom: 1rem;
}

/* Paragraphs */
.rd-para {
  margin-bottom: 1.25em;
  color: var(--rd-fg);
}

.rd-para:first-of-type::first-letter {
  font-size: 3.2em;
  line-height: 0.85;
  float: left;
  margin-right: 0.08em;
  margin-top: 0.05em;
  font-weight: 600;
}

/* Drop cap only on very first paragraph of the chapter */
.rd-section + .rd-section .rd-para:first-of-type::first-letter,
.rd-section-heading ~ .rd-para:not(:first-of-type)::first-letter {
  all: unset;
}

/* Page number badge */
.rd-page-num {
  display: inline-block;
  font-family: "Public Sans", sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--rd-muted);
  background: var(--rd-surface);
  border-radius: 3px;
  padding: 0 0.35em;
  margin-right: 0.4em;
  vertical-align: middle;
  position: relative;
  top: -0.1em;
}

/* ── Chapter Navigation (prev/next) ──────────────────────────────────── */
.rd-chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rd-border);
  gap: 1rem;
}

.rd-chapter-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--rd-border);
  background: var(--rd-bg);
  color: var(--rd-fg);
  font-family: "Public Sans", sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition:
    background 0.15s,
    border-color 0.15s;
  max-width: 48%;
  min-width: 0;
}

.rd-chapter-nav-btn:hover {
  background: var(--rd-surface);
  border-color: var(--rd-accent);
  color: var(--rd-fg);
}

.rd-chapter-nav-btn > span {
  min-width: 0;
  overflow: hidden;
}

.rd-chapter-nav-btn > i {
  flex-shrink: 0;
}

.rd-chapter-nav-btn .rd-nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.rd-chapter-nav-btn .rd-nav-hint {
  font-size: 0.68rem;
  color: var(--rd-muted);
  display: block;
  white-space: nowrap;
}

.rd-chapter-nav-btn.rd-nav-next {
  margin-left: auto;
  text-align: right;
}

/* ── TOC Offcanvas ───────────────────────────────────────────────────── */
.rd-toc-offcanvas {
  background: var(--rd-bg) !important;
  color: var(--rd-fg) !important;
  border-right: 1px solid var(--rd-border) !important;
  transition: var(--rd-transition);
  width: min(340px, 90vw) !important;
}

.rd-toc-offcanvas .offcanvas-header {
  border-bottom: 1px solid var(--rd-border);
  padding: 0.85rem 1rem;
}

.rd-toc-offcanvas .offcanvas-title {
  font-family: "Public Sans", sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rd-fg);
}

.rd-toc-offcanvas .btn-close {
  filter: none;
  opacity: 0.6;
}

html[data-rd-theme="dark"] .rd-toc-offcanvas .btn-close {
  filter: invert(1);
}

.rd-toc-offcanvas .offcanvas-body {
  padding: 0;
  overflow-y: auto;
}

/* TOC Chapter row */
.rd-toc-chapter {
  padding: 0.6rem 1rem 0.5rem;
  border-bottom: 1px solid var(--rd-border);
}

.rd-toc-chapter-link {
  display: block;
  font-family: "Public Sans", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--rd-fg);
  text-decoration: none;
  line-height: 1.35;
  padding: 0.2rem 0;
  transition: color 0.15s;
}

.rd-toc-chapter-link:hover {
  color: var(--rd-accent);
}

.rd-toc-chapter-link.active {
  color: var(--rd-accent);
}

/* TOC Subheading list */
.rd-toc-subs {
  list-style: none;
  padding: 0.3rem 0 0.2rem 0.75rem;
  margin: 0;
}

.rd-toc-sub-link {
  display: block;
  font-family: "Newsreader", serif;
  font-size: 0.82rem;
  color: var(--rd-muted);
  text-decoration: none;
  padding: 0.2rem 0;
  line-height: 1.35;
  transition: color 0.15s;
  border-left: 2px solid transparent;
  padding-left: 0.6rem;
}

.rd-toc-sub-link:hover {
  color: var(--rd-fg);
}

.rd-toc-sub-link.active {
  color: var(--rd-accent);
  border-left-color: var(--rd-accent);
}

/* ── Bible Reference Links ───────────────────────────────────────────── */
.bible-ref-link {
  color: var(--rd-accent);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}

.bible-ref-link:hover {
  color: var(--rd-accent);
  text-decoration-style: solid;
}

.bible-ref-popover {
  --bs-popover-max-width: 340px;
  font-family: var(--rd-font, serif);
}

.bible-ref-popover .popover-body {
  font-size: 0.88rem;
  line-height: 1.65;
  color: #18181b;
}

.bible-ref-popover .brf-verse {
  margin-bottom: 0.6em;
}

.bible-ref-popover .brf-verse:last-child {
  margin-bottom: 0;
}

.brf-vnum {
  font-size: 0.72em;
  font-weight: 700;
  color: #6b7280;
  margin-right: 0.15em;
  vertical-align: super;
  line-height: 0;
}

/* ── Bible Reading Viewer ────────────────────────────────────────────── */
.rd-bible-verse {
  font-family: var(--rd-font);
  font-size: var(--rd-size);
  line-height: var(--rd-lh);
  color: var(--rd-fg);
  margin-bottom: 0.25em;
}

.rd-verse-num {
  font-family: "Public Sans", sans-serif;
  font-size: 0.62em;
  font-weight: 700;
  color: var(--rd-muted);
  margin-right: 0.25em;
  vertical-align: super;
  line-height: 0;
}

/* ── Note body HTML (TinyMCE content) ───────────────────────────────── */
.rd-body-html p {
  margin-bottom: 1.25em;
  color: var(--rd-fg);
  font-family: var(--rd-font);
  font-size: var(--rd-size);
  line-height: var(--rd-lh);
}

.rd-body-html blockquote {
  border-left: 3px solid var(--rd-accent);
  padding-left: 1rem;
  margin-left: 0;
  margin-right: 0;
  color: var(--rd-fg);
}

.rd-body-html ul,
.rd-body-html ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25em;
  color: var(--rd-fg);
}

.rd-body-html li {
  margin-bottom: 0.35em;
}

/* ── Bookshelf Index page ────────────────────────────────────────────── */
.bookshelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.75rem;
}

.bookshelf-card {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--bs-border-color);
  transition:
    box-shadow 0.2s,
    transform 0.2s;
  background: #fff;
  text-decoration: none;
  color: inherit;
}

.bookshelf-card:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.13);
  transform: translateY(-3px);
}

.bookshelf-spine {
  height: 8px;
}

.bookshelf-card-body {
  padding: 1.25rem 1.25rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.bookshelf-title {
  font-family: "Libre Baskerville", serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  color: #18181b;
  margin-bottom: 0.3rem;
}

.bookshelf-author {
  font-family: "Public Sans", sans-serif;
  font-size: 0.78rem;
  color: #71717a;
  margin-bottom: auto;
}

.bookshelf-cta {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

/* ── TOC page ────────────────────────────────────────────────────────── */
.toc-hero {
  padding: 2.5rem 0 2rem;
}

.toc-book-title {
  font-family: "Libre Baskerville", serif;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.35rem;
}

.toc-book-author {
  font-family: "Public Sans", sans-serif;
  font-size: 0.85rem;
  color: #71717a;
}

.toc-section {
  margin-bottom: 0.25rem;
}

.toc-chapter-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--bs-border-color);
  text-decoration: none;
  color: inherit;
}

.toc-chapter-header:hover .toc-chapter-name {
  color: var(--highlight, #c0392b);
}

.toc-chapter-num {
  font-family: "Public Sans", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #71717a;
  flex-shrink: 0;
  min-width: 3rem;
}

.toc-chapter-name {
  font-family: "Libre Baskerville", serif;
  font-size: 0.95rem;
  line-height: 1.4;
  transition: color 0.15s;
}

.toc-sub-list {
  list-style: none;
  padding: 0.35rem 0 0.5rem 3.75rem;
  margin: 0;
}

.toc-sub-list li + li {
  margin-top: 0.15rem;
}

.toc-sub-link {
  font-family: "Newsreader", serif;
  font-size: 0.88rem;
  color: #52525b;
  text-decoration: none;
  transition: color 0.15s;
}

.toc-sub-link:hover {
  color: var(--highlight, #c0392b);
}

/* ── Bible TOC Accordion ─────────────────────────────────────────────── */

/* Testament / section header row */
.btoc-testament-hdr {
  padding: 0.45rem 1rem 0.3rem;
  font-family: "Public Sans", sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rd-muted);
  background: var(--rd-surface);
  border-bottom: 1px solid var(--rd-border);
  border-top: 1px solid var(--rd-border);
}

/* Today's readings block */
.btoc-readings {
  border-bottom: 2px solid var(--rd-border);
  padding-bottom: 0.25rem;
}

.btoc-reading-link {
  display: block;
  padding: 0.35rem 1rem;
  font-family: "Public Sans", sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--rd-accent);
  text-decoration: none;
  border-bottom: 1px solid var(--rd-border);
  transition: background 0.12s;
}

.btoc-reading-link:hover,
.btoc-reading-link.active {
  background: var(--rd-surface);
  color: var(--rd-accent);
}

.btoc-reading-link.active {
  border-left: 3px solid var(--rd-accent);
  padding-left: calc(1rem - 3px);
}

/* Book row */
details.btoc-book {
  border-bottom: 1px solid var(--rd-border);
}

details.btoc-book > summary.btoc-book-summary {
  list-style: none;
  cursor: pointer;
  padding: 0.5rem 1rem;
  font-family: "Public Sans", sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--rd-fg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: background 0.12s;
}

details.btoc-book > summary.btoc-book-summary::-webkit-details-marker {
  display: none;
}
details.btoc-book > summary.btoc-book-summary::marker {
  display: none;
  content: "";
}

details.btoc-book > summary.btoc-book-summary::after {
  content: "›";
  font-size: 1.1rem;
  color: var(--rd-muted);
  display: inline-block;
  transition: transform 0.15s;
}

details.btoc-book[open] > summary.btoc-book-summary::after {
  transform: rotate(90deg);
}

details.btoc-book > summary.btoc-book-summary:hover {
  background: var(--rd-surface);
}

/* Chapter row */
details.btoc-chapter {
  border-top: 1px solid var(--rd-border);
}

details.btoc-chapter > summary.btoc-chapter-summary {
  list-style: none;
  cursor: pointer;
  padding: 0.35rem 1rem 0.35rem 1.75rem;
  font-family: "Public Sans", sans-serif;
  font-size: 0.8rem;
  color: var(--rd-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: background 0.12s;
}

details.btoc-chapter > summary.btoc-chapter-summary::-webkit-details-marker {
  display: none;
}
details.btoc-chapter > summary.btoc-chapter-summary::marker {
  display: none;
  content: "";
}

details.btoc-chapter > summary.btoc-chapter-summary::after {
  content: "›";
  font-size: 1rem;
  display: inline-block;
  transition: transform 0.15s;
}

details.btoc-chapter[open] > summary.btoc-chapter-summary::after {
  transform: rotate(90deg);
}

details.btoc-chapter > summary.btoc-chapter-summary:hover {
  background: var(--rd-surface);
  color: var(--rd-fg);
}

/* Verse number grid */
.btoc-verses {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  padding: 0.5rem 1rem 0.5rem 1.75rem;
  background: var(--rd-surface);
  border-top: 1px solid var(--rd-border);
}

.btoc-verse-link {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  font-family: "Public Sans", sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--rd-muted);
  text-decoration: none;
  border-radius: 3px;
  line-height: 1.7;
  transition:
    background 0.1s,
    color 0.1s;
}

.btoc-verse-link:hover {
  background: var(--rd-accent);
  color: #fff;
}

/* Verse paragraphs in the reading area */
.btoc-verse-para {
  margin: 0 0 0.1em;
  line-height: 1.85;
}

.btoc-vnum {
  font-family: "Public Sans", sans-serif;
  font-size: 0.62em;
  font-weight: 700;
  color: var(--rd-muted);
  margin-right: 0.2em;
  vertical-align: super;
  line-height: 0;
}

.btoc-section-head {
  font-weight: 700;
  margin: 1.25em 0 0.25em;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rd-muted);
}
