/* hexdb.io live map (/map) */
html:has(.hx-map-page), body:has(.hx-map-page) { height: 100%; overflow: hidden; }
body:has(.hx-map-page) { display: flex; flex-direction: column; }
.hx-map-page { position: relative; flex: 1 1 auto; min-height: 0; }
.hx-map { position: absolute; inset: 0; background: #0d1424; }

.hx-map-page .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* floating boxes share one look */
.hx-map-status, .hx-map-error, .hx-panel, .hx-legend {
  position: absolute; z-index: 2;
  background: var(--hx-surface);
  border: 1px solid var(--hx-border);
  border-radius: var(--hx-radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.hx-map-status {
  top: 12px; left: 12px;
  display: flex; align-items: center; gap: 0.3rem;
  padding: 0.35rem 0.7rem; font-size: 0.85rem; color: var(--hx-muted);
}
.hx-map-status strong { color: #fff; font-weight: 600; }
.hx-map-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--hx-green); margin-right: 0.25rem; }
.hx-map-status .sep { margin: 0 0.2rem; }
.hx-map-status .stale { color: #fbbf24; }
.hx-map-error {
  top: 54px; left: 12px; padding: 0.35rem 0.7rem; font-size: 0.85rem;
  color: #fca5a5; border-color: #7f1d1d;
}

/* ---- selected aircraft panel ---- */
.hx-panel {
  top: 54px; left: 12px; width: 300px;
  max-height: calc(100% - 54px - 120px); overflow-y: auto;
  padding: 0.9rem 1rem 1rem; font-size: 0.875rem;
}
.hx-panel-close {
  position: absolute; top: 8px; right: 8px;
  border: 0; background: none; color: var(--hx-muted); padding: 4px 6px; border-radius: 4px;
}
.hx-panel-close:hover { color: #fff; background: var(--hx-surface-2); }
.hx-p-callsign { font-size: 1.35rem; font-weight: 700; color: #fff; font-family: var(--hx-mono); padding-right: 2rem; }
.hx-p-reg { color: var(--hx-text); font-weight: 600; }
.hx-p-tc { font-family: var(--hx-mono); font-size: 0.8rem; color: var(--hx-accent); margin-left: 0.25rem; }
.hx-p-type { color: var(--hx-text); }
.hx-p-sub { color: var(--hx-muted); font-size: 0.8rem; }
.hx-p-lost { display: none; color: #fbbf24; font-size: 0.8rem; margin-top: 0.25rem; }
.hx-panel.lost .hx-p-lost { display: block; }
.hx-p-photo { margin-top: 0.75rem; }
.hx-p-photo img { width: 100%; border-radius: 4px; border: 1px solid var(--hx-border); display: block; }
.hx-p-route { margin-top: 0.75rem; font-family: var(--hx-mono); font-weight: 600; color: #fff; }
.hx-p-route:empty { display: none; }
.hx-p-route .hx-p-sub { font-family: "Inter", system-ui, sans-serif; font-weight: 400; }
.hx-p-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 1rem;
  margin: 0.9rem 0 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--hx-border);
}
.hx-p-grid .wide { grid-column: 1 / -1; }
.hx-p-grid dt { font-size: 0.72rem; font-weight: 500; color: var(--hx-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.hx-p-grid dd { margin: 0; color: #fff; display: flex; align-items: center; gap: 0.4rem; }
.hx-p-link { font-size: 0.85rem; }

/* ---- key ---- */
.hx-legend {
  left: 12px; right: 12px; bottom: 30px;
  margin: 0 auto; max-width: 1040px;
  padding: 0.6rem 0.9rem 0.7rem;
}
.hx-legend-toggle {
  position: absolute; top: -1px; right: 12px; transform: translateY(-100%);
  display: flex; align-items: center; gap: 0.35rem;
  border: 1px solid var(--hx-border); border-bottom: 0; border-radius: 4px 4px 0 0;
  background: var(--hx-surface); color: var(--hx-muted); font-size: 0.78rem; padding: 0.2rem 0.6rem;
}
.hx-legend-toggle:hover { color: #fff; }
.hx-legend.collapsed { padding: 0; border: 0; background: none; box-shadow: none; }
.hx-legend.collapsed .hx-legend-toggle { border-bottom: 1px solid var(--hx-border); border-radius: 4px; transform: none; top: auto; bottom: 0; }
.hx-legend.collapsed .hx-legend-body { display: none; }
.hx-legend.collapsed .hx-legend-toggle i { transform: rotate(180deg); }
.hx-legend-body { display: flex; gap: 1.5rem; align-items: flex-start; }
.hx-legend-title { font-size: 0.72rem; font-weight: 600; color: var(--hx-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.35rem; }
.hx-legend-alt { flex: 1 1 340px; min-width: 0; }
.hx-alt-row { display: flex; align-items: flex-start; gap: 0.75rem; }
.hx-ground { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--hx-text); white-space: nowrap; line-height: 10px; }
.hx-alt-scale { flex: 1; min-width: 0; }
.hx-alt-bar { height: 10px; border-radius: 2px; }
.hx-alt-ticks { display: flex; justify-content: space-between; margin-top: 3px; font-size: 0.72rem; color: var(--hx-muted); font-family: var(--hx-mono); }
.hx-legend-icons { flex: 1.6 1 0; min-width: 0; }
.hx-icon-key { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; }
.hx-key { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; color: var(--hx-text); white-space: nowrap; }
.hx-key svg { fill: #cbd5e1; stroke: #050810; stroke-width: 1; stroke-linejoin: round; paint-order: stroke; }

/* MapLibre controls in the site's colours */
.hx-map-page .maplibregl-ctrl-group { background: var(--hx-surface); border: 1px solid var(--hx-border); box-shadow: none; }
.hx-map-page .maplibregl-ctrl-group button + button { border-top-color: var(--hx-border); }
.hx-map-page .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) brightness(0.85); }
.hx-map-page .maplibregl-ctrl-group button:hover { background-color: var(--hx-surface-2); }
.hx-map-page .maplibregl-ctrl-attrib { background: rgba(11, 17, 32, 0.8); color: var(--hx-muted); }
.hx-map-page .maplibregl-ctrl-attrib a { color: var(--hx-muted); }
.hx-map-page .maplibregl-ctrl-attrib-button { filter: invert(1); }
.hx-map-page .maplibregl-ctrl-bottom-right { bottom: 0; }

@media (max-width: 767px) {
  .hx-legend { left: 8px; right: 8px; bottom: 8px; padding: 0.5rem 0.7rem 0.6rem; }
  .hx-legend-body { flex-direction: column; gap: 0.6rem; }
  .hx-legend-alt, .hx-legend-icons { flex: none; width: 100%; }
  .hx-icon-key { gap: 0.25rem 0.7rem; }
  .hx-map-status { top: 8px; left: 8px; }
  .hx-panel {
    top: auto; left: 8px; right: 8px; bottom: 8px; width: auto;
    max-height: 55%; z-index: 3;
  }
}
