/* Visionneuse photo plein écran (static/js/lightbox.js) */

.ls-lb {
    --ls-lb-alpha: 1;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(6, 9, 12, var(--ls-lb-alpha));
    color: #fff;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: contain;
    font-family: inherit;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.ls-lb[hidden] { display: none; }
.ls-lb:focus { outline: none; }
.ls-lb.is-visible { opacity: 1; }

/* Zone d'affichage de la photo. Sur ordinateur, elle laisse la place à la barre
   du haut et aux miniatures ; sur téléphone, elle prend tout l'écran. */
.ls-lb__stage {
    position: absolute;
    inset: 64px 72px 104px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ls-lb--single .ls-lb__stage { inset: 64px 24px 24px; }

.ls-lb__img {
    display: block;
    max-width: none;
    max-height: none;
    transform-origin: 50% 50%;
    will-change: transform;
    cursor: zoom-in;
    -webkit-user-drag: none;
    user-select: none;
    pointer-events: auto;
    opacity: 1;
}
.ls-lb.is-zoomed .ls-lb__img { cursor: grab; }
.ls-lb.is-dragging .ls-lb__img { cursor: grabbing; }
.ls-lb__img.is-animating {
    transition: transform 0.28s cubic-bezier(0.22, 0.8, 0.3, 1), opacity 0.22s ease;
}

/* Barre du haut */
.ls-lb__bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    padding: 0 12px 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
    z-index: 3;
}
.ls-lb__counter {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.ls-lb__tools { display: flex; align-items: center; gap: 4px; }

.ls-lb__btn,
.ls-lb__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    color: #fff;
    cursor: pointer;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
}
.ls-lb__btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    transition: background-color 0.15s ease;
}
.ls-lb__btn:hover { background-color: rgba(255, 255, 255, 0.14); }
.ls-lb__btn:disabled { opacity: 0.35; cursor: default; background: transparent; }
.ls-lb__btn[hidden] { display: none; }
.ls-lb__btn svg,
.ls-lb__nav svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ls-lb__btn:focus-visible,
.ls-lb__nav:focus-visible,
.ls-lb__thumb:focus-visible {
    outline: 2px solid #ffd700;
    outline-offset: 2px;
}

/* Flèches précédent / suivant */
.ls-lb__nav {
    position: absolute;
    top: 50%;
    width: 52px;
    height: 52px;
    margin-top: -26px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 3;
    transition: background-color 0.15s ease, opacity 0.2s ease;
}
.ls-lb__nav:hover { background-color: rgba(255, 255, 255, 0.24); }
.ls-lb__nav:disabled { opacity: 0.25; cursor: default; background-color: rgba(255, 255, 255, 0.12); }
.ls-lb__nav svg { width: 26px; height: 26px; }
.ls-lb__nav--prev { left: 12px; }
.ls-lb__nav--next { right: 12px; }
.ls-lb__nav[hidden] { display: none; }

/* Miniatures */
.ls-lb__thumbs {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 92px;
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0));
    touch-action: pan-x;
    z-index: 3;
}
.ls-lb__thumbs::-webkit-scrollbar { display: none; }
.ls-lb__thumbs[hidden] { display: none; }
.ls-lb__thumb {
    flex: 0 0 auto;
    width: 88px;
    height: 66px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: #1e293b;
    opacity: 0.55;
    cursor: pointer;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}
/* Centrées quand elles tiennent, défilables sinon */
.ls-lb__thumb:first-child { margin-left: auto; }
.ls-lb__thumb:last-child { margin-right: auto; }
.ls-lb__thumb:hover { opacity: 0.85; }
.ls-lb__thumb.is-active { opacity: 1; border-color: #7fd47d; }
.ls-lb__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

/* Légende */
.ls-lb__caption {
    position: absolute;
    left: 50%;
    bottom: 104px;
    transform: translateX(-50%);
    max-width: min(90vw, 720px);
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    font-size: 0.88rem;
    text-align: center;
    z-index: 3;
    pointer-events: none;
}
.ls-lb__caption:empty,
.ls-lb--single .ls-lb__caption { display: none; }

/* Chargement */
.ls-lb__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42px;
    height: 42px;
    margin: -21px 0 0 -21px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ls-lb-spin 0.8s linear infinite;
    pointer-events: none;
    z-index: 2;
}
.ls-lb__spinner[hidden] { display: none; }
@keyframes ls-lb-spin { to { transform: rotate(360deg); } }

/* Aide gestuelle (téléphone, première ouverture) */
.ls-lb__hint {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 18px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.7);
    font-size: 0.9rem;
    line-height: 1.5;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    z-index: 4;
    animation: ls-lb-hint 3.2s ease forwards;
}
.ls-lb__hint[hidden] { display: none; }
@keyframes ls-lb-hint {
    0%, 75% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

/* Masquer l'interface d'un tap pour ne voir que la photo */
.ls-lb__bar,
.ls-lb__thumbs,
.ls-lb__caption { transition: opacity 0.2s ease; }
.ls-lb.is-bare .ls-lb__bar,
.ls-lb.is-bare .ls-lb__thumbs,
.ls-lb.is-bare .ls-lb__caption,
.ls-lb.is-bare .ls-lb__nav {
    opacity: 0;
    pointer-events: none;
}

/* Téléphone : la photo occupe tout l'écran, l'interface flotte par-dessus */
@media (max-width: 767.98px) {
    .ls-lb__stage,
    .ls-lb--single .ls-lb__stage { inset: 0; }
    .ls-lb__bar {
        height: 56px;
        padding: env(safe-area-inset-top, 0) 4px 0 16px;
        box-sizing: content-box;
    }
    .ls-lb__nav { display: none; }
    .ls-lb__thumbs {
        height: 72px;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0));
        box-sizing: content-box;
    }
    .ls-lb__thumb { width: 64px; height: 50px; }
    .ls-lb__caption { bottom: calc(96px + env(safe-area-inset-bottom, 0)); }
    .ls-lb__btn--zoom { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ls-lb,
    .ls-lb__img.is-animating { transition: none; }
}

/* Déclencheurs sur la page */
.ls-lb-trigger { cursor: zoom-in; }

/* Bouton « plein écran » posé sur la galerie de la page */
.ls-lb-open-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 7;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
}
.ls-lb-open-btn:hover { background: rgba(15, 23, 42, 0.9); transform: translateY(-1px); }
.ls-lb-open-btn:focus-visible { outline: 2px solid #ffd700; outline-offset: 2px; }
@media (max-width: 575.98px) {
    .ls-lb-open-btn { top: 10px; right: 10px; padding: 7px 12px; font-size: 0.8rem; }
}
