/* ==========================================================================
   Site popup  (markup: parts/section-popup.php, behaviour: assets/js/popup.js)
   Colors come from inline CSS variables set per popup in the Customizer:
   --bb-pop-accent, --bb-pop-bg, --bb-pop-text, --bb-pop-overlay
   ========================================================================== */

.bb-popup {
    --bb-pop-radius: 14px;
    --bb-pop-muted: color-mix(in srgb, var(--bb-pop-text) 62%, transparent);
    --bb-pop-line: color-mix(in srgb, var(--bb-pop-text) 14%, transparent);

    position: fixed;
    inset: 0;
    /* Must stay BELOW the custom cursor element from script.js (usually 9999+),
       otherwise the cursor renders behind the popup. Raise --bb-pop-z only if
       the popup needs to sit above the header/drawer and the cursor is higher still. */
    z-index: var(--bb-pop-z, 9000);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    color: var(--bb-pop-text);
    font-family: "Barlow", system-ui, sans-serif;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility 0s linear .25s;
}

.bb-popup[hidden] {
    display: none;
}

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

body.bb-popup-lock {
    overflow: hidden;
}

/* Backdrop ---------------------------------------------------------------- */

.bb-popup__overlay {
    position: absolute;
    inset: 0;
    background: rgba(8, 12, 20, var(--bb-pop-overlay));
    backdrop-filter: blur(3px);
}

/* Dialog ------------------------------------------------------------------ */

.bb-popup__dialog {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: var(--bb-pop-bg);
    border: 1px solid var(--bb-pop-line);
    border-top: 3px solid var(--bb-pop-accent);
    border-radius: var(--bb-pop-radius);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
    transform: translateY(16px) scale(.98);
    transition: transform .3s cubic-bezier(.2, .8, .2, 1);
    outline: none;
}

.bb-popup.is-open .bb-popup__dialog {
    transform: none;
}

.bb-popup__body {
    padding: 32px 32px 28px;
}

.bb-popup__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--bb-pop-text);
    background: color-mix(in srgb, var(--bb-pop-bg) 80%, transparent);
    border: 1px solid var(--bb-pop-line);
    border-radius: 50%;
    cursor: inherit;
    transition: border-color .2s, color .2s;
}

.bb-popup__close:hover {
    color: var(--bb-pop-accent);
    border-color: var(--bb-pop-accent);
}

/* Media ------------------------------------------------------------------- */

.bb-popup__media {
    line-height: 0;
}

.bb-popup__img {
    display: block;
    width: 100%;
    height: 190px;
    object-fit: cover;
}

/* Text -------------------------------------------------------------------- */

.bb-popup__subtitle {
    margin: 0 0 8px;
    font-family: "DM Mono", ui-monospace, monospace;
    font-size: 13px;
    letter-spacing: .02em;
    color: var(--bb-pop-accent);
}

.bb-popup__title {
    margin: 0 0 12px;
    font-family: "Barlow Condensed", "Barlow", sans-serif;
    font-size: clamp(28px, 5vw, 38px);
    font-weight: 700;
    line-height: 1.08;
    color: var(--bb-pop-text);
}

.bb-popup__title .text-gradient {
    background: linear-gradient(90deg, var(--bb-pop-accent), #2563EB);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.bb-popup__text {
    max-width: 60ch;
    font-size: 16px;
    line-height: 1.55;
    color: var(--bb-pop-muted);
}

.bb-popup__text p {
    margin: 0 0 10px;
}

.bb-popup__text p:last-child {
    margin-bottom: 0;
}

/* Newsletter form --------------------------------------------------------- */

.bb-popup__form {
    margin-top: 20px;
}

.bb-popup__field {
    display: flex;
    gap: 8px;
}

.bb-popup__field input[type="email"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 46px;
    padding: 0 14px;
    font: inherit;
    color: var(--bb-pop-text);
    background: color-mix(in srgb, var(--bb-pop-text) 6%, transparent);
    border: 1px solid var(--bb-pop-line);
    border-radius: 8px;
    cursor: inherit;
    transition: border-color .2s, box-shadow .2s;
}

.bb-popup__field input[type="email"]::placeholder {
    color: var(--bb-pop-muted);
}

.bb-popup__field input[type="email"]:focus {
    outline: none;
    border-color: var(--bb-pop-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--bb-pop-accent) 25%, transparent);
}

.bb-popup__msg {
    min-height: 0;
    margin: 8px 0 0;
    font-size: 14px;
}

.bb-popup__msg:empty {
    display: none;
}

.bb-popup__msg.is-error {
    color: #ff6b6b;
}

.bb-popup__msg.is-success {
    color: #34d399;
}

.bb-popup__note {
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--bb-pop-muted);
}

/* Buttons ----------------------------------------------------------------- */

.bb-popup__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    padding: 0 22px;
    font: 600 15px/1 "Barlow", sans-serif;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: inherit;
    transition: filter .2s, border-color .2s, color .2s;
}

.bb-popup__btn--primary {
    color: #080C14;
    background: var(--bb-pop-accent);
}

.bb-popup__btn--primary:hover {
    filter: brightness(1.1);
}

.bb-popup__btn--secondary {
    color: var(--bb-pop-text);
    background: transparent;
    border-color: var(--bb-pop-line);
}

.bb-popup__btn--secondary:hover {
    color: var(--bb-pop-accent);
    border-color: var(--bb-pop-accent);
}

.bb-popup__btn[disabled] {
    opacity: .6;
}

.bb-popup__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.bb-popup__dismiss {
    display: inline-block;
    margin-top: 16px;
    padding: 4px 0;
    font: inherit;
    font-size: 14px;
    color: var(--bb-pop-muted);
    background: none;
    border: 0;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: inherit;
}

.bb-popup__dismiss:hover {
    color: var(--bb-pop-text);
}

/* Focus ------------------------------------------------------------------- */

.bb-popup :focus-visible {
    outline: 2px solid var(--bb-pop-accent);
    outline-offset: 2px;
}

/* Layout: split ----------------------------------------------------------- */

.bb-popup--split .bb-popup__dialog {
    max-width: 820px;
}

.bb-popup--split.has-image .bb-popup__dialog {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.bb-popup--split .bb-popup__img {
    height: 100%;
    min-height: 320px;
}

.bb-popup--split .bb-popup__body {
    align-self: center;
}

/* Layout: corner slide-in ------------------------------------------------- */

.bb-popup--corner {
    inset: auto 0 0 auto;
    align-items: flex-end;
    justify-content: flex-end;
    width: auto;
    padding: 20px;
    pointer-events: none;
}

.bb-popup--corner .bb-popup__overlay {
    display: none;
}

.bb-popup--corner .bb-popup__dialog {
    max-width: 380px;
    pointer-events: auto;
    transform: translateX(32px);
}

.bb-popup--corner .bb-popup__body {
    padding: 24px 24px 22px;
}

.bb-popup--corner .bb-popup__title {
    font-size: 26px;
}

.bb-popup--corner .bb-popup__img {
    height: 140px;
}

.bb-popup--corner .bb-popup__field {
    flex-direction: column;
}

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

@media (max-width: 767px) {
    .bb-popup[data-mobile="0"] {
        display: none !important;
    }

    .bb-popup--split.has-image .bb-popup__dialog {
        grid-template-columns: 1fr;
    }

    .bb-popup--split .bb-popup__img {
        height: 190px;
        min-height: 0;
    }

    .bb-popup__body {
        padding: 24px 20px 22px;
    }

    .bb-popup__field {
        flex-direction: column;
    }

    .bb-popup__btn {
        width: 100%;
    }

    .bb-popup--corner {
        inset: auto 0 0 0;
        padding: 12px;
    }

    .bb-popup--corner .bb-popup__dialog {
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bb-popup,
    .bb-popup__dialog {
        transition: none;
    }
}