/* =============================================================================
   GALLERY & LIGHTBOX - MHB Theme
   Galerie masonry avec lightbox pour albums photos
   ============================================================================= */

/* =============================================================================
   GALLERY GRID - MASONRY
   ============================================================================= */

.mhb-gallery {
    padding: 0 0 80px;
}

.mhb-gallery__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    grid-auto-rows: 10px;
}

.mhb-gallery__item {
    position: relative;
    overflow: hidden;
    border-radius: var(--mhb-radius-md);
    background: var(--mhb-bg-dark-alt);
}

/* Masonry-like varying heights */
.mhb-gallery__item:nth-child(4n+1) { grid-row: span 28; }
.mhb-gallery__item:nth-child(4n+2) { grid-row: span 22; }
.mhb-gallery__item:nth-child(4n+3) { grid-row: span 32; }
.mhb-gallery__item:nth-child(4n+4) { grid-row: span 25; }

/* Variation pour plus de dynamisme */
.mhb-gallery__item:nth-child(5n+1) { grid-row: span 30; }
.mhb-gallery__item:nth-child(7n+1) { grid-row: span 35; }
.mhb-gallery__item:nth-child(11n+1) { grid-row: span 26; }

.mhb-gallery__link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
}

.mhb-gallery__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.mhb-gallery__hover {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mhb-gallery__hover svg {
    color: #fff;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.mhb-gallery__item:hover .mhb-gallery__img {
    transform: scale(1.05);
}

.mhb-gallery__item:hover .mhb-gallery__hover {
    opacity: 1;
}

.mhb-gallery__item:hover .mhb-gallery__hover svg {
    transform: scale(1);
}

/* =============================================================================
   LIGHTBOX
   ============================================================================= */

.mhb-album-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mhb-album-lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

.mhb-album-lightbox__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
}

.mhb-album-lightbox__container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 80px;
}

.mhb-album-lightbox__close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, transform 0.3s ease;
    z-index: 10;
}

.mhb-album-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.mhb-album-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, transform 0.3s ease;
    z-index: 10;
}

.mhb-album-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mhb-album-lightbox__nav--prev {
    left: 20px;
}

.mhb-album-lightbox__nav--prev:hover {
    transform: translateY(-50%) translateX(-3px);
}

.mhb-album-lightbox__nav--next {
    right: 20px;
}

.mhb-album-lightbox__nav--next:hover {
    transform: translateY(-50%) translateX(3px);
}

.mhb-album-lightbox__content {
    position: relative;
    max-width: 100%;
    max-height: calc(100% - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mhb-album-lightbox__loader {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mhb-album-lightbox__spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--mhb-accent);
    border-radius: 50%;
    animation: lightboxSpin 0.8s linear infinite;
}

@keyframes lightboxSpin {
    to { transform: rotate(360deg); }
}

.mhb-album-lightbox__image {
    max-width: 100%;
    max-height: calc(100vh - 160px);
    object-fit: contain;
    border-radius: var(--mhb-radius-md);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
}

.mhb-album-lightbox__footer {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 50px;
    padding: 0 20px;
}

.mhb-album-lightbox__caption {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    max-width: 600px;
}

.mhb-album-lightbox__counter {
    font-family: var(--mhb-font-display);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 2px;
}

.mhb-album-lightbox__current {
    color: #fff;
    font-weight: 700;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 1200px) {
    .mhb-gallery__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .mhb-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .mhb-gallery__item:nth-child(4n+1),
    .mhb-gallery__item:nth-child(4n+2),
    .mhb-gallery__item:nth-child(4n+3),
    .mhb-gallery__item:nth-child(4n+4),
    .mhb-gallery__item:nth-child(5n+1),
    .mhb-gallery__item:nth-child(7n+1),
    .mhb-gallery__item:nth-child(11n+1) {
        grid-row: span 20;
    }

    .mhb-gallery__item:nth-child(odd) { grid-row: span 22; }
    .mhb-gallery__item:nth-child(even) { grid-row: span 18; }
    .mhb-gallery__item:nth-child(3n+1) { grid-row: span 25; }

    .mhb-album-lightbox__container {
        padding: 60px 20px;
    }

    .mhb-album-lightbox__nav {
        width: 45px;
        height: 45px;
    }

    .mhb-album-lightbox__nav--prev {
        left: 10px;
    }

    .mhb-album-lightbox__nav--next {
        right: 10px;
    }
}

@media (max-width: 576px) {
    .mhb-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        grid-auto-rows: 8px;
    }

    .mhb-gallery__item {
        border-radius: var(--mhb-radius-sm);
    }

    .mhb-gallery__item:nth-child(odd),
    .mhb-gallery__item:nth-child(even),
    .mhb-gallery__item:nth-child(3n+1) {
        grid-row: span 16;
    }

    .mhb-gallery__item:nth-child(odd) { grid-row: span 18; }
    .mhb-gallery__item:nth-child(even) { grid-row: span 14; }

    .mhb-album-lightbox__nav {
        width: 40px;
        height: 40px;
        top: auto;
        bottom: 80px;
        transform: none;
    }

    .mhb-album-lightbox__nav--prev {
        left: 20px;
    }

    .mhb-album-lightbox__nav--next {
        right: 20px;
    }

    .mhb-album-lightbox__nav--prev:hover,
    .mhb-album-lightbox__nav--next:hover {
        transform: none;
    }

    .mhb-album-lightbox__close {
        width: 40px;
        height: 40px;
    }

    .mhb-album-lightbox__footer {
        flex-direction: column;
        gap: 8px;
        bottom: 15px;
    }

    .mhb-album-lightbox__image {
        max-height: calc(100vh - 200px);
    }
}
