/* The metro network: the map of a made-up city's metro that draws itself line by line, laid by its own trains.
   The page is one screen: the planner on the side, the map filling the rest. */
:root {
  --paper: #f4f0e6;         /* the map's paper */
  --ink: #18212b;           /* words, interchange rings, the destination */
  --muted: #6b6f72;         /* small words */
  --rule: #ddd6c6;          /* thin lines on the side */
  --river: #c3dde6;
  --river-ink: #7aa6b7;     /* the river's name */
  --park: #dfe6cc;
  --station: #ffffff;       /* the inside of a station */
  --crown: #df4430;         /* Crown line */
  --tide: #1f63c6;          /* Tide line */
  --orchard: #1c9558;       /* Orchard line */
  --quay: #f0a11a;          /* Quay line */
  --edge: clamp(16px, 3vw, 40px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Instrument Sans Variable', 'Instrument Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(250px, 320px) 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    'head map'
    'trip map'
    'legend map';
  column-gap: clamp(8px, 2vw, 32px);
  padding: var(--edge);
}

.side {
  display: contents;
}

/* ---------------------------------------------------------------- the title */
.head {
  grid-area: head;
  position: relative;
  z-index: 1;
}

.head__city {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.head__title {
  margin: 0;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1;
  font-weight: 680;
  font-stretch: 88%;
  letter-spacing: -0.02em;
}

.head__title span {
  display: inline-block;
}

.head__hint {
  margin: 12px 0 0;
  max-width: 26ch;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
}

.hint--touch {
  display: none;
}

@media (hover: none) {
  .hint--mouse {
    display: none;
  }
  .hint--touch {
    display: inline;
  }
}

/* ---------------------------------------------------------------- the planner */
.trip {
  grid-area: trip;
  align-self: center;
  position: relative;
  z-index: 1;
  min-height: 262px;
  padding: 22px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.trip__idle {
  margin: 0;
  max-width: 22ch;
  font-size: 15px;
  line-height: 1.4;
  color: var(--muted);
}

.trip__top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.trip__from {
  margin: 0;
  min-width: 0;
}

.trip__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.trip__name {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.05;
  font-weight: 680;
  font-stretch: 90%;
  letter-spacing: -0.01em;
}

.trip__time {
  margin: 0;
  flex: none;
  text-align: right;
  line-height: 1;
}

.trip__minutes {
  display: block;
  font-size: 44px;
  font-weight: 700;
  font-stretch: 80%;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.trip__unit {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.trip__steps {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.step {
  display: grid;
  grid-template-columns: 8px 1fr;
  column-gap: 12px;
  align-items: stretch;
  font-size: 14px;
  line-height: 1.35;
}

.step__bar {
  border-radius: 4px;
  background: var(--line);
  transform-origin: 50% 0;
}

.step__text {
  padding: 6px 0;
}

.step--change .step__bar {
  width: 2px;
  justify-self: center;
  background: repeating-linear-gradient(to bottom, var(--ink) 0 3px, transparent 3px 7px);
  border-radius: 0;
}

.step--note {
  display: block;
  color: var(--muted);
}

.step--change .step__text {
  color: var(--muted);
  font-size: 13px;
}

.chip {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px 3px;
  border-radius: 999px;
  background: var(--line);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
  vertical-align: 1px;
}

.chip--dark {
  color: var(--ink);
}

/* ---------------------------------------------------------------- the lines */
.legend {
  grid-area: legend;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.legend li {
  display: block;
}

.legend button {
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  padding: 6px 13px 7px;
  border: 0;
  border-radius: 999px;
  background: var(--line);
  color: #fff;
  cursor: pointer;
}

.legend button.chip--dark {
  color: var(--ink);
}

.legend button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- the map */
.map {
  grid-area: map;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: manipulation;
  /* the river runs off the edges of the map: they fade instead of cutting it */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent), linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent), linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  mask-composite: intersect;
}

.map__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
}

.map.is-near {
  cursor: pointer;
}

.map__art text {
  font-family: 'Instrument Sans Variable', 'Instrument Sans', system-ui, sans-serif;
  font-weight: 580;
  fill: var(--ink);
  paint-order: stroke;
  stroke: var(--paper);
  stroke-linejoin: round;
}

.map__art .river-name {
  font-style: italic;
  font-weight: 500;
  fill: var(--river-ink);
  stroke: none;
  letter-spacing: 0.2em;
}

.map__art .park-name {
  font-weight: 500;
  fill: #8d9a6c;
  stroke: none;
  letter-spacing: 0.08em;
}

.map__art .venue-name {
  fill: #fff;
  stroke: none;
  font-weight: 680;
}

/* ---------------------------------------------------------------- the phone: title on top, map, planner below */
@media (max-width: 760px) {
  .stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      'head'
      'legend'
      'map'
      'trip';
    row-gap: 12px;
    padding: 18px 16px 16px;
  }
  .head__city {
    margin-bottom: 6px;
    font-size: 11px;
  }
  .head__title {
    font-size: 27px;
  }
  .head__hint {
    margin-top: 6px;
    max-width: none;
    font-size: 13px;
  }
  .legend {
    gap: 6px;
  }
  .legend button {
    font-size: 12px;
    padding: 4px 10px 5px;
  }
  .trip {
    min-height: 136px;
    align-self: stretch;
    padding: 12px 0 0;
    border-bottom: 0;
  }
  .trip__idle {
    max-width: none;
    font-size: 14px;
  }
  .trip__name {
    font-size: 20px;
  }
  .trip__minutes {
    font-size: 34px;
  }
  .trip__steps {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 4px;
  }
  .step {
    display: block;
    font-size: 13px;
  }
  .step__bar {
    display: none;
  }
  .step__text {
    padding: 0;
  }
  .step--change {
    display: none;
  }
}
