:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --text-primary: #f5f5f5;
    --text-secondary: #a0a0b0;
    --accent: #9fb4c7;
    --accent-hover: #b9c9d8;
    --glass: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.1);
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Hero Section - Mobile Optimized */
.hero {
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: var(--safe-top) 1rem var(--safe-bottom);
}

.hero-bg {
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse at 20% 80%, rgba(159, 180, 199, 0.16) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(74, 110, 155, 0.12) 0%, transparent 50%),
        var(--bg-primary);
    z-index: 0;
}

.hero-content {
    text-align: center;
    z-index: 2;
    position: relative;
    padding: 0 1rem;
    max-width: 100%;
}

.hero-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 12vw, 8rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.75rem;
    animation: fadeInUp 1s ease-out;
    line-height: 1.1;
}

.hero-subtitle {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.25rem, 5vw, 3rem);
    color: var(--accent);
    margin-bottom: 0.75rem;
    animation: fadeInUp 1s ease-out 0.2s both;
}

.hero-description {
    font-size: clamp(0.9rem, 3vw, 1.25rem);
    color: var(--text-secondary);
    margin-bottom: 2rem;
    animation: fadeInUp 1s ease-out 0.4s both;
    padding: 0 0.5rem;
}

.scroll-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 50px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fadeInUp 1s ease-out 0.6s both;
    touch-action: manipulation;
}

.scroll-btn:hover,
.scroll-btn:active {
    background: var(--accent);
    color: var(--bg-primary);
    transform: translateY(-2px);
}

/* Floating Fragments - Hidden on mobile */
.floating-fragments {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.fragment {
    position: absolute;
    width: 150px;
    height: 200px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 8px;
    left: var(--x);
    top: var(--y);
    animation: float 8s ease-in-out infinite;
    animation-delay: var(--delay);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0.2;
}

.fragment::before {
    content: '';
    position: absolute;
    inset: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, transparent 100%);
    opacity: 0.1;
    border-radius: 4px;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(1deg); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Filter Section - Mobile First */
.filter-section {
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(to bottom, var(--bg-primary) 0%, transparent 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.filter-bar {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    align-items: center;
    overflow-x: auto;
    padding: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    mask-image: linear-gradient(to right, transparent, black 3%, black 97%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 3%, black 97%, transparent);
}

.filter-bar::-webkit-scrollbar {
    display: none;
}

.filter-btn,
.curator-pick {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.filter-btn {
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.filter-btn:hover,
.filter-btn:active,
.filter-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.curator-pick {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    margin-left: 0.25rem;
}

.curator-pick:hover,
.curator-pick:active {
    background: var(--accent);
    color: var(--bg-primary);
}

/* Gallery Section - Mobile Optimized */
.gallery-section {
    padding: 2rem 0.5rem;
}

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

/* Artwork Cards - Mobile First */
.artwork-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    aspect-ratio: 1 / 1.15;
    display: flex;
    flex-direction: column;
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

.artwork-card:active {
    transform: scale(0.98);
}

.artwork-image-container {
    width: 100%;
    height: 65%;
    overflow: hidden;
    position: relative;
    background: var(--bg-secondary);
}

.artwork-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
    will-change: transform;
}

.artwork-card:hover .artwork-image-container img,
.artwork-card:active .artwork-image-container img {
    transform: scale(1.03);
}

.artwork-placeholder {
    width: 100%;
    height: 65%;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.artwork-info {
    padding: 0.75rem;
    height: 35%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--glass);
}

.artwork-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem;
    line-height: 1.2;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.artwork-artist {
    color: var(--accent);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.15rem;
}

.artwork-meta {
    display: flex;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.7rem;
}

/* Lightbox - Mobile Optimized */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 1000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--safe-top) 0 var(--safe-bottom);
}

.lightbox.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-close {
    position: fixed;
    top: calc(0.5rem + var(--safe-top));
    right: 0.5rem;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    z-index: 1001;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    touch-action: manipulation;
}

.lightbox-close:active {
    background: var(--accent);
    color: var(--bg-primary);
}

.lightbox-content {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.lightbox-image-container {
    width: 100%;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    padding: 1rem;
    padding-top: calc(3rem + var(--safe-top));
}

.lightbox-image-container img {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
}

.lightbox-info {
    padding: 1.5rem 1rem;
    flex: 1;
}

.lightbox-info h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    line-height: 1.2;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.lightbox-artist {
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.lightbox-year,
.lightbox-style {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.lightbox-description {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

.lightbox-actions {
    display: flex;
    gap: 0.75rem;
    position: sticky;
    bottom: calc(1rem + var(--safe-bottom));
}

.fav-btn,
.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-radius: 50px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    touch-action: manipulation;
}

.fav-btn {
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.fav-btn:active,
.fav-btn.active {
    background: #e74c3c;
    border-color: #e74c3c;
    color: white;
}

.share-btn {
    background: var(--accent);
    border: none;
    color: var(--bg-primary);
}

.share-btn:active {
    background: var(--accent-hover);
}

/* Footer */
.footer {
    padding: 3rem 1rem;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Tablet (768px+) */
@media (min-width: 768px) {
    .container {
        padding: 0 1.5rem;
    }
    
    .hero {
        padding: var(--safe-top) 1.5rem var(--safe-bottom);
    }
    
    .hero-title {
        font-size: clamp(3rem, 10vw, 6rem);
    }
    
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.75rem;
    }
    
    .artwork-card {
        aspect-ratio: 1 / 1;
    }
    
    .artwork-image-container {
        height: 70%;
    }
    
    .artwork-info {
        height: 30%;
        padding: 1rem;
    }
    
    .artwork-title {
        font-size: 0.95rem;
    }
    
    .artwork-artist {
        font-size: 0.8rem;
    }
    
    .filter-btn,
    .curator-pick {
        padding: 0.6rem 1.25rem;
        font-size: 0.85rem;
    }
    
    .lightbox-image-container {
        min-height: 60vh;
    }
    
    .lightbox-image-container img {
        max-height: 70vh;
    }
    
    .lightbox-info {
        padding: 2rem 1.5rem;
    }
    
    .lightbox-info h2 {
        font-size: 2rem;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .container {
        padding: 0 2rem;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }
    
    .filter-bar {
        justify-content: center;
        flex-wrap: wrap;
        overflow-x: visible;
        mask-image: none;
        -webkit-mask-image: none;
        padding: 0.5rem 0;
    }
    
    .filter-bar::-webkit-scrollbar {
        display: none;
    }
    
    .lightbox-content {
        flex-direction: row;
        min-height: auto;
        height: 100vh;
        height: 100dvh;
    }
    
    .lightbox-image-container {
        width: 60%;
        height: 100%;
        min-height: auto;
        padding: 2rem;
        padding-top: 2rem;
    }
    
    .lightbox-image-container img {
        max-height: 80vh;
    }
    
    .lightbox-info {
        width: 40%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 2rem 3rem;
    }
    
    .lightbox-info h2 {
        font-size: 2.5rem;
    }
    
    .lightbox-actions {
        position: static;
        margin-top: 2rem;
    }
    
    .fav-btn,
    .share-btn {
        flex: 0 1 auto;
        padding: 1rem 2rem;
    }
}

/* Large Desktop (1400px+) */
@media (min-width: 1400px) {
    .gallery-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .artwork-title {
        font-size: 1rem;
    }
}

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

/* Dark mode support (system) */
@media (prefers-color-scheme: light) {
    /* Force dark theme regardless of system preference */
    :root {
        color-scheme: dark;
    }
}

/* Landscape mobile optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 4rem 1rem;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .lightbox-content {
        flex-direction: row;
    }
    
    .lightbox-image-container {
        width: 50%;
        min-height: auto;
        height: 100vh;
    }
    
    .lightbox-info {
        width: 50%;
    }
}
