:root {
  --tfl-blue: #10069F;
  --ink: #1D1D1B;
  --muted: #5F6368;
  --paper: #FFFFFF;
  --rule: #DCDCDA;
  --off: #C9CBCC;
  --font: 'Jost', 'Gill Sans', 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #F2F2F0; font-family: var(--font); color: var(--ink); }
#map { position: absolute; inset: 0; }

.maplibregl-ctrl-attrib { font-family: var(--font); }

button.icon { border: 0; background: none; color: inherit; cursor: pointer; padding: 6px; border-radius: 6px; display: grid; place-items: center; }
button.icon:hover { background: rgba(255,255,255,.15); }
:focus-visible { outline: 3px solid #FFCD00; outline-offset: 2px; }

/* ---------- panel: the TfL map key ---------- */
#panel {
  position: absolute; top: 16px; left: 16px; width: 300px; max-height: calc(100% - 32px);
  display: flex; flex-direction: column; background: var(--paper); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 10, 40, .35); overflow: hidden; z-index: 2;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; background: var(--tfl-blue); color: #fff; }
.brand h1 { font-size: 19px; font-weight: 500; margin: 0; flex: 1; letter-spacing: .01em; }
.mark { flex: none; border-radius: 7px; box-shadow: 0 0 0 1.5px rgba(255,255,255,.6); }
#collapse svg { transition: transform .2s; }
#panel.collapsed #collapse svg { transform: rotate(180deg); }
#panel.collapsed #panel-body { display: none; }
#panel-body { overflow-y: auto; padding: 4px 0 10px; overscroll-behavior: contain; }

section { padding: 10px 14px; border-bottom: 1px solid var(--rule); }
.toggles { display: grid; gap: 6px; }

.switch { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--off); position: relative; margin: 0; cursor: pointer; transition: background .15s; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--tfl-blue); }
.switch input:checked::after { transform: translateX(14px); }

.trains { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.speed { display: flex; border: 1.5px solid var(--tfl-blue); border-radius: 6px; overflow: hidden; }
.speed input { position: absolute; opacity: 0; pointer-events: none; }
.speed span { display: block; padding: 2px 8px; font-size: 13px; font-weight: 500; color: var(--tfl-blue); cursor: pointer; }
.speed input:checked + span { background: var(--tfl-blue); color: #fff; }
.speed input:focus-visible + span { outline: 3px solid #FFCD00; }

/* key: each line is a bar in its own colour, like the TfL map key */
.mode { padding: 10px 14px 4px; }
.mode-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.mode-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.mode-head button { border: 0; background: none; color: var(--tfl-blue); font: 500 13px var(--font); cursor: pointer; padding: 2px 4px; }
.bar {
  display: block; width: 100%; border: 0; text-align: left; cursor: pointer; margin: 0 0 3px;
  padding: 3px 10px; border-radius: 3px; font: 500 14px/1.35 var(--font); color: #fff;
  background: var(--c); transition: background .15s, color .15s;
}
.bar.light { color: var(--ink); }
.bar[aria-pressed="false"] { background: repeating-linear-gradient(90deg, var(--c) 0 6px, transparent 6px 10px) bottom / 100% 3px no-repeat, #F2F2F0; color: var(--muted); }
.bar:hover { filter: brightness(1.08); }
.mode.rail .bar { padding: 1px 10px; font-size: 13px; }

.note { margin: 10px 14px 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }

.search { display: grid; gap: 6px; }
.search label { font-size: 15px; font-weight: 500; }
.search input { font: 15px var(--font); padding: 7px 10px; border: 1.5px solid var(--off); border-radius: 6px; width: 100%; }
.search input:focus { border-color: var(--tfl-blue); outline: none; box-shadow: 0 0 0 3px rgba(16,6,159,.15); }

/* ---------- station card: a station nameboard ---------- */
#card {
  position: absolute; right: 16px; top: 16px; width: 280px; background: var(--paper); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 10, 40, .35); overflow: hidden; z-index: 2;
}
#card h2 { margin: 0; padding: 14px 40px 12px 16px; background: var(--tfl-blue); color: #fff; font-size: 22px; font-weight: 500; line-height: 1.15; }
#card .close { position: absolute; right: 6px; top: 8px; color: #fff; }
#card p { margin: 10px 16px 6px; font-size: 14px; color: var(--muted); }
#card ul { list-style: none; margin: 0; padding: 0 16px 14px; display: grid; gap: 3px; }
#card li { padding: 2px 10px; border-radius: 3px; color: #fff; font-size: 14px; font-weight: 500; background: var(--c); }
#card li.light { color: var(--ink); }
#card { max-height: calc(100% - 32px); display: flex; flex-direction: column; }
#card[hidden] { display: none; }
#card .times { border-top: 1px solid var(--rule); padding: 10px 16px 12px; overflow-y: auto; }
#card .times h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
#card #card-times { padding: 0; gap: 0; }
#card #card-times > li { background: none; color: var(--ink); padding: 0; border-radius: 0; border-bottom: 1px solid var(--rule); }
#card-times summary { display: flex; align-items: center; gap: 10px; padding: 7px 2px; cursor: pointer; font-size: 14px; list-style: none; }
#card-times summary::-webkit-details-marker { display: none; }
#card-times summary i { width: 14px; height: 14px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--rule); flex: none; }
#card-times summary span { flex: 1; }
#card-times summary b { font-weight: 600; font-variant-numeric: tabular-nums; }
#card-times ol { list-style: none; margin: 0 0 6px; padding: 0 0 0 24px; max-height: 180px; overflow-y: auto; }
#card #card-times ol li { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; padding: 2px 0; background: none; color: var(--ink); }
#card-times ol button { border: 0; background: none; padding: 0; font: inherit; color: var(--tfl-blue); cursor: pointer; text-align: left; }
#card-times ol button:hover { text-decoration: underline; }
#card-times ol span { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#card .times .hint { margin: 8px 0 0; font-size: 12.5px; }

/* reachable-area hover: journey time under the cursor */
#tip {
  position: absolute; z-index: 3; pointer-events: none; transform: translate(14px, -50%);
  background: var(--paper); border-radius: 6px; padding: 5px 10px; font-size: 14px; line-height: 1.3;
  box-shadow: 0 3px 12px rgba(0, 10, 40, .35); white-space: nowrap; display: flex; align-items: center; gap: 8px;
}
#tip[hidden] { display: none; }
#tip i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px var(--rule); flex: none; }
#tip b { font-weight: 600; font-variant-numeric: tabular-nums; }
#tip span { color: var(--muted); }

#loading {
  position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 3;
  background: var(--tfl-blue); color: #fff; padding: 8px 16px; border-radius: 20px; font-size: 15px;
}
#loading.done { display: none; }
#loading.error { background: #DA291C; }

@media (max-width: 640px) {
  #panel { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 55%; border-radius: 12px 12px 0 0; }
  #card { left: 16px; right: 16px; width: auto; top: 44px; } /* clear the attribution, which sits top-right on phones */
  /* the panel covers the bottom on phones: attribution moves to the top, zoom buttons go (pinch instead) */
  .maplibregl-ctrl-bottom-right { top: 0; bottom: auto; }
  .maplibregl-ctrl-group { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* planned stations: badge on the card */
.badge { display: inline-block; background: var(--ink); color: #fff; border-radius: 3px; padding: 0 6px; font-size: 12.5px; font-weight: 600; margin-right: 4px; }
