/* ==========================================================================
   Slider des vignettes de la galerie produit (Phlox + flexslider WooCommerce)
   Remplace la grille Phlox (li en float, 25%) par une rangée défilante.
   ========================================================================== */

.single-product .images .dsp-thumbs {
    --dsp-gap: 8px;
    --dsp-cols: 4;
    --dsp-accent: #D0187D; /* magenta de la page d'accueil */
    position: relative;
    margin-top: 10px;
}

.single-product .images .flex-control-thumbs {
    position: relative; /* offsetLeft des li calculé par rapport à la liste */
    display: flex;
    flex-wrap: nowrap;
    gap: var(--dsp-gap);
    margin: 10px 0 0;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.single-product .images .dsp-thumbs .flex-control-thumbs {
    margin-top: 0;
}

.single-product .images .flex-control-thumbs::-webkit-scrollbar {
    display: none;
}

.single-product .images .flex-control-thumbs li {
    flex: 0 0 calc((100% - (var(--dsp-cols) - 1) * var(--dsp-gap)) / var(--dsp-cols));
    width: auto;
    float: none;
    margin: 0;
    scroll-snap-align: start;
}

.single-product .images .flex-control-thumbs li img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    box-sizing: border-box;
    border: 2px solid transparent;
    border-radius: 14px;
    background: #F5F5F5;
    opacity: .7;
    transition: opacity .2s ease, border-color .2s ease;
}

.single-product .images .flex-control-thumbs li img.flex-active,
.single-product .images .flex-control-thumbs li img:hover {
    opacity: 1;
}

.single-product .images .flex-control-thumbs li img.flex-active {
    border-color: var(--dsp-accent);
}

/* Flèches */
.single-product .images .dsp-thumbs__nav {
    position: absolute;
    top: 50%;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
    color: #333;
    cursor: pointer;
    transform: translateY(-50%);
    transition: opacity .2s ease, background-color .2s ease, color .2s ease;
}

.single-product .images .dsp-thumbs__nav:hover,
.single-product .images .dsp-thumbs__nav:focus-visible {
    background: var(--dsp-accent);
    color: #fff;
    outline: none;
}

.single-product .images .dsp-thumbs__nav svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.single-product .images .dsp-thumbs__nav--prev { left: 6px; }
.single-product .images .dsp-thumbs__nav--next { right: 6px; }

.single-product .images .dsp-thumbs__nav[disabled] {
    opacity: 0;
    pointer-events: none;
}

/* --- Avant le démarrage du diaporama (évite que la page saute) -------------
   Sans ça, toutes les photos s'empilent quelques secondes et poussent le reste
   de la page vers le bas. */
.single-product .woocommerce-product-gallery:not(:has(.flex-viewport)) .woocommerce-product-gallery__image:nth-child(n+2) {
    display: none;
}
/* Pendant l'initialisation, flexslider agrandit énormément les images : on garde
   l'image principale carrée tant qu'il n'a pas fixé la hauteur. */
.single-product .woocommerce-product-gallery .flex-viewport:not([style*="height"]) {
    aspect-ratio: 1 / 1;
    overflow: hidden;
}
/* Place réservée pour la rangée de vignettes (10px + 1 vignette carrée) */
.single-product .woocommerce-product-gallery:has(.woocommerce-product-gallery__image:nth-child(2)):not(:has(.flex-control-thumbs))::after {
    content: "";
    display: block;
    padding-top: calc((100% - 3 * 8px) / 4 + 10px);
}

@media (max-width: 767px) {
    .single-product .images .dsp-thumbs {
        --dsp-cols: 3;
    }
    .single-product .woocommerce-product-gallery:has(.woocommerce-product-gallery__image:nth-child(2)):not(:has(.flex-control-thumbs))::after {
        padding-top: calc((100% - 2 * 8px) / 3 + 10px);
    }
}
