/*
 * twcommute.com. The page is a bus route: each section is a stop on a line down the left, and a bus
 * rides it as you scroll, turning yellow at each stop as it does on the app's live map.
 * Colours come from the app: its navy, its green bus lines, its at-a-stop yellow.
 */
/* Overpass (SIL Open Font License), from the US highway signs' typeface; Latin only. Chinese,
 * Japanese and Korean use the phone's own fonts, which are already installed and look native. */
@font-face {
  font-family: "Overpass";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/overpass-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --ink: #13294b;
  --text: #1c2433;
  --muted: #4b5563;
  --paper: #f3f5f8;
  --surface: #ffffff;
  --line: #0f7f40;
  --blue: #1f5fbf;
  --signal: #f5b400;
  --rail: #cfd7e3;
  --edge: #e2e7ef;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --rail-x: 28px;
  --gutter: 20px;
  --font: "Overpass", "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-zh: "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 400 1.0625rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  z-index: 10;
}

.skip:focus {
  top: 12px;
}

h1,
h2 {
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0;
}

h1 {
  font-size: clamp(2.5rem, 1.6rem + 4.2vw, 4.6rem);
  line-height: 1.02;
}

h2 {
  font-size: clamp(1.75rem, 1.25rem + 2vw, 2.6rem);
  line-height: 1.1;
}

p {
  margin: 0;
  max-width: 34em;
  text-wrap: pretty;
}

/* Nav */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 16px var(--gutter);
}

.brand {
  display: inline-flex;
  white-space: nowrap;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.125rem;
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
}

.mark {
  width: 34px;
  height: 20px;
}

.mark path {
  stroke: var(--line);
  stroke-width: 4;
  stroke-linecap: round;
}

.mark-a {
  fill: var(--surface);
  stroke: var(--line);
  stroke-width: 3;
}

.mark-b {
  fill: var(--signal);
  stroke: var(--ink);
  stroke-width: 2;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  white-space: nowrap;
  border-radius: 22px;
  font-weight: 600;
  text-decoration: none;
}

.nav-cta {
  background: var(--ink);
  color: #fff;
  transition: transform 160ms var(--ease-out);
}

.nav-cta:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .nav-links a:not(.nav-cta):hover {
    background: var(--edge);
  }
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 40px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px var(--gutter) 72px;
}

.hero-text {
  display: grid;
  gap: 22px;
  align-content: center;
}

.sign {
  display: inline-grid;
  justify-items: start;
  gap: 2px;
  width: max-content;
  padding: 12px 18px 12px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  border-left: 8px solid var(--line);
}

.sign-tag {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #c7d3e6;
}

.sign ruby {
  font-family: var(--font-zh);
  font-weight: 700;
  font-size: 2rem;
  line-height: 1.25;
  letter-spacing: 0.08em;
  ruby-align: center;
}

.sign rt {
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  color: #c7d3e6;
}

.sign-en {
  font-weight: 600;
  font-size: 0.9375rem;
}

.lede {
  font-size: 1.1875rem;
  color: var(--muted);
}

.stores {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.store {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 18px 8px 14px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 1.0625rem;
  line-height: 1.1;
}

.store svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.store small {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #c7d3e6;
}

.starting {
  font-weight: 600;
  color: var(--ink);
}

.hero-visual {
  position: relative;
  justify-self: center;
  width: min(100%, 320px);
}

.phone {
  margin: 0;
  padding: 8px;
  border-radius: 40px;
  background: var(--ink);
  box-shadow: 0 30px 60px -24px rgba(19, 41, 75, 0.45);
}

.phone img {
  border-radius: 32px;
  width: 100%;
}

.phone-sm {
  width: min(100%, 280px);
}

.arrive-pill {
  position: absolute;
  left: -14px;
  top: 21%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 8px;
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9375rem;
  box-shadow: 0 12px 30px -10px rgba(19, 41, 75, 0.35);
}

.arrive-pill b {
  font-weight: 800;
}

.arrive-pill span:last-child {
  color: var(--line);
  font-weight: 800;
}

.pill-bus {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--signal) url("/img/bus-details.png") center / 22px no-repeat;
}

/* Hero entrance: one orchestrated moment when the page opens. */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateX(-12px) scale(0.96);
  }
}

.hero-text > * {
  animation: rise 700ms var(--ease-out) both;
}

.hero-text > :nth-child(2) {
  animation-delay: 70ms;
}

.hero-text > :nth-child(3) {
  animation-delay: 140ms;
}

.hero-text > :nth-child(4) {
  animation-delay: 190ms;
}

.hero-text > :nth-child(5) {
  animation-delay: 230ms;
}

.phone {
  animation: rise 900ms var(--ease-out) 120ms both;
}

.arrive-pill {
  animation: arrive 500ms var(--ease-out) 1000ms both;
}

/* The route */
.route {
  position: relative;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 var(--gutter) 40px;
}

.rail {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 120px;
  left: calc(var(--gutter) + var(--rail-x) - 4px);
  width: 8px;
  border-radius: 4px;
  background: var(--rail);
}

.rail::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: var(--line);
  transform-origin: top;
  transform: scaleY(var(--progress, 0));
}

.bus {
  position: absolute;
  top: 0;
  left: -18px;
  width: 44px;
  height: 44px;
  transform: translateY(var(--bus-y, 0px)) rotate(180deg);
  filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 2px 4px rgba(19, 41, 75, 0.35));
  will-change: transform;
}

.bus-body,
.bus-details {
  position: absolute;
  inset: 0;
}

.bus-body {
  background: var(--line);
  -webkit-mask: url("/img/bus-body.png") center / contain no-repeat;
  mask: url("/img/bus-body.png") center / contain no-repeat;
  transition: background-color 200ms ease;
}

.bus-details {
  background: url("/img/bus-details.png") center / contain no-repeat;
}

.bus.at-stop .bus-body {
  background: var(--signal);
}

.stop {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  padding: 72px 0 72px calc(var(--rail-x) + 36px);
}

.stop-sign {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--ink);
}

.stop-sign .dot {
  position: absolute;
  left: calc(var(--rail-x) - 11px);
  margin-top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 5px solid var(--line);
  transition: background-color 200ms ease;
}

.stop.reached .dot {
  background: var(--signal);
}

.stop-sign [lang="zh-Hant"] {
  font-family: var(--font-zh);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.06em;
}

.stop-sign [lang="en"] {
  font-weight: 600;
  color: var(--muted);
}

.stop-text {
  display: grid;
  gap: 14px;
}

.stop-text p {
  color: var(--muted);
}

.stop-visual {
  display: flex;
  justify-content: center;
}

/* Leave card: the app's next-trip hero, counting down. */
.leave-card {
  width: min(100%, 360px);
  padding: 20px 22px;
  border-radius: 24px;
  background: var(--ink);
  color: #fff;
  display: grid;
  gap: 6px;
}

.lc-kicker {
  font-size: 0.875rem;
  font-weight: 600;
  color: #c7d3e6;
}

.lc-title {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.lc-line {
  color: #dbe3f0;
}

.lc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.chip-tpass {
  padding: 4px 12px;
  border-radius: 12px;
  background: #2b4a7a;
  font-size: 0.875rem;
  font-weight: 700;
}

.lc-go {
  padding: 10px 26px;
  border-radius: 24px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.roll {
  display: inline-grid;
  height: 1.15em;
  overflow: hidden;
  vertical-align: bottom;
}

.roll > span {
  transform: translateY(calc(var(--step, 0) * -100%));
  transition: transform 520ms var(--ease-in-out);
}

/* TPASS trips with stamps. */
.trips {
  list-style: none;
  margin: 0;
  padding: 0;
  width: min(100%, 420px);
  display: grid;
  gap: 10px;
}

.trips li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "mode name time" "mode stamp stamp";
  align-items: center;
  gap: 4px 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--edge);
}

.mode {
  grid-area: mode;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.mode::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  -webkit-mask: var(--glyph) center / 24px no-repeat;
  mask: var(--glyph) center / 24px no-repeat;
}

.m-bus {
  background: var(--line);
  --glyph: url("/img/glyph-bus.png");
}

.m-rail {
  background: var(--blue);
  --glyph: url("/img/glyph-train.png");
}

.m-hsr {
  background: #c2410c;
  --glyph: url("/img/glyph-train.png");
}

.trip-name {
  grid-area: name;
  font-weight: 700;
  color: var(--ink);
}

.trip-time {
  grid-area: time;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stamp {
  grid-area: stamp;
  justify-self: start;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 700;
  opacity: 0;
  transform: scale(1.25) rotate(-3deg);
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
}

.stamp.ok {
  background: #e5f5ea;
  color: #0b6b34;
}

.stamp.no {
  background: #fdecec;
  color: #a1251b;
}

.in .stamp {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.in li:nth-child(2) .stamp {
  transition-delay: 140ms;
}

.in li:nth-child(3) .stamp {
  transition-delay: 260ms;
}

/* YouBike card. */
.bike-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(100%, 420px);
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--edge);
}

.bike-badge {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffb400;
  box-shadow: inset 0 0 0 3px #fff, 0 0 0 1px var(--edge);
}

.bike-badge::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: #1a1300;
  -webkit-mask: url("/img/glyph-bike.png") center / 24px no-repeat;
  mask: url("/img/glyph-bike.png") center / 24px no-repeat;
}

.bike-name {
  display: grid;
  flex: 1;
  min-width: 0;
}

.bike-name b {
  color: var(--ink);
}

.bike-name span {
  font-size: 0.875rem;
  color: var(--muted);
}

.bike-count {
  display: grid;
  justify-items: end;
  line-height: 1;
}

.bike-count .roll {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--ink);
  height: 1.05em;
}

.bike-count small {
  font-weight: 700;
  color: var(--muted);
}

.bike-count em {
  font-style: normal;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #0b6b34;
  margin-top: 4px;
}

/* A day as a metro line. */
.day {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 6px 0 6px 0;
  width: min(100%, 400px);
  display: grid;
  gap: 26px;
}

.day::before {
  content: "";
  position: absolute;
  left: 61px;
  top: 18px;
  bottom: 18px;
  width: 8px;
  border-radius: 4px;
  background: var(--blue);
  transform-origin: top;
  transform: scaleY(0);
  transition: transform 1400ms var(--ease-in-out);
}

.day.in::before {
  transform: scaleY(1);
}

.day li {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr;
  column-gap: 40px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}

.day li::before {
  content: "";
  position: absolute;
  left: 56px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--blue);
}

.day b {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.day span {
  font-weight: 700;
  color: var(--ink);
}

.day small {
  grid-column: 2;
  color: var(--muted);
  font-weight: 600;
}

.day.in li {
  opacity: 1;
  transform: none;
}

.day.in li:nth-child(2) {
  transition-delay: 380ms;
}

.day.in li:nth-child(3) {
  transition-delay: 760ms;
}

.day.in li:nth-child(4) {
  transition-delay: 1140ms;
}

/* Ask: one question in eight languages. */
.ask-visual {
  position: relative;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.phrases {
  width: min(100%, 360px);
}

.phrases ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.phrases li {
  grid-area: 1 / 1;
  padding: 14px 18px;
  border-radius: 18px 18px 18px 6px;
  background: var(--surface);
  border: 1px solid var(--edge);
  color: var(--ink);
  font-weight: 700;
  opacity: 0;
  filter: blur(4px);
  transform: translateY(6px);
  transition: opacity 360ms ease, filter 360ms ease, transform 360ms var(--ease-out);
}

.phrases li small {
  display: block;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--muted);
}

.phrases li.on {
  opacity: 1;
  filter: none;
  transform: none;
}

/* Last stop */
.stop-end .stop-text {
  gap: 18px;
}

.stop-end h2 {
  font-size: clamp(2rem, 1.4rem + 2.6vw, 3.2rem);
}

.foot {
  max-width: 1160px;
  margin: 0 auto;
  padding: 32px var(--gutter) 48px;
  border-top: 1px solid var(--edge);
  display: grid;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--muted);
}

.foot p {
  max-width: 60em;
}

@media (max-width: 420px) {
  .nav {
    gap: 8px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .nav-links {
    gap: 2px;
  }

  .nav-links a {
    padding: 0 12px;
  }
}

@media (min-width: 900px) {
  :root {
    --gutter: 32px;
    --rail-x: 40px;
  }

  .hero {
    grid-template-columns: 1.15fr 0.85fr;
    padding-top: 40px;
    padding-bottom: 96px;
  }

  .hero-visual {
    justify-self: end;
    margin-right: 24px;
  }

  .arrive-pill {
    left: -64px;
  }

  .stop {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "sign sign" "text visual";
    column-gap: 48px;
    align-items: start;
    padding-top: 96px;
    padding-bottom: 96px;
  }

  .stop-sign {
    grid-area: sign;
  }

  .stop-text {
    grid-area: text;
  }

  .stop-visual {
    grid-area: visual;
  }

  .stop-end {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "sign" "text";
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .hero-text > *,
  .phone,
  .arrive-pill {
    animation: none;
  }

  .bus {
    display: none;
  }

  .rail::before {
    transform: none;
  }

  .stamp,
  .day li {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .day::before {
    transform: none;
    transition: none;
  }

  .roll > span {
    transition: none;
  }

  .phrases li {
    grid-area: auto;
    opacity: 1;
    filter: none;
    transform: none;
    transition: none;
  }

  .phrases ul {
    gap: 8px;
  }
}
