/**
 * WizAtom ProductMainImage — v2 CSS
 *
 * PDP / QuickView hero image with:
 *   - Primary media slide (image OR video) with slide-switch display
 *   - Hover magnifier lens (desktop only, gated by container :hover)
 *   - Mobile swipe + dot indicators
 *   - Overlay slots for tags + wishlist (same pattern as WizAtom_ProductImage)
 *
 * Layout-only CSS lives on the widget (widgets/v2/WizProductMainImage/style.css);
 * this file owns the atom surface — slides, images, magnifier, dots, overlays.
 */

/* ----------------------------------------------------------------
   Container
   ---------------------------------------------------------------- */
.wiz-main-image {
    --wiz-main-image-magnifier-size: 400px;
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    display: block;
}

.wiz-main-image__stage {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ----------------------------------------------------------------
   Slides (image + video)
   ---------------------------------------------------------------- */
.wiz-main-image__slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Active slide flips to position:relative so it sits in normal flow inside
   the stage — same contract images and videos have always relied on. The
   base position:absolute is for inactive slides (stacked, hidden via inline
   display:none). DO NOT change this back to absolute — image rendering
   depends on the slide being in flow so the <a class="wiz-main-image__media">
   inside it gets a measurable height to fill via height: 100%. */
.wiz-main-image__slide--active {
    position: relative;
    display: block !important;
}

.wiz-main-image__media {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: zoom-in;
}

.wiz-main-image__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

/* When lightbox is disabled, no zoom-in cursor */
.wiz-main-image[data-context="preview"] .wiz-main-image__media,
.wiz-main-image__media:not(.glightbox) {
    cursor: default;
}

/* ----------------------------------------------------------------
   Video slide

   Architecture mirrors the image slide exactly:
     .wiz-main-image__video-wrap = block container in normal flow
       (parallel to .wiz-main-image__media `<a>` link for images)
     .wiz-main-image__video      = absolute-positioned media that fills
       the wrap exactly via inset:0
       (parallel to .wiz-main-image__img inside the link)

   Why position:absolute on the <video>:
     The <video> element has intrinsic dimensions (poster image size,
     or 300×150 default) that flex/block layout would honor. With
     `position: absolute; inset: 0`, the video is REMOVED from intrinsic
     sizing concerns and forced to fill the wrap exactly — guarantees
     video height === image height, no overshoot regardless of poster
     aspect ratio.

   Native controls are intentionally NOT shown in the preview (the
   render omits the `controls` attribute). The expand-icon click opens
   GLightbox where native controls + fullscreen are available. Click
   on the video itself toggles play/pause via JS.
   ---------------------------------------------------------------- */
.wiz-main-image__video-wrap {
    position: relative;
    width: 100%;
    /* Two-tier height resolution:
       1. PRIMARY: `height: 100%` makes the wrap inherit the parent slide's
          actual height. When the slide has an explicit height (which it does
          in every normal layout — atom root has aspect-ratio + width=100%,
          stage = 100%, slide-active = 100% of stage), the wrap matches.
          THIS keeps the wrap responsive per-breakpoint: if QuickView mobile
          sets `.wiz-qv__main-image .wiz-main-image { aspect-ratio: 1/1 }`
          the slide is square, the wrap inherits.
       2. FALLBACK: `aspect-ratio: 1/1` only kicks in when `height: 100%`
          resolves to auto (parent has no explicit height — chain broken).
          When both width and height are explicit, browsers ignore
          aspect-ratio. So this is dormant in normal cases, active only
          as a safety net.
       Min-height ensures the wrap never collapses below the slide's height
       even if some browser quirk skips the aspect-ratio fallback. */
    height: 100%;
    min-height: 100%;
    aspect-ratio: 1 / 1;
    display: block;
    background: #000;
    overflow: hidden;
    cursor: pointer;            /* affordance for the JS play/pause click */
}

/* `!important` is intentional here — defeats inline `style="width:0..."`
   that hls.js / GLightbox / WP lazy-loaders sometimes inject onto <video>
   elements during init. Without these flags, the inline style wins by
   specificity and the video collapses to 0×0 → black screen on PDP. The
   runtime watchdog in product-main-image.js strips the inline attribute
   as a second line of defense. */
.wiz-main-image__video {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    object-position: center center;
    display: block !important;
    background: #000;
    margin: 0;
    padding: 0;
    min-width: 100%;
    min-height: 100%;
    max-width: 100%;
    max-height: 100%;
}

/* Zoom anchor wrapping the expand icon — sits on top of the video,
   doesn't intercept clicks on the video itself (the icon does). */
.wiz-main-image__video-zoom {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 3;
    display: none;              /* shown when the wrapper has is-lightbox-enabled */
    line-height: 0;
    text-decoration: none;
}

.wiz-main-image.is-lightbox-enabled .wiz-main-image__video-zoom {
    display: block;
}

/* The expand icon inside the zoom anchor reuses the same .__expand-icon
   class as images, so it inherits the existing 32×32 white-circle styling
   defined further down. We just override `position: absolute` to `static`
   here because the anchor is the positioned element in the video case. */
.wiz-main-image__video-zoom .wiz-main-image__expand-icon {
    position: static;
    bottom: auto;
    right: auto;
    display: flex;
}

/* ----------------------------------------------------------------
   Magnifier (hover zoom lens)
   ---------------------------------------------------------------- */
.wiz-main-image__magnifier {
    position: absolute;
    pointer-events: none;
    width: var(--wiz-main-image-magnifier-size);
    height: var(--wiz-main-image-magnifier-size);
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 50%;
    background-repeat: no-repeat;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    display: none;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
}

.wiz-main-image__magnifier.is-active {
    display: block;
    opacity: 1;
}

/* ----------------------------------------------------------------
   Lightbox expand icon (top-right of image when lightbox enabled)
   ---------------------------------------------------------------- */
.wiz-main-image__expand-icon {
    position: absolute;
    /* Bottom-right so it doesn't collide with the top-right wishlist icon
       (which is positioned by the WishlistIcon atom overlay rules below). */
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    /* pointer-events stay at default — the icon is inside the <a>, so
       clicks bubble to the GLightbox-bound anchor. `none` would work too
       but keeping default lets the icon show a hand cursor on hover. */
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    z-index: 2;
    color: #222;
}

/* Only surface the icon when lightbox is active on the container (opt-in via class
   set in JS when wizshop_settings.image_preview is true). */
.wiz-main-image.is-lightbox-enabled .wiz-main-image__expand-icon {
    display: flex;
}

/* Video lightbox trigger CSS removed — the render no longer emits this element
   for video slides. HTML5 <video controls> ships its own fullscreen button in
   the bottom-right; stacking a custom lightbox trigger on top of it produced a
   duplicate white circle and was visually confusing. Image slides retain
   .wiz-main-image__expand-icon for their own zoom affordance. */

/* ----------------------------------------------------------------
   Slide dots (shown on all breakpoints when multiple slides)
   ---------------------------------------------------------------- */
.wiz-main-image__dots {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
    z-index: 2;
    pointer-events: auto;
}

.wiz-main-image__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: width 0.2s ease, background-color 0.2s ease;
}

.wiz-main-image__dot--active {
    width: 20px;
    border-radius: 4px;
    background-color: #111111;
}

/* Hide dots on very large desktops where thumbnail carousel will be present */
@media (min-width: 1025px) {
    .wiz-main-image__dots {
        display: none;
    }
}

/* ----------------------------------------------------------------
   Overlay positioning for tags + wishlist
   Relies on .wiz-tags--positioned and .wiz-wishlist positioning
   conventions already set by those atoms.
   ---------------------------------------------------------------- */
.wiz-main-image .wiz-tags--positioned {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
}

.wiz-main-image .wiz-wishlist {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
}

.wiz-main-image .wiz-wishlist--top-left {
    left: 12px;
    right: auto;
}

/* ----------------------------------------------------------------
   Lightbox toolbar (ported from v1 product-image widget)
   Scoped to the `.wiz-main-image__lb` class that the atom JS adds to
   `.glightbox-container` on open — so v1 and v2 lightboxes can coexist.
   ---------------------------------------------------------------- */
.glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn {
    position: absolute;
    top: 20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: none;
    border-radius: 4px;
    color: #111;
    cursor: pointer;
    z-index: 10000;
    padding: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: background 0.2s ease;
}

.glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn:hover {
    background: #f3f4f6;
}

.glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn--zoom-out  { right: 210px; }
.glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn--zoom-in   { right: 160px; }
.glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn--download  { right: 110px; }
.glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn--fullscreen{ right: 60px; }

/* Collapse the toolbar when Download is hidden on video slides. */
.glightbox-container.wiz-main-image__lb.wiz-main-image__lb--no-download .wiz-main-image__lb-btn--zoom-out { right: 160px; }
.glightbox-container.wiz-main-image__lb.wiz-main-image__lb--no-download .wiz-main-image__lb-btn--zoom-in  { right: 110px; }

/* Move close to top-left (matches v1 placement in the screenshot). */
.glightbox-container.wiz-main-image__lb .gclose {
    top: 22px !important;
    left: 30px !important;
    right: auto !important;
}
.glightbox-container.wiz-main-image__lb .gclose svg {
    min-height: 14px !important;
}

/* Force the close + chevron icons white. GLightbox's stock CSS only colors
   paths carrying the `.garrow` class, so any other SVG child (incl. the
   close "X") inherits the document text colour and vanishes on the dark
   backdrop. Targeting `svg *` is the least-surprising fix. */
.glightbox-container.wiz-main-image__lb .gclose svg *,
.glightbox-container.wiz-main-image__lb .gprev svg *,
.glightbox-container.wiz-main-image__lb .gnext svg * {
    stroke: #ffffff !important;
}

/* Let zoom transform extend beyond the slide overflow boundary. */
.glightbox-container.wiz-main-image__lb .gslide.current .gslide-media {
    overflow: visible;
}

/* Hide the toolbar's Download button on video slides (class toggled by JS).
   The `display:none` is set inline by JS on the button itself; this is a
   defensive fallback for the button when inline style hasn't landed yet. */
.glightbox-container.wiz-main-image__lb--no-download .wiz-main-image__lb-btn--download {
    display: none;
}

/* ----------------------------------------------------------------
   Mobile
   ---------------------------------------------------------------- */
@media (max-width: 767px) {
    .wiz-main-image__magnifier {
        display: none !important; /* no hover → no magnifier on touch devices */
    }

    .wiz-main-image__expand-icon {
        bottom: 10px;
        right: 10px;
        width: 28px;
        height: 28px;
    }

    /* Compact toolbar on mobile — smaller buttons, tighter spacing. */
    .glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn {
        width: 36px;
        height: 36px;
        top: 12px;
    }
    .glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn--zoom-out  { right: 170px; }
    .glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn--zoom-in   { right: 128px; }
    .glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn--download  { right: 86px; }
    .glightbox-container.wiz-main-image__lb .wiz-main-image__lb-btn--fullscreen{ right: 44px; }
    .glightbox-container.wiz-main-image__lb.wiz-main-image__lb--no-download .wiz-main-image__lb-btn--zoom-out { right: 128px; }
    .glightbox-container.wiz-main-image__lb.wiz-main-image__lb--no-download .wiz-main-image__lb-btn--zoom-in  { right: 86px; }

    .glightbox-container.wiz-main-image__lb .gclose {
        top: 14px !important;
        left: 14px !important;
    }
}
