/* ByLfI Popup Manager – frontend styles
   Position: fixed on all variants → zero CLS, no layout shift.
   CSS custom properties (--pp-*) are set inline per popup from Bootstrap.php.
   ─────────────────────────────────────────────────────────────── */

/* Base – always hidden until JS reveals */
.bylfi-popup {
    display: none;
    box-sizing: border-box;
}

/* ── Modal ──────────────────────────────────────────────────────── */

.bylfi-popup[data-type="modal"] {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;

    opacity: 0;
    transition: opacity 0.18s ease;
}

.bylfi-popup[data-type="modal"].is-visible {
    opacity: 1;
}

.bylfi-popup__overlay {
    position: absolute;
    inset: 0;
    background: rgba(22, 23, 28, 0.58);
    cursor: pointer;
}

.bylfi-popup__dialog {
    position: relative;
    background: var(--pp-bg, #fdfcfa);
    color: var(--pp-text, #16171c);
    border-radius: 4px;
    padding: 2rem 2rem 1.75rem;
    width: 100%;
    max-width: 540px;
    max-height: calc(100svh - 2rem);
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(22, 23, 28, 0.12);
    overscroll-behavior: contain;

    transform: translateY(18px) scale(0.98);
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.bylfi-popup[data-type="modal"].is-visible .bylfi-popup__dialog {
    transform: translateY(0) scale(1);
}

/* ── Banner — Top ───────────────────────────────────────────────── */

.bylfi-popup[data-type="banner_top"] {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1080;

    transform: translateY(-100%);
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.bylfi-popup[data-type="banner_top"].is-visible {
    transform: translateY(0);
}

/* ── Banner — Bottom ────────────────────────────────────────────── */

/* --hk-bottom-stack kommt aus dem kritischen Theme-CSS (sass/_layers.scss) und
   sagt, wie viel Hoehe unten schon von Tab- und Kaufleiste belegt ist. Ohne den
   Versatz legte sich dieses Banner (z 1080) ueber beide. Auf dem Desktop und
   ausserhalb des Themes ist der Wert 0px, das Verhalten bleibt dort gleich.
   Der Ausblend-Transform muss den Versatz mitnehmen, sonst bliebe im
   versteckten Zustand ein Streifen sichtbar. */
.bylfi-popup[data-type="banner_bottom"] {
    display: block;
    position: fixed;
    bottom: var(--hk-bottom-stack, 0px);
    left: 0;
    right: 0;
    z-index: var(--hk-z-popup, 1080);

    transform: translateY(calc(100% + var(--hk-bottom-stack, 0px)));
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.bylfi-popup[data-type="banner_bottom"].is-visible {
    transform: translateY(0);
}

/* ── Banner inner wrapper (shared top + bottom) ──────────────────── */

.bylfi-popup__banner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: nowrap;
    background: var(--pp-bg, #16171c);
    color: var(--pp-text, #f9fafb);
    padding: 0.9rem 3.5rem 0.9rem 1.5rem;
    box-shadow: 0 1px 2px rgba(22, 23, 28, 0.08);
    box-sizing: border-box;
}

/* ── Close button ───────────────────────────────────────────────── */

.bylfi-popup__close {
    position: absolute;
    top: 0.6rem;
    right: 0.7rem;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--pp-text, #16171c);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.55;
    padding: 0;
    transition: opacity 0.18s, background 0.18s;
    flex-shrink: 0;
}

.bylfi-popup__close:hover,
.bylfi-popup__close:focus-visible {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08);
    outline: none;
}

/* ── Image ──────────────────────────────────────────────────────── */

.bylfi-popup__img {
    display: block;
    object-fit: cover;
    border-radius: 4px;
}

.bylfi-popup__img--modal {
    width: 100%;
    max-height: 220px;
    margin-bottom: 1.1rem;
}

.bylfi-popup__img--banner {
    width: clamp(56px, 8vw, 92px);
    height: clamp(56px, 8vw, 92px);
    max-width: 92px;
    max-height: 92px;
    flex: 0 0 auto;
    margin: 0;
}

/* ── Body / Content ─────────────────────────────────────────────── */

.bylfi-popup__body {
    box-sizing: border-box;
    min-width: 0;
}

.bylfi-popup__banner .bylfi-popup__body {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex: 1 1 auto;
}

.bylfi-popup__title {
    margin: 0 0 0.65rem;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    color: inherit;
}

.bylfi-popup__banner .bylfi-popup__title {
    margin: 0;
    font-size: 1rem;
    white-space: nowrap;
}

.bylfi-popup__content {
    font-size: 0.93rem;
    line-height: 1.58;
    color: inherit;
    opacity: 0.9;
    margin-bottom: 1.1rem;
}

.bylfi-popup__banner .bylfi-popup__content {
    margin: 0;
    flex: 1 1 auto;
}

.bylfi-popup__banner .bylfi-popup__content p {
    margin: 0;
}

.bylfi-popup__content p:last-child {
    margin-bottom: 0;
}

.bylfi-popup__content a {
    color: inherit;
    text-decoration: underline;
}

/* ── CTA Button ─────────────────────────────────────────────────── */

.bylfi-popup__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.45rem;
    border-radius: 999px;
    background: var(--pp-btn, #e2233b);
    color: var(--pp-btn-text, #fdfcfa) !important;
    font-weight: 600;
    font-size: 0.88rem;
    text-decoration: none !important;
    border: none;
    cursor: pointer;
    transition: opacity 0.18s, transform 0.18s;
    white-space: nowrap;
}

.bylfi-popup__banner .bylfi-popup__btn {
    flex: 0 0 auto;
    margin-left: auto;
}

.bylfi-popup__btn:hover {
    opacity: 0.84;
    transform: translateY(-1px);
}

.bylfi-popup__btn:focus-visible {
    outline: 2px solid var(--pp-btn, #e2233b);
    outline-offset: 3px;
}

/* ── Reduced motion ─────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .bylfi-popup[data-type="modal"],
    .bylfi-popup__dialog,
    .bylfi-popup[data-type="banner_top"],
    .bylfi-popup[data-type="banner_bottom"],
    .bylfi-popup__btn {
        transition: none !important;
        transform: none !important;
    }

    .bylfi-popup[data-type="modal"].is-visible,
    .bylfi-popup[data-type="banner_top"].is-visible,
    .bylfi-popup[data-type="banner_bottom"].is-visible {
        opacity: 1;
    }
}

/* ── Mobile adjustments ─────────────────────────────────────────── */

@media (max-width: 480px) {
    .bylfi-popup__dialog {
        padding: 1.5rem 1.25rem 1.35rem;
        border-radius: 4px;
    }

    .bylfi-popup__title {
        font-size: 1.15rem;
    }

    .bylfi-popup__banner {
        align-items: flex-start;
        flex-wrap: wrap;
        padding: 0.75rem 3.2rem 0.75rem 1rem;
    }

    .bylfi-popup__img--banner {
        width: 52px;
        height: 52px;
    }

    .bylfi-popup__banner .bylfi-popup__body {
        display: block;
        flex: 1 1 180px;
    }

    .bylfi-popup__banner .bylfi-popup__title,
    .bylfi-popup__banner .bylfi-popup__content {
        margin-bottom: 0.35rem;
    }

    .bylfi-popup__banner .bylfi-popup__btn {
        margin-left: 0;
    }
}

/* Premium Floating Reopen Trigger */
.bylfi-reopen-trigger {
    position: fixed;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    right: 1rem;
    width: 68px;
    height: 68px;
    padding: 0;
    background: #fdfcfa;
    border: 1px solid rgba(22, 23, 28, 0.14);
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(22, 23, 28, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1040;
    cursor: pointer;
    transition: opacity 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    color: #111827;
    pointer-events: none;
}

.bylfi-reopen-trigger.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.bylfi-reopen-trigger:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 28px rgba(22, 23, 28, 0.2);
}

.bylfi-reopen-trigger:focus-visible {
    outline: 3px solid #e2233b;
    outline-offset: 3px;
}

.bylfi-reopen-trigger i {
    font-size: 24px;
    display: block;
    line-height: 1;
}

.bylfi-reopen-trigger__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    transition: opacity 0.18s ease;
}

.bylfi-reopen-trigger__image.is-changing {
    opacity: 0;
}

.bylfi-reopen-trigger--image {
    width: 104px;
    height: 112px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.bylfi-reopen-trigger--image .bylfi-reopen-trigger__image {
    object-fit: contain;
    border-radius: 0;
    filter: drop-shadow(0 5px 8px rgba(22, 23, 28, 0.16));
}

.bylfi-reopen-trigger--image:hover {
    box-shadow: none;
}

@media (max-width: 768px) {
    .bylfi-reopen-trigger {
        bottom: calc(76px + env(safe-area-inset-bottom));
        right: .75rem;
        width: 58px;
        height: 58px;
    }
    .bylfi-reopen-trigger i {
        font-size: 20px;
    }
    .bylfi-reopen-trigger--image {
        width: 78px;
        height: 88px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bylfi-reopen-trigger {
        transition: none !important;
    }
    .bylfi-reopen-trigger__image {
        transition: none !important;
    }
}

/* ── Embedded forms (newsletter / contact) ─────────────────────── */

.bylfi-popup__form {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.bylfi-popup__form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.bylfi-popup__form-input {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    font-size: 0.85rem;
    box-sizing: border-box;
    font-family: inherit;
}

.bylfi-popup__form--newsletter .bylfi-popup__form-input {
    border-radius: 50px;
    font-size: 0.9rem;
}

.bylfi-popup__form-textarea {
    resize: vertical;
    min-height: 96px;
}

.bylfi-popup__form-submit {
    width: 100%;
    background: var(--pp-btn, #111827);
    color: var(--pp-btn-text, #ffffff);
    border: none;
    border-radius: 50px;
    padding: 0.7rem;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    margin-top: 0.15rem;
}
