/* WalchandOnGo — campus navigation UI
   Navy = structure and primary actions · Mint = route, destination, selection · Off-white = surfaces.
   Type scale: 12 / 14 / 16 / 20 / 28. Spacing: 4px grid. Tap targets >= 44px. */

:root {
  --navy: #12284c;
  --navy-2: #1d3b6b;
  --navy-tint: #e6ebf3;
  --mint: #6fe3b9;
  --mint-strong: #1f9d71;
  --mint-tint: #def7ec;
  --bg: #faf8f3;
  --surface: #fff;
  --surface-2: #f2efe8;
  --ink: #16233b;
  --muted: #566277;
  --faint: #6b7689;
  --line: #e3dfd5;
  --accent: var(--navy);          /* headings / selected state on surfaces */
  --on-accent: #fff;
  --danger: #b3382c;
  --amber: #8f5200;
  --focus: #0b6e4f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(18, 40, 76, .08), 0 6px 20px rgba(18, 40, 76, .12);
  --ease: cubic-bezier(.4, 0, .2, 1);
  --sidebar-w: 390px;
  --sheet-h: 52vh;
  --brand-h: 60px;
}
@supports (height: 1dvh) { :root { --sheet-h: 52dvh; } }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a2e;
    --surface: #17263f;
    --surface-2: #1d2f4d;
    --ink: #e8edf5;
    --muted: #aab6c8;
    --faint: #93a1b6;
    --line: #2b3f61;
    --navy-tint: #243a5e;
    --mint-tint: #1b4a40;
    --accent: var(--mint);
    --on-accent: #0f1a2e;
    --focus: #6fe3b9;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#map {
  position: absolute;
  inset: 0;
  left: var(--sidebar-w);
  z-index: 0;
  background: #faf8f3;
  transition: left .3s var(--ease);
}

button { font-family: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------------------------------------------------------------- sidebar */

.sidebar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg);
  box-shadow: var(--shadow);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  transition: transform .3s var(--ease);
}

.sidebar.hidden { transform: translateX(-100%); }
body.panel-hidden #map { left: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--brand-h);
  padding: 8px 8px 8px 18px;
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--navy);
  color: #fff;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--mint);
  color: var(--navy);
  font-weight: 800;
  font-size: 1.125rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.brand h1 { margin: 0; font-size: 1.0625rem; font-weight: 600; letter-spacing: .01em; color: #fff; }
.brand p { margin: 2px 0 0; font-size: .75rem; color: rgba(255, 255, 255, .78); }

.collapse, .reopen {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  margin-left: auto;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  transition: background .2s var(--ease);
}
.collapse:hover { background: rgba(255, 255, 255, .16); }
.collapse:focus-visible, .reopen:focus-visible { outline-color: var(--mint); }

.reopen {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 1001;
  background: var(--navy);
  box-shadow: var(--shadow);
  margin: 0;
}
.reopen:hover { background: var(--navy-2); }
.reopen[hidden] { display: none; }

/* ------------------------------------------------------------ search card */

.search-card {
  display: grid;
  grid-template-columns: 20px 1fr 44px;
  gap: 6px;
  align-items: center;
  padding: 16px 8px 4px 14px;
}

.field-rail { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.dot-start { background: var(--bg); border: 3px solid var(--accent); }
.dot-end { background: var(--mint); border: 3px solid var(--mint-strong); border-radius: 3px; }
.rail { flex: 1; width: 2px; min-height: 24px; background: repeating-linear-gradient(to bottom, var(--faint) 0 3px, transparent 3px 6px); }

.fields { display: grid; gap: 8px; }
.field { position: relative; }

.field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 1rem; /* 16px stops iOS zooming on focus */
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field input:hover { border-color: var(--faint); }
.field input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
.field input::placeholder { color: var(--faint); }

.swap {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  border-radius: 50%;
  transition: background .2s var(--ease);
}
.swap:hover { background: var(--navy-tint); }

/* ------------------------------------------------------------- typeahead */

.results {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 30;
  overflow: hidden;
  max-height: 290px;
  overflow-y: auto;
}
.results.open { display: block; animation: drop .18s var(--ease); }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }

.result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  font-size: .9375rem;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}
.result:hover, .result.active { background: var(--mint-tint); }
.result-name { flex: 1; }
.result-kind { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.result-special .result-name { color: var(--accent); font-weight: 600; }

.hint { margin: 4px 18px 12px; font-size: .875rem; color: var(--muted); line-height: 1.45; }

/* ------------------------------------------------------- weather / crowd */

.context { display: grid; gap: 10px; margin: 0 14px 14px; }
.ctl { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 10px; }
.ctl-label { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.seg {
  display: flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.seg button {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px;
  border: 0; background: transparent; color: var(--muted);
  font-size: .875rem; padding: 0 10px; border-radius: 999px; cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--navy); color: #fff; font-weight: 600; }
.seg button svg { flex: none; }
.context select[hidden] { display: none; }

/* crowd level as 1-3 filled bars */
.bars { display: inline-block; width: 14px; height: 14px; background:
    linear-gradient(currentColor, currentColor) 0 100% / 4px 5px no-repeat,
    linear-gradient(currentColor, currentColor) 5px 100% / 4px 9px no-repeat,
    linear-gradient(currentColor, currentColor) 10px 100% / 4px 14px no-repeat;
  opacity: .35; }
.bars.b1 { background-image: linear-gradient(currentColor, currentColor), linear-gradient(currentColor, currentColor), linear-gradient(currentColor, currentColor); }
.seg button.on .bars { color: var(--mint); opacity: 1; }
.seg button.on svg { color: var(--mint); }

/* --------------------------------------------------------------- summary */

.summary {
  margin: 0 14px 6px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(18, 40, 76, .05);
  animation: rise .25s var(--ease);
}
.summary[hidden] { display: none; }
@keyframes rise { from { transform: translateY(6px); } }

.summary-main { display: flex; align-items: baseline; gap: 10px; }
.summary-time { font-size: 1.75rem; font-weight: 700; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.summary-dist { font-size: 1rem; color: var(--muted); }
.summary-note { margin: 6px 0 0; font-size: .8125rem; color: var(--muted); }
.summary-note:empty { display: none; }

.nav-actions { display: flex; gap: 8px; margin-top: 14px; }

.btn-start, .btn-demo {
  cursor: pointer;
  min-height: 48px;
  border-radius: 999px;
  padding: 0 20px;
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid var(--navy);
  transition: background .2s var(--ease), transform .1s var(--ease);
}
.btn-start { flex: 1; background: var(--navy); color: #fff; }
.btn-start:hover { background: var(--navy-2); border-color: var(--navy-2); }
.btn-start.active { background: var(--danger); border-color: var(--danger); }
.btn-start.active:hover { background: #962d23; border-color: #962d23; }
.btn-demo { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-demo:hover:not(:disabled) { background: var(--mint-tint); }
.btn-demo:disabled { opacity: .5; cursor: default; }
.btn-start:active, .btn-demo:active { transform: scale(.97); }

/* ------------------------------------------------------- live navigation */

.nav-banner {
  position: sticky;
  top: var(--brand-h);
  z-index: 5;
  display: flex; align-items: center; gap: 14px;
  margin: 10px 14px 6px;
  padding: 14px 16px;
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  border: 2px solid var(--mint);
  box-shadow: var(--shadow);
  transition: background .3s var(--ease), color .3s var(--ease);
}
.nav-banner[hidden] { display: none; }
.nav-banner.arrived { background: var(--mint); color: #0b1c38; border-color: #0b1c38; }
.nav-banner.offroute { background: var(--amber); border-color: #fff; }
.nav-arrow { font-size: 2.75rem; line-height: 1; width: 56px; text-align: center; flex: none; color: var(--mint); }
.nav-banner.arrived .nav-arrow { color: #0b1c38; }
.nav-banner.offroute .nav-arrow { color: #fff; }
.nav-dist { font-size: 1.75rem; font-weight: 700; line-height: 1.15; }
.nav-instr { font-size: 1.125rem; font-weight: 500; }
.nav-meta { font-size: .875rem; margin-top: 4px; }
.nav-meta:empty { display: none; }

/* ----------------------------------------------------------------- steps */

.steps { list-style: none; margin: 8px 0 0; padding: 0; }
.steps:empty { display: none; }

.steps li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: baseline;
  margin: 0 8px;
  padding: 12px 10px;
  border-radius: 10px;
  font-size: .9375rem;
  line-height: 1.4;
  animation: rise .25s var(--ease) backwards;
}
.steps li:nth-child(2) { animation-delay: .04s; }
.steps li:nth-child(3) { animation-delay: .08s; }
.steps li:nth-child(n+4) { animation-delay: .12s; }
.steps li:hover { background: var(--mint-tint); }
.steps li.arrival { color: var(--accent); font-weight: 600; }
.steps li.current { background: var(--mint-tint); box-shadow: inset 4px 0 0 var(--mint-strong); font-weight: 600; }
.steps li.past { opacity: .6; }
.steps.live li { animation: none; }

.step-icon { color: var(--accent); font-size: 1.125rem; text-align: center; }
.step-dist { color: var(--muted); font-size: .8125rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.step-stairs { display: block; font-size: .8125rem; font-weight: 500; color: var(--amber); }
@media (prefers-color-scheme: dark) { .step-stairs { color: #f0b45a; } }

.credits {
  margin-top: auto;
  padding: 12px 18px;
  font-size: .75rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------ map pieces */

.leaflet-container { font-family: inherit; background: #faf8f3; }

.pin {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: .75rem; font-weight: 700;
  border: 2.5px solid #faf8f3;
  box-shadow: 0 2px 6px rgba(18, 40, 76, .45);
}
.pin-start { background: var(--navy); color: #fff; }
.pin-end { background: var(--mint); color: var(--navy); }

.turn-pin {
  width: 26px; height: 26px; border-radius: 50%;
  background: #faf8f3; color: var(--navy);
  border: 2px solid var(--navy);
  font-size: 17px; font-weight: 700; line-height: 22px; text-align: center;
  box-shadow: 0 1px 4px rgba(18, 40, 76, .4);
}

.user-dot {
  width: 18px; height: 18px; margin: 2px; border-radius: 50%; background: var(--navy);
  border: 3px solid var(--mint);
  box-shadow: 0 0 0 2px rgba(18, 40, 76, .35), 0 1px 5px rgba(0, 0, 0, .4);
  animation: pulse 1.8s infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(111, 227, 185, .25), 0 1px 5px rgba(0, 0, 0, .4); } }

/* Map controls */
.leaflet-bar, .leaflet-control-layers {
  border: none !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow) !important;
  overflow: hidden;
  background: #faf8f3;
}
.leaflet-bar a { background: #faf8f3; color: #12284c; border-bottom-color: var(--line); transition: background .15s var(--ease); }
.leaflet-bar a:hover { background: var(--mint-tint); color: #12284c; }
.leaflet-control-layers { font-family: inherit; color: var(--ink); }
.leaflet-control-layers-expanded { padding: 8px 12px; }
.leaflet-control-layers-toggle { background-color: #faf8f3; }
.leaflet-tooltip {
  background: var(--navy); color: #fff; border: none; border-radius: 8px;
  box-shadow: var(--shadow); padding: 5px 9px; font-size: .78rem;
}
.leaflet-tooltip-top:before { border-top-color: var(--navy); }
.leaflet-control-attribution { background: rgba(250, 248, 243, .85) !important; }

/* -------------------------------------------------------------- responsive */

/* Phones: the panel becomes a bottom sheet; the map keeps the area above it. */
@media (max-width: 760px) {
  :root { --sidebar-w: 100%; --brand-h: 56px; }

  #map { left: 0; bottom: var(--sheet-h); transition: bottom .3s var(--ease); }

  .sidebar {
    top: auto;
    height: var(--sheet-h);
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .brand { border-radius: 16px 16px 0 0; padding-top: 14px; }
  .brand::before { /* grab handle */
    content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px;
    margin-left: -18px; border-radius: 2px; background: rgba(255, 255, 255, .45);
  }
  .brand p { display: none; }
  .sidebar.hidden { transform: translateY(calc(100% - var(--brand-h) - env(safe-area-inset-bottom))); }
  body.panel-hidden #map { bottom: var(--brand-h); }
  .collapse { transform: rotate(-90deg); }
  .sidebar.hidden .collapse { transform: rotate(90deg); }
  .reopen { display: none !important; }

  /* Directions come first while navigating; Start / Demo stay pinned to the bottom of the sheet. */
  .nav-banner { order: 1; margin-top: 8px; }
  .search-card { order: 2; }
  .context { order: 3; margin-bottom: 8px; }
  .hint { order: 4; margin-bottom: 8px; }
  .summary { order: 5; position: sticky; bottom: 0; z-index: 4; margin-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -4px 14px rgba(18, 40, 76, .14); padding: 12px 14px; }
  .summary-time { font-size: 1.5rem; }
  .nav-actions { margin-top: 10px; }
  .steps { order: 6; }
  .credits { order: 7; }
  .leaflet-top.leaflet-right { top: 0; }
}

/* Short landscape phones: let the map have more room. */
@media (max-width: 760px) and (max-height: 500px) {
  :root { --sheet-h: 62%; }
}

@media (min-width: 761px) and (max-width: 1023px) {
  :root { --sidebar-w: 340px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Location nodes (map markers) */
.poi-node {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .3));
  transition: filter .15s ease;
  cursor: pointer;
}
.poi-node:hover { filter: drop-shadow(0 0 5px rgba(95, 220, 176, .95)); }
.poi-node.poi-selected { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .35)); }
.poi-node.poi-selected:hover { filter: drop-shadow(0 0 6px rgba(95, 220, 176, .95)); }

.dest-pin svg { display: block; overflow: visible; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
