/* Gallery Specific Styles */

/* Gallery Section – responsive, near full width, small gaps, aligned rows (matches featured grid) */
.gallery-section {
    padding: calc(var(--spacing-unit) * 6) 0 calc(var(--spacing-unit) * 12);
}

.gallery-section-container.container {
    max-width: 100%;
    padding-left: var(--spacing-unit);
    padding-right: var(--spacing-unit);
}

@media (min-width: 480px) {
    .gallery-section-container.container {
        padding-left: calc(var(--spacing-unit) * 1.5);
        padding-right: calc(var(--spacing-unit) * 1.5);
    }
}

@media (min-width: 768px) {
    .gallery-section-container.container {
        padding-left: calc(var(--spacing-unit) * 2);
        padding-right: calc(var(--spacing-unit) * 2);
    }
}

@media (min-width: 1200px) {
    .gallery-section-container.container {
        padding-left: calc(var(--spacing-unit) * 3);
        padding-right: calc(var(--spacing-unit) * 3);
    }
}

.gallery-grid-wrap {
    width: 100%;
    max-width: 100%;
}

/* Flexbox-based grid: rows span full width with gaps on all sides */
.gallery-grid {
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 2);
    width: 100%;
}

.gallery-row {
    display: flex;
    gap: calc(var(--spacing-unit) * 2);
    width: 100%;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border-radius: 6px;
    flex: 1;
    background-color: var(--border-color);
    transition: background-color 0.3s ease;
}

/* Images crop from center when needed for alignment */
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 1s ease-out, opacity 0.3s ease;
}

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

/* Responsive gaps */
@media (max-width: 768px) {
    .gallery-grid,
    .gallery-row {
        gap: var(--spacing-unit);
    }
}

.gallery-overlay {
    display: none;
}

.view-icon {
    display: none;
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#lightbox-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    user-select: none;
}

.lightbox-caption {
    color: #FFFFFF;
    margin-top: calc(var(--spacing-unit) * 2);
    text-align: center;
    font-size: 1rem;
    letter-spacing: 0.05em;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: fixed;
    background: none;
    border: none;
    color: #FFFFFF;
    font-size: 3rem;
    cursor: pointer;
    padding: calc(var(--spacing-unit) * 2);
    transition: opacity 0.3s ease;
    z-index: 2001;
    user-select: none;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    opacity: 0.7;
}

.lightbox-close {
    top: calc(var(--spacing-unit) * 2);
    right: calc(var(--spacing-unit) * 2);
    font-size: 4rem;
    line-height: 1;
}

.lightbox-prev {
    left: calc(var(--spacing-unit) * 2);
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-next {
    right: calc(var(--spacing-unit) * 2);
    top: 50%;
    transform: translateY(-50%);
}

@media (max-width: 768px) {
    .lightbox-close {
        top: calc(var(--spacing-unit) * 1);
        right: calc(var(--spacing-unit) * 1);
        font-size: 3rem;
    }

    .lightbox-prev,
    .lightbox-next {
        font-size: 2.5rem;
        padding: calc(var(--spacing-unit) * 1);
    }

    .lightbox-prev {
        left: 0;
    }

    .lightbox-next {
        right: 0;
    }

    #lightbox-image {
        max-height: 80vh;
    }
}

/* Loading State */
.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FFFFFF;
    font-size: 1.2rem;
}

/* Smooth Image Loading */
.gallery-item img,
.featured-item img {
    opacity: 0;
    transition: transform 1s ease-out, opacity 0.3s ease;
}

.gallery-item img.loaded,
.featured-item img.loaded {
    opacity: 1;
}
