/* ==========================================================================
   Gallery Page & Lightbox
   ========================================================================== */

/* ── Gallery Page Grid ── */
.gallery-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-sm);
}

.gallery-page-grid .gallery-item {
    aspect-ratio: 1;
}

/* ── Masonry-style variation ── */
.gallery-page-grid .gallery-item:nth-child(5n+1) {
    grid-row: span 2;
    aspect-ratio: auto;
}

/* ── Lightbox ── */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    backdrop-filter: blur(5px);
}

.gallery-lightbox::backdrop {
    background: rgba(0, 0, 0, 0.92);
}

.gallery-lightbox[open] {
    animation: lightboxFadeIn 0.3s ease;
}

@keyframes lightboxFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.lightbox-inner {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-inner img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: var(--sce-white);
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.lightbox-close:hover {
    opacity: 1;
}

.lightbox-caption {
    position: absolute;
    bottom: -40px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
}

.lightbox-counter {
    position: absolute;
    top: -40px;
    left: 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    font-weight: 500;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--sce-white);
    font-size: 1.5rem;
    cursor: pointer;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: -60px;
}

.lightbox-next {
    right: -60px;
}

/* ── Gallery Item Photo Count Badge ── */
.gallery-item-count {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-xl);
    margin-top: 0.35rem;
    backdrop-filter: blur(4px);
}

/* ── Gallery Item Placeholder ── */
.gallery-item-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, hsl(330, 65%, 55%), hsl(280, 55%, 45%));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    padding: 1rem;
    text-align: center;
}

.gallery-item-placeholder span {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .gallery-page-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .gallery-page-grid .gallery-item:nth-child(5n+1) {
        grid-row: span 1;
        aspect-ratio: 1;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.5);
    }
}
