/* ===== Bible Reader ===== */

.reader-toolbar {
    font-family: var(--font-ui);
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: var(--surface);
}

/* v1.1: two-row toolbar — selects on top, book+chapter heading below.
   The template uses .toolbar-controls for the selects row and keeps
   .reader-heading on its own row. */
.reader-toolbar .toolbar-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.reader-heading {
    font-family: var(--font-body);
    font-weight: 700;
    margin-top: 0.25rem;
}

.reader-body {
    padding-bottom: 2rem;
}

/* v1.1: verses render as blocks — each on its own line — and are clickable
   for highlight/copy. */
.reader-body .verse {
    display: block;
    padding: 4px 6px;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.reader-body .verse:hover {
    background-color: var(--surface-raised);
}

.reader-body .verse + .verse {
    margin-left: 0;
    margin-top: 0.25rem;
}

/* Verse numbers */
.reader-body sup.verse-num {
    font-family: var(--font-ui);
    font-size: 65%;
    color: var(--text-secondary);
    font-weight: 400;
    margin-right: 3px;
    cursor: default;
    vertical-align: super;
}

/* v1.5 / v1.6: persistent colour-highlight (stored in DB). The canonical
   palette hex is written to ``data-highlight-color``; this CSS maps that
   to an actual ``background-color`` via a custom property so dark mode
   can remap the same stored value to a darker, higher-contrast variant
   without requiring a DB migration or a round-trip. Light theme gets
   the pastel palette (designed for dark ink in both cases); dark theme
   gets hue-matched dark variants that read cleanly under white text. */
.reader-body .verse-marked {
    background-color: var(--verse-mark-color, transparent);
    padding: 2px 4px;
    border-radius: 2px;
    transition: background-color 0.3s ease;
}

/* Light-mode palette (canonical stored values — the 8 in
   ``HIGHLIGHT_COLORS``). ``data-highlight-color`` lives on the verse
   span, so the attribute selector binds the var per-element. */
[data-highlight-color="#FFF2A8"] { --verse-mark-color: #FFF2A8; }
[data-highlight-color="#D1ECF1"] { --verse-mark-color: #D1ECF1; }
[data-highlight-color="#D4EDDA"] { --verse-mark-color: #D4EDDA; }
[data-highlight-color="#F8D7DA"] { --verse-mark-color: #F8D7DA; }
[data-highlight-color="#B2EBF2"] { --verse-mark-color: #B2EBF2; }
[data-highlight-color="#A2D9CE"] { --verse-mark-color: #A2D9CE; }
[data-highlight-color="#F8BBD0"] { --verse-mark-color: #F8BBD0; }
[data-highlight-color="#E1BEE7"] { --verse-mark-color: #E1BEE7; }

/* Dark-mode variants — hue-matched but ~30% lightness so white verse
   text reads at roughly WCAG AA contrast. The ``/study/highlights``
   grid explicitly pins its text colour to #1a1a1a so those cards don't
   need this override (the page is paper-like by design). */
[data-theme="dark"] [data-highlight-color="#FFF2A8"] { --verse-mark-color: #7a6a00; }
[data-theme="dark"] [data-highlight-color="#D1ECF1"] { --verse-mark-color: #1e4a56; }
[data-theme="dark"] [data-highlight-color="#D4EDDA"] { --verse-mark-color: #1f5030; }
[data-theme="dark"] [data-highlight-color="#F8D7DA"] { --verse-mark-color: #6b2c34; }
[data-theme="dark"] [data-highlight-color="#B2EBF2"] { --verse-mark-color: #194c54; }
[data-theme="dark"] [data-highlight-color="#A2D9CE"] { --verse-mark-color: #1e5049; }
[data-theme="dark"] [data-highlight-color="#F8BBD0"] { --verse-mark-color: #7a2e4a; }
[data-theme="dark"] [data-highlight-color="#E1BEE7"] { --verse-mark-color: #4a2757; }

/* Transient click-select (.verse-highlight) wins over a persistent
   mark via specificity — two-class selector ``.reader-body
   .verse-highlight`` (0,2,0) beats ``.verse-marked`` (0,1,0). With
   the old inline-style approach we had to pop/restore the style in
   JS; since v1.6 that's no longer needed. */
.reader-body .verse-highlight,
.reader-body .verse-highlight:hover {
    background-color: var(--highlight-verse);
    padding: 2px 4px;
    border-radius: 2px;
    transition: background-color 0.3s ease;
}

/* Chapter nav */
.chapter-nav {
    border-color: var(--border) !important;
}

/* Version switcher */
#version-switcher,
#book-switcher {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    border-color: var(--border);
    border-radius: 4px;
}

/* Strong's toggle */
.strongs-toggle {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 12px;
}

.strongs-toggle.active {
    background-color: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ===== Context Panel (reader-specific additions) =====
   The shared panel chrome — .context-panel-toggle, .context-panel,
   .panel-tab, .panel-content, mobile overrides — lives in scribe.css
   so it loads on every page that mounts the panel (reader + notes
   editor). Only reader-exclusive rules live below. */

/* Floating-button stack (panel toggle → copy → highlighter) on the reader.
   All three sit on the right edge and share the same ``--floater-stride``
   so spacing is identical between every pair. Panel toggle is the anchor
   (``.context-panel-toggle`` in scribe.css): ``top: 50%`` +
   ``translateY(-50%)`` centres it on the viewport. Copy and highlighter
   piggy-back on the same centred anchor and offset by multiples of the
   stride — making the stack perfectly even regardless of button height
   (as long as the stride exceeds the height). */
:root {
    --floater-stride: 48px;
}

/* v1.1: floating Copy button appears when ≥1 verse is highlighted by
   click. Sits one stride below the panel toggle. */
.verse-copy-toggle {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(calc(-50% + var(--floater-stride)));
    z-index: 1040;
    border-radius: 8px;
    padding: 8px;
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: none;  /* shown via .is-visible when a highlight exists */
}

.verse-copy-toggle.is-visible {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.verse-copy-toggle.copied {
    background: var(--accent);
    color: var(--surface);
}

/* v1.5: floating Highlighter button. Sits two strides below the panel
   toggle (i.e. one stride below the copy button). Same ``.is-visible``
   gating as the copy button. */
.verse-highlight-toggle {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(calc(-50% + var(--floater-stride) * 2));
    z-index: 1040;
    border-radius: 8px;
    padding: 8px;
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: none;
}

.verse-highlight-toggle.is-visible {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.verse-highlight-toggle[aria-expanded="true"] {
    background: var(--accent);
    color: var(--surface);
}

/* Mobile: the panel toggle (scribe.css) docks at ``bottom: 80px``. Stack
   the copy and highlighter buttons ABOVE it at one and two strides so
   the group reads bottom-up as panel → copy → highlighter. Prior bug:
   highlighter was at ``bottom: 84px``, which put it directly under the
   panel toggle at ``bottom: 80px`` and made it disappear under it. */
@media (max-width: 767px) {
    .verse-copy-toggle {
        right: 12px;
        bottom: calc(80px + var(--floater-stride));
        top: auto;
        transform: none;
    }

    .verse-highlight-toggle {
        right: 12px;
        bottom: calc(80px + var(--floater-stride) * 2);
        top: auto;
        transform: none;
    }
}

/* Palette popover. Anchored left-of the highlight button so swatches
   don't spill off-screen on narrow windows. Uses the same translate
   offset as the highlight button itself so they stay visually aligned. */
.highlight-palette {
    position: fixed;
    right: 68px;
    top: 50%;
    transform: translateY(calc(-50% + var(--floater-stride) * 2));
    z-index: 1041;
    display: none;
    gap: 6px;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.highlight-palette.is-open {
    display: inline-flex;
    align-items: center;
}

.highlight-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.08);
    padding: 0;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.highlight-swatch:hover,
.highlight-swatch:focus-visible {
    transform: scale(1.1);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Eraser swatch: visually distinct from the 8 colour swatches. */
.highlight-swatch-erase {
    background: var(--surface);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border);
}

@media (max-width: 767px) {
    .highlight-palette {
        right: 60px;
        bottom: calc(80px + var(--floater-stride) * 2);
        top: auto;
        transform: none;
    }
}

/* Desktop: reader column shifts when panel is open */
@media (min-width: 1025px) {
    .offcanvas.show ~ .container-fluid .reader-col {
        margin-right: 340px;
        transition: margin-right 0.3s ease;
    }
}

/* (Mobile context-panel + toggle overrides moved to scribe.css so they
   apply on the notes editor too.) */

/* ─────────────────────────────────────────────────────────────────
   v1.10 — Rich-markup reader.

   Section headings imported from the source's ``chapters.content``
   blob (NLT/KJV/AMPC/GW). They render between verses, keyed by the
   verse number they precede. Two levels:

     * ``.reader-section-heading-major`` (``<h2>``) — the rare
       psalm-book divider ("Book One (Psalms 1-41)") or NLT's epistle
       super-headings. Larger, more breathing room.
     * ``.reader-section-heading`` (``<h3>``) — chapter sub-section
       headings ("The Sermon on the Mount", "The Beatitudes",
       "Teaching about Anger" …). These do most of the work in the
       Gospels and Psalms.
   ───────────────────────────────────────────────────────────────── */
.reader-section-heading {
    display: block;
    font-family: var(--font-ui);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.05rem;
    line-height: 1.3;
    margin: 1.4rem 0 0.6rem;
    letter-spacing: 0.01em;
}

.reader-section-heading-major {
    font-size: 1.25rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin: 1.8rem 0 0.5rem;
}

.reader-body > .verse + .reader-section-heading,
.reader-body > .verse + .reader-section-heading-major {
    /* Slight extra gap when a heading immediately follows a verse —
       the verse already ends a sentence, so the heading needs more
       air to read as a new section, not a continuation. */
    margin-top: 1.7rem;
}

/* ─────────────────────────────────────────────────────────────────
   Per-verse rich markup.

   * ``.woj`` — words of Jesus (red letter) when carried by source
     (NLT). Toggleable per-user via ``red_letter_enabled`` — when
     off, ``.reader-body-no-red-letter`` is set on the article and
     ``.woj`` falls back to the body colour.
   * ``.add`` — KJV translator-added words, italic in print.
   * ``.small-caps`` — divine name (LORD) and other small-caps usage.
   * ``.indent-1|2|3`` — poetry continuation lines.
   ───────────────────────────────────────────────────────────────── */
.reader-body .woj {
    color: #c41e3a;
}

[data-theme="dark"] .reader-body .woj {
    color: #ff7b8d;
}

.reader-body-no-red-letter .woj {
    color: inherit;
}

.reader-body .add,
.reader-body i {
    font-style: italic;
    color: var(--text-secondary);
}

.reader-body .small-caps {
    font-variant: small-caps;
    letter-spacing: 0.02em;
}

.reader-body .indent-1,
.reader-body .indent-2,
.reader-body .indent-3 {
    display: inline-block;
}

.reader-body .indent-1 { margin-left: 1.5rem; }
.reader-body .indent-2 { margin-left: 3rem; }
.reader-body .indent-3 { margin-left: 4.5rem; }

@media (max-width: 767.98px) {
    .reader-body .indent-1 { margin-left: 1rem; }
    .reader-body .indent-2 { margin-left: 2rem; }
    .reader-body .indent-3 { margin-left: 3rem; }
}

/* ─────────────────────────────────────────────────────────────────
   v1.9.17 — Mobile quick-nav.

   Floating bar that slides up just above the bottom-nav while the
   reader scrolls, then auto-hides after 5 s of inactivity. Desktop
   never sees it (``display: none`` outside the mobile media query).
   The in-flow ``.chapter-nav`` row at the end of the chapter is
   unchanged — quick-nav is a drive-by helper for mid-chapter
   scrolling, not a replacement.
   ───────────────────────────────────────────────────────────────── */
.bible-quick-nav {
    display: none;
}

@media (max-width: 767.98px) {
    .bible-quick-nav {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
        z-index: 1035;
        background-color: var(--surface, #fff);
        border-top: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
        transform: translateY(120%);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.25s ease, opacity 0.25s ease;
        font-family: var(--font-ui);
    }

    [data-theme="dark"] .bible-quick-nav {
        background-color: var(--surface, #1a1a1a);
    }

    .bible-quick-nav.is-visible {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .bible-quick-nav-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.55rem 0.85rem;
    }

    .bible-quick-nav-link {
        font-family: var(--font-ui);
    }

    .bible-quick-nav-spacer {
        flex: 0 0 auto;
        width: 1px;
    }

    .bible-quick-nav-top {
        position: relative;
        background: transparent;
        border: none;
        color: var(--text-primary);
        padding: 4px 14px 6px;
        line-height: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .bible-quick-nav-top:focus-visible {
        outline: 2px solid var(--text-primary);
        outline-offset: 2px;
        border-radius: 4px;
    }

    /* Echoes the bottom-nav active-tab pill underline so the
       quick-nav reads as part of the same nav language. */
    .bible-quick-nav-top::after {
        content: "";
        display: block;
        width: 28px;
        height: 2px;
        background-color: var(--text-primary);
        border-radius: 1px;
        margin: 6px auto 0;
    }
}
