/* ========================================================================
   Shared Media Popup Module — thumb trigger + popup dialog
   Types: pdf (image carousel), video (HLS/Plyr), invitation (hover-scroll)
   ======================================================================== */

/* ---------- Thumb / trigger ---------- */

.mi-media-thumb {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border-radius: 12px;
}

.mi-media-thumb img {
    width: 100%;
    height: auto;
    display: block;
}

.mi-media-thumb--video img,
.mi-media-thumb--pdf img {
    aspect-ratio: 9/16;
    object-fit: cover;
}

.mi-media-thumb__play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.mi-media-thumb__play svg {
    width: 28px;
    height: 28px;
}

/* Hover-to-scroll screenshot (invitation type) */
.mi-media-thumb__scrollshot {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    width: 100%;
    height: 360px;
    background: #f4f4f4;
}

.mi-media-thumb__scrollshot-img {
    display: block;
    width: 100%;
    height: auto;
    transform: translateY(0);
    transition: transform linear var(--mi-scroll-duration, 4s);
    will-change: transform;
}

.mi-media-thumb__scrollshot:hover .mi-media-thumb__scrollshot-img,
.mi-media-thumb__scrollshot.is-scrolling .mi-media-thumb__scrollshot-img {
    transform: translateY(calc(-1 * var(--mi-scroll-distance, 0px)));
}

/* Single product page main image area — taller than the grid card variant */
.mi-media-thumb__scrollshot--single-product {
    height: 640px;
    max-height: 75vh;
}

@media (max-width: 768px) {
    .mi-media-thumb__scrollshot--single-product {
        height: 480px;
    }
}

/* ---------- Popup dialog ---------- */

.mi-media-popup {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow-y: auto;
}

.mi-media-popup.active {
    display: flex;
}

.mi-media-popup__dialog {
    position: relative;
    display: flex;
    align-items: center;
    width: 92%;
    max-width: 1040px;
    /* Fixed height (not content-driven) — the media pane's video/carousel/
       screenshot each load asynchronously at different times, so sizing the
       dialog off their natural content height caused a visible "grows then
       shrinks" reflow with the scrollbar flickering in and out as each
       settled. A fixed box means nothing after first paint changes the
       dialog's own size; only the content pane scrolls internally if needed. */
    height: min(640px, 90vh);
    max-height: 90vh;
    background: #fff;
    padding: 60px 30px 40px;
    border-radius: 10px;
    overflow: hidden;
    transition: max-width 0.15s ease;
}

/* PDF's multi-image carousel needs more room than a single video/scrollshot pane */
.mi-media-popup__dialog--pdf {
    max-width: 1220px;
    height: min(680px, 90vh);
}

.mi-media-popup__dialog--pdf .mi-media-popup__media {
    width: 62%;
}

.mi-media-popup__dialog--pdf .mi-media-popup__content {
    width: 38%;
}

/* Invitation-website popup has 3 CTAs (Use This Template / Preview / View
   More Details) — the default 45% content width wrapped the row to two
   lines. Give content pane more room, same reasoning as the pdf variant
   above just mirrored (extra width going to content, not media). */
.mi-media-popup__dialog--invitation {
    max-width: 1100px;
}

.mi-media-popup__dialog--invitation .mi-media-popup__media {
    width: 45%;
}

.mi-media-popup__dialog--invitation .mi-media-popup__content {
    width: 55%;
}

/* Video is portrait content in a landscape-shaped pane — a full 55% width
   pane exaggerates the letterboxing either side of the frame, so give it
   less width than the default pdf/invitation split. */
.mi-media-popup__dialog--video .mi-media-popup__media {
    width: 42%;
}

.mi-media-popup__dialog--video .mi-media-popup__content {
    width: 58%;
}

.mi-media-popup__close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #333;
    line-height: 28px;
    text-align: center;
    font-size: 18px;
    color: #333;
    cursor: pointer;
    z-index: 10001;
    background: #fff;
}

.mi-media-popup__close:hover {
    background: #f5f5f5;
}

.mi-media-popup__share {
    position: absolute;
    top: 12px;
    right: 56px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #FF7396;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #fff;
    color: #FF7396;
    cursor: pointer;
    z-index: 10001;
    transition: all 0.2s ease;
}

.mi-media-popup__share svg {
    display: block;
    width: 14px;
    height: 14px;
}

.mi-media-popup__share:hover,
.mi-media-popup__share:focus {
    background: #FF7396;
    color: #fff;
    transform: scale(1.1);
    outline: none;
}

/* Media pane (left, 55%) — only one .mi-media-popup__pane--{type} shown at a time.
   Fixed to the dialog's full height so the box never resizes as that pane's
   own content (video metadata, carousel images, screenshot) finishes loading. */
.mi-media-popup__media {
    width: 55%;
    height: 100%;
    flex-shrink: 0;
    overflow: hidden;
}

.mi-media-popup__pane {
    display: none;
    width: 100%;
    height: 100%;
}

.mi-media-popup__pane.is-active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mi-media-popup__carousel {
    position: relative;
    width: 100%;
    height: 100%;
}

.mi-media-popup__carousel .owl-stage-outer,
.mi-media-popup__carousel .owl-stage,
.mi-media-popup__carousel .owl-item {
    height: 100%;
}

.mi-media-popup__carousel .owl-item img {
    width: 100%;
    height: 100%;
    /* contain, not cover — this is a full card design (text near the edges),
       cropping it to fill the frame was cutting off content. The pane
       background shows around the letterboxed image instead of blank white. */
    object-fit: contain;
    border-radius: 10px;
    /* Browsers paint a broken/missing image's own box white by default,
       hiding the parent's gray placeholder behind it — set it here too so a
       404'd image still reads as "empty placeholder", not a blank white gap. */
    background: #fff;
}

.mi-media-popup__video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

.mi-media-popup__carousel-item {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 10px;
}

/* Pill dots (no nav arrows — owlCarousel is initialized with nav:false).
   Core owl.carousel.min.css only sets cursor/user-select on .owl-dot, no
   visible shape — the owl-theme skin that normally draws these isn't
   enqueued, so the dots need their own look here. */
.mi-media-popup__carousel .owl-dots {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
}

.mi-media-popup__carousel .owl-dot span {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.2);
    transition: width 0.2s ease, background 0.2s ease;
}

.mi-media-popup__carousel .owl-dot.active span {
    width: 20px;
    background: #FF7396;
}

/* Plyr wraps <video> in its own markup in-place inside the pane — stretch
   its wrappers too, otherwise only the raw <video> would honor height:100%.
   Background forced to white (not Plyr's default black letterbox) — plyr.css
   loads after ours, so !important is needed to actually win the cascade. */
.mi-media-popup__pane--video .plyr,
.mi-media-popup__pane--video .plyr__video-wrapper,
.mi-media-popup__pane--video .mi-media-popup__video {
    width: 100%;
    height: 100%;
    background: #fff !important;
}

.mi-media-popup__pane--invitation .mi-media-popup__scrollshot {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    background: #f4f4f4;
}

.mi-media-popup__scrollshot-img {
    display: block;
    width: 100%;
    height: auto;
    transform: translateY(0);
    transition: transform linear var(--mi-scroll-duration, 4s);
    will-change: transform;
}

.mi-media-popup__scrollshot:hover .mi-media-popup__scrollshot-img,
.mi-media-popup__scrollshot.is-scrolling .mi-media-popup__scrollshot-img {
    transform: translateY(calc(-1 * var(--mi-scroll-distance, 0px)));
}

/* Content pane (right, 45%) — scrolls internally if its own content (long
   title, all three CTAs, etc.) exceeds the fixed dialog height, rather than
   growing the dialog itself. */
.mi-media-popup__content {
    width: 45%;
    padding-left: 24px;
    padding-right: 4px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.mi-media-popup__title {
    font-size: 20px;
    font-weight: 600;
    color: #111;
    margin: 0 0 14px;
    line-height: 1.3;
}

.mi-media-popup__features {
    list-style: none;
    padding: 0;
    margin: 0 0 1px;
}

.mi-media-popup__features li {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #313131;
    margin-bottom: 6px;
}

.mi-media-popup__features li svg {
    margin-right: 6px;
    flex-shrink: 0;
}

.mi-media-popup__price {
    font-size: 1.3rem;
    font-weight: 700;
    color: #FF7396;
}

.mi-media-popup__content .live-counter {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

.mi-media-popup__content .button_section {
    margin-bottom: 12px;
}

.mi-media-popup__cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.mi-media-popup__cta-row .button_section {
    flex: 1 1 auto;
    min-width: 140px;
    margin-bottom: 0;
}

.mi-media-popup__cta-row .mi-media-popup__cta {
    padding: 12px 14px;
    font-size: 14px;
    white-space: nowrap;
    width: 100%;
}

.mi-media-popup__cta-row .mi-media-popup__cta.wvp-popup-cta-details{
    background: #fff;
    color: #FF7396;
    border: 1px solid #FF7396;
}
.mi-media-popup__cta-row .mi-media-popup__cta.wvp-popup-cta-details:hover{
    background: #FF7396;
    color: #fff;
}

.mi-media-popup__cta {
    display: block;
    text-align: center;
    padding: 12px 24px;
    border-radius: 200px;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    text-transform: uppercase;
    transition: background 0.2s, color 0.2s;
}

.mi-media-popup__cta--primary {
    background: #FF7396;
    color: #fff;
    border: 1px solid #FF7396;
}

.mi-media-popup__cta--primary:hover {
    background: #ff5a80;
    color: #fff;
}

.mi-media-popup__cta--secondary {
    background: #fff;
    color: #FF7396;
    border: 1px solid #FF7396;
}

.mi-media-popup__cta--secondary:hover {
    background: #fff5f8;
    color: #ff5a80;
}

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

@media (max-width: 1024px) {
    .mi-media-popup__dialog {
        width: 95%;
        padding: 50px 20px 30px;
    }
}

@media (max-width: 768px) {
    .mi-media-popup__dialog {
        flex-direction: column;
        width: 100%;
        height: auto;
        max-height: 93vh;
        overflow-y: auto;
        padding: 50px 16px 30px;
        border-radius: 0;
    }

    /* Stacked layout: media pane gets its own fixed height (reserved up
       front, same reasoning as desktop) instead of 100% of the dialog,
       which only makes sense in the desktop side-by-side layout. Content
       pane flows/scrolls with the dialog rather than internally. */
    .mi-media-popup__media,
    .mi-media-popup__dialog--pdf .mi-media-popup__media,
    .mi-media-popup__dialog--video .mi-media-popup__media,
    .mi-media-popup__dialog--invitation .mi-media-popup__media {
        width: 100%;
        height: 50vh;
        max-height: 450px;
    }

    .mi-media-popup__content,
    .mi-media-popup__dialog--pdf .mi-media-popup__content,
    .mi-media-popup__dialog--video .mi-media-popup__content,
    .mi-media-popup__dialog--invitation .mi-media-popup__content {
        width: 100%;
        height: auto;
        overflow-y: visible;
        padding-left: 0;
        padding-top: 16px;
    }

    /* Long product titles ("Formal Muslim Wedding Invitation — Digital
       E-Invite Template") ate too much of the limited mobile height —
       keep to a single line with an ellipsis instead of wrapping. */
    .mi-media-popup__title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mi-media-popup__cta-row {
        flex-wrap: wrap;
    }

    .mi-media-popup__cta-row .button_section {
        flex: 1 1 45%;
    }

    .mi-media-popup__cta-row .mi-media-popup__cta {
        white-space: normal;
    }
}

@media (max-width: 640px) {
    .mi-media-popup__title {
        font-size: 17px;
    }
      .mi-media-popup__cta-row .button_section {
        flex: 1 1 50%;
    }
}
