/*
 * Itinera 360 - VR Semantic Archive
 * Copyright (C) 2026 Riccardo Tedeschi
 * Un'applicazione/manifesto per la valorizzazione del patrimonio culturale
 * A application/manifesto for cultural heritage valorization
 * * Questo programma è software libero: è possibile ridistribuirlo e/o
 * modificarlo secondo i termini della GNU Affero General Public License
 * come pubblicata dalla Free Software Foundation, versione 3.
 * * Questo programma è distribuito nella speranza che sia utile,
 * ma SENZA ALCUNA GARANZIA. Vedi la GNU Affero General Public License 
 * per ulteriori dettagli.
 * * Dovresti aver ricevuto una copia della GNU Affero General Public License
 * insieme a questo programma. In caso contrario, vedi <https://www.gnu.org/licenses/>.
*/

body, html {
  margin: 0; padding: 0;
  height: 100%; width: 100%;
  font-family: 'Open Sans', Arial, sans-serif;
  overflow: hidden; 
}

/* --- 1A. VARIABILI GLASSMORPHISM E COLORI (V1.0) --- */
:root {
  --ui-scale: 1.1;
  --c-sfondo: rgba(255, 255, 255, 0.65);         
  --c-sfondo-hover: rgba(255, 255, 255, 0.85);   
  --c-sfondo-active: rgba(240, 240, 240, 0.9);   
  --c-testo: #222;
  --c-testo-hover: #000;
  --c-ombra: rgba(0,0,0,0.15);
  --c-ombra-forte: rgba(0,0,0,0.5); 
  --c-separatore: rgba(0,0,0,0.1);
  --c-testo-etichetta: #fff;
  --c-ombra-etichetta: rgba(0,0,0,0.6);
  --c-sfondo-sidebar: rgba(255, 255, 255, 0.90); 
  --c-popup-tip: rgba(255, 255, 255, 0.65);
  --c-testo-dim: rgba(0, 0, 0, 0.6);
  
  /* Colore Accento Light Mode (Goldenrod Standard) */
  --c-accento: #DAA520;      
  --c-accento-dark: #DAA520; 
  --c-accento-rgb: 218, 165, 32; 
  
  --transition-speed: 0.5s; 
  
  /* Logica Vetro Perfetto Centralizzata */
  --glass-blur: blur(15px) saturate(180%);
  --glass-border: 1px solid rgba(255, 255, 255, 0.18);
}

body.dark-mode {
  --c-sfondo: rgba(18, 18, 18, 0.8);        
  --c-sfondo-hover: rgba(30, 30, 30, 0.85);
  --c-sfondo-active: rgba(50, 50, 50, 0.9);
  --c-testo: #eee;
  --c-testo-hover: #fff;
  --c-ombra: rgba(0,0,0,0.4);
  --c-ombra-forte: rgba(0,0,0,0.6);
  --c-separatore: rgba(255,255,255,0.1);
  --c-sfondo-sidebar: rgba(18, 18, 18, 0.8);   
  --c-popup-tip: rgba(18, 18, 18, 0.8);
  --c-testo-dim: rgba(255, 255, 255, 0.6);

  /* Colore Accento Dark Mode (Oro Vivo) */
  --c-accento: #e6b840;      
  --c-accento-dark: #e6b840; 
  --c-accento-rgb: 230, 184, 64;
  
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- 1B. APPLICAZIONE VETRO PERFETTO UNIFICATA --- */
header, 
#header-credits-box,
.map-ui-button,
.leaflet-control-zoom,
.leaflet-popup-content-wrapper,
.pnlm-controls-container .pnlm-controls,
.pnlm-orientation-button,
#info-sidebar,
#info-btn, #photo-wall-btn, #audio-btn, #video-btn, #fullscreen-btn,
#close-modal-btn,
#photo-wall-modal,
.pnlm-custom-scene-hotspot.icon-only-hotspot,
#secret-pill,
.search-dropdown {
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
}

/* Ombre morbide e discrete */
header, #header-credits-box, #info-sidebar, .search-dropdown, #photo-wall-modal {
  box-shadow: 0 2px 8px var(--c-ombra);
}

/* --- 2. HEADER E MENU DROP-DOWN --- */
header {
  position: absolute; z-index: 3001; top: 40px; left: 50%;
  transform: translateX(-50%); text-align: center;
  color: var(--c-testo); background: var(--c-sfondo); 
  border-radius: 15px; padding: 25px 40px;                
  transition: opacity 0.3s ease, visibility 0.3s ease, border-radius 0.3s ease, width 0.3s ease;
  width: auto; min-width: 320px;
  box-sizing: border-box;
}

header.is-expanded { border-radius: 15px 15px 0 0; }

.header-top {
  display: flex; justify-content: center; align-items: center; position: relative; min-height: 50px;
}

header h1 { margin: 0; display: flex; align-items: center; justify-content: center; }

.main-logo {
  height: 55px; width: auto; display: block; margin-bottom: 10px;
  image-rendering: -webkit-optimize-contrast; 
  transition: transform 0.3s ease, filter 0.3s ease;
  filter: drop-shadow(0 4px 8px rgba(230, 184, 64, 0.4)); 
}

.main-logo:hover { 
  transform: scale(1.02); 
  filter: drop-shadow(0 0 12px rgba(230, 184, 64, 0.7)); 
}

header h2 { 
  font-family: 'Playfair Display', serif; 
  font-size: 1.0em; font-weight: 700; color: #e6b840; 
  letter-spacing: 0.5px; margin-top: 5px; margin-bottom: 5px; 
  text-shadow: 0 2px 8px rgba(230, 184, 64, 0.3);
}

header p.header-subtitle { 
  margin: 0; width: 100%; font-size: 0.8em; font-weight: 400; 
  color: var(--c-testo); opacity: 0.75; line-height: 1.4; display: block;
}

/* REGOLE BOTTONI ICONE HEADER (MENU E RICERCA) */
.header-icon-button {
  position: absolute; background: none; border: none;
  color: var(--c-testo); font-size: 1.4em; cursor: pointer; padding: 10px;
  transition: transform 0.3s ease, color 0.3s ease, opacity 0.3s ease; 
  z-index: 10; pointer-events: auto;
  -webkit-tap-highlight-color: transparent !important;
}
.header-icon-button.left-icon { left: -10px; }
.header-icon-button.right-icon { right: -10px; }
.header-icon-button.hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }

header.is-expanded #menu-btn { transform: rotate(90deg); color: var(--c-accento-dark); }

/* --- AREA DINAMICA RICERCA E SOTTOTITOLO --- */
/* --- PILLOLA DELLA VERSIONE --- */
.header-version-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.05); 
  border: 1px solid var(--c-separatore);
  border-radius: 999px; 
  font-size: 0.65em; 
  font-weight: 700;
  color: var(--c-testo);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.4;
  user-select: none;
  pointer-events: auto; /* Attivato per renderlo cliccabile */
  cursor: pointer; /* Cursore a manina */
  transition: all 0.3s ease;
}

.header-version-pill:hover {
  opacity: 1;
  background: rgba(var(--c-accento-rgb), 0.15);
  border-color: var(--c-accento-dark);
}

body.dark-mode .header-version-pill {
  background: rgba(255, 255, 255, 0.05);
}

#header-dynamic-area {
  position: relative; margin-top: 0; margin-bottom: 0; 
  min-height: 0; display: flex; flex-direction: column; 
  align-items: center; width: 100%;
}

#search-container {
  position: relative; top: 0; width: 100%; max-width: 300px; 
  max-height: 0; margin-top: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.3s ease, margin-top 0.3s ease, opacity 0.3s ease; z-index: 20; 
}
#search-container.active {
  opacity: 1; max-height: 60px; margin-top: 15px; overflow: visible;
}

#search-input {
  width: 100%; padding: 6px 15px; border-radius: 20px; 
  border: 1px solid rgba(255,255,255,0.4); background: var(--c-sfondo-sidebar); 
  color: var(--c-testo); outline: none; font-family: inherit; font-size: 0.9em; 
  box-shadow: inset 0 2px 5px var(--c-ombra); box-sizing: border-box; transition: all 0.3s ease;
}
#search-input:focus { border-color: var(--c-accento-dark); box-shadow: 0 0 0 2px rgba(var(--c-accento-rgb), 0.3); }

/* DROPDOWN RISULTATI RICERCA */
.search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--c-sfondo-sidebar); border-radius: 12px; margin-top: 8px;
  max-height: 40vh; overflow-y: auto; text-align: left; opacity: 0; 
  visibility: hidden; transition: opacity 0.2s ease;
}
.search-dropdown.show { opacity: 1; visibility: visible; }
.search-result-item { padding: 10px 15px; cursor: pointer; border-bottom: 1px solid var(--c-separatore); display: flex; flex-direction: column; }
.search-result-name { font-weight: 800; font-size: 1.02em; color: var(--c-testo); line-height: 1.2; }
.search-result-subtitle { font-size: 0.85em; opacity: 0.85; color: var(--c-testo); margin-top: 2px; }
.search-result-tags { font-size: 0.7em; opacity: 0.5; color: var(--c-testo); margin-top: 4px; font-style: italic; }

/* --- TENDINA MENU IN VETRO --- */
#header-dropdown {
  max-height: 0; overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0 -40px; 
}
header.is-expanded #header-dropdown { max-height: 600px; margin-top: 0; border-top: none; }

.dropdown-content { 
  margin-top: 15px; border-top: 1px solid var(--c-separatore);
  padding: 10px 0; display: flex; flex-direction: column; 
}
.menu-item { display: flex; align-items: center; padding: 12px 25px; cursor: pointer; transition: background 0.2s ease; text-align: left; gap: 15px; }
.menu-item:hover { background: rgba(var(--c-accento-rgb), 0.1); }
.menu-item:active { background: rgba(var(--c-accento-rgb), 0.2); }
.menu-item i { width: 20px; color: var(--c-accento-dark); font-size: 1.2em; text-align: center; }
.menu-item span { font-size: 1em; font-weight: 600; color: var(--c-testo); }

/* --- SOTTOMENU FILTRI E TOGGLE SWITCH --- */
.submenu-content {
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s ease-in-out, margin 0.3s ease-in-out;
  background: rgba(0,0,0,0.03); border-radius: 8px; margin: 0 15px;
}
body.dark-mode .submenu-content { background: rgba(255,255,255,0.05); }
.submenu-content.open { max-height: 350px; margin-bottom: 10px; }

.filter-item { display: flex; align-items: center; padding: 10px 15px; gap: 12px; }
.filter-item span { font-size: 0.9em; color: var(--c-testo); flex-grow: 1; text-align: left; font-weight: 600; }
.filter-icon-wrapper { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 0.7em; flex-shrink: 0; }

.toggle-switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--c-separatore); transition: .3s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: var(--c-testo); transition: .3s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 50%; }
input:checked + .slider { background-color: var(--c-accento-dark); }
input:checked + .slider:before { transform: translateX(16px); background-color: #fff; }

/* STILE TESTO TEMA DARK/LIGHT */
#theme-text-label { font-weight: 600; }

/* --- 3. BOX CREDITI RESPONSIVE --- */
#header-credits-box {
  box-sizing: border-box; 
  position: absolute; z-index: 3000; top: 50%; left: 50%;
  transform: translate(-50%, -50%); 
  width: 90vw; max-width: 500px; 
  max-height: 85vh; max-height: 85dvh; 
  background: var(--c-sfondo); border-radius: 20px; padding: 30px; 
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; visibility: hidden; transition: all 0.4s ease;
}

body.credits-active header { opacity: 0; visibility: hidden; pointer-events: none; }
body.tour-open #main-header { opacity: 0; visibility: hidden; pointer-events: none; }
body.credits-active #header-credits-box { opacity: 1; visibility: visible; pointer-events: auto; }

.credits-box-content { overflow-y: auto; padding-right: 10px; padding-bottom: 20px; text-align: left; overscroll-behavior: contain; }
.credits-box-content::-webkit-scrollbar { width: 5px; }
.credits-box-content::-webkit-scrollbar-thumb { background: var(--c-separatore); border-radius: 10px; }

.credits-logos { display: flex; justify-content: center; margin-bottom: 25px; border-bottom: 1px solid var(--c-separatore); padding-bottom: 20px; }
.credits-logos img { height: 70px; width: auto; max-width: 100%; object-fit: contain; filter: drop-shadow(0 4px 8px var(--c-ombra)); }
body.dark-mode .credits-logos img { filter: drop-shadow(0 2px 4px rgba(255,255,255,0.1)) brightness(1.1); }

.credits-title { font-family: 'Playfair Display', serif; font-size: 2em; font-weight: 700; margin: 0 0 15px 0; color: var(--c-testo); text-align: center; }
.credits-section { margin-bottom: 25px; border-bottom: 1px solid var(--c-separatore); padding-bottom: 15px; }
.credits-section h3 { font-size: 1.1em; color: var(--c-accento-dark); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px; }
.credits-section p { font-size: 0.95em; line-height: 1.6; opacity: 0.9; margin: 5px 0; color: var(--c-testo); }

.author-note { border-bottom: none !important; margin-top: 10px; padding: 20px !important; background: rgba(var(--c-accento-rgb), 0.08); border-radius: 15px; text-align: center; }
.author-note i { color: var(--c-accento-dark); font-size: 1.3em; margin-bottom: 10px; display: block; }
.author-note em { font-family: 'Playfair Display', serif; font-size: 1.05em; line-height: 1.5; color: var(--c-testo); font-style: italic; }

.author-claim { display: block; color: var(--c-testo); font-weight: 400; font-size: 1.05em; margin-bottom: 8px; transition: color 0.3s ease; }
.author-contact { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--c-separatore); }
.author-contact a { color: var(--c-accento-dark); text-decoration: none; font-weight: 700; font-size: 0.95em; display: inline-flex; align-items: center; gap: 10px; transition: transform 0.2s ease, opacity 0.2s ease; }
.author-contact a:hover { transform: scale(1.05); opacity: 0.8; }
.author-contact i { display: inline-block !important; margin-bottom: 0 !important; font-size: 1.2em !important; }

.map-ui-button {
  width: calc(40px * var(--ui-scale)); height: calc(40px * var(--ui-scale));
  border-radius: 999px; background: var(--c-sfondo); color: var(--c-testo); 
  font-size: calc(18px * var(--ui-scale)); cursor: pointer;
  box-shadow: 0 4px 10px var(--c-ombra); transition: all 0.3s;
  display: flex; align-items: center; justify-content: center;
  padding: 0; -webkit-tap-highlight-color: transparent !important;
}
.map-ui-button:hover { background: var(--c-sfondo-hover); color: var(--c-testo-hover); border-radius: 999px; }
.map-ui-button:active { box-shadow: inset 0 0 0 50px var(--c-accento-dark), 0 2px 4px var(--c-ombra); color: #fff; transform: scale(1); border-radius: 999px; }

#close-credits-btn { position: absolute; top: 15px; right: 15px; z-index: 1002; --ui-scale: 0.85; }

/* ACCORDION CREDITI */
.credits-accordion summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; list-style: none; }
.credits-accordion summary::-webkit-details-marker { display: none; }
.credits-accordion summary h3 { margin-bottom: 0; }
.credits-accordion i { color: var(--c-accento-dark); transition: transform 0.3s ease; font-size: 0.9em; }
.credits-accordion[open] i { transform: rotate(180deg); }
.credits-accordion p { margin-top: 15px; animation: fade-in-down 0.3s ease forwards; }

@keyframes fade-in-down { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* --- 4. MAPPA E POPUP LEAFLET --- */
#map { height: 100%; width: 100%; }
.leaflet-control-container .leaflet-top.leaflet-left { position: absolute !important; top: auto !important; bottom: 86px !important; left: auto !important; right: 15px !important; }
.leaflet-control-container .leaflet-bottom.leaflet-right { bottom: 5px !important; right: 5px !important; }

.leaflet-control-zoom { 
  margin: 0 !important; 
  border-radius: 999px !important; 
  box-shadow: 0 4px 10px var(--c-ombra) !important; 
  overflow: hidden; 
  background: var(--c-sfondo); 
  outline: none !important; 
  border: none !important; /* AGGIUNTO: Rimuove il bordino chiaro del vetro */
  -webkit-tap-highlight-color: transparent !important; 
}
.leaflet-control-zoom a { background-color: transparent !important; color: var(--c-testo) !important; border: none !important; box-shadow: none !important; width: calc(40px * var(--ui-scale)) !important; height: calc(40px * var(--ui-scale)) !important; line-height: calc(40px * var(--ui-scale)) !important; font-size: calc(22px * var(--ui-scale)) !important; font-weight: bold !important; outline: none !important; text-decoration: none !important; -webkit-tap-highlight-color: transparent !important; appearance: none !important; }
.leaflet-control-zoom a:focus, .leaflet-control-zoom a:active { outline: 2px solid var(--c-sfondo) !important; outline-offset: -2px !important; }
body.dark-mode .leaflet-control-zoom a:focus { outline: 2px solid rgba(25, 25, 25, 0.8) !important; }
.leaflet-control-zoom-in { border-radius: 999px 999px 0 0 !important; border-bottom: 1px solid var(--c-separatore) !important; }
.leaflet-control-zoom-out { border-radius: 0 0 999px 999px !important; }
.leaflet-control-zoom-in:hover, .leaflet-control-zoom-out:hover { background-color: var(--c-sfondo-hover) !important; color: var(--c-testo-hover) !important; }
.leaflet-control-zoom-in:active, .leaflet-control-zoom-out:active { background-color: var(--c-sfondo-active) !important; }

.leaflet-popup-content-wrapper { border-radius: 12px; background: var(--c-sfondo); }
.leaflet-popup-tip { background: var(--c-popup-tip); box-shadow: 0 4px 15px var(--c-ombra); }
.leaflet-popup-content { text-align: center; }
.leaflet-popup-content b { font-size: 1.2em; font-weight: 700; color: var(--c-testo); }
.leaflet-popup-content small { font-size: 0.9em; color: var(--c-testo); opacity: 0.8; }

.popup-category-badge { display: inline-block; margin: 10px auto 5px auto; padding: 6px 15px; border-radius: 999px; background: rgba(0,0,0,0.1); color: var(--c-testo); font-weight: bold; font-size: 0.85em; border: 1px solid var(--c-separatore); }
.leaflet-popup-content button { margin-top: 5px; padding: 6px 15px; border: 1px solid var(--c-accento-dark); border-radius: 999px; background: var(--c-accento-dark); color: #fff; font-weight: bold; font-size: 0.85em; cursor: pointer; transition: all 0.2s ease; box-shadow: none; display: inline-block; }
.leaflet-popup-content button:hover { background: rgba(var(--c-accento-rgb), 0.15); color: var(--c-accento-dark); }
.leaflet-popup-content button:active { transform: scale(0.96); background: rgba(var(--c-accento-rgb), 0.25); }

/* --- 5. GESTIONE TOUR MODAL E PANNELLUM --- */
#tour-modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100%; background: #000; z-index: 2000; display: none; overflow: hidden; opacity: 1; transition: opacity var(--transition-speed) ease-in-out; }
#tour-modal.fade-out { opacity: 0; pointer-events: none; }
#tour-modal:fullscreen, #tour-modal:-webkit-full-screen, #tour-modal:-moz-full-screen { height: 100vh !important; }

#pannellum-wrapper { width: 100%; height: 100%; }
.pnlm-panorama-info { background: none !important; border-radius: 0 !important; padding: 0 !important; box-shadow: none !important; top: 10px !important; left: 10px !important; bottom: auto !important; display: inline-block !important; }
.pnlm-title-box { color: var(--c-testo-etichetta) !important; text-shadow: 0 1px 3px var(--c-ombra-etichetta) !important; padding-left: 0 !important; font-weight: 700 !important; font-size: 1.1em !important; }
.pnlm-controls-container { position: absolute !important; top: auto !important; left: auto !important; bottom: 86px !important; right: 15px !important; z-index: 2010 !important; }
.pnlm-controls-container .pnlm-controls { border-radius: 999px !important; box-shadow: 0 4px 10px var(--c-ombra) !important; background: var(--c-sfondo) !important; }
.pnlm-controls-container .pnlm-zoom-in { border-radius: 999px 999px 0 0 !important; border-bottom: 1px solid var(--c-separatore) !important; }
.pnlm-controls-container .pnlm-zoom-out { border-radius: 0 0 999px 999px !important; }
.pnlm-orientation-button { border-radius: 999px !important; background-color: var(--c-sfondo) !important; box-shadow: 0 4px 10px var(--c-ombra) !important; margin-top: calc(12px * var(--ui-scale)) !important; position: relative; overflow: hidden; }
.pnlm-controls-container .pnlm-zoom-controls { width: calc(40px * var(--ui-scale)); height: calc(80px * var(--ui-scale)); }
.pnlm-orientation-button { width: calc(40px * var(--ui-scale)) !important; height: calc(40px * var(--ui-scale)) !important; }
.pnlm-controls-container .pnlm-zoom-in, .pnlm-controls-container .pnlm-zoom-out { background-image: none !important; font-size: calc(22px * var(--ui-scale)) !important; font-weight: bold !important; line-height: calc(40px * var(--ui-scale)) !important; text-align: center !important; color: var(--c-testo) !important; }
.pnlm-controls-container .pnlm-zoom-in:hover { color: var(--c-testo-hover) !important; background-color: var(--c-sfondo-hover) !important; border-radius: 999px 999px 0 0 !important; }
.pnlm-controls-container .pnlm-zoom-out:hover { color: var(--c-testo-hover) !important; background-color: var(--c-sfondo-hover) !important; border-radius: 0 0 999px 999px !important; }
.pnlm-controls-container .pnlm-zoom-in:active { background-color: var(--c-sfondo-active) !important; }
.pnlm-controls-container .pnlm-zoom-out:active { background-color: var(--c-sfondo-active) !important; }
.pnlm-controls-container .pnlm-zoom-in::before { content: '+'; }
.pnlm-controls-container .pnlm-zoom-out::before { content: '−'; }

.pnlm-orientation-button { background-image: none !important; background-repeat: no-repeat !important; background-size: auto !important; color: var(--c-testo) !important; font-size: calc(20px * var(--ui-scale)) !important; display: flex !important; align-items: center; justify-content: center; }
.pnlm-orientation-button:hover { background-color: var(--c-sfondo-hover) !important; border-radius: 999px !important; }
.pnlm-orientation-button:active { background-color: var(--c-sfondo-active) !important; transform: scale(1); }
body.dark-mode .pnlm-orientation-button { filter: none !important; }
.pnlm-orientation-button::before { font-family: "Font Awesome 6 Free"; position: relative; z-index: 2; }
.pnlm-orientation-button-inactive::before { font-weight: 400; content: "\f14e"; }
.pnlm-orientation-button-active::before { font-weight: 900; content: "\f14e"; color: #fff !important; }
.pnlm-orientation-button::after { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--c-accento-dark); opacity: 0; transition: opacity 0.3s ease; pointer-events: none; z-index: 1; }
.pnlm-orientation-button-active::after { opacity: 1; }
.pnlm-fullscreen-toggle-button { display: none !important; }

/* --- 6. SIDEBAR IN VETRO E BOTTONI TOUR --- */
#info-sidebar { 
  position: absolute; top: 0; right: 0; width: 30%; height: 100%; 
  background: var(--c-sfondo-sidebar); 
  padding: 25px 0 25px 25px; 
  overflow: hidden; display: flex; flex-direction: column; 
  box-sizing: border-box; transform: translateX(100%); transition: transform 0.5s ease-in-out, width 0.5s ease-in-out; color: var(--c-testo); z-index: 3000 !important; 
}

#sidebar-scrollable-content { flex-grow: 1; overflow-y: auto; padding-right: 25px; transition: opacity 0.8s ease-in-out; opacity: 1; }
#sidebar-scrollable-content::-webkit-scrollbar { width: 5px; }
#sidebar-scrollable-content::-webkit-scrollbar-thumb { background: var(--c-separatore); border-radius: 10px; }

#tour-modal.sidebar-open #info-sidebar { transform: translateX(0); }
#info-sidebar #overlay-title { padding-right: 40px; } 
#info-sidebar #overlay-title h1 { font-family: 'Playfair Display', serif; font-size: 1.8em; font-weight: 700; margin: 0 0 15px 0; line-height: 1.2; color: var(--c-testo); }
#info-sidebar #overlay-subtitle h2 { font-size: 1.1em; font-weight: 700; margin: -5px 0 15px 0; line-height: 1.3; color: var(--c-testo); opacity: 0.9; }
#info-sidebar .thumbs { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 10px; margin-bottom: 20px; }
#info-sidebar .thumbs img { width: 100px; height: 70px; object-fit: cover; margin: 5px; cursor: pointer; border-radius: 5px; transition: transform 0.3s; }
#info-sidebar .thumbs img:hover { transform: scale(1.05); }
#info-sidebar #overlay-desc { margin-top: 0; line-height: 1.6; }
#info-sidebar #overlay-desc h2 { font-size: 1.1em; font-weight: 700; margin: 20px 0 10px 0; line-height: 1.3; color: var(--c-testo); }

#close-sidebar-btn { position: absolute; top: 15px; right: 15px; width: 36px; height: 36px; border: 1px solid var(--c-accento-dark); border-radius: 50%; background: var(--c-accento-dark); color: #fff; font-size: 16px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s ease; }
#close-sidebar-btn:hover { background: rgba(var(--c-accento-rgb), 0.15); color: var(--c-accento-dark); }
#close-sidebar-btn:active { transform: scale(0.90); background: rgba(var(--c-accento-rgb), 0.25); }

/* Bottoni UI */
#info-btn, #photo-wall-btn, #audio-btn, #video-btn, #fullscreen-btn { 
  width: calc(40px * var(--ui-scale)); 
  height: calc(40px * var(--ui-scale)); 
  border-radius: 999px; background: var(--c-sfondo); color: var(--c-testo); 
  font-size: calc(18px * var(--ui-scale)); cursor: pointer; 
  box-shadow: 0 4px 10px var(--c-ombra); 
  transition: right 0.5s ease-in-out, background 0.3s, color 0.3s, box-shadow 0.3s, transform 0.3s; 
  display: flex; align-items: center; justify-content: center; padding: 0; 
  box-sizing: border-box !important; flex-shrink: 0; 
}

#info-btn:hover, #photo-wall-btn:hover, #audio-btn:hover, #video-btn:hover, #fullscreen-btn:hover { background: var(--c-sfondo-hover); color: var(--c-testo-hover); }
#info-btn:active, #photo-wall-btn:active, #audio-btn:active, #video-btn:active, #fullscreen-btn:active { box-shadow: inset 0 0 0 50px var(--c-accento-dark), 0 2px 4px var(--c-ombra); color: #fff; transform: scale(1); }

#tour-ui-container { position: absolute; top: 15px; right: 15px; z-index: 2010; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* Nuovo Ordine Pulsantiera[cite: 5] */
#info-btn { order: 1; }
#photo-wall-btn { order: 2; }
#video-btn { order: 3; }
#audio-btn { order: 4; }

/* FIX FULLSCREEN: Z-index elevato per visibilità su mappa Leaflet[cite: 5, 7] */
#fullscreen-btn { 
  position: absolute; top: auto !important; left: auto !important; 
  bottom: 30px !important; right: 15px !important; 
  z-index: 3000; /* Sopra lo strato mappa[cite: 5] */
}

/* Stato attivo per i pulsanti durante il tour[cite: 5, 6] */
#tour-modal.sidebar-open #info-btn,
body.photo-wall-active #photo-wall-btn,
#audio-btn.playing { 
  box-shadow: inset 0 0 0 50px var(--c-accento-dark), 0 2px 4px var(--c-ombra); 
  color: #fff; 
}

/* Logica Fullscreen Dinamica e Z-index durante il tour[cite: 5, 6] */
body.tour-open #fullscreen-btn { z-index: 2010; } /* Sopra il tour-modal[cite: 5] */

body.in-fullscreen-mode:not(.tour-open) #fullscreen-btn { box-shadow: inset 0 0 0 50px #e6b840, 0 2px 4px var(--c-ombra); color: #fff; }
body.in-fullscreen-mode.tour-open #fullscreen-btn { box-shadow: inset 0 0 0 50px var(--c-accento-dark), 0 2px 4px var(--c-ombra); color: #fff; }

/* --- STILE BOTOONE MINIMAPPA A PILLOLA ORIZZONTALE --- */
#close-modal-btn { 
  position: absolute; 
  z-index: 2010; 
  top: auto !important; 
  right: auto !important; 
  bottom: 30px; 
  left: 15px; 
  width: auto; /* La larghezza si adatterà in base al testo e all'icona */
  height: calc(40px * var(--ui-scale)); /* Esattamente la stessa altezza dei bottoni di destra */
  padding: 0 calc(20px * var(--ui-scale)); /* Padding orizzontale per creare la forma a pillola */
  border-radius: 999px; /* Curvatura massima per la pillola */
  background: var(--c-sfondo); 
  color: var(--c-testo); 
  cursor: pointer; 
  box-shadow: 0 4px 10px var(--c-ombra); /* Ombra allineata a quella degli altri bottoni */
  transition: all 0.3s ease; 
  display: flex; 
  flex-direction: row; /* Disposizione in orizzontale */
  align-items: center; 
  justify-content: center; 
  overflow: hidden; 
}

#close-modal-btn:hover { 
  transform: scale(1.03); 
  background: var(--c-sfondo-hover); 
}

#close-modal-btn:active { 
  transform: scale(0.96); 
  box-shadow: 0 2px 8px var(--c-ombra); 
}

/* La griglia di sfondo (opzionale, manterrà l'effetto mappa) */
#close-modal-btn .minimap-bg { 
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; 
  opacity: 0.15; 
  background-image: linear-gradient(rgba(0,0,0,0.8) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,0.8) 1px, transparent 1px); 
  background-size: 15px 15px; z-index: 1; pointer-events: none; 
}

body.dark-mode #close-modal-btn .minimap-bg { 
  opacity: 0.1; 
  background-image: linear-gradient(rgba(255,255,255,0.8) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.8) 1px, transparent 1px); 
}

#close-modal-btn i { 
  position: relative; 
  z-index: 2; 
  font-size: calc(18px * var(--ui-scale)); /* Ridimensionata per stare nella pillola */
  color: var(--c-accento-dark); 
  margin-bottom: 0; /* Rimuoviamo il margine sotto... */
  margin-right: calc(8px * var(--ui-scale)); /* ...e lo mettiamo a destra verso il testo */
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); 
}

#close-modal-btn .minimap-text { 
  position: relative; 
  z-index: 2; 
  font-size: calc(12px * var(--ui-scale)); 
  font-weight: 700; 
  text-transform: uppercase; 
  letter-spacing: 0.5px; 
  line-height: 1; /* Previene disallineamenti verticali col font */
}

/* --- SEZIONE PHOTO WALL [Flex Masonry 4 Colonne - Itinera 360] --- */
#photo-wall-modal {
  box-sizing: border-box; 
  position: absolute; 
  z-index: 4000 !important; /* Blindatura sopra ogni elemento UI[cite: 4] */
  top: 0; 
  left: 0;
  width: 100vw; 
  height: 100vh; 
  height: 100dvh; 
  background: var(--c-sfondo) !important; 
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-radius: 0; 
  padding: 80px 20px 40px 20px; 
  display: flex !important; 
  flex-direction: column; 
  align-items: center; 
  overflow: hidden;
  
  /* Transizioni morbide per l'apertura con effetto scala[cite: 4] */
  opacity: 0; 
  visibility: hidden; 
  transform: scale(1.05); 
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), 
              visibility 0.5s, 
              transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

body.photo-wall-active #photo-wall-modal {
    opacity: 1 !important;
    visibility: visible !important;
    transform: scale(1);
}

/* --- STILE PULSANTE CHIUSURA (Coerente con Sidebar) --- */
#close-photo-wall-btn { 
    position: absolute; 
    top: 15px; 
    right: 15px; 
    width: 36px; 
    height: 36px; 
    border: 1px solid var(--c-accento-dark); 
    border-radius: 50%; 
    background: var(--c-accento-dark); 
    color: #fff; 
    font-size: 16px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    transition: all 0.2s ease; 
    z-index: 4010; 
}

#close-photo-wall-btn:hover { 
    background: rgba(var(--c-accento-rgb), 0.15); 
    color: var(--c-accento-dark); 
}

#close-photo-wall-btn:active { 
    transform: scale(0.90); 
    background: rgba(var(--c-accento-rgb), 0.25); 
}

/* --- SEZIONE PHOTO WALL: INTESTAZIONE --- */

/* Regola strutturale per allineare millimetricamente testi e foto */
#photo-wall-title,
#photo-wall-subtitle {
    width: 100%;
    max-width: 1300px; /* Stessa larghezza massima della griglia */
    margin-left: auto; /* Centratura rispetto allo schermo */
    margin-right: auto;
    text-align: left;
    display: block;
    flex-shrink: 0;
}

/* Titolo principale della galleria */
#photo-wall-title {
  font-family: 'Playfair Display', serif;
  font-size: 2.7em; /* RIPRISTINATO E POTENZIATO: Era 2.2em nelle ultime modifiche */
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 5px; 
  position: relative;
  line-height: 1.1; /* Migliora la leggibilità su titoli lunghi */
}

/* Sottotitolo della scena (es. "Chiesa di Santa Maria") */
#photo-wall-subtitle {
    font-family: 'Playfair Display', serif;
    font-size: 1.4em;
    font-weight: 600;
    font-style: italic;
    margin-top: 0;
    margin-bottom: 45px; /* AUMENTATO: dà molto più respiro tra testo e foto (era 25px) */
    color: var(--c-testo);
    opacity: 0.85;
    line-height: 1.2;
}

/* --- FIX INTESTAZIONE STICKY PHOTO WALL --- */

/* 1. Il contenitore generale occupa lo spazio ma NON scrolla */
#photo-wall-modal .credits-box-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  width: 100%;
  overflow: hidden !important; /* Blocca lo scroll globale */
  padding-bottom: 0 !important; 
}

/* 2. Titolo e sottotitolo restano fissi in alto (non si schiacciano) */
/* Sottotitolo della scena (es. "Chiesa di Santa Maria") */
#photo-wall-subtitle {
  font-family: 'Playfair Display', serif;
  font-size: 1.4em;
  font-weight: 600;
  font-style: italic;
  margin-top: 0;
  margin-bottom: 0; /* AZZERATO: Il respiro viene dato dal padding della griglia */
  color: var(--c-testo);
  opacity: 0.85;
  line-height: 1.2;
}

/* Griglia Flexbox per riempire correttamente le colonne */
.photo-grid-container {
  display: flex;
  flex-wrap: wrap; 
  gap: 20px;
  width: 100%;
  max-width: 1300px; 
  margin: 0 auto;
  
  /* TRUCCO 1: 40px di padding in alto garantiscono SEMPRE spazio, che ci sia o no il sottotitolo */
  padding: 40px 10px 40px 0; 
  
  justify-content: flex-start; 
  flex-grow: 1; 
  overflow-y: auto; 
  align-content: flex-start; 
  
  /* TRUCCO 2: Maschera per sfumare in trasparenza le foto quando scorrono verso l'alto */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0px, black 40px);
  mask-image: linear-gradient(to bottom, transparent 0px, black 40px);
}

/* 4. Assegniamo la scrollbar dorata direttamente alla griglia */
.photo-grid-container::-webkit-scrollbar {
  width: 6px;
}
.photo-grid-container::-webkit-scrollbar-thumb {
  background: var(--c-accento-dark);
  border-radius: 10px;
}

/* Desktop: 4 Colonne precise[cite: 4] */
.photo-grid-container a {
    display: block;
    flex: 1 1 calc(25% - 20px); 
    max-width: calc(25% - 20px);
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    background: rgba(0,0,0,0.05);
}

.photo-grid-container a img {
    width: 100%;
    height: 200px; 
    object-fit: cover; 
    display: block;
    transition: transform 0.6s ease;
}

/* Effetti Hover coordinati[cite: 4] */
.photo-grid-container a:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(var(--c-accento-rgb), 0.3);
}

.photo-grid-container a:hover img {
    transform: scale(1.1);
}

/* --- RESPONSIVE SCALARE --- */
@media (max-width: 1200px) {
    .photo-grid-container a { 
        flex: 1 1 calc(33.333% - 20px); 
        max-width: calc(33.333% - 20px); 
    }
}

@media (max-width: 900px) {
    .photo-grid-container a { 
        flex: 1 1 calc(50% - 20px); 
        max-width: calc(50% - 20px); 
    }
}

/* Smartphone: Disposizione a 2 colonne e fix distanziamento titolo[cite: 4, 7] */
@media (max-width: 600px) {
    #photo-wall-modal { 
        padding: 70px 10px 20px 10px; 
    }
    
    body.in-fullscreen-mode #close-photo-wall-btn { 
        top: 55px; 
    }
    
    /* Spingiamo in basso il titolo e gli diamo più importanza su mobile */
    #photo-wall-title {
        font-size: 2em; /* Alzato a 2em */
        margin-top: 30px; 
        margin-bottom: 25px;
        padding: 0 10px; 
        line-height: 1.2; 
    }
    
    .photo-grid-container {
        gap: 10px; 
    }

    .photo-grid-container a { 
        flex: 1 1 calc(50% - 10px); 
        max-width: calc(50% - 10px); 
        min-width: 0; 
    }
    
    .photo-grid-container a img {
        height: 120px; 
    }
}

/* Feedback pulsante attivo nella pulsantiera[cite: 4] */
body.photo-wall-active #photo-wall-btn {
    box-shadow: inset 0 0 0 50px var(--c-accento-dark), 0 2px 4px var(--c-ombra);
    color: #fff;
}

/* --- FIX FINALE PHOTO WALL MOBILE (SINISTRA) --- */
@media screen and (max-width: 768px) {
    
    /* Impedisce lo scroll orizzontale del modale */
    .credits-box-content {
        text-align: left !important;
        padding: 20px !important;
        width: 100% !important;
        box-sizing: border-box !important; /* CRUCIALE: il padding non gonfia la larghezza */
        overflow-x: hidden !important;
    }

    /* Allineamento millimetrico dei testi */
    #photo-wall-title, 
    #photo-wall-subtitle {
        text-align: left !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        display: block !important;
        width: auto !important; /* Evita forzature di larghezza */
    }

    #photo-wall-title {
        font-size: 1.8rem !important;
        margin-top: 0 !important;
        margin-bottom: 5px !important;
    }

    #photo-wall-subtitle {
      font-size: 1.25rem !important;
      margin-top: 0 !important;
      margin-bottom: 0 !important; /* AZZERATO anche su mobile */
      line-height: 1.2 !important;
    }
}

/* STILI LIGHTBOX */
.lb-nav a.lb-prev, .lb-nav a.lb-next, .lb-dataContainer .lb-close { background-image: none !important; }
.lb-nav a.lb-prev::before, .lb-nav a.lb-next::before, .lb-dataContainer .lb-close::before { font-family: "Font Awesome 6 Free"; font-weight: 900; display: flex; align-items: center; justify-content: center; color: #fff; opacity: 0.7; transition: opacity 0.3s ease, transform 0.2s ease; }
.lb-nav a.lb-prev::before { content: "\f053"; font-size: 36px; padding-left: 20px; }
.lb-nav a.lb-next::before { content: "\f054"; font-size: 36px; padding-right: 20px; }
.lb-nav a.lb-prev, .lb-nav a.lb-next { display: flex !important; align-items: center; height: 100%; }
.lb-nav a.lb-prev { justify-content: flex-start; }
.lb-nav a.lb-next { justify-content: flex-end; }
.lb-dataContainer .lb-close { display: block; float: right; width: 40px; height: 40px; text-align: center; outline: none; position: fixed !important; top: 20px !important; right: 20px !important; z-index: 9999 !important; background: rgba(0,0,0,0.5) !important; border-radius: 50%; }
.lb-dataContainer .lb-close::before { content: "\f00d"; font-size: 24px; line-height: 40px; width: 100%; height: 100%; }
.lb-nav a.lb-prev:hover::before, .lb-nav a.lb-next:hover::before, .lb-dataContainer .lb-close:hover::before { opacity: 1; transform: scale(1.1); }
.lb-dataContainer { height: auto; padding-bottom: 20px; }

/* --- 7. RESPONSIVE MOBILE --- */
body.is-iphone #fullscreen-btn { display: none !important; }
body.is-iphone .pnlm-controls-container { bottom: 30px !important; }

@media (max-width: 768px) {
  header { top: 20px; padding: 20px; width: 85vw; }
  .main-logo { height: 42px; }
  #header-dropdown { margin: 0 -20px; }
  
  #search-input { font-size: 16px; }
  #header-credits-box { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; border-radius: 0; border: none; top: 0; left: 0; transform: none; padding: 70px 25px 25px 25px; }
  #close-credits-btn { top: 15px; right: 15px; }
  .credits-box-content { padding-bottom: 30px; padding-right: 5px; }
  
  #info-sidebar { width: 100%; border-left: none; } 
  #tour-modal.sidebar-open #info-sidebar { transform: translateX(0); }
  
  #tour-modal.sidebar-open #tour-ui-container,
  #tour-modal.sidebar-open #fullscreen-btn { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; transition: opacity 0.2s ease 0.4s, visibility 0s ease 0.6s !important; }
  
  .lb-nav a.lb-prev, .lb-nav a.lb-next { width: 40% !important; } 
  .lb-dataContainer .lb-close { top: 10px !important; right: 10px !important; }
  .lightbox { top: 50% !important; transform: translateY(-50%) !important; }
  #photo-wall-modal { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
  .photo-grid-container { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
} 

/* --- 8. HOTSPOT ICONICI E MARKER (NO GLASS PER MARKER) --- */
.leaflet-marker-icon {
  -webkit-backdrop-filter: none; backdrop-filter: none;
  opacity: 1; border: none; filter: none;
}

.pnlm-hotspot.pnlm-info { background: none !important; border: none !important; width: auto !important; height: auto !important; }
.pnlm-hotspot.pnlm-info span { display: none; }
.pnlm-custom-scene-hotspot.icon-only-hotspot { position: relative; overflow: visible !important; background: var(--c-sfondo); color: var(--c-testo); border-radius: 50%; width: calc(40px * var(--ui-scale)); height: calc(40px * var(--ui-scale)); padding: 0; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px var(--c-ombra); cursor: pointer; animation: pulse-shadow 2s infinite alternate ease-in-out; }
.pnlm-custom-scene-hotspot.icon-only-hotspot i { margin: 0; font-size: calc(18px * var(--ui-scale)); transition: color 0.3s; }
.pnlm-custom-scene-hotspot.icon-only-hotspot:hover { background: var(--c-sfondo-hover); color: var(--c-testo-hover); }
.pnlm-custom-scene-hotspot.icon-only-hotspot:active { box-shadow: inset 0 0 0 50px var(--c-accento-dark), 0 2px 4px var(--c-ombra); color: #fff; transform: scale(1); animation: none; }
.pnlm-custom-scene-hotspot.icon-only-hotspot:active i { color: #fff; }

@keyframes pulse-shadow { from { box-shadow: inset 0 0 0 0 var(--c-accento-dark), 0 2px 4px var(--c-ombra); color: var(--c-testo); } to { box-shadow: inset 0 0 0 50px var(--c-accento-dark), 0 2px 4px var(--c-ombra); color: #fff; } }

.pnlm-custom-scene-hotspot.icon-only-hotspot::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(10px); background: var(--c-sfondo); color: var(--c-testo); border: 1px solid rgba(255,255,255,0.2); padding: calc(4px * var(--ui-scale)) calc(10px * var(--ui-scale)); border-radius: 6px; font-size: calc(14px * var(--ui-scale)); font-weight: 700; white-space: nowrap; box-shadow: 0 4px 15px var(--c-ombra-forte); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); -webkit-backdrop-filter: blur(12px) saturate(150%); backdrop-filter: blur(12px) saturate(150%); }
.pnlm-custom-scene-hotspot.icon-only-hotspot:hover::after { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* --- 9. ONBOARDING OVERLAY --- */
#onboarding-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.4); z-index: 3000; display: none; 
  align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: opacity 0.3s ease;
}

.onboarding-card { background: var(--c-sfondo); padding: 40px; border-radius: 20px; max-width: 500px; width: 90%; box-shadow: 0 15px 50px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2); text-align: center; color: var(--c-testo); box-sizing: border-box; }
.onboarding-main-icon { font-size: 3em; color: var(--c-accento-dark); margin-bottom: 20px; }
.onboarding-card h2 { font-family: 'Playfair Display', serif; margin-bottom: 25px; }
.onboarding-list { list-style: none; padding: 0; text-align: left; margin-bottom: 30px; }
.onboarding-list li { display: flex; gap: 15px; margin-bottom: 15px; align-items: flex-start; font-size: 0.95em; line-height: 1.4; }
.onboarding-list i { color: var(--c-accento-dark); width: 20px; text-align: center; margin-top: 3px; }
#close-onboarding-btn { background: var(--c-accento-dark); color: #fff; border: none; padding: 12px 30px; border-radius: 999px; font-weight: 700; cursor: pointer; transition: all 0.3s; }
#close-onboarding-btn:hover { transform: scale(1.05); filter: brightness(1.1); }
@media (max-width: 768px) { .onboarding-card { width: 85vw; padding: 30px 20px; } }

/* --- 10. VIDEO MODAL --- */
#video-modal { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); z-index: 3000; display: flex; align-items: center; justify-content: center; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); opacity: 0; transition: opacity 0.3s ease; }
.video-modal-content { position: relative; width: 90%; max-width: 900px; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; box-shadow: 0 15px 50px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2); }
#video-iframe-container { width: 100%; height: 100%; border-radius: 12px; overflow: hidden; }
#video-iframe-container iframe { width: 100%; height: 100%; border: none; }
#close-video-btn { position: absolute; top: -15px; right: -15px; width: 36px; height: 36px; border-radius: 50%; background: var(--c-accento-dark); color: #fff; border: 2px solid #fff; font-size: 16px; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; z-index: 3010; }
#close-video-btn:hover { transform: scale(1.1); }

/* --- 11. FIX NOTCH IN FULLSCREEN MOBILE --- */
@media (max-width: 768px) {
  body.in-fullscreen-mode header { top: 50px; }
  body.in-fullscreen-mode .pnlm-panorama-info { top: 50px !important; }
  body.in-fullscreen-mode #tour-ui-container { top: 55px; }
  body.in-fullscreen-mode #close-sidebar-btn, body.in-fullscreen-mode #close-credits-btn { top: 55px; }
  body.in-fullscreen-mode #info-sidebar #overlay-title { margin-top: 45px; }
}

/* --- 12. EASTER EGG & FIX COLORI --- */
.profile-pic-wrapper { position: relative; width: 130px; height: 130px; margin: 0 auto 15px auto; }
.author-profile-pic { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 50%; filter: drop-shadow(0 4px 10px var(--c-ombra)); transition: opacity 0.5s ease, visibility 0.5s ease; cursor: pointer; }
.secret-pic { opacity: 0; visibility: hidden; }
.profile-pic-wrapper.secret-active #author-profile-img { opacity: 0; visibility: hidden; }
.profile-pic-wrapper.secret-active .secret-pic { opacity: 1; visibility: visible; }

/* Forza il colore oro originale nei menu indipendentemente dal tour attivo */
header.is-expanded #menu-btn, .menu-item i, .credits-section h3, .credits-accordion i, .author-note i, .author-contact a { color: #e6b840 !important; }
input:checked + .slider { background-color: #e6b840 !important; }
body.dark-mode .logo-light { display: none !important; }
body:not(.dark-mode) .logo-dark { display: none !important; }

/* Easter Egg 2: Bottone invisibile sulla mappa */
.secret-map-trigger { cursor: default !important; background: transparent; border: none; }

#secret-pill { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 5000; padding: 12px 25px; background: var(--c-sfondo); color: var(--c-testo); border-radius: 999px; box-shadow: 0 10px 30px var(--c-ombra-forte); display: flex; align-items: center; gap: 12px; font-weight: 700; pointer-events: none; opacity: 0; transition: opacity 0.5s ease; }
#secret-pill.show { opacity: 1; }
#secret-pill i { color: var(--c-accento-dark); font-size: 1.2em; }

/* --- 13. TRANSIZIONI E PROGRESS BAR --- */

/* Assegniamo la transizione morbida solo agli elementi dinamici */
#sidebar-scene-meta, 
#overlay-desc-container { 
  transition: opacity 0.3s ease-out; 
  opacity: 1;
}

/* Progress bar della mappa (inalterata) */
.popup-progress-bar { 
  position: absolute; top: 0; left: 0; height: 100%; width: 0%; 
  opacity: 0.3; transition: width 0.4s ease-out; z-index: 1; 
}

/* --- 14. BOX NOTE TECNICHE (Technical Specs) --- */
#tech-notes-box {
  box-sizing: border-box; 
  position: absolute; z-index: 3000; top: 50%; left: 50%;
  transform: translate(-50%, -50%); 
  width: 90vw; max-width: 500px; 
  max-height: 85vh; max-height: 85dvh; 
  background: var(--c-sfondo); border-radius: 20px; padding: 30px; 
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; visibility: hidden; transition: all 0.4s ease;
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  box-shadow: 0 2px 8px var(--c-ombra);
}

body.tech-notes-active header { opacity: 0; visibility: hidden; pointer-events: none; }
body.tech-notes-active #tech-notes-box { opacity: 1; visibility: visible; pointer-events: auto; }

/* Nasconde il bottone fullscreen quando sono aperti i modal informativi (SOLO MOBILE) */
@media (max-width: 768px) {
    body.tech-notes-active #fullscreen-btn,
    body.credits-active #fullscreen-btn {
        opacity: 0 !important;
        pointer-events: none !important;
        visibility: hidden !important;
    }
}

@media (max-width: 768px) {
  #tech-notes-box { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; border-radius: 0; border: none; top: 0; left: 0; transform: none; padding: 70px 25px 25px 25px; }
}

/* --- 15. TIMELINE VERTICALE E COLORI NOTE TECNICHE --- */
.tech-timeline {
    position: relative;
    padding-left: 20px;
    margin-left: 10px;
    border-left: 2px solid var(--glass-border);
}

.timeline-node { position: relative; margin-bottom: 30px; }
.timeline-node:last-child { margin-bottom: 0; }

/* Barretta Luminosa */
.timeline-marker {
    position: absolute; left: -27px; top: 5px; width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--c-accento-dark);
    box-shadow: 0 0 10px var(--c-accento-dark);
}

.timeline-marker.inactive {
    background: var(--c-testo-dim);
    box-shadow: none;
}

/* Header della Versione */
.version-header { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.version-tag {
    background: rgba(var(--c-accento-rgb), 0.2);
    color: var(--c-accento-dark);
    padding: 2px 8px; border-radius: 4px; font-size: 0.8em; font-weight: bold;
}
.version-date { font-size: 0.75em; color: var(--c-testo-dim); text-transform: uppercase; letter-spacing: 1px; }

/* 1. TITOLI H3 (GOLDENROD) */
.credits-box-content h3,
.credits-section h3,
.timeline-content h3,
.version-title {
    color: var(--c-accento-dark);
    font-size: 1.2em;
    margin: 0 0 15px 0;
    transition: color 0.3s ease;
}

/* 2. SOTTOTITOLI H4 (DINAMICI DARK/LIGHT) */
.credits-box-content h4,
.credits-section h4,
.timeline-content h4 {
    color: var(--c-testo);
    font-size: 1.05em;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

/* 3. LISTE E PUNTI ELENCO */
.timeline-content ul { list-style-type: none; padding-left: 0; margin: 0 0 15px 0; }
.timeline-content ul li { font-size: 0.85em; color: var(--c-testo-dim); margin-bottom: 6px; position: relative; padding-left: 12px; }
.timeline-content ul li::before { content: "•"; color: var(--c-accento-dark); position: absolute; left: 0; }

/* --- 4. STILI PER LE MINOR RELEASES (PATCH NOTES) --- */
.minor-release-block {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed var(--c-testo-dim); /* La linea di separazione elegante */
}

.minor-release-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.minor-version-tag {
    background: transparent;
    color: var(--c-testo);
    border: 1px solid var(--c-testo-dim); /* Bordo sottile invece di sfondo pieno */
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: bold;
}

.minor-version-title {
    font-size: 0.9em;
    font-style: italic;
    color: var(--c-testo-dim);
}

/* --- UNIFORMITÀ COLORE ACCENTO (GOLDENROD DINAMICO) --- */

/* Applica l'oro a: Header H2, Titoli Box Progetto, Icone Menu e Titoli Note */
#main-header h2, 
.menu-item i, 
.credits-box-content h3, 
.credits-section h3,
.version-title {
    color: var(--c-accento-dark) !important;
    transition: color 0.3s ease;
}

/* Se vuoi che anche i pallini della timeline e i bullet point siano allineati */
.timeline-marker,
.timeline-content ul li::before {
    background-color: var(--c-accento-dark);
}

/* --- 16. STILI AGGIUNTIVI PER SIDEBAR SEMANTICA (Design Editoriale) --- */

/* 1. Titolo Principale e Intestazione Fissa */
#sidebar-header-fixed {
  padding-right: 40px; 
  margin-bottom: 20px;
}

#sidebar-header-fixed h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.3em; /* Aumentato per maggiore importanza gerarchica */
  font-weight: 700;
  margin: 0 0 10px 0;
  line-height: 1.15;
  color: var(--c-testo);
}

/* Sottotitolo Dinamico della Scena (es. "Cappella dei Duchi") */
#overlay-subtitle {
  font-family: 'Playfair Display', serif;
  font-size: 1.4em;
  font-weight: 600;
  font-style: italic;
  margin: -5px 0 12px 0; /* Lo avvicina all'H1 e lo distanzia dalla località */
  color: var(--c-testo);
  opacity: 0.85;
  line-height: 1.2;
}

/* Località e Accessibilità (Stile testo puro unificato) */
.sidebar-location, 
#sidebar-access-container {
  font-size: 0.95em;
  color: var(--c-testo);
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

/* Icone dinamiche colorate per Pin e Lucchetto */
.sidebar-location i, 
.access-badge i {
  color: var(--c-accento-dark);
  font-size: 1.1em;
  width: 16px;
  text-align: center;
}

/* Reset del Badge per renderlo testo libero e allineato */
.access-badge {
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  font-weight: 400 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  border: none !important;
  
  /* Aggiunte per l'allineamento millimetrico */
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
}

/* Divisore Orizzontale */
.sidebar-divider {
  border: none;
  border-top: 1px solid var(--c-separatore);
  margin: 20px 0;
  padding: 0;
}

/* 2. L'Occhiello (Metadati Dinamici Editoriali) */
#sidebar-scene-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 25px; /* Crea un elegante respiro tra le tre colonne */
  margin-bottom: 25px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 3px; /* Distanza tra etichetta e valore */
}

/* L'etichetta discreta superiore */
.meta-label {
  font-size: 0.65em;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  color: var(--c-testo);
  opacity: 0.5;
}

/* Il valore testuale inferiore */
.scene-meta-text {
  font-family: 'Open Sans', sans-serif;
  font-size: 0.85em;
  color: var(--c-accento-dark); /* Usiamo l'oro per far risaltare il dato! */
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 800;
}

/* Nascondiamo per sicurezza vecchi separatori se dovessero comparire */
.meta-separator { display: none !important; }

/* 3. Respiro e Leggibilità del Testo */
#overlay-desc {
  line-height: 1.85; /* Interlinea aumentata per non affaticare l'occhio */
  font-size: 0.98em;
  color: var(--c-testo);
}

#overlay-desc p {
  margin-bottom: 22px; /* Spazio netto tra i paragrafi */
}

/* 4. Il Capolettera Editoriale (Drop Cap) */
#overlay-desc > p:first-of-type::first-letter {
  font-family: 'Playfair Display', serif;
  font-size: 3.8em;
  color: var(--c-accento-dark);
  float: left;
  line-height: 0.8;
  margin-right: 10px;
  margin-top: 4px;
}

/* 5. Sfumatura di fine corsa (Fade-out inferiore) */

#info-sidebar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: linear-gradient(to bottom, transparent, var(--c-sfondo-sidebar));
  pointer-events: none; /* Permette i click e lo scroll attraverso la sfumatura */
  z-index: 10;
}

/* Aggiungiamo padding alla fine del contenuto scrollabile per evitare che l'ultima riga resti sotto la sfumatura */
#sidebar-scrollable-content {
  padding-bottom: 70px;
}

/* --- FOCUS MODE: Nascondi la minimappa quando la sidebar è aperta --- */

/* 1. Assicuriamoci che il pulsante abbia una transizione morbida per l'opacità */
#close-modal-btn {
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease !important;
}

/* 2. Quando il modale ha la classe sidebar-open, facciamo svanire la minimappa */
#tour-modal.sidebar-open #close-modal-btn {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* --- 17. SEGMENTED CONTROLS E SIDEBAR FISSA --- */

/* Fissa la parte alta e allinea i margini */
#sidebar-top-fixed {
    flex-shrink: 0;
    padding-right: 25px; 
}

/* Contenitore delle pillole */
.segmented-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    transition: opacity 0.3s ease; /* Transizione fluida */
}

/* Stile base delle pillole */
.segment-pill {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--c-separatore);
    border-radius: 999px;
    color: var(--c-testo);
    font-family: 'Open Sans', sans-serif;
    font-size: 0.85em;
    font-weight: 700;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
}

/* Pillola Attiva */
.segment-pill.active {
    opacity: 1;
    background: rgba(var(--c-accento-rgb), 0.15);
    border-color: var(--c-accento-dark);
    color: var(--c-accento-dark);
}

/* Gestione dei contenitori del contenuto */
.tab-content {
    transition: opacity 0.3s ease-out;
    opacity: 0;
}

.tab-content.active {
    opacity: 1;
}

/* --- LOGICA DI CARICAMENTO (OVERRIDE) --- */
/* Solo pillole e contenuti spariscono. L'occhiello rimane visibile. */

.sidebar-loading .segmented-controls,
.sidebar-loading .tab-content { 
  opacity: 0 !important; 
  pointer-events: none;
}

/* Forza la visibilità dell'occhiello per sovrascrivere eventuali residui */
.sidebar-loading #sidebar-scene-meta {
  opacity: 1 !important;
}

/* --- 18. NODI SEMANTICI (MODELLO A BLOCCHI) --- */

/* Contenitore del singolo blocco (es. un Autore o un Bene) */
.semantic-block {
    margin-bottom: 18px;
    padding: 15px;
    background: rgba(var(--c-accento-rgb), 0.05);
    border-radius: 12px;
    border-left: 4px solid var(--c-accento-dark);
    backdrop-filter: blur(5px);
}

/* Etichetta superiore (es. "AUTORE") */
.semantic-eyebrow {
    font-size: 0.65em;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 800;
    color: var(--c-testo);
    opacity: 0.5;
    margin-bottom: 6px;
}

/* Nome dell'entità (es. "Domenico Carella") */
.semantic-entity-name {
    font-size: 1.1em;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: var(--c-testo);
    margin-bottom: 12px;
    line-height: 1.2;
}

/* Contenitore dei bottoni/badge */
.semantic-badges {
    display: flex;
    flex-wrap: wrap; /* Permette ai badge di andare a capo su schermi piccoli */
    gap: 8px;
}

/* Stile base comune a tutti i badge */
.semantic-badge {
    padding: 5px 12px;
    font-size: 0.7em;
    border-radius: 20px;
    text-decoration: none !important;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

/* 1. Badge Catalogo ICCD (Ufficiale) */
.semantic-badge.iccd {
    background: #55738F;
    color: #fff;
}

/* 2. Badge ArCo (Ufficiale) */
.semantic-badge.arco {
    background: #F95700;
    color: #fff;
}

/* 3. Badge Wikidata (Ufficiale) */
.semantic-badge.wikidata {
    background: #339966;
    color: #fff;
}

/* Effetto al passaggio del mouse su tutti i badge */
.semantic-badge:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* --- 19. TRANSIZIONI CINEMATOGRAFICHE PANNELLUM --- */

/* 1. Spegne brutalmente il box di caricamento nativo */
.pnlm-load-box {
    display: none !important;
}

/* --- AGGIORNAMENTO SIPARIO TOTALE --- */

#custom-scene-loader {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.3); /* Leggermente più scuro per far risaltare la barra */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    
    /* VALORE CRITICO: Deve essere superiore a .info-sidebar e .info-btn */
    z-index: 9999; 
    
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

/* Quando il sipario è attivo */
#custom-scene-loader.active {
    opacity: 1;
    pointer-events: all; /* Sicurezza: blocca i clic dello user mentre carica! */
}

/* 3. La barra di scorrimento colorata (Design Consolidato) */
.custom-loader-bar {
    width: 240px; /* Leggermente più larga per equilibrio visivo */
    height: 4px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    /* Ombra profonda per staccarla dal fondo sfocato della sidebar */
    box-shadow: 0 0 30px rgba(0,0,0,0.6); 
    /* Forza il posizionamento nitido al centro del loader */
    z-index: 10000; 
}

.custom-loader-bar::after {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 40%;
    /* Il colore dinamico della categoria */
    background-color: var(--c-accento-dark, #ffffff); 
    border-radius: 10px;
    animation: customLoaderAnim 1.5s infinite ease-in-out;
}

@keyframes customLoaderAnim {
    0% { left: -40%; }
    100% { left: 100%; }
}

/* --- 20. STILE FONTI E BIBLIOGRAFIA NELLA SIDEBAR (Versione Minimal) --- */
.content-sources {
  margin-top: 40px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.05); /* Grigio neutro chiarissimo per Light Mode */
  border-radius: 12px; /* Angoli arrotondati su tutti i lati per un effetto "card" */
  font-size: 0.85em;
}

/* Adattamento per la Dark Mode */
body.dark-mode .content-sources {
  background: rgba(255, 255, 255, 0.08); /* Grigio neutro per Dark Mode */
}

.content-sources h4 {
  margin: 0 0 12px 0;
  font-size: 1.05em;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--c-testo);
  opacity: 0.6; /* Molto discreto */
  display: flex;
  align-items: center;
  gap: 8px;
}

.content-sources ul {
  margin: 0;
  padding-left: 18px;
  list-style-type: disc;
}

.content-sources li {
  margin-bottom: 8px;
  color: var(--c-testo);
  opacity: 0.8;
  line-height: 1.5;
}

.content-sources li:last-child {
  margin-bottom: 0;
}

/* Link eleganti e minimali */
.content-sources a {
  color: var(--c-testo);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

.content-sources a:hover {
  opacity: 1;
  color: var(--c-accento, #3498db);
}