/**
 * MUSEUM-QUALITY GALLERY STYLES
 * Inspired by: Rijksmuseum, The Met, British Museum, Van Gogh Museum
 *
 * Design Philosophy:
 * - Art-first: The artwork is the UI, minimize chrome
 * - Generous Interface: Always show content, no empty states
 * - Silent Navigation: Controls appear when needed
 * - Progressive Enhancement: Works without JS, enhanced with it
 * - Accessible: WCAG 2.2 AA compliant
 */

/* ============================================
   GALLERY CONTAINER & LAYOUT
   ============================================ */

.gallery-container {
    min-height: 100vh;
}

/* Header Section - Museum-style introduction */
.gallery-header {
    background: linear-gradient(135deg, #fafaf9 0%, #f5f5f4 100%);
    border-bottom: 1px solid #e7e5e4;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

/* ============================================
   FILTERS SECTION - Sticky filter bar
   ============================================ */

.filters-section {
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #57534e;
}

.filter-label svg {
    width: 1.125rem;
    height: 1.125rem;
}

.filter-select {
    appearance: none;
    background-color: #fafaf9;
    border: 1px solid #d6d3d1;
    border-radius: 0.5rem;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: 'Inter', system-ui, sans-serif;
    color: #1c1917;
    cursor: pointer;
    transition: all 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2378716c'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.125rem 1.125rem;
    min-width: 180px;
}

.filter-select:hover,
.filter-select:focus {
    border-color: #a8a29e;
    background-color: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(168, 162, 158, 0.1);
}

.filter-select:focus {
    box-shadow: 0 0 0 3px rgba(168, 162, 158, 0.2);
}

/* View Toggle */
.view-toggle {
    display: flex;
    background-color: #fafaf9;
    border: 1px solid #d6d3d1;
    border-radius: 0.5rem;
    overflow: hidden;
}

.view-toggle-btn {
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    color: #78716c;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-toggle-btn:hover {
    background-color: rgba(168, 162, 158, 0.1);
}

.view-toggle-btn.active {
    background-color: #1c1917;
    color: #fff;
}

/* ============================================
   MASONRY GRID LAYOUT
   ============================================ */

.masonry-grid {
    column-count: 1;
    column-gap: 1.5rem;
}

@media (min-width: 640px) {
    .masonry-grid {
        column-count: 2;
    }
}

@media (min-width: 768px) {
    .masonry-grid {
        column-count: 3;
    }
}

@media (min-width: 1024px) {
    .masonry-grid {
        column-count: 4;
    }
}

@media (min-width: 1280px) {
    .masonry-grid {
        column-count: 5;
    }
}

/* Prevent items from breaking across columns */
.gallery-item {
    break-inside: avoid;
    margin-bottom: 1.5rem;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.gallery-item:focus {
    outline: 3px solid #1c1917;
    outline-offset: 3px;
    border-radius: 0.5rem;
}

.gallery-item-inner {
    background-color: #fff;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.gallery-item:hover .gallery-item-inner {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

/* ============================================
   IMAGE CONTAINER - Peephole UI
   ============================================ */

.gallery-image-container {
    position: relative;
    overflow: hidden;
    background-color: #fafaf9;
}

.gallery-image {
    width: 100%;
    height: auto;
    display: block;
    transition: all 0.5s ease;
    will-change: transform, filter;
}

.gallery-image.loading {
    filter: blur(20px);
    opacity: 0.6;
}

.gallery-image.loaded {
    opacity: 1;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.05);
}

/* Overlay - Reveal on hover (Peephole UI) */
.gallery-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.8) 0%,
        rgba(0, 0, 0, 0.4) 50%,
        rgba(0, 0, 0, 0) 100%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.gallery-overlay-content {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.gallery-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.technique-badge {
    background-color: rgba(251, 191, 36, 0.9);
    color: #78350f;
}

.location-badge {
    background-color: rgba(96, 165, 250, 0.9);
    color: #1e3a8a;
}

.featured-badge {
    background-color: rgba(251, 146, 60, 0.9);
    color: #7c2d12;
}

.gallery-view-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 3.5rem;
    height: 3.5rem;
    min-width: 44px;
    min-height: 44px;
    background-color: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    color: #1c1917;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-item:hover .gallery-view-btn {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.gallery-view-btn:hover,
.gallery-view-btn:focus {
    background-color: #fff;
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ============================================
   IMAGE METADATA
   ============================================ */

.gallery-meta {
    padding: 1rem;
}

.gallery-title {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 700;
    color: #1c1917;
    margin: 0 0 0.5rem 0;
    line-height: 1.4;
}

.gallery-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.gallery-title a:hover,
.gallery-title a:focus {
    color: #57534e;
}

.gallery-caption {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.875rem;
    color: #78716c;
    line-height: 1.6;
    margin: 0 0 0.75rem 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: #78716c;
}

.gallery-detail {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.detail-icon {
    font-size: 0.875rem;
}

/* ============================================
   EMPTY STATE - Museum-quality messaging
   ============================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-state-icon {
    width: 6rem;
    height: 6rem;
    color: #d6d3d1;
    margin-bottom: 1.5rem;
}

.empty-state-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1c1917;
    margin: 0 0 0.75rem 0;
}

.empty-state-description {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1rem;
    color: #78716c;
    max-width: 400px;
    margin: 0;
}

/* ============================================
   FEATURED SECTION - Highlighted works
   ============================================ */

.featured-section {
    border-top: 1px solid #e7e5e4;
}

.featured-title {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 700;
    color: #1c1917;
    margin: 0 0 2rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 2rem;
}

@media (min-width: 768px) {
    .featured-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.featured-item {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 1rem;
    cursor: pointer;
}

.featured-link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
}

.featured-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.featured-item:hover .featured-image {
    transform: scale(1.1);
}

.featured-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.8) 0%,
        rgba(0, 0, 0, 0.2) 50%,
        rgba(0, 0, 0, 0) 100%
    );
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.featured-item:hover .featured-overlay {
    opacity: 1;
}

.featured-title-text {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.5rem 0;
}

.featured-location {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

/* ============================================
   LOAD MORE BUTTON
   ============================================ */

.load-more-btn {
    background-color: #1c1917;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.875rem 2rem;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 44px;
    min-height: 44px;
}

.load-more-btn:hover,
.load-more-btn:focus {
    background-color: #292524;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.load-more-btn:focus {
    outline: 3px solid #1c1917;
    outline-offset: 3px;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 640px) {
    .gallery-header {
        padding: 3rem 1rem;
    }

    .gallery-header h1 {
        font-size: 2.5rem;
    }

    .filters-section {
        position: relative;
    }

    .filter-group {
        flex: 1;
        min-width: 45%;
    }

    .filter-select {
        min-width: 100%;
        font-size: 0.8125rem;
    }

    .gallery-meta {
        padding: 0.75rem;
    }

    .gallery-title {
        font-size: 0.9375rem;
    }

    .featured-title {
        font-size: 1.5rem;
    }
}

/* ============================================
   ACCESSIBILITY - WCAG 2.2 AA
   ============================================ */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 3px solid #1c1917;
    outline-offset: 3px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .gallery-image,
    .gallery-overlay,
    .gallery-view-btn,
    .gallery-item-inner,
    .featured-image,
    .featured-overlay,
    .load-more-btn {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .gallery-overlay {
        background: rgba(0, 0, 0, 0.9);
    }

    .gallery-badge {
        border: 2px solid currentColor;
    }
}

/* Print styles */
@media print {
    .filters-section,
    .gallery-view-btn,
    .load-more-btn {
        display: none;
    }

    .gallery-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU acceleration for smooth animations */
.gallery-image,
.gallery-item-inner,
.featured-image {
    will-change: transform;
    transform: translateZ(0);
}

/* Prevent layout shift during load */
.gallery-image-container {
    aspect-ratio: attr(width) / attr(height);
}

/* Smooth image loading */
@keyframes blurIn {
    from {
        filter: blur(20px);
        opacity: 0;
    }
    to {
        filter: blur(0);
        opacity: 1;
    }
}

.gallery-image.loaded {
    animation: blurIn 0.6s ease-out;
}
