/*
 * Intermodal rail animation (A6). Renders inside Webflow's Shadow DOM: colours and fonts come in
 * through custom properties set from props. Sizes are stage pixels (1208 x 906, the WebM's size),
 * scaled to the component width. Panel sizes use --u (1px x --hud), so the list grows on narrow
 * screens; map markers scale on wrappers sync.ts never writes. The CSS defaults of everything
 * sync.ts writes are frame 0 on wide screens (the state before the script runs); the static copy
 * (.shim-zero) is written once with frame 0 when the timeline is built.
 */

.shim-root {
  --shim-accent: var(--_default---primary--ocean, #1c213d);
  --shim-progress: var(--_default---primary--sky, #00b2ff);
  --shim-highlight: var(--_default---primary--cloud-2, #f0f0f0);
  --shim-border: var(--_default---primary--cloud-3, #e7e7e7);
  --shim-warning: #ff7373;
  --shim-bg: var(--_default---swatch--neutral, #ffffff);
  --shim-white: #ffffff;
  --shim-font: var(--_typography---font--primary-family, "Fg Futurist", Arial, sans-serif);
  --shim-frame-radius: 8px;
  --shim-frame-border-color: var(--_default---primary--cloud-3, #e7e7e7);
  --shim-frame-border-width: 1px;
  --shim-inactive: color-mix(in srgb, var(--shim-accent) 40%, var(--shim-white));
  --shim-muted: color-mix(in srgb, var(--shim-accent) 60%, var(--shim-white));
  --shim-faint: color-mix(in srgb, var(--shim-accent) 45%, var(--shim-white));
  --shim-panel-w: 670px;
  --shim-card-left: calc(95 * var(--u));
  --shim-card-right: calc(43 * var(--u));
  --shim-badge-x: calc(20 * var(--u));
  --shim-gap: calc(27 * var(--u));
  --hud: 1;
  --u: calc(var(--hud) * 1px);

  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--shim-frame-radius);
  background: var(--shim-bg);
  font-family: var(--shim-font);
  color: var(--shim-accent);
  line-height: 1.25;
  isolation: isolate;
  contain: layout paint;
  container-type: inline-size;
  -webkit-font-smoothing: antialiased;
}

.shim-root[data-narrow="true"] {
  --shim-panel-w: 774px;
  --shim-card-left: calc(64 * var(--u));
  --shim-card-right: calc(12 * var(--u));
  --shim-badge-x: calc(12 * var(--u));
}

.shim-root *,
.shim-root *::before,
.shim-root *::after {
  box-sizing: border-box;
}

/* Frame border: drawn inside the root over everything, in screen pixels; on the root, it shows before the stage is ready */
.shim-root::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 10;
  border-radius: inherit;
  box-shadow: inset 0 0 0 var(--shim-frame-border-width) var(--shim-frame-border-color);
  pointer-events: none;
}

/* Webflow wraps the component in a div inside its shadow root; let it fill the parent */
:host > div:has(> .shim-root) {
  display: block;
  width: 100%;
}

/* ---------- stage and first load ---------- */

.shim-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1208px;
  height: 906px;
  overflow: hidden;
  transform-origin: 0 0;
}

/* Until the script has scaled the stage and built frame 0, only the CSS-sized poster shows */
.shim-root:not([data-ready="true"]) .shim-stage {
  opacity: 0;
}

.shim-root[data-ready="true"] .shim-poster {
  visibility: hidden;
}

.shim-poster {
  position: absolute;
  inset: 0;
}

/* The map image at geometry.ts MAP_RECT (43, -35.5, 1214 x 1005) */
.shim-poster__map {
  position: absolute;
  left: calc(43 / 1208 * 100%);
  top: calc(-35.5 / 906 * 100%);
  width: calc(1214 / 1208 * 100%);
  height: calc(1005 / 906 * 100%);
  max-width: none;
}

.shim-poster__panel {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: calc(670 / 1208 * 100%);
  background: var(--shim-bg);
}

/* Before the script has measured, the root's width alone decides the layout: below 604 px it is the narrow one */
@container (max-width: 603px) {
  .shim-poster__panel {
    width: calc(774 / 1208 * 100%);
  }

  /* Narrow frame 0: the camera rests on Shenyang at geometry.ts NARROW_REST_ZOOM (1.25), which the clamp turns into the map's top right corner */
  .shim-poster__map {
    left: auto;
    right: 0;
    top: 0;
    width: calc(1214 / 1208 * 125%);
    height: calc(1005 / 906 * 125%);
  }
}

.shim-scene {
  position: absolute;
  inset: 0;
}

/* The static frame-0 copy for the loop's crossfade (written once by a second sync at build) */
.shim-zero {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0;
  visibility: hidden;
}

/* ---------- map ---------- */

.shim-map {
  position: absolute;
  inset: 0;
}

.shim-map__layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 1208px;
  height: 906px;
  transform-origin: 0 0;
}

.shim-map__img {
  position: absolute;
  left: 43px;
  top: -35.5px;
  width: 1214px;
  height: 1005px;
  max-width: none;
  user-select: none;
}

.shim-routes {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
}

.shim-routes path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shim-route__casing {
  stroke: var(--shim-white);
  stroke-width: calc(14 * var(--u));
}

.shim-route__line {
  stroke: var(--shim-accent);
  stroke-width: calc(8 * var(--u));
}

.shim-marker {
  position: absolute;
  left: 0;
  top: 0;
}

.shim-marker__hud {
  position: absolute;
  left: 0;
  top: 0;
  scale: var(--hud);
}

/* Frame 0 positions (geometry.ts START, PIN1, PIN2): sync writes the same at t = 0 */
.shim-marker--vehicle {
  transform: translate(1108px, 65px);
}

.shim-marker--pin1 {
  transform: translate(1102px, 57px) scale(0);
}

.shim-marker--pin2 {
  transform: translate(727px, 858px);
}

.shim-pin {
  position: absolute;
  left: -24px;
  top: -24px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--shim-accent);
  color: var(--shim-white);
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--shim-white), 0 3px 8px rgb(28 33 61 / 0.3);
}

.shim-vehicle__halo,
.shim-vehicle__ring,
.shim-vehicle__body {
  position: absolute;
  left: -43px;
  top: -43px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
}

/* haloPulse(0) = 0.5: scale 1.25 + 0.2 x 0.5, opacity 0.22 + 0.18 x 0.5 */
.shim-vehicle__halo {
  background: var(--shim-progress);
  opacity: 0.31;
  transform: scale(1.35);
}

.shim-vehicle__ring {
  border: 4px solid var(--shim-progress);
  opacity: 0;
}

.shim-vehicle__body {
  background: var(--shim-accent);
  color: var(--shim-white);
  box-shadow: 0 0 0 3px var(--shim-white), 0 4px 12px rgb(28 33 61 / 0.3);
}

.shim-vehicle__icon {
  position: absolute;
  left: 20px;
  top: 20px;
  width: 46px;
  height: 46px;
}

.shim-vehicle__train {
  opacity: 0;
}

/* ---------- leg card and mode chips ---------- */

.shim-leg {
  position: absolute;
  left: 690px;
  top: 20px;
  z-index: 2;
  display: flex;
  gap: calc(14 * var(--u));
  align-items: flex-start;
  max-width: calc(1208px - 690px - 20px);
  padding: calc(14 * var(--u)) calc(18 * var(--u));
  border-radius: calc(14 * var(--u));
  background: var(--shim-white);
  box-shadow: 0 0 0 calc(1.5 * var(--u)) var(--shim-border), 0 calc(6 * var(--u)) calc(18 * var(--u)) rgb(28 33 61 / 0.12);
  opacity: 0;
  visibility: hidden;
}

/* Phones: along the bottom of the window, where the train only arrives once the card has gone (sync.ts) */
.shim-root[data-narrow="true"] .shim-leg {
  left: 786px;
  right: 12px;
  top: auto;
  bottom: 16px;
  max-width: none;
}

.shim-leg__icon {
  flex: none;
  width: calc(32 * var(--u));
  height: calc(32 * var(--u));
  color: var(--shim-progress);
}

.shim-leg__title {
  font-size: calc(22 * var(--u));
  font-weight: 500;
}

.shim-leg__sub {
  font-size: calc(18 * var(--u));
  color: var(--shim-muted);
}

.shim-num {
  display: inline-block;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--shim-accent);
}

.shim-modechip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: calc(10 * var(--u));
  padding: calc(10 * var(--u)) calc(18 * var(--u));
  border-radius: 999px;
  background: var(--shim-white);
  box-shadow: 0 0 0 calc(1.5 * var(--u)) var(--shim-border), 0 calc(4 * var(--u)) calc(14 * var(--u)) rgb(28 33 61 / 0.14);
  font-size: calc(20 * var(--u));
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
}

.shim-modechip__icon {
  width: calc(26 * var(--u));
  height: calc(26 * var(--u));
  color: var(--shim-progress);
}

/* ---------- panel ---------- */

.shim-panel {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1;
  width: var(--shim-panel-w);
  background: var(--shim-bg);
}

.shim-list {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.shim-scroll {
  position: relative;
  padding: calc(37 * var(--u)) var(--shim-card-right) calc(37 * var(--u)) var(--shim-card-left);
}

.shim-card {
  position: relative;
  margin-bottom: var(--shim-gap);
  padding: calc(20 * var(--u)) calc(15 * var(--u)) calc(14 * var(--u));
  border: calc(1.5 * var(--u)) solid var(--shim-border);
  border-radius: calc(14 * var(--u));
  background: var(--shim-white);
  box-shadow: 0 calc(2 * var(--u)) calc(10 * var(--u)) rgb(28 33 61 / 0.05);
}

/* Stepper: badges sit at their card's top; the track runs from badge 1 to badge 2 inside card 1 */
.shim-badge {
  --arrive: 0;
  position: absolute;
  left: calc(var(--shim-badge-x) - var(--shim-card-left));
  top: 0;
  width: calc(40 * var(--u));
  height: calc(40 * var(--u));
  display: grid;
  place-items: center;
  border-radius: calc(8 * var(--u));
  font-size: calc(22 * var(--u));
  font-weight: 500;
  line-height: 1;
  background: color-mix(in srgb, var(--shim-progress) calc(var(--arrive) * 100%), var(--shim-white));
  color: color-mix(in srgb, var(--shim-white) calc(var(--arrive) * 100%), var(--shim-accent));
  box-shadow: 0 0 0 calc(1.5 * var(--u)) color-mix(in srgb, var(--shim-progress) calc(var(--arrive) * 100%), var(--shim-border)),
    0 calc(2 * var(--u)) calc(6 * var(--u)) rgb(28 33 61 / 0.12);
}

.shim-badge.is-reached {
  --arrive: 1;
}

.shim-track {
  position: absolute;
  left: calc(var(--shim-badge-x) - var(--shim-card-left) + 17 * var(--u));
  top: calc(20 * var(--u));
  width: calc(6 * var(--u));
  height: calc(100% + var(--shim-gap));
  border-radius: calc(3 * var(--u));
  background: var(--shim-border);
}

.shim-track__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--shim-progress);
  transform: scaleY(0);
  transform-origin: 50% 0;
}

.shim-card__head {
  position: relative;
  padding-bottom: calc(17 * var(--u));
  margin-bottom: calc(19 * var(--u));
  border-bottom: calc(1.5 * var(--u)) solid var(--shim-border);
}

.shim-card--dest {
  padding-bottom: calc(8 * var(--u));
}

.shim-card--dest .shim-card__head {
  padding-bottom: calc(13 * var(--u));
  margin-bottom: calc(9 * var(--u));
}

.shim-card__title {
  padding-right: calc(40 * var(--u));
  font-size: calc(28 * var(--u));
  font-weight: 500;
}

.shim-card__code {
  margin-left: calc(4 * var(--u));
  font-size: calc(24 * var(--u));
  font-weight: 400;
  font-style: italic;
  color: var(--shim-faint);
}

.shim-card__type {
  margin-top: calc(14 * var(--u));
  font-size: calc(22 * var(--u));
  color: var(--shim-muted);
}

.shim-card--dest .shim-card__type {
  color: var(--shim-faint);
}

.shim-chev {
  position: absolute;
  right: calc(16 * var(--u));
  top: calc(24 * var(--u));
  width: calc(24 * var(--u));
  height: calc(24 * var(--u));
  color: var(--shim-accent);
}

.shim-chip {
  display: inline-block;
  margin-top: calc(10 * var(--u));
  padding: calc(9 * var(--u)) calc(24 * var(--u));
  border-radius: calc(23 * var(--u));
  background: var(--shim-highlight);
  font-size: calc(22 * var(--u));
}

/* ---------- milestone rows ---------- */

.shim-rows {
  position: relative;
}

/* Current-status band (the colour guide's highlighted row); sync writes y, height and opacity */
.shim-band {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: calc(40 * var(--u));
  border-radius: calc(10 * var(--u));
  background: var(--shim-highlight);
  opacity: 0;
}

.shim-row {
  --on: 0;
  --dt: 0;
  --band: 0;
  --shim-row-ink: color-mix(in srgb, var(--shim-accent) calc(var(--on) * 100%), var(--shim-inactive));
  position: relative;
  display: grid;
  grid-template-columns: calc(32 * var(--u)) minmax(0, 1fr) auto calc(80 * var(--u)) calc(67 * var(--u));
  column-gap: calc(12 * var(--u));
  align-items: center;
  height: calc(40 * var(--u));
  padding: 0 calc(9 * var(--u)) 0 calc(8 * var(--u));
  font-size: calc(23 * var(--u));
  white-space: nowrap;
}

.shim-card--dest .shim-row {
  height: calc(52 * var(--u));
}

.shim-row__icon {
  width: calc(32 * var(--u));
  height: calc(28 * var(--u));
  color: color-mix(in srgb, var(--shim-progress) calc(var(--on) * 100%), var(--shim-inactive));
}

.shim-row__label {
  padding-left: calc(24 * var(--u));
  overflow: hidden;
  text-overflow: ellipsis;
  color: color-mix(in srgb, var(--shim-progress) calc(var(--band) * 100%), var(--shim-row-ink));
}

/* Starts where the other labels start (x 186 in the WebM), text inset 12 px */
.shim-row__pill {
  display: inline-block;
  padding: calc(4 * var(--u)) calc(12 * var(--u));
  border-radius: calc(20 * var(--u));
  background: color-mix(in srgb, var(--shim-progress) calc(var(--on) * 15%), var(--shim-highlight));
}

.shim-row__date,
.shim-row__time {
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--shim-progress) calc(var(--dt) * 100%), var(--shim-inactive));
}

.shim-row__time {
  text-align: right;
}

.shim-row[data-on="true"] .shim-row__label,
.shim-row[data-dt="true"] .shim-row__date,
.shim-row[data-dt="true"] .shim-row__time,
.shim-row--strong .shim-row__date,
.shim-row--strong .shim-row__time {
  font-weight: 500;
}

.shim-row__tags {
  display: flex;
  align-items: center;
  gap: calc(12 * var(--u));
}

.shim-tag {
  display: inline-grid;
  place-items: center;
  height: calc(28 * var(--u));
  font-size: calc(19 * var(--u));
  line-height: 1;
}

.shim-tag--eta {
  width: calc(28 * var(--u));
  border-radius: calc(6 * var(--u));
  background: var(--shim-accent);
  color: var(--shim-white);
  font-style: italic;
  font-weight: 500;
}

.shim-tag--etd {
  padding: 0 calc(9 * var(--u));
  border: calc(1.5 * var(--u)) solid var(--shim-inactive);
  border-radius: calc(8 * var(--u));
  color: var(--shim-inactive);
}

.shim-tag--delay {
  --pulse: 0;
  padding: 0 calc(10 * var(--u));
  border-radius: calc(14 * var(--u));
  background: var(--shim-warning);
  color: var(--shim-white);
  font-weight: 500;
  scale: calc(1 + 0.15 * var(--pulse));
  box-shadow: 0 0 0 calc(8 * var(--u) * var(--pulse)) color-mix(in srgb, var(--shim-warning) calc(var(--pulse) * 30%), transparent);
}

/* Phones: rows stack, date and time under the label */
.shim-root[data-narrow="true"] .shim-row {
  grid-template-columns: calc(32 * var(--u)) minmax(0, 1fr) auto;
  row-gap: calc(2 * var(--u));
  height: auto;
  padding-block: calc(8 * var(--u));
}

.shim-root[data-narrow="true"] .shim-row__icon {
  grid-row: 1 / span 2;
}

.shim-root[data-narrow="true"] .shim-row__date {
  grid-column: 2;
  grid-row: 2;
  padding-left: calc(24 * var(--u));
}

.shim-root[data-narrow="true"] .shim-row__time {
  grid-column: 3;
  grid-row: 2;
}

