* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Filler content above and below so you can see the effect */
.intro,
.outro {
  height: 60vh;
  display: grid;
  place-items: center;
  background: #f2f2f2;
}

/* Track height = 4 images x 500px of scroll distance.
   Change 2000px if you want slower/faster swaps. */
.scroll-track {
  height: 2000px;
  width: 100%;
}

/* The 500px full-width panel that stays pinned while scrolling */
.sticky-panel {
  position: sticky;
  top: 0;
  width: 100%;
  height: 700px;
  overflow: hidden;
  background: #000;
}

/* All images stacked on top of each other; only the active one is visible */
.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translateY(100%);          /* waiting below the panel */
  transition: transform 0.6s ease;
}

/* Later images sit on top of earlier ones, so each slides over the last */
.layer:nth-child(1) { z-index: 1; }
.layer:nth-child(2) { z-index: 2; }
.layer:nth-child(3) { z-index: 3; }
.layer:nth-child(4) { z-index: 4; }

/* Active images sit in place; the newest one is on top */
.layer.is-active {
  transform: translateY(0);
}
