/**
 * Page publique /galerie-photo/ - grille + lightbox (patrimoine).
 */

/* Footer collé en bas du viewport si peu de contenu (même principe que pages/inscriptions).
   Ce fichier n’est chargé que sur /galerie-photo/, donc html { min-height } est sans effet ailleurs. */
html {
    min-height: 100vh;
}

body.galerie-photo-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.galerie-photo-page main.galerie-photo-main {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
}

.galerie-photo-main {
    padding-bottom: 3rem;
}

/* Bulle d’aide au-dessus de la grille */
.galerie-photo-help {
    margin: 0 0 2rem;
    padding-bottom: 6px;
    width: 100%;
    max-width: none;
}

.galerie-photo-help__bubble {
    position: relative;
    width: 100%;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem 1rem 0.95rem 1rem;
    padding-left: 0.95rem;
    background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
    border: 1px solid rgba(37, 99, 235, 0.22);
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

/* Petit « bec » de bulle */
.galerie-photo-help__bubble::before {
    content: '';
    position: absolute;
    left: 1.35rem;
    bottom: -8px;
    width: 14px;
    height: 14px;
    background: #e0f2fe;
    border-right: 1px solid rgba(37, 99, 235, 0.18);
    border-bottom: 1px solid rgba(37, 99, 235, 0.18);
    transform: rotate(45deg);
    border-radius: 0 0 2px 0;
}

.galerie-photo-help__icon {
    flex-shrink: 0;
    margin-top: 0.1rem;
    color: #2563eb;
    font-size: 1.15rem;
    line-height: 1;
}

.galerie-photo-help__text {
    margin: 0;
    color: #334155;
    font-size: 0.95rem;
    line-height: 1.55;
}

.galerie-photo-help__text kbd {
    padding: 0.12em 0.4em;
    font-size: 0.82em;
    font-family: inherit;
    border-radius: 5px;
    background: #fff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
}

.galerie-photo-section {
    position: relative;
}

.galerie-photo__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem 1.1rem;
}

.galerie-photo__cell {
    margin: 0;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    overflow: hidden;
    background: #f1f5f9;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.galerie-photo__cell:hover {
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    transform: translateY(-2px);
}

.galerie-photo__zoomable {
    border: none;
    padding: 0;
    margin: 0;
    cursor: zoom-in;
    display: block;
    width: 100%;
    text-align: left;
    background: #0f172a;
    color: inherit;
    font: inherit;
}

.galerie-photo__thumb-wrap {
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #0f172a;
}

.galerie-photo__thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.galerie-photo__caption {
    margin: 0;
    padding: 0.65rem 0.85rem 0.85rem;
    font-size: 0.88rem;
    line-height: 1.4;
    color: #334155;
    background: #fff;
    flex: 0 0 auto;
}

/* Lightbox */
.galerie-photo__modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 2000;
}

.galerie-photo__modal--visible {
    display: flex;
}

.galerie-photo__modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(3px);
    cursor: pointer;
}

.galerie-photo__modal-content {
    position: relative;
    /* Presque tout l’écran : largeur jusqu’à 1920px pour exploiter les fichiers sources */
    width: min(1920px, calc(100vw - 1rem));
    max-width: 100%;
    height: calc(100vh - 1rem);
    max-height: calc(100vh - 1rem);
    background: #0f172a;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

@supports (height: 100dvh) {
    .galerie-photo__modal-content {
        height: calc(100dvh - 1rem);
        max-height: calc(100dvh - 1rem);
    }
}

.galerie-photo__modal-image-wrap {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.galerie-photo__modal-image-wrap::before {
    content: '';
    position: absolute;
    inset: -12%;
    background-image: var(--galerie-photo-modal-bg, none);
    background-size: cover;
    background-position: center;
    filter: blur(36px) brightness(0.65);
    opacity: 0.85;
    z-index: 0;
}

.galerie-photo__modal-image-wrap img {
    position: relative;
    z-index: 1;
    display: block;
    /* Taille intrinsèque si elle tient ; sinon réduction pour tenir dans la zone (sans agrandissement) */
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    image-rendering: auto;
}

.galerie-photo__modal-caption {
    margin: 0;
    padding: 0.9rem 1.25rem 1.1rem;
    color: #f8fafc;
    font-size: 0.98rem;
    line-height: 1.45;
    flex-shrink: 0;
    min-height: 2.5rem;
}

.galerie-photo__modal--no-fs .galerie-photo__modal-fs {
    display: none;
}

.galerie-photo__modal-fs {
    position: absolute;
    top: 0.65rem;
    right: calc(0.65rem + 42px + 0.35rem);
    border: none;
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    z-index: 10;
    font-size: 0.95rem;
}

.galerie-photo__modal-fs:hover {
    background: rgba(37, 99, 235, 0.95);
}

.galerie-photo__modal-fs.is-active {
    background: rgba(37, 99, 235, 0.9);
}

/* Plein écran natif (API Fullscreen sur .galerie-photo__modal) */
.galerie-photo__modal:fullscreen,
.galerie-photo__modal:-webkit-full-screen {
    display: flex;
    padding: 0;
    background: #000;
    align-items: center;
    justify-content: center;
}

.galerie-photo__modal:fullscreen .galerie-photo__modal-overlay,
.galerie-photo__modal:-webkit-full-screen .galerie-photo__modal-overlay {
    display: none;
}

.galerie-photo__modal:fullscreen .galerie-photo__modal-content,
.galerie-photo__modal:-webkit-full-screen .galerie-photo__modal-content {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
}

.galerie-photo__modal:fullscreen .galerie-photo__modal-image-wrap,
.galerie-photo__modal:-webkit-full-screen .galerie-photo__modal-image-wrap {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
}

.galerie-photo__modal:fullscreen .galerie-photo__modal-image-wrap img,
.galerie-photo__modal:-webkit-full-screen .galerie-photo__modal-image-wrap img {
    max-width: 100%;
    max-height: 100%;
}

.galerie-photo__modal-close {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    border: none;
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    z-index: 10;
}

.galerie-photo__modal-close:hover {
    background: rgba(37, 99, 235, 0.95);
}

.galerie-photo__modal-prev,
.galerie-photo__modal-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 10;
    font-size: 1.15rem;
}

.galerie-photo__modal-prev {
    left: 0.65rem;
}

.galerie-photo__modal-next {
    right: 0.65rem;
}

.galerie-photo__modal-prev:hover,
.galerie-photo__modal-next:hover {
    background: rgba(37, 99, 235, 0.95);
    transform: translateY(-50%) scale(1.06);
}

.galerie-photo__modal-counter {
    position: absolute;
    top: 0.65rem;
    left: 0.65rem;
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    z-index: 10;
}

@media (max-width: 640px) {
    .galerie-photo__grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 0.75rem;
    }

    .galerie-photo__modal-prev,
    .galerie-photo__modal-next {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .galerie-photo__modal-prev {
        left: 0.4rem;
    }

    .galerie-photo__modal-next {
        right: 0.4rem;
    }
}
