/* Modern Gallery Styles */

/* Gallery Hero Section */
.gallery-hero {
    padding: 7rem 0 2.5rem; /* ensure clear of fixed navbar */
    /* Provide a subtle, high-contrast backdrop for headings */
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    text-align: center;
    position: relative;
}

.gallery-hero::before { display: none; }

.gallery-hero-content {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.gallery-title, #gallery .section-title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.1;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.gallery-subtitle, #gallery .section-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    font-weight: 500;
    transition: color 0.3s ease;
}

.gallery-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 2rem;
    max-width: 500px;
    margin: 0 auto;
}

.gallery-stat {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    padding: 2rem;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.gallery-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-stellar);
}

.gallery-stat:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.gallery-stat .stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.gallery-stat .stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Modern Gallery Filters */
.gallery-filters {
    padding: 1.25rem 0;
    background: rgba(255, 255, 255, 0.88); /* lighter for better contrast */
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    margin: 0 1.5rem 1.25rem; /* slight gap below nav */
}

/* Wrap around filters/grid to control bottom spacing and match index footer */
.gallery-main-wrap {
    padding-bottom: 4rem;
}

/* Match index footer spacing above footer */
footer.footer {
    margin-top: 2rem;
}

.filter-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.search-box {
    flex: 1;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 9999px;
    font-size: 1rem;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m21 21-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") no-repeat 0.75rem center;
    background-size: 1rem;
    background-color: rgba(255,255,255,0.98);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.filter-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.filter-group select {
    padding: 0.75rem 1rem;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 9999px;
    font-size: 0.875rem;
    background: rgba(255,255,255,0.9);
    cursor: pointer;
    transition: border-color 0.3s ease;
    min-width: 120px;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.clear-filters, #clear-filters {
    background: rgba(255,255,255,0.9);
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.25);
    padding: 0.75rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-filters:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Gallery Grid */
.gallery-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

/* Modern Photo Grid */
#photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 2rem 1rem;
    max-width: 1400px;
    margin: 0 auto;
    background: linear-gradient(180deg, rgba(229,90,60,0.04) 0%, rgba(101,182,167,0.04) 100%);
    border-radius: 20px;
}

/* Reusable photo-card styling (glassy, rounded, overlay text) */
.photo-card {
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    min-height: 220px;
}

.photo-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
}

.photo-card img {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: cover;
    transition: transform 0.35s ease;
    flex-shrink: 0;
}

.photo-card:hover img { transform: scale(1.05); }

.photo-card .photo-card__overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 16px 18px;
    color: white;
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.55) 85%);
}

.photo-card .photo-card__title {
    margin: 0 0 6px 0;
    font-weight: 700;
    font-size: 1.05rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.photo-card .photo-card__meta {
    font-size: 0.9rem;
    opacity: 0.95;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* Desktop caption styling - hidden on mobile */
.photo-card__desktop-caption {
    display: none;
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
    text-align: center;
}

.desktop-caption__title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 6px;
    line-height: 1.25;
    text-align: center;
}

.desktop-caption__details {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    color: #6b7280;
    font-size: 0.92rem;
}

.desktop-caption__year {
    font-size: 0.92rem;
    color: #6b7280;
    font-weight: 500;
}

.desktop-caption__maps {
    font-size: 0.92rem;
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
    padding: 0;
    background: transparent;
    border-radius: 0;
    transition: color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.desktop-caption__maps:hover {
    text-decoration: underline;
    color: #1d4ed8;
}

/* Dot separator only when both year and link exist */
.desktop-caption__year + .desktop-caption__maps::before {
    content: '•';
    color: #9ca3af;
    margin-right: 6px;
}

/* Show desktop captions only on desktop/tablet */
@media (min-width: 768px) {
    .photo-card .photo-card__desktop-caption {
        display: block !important;
    }
    
    /* Hide mobile overlay on desktop */
    .photo-card .photo-card__overlay {
        display: none !important;
    }
    
    /* Make sure the image takes proper space */
    .photo-card img {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }
}

.photo-item { 
    background: transparent; 
    border-radius: 18px; 
    overflow: visible; 
    border: none; 
    box-shadow: none; 
    padding: 0; 
    cursor: pointer;
}
.photo-item .photo-card { 
    display: flex; 
    flex-direction: column;
    height: 100%;
}
.photo-thumbnail { display: none; }
.photo-info { display: none; }

.photo-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
    color: #1a1a2e;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.photo-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.photo-location {
    font-size: 0.875rem;
    color: #4a5568;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.photo-location::before {
    content: "📍";
    font-size: 0.75rem;
}

.photo-year {
    font-size: 0.875rem;
    color: #4a5568;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.photo-year::before {
    content: "📅";
    font-size: 0.75rem;
}

.photo-coordinates {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.photo-coordinates a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    display: inline-block;
    transition: all 0.2s ease;
}

.photo-coordinates a:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.photo-year {
    color: var(--text-light);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.photo-year::before {
    content: "📅";
    font-size: 0.75rem;
}

.photo-coordinates {
    font-size: 0.75rem;
}

.photo-coordinates a {
    color: var(--primary-color);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.photo-coordinates a::before {
    content: "🗺️";
    font-size: 0.625rem;
}

.photo-coordinates a:hover {
    background: var(--primary-color);
    color: white;
}

.no-coordinates {
    color: var(--text-light);
    font-style: italic;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 3rem;
}

.pagination button {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    min-width: 2.5rem;
}

.pagination button:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.pagination button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination span {
    color: var(--text-light);
    padding: 0 0.5rem;
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4rem;
    color: var(--text-secondary);
}

.loading::before {
    content: "";
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2vh 2vw; /* breathe around content so edges aren’t clipped */
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    position: relative;
    max-width: min(1200px, 96vw);
    max-height: 96vh;
    background: transparent; /* image defines visual bounds */
    border-radius: var(--radius-lg);
    overflow: hidden; /* keep buttons within box */
    box-shadow: var(--shadow-xl);
}

/* Ensure overlays anchor to the image area */
.lightbox-image-container { position: relative; }
.lightbox-image-container > img { display:block; }

/* Subtle metadata caption inside lightbox */
.lightbox-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.75rem;
    display: flex !important;
    justify-content: center;
    pointer-events: none;
    z-index: 99;
}

.lightbox-caption .caption-inner {
    pointer-events: auto;
    background: rgba(15,23,42,0.38);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    font-size: 0.95rem;
    line-height: 1;
    display: inline-flex;
    gap: 0.6rem;
    align-items: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

/* Subtle gray map link inside the desktop caption */
.lightbox-caption .caption-inner .maps-link {
    color: #cbd5e1; /* slate-300 */
    text-decoration: none;
}
.lightbox-caption .caption-inner .maps-link:hover { color: #e2e8f0; }

.lightbox-caption .dot { opacity: 0.7; }

.lightbox-image {
    /* Fit entire image within viewport; never crop */
    display: block;
    width: auto;
    height: auto;
    max-width: 96vw;
    max-height: 96vh;
    object-fit: contain;
    margin: 0 auto;
}

.lightbox-info { padding: 1.25rem 1.5rem 1.75rem; }

.lightbox-title {
    font-size: clamp(1.25rem, 1.2vw + 1rem, 1.75rem);
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.lightbox-details { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }

.lightbox-location,
.lightbox-year,
.lightbox-coordinates {
    padding: 0.4rem 0.6rem;
    background: rgba(255,255,255,0.06);
    border-radius: 999px;
    font-size: 0.9rem;
    color: #e2e8f0;
}

.lightbox-coordinates a,
.maps-link {
    color: var(--accent, var(--primary-color));
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    background: color-mix(in oklab, var(--accent, #60a5fa) 15%, transparent);
    border: 1px solid color-mix(in oklab, var(--accent, #60a5fa) 30%, transparent);
}

.lightbox-coordinates a::before,
.maps-link::before { content: "🗺️"; font-size: 0.85em; }

.lightbox-coordinates a:hover,
.maps-link:hover { background: color-mix(in oklab, var(--accent, #60a5fa) 25%, transparent); }

.lightbox-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    transition: background 0.3s ease;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Navigation Buttons */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-btn:disabled:hover {
    transform: translateY(-50%) scale(1);
}

#prev-btn {
    left: 1rem;
}

#next-btn {
    right: 1rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .gallery-title {
        font-size: 2.5rem;
    }
    
    .filter-container {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .filter-group {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .gallery-hero {
        padding: 6rem 0 3rem;
    }
    
    .gallery-title {
        font-size: 2rem;
    }
    
    .gallery-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
    
    .gallery-stat {
        padding: 1rem;
    }
    
    .gallery-stat .stat-number {
        font-size: 1.5rem;
    }
    
    .gallery-main {
        padding: 2rem 1rem;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }
    
    .lightbox-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .lightbox-info {
        padding: 1.5rem;
    }
    
    .lightbox-details {
        grid-template-columns: 1fr;
    }
    
    .nav-btn {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .gallery-filters {
        padding: 1rem 0;
    }
    
    .filter-container {
        padding: 0 1rem;
    }
    
    .search-box {
        min-width: auto;
    }
    
    /* Small phone layout */
    #photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 0.75rem;
        padding: 1rem;
    }
    
    .photo-item {
        border-radius: 12px;
    }
    
    .photo-thumbnail {
        height: 160px;
    }
    
    .photo-info {
        padding: 0.875rem;
    }
    
    .photo-title {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    .photo-location,
    .photo-year {
        font-size: 0.8rem;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .pagination button {
        padding: 0.5rem 0.75rem;
        min-width: 2rem;
    }
    
    /* Mobile photo grid improvements */
    #photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1rem;
        padding: 1.5rem;
    }
    
    .photo-thumbnail {
        height: 200px;
    }
    
    .photo-info {
        padding: 1rem;
    }

    /* iPhone-friendly lightbox layout */
    .lightbox { padding: max(env(safe-area-inset-top), 10px) 10px max(env(safe-area-inset-bottom), 10px); }
    .lightbox-content { width: 100%; max-width: 100vw; max-height: calc(100vh - 20px); border-radius: 18px; }
    .lightbox-image { width: 100%; max-width: 100%; max-height: calc(100vh - 220px); }
    /* Hide the floating caption pill on small screens, rely on title/details block */
    .lightbox-caption { display: none !important; }
    .lightbox-title { display: block; }
    .lightbox-caption .caption-inner { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); font-size: 0.9rem; padding: 0.4rem 0.6rem; }
    .lightbox-info { padding: 0.7rem 0.85rem; margin-top: 0.5rem; background: rgba(0,0,0,0.52); color: #e5e7eb; border-radius: 12px; }
    .lightbox-details { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 0.5rem; }
    .lightbox-location, .lightbox-year, .lightbox-coordinates { background: transparent; padding: 0; color: #cbd5e1; }
    .lightbox-coordinates a { background: rgba(255,255,255,0.06); color: #93c5fd; border: 1px solid rgba(255,255,255,0.12); font-size: 0.8rem; padding: 0.15rem 0.5rem; border-radius: 999px; }
    /* Minimize or hide big downloads on phones */
    #download-link.download-btn, .download-btn { display: none !important; }
    .nav-btn { width: 42px; height: 42px; left: auto; right: auto; background: rgba(0,0,0,0.55); border:1px solid rgba(255,255,255,0.12); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
    #prev-btn { left: 8px; }
    #next-btn { right: 8px; }
}