/* The map and everything drawn over it. Stream C. Colours come from
   tokens.css only. The --cover-* variables are set by views/map.js: how far
   the panel, sheet and runway reach into the map from each edge, so controls
   and chips sit in the part of the map you can actually see. */

#map { --cover-t: 0px; --cover-r: 0px; --cover-b: 0px; --cover-l: 0px; overflow: hidden; }
.map-canvas { position: absolute; inset: 0; background: var(--ground); }
.map-canvas .maplibregl-canvas { outline: none; }
#map.picking .maplibregl-canvas { cursor: crosshair !important; }

/* MapLibre's own controls, moved into the visible rectangle and sized for fingers. */
.map-canvas .maplibregl-ctrl-top-right { top: var(--cover-t); right: var(--cover-r); }
.map-canvas .maplibregl-ctrl-bottom-right { bottom: var(--cover-b); right: var(--cover-r); }
.map-canvas .maplibregl-ctrl-bottom-left { bottom: var(--cover-b); left: var(--cover-l); }
.map-canvas .maplibregl-ctrl-group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.map-canvas .maplibregl-ctrl-group button { width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 0; background-color: transparent; }
.map-canvas .maplibregl-ctrl-group button + button { border-top: 1px solid var(--line); }
.map-canvas .maplibregl-ctrl-icon { filter: none; }
:root[data-theme="dark"] .map-canvas .maplibregl-ctrl-icon { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .map-canvas .maplibregl-ctrl-icon { filter: invert(1); } }
.map-canvas .maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--muted); font: 400 11px/1.4 var(--font-sans); border-radius: 8px 0 0 0; }
.map-canvas .maplibregl-ctrl-attrib a { color: var(--muted); }
.map-canvas .maplibregl-ctrl-attrib.maplibregl-compact { min-height: 44px; min-width: 44px; border-radius: var(--radius) 0 0 0; }
.map-canvas .maplibregl-ctrl-attrib-button { width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; background-color: transparent; background-repeat: no-repeat; background-position: center; }
.map-canvas .maplibregl-ctrl-attrib-inner { line-height: 44px; }
@media (max-width: 899px) {
  .map-canvas .maplibregl-ctrl-top-right { display: none; }
}

/* Chips and notes in the corners. */
.map-ui {
  position: absolute; z-index: 3; pointer-events: none; display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  top: var(--cover-t); right: var(--cover-r); bottom: var(--cover-b); left: var(--cover-l);
  padding: 8px max(8px, env(safe-area-inset-right, 0px)) 8px max(8px, env(safe-area-inset-left, 0px));
}
.map-ui > * { pointer-events: auto; }
.ui-tl { display: flex; flex-wrap: wrap; gap: 8px; max-width: 100%; }
.ui-bl { position: absolute; left: 8px; bottom: 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; max-width: calc(100% - 64px); }
.chip {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: .85rem; line-height: 1.2;
}
.chip[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.note { color: var(--muted); box-shadow: none; background: color-mix(in srgb, var(--surface) 88%, transparent); }
.search-area { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.search-area[hidden] { display: none; }

.legend { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); font-size: .8rem; }
.legend summary { min-height: 44px; display: flex; align-items: center; padding: 0 12px; cursor: pointer; }
.legend-list { list-style: none; margin: 0; padding: 0 12px 10px; display: grid; gap: 6px; }
.legend-list li { display: flex; align-items: center; gap: 8px; }
.ui-bl select { width: auto; max-width: 100%; box-shadow: var(--shadow); }
/* The one-button version of the legend and lens select is for phones. */
.chip.pins { display: none; }
.legend-body { display: grid; gap: 6px; }
.legend-body .legend-list { padding: 0; }
.pins-lens { display: block; margin-bottom: 10px; }
.pins-lens select { width: 100%; }

/* Phone: one row of chips that scrolls sideways inside itself (about 52 px
   tall), so the map keeps its pins. The no-location note is in the list and
   the legend and lens are the "Pins" chip. */
@media (max-width: 899px) {
  .ui-tl { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; max-width: calc(100% + 8px); margin-right: -8px; padding: 4px 8px 4px 0; }
  .ui-tl::-webkit-scrollbar { display: none; }
  .ui-tl > .chip { flex: none; white-space: nowrap; box-shadow: var(--shadow-sm); }
  .chip.note { display: none; }
  .chip.pins { display: inline-flex; }
  .ui-bl { display: none; }
}
@media (min-width: 900px) { .ui-bl select { font-size: .85rem; } }

.sw {
  --sw: var(--text); flex: none; width: 18px; height: 18px; display: inline-grid; place-items: center; box-sizing: border-box;
  background: var(--sw); color: var(--surface); border: 2px solid var(--sw); font: 600 11px/1 var(--font-sans);
}
.sw-circle { border-radius: 50%; }
.sw-square { border-radius: 3px; }
.sw-diamond { transform: rotate(45deg) scale(.78); }
.sw-triangle { clip-path: polygon(50% 0, 100% 100%, 0 100%); border: 0; width: 20px; }
.sw.ring { background: var(--surface); color: var(--sw); }
.sw.dashed { border-style: dashed; }
.sw.hybrid { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw); }
.pulse-sw { --sw: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }

/* The cluster bubble as it is in the legend. */
.sw-cluster {
  flex: none; width: 34px; height: 34px; box-sizing: border-box; border-radius: 50%; border: 2px solid var(--accent); background: var(--surface);
  display: grid; place-content: center; text-align: center; gap: 1px;
}
.sw-cluster .cluster-n { font-size: 12px; }
.sw-cluster .cluster-d { font-size: 10px; }

/* Cluster bubbles. */
.cluster-wrap { line-height: 1; }
.cluster {
  min-height: 0; padding: 0; border-radius: 50%; border: 2px solid var(--accent); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); display: grid; place-content: center; text-align: center; gap: 1px;
}
.cluster:hover { background: var(--accent-tint); }
.cluster-n { font: 500 15px/1 var(--font-mono); }
.cluster-d { font: 500 11px/1 var(--font-mono); color: var(--muted); }

/* Home and range. */
.home-marker { display: flex; flex-direction: column; align-items: center; gap: 2px; pointer-events: none; }
.home-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow); border: 2px solid var(--surface); }
.home-marker:not(.primary) .home-icon { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.home-label { font: 600 11px/1.2 var(--font-sans); padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, var(--surface) 90%, transparent); color: var(--text); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.band-label { font: 500 11px/1.3 var(--font-mono); padding: 1px 6px; border-radius: 6px; color: var(--accent); background: color-mix(in srgb, var(--surface) 88%, transparent); pointer-events: none; white-space: nowrap; }
.band-label.main { font-weight: 500; border: 1px solid var(--accent); }

/* Tooltip, cluster menu, banner, failure. */
.map-tip {
  position: absolute; z-index: 5; max-width: 280px; padding: 8px 10px; border-radius: 8px; pointer-events: none;
  background: var(--text); color: var(--surface); box-shadow: var(--shadow); font-size: .82rem;
}
.map-tip[hidden], .map-menu[hidden], .map-banner[hidden] { display: none; }
.tip-name { font-weight: 600; }
.map-menu {
  position: absolute; z-index: 6; width: min(300px, calc(100% - 16px)); max-height: 60%; overflow: auto; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.map-menu-title { font-weight: 600; padding: 4px 6px 6px; }
.map-menu ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.map-menu li button { width: 100%; display: grid; text-align: left; justify-content: stretch; padding: 6px 8px; border-color: transparent; background: transparent; }
.map-menu li button:hover { background: var(--accent-tint); }
.mm-name { font-weight: 600; }
.mm-sub { font-size: .8rem; }
.map-menu-note { padding: 4px 6px; }
.map-menu-close { width: 100%; margin-top: 6px; }
.map-banner {
  position: absolute; z-index: 4; left: calc(var(--cover-l) + 8px); right: calc(var(--cover-r) + 8px); bottom: calc(var(--cover-b) + 64px);
  max-width: 520px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--soon); border-radius: var(--radius); box-shadow: var(--shadow); font-size: .85rem;
}
.map-banner button { min-height: 44px; }
.map-failed { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; color: var(--text); }
