/* =========================================================
   L'ATELIER — GALERIES
   ========================================================= */


/* =========================================================
   1. RÈGLES COMMUNES
   ========================================================= */

.gallery-flow {
    margin: 2rem 0;
}

.gallery-flow-item {
    margin: 0;
    min-width: 0;
}

.gallery-flow-item[id] {
    scroll-margin-top: 6rem;
}

.gallery-flow-image-button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 1rem;
    overflow: hidden;
    background: transparent;
    cursor: zoom-in;
}

.gallery-flow-image-button img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    transition: transform .2s ease;
}

.gallery-flow-image-button:hover img {
    transform: scale(1.025);
}


/* Mise en évidence d'une image appelée par imgref */

.gallery-flow-item:target {
    outline: none;
}

.gallery-flow-item:target .gallery-flow-image-button {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .14);
}


/* =========================================================
   2. LÉGENDES
   ========================================================= */

.gallery-flow figcaption {
    margin-top: .55rem;
    padding: 0 .35rem;
    text-align: center;
    color: rgba(30, 30, 25, .72);
    font-size: .9rem;
    font-style: italic;
    line-height: 1.45;
}

.gallery-flow--grid figcaption {
    margin-top: .45rem;
    font-size: .85rem;
}

.gallery-flow--carousel figcaption {
    margin-top: .6rem;
}


/* =========================================================
   3. GALERIE EN GRILLE
   ========================================================= */

.gallery-flow-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}


/* =========================================================
   4. CARROUSEL
   ========================================================= */

.gallery-flow--carousel {
    position: relative;
    margin: 1.5rem 0;
}

.gallery-flow--carousel .gallery-flow-carousel-track {
    position: relative;
    width: 100%;
}

.gallery-flow--carousel .gallery-flow-item {
    display: none;
    position: relative;
    margin: 0;
    padding: 0;
    background: transparent;
}

.gallery-flow--carousel .gallery-flow-item.is-active {
    display: block;
}

.gallery-flow--carousel .gallery-flow-image-button {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: .7rem;
    overflow: hidden;
    background: transparent;
    cursor: zoom-in;
    aspect-ratio: auto;
}

.gallery-flow--carousel .gallery-flow-image-button img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 75vh;
    margin: 0;
    padding: 0;
    aspect-ratio: auto;
    object-fit: contain;
    border-radius: .7rem;
}


/* ---------------------------------------------------------
   Navigation du carrousel

   gallery.js donne à ce bloc la hauteur réelle de l'image.
   Les contrôles restent donc placés sur l'image et non
   sur la légende.
   --------------------------------------------------------- */

.gallery-flow--carousel .gallery-flow-carousel-nav {
    position: absolute;
    top: 0;
    right: 0;
    bottom: auto;
    left: 0;
    z-index: 10;
    margin: 0;
    pointer-events: none;
}


/* Flèches */

.gallery-flow--carousel .gallery-flow-prev,
.gallery-flow--carousel .gallery-flow-next {
    position: absolute;
    top: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    transform: translateY(-50%);
    background: rgba(20, 20, 18, .48);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    font-size: 1.55rem;
    line-height: 1;
    cursor: pointer;
    pointer-events: auto;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.gallery-flow--carousel .gallery-flow-prev {
    left: .65rem;
}

.gallery-flow--carousel .gallery-flow-next {
    right: .65rem;
}

.gallery-flow--carousel .gallery-flow-prev:hover,
.gallery-flow--carousel .gallery-flow-next:hover {
    background: rgba(20, 20, 18, .68);
}


/* Points */

.gallery-flow--carousel .gallery-flow-dots {
    position: absolute;
    left: 50%;
    bottom: .8rem;
    display: flex;
    align-items: center;
    gap: .35rem;
    margin: 0;
    padding: .22rem .38rem;
    border-radius: 999px;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, .42);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
    pointer-events: auto;
}

.gallery-flow--carousel .gallery-flow-dots button {
    display: block;
    width: .4rem;
    height: .4rem;
    margin: 0 .14rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .9);
    border-radius: 50%;
    background: transparent;
    opacity: .9;
    cursor: pointer;
    pointer-events: auto;
}

.gallery-flow--carousel .gallery-flow-dots button.is-active {
    background: #fff;
    opacity: 1;
}


/* =========================================================
   5. RÉFÉRENCES TEXTE → IMAGE
   ========================================================= */

.gallery-flow-imgref,
.prose .gallery-flow-imgref {
    color: inherit;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-thickness: 1px;
    text-underline-offset: .18em;
    cursor: pointer;
}

.prose .gallery-flow-imgref::after {
    content: " ↗";
    font-size: .75em;
    opacity: .55;
}

.prose .gallery-flow-imgref:hover {
    text-decoration-style: solid;
}


/* =========================================================
   6. LIGHTBOX
   ========================================================= */

.latelier-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(10, 14, 12, .96);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}

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

.latelier-lightbox-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(96vw, 1500px);
    height: 94vh;
}

.latelier-lightbox-content {
    position: relative;
    display: flex;
    flex: 0 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    max-width: calc(100% - 7rem);
    height: auto;
    max-height: none;
}


/* ---------------------------------------------------------
   Wrapper de l'image

   Le compteur et les zones tactiles sont positionnés
   par rapport à ce wrapper, donc exactement à l'image.
   --------------------------------------------------------- */

.latelier-lightbox-image-wrap {
    position: relative;
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
}

.latelier-lightbox-image-wrap > img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 76vh;
    object-fit: contain;
    border-radius: .6rem;
}


/* ---------------------------------------------------------
   Compteur
   --------------------------------------------------------- */

.latelier-lightbox-image-wrap .latelier-lightbox-counter {
    position: absolute;
    top: .65rem;
    left: .65rem;
    right: auto;
    bottom: auto;
    z-index: 50;
    width: auto;
    height: auto;
    margin: 0;
    padding: .28rem .5rem;
    border-radius: 999px;
    color: #fff;
    background: rgba(0, 0, 0, .42);
    font-size: .82rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    text-align: left;
    pointer-events: none;
}


/* ---------------------------------------------------------
   Navigation lightbox

   Les boutons occupent une grande zone invisible sur toute
   la hauteur de l'image. Seul le cercle du chevron apparaît.
   --------------------------------------------------------- */

.latelier-lightbox-image-wrap .latelier-lightbox-prev,
.latelier-lightbox-image-wrap .latelier-lightbox-next {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    width: 24%;
    height: 100%;
    margin: 0;
    padding: 0 .55rem;
    border: 0;
    border-radius: 0;
    transform: none;
    background: transparent;
    color: #fff;
    font-size: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.latelier-lightbox-image-wrap .latelier-lightbox-prev {
    left: 0;
    right: auto;
    justify-content: flex-start;
}

.latelier-lightbox-image-wrap .latelier-lightbox-next {
    right: 0;
    left: auto;
    justify-content: flex-end;
}

.latelier-lightbox-image-wrap .latelier-lightbox-prev::after,
.latelier-lightbox-image-wrap .latelier-lightbox-next::after {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.65rem;
    height: 2.65rem;
    flex: 0 0 2.65rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, .42);
    color: #fff;
    font-size: 1.6rem;
    font-weight: 400;
    line-height: 1;
    box-sizing: border-box;
    pointer-events: none;
}

.latelier-lightbox-image-wrap .latelier-lightbox-prev::after {
    content: '‹';
}

.latelier-lightbox-image-wrap .latelier-lightbox-next::after {
    content: '›';
}

.latelier-lightbox-image-wrap .latelier-lightbox-prev[hidden],
.latelier-lightbox-image-wrap .latelier-lightbox-next[hidden] {
    display: none;
}


/* ---------------------------------------------------------
   Légende et lien original
   --------------------------------------------------------- */

.latelier-lightbox-caption {
    max-width: 50rem;
    margin-top: .7rem;
    color: rgba(255, 255, 255, .78);
    font-size: .9rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: center;
}

.latelier-lightbox-original {
    display: inline-block;
    margin-top: .35rem;
    color: rgba(255, 255, 255, .48);
    font-size: .75rem;
    text-decoration: none;
}

.latelier-lightbox-original:hover,
.latelier-lightbox-original:focus-visible {
    color: rgba(255, 255, 255, .8);
    text-decoration: underline;
}


/* ---------------------------------------------------------
   Fermeture
   --------------------------------------------------------- */

.latelier-lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .30);
    color: #fff;
    font-size: 1.35rem;
    line-height: 1;
    opacity: .8;
    cursor: pointer;
}

.latelier-lightbox-close:hover,
.latelier-lightbox-close:focus-visible {
    background: rgba(0, 0, 0, .65);
    opacity: 1;
}


/* =========================================================
   7. RESPONSIVE
   ========================================================= */

@media (max-width: 850px) {

    .gallery-flow-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .gallery-flow--carousel {
        margin: 1rem 0 .5rem;
    }

    .gallery-flow--carousel .gallery-flow-image-button img {
        max-height: 70vh;
        border-radius: .55rem;
    }

    .gallery-flow--carousel .gallery-flow-prev,
    .gallery-flow--carousel .gallery-flow-next {
        width: 2.2rem;
        height: 2.2rem;
        font-size: 1.45rem;
    }

    .gallery-flow--carousel .gallery-flow-prev {
        left: .4rem;
    }

    .gallery-flow--carousel .gallery-flow-next {
        right: .4rem;
    }

    .gallery-flow--carousel .gallery-flow-dots {
        bottom: .7rem;
    }

    .gallery-flow figcaption {
        margin-top: .35rem;
        font-size: .86rem;
        line-height: 1.35;
    }

    .prose .gallery-flow-imgref::after {
        font-size: .7em;
    }
}


@media (max-width: 700px) {

    .latelier-lightbox {
        padding: .5rem;
    }

    .latelier-lightbox-inner {
        width: 100%;
        height: 96vh;
    }

    .latelier-lightbox-content {
        max-width: 100%;
        height: auto;
        max-height: none;
    }

    .latelier-lightbox-image-wrap > img {
        max-width: 100%;
        max-height: 72vh;
        border-radius: .45rem;
    }

    .latelier-lightbox-image-wrap .latelier-lightbox-prev,
    .latelier-lightbox-image-wrap .latelier-lightbox-next {
        width: 27%;
        padding: 0 .4rem;
    }

    .latelier-lightbox-image-wrap .latelier-lightbox-prev::after,
    .latelier-lightbox-image-wrap .latelier-lightbox-next::after {
        width: 2.5rem;
        height: 2.5rem;
        flex-basis: 2.5rem;
        font-size: 1.55rem;
    }

    .latelier-lightbox-image-wrap .latelier-lightbox-counter {
        top: .5rem;
        left: .5rem;
        font-size: .78rem;
    }

    .latelier-lightbox-caption {
        margin-top: .55rem;
        padding: 0 .5rem;
        font-size: .86rem;
    }

    .latelier-lightbox-original {
        margin-top: .3rem;
        font-size: .72rem;
    }

    .latelier-lightbox-close {
        top: 1rem;
        right: .8rem;
        width: 2.35rem;
        height: 2.35rem;
    }
}


@media (max-width: 480px) {

    .gallery-flow-grid {
        gap: .7rem;
    }

    .gallery-flow-image-button {
        border-radius: .8rem;
    }
}


/* =========================================================
   8. ACCESSIBILITÉ
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    .gallery-flow-image-button img {
        transition: none;
    }
}
