/* Google-Maps-inspired: white cards, soft shadows, Roboto, blue accents. Phone first. */
:root {
  --bg: #f1f3f4; --card: #fff; --ink: #202124; --muted: #5f6368; --line: #dadce0;
  --blue: #1a73e8; --green: #188038; --green-bg: #e6f4ea; --yellow: #b06000; --yellow-bg: #fef7e0;
  --red: #c5221f; --red-bg: #fce8e6; --off-bg: #e8eaed;
  --shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
}
* { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 Roboto, system-ui, sans-serif; }
a { color: var(--blue); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.topbar { gap: 10px;
   position: sticky; top: 0; z-index: 1000; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--card); box-shadow: var(--shadow); }
.brand { display: flex; gap: 10px; align-items: center; }
.brand b { display: block; font-size: 17px; }
.brand small { color: var(--muted); }
.logo { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff; display: grid;
  place-items: center; font-weight: 700; }
#updated { font-size: 12px; }

main { max-width: 980px; margin: 0 auto; padding: 12px 16px 24px; display: grid; gap: 12px; }
.card { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; }
h1, h2 { margin: 0 0 6px; font-weight: 500; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }

/* status */
.status { display: flex; gap: 14px; align-items: flex-start; }
.status p { margin: 0; color: var(--muted); }
.status-dot { flex: 0 0 18px; height: 18px; margin-top: 4px; border-radius: 50%; background: #9aa0a6; }
.status.green { background: var(--green-bg); } .status.green .status-dot { background: var(--green); }
.status.yellow { background: var(--yellow-bg); } .status.yellow .status-dot { background: #f9ab00; }
.status.red { background: var(--red-bg); } .status.red .status-dot { background: var(--red); }
.status.off { background: var(--off-bg); }
.status.green h1 { color: var(--green); } .status.yellow h1 { color: var(--yellow); } .status.red h1 { color: var(--red); }

/* alerts */
#alerts h2 { font-size: 15px; color: var(--muted); }
.alert { border-left: 4px solid var(--red); padding: 8px 12px; margin-top: 8px; background: #fff; }
.alert small { display: block; color: var(--muted); margin-top: 4px; }

/* map */
.map-card { padding: 0; overflow: hidden; }
#map { height: 52vh; min-height: 320px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 22px; height: 5px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.train { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.train-label { background: #fff; border: 0; border-radius: 10px; box-shadow: var(--shadow); padding: 2px 8px;
  font: 500 12px Roboto, sans-serif; color: var(--ink); white-space: nowrap; }
.train-label.long { color: var(--yellow); }
.leaflet-popup-content { font: 13px Roboto, sans-serif; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.chip { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 12px; text-align: center; }
.chip b { display: block; font-size: 22px; font-weight: 500; color: var(--blue); }
.chip span { font-size: 12px; color: var(--muted); }

/* planner */
.plan-form { display: grid; gap: 10px; }
.plan-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
select { font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.primary { font: 500 15px Roboto, sans-serif; padding: 11px; border: 0; border-radius: 20px; background: var(--blue); color: #fff; }
.link-btn { justify-self: start; border: 0; background: none; color: var(--blue); font: inherit; padding: 0; }
.plan-result { margin-top: 12px; }
.option { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 8px; }
.option.best { border-color: var(--blue); }
.option b { font-size: 18px; font-weight: 500; }
.option .steps { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }

/* calendar */
.cal { list-style: none; margin: 8px 0 0; padding: 0; }
.cal li { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.cal .date { text-align: center; color: var(--blue); font-weight: 500; line-height: 1.1; }
.cal .date span { display: block; font-size: 22px; }
.cal .tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--off-bg); color: var(--muted); }
.cal .tag.service { background: var(--yellow-bg); color: var(--yellow); }
.venues summary { cursor: pointer; color: var(--blue); margin-top: 10px; }
.venues li { margin: 6px 0; }

footer { max-width: 980px; margin: 0 auto; padding: 8px 16px 32px; font-size: 13px; color: var(--muted); }

@media (min-width: 900px) {
  main { grid-template-columns: 1fr 1fr; }
  #status, #alerts, .map-card, .stats, .linestatus-card, section[aria-labelledby="trains-h"] { grid-column: 1 / -1; }
  #map { height: 60vh; }
}
@media (max-width: 420px) {
  .chip b { font-size: 19px; }
}

/* trains right now */
.trow { border-top: 1px solid var(--line); padding: 10px 0; }
.trow:first-child { border-top: 0; }
.thead { margin-bottom: 6px; }
.ldot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.tsteps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 14px; }
.tsteps small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.warn { color: var(--yellow); font-weight: 500; }
@media (max-width: 520px) { .tsteps { grid-template-columns: 1fr; gap: 4px; } .tsteps > div { display: flex; gap: 8px; } .tsteps small { width: 40px; flex: none; } }

.clockbox { text-align: right; line-height: 1.15; }
.now-time { font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
#updated { display: block; font-size: 11px; }

.arrive-pop .leaflet-popup-content-wrapper { background: #e8f0fe; }

/* next-stop indicator: pulsing ring in the line colour */
.next-ring { width: 34px; height: 34px; border-radius: 50%; border: 3px solid; opacity: .85; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(.7); opacity: .9; } 50% { transform: scale(1.15); opacity: .45; } }
.next-label { background: #fff; border: 0; border-radius: 10px; box-shadow: var(--shadow); padding: 1px 7px; font: 500 11px Roboto, sans-serif; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .next-ring { animation: none; } }

/* train marker with direction arrow */
.train-wrap { position: relative; width: 44px; height: 44px; }
.train-wrap .train { position: absolute; left: 12px; top: 12px; }
.dir { position: absolute; inset: 0; }
.dir-tip { position: absolute; left: 50%; top: -4px; transform: translateX(-50%); width: 0; height: 0;
  border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 16px solid;
  filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 1px #fff); }

/* ticker */
.ticker { overflow: hidden; background: #202124; color: #e8eaed; font-size: 13px; white-space: nowrap; }
.ticker-track { display: inline-block; padding: 6px 0; animation: tick 40s linear infinite; }
.ticker-track span { padding: 0 6px; }
.ticker-track .sep { color: #8ab4f8; }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ticker-track { animation: none; white-space: normal; } }
.sound-btn { margin-left: auto; font-size: 20px; border: 1px solid var(--line); background: #fff; border-radius: 50%; width: 38px; height: 38px; cursor: pointer; }
.topbar { gap: 10px; }

.legend-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-right: 12px; }
.basemap-btn { font: 12px Roboto, sans-serif; color: var(--blue); background: none; border: 1px solid var(--line); border-radius: 14px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }

.map-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ring-key { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #6d27b8; background: #c9b3ea; margin-right: 6px; vertical-align: middle; }
/* line status */
.linestatus { display: grid; gap: 4px; margin-top: 6px; }
.ls-row { display: grid; grid-template-columns: 110px 1fr; background: #f1f3f4; border-radius: 6px; overflow: hidden; }
.ls-name { color: #fff; font-weight: 700; padding: 9px 12px; }
.ls-state { padding: 9px 12px; display: flex; align-items: center; gap: 8px; }
.ls-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.ls-dot.ok { background: var(--green); } .ls-dot.info { background: #f9ab00; } .ls-dot.bad { background: var(--red); } .ls-dot.idle { background: #bdc1c6; }

/* ride guides */
.guides { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }
.guide { position: relative; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 0 0 8px; overflow: hidden; cursor: pointer; font: inherit; color: var(--ink); }
.guide img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.guide .play { position: absolute; top: 28%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,.65); color: #fff; border-radius: 50%; width: 40px; height: 40px; display: grid; place-items: center; font-size: 16px; }
.guide b { display: block; padding: 6px 10px 0; font-weight: 500; font-size: 14px; }
.guide small { display: block; padding: 0 10px; color: var(--muted); font-size: 12px; }
.guide-frame { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 10px; }
.official { font-size: 13px; }
@media (max-width: 420px) { .guides { grid-template-columns: 1fr; } }

.transloc-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.transloc-links a { font-size: 13px; text-decoration: none; border: 1px solid var(--line); border-radius: 16px; padding: 5px 12px; background: #fff; }
