/* School-board guide. Light tool, same navy and gold as the Live Free Index. */

.guide {
  --navy: #0b1f3a;
  --navy2: #13294b;
  --ink: #13233d;
  --mut: #5d6b80;
  --line: #e3e8ef;
  --acc: #e8a33d;
  --bg: #f7f8fb;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

html:has(body.page-guide) {
  height: 100dvh;
  height: 100svh;
  overflow: hidden;
  background-image: none;
  background-color: #f7f8fb;
}
body.page-guide::before {
  content: none !important;
  display: none !important;
}
body.page-guide {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  height: 100svh;
  min-height: 0;
  overflow: hidden;
  background: #f7f8fb;
  color: var(--ink, #13233d);
}

.guide {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.guide-banner {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px 16px;
}
.guide-banner-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 28px;
}
.guide .kicker {
  flex: 1 0 100%;
  margin: 0;
  font: 700 12px/1 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--acc);
}
.guide-banner h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}
.guide .dek {
  margin: 0;
  flex: 1 1 280px;
  max-width: 640px;
  color: #c9d3e3;
  font-size: 16px;
  line-height: 1.4;
}
.guide .banner-map {
  margin-left: auto;
  align-self: center;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 2px solid var(--acc);
  padding: 6px 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.guide .banner-map:hover { color: var(--acc); }

.guide-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(440px, 560px);
  grid-template-rows: minmax(0, 1fr);
}

.guide-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #e7eef6;
}
#guide-map {
  position: absolute;
  inset: 0;
}
#guide-map .maplibregl-ctrl-attrib {
  font-size: 11px;
}
.hover-name {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 2;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(11, 31, 58, 0.92);
  color: #fff;
  font: 600 13px/1.2 "IBM Plex Sans", system-ui, sans-serif;
  pointer-events: none;
}
.hover-name:empty { display: none; }
.guide-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  max-width: calc(100% - 24px);
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(11, 31, 58, 0.08);
  font: 13px/1.3 "IBM Plex Sans", system-ui, sans-serif;
  color: var(--ink);
}
.key-toggle { display: none; }
.key-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.guide-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid #fff;
  box-shadow: 0 0 0 1px #c5d0de;
}
.swatch.people { background: #8eadd4; }
.swatch.plain { background: #d5e0ee; }
.swatch.selected { background: #0b1f3a; }

.guide-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(11, 31, 58, 0.04);
}
.sheet-handle {
  display: none;
}
.panel-tools {
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.find-label {
  display: block;
  margin: 0 0 6px;
  font: 700 11px/1 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mut);
}
.guide input[type="text"],
.guide select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: 16px/1.3 "IBM Plex Sans", system-ui, sans-serif;
}
.guide select { margin-top: 10px; }
.tool-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
#locate {
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font: 700 14px/1 "IBM Plex Sans", system-ui, sans-serif;
  cursor: pointer;
}
#locate:hover { background: var(--navy2); }
#locate-status {
  min-height: 1.2em;
  margin: 8px 0 0;
  color: var(--mut);
  font-size: 13px;
}
#town-matches {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  max-height: 220px;
  overflow: auto;
}
#town-matches[hidden] { display: none; }
#town-matches li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
}
#town-matches li:hover,
#town-matches li[aria-selected="true"] { background: #f3f6fb; }

.panel-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 18px 28px;
}
.guide-panel h2 {
  margin: 12px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  line-height: 1.1;
  color: var(--navy);
}
.guide-panel h3 {
  margin: 18px 0 8px;
  font: 700 16px/1.3 "IBM Plex Sans", system-ui, sans-serif;
  color: var(--navy);
}
.guide-panel p,
.guide-panel li {
  font: 15.5px/1.45 "IBM Plex Sans", system-ui, sans-serif;
  color: #243044;
}
.guide-panel .lede-block p,
.guide-copy > p { margin: 0 0 10px; }
.people { margin: 0; padding: 0 0 0 18px; }
.people li { margin: 0 0 8px; }
.steps, .help { list-style: none; margin: 0; padding: 0; }
.step, .help li {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.help { counter-reset: help; }
.help li { counter-increment: help; }
.help li::before {
  content: counter(help);
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e7eef8;
  color: var(--navy);
  font: 700 13px/32px "IBM Plex Sans", system-ui, sans-serif;
  text-align: center;
}
.help li h3,
.help li p { grid-column: 2; }
.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font: 700 13px/32px "IBM Plex Sans", system-ui, sans-serif;
  text-align: center;
}
.when {
  margin: 2px 0 2px;
  font: 700 12px/1.3 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--acc);
}
.flag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff6df;
  color: #8a5a12;
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 11px;
}
.step h3, .help h3 { margin: 0 0 4px; font-size: 16px; }
.step p, .help p { margin: 0; }
.step-sources { margin-top: 6px; font-size: 13px; line-height: 1.45; }
.step-sources a { color: var(--navy2); font-weight: 600; }
.step-sources a, .fact-sep { overflow-wrap: anywhere; }
.contact {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4f7fb;
}
.contact p { margin: 0 0 6px; }
.contact-links a, .map-jump a, .source-line {
  font-size: 14px;
}
.contact-links a, .map-jump a {
  color: var(--navy2);
  font-weight: 700;
}
.source-line { color: var(--mut); font-size: 13px; }
.map-jump { margin-top: 12px; }
.newsletter-line {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.4;
}

.guide :focus-visible {
  outline: 2px solid #e0b84e;
  outline-offset: 2px;
}

@media (max-width: 900px) {
  body.page-guide {
    height: 100dvh;
    height: 100svh;
    overflow-x: hidden;
  }
  .guide-banner { padding: 10px 16px 8px; }
  .guide-banner-inner {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px 12px;
  }
  .guide .kicker { display: none; }
  .guide-banner h1 {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 22px;
    line-height: 1.15;
  }
  .guide .dek { display: none; }
  .guide .banner-map {
    flex: 0 0 auto;
    margin: 0;
    min-height: 44px;
    font-size: 16px;
  }
  .guide-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .guide-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
  }
  .guide-legend {
    top: 8px;
    left: 8px;
    right: auto;
    bottom: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    max-width: calc(100% - 68px);
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .key-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--navy);
    font: 700 15px/1 "IBM Plex Sans", system-ui, sans-serif;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(11, 31, 58, 0.12);
  }
  .key-body { display: none; }
  .guide-legend.is-open .key-body {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px 10px;
    max-width: 100%;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(11, 31, 58, 0.08);
    font-size: 14px;
    line-height: 1.35;
  }
  .guide-stage .maplibregl-ctrl-top-right {
    top: 8px;
    right: 8px;
  }
  .hover-name { display: none; }
  .guide-panel {
    position: relative;
    flex: 0 0 auto;
    height: auto;
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 24px rgba(11, 31, 58, 0.12);
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    z-index: 6;
  }
  .guide-panel:not(.is-expanded) .panel-scroll,
  .guide-panel:not(.is-expanded) .town-list-block,
  .guide-panel:not(.is-expanded) #locate-status:empty {
    display: none;
  }
  .guide-panel.is-expanded:not(.is-town) {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 72dvh;
    max-height: 72svh;
    display: flex;
  }
  .guide-panel.is-town {
    position: fixed;
    inset: 0;
    height: 100dvh;
    height: 100svh;
    max-height: none;
    z-index: 40;
    border-radius: 0;
    border-top: 0;
    padding-bottom: 0;
  }
  .sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 8px 16px;
    border: 0;
    background: #f4f7fb;
    color: var(--navy);
    font: 700 17px/1.2 "IBM Plex Sans", system-ui, sans-serif;
    cursor: pointer;
  }
  .guide-panel.is-expanded .sheet-handle {
    min-height: 56px;
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    background: var(--navy);
    color: #fff;
  }
  .grab {
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: #c5d0de;
  }
  .guide-panel.is-expanded .grab { background: var(--acc); }
  .panel-tools {
    position: relative;
    padding: 4px 20px 12px;
  }
  #town-matches {
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: calc(100% - 4px);
    z-index: 8;
    max-height: 40svh;
  }
  .tool-row { display: block; }
  #locate {
    width: 100%;
    min-height: 48px;
    font-size: 16px;
  }
  #locate-status {
    font-size: 16px;
    line-height: 1.45;
  }
  .find-label { margin-top: 14px; }
  .panel-tools .find-label:first-of-type { margin-top: 0; }
  .guide input[type="text"],
  .guide select {
    font-size: 16px;
    min-height: 48px;
  }
  .panel-scroll {
    padding: 12px 20px max(56px, calc(env(safe-area-inset-bottom, 0px) + 32px));
    -webkit-overflow-scrolling: touch;
  }
  .guide-panel h2 {
    font-size: 28px;
    line-height: 1.2;
    margin: 8px 0 14px;
  }
  .guide-panel h3 {
    font-size: 18px;
    line-height: 1.35;
    margin: 22px 0 10px;
  }
  .guide-panel p,
  .guide-panel li {
    font-size: 17px;
    line-height: 1.55;
  }
  .step,
  .help li {
    padding: 20px 0;
    gap: 14px;
  }
  .step h3,
  .help h3 {
    font-size: 18px;
    line-height: 1.35;
    margin-bottom: 8px;
  }
  .when {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    line-height: 1.4;
    letter-spacing: 0.04em;
  }
  .flag {
    display: inline-block;
    margin: 0;
    font-size: 14px;
    line-height: 1.3;
    padding: 4px 10px;
  }
  .people li { margin-bottom: 12px; }
  .contact { margin-top: 22px; padding: 16px; }
  .link-sep { display: none; }
  .contact-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }
  .contact-links a,
  .map-jump a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    font-size: 16px;
  }
  .source-line,
  .map-jump {
    font-size: 16px;
    line-height: 1.5;
  }
  .guide-panel,
  .panel-scroll,
  .step p,
  .help p,
  .source-line,
  .contact {
    overflow-wrap: anywhere;
  }
}
