/* =============================================================================
   Bible Reader — Design System
   Warm reading-focused layout with bottom sheet panels and passage picker
   ============================================================================= */

.bible-reader {
    --br-primary: #2a5c8b;
    --br-primary-dk: #1e3f63;
    --br-accent: #c9a227;
    --br-surface: #faf8f4;
    --br-surface-2: #f0ebe3;
    --br-border: #e0d9ce;
    --br-text: #1c1917;
    --br-text-2: #716b65;
    --br-red: #dc2626;
    --br-radius: 12px;
    --br-sheet-r: 20px;
    --br-verse-sz: 18px;
    background: var(--br-surface);
    min-height: calc(100vh - 80px);
}

/* =============================================================================
   Toolbar
   ============================================================================= */

.br-toolbar {
    position: sticky;
    top: 60px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0;
    background: var(--br-surface);
    border-bottom: 1px solid var(--br-border);
}

.br-passage-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    min-width: 0;
    max-width: 260px;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 1px solid var(--br-border);
    border-radius: var(--br-radius);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--br-text);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.br-passage-btn:hover {
    border-color: var(--br-primary);
    background: #f0f5fb;
    box-shadow: 0 1px 6px rgba(42,92,139,0.1);
}
.br-passage-icon { color: var(--br-primary); font-size: 20px; flex-shrink: 0; }
.br-passage-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.br-passage-chevron { font-size: 20px; color: var(--br-text-2); flex-shrink: 0; }

.br-toolbar-start {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.br-translation-select {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--br-border);
    border-radius: var(--br-radius);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--br-text);
    background: #fff;
    cursor: pointer;
    max-width: 110px;
}
.br-translation-select:focus { outline: 2px solid var(--br-primary); outline-offset: 1px; }

.br-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--br-text-2);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.br-icon-btn:hover { background: var(--br-surface-2); color: var(--br-primary); }
.br-icon-btn .material-symbols-outlined { font-size: 20px; }

/* =============================================================================
   Auth Banner
   ============================================================================= */

.br-auth-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 0.65rem 0.9rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: #1e40af;
    transition: outline 0.3s;
}
.br-auth-banner .material-symbols-outlined { font-size: 18px; flex-shrink: 0; }
.br-auth-banner > span:last-of-type { flex: 1; }
.br-link-btn {
    display: inline-block;
    background: var(--br-primary);
    color: #fff !important;
    padding: 0.28rem 0.7rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
}
.br-link-btn:hover { background: var(--br-primary-dk); }

/* =============================================================================
   Reading Pane
   ============================================================================= */

.br-pane {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.25rem 0 5rem;
}

.br-passage-heading {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--br-text);
    margin-bottom: 1.25rem;
    line-height: 1.3;
}

/* =============================================================================
   Verses
   ============================================================================= */

.verse {
    position: relative;
    padding: 0.35rem 2rem 0.35rem 0.75rem;
    margin-bottom: 0.1rem;
    border-radius: 6px;
    border-left: 3px solid transparent;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: var(--br-verse-sz);
    line-height: 1.85;
    color: var(--br-text);
    cursor: pointer;
    transition: background 0.1s;
}
.verse:hover { background: var(--br-surface-2); }
.verse:active { background: var(--br-border); }

.verse-num {
    display: inline-block;
    font-size: 0.65em;
    font-weight: 700;
    color: var(--br-text-2);
    vertical-align: super;
    margin-right: 0.3em;
    user-select: none;
    font-family: 'Segoe UI', system-ui, sans-serif;
    letter-spacing: 0.01em;
}

.words-of-jesus { color: #b91c1c; }

/* Left-border markers */
.verse.is-favourite { border-left-color: var(--br-accent); }
.verse.has-note { border-left-color: #2563eb; }
.verse.has-link { border-left-color: #059669; }
.verse.is-favourite.has-note { border-left-color: var(--br-accent); }

/* Margin icons */
.verse-indicators {
    position: absolute;
    top: 0.55rem;
    right: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 1px;
    pointer-events: none;
    user-select: none;
}
.verse-indicators .material-symbols-outlined {
    font-size: 12px;
    line-height: 1;
    opacity: 0;
    display: block;
}
.verse.is-favourite .vi-fav { opacity: 0.75; color: var(--br-accent); }
.verse.has-note .vi-note  { opacity: 0.75; color: #2563eb; }
.verse.has-link .vi-link  { opacity: 0.75; color: #059669; }

/* Highlight backgrounds */
.verse.highlight-slot_1 { background: rgba(254,240,138,.45); }
.verse.highlight-slot_2 { background: rgba(187,247,208,.45); }
.verse.highlight-slot_3 { background: rgba(191,219,254,.45); }
.verse.highlight-slot_4 { background: rgba(251,207,232,.45); }
.verse.highlight-slot_5 { background: rgba(233,213,255,.45); }
.verse.highlight-slot_6 { background: rgba(245,208,254,.45); }
.verse.highlight-slot_7 { background: rgba(254,215,170,.45); }
.verse.highlight-slot_8 { background: rgba(253,230,138,.45); }

.verse:hover.highlight-slot_1 { background: rgba(254,240,138,.65); }
.verse:hover.highlight-slot_2 { background: rgba(187,247,208,.65); }
.verse:hover.highlight-slot_3 { background: rgba(191,219,254,.65); }
.verse:hover.highlight-slot_4 { background: rgba(251,207,232,.65); }
.verse:hover.highlight-slot_5 { background: rgba(233,213,255,.65); }
.verse:hover.highlight-slot_6 { background: rgba(245,208,254,.65); }
.verse:hover.highlight-slot_7 { background: rgba(254,215,170,.65); }
.verse:hover.highlight-slot_8 { background: rgba(253,230,138,.65); }

/* Font size variants */
.bible-reader.font-sm .verse { --br-verse-sz: 15px; }
.bible-reader.font-md .verse { --br-verse-sz: 18px; }
.bible-reader.font-lg .verse { --br-verse-sz: 21px; }

/* =============================================================================
   Chapter Navigation
   ============================================================================= */

.br-chapter-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2.5rem;
}

.br-nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    border: 1px solid var(--br-border);
    border-radius: 10px;
    background: #fff;
    color: var(--br-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    max-width: 48%;
}
.br-nav-btn:hover {
    background: #f0f5fb;
    border-color: var(--br-primary);
    box-shadow: 0 2px 8px rgba(42,92,139,0.1);
}
.br-nav-btn .material-symbols-outlined { font-size: 18px; flex-shrink: 0; }
.br-nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.br-nav-next { flex-direction: row-reverse; text-align: right; }

/* =============================================================================
   Loading & Empty
   ============================================================================= */

.br-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3.5rem 0;
    color: var(--br-text-2);
    font-size: 0.9rem;
}
.br-spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid var(--br-border);
    border-top-color: var(--br-primary);
    border-radius: 50%;
    animation: br-spin 0.65s linear infinite;
    flex-shrink: 0;
}
@keyframes br-spin { to { transform: rotate(360deg); } }

.br-empty {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem;
    text-align: center;
    color: var(--br-text-2);
    gap: 1rem;
}
.br-empty-icon { font-size: 52px; color: var(--br-border); display: block; }
.br-empty p { font-size: 0.95rem; max-width: 260px; line-height: 1.5; }
.br-btn-primary {
    display: inline-block;
    background: var(--br-primary);
    color: #fff;
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.br-btn-primary:hover { background: var(--br-primary-dk); }

/* =============================================================================
   Picker Overlay
   ============================================================================= */

.br-picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.br-picker-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.br-picker-sheet {
    background: #fff;
    border-radius: var(--br-sheet-r) var(--br-sheet-r) 0 0;
    width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -4px 32px rgba(0,0,0,.15);
}
.br-picker-overlay.open .br-picker-sheet { transform: translateY(0); }

@media (min-width: 640px) {
    .br-picker-overlay { align-items: center; justify-content: center; }
    .br-picker-sheet {
        border-radius: var(--br-sheet-r);
        width: 560px;
        max-height: 78vh;
        transform: scale(0.94) translateY(12px);
    }
    .br-picker-overlay.open .br-picker-sheet { transform: scale(1) translateY(0); }
}

.br-picker-header {
    display: flex;
    align-items: center;
    padding: 0.85rem 0.85rem 0.6rem;
    gap: 0.4rem;
    border-bottom: 1px solid var(--br-border);
}
.br-picker-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 700;
    color: var(--br-text);
    text-align: center;
}
.br-picker-back { color: var(--br-primary); }

.br-picker-search-wrap {
    position: relative;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--br-border);
}
.br-search-icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--br-text-2);
    font-size: 17px;
    pointer-events: none;
}
.br-picker-search {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.2rem;
    border: 1px solid var(--br-border);
    border-radius: 8px;
    font-size: 0.92rem;
    background: var(--br-surface);
    color: var(--br-text);
}
.br-picker-search:focus { outline: 2px solid var(--br-primary); outline-offset: 1px; border-color: var(--br-primary); }

.br-picker-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.85rem 1.25rem;
}

/* Book grid */
.br-book-section-header {
    grid-column: 1 / -1;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--br-text-2);
    padding: 0.65rem 0.25rem 0.3rem;
}
.br-book-section-header:first-child { padding-top: 0.25rem; }

.br-book-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
}
@media (min-width: 380px) { .br-book-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 520px) { .br-book-grid { grid-template-columns: repeat(5, 1fr); } }

.br-book-btn {
    padding: 0.5rem 0.2rem;
    border: 1px solid var(--br-border);
    border-radius: 8px;
    background: var(--br-surface);
    color: var(--br-text);
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.br-book-btn:hover { background: #e8f0fa; border-color: var(--br-primary); color: var(--br-primary); }
.br-book-btn.active { background: var(--br-primary); color: #fff; border-color: var(--br-primary); }

/* Chapter grid */
.br-chapter-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.35rem;
}
@media (min-width: 380px) { .br-chapter-grid { grid-template-columns: repeat(7, 1fr); } }
@media (min-width: 520px) { .br-chapter-grid { grid-template-columns: repeat(9, 1fr); } }

.br-chapter-btn {
    aspect-ratio: 1;
    border: 1px solid var(--br-border);
    border-radius: 8px;
    background: var(--br-surface);
    color: var(--br-text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.br-chapter-btn:hover { background: #e8f0fa; border-color: var(--br-primary); color: var(--br-primary); }
.br-chapter-btn.active { background: var(--br-primary); color: #fff; border-color: var(--br-primary); }

/* =============================================================================
   Shared sheet chrome
   ============================================================================= */

.br-sheet-handle {
    width: 36px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
}

/* =============================================================================
   Action Sheet
   ============================================================================= */

.br-action-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border-radius: var(--br-sheet-r) var(--br-sheet-r) 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 28px rgba(0,0,0,.12);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.br-action-sheet.open { transform: translateY(0); }

.br-action-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.85rem 0.2rem;
}
.br-action-ref {
    font-family: Georgia, serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--br-text);
}

/* Unauthenticated state within action sheet */
.br-action-unauthed {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    margin: 0.25rem 0.85rem 0.5rem;
    font-size: 0.83rem;
    color: #1e40af;
}
.br-action-unauthed .material-symbols-outlined { font-size: 17px; flex-shrink: 0; }
.br-action-unauthed span { flex: 1; }

/* Highlight swatches */
.br-highlight-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.85rem 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.br-hl-swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.br-hl-swatch:hover { transform: scale(1.18); }
.br-hl-swatch.active {
    border-color: var(--br-primary);
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--br-primary);
    transform: scale(1.1);
}
.br-hl-clear {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1.5px solid var(--br-border);
    background: var(--br-surface-2);
    color: var(--br-text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.br-hl-clear:hover { background: #fee2e2; border-color: #ef4444; color: #ef4444; }
.br-hl-clear .material-symbols-outlined { font-size: 15px; }

/* Action buttons */
.br-action-row {
    display: flex;
    gap: 0.4rem;
    padding: 0.25rem 0.85rem 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.br-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.6rem 0.75rem 0.55rem;
    border-radius: 10px;
    border: 1px solid var(--br-border);
    background: var(--br-surface);
    color: var(--br-text);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    min-width: 58px;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.br-action-btn:hover { background: #e8f0fa; border-color: var(--br-primary); color: var(--br-primary); }
.br-action-btn.active { background: #fefce8; border-color: var(--br-accent); color: var(--br-accent); }
.br-action-icon { font-size: 22px; }

/* Desktop: center the sheet */
@media (min-width: 640px) {
    .br-action-sheet {
        max-width: 520px;
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(100%);
        border-radius: var(--br-sheet-r);
        bottom: 1.5rem;
    }
    .br-action-sheet.open { transform: translateX(-50%) translateY(0); }
}

/* =============================================================================
   Note Panel
   ============================================================================= */

.br-note-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1060;
    background: #fff;
    border-radius: var(--br-sheet-r) var(--br-sheet-r) 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 28px rgba(0,0,0,.15);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.br-note-panel.open { transform: translateY(0); }

.br-note-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem 0.5rem;
    border-bottom: 1px solid var(--br-border);
    flex-shrink: 0;
}
.br-note-icon { color: var(--br-primary); font-size: 20px; }
.br-note-ref {
    flex: 1;
    font-family: Georgia, serif;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--br-text);
}

.br-note-textarea {
    flex: 1;
    border: none;
    padding: 0.75rem 0.85rem;
    font-size: 1rem;
    line-height: 1.65;
    color: var(--br-text);
    resize: none;
    min-height: 130px;
    max-height: 40vh;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #fff;
}
.br-note-textarea:focus { outline: none; }
.br-note-textarea::placeholder { color: #b0a9a0; }

.br-note-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.85rem 1rem;
    border-top: 1px solid var(--br-border);
    gap: 0.5rem;
    flex-shrink: 0;
}
.br-note-footer-right { display: flex; gap: 0.5rem; margin-left: auto; }

.br-btn-danger {
    padding: 0.5rem 1rem;
    border: 1px solid #ef4444;
    border-radius: 8px;
    background: transparent;
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.br-btn-danger:hover { background: #fef2f2; }

.br-btn-ghost {
    padding: 0.5rem 1rem;
    border: 1px solid var(--br-border);
    border-radius: 8px;
    background: transparent;
    color: var(--br-text-2);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.br-btn-ghost:hover { background: var(--br-surface-2); }

@media (min-width: 640px) {
    .br-note-panel {
        max-width: 520px;
        left: 50%;
        right: auto;
        border-radius: var(--br-sheet-r);
        bottom: 1.5rem;
        transform: translateX(-50%) translateY(100%);
    }
    .br-note-panel.open { transform: translateX(-50%) translateY(0); }
}

/* =============================================================================
   Backdrop
   ============================================================================= */

.br-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(0,0,0,.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.br-backdrop.visible {
    opacity: 1;
    pointer-events: all;
}

/* =============================================================================
   Toast
   ============================================================================= */

.br-toast {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: rgba(28,25,23,.88);
    color: #fff;
    padding: 0.55rem 1.25rem;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    white-space: nowrap;
    pointer-events: none;
}
.br-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =============================================================================
   Responsive tweaks
   ============================================================================= */

@media (max-width: 576px) {
    .br-toolbar { padding: 0.4rem 0; }
    .br-pane { padding-top: 0.75rem; }
    .br-translation-select { max-width: 80px; font-size: 0.8rem; }
    .br-passage-btn { max-width: none; }
}
