/* ==========================================================================
   ELLIOTT PICTURES GALLERY - MAIN STYLESHEET
   --------------------------------------------------------------------------
   This file implements a premium, modern, responsive dark theme design
   utilizing glassmorphism, smooth animations, and photography-first layouts.
   ========================================================================== */

/* 1. CSS VARIABLES (Design Tokens) */
:root {
    --bg-main: #0a0b0d;          /* Deep slate background */
    --bg-card: #15171c;          /* Muted card background */
    --text-primary: #f3f4f6;     /* White/off-white for headers */
    --text-secondary: #9ca3af;   /* Muted gray for descriptions/metadata */
    --accent: #d4af37;           /* Warm gold accent */
    --accent-hover: #f1c40f;     /* Vibrant yellow-gold for active states */
    --glass-bg: rgba(21, 23, 28, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 2. BASE RESET & TYPOGRAPHY */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 3. LAYOUT & CONTAINERS */
.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* 4. HEADER SECTION */
.gallery-header {
    text-align: center;
    max-width: 700px;
    margin: 0 auto 4rem auto;
}

.gallery-title {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #ffffff 40%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gallery-intro {
    font-size: clamp(1rem, 2vw, 1.15rem);
    font-weight: 300;
    color: var(--text-secondary);
}

/* 5. PHOTO GRID SYSTEM */
.gallery-grid-wrapper {
    flex-grow: 1;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    position: relative;
    min-height: 250px;
}

/* 6. PHOTO CARDS & THUMBNAILS */
.gallery-item {
    background-color: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: var(--transition-smooth);
    aspect-ratio: 3 / 2; /* Unified landscape crop for stability */
}

/* Card Hover Animations */
.gallery-item:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: var(--shadow-lg);
    border-color: rgba(212, 175, 55, 0.3); /* Subtle gold border on hover */
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), filter 0.6s ease;
    filter: brightness(0.9);
}

.gallery-item:hover img {
    transform: scale(1.06);
    filter: brightness(1.05);
}

/* Caption Overlay (Appears on Hover) */
.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem;
    background: linear-gradient(to top, rgba(10, 11, 13, 0.9) 0%, rgba(10, 11, 13, 0.4) 70%, transparent 100%);
    opacity: 0;
    transform: translateY(10px);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none; /* Let clicks pass through to parent item */
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
    transform: translateY(0);
}

.gallery-item-caption {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 7. LOADING INDICATORS & SPINNERS */
.loading-indicator {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 0;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(212, 175, 55, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

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

/* 8. LIGHTBOX OVERLAY */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(5, 6, 8, 0.96);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 2000;
    display: none; /* Managed by JS */
    opacity: 0;
    transition: opacity 0.4s ease;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.lightbox.active {
    opacity: 1;
}

/* Make Lightbox scroll-free */
body.lightbox-open {
    overflow: hidden;
}

/* Lightbox Content Layout */
.lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 90%;
    height: 90%;
    max-width: 1100px;
    position: relative;
}

.lightbox-image-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox.active .lightbox-image {
    opacity: 1;
    transform: scale(1);
}

/* Image spinner inside lightbox */
.lightbox-spinner {
    position: absolute;
    display: none;
}

/* Lightbox Info & Glassmorphism Details */
.lightbox-info {
    width: 100%;
    max-width: 800px;
    margin-top: 1.5rem;
    padding: 1.25rem 2rem;
    background-color: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.lightbox-caption {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.lightbox-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 0.5rem;
}

.lightbox-counter {
    font-weight: 500;
}

.lightbox-keyboard-hint {
    opacity: 0.6;
}

/* 9. LIGHTBOX CONTROLS (UI Buttons) */
.lightbox-btn {
    position: absolute;
    background-color: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: var(--transition-smooth);
    z-index: 2100;
}

.lightbox-btn:hover {
    background-color: rgba(212, 175, 55, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

/* Close button (top right) */
.close-btn {
    top: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.75rem;
    line-height: 1;
}

/* Next / Prev Nav buttons (sides) */
.prev-btn, .next-btn {
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 1.25rem;
}

.prev-btn { left: 2rem; }
.next-btn { right: 2rem; }

/* Micro-animations on press */
.lightbox-btn:active {
    transform: translateY(-50%) scale(0.92);
}
.close-btn:active {
    transform: scale(0.92);
}

/* 10. FOOTER */
.gallery-footer {
    text-align: center;
    padding: 3rem 0 0 0;
    margin-top: 4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   11. RESPONSIVENESS & MEDIA QUERIES
   ========================================================================== */

/* Tablet view styling */
@media (max-width: 900px) {
    .gallery-container {
        padding: 2rem 1rem;
    }
    
    .gallery-header {
        margin-bottom: 2.5rem;
    }

    .prev-btn { left: 1rem; }
    .next-btn { right: 1rem; }
}

/* Mobile view styling */
@media (max-width: 600px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }
    
    /* Reposition buttons for small mobile screens so they don't overlay content */
    .prev-btn, .next-btn {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }
    .prev-btn { left: 0.5rem; }
    .next-btn { right: 0.5rem; }
    
    .close-btn {
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .lightbox-info {
        padding: 1rem;
        width: 95%;
    }

    .lightbox-keyboard-hint {
        display: none; /* Keyboard hints don't apply to mobile touch */
    }
}
