/* Same palette and type as the campus-route-planner repo's web/styles.css */
:root {
  --paper: #f6f1e6;
  --ink: #1c2430;
  --muted: #5e6872;
  --faint: #8a8f94;
  --line: #e3d9c6;
  --green: #1f6b4a;
  --green-dark: #174e36;
  --gold: #e4b33a;
  --walk: #1557b0;
  --route: #e23b00;
  --frontier: #e4b33a;
  --settled: #1557b0;
  --radius: 12px;
  --serif: Palatino, "Palatino Linotype", "Iowan Old Style", "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #d5ddd8;
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#map { position: fixed; inset: 0; background: #d5ddd8; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }

/* ---------- panel ---------- */
.panel {
  position: fixed;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 22px 16px;
  background: rgba(246, 241, 230, 0.96);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(28, 36, 48, 0.18);
  overflow-y: auto;
  scrollbar-width: thin;
  z-index: 2;
}

.crumb { font-size: 12px; color: var(--muted); text-decoration: none; }
.crumb span { color: var(--faint); margin: 0 2px; }
.crumb:hover { color: var(--green); }

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
}
h1 {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.05;
}
.lede { margin: 8px 0 0; color: var(--muted); }

/* ---------- form ---------- */
.fields {
  position: relative;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.field {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  padding: 9px 48px 9px 12px;
}
.field + .field { border-top: 1px solid var(--line); }
.field label {
  grid-column: 2;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input {
  grid-column: 2;
  width: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: 500 15px/1.4 var(--sans);
}
.field input::placeholder { color: var(--faint); font-weight: 400; }
.fields:focus-within { outline: 2px solid var(--green); border-color: transparent; }
.dot {
  grid-row: 1 / 3;
  align-self: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--ink);
}
.dot.start { background: var(--gold); }
.dot.end { background: var(--green); }

.swap {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  z-index: 3;
  transition: color 0.15s, transform 0.25s;
}
.swap:hover { color: var(--green); transform: translateY(-50%) rotate(180deg); }

.suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 290px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 32px rgba(28, 36, 48, 0.16);
  z-index: 10;
}
.suggest li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.suggest li[aria-selected="true"], .suggest li:hover { background: #eef5f0; }
.suggest .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest mark { background: none; color: var(--green); font-weight: 700; }
.suggest .tag {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--muted);
  border: 1px solid var(--line);
}
.suggest .tag.sjsu { color: var(--green); border-color: rgba(31, 107, 74, 0.35); background: #eef5f0; }
.suggest .alias { color: var(--faint); font-size: 12px; }
.suggest .empty { color: var(--muted); cursor: default; background: none !important; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  transition: 0.15s;
}
.chips button:hover { color: var(--green); border-color: var(--green); }

.go {
  margin-top: 12px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  font-weight: 650;
  font-size: 15px;
  color: white;
  background: var(--green);
  transition: background 0.15s;
}
.go:not(:disabled):hover { background: var(--green-dark); }
.status { margin: 12px 0 0; min-height: 1.5em; font-size: 14px; color: var(--muted); }
.status.error { color: #b3361b; }

/* ---------- result ---------- */
.result[hidden] { display: none; }
.result {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  animation: rise 0.35s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  padding: 10px 14px;
  border-radius: var(--radius);
  background: white;
  border: 1px solid var(--line);
}
.stat span { display: block; font-family: var(--serif); font-size: 26px; font-weight: 600; line-height: 1.2; }
.stat small { color: var(--muted); font-size: 12px; }

.player {
  padding: 12px;
  border-radius: var(--radius);
  background: white;
  border: 1px solid var(--line);
}
.transport { display: flex; align-items: center; gap: 6px; }
.icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  transition: background 0.15s;
}
.icon:not(:disabled):hover { background: #eef5f0; }
.icon.primary { width: 44px; background: var(--green); border-color: transparent; color: white; }
.icon.primary:hover { background: var(--green-dark) !important; }
.icon .i-pause { display: none; }
.playing .icon .i-pause { display: block; }
.playing .icon .i-play { display: none; }

.speed { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.speed input { width: 84px; accent-color: var(--green); }
.speed output { width: 34px; font: 600 12px var(--mono); color: var(--muted); text-align: right; }

.scrub {
  position: relative;
  height: 5px;
  margin: 12px 0 10px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  cursor: pointer;
}
#scrub-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--settled), var(--gold), var(--route)); }

.live { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.live div { display: flex; flex-direction: column; }
.live b { font: 600 15px var(--mono); font-variant-numeric: tabular-nums; }
.live small { font-size: 11px; color: var(--muted); }
.log { margin: 10px 0 0; min-height: 2.9em; font: 12px/1.45 var(--mono); color: var(--muted); }
.log b { color: var(--ink); font-weight: 600; }
.log .k-pop { color: var(--settled); font-weight: 600; }
.log .k-relax { color: #a8790f; font-weight: 600; }
.log .k-done { color: var(--route); font-weight: 600; }

.code { border-radius: var(--radius); border: 1px solid var(--line); background: #fffdf8; overflow: hidden; }
.code summary {
  padding: 10px 14px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  list-style: none;
}
.code summary::-webkit-details-marker { display: none; }
.code summary::before { content: "▸"; display: inline-block; margin-right: 8px; transition: transform 0.2s; }
.code[open] summary::before { transform: rotate(90deg); }
.code summary code { font-family: var(--mono); color: var(--ink); }
.code pre { margin: 0; padding: 2px 0 10px; font: 11.5px/1.75 var(--mono); overflow-x: auto; color: #4a5562; }
.code pre span { display: block; padding: 0 14px; border-left: 3px solid transparent; transition: background 0.12s; white-space: pre; }
.code pre span.on { background: rgba(21, 87, 176, 0.1); border-left-color: var(--settled); color: var(--ink); }
.code pre span.on.relax { background: rgba(228, 179, 58, 0.18); border-left-color: var(--gold); }
.code pre span.on.stale { background: rgba(94, 104, 114, 0.1); border-left-color: var(--faint); }
.code pre i { color: var(--faint); font-style: normal; }
.code .note { margin: 0; padding: 10px 14px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.lg { width: 11px; height: 11px; border-radius: 50%; display: inline-block; border: 2px solid white; box-shadow: 0 0 0 1px rgba(28, 36, 48, 0.25); }
.lg.frontier { background: var(--frontier); }
.lg.settled { background: var(--settled); }
.lg.route { width: 20px; height: 6px; border-radius: 3px; background: var(--route); }

.credits { margin-top: auto; padding-top: 4px; border-top: 1px solid var(--line); }
.credits p { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- map chrome ---------- */
.mode {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  padding: 4px;
  gap: 2px;
  background: rgba(246, 241, 230, 0.96);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(28, 36, 48, 0.16);
  z-index: 2;
}
.mode button {
  padding: 7px 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  font-size: 13px;
}
.mode button[aria-pressed="true"] { background: var(--green); color: white; }

.maplibregl-ctrl-group { border-radius: 12px !important; overflow: hidden; box-shadow: 0 8px 24px rgba(28, 36, 48, 0.16) !important; }
.maplibregl-ctrl-group button { width: 34px; height: 34px; }
.maplibregl-ctrl-top-right { top: 62px; right: 6px; }

.pin { display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.pin .lbl {
  margin-bottom: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(28, 36, 48, 0.25);
}
.pin .stem { width: 2px; height: 18px; background: var(--ink); }
.pin .base { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--ink); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.pin.start .lbl { background: var(--gold); color: var(--ink); }
.pin.start .base { background: var(--gold); }
.pin.end .lbl { background: var(--green); color: white; }
.pin.end .base { background: var(--green); }

.hover-tip .maplibregl-popup-content {
  padding: 5px 10px;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(28, 36, 48, 0.18);
}
.hover-tip .maplibregl-popup-tip { display: none; }
.hover-tip small { color: var(--muted); margin-left: 6px; font-weight: 400; }

.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--paper);
  z-index: 20;
  transition: opacity 0.6s;
}
.loading.done { opacity: 0; pointer-events: none; }
.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- phones: panel becomes a bottom sheet ---------- */
@media (max-width: 760px) {
  .panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 46vh;
    padding: 14px 16px;
    gap: 14px;
    border-radius: 18px;
  }
  .intro .lede, .credits, .crumb { display: none; }
  h1 { font-size: 26px; }
  .mode { top: 10px; right: 10px; }
  .maplibregl-ctrl-top-right { top: 54px; }
  .code { display: none; }
}

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