/* Building progress: a thin line of dated dots and the chosen date's picture.
 * Wide screens: the line runs down the left, every date next to its dot.
 * Phones: it runs across above the picture; only the chosen date is shown,
 * as the picture's caption. shared/timeline/ makes the dots switch pictures. */

.timeline {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 48px;
}

.timeline-line {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
}

/* Each step stretches so the dots spread along the picture's height. */
.timeline-step {
  position: relative;
  flex: 1 1 0;
  min-height: 44px;
}

.timeline-step:last-child {
  flex: 0 0 auto;
  min-height: 0;
}

/* The line: from each dot's centre to the next one's. */
.timeline-step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 12px;
  bottom: -12px;
  width: 2px;
  background: var(--line);
}

/* Up to the chosen date the line is coloured in: newest first, so from the
 * chosen dot to the end of the line (the oldest). */
.timeline-step:has(> [aria-current])::before,
.timeline-step:has(> [aria-current]) ~ .timeline-step::before {
  background: var(--highlight);
}

.timeline-dot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 24px;
  color: var(--muted);
  text-decoration: none;
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  white-space: nowrap;
  border-radius: 6px;
}

.timeline-dot::before {
  content: '';
  flex: none;
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  margin: 6px;
  border-radius: 50%;
  border: 2px solid var(--highlight);
  background: var(--bg);
  transition: transform .2s, background .2s;
}

.timeline-dot:hover {
  color: var(--text);
}

.timeline-dot:hover::before {
  transform: scale(1.2);
}

.timeline-dot[aria-current] {
  color: var(--text);
  font-weight: 600;
}

.timeline-dot[aria-current]::before {
  background: var(--highlight);
  transform: scale(1.35);
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px var(--highlight);
}

.timeline-dot:focus-visible {
  outline: 2px solid var(--highlight);
  outline-offset: 4px;
}

.timeline-stage {
  margin: 0;
}

.timeline-stage img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: var(--line);
  transition: opacity .25s;
}

.timeline-stage img.is-loading {
  opacity: .4;
}

/* The chosen date: on wide screens the line already shows it. */
.timeline-date {
  display: none;
}

@media (max-width: 640px) {
  .timeline {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .timeline-line {
    flex-direction: row;
    padding: 4px 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .timeline-line::-webkit-scrollbar {
    display: none;
  }

  .timeline-step {
    flex: 1 0 36px;
    min-height: 0;
  }

  .timeline-step:not(:last-child)::before {
    left: 12px;
    right: -12px;
    top: 11px;
    bottom: auto;
    width: auto;
    height: 2px;
  }

  .timeline-dot {
    width: 24px;
  }

  /* A bigger target for the finger than the dot itself. */
  .timeline-dot::after {
    content: '';
    position: absolute;
    inset: -10px -6px;
  }

  /* Dates stay readable to screen readers, but only the chosen one shows. */
  .timeline-dot time {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .timeline-date {
    display: block;
    margin: 12px 0 10px;
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
  }

  .timeline-stage img {
    border-radius: 8px;
  }
}
