/* =============================================
   Gallery Manager — Frontend CSS
   ============================================= */

.gallery-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 0;
}

/* ---- Grille albums ---- */
.gallery-albums-grid {
    display: grid;
    grid-template-columns: repeat(var(--gallery-columns, 3), 1fr);
    gap: 2rem;
    margin-bottom: 2.5rem;
}

/* ---- Carte album ---- */
.gallery-album-card {
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
    transition: transform .25s, box-shadow .25s;
    outline: none;
    display: flex;
    flex-direction: column;
}

.gallery-album-card:hover,
.gallery-album-card:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 10px 28px rgba(0,0,0,.14);
}

/* ---- Photo de couverture ---- */
.gallery-album-cover {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4/3;
    background: #f0f4f8;
}

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

.gallery-album-card:hover .gallery-cover-img,
.gallery-album-card:focus-visible .gallery-cover-img {
    transform: scale(1.05);
}

.gallery-cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.gallery-cover-placeholder svg {
    width: 70%;
    height: auto;
    opacity: .5;
}

/* ---- Overlay au hover ---- */
.gallery-album-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .25s;
}

.gallery-album-card:hover .gallery-album-overlay,
.gallery-album-card:focus-visible .gallery-album-overlay {
    opacity: 1;
}

.gallery-open-label {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: #fff;
    font-size: .9rem;
    font-weight: 600;
    padding: .45rem 1rem;
    border: 2px solid rgba(255,255,255,.85);
    border-radius: 24px;
    letter-spacing: .02em;
    backdrop-filter: blur(4px);
    background: rgba(255,255,255,.12);
}

/* ---- Infos album ---- */
.gallery-album-info {
    padding: .9rem 1rem .8rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    border-top: 1px solid #eef0f3;
    flex: 1;
}

.gallery-album-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 .1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-album-date {
    font-size: .8rem;
    color: #718096;
    text-transform: capitalize;
}

.gallery-album-desc {
    font-size: .82rem;
    color: #4a5568;
    margin: .3rem 0 0;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- Pagination ---- */
.gallery-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    justify-content: center;
    margin-top: 2rem;
}

.gallery-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 .65rem;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    background: #fff;
    color: #2d3748;
    text-decoration: none;
    font-size: .875rem;
    transition: background .15s, color .15s, border-color .15s;
}

.gallery-page-btn:hover {
    background: #ebf4ff;
    border-color: #3182ce;
    color: #2b6cb0;
}

.gallery-page-btn.active {
    background: #3182ce;
    border-color: #3182ce;
    color: #fff;
    font-weight: 700;
}

.gallery-empty {
    text-align: center;
    color: #718096;
    padding: 3rem 0;
    font-style: italic;
}

/* =============================================
   Modale mosaïque
   ============================================= */

.gallery-modal {
    position: fixed;
    inset: 0;
    z-index: 99990;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-modal[hidden] { display: none; }

.gallery-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(3px);
    cursor: pointer;
}

.gallery-modal-box {
    position: relative;
    z-index: 1;
    width: min(96vw, 1100px);
    height: min(90vh, 860px);
    background: #fff;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,.35);
}

.gallery-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eef0f3;
    gap: 1rem;
    flex-shrink: 0;
}

.gallery-modal-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.gallery-modal-meta-top {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    flex-wrap: wrap;
}

.gallery-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a202c;
}

.gallery-modal-date {
    font-size: .82rem;
    color: #718096;
    text-transform: capitalize;
    white-space: nowrap;
}

.gallery-modal-desc {
    font-size: .875rem;
    color: #4a5568;
    margin: 0;
    line-height: 1.55;
}

.gallery-modal-desc[hidden] { display: none; }

.gallery-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f7fafc;
    color: #4a5568;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: .1rem;
    transition: background .15s, color .15s;
}

.gallery-modal-close:hover {
    background: #fed7d7;
    color: #c53030;
}

.gallery-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: #f7fafc;
    position: relative;
}

/* ---- Mosaïque ---- */
.gallery-mosaic {
    columns: 3;
    column-gap: .75rem;
}

.gallery-mosaic-item {
    break-inside: avoid;
    margin-bottom: .75rem;
    border-radius: 8px;
    overflow: hidden;
    cursor: zoom-in;
    position: relative;
    background: #e2e8f0;
}

.gallery-mosaic-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform .3s, filter .3s;
}

.gallery-mosaic-item:hover img {
    transform: scale(1.03);
    filter: brightness(.88);
}

.gallery-loading {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(247,250,252,.85);
    z-index: 2;
    gap: .75rem;
    color: #718096;
}

.gallery-loading[hidden] { display: none; }

.gallery-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: #3182ce;
    border-radius: 50%;
    animation: gallery-spin .7s linear infinite;
    display: inline-block;
}

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

.gallery-empty-album {
    text-align: center;
    color: #a0aec0;
    padding: 3rem;
    font-style: italic;
}

/* =============================================
   Lightbox plein écran
   ============================================= */

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,.95);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-lightbox[hidden] { display: none; }

.gallery-lightbox-backdrop {
    position: absolute;
    inset: 0;
    cursor: zoom-out;
}

.gallery-lb-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: calc(100vw - 140px);
    max-height: 100vh;
}

.gallery-lb-img {
    max-width: 100%;
    max-height: calc(100vh - 60px);
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
    display: block;
}

.gallery-lb-counter {
    color: rgba(255,255,255,.6);
    font-size: .85rem;
    margin-top: .75rem;
    text-align: center;
    letter-spacing: .05em;
}

/* Boutons navigation */
.gallery-lb-nav {
    position: absolute;
    z-index: 2;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.25);
    background: rgba(0,0,0,.45);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
}

.gallery-lb-nav:hover {
    background: rgba(255,255,255,.15);
    border-color: rgba(255,255,255,.6);
}

.gallery-lb-nav:disabled {
    opacity: .2;
    cursor: default;
}

.gallery-lb-prev { left: 1rem; }
.gallery-lb-next { right: 1rem; }

.gallery-lb-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.25);
    background: rgba(0,0,0,.45);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
}

.gallery-lb-close:hover {
    background: rgba(220,38,38,.7);
    border-color: transparent;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .gallery-albums-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    .gallery-mosaic { columns: 2; }
}

@media (max-width: 580px) {
    .gallery-albums-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .gallery-mosaic { columns: 2; column-gap: .5rem; }
    .gallery-mosaic-item { margin-bottom: .5rem; }

    .gallery-modal-box {
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
    }
    .gallery-lb-content {
        max-width: calc(100vw - 80px);
    }
    .gallery-lb-prev { left: .25rem; }
    .gallery-lb-next { right: .25rem; }
}
