/* SEPTA's maps, /septa/map and /septa/bus-map (story #1531), over site.css. The bus map's lines
   keep their width in screen pixels however far it is zoomed (vector-effect); the rail map's
   diagram scales like a printed map. */

:root {
  --map-bg: #ffffff;
  --map-bus: #8a93a8;
  --map-frequent: #ef3340;
  --map-label: #2b3550;
  --map-halo: #ffffff;
  --map-rail: #4f758b;
}

:root[data-theme="dark"] {
  --map-bg: #0f1730;
  --map-bus: #4c5878;
  --map-frequent: #ff6b78;
  --map-label: #d6dcee;
  --map-halo: #0f1730;
  --map-rail: #8fb3c7;
}

.line-map-page h1 {
  font-size: clamp(36px, 7vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 4px 0 12px;
}

.line-map-page h2 {
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 40px 0 6px;
}

.line-map-page .hero { padding-top: 40px; }

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lede { font-size: 20px; color: var(--muted); max-width: 46em; }

/* The map */

.line-map {
  position: relative;
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--map-bg);
  overflow: hidden;
}

.line-map .map {
  display: block;
  width: 100%;
  height: auto;
  min-height: 320px;
  max-height: min(78vh, 760px);
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.line-map .map.dragging { cursor: grabbing; }

.map .line {
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.map .mode-bus .line { stroke: var(--map-bus); stroke-width: 1.1px; }
.map .mode-bus .line.frequent { stroke: var(--map-frequent); stroke-width: 1.6px; }
.map .mode-regional_rail .line { stroke-width: 3px; }
.map .mode-metro .line { stroke-width: 4px; }

/* SEPTA paints every Regional Rail line the same slate; dark mode lightens it. */
:root[data-theme="dark"] .map .mode-regional_rail .line { stroke: var(--map-rail); }

.map .termini text {
  fill: var(--map-label);
  font-size: 120px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--map-halo);
  stroke-width: 3px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  dominant-baseline: middle;
  pointer-events: none;
}

/* Layers turned off with the checkboxes. */
.line-map.hide-bus .mode-bus,
.line-map.hide-metro .mode-metro,
.line-map.hide-regional_rail .mode-regional_rail { display: none; }

.map-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.map-layers,
.map-zoom {
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  font-size: 14px;
}

.map-layers legend { float: left; font-weight: 700; margin-right: 4px; }
.map-layers label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.map-zoom { padding: 4px; gap: 4px; }

.map-zoom button {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* Without JavaScript the map can't be zoomed, so the controls would do nothing. */
.line-map:not(.ready) .map-controls { display: none; }

.map-pick {
  position: absolute;
  right: 10px;
  bottom: 10px;
  margin: 0;
  padding: 4px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}

.line-map:not(.ready) .map-pick { display: none; }

/* The line diagram, in its own units (about a station apart), so it scales like a printed map. */

:root {
  --d-ink: #1b2030;
  --d-name: #1b2030;
  --d-halo: #ffffff;
  --d-stop: #ffffff;
}

:root[data-theme="dark"] {
  --d-ink: #e8ecf7;
  --d-name: #e8ecf7;
  --d-halo: #0f1730;
  --d-stop: #0f1730;
}

.map.diagram .d-line {
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.map.diagram .d-regional_rail { stroke-width: 0.5; }
.map.diagram .d-metro { stroke-width: 0.75; }

:root[data-theme="dark"] .map.diagram .d-regional_rail { stroke: #8fb3c7; }

.map.diagram .d-interchange {
  stroke: var(--d-ink);
  stroke-width: 0.45;
  stroke-linecap: round;
}

.map.diagram .d-station { stroke: var(--d-ink); }
.map.diagram .s-rail { fill: var(--d-ink); stroke: none; }
.map.diagram .s-metro { fill: var(--d-stop); stroke: none; }
.map.diagram .s-interchange { fill: var(--d-stop); stroke-width: 0.18; }
.map.diagram .s-terminus { stroke-width: 0.18; }
.map.diagram .d-station.picked { stroke: var(--map-frequent); stroke-width: 0.35; }

.map.diagram .d-name {
  fill: var(--d-name);
  font-size: 0.95px;
  font-weight: 500;
  paint-order: stroke;
  stroke: var(--d-halo);
  stroke-width: 0.3px;
  stroke-linejoin: round;
  pointer-events: none;
}

.map.diagram .d-terminus-name { font-size: 1.5px; font-weight: 800; }

.map-section h2 { margin-top: 32px; }

/* The lists of lines */

.list-note { color: var(--muted); margin: 0 0 12px; max-width: 46em; }

.line-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px 20px;
}

.line-list li { display: flex; gap: 10px; align-items: baseline; }

.badge {
  flex: none;
  min-width: 44px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.line-list .lines-bus li { font-size: 15px; }

.about p { color: var(--muted); max-width: 46em; }

/* On a phone the controls would cover most of the map, so they go above it. */
@media (max-width: 600px) {
  .lede { font-size: 18px; }
  .line-map { margin-left: -4px; margin-right: -4px; }
  .map-controls { position: static; padding: 8px 8px 0; }
  .map-layers legend { display: none; }
  .map-pick { position: static; margin: 0 8px 8px; }
}

/* The bus map's key. Its swatches match the map's lines and the list's badges. */

.map-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: 10px 24px;
  margin: 14px 0 0;
}

.map-legend > div { display: flex; gap: 10px; align-items: center; }
.map-legend dt { flex: none; display: flex; gap: 8px; align-items: center; width: 96px; }
.map-legend dd { margin: 0; color: var(--muted); font-size: 15px; }
.map-legend dd strong { color: var(--ink); }

.key-line { display: inline-block; width: 36px; border-radius: 3px; }
.key-frequent { height: 4px; background: var(--map-frequent); }
.key-bus { height: 3px; background: var(--map-bus); }
.key-rail { height: 5px; background: var(--map-rail); }
.key-metro {
  height: 6px;
  background: linear-gradient(90deg, #0097d6 0 20%, #f26100 20% 40%, #5f249f 40% 60%, #5a960a 60% 80%, #ffd700 80%);
}
