/* ============================================================
   BOMAtlas Atlas Shell — the education-atlas app chrome.
   Light, clean, map-first. Used by / and the education shells
   (/trade-schools/, /universities/, /community-colleges/,
   /private-colleges/, /education/).

   Segment hues are palette-validated for the light basemap
   (lightness band, chroma floor, CVD separation, contrast).
   Type identity is never color-alone: list rows, the legend,
   and the selection card all carry the type label as text.
   ============================================================ */

:root {
  --ink: #0f172a;
  --ink-2: #46556a;
  --ink-3: #8b97a8;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.16);
  --paper: #ffffff;
  --paper-2: #f6f8fa;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --seg-trade: #d97706;
  --seg-cc: #0d9488;
  --seg-pub: #2563eb;
  --seg-priv: #db2777;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  background: var(--paper);
}
body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────────── */
.hp-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3000;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--line);
  height: 56px;
}
.hp-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  height: 56px;
}
.hp-logo {
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.03em;
  margin-right: auto;
}
.hp-logo span {
  color: var(--accent);
}
.hp-nav {
  display: flex;
  align-items: center;
  gap: 22px;
}
.hp-nav a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: color 0.15s;
}
.hp-nav a:hover,
.hp-nav a[aria-current='page'] {
  color: var(--ink);
}
.hp-nav-cta {
  background: var(--accent);
  color: #fff !important;
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 600;
}
.hp-nav-cta:hover {
  background: var(--accent-2);
}
.hp-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  margin: -10px -10px -10px 0;
}
.hp-menu-btn svg {
  width: 22px;
  height: 22px;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
}
@media (max-width: 768px) {
  .hp-menu-btn {
    display: block;
  }
  .hp-nav {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  }
  .hp-nav.active {
    display: flex;
  }
  .hp-nav a {
    padding: 13px 20px;
    font-size: 15px;
    border-top: 1px solid var(--line);
  }
  .hp-nav-cta {
    border-radius: 0;
    text-align: center;
  }
}

/* ── App shell: the map IS the page ─────────────────────────── */
html.atlas-app,
body.ts-app {
  height: 100%;
}
body.ts-app {
  overflow: hidden;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 4000;
}
.skip-link:focus {
  left: 0;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-main {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
}
#map {
  position: absolute;
  inset: 0;
  background: #e9edf1;
}
.map-dead {
  display: grid;
  place-content: center;
  height: 100%;
  color: var(--ink-2);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}
.map-attrib {
  position: absolute;
  bottom: 8px;
  left: 10px;
  z-index: 5;
  font-size: 10.5px;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.75);
  padding: 2px 8px;
  border-radius: 6px;
  pointer-events: none;
}

/* ── Floating directory panel ───────────────────────────────── */
.panel {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: 400px;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow:
    0 2px 8px rgba(15, 23, 42, 0.08),
    0 24px 64px rgba(15, 23, 42, 0.16);
  overflow: hidden;
  z-index: 10;
}
.panel-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.panel-head h1 {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
  color: var(--ink);
  margin: 0 0 10px;
}
.panel-head h1 em {
  font-style: normal;
  color: var(--accent);
}
.panel-sub {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0 0 10px;
}

/* Segment tabs: one dot per institution type */
.ts-segments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.ts-segments button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.08s;
}
.ts-segments button:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}
.ts-segments button:active {
  transform: scale(0.96);
}
.ts-segments button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.seg-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.panel-stats {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  margin: 0 0 10px;
  font-variant-numeric: tabular-nums;
}
.panel-stats strong {
  color: var(--ink);
  font-weight: 700;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.search-row input[type='text'] {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 12px;
  background: var(--paper-2);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.search-row input[type='text']:focus {
  border-color: var(--accent);
  background: var(--paper);
}
.search-row input[type='text']::placeholder {
  color: var(--ink-3);
}
.search-row select {
  flex: 0 0 132px;
  appearance: none;
  -webkit-appearance: none;
  padding: 9px 28px 9px 12px;
  background: var(--paper-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%230f172a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
    no-repeat right 10px center / 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.chips-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin: 0 0 4px;
}
.ts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ts-chips button {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.08s;
}
.ts-chips button:hover {
  border-color: var(--accent);
  color: var(--accent-2);
}
.ts-chips button:active {
  transform: scale(0.96);
}
.ts-chips button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Type legend (Everything view) */
.ts-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.ts-legend button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s;
}
.ts-legend button:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}
.lg-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.lg-n {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.sg-type .lg-dot {
  width: 7px;
  height: 7px;
  margin-right: 3px;
  vertical-align: 0;
  display: inline-block;
}

/* Selected school card */
.selected-school-panel {
  display: none;
  padding: 12px 16px;
  background: var(--paper);
  border-bottom: 2px solid var(--accent);
}
.selected-school-panel.visible {
  display: block;
}
.selected-school-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.selected-school-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  padding-top: 4px;
}
.selected-school-close {
  background: none;
  border: none;
  color: var(--ink-2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  margin: -8px -10px 0 0;
  border-radius: 8px;
}
.selected-school-close:hover {
  color: var(--ink);
  background: var(--paper-2);
}
.selected-school-info {
  margin-top: 4px;
}
.sel-meta {
  color: var(--ink-2);
  font-size: 12.5px;
}
.sel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.sel-chip {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-2);
}
.selected-school-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.selected-school-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}
.selected-school-btn:hover {
  background: var(--accent-2);
}
.selected-school-btn.secondary {
  background: var(--paper-2);
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
}
.selected-school-btn.secondary:hover {
  background: #eef1f5;
  color: var(--ink);
}

/* Directory list */
.school-list {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.school-list::-webkit-scrollbar {
  width: 8px;
}
.school-list::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}
.loading {
  padding: 24px;
  text-align: center;
  color: var(--ink-2);
  font-size: 13px;
}
.sg-count {
  padding: 8px 16px 4px;
  font-size: 11px;
  color: var(--ink-2);
}
.sg-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  cursor: pointer;
  border: none;
  border-bottom: 1px solid var(--line);
  background: none;
  font-family: inherit;
  text-align: left;
  transition:
    background 0.12s,
    box-shadow 0.12s;
}
.sg-row:hover {
  background: var(--paper-2);
  box-shadow: inset 3px 0 0 var(--accent);
}
.sg-fav {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
}
.sg-mono {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.sg-body {
  min-width: 0;
  flex: 1;
  display: block;
}
.sg-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sg-meta {
  display: block;
  font-size: 11.5px;
  color: var(--ink-2);
  margin-top: 1px;
}
.sg-empty {
  min-height: 60%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  text-align: center;
  padding: 24px;
}
.sg-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.sg-empty-hint {
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

/* Panel foot: state links (SEO) + cross-links */
.panel-foot {
  border-top: 1px solid var(--line);
  padding: 8px 16px 10px;
  background: var(--paper-2);
}
.panel-foot details summary {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  padding: 4px 0;
}
.ts-state-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 10px;
  margin: 6px 0 4px;
  max-height: 180px;
  overflow-y: auto;
}
.ts-state-grid a {
  font-size: 12px;
  color: var(--ink-2);
  text-decoration: none;
  padding: 2px 0;
}
.ts-state-grid a:hover {
  color: var(--accent);
}
.foot-note {
  font-size: 11.5px;
  margin-top: 4px;
  line-height: 1.5;
}
.foot-link {
  color: var(--ink-2);
  font-weight: 600;
  text-decoration: none;
}
.foot-link:hover {
  color: var(--accent);
}
.foot-tools {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 4px;
}
.foot-tools a {
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
}
.foot-tools a:hover {
  color: var(--accent);
}

/* Embed mode: bare map */
.embed-mode .hp-header,
.embed-mode .panel {
  display: none !important;
}
.embed-mode .app-main {
  top: 0;
}

/* Sheet handle: mobile-only affordance */
.sheet-handle {
  display: none;
}

/* ── Mobile: map on top, panel as bottom sheet ──────────────── */
@media (max-width: 768px) {
  .app-main {
    display: flex;
    flex-direction: column;
  }
  #map {
    position: relative;
    inset: auto;
    flex: 1 1 auto;
    min-height: 90px;
  }
  .sheet-handle {
    display: grid;
    place-items: center;
    width: 100%;
    padding: 10px 0 4px;
    background: none;
    border: none;
    cursor: grab;
    flex-shrink: 0;
  }
  .sheet-handle::before {
    content: '';
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: var(--line-strong);
  }
  .panel {
    position: relative;
    inset: auto;
    width: auto;
    flex: 0 0 56%;
    max-height: 56%;
    border-radius: 14px 14px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    transition:
      flex-basis 0.28s ease,
      max-height 0.28s ease;
  }
  .panel.sheet-expanded {
    flex: 0 0 88%;
    max-height: 88%;
  }
  .panel.sheet-peek {
    flex: 0 0 22%;
    max-height: 22%;
  }
  .panel.sheet-peek .panel-head,
  .panel.sheet-peek .panel-foot,
  .panel.sheet-peek .selected-school-panel {
    display: none;
  }
  .panel-head {
    padding: 10px 14px 8px;
  }
  .panel-head h1 {
    font-size: 19px;
    margin-bottom: 8px;
  }
  .panel-sub {
    display: none;
  }
  .ts-segments {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 8px;
  }
  .ts-segments::-webkit-scrollbar {
    display: none;
  }
  .ts-segments button {
    white-space: nowrap;
    padding: 9px 13px;
    min-height: 38px;
  }
  .panel-stats {
    margin-bottom: 8px;
  }
  /* 16px inputs: iOS Safari zooms the page on focus below 16px */
  .search-row input[type='text'],
  .search-row select {
    font-size: 16px;
  }
  .ts-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .ts-chips::-webkit-scrollbar {
    display: none;
  }
  .ts-chips button {
    white-space: nowrap;
    padding: 7px 11px;
  }
  .ts-legend {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 8px;
  }
  .ts-legend::-webkit-scrollbar {
    display: none;
  }
  .ts-legend button {
    white-space: nowrap;
  }
  /* When a school is selected, hand its card the head's space */
  .panel.has-selection .panel-stats,
  .panel.has-selection .chips-label,
  .panel.has-selection .ts-chips,
  .panel.has-selection .ts-legend,
  .panel.has-selection .panel-sub {
    display: none;
  }
  .panel-foot {
    padding: 6px 14px 8px;
  }
  .map-attrib {
    display: none;
  }
}

/* Landscape phones: the sheet itself scrolls */
@media (max-height: 500px) {
  .panel {
    overflow-y: auto;
    flex: 0 0 62%;
    max-height: 62%;
  }
  .panel-head {
    flex-shrink: 0;
  }
  .school-list {
    flex: none;
    min-height: 160px;
  }
}

/* ── Lead CTA (panel foot on map shells) ────────────────────── */
.foot-cta {
  display: block;
  text-align: center;
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  padding: 10px 14px;
  margin: 4px 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s;
}
.foot-cta:hover {
  background: var(--accent-2);
}
