/* Product Gallery module (#1071) */
.bim-product-gallery {
    width: 100%;
}

/* Viewer */
.bim-gallery-viewer {
    position: relative;
    width: 100%;
    aspect-ratio: var(--bim-gallery-ratio, 16 / 9);
    background: #f3f4f6;
    border-radius: 8px;
    overflow: hidden;
}
/* Slow true crossfade: the outgoing slide keeps fading while the incoming
   one fades in above it (visibility is DELAYED until the fade completes —
   flipping it instantly is what caused the old flash). */
.bim-gallery-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease-in-out, visibility 0s linear 0.8s;
}
.bim-gallery-slide.is-active {
    opacity: 1;
    visibility: visible;
    z-index: 1;
    transition: opacity 0.8s ease-in-out, visibility 0s;
}
@media (prefers-reduced-motion: reduce) {
    .bim-gallery-slide {
        transition: none;
    }
}
.bim-gallery-slide[data-type="image"] {
    cursor: zoom-in;
}
.bim-gallery-slide-image,
.bim-gallery-slide[data-type="image"] img {
    width: 100%;
    height: 100%;
    object-fit: var(--bim-gallery-fit, cover);
    display: block;
}

/* Arrows — position is pinned !important: dealer themes commonly reset
   button:focus/:active to position:relative (0,1,1 beats a bare class),
   which teleports the button out from under the cursor mid-click, killing
   the click (viewer) or landing it on the backdrop (lightbox close bug). */
.bim-gallery-nav {
    position: absolute !important;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.55);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
}
.bim-gallery-viewer:hover .bim-gallery-nav,
.bim-gallery-nav:focus-visible {
    opacity: 1;
}
.bim-gallery-nav:hover {
    background: rgba(15, 23, 42, 0.8);
}
.bim-gallery-nav--prev { left: 12px; }
.bim-gallery-nav--next { right: 12px; }

/* Thumbnail strip — scrollbar hidden (still swipe/scrollable); frontend.js
   keeps the active thumb scrolled into view instead. position:relative so
   thumb offsetLeft is strip-relative for that reveal logic. */
.bim-gallery-thumbs {
    position: relative;
    display: flex;
    gap: 8px;
    margin-top: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.bim-gallery-thumbs::-webkit-scrollbar {
    display: none;
}
.bim-gallery-thumb {
    position: relative;
    flex: 0 0 auto;
    width: 88px;
    height: 66px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: #0b1220;
}
.bim-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.75;
    transition: opacity 0.2s ease;
}
.bim-gallery-thumb:hover img,
.bim-gallery-thumb.is-active img {
    opacity: 1;
}
.bim-gallery-thumb.is-active {
    border-color: #2563eb;
}
.bim-gallery-thumb-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

/* Lightbox */
.bim-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
}
.bim-gallery-lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.92);
}
.bim-gallery-lightbox-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}
.bim-gallery-lightbox-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 85vh;
}
.bim-gallery-lightbox-content img {
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}
.bim-gallery-lightbox-content .bim-video-embed {
    width: min(90vw, 1100px);
    aspect-ratio: 16 / 9;
    height: auto;
}
.bim-gallery-lightbox-close,
.bim-gallery-lightbox-prev,
.bim-gallery-lightbox-next {
    position: absolute !important; /* see the arrow pin note above */
    z-index: 2;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}
.bim-gallery-lightbox-close:hover,
.bim-gallery-lightbox-prev:hover,
.bim-gallery-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.28);
}
.bim-gallery-lightbox-close {
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    font-size: 26px;
    line-height: 1;
}
.bim-gallery-lightbox-prev,
.bim-gallery-lightbox-next {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    font-size: 18px;
}
.bim-gallery-lightbox-prev { left: 20px; }
.bim-gallery-lightbox-next { right: 20px; }
.bim-gallery-lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    letter-spacing: 0.04em;
}
body.bim-gallery-lightbox-open {
    overflow: hidden;
}

/* Mobile */
@media (max-width: 640px) {
    .bim-gallery-nav {
        opacity: 1;
        width: 34px;
        height: 34px;
    }
    .bim-gallery-thumb {
        width: 64px;
        height: 48px;
    }
    .bim-gallery-lightbox-container {
        padding: 12px;
    }
    .bim-gallery-lightbox-prev { left: 8px; }
    .bim-gallery-lightbox-next { right: 8px; }
}
