/* ============================================================
   WC Smart Gallery — styles v1.4.0
   Image principale en haut, bande de vignettes en dessous.
   La vignette de l'image active est masquée.
   ============================================================ */

/* ---------- Wrapper ---------- */
.wcsg-wrapper {
    --wcsg-max-h:          800px;  /* hauteur maximale de l'image principale */
    --wcsg-thumb-visible:  5;      /* nb de vignettes visibles avant scroll  */
    --wcsg-gap:            8px;
    --wcsg-transition:     0.7s ease;
    --wcsg-radius:         4px;

    /* Largeur d'une vignette pour qu'il en tienne exactement N sur la ligne.
       flex-grow comble la largeur s'il y en a moins (4, 3, …). */
    --wcsg-thumb-basis: calc(
        (100% - (var(--wcsg-thumb-visible) - 1) * var(--wcsg-gap))
        / var(--wcsg-thumb-visible)
    );

    display: flex;
    flex-direction: column;
    gap: var(--wcsg-gap);

    /* Pleine largeur, zéro padding/margin forcé */
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

/* ---------- Main image area ---------- */
.wcsg-main {
    position: relative;
    overflow: hidden;
    border-radius: var(--wcsg-radius);
    background: #f5f5f5;
    width: 100%;
    aspect-ratio: 1 / 1;        /* carré tant que la largeur ≤ hauteur max */
    max-height: var(--wcsg-max-h);
}

.wcsg-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity var(--wcsg-transition);
    pointer-events: none;
}
.wcsg-slide.is-active {
    opacity: 1;
    pointer-events: auto;
}
.wcsg-slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Curseur zoom sur l'image active */
.wcsg-slide.is-active img { cursor: zoom-in; }

/* ---------- Thumbnails (bande horizontale sous l'image) ---------- */
.wcsg-thumbs {
    display: flex;
    gap: var(--wcsg-gap);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none; /* Firefox */
    cursor: grab;
}
.wcsg-thumbs::-webkit-scrollbar { display: none; }
.wcsg-thumbs.is-dragging { cursor: grabbing; }

.wcsg-thumb {
    /* Taille fixe « 5 par ligne » dans tous les cas : pas d'agrandissement pour combler.
       grow:0 → ne grandit pas s'il y en a moins de 5 ; shrink:0 → scroll s'il y en a plus. */
    flex: 0 0 var(--wcsg-thumb-basis);
    cursor: pointer;
    border-radius: var(--wcsg-radius);
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s ease, opacity 0.2s ease;
    opacity: 0.65;
    outline: none;
    box-sizing: border-box;
    aspect-ratio: 1 / 1;        /* carré */
}
.wcsg-thumbs.is-dragging .wcsg-thumb { pointer-events: none; }
.wcsg-thumb:hover { opacity: 1; }
.wcsg-thumb:focus-visible {
    border-color: #0073aa;
    opacity: 1;
}
.wcsg-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* La vignette de l'image actuellement affichée est masquée ;
   la bande se resserre automatiquement (flex). */
.wcsg-thumb.is-active { display: none; }

/* ---------- Lightbox ---------- */
.wcsg-lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.88);
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.wcsg-lightbox-overlay.is-open { display: flex; }

.wcsg-lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    cursor: default;
    transition: opacity 0.2s ease;
}
.wcsg-lightbox-img.is-loading {
    opacity: 0;
}

.wcsg-lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease;
}
.wcsg-lightbox-close:hover { background: rgba(255,255,255,0.3); }

.wcsg-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    /* z-index au-dessus de l'image agrandie + !important pour passer devant les styles du thème */
    z-index: 100000 !important;
    background: #fff !important;
    border: 1px solid rgba(255,255,255,0.3);
    color: #111 !important;
    font-size: 1.4rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    transition: background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.wcsg-lightbox-nav:hover:not(:disabled) {
    background: #f0f0f0;
    box-shadow: 0 3px 12px rgba(0,0,0,0.45);
}
.wcsg-lightbox-nav:disabled {
    opacity: 0.25;
    cursor: default;
    box-shadow: none;
}
.wcsg-lightbox-nav svg {
    display: block;
    width: 22px;
    height: 22px;
    pointer-events: none;
}
.wcsg-lightbox-prev { left: 20px; }
.wcsg-lightbox-next { right: 20px; }

@media (max-width: 600px) {
    .wcsg-lightbox-prev { left: 8px; }
    .wcsg-lightbox-next { right: 8px; }
}

/* ============================================================
   MOBILE  (≤ 767px) — image plein écran + swipe + flèches
   ============================================================ */
@media (max-width: 767px) {
    .wcsg-main {
        touch-action: pan-y;
    }

    .wcsg-slide {
        position: absolute;
        inset: 0;
        opacity: 0;
        transform: translateX(100%);
        transition: opacity var(--wcsg-transition), transform var(--wcsg-transition);
    }
    .wcsg-slide.is-active {
        opacity: 1;
        transform: translateX(0);
    }
    .wcsg-slide.is-leaving-left {
        opacity: 0;
        transform: translateX(-100%);
    }
    .wcsg-slide.is-leaving-right {
        opacity: 0;
        transform: translateX(100%);
    }
    /* Pré-position du slide entrant pour direction 'prev' (vient de la gauche) */
    .wcsg-slide.is-entering-from-left {
        opacity: 0;
        transform: translateX(-100%);
        transition: none;
    }

}

/* ---------- Flèches de navigation (bulles blanches, flèches noires) ---------- */
/* Visibles sur desktop ET mobile, par-dessus l'image principale. */
.wcsg-arrow {
    /* !important : empêche Elementor d'écraser le style des boutons. */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: #fff !important;
    border: none !important;
    border-radius: 50% !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 0 !important;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25) !important;
    color: #111 !important;
    padding: 0 !important;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}
.wcsg-arrow:hover:not(:disabled) {
    background: #f0f0f0 !important;
    box-shadow: 0 3px 12px rgba(0,0,0,0.35) !important;
}
.wcsg-arrow svg {
    display: block;
    width: 22px;
    height: 22px;
    pointer-events: none;
}
.wcsg-arrow-prev { left: 10px; }
.wcsg-arrow-next { right: 10px; }
