/* Reset e Variabili */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --accent-color: #000000;
    --overlay-color: rgba(255, 255, 255, 0.98);
    --transition: all 0.3s ease;
    --font-main: 'Inter', sans-serif;
}

/* Base Styles */
body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    gap: 30px;
}

.logo a {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    text-decoration: none;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.nav {
    display: flex;
    gap: 30px;
    align-items: center;
}

.nav-link {
    font-size: 14px;
    color: var(--text-color);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.nav-link:hover {
    opacity: 1;
}

/* ============================================
   SEARCH BAR & DROPDOWN
   ============================================ */

.search-container {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    opacity: 0.5;
    pointer-events: none;
    stroke-width: 2;
}

.search-bar {
    width: 300px;
    padding: 8px 16px 8px 36px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 24px;
    font-size: 13px;
    font-family: var(--font-main);
    background: rgba(255,255,255,0.9);
    transition: all 0.3s ease;
}

.search-bar:focus {
    outline: none;
    border-color: var(--text-color);
    background: white;
    width: 400px;
}

/* Dropdown */
.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 400px;
    overflow-y: auto;
    background: white;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.search-dropdown.show {
    opacity: 1;
    pointer-events: all;
}

.tag-category {
    padding: 12px 0;
}

.tag-category:first-child {
    padding-top: 8px;
}

.tag-category:last-child {
    padding-bottom: 8px;
}

.tag-category-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #999;
    margin-bottom: 8px;
    padding: 0 16px;
}

.tag-item {
    padding: 6px 16px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
}

.tag-item:hover,
.tag-item.highlighted {
    background: rgba(0,0,0,0.04);
    color: var(--text-color);
}

.tag-item::before {
    content: "•";
    margin-right: 8px;
    color: #ccc;
    font-size: 10px;
}

/* Search Results Count */
.search-results-count {
    position: fixed;
    top: 140px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: var(--text-color);
    color: white;
    font-size: 12px;
    letter-spacing: 1px;
    border-radius: 20px;
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.search-results-count.show {
    opacity: 1;
}

/* Locations Bar */
.locations-bar-container {
    position: fixed;
    top: 80px; /* Adjusted below new header height/spacing if needed, though 70px was old */
    /* Let's stick to original if header height is same, but header has more padding/items now.
       Actually header padding is 20px top/bottom, so height is roughly 60-70px.
       Let's check previous value: 70px.
       New header might be slightly taller or same. Let's keep 70px or adjust if needed.
       Wait, the PRD doesn't specify changing this, but header flex wrap might change height.
       I'll stick to previous logic but ensure it works.
    */
    top: 80px;
    left: 0;
    width: 100%;
    z-index: 999;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 10px 0;
    overflow-x: auto;
    white-space: nowrap;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.locations-bar-container::-webkit-scrollbar {
    display: none;
}

.locations-bar {
    display: inline-flex;
    padding: 0 40px;
    gap: 20px;
    align-items: center;
}

.location-filter {
    background: none;
    border: none;
    font-family: var(--font-main);
    font-size: 13px;
    color: #888;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 5px 10px;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.location-filter:hover {
    color: var(--text-color);
    background-color: rgba(0, 0, 0, 0.03);
}

.location-filter.active {
    color: var(--bg-color);
    background-color: var(--text-color);
    font-weight: 500;
}

/* Main Content */
.main {
    padding-top: 140px;
    min-height: 100vh;
}

/* Gallery Container */
.gallery-container {
    padding: 0 20px;
    width: 100%;
    margin: 0 auto;
    max-width: 1800px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

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

/* Year Section */
.year-section {
    margin-bottom: 60px;
}

.year-header {
    font-size: 24px;
    font-weight: 300;
    margin-bottom: 20px;
    padding-left: 10px;
    letter-spacing: -0.5px;
    position: sticky;
    top: 130px; /* Adjusted for top bars */
    z-index: 900;
    mix-blend-mode: difference;
    color: white;
}

/* Masonry Grid - Tighter Layout */
.masonry-grid {
    position: relative;
    margin-bottom: 40px;
}

/* Grid Columns */
.masonry-grid.columns-4 .gallery-item {
    width: calc(25% - 6px);
}

.masonry-grid.columns-3 .gallery-item {
    width: calc(33.333% - 5.33px);
}

.masonry-grid.columns-2 .gallery-item {
    width: calc(50% - 4px);
}

.masonry-grid.columns-1 .gallery-item {
    width: 100%;
}

/* Default to 4 columns for tighter look on large screens */
.masonry-grid .gallery-item {
    width: calc(25% - 6px);
}

@media (max-width: 1400px) {
    .masonry-grid .gallery-item {
        width: calc(33.333% - 5.33px);
    }
}

@media (max-width: 900px) {
    .masonry-grid .gallery-item {
        width: calc(50% - 4px);
    }
}

@media (max-width: 600px) {
    .masonry-grid .gallery-item {
        width: 100%;
    }

    .header {
        padding: 15px 20px;
    }

    .locations-bar {
        padding: 0 20px;
    }

    .gallery-container {
        padding: 0 10px;
    }
}

/* Gallery Items */
.gallery-item {
    position: absolute;
    margin-bottom: 8px;
    opacity: 0;
    transition: transform 0.4s ease, opacity 0.4s ease;
    overflow: hidden;
}

.gallery-container.loaded .gallery-item {
    opacity: 1;
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.5s ease;
}

/* Minimal Hover Effect */
.gallery-item:hover img {
    transform: scale(1.03);
}

/* Lazy loading styles */
.gallery-item img.lazy {
    opacity: 0;
    background-color: #f5f5f5;
    min-height: 200px;
}

.gallery-item img.lazy.loaded,
.gallery-item img:not(.lazy) {
    opacity: 1;
    background: none;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.98);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

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

.lightbox-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    transition: max-width 0.3s ease;
}

.lightbox-close {
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 32px;
    font-weight: 300;
    color: var(--text-color);
    cursor: pointer;
    background: none;
    border: none;
    transition: transform 0.3s ease;
}

.lightbox-close:hover {
    transform: rotate(90deg);
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-color);
    cursor: pointer;
    padding: 20px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    opacity: 1;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-caption {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    color: #666;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ============================================
   LIGHTBOX INFO BUTTON
   ============================================ */

.lightbox-info-btn {
    position: absolute;
    top: 30px;
    left: 30px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    transition: all 0.2s ease;
    z-index: 2001;
}

.lightbox-info-btn:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ============================================
   METADATA WIDGET (SIDE PANEL)
   ============================================ */

.metadata-widget {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(10px);
    border-left: 1px solid rgba(0,0,0,0.1);
    padding: 80px 24px 32px;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
    z-index: 2000;
}

.metadata-widget.show {
    transform: translateX(0);
}

/* Custom scrollbar for widget */
.metadata-widget::-webkit-scrollbar {
    width: 6px;
}

.metadata-widget::-webkit-scrollbar-track {
    background: transparent;
}

.metadata-widget::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.metadata-widget::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.3);
}

.metadata-widget-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.metadata-widget-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.metadata-widget-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    color: var(--text-color);
}

.metadata-widget-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.metadata-widget-section li {
    font-size: 13px;
    line-height: 1.8;
    color: #555;
    display: flex;
    align-items: flex-start;
}

.metadata-widget-section li strong {
    font-weight: 600;
    color: var(--text-color);
    margin-right: 4px;
    min-width: fit-content;
}

.metadata-widget-section li::before {
    content: "•";
    margin-right: 8px;
    color: #ccc;
    flex-shrink: 0;
    line-height: inherit;
}

.scene-description {
    font-size: 13px;
    line-height: 1.7;
    color: #666;
    margin-top: 8px;
    font-style: italic;
}

.confidence {
    font-size: 11px;
    color: #999;
    font-weight: normal;
}

/* Colors Section in Widget */
.color-widget-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.color-widget-swatch {
    width: 24px;
    height: 24px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.color-widget-hex {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--text-color);
    flex: 1;
}

.color-widget-percentage {
    font-size: 11px;
    color: #999;
    margin-left: auto;
}

/* Loader */
.gallery-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.gallery-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-text {
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 11px;
    color: #999;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.3;
    }
}

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

@media (max-width: 768px) {
    .search-container {
        max-width: none;
        width: 100%;
        order: 3;
    }
    
    .header {
        flex-wrap: wrap;
        padding: 15px 20px;
    }
    
    .search-bar {
        width: 100%;
        font-size: 14px;
    }
    
    .search-bar:focus {
        width: 100%;
    }
    
    .search-dropdown {
        left: 0;
        right: 0;
        max-height: 300px;
    }
    
    /* Metadata widget on mobile */
    .metadata-widget {
        width: 100%;
        border-left: none;
        border-top: 1px solid rgba(0,0,0,0.1);
    }
    
    .metadata-widget.show {
        transform: translateX(0);
    }
    
    .lightbox-info-btn {
        top: 20px;
        left: 20px;
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .lightbox-close {
        top: 20px;
        right: 20px;
    }
    
    /* Keep image full width on mobile */
    .lightbox-content {
        max-width: 90vw !important;
    }
}

@media (max-width: 480px) {
    .metadata-widget {
        padding: 60px 20px 24px;
    }
    
    .tag-item {
        padding: 8px 16px;
        font-size: 14px;
    }
}