/* ==========================================================
   Bible reader (/bible/), its popups and the side panel
   (also used on devotion pages), and the study method guide.
   Built on the site's tokens in style.css.
   ========================================================== */

/* ---------- Reader colors: dark by default, light on request ---------- */
:root {
  --r-bg: var(--espresso);
  --r-surface: var(--roast);
  --r-raised: #4A3324;
  --r-text: var(--steam);
  --r-muted: var(--muted-d);
  --r-accent: var(--dawn);
  --r-accent-soft: rgba(240, 180, 65, .14);
  --r-line: rgba(245, 243, 240, .12);
  --r-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --r-pane-w: 50vw;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --r-bg: #FBF8F3; --r-surface: #F1EBE2; --r-raised: #E8DFD2; --r-text: var(--ink); --r-muted: var(--muted-l);
    --r-accent: var(--link-l); --r-accent-soft: rgba(154, 98, 0, .1); --r-line: rgba(35, 23, 16, .12); --r-shadow: 0 10px 30px rgba(35, 23, 16, .18);
  }
}
:root[data-theme="light"] {
  --r-bg: #FBF8F3; --r-surface: #F1EBE2; --r-raised: #E8DFD2; --r-text: var(--ink); --r-muted: var(--muted-l);
  --r-accent: var(--link-l); --r-accent-soft: rgba(154, 98, 0, .1); --r-line: rgba(35, 23, 16, .12); --r-shadow: 0 10px 30px rgba(35, 23, 16, .18);
}

body.reader-page { background: var(--r-bg); color: var(--r-text); }
body.reader-page main { background: var(--r-bg); color: var(--r-text); }
body.reader-page .site-header, body.reader-page .site-footer { color: var(--steam); }
body.reader-page .site-footer { background: var(--espresso); }
body.reader-page .page-head h1, body.reader-page .lede { color: var(--r-text); }
body.reader-page .lede, body.reader-page .crumbs { color: var(--r-muted); }
body.reader-page .kicker { color: var(--r-accent); }
.reader-page main p a:not([class]), .split-pane p a:not([class]), .xr-pop a:not([class]) { color: var(--r-accent); }

/* ---------- Book and chapter lists ---------- */
.book-grid, .chapter-grid { list-style: none; padding: 0; margin: 0 0 2.5rem; display: grid; gap: .6rem; }
.book-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.chapter-grid { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
.book-grid a, .chapter-grid a {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  min-height: 48px; padding: .6rem .9rem; border-radius: 10px;
  background: var(--r-surface); color: var(--r-text); text-decoration: none; font-weight: 500;
  border: 1px solid transparent;
}
.chapter-grid a { justify-content: center; font-variant-numeric: tabular-nums; }
.book-grid a:hover, .chapter-grid a:hover { border-color: var(--r-accent); }
.has-devs { min-width: 1.5rem; height: 1.5rem; padding: 0 .4rem; border-radius: 999px; background: var(--r-accent); color: var(--r-bg); font-size: .8rem; font-weight: 700; display: inline-grid; place-items: center; }
.chapter-grid a.has-dev::after { content: ""; position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--r-accent); }
.reader-page .testament { color: var(--r-accent); }

/* ---------- "Learn the method" card ---------- */
.method-card {
  display: flex; gap: 1rem; align-items: center; margin-top: 1.75rem; padding: .9rem; max-width: 36rem;
  background: var(--r-surface); border: 1px solid var(--r-line); border-radius: 12px; color: var(--r-text); text-decoration: none;
}
.method-card:hover { border-color: var(--r-accent); }
.method-card img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; flex: none; }
.method-card > span { display: grid; gap: .15rem; }
.method-kicker { color: var(--r-accent); font-size: .85rem; font-weight: 700; }
.method-title { font-family: "Bitter", Georgia, serif; font-weight: 800; font-size: 1.15rem; }
.method-sub { color: var(--r-muted); font-size: .95rem; }

/* ---------- Chapter page ---------- */
.reader-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; padding-top: 1.5rem; }
.reader-top .crumbs { margin: 0; }
.reader-tools { display: flex; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; }
.rt-link { color: var(--r-accent); font-weight: 500; font-size: .95rem; }
.rt-theme {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: .4rem .8rem;
  border-radius: 999px; border: 1px solid var(--r-line); background: transparent; color: var(--r-text);
  font: 500 .9rem/1 "Figtree", system-ui, sans-serif; cursor: pointer;
}
.rt-theme:hover { border-color: var(--r-accent); }

.chapter { padding-top: 1.5rem; padding-bottom: 3rem; }
.chapter h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); font-weight: 800; color: var(--r-text); }
.chapter-meta { margin-top: .5rem; color: var(--r-muted); }
.chapter-meta a { color: var(--r-accent); }
.verses { margin-top: 2rem; max-width: 40rem; }
.v {
  font-family: Georgia, "Times New Roman", serif; font-size: 1.2rem; line-height: 1.75;
  margin: 0 0 .5rem; padding: .1rem .5rem .1rem .75rem; border-left: 3px solid transparent; border-radius: 0 6px 6px 0;
  scroll-margin-top: 6rem; transition: background-color .3s;
}
.v.has-dev { border-left-color: var(--r-accent); }
.v.hl { background: var(--r-accent-soft); }
.vn {
  font-family: "Figtree", system-ui, sans-serif; font-size: .62em; font-weight: 600;
  color: var(--r-muted); opacity: .75; margin-right: .4em; vertical-align: .55em; line-height: 0; user-select: none;
}
.xr {
  display: inline-grid; place-items: center; width: 26px; height: 26px; margin: 0 0 0 .1rem; padding: 0;
  vertical-align: -.15em; border: 0; border-radius: 50%; background: transparent; cursor: pointer;
}
.xr::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--r-accent); opacity: .8; }
.xr:hover::after, .xr[aria-expanded="true"]::after { opacity: 1; transform: scale(1.35); }
.xr:focus-visible { outline: 2px solid var(--r-accent); outline-offset: 1px; }

/* Devotion cards inside the text */
.dev-card {
  max-width: 40rem; margin: 1.25rem 0 1rem; padding: .85rem .9rem .9rem;
  background: var(--r-surface); border: 1px solid var(--r-line); border-left: 4px solid var(--r-accent); border-radius: 0 12px 12px 0;
}
.dev-kicker { color: var(--r-accent); font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-bottom: .6rem; }
.dev-kicker::before { content: "▶ "; }
.dev-link { display: flex; gap: .85rem; align-items: center; color: var(--r-text); text-decoration: none; }
.dev-link + .dev-link { margin-top: .65rem; }
.dev-link img { width: 128px; height: 72px; object-fit: cover; border-radius: 6px; flex: none; background: #1A100A; }
.dev-text { display: grid; gap: .2rem; }
.dev-title { font-weight: 700; line-height: 1.3; }
.dev-link:hover .dev-title { text-decoration: underline; text-decoration-color: var(--r-accent); }
.dev-meta { color: var(--r-muted); font-size: .9rem; }

/* Previous / chapter picker / next */
.reader-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75rem; margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--r-line); max-width: 40rem; }
.rb-prev, .rb-next { display: inline-flex; align-items: center; gap: .4rem; min-height: 48px; color: var(--r-text); text-decoration: none; font-weight: 500; }
.rb-next { justify-self: end; }
.rb-prev span[aria-hidden], .rb-next span[aria-hidden] { font-size: 1.6rem; line-height: 1; color: var(--r-accent); }
.rb-prev:hover .rb-label, .rb-next:hover .rb-label { text-decoration: underline; }
.rb-pick {
  min-height: 44px; padding: .5rem 1.1rem; border-radius: 999px; border: 1px solid var(--r-accent);
  background: transparent; color: var(--r-text); font: 700 1rem/1 "Figtree", system-ui, sans-serif; cursor: pointer; white-space: nowrap;
}
.rb-pick:hover { background: var(--r-accent-soft); }
.reader-credit { margin-top: 2rem; font-size: .85rem; color: var(--r-muted); max-width: 40rem; }
.reader-page main .reader-credit a:not([class]) { color: var(--r-muted); font-weight: 400; }

@media (max-width: 719px) {
  /* Chapter bar pinned to the bottom of the screen on phones */
  .reader .reader-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; max-width: none;
    padding: .35rem 1rem calc(.35rem + env(safe-area-inset-bottom)); background: var(--r-surface); border-top: 1px solid var(--r-line);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, .18);
  }
  .rb-label { display: none; }
  .rb-prev, .rb-next { min-width: 48px; justify-content: center; }
  .reader-page:has(.reader) .site-footer { padding-bottom: 5.5rem; }
  .v { font-size: 1.12rem; padding-left: .6rem; }
  .rt-theme-label { display: none; }
}

/* ---------- Cross-reference popup ---------- */
.xr-pop {
  position: absolute; z-index: 60; width: min(26rem, calc(100vw - 2rem)); max-height: min(28rem, 70vh); overflow: auto;
  background: var(--r-surface); color: var(--r-text); border: 1px solid var(--r-line); border-radius: 12px; box-shadow: var(--r-shadow);
  padding: .4rem 0; font-size: 1rem;
}
.xr-pop-head { display: flex; align-items: center; justify-content: space-between; padding: .4rem .5rem .4rem 1rem; color: var(--r-muted); font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.xr-close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--r-muted); font-size: 1.4rem; cursor: pointer; }
.xr-close:hover { background: var(--r-raised); color: var(--r-text); }
.xr-item { padding: .7rem 1rem .8rem; border-top: 1px solid var(--r-line); }
.xr-ref { font-weight: 700; }
.xr-text { margin-top: .3rem; font-family: Georgia, serif; line-height: 1.6; color: var(--r-text); }
.xr-text sup { font-family: "Figtree", sans-serif; font-size: .7em; color: var(--r-muted); margin-right: .25em; }
.xr-actions { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .55rem; align-items: center; }
.xr-open {
  min-height: 36px; padding: .35rem .9rem; border-radius: 999px; border: 1px solid var(--r-accent);
  background: transparent; color: var(--r-accent); font: 700 .9rem/1 "Figtree", sans-serif; cursor: pointer;
}
.xr-open:hover { background: var(--r-accent); color: var(--r-bg); }
.xr-newtab { color: var(--r-muted); font-size: .9rem; }
.xr-newtab:hover { color: var(--r-text); }
.xr-credit { padding: .4rem 1rem .3rem; font-size: .75rem; color: var(--r-muted); }
@media (hover: none) { .xr-newtab { display: none; } }
@media (max-width: 719px) {
  .xr-pop { position: fixed; left: .75rem !important; right: .75rem; top: auto !important; bottom: calc(4.5rem + env(safe-area-inset-bottom)); width: auto; max-height: 60vh; }
}

/* ---------- Side panel (desktop) / bottom sheet (phone) ---------- */
.split-pane {
  position: fixed; z-index: 50; background: var(--r-bg); color: var(--r-text);
  display: flex; flex-direction: column; box-shadow: var(--r-shadow);
  transition: transform .28s ease, visibility .28s;
  visibility: hidden;
}
.split-pane.is-open { visibility: visible; }
.split-head {
  display: flex; align-items: center; gap: .5rem; padding: .6rem .6rem .6rem 1.25rem;
  border-bottom: 1px solid var(--r-line); background: var(--r-surface); flex: none;
}
.split-title { font-family: "Bitter", Georgia, serif; font-weight: 800; font-size: 1.15rem; margin-right: auto; }
.split-head a { color: var(--r-accent); font-size: .9rem; font-weight: 500; }
.split-body { overflow: auto; padding: 1rem 1.25rem 3rem; overscroll-behavior: contain; flex: 1; }
.split-body .v { font-size: 1.1rem; }
.split-body .xr, .split-body .dev-card { display: none; }
.split-handle { display: none; }

@media (min-width: 900px) {
  .split-pane { top: 0; right: 0; bottom: 0; width: var(--r-pane-w); border-left: 1px solid var(--r-line); transform: translateX(100%); }
  .split-pane.is-open { transform: translateX(0); }
  /* Reader: the two chapters side by side */
  body.reader-page.split-open .reader { margin-right: var(--r-pane-w); }
  /* Devotion pages: a narrower panel next to the video */
  body:not(.reader-page) { --r-pane-w: min(520px, 42vw); }
}
@media (min-width: 1280px) {
  body:not(.reader-page).split-open main { margin-right: var(--r-pane-w); }
}
@media (max-width: 899px) {
  .split-pane { left: 0; right: 0; bottom: 0; height: 78vh; border-radius: 16px 16px 0 0; transform: translateY(100%); }
  .split-pane.is-open { transform: translateY(0); }
  .split-handle { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--r-line); margin: .5rem auto 0; flex: none; }
  .split-head { border-radius: 16px 16px 0 0; touch-action: none; }
  .split-newtab { display: none; }
}
.split-scrim { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .35); }
@media (min-width: 900px) { .split-scrim { display: none; } }

/* ---------- Book & chapter picker ---------- */
.picker {
  width: min(44rem, calc(100vw - 2rem)); max-height: min(40rem, 85vh); padding: 0; border: 1px solid var(--r-line); border-radius: 14px;
  background: var(--r-bg); color: var(--r-text); box-shadow: var(--r-shadow);
}
.picker::backdrop { background: rgba(0, 0, 0, .5); }
.picker-head { position: sticky; top: 0; display: flex; align-items: center; gap: .5rem; padding: .6rem .6rem .6rem 1.25rem; background: var(--r-surface); border-bottom: 1px solid var(--r-line); }
.picker-head h2 { font-size: 1.2rem; margin-right: auto; }
.picker-back { min-height: 40px; padding: 0 .75rem; border: 0; border-radius: 999px; background: transparent; color: var(--r-accent); font: 700 .95rem "Figtree", sans-serif; cursor: pointer; }
.picker-body { padding: 1rem 1.25rem 1.5rem; }
.picker-body h3 { font-family: "Figtree", sans-serif; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--r-accent); margin: .5rem 0 .75rem; }
.picker .book-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); margin-bottom: 1.5rem; }
.picker .book-grid button, .picker .chapter-grid a {
  width: 100%; min-height: 46px; padding: .5rem .75rem; border-radius: 10px; border: 1px solid transparent;
  background: var(--r-surface); color: var(--r-text); font: 500 .95rem "Figtree", sans-serif; text-align: left; cursor: pointer;
}
.picker .book-grid button:hover, .picker .chapter-grid a:hover, .picker .book-grid button[aria-current] { border-color: var(--r-accent); }

/* ---------- Devotion page: "read in context" links ---------- */
.read-context { color: inherit; text-decoration: underline; text-decoration-color: var(--dawn); text-underline-offset: .2em; }
.read-context:hover { color: var(--dawn); }
.scripture .read-more { margin-left: auto; color: var(--dawn); font-size: .9rem; font-weight: 600; text-decoration: none; }
.scripture .read-more:hover { text-decoration: underline; }

/* ---------- The three-column method guide ---------- */
.method { padding: 0 0 5rem; }
.method-video { max-width: 280px; margin: 0 0 2.5rem; }
.method-video .player { aspect-ratio: 9 / 16; }
.method-video-note { margin-top: .6rem; color: var(--muted-d); font-size: .95rem; }
.method-step { padding: 1.5rem 1.6rem; background: var(--roast); border-radius: 12px; margin-bottom: 1.5rem; }
.method-step h2, .method-col h2, .method-try h2 { font-size: clamp(1.35rem, 2.6vw, 1.7rem); font-weight: 800; margin-bottom: .75rem; }
.method-step p + p, .method-col p + p, .method-try p + p { margin-top: .75rem; }
.method-warning { color: var(--dawn); }
.method-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 2rem 0 1.5rem; }
.method-col { padding: 1.3rem 1.3rem 1.5rem; border: 1px solid rgba(245, 243, 240, .14); border-top: 4px solid var(--dawn); border-radius: 10px; }
.method-num { color: var(--dawn); font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .35rem; }
.speck { margin: 1rem 0 0; display: grid; gap: .75rem; }
.speck dt { font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.speck dd { margin: .2rem 0 0 2.2rem; color: var(--muted-d); font-size: .95rem; }
.speck-letter { width: 1.7rem; height: 1.7rem; border-radius: 6px; background: var(--dawn); color: var(--espresso); display: inline-grid; place-items: center; font-family: "Bitter", serif; font-weight: 800; }
.method-try { margin-top: 2.5rem; }
.method-try .btn { margin-top: 1rem; }
@media (max-width: 860px) { .method-columns { grid-template-columns: 1fr; } }

@media print {
  .site-header, .site-footer, .cta, .browse-buttons, .method-video, .method-try .btn { display: none !important; }
  body, main, .method-step, .method-col { background: #fff !important; color: #000 !important; }
  .method-columns { grid-template-columns: 1fr 1fr 1fr; }
  .method-col { border-color: #999; }
  .speck dd, .method-video-note { color: #333 !important; }
  .speck-letter { background: #000; color: #fff; }
  .method-warning, .method-num { color: #000 !important; }
}

/* More than two devotions on one spot: the rest fold away */
.dev-more { margin-top: .65rem; }
.dev-more summary { cursor: pointer; color: var(--r-accent); font-weight: 700; font-size: .9rem; width: fit-content; min-height: 32px; display: flex; align-items: center; }
.dev-more[open] summary { margin-bottom: .65rem; }
@media (max-width: 719px) {
  .dev-link img { width: 96px; height: 54px; }
  .dev-title { font-size: .95rem; }
  .dev-card { padding: .7rem .75rem .75rem; }
}

/* ---------- Selecting verses to journal on ---------- */
.reader .verses .v { cursor: pointer; }
.v.sel { background: var(--r-accent-soft); box-shadow: inset 3px 0 0 var(--r-accent); }
.sel-hint { white-space: nowrap; }
.sel-bar {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: 1.5rem;
  display: flex; align-items: center; gap: .6rem; padding: .45rem .45rem .45rem 1rem;
  max-width: calc(100vw - 1.5rem); border-radius: 999px; background: var(--r-surface); border: 1px solid var(--r-line); box-shadow: var(--r-shadow);
}
.sel-label { font-weight: 700; color: var(--r-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-bar .btn-small { white-space: nowrap; }
/* "Journal this passage" pill (sticks under the site header while reading) */
.jp-wrap { position: sticky; top: calc(var(--hdr, 4.5rem) + .5rem); z-index: 8; height: 0; overflow: visible; display: flex; justify-content: flex-end; pointer-events: none; }
.jp {
  pointer-events: auto; display: inline-flex; align-items: center; gap: .45rem; min-height: 40px; padding: .4rem .9rem .4rem .75rem; margin-top: .9rem;
  border-radius: 999px; border: 1px solid var(--r-accent); background: var(--r-surface); color: var(--r-accent);
  font: 700 .9rem/1.1 "Figtree", system-ui, sans-serif; text-decoration: none; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); white-space: nowrap;
}
.jp:hover { background: var(--r-accent); color: var(--r-bg); }
.jp:focus-visible { outline: 3px solid var(--r-accent); outline-offset: 2px; }
.jp-ref { font-weight: 500; color: var(--r-muted); padding-left: .45rem; border-left: 1px solid var(--r-line); }
.jp:hover .jp-ref { color: inherit; border-color: currentColor; }
.chapter h1 { padding-right: 15rem; }
@media (max-width: 719px) {
  .chapter h1 { padding-right: 0; }
  .jp-wrap {
    top: var(--hdr, 6rem); height: auto; max-width: none; margin-top: .75rem; padding: .4rem 16px;
    background: var(--r-bg); border-bottom: 1px solid var(--r-line); pointer-events: auto;
  }
  .jp { margin-top: 0; font-size: .85rem; box-shadow: none; }
}
@media (max-width: 719px) {
  .sel-bar { bottom: calc(4.4rem + env(safe-area-inset-bottom)); }
}
