/* ════════════════════════════════════════════════════════════════
   TRAMANDA 2.0 — style.css  (Fase 1 finale — Layout Immersivo)
   Font: Cormorant Garamond (display) · DM Mono (UI)
   ════════════════════════════════════════════════════════════════ */

/* ── Token ───────────────────────────────────────────────────── */
:root {
  --c-void:       #050810;
  --c-abyss:      #0a0f1e;
  --c-ridge-1:    #0d1a2e;
  --c-ridge-2:    #0e2240;
  --c-ridge-3:    #112b50;
  --c-accent:     #67e8f9;        /* ciano orografico — colore principale UI */
  --c-accent-dim: rgba(103,232,249,.15);
  --c-glow:       rgba(103,232,249,.30);
  --c-frost:      rgba(255,255,255,.06);
  --c-border:     rgba(255,255,255,.10);
  --c-border-h:   rgba(103,232,249,.40);
  --c-text:       rgba(255,255,255,.90);
  --c-text-muted: rgba(255,255,255,.45);
  --c-error:      #f87171;

  --ff-display: 'Cormorant Garamond', Georgia, serif;
  --ff-mono:    'DM Mono', 'Courier New', monospace;

  --r-card:    20px;
  --r-hud:     14px;
  --r-input:   10px;
  --blur-hud:  blur(24px) saturate(160%);
  --blur-card: blur(32px) saturate(180%);
  --tr-base:   220ms cubic-bezier(.4,0,.2,1);
}

/* ── Reset totale ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;           /* niente scrollbar — layout immersivo */
  background: var(--c-void);
  color: var(--c-text);
  font-family: var(--ff-mono);
  font-weight: 300;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  letter-spacing: .02em;
}

/* ════════════════════════════════════════════════════════════════
   MAPPA — base del layout, occupa tutto il viewport
   ════════════════════════════════════════════════════════════════ */
#map-container {
  position: fixed;
  inset: 0;                   /* top:0 right:0 bottom:0 left:0 */
  width: 100vw;
  height: 100vh;
  z-index: 0;
  background: transparent; /* trasparente: evita quadrati scuri durante flyToBounds */
  background-color: #0a1628; /* fallback visibile solo prima dei tile */
}

/* Shimmer durante fetch GeoJSON */
#map-container::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 900;
  background: linear-gradient(
    105deg,
    transparent           0%,
    transparent          35%,
    rgba(103,232,249,.09) 50%,
    transparent          65%,
    transparent         100%
  );
  background-size: 200% 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

#map-container.map-shimmer::after {
  opacity: 1;
  animation: shimmer-slide 1.4s linear infinite;
}

#map-container.map-shimmer {
  box-shadow: inset 0 0 0 1px rgba(103,232,249,.2);
}

@keyframes shimmer-slide {
  from { background-position:  200% 0; }
  to   { background-position: -200% 0; }
}

/* ════════════════════════════════════════════════════════════════
   OVERLAY CENTRATO — wrapper per il login
   ════════════════════════════════════════════════════════════════ */
.overlay-centrato {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  /* Sfondo scuro semitrasparente dietro la card */
  background: rgba(5, 8, 16, .55);
  backdrop-filter: blur(4px);
}

/* ════════════════════════════════════════════════════════════════
   GLASS CARD — form di login
   ════════════════════════════════════════════════════════════════ */
.glass-card {
  position: relative;
  overflow: hidden;           /* contiene .orographic-bg interno */
  width: 100%;
  max-width: 400px;
  background: var(--c-frost);
  backdrop-filter: var(--blur-card);
  -webkit-backdrop-filter: var(--blur-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  padding: 2.2rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.04) inset,
    0 12px 60px rgba(0,0,0,.7),
    0 0 80px var(--c-glow);
}

/* Sfondo orografico animato dentro la card login */
.orographic-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: linear-gradient(175deg, var(--c-abyss) 0%, var(--c-ridge-1) 40%, var(--c-void) 100%);
}

.layer {
  position: absolute;
  inset: 0;
}

.layer-1 {
  bottom: 0; height: 55%;
  background: linear-gradient(180deg, transparent 0%, var(--c-ridge-1) 100%);
  clip-path: polygon(0% 60%,5% 45%,12% 55%,20% 30%,28% 50%,35% 20%,42% 40%,50% 15%,58% 35%,65% 22%,72% 42%,80% 18%,88% 38%,95% 25%,100% 45%,100% 100%,0% 100%);
  opacity: .6;
  animation: drift-slow 28s ease-in-out infinite alternate;
}

.layer-2 {
  bottom: 0; height: 42%;
  background: linear-gradient(180deg, transparent 0%, var(--c-ridge-2) 100%);
  clip-path: polygon(0% 55%,8% 38%,16% 52%,24% 28%,32% 46%,40% 18%,48% 38%,56% 12%,64% 32%,72% 20%,80% 40%,88% 16%,96% 36%,100% 22%,100% 100%,0% 100%);
  opacity: .7;
  animation: drift-mid 18s ease-in-out infinite alternate;
}

.layer-3 {
  bottom: 0; height: 30%;
  background: linear-gradient(180deg, transparent 0%, var(--c-ridge-3) 100%);
  clip-path: polygon(0% 65%,7% 42%,15% 58%,23% 32%,31% 52%,39% 22%,47% 44%,55% 16%,63% 38%,71% 24%,79% 46%,87% 20%,95% 40%,100% 28%,100% 100%,0% 100%);
  opacity: .85;
  animation: drift-fast 12s ease-in-out infinite alternate;
}

.noise-overlay {
  position: absolute; inset: 0; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

@keyframes drift-slow { from { transform: translateX(0); } to { transform: translateX(-3%); } }
@keyframes drift-mid  { from { transform: translateX(0); } to { transform: translateX(2.5%); } }
@keyframes drift-fast { from { transform: translateX(0); } to { transform: translateX(-2%); } }

/* Tutto il contenuto card va sopra l'orographic-bg */
.glass-card > * { position: relative; z-index: 1; }

/* Animazione ingresso card */
.card-animata {
  opacity: 1;
  animation: card-entra .7s var(--tr-base) both;
}

@keyframes card-entra {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Elementi interni card ───────────────────────────────────── */
.card-header {
  display: flex;
  align-items: center;
  gap: .8rem;
  width: 100%;
  justify-content: center;
}

.wordmark {
  font-family: var(--ff-display);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 600;
  letter-spacing: .22em;
  color: var(--c-text);
}

.version-tag {
  font-size: .6rem;
  letter-spacing: .14em;
  color: var(--c-accent);
  border: 1px solid var(--c-accent);
  padding: .12rem .45rem;
  border-radius: 4px;
  opacity: .85;
}

.cantiere-icon {
  color: var(--c-text-muted);
  display: flex; align-items: center; justify-content: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 1px solid var(--c-border);
  background: rgba(255,255,255,.04);
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--c-accent-dim); }
  50%       { box-shadow: 0 0 0 10px transparent; }
}

.card-title {
  font-family: var(--ff-display);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 300;
  letter-spacing: .05em;
  text-align: center;
  color: var(--c-text);
  line-height: 1.1;
}

.card-subtitle {
  font-size: .75rem;
  color: var(--c-text-muted);
  text-align: center;
  line-height: 1.7;
  letter-spacing: .03em;
}

/* ── Form login ──────────────────────────────────────────────── */
.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .9rem;
}

.field-group { display: flex; flex-direction: column; gap: .35rem; }

.field-label {
  font-size: .66rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-text-muted);
}

.input-wrapper { position: relative; }

.glass-input {
  width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--c-border);
  border-radius: var(--r-input);
  color: var(--c-text);
  font-family: var(--ff-mono);
  font-size: .82rem;
  font-weight: 300;
  letter-spacing: .03em;
  padding: .7rem 1rem;
  outline: none;
  transition: border-color var(--tr-base), background var(--tr-base), box-shadow var(--tr-base);
  backdrop-filter: blur(8px);
}

.glass-input::placeholder { color: rgba(255,255,255,.2); }

.glass-input:focus {
  border-color: var(--c-border-h);
  background: rgba(103,232,249,.05);
  box-shadow: 0 0 0 3px rgba(103,232,249,.10);
}

.input-wrapper .glass-input { padding-right: 3rem; }

.toggle-pw {
  position: absolute; right: .75rem; top: 50%;
  transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer;
  color: var(--c-text-muted); padding: .25rem;
  transition: color var(--tr-base);
  display: flex; align-items: center; justify-content: center;
}
.toggle-pw:hover { color: var(--c-text); }

.error-msg {
  font-size: .7rem;
  color: var(--c-error);
  text-align: center;
  min-height: 1.1em;
  letter-spacing: .03em;
  transition: opacity .2s ease;
}
.error-msg:empty { opacity: 0; }

.btn-accedi {
  width: 100%;
  padding: .8rem 1.5rem;
  border: 1px solid var(--c-accent);
  border-radius: var(--r-input);
  background: rgba(103,232,249,.10);
  color: var(--c-text);
  font-family: var(--ff-mono);
  font-size: .8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  gap: .75rem;
  transition: background var(--tr-base), box-shadow var(--tr-base), transform var(--tr-base);
  backdrop-filter: blur(8px);
}
.btn-accedi:hover:not(:disabled) {
  background: rgba(103,232,249,.22);
  box-shadow: 0 0 24px rgba(103,232,249,.25);
  transform: translateY(-1px);
}
.btn-accedi:disabled { opacity: .5; cursor: not-allowed; }

.spinner {
  display: none;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: var(--c-text);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.spinner.active { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════════
   HUD — pannelli floating glassmorphism sopra la mappa
   Tutti usano position:fixed e z-index > 10
   ════════════════════════════════════════════════════════════════ */
.hud {
  position: fixed;
  z-index: 200;
  background: rgba(5, 8, 16, .72);
  backdrop-filter: var(--blur-hud);
  -webkit-backdrop-filter: var(--blur-hud);
  border: 1px solid var(--c-border);
  border-radius: var(--r-hud);
  color: var(--c-text);
  font-family: var(--ff-mono);
  font-size: .72rem;
  letter-spacing: .04em;
  box-shadow:
    0 4px 24px rgba(0,0,0,.5),
    0 0 0 1px rgba(255,255,255,.03) inset;
}

/* ── Wordmark — alto sinistra ────────────────────────────────── */
.hud-brand {
  top: 1.2rem; left: 1.2rem;
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem 1rem;
}

.hud-brand .wordmark {
  font-size: 1rem;
  letter-spacing: .2em;
}

/* ── Pannello utente — alto destra ───────────────────────────── */
.hud-utente {
  top: 1.2rem; right: 1.2rem;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1rem;
}

.hud-info { display: flex; flex-direction: column; gap: .15rem; }

.hud-welcome {
  font-size: .6rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--c-text-muted);
}

.hud-username {
  font-family: var(--ff-display);
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: .04em;
  line-height: 1.1;
}

/* ── Breadcrumb — basso sinistra ─────────────────────────────── */
.hud-breadcrumb {
  bottom: 2rem; left: 1.2rem;
  display: flex; align-items: center; gap: .4rem;
  padding: .5rem .9rem;
  flex-wrap: wrap;
  max-width: calc(100vw - 2.4rem);
}

/* ── Nota ultimo accesso — basso destra ─────────────────────── */
.hud-nota {
  bottom: 2rem; right: 1.2rem;
  padding: .45rem .9rem;
  color: var(--c-text-muted);
  font-size: .62rem;
  letter-spacing: .05em;
  max-width: 320px;
  text-align: right;
}

/* ── Badge ruolo ─────────────────────────────────────────────── */
.role-badge {
  display: inline-block;
  margin-top: .2rem;
  font-size: .6rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-accent);
  border: 1px solid var(--c-accent);
  padding: .1rem .5rem;
  border-radius: 4px;
  opacity: .85;
}

.role-supreme {
  display: inline-block;
  margin-top: .2rem;
  font-size: .58rem;
  font-weight: 400;
  letter-spacing: .16em;
  text-transform: uppercase;
  line-height: 1.5;
  padding: .25rem .7rem;
  border-radius: 4px;
  background: linear-gradient(90deg, #c9a84c 0%, #e8d48b 35%, #67e8f9 70%, #93c5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  border: 1px solid rgba(103,232,249,.45);
  box-shadow: 0 0 10px rgba(103,232,249,.2), 0 0 24px rgba(201,168,76,.1);
  animation: supreme-glow 3.5s ease-in-out infinite alternate;
}

@keyframes supreme-glow {
  from { box-shadow: 0 0 8px  rgba(103,232,249,.15), 0 0 18px rgba(201,168,76,.06); }
  to   { box-shadow: 0 0 16px rgba(103,232,249,.40), 0 0 36px rgba(201,168,76,.18); }
}

/* ── Logout ──────────────────────────────────────────────────── */
.btn-logout {
  display: flex; align-items: center; gap: .35rem;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  color: var(--c-text-muted);
  font-family: var(--ff-mono);
  font-size: .68rem;
  letter-spacing: .08em;
  padding: .4rem .8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--tr-base), border-color var(--tr-base), background var(--tr-base);
}
.btn-logout:hover {
  color: var(--c-text);
  border-color: var(--c-border-h);
  background: rgba(103,232,249,.08);
}

/* ════════════════════════════════════════════════════════════════
   BREADCRUMB
   ════════════════════════════════════════════════════════════════ */
.bc-item    { color: var(--c-text-muted); font-size: .68rem; }
.bc-attivo  { color: var(--c-text); }
.bc-link    { color: var(--c-accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; transition: opacity var(--tr-base); }
.bc-link:hover { opacity: .7; }
.bc-sep     { color: rgba(255,255,255,.2); font-size: .8rem; }

/* ════════════════════════════════════════════════════════════════
   MESSAGGI ERRORE / INFO sopra la mappa
   ════════════════════════════════════════════════════════════════ */
.map-messaggio {
  position: fixed;
  bottom: 5rem; left: 50%; transform: translateX(-50%);
  z-index: 300;
  display: none;
  background: rgba(10,15,30,.92);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: .5rem 1.1rem;
  font-size: .7rem;
  color: var(--c-text-muted);
  letter-spacing: .04em;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  transition: opacity .3s ease;
}

/* ════════════════════════════════════════════════════════════════
   TOOLTIP LEAFLET
   ════════════════════════════════════════════════════════════════ */
.tooltip-tramanda {
  background: rgba(5,8,16,.88) !important;
  border: 1px solid rgba(103,232,249,.3) !important;
  border-radius: 6px !important;
  color: rgba(255,255,255,.9) !important;
  font-family: 'DM Mono', monospace !important;
  font-size: .68rem !important;
  letter-spacing: .04em !important;
  padding: .3rem .6rem !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.5) !important;
  backdrop-filter: blur(8px) !important;
}
.tooltip-tramanda::before { display: none !important; }

/* ════════════════════════════════════════════════════════════════
   OVERRIDE CONTROLLI LEAFLET
   ════════════════════════════════════════════════════════════════ */
.leaflet-control-zoom a {
  background-color: rgba(5,8,16,.85) !important;
  backdrop-filter: blur(8px) !important;
  color: var(--c-text) !important;
  border-color: var(--c-border) !important;
  font-family: var(--ff-mono) !important;
}
.leaflet-control-zoom a:hover {
  background-color: rgba(103,232,249,.15) !important;
}

.leaflet-control-attribution {
  background: rgba(5,8,16,.75) !important;
  color: var(--c-text-muted) !important;
  font-size: .55rem !important;
  font-family: var(--ff-mono) !important;
  backdrop-filter: blur(6px) !important;
}
.leaflet-control-attribution a { color: var(--c-accent) !important; }

/* ════════════════════════════════════════════════════════════════
   UTILITY
   ════════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }

/* Dashboard: invisibile di default, visibile con .is-visible */
#view-dashboard {
  opacity: 0;
  transition: opacity .45s var(--tr-base);
  pointer-events: none;   /* mai intercettare click — passa tutto alla mappa */
}
#view-dashboard.is-visible {
  opacity: 1;
  pointer-events: none;   /* il contenitore resta trasparente ai click */
}

/* Solo i pannelli HUD figli sono cliccabili */
#view-dashboard.is-visible .hud {
  pointer-events: auto;
}

#view-serranda {
  opacity: 1;
}

/* ── Vignetta mappa ──────────────────────────────────────────── */
/*
  Overlay fisso sopra la mappa, pointer-events:none per non
  bloccare i click sui poligoni Leaflet sottostanti.
  radial-gradient: centro trasparente, bordi scuri — effetto
  spotlight sull'Italia senza problemi di layer o zoom.
*/
#map-vignetta {
  position: fixed;
  inset: 0;
  pointer-events: none !important;
  z-index: 450;          /* sopra tile+overlay leaflet, sotto HUD (1000+) */
  background: radial-gradient(
    ellipse 70% 80% at 50% 50%,
    transparent 30%,
    rgba(5, 8, 16, 0.50) 65%,
    rgba(5, 8, 16, 0.92) 100%
  );
}

/* ── Responsive mobile ───────────────────────────────────────── */
@media (max-width: 768px) {

  /* Blocca scroll/overscroll della pagina — la mappa occupa tutto */
  body {
    overscroll-behavior: none;
    touch-action: none;
  }

  /* Vignetta più leggera — schermo piccolo, meno bordo */
  #map-vignetta {
    z-index: 450;
    background: radial-gradient(
      ellipse 85% 90% at 50% 50%,
      transparent 28%,
      rgba(5, 8, 16, 0.45) 62%,
      rgba(5, 8, 16, 0.90) 100%
    );
  }

  /* HUD: riposizionati per schermi verticali
     Brand: alto sinistra (invariato, solo più compatto)
     Utente: alto destra (invariato, più compatto)
     Breadcrumb: basso sinistra, allargato
     Nota: nascosta su mobile — poco spazio */
  .hud-brand {
    position: fixed;
    top: 10px; left: 10px;
    width: auto; max-width: 45vw;
    padding: .4rem .75rem;
  }
  .hud-brand .wordmark { font-size: .8rem; }

  .hud-utente {
    position: fixed;
    top: 10px; right: 10px;
    width: auto; max-width: 45vw;
    padding: .4rem .75rem;
    gap: .5rem;
  }
  .hud-username { font-size: .85rem; }
  .hud-welcome  { display: none; }

  .hud-breadcrumb {
    bottom: 1.2rem; left: .8rem;
    padding: .4rem .75rem;
    font-size: .7rem;
    max-width: calc(100vw - 1.6rem);
  }

  /* Nota ultimo accesso: nascosta su mobile */
  .hud-nota { display: none; }

  /* Nasconde i controlli zoom +/- di Leaflet su mobile
     (si naviga con tap e pinch) */
  .leaflet-control-zoom { display: none !important; }
}

/* ── Label geografiche ───────────────────────────────────────── */
.mappa-label {
  display: inline-block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-weight: 700;
  color: rgba(255,255,255,0.90);
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  /* alone bianco per leggibilità su satellite */
  text-shadow:
    0 0 6px rgba(255,255,255,0.35),
    0 1px 3px rgba(0,0,0,0.95),
    0 0 14px rgba(0,0,0,0.80);
  transform: translateX(-50%);
}
.mappa-label-regioni  { font-size: .66rem; opacity: .90; letter-spacing: -.02em; }
.mappa-label-province { font-size: .58rem; opacity: .75; }
.mappa-label-comuni   { font-size: .48rem; opacity: .65; font-weight: 600; }
.mappa-label-sigla    { font-size: .60rem; opacity: .80; letter-spacing: .12em; }

@media (max-width: 768px) {
  .mappa-label-regioni  { font-size: .68rem; }
  .mappa-label-province { font-size: .56rem; }
  .mappa-label-comuni   { font-size: .46rem; }
}

/* ── Version counter ─────────────────────────────────────────── */
#version-counter {
  position: fixed;
  bottom: .6rem;
  right: .6rem;
  z-index: 190;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .55rem;
  letter-spacing: .08em;
  color: rgba(255,255,255,0.22);
  pointer-events: none;
  user-select: none;
}



/* ═══════════════════════════════════════════════════════════════
   MOBILE-ONLY — solo map-mobile.js
   Tutte le regole seguenti si applicano esclusivamente a mobile.
   Non interferiscono con la versione desktop.
   ═══════════════════════════════════════════════════════════════ */

/* ── HUD mobile: font sans-serif, dimensioni ridotte del 30% ─── */
@media (max-width: 768px) {

  /* Rimuovi Cormorant Garamond su mobile — usa sans-serif di sistema */
  .wordmark, .version-tag, .hud, .bc-item,
  .hud-welcome, .hud-username, .role-badge {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  }

  /* Brand: compatto */
  .hud-brand {
    padding: .28rem .55rem;
  }
  .hud-brand .wordmark {
    font-size: .62rem;
    letter-spacing: .18em;
  }
  .hud-brand .version-tag { font-size: .52rem; }

  /* Utente: compatto */
  .hud-utente {
    padding: .28rem .55rem;
    gap: .35rem;
  }
  .hud-username  { font-size: .70rem; }
  .role-badge    { font-size: .55rem; padding: .1rem .35rem; }
  .btn-logout    { font-size: .65rem; padding: .25rem .5rem; gap: .3rem; }
  .btn-logout svg { width: 12px; height: 12px; }

  /* Vignetta mobile: z-index sotto gli HUD (z 500+) ma sopra la mappa */
  /* #map-vignetta mobile: vedi regola base sopra */
}

/* ── FAB Ricerca ─────────────────────────────────────────────── */
#mob-fab {
  position:   fixed;
  left:       14px;
  bottom:     14px;
  z-index:    850;
  display:    flex;
  flex-direction: column;
  align-items: flex-start;
  gap:        6px;
}

/* Pulsante cerchio */
#mob-fab-btn {
  width:           48px;
  height:          48px;
  border-radius:   50%;
  border:          1px solid rgba(255,255,255,0.22);
  background:      rgba(10,14,26,0.82);
  backdrop-filter: blur(14px);
  color:           rgba(255,255,255,0.85);
  display:         flex;
  align-items:     center;
  justify-content: center;
  cursor:          pointer;
  flex-shrink:     0;
  transition:      opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
#mob-fab-btn:active { opacity: .7; }

/* Contenitore input — inizia collassato */
#mob-search-inner {
  display:         flex;
  align-items:     center;
  gap:             6px;
  width:           0;
  overflow:        hidden;
  opacity:         0;
  border-radius:   24px;
  border:          1px solid rgba(255,255,255,0.18);
  background:      rgba(10,14,26,0.88);
  backdrop-filter: blur(16px);
  transition:      width 0.25s cubic-bezier(.4,0,.2,1),
                   opacity 0.20s ease,
                   border-radius 0.25s ease;
  white-space:     nowrap;
}

/* Stato aperto */
#mob-fab.fab-aperto #mob-fab-btn       { opacity: 0; pointer-events: none; position: absolute; }
#mob-fab.fab-aperto #mob-search-inner  {
  width:         calc(100vw - 56px);   /* larghezza schermo - margine */
  opacity:       1;
  padding:       0 10px 0 16px;
}

#mob-search-input {
  flex:            1;
  min-width:       0;
  border:          none;
  background:      transparent;
  color:           #fff;
  font-family:     'DM Mono', monospace;
  font-size:       .82rem;
  padding:         11px 0;
  outline:         none;
  -webkit-appearance: none;
}
#mob-search-input::placeholder { color: rgba(255,255,255,0.35); }

#mob-search-close {
  background:  transparent;
  border:      none;
  color:       rgba(255,255,255,0.50);
  font-size:   1rem;
  padding:     8px 4px;
  cursor:      pointer;
  flex-shrink: 0;
  line-height: 1;
}
#mob-search-close:active { color: #fff; }

/* Risultati ricerca */
#mob-search-results {
  list-style:      none;
  margin:          0;
  padding:         4px 0;
  border-radius:   12px;
  border:          1px solid rgba(255,255,255,0.12);
  background:      rgba(10,14,26,0.92);
  backdrop-filter: blur(16px);
  display:         none;
  width:           calc(100vw - 28px);
  max-height:      240px;
  overflow-y:      auto;
}

#mob-search-results li {
  display:     flex;
  align-items: center;
  gap:         8px;
  padding:     10px 14px;
  color:       rgba(255,255,255,0.85);
  font-size:   .80rem;
  font-family: 'DM Mono', monospace;
  cursor:      pointer;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
#mob-search-results li:last-child  { border-bottom: none; }
#mob-search-results li:active      { background: rgba(212,175,55,0.12); }

.mob-res-tipo {
  font-size:    .60rem;
  color:        #D4AF37;
  letter-spacing: .08em;
  text-transform: uppercase;
  flex-shrink:  0;
  min-width:    52px;
}

/* ── Spinner ricerca ────────────────────────────────────────── */
#mob-search-spinner {
  display:          none;
  width:            14px;
  height:           14px;
  border:           2px solid rgba(255,255,255,0.15);
  border-top-color: rgba(255,255,255,0.75);
  border-radius:    50%;
  flex-shrink:      0;
  animation:        mob-spin 0.7s linear infinite;
}
#mob-search-spinner.attivo { display: block; }
@keyframes mob-spin { to { transform: rotate(360deg); } }

/* Risultati ricerca: z-index sopra tutto, segue tastiera Android */
#mob-search-results {
  z-index:  1100 !important;  /* sopra pane Leaflet (max ~600) e vignetta */
  position: relative;
}

/* ── Focus area highlight (GeoJSON layer con fade) ─────────── */
.focus-smooth path {
  transition: fill-opacity 0.6s ease-in-out;
}

/* ── User Menu v0.018m ───────────────────────────────────────── */
#user-menu-wrapper {
  position:       fixed;
  top:            14px;
  right:          14px;
  z-index:        900;
  display:        flex;
  flex-direction: column;
  align-items:    flex-end;
  gap:            8px;
  background:     none !important;
  border:         none !important;
  box-shadow:     none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding:        0 !important;
  pointer-events: auto;
}
#user-trigger {
  width:            48px;
  height:           48px;
  border-radius:    50%;
  border:           1px solid rgba(255,255,255,0.22);
  background:       rgba(10,14,26,0.82);
  backdrop-filter:  blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color:            rgba(255,255,255,0.85);
  display:          flex;
  align-items:      center;
  justify-content:  center;
  cursor:           pointer;
  flex-shrink:      0;
  transition:       opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
#user-trigger:active { opacity: 0.7; }
#user-dropdown {
  display:          none;
  background:       rgba(10,14,26,0.92);
  backdrop-filter:  blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border:           1px solid rgba(255,255,255,0.12);
  border-radius:    12px;
  padding:          12px;
  min-width:        180px;
  font-family:      'DM Mono', monospace;
  transform:        scale(0.85) translateY(-8px);
  transform-origin: top right;
  opacity:          0;
  transition:       transform 0.22s cubic-bezier(0.34,1.56,0.64,1),
                    opacity 0.18s ease;
}
#user-dropdown.visibile {
  display:        block;
  transform:      scale(1) translateY(0);
  opacity:        1;
  pointer-events: auto;
}
.ud-header { display: flex; flex-direction: column; gap: 3px; padding-bottom: 4px; }
.ud-name {
  font-size: 0.78rem; color: var(--c-text); font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px;
}
.ud-divider { border: none; border-top: 1px solid rgba(255,255,255,0.08); margin: 8px 0; }
.ud-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: none; color: var(--c-text-muted);
  font-family: 'DM Mono', monospace; font-size: 0.75rem;
  padding: 6px 4px; cursor: pointer; border-radius: 6px;
  transition: background 0.15s, color 0.15s; text-align: left;
}
.ud-item:active { background: rgba(255,255,255,0.06); color: var(--c-text); }
.ud-logout { color: rgba(255,100,100,0.75); }
.ud-logout:active { color: rgba(255,120,120,1); }

/* ── Modal Comune di Riferimento ────────────────────────────── */
#modal-comune {
  position:        fixed;
  inset:           0;
  z-index:         1200;
  display:         flex;
  align-items:     flex-start;
  justify-content: center;
  padding-top:     40px;
  background:      rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  padding:         40px 20px 20px;
}
.mc-card {
  width:      100%;
  max-width:  400px;
  padding:    28px 24px;
  display:    flex;
  flex-direction: column;
  gap:        12px;
}
.mc-titolo {
  font-family: var(--ff-serif);
  font-size:   1.3rem;
  font-weight: 400;
  color:       var(--c-text);
  margin:      0;
}
.mc-sub {
  font-size:  0.75rem;
  color:      var(--c-text-muted);
  margin:     0;
  line-height: 1.5;
}
.mc-input { width: 100%; box-sizing: border-box; }
.mc-lista {
  list-style:  none;
  margin:      0;
  padding:     0;
  max-height:  200px;
  overflow-y:  auto;
}
.mc-item {
  padding:     10px 8px;
  font-family: var(--ff-mono);
  font-size:   0.78rem;
  color:       var(--c-text);
  cursor:      pointer;
  border-radius: 6px;
  transition:  background 0.15s;
}
.mc-item:hover, .mc-item:active { background: rgba(255,255,255,0.07); }
.mc-stato {
  font-size:  0.7rem;
  color:      var(--c-text-muted);
  min-height: 1em;
  margin:     0;
}

/* Comune nel dropdown utente */
.ud-comune {
  font-size:   0.68rem;
  color:       var(--c-text-muted);
  margin-top:  2px;
  display:     block;
}

/* ── Add Word v0.020m ─────────────────────────────────────────── */
#add-word-wrapper {
  position:        fixed;
  bottom:          14px;
  right:           14px;
  z-index:         900;
  display:         flex;
  flex-direction:  column;
  align-items:     flex-end;
  gap:             8px;
  background:      none !important;
  border:          none !important;
  box-shadow:      none !important;
  backdrop-filter: none !important;
  padding:         0 !important;
  pointer-events:  auto;
}

#add-word-trigger {
  width:           48px;
  height:          48px;
  border-radius:   50%;
  border:          1px solid rgba(255,255,255,0.22);
  background:      rgba(10,14,26,0.82);
  backdrop-filter: blur(14px);
  color:           rgba(255,255,255,0.85);
  display:         flex;
  align-items:     center;
  justify-content: center;
  cursor:          pointer;
  flex-shrink:     0;
  transition:      opacity 0.2s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#add-word-trigger:active   { opacity: 0.7; }
#add-word-trigger.aperto   { transform: rotate(45deg); }

#add-word-dropdown {
  display:          none;
  background:       rgba(10,14,26,0.92);
  backdrop-filter:  blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border:           1px solid rgba(255,255,255,0.12);
  border-radius:    12px;
  padding:          16px;
  width:            calc(100vw - 60px);
  max-width:        340px;
  transform:        scale(0.9) translateY(10px);
  transform-origin: bottom right;
  opacity:          0;
  transition:       transform 0.22s cubic-bezier(0.34,1.56,0.64,1),
                    opacity 0.18s ease;
}
#add-word-dropdown.visibile {
  transform: scale(1) translateY(0);
  opacity:   1;
}

.aw-titolo {
  font-family: var(--ff-serif);
  font-size:   1rem;
  color:       var(--c-text);
  margin:      0 0 12px;
}
.aw-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.aw-label { font-family: var(--ff-mono); font-size: 0.65rem; color: var(--c-text-muted); }
.aw-input { width: 100%; box-sizing: border-box; font-size: 0.82rem; }
.aw-comune-txt {
  font-family: var(--ff-mono);
  font-size:   0.78rem;
  color:       var(--c-text);
  margin:      0;
  padding:     8px 10px;
  background:  rgba(255,255,255,0.04);
  border-radius: 6px;
}
.aw-audio-row { flex-direction: row; gap: 8px; }
.aw-btn {
  display:       flex;
  align-items:   center;
  gap:           6px;
  padding:       8px 14px;
  border-radius: 8px;
  border:        1px solid rgba(255,255,255,0.15);
  background:    rgba(255,255,255,0.06);
  color:         var(--c-text);
  font-family:   var(--ff-mono);
  font-size:     0.72rem;
  cursor:        pointer;
  transition:    background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.aw-btn:disabled { opacity: 0.35; cursor: default; }
.aw-btn:not(:disabled):active { background: rgba(255,255,255,0.12); }
.aw-btn-rec.registrando { color: #ff6464; border-color: rgba(255,100,100,0.4); }
.aw-btn-pubblica {
  width:      100%;
  justify-content: center;
  margin-top: 4px;
  background: rgba(15,32,64,0.7);
  border-color: rgba(255,255,255,0.2);
}
.aw-btn-pubblica:not(:disabled):active { background: rgba(15,32,64,0.9); }
.aw-stato {
  font-family: var(--ff-mono);
  font-size:   0.68rem;
  color:       var(--c-text-muted);
  min-height:  1em;
  margin:      0;
}

/* Pin cluster comuni sulla mappa */
.pin-comune {
  width:           40px;
  height:          40px;
  border-radius:   50%;
  background:      rgba(10,14,26,0.85);
  border:          1.5px solid rgba(255,255,255,0.30);
  backdrop-filter: blur(8px);
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-family:     var(--ff-mono);
  font-size:       0.75rem;
  color:           #fff;
  font-weight:     600;
  box-shadow:      0 2px 12px rgba(0,0,0,0.5);
  cursor:          pointer;
  transition:      transform 0.15s;
}
.pin-comune:active { transform: scale(0.92); }
