/* CSW transportation finder. Colors and typefaces are CSW's own (csw.org site stylesheet). */
:root {
  --navy: #013b5f;
  --blue: #0068a9;
  --blue-deep: #015082;
  --yellow: #fcb917;
  --mist: #ebf8fc;
  --wash: #f5f9fb;
  --paper: #ffffff;
  --ink: #1e1e1e;
  --ink-soft: #46596a;
  --on-navy-soft: #cfe3ee;
  --line: #d3e1ea;
  --alert: #a3290a;

  --serif: "Alegreya", Georgia, "Times New Roman", serif;
  --sans: "Figtree", "Segoe UI", system-ui, sans-serif;

  --gutter: 28px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-pop: 0 10px 28px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  caret-color: var(--blue);
}

::selection { background: var(--yellow); color: var(--navy); }

a { color: var(--blue); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--blue-deep); text-decoration-thickness: 2px; }

button { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.masthead :focus-visible { outline-color: var(--yellow); }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 2000;
  padding: 10px 14px; background: var(--yellow); color: var(--navy); font-weight: 700; border-radius: 6px;
}
.skip:focus { top: 12px; }

/* ---------- Layout ---------- */

.app { display: block; }

.map-wrap { position: relative; height: 54vh; min-height: 320px; background: var(--mist); }
#map { position: absolute; inset: 0; }

@media (min-width: 900px) {
  .app {
    display: grid;
    grid-template-columns: minmax(380px, 448px) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100dvh;
  }
  .concept-note { grid-column: 1 / -1; grid-row: 1; }
  .masthead { grid-column: 1; grid-row: 2; }
  .results { grid-column: 1; grid-row: 3; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #9db7c8 transparent; }
  .map-wrap { grid-column: 2; grid-row: 2 / span 2; height: auto; min-height: 0; }
}

.concept-note {
  margin: 0;
  padding: 8px var(--gutter);
  background: #fff3cc;
  color: var(--navy);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
}

/* ---------- Masthead and search ---------- */

.masthead {
  position: relative;
  z-index: 1100;
  background: var(--navy);
  color: var(--paper);
  padding: 22px var(--gutter) 24px;
}

.brand { display: inline-block; line-height: 0; border-radius: 4px; }
.brand img { width: 190px; height: auto; }

.masthead h1 {
  margin: 22px 0 8px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2.25rem;
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.lede { margin: 0 0 20px; max-width: 42ch; color: var(--on-navy-soft); text-wrap: pretty; }

.search label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.9375rem; }

.combo { position: relative; display: flex; }

.combo input {
  flex: 1 1 auto;
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--paper);
  border-radius: 6px 0 0 6px;
}
.combo input::placeholder { color: #5d6f7d; opacity: 1; }
.combo input:focus-visible { outline: none; border-color: var(--yellow); box-shadow: inset 0 0 0 1px var(--yellow); }

.combo button[type="submit"] {
  flex: 0 0 auto;
  height: 52px;
  padding: 0 18px;
  font-weight: 700;
  color: var(--navy);
  background: var(--yellow);
  border: 0;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  transition: background-color 160ms var(--ease-out);
}
.combo button[type="submit"]:hover { background: #ffd04f; }
.combo button[type="submit"]:active { background: #e6a70f; }
.combo button[type="submit"][disabled] { background: #b9c9d3; color: #33475a; cursor: progress; }

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  margin: 0; padding: 6px;
  list-style: none;
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
  max-height: 300px;
  overflow-y: auto;
}
.suggestions li { padding: 10px 12px; border-radius: 6px; cursor: pointer; line-height: 1.3; }
.suggestions li small { display: block; font-size: 0.875rem; color: var(--ink-soft); }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--mist); }
.suggestions .empty { cursor: default; color: var(--ink-soft); }
.suggestions .empty:hover { background: none; }

.search-error {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: #fff1ec;
  color: var(--alert);
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
}

.starter { margin-top: 14px; }
.hint { margin: 0 0 10px; font-size: 0.9375rem; color: var(--on-navy-soft); }

.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.examples-label { font-size: 0.9375rem; color: var(--on-navy-soft); margin-right: 2px; }
.examples button {
  padding: 6px 12px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--paper);
  background: transparent;
  border: 1px solid #5f8aa5;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}
.examples button:hover { background: #0b507c; border-color: var(--on-navy-soft); }

/* After a search the masthead shrinks so results get the room. */
.app[data-state="results"] .masthead { padding-top: 16px; padding-bottom: 18px; }
.app[data-state="results"] .masthead h1 { font-size: 1.5rem; margin: 14px 0 12px; }
.app[data-state="results"] .lede,
.app[data-state="results"] .starter,
.app[data-state="results"] .search label { display: none; }
.app[data-state="results"] .brand img { width: 150px; }

/* ---------- Results ---------- */

.results { padding: 4px var(--gutter) 40px; background: var(--paper); }
.results:focus { outline: none; }

.results h2 {
  margin: 32px 0 10px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.4375rem;
  line-height: 1.2;
  color: var(--navy);
  text-wrap: balance;
}
.results h2:first-child { margin-top: 24px; }

.from { margin: 20px 0 -8px; font-size: 0.9375rem; color: var(--ink-soft); }
.from strong { color: var(--ink); font-weight: 600; }

.intro { margin: 0 0 12px; font-size: 0.9375rem; color: var(--ink-soft); max-width: 46ch; }
.aside { margin: 12px 0 0; font-size: 0.9375rem; color: var(--ink-soft); }

.notice {
  margin: 20px 0 0;
  padding: 14px 16px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.notice p { margin: 0; }
.notice p + p { margin-top: 8px; }

/* Options: one accordion, the open one is the option drawn on the map. */
.options { margin: 0; padding: 0; list-style: none; }
.option { margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); border-top: 1px solid var(--line); }
.option:last-child { border-bottom: 1px solid var(--line); }
.option.is-open { background: var(--mist); }

.option-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 0;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}
.option-head:hover .option-title { color: var(--blue-deep); text-decoration: underline; text-underline-offset: 0.18em; }

.roundel {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--route, var(--navy));
  color: var(--paper);
  font-weight: 700;
  font-size: 1.0625rem;
  line-height: 1;
}
.roundel svg { width: 20px; height: 20px; }
.roundel--line { background: var(--paper); color: var(--navy); box-shadow: inset 0 0 0 2px var(--navy); }

.option-title { display: block; font-weight: 700; line-height: 1.25; color: var(--navy); }
.option-sub { display: block; font-size: 0.9375rem; line-height: 1.35; color: var(--ink-soft); }

.figure { text-align: right; white-space: nowrap; }
.figure-label { display: block; font-size: 0.8125rem; color: var(--ink-soft); line-height: 1.2; }
.figure-value {
  display: block;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3125rem;
  line-height: 1.15;
  color: var(--navy);
  font-variant-numeric: lining-nums tabular-nums;
}

.option-body { padding: 2px 0 20px; }
.option-body[hidden] { display: none; }

/* The journey: a short vertical timetable. */
.journey { margin: 4px 0 0; padding: 0; list-style: none; }
.journey li {
  position: relative;
  display: grid;
  grid-template-columns: 74px 22px minmax(0, 1fr);
  column-gap: 10px;
  padding-bottom: 18px;
}
.journey li:last-child { padding-bottom: 0; }

.j-time {
  text-align: right;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.3;
  color: var(--navy);
  font-variant-numeric: lining-nums tabular-nums;
}
.j-time small { display: block; font-family: var(--sans); font-weight: 400; font-size: 0.8125rem; color: var(--ink-soft); line-height: 1.1; }

.j-node {
  position: relative; z-index: 1;
  justify-self: center;
  width: 14px; height: 14px; margin-top: 5px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--navy);
}
.j-node--stop { background: var(--route, var(--navy)); border-color: var(--route, var(--navy)); }
.j-node--campus { background: var(--navy); border-color: var(--yellow); width: 16px; height: 16px; margin-top: 4px; }

/* Connector from this node to the next one. */
.journey li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: calc(74px + 10px + 11px - 1.5px);
  top: 16px; bottom: -6px;
  width: 3px;
  background: var(--leg, var(--navy));
  transform-origin: top;
}
.journey li[data-leg="drive"]::after,
.journey li[data-leg="walk"]::after {
  width: 0;
  background: none;
  border-left: 3px dotted var(--navy);
}

.j-text { min-width: 0; }
.j-label { display: block; font-weight: 600; line-height: 1.3; padding-top: 1px; }
.j-place { display: block; font-size: 0.9375rem; color: var(--ink-soft); line-height: 1.35; }
.j-leg { display: block; margin-top: 8px; font-size: 0.9375rem; color: var(--ink-soft); line-height: 1.35; }

@media (prefers-reduced-motion: no-preference) {
  .option.is-fresh .journey li:not(:last-child)::after { animation: draw 520ms var(--ease-out) backwards; }
  .option.is-fresh .journey li:nth-child(2)::after { animation-delay: 160ms; }
  .option.is-fresh .journey li:nth-child(3)::after { animation-delay: 320ms; }
  @keyframes draw { from { transform: scaleY(0); } }
}

.facts { margin: 18px 0 0; padding: 14px 0 0; border-top: 1px solid #bfd9e6; }
.facts h3 { margin: 0 0 6px; font-size: 0.9375rem; font-weight: 700; color: var(--navy); }
.facts dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; font-size: 0.9375rem; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; font-variant-numeric: lining-nums tabular-nums; }
.facts dd small { display: block; font-size: 0.875rem; color: var(--ink-soft); }
.facts p { margin: 10px 0 0; font-size: 0.9375rem; text-wrap: pretty; }
.facts p:first-child { margin-top: 0; }
.facts + .facts { margin-top: 14px; }
.tradeoff strong { font-variant-numeric: lining-nums tabular-nums; }

/* All bus lines */
.lines { margin: 0; padding: 0; list-style: none; }
.line { border-top: 1px solid var(--line); }
.line:last-child { border-bottom: 1px solid var(--line); }
.line .option-head { grid-template-columns: 38px minmax(0, 1fr) auto; }

.stops { margin: 0; padding: 0 0 16px 50px; list-style: none; }
.stops li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-top: 1px dashed var(--line); }
.stops li:first-child { border-top: 0; padding-top: 2px; }
.stop-name { font-weight: 600; line-height: 1.3; }
.stop-place { grid-column: 1; font-size: 0.9375rem; color: var(--ink-soft); line-height: 1.35; }
.stop-am { grid-column: 2; grid-row: 1; text-align: right; font-weight: 600; white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
.stop-pm { grid-column: 1 / -1; font-size: 0.9375rem; color: var(--ink-soft); line-height: 1.4; font-variant-numeric: lining-nums tabular-nums; }

/* Visit prompt */
.visit { margin: 36px calc(var(--gutter) * -1) 0; padding: 26px var(--gutter) 28px; background: var(--navy); color: var(--paper); }
.visit h2 { margin: 0 0 6px; color: var(--paper); }
.visit p { margin: 0 0 16px; color: var(--on-navy-soft); max-width: 44ch; }
.visit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.btn {
  display: inline-block;
  padding: 11px 18px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 6px;
  transition: background-color 160ms var(--ease-out);
}
.btn--primary { background: var(--yellow); color: var(--navy); }
.btn--primary:hover { background: #ffd04f; color: var(--navy); }
.btn--ghost { color: var(--paper); box-shadow: inset 0 0 0 2px #5f8aa5; }
.btn--ghost:hover { color: var(--paper); background: #0b507c; }
.visit :focus-visible { outline-color: var(--yellow); }
.visit .costs { color: var(--paper); font-weight: 600; }

.fineprint { margin: 22px 0 0; font-size: 0.875rem; color: var(--ink-soft); line-height: 1.5; }
.fineprint p { margin: 0 0 8px; max-width: 62ch; text-wrap: pretty; }

/* Loading */
.skeleton { margin-top: 28px; }
.skeleton div { height: 16px; margin-bottom: 14px; border-radius: 4px; background: linear-gradient(90deg, #e3eef4 0%, #f3f8fb 40%, #e3eef4 80%); background-size: 300% 100%; }
.skeleton div:nth-child(1) { width: 55%; height: 24px; }
.skeleton div:nth-child(2) { width: 90%; }
.skeleton div:nth-child(3) { width: 72%; }
.skeleton div:nth-child(4) { width: 84%; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton div { animation: shimmer 1.4s linear infinite; }
  @keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Map ---------- */

.leaflet-container { font-family: var(--sans); font-size: 0.875rem; background: #e8f0f4; }
.leaflet-tile-pane { filter: saturate(0.3) brightness(1.03) contrast(0.94); }
.leaflet-container a { color: var(--blue); }
.leaflet-container :focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.leaflet-control-attribution { font-size: 0.75rem; }

.leaflet-bar a { color: var(--navy); }

.pin { display: grid; place-items: center; border-radius: 50%; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3); }
.pin--campus { width: 44px; height: 44px; background: var(--navy); border: 3px solid var(--yellow); color: var(--paper); font-weight: 700; font-size: 0.8125rem; letter-spacing: 0.02em; }
.pin--home { width: 38px; height: 38px; background: var(--yellow); border: 3px solid var(--navy); color: var(--navy); }
.pin--home svg { width: 20px; height: 20px; }
.pin--station { width: 26px; height: 26px; background: var(--paper); border: 3px solid var(--navy); color: var(--navy); }
.pin--station svg { width: 14px; height: 14px; }

.leaflet-tooltip {
  padding: 6px 10px;
  font-family: var(--sans); font-size: 0.875rem; line-height: 1.3;
  color: var(--ink);
  background: var(--paper);
  border: 0; border-radius: 6px;
  box-shadow: var(--shadow-pop);
}
.leaflet-tooltip::before { display: none; }
.leaflet-tooltip strong { color: var(--navy); }

.leaflet-popup-content-wrapper { border-radius: 8px; box-shadow: var(--shadow-pop); }
.leaflet-popup-content { margin: 14px 16px; font-size: 0.9375rem; line-height: 1.4; color: var(--ink); }
.popup-route { display: inline-block; margin-bottom: 4px; padding: 2px 8px; border-radius: 999px; background: var(--route); color: var(--paper); font-size: 0.8125rem; font-weight: 700; }
.popup-title { display: block; font-weight: 700; color: var(--navy); }
.popup-place { display: block; color: var(--ink-soft); margin-bottom: 6px; }
.popup-times { display: block; font-variant-numeric: lining-nums tabular-nums; }

.reset-view {
  position: absolute; z-index: 1000; top: 12px; right: 12px;
  padding: 9px 14px;
  font-weight: 600; font-size: 0.9375rem;
  color: var(--navy);
  background: var(--paper);
  border: 0; border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  cursor: pointer;
}
.reset-view:hover { background: var(--mist); }
.reset-view[hidden] { display: none; }

@media (max-width: 899px) {
  :root { --gutter: 20px; }
  .masthead h1 { font-size: 1.875rem; }
  .combo button[type="submit"] { padding: 0 14px; }
}
