/* Il controllo Layers è separato da Leaflet solo a livello DOM/stacking.
 * Il portal non intercetta la mappa: lo fa esclusivamente il suo contenuto. */
#dsc-layers-panel-portal {
  position: fixed;
  inset: 0;
  z-index: var(--dsc-map-panel-priority-z);
  pointer-events: none;
}

#dsc-layers-panel-portal > .leaflet-control-layers {
  position: fixed;
  top: calc(var(--topbarHeight, 0px) + 10px);
  right: 10px;
  margin: 0;
  pointer-events: auto;
}

/* Il comando compare esclusivamente nella PWA installata/standalone. */
#pwa-fab-toggle {
  display: none;
}

body.pwa-standalone #pwa-fab-toggle {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 10001;
  display: grid;
  width: 52px;
  height: 52px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .30);
  touch-action: manipulation;
  cursor: pointer;
}

/* PWA, partendo da destra: master, Selezione zone, Search, Aiuti. */
body.pwa-standalone #layers-fab { right: 70px !important; bottom: 14px !important; }
body.pwa-standalone #search-fab { right: 126px !important; bottom: 14px !important; }
body.pwa-standalone #help-fab { right: 182px !important; bottom: 14px !important; }
body.pwa-standalone #ai-fab { right: 14px !important; bottom: 70px !important; }
body.pwa-standalone #tools-fab { right: 14px !important; bottom: 125px !important; }
body.pwa-standalone #updates-fab { right: 14px !important; bottom: 180px !important; }
body.pwa-standalone #follow-fab { right: 14px !important; bottom: 236px !important; }
body.pwa-standalone #dsc-assistant-fab { right: 14px !important; bottom: 292px !important; }

body.pwa-standalone #pwa-fab-toggle:focus-visible {
  outline: 3px solid var(--info);
  outline-offset: 2px;
}

/* Nessun elemento invisibile resta attivo quando il gruppo è compresso. */
body.pwa-standalone.pwa-fabs-collapsed #ai-fab,
body.pwa-standalone.pwa-fabs-collapsed #help-fab,
body.pwa-standalone.pwa-fabs-collapsed #layers-fab,
body.pwa-standalone.pwa-fabs-collapsed #search-fab,
body.pwa-standalone.pwa-fabs-collapsed #updates-fab,
body.pwa-standalone.pwa-fabs-collapsed #tools-fab,
body.pwa-standalone.pwa-fabs-collapsed #follow-fab,
body.pwa-standalone.pwa-fabs-collapsed #dsc-assistant-fab {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  transform: scale(.84);
}

@media (prefers-reduced-motion: no-preference) {
  body.pwa-standalone #ai-fab,
  body.pwa-standalone #help-fab,
  body.pwa-standalone #layers-fab,
  body.pwa-standalone #search-fab,
  body.pwa-standalone #updates-fab,
  body.pwa-standalone #tools-fab,
  body.pwa-standalone #follow-fab,
  body.pwa-standalone #dsc-assistant-fab {
    transition: opacity .16s ease, transform .16s ease, visibility 0s linear .16s;
  }

  body.pwa-standalone:not(.pwa-fabs-collapsed) #ai-fab,
  body.pwa-standalone:not(.pwa-fabs-collapsed) #help-fab,
  body.pwa-standalone:not(.pwa-fabs-collapsed) #layers-fab,
  body.pwa-standalone:not(.pwa-fabs-collapsed) #search-fab,
  body.pwa-standalone:not(.pwa-fabs-collapsed) #updates-fab,
  body.pwa-standalone:not(.pwa-fabs-collapsed) #tools-fab,
  body.pwa-standalone:not(.pwa-fabs-collapsed) #follow-fab,
  body.pwa-standalone:not(.pwa-fabs-collapsed) #dsc-assistant-fab {
    transition-delay: 0s;
  }
}
