/* School Money — map.css (unit C1, the /map/ explorer). Uses app.css tokens only; no palette of its own.
   Works from 360px wide with no horizontal scroll: only the table scrolls sideways, inside .mx-scroll. */

/* ---------- controls ---------- */
.mx-controls { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; margin: 0 0 14px; min-width: 0; }
.mx-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 200px; }
.mx-field > label, .mx-field > legend { font-weight: 600; font-size: .9rem; }
.mx-controls fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.mx-controls select, .mx-controls input[type="search"] { width: 100%; max-width: 100%; min-height: var(--tap); padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--card); }
.mx-range { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mx-range input[type="range"] { flex: 1 1 auto; min-width: 0; min-height: var(--tap); accent-color: var(--accent); }
.mx-range output { flex: none; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 4.5em; }
.mx-geo { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; }
.mx-geo legend { width: 100%; margin-bottom: 4px; }
.mx-check { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); cursor: pointer; }
.mx-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.mx-search { position: relative; flex: 2 1 260px; }
.mx-filters { flex: 1 1 100%; min-width: 0; }
.mx-filters summary { cursor: pointer; color: var(--accent); min-height: var(--tap); display: flex; align-items: center; font-weight: 600; }
.mx-group { display: flex; flex-wrap: wrap; gap: 0 16px; margin: 6px 0 !important; }
.mx-group legend { font-weight: 600; font-size: .9rem; width: 100%; }

/* ---------- map and card ---------- */
.mx-stage { position: relative; min-width: 0; }
/* isolation keeps Leaflet's pane z-indexes (400-1000) inside the map, under the header and app.js's pin bar. */
.mx-map { height: min(70vh, 640px); min-height: 320px; width: 100%; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card-2); overflow: hidden; isolation: isolate; }
.mx-map.mx-off { height: auto; min-height: 0; padding: 16px; }
.mx-map:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.mx-note { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--card); }
.mx-map .leaflet-bar a { width: var(--tap); height: var(--tap); line-height: var(--tap); font-size: 20px; background: var(--card); color: var(--ink);
  border-bottom-color: var(--line); }
.mx-map .leaflet-bar a:hover { background: var(--card-2); }
.mx-map .leaflet-bar { border-color: var(--line-strong); box-shadow: var(--shadow); }
.mx-map .leaflet-control-attribution { background: var(--card); color: var(--ink-2); }
.mx-map .leaflet-control-attribution a { color: var(--accent); }
.mx-map .leaflet-tooltip { background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.mx-tip { display: flex; flex-direction: column; gap: 2px; font: .9rem/1.35 var(--font); max-width: 240px; white-space: normal; }

.mx-card { position: absolute; z-index: 70; top: 12px; right: 12px; width: min(360px, calc(100% - 24px)); max-height: calc(100% - 24px);
  overflow-y: auto; padding: 14px 16px 16px; background: var(--card); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); }
.mx-card[hidden] { display: none; }
.mx-close { position: absolute; top: 6px; right: 6px; width: var(--tap); height: var(--tap); border: 0; border-radius: 999px;
  background: transparent; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--ink-2); }
.mx-close:hover { background: var(--card-2); color: var(--ink); }
.mx-card-title { font-size: 1.15rem; margin: 2px 44px 8px 0; }
.mx-card-title:focus { outline: none; }
.mx-card-title:focus-visible { outline: 3px solid var(--accent); }
.mx-lines { margin: 10px 0; display: grid; gap: 2px 0; }
.mx-lines dt { font-size: .82rem; color: var(--ink-2); margin-top: 6px; }
.mx-lines dd { margin: 0; font-variant-numeric: tabular-nums; }
svg.chart.mx-spark { width: 100%; max-width: 240px; height: 56px; margin: 6px 0 2px; }
.mx-spark-cap { margin: 0 0 8px; }
.mx-why-card { margin: 10px 0; font-size: .92rem; }
.mx-why-card summary { cursor: pointer; color: var(--accent); min-height: var(--tap); display: flex; align-items: center; font-weight: 600; }
.mx-why-card p { margin: 6px 0; }
.mx-actions { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 12px; }
.mx-actions a { display: inline-flex; align-items: center; min-height: var(--tap); }
.mx-actions .mx-open { font-weight: 700; }
.mx-actions button.pin { min-height: var(--tap); }

@media (max-width: 600px) {
  .mx-map { height: 55vh; min-height: 280px; }
  .mx-card { position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 60vh; overflow-y: auto;
    border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; padding-bottom: max(16px, env(safe-area-inset-bottom));
    animation: mx-rise .18s ease-out; }
}
@keyframes mx-rise { from { transform: translateY(24px); } to { transform: none; } }

/* ---------- legend ---------- */
.mx-legend { margin: 12px 0 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); min-width: 0; }
.mx-legend-title { font-weight: 700; margin: 0 0 6px; }
.mx-key { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.mx-key li { display: flex; align-items: center; gap: 8px; min-height: 28px; font-variant-numeric: tabular-nums; }
.mx-sw { flex: none; width: 22px; height: 16px; border-radius: 3px; border: 1px solid var(--line-strong); }
.mx-sw-none { background: repeating-linear-gradient(45deg, var(--card) 0 3px, var(--ink-3) 3px 5px); }
.mx-dot { width: 14px; height: 14px; border-radius: 999px; }
.mx-dot-none { background: var(--card); border: 2px solid var(--ink-3); }
.mx-icon { width: 1em; text-align: center; }
.mx-eng { font-weight: 700; color: var(--ink); }
.mx-dotkey { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.mx-dothead { margin: 0 0 4px; font-weight: 600; }

/* ---------- context and table ---------- */
.mx-why { margin: 18px 0; padding: 4px 16px 6px; border-left: 4px solid var(--accent); background: var(--card); border-radius: var(--radius-s); }
.mx-why h2 { font-size: 1.1rem; margin: .8em 0 .4em; }
.mx-tablebox { min-width: 0; }
.mx-scroll { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.mx-scroll table { min-width: 320px; }
.mx-scroll caption { text-align: left; caption-side: top; color: var(--ink-2); font-size: .9rem; padding: 0 0 8px; }
.mx-scroll th[scope="row"] { text-align: left; font-weight: 600; }
.mx-show { margin-left: 10px; min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--card); font-size: .82rem; font-weight: 600; cursor: pointer; }
.mx-show:hover { background: var(--accent-soft); border-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .mx-card { animation: none; }
  .mx-scroll { scroll-behavior: auto; }
}
