:root {
    --bg-base: #09090b;
    --bg-hover: #27272a;
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --accent: #3b82f6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow-x: hidden;
}

*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: inherit;
}

/* ==========================================================================
   FLOATING COMMAND PILL (Arc/Cosmos Style)
   ========================================================================== */
.floating-pill {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(24, 24, 27, 0.7);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    display: flex;
    align-items: center;
    padding: 6px 12px;
    z-index: 100;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05) inset;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s;
}

.floating-pill.hidden {
    transform: translate(-50%, -150%);
    opacity: 0;
    pointer-events: none;
}

.pill-titles {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
}

#gallery-title {
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.badge {
    background: rgba(255,255,255,0.1);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.pill-divider {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.15);
    margin: 0 4px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.1);
    transform: scale(1.05);
}

.active-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    display: none;
    box-shadow: 0 0 8px var(--accent);
}

.active-dot.visible {
    display: block;
}

/* ==========================================================================
   SLIDE-OVER FILTER PANEL
   ========================================================================== */
.filter-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 360px;
    background: rgba(18, 18, 20, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-left: 1px solid var(--border-color);
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.filter-panel.open {
    transform: translateX(0);
}

.panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
}

.panel-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.filter-section {
    margin-bottom: 2.5rem;
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.filter-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.chip {
    padding: 6px 12px;
    border-radius: 100px; /* Fully rounded premium look */
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.chip.active {
    background: var(--accent);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 112, 243, 0.3);
}

.chip-count {
    font-size: 0.7rem;
    opacity: 0.7;
}


.filter-option {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    user-select: none;
}

.filter-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.filter-option.active {
    background: var(--accent);
    color: white;
}

/* Timeline */
.timeline-list { list-style: none; }
.timeline-placeholder { color: var(--text-secondary); font-size: 0.85rem; font-style: italic; }

.timeline-year { margin-bottom: 0.25rem; }
.year-label {
    font-size: 0.95rem; font-weight: 500; padding: 8px 12px; cursor: pointer;
    border-radius: 8px; transition: all 0.2s; display: flex; justify-content: space-between;
    align-items: center; color: var(--text-secondary);
}
.year-label:hover { background: var(--bg-hover); color: var(--text-primary); }
.year-label.active { color: var(--accent); }
.year-label::after { content: "›"; transition: transform 0.2s; font-size: 1.2rem; line-height: 1; display: inline-block; }
.timeline-year.expanded .year-label::after { transform: rotate(90deg); }

.timeline-months {
    list-style: none; margin-left: 18px; padding-left: 12px;
    border-left: 1px solid var(--border-color); display: none; margin-top: 4px; margin-bottom: 8px;
}
.timeline-year.expanded .timeline-months { display: block; }
.timeline-month {
    font-size: 0.85rem; color: var(--text-secondary); padding: 6px 12px;
    cursor: pointer; border-radius: 6px; margin-bottom: 2px; transition: all 0.2s;
}
.timeline-month:hover { background: var(--bg-hover); color: var(--text-primary); }
.timeline-month.active { color: var(--accent); font-weight: 500; background: rgba(59, 130, 246, 0.1); }


/* ==========================================================================
   MAIN CONTENT & FULL BLEED GRID
   ========================================================================== */
.main-content {
    min-height: 100vh;
    padding-top: 6rem; /* Space for floating pill */
    max-width: 1920px;
    margin: 0 auto;
}

.gallery-grid {
    --grid-gap: 8px;
    padding: 0 12px 4rem;
    column-count: 2;
    column-gap: var(--grid-gap);
}

@media (min-width: 768px) {
    .gallery-grid { --grid-gap: 16px; padding: 0 24px 4rem; column-count: 3; }
}
@media (min-width: 1024px) {
    .gallery-grid { --grid-gap: 20px; padding: 0 32px 4rem; column-count: 4; }
}
@media (min-width: 1440px) {
    .gallery-grid { --grid-gap: 24px; padding: 0 48px 4rem; column-count: 5; }
}
@media (min-width: 1920px) {
    .gallery-grid { padding: 0 64px 4rem; column-count: 5; } /* Cap at 5 columns to preserve image scale */
}

.gallery-item {
    break-inside: avoid;
    margin-bottom: var(--grid-gap);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    cursor: zoom-in;
    transform: translateZ(0); /* Force GPU */
    background: var(--bg-hover);
}

/* Skeleton Loading Shimmer Effect */
.gallery-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    transform: translateX(-100%);
    animation: shimmer 1.5s infinite;
    z-index: 0;
    pointer-events: none;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

.gallery-item:has(img.img-loaded)::before,
.gallery-item:has(img.img-error)::before {
    display: none; /* Turn off animation when loaded to save CPU */
}

.gallery-item img {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s ease-out;
    opacity: 0;
    will-change: transform, opacity;
}

.gallery-item img.img-loaded { opacity: 1; }
.gallery-item img.img-error {
    opacity: 1; min-height: 300px; background-color: var(--bg-hover);
    color: transparent; position: relative;
}
.gallery-item img.img-error::before {
    content: "Asset missing"; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); color: var(--text-secondary);
    font-size: 0.85rem; font-weight: 500;
}

.gallery-item::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0) 50%, rgba(9,9,11,0.8) 100%);
    opacity: 0; transition: opacity 0.3s; pointer-events: none;
}

.gallery-item:hover::after { opacity: 1; }
.gallery-item:hover img { transform: scale(1.04); }

.item-overlay {
    position: absolute; bottom: 0; left: 0; right: 0; padding: 1rem;
    opacity: 0; transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; justify-content: flex-end; align-items: flex-end;
    pointer-events: none; z-index: 2;
}

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

.mini-badge {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* ==========================================================================
   INFINITE SCROLL LOADER
   ========================================================================== */
.scroll-trigger {
    padding: 4rem;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s;
}
.scroll-trigger.active { opacity: 1; }
.spinner {
    width: 32px; height: 32px; border: 3px solid var(--bg-hover);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 1s linear infinite; margin: 0 auto;
}
@keyframes spin { 100% { transform: rotate(360deg); } }
.loading { text-align: center; padding: 10rem 2rem; color: var(--text-secondary); font-size: 1.1rem; }

/* ==========================================================================
   CINEMATIC LIGHTBOX
   ========================================================================== */
.modal {
    position: fixed; inset: 0; z-index: 1000; display: flex;
    align-items: center; justify-content: center; visibility: hidden; opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.5s;
}
.modal.active { visibility: visible; opacity: 1; }
.modal-backdrop {
    position: absolute; inset: 0; 
    background: radial-gradient(circle at center, rgba(9, 9, 11, 0.8) 0%, rgba(0, 0, 0, 1) 100%);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
}
.modal-track-container {
    position: absolute; inset: 0; z-index: 1001;
    overflow: hidden; user-select: none; -webkit-user-select: none;
    touch-action: none; /* Prevent native scrolling/pinching */
    cursor: zoom-in;
}
.modal-track-container.is-zoomed { cursor: grab; }
.modal-track-container.is-dragging { cursor: grabbing; }
.modal-track {
    display: flex; width: 300vw; height: 100%;
    transform: translate3d(-100vw, 0, 0); /* Center on current slide */
    will-change: transform;
}
.modal-slide {
    width: 100vw; height: 100%;
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.modal-slide img {
    max-width: 100vw; max-height: 100vh;
    will-change: transform;
    opacity: 1; transition: opacity 0.2s;
}
.modal-slide img.img-error { min-width: 300px; min-height: 300px; background: var(--bg-hover); opacity: 1; }

.modal-ui-layer {
    position: absolute; inset: 0; z-index: 1002;
    pointer-events: none; /* Let touches pass to track */
}
.modal-ui-layer > * {
    pointer-events: auto; /* Re-enable for buttons */
}

.modal-btn {
    position: absolute; z-index: 1002; background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.05); color: white; backdrop-filter: blur(12px);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-btn:hover { background: rgba(255,255,255,0.15); transform: scale(1.1); }
.close-btn { top: 2rem; right: 2rem; width: 48px; height: 48px; border-radius: 24px; font-size: 1.5rem; }
.nav-left-btn, .nav-right-btn { top: 50%; transform: translateY(-50%); width: 56px; height: 56px; border-radius: 28px; font-size: 2rem; }
.nav-left-btn { left: 2rem; }
.nav-right-btn { right: 2rem; }
.nav-left-btn:hover, .nav-right-btn:hover { transform: translateY(-50%) scale(1.1); }

/* Auto-Hide UI Logic */
.modal.ui-hidden .modal-btn,
.modal.ui-hidden .modal-info-panel {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}
.modal.ui-hidden .nav-left-btn { transform: translateY(-50%) translateX(-10px); }
.modal.ui-hidden .nav-right-btn { transform: translateY(-50%) translateX(10px); }


.modal-info-panel {
    position: absolute; bottom: calc(2rem + env(safe-area-inset-bottom, 0px)); 
    left: 50%; transform: translateX(-50%);
    background: rgba(18, 18, 20, 0.6); backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.05); padding: 12px 28px; border-radius: 30px;
    display: flex; gap: 24px; z-index: 1002; align-items: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.info-group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.info-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-secondary); }
.info-value { font-size: 0.85rem; font-weight: 500; color: white; letter-spacing: 0.02em; }
.info-divider { width: 1px; height: 24px; background: rgba(255,255,255,0.1); }

/* Apply safe area to close button */
.close-btn { 
    top: calc(2rem + env(safe-area-inset-top, 0px)); 
    right: calc(2rem + env(safe-area-inset-right, 0px)); 
    width: 48px; height: 48px; border-radius: 24px; font-size: 1.5rem; 
}

/* ==========================================================================
   MOBILE RESPONSIVENESS
   ========================================================================== */
@media (max-width: 768px) {
    .floating-pill { top: 1rem; width: 90%; justify-content: space-between; padding: 6px; }
    .filter-panel { width: 300px; }
    .modal-info-panel { bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); padding: 8px 16px; gap: 16px; width: 90%; justify-content: center; }
    .nav-left-btn { left: 1rem; width: 44px; height: 44px; }
    .nav-right-btn { right: 1rem; width: 44px; height: 44px; }
    .close-btn { top: 1rem; right: 1rem; width: 40px; height: 40px; }
    .main-content { padding-top: 5rem; }
}
