/* ============================================================
   L2M - Galerie photos (fiche référence)
   ============================================================ */

.l2m-gallery {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ------------------------------------------------------------
   Image principale
   ------------------------------------------------------------ */
.l2m-gallery__main {
    width: 100%;
    aspect-ratio: 886 / 439;
    border-radius: var(--l2m-radius-hero);
    overflow: hidden;
    box-shadow: 2px 4px 10px 2px rgba(0, 0, 0, 0.25);
}

.l2m-gallery__main-link {
    display: block;
    width: 100%;
    height: 100%;
    cursor: zoom-in;
}

.l2m-gallery__main-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.l2m-gallery__main:hover .l2m-gallery__main-img {
    transform: scale(1.02);
}

/* ------------------------------------------------------------
   Barre de thumbnails avec flèches de navigation
   ------------------------------------------------------------ */
.l2m-gallery__thumbs-track {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

/* Flèches de navigation */
.l2m-gallery__thumbs-arrow {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--l2m-white);
    border: 1.5px solid var(--l2m-gray-border);
    color: var(--l2m-blue);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: background var(--l2m-transition), border-color var(--l2m-transition), color var(--l2m-transition);
    visibility: hidden; /* hidden by default, JS shows them */
    padding: 0;
    outline: none;
}

.l2m-gallery__thumbs-arrow:hover {
    background: var(--l2m-teal);
    border-color: var(--l2m-teal);
    color: var(--l2m-white);
}

.l2m-gallery__thumbs-arrow:focus-visible {
    box-shadow: 0 0 0 3px rgba(17, 172, 176, 0.3);
}

/* Viewport : cache ce qui dépasse */
.l2m-gallery__thumbs-viewport {
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

/* Piste intérieure : flex row, animée par translateX */
.l2m-gallery__thumbs {
    display: flex;
    gap: 16px;
    padding-bottom: 15px;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* Thumbnail individuel */
.l2m-gallery__thumb {
    flex-shrink: 0;
    /* La largeur est calculée et injectée par JS via --l2m-thumb-width */
    width: var(--l2m-thumb-width, 158px);
    aspect-ratio: 1 / 1;
    border-radius: var(--l2m-radius-card);
    overflow: hidden;
    padding: 0;
    border: 2.5px solid transparent;
    cursor: pointer;
    transition: border-color var(--l2m-transition), box-shadow var(--l2m-transition);
    outline: none;
    position: relative;
    background: var(--l2m-gray-border);
}

.l2m-gallery__thumb:focus-visible {
    border-color: var(--l2m-teal);
    box-shadow: 0 0 0 3px rgba(17, 172, 176, 0.3);
}

.l2m-gallery__thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.l2m-gallery__thumb:hover .l2m-gallery__thumb-img {
    transform: scale(1.06);
}

/* Overlay turquoise sur thumbnail actif */
.l2m-gallery__thumb-overlay {
    position: absolute;
    inset: 0;
    background: var(--l2m-teal);
    opacity: 0;
    transition: opacity var(--l2m-transition);
    pointer-events: none;
}

.l2m-gallery__thumb--active {
    border-color: var(--l2m-teal);
}

.l2m-gallery__thumb--active .l2m-gallery__thumb-overlay {
    opacity: 0.45;
}

/* ------------------------------------------------------------
   Lightbox
   ------------------------------------------------------------ */
.l2m-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.l2m-lightbox.l2m-lightbox--open {
    display: flex;
}

.l2m-lightbox__img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.l2m-lightbox__close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    opacity: 0.8;
    transition: opacity var(--l2m-transition);
}

.l2m-lightbox__close:hover {
    opacity: 1;
}

.l2m-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--l2m-transition);
    padding: 0;
}

.l2m-lightbox__nav:hover {
    background: var(--l2m-teal);
    border-color: var(--l2m-teal);
}

.l2m-lightbox__prev { left: 20px; }
.l2m-lightbox__next { right: 20px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablette (≤ 1024px) — 3 miniatures visibles */
@media (max-width: 1024px) {
    .l2m-gallery {
        max-width: 100%;
        gap: 16px;
    }

    .l2m-gallery__main {
        border-radius: 30px;
    }

    .l2m-gallery__thumbs-arrow {
        width: 32px;
        height: 32px;
    }
}

/* Mobile (≤ 768px) — 2 miniatures visibles */
@media (max-width: 768px) {
    .l2m-gallery {
        gap: 12px;
    }

    .l2m-gallery__main {
        aspect-ratio: 4 / 3;
        border-radius: 20px;
    }

    .l2m-gallery__thumbs {
        gap: 10px;
    }

    .l2m-gallery__thumbs-arrow {
        width: 28px;
        height: 28px;
    }

    .l2m-lightbox__nav {
        width: 40px;
        height: 40px;
    }

    .l2m-lightbox__prev { left: 8px; }
    .l2m-lightbox__next { right: 8px; }
}

/* Très petit mobile (≤ 480px) */
@media (max-width: 480px) {
    .l2m-gallery__main {
        border-radius: 16px;
    }

    .l2m-gallery__thumb {
        border-radius: 12px;
    }
}
