/* ═══════════════════════════════════════════════════════════════════════════
   BibleRefPopup — Modern Elevated Card
   Premium floating popup: gradient header, layered shadows, pill buttons,
   micro-interactions. Style foundation for the rest of the app.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Backdrop (click-to-close layer, no visual effect) ───────────────────── */
.brf-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 19999;
    background: transparent;
}

/* ─── Container ───────────────────────────────────────────────────────────── */
.bible-ref-popup {
    display: none;
    flex-direction: column;
    position: fixed;
    z-index: 20000;

    width: 580px;
    max-width: 95vw;
    max-height: 72vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    overflow: hidden;

    /* Elevated card — border + inset highlight + layered shadow */
    background: var(--surface, #fff);
    border: 1px solid rgba(0, 0, 0, 0.08);
    /* corners: .modal-shell (css/modal-header.css) */
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        inset 0 -1px 0 rgba(0, 0, 0, 0.03),
        0 2px 4px rgba(0, 0, 0, 0.04),
        0 8px 16px rgba(0, 0, 0, 0.08),
        0 20px 40px rgba(0, 0, 0, 0.12),
        0 40px 80px rgba(0, 0, 0, 0.1);
    animation: brf-pop-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Entrance animations ─────────────────────────────────────────────────── */
@keyframes brf-pop-in {
    0% {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}


/* ─── Header (draggable) ──────────────────────────────────────────────────── */
/* Look: the one header bar — .modal-header / .modal-mark / .modal-title /
   .modal-ctl / .modal-close in css/modal-header.css. Only the drag
   cursor is this window's own. */
.brf-header {
    cursor: grab;
}

.brf-header:active {
    cursor: grabbing;
}

/* ─── Body (two-panel row) ────────────────────────────────────────────────── */
.brf-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ─── Left panel (verses) ─────────────────────────────────────────────────── */
.brf-left {
    flex: 1;
    overflow-y: auto;
    min-width: 0;
    min-height: 180px;
}

/* ─── Verse card ──────────────────────────────────────────────────────────── */
.brf-verse {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid rgba(var(--border-rgb), 0.15);
    transition: all 0.2s ease;
    position: relative;
}

.brf-verse::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 0 3px 3px 0;
    transition: width 0.2s ease;
}

.brf-verse:hover {
    background: rgba(var(--primary-rgb), 0.04);
}

.brf-verse:hover::before {
    width: 3px;
}

.brf-verse:last-child {
    border-bottom: none;
}

/* HOLDER LAW (2026-09-14): the popup mounts THE reader VerseCard —
   the hand-rolled header/ref/dots/actions markup is retired. */
.brf-verse .verse-container {
    margin: 0;
    padding: 0.15rem 0;
    background: transparent;
}
.brf-verse .openbtn {
    border: none;
    background: none;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.2rem 0;
}
.brf-verse .openbtn:hover { text-decoration: underline; }


/* Strong's numbers inside popup — sit on baseline */
.bible-ref-popup sup.strongs {
    vertical-align: baseline;
    top: 0;
    font-size: 0.65rem;
    padding: 0.1rem 0.25rem;
    margin: 0 0.1rem;
    font-family: 'Inter', sans-serif;
}

.bible-ref-popup sup.strongs:hover {
    transform: none;
}

/* ─── The Trail — a PATH, not a list (approved mock 2026-09-01):
   footsteps on a dotted line; visited steps are ringed prints; the
   current step carries the 👣 on solid purple; origins whispered. ─── */
.brf-trail {
    display: none;
    flex-direction: column;
    width: 205px;
    flex-shrink: 0;
    overflow: hidden;
    background: rgba(var(--primary-rgb), 0.03);
    border-left: 1px solid rgba(var(--border-rgb), 0.18);
}
.brf-trail.brf-trail-open { display: flex; }

.brf-trail-heading {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--gold-text);
    padding: 0.75rem 0.8rem 0.45rem;
    flex-shrink: 0;
}

.brf-trail-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.2rem 0.5rem 0.5rem 0.55rem;
    position: relative;
}
/* the dotted walking line */
.brf-trail-list::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 14px;
    bottom: 14px;
    border-left: 2px dotted var(--border-color, rgba(var(--border-rgb), 0.6));
}

/* ─── Steps ───────────────────────────────────────────────────────────── */
.brf-trail-item {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.5rem 0.4rem 1.55rem;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 9px;
    line-height: 1.3;
    word-break: break-word;
    color: var(--text-primary);
    transition: background 0.15s ease;
    margin-bottom: 2px;
}
/* the footprint dot */
.brf-trail-item::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid rgba(var(--primary-rgb), 0.55);
    box-sizing: border-box;
}

.brf-trail-item:hover {
    background: rgba(var(--primary-rgb), 0.08);
}

/* Current step — solid purple, wearing the feet */
.brf-trail-item.brf-trail-current {
    background: var(--primary);
    color: white;
    font-weight: 600;
}
.brf-trail-item.brf-trail-current::before {
    content: '👣';
    font-size: 0.62rem;
    line-height: 1;
    width: auto;
    height: auto;
    border: none;
    background: none;
    left: 1px;
}

.brf-trail-item-label {
    flex: 1;
    min-width: 0;
}
.brf-step-ref { display: block; font-weight: 600; }
.brf-trail-current .brf-step-ref { font-weight: 700; }
/* the origin whisper — how this step was reached */
.brf-step-via {
    font-size: 0.64rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 0.05rem;
}
.brf-trail-current .brf-step-via { color: rgba(255, 255, 255, 0.75); }

/* ─── Trail footer — count + Clear (its honest home) ─────────────────── */
.brf-trail-foot {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    border-top: 1px solid rgba(var(--border-rgb), 0.25);
}
.brf-trail-count {
    font-size: 0.66rem;
    color: var(--text-secondary);
}
.brf-trail-clear {
    border: none;
    background: none;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.2rem 0.3rem;
    border-radius: 6px;
}
.brf-trail-clear:hover { color: var(--danger); }

/* Remove button — hidden until hover */
.brf-trail-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0 0.15rem;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.brf-trail-item:hover .brf-trail-remove {
    opacity: 0.5;
}

.brf-trail-remove:hover {
    opacity: 1 !important;
}

.brf-trail-current .brf-trail-remove {
    color: rgba(255, 255, 255, 0.6);
}

.brf-trail-current:hover .brf-trail-remove {
    opacity: 0.7;
}

.brf-trail-current .brf-trail-remove:hover {
    color: white;
    opacity: 1 !important;
}

/* ─── Loading state ───────────────────────────────────────────────────────── */
.brf-loading {
    padding: 1.2rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ─── Dark theme overrides ────────────────────────────────────────────────── */
[data-theme="dark"] .bible-ref-popup {
    background: var(--surface, #2A2A2A);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        inset 0 -1px 0 rgba(0, 0, 0, 0.15),
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 8px 16px rgba(0, 0, 0, 0.3),
        0 20px 40px rgba(0, 0, 0, 0.3),
        0 40px 80px rgba(0, 0, 0, 0.25);
}

/* Header bar and close: css/modal-header.css (one header bar, 2026-09-17). */

[data-theme="dark"] .brf-verse {
    border-bottom-color: rgba(var(--border-rgb), 0.2);
}

[data-theme="dark"] .brf-trail {
    background: rgba(var(--primary-rgb), 0.06);
    border-left-color: rgba(var(--border-rgb), 0.12);
}

[data-theme="dark"] .brf-trail-item.brf-trail-current {
    box-shadow: 0 2px 12px rgba(var(--primary-rgb), 0.45);
}

/* ─── Scrollbar styling ───────────────────────────────────────────────────── */
.brf-left::-webkit-scrollbar,
.brf-trail-list::-webkit-scrollbar {
    width: 5px;
}

.brf-left::-webkit-scrollbar-track,
.brf-trail-list::-webkit-scrollbar-track {
    background: transparent;
}

.brf-left::-webkit-scrollbar-thumb,
.brf-trail-list::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-rgb), 0.15);
    border-radius: 10px;
}

.brf-left::-webkit-scrollbar-thumb:hover,
.brf-trail-list::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--primary-rgb), 0.3);
}

/* ────────────────────────────────────────────────────────────────────────────
   MOBILE — bottom sheet layout for phones
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .bible-ref-popup {
        width: 100vw !important;
        max-width: 100vw;
        left: 0 !important;
        top: auto !important;
        bottom: 0;
        border-radius: 0;
        max-height: 80vh;
        max-height: 80dvh;
        animation: brf-slide-up 0.25s ease-out;
    }

    @keyframes brf-slide-up {
        from { transform: translateY(100%); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }

    .brf-header {
        cursor: default;
    }

    .brf-header:active {
        cursor: default;
    }

    /* Phone: the trail walks SIDEWAYS — swipeable crumbs above the verse
       (approved mock note 04). Same steps, same taps; whispers + the
       dotted line rest on desktop only. */
    .brf-body { flex-direction: column; }
    .brf-trail.brf-trail-open {
        order: -1;
        width: 100%;
        border-left: none;
        border-bottom: 1px solid rgba(var(--border-rgb), 0.25);
    }
    .brf-trail-heading { display: none; }
    .brf-trail-list {
        display: flex;
        gap: 0.35rem;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0.55rem 0.75rem;
        -webkit-overflow-scrolling: touch;
    }
    .brf-trail-list::before { display: none; }
    .brf-trail-item {
        flex-shrink: 0;
        padding: 0.28rem 0.6rem;
        border: 1px solid rgba(var(--border-rgb), 0.5);
        border-radius: 999px;
        background: var(--surface);
        margin-bottom: 0;
    }
    .brf-trail-item::before { display: none; }
    .brf-trail-item.brf-trail-current {
        border-color: var(--primary);
    }
    .brf-trail-item.brf-trail-current .brf-step-ref::before {
        content: '👣 ';
        font-size: 0.65rem;
    }
    .brf-step-via { display: none; }
    .brf-trail-remove { display: none; }
    .brf-trail-foot { padding: 0.35rem 0.75rem 0.45rem; border-top: none; }

    .frosted-close-btn,
    .bible-ref-popup .modal-ctl,
    .bible-ref-popup .modal-close {
        min-width: 36px;
        min-height: 36px;
    }

    .brf-backdrop {
        background: rgba(0, 0, 0, 0.3);
    }

}

/* ────────────────────────────────────────────────────────────────────────────
   TOUCH DEVICES — show hover-only action buttons at reduced opacity
   ──────────────────────────────────────────────────────────────────────────── */
@media (hover: none) {
    .brf-trail-remove { opacity: 0.5; }
}
