/* Lightbox Base */
#lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;

    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

/* Active State */
#lightbox.active {
    opacity: 1;
    visibility: visible;
}

/* Image */
#lightbox img {
    max-width: 90%;
    max-height: 85vh;
    border-radius: 12px;
    object-fit: contain;
}

/* Navigation Buttons */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
}

.lightbox-nav.prev {
    left: 20px;
}

.lightbox-nav.next {
    right: 20px;
}

/* Card bottom title overlay */
.gallery-title-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, transparent 100%);
    padding: 32px 14px 14px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    pointer-events: none;
}

/* Lightbox title bar */
#lightbox-title-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 20px 60px 18px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.01em;
    pointer-events: none;
}

#lightbox-title:empty + * ,
#lightbox-title-bar:has(#lightbox-title:empty) {
    display: none;
}

/* Repeating asymmetric grid spans & heights for the backend loop */
@media (min-width: 768px) {
    .gallery-card:nth-child(6n+1) {
        grid-column: span 8 / span 8;
        height: 500px;
    }
    .gallery-card:nth-child(6n+2) {
        grid-column: span 4 / span 4;
        height: 500px;
    }
    .gallery-card:nth-child(6n+3) {
        grid-column: span 5 / span 5;
        height: 400px;
    }
    .gallery-card:nth-child(6n+4) {
        grid-column: span 7 / span 7;
        height: 400px;
    }
    .gallery-card:nth-child(6n+5) {
        grid-column: span 6 / span 6;
        height: 450px;
    }
    .gallery-card:nth-child(6n+6) {
        grid-column: span 6 / span 6;
        height: 450px;
    }
}

/* Mobile responsive fallback: full width and standard height */
@media (max-width: 767px) {
    .gallery-card {
        height: 350px !important;
    }
}