/* Aba Mapa. Celular: filtros, mapa e lista empilhados. A partir de 768px: barra lateral
   (filtros + lista) à esquerda e o mapa no resto do ecrã. */
.map-shell {
  display: grid;
  height: calc(100dvh - 4rem); /* abaixo do cabeçalho (h-16) */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 30%);
  grid-template-areas: "filters" "map" "list";
}
/* Dentro do app Android (/mapa?app=1) não há cabeçalho: o mapa ocupa o ecrã inteiro. */
.app-mode .map-shell { height: 100dvh; }
/* Celular: as categorias ficam numa só fila, que rola na horizontal. */
@media (max-width: 767px) {
  /* relative: as caixas invisíveis dos chips (sr-only, position: absolute) ficam presas na
     fila que rola; sem isto escapam para a direita e alargam a página inteira. */
  .map-chips #category-chips { position: relative; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .map-chips #category-chips::-webkit-scrollbar { display: none; }
  .map-chips #category-chips > * { flex: none; }
  .map-chips #category-chips span { padding-top: .25rem; padding-bottom: .25rem; font-size: .8125rem; }
}
@media (min-width: 768px) {
  /* Barra lateral: chips menores, para todas as categorias caberem sem barra de rolagem. */
  .map-chips #category-chips { gap: .375rem; }
  .map-chips #category-chips label > span { padding: .125rem .5rem; font-size: .8125rem; }
  .map-shell {
    grid-template-columns: 24rem minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "filters map" "list map";
  }
}
.map-filters { grid-area: filters; }
.map-list { grid-area: list; }
.map-canvas { grid-area: map; isolation: isolate; background: #e8e4dc; }

/* Tema escuro (CARTO Positron invertido), inspirado nos mapas de apps de transporte:
   quarteirões cinza-azulados (~#3d4049), ruas mais escuras, textos claros, com um pouco mais
   de contraste entre ruas e quarteirões. Os mosaicos são recoloridos em <canvas> pelo map.js
   (DarkTiles); o filtro CSS abaixo é só o recurso de um mosaico cujos pixels não se podem ler. */
.map-dark { background: #3a3d44; }
.map-dark .map-tile-css {
  filter: invert(1) brightness(2.2) contrast(.72) sepia(.3) hue-rotate(185deg) saturate(.9);
}
.map-dark .leaflet-bar a,
.map-dark .leaflet-bar a:hover {
  border-bottom-color: #3f3f46;
  background: #18181b;
  color: #f4f4f5;
}
.map-dark .leaflet-bar a:hover { color: #ff8000; }
.map-dark .leaflet-bar { border-color: rgba(0, 0, 0, .4); }
.map-dark .leaflet-control-attribution {
  background: rgba(24, 24, 27, .75);
  color: #a1a1aa;
}
.map-dark .leaflet-control-attribution a { color: #d4d4d8; }

/* Marcadores: o emoji da categoria num círculo branco com borda laranja. */
.map-pin {
  display: grid;
  place-items: center;
  border: 2px solid #ff8000;
  border-radius: 9999px;
  background: #fff;
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.map-pin:hover { transform: scale(1.12); }

/* Grupos de marcadores próximos (agrupamento). */
.map-cluster {
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 128, 0, .35);
  border-radius: 9999px;
  background: #ff8000;
  background-clip: padding-box;
  color: #000;
  font: 700 13px/1 Inter, ui-sans-serif, system-ui, sans-serif;
}
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow { transition: transform .3s ease-out, opacity .3s ease-in; }

/* Posição do usuário: ponto azul com pulsação. */
.map-me {
  border: 3px solid #fff;
  border-radius: 9999px;
  background: #2563eb;
  box-shadow: 0 0 0 0 rgba(37, 99, 235, .6);
  animation: map-pulse 2s infinite;
}
@keyframes map-pulse {
  70% { box-shadow: 0 0 0 14px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .map-me { animation: none; }
}

/* Balão do marcador. */
.map-popup { font: 13px/1.4 Inter, ui-sans-serif, system-ui, sans-serif; color: #18181b; }
.map-popup h3 { margin: 0 0 6px; font-size: 15px; font-weight: 700; line-height: 1.25; }
.map-popup p { margin: 2px 0; }
.map-popup .muted { color: #52525b; }
.map-popup .desc { margin-top: 6px; }
.map-popup .actions { display: flex; gap: 12px; margin-top: 8px; font-weight: 600; }
.map-popup .actions a { color: #e67300; }
.map-popup .desc {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
/* Celular: balão compacto, para caber no mapa sem tapar os controlos. */
@media (max-width: 767px) {
  .map-canvas .leaflet-popup-content { margin: 10px 14px; }
  .map-popup { font-size: 12px; line-height: 1.35; }
  .map-popup h3 { margin-bottom: 4px; font-size: 13px; }
  .map-popup .desc { margin-top: 4px; -webkit-line-clamp: 2; }
  .map-popup .actions { margin-top: 6px; }
}
