/* Productgalerij: vast 3:2 blok, thumbnails en fullscreen popup
---------------------------------------------------------------------------- */
.ds-gallery {
    position: relative;
}

@media (min-width: 800px) {
    .woocommerce div.product div.ds-gallery {
        width: 64%;
        margin-right: 3%;
    }
}

.ds-gallery__stage,
.ds-lightbox__stage {
    position: relative;
}

/* Horizontale scroll-snap slider: native swipe op mobiel, geen library nodig */
.ds-gallery__track {
    display: flex;
    /* Witte tussenruimte: afrondingsverschillen tonen wit in plaats van een randje van de buurslide */
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}
.ds-gallery__track::-webkit-scrollbar {
    display: none;
}

.ds-gallery__slide,
.ds-lightbox__slide {
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

/* Vaste hoogte: elk beeld past binnen hetzelfde 3:2 blok, de breedte mag verschillen */
.ds-gallery__open {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;
    padding: 0;
    border: 0;
    background: #fff;
    cursor: zoom-in;
}

.woocommerce div.product div.images img.ds-gallery__img,
.ds-gallery__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Pijlen */
.ds-gallery__arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 8px 0 rgba(0, 0, 0, .2);
    transform: translateY(-50%);
    cursor: pointer;
    transition: opacity .15s linear;
}
.ds-gallery__arrow::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border: solid #292948;
    border-width: 0 2px 2px 0;
    transform: translate(-65%, -50%) rotate(-45deg);
}
.ds-gallery__arrow--prev {
    left: 10px;
}
.ds-gallery__arrow--prev::before {
    transform: translate(-35%, -50%) rotate(135deg);
}
.ds-gallery__arrow--next {
    right: 10px;
}
.ds-gallery__arrow:disabled {
    opacity: 0;
    pointer-events: none;
}

/* Teller op de pagina: alleen op mobiel, waar de pijlen verborgen zijn */
.ds-gallery__counter {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(41, 41, 72, .7);
    color: #fff;
    font-size: 12px;
    pointer-events: none;
}

/* Mobiel: kleinere pijlen (zoals Coolblue) en kleinere labels op de foto */
@media (max-width: 799px) {
    .ds-gallery__stage .ds-gallery__arrow {
        width: 34px;
        height: 34px;
    }
    .ds-gallery__stage .ds-gallery__arrow::before {
        width: 8px;
        height: 8px;
    }
    .ds-gallery__stage .ds-gallery__arrow--prev {
        left: 6px;
    }
    .ds-gallery__stage .ds-gallery__arrow--next {
        right: 6px;
    }

    .woocommerce .type-product .ds-gallery .onsale {
        margin: 8px !important;
        padding: 3px 8px !important;
        font-size: 10px;
    }
    /* Kenmerklabel ("Tegen nekpijn", "Warm dekbed") op mobiel niet over de foto */
    .ds-gallery .temp-duvet {
        display: none;
    }
}
@media (min-width: 800px) {
    .ds-gallery__counter {
        display: none;
    }
}

/* Play-knop over video-afbeeldingen */
.ds-gallery__play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 68px;
    height: 48px;
    border-radius: 12px;
    background: rgba(0, 0, 0, .75);
    transform: translate(-50%, -50%);
}
.ds-gallery__play::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    border-style: solid;
    border-width: 10px 0 10px 17px;
    border-color: transparent transparent transparent #fff;
    transform: translate(-40%, -50%);
}

/* Thumbnails */
.ds-gallery__thumbs {
    position: relative;
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding: 2px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.ds-gallery__thumb {
    position: relative;
    flex: 0 0 72px;
    aspect-ratio: 1;
    padding: 4px;
    border: 1px solid #cbcbcb;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
}
.ds-gallery__thumb.is-active {
    border-color: #292948;
    box-shadow: inset 0 0 0 1px #292948;
}
.woocommerce div.product div.images .ds-gallery__thumb img,
.ds-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.ds-gallery__thumb--video::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    border-style: solid;
    border-width: 7px 0 7px 12px;
    border-color: transparent transparent transparent #fff;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, .8));
    transform: translate(-40%, -50%);
}

/* Thumbnails op de pagina: vaste rij zonder scrollen, de laatste wordt "+N" (zoals Coolblue).
   Aantal kolommen moet overeenkomen met DS_GALLERY_THUMBS_DESKTOP/_MOBILE in product-gallery.php. */
.ds-gallery > .ds-gallery__thumbs {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    overflow: visible;
}
.ds-gallery > .ds-gallery__thumbs .ds-gallery__thumb:nth-child(n+9) {
    display: none;
}

.ds-gallery__more {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    background: rgba(41, 41, 72, .8);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}

@media (min-width: 800px) {
    .ds-gallery__more--desktop {
        display: flex;
    }
}

@media (max-width: 799px) {
    .ds-gallery > .ds-gallery__thumbs {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
    .ds-gallery > .ds-gallery__thumbs .ds-gallery__thumb:nth-child(n+6) {
        display: none;
    }
    .ds-gallery__more--mobile {
        display: flex;
    }
}

/* Algemene button:hover/focus-stijlen van het theme (groene achtergrond, rand 0) hier niet toepassen */
.ds-gallery .ds-gallery__open:hover,
.ds-gallery .ds-gallery__open:focus,
.ds-gallery .ds-gallery__arrow:hover,
.ds-gallery .ds-gallery__arrow:focus {
    background-color: #fff;
    color: inherit;
}
.ds-gallery .ds-gallery__thumb:hover,
.ds-gallery .ds-gallery__thumb:focus {
    border-width: 1px;
    background-color: #fff;
    color: inherit;
}
.ds-gallery .ds-gallery__thumb:hover {
    border-color: #292948;
}
.ds-gallery .ds-lightbox__close:hover,
.ds-gallery .ds-lightbox__close:focus,
.ds-gallery .ds-lightbox__video:hover,
.ds-gallery .ds-lightbox__video:focus {
    background: none;
    color: inherit;
}
.ds-gallery .ds-gallery__arrow:hover {
    box-shadow: 0 0 12px 0 rgba(0, 0, 0, .3);
}
.ds-gallery button:focus {
    outline: none;
}
.ds-gallery button:focus-visible {
    outline: 2px solid #292948;
    outline-offset: 2px;
}

/* Popup
---------------------------------------------------------------------------- */
html:has(.ds-lightbox[open]) {
    overflow: hidden;
}

.ds-lightbox {
    width: min(1100px, 100vw - 40px);
    max-width: none;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: #fff;
    color: #292948;
}
.ds-lightbox::backdrop {
    background: rgba(41, 41, 72, .7);
}
.ds-lightbox[open] {
    animation: ds-lightbox-in .2s ease-out;
}
@keyframes ds-lightbox-in {
    from { opacity: 0; transform: scale(.97); }
}

.ds-lightbox__inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 20px 20px;
}

.ds-lightbox__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.ds-lightbox__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

.ds-lightbox__close {
    position: relative;
    flex: 0 0 40px;
    height: 40px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}
.ds-lightbox__close::before,
.ds-lightbox__close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 2px;
    background: #292948;
    transform: translate(-50%, -50%) rotate(45deg);
}
.ds-lightbox__close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* Zelfde vaste blok in de popup, zo hoog als het scherm toelaat */
.ds-lightbox__slide {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: min(66vh, (min(1100px, 100vw - 40px) - 40px) * 2 / 3);
}

.woocommerce div.product div.images img.ds-lightbox__img,
.ds-lightbox__img,
.ds-lightbox__video {
    width: 100%;
    height: 100%;
}
.woocommerce div.product div.images img.ds-lightbox__img,
.ds-lightbox__img {
    object-fit: contain;
}

.ds-lightbox__video {
    position: relative;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

.ds-lightbox__slide .ds-gallery__iframe {
    width: 100%;
    height: auto;
    max-height: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
}

.ds-lightbox__counter {
    margin: 0;
    text-align: center;
    font-size: 15px;
}

.ds-lightbox .ds-gallery__thumbs {
    justify-content: safe center;
    margin-top: 0;
}

@media (min-width: 800px) {
    .ds-lightbox__counter {
        display: none;
    }
    .ds-lightbox .ds-gallery__arrow--prev {
        left: 0;
    }
    .ds-lightbox .ds-gallery__arrow--next {
        right: 0;
    }
}

/* Mobiel: popup schermvullend, zoals in een app */
@media (max-width: 799px) {
    .ds-lightbox {
        width: 100vw;
        height: 100dvh;
        max-height: none;
        margin: 0;
        border-radius: 0;
    }
    .ds-lightbox__inner {
        height: 100%;
        padding: 0 0 16px;
    }
    .ds-lightbox__header {
        padding: 12px 16px;
        background: #292948;
        color: #fff;
    }
    .ds-lightbox__close::before,
    .ds-lightbox__close::after {
        background: #fff;
    }
    .ds-lightbox__stage {
        flex: 1;
        display: flex;
        min-height: 0;
    }
    .ds-lightbox__stage .ds-gallery__track {
        flex: 1;
    }
    .ds-lightbox__slide {
        height: auto;
        padding: 0 16px;
    }
    .ds-lightbox__stage .ds-gallery__arrow {
        display: none;
    }
    .ds-lightbox .ds-gallery__thumbs {
        justify-content: flex-start;
        padding: 2px 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ds-lightbox[open] {
        animation: none;
    }
}
