/* JeffDavisEdu — map page only (loaded by pages/map.php). The map fills the
   space between the site header and footer; the details panel slides in from
   the right on wide screens and becomes a bottom sheet on phones. */
body.has-map .site-main { display: flex; flex-direction: column; padding-bottom: 0; min-height: calc(100vh - var(--header-h)); }

.topbar {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--tan-line);
}
.field { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--ink-2); }
.search-field { flex: 1 1 220px; }
.field input, .field select, .tl-controls select {
  min-height: 42px; padding: 6px 10px; font: inherit; color: var(--ink);
  border: 1px solid var(--tan); border-radius: 8px; background: var(--surface);
}
.topbar .btn-ghost { margin-left: auto; }

.btn-icon {
  min-height: 42px; min-width: 42px; padding: 6px; font: inherit; cursor: pointer; line-height: 1;
  border: 1px solid var(--tan-line); border-radius: 8px; background: var(--surface); color: var(--navy);
}
.btn-icon:hover { background: var(--navy-soft); }

.banner {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 16px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px;
  border-bottom: 1px solid #fcd9b6;
}
.banner-close { background: none; border: 0; font-size: 18px; min-width: 42px; min-height: 42px; margin: -6px 0; cursor: pointer; color: inherit; }

/* ---------- stage: map + panel + legend ---------- */
.stage { position: relative; flex: 1 1 auto; min-height: 420px; overflow: hidden; }
.map { position: absolute; inset: 0; background: #eef1f4; }

.legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 5;
  background: rgba(255, 255, 255, .95); border: 1px solid var(--tan-line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; max-width: 220px;
}
.legend-title { font-weight: 600; margin-bottom: 4px; color: var(--navy); }
.legend-row { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.swatch {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--ink); font-size: 11px; font-weight: 600;
}
.swatch.np { background: #fff; border-color: #8a8f98; color: #4b5563; font-size: 9px; font-weight: 500; }
.legend-ramp { height: 10px; border-radius: 3px; border: 1px solid var(--line); margin: 4px 0 2px; }
.legend-ramp-labels { display: flex; justify-content: space-between; color: var(--ink-2); }

.panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 400px; max-width: 100%; z-index: 6;
  background: var(--surface); border-left: 1px solid var(--tan-line); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transform: translateX(100%); visibility: hidden;
}
.panel.open { transform: none; visibility: visible; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--tan-line); background: var(--cream); }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-body { overflow: auto; padding: 12px; flex: 1 1 auto; font-size: 14px; }
.panel-body .facts { font-size: 13px; gap: 4px 12px; }
.panel-link { margin: 0 0 10px; font-weight: 600; }

.value-box { background: var(--cream); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px; }
.value-label { font-size: 12px; color: var(--ink-2); }
.value-box .value-big { font-size: 22px; margin: 2px 0; }
.source-link { font-size: 12px; }

.charts { display: flex; flex-direction: column; gap: 14px; }
.panel .chart-canvas { height: 150px; }
.panel .chart-title { font-size: 13px; }
.panel .chart-cap { font-size: 11px; }

/* ---------- timeline ---------- */
.timeline {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px 14px;
  padding: 8px 16px; background: var(--surface); border-top: 1px solid var(--tan-line);
}
.tl-controls { display: flex; gap: 6px; align-items: center; }
.tl-controls select { min-height: 42px; }
input[type=range] { width: 100%; min-height: 42px; margin: 0; accent-color: var(--navy); }
.tl-label { display: flex; flex-direction: column; min-width: 120px; text-align: right; }
.tl-label strong { color: var(--navy); }
.tl-note { font-size: 12px; color: var(--ink-2); max-width: 320px; }

/* ---------- about modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(17, 24, 39, .5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: var(--surface); border-radius: var(--radius); max-width: 680px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--tan-line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 12px 16px; overflow: auto; }
.modal-body h3 { font-size: 15px; margin: 14px 0 6px; }
.modal-body ul { padding-left: 20px; margin: 0; }

.maplibregl-popup-content { font: 13px/1.3 system-ui, sans-serif; padding: 6px 10px; border-radius: 6px; }

/* ---------- mobile: panel becomes a bottom sheet ---------- */
@media (max-width: 720px) {
  .topbar { padding: 6px 12px; gap: 8px 10px; }
  .field { flex: 1 1 120px; }
  .search-field { flex-basis: 100%; }
  .topbar .btn-ghost { display: none; }   /* the About page link in the footer covers it */
  .stage { min-height: 50vh; }
  .panel {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 60vh; z-index: 40;
    border-left: 0; border-top: 1px solid var(--tan-line); border-radius: 12px 12px 0 0;
    transform: translateY(100%);
  }
  .panel.open { transform: none; }
  .legend { left: 8px; right: 8px; bottom: 8px; max-width: none; font-size: 11px; padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: center; }
  .legend-title { width: 100%; margin-bottom: 2px; }
  .legend-row { gap: 5px; }
  .legend-ramp, .legend-ramp-labels { width: 100%; }
  body.panel-open .legend { display: none; }
  .timeline { grid-template-columns: 1fr auto; padding: 6px 12px; }
  .tl-controls { order: 2; }
  .tl-label { order: 3; text-align: left; }
  input[type=range] { order: 1; grid-column: 1 / -1; }
  .tl-note { max-width: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .panel { transition: transform .2s ease, visibility .2s; }
}

@media print {
  .topbar, .timeline, .banner, .modal, .maplibregl-ctrl, .panel-close, .btn-icon { display: none !important; }
  .stage { min-height: 60vh; }
  .panel { position: static; transform: none; visibility: visible; width: auto; box-shadow: none; border: 0; }
}

/* Board districts toggle */
.field[hidden] { display: none; }
.field-check { flex-direction: row; align-items: center; gap: 6px; align-self: flex-end; padding-bottom: 6px; }
.field-check input { width: auto; }

/* ---------- 2026-11: bigger markers, district colour key, credit, phone layout ---------- */
.swatch.na { width: 14px; height: 14px; background: #e5e7eb; border-color: #b5bac4; margin: 0 4px; }
.district-legend { left: auto; right: 12px; bottom: 36px; max-width: 300px; max-height: 46vh; overflow: auto; }
.district-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.district-key { display: flex; align-items: center; gap: 5px; min-height: 22px; text-decoration: none; color: var(--ink); font-size: 11.5px; min-width: 0; }
.district-key:hover .district-no { text-decoration: underline; }
.district-sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .25); flex: none; }
.district-no { font-weight: 700; color: var(--navy); flex: none; }
.district-member { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-foot { margin: 6px 0 0; font-size: 10.5px; color: var(--muted); line-height: 1.3; }
.map-credit { position: absolute; right: 12px; bottom: 12px; z-index: 5; background: rgba(255, 255, 255, .95); border: 1px solid var(--tan-line); border-radius: 999px; padding: 3px 10px; font-size: 11.5px; color: var(--ink-2); text-decoration: none; box-shadow: var(--shadow); }
.map-credit strong { color: var(--navy); }
.map-credit:hover { background: #fff; color: var(--navy); }
body.panel-open .map-credit, body.panel-open .district-legend { right: 412px; }
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib { margin-right: 0; margin-bottom: 36px; }
@media (max-width: 720px) {
  body.has-map .site-main { min-height: 0; }
  .stage { min-height: 260px; flex: none; }   /* height set by js/app.js so the timeline stays in view */
  .topbar { padding: 6px 10px; gap: 6px 8px; }
  .field input, .field select { min-height: 38px; padding: 4px 8px; font-size: 14px; }
  .search-field { flex-basis: 100%; }
  .field { flex: 1 1 100px; }
  .field-check { flex: 1 1 auto; padding-bottom: 8px; }
  .legend { max-width: 46%; right: auto; }
  .district-legend { left: auto; right: 8px; bottom: 34px; max-width: 52%; max-height: 40vh; font-size: 10.5px; display: block; }
  .district-grid { grid-template-columns: 1fr; }
  .district-member { display: none; }
  .map-credit { bottom: 8px; right: 8px; font-size: 10.5px; padding: 2px 8px; }
  body.panel-open .map-credit, body.panel-open .district-legend { right: 8px; }
  body.panel-open .district-legend, body.panel-open .map-credit { display: none; }
  .timeline { grid-template-columns: auto 1fr; gap: 4px 10px; padding: 6px 10px; }
  .tl-controls { order: 1; }
  .tl-label { order: 2; text-align: right; min-width: 0; }
  input[type=range] { order: 3; grid-column: 1 / -1; min-height: 34px; }
  .tl-note { display: none; }
  .btn-icon { min-height: 38px; min-width: 38px; }
  .tl-controls select { min-height: 38px; }
}

/* ---------- 2026-11: collapsible legends, split-precinct stripes ---------- */
.legend-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; margin: 0 0 4px; padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--navy); text-align: left; cursor: pointer; }
.legend-toggle:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 4px; }
.legend-chev { flex: none; font-size: 12px; transition: transform .15s; }
.legend.collapsed .legend-toggle { margin: 0; }
.legend.collapsed .legend-chev { transform: rotate(-90deg); }
.legend.collapsed .legend-body { display: none; }
.split-sw { background: repeating-linear-gradient(45deg, #e6194b 0 4px, #4363d8 4px 8px); }
.district-key-split { grid-column: 1 / -1; margin-top: 4px; align-items: flex-start; font-size: 11px; color: var(--ink-2); }
@media (max-width: 720px) {
  .legend { padding: 6px 10px; }
  .legend.collapsed { max-width: none; }
  .district-legend { display: block; bottom: 36px; max-height: 50vh; }
  .district-legend[hidden] { display: none; }
  .district-legend:not(.collapsed) { max-width: 62%; }
  .district-legend .district-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- school tags (DOM markers, js/app.js updateMarkers/declutter) ----------
   A fixed-size, labelled tag per school: value + the school's short name. Crowded tags are stacked by the
   script, each with a line back to the dot on the school's real location. */
.smk { width: 0; height: 0; }   /* positioned by MapLibre (.maplibregl-marker is absolute) */
.smk-pill {
  position: absolute; left: 0; top: 0; display: inline-flex; align-items: stretch; white-space: nowrap;
  min-height: 28px; padding: 0; margin: 0; font: 600 13px/1 var(--font, system-ui, sans-serif); cursor: pointer;
  background: #fff; border: 1.5px solid #1f2937; border-radius: 999px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(15, 30, 46, .35); color: #1f2937;
}
.smk-val { display: inline-flex; align-items: center; padding: 0 8px; min-width: 30px; justify-content: center; border-right: 1.5px solid #1f2937; font-variant-numeric: tabular-nums; }
.smk-name { display: inline-flex; align-items: center; padding: 0 8px 0 6px; background: #fff; color: #1f2937; font-size: 12px; letter-spacing: .02em; }
.smk-pill:hover, .smk-pill:focus-visible { outline: 3px solid #d97706; outline-offset: 1px; }
.smk-pill.is-selected { outline: 3px solid #d97706; outline-offset: 1px; box-shadow: 0 2px 8px rgba(15, 30, 46, .5); }
.smk-pill.is-np .smk-val { font-weight: 500; font-style: italic; color: #4b5563 !important; background: #fff !important; }
.smk-pill.is-na { opacity: .7; border-color: #b5bac4; box-shadow: none; min-height: 24px; font-size: 11px; }
.smk-pill.is-na .smk-val { border-right-color: #b5bac4; background: #e5e7eb !important; color: #6b7280 !important; }
.smk-line { position: absolute; left: 0; top: 0; height: 1.5px; width: 0; background: #1f2937; transform-origin: 0 50%; opacity: .7; pointer-events: none; }
@media (max-width: 720px), (pointer: coarse) {
  .smk-pill { min-height: 32px; font-size: 14px; }
  .smk-name { font-size: 12.5px; }
  .smk-pill.is-na { min-height: 26px; }
}
/* School Board districts: what the extra key items look like, the shading slider, the school panel box */
.proposed-sw { background: repeating-linear-gradient(90deg, #111827 0 5px, transparent 5px 8px) center / 100% 2px no-repeat; border: 0; }
.undecided-sw { background: repeating-linear-gradient(45deg, #4b5563 0 2px, #f3f4f6 2px 5px); }
.district-opacity { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 11px; color: var(--ink-2); }
.district-opacity input { flex: 1; min-width: 80px; }
.school-district { border: 1px solid var(--tan-line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; background: #fff; }
.school-district p { margin: 2px 0; }
.popup-rule { border: 0; border-top: 1px solid var(--tan-line); margin: 8px 0; }
/* popups sit above the school tags (which use z-index 1-3) */
.maplibregl-popup { z-index: 8; }
.jde-popup .maplibregl-popup-content { max-height: 46vh; overflow: auto; padding: 10px 12px; font-size: 13px; line-height: 1.35; }
