/* ============================================================================
   DYNAMIC GALLERY PAGE STYLES
   ============================================================================
   Advanced image handling with creative layouts and animations
   ============================================================================ */

/* Gallery Main Layout */
.gallery-main {
    padding-top: 80px;
    min-height: 100vh;
}

/* Gallery Hero Section */
.gallery-hero {
    padding: var(--space-20) 0 var(--space-16);
    background: linear-gradient(135deg, var(--primary-purple-100), var(--accent-gold-50));
    position: relative;
    overflow: hidden;
}

.gallery-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(107, 70, 193, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(245, 158, 11, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

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

.gallery-hero h1 {
    font-size: clamp(var(--text-4xl), 6vw, var(--text-6xl));
    color: var(--neutral-900);
    margin-bottom: var(--space-6);
    background: linear-gradient(135deg, var(--primary-purple), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gallery-hero p {
    font-size: var(--text-xl);
    color: var(--neutral-600);
    font-style: italic;
    line-height: 1.8;
}

/* Gallery Controls */
.gallery-controls {
    padding: var(--space-12) 0;
    background: var(--white);
    border-bottom: 1px solid var(--neutral-200);
    position: relative;
    backdrop-filter: blur(10px);
}

.gallery-controls .container {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-8);
    flex-wrap: wrap;
    /* Smooth transition for fade effect */
    transition: opacity 0.3s ease-out;
    /* Ensure the element maintains its layout space even when faded */
    will-change: opacity;
}

.filter-controls,
.size-controls {
    flex: 1;
    min-width: 300px;
}

.filter-controls h3,
.size-controls h3 {
    font-size: var(--text-lg);
    color: var(--neutral-800);
    margin-bottom: var(--space-4);
    font-family: var(--font-display);
}

.filter-buttons,
.size-buttons {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.filter-btn,
.size-btn {
    padding: var(--space-2) var(--space-4);
    border: 2px solid var(--neutral-300);
    background: var(--white);
    color: var(--neutral-700);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.filter-btn::before,
.size-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.filter-btn:hover::before,
.size-btn:hover::before {
    left: 100%;
}

.filter-btn:hover,
.size-btn:hover {
    border-color: var(--primary-purple);
    color: var(--primary-purple);
    transform: translateY(-2px);
}

.filter-btn.active,
.size-btn.active {
    background: linear-gradient(135deg, var(--primary-purple), var(--primary-purple-dark));
    color: var(--white);
    border-color: var(--primary-purple);
    box-shadow: 0 4px 15px rgba(107, 70, 193, 0.3);
}

/* Gallery Section */
.gallery-section {
    padding: var(--space-16) 0;
    background: var(--neutral-50);
}

/* Masonry Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-6);
    position: relative;
}

/* Gallery Item Styles */
.gallery-item {
    background: var(--white);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    position: relative;
    cursor: pointer;
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.6s ease-out forwards;
}

.gallery-item:nth-child(odd) {
    animation-delay: 0.1s;
}

.gallery-item:nth-child(even) {
    animation-delay: 0.2s;
}

.gallery-item:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-xl);
}

/* Image Container */
.gallery-item-image {
    position: relative;
    overflow: hidden;
    background: var(--neutral-100);
}

.gallery-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Handles all aspect ratios gracefully */
    object-position: center;
    transition: transform var(--transition-slow);
    filter: brightness(0.9) contrast(1.1);
    /* Responsive image handling for all orientations */
    max-width: 100%;
    max-height: 100%;
}

.gallery-item:hover .gallery-item-image img {
    transform: scale(1.1);
    filter: brightness(1) contrast(1.2);
}

/* Size-based styling - Responsive for all image orientations */
.gallery-item.small .gallery-item-image {
    height: 200px;
    /* Handles portrait, landscape, and square images */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gallery-item.medium .gallery-item-image {
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gallery-item.large .gallery-item-image {
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Additional responsive image handling */
.gallery-item-image {
    position: relative;
    overflow: hidden;
    background: var(--neutral-100);
    /* Ensure proper aspect ratio handling */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Portrait image handling */
.gallery-item-image img[style*="aspect-ratio"] {
    width: auto;
    height: 100%;
    max-width: 100%;
}

/* Landscape image handling */
.gallery-item-image img:not([style*="aspect-ratio"]) {
    width: 100%;
    height: auto;
    min-height: 100%;
}

/* Gallery Overlay */
.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: var(--white);
    padding: var(--space-6);
    transform: translateY(100%);
    transition: transform var(--transition-normal);
}

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

.gallery-overlay h3 {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--white);
}

.gallery-overlay p {
    font-size: var(--text-sm);
    opacity: 0.9;
    margin-bottom: var(--space-2);
    color: var(--white);
}

.gallery-category {
    display: inline-block;
    background: var(--primary-purple);
    color: var(--white);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Loading Indicator */
.loading-indicator {
    text-align: center;
    padding: var(--space-12);
    display: none;
}

.loading-indicator.active {
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--neutral-200);
    border-top: 4px solid var(--primary-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--space-4);
}

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

/* Lightbox Styles */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

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

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

.lightbox-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    max-width: 100%;
    max-height: 100%;
}

.lightbox-content img {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.lightbox-info {
    padding: var(--space-6);
    background: var(--white);
}

.lightbox-info h3 {
    font-size: var(--text-xl);
    color: var(--neutral-900);
    margin-bottom: var(--space-2);
}

.lightbox-info p {
    color: var(--neutral-600);
    margin-bottom: var(--space-3);
}

.lightbox-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    background: rgba(0, 0, 0, 0.7);
    color: var(--white);
    border: none;
    border-radius: var(--radius-full);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    z-index: 10;
}

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

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: var(--white);
    border: none;
    border-radius: var(--radius-full);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    z-index: 10;
}

.lightbox-prev {
    left: var(--space-4);
}

.lightbox-next {
    right: var(--space-4);
}

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

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: var(--space-4);
    }
    
    .gallery-controls .container {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .gallery-main {
        padding-top: 60px;
    }
    
    .gallery-controls {
        top: 60px;
        padding: var(--space-8) 0;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: var(--space-3);
    }
    
    .filter-controls,
    .size-controls {
        min-width: 100%;
    }
    
    .lightbox-nav {
        width: 50px;
        height: 50px;
    }
    
    .lightbox-close {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    
    .gallery-item.small .gallery-item-image,
    .gallery-item.medium .gallery-item-image,
    .gallery-item.large .gallery-item-image {
        height: 250px;
    }
}