/*
 * The map is the picture, and the interface a caption laid over it, on soft shades rather than
 * in boxes, as on the train and flight maps. The look and its tokens are theme.css's; js/map.js
 * uses the same colours on the map.
 */

:root {
  --index: 420px;
  --timeline: 124px;
}

html,
body {
  height: 100%;
}

/* Small tracked capitals: every label, every control */
.wordmark,
.seg button,
.row,
.back {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#app {
  position: relative;
  height: 100dvh;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

/* A soft shade at the top, so the wordmark and controls read over the map */
#app::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: 140px;
  background: linear-gradient(rgb(8 8 8 / 0.6), rgb(8 8 8 / 0));
  pointer-events: none;
}

/* Hidden, only the Show button stays */
.topbar,
.index,
.timeline,
.map-controls .seg {
  transition: opacity var(--fade);
}

#app.chrome-hidden :is(.topbar, .index, .timeline, .map-controls .seg:not(:has(.chrome-toggle))) {
  opacity: 0;
  visibility: hidden;
}

#app.chrome-hidden::before {
  opacity: 0;
}

/* ---------- Along the top ---------- */

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  padding: 30px var(--gutter) 0;
}

.wordmark {
  font-weight: 500;
  letter-spacing: 0.32em;
  text-shadow: var(--lift-text);
}

.map-controls {
  position: absolute;
  top: 26px;
  right: var(--gutter);
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: baseline;
  gap: 10px 32px;
}

.seg {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.seg button {
  padding: 4px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  color: var(--ink-3);
  text-shadow: var(--lift-text);
  transition: color var(--fade);
}

.seg button:hover {
  color: var(--ink);
}

.seg button[aria-pressed='true'] {
  border-bottom-color: var(--ink);
  color: var(--ink);
}

.seg button.play {
  color: var(--neon);
}

/* ---------- The index ---------- */

.index {
  position: absolute;
  top: 0;
  left: 0;
  bottom: var(--timeline);
  z-index: 2;
  width: var(--index);
  padding: 104px 80px 32px var(--gutter);
  overflow-y: auto;
  scrollbar-width: none;
  background: linear-gradient(
    90deg,
    rgb(8 8 8 / 0.94) 0%,
    rgb(8 8 8 / 0.9) 70%,
    rgb(8 8 8 / 0) 100%
  );
}

.hero-value {
  margin: 0 0 10px;
  font-size: 88px;
  font-weight: var(--display-weight);
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 0.9;
  letter-spacing: var(--display-tracking);
  white-space: nowrap;
}

.qty-u {
  margin-left: 6px;
  color: var(--ink-3);
  font-size: 22px;
  letter-spacing: 0;
}

.hero-sub {
  margin: 0 0 36px;
  color: var(--ink-2);
  line-height: 1.8;
}

.hero-sub .now {
  color: var(--neon);
}

.section {
  margin-bottom: 28px;
}

.section-title {
  margin: 0 0 12px;
  color: var(--ink-3);
}

.row {
  display: grid;
  grid-template-columns: 56px 1fr 58px;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  text-align: left;
  transition: color var(--fade);
}

.row:hover,
.row[aria-pressed='true'] {
  color: var(--ink);
}

.rows.some .row:not([aria-pressed='true']) {
  color: var(--ink-3);
}

.row .bar {
  position: relative;
  height: 1px;
  background: var(--ink-4);
}

.row .bar i {
  position: absolute;
  inset: 0 auto 0 0;
  background: currentColor;
}

.row .num {
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* A place's name wants the room a year's bar has */
.place {
  grid-template-columns: 1fr auto;
}

.hint {
  margin: 0;
  color: var(--ink-3);
}

/* ---------- A run, picked ---------- */

.back {
  padding: 4px 0;
  margin: 0 0 20px;
  border: 0;
  background: none;
  color: var(--ink-3);
}

.back:hover {
  color: var(--ink);
}

.run-date {
  margin: 0 0 4px;
  color: var(--neon);
  font-size: 26px;
  font-weight: var(--display-weight);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.run-day {
  margin: 0 0 18px;
  color: var(--ink-3);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 12px;
  margin: 0 0 28px;
}

.stats dt {
  color: var(--ink-3);
}

.stats dd {
  margin: 0;
  font-size: 22px;
  font-weight: var(--display-weight);
  font-variant-numeric: tabular-nums;
}

.here .row {
  grid-template-columns: 1fr auto auto;
  gap: 14px;
}

.here .row[aria-pressed='true'] {
  color: var(--neon);
}

/* ---------- Along the bottom: distance by month ---------- */

.timeline {
  position: absolute;
  inset: auto 0 0;
  z-index: 3;
  height: var(--timeline);
  padding: 34px var(--gutter) 34px;
  background: linear-gradient(rgb(8 8 8 / 0), rgb(8 8 8 / 0.92) 35%);
}

#chart {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  cursor: pointer;
}

.axis {
  position: relative;
  height: 0;
  color: var(--ink-3);
}

.axis span {
  position: absolute;
  top: 6px;
  white-space: nowrap;
}

/* ---------- The map's own controls ---------- */

.maplibregl-ctrl-bottom-right {
  z-index: 4;
}

.maplibregl-ctrl-attrib {
  background: rgb(8 8 8 / 0.8) !important;
  color: var(--ink-3);
  font: 300 10px/1.6 var(--font);
}

.maplibregl-ctrl-attrib.maplibregl-compact {
  border-radius: 0 !important;
}

.maplibregl-ctrl-attrib a {
  color: var(--ink-2) !important;
}

.maplibregl-ctrl-attrib-button {
  filter: invert(1);
  opacity: 0.5;
}

/* ---------- A phone: the map above, the index in a sheet below it ---------- */

@media (max-width: 860px) {
  :root {
    --index: 100%;
    --timeline: 88px;
  }

  .topbar {
    padding-top: 28px;
  }

  .map-controls {
    top: 24px;
    gap: 10px 16px;
  }

  .index {
    top: auto;
    max-height: 48dvh;
    padding: 56px var(--gutter) 8px;
    background: linear-gradient(rgb(8 8 8 / 0), rgb(8 8 8 / 0.92) 50px);
  }

  .hero-value {
    font-size: 56px;
  }

  .hero-sub {
    margin-bottom: 14px;
  }

  .section {
    margin-bottom: 14px;
  }

  .section-title,
  .hint {
    display: none;
  }

  #years {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0 16px;
  }

  #places {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 16px;
  }

  #years .row {
    grid-template-columns: 1fr auto;
  }

  #years .bar {
    display: none;
  }

  .stats {
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 14px;
  }

  .stats dd {
    font-size: 16px;
  }

  .run-date {
    font-size: 20px;
  }

  .timeline {
    padding: 14px var(--gutter) 26px;
  }
}
