/* Posh Popup Frontend Styles — v1.0.17 more side padding */

/* Full-viewport layer: scrolls when card is taller than viewport (125%–150% zoom, long content) */
.posh-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    z-index: 999999;
    width: 100%;
    max-width: none;
    height: auto;
    min-height: 100dvh;
    margin: 0;
    padding: max(var(--posh-overlay-inset), env(safe-area-inset-top))
        max(var(--posh-overlay-inset), env(safe-area-inset-right))
        max(var(--posh-overlay-inset), env(safe-area-inset-bottom))
        max(var(--posh-overlay-inset), env(safe-area-inset-left));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: transparent;
    transform: none;
    top: auto;
    left: auto;
    animation: fadeIn 0.3s ease-in-out;
    border-radius: 0;
    /* Variables (inherited by .posh-popup-container and descendants) */
    --posh-overlay-inset: clamp(14px, 3.5vmin, 36px);
    --posh-overlay-max-w: 920px;
    --posh-overlay-max-h: min(92dvh, 760px);
    --posh-overlay-min-h: 0;
    --posh-image-max-h: min(48vh, 380px);
    --posh-video-max-w: min(100%, 88vw, 360px);
    --posh-wrap-pad-x: clamp(14px, 3vw, 24px);
    --posh-wrap-pad-top: clamp(10px, 2vh, 20px);
    --posh-wrap-pad-bottom: clamp(12px, 2.5vh, 22px);
    --posh-grid-gap: clamp(8px, 1.8vw, 16px);
}

.posh-popup-overlay.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Card: sized and themed here so the outer overlay can scroll without clipping */
.posh-popup-container {
    position: relative;
    box-sizing: border-box;
    width: min(var(--posh-overlay-max-w), 100%);
    max-width: 100%;
    flex: 0 0 auto;
    margin-top: auto;
    margin-bottom: auto;
    margin-left: auto;
    margin-right: auto;
    min-height: min(
        var(--posh-overlay-min-h, 0),
        calc(100dvh - max(var(--posh-overlay-inset), env(safe-area-inset-top)) - max(var(--posh-overlay-inset), env(safe-area-inset-bottom)) - 16px)
    );
    /* Let the card grow with content — no second scrollbar inside the popup; outer overlay scrolls if needed */
    max-height: none;
    overflow-x: hidden;
    overflow-y: visible;
    background-color: #0f2b3a;
    background-image: var(--posh-popup-bg-image,
        radial-gradient(circle at 20% 15%, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 45%),
        radial-gradient(circle at 80% 70%, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0) 50%),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0px, rgba(255,255,255,0.03) 1px, rgba(0,0,0,0) 3px, rgba(0,0,0,0) 6px),
        repeating-linear-gradient(90deg, rgba(0,0,0,0.04) 0px, rgba(0,0,0,0.04) 1px, rgba(0,0,0,0) 4px, rgba(0,0,0,0) 8px)
    );
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 18px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
    animation: slideUp 0.4s ease-out;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.posh-popup-header {
    padding: clamp(8px, 1.5vh, 12px) clamp(14px, 3vw, 22px) clamp(14px, 2.8vh, 22px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
    min-height: 50px;
}

.posh-popup-title {
    margin: clamp(6px, 1.5vh, 15px) 0 0 0;
    color: #ffffff;
    font-size: clamp(16px, 4.2vw, 24px);
    font-weight: 700;
    letter-spacing: 0.5px;
    flex: 1;
    text-align: center;
    line-height: 1.2;
}

/* Override theme rules like:
   [type=button]:not(:disabled), button:not(:disabled) { display: none; }
   (used to hide mobile menu buttons on desktop — must not hide popup close) */
.posh-popup-overlay button.posh-popup-close,
.posh-popup-overlay .posh-popup-close,
.posh-popup-overlay [type="button"].posh-popup-close {
    position: absolute;
    top: clamp(8px, 2vh, 15px);
    right: clamp(12px, 3vw, 20px);
    background: transparent;
    border: none;
    height: auto;
    width: auto;
    min-width: auto;
    min-height: auto;
    border-radius: 0;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    color: #ffffff;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center;
    justify-content: center;
    transition: none;
    padding: 0;
    margin: 0;
    gap: 10px;
    clip: auto;
    clip-path: none;
    overflow: visible;
    pointer-events: auto;
}

.posh-popup-overlay .posh-popup-close:hover,
.posh-popup-overlay .posh-popup-close:active,
.posh-popup-overlay .posh-popup-close:focus {
    background: transparent !important;
    color: #ffffff !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.posh-popup-close-text {
    font-size: 20px;
    font-weight: 500;
    opacity: 0.95;
}

.posh-popup-close-x {
    font-size: 30px;
    line-height: 1;
    margin-top: -2px;
    opacity: 0.95;
}

.posh-popup-overlay .posh-popup-close:hover .posh-popup-close-text,
.posh-popup-overlay .posh-popup-close:hover .posh-popup-close-x,
.posh-popup-overlay .posh-popup-close:active .posh-popup-close-text,
.posh-popup-overlay .posh-popup-close:active .posh-popup-close-x,
.posh-popup-overlay .posh-popup-close:focus .posh-popup-close-text,
.posh-popup-overlay .posh-popup-close:focus .posh-popup-close-x {
    color: #ffffff !important;
    opacity: 0.95 !important;
    background: transparent !important;
}


.posh-popup-content-wrapper {
    padding: var(--posh-wrap-pad-top) var(--posh-wrap-pad-x) var(--posh-wrap-pad-bottom);
    width: 100%;
    max-width: 100%;
    margin: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: visible;
    min-height: 0;
    box-sizing: border-box;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
}

.posh-popup-content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--posh-grid-gap);
    margin-bottom: 0;
    width: 100%;
    min-width: 0;
    min-height: 0;
    /* Same row height for both columns so CTAs can sit on one baseline */
    align-items: stretch;
    /* Cap white media frames so a tall image cannot tower over the 16:9 video column */
    --posh-dual-shell-max-h: min(392px, 56dvh);
}

/* Two-column only: same max height for both shells; clip overflow with centered content */
.posh-popup-content-grid .posh-popup-media-shell {
    max-height: var(--posh-dual-shell-max-h);
    overflow: hidden;
}

.posh-popup-content-grid .posh-popup-media-shell .posh-popup-image-box img {
    max-height: min(
        var(--posh-image-max-h),
        calc(var(--posh-dual-shell-max-h) - clamp(20px, 4vw, 44px))
    );
}

.posh-popup-content-grid > .posh-popup-content-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

.posh-popup-content-card {
    display: flex;
    flex-direction: column;
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
    box-shadow: none;
    justify-content: flex-start;
    align-items: stretch;
    min-width: 0;
}

.posh-popup-content-single {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0;
    width: 100%;
}

.posh-popup-content-single .posh-popup-content-card {
    max-width: min(760px, 100%);
    width: 100%;
}

.posh-popup-media-container {
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 0;
    margin-bottom: 8px;
    padding-bottom: 0;
}

/* Media (image or video): wrapper height follows outer shell + inner box */
.posh-popup-media-container:has(.posh-popup-media-shell) {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    min-height: 0;
    line-height: 0;
}

/* Shared white outer frame for image + video */
.posh-popup-media-shell {
    --posh-media-shell-min-h: 350px;
    width: 100%;
    max-width: 100%;
    min-height: var(--posh-media-shell-min-h);
    background: #ffffff;
    border-radius: 8px;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(8px, 2vw, 20px);
    box-sizing: border-box;
    margin: 0 auto;
    line-height: 0;
}

.posh-popup-media-shell .posh-popup-video-box {
    width: 100%;
    max-width: var(--posh-video-max-w);
    flex: 0 0 auto;
    margin-left: auto;
    margin-right: auto;
    box-shadow: none;
}

.posh-popup-media-shell .posh-popup-image-box,
.posh-popup-media-shell .posh-popup-media-box.posh-popup-image-box {
    width: 100%;
    max-width: var(--posh-image-max-w, none);
    flex: 0 0 auto;
    margin-left: auto;
    margin-right: auto;
    box-shadow: none;
    padding: 0;
    background: transparent;
    line-height: normal;
}

/* Fill the white shell width; height uses shell minus padding and global image cap */
.posh-popup-media-shell .posh-popup-image-box img {
    border-radius: 8px;
    width: 100%;
    height: auto;
    max-height: min(
        var(--posh-image-max-h),
        calc(var(--posh-media-shell-min-h) - clamp(16px, 4vw, 40px))
    );
    margin: 0 auto;
    object-fit: contain;
    object-position: center;
    display: block;
}

/* No max-width here — same node uses .posh-popup-video-box / .posh-popup-image-box caps (avoids 100% winning) */
.posh-popup-media-box {
    width: 100%;
    min-width: 0;
    position: relative;
    overflow: hidden;
    background: transparent;
    margin: 0 auto;
}

.posh-popup-media-box.posh-popup-image-box,
.posh-popup-image-box {
    width: 100%;
    max-width: var(--posh-image-max-w, none);
    margin-left: auto;
    margin-right: auto;
    height: auto;
    min-height: 0;
    max-height: none;
    display: block;
    padding: clamp(6px, 1.5vmin, 12px);
    background: #ffffff;
    border-radius: 8px;
    box-shadow: none;
    flex-shrink: 0;
    margin: 0 auto 0 auto;
    box-sizing: border-box;
    position: relative;
}

.posh-popup-image-box img {
    width: 100%;
    height: auto;
    max-height: var(--posh-image-max-h);
    object-fit: contain;
    display: block;
    border-radius: 4px;
}

/* Video area: white frame height = strict 16:9 of its width (button lives outside this box) */
.posh-popup-media-box.posh-popup-video-box,
.posh-popup-video-box {
    width: 100%;
    max-width: var(--posh-video-max-w);
    margin: 0 auto;
    aspect-ratio: 16 / 9;
    height: auto;
    min-height: 0;
    max-height: none;
    position: relative;
    display: block;
    background: #ffffff;
    border-radius: 8px;
    padding: 0;
    box-shadow: none;
    flex-shrink: 0;
    box-sizing: border-box;
    overflow: hidden;
    background-color: #ffffff !important;
    line-height: 0;
    contain: layout;
}

.posh-popup-video-box .posh-popup-youtube-thumbnail {
    line-height: normal;
}

/* White background overlay behind video */
.posh-popup-video-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 0;
    border-radius: 8px;
}

.posh-popup-video-box iframe,
.posh-popup-video-box video {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    background: #ffffff;
    z-index: 1;
}

/* YouTube Custom Thumbnail Styles */
.posh-popup-youtube-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
    z-index: 2;
}

.posh-popup-thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    /* Clip a few pixels to hide source-image edge artifacts (thin lines). */
    clip-path: inset(1px);
    background: #ffffff;
}

.posh-popup-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    transition: transform 0.2s ease;
}

.posh-popup-youtube-thumbnail:hover .posh-popup-play-button {
    transform: translate(-50%, -50%) scale(1.1);
}

/* Fills .posh-popup-video-box (already 16:9) */
.posh-popup-youtube-iframe-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    transform: none;
    overflow: hidden;
    border-radius: 8px;
    z-index: 1;
    background: #ffffff;
}

.posh-popup-youtube-iframe-wrapper iframe,
.posh-popup-youtube-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    background: #ffffff;
}

/* Override YouTube's black background (we can't change black inside iframe; this helps where visible) */
.posh-popup-video-box iframe[src*="youtube.com"],
.posh-popup-video-box iframe[src*="youtu.be"],
.posh-popup-youtube-iframe {
    background: #ffffff !important;
    /* Prevent YouTube hover UI from appearing over the video. */
    pointer-events: none;
}

/* Extra guard: media never spills past card (zoom / small viewports) */
.posh-popup-container .posh-popup-media-box {
    max-inline-size: 100%;
}

.posh-popup-container .posh-popup-media-shell {
    max-inline-size: 100%;
}

.posh-popup-container .posh-popup-image-box img {
    max-width: 100%;
    height: auto;
}

.posh-popup-card-button {
    padding: clamp(6px, 1.2vh, 10px) clamp(6px, 1.5vw, 10px) clamp(10px, 2vh, 16px);
    text-align: center;
    background: transparent;
    border-top: 0;
    flex-shrink: 0;
    margin-top: 0;
}

/* Dual column: push buttons to bottom of the shared row height (image vs video height mismatch) */
.posh-popup-content-grid > .posh-popup-content-card > .posh-popup-card-button {
    margin-top: auto;
}

.posh-popup-button {
    display: inline-block;
    background: #FFC65C;
    color: #1a1a1a;
    padding: clamp(8px, 1.8vh, 10px) clamp(14px, 4vw, 30px);
    border-radius: 8px;
    text-decoration: none;
    font-size: clamp(13px, 3.2vw, 16px);
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    border: none;
    cursor: pointer;
    letter-spacing: 0.2px;
    width: 100%;
    box-sizing: border-box;
}

.posh-popup-button:hover {
    background: #E8B54A;
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
    color: #1a1a1a;
}

/* Medium: tablet / small laptop — min-h must not use tiny vh on ~768px-tall screens */
@media (min-width: 721px) and (max-width: 1023px) {
    .posh-popup-overlay {
        --posh-overlay-inset: clamp(16px, 3vmin, 30px);
        --posh-wrap-pad-x: clamp(14px, 2.8vw, 22px);
        --posh-overlay-max-w: 800px;
        --posh-overlay-max-h: min(96vh, 1020px);
        --posh-overlay-min-h: min(68dvh, 720px);
        --posh-image-max-h: min(62vh, 580px);
        --posh-video-max-w: min(100%, 62vw, 480px);
        --posh-wrap-pad-top: clamp(12px, 2.5vh, 22px);
        --posh-wrap-pad-bottom: clamp(14px, 2.8vh, 24px);
    }

}

/* Laptop (1024–1399px) */
@media (min-width: 1024px) {
    .posh-popup-overlay {
        --posh-overlay-max-w: 960px;
        --posh-overlay-max-h: min(95vh, 1040px);
        --posh-overlay-min-h: min(54vh, 640px);
        --posh-image-max-h: min(63vh, 600px);
        --posh-video-max-w: min(100%, 560px, calc(54vh * 16 / 9));
    }
}

@media (min-width: 1400px) {
    .posh-popup-overlay {
        --posh-overlay-max-h: min(96vh, 1100px);
        --posh-overlay-min-h: min(56vh, 700px);
        --posh-image-max-h: min(65vh, 640px);
        --posh-video-max-w: min(100%, 600px, calc(56vh * 16 / 9));
    }
}

@media (min-width: 1920px) {
    .posh-popup-overlay {
        --posh-overlay-max-w: 1020px;
        --posh-overlay-max-h: min(96vh, 1160px);
        --posh-overlay-min-h: min(58vh, 740px);
        --posh-image-max-h: min(68vh, 680px);
        --posh-video-max-w: min(100%, 640px, calc(58vh * 16 / 9));
    }
}

/* Ultra-wide / 4K: fixed-ish footprint, not shorter than laptop tier */
@media (min-width: 2560px) {
    .posh-popup-overlay {
        --posh-overlay-max-w: 1120px;
        --posh-overlay-max-h: min(94vh, 1080px);
        --posh-overlay-min-h: 720px;
        --posh-image-max-h: 600px;
        --posh-video-max-w: 760px;
    }

    .posh-popup-container {
        width: min(1120px, calc(100vw - var(--posh-overlay-inset) * 2));
        max-width: min(1120px, calc(100vw - var(--posh-overlay-inset) * 2));
    }
}

/* Narrow / stacked — cap modal width vs viewport (was almost full-width on many phones) */
@media (max-width: 720px) {
    .posh-popup-overlay {
        --posh-overlay-inset: clamp(14px, 4.5vw, 24px);
        --posh-overlay-max-w: min(380px, calc(92vw - 20px));
        --posh-overlay-max-h: min(90vh, 720px);
        --posh-video-max-w: min(100%, 78vw, 272px);
        --posh-image-max-w: var(--posh-video-max-w);
        --posh-wrap-pad-x: clamp(12px, 4vw, 18px);
    }

    .posh-popup-content-single .posh-popup-content-card {
        max-width: 100%;
    }

    .posh-popup-content-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 480px) {
    .posh-popup-overlay {
        --posh-overlay-inset: clamp(12px, 5vw, 22px);
        --posh-overlay-max-w: min(336px, calc(94vw - 16px));
        --posh-overlay-max-h: min(92dvh, 680px);
        --posh-overlay-min-h: 0;
        --posh-video-max-w: min(100%, 82vw, 240px);
        --posh-image-max-w: var(--posh-video-max-w);
        --posh-image-max-h: min(40vh, 300px);
        --posh-wrap-pad-x: clamp(12px, 4.5vw, 16px);
        --posh-wrap-pad-bottom: clamp(12px, 3vh, 20px);
    }

    .posh-popup-container {
        border-radius: clamp(10px, 3vw, 18px);
    }

    .posh-popup-media-shell {
        min-height: min(var(--posh-media-shell-min-h), 68dvh);
    }
}

/* Small tablets (not phones — 481–768px) + roomier max height at zoom */
@media (min-width: 481px) and (max-width: 768px) {
    .posh-popup-overlay {
        --posh-overlay-max-h: min(94dvh, 760px);
    }
}

@media (max-width: 768px) {
    .posh-popup-title {
        font-size: clamp(15px, 4.2vw, 18px);
    }
}
