@layer components {
  .u-ht {
    container-type: inline-size;
    container-name: u-ht;
  }

  .u-ht__track {
    /* Count-based columns: each milestone gets a min width, so when the row
       outgrows the container it scrolls horizontally instead of squeezing the
       cards. The connecting line + items are explicitly placed into row 1 so
       the line can span the full (scrollable) track width. */
    display: grid;
    grid-template-columns: repeat(var(--u-ht-count, 6), minmax(14rem, 1fr));
    /* Three shared rows — top cards / markers / bottom cards. Each item maps
       onto them via subgrid, so every row sizes to its tallest card and the
       track is exactly as tall as its content (no even-split clipping, markers
       stay aligned across columns). */
    grid-template-rows: auto auto auto;
    position: relative;
    margin-top: var(--space-l);
    overflow-x: auto;
    /* Pin the cross axis: without this, `overflow-x: auto` computes `overflow-y`
       to `auto` too, and once the x-scrollbar appears it eats height and trips a
       spurious y-scrollbar. `hidden` keeps the height purely content-driven. */
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    /* Breathing room between the cards and the horizontal scrollbar. */
    padding-bottom: var(--space-s);
  }

  .u-ht__line {
    grid-row: 2;            /* the marker row */
    grid-column: 1 / -1;
    align-self: center;
    height: 2px;
    background: var(--border-primary);
    z-index: 0;
  }

  .u-ht__item {
    grid-column: var(--u-ht-col, auto);
    grid-row: 1 / -1;
    display: grid;
    grid-template-rows: subgrid;  /* top → row 1, marker → row 2, bottom → row 3 */
    position: relative;
    z-index: 1;
    scroll-snap-align: center;
  }

  .u-ht__top,
  .u-ht__bottom {
    flex: 1;
    display: flex;
    min-height: 14rem;
  }

  .u-ht__top {
    align-items: flex-end;
    justify-content: center;
    padding-bottom: var(--space-m);
  }

  .u-ht__bottom {
    align-items: flex-start;
    justify-content: center;
    padding-top: var(--space-m);
  }

  .u-ht__marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3xs);
    position: relative;
    z-index: 2;
    padding: var(--space-3xs) 0;
  }

  .u-ht__dot {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    border: 3px solid var(--border-primary);
    transition: all 0.3s ease;
  }

  .u-ht__item:hover .u-ht__dot,
  .u-ht__item--active .u-ht__dot {
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: 0 0 0 5px var(--primary-10);
  }

  .u-ht__year {
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    color: var(--text-body);
    opacity: 0.6;
    letter-spacing: 0.05em;
    white-space: nowrap;
    transition: all 0.3s ease;
  }

  .u-ht__item:hover .u-ht__year,
  .u-ht__item--active .u-ht__year {
    color: var(--primary);
    opacity: 1;
  }

  .u-ht__card {
    padding: var(--space-m);
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-m);
    transition: all 0.3s ease;
    max-width: 22rem;
  }

  .u-ht__item:hover .u-ht__card {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-10);
  }

  .u-ht__item--active .u-ht__card {
    border-color: var(--primary);
    background: var(--primary-5);
  }

  .u-ht__card-title {
    font-size: var(--text-s);
    font-weight: var(--weight-semibold);
    color: var(--text-title);
    line-height: 1.3;
    margin-bottom: var(--space-3xs);
  }

  .u-ht__card-text {
    font-size: var(--text-xs);
    color: var(--text-body);
    line-height: 1.6;
    opacity: 0.85;
  }

  @container u-ht (max-width: 968px) {
    /* Stay on the horizontal scroller (cards keep their min width); just trim
       the vertical breathing room a touch. */
    .u-ht__top,
    .u-ht__bottom { min-height: 10rem; }
  }

  @container u-ht (max-width: 768px) {
    .u-ht__track {
      display: flex;
      flex-direction: column;
      grid-template-columns: none;
      gap: 0;
      padding: 0;
      position: relative;
      overflow: visible;
    }

    .u-ht__line {
      position: absolute;
      align-self: stretch;
      left: 1.35rem;
      top: 0;
      bottom: 0;
      right: auto;
      width: 2px;
      height: auto;
      background: var(--border-primary);
    }

    .u-ht__item {
      grid-column: auto;
      grid-row: auto;
      display: flex;
      grid-template-rows: none;
      flex-direction: row;
      align-items: flex-start;
      gap: var(--space-l);
      padding: 0 0 var(--space-xl) 0;
      min-height: auto;
    }

    .u-ht__item:last-child {
      padding-bottom: 0;
    }

    .u-ht__top,
    .u-ht__bottom {
      display: contents;
    }

    .u-ht__marker {
      order: -1;
      flex-direction: column;
      gap: var(--space-3xs);
      padding: 0;
      flex-shrink: 0;
      width: 2.8rem;
      align-items: center;
    }

    .u-ht__dot { margin-top: 0.3rem; }

    .u-ht__year {
      font-size: var(--text-2xs);
      font-weight: var(--weight-bold);
      text-align: center;
      letter-spacing: 0.04em;
    }

    .u-ht__card {
      max-width: none;
      flex: 1;
      padding: var(--space-m);
    }

    .u-ht__card-title { font-size: var(--text-m); }
    .u-ht__card-text  { font-size: var(--text-s); }
  }

  @container u-ht (max-width: 480px) {
    .u-ht__item {
      gap: var(--space-m);
      padding-bottom: var(--space-l);
    }
    .u-ht__line { left: 1.15rem; }
    .u-ht__marker { width: 2.4rem; }
    .u-ht__card { padding: var(--space-s); }
    .u-ht__card-title { font-size: var(--text-s); }
    .u-ht__card-text  { font-size: var(--text-xs); }
  }
}
