/* ==========================================================================
   RAIL
   More than three of anything is a rail: a row that scrolls sideways with a
   snap and runs off the right edge of the screen, so there is always a card
   half in view to say there are more. Its first card lines up with the
   section's text. Each card (.rail-step) steps forward as it arrives, where
   the browser can tie that to the scroll.
   ========================================================================== */

.rail {
  --rail-gutter: 1.25rem;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--rail-card, 64%);
  gap: 0.875rem;
  margin-left: calc(var(--rail-gutter) * -1);
  margin-right: calc(var(--rail-gutter) * -1);
  padding-left: var(--rail-gutter);
  padding-right: var(--rail-gutter);
  padding-bottom: 0.5rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-left: var(--rail-gutter);
  scrollbar-width: none;
}

/* Tablet Portrait Up - Min 600px */
@media (min-width: 600px) {
  .rail {
    --rail-gutter: 2rem;
    --rail-card: 38%;
    gap: 1.25rem;
  }
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .rail {
    --rail-gutter: max(3rem, calc((100vw - 1280px) / 2 + 3rem));
    --rail-card: 300px;
    gap: 1.5rem;
  }
}

.rail::-webkit-scrollbar {
  display: none;
}

.rail > li {
  scroll-snap-align: start;
}

/* STEP */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .rail-step {
      animation: rail-step-in linear both;
      animation-timeline: view(inline);
      animation-range: entry 0% entry 60%;
    }
  }
}

@keyframes rail-step-in {
  from {
    opacity: 0.4;
    scale: 0.92;
  }
}
