html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #fcfcfc;
}

#map {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  /* la mappa lascia spazio alla bottom-nav (64px) */
  height: calc(100dvh - 64px);
}

/* Bottone cambio layer */
.layer-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1000;
  background: #ffffff;
  border: 1px solid #ccc;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  font-size: 14px;
}

.layer-toggle:hover {
  background: #f5f5f5;
}

@media (max-width: 768px) {
  /* nascondi zoom su mobile */
  .leaflet-control-zoom {
    display: none;
  }

  /* layer in basso a destra */
  .layer-toggle {
    top: auto;
    right: 16px;
    bottom: 80px; /* sopra la bottom nav */
  }

  /* bottone ? sopra il layer */
  .legend-toggle {
    top: auto;
    right: 16px;
    bottom: 130px;
  }

  /* nuvoletta sopra entrambi */
  .legend-bubble {
    top: auto;
    right: 16px;
    bottom: 180px;
  }
}


/* Bottone legenda "?" */
.legend-toggle {
  position: absolute;
  top: 72px;          /* sotto al bottone layer su desktop */
  right: 16px;
  z-index: 1100;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid #ccc;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.legend-toggle span {
  pointer-events: none;
}

/* Nuvoletta legenda */
.legend-bubble {
  position: absolute;
  top: 120px;         /* vicino al bottone ? */
  right: 16px;
  z-index: 1050;
  max-width: 260px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  font-size: 12px;
  color: #333;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition:
    opacity 180ms ease-out,
    transform 180ms ease-out;
}

.legend-bubble h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.legend-bubble ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.legend-bubble li {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

/* Puntini colorati legenda */
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-in-corso {
  background: #f0ad4e;
}

.legend-fermo {
  background: #999999;
}

.legend-completato {
  background: #5cb85c;
}

.legend-guasto {
  background: #d9534f;
}

/* Stato aperto legenda */
.legend-bubble--open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}


/* Modal scheda cantiere */
.site-modal {
  position: fixed;
  inset: 0;
  /* nascosto di default ma animabile */
  opacity: 0;
  pointer-events: none;
  z-index: 4000;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  transition: opacity 220ms cubic-bezier(0.2, 0, 0, 1);
}

.site-modal--open {
  opacity: 1;
  pointer-events: auto;
}

.site-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.site-modal__content {
  position: absolute;
  inset: auto 0 0 0;
  max-height: 80%;
  background: #ffffff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* stato iniziale per animazione */
  transform: translateY(16px);
  opacity: 0;
  transition:
    transform 260ms cubic-bezier(0.2, 0, 0, 1),
    opacity 260ms cubic-bezier(0.2, 0, 0, 1);
}

/* quando il modal è aperto, la card sale e diventa opaca */
.site-modal--open .site-modal__content {
  transform: translateY(0);
  opacity: 1;
}

/* Desktop: card centrata e leggermente staccata dal basso */
@media (min-width: 1024px) {
  .site-modal__content {
    inset: auto 15% 8% 15%;
    max-width: 900px;
    margin: 0 auto;
    border-radius: 18px;
  }
}

.site-modal__image-wrapper {
  width: 100%;
  max-height: 220px;
  overflow: hidden;
}

.site-modal__image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.site-modal__body {
  padding: 14px 16px 18px;
}

.site-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.site-modal__body h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.site-modal__status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #fff;
}

.site-modal__description {
  margin: 8px 0 10px;
  font-size: 0.92rem;
  line-height: 1.35;
}

.site-modal__meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #666;
}

.site-modal__maps-link {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #1976d2;
  color: #1976d2;
  text-decoration: none;
  white-space: nowrap;
}

.site-modal__maps-link:hover {
  background: #1976d2;
  color: #fff;
}

.site-modal__close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border-radius: 999px;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

/* Zoom Leaflet con un po' di stile */
.leaflet-control-zoom {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  border-radius: 8px;
}

@media (max-width: 768px) {
  .leaflet-control-zoom {
    display: none;
  }
}

/* Bottom navigation bar */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  background: #ffffff;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 3000;
}

.bottom-nav__item {
  flex: 1;
  height: 100%;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: #777;
  cursor: pointer;
}

.bottom-nav__icon {
  font-size: 18px;
}

.bottom-nav__item--active {
  color: #1976d2;
  font-weight: 600;
}

/* Viste secondarie (Notizie, Profilo) sopra la mappa, sotto la nav */
.bottom-view {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 64px; /* stessa altezza della nav */
  background: #fcfcfc;
  z-index: 2500;
  overflow-y: auto;
}

.bottom-view--hidden {
  display: none;
}
