/* Whichway Atlas: a full-window map with docked panels (palette and chart styles come from ../styles.css). */
body.atlas { --head-h: 56px; --dock-w: 400px; --tl-h: 104px; --ink: var(--text-primary);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; height: 100vh; height: 100dvh; overflow: hidden; background: var(--surface-1); }
.mono, .num, .clock { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
body.atlas button { font: inherit; }

/* header */
.atlas-head { height: var(--head-h); display: flex; align-items: center; gap: 22px; padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--surface-1); position: relative; z-index: 6; }
.atlas-brand { font-weight: 700; font-size: 18px; color: var(--text-primary); letter-spacing: -.01em; white-space: nowrap; }
.atlas-brand span { font-weight: 400; color: var(--text-secondary); }
.atlas-brand:hover { text-decoration: none; }
.mode { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.mode .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--de-emphasis); }
.mode.live .dot { background: var(--status-good); box-shadow: 0 0 0 0 var(--status-good); animation: livepulse 2s infinite; }
.mode.scheduled .dot, .mode.replay .dot { background: var(--status-warning); }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--status-good) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.kpis { display: flex; gap: 18px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; }
.kpis b { font: 600 16px "IBM Plex Mono", monospace; color: var(--text-primary); margin-right: 4px; }
.kpis .kpi-crit b { color: var(--status-critical); } .kpis .kpi-warn b { color: color-mix(in oklab, var(--status-warning) 70%, var(--text-primary)); }
.head-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search { width: 280px; }
.search .combo-list { width: 360px; right: 0; left: auto; }
.clock { font-size: 13px; color: var(--text-secondary); }

/* layout */
.atlas-body { position: relative; height: calc(100% - var(--head-h)); display: flex; }
.dock { width: var(--dock-w); flex: none; background: var(--surface-1); display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 4; transition: margin .22s ease; }
.dock.left { border-right: 1px solid var(--border); }
.dock.right { border-left: 1px solid var(--border); }
.dock.left.closed { margin-left: calc(-1 * var(--dock-w)); }
.dock.right.closed { margin-right: calc(-1 * var(--dock-w)); }
.dock.wide { --dock-w: 560px; }
.dock-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px 0; min-height: 44px; border-bottom: 1px solid var(--border); }
.dock.left .dock-head { padding-bottom: 10px; }
.dock-title { font-weight: 600; font-size: 15px; flex: 1; }
.dock-close { margin-left: auto; font-size: 13px; }
.dock-body { flex: 1; overflow-y: auto; padding: 18px; min-height: 0; overscroll-behavior: contain; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; }
.tabs { display: flex; gap: 18px; flex: 1; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 0 0 10px; color: var(--text-secondary); cursor: pointer; font-weight: 500; }
.tabs button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--text-primary); font-weight: 600; }

.stage { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0 0 var(--tl-h) 0; background: #e6edf3; }
:root[data-theme="dark"] #map { background: #0e1116; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #map { background: #0e1116; } }
.dock-open { position: absolute; top: 12px; z-index: 3; display: none; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); border-radius: 6px; padding: 6px 10px; cursor: pointer; box-shadow: var(--shadow); font-size: 13px; }
.dock-open.left { left: 12px; } .dock-open.right { right: 12px; }
.dock-open.show { display: block; }

.map-card { position: absolute; z-index: 2; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.10); }
.layers-card { left: 12px; bottom: calc(var(--tl-h) + 12px); padding: 10px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; max-width: 220px; }
.layers-card.collapsed > :not(:first-child) { display: none; }
.layers-card .kicker { cursor: pointer; margin-top: 4px; }
.layers-card > .kicker:first-child::after { content: " ▾"; } .layers-card.collapsed > .kicker:first-child::after { content: " ▸ layers"; }
.layers-card label { display: flex; gap: 7px; align-items: center; cursor: pointer; color: var(--text-secondary); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-top: 2px; }
.seg button { border: 0; background: var(--surface-1); color: var(--text-secondary); padding: 4px 10px; cursor: pointer; font-size: 12px; }
.seg button.on { background: var(--text-primary); color: var(--surface-1); }
.legend-late { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--text-secondary); margin-top: 4px; }
.legend-late i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.k-good { background: var(--status-good); } .k-warn { background: var(--status-warning); } .k-crit { background: var(--status-critical); } .k-na { background: var(--de-emphasis); }

/* inspector: the selected train or station, floating over the map */
.inspector { right: 12px; top: 12px; width: 340px; max-height: calc(100% - var(--tl-h) - 24px); overflow-y: auto; padding: 16px 18px; }
.insp-head { display: flex; align-items: center; gap: 12px; }
.insp-head .t { font-size: 17px; font-weight: 600; line-height: 1.25; }
.insp-head .s { font-size: 12.5px; color: var(--text-secondary); }
.insp-close { position: absolute; top: 8px; right: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 6px; }
.stat3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 12px 0; margin: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.stat3 .l, .stat2 .l { font-size: 11.5px; color: var(--text-secondary); }
.stat3 .v { font-size: 18px; font-weight: 600; }
.stat2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.stat2 .v { font-size: 20px; font-weight: 600; line-height: 1.2; }
.stops-ahead { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; margin: 6px 0 12px; }
.stops-ahead div { display: flex; justify-content: space-between; gap: 10px; }
.stops-ahead .mono { color: var(--text-secondary); font-size: 12.5px; white-space: nowrap; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { flex: 1; min-height: 36px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); cursor: pointer; padding: 6px 12px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.btn.primary { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); font-weight: 600; }
.btn:hover { filter: brightness(1.05); }
.late-good { color: var(--success-text); } .late-warn { color: color-mix(in oklab, var(--status-warning) 65%, var(--text-primary)); } .late-crit { color: var(--status-critical); }

/* bullets */
.bullet { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px; flex: none; line-height: 1; }
.bullet.lg { width: 44px; height: 44px; font-size: 22px; }
.bullet.md { width: 32px; height: 32px; font-size: 15px; }
.bullet.sm { width: 20px; height: 20px; font-size: 10.5px; }
.bullet.dark { color: #111; }
.bullet.xs-text { font-size: 9px; }

/* left: line list and line detail */
.line-grid { display: flex; flex-direction: column; }
.line-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--grid); cursor: pointer; border-radius: 6px; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; color: inherit; width: 100%; }
.line-row:hover { background: var(--page); }
.line-row .n { font-weight: 600; }
.line-row .d { font-size: 12px; color: var(--text-secondary); }
.st-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.st-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--de-emphasis); }
.st-good .dot { background: var(--status-good); } .st-degraded .dot { background: var(--status-warning); } .st-disrupted .dot { background: var(--status-critical); }
.big-stat { font-size: 56px; font-weight: 600; line-height: 1; letter-spacing: -.03em; }
.lede { font-size: 14px; color: var(--text-secondary); margin: 6px 0 0; }
.section { padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--border); }
.section > .kicker { margin-bottom: 8px; display: block; }
.dirs { display: flex; gap: 6px; margin: 12px 0; }
.dirs button { border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; }
.dirs button.on { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.train-list { display: flex; flex-direction: column; }
.train-list button { display: grid; grid-template-columns: 1fr auto; gap: 8px; text-align: left; padding: 7px 4px; border: 0; border-bottom: 1px solid var(--grid); background: none; color: inherit; cursor: pointer; font-size: 13px; }
.train-list button:hover { background: var(--page); }
.train-list .sub { font-size: 11.5px; color: var(--text-secondary); }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; padding: 4px 0; }
.kv span:first-child { color: var(--text-secondary); }
.dock-body .chart svg { font-size: 13px; }

/* right: feed */
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); border-radius: 999px; padding: 3px 11px; cursor: pointer; font-size: 12.5px; }
.chip.on { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.chip .c { opacity: .7; margin-left: 3px; }
.feed { display: flex; flex-direction: column; }
.feed-item { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--grid); cursor: pointer; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; color: inherit; width: 100%; }
.feed-item:hover { background: var(--page); }
.feed-item .t { font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.feed-item .x { font-size: 12.5px; color: var(--text-secondary); line-height: 1.4; margin-top: 2px; }
.feed-item .m { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; margin-top: 4px; color: var(--muted); }
.feed-item .m.live { color: var(--status-critical); } .feed-item .m.warn { color: color-mix(in oklab, var(--status-warning) 60%, var(--text-primary)); } .feed-item .m.research { color: var(--series-1); }
.feed-item.closed .t { color: var(--text-secondary); font-weight: 500; }
.feed-item .icon { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--page); color: var(--text-secondary); font-size: 12px; }
.feed-item b, .feed-item strong { font-weight: 600; }

/* right: route */
.route-form { display: flex; flex-direction: column; gap: 8px; }
.route-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.route-form .combo { width: 100%; display: block; }
.route-form .combo-input { height: 40px; font-size: 15px; }
.route-tools { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--text-secondary); }
.opt { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-top: 10px; cursor: pointer; background: var(--surface-1); text-align: left; width: 100%; color: inherit; display: block; }
.opt.sel { border: 2px solid var(--text-primary); padding: 11px 13px; }
.opt .top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.opt .big { font-size: 24px; font-weight: 600; }
.opt .rng { font-size: 12.5px; color: var(--text-secondary); text-align: right; }
.opt .legs { display: flex; align-items: center; gap: 5px; font-size: 13px; margin: 6px 0; flex-wrap: wrap; }
.opt .why { font-size: 12.5px; color: var(--text-secondary); margin-top: 6px; }
.opt .deps { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.legbar { display: flex; height: 9px; border-radius: 5px; overflow: hidden; background: var(--page); margin: 8px 0 2px; }
.legbar span { display: block; height: 100%; }
.warn-line { font-size: 12.5px; margin-top: 4px; color: color-mix(in oklab, var(--status-warning) 60%, var(--text-primary)); }

/* right: stations */
.dep { display: grid; grid-template-columns: 54px 28px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--grid); }
.dep .min { font: 600 22px "IBM Plex Mono", monospace; }
.dep .to { font-size: 13.5px; line-height: 1.3; }
.dep .to .sub { font-size: 11.5px; color: var(--text-secondary); display: block; }
.dep .rng { font-size: 11.5px; color: var(--text-secondary); text-align: right; white-space: nowrap; }
.dep.gap { background: color-mix(in oklab, var(--status-warning) 12%, transparent); }
.target-row { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--grid); background: none; color: inherit; padding: 10px 4px; cursor: pointer; }
.target-row:hover { background: var(--page); }
.target-row .t { font-weight: 600; font-size: 13.5px; }
.target-row .x { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.note { padding: 10px 12px; background: color-mix(in oklab, var(--status-warning) 14%, var(--surface-1)); border-radius: 8px; font-size: 13px; margin: 10px 0; }
.note.info { background: var(--page); }

/* timeline (bottom of the map) */
.timeline { position: absolute; left: 0; right: 0; bottom: 0; height: var(--tl-h); background: var(--surface-1); border-top: 1px solid var(--border); padding: 10px 18px 8px; z-index: 3; display: flex; flex-direction: column; gap: 6px; }
.tl-top { white-space: nowrap; overflow: hidden; display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--text-secondary); }
.tl-top b { color: var(--text-primary); font-weight: 600; }
.tl-top .btn { flex: none; min-height: 28px; padding: 3px 10px; font-size: 12px; }
.tl-track { position: relative; height: 44px; cursor: pointer; touch-action: none; }
.tl-bars { position: absolute; inset: 0 0 12px 0; display: flex; align-items: flex-end; gap: 2px; }
.tl-bars span { flex: 1; background: var(--grid); border-radius: 2px 2px 0 0; min-height: 2px; }
.tl-bars span.past { background: color-mix(in oklab, var(--series-1) 35%, var(--grid)); }
.tl-range { position: absolute; bottom: 12px; height: 4px; background: var(--series-1); border-radius: 2px; }
.tl-ev { position: absolute; bottom: 10px; width: 3px; height: 8px; border-radius: 1px; background: var(--status-critical); }
.tl-head { position: absolute; top: -2px; bottom: 8px; width: 3px; margin-left: -1px; background: var(--text-primary); border-radius: 2px; }
.tl-head::after { content: ""; position: absolute; left: -5px; top: -4px; width: 13px; height: 13px; border-radius: 50%; background: var(--text-primary); }
.tl-track:focus { outline: none; }
.tl-track.kbd:focus { outline: 2px solid var(--series-1); outline-offset: 4px; border-radius: 4px; }
.tl-track.dragging { cursor: grabbing; }
.tl-head { cursor: grab; }
.tl-head::before { content: ""; position: absolute; left: -10px; right: -10px; top: -8px; bottom: -4px; }
.tl-tip { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); padding: 2px 6px; border-radius: 4px; background: var(--text-primary); color: var(--surface-1); font-size: 11px; white-space: nowrap; opacity: 0; transition: opacity .12s; pointer-events: none; }
.tl-track.dragging .tl-tip, .tl-track.kbd:focus .tl-tip { opacity: 1; }
.tl-axis { position: absolute; left: 0; right: 0; bottom: -4px; display: flex; justify-content: space-between; font: 10.5px "IBM Plex Mono", monospace; color: var(--muted); }

/* map popups and markers */
.maplibregl-popup-content { background: var(--surface-1); color: var(--text-primary); border-radius: 8px; padding: 8px 10px; font: 12.5px "IBM Plex Sans", sans-serif; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.maplibregl-popup-tip { border-top-color: var(--surface-1) !important; border-bottom-color: var(--surface-1) !important; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tl-h) + 24px); transform: translateX(-50%); background: var(--text-primary); color: var(--surface-1); padding: 8px 14px; border-radius: 8px; font-size: 13px; z-index: 20; max-width: 90vw; }
.empty-s { color: var(--text-secondary); font-size: 13px; padding: 14px 0; }
.small-print { font-size: 11.5px; color: var(--muted); margin-top: 14px; line-height: 1.45; }

/* narrow screens: the panels float over the map and only one is open at a time */
@media (max-width: 1100px) { body.atlas { --dock-w: 360px; } .kpis { display: none; } }
@media (max-width: 820px) {
  body.atlas { --tl-h: 84px; }
  .atlas-head { gap: 10px; padding: 0 12px; }
  .mode .txt { display: none; }
  .search { width: 150px; } .clock { display: none; }
  .dock { position: absolute; top: 0; bottom: 0; width: min(92vw, 400px); box-shadow: 0 0 32px rgba(0,0,0,.2); }
  .dock.left { left: 0; } .dock.right { right: 0; }
  .dock.left.closed { margin-left: calc(-1 * min(92vw, 400px)); } .dock.right.closed { margin-right: calc(-1 * min(92vw, 400px)); }
  .inspector { left: 12px; right: 12px; width: auto; top: auto; bottom: calc(var(--tl-h) + 12px); max-height: 50%; }
  .layers-card { top: 52px; bottom: auto; }
  .layers-card.collapsed { padding: 6px 10px; }
  .tl-desc { display: none; }
}
