/* ==========================================================================
   Bible reader - the Scripture is the visual focus.
   Font size is driven by --reader-size (set by bible.js from user preferences).
   ========================================================================== */
:root { --reader-size: 18px; --reader-line: 1.85; --reader-width: 720px; }
[data-layout="compact"] { --reader-line: 1.6; --reader-width: 820px; }
[data-layout="comfortable"] { --reader-line: 1.85; --reader-width: 720px; }
[data-layout="large"] { --reader-line: 2.05; --reader-width: 680px; }

.reader-toolbar {
    position: sticky; top: var(--tb-header-h); z-index: 1020;
    background: color-mix(in srgb, var(--tb-surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--tb-border); padding: .5rem 0;
}
.reader-toolbar .form-select, .reader-toolbar .btn { min-height: 38px; }
.reader-toolbar .btn.active { background: var(--tb-gold-soft); border-color: var(--tb-gold); color: var(--tb-heading); }
.reader-selects { min-width: 0; }
.reader-selects .js-sel-book { min-width: 0; flex: 1 1 140px; max-width: 220px; }

.reader-container { max-width: var(--reader-width); padding-top: 1.25rem; padding-bottom: 2rem; }
.chapter-header { margin: .5rem 0 1.75rem; }
.chapter-header .book-label { display: block; color: var(--tb-gold); font-weight: 700; text-transform: uppercase; letter-spacing: .14em; font-size: .8rem; }
.chapter-header .chapter-title { font-family: var(--tb-serif); font-size: clamp(1.9rem, 5vw, 2.6rem); margin: .2rem 0; }
.chapter-header .translation-label { color: var(--tb-muted); font-size: .85rem; }

.scripture {
    font-family: var(--tb-serif);
    font-size: var(--reader-size);
    line-height: var(--reader-line);
    color: var(--tb-text);
    text-align: left;
    hyphens: manual;
    overflow-wrap: break-word;
}
.scripture .verse {
    cursor: pointer; border-radius: 4px; transition: background-color .15s ease;
    -webkit-tap-highlight-color: transparent; padding: .08em 0;
    box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.scripture .verse:hover { background: color-mix(in srgb, var(--tb-gold) 10%, transparent); }
.scripture .verse:focus-visible { outline: 2px solid var(--tb-gold-2); outline-offset: 1px; }
.scripture .verse.selected { background: color-mix(in srgb, var(--tb-navy) 12%, transparent); text-decoration: underline dotted var(--tb-gold); text-underline-offset: 5px; }
[data-theme="dark"] .scripture .verse.selected { background: rgba(157, 184, 255, .16); }
.scripture .verse:target { background: var(--tb-gold-soft); }

/* Verse numbers: distinguishable, and excluded from copy selections. */
.vnum {
    font-family: var(--tb-sans); font-size: .62em; font-weight: 700; color: var(--tb-verse-num);
    vertical-align: super; line-height: 0; margin-right: .22em; margin-left: .1em;
    user-select: none; -webkit-user-select: none;
}
.hide-vnum .scripture .vnum { display: none; }
/* Default: one verse per line with the number in its own gutter, so each verse is easy to find. */
#scripture .verse { display: block; position: relative; padding: .35em .5em .35em 2.6em; margin: 0 -.5em .15em; border-radius: 8px; }
#scripture .verse .vnum { position: absolute; left: .5em; top: .95em; width: 1.8em; text-align: right; font-size: .62em; line-height: 1; vertical-align: baseline; margin: 0; }
#scripture .verse + .verse { border-top: 1px solid color-mix(in srgb, var(--tb-border) 55%, transparent); }
.hide-vnum #scripture .verse { padding-left: .5em; }
/* Optional paragraph mode (continuous text). */
.verse-paragraph #scripture .verse { display: inline; position: static; padding: .08em 0; margin: 0; border: 0; }
.verse-paragraph #scripture .verse .vnum { position: static; width: auto; font-size: .62em; vertical-align: super; line-height: 0; margin-right: .22em; margin-left: .1em; }
/* Search-term highlighting */
mark, .scripture mark { background: color-mix(in srgb, var(--tb-gold-2) 45%, transparent); color: inherit; padding: 0 .12em; border-radius: 3px; box-shadow: inset 0 -2px 0 var(--tb-gold); }
#scripture .verse.search-hit { background: var(--tb-gold-soft); box-shadow: inset 3px 0 0 var(--tb-gold); }
.scripture-single { font-size: calc(var(--reader-size) * 1.25); line-height: 1.7; }
.scripture-context { font-size: 1rem; line-height: 1.75; }
.scripture-context .context-current { background: var(--tb-gold-soft); border-radius: 6px; padding: .2rem .4rem; }
.vnum-link { text-decoration: none; }

/* Personal markers */
.vmarks { font-family: var(--tb-sans); font-size: .6em; color: var(--tb-gold); margin-left: .15em; user-select: none; -webkit-user-select: none; }
.verse[data-bm="1"] .vmarks::before { content: "\f02e"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: .25em; }
.verse[data-fav="1"] .vmarks::after { content: "\f004"; font-family: "Font Awesome 6 Free"; font-weight: 900; color: #d9485f; margin-right: .25em; }
.verse:not([data-notes="0"])[data-notes] .vtext { text-decoration: underline; text-decoration-style: dotted; text-decoration-color: var(--tb-gold); text-underline-offset: 4px; }

/* Controlled highlight palette */
.verse.hl-yellow { background: #fde68a; }
.verse.hl-green { background: #bbf7d0; }
.verse.hl-blue { background: #bfdbfe; }
.verse.hl-pink { background: #fbcfe8; }
.verse.hl-orange { background: #fed7aa; }
[data-theme="dark"] .verse.hl-yellow { background: rgba(253, 230, 138, .28); }
[data-theme="dark"] .verse.hl-green { background: rgba(134, 239, 172, .22); }
[data-theme="dark"] .verse.hl-blue { background: rgba(147, 197, 253, .24); }
[data-theme="dark"] .verse.hl-pink { background: rgba(249, 168, 212, .24); }
[data-theme="dark"] .verse.hl-orange { background: rgba(253, 186, 116, .24); }
[data-theme="dark"] .verse[class*="hl-"] { color: #fff; }

/* Chapter navigation */
.reader-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; align-items: stretch; margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--tb-border); }
.reader-nav-btn { display: flex; align-items: center; gap: .6rem; min-height: 56px; }
.reader-nav-btn span { display: flex; flex-direction: column; line-height: 1.2; font-weight: 600; min-width: 0; }
.reader-nav-btn span small { font-weight: 400; opacity: .75; font-size: .75rem; }
.reader-nav-btn.text-end { justify-content: flex-end; }
.reader-nav-btn.text-end span { align-items: flex-end; }
.reader-nav-center { min-height: 56px; background: var(--tb-surface-2); border: 1px solid var(--tb-border); color: var(--tb-text); }
@media (max-width: 575.98px) {
    .reader-nav-btn { font-size: .85rem; padding: .4rem .6rem; }
}

/* Verse action sheet: bottom sheet on phones, floating card on larger screens */
.verse-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1060;
    background: var(--tb-surface); color: var(--tb-text);
    border-top-left-radius: 18px; border-top-right-radius: 18px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .22);
    padding: .6rem 1rem calc(1rem + env(safe-area-inset-bottom));
    transform: translateY(0); animation: sheet-in .18s ease-out;
}
.verse-sheet[hidden] { display: none; }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: var(--tb-border); margin: 0 auto .6rem; }
.sheet-ref { font-family: var(--tb-serif); font-size: 1.05rem; color: var(--tb-heading); }
.sheet-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.sheet-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
    min-height: 64px; border-radius: 12px; border: 1px solid var(--tb-border); background: var(--tb-surface-2);
    color: var(--tb-text); font-size: .78rem; text-decoration: none; padding: .4rem;
}
.sheet-btn i { font-size: 1.15rem; color: var(--tb-navy); }
[data-theme="dark"] .sheet-btn i { color: var(--tb-link); }
.sheet-btn:hover, .sheet-btn.on { border-color: var(--tb-gold); background: var(--tb-gold-soft); color: var(--tb-heading); }
.sheet-btn.on i { color: var(--tb-gold); }
.sheet-colors { display: flex; gap: .6rem; justify-content: center; margin-top: .75rem; }
.color-dot { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--tb-border); display: inline-flex; align-items: center; justify-content: center; color: var(--tb-muted); background: var(--tb-surface); }
.color-dot.active { border-color: var(--tb-navy); box-shadow: 0 0 0 3px var(--tb-gold-2); }
@media (min-width: 768px) {
    .verse-sheet { left: auto; right: 1.5rem; bottom: 1.5rem; width: 380px; border-radius: 18px; animation: none; }
    .sheet-handle { display: none; }
}

/* Audio */
.audio-player .form-range { height: 1.2rem; }

/* Picker */
.picker-books .accordion-button { font-weight: 600; background: var(--tb-surface); color: var(--tb-text); }
.picker-books .accordion-button:not(.collapsed) { background: var(--tb-navy-soft); color: var(--tb-heading); box-shadow: none; }
.picker-books .accordion-item { background: var(--tb-surface); border-color: var(--tb-border); }
.picker-books .accordion-body { padding: .75rem; }

.verse-feature .scripture-single .verse { cursor: pointer; }
.xref-list li { border-bottom: 1px dashed var(--tb-border); padding-bottom: .6rem; }
.xref-list li:last-child { border-bottom: 0; }

/* ==========================================================================
   Mobile-first additions: verse jump, omitted verses, read-aloud player.
   Base rules target phones; min-width queries enhance for tablets/desktops.
   ========================================================================== */

/* Toolbar: on phones the four pickers share one full-width row, tools wrap below. */
.reader-selects { display: grid !important; grid-template-columns: 72px minmax(0, 1fr) 66px 80px; gap: .4rem !important; width: 100%; flex: 1 1 100%; }
.reader-selects .form-select { max-width: none !important; min-height: 44px; font-size: 16px; padding: .375rem 1.5rem .375rem .55rem; background-position: right .4rem center; } /* 16px stops iOS zoom-on-focus */
.reader-toolbar .btn { min-height: 44px; min-width: 44px; }
.reader-toolbar .container > .d-flex:last-child { width: 100%; justify-content: space-between; }
@media (min-width: 768px) {
    .reader-selects { display: flex !important; width: auto; flex: 1 1 auto; }
    .reader-selects .form-select { max-width: 104px !important; min-height: 38px; font-size: .9rem; }
    .reader-selects .js-sel-book { max-width: 240px !important; min-width: 150px; flex: 1 1 160px; }
    .reader-selects .js-sel-translation, .reader-selects .js-sel-verse { max-width: 88px !important; }
    .reader-selects .js-sel-chapter { max-width: 76px !important; }
    .reader-toolbar .btn { min-height: 38px; font-size: .9rem; }
    .reader-toolbar .btn { min-width: 38px; }
    .reader-toolbar .container > .d-flex:last-child { width: auto; }
}

.scripture .verse.flash .vtext { background: var(--tb-gold-soft); box-shadow: 0 0 0 3px var(--tb-gold-soft); transition: background-color .3s ease; }
.scripture .verse.omitted { cursor: default; }
.vomitted { font-family: var(--tb-sans); font-size: .82em; font-style: italic; color: var(--tb-muted); }
.vomitted a { font-style: normal; }

/* Verse currently being read aloud */
.scripture .verse.tts-current .vtext { background: color-mix(in srgb, var(--tb-gold-2) 32%, transparent); border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.reader-toolbar .js-tts-open.active { background: var(--tb-gold-soft); border-color: var(--tb-gold); }

/* Read-aloud player: bottom bar, thumb-reachable, clear of the iPhone home indicator. */
.tts-player {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1050;
    background: var(--tb-surface); color: var(--tb-text);
    border-top: 1px solid var(--tb-border); box-shadow: 0 -8px 30px rgba(0, 0, 0, .14);
    padding: .55rem 0 calc(.55rem + env(safe-area-inset-bottom));
}
.tts-player[hidden] { display: none; }
.tts-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "progress progress" "controls settings"; gap: .35rem .5rem; align-items: center; }
.tts-progress { grid-area: progress; min-width: 0; }
.tts-progress .form-range { height: 1.4rem; }
.tts-controls { grid-area: controls; display: flex; align-items: center; gap: .3rem; }
.tts-settings { grid-area: settings; display: flex; align-items: center; gap: .3rem; }
.tts-player .btn { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
.tts-player .btn-icon { width: 48px; height: 48px; border-radius: 50%; }
.tts-player .js-tts-rate { width: 76px; min-height: 44px; font-size: 16px; }
.tts-player .btn:disabled { opacity: .35; }
body.tts-open { padding-bottom: calc(130px + env(safe-area-inset-bottom)); }
.tts-player .tts-close { min-height: 32px; min-width: 36px; padding: 0; margin: -.35rem -.3rem -.35rem 0; font-size: 1.05rem; }
@media (max-width: 419.98px) {
    .tts-controls .js-tts-prev-chapter, .tts-controls .js-tts-next-chapter { display: none !important; }
    .tts-controls { gap: .6rem; }
}
@media (min-width: 768px) {
    .tts-row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "controls progress settings"; gap: 1rem; }
    .tts-player .btn { min-height: 38px; min-width: 38px; }
    .tts-player .js-tts-rate { min-height: 38px; font-size: .88rem; }
    body.tts-open { padding-bottom: 88px; }
}
[data-theme="dark"] .tts-player .btn-light { background: var(--tb-surface-2); border-color: var(--tb-border); color: var(--tb-text); }

/* Verse page: keep actions finger-sized on phones */
@media (max-width: 575.98px) {
    .verse-feature .d-flex.flex-wrap.gap-2:not(.share-links) > .btn { flex: 1 1 calc(50% - .5rem); min-height: 44px; }
    .share-links { display: grid !important; grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .share-links .btn { min-height: 44px; padding-inline: 0; }
    .sheet-btn { min-height: 68px; }
}
@media (max-width: 399.98px) {
    .reader-selects { grid-template-columns: 62px minmax(0, 1fr) 58px 62px; gap: .3rem !important; }
    .reader-selects .form-select { padding-left: .45rem; padding-right: 1.25rem; background-position: right .3rem center; background-size: 12px 10px; }
}

/* ---------- Faster reading: picker, phone dock, continue reading, offline ---------- */
.picker-heading { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--tb-muted); margin: 1rem 0 .5rem; }
.picker-heading:first-child { margin-top: 0; }
.picker-book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .4rem; }
.picker-book { display: flex; align-items: center; min-height: 44px; padding: .3rem .6rem; border-radius: 10px; border: 1px solid var(--tb-border); background: var(--tb-surface); color: var(--tb-text); text-decoration: none; font-weight: 600; font-size: .9rem; line-height: 1.15; }
.picker-book:hover, .picker-book.current { background: var(--tb-navy); color: #fff; border-color: var(--tb-navy); }
.picker-recent-links { display: flex; flex-wrap: wrap; gap: .4rem; }
.js-picker-chapters .chapter-grid a { height: 52px; }

.reader-dock { display: none; }
@media (max-width: 767.98px) {
    .reader-dock {
        display: flex; align-items: stretch; gap: .25rem; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040;
        padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
        background: var(--tb-surface); border-top: 1px solid var(--tb-border); box-shadow: 0 -4px 14px rgba(0, 0, 0, .08);
    }
    .dock-btn { flex: 0 0 52px; display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 12px; color: var(--tb-heading); text-decoration: none; font-size: 1.1rem; }
    a.dock-btn:active { background: var(--tb-surface-2); }
    .dock-ref { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px; border: 1px solid var(--tb-border); border-radius: 12px; background: var(--tb-surface-2); color: var(--tb-heading); font-weight: 700; }
    .dock-ref span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    body:has(.reader-dock) { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
    body:has(.reader-dock) .cookie-banner { bottom: calc(70px + env(safe-area-inset-bottom)); }
    /* The dock does the navigating on phones, so the toolbar can scroll away and leave room to read. */
    .reader-toolbar { position: static; }
}

.continue-reading { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; margin-bottom: 1rem; border-radius: 12px; border: 1px solid var(--tb-gold); background: var(--tb-gold-soft); color: var(--tb-heading); text-decoration: none; font-size: 1.02rem; }
.continue-reading:hover { color: var(--tb-heading); box-shadow: var(--tb-shadow); }
.continue-reading[hidden] { display: none; }
.goto-card { display: flex; align-items: center; gap: .8rem; padding: .9rem 1.1rem; margin-bottom: 1rem; border-radius: 12px; background: var(--tb-navy); color: #fff; text-decoration: none; }
.goto-card:hover { color: #fff; opacity: .94; }
.goto-card strong { display: block; font-size: 1.05rem; }
.goto-card small { display: block; opacity: .85; line-height: 1.35; }
.offline-note { margin: .75rem 0 0; padding: .45rem .75rem; border-radius: 8px; background: var(--tb-surface-2); color: var(--tb-muted); font-size: .84rem; text-align: center; }
.offline-status { margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--tb-border); }
button.testament-link, button.book-hit { width: 100%; border: 0; background: transparent; text-align: left; color: inherit; font: inherit; }
button.chip-remove { border: 0; }
