/* The first-person scene is an enhancement. The original document layout is
   retained until WebGL is ready and whenever motion is disabled. */
.rail-ready:not(.motion-paused) .rail-scene {
  inset: 88px 0 0;
  width: 100%;
  height: calc(100svh - 88px);
  display: block;
  background: #e8e9db;
  opacity: 1;
}
.rail-ready:not(.motion-paused) .rail-scene canvas { width: 100%; height: 100%; }
.rail-ready:not(.motion-paused) .hero { min-height: 115svh; align-items: flex-start; padding-top: 58px; }
.rail-ready:not(.motion-paused) .hero-copy,
.rail-ready:not(.motion-paused) .station-copy {
  width: 370px;
  max-width: 35%;
  padding: 28px;
  background: rgba(245, 242, 233, 0.96);
  border: 1px solid rgba(97, 99, 91, 0.18);
  box-shadow: 0 12px 45px #263b370a;
  border-radius: 2px;
}
.rail-ready:not(.motion-paused) .hero h1 { font-size: clamp(60px, 6.1vw, 94px); margin: 25px 0; }
.rail-ready:not(.motion-paused) .hero-intro { font-size: 20px; }
.rail-ready:not(.motion-paused) .hero-description { font-size: 13px; line-height: 1.8; margin-top: 15px; }
.rail-ready:not(.motion-paused) .hero-actions { flex-wrap: wrap; gap: 12px 22px; margin-top: 24px; }
.rail-ready:not(.motion-paused) .hero-actions .button { min-height: 45px; padding: 10px 16px; gap: 15px; font-size: 12px; }
.rail-ready:not(.motion-paused) .hero-actions .text-link { font-size: 12px; }
.rail-ready:not(.motion-paused) .hero-role { font-size: 10px; margin-top: 24px; }
.rail-ready:not(.motion-paused) .hero .home-illustration,
.rail-ready:not(.motion-paused) .station-art { display: none; }
.rail-ready:not(.motion-paused) .hero-bottom { width: 100%; color: #263b37; bottom: 40px; }
.rail-ready:not(.motion-paused) .journey-heading-copy { width: 370px; max-width: 35%; background: var(--paper); padding: 24px; display: block; }
.rail-ready:not(.motion-paused) .journey-heading-copy > p:last-child { margin-top: 10px; }
.rail-ready:not(.motion-paused) .station { min-height: 145svh; display: flex; align-items: flex-start; padding-block: 65px 80px; }
.rail-ready:not(.motion-paused) .station-copy { position: relative; z-index: 1; }
.rail-ready:not(.motion-paused) .station-routes { gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.rail-ready:not(.motion-paused) .station-id { font-size: 9px; margin-bottom: 16px; }
.rail-ready:not(.motion-paused) .station h2 { font-size: clamp(35px, 3.5vw, 55px); }
.rail-ready:not(.motion-paused) .station-summary { font-size: 17px; margin-top: 22px; }
.rail-ready:not(.motion-paused) .station-contribution { font-size: 13px; line-height: 1.8; margin-top: 16px; }
.rail-ready:not(.motion-paused) .station-metric { margin: 22px 0 12px; }
.rail-ready:not(.motion-paused) .station-metric strong { font-size: 29px; }
.rail-ready:not(.motion-paused) .station-metric span { font-size: 9px; }
.rail-ready:not(.motion-paused) .station .text-link { font-size: 12px; }
.rail-ready:not(.motion-paused) .kitchen-link { margin-left: 0; }
.rail-ready:not(.motion-paused) .scene-coordinate { top: 24px; right: 32px; color: #344b40; }
.rail-ready:not(.motion-paused) .scene-caption { top: 50px; bottom: auto; right: 32px; left: auto; color: #344b40; }
.cab-telemetry {
  position: absolute; bottom: 88px; right: 32px;
  display: flex; align-items: center; gap: 22px;
  font: 10px/1.5 var(--mono); letter-spacing: 0.03em; color: #f5f2e9;
  background: #213a33ed; border: 1px solid #aab5a04d; padding: 10px 16px;
}
.cab-telemetry b { font-size: 22px; font-weight: 400; margin-right: 4px; }
.rail-ready:not(.motion-paused) .journey-controls { right: 32px; bottom: 24px; background: #f5f2e9f5; color: var(--ink); max-width: calc(100% - 40px); }
.rail-ready:not(.motion-paused) .journey-controls button:hover,
.rail-ready:not(.motion-paused) .journey-controls button[aria-expanded="true"],
.rail-ready:not(.motion-paused) .journey-controls button[aria-pressed="true"] { background: #dfdfd1; }
.rail-ready:not(.motion-paused) .journey-controls .current-stop { display: none; }
.rail-ready:not(.motion-paused) .drive-panel { right: 32px; bottom: 150px; }
.rail-ready:not(.motion-paused).rail-outside .rail-scene { opacity: 0; }
.rail-ready:not(.motion-paused) .network-section { position: relative; background: var(--paper); }
@media (max-width: 1050px) and (min-width: 761px) {
  .rail-ready:not(.motion-paused) .hero-copy, .rail-ready:not(.motion-paused) .station-copy { max-width: 38%; padding: 22px; }
  .rail-ready:not(.motion-paused) .hero h1 { font-size: 69px; }
  .rail-ready:not(.motion-paused) .scene-coordinate, .rail-ready:not(.motion-paused) .scene-caption { right: 20px; }
  .cab-telemetry { right: 20px; }
  .cab-telemetry > span:last-child { display: none; }
}
@media (max-width: 760px) {
  .rail-ready:not(.motion-paused) .rail-scene { inset: 78px 0 0; height: calc(100svh - 78px); }
  .rail-ready:not(.motion-paused) .hero { min-height: 155svh; padding-top: 46svh; padding-bottom: 100px; }
  .rail-ready:not(.motion-paused) .hero-copy, .rail-ready:not(.motion-paused) .station-copy {
    width: 100%; max-width: 100%; padding: 24px;
    background: rgba(245, 242, 233, 0.97);
  }
  .rail-ready:not(.motion-paused) .hero h1 { font-size: 66px; max-width: none; margin-block: 20px; }
  .rail-ready:not(.motion-paused) .hero-intro { max-width: none; font-size: 19px; }
  .rail-ready:not(.motion-paused) .hero-description { max-width: none; }
  .rail-ready:not(.motion-paused) .hero-bottom { display: none; }
  .rail-ready:not(.motion-paused) .journey-heading-copy { width: 100%; max-width: 100%; padding: 24px; }
  .rail-ready:not(.motion-paused) .station { min-height: 165svh; padding-top: 47svh; padding-bottom: 90px; }
  .rail-ready:not(.motion-paused) .station::before, .rail-ready:not(.motion-paused) .station::after { display: none; }
  .rail-ready:not(.motion-paused) .station h2 { font-size: 43px; }
  .rail-ready:not(.motion-paused) .scene-coordinate { display: block; top: 16px; right: auto; left: 20px; font-size: 8px; }
  .rail-ready:not(.motion-paused) .scene-caption { top: 36px; right: auto; left: 20px; font-size: 9px; }
  .cab-telemetry { bottom: auto; top: 60px; left: 20px; right: auto; padding: 7px 10px; gap: 12px; font-size: 8px; }
  .cab-telemetry b { font-size: 16px; }
  .cab-telemetry > span:last-child { display: none; }
  .rail-ready:not(.motion-paused) .journey-controls { left: 50%; right: auto; bottom: 12px; width: max-content; max-width: calc(100% - 16px); }
  .rail-ready:not(.motion-paused) .journey-controls button { font-size: 9px; padding: 10px 8px; }
  .rail-ready:not(.motion-paused) .journey-controls #map-toggle { padding-inline: 12px; }
  .rail-ready:not(.motion-paused) .drive-panel { bottom: 76px; right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .rail-ready:not(.motion-paused) .rail-scene { display: none !important; }
}
@media print {
  .rail-ready:not(.motion-paused) .rail-scene { display: none; }
  .rail-ready:not(.motion-paused) .hero, .rail-ready:not(.motion-paused) .station { min-height: 0; padding: 20px 0; }
  .rail-ready:not(.motion-paused) .hero-copy, .rail-ready:not(.motion-paused) .station-copy { width: 100%; max-width: none; border: 0; padding: 0; box-shadow: none; }
}

/* Cab mode owns the viewport. Reading mode retains the document above. */
body.immersive { overflow: hidden; overscroll-behavior: none; height: 100dvh; background: #233b34; }
.immersive .site-header, .immersive .site-footer,
.immersive .railway > :not(.rail-scene),
.immersive .network-section, .immersive .about-section, .immersive .contact-section,
.immersive .drive-panel { display: none !important; }
.immersive .railway { isolation: auto; }
.rail-ready.immersive:not(.motion-paused) .rail-scene {
  inset: 0; width: 100%; height: 100dvh; z-index: 0; opacity: 1;
  background: #c9dcd9;
  pointer-events: auto;
}
.immersive #rail-canvas { touch-action: none; cursor: grab; }
.immersive #rail-canvas:active { cursor: grabbing; }
.rail-ready.immersive:not(.motion-paused) .scene-coordinate,
.rail-ready.immersive:not(.motion-paused) .scene-caption,
.immersive .cab-telemetry { display: none; }
.cab-interface { position: fixed; inset: 0; z-index: 10; pointer-events: none; color: #f5f2e9; }
.cab-interface a, .cab-interface button, .cab-stop-card { pointer-events: auto; }
.cab-brand {
  position: absolute; top: max(26px, env(safe-area-inset-top)); left: max(30px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 12px;
  color: #173b32; font: 700 11px/1.5 Arial, sans-serif; letter-spacing: .10em;
  background: #f5f2e9e8; border: 1px solid #f5f2e940; border-radius: 4px; padding: 9px 12px;
}
.cab-brand-mark { border: 1px solid #173b3259; border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; font: 17px Georgia, serif; letter-spacing: -.06em; }
.cab-brand small { display: block; font: 10px/1.5 var(--mono); letter-spacing: 0; margin-top: 3px; }
.cab-route { position: absolute; top: 38px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; color: #29493c; font: 9px var(--mono); letter-spacing: .09em; }
.cab-route-dot { width: 6px; height: 6px; border-radius: 50%; background: #4b6b47; box-shadow: 0 0 0 4px #4b6b4712; }
.rail-ready.immersive:not(.motion-paused) .journey-controls {
  top: max(24px, env(safe-area-inset-top)); right: max(28px, env(safe-area-inset-right)); bottom: auto; left: auto;
  transform: none; max-width: none; width: auto; padding: 4px; gap: 2px;
  background: #193c33eb; color: #f5f2e9; border: 1px solid #f5f2e92e;
  border-radius: 6px; box-shadow: 0 4px 20px #172d3214;
}
.immersive .journey-controls #look-toggle, .immersive .journey-controls #drive-toggle { display: none; }
.immersive .journey-controls button { min-height: 44px; }
.immersive .journey-controls #motion-toggle { width: 38px; padding: 8px; font-size: 0; }
.immersive .journey-controls #motion-toggle::before { content: "Ⅱ"; font-size: 17px; }
.immersive .journey-controls #map-toggle { background: transparent; color: #f5f2e9; padding-inline: 13px; font-size: 11px; }
.immersive .journey-controls #view-toggle { padding-inline: 13px; font-size: 11px; }
.rail-ready.immersive:not(.motion-paused) .journey-controls button:hover { color: #193c33; background: #f5f2e9; }
.rail-ready.immersive:not(.motion-paused) .journey-controls button[aria-pressed="true"] { color: #193c33; background: #e1e7d4; }
.cab-stop-card {
  position: absolute; left: max(30px, env(safe-area-inset-left)); bottom: max(30px, env(safe-area-inset-bottom));
  width: 345px; padding: 22px 24px 15px; border-radius: 4px;
  background: #15362deb; border: 1px solid #d9e3ca45; box-shadow: 0 8px 36px #102e251c;
  backdrop-filter: blur(18px);
}
.cab-stop-eyebrow { color: #c4d4b8; font: 9px/1.6 var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.cab-stop-card h1 { font-size: 35px; line-height: 1.05; letter-spacing: -.045em; margin: 12px 0 11px; }
#cab-stop-summary { color: #dce5d3; font: 12px/1.7 Arial, sans-serif; max-width: 280px; }
#cab-details { width: 100%; display: flex; align-items: center; justify-content: space-between; margin-top: 14px; min-height: 44px; padding: 5px 0; border: 0; border-top: 1px solid #dce5d333; color: #fff7e5; text-align: left; font-size: 11px; }
#cab-details:hover { color: #e2b879; }
.cab-driving {
  position: absolute; right: max(30px, env(safe-area-inset-right)); bottom: max(30px, env(safe-area-inset-bottom));
  width: 330px; pointer-events: auto;
}
.cab-driving-help { margin: 0 0 12px; color: #f5f2e9; text-align: center; font: 10px/1.6 var(--mono); text-shadow: 0 1px 6px #102d25; }
.cab-driving-buttons { display: flex; gap: 7px; }
.cab-driving-buttons button {
  min-height: 62px; display: flex; align-items: center; justify-content: center; gap: 14px;
  border: 1px solid #e2e7d299; border-radius: 5px; background: #f2f0e6f2;
  color: #1c3a31; font: 12px Arial, sans-serif; flex: 1; touch-action: none; user-select: none;
  box-shadow: 0 5px 20px #102d2526; -webkit-user-select: none;
}
.cab-driving-buttons button > span[aria-hidden] { font-size: 26px; line-height: 1; }
.cab-driving-buttons #cab-brake { flex: 0 0 62px; flex-direction: column; gap: 3px; font-size: 9px; background: #173b32f2; color: #f4eedb; }
.cab-driving-buttons #cab-brake > span[aria-hidden] { font-size: 17px; }
.cab-driving-buttons button:hover, .cab-driving-buttons button.engaged { background: #d6dfbd; border-color: #d6dfbd; }
.cab-driving-buttons #cab-brake:hover { background: #315347; }
.cab-driving-footer { margin-top: 8px; min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 15px; background: #173b32ed; border: 1px solid #e2e7d23d; border-radius: 4px; padding: 3px 12px; font: 9px var(--mono); }
.cab-driving-footer button { border: 0; padding: 6px 0; min-height: 36px; font-size: 10px; color: #f5f2e9; }
#cab-hud-speed { font: 22px Arial, sans-serif; font-variant-numeric: tabular-nums; margin-right: 3px; }
.cab-driving-footer small { font-size: 8px; }
#cab-gear { color: #d0debd; font-size: 8px; letter-spacing: .06em; }
.cab-live-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#stop-dialog { width: min(620px, calc(100% - 28px)); max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); border: 1px solid #b6bdac; border-radius: 6px; padding: 0; background: #f5f2e9; }
.immersive #map-dialog { max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
#stop-dialog::backdrop { background: #102b2566; backdrop-filter: blur(6px); }
.stop-dialog-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px 26px; background: #f5f2e9; border-bottom: 1px solid #d6d5ca; z-index: 1; }
#stop-close { border: 0; min-width: 44px; min-height: 44px; font-size: 27px; }
#stop-dialog-content { padding: 28px 32px 36px; }
#stop-dialog-content .hero-copy, #stop-dialog-content .station-copy { width: 100%; max-width: none; padding: 0; border: 0; background: transparent; box-shadow: none; }
#stop-dialog-content h1, #stop-dialog-content h2 { font-size: 48px; margin: 18px 0; }
#stop-dialog-content .hero-role { margin-top: 20px; }
#stop-dialog-content .hero-intro { margin-top: 20px; }
#stop-dialog-content .hero-description { margin-top: 18px; }
#stop-dialog-content .hero-actions { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 25px; }
.immersive .skip-link:focus { z-index: 60; }
@media (max-width: 900px) {
  .cab-route { display: none; }
  .cab-stop-card { width: 295px; }
  .cab-driving { width: 290px; }
}
@media (max-width: 600px) {
  .cab-brand { top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); gap: 8px; font-size: 9px; letter-spacing: .04em; padding: 7px 8px; }
  .cab-brand-mark { width: 30px; height: 30px; font-size: 14px; }
  .cab-brand small { font-size: 8px; margin-top: 1px; }
  .rail-ready.immersive:not(.motion-paused) .journey-controls { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); padding: 2px; gap: 0; }
  .immersive .journey-controls #motion-toggle { width: 28px; min-height: 44px; padding-inline: 4px; }
  .immersive .journey-controls #map-toggle, .immersive .journey-controls #view-toggle { font-size: 9px; padding: 8px; min-height: 44px; }
  .immersive .journey-controls #map-toggle > span { display: none; }
  .cab-stop-card { left: max(16px, env(safe-area-inset-left)); bottom: calc(179px + env(safe-area-inset-bottom)); width: calc(100% - 32px); padding: 13px 17px 8px; }
  .cab-stop-eyebrow { font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cab-stop-card h1 { font-size: 27px; margin: 7px 0 0; }
  #cab-stop-summary { display: none; }
  #cab-details { margin-top: 6px; min-height: 39px; font-size: 10px; }
  .cab-driving { left: max(16px, env(safe-area-inset-left)); right: max(16px, env(safe-area-inset-right)); bottom: calc(15px + env(safe-area-inset-bottom)); width: auto; }
  .cab-driving-help { font-size: 8px; margin-bottom: 8px; }
  .desktop-drive-help { display: none; }
  .cab-driving-buttons button { min-height: 54px; font-size: 11px; }
  .cab-driving-buttons #cab-brake { flex-basis: 54px; }
  .cab-driving-footer { margin-top: 6px; }
  #stop-dialog-content { padding: 20px 24px 30px; }
  #stop-dialog-content h1, #stop-dialog-content h2 { font-size: 39px; }
}
@media (max-width: 360px) {
  .cab-brand > span:last-child { max-width: 108px; }
  .cab-brand small { font-size: 7px; }
  .cab-brand-mark { display: none; }
}
@media (max-height: 550px) and (orientation: landscape) {
  .cab-brand { top: max(12px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); }
  .rail-ready.immersive:not(.motion-paused) .journey-controls { top: max(10px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); }
  .cab-stop-card { bottom: max(16px, env(safe-area-inset-bottom)); left: max(16px, env(safe-area-inset-left)); width: 260px; padding: 13px 18px 8px; }
  .cab-stop-card h1 { font-size: 27px; margin: 7px 0; }
  #cab-stop-summary { display: none; }
  #cab-details { margin-top: 8px; }
  .cab-driving { bottom: max(16px, env(safe-area-inset-bottom)); right: max(16px, env(safe-area-inset-right)); width: 280px; }
  .cab-driving-help { display: none; }
  .cab-driving-buttons button { min-height: 48px; }
}

/* Keep the Tube desk and the driver's hands clear of the reading card. */
@media (min-width: 901px) and (min-height: 551px) {
  .cab-stop-card { top: 108px; bottom: auto; width: 300px; padding: 17px 20px 10px; }
  .cab-stop-card h1 { font-size: 30px; }
}
.cab-route { color: #e0e5df; background: #13212bd9; border: 1px solid #dce6e129; border-radius: 20px; padding: 9px 13px; top: 30px; }
.cab-route-dot { background: #b9d69a; }
@media (max-width: 600px) and (min-height: 551px) {
  .cab-stop-card { top: calc(76px + env(safe-area-inset-top)); bottom: auto; display: grid; grid-template-columns: 1fr 42px; column-gap: 8px; padding: 11px 15px; }
  .cab-stop-eyebrow { grid-column: 1 / -1; }
  .cab-stop-card h1 { grid-column: 1; font-size: 24px; align-self: center; }
  #cab-details { grid-column: 2; grid-row: 2; border: 1px solid #dce5d34a; border-radius: 50%; width: 40px; height: 40px; justify-content: center; font-size: 0; margin-top: 4px; }
  #cab-details > span { font-size: 18px; }
}
