/* ==========================================================================
   ID Popup, Frontend Stylesheet
   ========================================================================== */

/* --------------------------------------------------------------------------
   Overlay
   Explicit top/right/bottom/left instead of the `inset` shorthand for
   compatibility with older mobile browsers (pre-Chrome 87 / Safari 14.1).
   Very high z-index so themes with sticky headers cannot render above it.
   -------------------------------------------------------------------------- */
.id-popup-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999998;
    display: none;
    background-color: rgba(0, 0, 0, 0.7);
}

/* Body-scroll lock: JS toggles this class while any popup is open, so the
   page cannot scroll or overflow horizontally underneath the popup. */
body.id-popup-open {
    overflow: hidden !important;
}

/* --------------------------------------------------------------------------
   Popup Container
   -------------------------------------------------------------------------- */
.id-popup-container {
    position: fixed;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    z-index: 999999;
    display: none;
    background: transparent;
    /* Width is driven by the user's Desktop Max Width setting via the
       inline max-width on the element. width: 100% here just means "fill
       the max-width the admin picked", not a hardcoded number. */
    width: 100%;
    box-sizing: border-box;
    /* No max-height, no overflow: the image is sized to fit viewport
       height (see .id-popup-container img below), so no scrollbar ever
       needs to appear on the popup. */
}

/* --------------------------------------------------------------------------
   Popup Images
   -------------------------------------------------------------------------- */
.id-popup-container img {
    max-width: 100%;
    /* Cap image at viewport height so tall portrait images never overflow
       the screen. Browser scales to fit both dimensions maintaining aspect
       ratio, so no scrollbars ever appear. */
    max-height: 90vh;
    height: auto;
    width: auto;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: block;
    margin: 0 auto;
}

/* Inner wrapper: anchors the close button to the popup image, so its
   position stays fixed relative to the image whether or not a logo is shown. */
.id-popup-container .id-popup-inner {
    position: relative;
    display: block;
}

/* Site logo above popup, top-left */
.id-popup-container .id-popup-site-logo {
    max-height: 48px;
    width: auto;
    max-width: 200px;
    margin: 0 0 12px 0;
    border-radius: 0;
    box-shadow: none;
    display: block;
}

/* Desktop image shown by default, mobile image hidden */
.id-popup-container .desktop-image {
    display: block;
}

.id-popup-container .mobile-image {
    display: none;
}

/* --------------------------------------------------------------------------
   Close Button (desktop default: overlaps top-right corner of popup image)
   -------------------------------------------------------------------------- */
.id-popup-close-btn {
    position: absolute;
    top: -20px;
    right: -20px;
    cursor: pointer;
    color: #e11d48;
    font-family: Arial, sans-serif;
    font-size: 32px;
    font-weight: 400;
    width: 40px;
    height: 40px;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    line-height: 0;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    z-index: 2;
}

.id-popup-close-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* --------------------------------------------------------------------------
   Mobile Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
    /* Force mobile bounds using viewport units (vw/vh) so the popup is
       ALWAYS relative to the actual viewport, not a transformed ancestor
       (some themes and Bootstrap add transforms on body which would
       otherwise make % width measure against a broken containing block
       and stretch/push the page). */
    .id-popup-container {
        width: var(--id-mobile-max-width, 90vw) !important;
        max-width: var(--id-mobile-max-width, 90vw) !important;
    }

    /* Popup image on mobile: never exceed the popup width AND never exceed
       the viewport height. No scrollbars. */
    .id-popup-container img {
        max-width: 100% !important;
        max-height: 85vh !important;
        width: auto !important;
        height: auto !important;
    }

    /* Keep close button INSIDE the popup on narrow screens so it never falls
       off the viewport edge and is always tappable. */
    .id-popup-close-btn {
        top: 6px;
        right: 6px;
        width: 34px;
        height: 34px;
        font-size: 26px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    }

    .id-popup-container .desktop-image {
        display: none;
    }

    .id-popup-container .mobile-image {
        display: block;
    }

    /* Smaller logo on mobile so it does not push the image off-screen */
    .id-popup-container .id-popup-site-logo {
        max-height: 36px;
        max-width: 140px;
        margin-bottom: 8px;
    }
}
