/* Lines metro map. Tokens (colours, fonts) come from ../lines.css. */

body.metro { min-height: 100vh; }
.metro .masthead { padding-top: 18px; padding-bottom: 14px; }

.map-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px;
  padding: 10px var(--gutter); border-bottom: 1px solid var(--rule);
}
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend button {
  --c: var(--ink-3);
  display: inline-flex; align-items: center; gap: 7px;
  font: 700 0.9rem/1 var(--font); color: var(--ink);
  background: var(--paper); border: 1.5px solid var(--rule); border-radius: 999px;
  padding: 4px 11px 4px 4px; cursor: pointer;
}
.legend button:hover { border-color: var(--c); }
.legend button[aria-pressed="true"] { border-color: var(--c); background: var(--paper-2); box-shadow: inset 0 0 0 1.5px var(--c); }
.legend .disc {
  width: 22px; height: 22px; border-radius: 50%; background: var(--c); color: var(--badge-ink);
  display: grid; place-items: center; font-size: 0.8rem;
}
.map-tools { display: flex; align-items: center; gap: 10px; }
.map-tools input {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--rule); border-radius: 8px; padding: 7px 10px; width: 14rem; max-width: 46vw;
}
.map-tools input:focus { border-color: var(--ink); outline: none; }
.view-toggle { display: inline-flex; border: 1.5px solid var(--ink-3); border-radius: 8px; overflow: hidden; }
.view-toggle button { font: 700 0.88rem/1 var(--font); color: var(--ink-2); background: var(--paper); border: 0; padding: 8px 12px; cursor: pointer; }
.view-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.metro-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.map-wrap {
  position: relative; flex: none;
  height: max(520px, calc(100vh - 220px));
  overflow: hidden; background: var(--paper);
  touch-action: none; cursor: grab;
}
.map-wrap.dragging { cursor: grabbing; }
#map { position: absolute; inset: 0; display: block; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; }

/* tracks */
.casing { fill: none; stroke: var(--paper); stroke-width: 11; stroke-linejoin: round; stroke-linecap: round; }
.track { fill: none; stroke: var(--c); stroke-width: 7; stroke-linejoin: round; stroke-linecap: round; }
.track.stub { stroke-linecap: butt; }
.letter-disc { fill: var(--c); stroke: var(--paper); stroke-width: 2.5; }
.letter { fill: var(--badge-ink); font: 700 14px var(--font); text-anchor: middle; }

/* stations */
.stn { cursor: pointer; outline: none; }
.stn .dot { fill: var(--dot-fill); stroke: var(--c); stroke-width: 3.2; }
.stn.s1 .dot { stroke-width: 2.6; }
.stn .pill-edge { fill: none; stroke: var(--ink); stroke-linecap: round; }
.stn .pill { fill: none; stroke: var(--dot-fill); stroke-linecap: round; }
.stn .hit { fill: transparent; stroke: none; }
.stn:hover .dot, .stn:hover .pill-edge { filter: drop-shadow(0 0 3px var(--c, var(--ink))); }
.stn:focus-visible .hit, .stn.selected .hit { stroke: var(--focus); stroke-width: 3; }
.hub { cursor: default; outline: none; }
.theme { cursor: pointer; outline: none; }
.theme-halo { fill: var(--paper); stroke: var(--c); stroke-width: 3; }
.theme-disc { fill: var(--c); }
.theme-letter { fill: var(--badge-ink); font: 700 17px var(--font); text-anchor: middle; pointer-events: none; }
.theme .hit { fill: transparent; }
.theme:focus-visible .hit { stroke: var(--focus); stroke-width: 3; }
.theme-label { font-weight: 700; letter-spacing: 0.02em; }
.ghost { fill: var(--c); stroke: var(--paper); stroke-width: 1.5; display: none; }
.hub-ring { fill: var(--ink); }
.hub-fill { fill: var(--paper-2); }
.hub-plate { fill: var(--ink); }
.hub-name { fill: var(--paper); font: 700 12px var(--font); letter-spacing: 0.22em; text-anchor: middle; }
.hub:focus-visible .hub-ring { stroke: var(--focus); stroke-width: 4; }

.label {
  font-family: var(--font); font-weight: 700; fill: var(--ink);
  paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round;
  pointer-events: none;
}
.label.s1 { font-weight: 400; fill: var(--ink-2); }
.far .label.s1 { display: none; }
.far.focus-mode .label.on.s1 { display: inline; }

/* following one line */
.focus-mode .tracks [data-line]:not(.on),
.focus-mode .stn:not(.on),
.focus-mode .label:not(.on) { opacity: 0.13; transition: opacity 160ms ease; }

/* zoom + hint */
.zoom { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; border: 1.5px solid var(--rule); border-radius: 10px; overflow: hidden; background: var(--paper); }
.zoom button { font: 700 1.15rem/1 var(--font); width: 40px; height: 40px; border: 0; border-bottom: 1px solid var(--rule); background: var(--paper); color: var(--ink); cursor: pointer; }
.zoom button:last-child { border-bottom: 0; }
.zoom button:hover { background: var(--paper-2); }
.map-hint { position: absolute; left: 14px; bottom: 10px; margin: 0; font-size: 0.82rem; color: var(--ink-3); pointer-events: none; }

/* station card */
.card {
  position: absolute; top: 14px; right: 14px; width: min(340px, calc(100% - 28px));
  background: var(--paper); border: 1.5px solid var(--ink); border-radius: 12px;
  padding: 16px 16px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14); cursor: auto;
}
.card-close { position: absolute; top: 6px; right: 8px; font: 700 1.3rem/1 var(--font); background: none; border: 0; color: var(--ink-3); cursor: pointer; width: 32px; height: 32px; }
.card h2 { margin: 0 26px 6px 0; font-size: 1.2rem; line-height: 1.2; }
.card h2 a { text-decoration: none; border-bottom: 2px solid var(--rule); }
.card h2 a:hover { border-bottom-color: var(--ink); }
.card .note { margin: 0 0 8px; color: var(--ink-2); }
.card .where { margin: 0 0 10px; font-size: 0.85rem; color: var(--ink-3); }
.card .card-lines { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.card .card-lines button {
  --c: var(--ink-3);
  display: inline-flex; align-items: center; gap: 6px; font: 700 0.85rem/1 var(--font); color: var(--ink);
  background: var(--paper); border: 1.5px solid var(--rule); border-radius: 999px; padding: 3px 10px 3px 3px; cursor: pointer;
}
.card .card-lines .disc { width: 18px; height: 18px; border-radius: 50%; background: var(--c); color: var(--badge-ink); display: grid; place-items: center; font-size: 0.7rem; }
.card .open {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; text-decoration: none;
  background: var(--ink); color: var(--paper); border-radius: 8px; padding: 9px 14px;
}

/* list view */
.listview { padding: 22px var(--gutter) 60px; max-width: 980px; }
.listview:focus { outline: none; }
.lv-line { margin: 0 0 30px; }
.lv-line h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; font-size: 1.35rem; }
.lv-line h3 .disc { --c: var(--ink-3); width: 30px; height: 30px; border-radius: 50%; background: var(--c); color: var(--badge-ink); display: grid; place-items: center; font-size: 1rem; flex: none; }
.lv-line .blurb { margin: 0 0 10px 40px; color: var(--ink-2); }
.lv-line ol { margin: 0 0 0 40px; padding: 0; list-style: none; border-left: 6px solid var(--c); }
.lv-line li { padding: 6px 0 6px 16px; }
.lv-line li a { font-weight: 700; text-decoration: none; }
.lv-line li a:hover { text-decoration: underline; }
.lv-line li .note { display: block; color: var(--ink-2); font-size: 0.92rem; }
.lv-line li .also { display: block; color: var(--ink-3); font-size: 0.82rem; }

@media (max-width: 820px) {
  .map-bar { padding: 8px 16px; }
  .legend { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: 100%; padding-bottom: 2px; }
  .legend::-webkit-scrollbar { display: none; }
  .legend button { flex: none; }
  .map-tools { width: 100%; }
  .map-tools input { flex: 1; width: auto; max-width: none; }
  .map-wrap { height: max(440px, calc(100svh - 230px)); }
  .card { top: auto; bottom: 10px; right: 10px; left: 10px; width: auto; max-height: 46%; overflow: auto; }
  .map-hint { display: none; }
  .zoom { bottom: auto; top: 10px; right: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .focus-mode * { transition: none !important; }
}


/* live trains (live.mjs): stations people visited in the last hour or two
   pulse and get a train out along their line; earlier-today stations now
   and then. Reduced motion: no trains, rings hold still. */
.train { transition: opacity 450ms ease; }
.train.gone { opacity: 0; }
/* solid and glowing, so a train never reads as a (white, outlined) station */
.train-glow { fill: var(--c); opacity: 0.25; }
.train-car { fill: var(--c); stroke: var(--paper); stroke-width: 1.6; }
.train-lamp { fill: var(--paper); }
.focus-mode .trains [data-line]:not(.on) { opacity: 0.13; }
.live-ring {
  fill: none; stroke: var(--c, var(--ink)); stroke-width: 2.5; vector-effect: non-scaling-stroke; opacity: 0.6; pointer-events: none;
  transform-box: fill-box; transform-origin: center; animation: live-pulse 2.4s ease-out infinite;
}
@keyframes live-pulse { 0% { transform: scale(0.85); opacity: 0.7; } 100% { transform: scale(1.7); opacity: 0; } }
.stn.arrive .dot, .stn.arrive .pill-edge { animation: live-arrive 800ms ease-out; }
@keyframes live-arrive { 40% { filter: drop-shadow(0 0 6px var(--c, var(--ink))); } }
.live-key {
  position: absolute; left: 14px; top: 12px; margin: 0; display: flex; align-items: center; gap: 7px;
  font-size: 0.82rem; font-weight: 700; color: var(--ink-2); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 999px; padding: 4px 11px 4px 9px; cursor: help;
}
.live-key::before, .card .live-line.now::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-red); flex: none;
  animation: live-blink 1.6s steps(2, start) infinite;
}
@keyframes live-blink { 50% { opacity: 0.3; } }
.card .live-line { display: flex; align-items: center; gap: 7px; margin: 0 0 10px; font-size: 0.88rem; font-weight: 700; color: var(--ink-2); }
.lv-line li .live-tag {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--line-red); border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: 2px;
}
@media (max-width: 820px) { .live-key { top: 10px; left: 10px; } }
@media (prefers-reduced-motion: reduce) {
  .live-ring, .live-key::before, .card .live-line.now::before, .stn.arrive .dot, .stn.arrive .pill-edge { animation: none; }
  .live-ring { transform: scale(1.25); }
}
