/* ===== GALLERY PAGE STYLES ===== */

/* Header nav for gallery */
.header-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.header-nav-link {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-500);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.header-nav-link:hover {
    color: var(--gray-800);
    background: var(--gray-100);
}

.header-nav-link.active {
    color: var(--green-600);
    background: var(--green-50);
    font-weight: 600;
}

/* Gallery Hero */
.gallery-hero {
    padding: 8rem 1.5rem 3rem;
    text-align: center;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--green-50) 50%, var(--gray-50) 100%);
    position: relative;
    overflow: hidden;
}

.gallery-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(5, 150, 105, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.gallery-hero-content {
    max-width: 640px;
    margin: 0 auto;
}

.gallery-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--white);
    border: 1px solid var(--green-100);
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--green-600);
    margin-bottom: 1.5rem;
}

.gallery-hero h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    color: var(--gray-900);
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.gallery-hero h1 span {
    color: var(--green-600);
}

.gallery-hero-subtitle {
    font-size: 1.1rem;
    color: var(--gray-500);
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.gallery-hero-desc {
    font-size: 0.9rem;
    color: var(--gray-400);
}

.gallery-hero-author {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.35rem 1rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-500);
    font-style: italic;
}

/* Gallery Section */
.gallery-section {
    padding: 2rem 1.5rem 4rem;
    background: var(--gray-50);
    min-height: 60vh;
}

/* Gallery Grid — CSS Grid Mosaic */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 220px;
    gap: 6px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Landscape photos: 1 col x 1 row (default) */
.gallery-item {
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    background: var(--gray-200);
    transform: translateZ(0);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Portrait photos: span 2 rows */
.gallery-item.portrait {
    grid-row: span 2;
}

/* Featured items: span 2 cols x 2 rows (every ~20th photo) */
.gallery-item.featured {
    grid-column: span 2;
    grid-row: span 2;
}

.gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

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

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

/* Hover overlay */
.gallery-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(5, 150, 105, 0.6) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 1rem;
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-overlay svg {
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* Skeleton loading */
.gallery-item.skeleton {
    aspect-ratio: 3 / 2;
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Fade in animation */
.gallery-item.loaded {
    animation: gallery-fade-in 0.5s ease forwards;
}

@keyframes gallery-fade-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loader */
.gallery-loader {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--gray-400);
    font-size: 0.9rem;
}

.gallery-loader.visible {
    display: flex;
}

.gallery-loader-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--green-500);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ===== LIGHTBOX ===== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(16px);
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

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

.lightbox-image {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
}

.lightbox-image.loading {
    opacity: 0.3;
}

.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.lightbox-loading.visible {
    display: block;
}

.lightbox-loading .gallery-loader-spinner {
    border-color: rgba(255,255,255,0.2);
    border-top-color: white;
}

.lightbox-bottom {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    padding: 0.75rem 1.5rem;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.lightbox-counter {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.lightbox-author {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    font-style: italic;
    white-space: nowrap;
}

.lightbox-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: var(--green-600);
    color: white;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 100px;
    transition: background 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}

.lightbox-download:hover {
    background: var(--green-500);
    transform: scale(1.05);
}

/* Back to top */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    width: 48px;
    height: 48px;
    background: var(--green-600);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
    pointer-events: none;
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.back-to-top:hover {
    background: var(--green-500);
    transform: translateY(-2px);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 200px;
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 160px;
        gap: 4px;
    }

    .gallery-item {
        border-radius: 6px;
    }

    /* On mobile, featured items only span 2 cols (not 2 rows) */
    .gallery-item.featured {
        grid-column: span 2;
        grid-row: span 1;
    }

    .gallery-hero {
        padding: 7rem 1rem 2rem;
    }

    .gallery-hero h1 {
        font-size: 1.8rem;
    }

    .gallery-section {
        padding: 1rem 0.5rem 3rem;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .lightbox-prev {
        left: 0.5rem;
    }

    .lightbox-next {
        right: 0.5rem;
    }

    .lightbox-bottom {
        bottom: 1rem;
        padding: 0.6rem 1rem;
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .lightbox-close {
        top: 0.5rem;
        right: 0.5rem;
        width: 40px;
        height: 40px;
    }

    .header-nav-link {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 140px;
        gap: 3px;
    }

    .gallery-item {
        border-radius: 4px;
    }

    .gallery-item.featured {
        grid-column: span 2;
        grid-row: span 1;
    }

    .gallery-item.portrait {
        grid-row: span 2;
    }

    .gallery-hero h1 {
        font-size: 1.5rem;
    }

    .gallery-hero-subtitle {
        font-size: 0.95rem;
    }

    .lightbox-image {
        max-width: 96vw;
        max-height: 75vh;
        border-radius: 4px;
    }
}
