/**
 * Main CSS - Archivio Futuro Theme
 * Stile minimalista ispirato a Below the Surface
 * Versione 2.0 - Ottimizzato e Pulito
 */

/* ========================================
   RESET & BASE
======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/**
 * Altezza dell'header fisso.
 * Valore di fallback: viene sovrascritto a runtime con l'altezza REALE del
 * masthead (snippet inline in header.php + main.js), quindi cambiando padding,
 * logo o font della nav non c'e' nulla da riallineare a mano.
 * body, .archivio-header e il dettaglio foto seguono questa variabile.
 */
:root {
    --header-height: 60px;
}

body {
    font-family: var(--font-primary);
    color: var(--color-primary);
    background: var(--color-secondary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-top: var(--header-height); /* Spazio per header fixed */
}

body.home {
    padding-top: 20px;
}

body.menu-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
}

html {
    scroll-behavior: smooth;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: opacity 0.3s ease;
}

a:hover {
    opacity: 0.7;
}

/* ========================================
   HEADER
======================================== */

.site-header {
    background: var(--color-secondary);
    border-bottom: 1px solid var(--color-primary);
    position: fixed !important;
    top: 0 !important;
    left: 0;
    right: 0;
    z-index: 9999;
    transition: transform 0.3s ease;
}
.site-header.header-hidden {
    transform: translateY(-100%);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 30px;
    margin: 0 auto;
}

.site-branding .custom-logo-link {
    display: flex;
    align-items: center;
}
.site-branding .custom-logo {
    width: 160px;
    height: 40px;
    max-height: 40px;
    object-fit: contain;
    object-position: left center;
}

.site-title {
    font-size: 24px;
    font-weight: bold;
    letter-spacing: -0.5px;
}

.site-title a {
    color: var(--color-primary);
}

.main-navigation {
    display: flex;
    align-items: center;
    gap: 40px;
}

.menu-buttons {
    display: flex;
    gap: 40px;
}

.main-navigation .nav-menu {
    display: flex;
    gap: 60px;
    list-style: none;
}

.main-navigation .nav-menu a {
    font-size: 18px !important;
    text-transform: uppercase !important;
    letter-spacing: 1.5px !important;
    font-weight: 500 !important;
}

/* Header Search */
.header-search-box {
    display: flex;
    align-items: center;
    overflow: hidden;
    transition: all 0.3s ease;
}

.header-search-box.active {
    max-width: 300px;
}

.header-search-input {
    width: 0;
    padding: 0;
    border: none;
    font-size: 14px;
    background: transparent;
    transition: all 0.3s ease;
    opacity: 0;
}

.header-search-box.active .header-search-input {
    width: 240px;
    padding: 8px 12px;
    opacity: 1;
}

.header-search-input:focus {
    outline: none;
}

.header-search-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--color-primary);
}

.search-text-desktop {
    display: inline;
}

.search-icon-mobile {
    display: none;
}

/* Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 2px;
    background: var(--color-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

/* Animazione Hamburger -> X */
body .menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

body .menu-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: scale(0);
}

body .menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* ========================================
   HOMEPAGE
======================================== */

.hero-section {
    height: 100vh;
    min-height: 100vh;
    display: flex;
    align-items: center;
    border-bottom: none;
    overflow: hidden;
}

.hero-container {
    width: 100%;
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}

.hero-text {
    padding-right: 40px;
}

.hero-title {
    font-size: 32px;
    line-height: 1.4;
    margin-bottom: 30px;
    font-weight: normal;
}

.hero-cta p {
    font-size: 18px;
    margin-top: 20px;
}

.hero-pattern {
    width: 100%;
    height: 100%;
}

.hero-pattern video,
.hero-pattern img,
.hero-pattern svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pattern-column {
    flex: 1;
}

.pattern-column svg {
    width: 100%;
    height: 100%;
    color: var(--color-primary);
}

/* Eventi Section - nascosta */
.eventi-section {
    display: none;
}

.section-title {
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 40px;
    font-weight: bold;
}

.eventi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

.evento-card {
    border: 1px solid var(--color-accent);
}

.evento-image {
    aspect-ratio: 4/3;
    overflow: hidden;
    background: var(--color-accent);
}

.evento-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.evento-card:hover .evento-image img {
    transform: scale(1.05);
}

.evento-content {
    padding: 20px;
}

.evento-data {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.evento-title {
    font-size: 18px;
    margin-bottom: 10px;
    font-weight: bold;
}

.evento-luogo {
    font-size: 14px;
    color: #666;
}

/* Archivio CTA */
.archivio-cta-section {
    padding: 100px 0;
    text-align: center;
}

.archivio-cta-content h2 {
    font-size: 36px;
    margin-bottom: 20px;
}

.archivio-cta-content p {
    font-size: 18px;
    margin-bottom: 30px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* ========================================
   BUTTONS
======================================== */

.btn {
    display: inline-block;
    padding: 12px 30px;
    border: 2px solid var(--color-primary);
    background: transparent;
    color: var(--color-primary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-lg {
    width:100%;
    padding: 24px ;
}

.btn:hover {
    background: var(--color-primary);
    color: var(--color-secondary);
    opacity: 1;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-secondary);
}

.btn-primary:hover {
    background: transparent;
    color: var(--color-primary);
}

.btn-hero {
    background: #000;
    color: #fff;
    border-color: #000;
}

.btn-hero:hover {
    background: transparent;
    color: #000;
}

/* ========================================
   SPLASH SCREEN
======================================== */

.archivio-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}
.archivio-splash.fade-out {
    opacity: 0;
    pointer-events: none;
}
.splash-logo {
    max-width: 200px;
    max-height: 120px;
    opacity: 0.9;
}
.splash-title {
    color: #fff;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ========================================
   ARCHIVIO PAGE
======================================== */

.archivio-page {
    background: white;
    /* Lo spazio per .archivio-header (fixed) e' tutto su .archivio-main,
       calcolato sull'altezza reale della barra: vedi --archivio-header-height */
    padding-top: 0;
}

.archivio-header {
    padding: 0;
    position: fixed;
    top: var(--header-height); /* Altezza del site-header */
    left: 0;
    right: 0;
    z-index: 999;
    transition: top 0.3s ease;
}

/* Header nascosto allo scroll: ricerca + tag filtri salgono al posto della nav */
body.header-hidden .archivio-header {
    top: 0;
}

.archivio-header .container {
    max-width: 1400px;
}

.page-title {
    font-size: 42px;
    margin-bottom: 16px;
    font-weight: 300;
    letter-spacing: -0.5px;
}

.page-intro {
    font-size: 16px;
    max-width: 700px;
    margin-bottom: 20px;
    color: #666;
    line-height: 1.7;
}

/* Active Filters Bar - Mostra solo filtri attivi come badge */
.active-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 15px 60px;
    background: transparent;
    min-height: 52px;
}

.active-filters-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* Badge filtro attivo */
.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #000;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid #000;
    transition: all 0.2s ease;
}

.filter-badge:hover {
    background: #333;
    border-color: #333;
}

.badge-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.badge-remove:hover {
    opacity: 1;
}

.clear-all-filters {
    background:#fff;
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid #ddd;
    transition: all 0.2s;
}

.clear-all-filters:hover {
    background: #f5f5f5;
    border-color: #ccc;
    color: #000;
    opacity: 1;
}

/* Archivio Main Layout */
/**
 * .archivio-header e' in position:fixed, quindi non occupa spazio nel flusso:
 * la griglia va spinta giu' della sua altezza reale.
 * --archivio-header-height viene misurata via JS (page-archivio.php) e si
 * adegua a titolo, intro e tag filtri che vanno a capo.
 * Il fallback 140px vale se il JS non gira.
 */
.archivio-main {
    padding: 0;
    padding-top: var(--archivio-header-height, 140px);
    background: white;
    position: relative;
}

.archivio-container {
    display: block;
    max-width: 100vw;
    margin: 0 auto;
    padding: 0;
    position: relative;
}

.back-to-archive {
    position: absolute;
    top: 5px;
    left: 0;
}

.foto-single-content-bts {
    position: relative;
    padding-top: 20px;
}

.related-title {
    font-weight: 400;
    font-size: 16px !important;
    text-transform: uppercase;
}

/* ========================================
   TIMELINE - VERTICAL BAR STYLE
======================================== */

.archivio-timeline {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 120px;
    z-index: 1000;
    pointer-events: none;
}

.archivio-timeline .timeline-inner {
    pointer-events: auto;
}

.timeline-inner {
    position: fixed;
    top: 100px;
    bottom: 100px;
    right: 00px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    z-index: 1000;
}

.timeline-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.timeline-bar {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding: 10px 0;
}

/* Linea verticale */
.timeline-bar::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #e0e0e0;
}

.timeline-year {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

/* Lineetta orizzontale (tick) */
.timeline-tick {
    display: block;
    width: 15px;
    height: 3px;
    background: #000;
    margin-left: 8px;
    transition: all 0.3s ease;
}

.timeline-year-label {
    font-size: 16px;
    font-weight: 400;
    color: #000;
    letter-spacing: 0;
    line-height: 1;
    white-space: nowrap;
    transition: all 0.3s ease;
}

/* Anno attivo */
.timeline-year.active .timeline-tick {
    width: 40px;
    background: #000;
}

.timeline-year.active .timeline-year-label {
    font-size: 32px;
    font-weight: 600;
    color: #000;
}

/* Hover */
.timeline-year:hover .timeline-tick {
    width: 32px;
    background: #000;
}

.timeline-year:hover .timeline-year-label {
    color: #333;
}

/* Anno con foto (ha il pallino) */
.timeline-year.has-photos::after {
    content: '';
    position: absolute;
    right: -3px;
    width: 0px;
    height: 0px;
    background: #000;
    border-radius: 50%;
}

.timeline-year:not(.has-photos) {
    opacity: 0.35 !important;
}

.timeline-year.has-photos {
    opacity: 1 !important;
}

.timeline-year:not(.has-photos) .timeline-tick {
    width: 10px;
}

.timeline-year:not(.has-photos):hover {
    opacity: 0.6;
}

/* Anno in caricamento (click su decade non ancora nel DOM) */
.timeline-year.loading .timeline-year-label {
    animation: timelinePulse 0.8s ease-in-out infinite;
}

.timeline-year.loading .timeline-tick {
    animation: timelinePulse 0.8s ease-in-out infinite;
}

@keyframes timelinePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Timeline nascosta quando il footer entra nel viewport (evita la sovrapposizione) */
.archivio-timeline .timeline-inner {
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.archivio-timeline.timeline-hidden .timeline-inner {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.timeline-loading {
    text-align: center;
    padding: 40px 20px;
    color: #ccc;
    font-size: 12px;
}

.timeline-loading .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f0f0f0;
    border-top-color: #999;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Infinite Scroll Loading */
.load-more-container {
    text-align: center;
    padding: 40px 20px;
    clear: both;
}

.load-more-container .loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.load-more-container .loading-spinner .spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f0f0f0;
    border-top-color: #333;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Messaggio fine archivio */
.archivio-end-message {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
    font-style: italic;
    clear: both;
}

/* Grid Foto - 3 Colonne Masonry */
.archivio-content {
    padding: 20px 60px 20px 60px;
    background: white;
    position: relative;
    min-height: 63vh;
    width: 100%;
}

.archivio-stats {
    position: absolute;
    bottom: 20px;
    right: 20px;
    margin: 0;
    padding: 0;
    border: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: transparent;
    text-align: right;
    font-size: 10px;
    color: #bbb;
    z-index: 5;
}

.stat-item {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-item strong {
    font-size: 11px;
    display: inline;
    margin: 0;
    font-weight: 500;
}

.archivio-grid {
    width: 100%;
}

.foto-item {
    width: calc(25% - 10px);
    margin-bottom: 10px;
    background: white;
    transition: transform 0.3s ease;
    position: relative;
}

.foto-item:hover {
    z-index: 10;
}

.foto-link {
    display: block;
    color: inherit;
}

.foto-link:hover {
    opacity: 1;
}

.foto-image {
    overflow: visible;
    position: relative;
    background: transparent;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.4s ease;
}

.foto-image img {
    width: 100%;
    height: auto;
    display: block;
    position: relative;
}

.foto-item:hover .foto-image {
    transform: scale(1.15);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
    z-index: 4999;
    background: #fff;
}

/* Box info hover sopra la foto */
.foto-hover-box {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #000;
    color: #fff;
    padding: 10px 12px;
    z-index: 10000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.foto-hover-box .hover-title {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.foto-hover-box .hover-anno {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.7;
}

.foto-info,
.related-info {
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: 0 10px;
    min-height: 36px;
    gap: 8px;
    display:none;
}

.foto-title {
    font-size: 12px;
    margin-bottom: 0;
    font-weight: 400;
    line-height: 1.3;
    color: #333;
    text-transform: uppercase;
    flex: 1;
    /* Limita a 2 righe */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.foto-meta {
    display: block;
    margin-bottom: 0;
    font-size: 10px;
    color: #aaa;
    font-weight: 400;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: right;
}

.foto-meta span {
    display: inline;
}

/* Animazioni */
.foto-item {
    animation: fadeInUp 0.6s ease backwards;
}

.foto-item:nth-child(1) {
    animation-delay: 0.05s;
}

.foto-item:nth-child(2) {
    animation-delay: 0.1s;
}

.foto-item:nth-child(3) {
    animation-delay: 0.15s;
}

.foto-item:nth-child(4) {
    animation-delay: 0.2s;
}

.foto-item:nth-child(5) {
    animation-delay: 0.25s;
}

.foto-item:nth-child(6) {
    animation-delay: 0.3s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* No Results */
.no-photos {
    text-align: center;
    padding: 120px 40px;
    color: #999;
    grid-column: 1 / -1;
}

.no-photos::before {
    content: "";
    display: block;
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.no-photos p {
    font-size: 16px;
    font-weight: 300;
    margin: 0;
    color: #aaa;
}

/* ========================================
   FILTERS SIDEBAR - Pannello laterale
======================================== */

.filters-sidebar {
    position: fixed;
    top: 0;
    left: -350px;
    width: 350px;
    height: 100vh;
    height: 100dvh;
    background: #000;
    color: #fff;
    z-index: 9999;
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* Colonna: header fisso, contenuto scrollabile, azioni ancorate in basso */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
}

.filters-sidebar.active {
    left: 0;
}

.filters-header {
    padding: 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.filters-header h3 {
    font-size: 16px;
    font-weight: 300;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 0;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.sidebar-close-btn:hover {
    opacity: 1;
}

body.filters-open {
    overflow: hidden;
}

.filters-content {
    padding: 30px;
    padding-bottom: 40px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-group {
    margin-bottom: 40px;
}

.filters-sidebar .filter-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #999;
    font-weight: 500;
}

.filter-search-input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 13px;
    margin-top: 8px;
    outline: none;
    transition: border-color 0.2s;
}
.filter-search-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}
.filter-search-input:focus {
    border-color: rgba(255, 255, 255, 0.4);
}

.filters-sidebar .filter-items-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.filters-sidebar .year-item,
.filters-sidebar .category-item {
    padding: 10px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    color: #fff;
}

.filters-sidebar .filter-item-label {
    font-weight: 500;
}

.filters-sidebar .filter-item-count {
    display: none;
}

.filters-sidebar .year-item:hover,
.filters-sidebar .category-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.filters-sidebar .year-item.selected,
.filters-sidebar .category-item.selected {
    background: #fff;
    color: #000;
    border-color: #fff;
}

.filters-sidebar .loading-filter {
    grid-column: 1 / -1;
    text-align: center;
    color: #666;
    font-size: 12px;
    padding: 20px;
}

/* Pulsanti azione filtri - ancorati in fondo al pannello, non scrollano */
.filters-actions {
    position: relative;
    flex-shrink: 0;
    padding: 20px 30px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    background: #000;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Nessun filtro selezionato ne attivo: niente barra azioni ingombrante */
.filters-actions:not(.has-buttons) {
    padding: 0;
    border-top: none;
}

.filters-btn {
    /* Affiancati; se il testo non ci sta vanno a capo uno sotto l'altro */
    flex: 1 1 130px;
    padding: 14px 20px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    display: none;
}

.filters-btn.visible {
    display: block;
}

.filters-btn-reset {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
}

.filters-btn-reset:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
}

.filters-btn-apply {
    background: #fff;
    border: 1px solid #fff;
    color: #000;
}

.filters-btn-apply:hover {
    background: #ddd;
    border-color: #ddd;
}

.filters-toggle {
    position: relative;
    width: 36px;
    height: 36px;
    background: #000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.filters-toggle:hover {
    background: #333;
}

.filters-toggle .icon-search,
.filters-toggle .icon-close {
    position: absolute;
    transition: all 0.3s ease;
    color: #fff;
    width: 18px;
    height: 18px;
}

.filters-toggle .icon-search {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.filters-toggle .icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.filters-toggle.active .icon-search {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.filters-toggle.active .icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.filters-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 4998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.filters-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   SINGLE FOTO - Layout 3 colonne
======================================== */

.foto-detail-page {
    background: #fff;
}

.foto-detail {
    height: calc(100vh - 80px);
    display: grid;
    grid-template-columns: 250px 1fr 150px;
    grid-template-rows: 1fr;
    background: #fff;
    overflow: hidden;
}

/* Colonna sinistra: metadati */
.foto-detail-meta {
    padding: 30px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e8e8e8;
    overflow: hidden;
    height: 100%;
}

.foto-detail-meta-inner {
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.foto-detail-meta .detail-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.foto-detail-meta .detail-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    font-weight: 500;
}

.foto-detail-meta .detail-value {
    font-size: 15px;
    color: #000;
    line-height: 1.5;
}

.foto-detail-meta .detail-value-multiline {
    white-space: pre-line;
    font-family: monospace;
    font-size: 13px;
}

.detail-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #000;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 6px;
    margin-bottom: 4px;
}

/* Tag cliccabili: rimandano alla gallery filtrata */
a.detail-badge {
    color: #fff;
    cursor: pointer;
}

a.detail-badge:hover {
    background: #333;
    opacity: 1;
}

.detail-value a.detail-link {
    color: #000;
    border-bottom: 1px solid #bbb;
    cursor: pointer;
}

.detail-value a.detail-link:hover {
    border-bottom-color: #000;
    opacity: 1;
}

.back-link {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    color: #000;
    letter-spacing: 0.5px;
    transition: opacity 0.2s;
}

.back-link-desktop {
    margin-top: 20px;
    padding: 15px 0 0;
    border-top: 1px solid #e8e8e8;
    background: #fff;
    flex-shrink: 0;
}

.back-link-mobile {
    display: none;
}

.back-link:hover {
    opacity: 0.6;
}

/* Colonna centrale: foto */
.foto-detail-image {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 20px;
    background: #fff;
    cursor: ns-resize;
}

.foto-detail-image img {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
    transition: opacity 0.2s ease;
    user-select: none;
    -webkit-user-drag: none;
}

/* Frecce navigazione foto - nascoste */
.nav-arrow {
    display: none;
}

@media (max-width: 768px) {
    .nav-arrow {
        display: none;
    }
}

/* Colonna destra: anno + thumbnail */
.foto-detail-sidebar {
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    /* Anno, frecce e colonna anteprime allineati sullo stesso asse centrale */
    align-items: center;
    border-left: 1px solid #e8e8e8;
    overflow: hidden;
}

.sidebar-anno {
    font-size: 28px;
    font-weight: 600;
    color: #000;
    margin-bottom: 15px;
    line-height: 1;
    width: 100%;
    text-align: center;
}

/* Frecce pagina sidebar thumbnails */
.sidebar-nav {
    background: none;
    border: none;
    color: #999;
    font-size: 28px;
    cursor: pointer;
    padding: 4px 0;
    text-align: center;
    width: 100%;
    line-height: 1;
    transition: color 0.2s;
    flex-shrink: 0;
    transform: rotate(90deg);
}

.sidebar-nav:hover {
    color: #000;
}

.sidebar-thumbs {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.sidebar-thumbs::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.sidebar-thumb {
    width: 86px;
    height: 86px;
    object-fit: cover;
    cursor: pointer;
    /* Bordo sempre presente (trasparente): la selezione non sposta le anteprime */
    border: 3px solid transparent;
    transition: border-color 0.3s ease;
    flex-shrink: 0;
}

/* Riquadro di selezione: linea singola, nessun anello aggiuntivo */
.sidebar-thumb.active {
    border-color: #000;
    box-shadow: none;
    transform: none;
    position: relative;
    z-index: 2;
}


/* ========================================
   FOOTER
======================================== */

.site-footer {
    background: var(--color-primary);
    color: var(--color-secondary);
    padding: 30px 0 30px;
    margin-top: 100px;
    width: 100%;
    box-sizing: border-box;
}

.footer-container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 0 30px;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 60px;
    min-height: 120px;
    position: relative;
}

/* Logo a destra, menu a sinistra */
.footer-widgets {
    order: 2;
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
}

.footer-widgets a.custom-logo-link {
    display: flex !important;
    width: fit-content !important;
    max-width: fit-content !important;
    flex: 0 0 auto !important;
}

.footer-widgets img,
.footer-widgets svg {
    width: 82px;
    max-width: 82px;
    height: 40px;
    object-fit: contain;
    object-position: left center;
    display: block;
    filter: brightness(0) invert(1);
}

.footer-info {
    order: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.footer-info a {
    text-decoration: none;
    color: var(--color-secondary);
}

.footer-navigation {
    flex: 1;
}

.footer-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-menu a {
    color: var(--color-secondary);
    font-size: 24px;
    font-weight: 300;
    letter-spacing: 0.02em;
}

.site-info {
    margin-top: auto;
    padding-top: 50px;
    text-align: left;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.site-info p {
    margin: 0;
}

.site-info a {
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
}

/* ========================================
   RESPONSIVE - TABLET
======================================== */

@media (max-width: 1200px) {
    .foto-item {
        width: calc(33.333% - 7px);
    }

    .archivio-timeline {
        width: 80px;
    }

    .archivio-content {
        padding-right: 80px;
    }

    .timeline-inner {
        right: 10px;
    }

    /* Info foto in colonna su tablet */
    .foto-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        min-height: auto;
    }

    .foto-title {
        font-size: 11px;
    }

    .foto-meta {
        text-align: left;
    }
}

@media (max-width: 1024px) {
    .hero-content {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   RESPONSIVE - MOBILE (max-width: 768px)
======================================== */

@media (max-width: 768px) {

    .container,
    .header-container {
        padding: 6px 15px;
    }

    /* Footer mobile: resta su una riga, logo a destra */
    .footer-container {
        padding: 0px 20px;
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        gap: 20px;
        min-height: unset;
    }

    .footer-widgets {
        order: 2;
        margin-left: 0;
        flex-shrink: 0;
        display: flex;
        align-items: flex-start;
        padding-top: 4px;
    }

    .footer-info {
        order: 1;
        flex: 1;
    }

    .site-info {
        text-align: left;
        padding-top: 60px;
        border-top: 0px solid rgba(255, 255, 255, 0.1);
        width: 100%;
    }

    .site-footer {
        padding: 40px 0 24px;
        margin-top: 60px;
    }

    /* HEADER MOBILE */
    .header-container {
        position: relative;
        display: flex;
        justify-content: space-between;
        align-items: center;
        /* padding: 20px; */
    }

    .site-branding {
        flex: 1;
        z-index: 1001;
    }

    /* Search Icon Mobile */
    .search-text-desktop {
        display: none;
    }

    .search-icon-mobile {
        display: block;
        width: 24px;
        height: 24px;
        stroke: #000;
    }

    .header-search-btn {
        padding: 0;
        width: 24px;
        height: 24px;
    }

    .header-search-box {
        order: 2;
        margin-right: 10px;
        z-index: 1001;
    }

    /* Menu Toggle VISIBILE */
    body .site-header .menu-toggle {
        display: flex !important;
        flex-direction: column !important;
        gap: 5px !important;
        z-index: 1002;
        order: 3;
    }

    /* Menu Mobile Full Screen */
    .main-navigation {
        position: fixed;
        top: 0; 
        left: 0;
        width: 100%;
        height: 100vh;
        background: var(--color-secondary);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-top: 1px solid var(--color-primary);
        z-index: 1000;
        overflow-y: auto;
        padding: 0;
    }

    .main-navigation.active {
        transform: translateX(0);
    }

    .main-navigation .nav-menu {
        flex-direction: column;
        padding: 40px 0px;
        gap: 20px;
    }

    .main-navigation .nav-menu a {
        font-size: 18px !important;
        text-transform: uppercase !important;
        letter-spacing: 1.5px !important;
        display: block;
        padding: 12px 20px;
        border-bottom: 1px solid #f0f0f0;
        width:100vw;
    }

    .menu-buttons {
        gap: 0;
    }

    /* ARCHIVIO MOBILE */
    body .archivio-page .archivio-container {
        display: block !important;
        padding: 0;
        position: relative;
    }

    body .archivio-page .archivio-content {
        padding: 15px 10px 120px !important;
    }

    /* TIMELINE MOBILE - Barra verticale compatta a destra */
    .archivio-timeline {
        position: relative !important;
    }

    .timeline-inner {
        position: fixed !important;
        bottom: 120px !important;
        right: 6px !important;
        z-index: 100 !important;
    }

    .timeline-content {
        height: 100% !important;
    }

    .timeline-bar {
        height: 100% !important;
    }

    .timeline-year {
        padding: 3px 0 !important;
    }

    .timeline-year-label {
        font-size: 12px !important;
        font-weight: 500 !important;
        color: #999 !important;
        letter-spacing: -0.02em !important;
    }

    .timeline-year.active .timeline-year-label {
        font-size: 18px !important;
        font-weight: 700 !important;
        color: #000 !important;
    }

    .timeline-year.has-photos .timeline-year-label {
        color: #555 !important;
    }

    .timeline-tick {
        display: none !important;
    }

    .timeline-year.has-photos::after {
        display: none !important;
    }

    /* Stats rimangono fisse in basso, OK */
    .archivio-stats {
        position: fixed !important;
        bottom: 90px !important;
        right: 15px !important;
        z-index: 50;
    }

    body .archivio-page .stat-item {
        font-size: 11px !important;
        color: rgba(0, 0, 0, 0.25) !important;
    }

    /* GRID MOBILE - Masonry come su desktop.
       Le CSS columns bilanciavano le altezze (colonna 1 = foto recenti,
       colonna 3 = foto vecchie): l'ordine cronologico visivo saltava e
       la timeline non poteva evidenziare la decade corretta. */
    body .archivio-page .archivio-grid {
        display: block !important;
        column-count: auto !important;
        padding: 0 !important;
        width: 100% !important;
    }

    body .archivio-page .foto-item {
        width: calc(33.333% - 4px) !important;
        margin-bottom: 6px !important;
        background: transparent !important;
    }

    body .archivio-page .foto-item:hover {
        transform: none !important;
        z-index: auto !important;
    }

    body .archivio-page .foto-item:hover .foto-image {
        transform: none !important;
        box-shadow: none !important;
    }

    body .archivio-page .foto-hover-box {
        display: none !important;
    }

    body .archivio-page .foto-image {
        margin-bottom: 0 !important;
    }

    body .archivio-page .foto-image img {
        width: 100% !important;
        height: auto !important;
    }

    /* NASCONDI INFO FOTO */
    body .archivio-page .foto-info,
    body .archivio-page .foto-title,
    body .archivio-page .foto-meta {
        display: none !important;
    }

    /* Con la nav nascosta il titolo pagina si ritira: ricerca e tag filtri
       salgono all'altezza della nav invece di restare sospesi a meta' viewport */
    body.header-hidden .archivio-header > .container-fluid {
        display: none;
    }

    /* Active Filters Mobile */
    .active-filters {
        padding: 10px 15px;
        min-height: 42px;
        /* Con la nav nascosta la barra scorre sopra la griglia: serve un fondo leggibile */
        background: rgba(255, 255, 255, 0.92);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
    }

    .filter-badge {
        padding: 4px 8px;
        font-size: 10px;
    }

    .badge-remove {
        font-size: 12px;
    }

    .clear-all-filters {
        padding: 4px 8px;
        font-size: 10px;
    }

    /* ALTRO */
    .hero-content {
        grid-template-columns: 1fr;
    }

    .hero-pattern {
        height: 300px;
    }

    .page-title {
        font-size: 32px;
    }

    .foto-details-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    /* Nasconde il testo "Cerca" nei bottoni */
    .search-text-desktop {
        display: none;
    }

    .search-icon-mobile {
        display: block;
    }

    /* Overlay */
    .header-search-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(10, 10, 10, 0.8);
        backdrop-filter: blur(4px);
        display: none;
        align-items: center;
        justify-content: center;
        padding: 20px;
        z-index: 9999;
    }

    .header-search-overlay.active {
        display: flex;
    }

    /* Input fullscreen */
    .header-search-overlay input[type="search"] {
        width: 100%;
        padding: 16px 20px;
        font-size: 18px;
        border-radius: 12px;
        border: 1px solid var(--color-primary);
        background: var(--color-secondary);
        color: var(--color-white);
    }

    /* Icona chiusura */
    .header-search-close {
        position: absolute;
        top: 20px;
        right: 20px;
        font-size: 32px;
        cursor: pointer;
        color: var(--color-white);
    }

    .header-search-box {
        display: flex;
        flex: 1 1 auto;
        /* permette di adattarsi */
        max-width: 100%;
        /* non supera mai lo schermo */
        overflow: hidden;
        /* per sicurezza */
    }

    .header-search-box.active .header-search-input {
        width: 100% !important;
        /* prende tutta la larghezza disponibile */
        padding: 8px 12px;
        opacity: 1;
    }
}

/* ========================================
   RESPONSIVE - SMALL MOBILE (max-width: 480px)
======================================== */

@media (max-width: 480px) {
    .site-title {
        font-size: 18px;
    }

    body .archivio-page .archivio-grid {
        gap: 6px !important;
    }

    body .archivio-page .archivio-content {
        padding: 15px 8px 120px !important;
    }

    /* Timeline small mobile */
    .timeline-inner {
        right: 5px !important;
        bottom: 100px !important;
    }

    .timeline-year-label {
        font-size: 11px !important;
        font-weight: 500 !important;
    }

    .timeline-year.active .timeline-year-label {
        font-size: 14px !important;
        font-weight: 700 !important;
    }

    .timeline-tick {
        display: none !important;
    }

    .archivio-stats {
        right: 10px !important;
    }

    .filters-sidebar {
        width: 100vw;
        left: -100vw;
    }

    .filter-items-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-title {
        font-size: 24px;
    }

    .foto-year-overlay {
        font-size: 48px;
        right: 15px;
    }
}


@media (max-width: 768px) {

    /* DETAIL PAGE MOBILE - immagine a tutto schermo, scroll unico di pagina */
    .foto-detail {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: auto;
        overflow: visible;
    }

    .foto-detail-sidebar {
        display: none;
    }

    .foto-detail-image {
        width: 100%;
        /* Massima dimensione possibile: viewport intera meno la nav */
        height: calc(100vh - var(--header-height));
        height: calc(100dvh - var(--header-height));
        cursor: ew-resize;
        overflow: hidden;
        padding: 0;
        order: 1;
    }

    .foto-detail-image #detail-main-img {
        width: 100%;
        height: 100%;
        max-height: none;
        object-fit: contain;
    }

    /* Niente scroll isolato sui dati: scorre la pagina fino al footer */
    .foto-detail-meta {
        order: 2;
        width: 100%;
        height: auto;
        min-height: auto;
        border-right: none;
        overflow: visible;
        padding: 20px;
    }

    .foto-detail-meta-inner {
        overflow: visible;
        min-height: 0;
        flex: 0 0 auto;
    }

    .back-link-desktop {
        display: none;
    }

    .back-link-mobile {
        display: block;
        padding: 20px;
        text-align: center;
        order: 3;
    }
}
