/* SNOWLINE map view. The card view answers "which mountain"; this answers "where is it,
   and what is between me and it". */

.map-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.map-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  z-index: 500;
}
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); letter-spacing: -0.02em; }
.map-nav { display: flex; gap: 12px; font-size: 0.86rem; }
.map-nav a { color: var(--text-dim); text-decoration: none; }
.map-nav a:hover { color: var(--accent); }
.map-nav .here { color: var(--accent); font-weight: 600; }

.layers { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.layers button {
  background: var(--bg-raised);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.layers button.on { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }
.layers button .n { opacity: 0.75; font-variant-numeric: tabular-nums; }

.map-status { font-size: 0.78rem; color: var(--text-faint); width: 100%; }

#map { flex: 1; background: var(--bg); }

/* Leaflet's own chrome, themed to match */
.leaflet-container { background: var(--bg); font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px var(--shadow);
}
.leaflet-popup-content { margin: 12px 14px; font-size: 0.86rem; line-height: 1.45; }
.leaflet-popup-content h4 { margin: 0 0 6px; font-size: 1rem; letter-spacing: -0.01em; }
.leaflet-popup-content .meta { color: var(--text-faint); font-size: 0.76rem; margin-bottom: 6px; }
.leaflet-popup-content .warn { color: var(--warn); font-weight: 600; }
.leaflet-popup-content a { color: var(--accent); }
.leaflet-popup-content img { width: 100%; border-radius: 6px; margin-top: 8px; display: block; }
.leaflet-control-attribution {
  background: rgba(0,0,0,0.55) !important; color: #cfd8e4 !important; font-size: 10px;
}
.leaflet-control-attribution a { color: #8fc6e6 !important; }
.leaflet-bar a { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.leaflet-bar a:hover { background: var(--bg-raised); }

/* Ski-area marker — a labelled dot, so the name is readable without clicking */
.ski-marker {
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap; font-size: 0.72rem; font-weight: 600;
  color: var(--text); text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}
.ski-marker::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0b1119; flex: none;
}
.ski-marker.closed::before { background: var(--bad); }

.cam-marker, .alert-marker, .pass-marker {
  width: 12px; height: 12px; border-radius: 3px;
  border: 2px solid #0b1119;
}
.cam-marker { background: #7dd3fc; }
.alert-marker { background: var(--bad); border-radius: 50%; }
.pass-marker { background: var(--warn); transform: rotate(45deg); }

.map-legend {
  position: absolute; bottom: 18px; left: 14px; z-index: 600;
  background: color-mix(in srgb, var(--bg-card) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px;
  max-width: 268px; font-size: 0.76rem;
  box-shadow: 0 4px 18px var(--shadow);
}
.map-legend strong { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); }
.map-legend ul { list-style: none; margin: 7px 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.map-legend li { display: flex; align-items: center; gap: 7px; color: var(--text-dim); }
.map-legend i { width: 13px; height: 13px; border-radius: 3px; display: inline-block; flex: none; border: 1px solid rgba(255,255,255,0.15); }
.legend-note { margin: 8px 0 0; color: var(--text-faint); font-size: 0.72rem; line-height: 1.4; }

@media (max-width: 700px) {
  .map-legend { display: none; }
  .layers { margin-left: 0; }
}

/* Zoomed out the names collide into mush; the dot still carries the location, and the
   marker's title attribute keeps the name available on hover. */
body.labels-off .ski-marker { font-size: 0; gap: 0; }
body.labels-off .ski-marker::before { width: 11px; height: 11px; }

/* One tile source, themed to match rather than a second provider with its own terms.
   OSM tiles are light; inverting and rotating the hue gives a dark basemap that keeps
   roads and terrain legible. Light-mode viewers get the tiles as drawn. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9) saturate(0.75);
  }
  /* Camera photos are content, not chrome — don't invert those. */
  :root:not([data-theme="light"]) .leaflet-popup-content img { filter: none; }
}
