#galerie {
    background: var(--off-black);
}

[hidden] {
    display: none !important;
}

/* En-tête */

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 60px;
}

.filter-btn {
    background: none;
    border: none;
    color: var(--brun);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    padding-bottom: 4px;
    border-bottom: 1px solid transparent;
    transition: color 0.3s, border-color 0.3s;
}

.filter-btn:hover,
.filter-btn:focus-visible {
    color: var(--vert-clair);
    border-bottom-color: var(--vert);
}

/* Vue 1 : albums */

.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 28px 20px;
}

.album-card {
    all: unset;
    box-sizing: border-box;
    cursor: pointer;
    display: block;
}

.album-card:focus-visible {
    outline: 1px solid var(--vert);
    outline-offset: 6px;
}

.album-cover {
    display: block;
    aspect-ratio: 4 / 5;
    border-radius: 8px;
    overflow: hidden;
    background: var(--dark);
}

.album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), filter 0.4s;
    filter: brightness(0.92);
}

.album-card:hover .album-cover img,
.album-card:focus-visible .album-cover img {
    transform: scale(1.04);
    filter: brightness(1);
}

.album-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 16px 2px 0;
    border-bottom: 1px solid transparent;
}

.album-name {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.5rem;
    font-style: italic;
    font-weight: 300;
    color: var(--cream);
    transition: color 0.3s;
}

.album-card:hover .album-name {
    color: var(--vert-clair);
}

.album-count {
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--brun);
    white-space: nowrap;
}

/* Sur grand écran, le premier album est mis en avant */
@media (min-width: 900px) {
    .album-card:first-child {
        grid-column: span 2;
    }

    .album-card:first-child .album-cover {
        aspect-ratio: 8 / 5;
    }
}

/* Vue 2 : photos de l'album (masonry) */

.gallery-grid {
    --g: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    grid-auto-rows: 1px;
    column-gap: var(--g);
    row-gap: 0;
}

.gallery-item {
    all: unset;
    box-sizing: border-box;
    display: block;
    grid-row-end: span 300;
    position: relative;
    cursor: zoom-in;
}

.gallery-item:focus-visible .gallery-placeholder {
    outline: 1px solid var(--vert);
    outline-offset: 3px;
}

.gallery-placeholder {
    position: absolute;
    inset: 0 0 var(--g) 0;
    display: block;
    border-radius: 8px;
    overflow: hidden;
    background: var(--dark);
}

.gallery-placeholder-inner {
    display: block;
    width: 100%;
    height: 100%;
}

.gallery-placeholder-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.gallery-item:hover .gallery-placeholder-inner img {
    transform: scale(1.04);
}

/* Visionneuse */

.lightbox {
    border: 0;
    padding: 0;
    background: transparent;
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    color: var(--cream);
    touch-action: pan-y;
}

.lightbox::backdrop {
    background: rgba(10, 10, 10, 0.95);
}

.lightbox[open] {
    display: grid;
    grid-template-rows: 1fr auto;
    place-items: center;
    gap: 14px;
    padding: 56px 72px 28px;
}

.lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    min-height: 0;
}

.lightbox p {
    font-size: 0.65rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--brun);
}

.lb-btn {
    position: absolute;
    background: none;
    border: 1px solid rgba(105, 147, 136, 0.4);
    color: var(--vert-clair);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
}

.lb-btn:hover,
.lb-btn:focus-visible {
    border-color: var(--vert-clair);
    background: rgba(105, 147, 136, 0.1);
}

.lb-close {
    top: 20px;
    right: 24px;
}

.lb-prev {
    left: 16px;
    top: 50%;
}

.lb-next {
    right: 16px;
    top: 50%;
}

@media (max-width: 700px) {
    .gallery-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .lightbox[open] {
        padding: 64px 12px 24px;
    }

    .lb-prev,
    .lb-next {
        top: auto;
        bottom: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* Mobile : on réduit les marges (le site impose 60px de chaque côté) et on passe en 2 colonnes */
@media (max-width: 700px) {
    #galerie {
        padding: 72px 18px;
    }

    .gallery-header {
        margin-bottom: 36px;
    }

    .album-grid {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .album-name {
        font-size: 1.3rem;
    }

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