/* === Lightbox Galerie === */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(40, 32, 24, 0.82);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    overscroll-behavior: contain;
}

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

.lightbox__inner {
    position: relative;
    width: min(92vw, 1100px);
    height: min(86vh, 800px);
    display: grid;
    grid-template-rows: 1fr auto;
    gap: .75rem;
}

.lightbox__stage {
    position: relative;
    background: var(--bg-primary);
    border-radius: 14px;
    box-shadow: 0 4px 32px rgba(63, 47, 37, 0.18);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    min-height: 200px;
}

/* image principale */
.lightbox__img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(63, 47, 37, 0.14);
    transition: opacity 0.6s ease;
    opacity: 1;
    display: block;
    user-select: none;
    pointer-events: none; /* évite de bloquer les clics sur les boutons superposés */
}

.lightbox__img.is-fading {
    opacity: 0;
}

/* vignettes */
.lightbox__thumbs {
    display: grid;
    grid-auto-flow: column;
    gap: .5rem;
    overflow-x: auto;
    padding: .25rem;
}

.lightbox__thumb {
    width: 80px;
    height: 60px;
    flex: 0 0 auto;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    opacity: .65;
    outline: 2px solid transparent;
    border: 0;
    background: transparent;
}

.lightbox__thumb.is-active {
    opacity: 1;
    outline-color: var(--green);
}

.lightbox__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* boutons nav */
.lightbox__btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.88);
    border: 1.5px solid rgba(63, 47, 37, 0.12);
    color: var(--text-primary);
    font-size: 22px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    z-index: 2;
    box-shadow: 0 2px 10px rgba(63, 47, 37, 0.10);
}

.lightbox__btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(92, 147, 111, 0.35);
}

.lightbox__prev {
    left: .5rem;
}

.lightbox__next {
    right: .5rem;
}

/* fermer */
.lightbox__close {
    position: absolute;
    top: .5rem;
    right: .5rem;
    background: rgba(255, 255, 255, 0.88);
    border: 1.5px solid rgba(63, 47, 37, 0.12);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 3;
    box-shadow: 0 2px 10px rgba(63, 47, 37, 0.10);
}

/* légende */
.lightbox__caption {
    color: white;
    font-size: 1.4rem;
    font-weight: 600;
    text-align: center;
}

/* play/pause */
.lightbox__play {
    position: absolute;
    bottom: .75rem;
    right: 3.5rem;
    background: rgba(255, 255, 255, 0.88);
    border: 1.5px solid rgba(63, 47, 37, 0.12);
    color: var(--text-primary);
    font-size: 20px;
    line-height: 21px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    transition: background .2s, transform .2s;
    z-index: 3;
    box-shadow: 0 2px 10px rgba(63, 47, 37, 0.10);
}

.lightbox__play:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

.lightbox__play.is-playing {
    background: var(--green);
    color: #fff;
    border-color: transparent;
}

/* ---- NOUVEAU : bouton Zoom (remplace fullscreen) ---- */
.lightbox__zoom {
    position: absolute;
    bottom: .75rem;
    right: .75rem;
    background: rgba(255, 255, 255, 0.88);
    border: 1.5px solid rgba(63, 47, 37, 0.12);
    color: var(--text-primary);
    font-size: 18px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    transition: background .2s, transform .2s;
    z-index: 3;
    box-shadow: 0 2px 10px rgba(63, 47, 37, 0.10);
}

.lightbox__zoom:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

.lightbox__zoom.is-active {
    background: var(--green);
    color: #fff;
    border-color: transparent;
}

/* === Zoom lightbox (sans plein écran navigateur) === */
.lightbox.is-zoomed .lightbox__inner {
    width: 98vw;
    height: 96vh;
}

.lightbox.is-zoomed .lightbox__stage {
    padding: .5rem;
}

.lightbox.is-zoomed .lightbox__thumbs {
    display: none;
}

/* on cache les vignettes en mode zoom */

/* focus visible (A11Y) */
.lightbox__btn:focus-visible,
.lightbox__close:focus-visible,
.lightbox__play:focus-visible,
.lightbox__zoom:focus-visible,
.lightbox__thumb:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

/* mobile */
@media (max-width: 600px) {
    .lightbox__inner {
        width: 100vw;
        height: 100dvh;
        gap: 0;
        grid-template-rows: 1fr auto auto;
    }

    .lightbox__stage {
        border-radius: 0;
        padding: 0.5rem;
    }

    .lightbox__btn {
        width: 52px;
        height: 52px;
        font-size: 24px;
    }

    .lightbox__close {
        width: 44px;
        height: 44px;
    }

    .lightbox__play,
    .lightbox__zoom {
        width: 44px;
        height: 44px;
    }

    .lightbox__thumbs {
        padding: 0.4rem 0.5rem;
        gap: 0.4rem;
    }

    .lightbox__thumb {
        width: 60px;
        height: 44px;
    }

    .lightbox__caption {
        font-size: 1.1rem;
        padding: 0.4rem 1rem 0.6rem;
    }
}

/* respect de l’utilisateur : réduit les animations si demandé */
@media (prefers-reduced-motion: reduce) {
    .lightbox__img {
        transition: none;
    }
}

/* ============================================
   DTI VIEWER — visualiseur simple (sans galerie)
   ============================================ */
.dti-viewer {
    position: fixed;
    inset: 0;
    background: rgba(10, 5, 20, 0.92);
    backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3.5rem 4rem 2rem;
    z-index: 9999;
}

.dti-viewer.is-open {
    display: flex;
}

/* Barre titre : caption + boutons expand/close */
.dti-viewer__toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: min(84vw, 660px);
    transition: opacity 0.2s;
}

.dti-viewer__caption {
    flex: 1;
    color: rgba(255, 255, 255, 0.88);
    font-size: 1rem;
    font-weight: 600;
    min-height: 1.4em;
}

.dti-viewer.is-expanded .dti-viewer__toolbar {
    opacity: 0;
    pointer-events: none;
}

/* Stage : wraps l'image + flèches pour un centrage précis */
.dti-viewer__stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Image */
.dti-viewer__img {
    max-width: min(84vw, 660px);
    max-height: 72vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 60px rgba(0, 0, 0, 0.55);
    transition: max-width 0.35s ease, max-height 0.35s ease, opacity 0.25s ease;
    user-select: none;
    pointer-events: auto; /* double-clic/tap pour agrandir */
    display: block;
}

.dti-viewer__img.is-fading {
    opacity: 0;
}

/* Mode agrandi */
.dti-viewer.is-expanded .dti-viewer__img {
    max-width: min(96vw, 1400px);
    max-height: 90vh;
    border-radius: 8px;
}


/* Icônes blanches */
.dti-viewer__close img,
.dti-viewer__nav img,
.dti-viewer__expand img {
    filter: brightness(0) invert(1);
    width: 20px;
    height: 20px;
    display: block;
}

/* Boutons fermer + agrandir (dans la toolbar) */
.dti-viewer__close,
.dti-viewer__expand {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.2s;
}

.dti-viewer__close:hover,
.dti-viewer__expand:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* Boutons navigation (relatifs au stage) */
.dti-viewer__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.2s;
}

.dti-viewer__nav:hover {
    background: rgba(255, 255, 255, 0.28);
}

.dti-viewer__prev { left: -3.5rem; }
.dti-viewer__next { right: -3.5rem; }

.dti-viewer__expand.is-active {
    background: rgba(162, 89, 255, 0.55);
    border-color: rgba(162, 89, 255, 0.8);
}

/* Focus visible */
.dti-viewer__close:focus-visible,
.dti-viewer__nav:focus-visible,
.dti-viewer__expand:focus-visible {
    outline: 2px solid rgba(162, 89, 255, 0.8);
    outline-offset: 2px;
}

/* Mobile */
@media (max-width: 600px) {
    .dti-viewer {
        padding: 3.5rem 1rem 1.5rem;
        gap: 0.5rem;
    }

    .dti-viewer__img {
        max-width: 92vw;
        max-height: 72vh;
        border-radius: 10px;
    }

    .dti-viewer.is-expanded .dti-viewer__img {
        max-width: 100vw;
        max-height: 88vh;
        border-radius: 0;
    }

    .dti-viewer__nav {
        width: 44px;
        height: 44px;
    }

    /* Sur mobile les flèches sont à l'intérieur du stage */
    .dti-viewer__prev { left: 0.25rem; }
    .dti-viewer__next { right: 0.25rem; }

    .dti-viewer__toolbar {
        width: 92vw;
    }

    .dti-viewer__caption {
        font-size: 0.9rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dti-viewer__img {
        transition: opacity 0.25s ease;
    }
}