/* ============ Berkley Bus Network — V2 ============
   Mobile-first, iframe-embed-safe: no sticky UI, no overlays, no internal
   scrolling assumptions. Design tokens first, then components in view order,
   then the retained static-map drawing classes. */

:root {
  --ink: #101418;
  --ink-soft: #45505c;
  --ink-faint: #8a94a0;
  --paper: #f4f5f7;
  --surface: #ffffff;
  --hairline: #eceef0;
  --field: #f1f3f5;
  --brand-navy: #000078;
  --brand-teal: #007884;
  --radius: 14px;
  --radius-lg: 18px;
  --pad: 20px;
  --focus: 0 0 0 3px #ffffff, 0 0 0 6px var(--brand-navy);
}

.bus-v2-page { background: var(--paper); margin: 0; }

.bnw {
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0 auto;
  max-width: 640px;
  padding: 18px 16px 40px;
}

.bnw :focus-visible { border-radius: 8px; box-shadow: var(--focus); outline: none; }

.bnw h1, .bnw h2, .bnw h3 { color: var(--ink); }

/* styles.css styles `button` globally for the zone checker — neutralise inside .bnw */
.bnw button {
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: inherit;
  font: inherit;
  letter-spacing: normal;
  padding: 0;
  text-transform: none;
}

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.bnw-view { background: var(--surface); border-radius: var(--radius-lg); padding: var(--pad); }

.bnw-noscript {
  background: #fff6e8;
  border-left: 4px solid #b3541e;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 14px;
  padding: 12px 14px;
}

/* ---------- brand + headline ---------- */
.bnw-brand { align-items: center; display: flex; gap: 10px; }
.bnw-mark { background: var(--brand-navy); border-radius: 8px; color: #fff; font-size: 11px; font-weight: 800; padding: 5px 7px; }
.bnw-brand-label { color: var(--ink-soft); font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.bnw .bnw-headline { color: var(--brand-navy); font-size: clamp(26px, 7vw, 34px); font-weight: 850; letter-spacing: -0.03em; line-height: 1.04; margin: 12px 0 0; }

/* ---------- search ---------- */
.bnw-search {
  align-items: center;
  background: var(--field);
  border: 2px solid var(--brand-navy);
  border-radius: 999px; /* quiet echo of the school site's pill buttons */
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 4px 4px 4px 16px;
}
.bnw-search:focus-within { border-color: var(--brand-teal); }
.bnw-search-icon { color: var(--ink); flex: 0 0 auto; }
.bnw-search input {
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--ink);
  flex: 1;
  font: 600 15px/1.2 inherit;
  min-height: 44px;
  min-width: 0;
  outline: none;
  padding: 0;
}
.bnw-search input:focus,
.bnw-search input:focus-visible {
  border-radius: 0;
  box-shadow: none;
  outline: none;
}
.bnw-search input::placeholder { color: var(--ink-faint); }
.bnw-search button {
  background: var(--brand-navy);
  border: 0;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  font: 700 14px/1 inherit;
  min-height: 44px;
  padding: 0 20px;
}
.bnw-privacy { color: var(--ink-faint); font-size: 11.5px; font-weight: 600; margin: 8px 2px 0; }

/* ---------- direction toggle ---------- */
.bnw-direction { background: var(--field); border-radius: 12px; display: flex; gap: 4px; margin-top: 14px; padding: 4px; }
.bnw-direction label { flex: 1; position: relative; }
.bnw-direction input { inset: 0; margin: 0; opacity: 0; position: absolute; }
.bnw-direction span {
  border-radius: 9px;
  color: var(--ink-soft);
  cursor: pointer;
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 40px;
  min-height: 40px;
  text-align: center;
}
.bnw-direction input:checked + span { background: var(--brand-navy); color: #fff; }
.bnw-direction input:focus-visible + span { box-shadow: var(--focus); }

/* ---------- route list ---------- */
.bnw-routes { margin-top: 10px; }
.bnw-route {
  align-items: center;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 12px;
  min-height: 68px;
  padding: 10px 4px;
  text-align: left;
  width: 100%;
}
.bnw-route:last-child { border-bottom: 0; }
.bullet {
  align-items: center;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 800;
  height: 44px;
  justify-content: center;
  width: 44px;
}
.bnw-route .t { flex: 1; min-width: 0; }
.bnw-route .t b { display: block; font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.bnw-route .t span { color: var(--ink-soft); display: block; font-size: 12.5px; margin-top: 2px; }
.bnw-route .rt { flex: 0 0 auto; margin-left: auto; text-align: right; }
.bnw-route .rt b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; font-weight: 850; }
.bnw-route .rt small { color: var(--ink-faint); display: block; font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.bnw-route .arr { color: var(--ink-faint); flex: 0 0 auto; font-size: 20px; }

/* ---------- search results + matched stop ---------- */
.bnw-search-result {
  background: var(--field);
  border-left: 4px solid var(--brand-teal);
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  margin-top: 12px;
  padding: 12px 14px;
}
.bnw-search-result.warning { border-left-color: #b3541e; }
.bnw-switch-hint { margin-top: 8px; }
.bnw-switch-hint button {
  color: var(--brand-navy);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 800;
  min-height: 44px;
  text-decoration: underline;
}
.bnw-result-routes { display: grid; gap: 6px; margin-top: 10px; }
.bnw-result-routes button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  font-size: 13.5px;
  font-weight: 700;
  gap: 10px;
  line-height: 1.3;
  min-height: 48px;
  padding: 6px 10px;
  text-align: left;
}
.bnw-result-routes .bullet { font-size: 11px; height: 30px; width: 30px; }
.strip .is-match > div {
  background: color-mix(in srgb, var(--line) 10%, #fff);
  border-radius: 10px;
  margin: -4px 0 0 -6px;
  padding: 4px 8px 16px 6px;
}
.bnw-your-stop {
  background: var(--line);
  border-radius: 999px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  text-transform: uppercase;
  vertical-align: 2px;
}
@media (prefers-reduced-motion: no-preference) {
  .strip .is-match .dot { animation: bnw-pulse 1s ease 2; }
  @keyframes bnw-pulse {
    50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--line) 30%, transparent); }
  }
}

/* ---------- route view ---------- */
.bnw-back {
  align-items: center;
  color: var(--brand-navy);
  cursor: pointer;
  display: flex;
  font-size: 15px;
  font-weight: 800;
  justify-content: flex-start;
  justify-self: start;
  min-height: 44px;
  padding: 0 4px;
  text-align: left;
  width: 100%;
}
.bnw-route-header { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.bullet-lg { font-size: 16px; height: 48px; width: 48px; }
.bnw-route-header h2 { font-size: 21px; font-weight: 850; letter-spacing: -0.02em; margin: 0; }
.bnw-route-header h2:focus { outline: none; }
.bnw-route-header p { color: var(--ink-soft); font-size: 13px; font-weight: 600; margin: 2px 0 0; }
.bnw-areas { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.bnw-areas i { background: var(--field); border-radius: 999px; color: var(--ink-soft); font-size: 11.5px; font-style: normal; font-weight: 700; padding: 5px 10px; }

/* ---------- strip map ---------- */
.bnw-strip-title { color: var(--ink-soft); font-size: 12px; font-weight: 800; letter-spacing: 0.06em; margin: 18px 0 10px; text-transform: uppercase; }
.strip { list-style: none; margin: 0; padding: 0; }
.strip .stop { display: flex; gap: 14px; position: relative; }
.strip .stop::before { background: var(--line); bottom: 0; content: ""; left: 7px; position: absolute; top: 0; width: 6px; }
.strip .stop:first-child::before { border-radius: 3px 3px 0 0; top: 6px; }
.strip .stop:last-child::before { border-radius: 0 0 3px 3px; bottom: auto; height: 6px; top: 6px; }
.strip .dot { background: #fff; border: 4px solid var(--line); border-radius: 50%; box-sizing: border-box; flex: 0 0 auto; height: 20px; margin-top: 2px; width: 20px; z-index: 1; }
.strip .stop > div { padding-bottom: 20px; min-width: 0; }
.strip .nm { display: block; font-size: 14.5px; font-weight: 700; }
.strip .rd { color: var(--ink-soft); display: block; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; margin-top: 1px; text-transform: uppercase; }
.strip .terminus .dot { background: var(--line); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--line); }
.strip .terminus .nm { font-size: 16px; font-weight: 850; }
.strip .stop:last-child > div { padding-bottom: 4px; }

/* ---------- inline map blocks ---------- */
.bnw-map-block { margin-top: 18px; }
.bnw-map-card { border-radius: var(--radius); cursor: pointer; display: block; overflow: hidden; position: relative; width: 100%; }
.bnw-map-card img { display: block; filter: saturate(0.9); height: 120px; object-fit: cover; object-position: 38% 40%; width: 100%; }
.bnw-map-card b { background: var(--brand-navy); border-radius: 999px; bottom: 10px; color: #fff; font-size: 12px; font-weight: 700; left: 10px; padding: 7px 12px; position: absolute; }
.bnw-map-panel .static-map-canvas { aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; position: relative; }
.bnw-map-note { color: var(--ink-faint); font-size: 11.5px; margin: 8px 2px 0; }

/* ---------- footer ---------- */
.bnw-footer { color: var(--ink-soft); font-size: 12.5px; line-height: 1.55; padding: 18px 6px 0; }
.bnw-footer a { color: var(--brand-navy); font-weight: 700; }
.bnw-attribution { color: var(--ink-faint); font-size: 11px; margin-top: 6px; }

@media (prefers-reduced-motion: no-preference) {
  .bnw-map-panel, .bnw-view { transition: opacity 0.18s ease; }
}

/* ---------- desktop two-pane (only if the iframe/window is wide) ---------- */
@media (min-width: 860px) {
  .bnw { max-width: 1160px; }
  .bnw-view:not([hidden]) {
    display: grid;
    gap: 0 28px;
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  }
  .bnw-view > * { grid-column: 1; }
  .bnw-view .bnw-map-block {
    align-self: start;
    grid-column: 2;
    grid-row: 1 / span 12;
    margin-top: 0;
  }
  .bnw-map-card { display: none; }
  /* !important needed: styles.css sets [hidden] { display: none !important } */
  .bnw-map-panel[hidden] { display: block !important; }
}

/* ---------- embed mode (inside the school CMS iframe) ---------- */
html.embed .bnw { padding: 4px 10px 24px; }
html.embed .bnw-brand { display: none; }
html.embed .bnw-headline { font-size: 22px; margin-top: 4px; }
html.embed .bnw-view { border-radius: 10px; padding: 14px; }

/* ============ retained static-map drawing classes ============
   The SVG overlay drawing code in bus-finder-v2.js depends on these. */
.static-map-canvas img,
.static-map-overlay {
  display: block;
  height: 100%;
  inset: 0;
  position: absolute;
  width: 100%;
}
.static-map-canvas img { object-fit: fill; }
.static-map-overlay { overflow: visible; pointer-events: none; }
.static-route-halo,
.static-route-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.static-route-halo { stroke: rgba(255, 255, 255, 0.96); stroke-width: 10px; }
.static-route-line { stroke-width: 6px; }
/* Strokes are non-scaling screen pixels: slim them on narrow embeds.
   (Network-overview widths are set inline per route by drawNetworkMap.) */
@media (max-width: 640px) {
  .static-route-halo { stroke-width: 7px; }
  .static-route-line { stroke-width: 4.5px; }
}
.static-stop-dot { fill: #ffffff; stroke-width: 3px; }
.static-school-halo { fill: #ffffff; stroke: rgba(0, 0, 120, 0.2); stroke-width: 4px; }
.static-school-dot { fill: var(--brand-navy); }
.static-hub {
  fill: #ffffff;
  stroke: var(--brand-navy);
  stroke-width: 3.5px;
  vector-effect: non-scaling-stroke;
}
.static-school-label {
  fill: var(--brand-navy);
  font-family: Inter, system-ui, sans-serif;
  font-size: 20px;
  font-weight: 850;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 5px;
}
