/**
 * Black November campaign popup.
 *
 * One artwork per page group (front page / weight loss, plastic surgery,
 * HELP, ESG, bypass+sleeve, gastric balloon). Fixed overlay above every other
 * UI layer, artwork in a portrait box with the Book Consultation CTA pinned
 * underneath, and a close affordance on top.
 */

.bn-popup {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* Height consumed around the artwork: popup side padding + the CTA bar.
       The image cap further down subtracts it so the box stays tight. */
    --bn-overhead: 112px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

/*
 * Mobile browsers center-flex against the LARGE viewport while only the small
 * viewport is visible when the URL bar is up; without 100svh the dialog would
 * center off-screen and clip the close icon and CTA. (Percentage caps on the
 * box itself were dropped: with a definite box cap, the contained artwork
 * flex-inflates and leaves a dead band under the poster.)
 */
@supports (height: 100svh) {

    .bn-popup {
        height: 100svh;
    }
}

.bn-popup.is-open {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Scrim - blurred so the page reads as "behind" the offer. */
.bn-popup-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 7, 2, 0.72);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

/*
 * Portrait box: its height is exactly artwork + CTA - no box-level cap, so
 * nothing can flex-inflate it and leave dead space under the poster. The
 * artwork itself stays capped for short viewports (see .bn-popup-img).
 */
.bn-popup-box {
    position: relative;
    z-index: 1;
    width: min(420px, 100%);
    border-radius: 14px;
    overflow: hidden;
    background: #170c05;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 189, 37, 0.18);
    transform: translateY(14px) scale(0.97);
    transition: transform 0.3s ease;
}

.bn-popup.is-open .bn-popup-box {
    transform: none;
}

.bn-popup-img {
    display: block;
    width: 100%;
    height: auto;
    /*
     * Short-viewport safety only: shrinks the artwork at most to this, so the
     * CTA bar always stays on screen. On normal screens the cap never binds
     * and the poster fills the box edge to edge. Contain letterboxes any
     * leftover space at the sides, where the poster's own dark edges read as
     * padding.
     */
    max-height: calc(100svh - var(--bn-overhead, 112px));
    object-fit: contain;
    object-position: center top;
}

/* Same cap for engines without small-viewport units. */
@supports not (height: 100svh) {

    .bn-popup-img {
        max-height: calc(100vh - var(--bn-overhead, 112px));
    }
}

/* Close affordance floats over the artwork's top-right corner. */
.bn-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(15, 7, 2, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.28);
    cursor: pointer;
    transition: background-color 0.25s ease;
}

.bn-popup-close:hover,
.bn-popup-close:focus-visible {
    background: rgba(15, 7, 2, 0.88);
}

/* Explicit size: without it the flex-item SVG can collapse to a hairline
   (it carries 16px width/height attributes only). */
.bn-popup-close svg {
    display: block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.bn-popup-close:focus-visible {
    outline: 2px solid #FFBD25;
    outline-offset: -4px;
}

/* ---------- CTA ---------- */

.bn-popup-cta {
    display: flex;
    justify-content: center;
    padding: 12px 14px;
    background:
        radial-gradient(120% 200% at 50% 0%, rgba(122, 82, 40, 0.35) 0%, rgba(122, 82, 40, 0) 65%),
        rgba(15, 7, 2, 0.94);
}

.bn-popup-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 12px 30px;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffd35e 0%, #FFBD25 55%, #f0a916 100%);
    box-shadow: 0 4px 14px rgba(255, 189, 37, 0.35);
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #3a2313;
    text-decoration: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
}

.bn-popup-btn:hover,
.bn-popup-btn:focus-visible {
    text-decoration: none;
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(255, 189, 37, 0.45);
}

.bn-popup-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 3px;
}

.bn-popup-btn svg {
    transition: transform 0.25s ease;
}

.bn-popup-btn:hover svg {
    transform: translateX(3px);
}

/* Page scroll locks while the dialog is up (own class - the theme's
   .modal-open belongs to the video drawer). */
body.bn-popup-open {
    overflow: hidden;
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {

    .bn-popup {
        /* Safe-area keeps the CTA clear of notches and gesture bars. */
        padding: 14px 14px max(14px, env(safe-area-inset-bottom, 14px));
        /* Smaller chrome (28) plus the compact CTA (~66) - keeps the same
           safety cap working on phones, growing with any notch. */
        --bn-overhead: calc(104px + env(safe-area-inset-bottom, 0px));
    }

    .bn-popup-box {
        width: min(400px, 100%);
        border-radius: 12px;
    }

    .bn-popup-cta {
        padding: 10px 12px;
    }

    .bn-popup-btn {
        padding: 11px 24px;
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .bn-popup,
    .bn-popup-box,
    .bn-popup-btn,
    .bn-popup-btn svg {
        transition: none;
    }

    .bn-popup-box,
    .bn-popup-btn:hover,
    .bn-popup-btn svg {
        transform: none;
    }
}
