/* ===== FILE CSS ULTRA MODERNO PER MUSEO E DIGITAL HUMANITIES ===== */
@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital@0;1&family=Open+Sans:wght@400;600;700&display=swap');

/* ============== ROOT VARIABLES ============== */
:root {
  /* Tema chiaro (esistente) */
  --background-color: #f9f7f1;
  --text-color: #333;
  --link-color: #2b4a6f;
  --link-hover-color: #ff9800;
  --header-background: linear-gradient(120deg, #1e3c72, #2a5298);
  --navbar-link-color: #ffffffcc;
  --navbar-active-color: #ffffff;
  --card-background: #ffffff;
  --border-color: #e0e0e0;
  --shadow-soft: 0 6px 18px rgba(0,0,0,0.08);

  /* Nuove variabili per le card */
  --card-accent-light: linear-gradient(135deg, #1e3c72, #2a5298);
  --card-accent-dark: linear-gradient(135deg, #ff9800, #ff6d00);
  --card-shadow-hover: 0 24px 48px -12px rgba(30, 60, 114, 0.22);
  --card-radius: 0.75rem;
  --transition-museum: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

body.dark-mode {
  /* Tema scuro (esistente) */
  --background-color: #1f1f1f;
  --text-color: #eee;
  --link-color: #9ecaff;
  --link-hover-color: #ffb347;
  --header-background: linear-gradient(120deg, #121212, #1e1e1e);
  --navbar-link-color: #ccc;
  --navbar-active-color: #ffffff;
  --card-background: #2a2a2a;
  --border-color: #444;
  --shadow-soft: 0 6px 18px rgba(255,255,255,0.05);

  /* Override nuove variabili per dark mode */
  --card-accent-light: linear-gradient(135deg, #ff9800, #ff6d00);
  --card-shadow-hover: 0 24px 48px -12px rgba(255, 152, 0, 0.18);
}

/* General styles */
body {
  background: var(--background-color);
  color: var(--text-color);
  font-family: 'Open Sans', sans-serif;
  transition: all 0.4s ease;
}

/* TITOLI SEZIONI */
section h2 {
  text-align: center;
  font-family: 'Libre Baskerville', serif;
  font-size: clamp(2em, 4vw, 2.6em);
  margin-bottom: 30px;
  color: var(--link-color);
  letter-spacing: 0.5px;
  position: relative;
}

section h2::after {
  content: "";
  display: block;
  width: 80px;
  height: 4px;
  margin: 16px auto 0;
  background: linear-gradient(90deg, var(--link-hover-color), var(--link-color), var(--link-hover-color));
  background-size: 200% 100%;
  background-position: 0% 50%;
  border-radius: 50px;
  opacity: 0;
  transform: scaleX(0.5);
  animation: underlineEntrance 1.2s ease-out forwards 0.4s, underlineWave 3s infinite ease-in-out alternate;
}

@keyframes underlineEntrance {
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

@keyframes underlineWave {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 100% 50%;
  }
}


/* === DATASET SELECTOR ULTRA-MODERNO === */
.dataset-selector {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
  margin: 50px 0;
  padding: 0 10px;
}

/* Singola Card */
.dataset-option {
  flex: 1 1 260px;
  min-width: 240px;
  background: var(--card-background);
  border: 2px solid var(--border-color);
  border-radius: 16px;
  padding: 28px 22px;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s ease;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.dataset-option::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top center, rgba(255, 152, 0, 0.2) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.4s;
  z-index: 0;
}

.dataset-option:hover::before {
  opacity: 1;
}

.dataset-option:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  border-color: var(--link-hover-color);
}

/* Card attiva */
.dataset-option.active {
  border-color: var(--link-color);
  background: linear-gradient(135deg, rgba(42,82,152,0.05), rgba(255,255,255,0.9));
}

/* Icona grande */
.dataset-option i {
  font-size: 3rem;
  color: var(--link-color);
  margin-bottom: 18px;
  display: block;
  transition: color 0.3s ease, transform 0.3s ease;
  z-index: 1;
  position: relative;
}

.dataset-option:hover i {
  color: var(--link-hover-color);
  transform: scale(1.1);
}

/* Titolo della Card */
.dataset-option h3 {
  margin: 12px 0 8px;
  font-size: 1.5em;
  color: var(--text-color);
  font-family: 'Libre Baskerville', serif;
  letter-spacing: 0.5px;
  transition: color 0.3s ease;
  z-index: 1;
  position: relative;
}

/* Descrizione */
.dataset-option p {
  color: #666;
  font-size: 1em;
  line-height: 1.6;
  max-width: 90%;
  margin: 0 auto;
  z-index: 1;
  position: relative;
}

/* === DARK MODE === */
body.dark-mode .dataset-option {
  background: var(--card-background);
  border-color: var(--border-color);
}

body.dark-mode .dataset-option:hover {
  border-color: var(--link-hover-color);
  box-shadow: 0 10px 30px rgba(255,255,255,0.08);
}

body.dark-mode .dataset-option.active {
  background: linear-gradient(135deg, rgba(30,50,70,0.4), rgba(20,20,20,0.9));
}

body.dark-mode .dataset-option h3,
body.dark-mode .dataset-option p {
  color: var(--text-color);
}

body.dark-mode .dataset-option i {
  color: var(--link-color);
}

body.dark-mode .dataset-option:hover i {
  color: var(--link-hover-color);
}

body.dark-mode .dataset-option::before {
  background: radial-gradient(circle at top center, rgba(255, 152, 0, 0.1) 0%, transparent 70%);
}

.dataset-option[data-dataset="slovenia"] i {
    color: #E15759;
}

.annotation {
    font-size: 0.9em;
    color: #666;
}



/* === BASE GLOBALE MODERNISSIMA === */
body {
  margin: 0;
  padding: 0;
  font-family: 'Open Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: clamp(1rem, 1.2vw, 1.1rem); /* Font molto fluido */
  background: var(--background-color);
  color: var(--text-color);
  line-height: 1.75; /* Respiro elegante */
  scroll-behavior: smooth;
  transition: background-color 0.4s ease, color 0.4s ease, font-size 0.3s ease;
  overflow-x: hidden; /* Sicurezza responsive */
  letter-spacing: 0.2px;
  word-spacing: 0.5px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Dark mode */
body.dark-mode {
  background: var(--background-color);
  color: var(--text-color);
}

/* === LINK STYLE ULTRA MODERNO === */
a {
  color: var(--link-color);
  text-decoration: none;
  position: relative;
  display: inline-block;
  transition: color 0.3s ease, transform 0.2s ease;
}

/* Hover effetto elegante */
a::after {
  content: "";
  display: block;
  width: 0%;
  height: 2px;
  background: var(--link-hover-color);
  transition: width 0.3s ease;
  margin-top: 4px;
  border-radius: 2px;
}

a:hover::after {
  width: 100%;
}

a:hover {
  color: var(--link-hover-color);
  transform: translateY(-1px);
}

/* Dark Mode */
body.dark-mode a {
  color: var(--link-color);
}

body.dark-mode a:hover {
  color: var(--link-hover-color);
}

/* Piccolo miglioramento anche per focus accessibilità */
a:focus-visible {
  outline: 2px dashed var(--link-hover-color);
  outline-offset: 4px;
}



/* === HEADER === */

header {
  background: linear-gradient(135deg, #162447, #1f4068, #1b1b2f);
  background-size: 400% 400%;
  color: #fff;
  text-align: center;
  padding: 100px 20px; /* <-- PIU' RESPIRO! */
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
  transition: background-position 0.5s ease, background 0.5s ease, transform 0.4s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  min-height: 90vh; /* <-- PUOI ANCHE AGGIUNGERE QUESTO per effetto "hero" */
  display: flex;
  flex-direction: column;
  justify-content: center;
}


/* Animazione dinamica automatica */
@keyframes headerPulse {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Effetto continuo elegante */
header.animated {
  animation: headerPulse 18s ease infinite;
}

/* Hover ancora più coinvolgente */
header:hover {
  background-position: right center;
  transform: translateY(-2px) scale(1.01);
}

/* Dark mode migliorato */
body.dark-mode header {
  background: linear-gradient(135deg, #0d0d0d, #1a1a1a, #222);
  background-size: 300% 300%;
}

/* === Titolo === */
header h1 {
  margin: 0;
  font-family: 'Libre Baskerville', serif;
  font-size: clamp(1.8em, 4vw, 2.4em);
  letter-spacing: 0.8px;
  text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.5);
  animation: fadeInDown 1s ease both;
}

/* === Sottotitolo === */
header .sottotitolo {
  font-style: italic;
  font-size: clamp(0.95em, 2vw, 1.2em);
  color: #d8d8d8;
  margin: 8px 0 14px 0;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  animation: fadeInUp 1s ease both 0.3s;
}

/* Fade in elegante */
@keyframes fadeInDown {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* ===== HEADER RIDOTTO PER TABLET ===== */
@media (max-width: 1024px) and (min-width: 769px) {
  header {
    padding: 60px 20px !important; /* Ridotto da 100px */
    min-height: 60vh !important; /* Ridotto da 90vh */
  }

  header h1 {
    font-size: clamp(1.6em, 3.5vw, 2em) !important; /* Più compatto */
    margin-bottom: 10px !important;
  }

  header .sottotitolo {
    font-size: clamp(0.85em, 1.8vw, 1em) !important;
    margin-bottom: 10px !important;
  }

  .section-navbar {
    margin-top: 20px !important;
    padding: 8px 16px !important;
    max-width: 96% !important;
  }

  /* Animazioni più veloci su tablet */
  header.animated {
    animation-duration: 12s !important;
  }

  /* Riduci lo spazio tra elementi */
  .header-content {
    gap: 15px !important;
  }
}

/* Mantieni dimensioni originali per mobile */
@media (max-width: 768px) {
  header {
    padding: 100px 20px !important;
    min-height: 90vh !important;
  }
}


/* === SWITCH LIGHT/DARK MODE SUPER MODERNO === */
.theme-toggle {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 1000;
}

.theme-switch {
  background: linear-gradient(135deg, #ffffff, #e0e0e0);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: all 0.4s ease;
}

.theme-switch:hover {
  background: linear-gradient(135deg, #f5f5f5, #dddddd);
  transform: translateY(-3px) scale(1.05);
}

.switch-icon {
  position: relative;
  width: 26px;
  height: 26px;
  font-size: 1.7em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.switch-icon .sun,
.switch-icon .moon {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  transform-origin: center;
  transition: opacity 0.4s ease, transform 0.6s ease;
}

.switch-icon .sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.switch-icon .moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0);
}

body.dark-mode .switch-icon .sun {
  opacity: 0;
  transform: rotate(90deg) scale(0);
}

body.dark-mode .switch-icon .moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* === Modalità Scura Modernizzata === */
body.dark-mode .theme-switch {
  background: linear-gradient(135deg, #222, #333);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.08);
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

/* Animazione icone migliorata */
body.dark-mode .switch-icon .sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
  transition: opacity 0.4s, transform 0.6s;
}

body.dark-mode .switch-icon .moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
  transition: opacity 0.4s, transform 0.6s;
}




/* === NAVBAR ORIZZONTALE STILE APP === */
.section-navbar {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap; /* 🔥 Così su mobile si adatta senza andare a capo forzato */
  gap: 16px;
  margin-top: 30px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 18px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  max-width: 92%;
  margin-inline: auto;
}

/* LINK NAVIGAZIONE */
.section-navbar a {
  display: flex;
  flex-direction: column; /* Icona sopra, testo sotto */
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  color: #ffffffcc;
  font-weight: 500;
  font-size: 0.95em;
  background: transparent;
  padding: 10px 14px;
  border-radius: 12px;
  transition: all 0.4s ease;
}

/* Icone */
.section-navbar a i {
  font-size: 1.6em;
  transition: transform 0.3s ease;
}

/* Testo */
.section-navbar a span {
  font-size: 0.85em;
}

/* Hover effetto */
.section-navbar a:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffd700;
  transform: translateY(-2px);
}

.section-navbar a:hover i {
  transform: scale(1.2);
}

/* Link attivo */
.section-navbar a.attivo {
  background: linear-gradient(135deg, #ffd700, #ffa500);
  color: #1b1b2f;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* === DARK MODE === */
body.dark-mode .section-navbar {
  background: rgba(30, 30, 30, 0.2);
}

body.dark-mode .section-navbar a {
  color: #ccc;
}

body.dark-mode .section-navbar a:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffdd66;
}

body.dark-mode .section-navbar a.attivo {
  background: linear-gradient(135deg, #ffdd66, #ffbb33);
  color: #1b1b2f;
}


/* === CONTENITORE TECA MUSEALE PER LISTA LUOGHI === */
.lista-luoghi-wrapper {
  max-width: 1400px;
  margin: 5rem auto;
  padding: 3rem 2rem;
  background: linear-gradient(135deg, rgba(250, 250, 250, 0.95), rgba(245, 245, 245, 0.95));
  border: 1px solid rgba(180, 180, 180, 0.3);
  border-radius: 32px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  transition: all 0.6s ease;
  overflow: hidden;
}

/* === GRIGLIA INTERNAMENTE === */
#lista-luoghi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2.8rem;
  margin-top: 2rem;
  animation: fadeInUpGrid 1s ease forwards;
}

/* Singola Card */
.luogo-card {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
  transition: all 0.4s ease;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}

.luogo-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.1);
}

/* Titolo */
.luogo-card h3 {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.6em;
  color: #2b4a6f;
  margin-bottom: 0.5rem;
}

/* Descrizione */
.luogo-card p {
  font-size: 1.05em;
  color: #555;
  line-height: 1.7;
}

/* === Animazione elegante === */
@keyframes fadeInUpGrid {
  0% {
    opacity: 0;
    transform: translateY(40px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === DARK MODE della TECA === */
body.dark-mode .lista-luoghi-wrapper {
  background: linear-gradient(135deg, rgba(30, 30, 30, 0.92), rgba(20, 20, 20, 0.9));
  border: 1px solid rgba(80, 80, 80, 0.4);
  box-shadow: 0 14px 34px rgba(255, 255, 255, 0.05);
}

body.dark-mode .luogo-card {
  background: rgba(40, 40, 40, 0.9);
  box-shadow: 0 8px 20px rgba(255, 255, 255, 0.06);
}

body.dark-mode .luogo-card h3 {
  color: #aad4ff;
}

body.dark-mode .luogo-card p {
  color: #ccc;
}



/* ============== ARCHIVIO VIDEO INTERATTIVO - STILE MUSEALE OTTIMIZZATO ============== */

/* Variabili */
:root {
  --video-card-bg: rgba(255, 255, 255, 0.96);
  --video-card-bg-hover: rgba(240, 243, 255, 0.98);
  --video-card-border: rgba(220, 220, 230, 0.4);
  --video-card-shadow: 0 4px 20px rgba(42, 67, 113, 0.1);
  --video-card-shadow-hover: 0 8px 30px rgba(42, 67, 113, 0.2);
  --link-color: #3b5bdb;
  --link-hover-color: #ff9800;
  --overlay-bg: rgba(0, 0, 0, 0.8);
}

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




/* Carousel orizzontale */
.video-carousel {
  display: flex;
  overflow-x: auto;
  gap: 2rem;
  padding-bottom: 2rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.video-carousel::-webkit-scrollbar {
  height: 6px;
}

.video-carousel::-webkit-scrollbar-thumb {
  background: rgba(100, 100, 150, 0.4);
  border-radius: 3px;
}

/* Card */
.video-card {
  flex: 0 0 auto;
  width: 300px;
  background: var(--video-card-bg);
  border: 1px solid var(--video-card-border);
  border-radius: 16px;
  box-shadow: var(--video-card-shadow);
  overflow: hidden;
  scroll-snap-align: start;
  position: relative;
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.video-card:hover {
  transform: scale(1.02);
  box-shadow: var(--video-card-shadow-hover);
  background: var(--video-card-bg-hover);
}

/* Thumbnail */
.video-thumbnail-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: #000;
}

.video-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Pulsante play */
.video-play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.video-play-button::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid var(--link-color);
}

.video-card:hover .video-play-button {
  transform: translate(-50%, -50%) scale(1.05);
}

/* Info */
.video-info {
  padding: 1.2rem 1rem;
  background: var(--video-card-bg);
}

.video-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--link-color);
  margin-bottom: 0.5rem;
  transition: color 0.3s ease;
}

.video-card:hover .video-title {
  color: var(--link-hover-color);
}

.video-meta {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.video-description {
  font-size: 0.95rem;
  color: #555;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Stato playing */
.video-card.playing {
  border: 2px solid var(--link-hover-color);
  box-shadow: var(--video-card-shadow-hover);
  z-index: 10;
  transform: scale(1.05);
}

.video-player-embed {
  position: absolute;
  inset: 0;
  background: #000;
  display: none;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  z-index: 5;
}

.video-player-embed iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.video-card.playing .video-player-embed {
  display: block;
}

.video-card.playing .video-play-button {
  opacity: 0;
  pointer-events: none;
}

/* Overlay mobile */
.video-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.video-overlay.visible {
  display: block;
  opacity: 1;
}

/* MOBILE Ottimizzazione player */
@media (max-width: 768px) {
  .video-card.playing {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 90vw;
    max-width: 600px;
    height: auto;
    transform: translate(-50%, -50%) scale(1);
    z-index: 1000;
    border-radius: 16px;
  }

  .video-card.playing .video-info {
    display: none;
  }
}

/* DARK MODE */
body.dark-mode {
  --video-card-bg: rgba(30, 30, 40, 0.95);
  --video-card-bg-hover: rgba(40, 40, 50, 0.98);
  --video-card-border: rgba(80, 80, 90, 0.3);
  --video-card-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --video-card-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.6);
  --link-color: #aad4ff;
  --link-hover-color: #ff9800;
}

body.dark-mode .video-archive-section {
  background: linear-gradient(155deg, #12121a 0%, #0d0d1a 100%);
}



/* === SUPER POPUP FIX MODERNO === */

/* Contenitore principale del popup Leaflet */
.leaflet-popup {
  max-width: 92vw !important;
  width: auto !important;
  margin: 0 auto !important;
}

/* Wrapper esterno */
.leaflet-popup-content-wrapper {
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 32px 32px 24px 24px !important;
  overflow: visible !important;
  position: relative;
}

/* Wrapper contenuto popup */
.leaflet-popup-content {
  margin: 0 !important;
  width: 100% !important;
  max-width: none !important;
  overflow: visible !important;
  padding: 0 !important;
  display: flex;
  justify-content: center;
}

/* Nasconde il triangolino di Leaflet */
.leaflet-popup-tip-container {
  display: none;
}

/* === X di chiusura ULTRA MODERNA === */
.leaflet-popup-close-button {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 190px;
  height: 190px;
  line-height: 190px;
  font-size: 190px;
  color: #333;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  border: 1px solid rgba(200, 200, 200, 0.4);
  border-radius: 50%;
  text-align: center;
  cursor: pointer;
  z-index: 2000;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  transition: all 0.35s ease;
}

.leaflet-popup-close-button:hover {
  background: linear-gradient(135deg, #ff6b6b, #ff8e53);
  color: white;
  transform: scale(1.15) rotate(8deg);
  box-shadow: 0 8px 24px rgba(255, 105, 97, 0.5);
}

/* === Dark Mode della X === */
body.dark-mode .leaflet-popup-close-button {
  color: #eee;
  background: rgba(30, 30, 30, 0.7);
  border: 1px solid rgba(80, 80, 80, 0.6);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.05);
}

body.dark-mode .leaflet-popup-close-button:hover {
  background: linear-gradient(135deg, #ff6666, #ff9966);
  color: #fff;
  transform: scale(1.15) rotate(8deg);
  box-shadow: 0 8px 24px rgba(255, 165, 150, 0.5);
}


/* === Struttura interna scrollabile === */
.popup-outer-container {
  position: relative;
  width: 100%;
}

.popup-inner-wrapper {
  max-height: 80vh;
  overflow-y: auto;
  padding: 80px 20px 20px 20px;
  box-sizing: border-box;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

/* Scrollbar elegante */
.popup-inner-wrapper::-webkit-scrollbar {
  width: 8px;
}
.popup-inner-wrapper::-webkit-scrollbar-thumb {
  background-color: #b49e87;
  border-radius: 8px;
}
.popup-inner-wrapper::-webkit-scrollbar-track {
  background: #f0edea;
}
.popup-inner-wrapper {
  scrollbar-width: thin;
  scrollbar-color: #b49e87 #f0edea;
}

/* === Contenuto popup === */
.popup-content {
  background: 
    linear-gradient(160deg, rgba(255, 255, 250, 0.88), rgba(245, 243, 240, 0.88)),
    url('media/texture-museo.png') center/cover no-repeat;
  background-blend-mode: overlay;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  padding: 32px 24px 32px 24px;
  border-radius: 30px;
  width: min(86vw, 620px);
  font-family: 'Libre Baskerville', serif;
  font-size: clamp(2em, 2vw, 2em);
  color: #222;
  line-height: 1.9;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(160, 130, 100, 0.3);
  animation: revealPopup 0.8s ease forwards;
  transition: all 0.4s ease;
}

/* Dark Mode per popup */
body.dark-mode .popup-content {
  background: 
    linear-gradient(160deg, rgba(30, 30, 30, 0.92), rgba(20, 20, 20, 0.9)),
    url('media/texture-museo.png') center/cover no-repeat;
  background-blend-mode: multiply;
  color: #eee;
  border: 1px solid rgba(220, 220, 220, 0.1);
  box-shadow: 0 20px 40px rgba(255, 255, 255, 0.05);
}

/* === Testi interni === */
.popup-content h3 {
  text-align: center;
  font-size: clamp(2.2em, 3vw, 2.6em);
  margin-bottom: 24px;
  color: #1a3c88;
  letter-spacing: 0.8px;
  padding-bottom: 8px;
  border-bottom: 2px solid #ffd700;
  width: fit-content;
  margin-inline: auto;
}
body.dark-mode .popup-content h3 {
  color: #7fcaff;
  border-bottom: 2px solid #ffdd66;
}

@media (max-width: 480px) {
  .popup-content h3 {
    font-size: clamp(1.8em, 5vw, 2.2em);
  }
}


.popup-content em {
  display: block;
  font-style: italic;
  font-size: clamp(1.05em, 1.4vw, 1.2em);
  color: #666;
  margin-bottom: 20px;
  text-align: center;
  opacity: 0.9;
}
body.dark-mode .popup-content em {
  color: #bbb;
}

.popup-content p {
  margin: 18px 0;
  font-size: 1.05em;
  line-height: 2;
  padding-inline: 8px;
  text-align: justify;
  word-break: break-word;
  hyphens: auto;
}

/* Media e oggetti */
.popup-content img,
.popup-content audio {
  margin-top: 40px;
  width: 92%;
  max-width: 620px;
  padding: 16px;
  background: linear-gradient(135deg, #f9f7f1, #f0f0eb);
  border: 1px solid #d4cfc7;
  border-radius: 28px;
  box-shadow: 
    0 4px 8px rgba(0,0,0,0.1),
    0 8px 24px rgba(0,0,0,0.08);
  display: block;
  margin-inline: auto;
  object-fit: contain;
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  font-family: 'Libre Baskerville', serif;
  accent-color: #2b4a6f; /* Colora slider e pulsanti dove supportato */
  transition: background 0.5s ease, box-shadow 0.5s ease, border 0.5s ease;
}

/* Hover morbido */
.popup-content audio:hover {
  background: linear-gradient(135deg, #fbfaf7, #f6f5f0);
  border-color: #c2b8aa;
  box-shadow: 
    0 6px 12px rgba(0,0,0,0.15),
    0 12px 32px rgba(0,0,0,0.1);
}

/* Dark Mode */
body.dark-mode .popup-content audio {
  background: linear-gradient(135deg, #2c2c2c, #1e1e1e);
  border: 1px solid #444;
  box-shadow: 
    0 4px 8px rgba(255,255,255,0.04),
    0 8px 24px rgba(255,255,255,0.06);
  accent-color: #aad4ff; /* slider azzurro in dark mode */
  color: #eee;
}

body.dark-mode .popup-content audio:hover {
  background: linear-gradient(135deg, #333, #262626);
  border-color: #555;
}




/* Animazione di apertura */
@keyframes revealPopup {
  0% {
    opacity: 0;
    transform: scale(0.94) translateY(50px);
  }
  60% {
    opacity: 0.7;
    transform: scale(1.02) translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}


/* === DESKTOP STYLES === */


#map {
  width: 100%;
  height: 100%;
  z-index: 1;
  background: linear-gradient(135deg, #d1d5db, #e5e7eb);
}

/* On expansion */
.map-expanded #map-container {
  height: 95vh;
  transform: scale(1.02); /* Slight scaling for the expanded state */
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2); /* Stronger shadow for more focus */
}

/* Controlli mappa Premium */
.map-controls {
  position: absolute;
  bottom: 28px;
  right: 28px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.map-btn {
  background: linear-gradient(145deg, #4f46e5, #6d28d9);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 54px;
  height: 54px;
  font-size: 1.4em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  transition: all 0.3s ease; /* Smooth transition for interactions */
}

.map-btn:hover {
  background: linear-gradient(145deg, #6d28d9, #4f46e5);
  transform: scale(1.15); /* Slight scale effect for hover */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); /* Enhanced hover shadow */
}

/* === Animazione chiusura popup === */
.leaflet-popup.closing {
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.3s ease;
}



/* ==================== SEZIONI ARCHIVIO ==================== */
.media-archive-section {
  --card-bg-light: rgba(255, 255, 255, 0.85);
  --card-bg-dark: rgba(30, 30, 30, 0.9);
  --card-accent-light: linear-gradient(180deg, #2b4a6f, #557aa8);
  --card-accent-dark: #5590d9;
  --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  --card-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.2);
  
  max-width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.25rem;
  background: linear-gradient(135deg, rgba(245, 245, 245, 0.9), rgba(255, 255, 255, 0.8));
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.media-archive-section:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* Griglia contenitore */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 1.875rem;
  margin-top: 1.5rem;
}

/* CARD GENERICA (condivisa tra video e luoghi) */
.media-card {
  position: relative;
  background: var(--card-bg-light);
  backdrop-filter: blur(12px);
  padding: 1.5rem;
  border-radius: 1.125rem;
  box-shadow: var(--card-shadow);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
  z-index: 1;
}

.media-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 0.375rem;
  height: 100%;
  background: var(--card-accent-light);
  border-radius: 0.375rem 0 0 0.375rem;
  transition: background 0.3s ease;
}

.media-card:hover {
  transform: translateY(-0.5rem);
  box-shadow: var(--card-shadow-hover);
  z-index: 2;
}

/* Contenuti card */
.media-card-header {
  font-size: 1.4em;
  margin: 0;
  color: #2b4a6f;
  letter-spacing: 0.03125em;
  font-weight: 600;
  transition: color 0.3s ease;
}

.media-card-meta {
  color: #777;
  font-style: italic;
  font-size: 1em;
  margin: 0.375rem 0;
}

.media-card-content {
  font-size: 1em;
  line-height: 1.8;
  color: #444;
  margin: 0.375rem 0;
}

.media-card-link {
  color: #1e3a8a;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.3s ease;
  display: inline-block;
  margin-top: 0.5rem;
}

.media-card-link:hover {
  color: #ff6f61;
  text-decoration: underline;
}

.media-card-image {
  max-width: 100%;
  border-radius: 0.75rem;
  display: block;
  margin-top: 1rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  transition: transform 0.3s ease;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.media-card-image:hover {
  transform: scale(1.02);
}

/* ==================== DARK MODE ==================== */
body.dark-mode .media-archive-section {
  background: linear-gradient(135deg, rgba(30, 30, 30, 0.9), rgba(20, 20, 20, 0.8));
}

body.dark-mode .media-card {
  background: var(--card-bg-dark);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.08);
}

body.dark-mode .media-card::before {
  background: var(--card-accent-dark);
}

body.dark-mode .media-card-header {
  color: #aad4ff;
}

body.dark-mode .media-card-meta {
  color: #ccc;
}

body.dark-mode .media-card-content {
  color: #ddd;
}

body.dark-mode .media-card-link {
  color: #ffd580;
}

body.dark-mode .media-card-link:hover {
  color: #ffbe5c;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .media-archive-section {
    padding: 1.25rem;
  }
  
  .media-grid {
    gap: 1.25rem;
  }
  
  .media-card {
    padding: 1.125rem;
  }
}

@media (max-width: 480px) {
  .media-archive-section {
    padding: 0.9375rem;
    border-radius: 0.75rem;
  }
  
  .media-grid {
    grid-template-columns: 1fr;
    gap: 0.9375rem;
  }
  
  .media-card {
    padding: 0.75rem;
    border-radius: 0.625rem;
  }
}

/* ==================== SPECIFICI PER LISTA LUOGHI ==================== */
#lista-luoghi {
  /* Stili specifici aggiuntivi se necessario */
}

/* ==================== SPECIFICI PER VIDEO LIST ==================== */
#video-list .media-card {
  /* Sovrascritture specifiche per video */
  padding-bottom: 0;
}

.video-player-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  margin: -1.5rem -1.5rem 1rem -1.5rem;
}

.video-player-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0.75rem 0.75rem 0 0;
}


/* === FOOTER SUPER MODERNO === */
footer {
  text-align: center;
  padding: 28px 14px;
  color: #777;
  font-size: 0.9em;
  background: linear-gradient(0deg, #f8f9fa 0%, #ffffff 100%);
  margin-top: 60px;
  border-top: 1px solid #eee;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}

.footer-social {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
}

.footer-social a {
  color: inherit;
  text-decoration: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.footer-social i, .footer-social img {
  font-size: 30px;
  width: 30px;
  height: 30px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.footer-social a:hover i,
.footer-social a:hover img {
  transform: scale(1.3) rotate(6deg);
  opacity: 0.85;
}


/* === GLOSSARIO SUPER MODERNO === */
.glossary-container {
  padding: 40px 20px;
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  gap: 24px;
}

.glossary-item {
  padding: 24px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-left: 5px solid #2b4a6f;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.4s ease;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInSlide 0.6s forwards;
}

.glossary-item:hover {
  background: rgba(245, 249, 255, 0.85);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1);
}

.glossary-term {
  font-family: 'Libre Baskerville', serif;
  font-size: clamp(1.6em, 3vw, 2em);
  color: #1e40af;
  margin-bottom: 12px;
}

.glossary-def {
  font-size: 1.1em;
  color: #444;
  line-height: 1.8;
  text-align: justify;
}

/* === DARK MODE === */
body.dark-mode .glossary-item {
  background: rgba(30, 30, 30, 0.8);
  border-left-color: #5590d9;
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.08);
}

body.dark-mode .glossary-term {
  color: #8dcaff;
}

body.dark-mode .glossary-def {
  color: #ccc;
}

/* === Animazione comparsa === */
@keyframes fadeInSlide {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}


/* === DARK MODE PER FILTRI E FOOTER SUPER MODERNA === */
body.dark-mode #filtro-categorie,
body.dark-mode #filtro-periodi,
body.dark-mode #barra-ricerca {
  background: rgba(30, 30, 30, 0.8);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(100, 100, 100, 0.4);
  color: #ddd;
  transition: all 0.4s ease;
}

body.dark-mode footer {
  background: linear-gradient(180deg, #1c1c1c 0%, #121212 100%);
  color: #bbb;
}

/* === PROGETTO BOX MODERNO === */
.progetto-box {
  background: rgba(255, 255, 255, 0.92);
  padding: 30px;
  border-left: 5px solid #2b4a6f;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  border-radius: 16px;
  font-size: 1.1em;
  line-height: 1.8;
  margin-top: 24px;
  transition: all 0.4s ease;
}

.progetto-box:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.12);
}

body.dark-mode .progetto-box {
  background: rgba(40, 40, 40, 0.9);
  border-left-color: #5590d9;
  color: #ddd;
}

/* === PATCH ICON MARKER TAPPE MODERNO === */
.leaflet-div-icon {
  background: transparent !important;
  border: none !important;
  pointer-events: auto !important;
}

.leaflet-div-icon div {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: darkred;
  border: 2px solid white;
  box-shadow: 0 0 10px rgba(255,0,0,0.5);
}

/* === FOTO BOX MODERNO === */
.foto-box {
  margin-top: 16px;
}

.foto-box .caption {
  font-size: 0.9em;
  color: #666;
  margin-top: 8px;
  font-style: italic;
  text-align: center;
}

body.dark-mode .foto-box .caption {
  color: #bbb;
}

/* === PATCH: IMMAGINI NEI LUOGHI === */
.luogo-scheda img {
  max-width: 100%;
  border-radius: 10px;
  display: block;
  margin-top: 16px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  transition: transform 0.3s ease;
}

.luogo-scheda img:hover {
  transform: scale(1.02);
}

.luogo-scheda figure {
  margin: 0;
  margin-top: 16px;
}

.luogo-scheda figcaption {
  font-size: 0.9em;
  font-style: italic;
  margin-top: 6px;
  color: #666;
  text-align: center;
}

body.dark-mode .luogo-scheda figcaption {
  color: #ccc;
}

/* === LIGHTBOX SUPER MODERNO === */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 5, 5, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  cursor: zoom-out;
  opacity: 0;
  animation: fadeInLightbox 0.4s forwards ease-out;
}

@keyframes fadeInLightbox {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.lightbox-img {
  max-height: 82vh;
  max-width: 92vw;
  object-fit: contain;
  transition: transform 0.3s ease;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: linear-gradient(135deg, #a64942, #e57373);
  color: white;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  transition: transform 0.3s ease, background 0.3s ease;
}

.lightbox-close:hover {
  transform: scale(1.15);
  background: linear-gradient(135deg, #e57373, #f28b82);
}

.lightbox-caption {
  color: white;
  text-align: center;
  margin-top: 18px;
  font-size: 1.1em;
  max-width: 80%;
  padding: 10px 14px;
  background: rgba(20, 20, 20, 0.8);
  border-radius: 8px;
}


/* =============== ULTRA MODERN MAPPA STYLE =============== */
#map-container {
  width: 100%;
  height: 90vh;  
  margin-bottom: 0;
  position: relative;
  padding: 0;
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
  transition: all 0.5s cubic-bezier(0.33, 1, 0.68, 1);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.15),
    inset 0 -4px 20px rgba(0,0,0,0.05);
}


/* Updated tablet breakpoint */
@media (max-width: 1024px) and (orientation: portrait) {
  #map-container {
    height: 72vh !important; /* Slightly taller, more balanced */
    margin-bottom: 100px;
  }
  
  #map {
    height: 100% !important;
  }

  #timeline-wrapper.floating-timeline {
    bottom: 80px;
    height: 120px;
  }
}


/* For landscape tablets */
@media (max-width: 1024px) and (orientation: landscape) {
  #map-container {
    height: 70vh !important; /* Slightly taller than portrait */
  }
}
/* Zona di espansione monumentale */
.map-bottom-extension {
  position: relative;
  height: 300px; /* 🔥 Altezza extra mostruosa */
  width: 100%;
  margin-top: -60px; /* Sovrappone la mappa */
  background: 
    linear-gradient(to bottom, 
      rgba(242, 245, 249, 0) 0%,
      var(--background-color) 70%),
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 10" preserveAspectRatio="none"><path d="M0,0 L100,0 L100,5 C60,15 40,-5 0,5 Z" fill="%23f2f5f9"/></svg>') top/100% auto no-repeat;
  z-index: 0;
  pointer-events: none;
}

/* Effetto onda dinamica */
@keyframes waveMotion {
  0%, 100% { background-position-x: 0%; }
  50% { background-position-x: 100%; }
}


/* Mappa vera e propria */
#map {
  width: 100%;
  height: 100%;
  z-index: 1;
  background: linear-gradient(135deg, #d1d5db, #e5e7eb);
  transition: inherit;
}



/* === CONTROLLI MAPPA STILE PREMIUM === */
.map-controls {
  position: absolute;
  bottom: 28px;
  right: 28px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.map-btn {
  background: linear-gradient(145deg, #4f46e5, #6d28d9);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 54px;
  height: 54px;
  font-size: 1.4em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  transition: all 0.4s ease;
}

.map-btn:hover {
  background: linear-gradient(145deg, #6d28d9, #4f46e5);
  transform: scale(1.15);
}

/* Bottoni dark mode */
body.dark-mode .map-btn {
  background: linear-gradient(145deg, #1f1f1f, #333);
  color: #eee;
  box-shadow: 0 6px 18px rgba(255, 255, 255, 0.08);
}

body.dark-mode .map-btn:hover {
  background: linear-gradient(145deg, #333, #1f1f1f);
}

/* Hover marker effetto tridimensionale */
.leaflet-marker-icon {
  transition: transform 0.3s ease, filter 0.3s ease;
}

.leaflet-marker-icon:hover {
  transform: scale(1.25) translateY(-6px);
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.35));
}

/* Effetto loading */
.map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  padding: 18px 30px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  display: none;
  font-weight: 600;
  font-size: 1.2em;
  letter-spacing: 0.6px;
}

body.dark-mode .map-loading {
  background: rgba(25, 25, 25, 0.85);
  color: #eee;
}



/* BONUS: Dark mode map background */
body.dark-mode #map {
  background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
}


/* ========== MODERN DATA TABLE & GRAPH STYLES ========== */

/* Data table principale */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 24px;
  font-family: 'Open Sans', sans-serif;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

/* Celle */
.data-table th, .data-table td {
  padding: 14px 18px;
  text-align: left;
  font-size: 0.95em;
  border-bottom: 1px solid #e0e0e0;
}

/* Intestazioni */
.data-table th {
  background: linear-gradient(135deg, #e0e7ef, #f2f4f8);
  font-weight: 700;
  color: #333;
  font-size: 1em;
}

/* Riga hover */
.data-table tr:hover {
  background-color: #f5f9ff;
}

/* Riga speciale (totali ecc.) */
.data-table tr.total-row {
  background: #eef2f7;
  font-weight: 600;
}

/* Errori */
.error-message {
  color: #721c24;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  padding: 14px 18px;
  border-radius: 8px;
  margin: 24px 0;
  font-weight: 500;
}

/* Controlli grafico */
#graph-controls {
  background: linear-gradient(135deg, #f9fafb, #f1f3f5);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* Selettori */
#year-selector, #data-selector, #graph-controls select {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #ced4da;
  background: #fff;
  font-family: 'Open Sans', sans-serif;
  font-size: 1em;
  transition: border-color 0.3s;
}

#year-selector:focus, #data-selector:focus, #graph-controls select:focus {
  border-color: #4f46e5;
  outline: none;
}

/* Contenitore grafico */
#chart-container {
  margin: 24px 0;
  padding: 18px;
  background: #ffffff;
  border: 1px solid #eee;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}

/* === DARK MODE === */
body.dark-mode .data-table {
  background: #1f1f1f;
  color: #eee;
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.05);
}

body.dark-mode .data-table th {
  background: linear-gradient(135deg, #2a2a2a, #333);
  color: #ccc;
}

body.dark-mode .data-table tr:hover {
  background: #2d2d2d;
}

body.dark-mode .data-table tr.total-row {
  background: #2b2b2b;
}

body.dark-mode #graph-controls {
  background: linear-gradient(135deg, #2b2b2b, #1f1f1f);
  box-shadow: 0 4px 12px rgba(255,255,255,0.04);
}

body.dark-mode #year-selector, 
body.dark-mode #data-selector,
body.dark-mode #graph-controls select {
  background: #333;
  color: #eee;
  border: 1px solid #555;
}

body.dark-mode #chart-container {
  background: #2a2a2a;
  border-color: #444;
  box-shadow: 0 6px 20px rgba(255,255,255,0.05);
}

body.dark-mode .error-message {
  background: #7a1f1f;
  color: #f2f2f2;
  border: 1px solid #a94442;
}
/* === Floating Timeline Elegant Modern Style === */
/* Timeline Wrapper Flottante */
#timeline-wrapper.floating-timeline {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  max-width: 1300px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(14px);
  border-radius: 20px;
  padding: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow-x: hidden;
  overflow-y: hidden;
  z-index: 0;
  height: 140px; /* 🔥 leggermente più alto */
}

/* Timeline Interna */
#timeline {
  min-width: 1000px;
  height: 160px; /* 🔥 più spazio per vedere sia eventi sia asse */
}

@media (max-width: 1024px) and (orientation: portrait) {
  #period-timeline-container {
    left: auto !important;
    right: auto !important;
    transform: none !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

  #timeline {
    min-width: unset; /* consente l’adattamento */
    width: 100%;
  }
}



/* Asse temporale */
.vis-time-axis {
  font-size: 13px;
  font-weight: 600;
  color: #666;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  padding: 4px 0;
  margin-top: 8px; /* 🔥 piccolissima spaziatura */
}


/* Timeline Items */
.vis-item {
  background: rgba(255, 255, 255, 0.85) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  border-radius: 12px !important;
  font-size: 13px;
  font-weight: 500;
  color: #333;
  padding: 6px 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

/* Timeline Items Hover Effect */
.vis-item:hover {
  background: rgba(255, 255, 255, 0.95) !important;
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
  border-color: rgba(0, 0, 0, 0.2) !important;
}

/* Timeline Current Time Line */
.vis-current-time {
  background: linear-gradient(90deg, #ff9800, #ff5722);
  height: 2px;
  box-shadow: 0 0 4px rgba(255, 120, 0, 0.6);
  border-radius: 2px;
}

/* Dark Mode Adjustments */
body.dark-mode #timeline-wrapper.floating-timeline {
  background: rgba(30, 30, 30, 0.8);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.08);
}

body.dark-mode .vis-item {
  background: rgba(40, 40, 40, 0.85) !important;
  border: 1px solid rgba(80, 80, 80, 0.4) !important;
  color: #ccc;
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
}

body.dark-mode .vis-item:hover {
  background: rgba(50, 50, 50, 0.95) !important;
  box-shadow: 0 8px 18px rgba(255, 255, 255, 0.1);
}

body.dark-mode .vis-time-axis {
  color: #aaa;
  background: rgba(40, 40, 40, 0.7);
}

/* Responsive Mobile Optimization */
@media (max-width: 768px) {
  #timeline-wrapper.floating-timeline {
    bottom: 10px;
    height: 100px;
    width: 95%;
    padding: 6px;
  }

  #timeline {
    height: 80px;
  }

  .vis-item {
    font-size: 12px;
    padding: 5px 8px;
  }
}


/* ✅ Timeline nascosta solo su telefoni minuscoli, NON su tablet */
@media (max-width: 380px) {
  .vis-timeline {
    display: none;
  }
}



/* === MOBILE FIX PERFORMANCE BOOST === */
@media (max-width: 768px) {
  * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  header.animated {
    animation: none !important;
  }

  section h2::after {
    animation: underlineEntrance 1.2s ease-out forwards 0.4s !important;
  }

  html, body {
    scroll-behavior: auto !important;
  }

  .dataset-option:hover,
  .luogo-card:hover,
  .media-card:hover {
    transform: none !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08) !important;
  }
}

/* === Modern Word Transition System === */
.dynamic-word-container {
  display: inline-block;
  position: relative;
  height: 1.2em; /* Fixed height to prevent layout shift */
  vertical-align: top;
}

.fade-word {
  display: inline-block;
  font-weight: 600;
  transition: all 0.5s ease;
  /* e tutto il resto */
}


/* === Fade Out Animation === */
.fade-word.fade-out {
  animation: 
    fadeOut 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards,
    slightBlurOut 0.8s ease-out forwards;
}

@keyframes fadeOut {
  0% {
    opacity: 1;
    transform: translateY(0) scaleX(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-15%) scaleX(0.98);
  }
}

@keyframes slightBlurOut {
  0% { filter: blur(0); }
  50% { filter: blur(2px); }
  100% { filter: blur(0); }
}

/* === Modern Enter Animation === */
.highlight-change {
  animation: 
    modernEnter 1s cubic-bezier(0.34, 1.56, 0.64, 1) both,
    slightBlurIn 1s ease-out both;
}

@keyframes modernEnter {
  0% {
    opacity: 0;
    transform: translateY(15%) scaleX(0.98);
    font-weight: 700;
  }
  30% {
    opacity: 1;
    transform: translateY(-5%) scaleX(1.02);
    font-weight: 700;
  }
  60% {
    transform: translateY(2%) scaleX(1);
    font-weight: 650;
  }
  100% {
    opacity: 1;
    transform: translateY(0) scaleX(1);
    font-weight: 600;
  }
}

@keyframes slightBlurIn {
  0% { filter: blur(2px); }
  70% { filter: blur(0); }
  100% { filter: blur(0); }
}

/* === Dark Mode Adjustments === */
body.dark-mode .fade-word {
  color: var(--link-color);
}

/* === Accessibility Focus State === */
.fade-word:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

//* === TIMELINE PERIODI POLITICI – UX/UI PREMIUM === */
#period-timeline-container {
  position: relative;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 48px);
  max-width: 1400px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  padding: 20px 24px;
  border-radius: 20px;
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.15),
    0 4px 6px rgba(0, 0, 0, 0.04);
  z-index: 0;
  pointer-events: auto;
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Wrapper e linea */
.timeline-wrapper {
  position: relative;
  width: 100%;
  height: 16px;
  margin: 12px 0 18px;
}

.timeline-line {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 6px;
  background: linear-gradient(90deg, 
    #2b4a6f 0%, 
    #3a6ea5 25%, 
    #ff9800 75%, 
    #ff6d00 100%);
  border-radius: 3px;
  transform: translateY(-50%);
  z-index: 1;
  box-shadow: 
    inset 0 1px 3px rgba(0, 0, 0, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Slider avanzato */
#period-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px; /* Area touch più ampia */
  background: transparent;
  margin: 0;
  position: relative;
  top: -16px;
  z-index: 3;
  cursor: pointer;
  outline: none;
  touch-action: manipulation;
}

/* Thumb premium */
#period-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  background: radial-gradient(
    circle at center, 
    rgba(255, 255, 255, 0.9) 30%, 
    rgba(255, 152, 0, 0.8) 100%);
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 
    0 0 0 2px rgba(255, 152, 0, 0.8),
    0 4px 20px rgba(255, 152, 0, 0.4);
  cursor: grab;
  transition: 
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border 0.2s ease;
}

#period-slider:active::-webkit-slider-thumb {
  transform: scale(1.3);
  box-shadow: 
    0 0 0 4px rgba(255, 152, 0, 0.3),
    0 6px 24px rgba(255, 152, 0, 0.5);
  cursor: grabbing;
}

/* Etichette intelligenti */
.period-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  gap: 8px;
}

.period-labels div {
  flex: 1 1 auto;
  text-align: center;
  min-width: 0;
  padding: 8px 6px;
  font-size: clamp(0.75rem, 1.6vw, 0.9rem);
  font-weight: 600;
  color: #444;
  border-radius: 8px;
  transition: 
    all 0.3s ease,
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.period-labels div:hover {
  background: rgba(0, 0, 0, 0.03);
}

.period-labels div.active-period {
  color: #fff;
  background: linear-gradient(135deg, #ff9800, #ff6d00);
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
  transform: translateY(-3px);
  font-weight: 700;
}

/* Bottone Mostra Tutti Premium */
#mostra-tutti-container {
  position: relative;
  right: auto;
  top: auto;
  margin: 24px auto 0;
  text-align: center;
}


#mostra-tutti-btn {
  padding: 10px 24px;
  background: linear-gradient(135deg, #4f46e5, #6d28d9);
  color: #fff;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 
    0 4px 12px rgba(79, 70, 229, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.05);
  transition: 
    all 0.3s ease,
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#mostra-tutti-btn:hover {
  background: linear-gradient(135deg, #6d28d9, #4f46e5);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 
    0 6px 16px rgba(79, 70, 229, 0.4),
    0 3px 6px rgba(0, 0, 0, 0.08);
}

#mostra-tutti-btn:active {
  transform: translateY(0) scale(0.98);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
  #period-timeline-container {
    padding: 18px;
    width: calc(100% - 36px);
  }
  
  #mostra-tutti-container {
    right: 18px;
    top: 18px;
  }
}

/* Tablet Landscape */
@media (max-width: 1024px) and (orientation: landscape) {
  #period-timeline-container {
    max-width: 900px;
    bottom: 20px;
    padding: 16px;
  }
  
  .period-labels div {
    font-size: 0.8rem;
    padding: 6px 4px;
  }
}

/* Tablet Portrait */
@media (max-width: 1024px) and (orientation: portrait) {
  #period-timeline-container {
    position: relative;
    bottom: auto;
    margin: 20px auto 0;
    width: calc(100% - 32px);
    padding: 16px;
  }
  
  .period-labels {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .period-labels div {
    flex: 1 0 calc(33.333% - 12px);
    font-size: 0.75rem;
    padding: 6px 2px;
  }
  
  #mostra-tutti-container {
    position: relative;
    right: auto;
    top: auto;
    margin: 16px auto 0;
    width: 100%;
  }
  
  #mostra-tutti-btn {
    width: 100%;
    padding: 12px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  #period-timeline-container {
    padding: 14px;
    border-radius: 16px;
  }
  
  .timeline-wrapper {
    height: 14px;
    margin: 8px 0 14px;
  }
  
  .timeline-line {
    height: 5px;
  }
  
  #period-slider {
    height: 28px;
    top: -14px;
  }
  
  #period-slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }
  
  .period-labels div {
    flex: 1 0 calc(50% - 8px);
    font-size: 0.7rem;
    padding: 6px 2px;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  #period-timeline-container {
    padding: 12px;
    width: calc(100% - 24px);
  }
  
  .period-labels div {
    font-size: 0.65rem;
    padding: 5px 1px;
  }
}

/* ===== DARK MODE PREMIUM ===== */
body.dark-mode #period-timeline-container {
  background: rgba(25, 25, 35, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.3),
    0 4px 6px rgba(0, 0, 0, 0.02);
}

body.dark-mode .timeline-line {
  background: linear-gradient(90deg, 
    #4f46e5 0%, 
    #6366f1 25%, 
    #f59e0b 75%, 
    #f97316 100%);
  box-shadow: 
    inset 0 1px 3px rgba(0, 0, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.1);
}

body.dark-mode .period-labels div {
  color: #ddd;
  background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .period-labels div:hover {
  background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .period-labels div.active-period {
  color: #fff;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
}

body.dark-mode #period-slider::-webkit-slider-thumb {
  background: radial-gradient(
    circle at center, 
    rgba(255, 255, 255, 0.9) 30%, 
    rgba(245, 158, 11, 0.8) 100%);
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 
    0 0 0 2px rgba(245, 158, 11, 0.8),
    0 4px 20px rgba(245, 158, 11, 0.4);
}

body.dark-mode #mostra-tutti-btn {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  box-shadow: 
    0 4px 12px rgba(99, 102, 241, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.1);
}

body.dark-mode #mostra-tutti-btn:hover {
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  box-shadow: 
    0 6px 16px rgba(99, 102, 241, 0.4),
    0 3px 6px rgba(0, 0, 0, 0.15);
}

/* High DPI/Retina */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  #period-slider::-webkit-slider-thumb {
    width: 32px;
    height: 32px;
    border-width: 4px;
  }
  
  .timeline-line {
    height: 5px;
  }
}


/* === Archivio Sezione Responsive Fix === */



/* Contenitore Archivio */
#archivio-luoghi {
  margin-top: 40px; /* Default Desktop */
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  #archivio-luoghi {
    margin-top: 280px; /* 🔥 Much lower now, no more collision with timeline */
  }
}


/* Mobile */
@media (max-width: 768px) {
  #archivio-luoghi {
    margin-top: 300px;
  }
}

@media (max-width: 1024px) and (orientation: portrait) {
  .popup-content {
    width: 92vw !important;
    max-width: 580px !important;
    height: auto !important;
    max-height: 68vh !important; /* 🔥 non troppo lungo, più armonico */
    font-size: clamp(1em, 2.3vw, 1.15em) !important; /* 🔥 Un filo più piccolo, molto fluido */
    padding: 24px 18px !important;
    overflow-y: auto !important;
    border-radius: 24px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important; /* più morbido */
  }

  .popup-inner-wrapper {
    max-height: 68vh !important;
    padding: 32px 16px 20px 16px !important;
    overflow-y: auto !important;
  }

  .popup-content h3 {
    font-size: clamp(2em, 4vw, 2.4em) !important; /* 🔥 Titolo leggermente più piccolo */
    margin-bottom: 18px !important;
    text-align: center;
    line-height: 1.2;
  }

  .popup-content img,
  .popup-content audio {
    width: 96% !important;
    max-width: 560px !important;
    margin-top: 20px !important;
    padding: 12px !important;
    background: #fafafa !important;
    border: 1px solid #d4cfc7 !important;
    border-radius: 20px !important;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08) !important;
    display: block !important;
    margin-inline: auto;
    object-fit: contain !important;
    font-family: 'Libre Baskerville', serif;
    accent-color: #2b4a6f !important;
  }

  .popup-content audio {
    height: 48px !important; /* 🔥 Player compattato */
    background: #fafafa !important; /* Sicuro per il rendering */
    border-radius: 12px !important;
  }

  .leaflet-popup-close-button {
    top: 12px !important;
    right: 12px !important;
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    font-size: 32px !important;
  }
}



  /* MAP section on mobile */
  #map-container {
    position: relative;
    height: 84vh !important;
    min-height: 400px;
    padding-bottom: 0;
    margin-bottom: 120px; /* Leave space after map for the archivio */
    z-index: 1;
  }

  #map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
  }

  /* TIMELINE properly inside map */
  #period-timeline-container {
    position: relative; /* Correct! Not fixed! */
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 500px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 16px;
    padding: 12px 16px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    z-index: 10; /* Above map */
    animation: fadeInTimeline 0.8s ease both;
  }

  /* Timeline internal elements */
  .timeline-wrapper {
    width: 100%;
    margin-bottom: 10px;
  }

  #period-slider {
    width: 100%;
  }

  /* Timeline labels */
  .period-labels {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    font-size: 0.75rem;
    text-align: center;
  }

  .period-labels div {
    flex: 0 1 auto;
    padding: 4px 8px;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  /* Show All Button */
  #mostra-tutti-container {
    text-align: center;
    margin-top: 8px;
  }

  #mostra-tutti-btn {
    padding: 8px 16px;
    font-size: 0.9em;
    border-radius: 8px;
    background-color: var(--link-color);
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
  }

  #mostra-tutti-btn:hover {
    background-color: var(--link-hover-color);
  }

  /* Ensure other components have correct stacking */
  .hero-card, .dataset-option, .media-card {
    z-index: 2;
    position: relative;
  }
}

/* === Timeline Entrance Animation === */
@keyframes fadeInTimeline {
  from {
    opacity: 0;
    transform: translate(-50%, 30px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
/* === MOBILE FIX - TIMELINE POSITIONING === */
@media (max-width: 768px) {
  #map-container {
    position: relative;
    height: 82vh !important;      /* 🔽 leggermente ridotto rispetto a 85vh */
    min-height: 360px;            /* 🔽 un filo meno */
    padding-top: 16px;            /* 🔽 meno respiro in alto, ma ancora ok per i popup */
    margin-bottom: 90px;          /* 🔽 ridotto leggermente anche lo spazio sotto */
    z-index: 1;
  }

  #map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
  }
}



  /* TIMELINE properly below map */
  #period-timeline-container {
    position: relative; /* Changed from fixed to relative */
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 1500px;
    background: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 16px;
    padding: 12px 16px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    z-index: 10; /* Above map */
    animation: fadeInTimeline 0.8s ease both;
    margin-top: -99px; /* Pull up slightly into map space */
    margin-bottom: 40px; /* Space below timeline */
  }

  /* Timeline internal elements */
  .timeline-wrapper {
    width: 100%;
    margin-bottom: 10px;
  }

  #period-slider {
    width: 100%;
  }

  /* Timeline labels */
  .period-labels {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    font-size: 0.75rem;
    text-align: center;
  }

  /* Show All Button */
  #mostra-tutti-container {
    text-align: center;
    margin-top: 8px;
  }

  /* Ensure other components have correct stacking */
  .hero-card, .dataset-option, .media-card {
    z-index: 2;
    position: relative;
  }
}

/* === Timeline Entrance Animation === */
@keyframes fadeInTimeline {
  from {
    opacity: 0;
    transform: translate(-50%, 30px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* === HERO CARD CATEGORIE MACRO === */
.hero-card {
  width: 280px;
  height: 180px;
  background: var(--card-background);
  border-radius: var(--card-radius);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
  margin: 16px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
}

.hero-card:hover {
  transform: scale(1.04);
  box-shadow: var(--card-shadow-hover);
}

.hero-card-title {
  z-index: 1;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* Overlay per rendere leggibile il testo su sfondi chiari */
.hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.4), rgba(0,0,0,0));
  z-index: 0;
}

.leaflet-control-layers.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* === Desktop only: Abbassa decisamente la timeline === */
@media (min-width: 1025px) {
  #timeline-wrapper.floating-timeline {
    bottom: 100px !important;
  }

  #timeline {
    height: 170px !important;
  }
}

}


body.popup-open #timeline-wrapper.floating-timeline {
  transform: scale(0.96);
  filter: blur(2px);
  opacity: 0.2;
}

.accordion-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.accordion-item {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.accordion-header {
  background: var(--card-background);
  color: var(--text-color);
  font-weight: bold;
  padding: 18px 20px;
  font-size: 1.1em;
  cursor: pointer;
  text-align: left;
  width: 100%;
  border: none;
  outline: none;
  transition: background 0.3s ease;
}

.accordion-header:hover {
  background: var(--link-hover-color);
  color: white;
}

.accordion-body {
  padding: 16px 20px;
  display: none;
  background: rgba(250, 250, 250, 0.85);
  color: var(--text-color);
  border-top: 1px solid var(--border-color);
}

.accordion-item.active .accordion-body {
  display: block;
}
/* === Evidenziazione approfondimenti === */
.lista-approfondimenti li.highlight {
  border-left: 4px solid #ff9800;
  background-color: rgba(255, 235, 200, 0.3);
  transition: all 0.6s ease;
}

.mini-header {
  padding: 10px 20px;
  background: var(--background-color, #f9f9f9);
  border-bottom: 1px solid #ccc;
  text-align: left;
}

.mini-header .back-link {
  font-size: 0.9rem;
  color: var(--link-color, #333);
  text-decoration: none;
}

.mini-title {
  font-size: 1.4rem;
  margin-top: 5px;
  line-height: 1.2;
}

#wordcloud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  background-color: #f4f4f4;
  border-radius: 12px;
  box-shadow: 0 0 12px rgba(0,0,0,0.1);
  margin-top: 30px;
}

.cloud-word {
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, color 0.2s ease;
  display: inline-block;
  user-select: none;
}

.cloud-word:hover {
  background-color: #f0f0f0;
  border-radius: 4px;
  transform: scale(1.1);
  transition: all 0.2s ease;
}

/* Filters Container */
.filters-container {
    display: flex;
    gap: 25px;
    justify-content: center;
    margin: 40px 0;
    flex-wrap: wrap;
}

.filter-block {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.filter-block label {
    font-size: 1.1em;
    color: #444;
    margin-bottom: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.filter-block select {
    padding: 12px;
    font-size: 1em;
    border-radius: 10px;
    border: 1px solid #ddd;
    background-color: #fafafa;
    transition: all 0.3s ease-in-out;
    width: 200px;
    color: #555;
}

.filter-block select:focus {
    outline: none;
    border-color: var(--link-hover-color);
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.5);
}

.filter-block select:hover {
    border-color: var(--link-hover-color);
}

/* ==========================================================
   EDGE‑FLUSH TOOLBAR — sleek “neumorphic‑glass” look
   (layout and adaptiveness unchanged)


/* Base Flex Layout for Category Toolbar */
.category-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.5rem, 1vw, 0.9rem);
  justify-content: center;
  margin: 0;
  padding: 0.5rem;
  list-style: none;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
}

/* Fallback for older browsers (IE, legacy Edge) */
@supports not (gap: 0.5rem) {
  .category-toolbar {
    margin: -0.25rem;
  }
  .category-toolbar > * {
    margin: 0.25rem;
  }
}

/* Button Styles for Category Buttons */
.category-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  font-family: "Libre Baskerville", Georgia, "Times New Roman", serif;
  font-size: clamp(0.85rem, 1.9vw, 1.05rem);
  text-transform: capitalize;
  border: 2px solid #2e6a47;
  background-color: transparent;
  color: #333;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  outline: none;
}

/* Focus styles for better accessibility */
.category-btn:focus-visible {
  outline: 2px solid #00796b;
  outline-offset: 2px;
}

/* Hover, active, and focus states */
.category-btn:hover,
.category-btn:focus-visible {
  background-color: #00796b;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.category-btn:active {
  transform: translateY(0) scale(0.96);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.14) inset;
}

/* Active state for the selected category */
.category-btn.active {
  background: linear-gradient(135deg, #009688, #00796b);
  color: #fff;
  box-shadow: 0 0 0 3px hsla(0, 0%, 100%, 0.35) inset, 0 8px 22px rgba(0, 0, 0, 0.15);
}

/* Adding a ripple effect */
.category-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: currentColor;
  opacity: 0;
  transform: scale(0.25);
  transition: transform 0.5s, opacity 0.5s;
  pointer-events: none;
}

.category-btn:active::after {
  opacity: 0.08;
  transform: scale(1.6);
  transition: none;
}

/* Dark Mode Styles */
@media (prefers-color-scheme: dark) {
  .category-btn {
    background-color: #ffffff;
    color: #000;
    border-color: #4a6b5e;
  }

  .category-btn:hover,
  .category-btn:focus-visible {
    background-color: #e0f2f1;
    border-color: #00796b;
  }

  .category-btn:active {
    background-color: #b2dfdb;
  }

  .category-btn.active {
    background: linear-gradient(135deg, #00695c, #004d40);
    border-color: #004d40;
  }
}



/* Legacy Browser Fallback for font-size clamp */
@supports not (font-size: clamp(1rem, 1vw, 1.2rem)) {
  .category-btn {
    font-size: min(max(0.85rem, 1.9vw), 1.05rem);
  }


