* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: #0d0d0d;
  color: #ffffff;
  font-family: Arial, sans-serif;
  overflow-x: hidden;
}

.intro,
.outro {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  text-align: center;
}

.intro h1,
.outro h2 {
  max-width: 800px;
  font-size: clamp(2rem, 5vw, 5rem);
  line-height: 1.1;
}

/*
      This section is tall because its height controls how long
      the scroll animation lasts.
    */
.scroll-animation {
  position: relative;
  height: 400vh;
  padding: 45px 0 0;
  margin: 0;
}

/*
      This container stays fixed inside the viewport while
      the user scrolls through the tall section.
    */
.sticky-container {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  perspective: 1200px;
  padding-bottom: 70px;
}

.scroll-animation-header {
  position: absolute;
  top: 22px;
  left: 50%;
  z-index: 20;
  width: min(90vw, 900px);
  transform: translateX(-50%);
  text-align: center;
}

.scroll-animation-title {
  color: #fff;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(26px, 3.2vw, 44px);
  line-height: 1.15;
  text-shadow: 0 0 24px rgba(255, 64, 64, 0.35);
}

.mobile-scroll-cue {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: fit-content;
  margin: 20px auto 0;
  color: rgba(255, 255, 255, 0.78);
  font-family: "Poppins", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.mobile-scroll-cue.is-scrolling {
  opacity: 0;
  visibility: hidden;
}

.mobile-scroll-cue i {
  color: #ff5a5a;
  font-size: 13px;
  animation: scrollCueBounce 1.4s ease-in-out infinite;
  filter: drop-shadow(0 0 7px rgba(255, 70, 70, 0.6));
}

.image-stack {
  position: relative;
  width: auto;
  height: min(74vh, 700px);
  max-width: 84vw;
  aspect-ratio: 1080 / 1410;
}

.stack-image {
  --progress: 0;
  --clarity: 0;

  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;

  border-radius: 24px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.1);

  opacity: var(--progress);

  transform: translateY(calc((1 - var(--progress)) * 100px))
    scale(calc(0.88 + var(--progress) * 0.12))
    rotateX(calc((1 - var(--progress)) * 8deg));

  filter: blur(calc((1 - var(--clarity)) * 8px))
    brightness(calc(0.65 + var(--clarity) * 0.35));

  will-change: transform, opacity, filter;
}

/*
      Later images receive a slightly smaller size and higher
      vertical position, creating the stacked appearance.
    */
.stack-image:nth-child(1) {
  z-index: 1;
}

.stack-image:nth-child(2) {
  z-index: 2;
  transform: translateY(calc(30px + ((1 - var(--progress)) * 100px)))
    scale(calc(0.84 + var(--progress) * 0.12))
    rotateX(calc((1 - var(--progress)) * 8deg));
}

.stack-image:nth-child(3) {
  z-index: 3;
  transform: translateY(calc(60px + ((1 - var(--progress)) * 100px)))
    scale(calc(0.8 + var(--progress) * 0.12))
    rotateX(calc((1 - var(--progress)) * 8deg));
}

.scroll-progress {
  position: absolute;
  right: 30px;
  top: 50%;
  width: 4px;
  height: 180px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.scroll-progress-bar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #ffffff;
  transform: scaleY(0);
  transform-origin: top;
  will-change: transform;
}

.image-number {
  position: absolute;
  left: 30px;
  bottom: 30px;
  z-index: 10;
  font-size: 14px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

@media (min-width: 1301px) {
  .sticky-container {
    flex-direction: column;
    padding: 24px 0 45px;
  }

  .scroll-animation-header {
    position: relative;
    top: auto;
    left: auto;
    flex-shrink: 0;
    margin-bottom: 16px;
    transform: none;
  }

  .scroll-animation-title {
    font-size: clamp(24px, 2.6vw, 38px);
  }

  .image-stack {
    height: min(64vh, 620px);
    flex-shrink: 1;
  }
}

@media (max-width: 768px) {
  .sticky-container {
    padding-bottom: 0px;
  }
  .scroll-animation {
    height: 350vh;
    padding-top: 35px;
  }

  .scroll-animation-header {
    top: 18px;
    width: min(88vw, 430px);
  }

  .scroll-animation-title {
    font-size: clamp(20px, 6vw, 27px);
  }

  .mobile-scroll-cue {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: fit-content;
    margin: 30px auto 0;
    color: rgba(255, 255, 255, 0.78);
    font-family: "Poppins", sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    pointer-events: none;
    opacity: 1;
    visibility: visible;
  }

  .mobile-scroll-cue.is-scrolling {
    opacity: 1;
    visibility: visible;
  }

  .mobile-scroll-cue i {
    color: #ff5a5a;
    font-size: 13px;
    animation: scrollCueBounce 1.4s ease-in-out infinite;
    filter: drop-shadow(0 0 7px rgba(255, 70, 70, 0.6));
  }

  .image-stack {
    width: auto;
    height: min(56vh, 520px);
    max-width: 84vw;
  }

  .stack-image:nth-child(2) {
    transform: translateY(calc(20px + ((1 - var(--progress)) * 80px)))
      scale(calc(0.84 + var(--progress) * 0.12));
  }

  .stack-image:nth-child(3) {
    transform: translateY(calc(40px + ((1 - var(--progress)) * 80px)))
      scale(calc(0.8 + var(--progress) * 0.12));
  }

  .scroll-progress {
    right: 14px;
  }

  .image-number {
    left: 20px;
    bottom: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stack-image {
    filter: none;
  }

  .mobile-scroll-cue i {
    animation: none;
  }
}

@keyframes scrollCueBounce {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.55;
  }

  50% {
    transform: translateY(6px);
    opacity: 1;
  }
}
