/**
 * Reference modal — fullscreen overlay (search-overlay pattern).
 * Dark glass theme spójny z bp-realization-modal ale węższy panel
 * (opinie są typo-led, mniej content).
 */

.bp-reference-modal {
    --bpr-bg:           #0b1220;
    --bpr-text:         rgba(255, 255, 255, 0.92);
    --bpr-text-muted:   rgba(255, 255, 255, 0.62);
    --bpr-text-subtle:  rgba(255, 255, 255, 0.45);
    --bpr-border:       rgba(255, 255, 255, 0.08);
    --bpr-primary:      var(--bs-primary, #0d6efd);
    --bpr-primary-rgb:  var(--bs-primary-rgb, 13, 110, 253);

    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(1rem, 5vh, 4rem) clamp(0.75rem, 3vw, 2rem);
    background: rgba(7, 11, 20, 0.6);
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.25s ease,
        backdrop-filter 0.25s ease,
        visibility 0s linear 0.25s;
}

.bp-reference-modal.is-open {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

body.bp-reference-modal-open { overflow: hidden; }

/* Panel — węższy niż realization modal bo content lighter */
.bp-reference-modal__panel {
    position: relative;
    width: 100%;
    max-width: 760px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bpr-bg);
    color: var(--bpr-text);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        0 32px 80px -16px rgba(0, 0, 0, 0.6),
        0 12px 24px -8px rgba(0, 0, 0, 0.4);
    transform: translateY(-12px) scale(0.985);
    opacity: 0;
    transition:
        transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.22s ease;
}
.bp-reference-modal.is-open .bp-reference-modal__panel {
    transform: translateY(0) scale(1);
    opacity: 1;
}

@media (max-width: 767.98px) {
    .bp-reference-modal { padding: 0; }
    .bp-reference-modal__panel {
        max-width: none;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: 0;
    }
}

/* Close X (floating top-right) */
.bp-reference-modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;

    i { font-size: 1rem; }

    &:hover, &:focus-visible {
        background: rgba(var(--bpr-primary-rgb), 0.25);
        border-color: rgba(var(--bpr-primary-rgb), 0.5);
        transform: rotate(90deg);
    }
}

/* Loading */
.bp-reference-modal__loading {
    position: absolute;
    inset: 0;
    background: rgba(11, 18, 32, 0.92);
    backdrop-filter: blur(20px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}
.bp-reference-modal__spinner {
    width: 56px;
    height: 56px;
    color: var(--bpr-primary);
    animation: bpr-spin 1s linear infinite;
}
.bp-reference-modal__spinner i { font-size: 2.5rem; }

@keyframes bpr-spin {
    to { transform: rotate(360deg); }
}

/* Scroll container */
.bp-reference-modal__scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    padding: 3.5rem clamp(1.5rem, 4vw, 3rem) 0;
}
.bp-reference-modal__scroll::-webkit-scrollbar { width: 8px; }
.bp-reference-modal__scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Header — typography-led big quote intro */
.bp-reference-modal__header {
    position: relative;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--bpr-border);
    margin-bottom: 2rem;
}

.bp-reference-modal__header-quote {
    position: absolute;
    top: -1rem;
    left: -0.5rem;
    font-size: 7rem;
    line-height: 1;
    color: rgba(var(--bpr-primary-rgb), 0.18);
    z-index: 0;
    pointer-events: none;
    font-style: italic;
}

.bp-reference-modal__stars {
    position: relative;
    display: inline-flex;
    gap: 0.15rem;
    color: var(--bs-warning, #ffc107);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.bp-reference-modal__title {
    position: relative;
    margin: 0 0 0.85rem;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: #fff;
}

.bp-reference-modal__summary {
    position: relative;
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.6;
    color: var(--bpr-text);
    font-family: ui-serif, Georgia, 'Times New Roman', serif;
    font-style: italic;
}

/* Sections */
.bp-reference-modal__section-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 1.25rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--bpr-text-muted);

    i {
        color: var(--bpr-primary);
        font-size: 1rem;
    }
}

.bp-reference-modal__content-section {
    margin-bottom: 2.5rem;
}

.bp-reference-modal__prose {
    font-size: 1rem;
    line-height: 1.75;
    color: rgba(255, 255, 255, 0.85);

    p { margin: 0 0 1.15em; }
    p:last-child { margin-bottom: 0; }
    strong, b { color: #fff; }
    a { color: var(--bpr-primary); }
}

/* Gallery — masonry-light grid */
.bp-reference-modal__gallery {
    margin-bottom: 2.5rem;
}

.bp-reference-modal__gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.6rem;
}

.bp-reference-modal__gallery-grid img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
    cursor: zoom-in;
    transition: transform 0.3s ease, opacity 0.2s ease;

    &:hover {
        transform: scale(1.03);
        opacity: 0.95;
    }
}

/* Realization link */
.bp-reference-modal__realization {
    margin-bottom: 2.5rem;
}

.bp-reference-modal__realization-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.75rem 1.15rem;
    background: rgba(var(--bpr-primary-rgb), 0.12);
    border: 1px solid rgba(var(--bpr-primary-rgb), 0.3);
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;

    i { font-size: 1rem; transition: transform 0.2s; }

    &:hover {
        background: rgba(var(--bpr-primary-rgb), 0.22);
        border-color: rgba(var(--bpr-primary-rgb), 0.5);
        color: #fff;
        transform: translateY(-1px);

        i { transform: translate(2px, -2px); }
    }
}

/* Author footer — sticky to bottom area */
.bp-reference-modal__author {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem clamp(1.5rem, 4vw, 3rem);
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid var(--bpr-border);
    flex-wrap: wrap;
}

.bp-reference-modal__author-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.12);
}

.bp-reference-modal__author-text {
    flex: 1;
    min-width: 0;
}

.bp-reference-modal__author-name {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
}

.bp-reference-modal__author-meta {
    display: block;
    font-size: 0.85rem;
    color: var(--bpr-text-muted);
    margin-top: 0.15rem;
}

.bp-reference-modal__author-logo {
    max-width: 96px;
    max-height: 42px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 5px;
    flex-shrink: 0;
    filter: brightness(0) invert(0.95);
}

.bp-reference-modal__author-pdf {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    background: rgba(var(--bpr-primary-rgb), 0.15);
    border: 1px solid rgba(var(--bpr-primary-rgb), 0.3);
    border-radius: 8px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;

    i { font-size: 1rem; }

    &:hover {
        background: rgba(var(--bpr-primary-rgb), 0.28);
        border-color: rgba(var(--bpr-primary-rgb), 0.55);
        color: #fff;
    }
}

@media (max-width: 575.98px) {
    .bp-reference-modal__scroll { padding-top: 2.75rem; }
    .bp-reference-modal__header-quote { font-size: 5rem; }
    .bp-reference-modal__author {
        gap: 0.75rem;
    }
    .bp-reference-modal__author-pdf span { display: none; }
}
