/* Gallery Page Styles */

.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 3rem 1.5rem;
}

.gallery-container h1 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--nav-color, #801010);
}

.gallery-date {
    text-align: center;
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 1rem;
    font-style: italic;
}

/* Photo Grid - 4 columns default */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-top: 2rem;
    justify-content: center;
}

/* Note: With 198 photos:
   - 6 columns: 33 rows (no remainder)
   - 5 columns: 39 rows + 3 remainder (centered above)
   - 4 columns: 49 rows + 2 remainder 
   - 3 columns: 66 rows (no remainder)
   - 1 column: 198 rows (no remainder)
*/

/* Responsive breakpoints */
/* 2000+ px - 6 columns */
@media (min-width: 2000px) {
    .photo-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* 1650 - 2000 px - 5 columns */
@media (min-width: 1650px) and (max-width: 1999px) {
    .photo-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* 1300 - 1650 px - 4 columns */
@media (min-width: 1300px) and (max-width: 1649px) {
    .photo-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 950 - 1300 px - 3 columns */
@media (min-width: 950px) and (max-width: 1299px) {
    .photo-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 600 - 950 px - 2 columns */
@media (min-width: 600px) and (max-width: 949px) {
    .photo-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Less than 600 px - 1 column */
@media (max-width: 599px) {
    .photo-grid {
        grid-template-columns: 1fr;
    }
}

/* Individual photo container */
.photo-item {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
    background: #f5f5f5;
    cursor: pointer;
    transition: transform 0.3s ease;
    transform-origin: center;
}

.photo-item:hover {
    transform: scale(1.05);
    z-index: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.photo-item a {
    display: block;
    width: 100%;
    height: 100%;
}

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

/* Adjust aspect ratio for portrait photos */
.photo-item.portrait {
    grid-row: span 2;
    aspect-ratio: 3/4;
}

/* Landscape photos can span 2 columns occasionally */
.photo-item.landscape-wide {
    grid-column: span 2;
    aspect-ratio: 2/1;
}

/* Loading state */
.photo-item.loading {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #f8f8f8 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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


/* Lightbox styles */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    overflow: auto;
    cursor: zoom-out;
    visibility: hidden;
    opacity: 0;
}

.lightbox:target {
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: visible;
    opacity: 1;
}

/* Use content-visibility to defer rendering of non-visible lightboxes */
.lightbox:not(:target) {
    content-visibility: auto;
    contain-intrinsic-size: 100vw 100vh;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    margin: auto;
    cursor: default;
    display: inline-block;
}

.lightbox-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    cursor: zoom-in;
}

/* Close button - positioned relative to image */
.lightbox-close {
    position: absolute;
    top: 25px;
    right: 25px;
    color: white;
    font-size: 2.5rem;
    font-weight: 300;
    text-decoration: none;
    line-height: 1;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.7);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.lightbox-close:hover {
    opacity: 0.9;
    transform: scale(1.1);
}

/* Download button - positioned bottom right, mirroring close button */
.lightbox-download {
    position: absolute;
    bottom: 25px;
    right: 25px;
    width: 2.5rem;
    height: 2.5rem;
    background-image: url('../icons/download.svg');
    background-size: 24px 24px;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
    filter: brightness(0) invert(1) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.7));
}

.lightbox-download:hover {
    opacity: 0.9;
    transform: scale(1.1);
}

/* Navigation arrows - positioned fixed relative to viewport */
.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 3rem;
    text-decoration: none;
    font-weight: 300;
    transition: opacity 0.2s;
    user-select: none;
    z-index: 10;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.lightbox-nav:hover {
    opacity: 0.7;
}

/* Position arrows outside the image container */
.lightbox-prev {
    left: -60px; /* Outside left edge of image container */
}

.lightbox-next {
    right: -60px; /* Outside right edge of image container */
}

/* Photo number indicator - positioned relative to photo bottom */
.lightbox-counter {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 0.9rem;
    opacity: 0.8;
    z-index: 10;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Click outside to close - backdrop link */
.lightbox-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: zoom-out;
}

.lightbox-content {
    position: relative;
    z-index: 2;
}

/* Mobile adjustments */
@media (max-width: 918px) {
    .lightbox-content {
        max-width: 100%;
        max-height: 100vh;
    }
    
    .lightbox-image {
        max-width: 100%;
        max-height: 100vh;
    }
    
    .lightbox-close {
        top: 20px;
        right: 20px;
    }
    
    .lightbox-download {
        bottom: 20px;
        right: 20px;
    }
    
    .lightbox-prev {
        left: 20px;
    }
    
    .lightbox-next {
        right: 20px;
    }
}

/* Print styles */
@media print {
    .photo-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .lightbox {
        display: none !important;
    }
}

/* Download buttons */
.download-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.download-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: var(--nav-color, #801010);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease;
    text-align: center;
    min-width: 200px;
}

.download-btn:hover {
    background-color: #a01515;
    transform: translateY(-1px);
}

.download-btn:active {
    transform: translateY(0);
}

/* Mobile adjustments for download buttons */
@media (max-width: 768px) {
    .download-buttons {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }

    .download-btn {
        min-width: 250px;
        padding: 1rem 2rem;
    }
}