/* CSS Reset and Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fafafa;
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

/* Accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 768px) {
    .container {
        padding: 0 2rem;
    }
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3rem 0;
    text-align: center;
}

.header__title {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.header__subtitle {
    font-size: 1.125rem;
    opacity: 0.9;
    font-weight: 300;
}

@media (min-width: 768px) {
    .header__title {
        font-size: 3.5rem;
    }
    
    .header__subtitle {
        font-size: 1.25rem;
    }
}

/* Main Content */
.main {
    padding: 3rem 0;
}

/* Filters */
.filters {
    margin-bottom: 3rem;
}

.filters__container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.filter-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    background-color: #fff;
    color: #666;
    font-weight: 500;
    font-size: 0.875rem;
    border: 2px solid #e1e5e9;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
    color: #667eea;
}

.filter-btn--active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.filter-btn--active:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

/* Gallery */
.gallery__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    padding: 1rem 0;
}

@media (min-width: 640px) {
    .gallery__grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .gallery__grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 3rem;
    }
}

/* Gallery Items */
.gallery__item {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    opacity: 1;
    transform: scale(1);
}

.gallery__item:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.gallery__item.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.image-container {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4/3;
    background-color: #f0f0f0;
}

.gallery__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery__item:hover .gallery__image {
    transform: scale(1.05);
}

/* Image Overlay */
.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery__item:hover .image-overlay {
    opacity: 1;
}

.image-overlay__btn {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 1rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.image-overlay__btn:hover {
    background: white;
    transform: scale(1.1);
}

/* Gallery Info */
.gallery__info {
    padding: 1.5rem;
}

.gallery__title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1a1a1a;
}

.gallery__category {
    font-size: 0.875rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

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

.lightbox__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.lightbox__container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    margin: 2rem;
}

.lightbox__close {
    position: absolute;
    top: -3rem;
    right: 0;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.75rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 1001;
}

.lightbox__close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.lightbox__content {
    position: relative;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
}

.lightbox__image {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
}

.lightbox__info {
    padding: 1.5rem;
    background: white;
}

.lightbox__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a1a1a;
}

/* Lightbox Navigation */
.lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 1rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.lightbox__nav--prev {
    left: -4rem;
}

.lightbox__nav--next {
    right: -4rem;
}

@media (max-width: 768px) {
    .lightbox__nav--prev {
        left: 1rem;
    }
    
    .lightbox__nav--next {
        right: 1rem;
    }
    
    .lightbox__close {
        top: 1rem;
        right: 1rem;
    }
}

/* Lazy Loading */
.lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-load.loaded {
    opacity: 1;
}

/* Loading Animation */
@keyframes pulse {
    0% {
        background-color: #f0f0f0;
    }
    50% {
        background-color: #e0e0e0;
    }
    100% {
        background-color: #f0f0f0;
    }
}

.image-container.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Footer */
.footer {
    background: #1a1a1a;
    color: #ccc;
    padding: 2rem 0;
    text-align: center;
    margin-top: 4rem;
}

.footer__text {
    font-size: 0.875rem;
}

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

.gallery__item {
    animation: fadeInUp 0.6s ease forwards;
}

.gallery__item:nth-child(1) { animation-delay: 0.1s; }
.gallery__item:nth-child(2) { animation-delay: 0.2s; }
.gallery__item:nth-child(3) { animation-delay: 0.3s; }
.gallery__item:nth-child(4) { animation-delay: 0.4s; }
.gallery__item:nth-child(5) { animation-delay: 0.5s; }
.gallery__item:nth-child(6) { animation-delay: 0.6s; }

/* Focus Styles for Accessibility */
.filter-btn:focus,
.image-overlay__btn:focus,
.lightbox__close:focus,
.lightbox__nav:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .gallery__item {
        border: 2px solid #000;
    }
    
    .filter-btn {
        border-width: 3px;
    }
}

/* Print Styles */
@media print {
    .filters,
    .lightbox,
    .image-overlay {
        display: none;
    }
    
    .gallery__grid {
        display: block;
    }
    
    .gallery__item {
        break-inside: avoid;
        margin-bottom: 1rem;
    }
}