/* ═══════════════════════════════════════════════════════════════════════════
   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);
    border-radius: 16px;
    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) ──────────────────────────────────────────────────── */
.brf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
    cursor: grab;
    padding: 0.85rem 1.2rem;
    border-radius: 16px 16px 0 0;
}

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

.brf-header-title {
    flex: 1;
    min-width: 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* close button now uses shared .frosted-close-btn in styles.css */

/* ─── 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, #5B4B8A, #7C6BA6);
    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;
}

.brf-verse-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.brf-verse-ref {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    letter-spacing: 0.01em;
}

.brf-tag-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.brf-tag-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.brf-verse-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    margin-left: auto;
}

/* ─── Action buttons ──────────────────────────────────────────────────────── */

/* BibleRefPopup action buttons use .verse-action-btn from styles.css */

/* ─── Verse text ──────────────────────────────────────────────────────────── */
.brf-verse-text {
    color: var(--text-primary, #333);
    line-height: 1.7;
    font-size: 0.88rem;
    font-family: 'Crimson Text', Georgia, serif;
}

/* 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;
}

/* ─── Trail sidebar ───────────────────────────────────────────────────────── */
.brf-trail {
    display: none;
    flex-direction: column;
    width: 200px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 0 0 16px 0;

    /* Subtle purple-tinted panel */
    background: rgba(var(--primary-rgb), 0.03);
    border-left: 1px solid rgba(var(--border-rgb), 0.18);
}

.brf-trail-heading {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    padding: 0.7rem 0.75rem 0.4rem;
    opacity: 0.6;
    flex-shrink: 0;
}

.brf-trail-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.2rem 0.45rem 0.5rem;
}

/* ─── Trail items ─────────────────────────────────────────────────────────── */
.brf-trail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.65rem;
    font-size: 0.73rem;
    cursor: pointer;
    border-radius: 10px;
    line-height: 1.3;
    word-break: break-word;
    color: var(--text-primary);
    opacity: 0.65;
    transition: all 0.2s ease;
    margin-bottom: 3px;
}

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

/* Active trail item — gradient glow */
.brf-trail-item.brf-trail-current {
    background: linear-gradient(135deg, #5B4B8A, #7C6BA6);
    color: white;
    font-weight: 600;
    opacity: 1;
    box-shadow: 0 2px 10px rgba(var(--primary-rgb), 0.35);
}

.brf-trail-item-label {
    flex: 1;
    min-width: 0;
}

/* 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);
}

[data-theme="dark"] .brf-header {
    background: linear-gradient(135deg, #3D2F66 0%, #5B4B8A 40%, #6E5C9E 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* dark close button handled by shared .frosted-close-btn */

[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
   ──────────────────────────────────────────────────────────────────────────── */
/* Hide redundant verse ref — already shown in header */
.brf-verse-ref {
    display: none;
}

@media (max-width: 480px) {
    .bible-ref-popup {
        width: 100vw !important;
        max-width: 100vw;
        left: 0 !important;
        top: auto !important;
        bottom: 0;
        border-radius: 16px 16px 0 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 {
        border-radius: 16px 16px 0 0;
        cursor: default;
    }

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

    .brf-trail {
        display: none;
    }

    .frosted-close-btn {
        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; }
}
