/* ==========================================================================
   Mediart — Lightbox
   ========================================================================== */

/* ── Curseur sur les items cliquables ───────────────────────────────────── */

.mediart-gallery .mediart-item[data-full] {
    cursor: zoom-in;
}

.mediart-gallery .mediart-item[data-full]:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.8);
    outline-offset: 4px;
    border-radius: 4px;
}

/* ── Overlay principal ──────────────────────────────────────────────────── */

.mediart-lb {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mediart-lb.is-open {
    visibility: visible;
    opacity: 1;
}

/* ── Fond sombre ────────────────────────────────────────────────────────── */

.mediart-lb__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.93);
    cursor: zoom-out;
}

/* ── Bouton fermer ──────────────────────────────────────────────────────── */

.mediart-lb__close {
    position: absolute;
    top: 18px;
    right: 22px;
    z-index: 10;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, transform 0.15s ease;
}

.mediart-lb__close:hover,
.mediart-lb__close:focus-visible {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* ── Centrage du contenu ────────────────────────────────────────────────── */

.mediart-lb__content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: min(88vw, 1200px);
    max-height: 90vh;
    gap: 14px;
    /* Espace latéral pour les boutons prev/next positionnés en absolu. */
    padding: 0 72px;
    box-sizing: border-box;
}

/* ── Zone image ─────────────────────────────────────────────────────────── */

.mediart-lb__img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Hauteur max = espace dispo moins la légende. */
    max-height: calc(90vh - 70px);
    overflow: hidden;
}

/* ── Image ──────────────────────────────────────────────────────────────── */

.mediart-lb__img {
    display: block;
    max-width: 100%;
    max-height: calc(90vh - 70px);
    object-fit: contain;
    object-position: center center;
    border-radius: 4px;
    user-select: none;
    /* Animation de transition entre images. */
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

/* État "en cours de chargement" déclenché par JS. */
.mediart-lb__img.is-loading {
    opacity: 0;
    transform: scale(0.97);
}

/* ── Boutons précédent / suivant ────────────────────────────────────────── */

.mediart-lb__prev,
.mediart-lb__next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease;
}

.mediart-lb__prev { left: 16px; }
.mediart-lb__next { right: 16px; }

.mediart-lb__prev:hover,
.mediart-lb__prev:focus-visible,
.mediart-lb__next:hover,
.mediart-lb__next:focus-visible {
    background: rgba(255, 255, 255, 0.26);
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.mediart-lb__prev:hover  { transform: translateY(-50%) translateX(-2px); }
.mediart-lb__next:hover  { transform: translateY(-50%) translateX(2px); }

/* Masqué quand une seule image. */
.mediart-lb__prev[hidden],
.mediart-lb__next[hidden] {
    display: none;
}

/* Flèches dessinées en CSS — zéro image. */
.mediart-lb__prev::before,
.mediart-lb__next::before {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    border-style: solid;
    border-color: #fff;
}

.mediart-lb__prev::before {
    border-width: 0 0 2px 2px;
    transform: rotate(45deg) translate(2px, -2px);
}

.mediart-lb__next::before {
    border-width: 2px 2px 0 0;
    transform: rotate(45deg) translate(-2px, 2px);
}

/* ── Légende (mention + compteur) ───────────────────────────────────────── */

.mediart-lb__caption {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    min-height: 22px;
}

.mediart-lb__mention {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.8rem;
    font-style: italic;
    line-height: 1.4;
    flex: 1;
}

.mediart-lb__counter {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* ── Responsive mobile ───────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .mediart-lb__content {
        padding: 0 52px;
        max-width: 100vw;
    }

    .mediart-lb__prev { left: 4px; }
    .mediart-lb__next { right: 4px; }

    .mediart-lb__prev,
    .mediart-lb__next {
        width: 40px;
        height: 40px;
    }

    .mediart-lb__close {
        top: 10px;
        right: 12px;
        width: 38px;
        height: 38px;
        font-size: 18px;
    }

    .mediart-lb__img-wrap,
    .mediart-lb__img {
        max-height: calc(85vh - 60px);
    }
}

/* ── Respect prefers-reduced-motion ─────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .mediart-lb,
    .mediart-lb__img {
        transition: none;
    }
}
