/* ==========================================================================
   Tant d'aime — Lightbox
   Agrandissement des photos (articles, pages et galeries)
   ========================================================================== */

/* Curseur sur les images cliquables */
.tda-zoomable {
    cursor: zoom-in;
}

/* Overlay */
.tda-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    background: rgba(12, 8, 14, 0.94);
    opacity: 0;
    transition: opacity 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.tda-lightbox.is-open {
    display: block;
}

.tda-lightbox.is-visible {
    opacity: 1;
}

body.tda-lightbox-open {
    overflow: hidden;
}

/* Zone de l'image (scroll natif quand on zoome) */
.tda-lightbox__stage {
    position: absolute;
    inset: 0;
    display: flex;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 4.5rem 1rem 5rem;
    cursor: zoom-in;
}

.tda-lightbox__stage.is-zoomed {
    cursor: grab;
}

.tda-lightbox__stage.is-grabbing {
    cursor: grabbing;
}

.tda-lightbox__img {
    margin: auto;
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 0.22s ease, transform 0.22s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.tda-lightbox__img.is-ready {
    opacity: 1;
    transform: scale(1);
}

/* Quand on zoome, l'image dépasse le stage et devient scrollable */
.tda-lightbox__stage.is-zoomed .tda-lightbox__img {
    max-width: none;
    max-height: none;
    border-radius: 0;
    transition: none;
}

/* Spinner de chargement */
.tda-lightbox__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42px;
    height: 42px;
    margin: -21px 0 0 -21px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tda-spin 0.8s linear infinite;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.tda-lightbox.is-loading .tda-lightbox__spinner {
    opacity: 1;
}

@keyframes tda-spin {
    to { transform: rotate(360deg); }
}

/* Boutons */
.tda-lightbox button {
    font: inherit;
    color: #fff;
    background: rgba(127, 75, 117, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
}

.tda-lightbox button:hover:not(:disabled) {
    background: #9a5f8f;
}

.tda-lightbox button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* Fermer */
.tda-lightbox__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 46px;
    height: 46px;
    font-size: 1.9rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.14);
    z-index: 3;
}

.tda-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: rotate(90deg);
}

/* Navigation prev / next */
.tda-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 54px;
    height: 54px;
    font-size: 0;
    z-index: 3;
}

.tda-lightbox__nav::after {
    content: '';
    width: 13px;
    height: 13px;
    border-top: 3px solid #fff;
    border-right: 3px solid #fff;
}

.tda-lightbox__nav--prev {
    left: 18px;
}

.tda-lightbox__nav--prev::after {
    transform: rotate(-135deg);
    margin-left: 4px;
}

.tda-lightbox__nav--next {
    right: 18px;
}

.tda-lightbox__nav--next::after {
    transform: rotate(45deg);
    margin-right: 4px;
}

.tda-lightbox__nav:hover:not(:disabled) {
    transform: translateY(-50%) scale(1.08);
}

.tda-lightbox__nav[hidden] {
    display: none;
}

/* Zoom */
.tda-lightbox__zoom {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    gap: 8px;
    z-index: 3;
}

.tda-lightbox__zoom button {
    width: 42px;
    height: 42px;
    font-size: 1.35rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.14);
}

.tda-lightbox__zoom button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.28);
}

.tda-lightbox__zoom button:disabled {
    opacity: 0.35;
    cursor: default;
}

/* Bas : légende + compteur */
.tda-lightbox__bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1rem 1.25rem 1.15rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
    pointer-events: none;
    z-index: 2;
}

.tda-lightbox__caption {
    color: #fff;
    font-size: 0.95rem;
    line-height: 1.45;
    text-align: center;
    max-width: min(760px, 92vw);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.tda-lightbox__caption:empty {
    display: none;
}

.tda-lightbox__counter {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.45);
    padding: 5px 14px;
    border-radius: 20px;
}

.tda-lightbox__counter:empty {
    display: none;
}

/* Mobile */
@media (max-width: 768px) {
    .tda-lightbox__stage {
        padding: 4rem 0.5rem 4.5rem;
    }

    .tda-lightbox__nav {
        width: 44px;
        height: 44px;
    }

    .tda-lightbox__nav--prev {
        left: 8px;
    }

    .tda-lightbox__nav--next {
        right: 8px;
    }

    .tda-lightbox__close {
        top: 10px;
        right: 10px;
        width: 42px;
        height: 42px;
    }

    .tda-lightbox__zoom {
        top: 10px;
        left: 10px;
    }

    .tda-lightbox__caption {
        font-size: 0.88rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tda-lightbox,
    .tda-lightbox__img,
    .tda-lightbox button {
        transition: none;
    }

    .tda-lightbox__spinner {
        animation: none;
    }
}
