/**
 * BW Product Gallery.
 *
 * Defaults are kept at the same weight as the CSS Elementor generates from the
 * widget's controls (.elementor-element-N .bw-pg-x), so controls win on source
 * order rather than being locked out.
 */

.elementor-widget-bw-product-gallery {
    --bw-blue: #005eb8;
    --bw-blue-dk: #00427f;
    --bw-orange: #f28120;
    --bw-ink: #101720;
    --bw-mute: #8a95a1;
    --bw-line: #e2e6ea;
    --bw-soft: #f7f9fb;
}

.elementor-widget-bw-product-gallery * {
    box-sizing: border-box;
}

.elementor-widget-bw-product-gallery .bw-pg {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* --------------------------------------------------------------- stage --- */
.elementor-widget-bw-product-gallery .bw-pg-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 460px;
    padding: 18px;
    border: 1px solid var(--bw-line);
    border-radius: 14px;
    background: var(--bw-soft);
    overflow: hidden;
}

.elementor-widget-bw-product-gallery .bw-pg-stage.is-zoomable {
    cursor: zoom-in;
}

.elementor-widget-bw-product-gallery .bw-pg-stage-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    /* product shots are photographed on white, so multiply hides the box seam */
    mix-blend-mode: multiply;
}

/* video fills the stage edge to edge — the padding that frames a product shot
   just letterboxes an embed */
.elementor-widget-bw-product-gallery .bw-pg-stage-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
    display: block;
}

.elementor-widget-bw-product-gallery .bw-pg-noimg {
    font: 700 10px/1 'Open Sans', Arial, sans-serif;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--bw-mute);
}

/* ------------------------------------------------------------ thumbs --- */
.elementor-widget-bw-product-gallery .bw-pg-thumbs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.elementor-widget-bw-product-gallery .bw-pg-thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    padding: 6px;
    margin: 0;
    border: 1px solid var(--bw-line);
    border-radius: 9px;
    background: var(--bw-soft);
    cursor: pointer;
    overflow: hidden;
    transition: border-color .15s ease;
}

.elementor-widget-bw-product-gallery .bw-pg-thumb:hover {
    border-color: #cfd8e3;
}

.elementor-widget-bw-product-gallery .bw-pg-thumb.is-active {
    border-color: var(--bw-blue);
    box-shadow: inset 0 0 0 1px var(--bw-blue);
}

.elementor-widget-bw-product-gallery .bw-pg-thumb:focus-visible {
    outline: 2px solid var(--bw-orange);
    outline-offset: 2px;
}

.elementor-widget-bw-product-gallery .bw-pg-thumb img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    mix-blend-mode: multiply;
}

.elementor-widget-bw-product-gallery .bw-pg-play {
    position: absolute;
    right: 5px;
    bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bw-blue);
    color: #fff;
    /* the thumbnail image uses multiply; without this the badge blends away */
    mix-blend-mode: normal;
}

.elementor-widget-bw-product-gallery .bw-pg-play svg {
    display: block;
    margin-left: 1px;
}

/* the 3D badge carries a short label instead of a glyph, so it is a pill */
.elementor-widget-bw-product-gallery .bw-pg-play.is-model {
    width: auto;
    min-width: 20px;
    padding: 0 7px;
    border-radius: 999px;
    font: 800 9px/20px 'Open Sans', Arial, sans-serif;
    letter-spacing: .8px;
    text-transform: uppercase;
}

/* ---------------------------------------------------- thumbs on the left --
 * The prefix_class control writes bw-pg-thumbs-left / -bottom onto the widget
 * wrapper, and the responsive variants add -tablet- / -mobile-.            */
.bw-pg-thumbs-left .bw-pg,
.bw-pg-thumbs-tablet-left .bw-pg,
.bw-pg-thumbs-mobile-left .bw-pg {
    flex-direction: row-reverse;
    align-items: stretch;
}

.bw-pg-thumbs-left .bw-pg-stage,
.bw-pg-thumbs-tablet-left .bw-pg-stage,
.bw-pg-thumbs-mobile-left .bw-pg-stage {
    flex: 1 1 auto;
    min-width: 0;
}

.bw-pg-thumbs-left .bw-pg-thumbs,
.bw-pg-thumbs-tablet-left .bw-pg-thumbs,
.bw-pg-thumbs-mobile-left .bw-pg-thumbs {
    flex: 0 0 84px;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
}

/* --------------------------------------------------------- overlay --- */
/* Appended to <body>, so these selectors are unscoped by necessity. */
body.bw-pg-locked {
    overflow: hidden;
}

.bw-pg-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5vmin;
    background: rgba(16, 23, 32, .92);
}

/* The overlay is built once and reused, so it spends most of its life
   hidden. Astra sets `display` on some elements hard enough to defeat the
   [hidden] attribute, hence the explicit rule. */
.bw-pg-overlay[hidden],
.bw-pg-overlay-slot[hidden],
.bw-pg-overlay-frame[hidden] {
    display: none !important;
}

.bw-pg-overlay-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    /* flex items default to min-height/min-width auto, which refuses to
       shrink below the content's intrinsic size — that is what let a tall
       image push past the viewport */
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
}

/* Video wants a fixed 16:9 box; a photo should stay its own shape. */
.bw-pg-overlay-frame.is-video {
    width: min(1100px, 100%);
    aspect-ratio: 16 / 9;
}

/* The 3D viewer's own slot, beside the media frame rather than inside it, so
   showing a photo can empty the frame without touching the viewer's DOM.
   It wants as much room as it can get — orbiting a pump in a letterboxed
   strip is miserable. */
.bw-pg-overlay-slot {
    width: min(1400px, 100%);
    height: calc(100vh - 10vmin);
}

.bw-pg-overlay-slot model-viewer,
.bw-pg-overlay-slot .model-viewer {
    width: 100%;
    height: 100%;
    display: block;
    background: #fff;
    border-radius: 8px;
}

/* The viewer is moved out of here into the overlay at init, so after page
   load this is empty and has nothing to show. */
.elementor-widget-bw-product-gallery .bw-pg-model-src {
    display: none;
}

/* Sized against the viewport, not the parent. `max-height: 100%` was
   resolving to `none` here: the frame has auto height, and a percentage
   max-height against an auto-height parent is ignored — so a portrait image
   rendered at full resolution and ran off the top and bottom of the screen.
   The 10vmin matches the overlay's 5vmin of padding on each side. */
.bw-pg-overlay-img {
    max-width: min(100%, calc(100vw - 10vmin));
    max-height: calc(100vh - 10vmin);
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    background: #fff;
    border-radius: 8px;
}

.bw-pg-overlay-video {
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 10vmin);
    display: block;
    border: 0;
    border-radius: 8px;
    background: #000;
}

/* These live on <body>, outside the widget wrapper, so the theme's own
   `button` rules reach them. Its padding stretched the close button into an
   ellipse and pushed the arrow glyphs off-centre — hence the explicit reset
   plus box-sizing and flex:none so the declared size is the final size. */
.bw-pg-overlay-close,
.bw-pg-overlay-nav {
    position: absolute;
    box-sizing: border-box;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0;
    border: 0;
    background: rgba(255, 255, 255, .12) !important;
    color: #fff !important;
    cursor: pointer;
    line-height: 0;
    transition: background .15s ease;
}

/* The theme paints button :hover and :focus orange. These controls sit on
   <body>, outside any widget wrapper, so those rules reach them and were
   turning the close button into an orange disc the moment it took focus —
   which it does on open. Forced for the same reason the padding is. */
.bw-pg-overlay-close:hover,
.bw-pg-overlay-nav:hover,
.bw-pg-overlay-close:focus,
.bw-pg-overlay-nav:focus,
.bw-pg-overlay-close:active,
.bw-pg-overlay-nav:active {
    background: rgba(255, 255, 255, .26) !important;
    color: #fff !important;
}

.bw-pg-overlay-close svg,
.bw-pg-overlay-nav svg {
    display: block;
}

.bw-pg-overlay-close:hover,
.bw-pg-overlay-nav:hover {
    background: rgba(255, 255, 255, .24);
}

/* Keyboard users still get a visible ring; mouse users do not, which is why
   this is :focus-visible and the rule above is plain :focus. */
.bw-pg-overlay-close:focus-visible,
.bw-pg-overlay-nav:focus-visible {
    outline: 2px solid #f28120;
    outline-offset: 2px;
}

.bw-pg-overlay-close {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
}

.bw-pg-overlay-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 64px;
    min-width: 48px;
    border-radius: 10px;
}

.bw-pg-overlay-nav.is-prev { left: 16px; }
.bw-pg-overlay-nav.is-next { right: 16px; }

/* ------------------------------------------------------- responsive --- */
@media (max-width: 767px) {
    .elementor-widget-bw-product-gallery .bw-pg-stage {
        height: 320px;
        padding: 12px;
    }

    /* a 84px rail eats too much of a phone screen — stack regardless */
    .bw-pg-thumbs-left .bw-pg,
    .bw-pg-thumbs-tablet-left .bw-pg {
        flex-direction: column;
    }

    .bw-pg-thumbs-left .bw-pg-thumbs,
    .bw-pg-thumbs-tablet-left .bw-pg-thumbs {
        flex: none;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .bw-pg-overlay-nav {
        width: 40px;
        height: 52px;
    }
}
