/* CSS Custom Properties for easy theming */
:root {
    --primary-color: #6B7A5A; /* Olive green */
    --primary-light: #8A9B7A;
    --primary-dark: #4A5642;
    --background-color: #FAFAFA;
    --surface-color: #FFFFFF;
    --text-primary: #2C2C2C;
    --text-secondary: #666666;
    --border-light: #E5E5E5;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
}

/* Password Protection Styles */
.password-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--background-color) 0%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.password-container {
    background: var(--surface-color);
    padding: 3rem 2.5rem;
    border-radius: 16px;
    box-shadow: 0 20px 40px var(--shadow-medium);
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--border-light);
}

.password-container h1 {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.password-container p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.password-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.password-input {
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: var(--background-color);
    color: var(--text-primary);
}

.password-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(107, 122, 90, 0.1);
}

.password-submit {
    padding: 1rem 1.25rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
}

.password-submit:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-medium);
}

.password-submit:active {
    transform: translateY(0);
}

.password-error {
    color: #d32f2f;
    font-size: 0.9rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background-color: rgba(211, 47, 47, 0.1);
    border-radius: 6px;
    border-left: 4px solid #d32f2f;
    display: none;
}

.password-error.show {
    display: block;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Hide gallery content initially */
.gallery-content {
    display: none;
}

.gallery-content.unlocked {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
}

/* Navigation Header */
.nav-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 8px var(--shadow-light);
    z-index: 1000;
    transition: transform 0.3s ease;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.gallery-title {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: 1px;
}

.chapter-nav {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chapter-nav li {
    margin: 0;
}

.chapter-nav a {
    display: block;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 20px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    white-space: nowrap;
}

.chapter-nav a:hover {
    background-color: var(--primary-light);
    color: white;
    transform: translateY(-1px);
}

.chapter-nav a.active {
    background-color: var(--primary-color);
    color: white;
}

/* Main Gallery */
.gallery-main {
    margin-top: 100px; /* Account for fixed header */
    padding: 2rem 0;
}

.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Chapter Sections */
.chapter-section {
    margin-bottom: 4rem;
    scroll-margin-top: 120px; /* Offset for fixed header */
}

.chapter-title {
    font-size: 2rem;
    font-weight: 300;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-light);
    letter-spacing: 0.5px;
}

.chapter-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: normal;
    margin-left: 1rem;
}

/* NEW DYNAMIC PHOTO GRID */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
    align-items: start;
}

.photo-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-light);
    transition: all 0.3s ease;
    cursor: pointer;
    background-color: var(--surface-color);
    display: block;
    width: 100%;
    grid-column: span 1; /* Default: single column */
}

/* Landscape photos span 2 columns */
.photo-item.landscape {
    grid-column: span 2;
}

/* Portrait photos span 1 column */
.photo-item.portrait {
    grid-column: span 1;
}

/* Square photos span 1 column */
.photo-item.square {
    grid-column: span 1;
}

.photo-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px var(--shadow-medium);
}

.photo-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    object-fit: cover;
    min-height: 200px;
    max-height: 500px;
}

.photo-item:hover img {
    transform: scale(1.05);
}

/* Lazy loading placeholder */
.photo-item.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    min-height: 200px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--background-color);
    z-index: 2000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-light);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3000;
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.lightbox-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 1rem 0.75rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: -60px;
}

.lightbox-next {
    right: -60px;
}

.lightbox-info {
    margin-top: 1rem;
    text-align: center;
    color: white;
    font-size: 0.9rem;
}

.lightbox-counter {
    opacity: 0.8;
}

.lightbox-title {
    margin-left: 1rem;
    font-weight: 500;
}

/*loading state for lightbox */
.lightbox-image {
    transition: opacity 0.3s ease;
}

.lightbox.active::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.lightbox-image[src]:not([src=""]) ~ .lightbox::before {
    opacity: 0;
}


/* Error Message */
.error-message {
    text-align: center;
    padding: 4rem 2rem;
    margin-top: 100px;
    color: var(--text-secondary);
}

.error-message h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.error-message code {
    background-color: var(--border-light);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* RESPONSIVE DESIGN WITH DYNAMIC GRID */
@media (max-width: 1200px) {
    .photo-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
    }
    
    .photo-item.landscape {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        padding: 1rem;
        text-align: center;
    }
    
    .gallery-title {
        margin-bottom: 1rem;
        font-size: 1.25rem;
    }
    
    .chapter-nav {
        justify-content: center;
    }
    
    .gallery-main {
        margin-top: 140px;
        padding: 1rem 0;
    }
    
    .gallery-container {
        padding: 0 1rem;
    }
    
    .photo-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .photo-item.landscape {
        grid-column: span 2;
    }
    
    .chapter-title {
        font-size: 1.5rem;
    }
    
    .lightbox-nav {
        display: none; /* Hide nav arrows on mobile */
    }
    
    .lightbox-close {
        top: -40px;
        font-size: 1.5rem;
        width: 35px;
        height: 35px;
    }
}

@media (max-width: 480px) {
    .photo-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .photo-item.landscape,
    .photo-item.portrait,
    .photo-item.square {
        grid-column: span 1;
    }
    
    .gallery-container {
        padding: 0 0.5rem;
    }
}