😘CSS Scroll Triggered Animations Full (ok)

<input type="checkbox" id="debug" />
<main>
  <h1>The Polar Bear</h1>
  <p>
    <b>This is a demo for
      <a href="https://brm.us/scroll-triggered-animations" target="_top">https://brm.us/scroll-triggered-animations</a>,
      which explains how the code works.</b>
  </p>
  <p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer mattis
    turpis eu neque tincidunt lacinia. Pellentesque habitant morbi tristique
    senectus et netus et malesuada fames ac turpis egestas. Aliquam auctor
    ultrices tortor et volutpat. Donec eu semper orci, eu fermentum orci.
    Vivamus aliquam lobortis egestas. Proin vel mauris vitae sem auctor cursus.
    Aenean sit amet odio at magna pharetra luctus nec eget urna. Vestibulum ante
    ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae;
    Praesent in leo at tellus ultricies laoreet.
  </p>
  <p>
    Nam pulvinar congue condimentum. Pellentesque fringilla ante sed massa
    tincidunt feugiat. Nulla bibendum est eros, non malesuada dolor vehicula in.
    Morbi eu cursus arcu. Phasellus ultricies ornare lorem, non interdum orci
    condimentum eu. Donec condimentum condimentum ligula ut placerat. Vestibulum
    id neque condimentum, molestie nunc vel, suscipit turpis. Quisque orci
    velit, mattis et nibh non, tempor finibus erat. Nullam tristique, tortor non
    commodo cursus, magna turpis rhoncus leo, quis porta quam ante sed orci.
    Nunc vehicula imperdiet leo in vulputate. Quisque quis dolor orci.
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p class="text-center">
    <span class="debugwrapper">
      <img src="https://placehold.co/600x400" alt title width="1080" height="720" class="revealing-image" />
    </span>
  </p>
  <p>
    <a href="https://unsplash.com/photos/PX_1j-M59I8">Polar bear walking</a> by
    <a href="https://unsplash.com/@dtbosse">Daniel Bosse</a>
  </p>
</main>
* {
  box-sizing: border-box;
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  font-family: SF Pro Text, SF Pro Icons, Helvetica Neue, Helvetica, Arial, sans-serif;
  color: hsl(0 0% 100%);
  background: hsl(0, 0%, 6%);
}

section {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.section__content {
	min-height: 100vh;
	position: sticky;
	top: 0;
	width: 100vw;
	display: grid;
	place-items: center;
	padding: 1rem;
	width: 60ch;
	max-width: 100vw;
	margin: 0 auto;
}

.section__content p {
	font-weight: 600;
	max-width: 40ch;
	font-size: clamp(1rem, 1vw + 1rem, 4rem);
	margin: 0;
	color: hsl(0 0% 100% / 0.5);
}

.section__content h2 {
	text-align: left;
	display: grid;
	gap: 0;
}

.section__content h2 span:first-of-type {
	opacity: 0.5;
	padding-left: 1rem;
	font-size: clamp(1rem, 1vw + 1rem, 4rem);
}

.section__content h2 span:last-of-type {
	background: linear-gradient(
		90deg,
		hsl(0 0% 100%),
		hsl(0 0% 80%) 50%,
		hsl(240deg 100% 75%),
		hsl(320deg 100% 75%),
		hsl(140deg 100% 75%),
		hsl(10deg 100% 75%)
	);
	-webkit-background-clip: text;
	color: transparent;
	background-size: 300% 200%;
	animation: bg-move both linear;
	animation-timeline: --section;
	animation-range: cover 0% exit 0%;
	background-position: 0 0;
}

@keyframes bg-move {
	to {
		background-position: 100% 200%;
	}
}

.section__content p span {
	color: hsl(0 0% 100% / 1);
}

:is(h1, h2) {
  margin: 0;
  font-size: 2.5rem;
}

section:nth-of-type(1),
section:nth-of-type(2),
section:nth-of-type(3),
section:nth-of-type(4) {
	position: relative;
	width: 100vw;
	display: block;
	view-timeline-name: --section;
}

/* CTA Specific stuff goes here.... */
.cta {
  position: sticky;
  z-index: 10;
  top: calc(100% - 6rem);
  display: inline-block;
  width: 100%;
  display: grid;
  place-items: center;
  /* Activates showing the CTA */
  animation: activate both linear, activate linear reverse;
  animation-timeline: --section, view();
  animation-range: entry, cover 50%;
}

.cta__content {
	position: relative;
}

/* Word */
.cta span:nth-of-type(1) {
  opacity: var(--scale, 0);
  transition: opacity 0.2s 0.6s;
  white-space: nowrap;
  padding: 0 0 0 0.5rem;
}

/* The Bloom */
.cta__content::before {
  --back: linear(
    0, 0.3412 4.06%, 0.6411 8.2%,
    0.9005 12.43%, 1.1205 16.77%,
    1.3013 21.22%, 1.4438 25.8%,
    1.549 30.54%, 1.5878 32.98%,
    1.6175 35.47%, 1.6457 39.41%,
    1.6518 41.44%, 1.6528 43.52%,
    1.6391 47.83%, 1.6042 52.44%,
    1.5562 56.74%, 1.4899 61.5%,
    1.202 78.86%, 1.0988 85.97%,
    1.0551 89.79%, 1.0244 93.36%,
    1.0061 96.75%, 1
  );
  content: "";
  background: hsl(210 100% 45%);
  position: absolute;
  inset: 0;
  border-radius: 100px;
  z-index: -1;
}

/* The icon holder */
.cta span:nth-of-type(2) {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: hsl(210 100% 45%);
  color: white;
  padding: 0.25rem;
  display: grid;
  place-items: center;
}

.cta svg {
  width: 20px;
  fill: hsl(0 0% 100% / 0.75);
}

.cta a:is(:hover, :focus-visible) svg {
  fill: white;
}

.cta a {
  --elastic: linear(
    0, 0.4789 7.06%, 0.7612 12.38%,
    0.8693 15.13%, 0.9538 17.95%,
    1.0165 20.89%, 1.059 24.04%,
    1.0829 27.58%, 1.0884 31.64%,
    1.0769 36.44%, 1.0202 50.6%,
    1.0005 59.62%, 0.9945 70.6%, 1
  );
  text-decoration-line: none;
  overflow: hidden;
  border-radius: 100px;
  padding: 1rem;
  background: hsl(240 2% 20% / 1);
  box-shadow: 0 1px hsl(0 0% 100% / 0.25) inset;
  color: hsl(0 0% 100%);
  display: grid;
  align-items: center;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 1.1rem;
  grid-template-columns: 0 36px;
}


@keyframes activate {
  0% { --active: 0; }
  100% { --active: 1; }
}

section:nth-of-type(1) {
	height: 200vh;
}

section:nth-of-type(2) {
	--content-size: 186px;
	height: 400vh;
}

section:nth-of-type(3) {
	--content-size: 180px;
  height: 300vh;
}

section:nth-of-type(4) {
	--content-size: 140px;
	height: 500vh;
}

/* Use style queries to dictate the timing, etc. */
@container style(--active: 0) {
  .cta__content::before {
    scale: 0;
    opacity: 0;
    transition: scale 0.5s var(--back);
  }
  .cta a {
    scale: 0;
    transition: scale 0.2s 0.7s, grid-template-columns 0.5s 0.2s var(--elastic);
    grid-template-columns: 0 36px;
  }
  .cta__content span:first-of-type {
    opacity: 0;
    transition: opacity 0.2s 0s;
  }
  .cta__content span:last-of-type {
    scale: 0;
    opacity: 0;
    transition: scale 0.2s, opacity 0.2s;
  }
}
@container style(--active: 1) {
  .cta__content::before {
    scale: 0.99;
    opacity: 1;
    transition: scale 0.5s var(--back);
  }
  .cta a {
    scale: 1;
    transition: scale 0.2s 0s, grid-template-columns 0.5s 0.6s var(--elastic);
    grid-template-columns: var(--content-size, auto) 36px;
  }
  .cta__content span:first-of-type {
    opacity: 1;
    transition: opacity 0.2s 0.7s;
  }
  .cta__content span:last-of-type {
    scale: 1;
    opacity: 1;
    transition: scale 0.2s 0.4s, opacity 0.2s 0.4s;
  }
}

/* Nav stuff */
nav {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	border-bottom: 1px solid hsl(0 0% 50%);
	height: 52px;
	background: hsl(0 0% 20% / 0.75);
	backdrop-filter: blur(4px);
	z-index: 2;
}


.nav__content {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 800px;
	max-width: 100vh;
	padding: 0 1rem;
	margin: 0 auto;
	height: 100%;
}

nav a {
	text-decoration: none;
	background: hsl(210 100% 45%);
	color: hsl(0 0% 98%);
	font-weight: 400;
	padding: 0.5rem 1rem;
	border-radius: 100px;
	font-size: 0.875rem;
}

nav img {
	height: 50%;
	justify-self: start;
}

.support {
  position: fixed;
  z-index: 10;
  left: 1rem;
  top: 1rem;
  background: white;
  color: black;
  padding: 2rem;
  border: 4px solid hsl(45 80% 50%);
}

@supports (animation-timeline: view()) {
  .support {
    display: none;
  }
}

/* Heading */
h1 {
	display: grid;
}

:is(h1, h2) {
	font-size: clamp(2.5rem, 7vw + 1rem, 10rem);
	text-align: center;
	line-height: 1;
	margin: 0;
	width: 100%;
}

h1 {
	position: fixed;
	top: 50%;
	left: 50%;
	translate: -50% -50%;
}

h1 span:first-of-type {
	display: inline-block;
  color: hsl(0 100% 50%);
	font-size: 0.35em;
}

h1 span:last-of-type {
	display: inline-block;
}

h1 span:first-of-type {
	display: inline-block;
	animation: fade-away both linear;
	animation-timeline: --section;
	animation-range: entry-crossing 50% exit 50%;
}

h1 span:last-of-type {
	display: inline-block;
	animation: scale-up both cubic-bezier(.1,.7,.9,1.3), fade-away both linear;
	animation-timeline: --section;
	animation-range: entry-crossing 60% exit 70%, exit 10% exit 50%;	
}

@keyframes scale-up {
	to {
		scale: 1.5;
	}
}

@keyframes grow {
	0% {
		scale: 0.5;
		opacity: 0;
	}
}

@keyframes fade-away {
	100% {
		opacity: 0;
	}
}


video {
	position: fixed;
	inset: 0;
	object-fit: cover;
	width: 100%;
	height: 100vh;
	z-index: -1;
	filter: saturate(0.1) brightness(0.5);
	opacity: 0;
	animation: fade-in both linear, fade-out both linear;
	animation-timeline: --section;
	animation-range: entry 10% entry 15%, exit 10% exit 15%;
}

@keyframes fade-in {
	to {
		opacity: 0.2;
	}
}

@keyframes fade-out {
	to {
		opacity: 0;
	}
}

<div role="img" class="intro" aria-label="Scroll down for the magic">
  <span>👋</span>
  <span>⬇️</span>
</div>
<div class="box">
  <p class="text">hello</p>
</div>
<div class="box">
  <p class="text">is it me you're looking for?</p>
</div>
<div class="box">
  <p class="text">I can see it in your eyes</p>
</div>
<div class="box">
  <p class="text">I can see it in your smile</p>
</div>
<div class="smile" role="img" aria-hidden>
  <div>
    <span>☺️</span>
    <span>🙂</span>
    <span>😉</span>
  </div>
</div>
* {
  box-sizing: border-box;
}

:root {
  --color: #1e293b;
  --c1: #fbda61;
  --c2: #ff5acd;
  --c3: #2563eb;
  --gradient: linear-gradient(
    60deg,
    var(--c3),
    var(--c2),
    var(--c1),
    var(--c2),
    var(--c3)
  );
  --scale-start: 0.5;
  --scale-end: 1.001;
  --hover-offset: 5%;

  /* 
    linear easing generator
    https://linear-easing-generator.netlify.app/
  */
  /* prettier-ignore */
  --ease-elastic: linear(
    0, 0.186 2.1%, 0.778 7.2%, 1.027 9.7%, 1.133, 1.212, 1.264, 1.292 15.4%,
    1.296, 1.294, 1.285, 1.269 18.9%, 1.219 20.9%, 1.062 25.8%, 0.995 28.3%,
    0.944 31.1%, 0.93, 0.921, 0.92 35.7%, 0.926, 0.94 39.7%, 1.001 47%, 1.014,
    1.021 52.4%, 1.02 56.4%, 1 65.5%, 0.994 70.7%, 1.001 88.4%, 1
  );
  --ease-bounce-out: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-reduced-motion) {
  :root {
    --scale-start: var(--scale-end);
    --ease-elastic: ease-out;
    --ease-bounce-out: ease-out;
    --hover-offset: 0;
  }
}

body {
  padding-inline: 1rem;
  font-family: system-ui;
  font-weight: 800;
  font-size: calc(1rem + 10vmin);
  text-align: center;
  overflow-x: hidden;
}

.intro {
  display: flex;
  justify-content: center;
  gap: 0.2em;
  font-size: 0.5em;
  margin-block-start: calc(50vh - 1ex);
}

.intro span {
  display: inline-block;
}

.intro span:first-child {
  transform-origin: right bottom;
  animation: wave 250ms 1s ease 3;
}

.intro span:last-child {
  animation: hover 500ms linear infinite;
}

.box {
  margin-block: 80vh;
}

.text {
  margin-inline: auto;
  padding-block: 0.2em;
  max-inline-size: 15ch;
  text-wrap: balance;
  background-image: var(--gradient);
  background-size: 400%;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

@supports (animation-timeline: view()) {
  .box {
    animation: trigger steps(1) both, fade linear both;
    animation-timeline: view();
    animation-range: entry 80% contain 40%;
  }

  .text {
    animation: pop-back 300ms var(--ease-bounce-out) forwards;
  }

  @container style(--animate: true) {
    .text {
      animation: pop 600ms var(--ease-elastic) forwards,
        text-gradient 1s cubic-bezier(0, 0.55, 0.45, 1) forwards;
    }
  }
}

.smile {
  width: 1em;
  margin-inline: auto;
  overflow: hidden;
  white-space: nowrap;
  margin-block-end: calc(50vh - 1ex);
}

.smile div {
  display: flex;
  animation: wink 1s steps(1) infinite;
}

.smile span {
  display: inline-block;
  width: 1em;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes trigger {
  to {
    --animate: true;
  }
}

@keyframes pop {
  from {
    scale: var(--scale-start);
  }
  to {
    scale: var(--scale-end);
  }
}

@keyframes text-gradient {
  100% {
    background-position: 150% center;
  }
}

@keyframes pop-back {
  from {
    scale: var(--scale-end);
  }
  to {
    color: var(--color);
    scale: var(--scale-start);
  }
}

@keyframes wink {
  0%,
  100% {
    translate: 0 0;
  }
  25%,
  75% {
    translate: -100% 0;
  }
  50% {
    translate: -200% 0;
  }
}

@keyframes wave {
  50% {
    rotate: 10deg;
  }
}

@keyframes hover {
  from,
  to {
    translate: 0 calc(var(--hover-offset) * -1);
  }
  50% {
    translate: 0 var(--hover-offset);
  }
}

<div class="support">Check this out in Chrome 115+ / Chrome Canary</div>
    <nav>
      <div class="nav__content">
        <img
          src="https://assets.codepen.io/605876/bear-2022--white.png"
          alt=""
        />
        <a
          href="https://twitter.com/intent/follow?screen_name=jh3yy"
          target="_blank"
          >Follow</a
        >
      </div>
    </nav>
    <section>
      <div class="section__content">
        <h1>
          <span>All-new</span>
          <span>CSS Pro</span>
        </h1>
      </div>
    </section>
    <section>
      <div class="cta">
        <div class="cta__content">
          <a
            href="https://codepen.io/jh3y/details/zYyzYpY"
            target="_blank"
            rel="noopener noreferrer"
          >
            <span>Add to Bookmarks</span>
            <span>
              <svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="currentColor"
                class="w-6 h-6"
              >
                <path
                  fill-rule="evenodd"
                  d="M12 3.75a.75.75 0 01.75.75v6.75h6.75a.75.75 0 010 1.5h-6.75v6.75a.75.75 0 01-1.5 0v-6.75H4.5a.75.75 0 010-1.5h6.75V4.5a.75.75 0 01.75-.75z"
                  clip-rule="evenodd"
                />
              </svg>
            </span>
          </a>
        </div>
      </div>
      <div class="section__content">
        <p>
          Dynamic call-to-action powered by <span>container queries</span> and
          <span>scroll-driven animations</span>.
        </p>
      </div>
    </section>
    <section>
      <video
        src="https://assets.codepen.io/605876/seoul-21116.mp4"
        autoplay
        playsinline
        muted
        loop
      ></video>
      <div class="cta">
        <div class="cta__content">
          <a
            href="https://codepen.io/jh3y/details/zYyzYpY"
            target="_blank"
            rel="noopener noreferrer"
          >
            <span>Heart this pen (3x)</span>
            <span>
              <svg
                aria-hidden="true"
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 24 24"
                fill="currentColor"
                class="w-6 h-6"
              >
                <path
                  d="M11.645 20.91l-.007-.003-.022-.012a15.247 15.247 0 01-.383-.218 25.18 25.18 0 01-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0112 5.052 5.5 5.5 0 0116.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 01-4.244 3.17 15.247 15.247 0 01-.383.219l-.022.012-.007.004-.003.001a.752.752 0 01-.704 0l-.003-.001z"
                />
              </svg>
            </span>
          </a>
        </div>
      </div>
      <div class="section__content">
        <p>
          Define transition sequences using <span>style queries</span>. Then
          toggle them with <span>scroll-driven animations</span>. Resulting in
          <span>scroll-triggered animations</span>.
        </p>
      </div>
    </section>
    <section>
      <div class="cta">
        <div class="cta__content">
          <a
            href="https://twitter.com/intent/tweet?text=%22Apple%20Style%20CTA%20Reveal%20with%20CSS%20scroll-driven%20animations%22%20via%20%40jh3yy%0Ahttps://codepen.io/jh3y/pen/zYyzYpY"
            target="_blank"
            rel="noopener noreferrer"
          >
            <span>Share over on</span>
            <span>
              <svg
                role="img"
                viewBox="0 0 24 24"
                xmlns="http://www.w3.org/2000/svg"
              >
                <title>X</title>
                <path
                  d="M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z"
                />
              </svg>
            </span>
          </a>
        </div>
      </div>
      <div class="section__content">
        <h2><span>Become a</span><span>CSS Pro</span></h2>
      </div>
    </section>
    <section>
      <h2>fin.</h2>
    </section>
* {
  box-sizing: border-box;
}
body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  font-family: SF Pro Text, SF Pro Icons, Helvetica Neue, Helvetica, Arial,
    sans-serif;
  color: hsl(0 0% 100%);
  background: hsl(0, 0%, 6%);
}
section {
  min-height: 100vh;
  display: grid;
  place-items: center;
  &:nth-of-type(1),
  &:nth-of-type(2),
  &:nth-of-type(3),
  &:nth-of-type(4) {
    position: relative;
    width: 100vw;
    display: block;
    view-timeline-name: --section;
  }
}
.section__content {
  min-height: 100vh;
  position: sticky;
  top: 0;
  width: 100vw;
  display: grid;
  place-items: center;
  padding: 1rem;
  width: 60ch;
  max-width: 100vw;
  margin: 0 auto;
  p {
    font-weight: 600;
    max-width: 40ch;
    font-size: clamp(1rem, 1vw + 1rem, 4rem);
    margin: 0;
    color: rgba(255, 255, 255, 0.5);
    span {
      color: #fff;
    }
  }
  h2 {
    text-align: left;
    display: grid;
    gap: 0;
    span {
      &:first-of-type {
        opacity: 0.5;
        padding-left: 1rem;
        font-size: clamp(1rem, 1vw + 1rem, 4rem);
      }
      &:last-of-type {
        background: linear-gradient(
          90deg,
          hsl(0deg, 0%, 100%),
          hsl(0deg, 0%, 80%) 50%,
          hsl(240deg, 100%, 75%),
          hsl(320deg, 100%, 75%),
          hsl(140deg, 100%, 75%),
          hsl(10deg, 100%, 75%)
        );
        -webkit-background-clip: text;
        color: rgba(0, 0, 0, 0);
        background-size: 300% 200%;
        animation: bg-move both linear;
        animation-timeline: --section;
        animation-range: cover 0% exit 0%;
        background-position: 0 0;
      }
    }
  }
}
:is(h1, h2) {
  margin: 0;
  font-size: 2.5rem;
}
.cta {
  position: sticky;
  z-index: 10;
  top: calc(100% - 6rem);
  display: inline-block;
  width: 100%;
  display: grid;
  place-items: center;
  animation: activate both linear, activate linear reverse;
  animation-timeline: --section, view();
  animation-range: entry, cover 50%;
  span {
    &:nth-of-type(1) {
      opacity: var(--scale, 0);
      transition: opacity 0.2s 0.6s;
      white-space: nowrap;
      padding: 0 0 0 0.5rem;
    }
    &:nth-of-type(2) {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: #0073e6;
      color: #fff;
      padding: 0.25rem;
      display: grid;
      place-items: center;
    }
  }
  svg {
    width: 20px;
    fill: rgba(255, 255, 255, 0.75);
  }
  a {
    --elastic: linear(
      0,
      0.4789 7.06%,
      0.7612 12.38%,
      0.8693 15.13%,
      0.9538 17.95%,
      1.0165 20.89%,
      1.059 24.04%,
      1.0829 27.58%,
      1.0884 31.64%,
      1.0769 36.44%,
      1.0202 50.6%,
      1.0005 59.62%,
      0.9945 70.6%,
      1
    );
    -webkit-text-decoration-line: none;
    text-decoration-line: none;
    overflow: hidden;
    border-radius: 100px;
    padding: 1rem;
    background: #323234;
    box-shadow: 0 1px rgba(255, 255, 255, 0.25) inset;
    color: #fff;
    display: grid;
    align-items: center;
    font-weight: 600;
    letter-spacing: -0.01em;
    font-size: 1.1rem;
    grid-template-columns: 0 36px;
  }
  &:is(:hover, :focus-visible) {
    svg {
      fill: #fff;
    }
  }
}
@keyframes activate {
  0% {
    --active: 0;
  }
  100% {
    --active: 1;
  }
}
section {
  &:nth-of-type(1) {
    height: 200vh;
  }
  &:nth-of-type(2) {
    --content-size: 186px;
    height: 400vh;
  }
  &:nth-of-type(3) {
    --content-size: 180px;
    height: 300vh;
  }
  &:nth-of-type(4) {
    --content-size: 140px;
    height: 500vh;
  }
}
/* Use style queries to dictate the timing, etc. */
@container style(--active: 0) {
  .cta__content {
    &::before {
      scale: 0;
      opacity: 0;
      transition: scale 0.5s var(--back);
    }
    span {
      &:first-of-type {
        opacity: 0;
        transition: opacity 0.2s 0s;
      }
      &:last-of-type {
        scale: 0;
        opacity: 0;
        transition: scale 0.2s, opacity 0.2s;
      }
    }
  }
  .cta {
    a {
      scale: 0;
      transition: scale 0.2s 0.7s,
        grid-template-columns 0.5s 0.2s var(--elastic);
      grid-template-columns: 0 36px;
    }
  }
}
@container style(--active: 1) {
  .cta__content {
    &::before {
      scale: 0.99;
      opacity: 1;
      transition: scale 0.5s var(--back);
    }
    span {
      &:first-of-type {
        opacity: 1;
        transition: opacity 0.2s 0.7s;
      }
      &:last-of-type {
        scale: 1;
        opacity: 1;
        transition: scale 0.2s 0.4s, opacity 0.2s 0.4s;
      }
    }
  }
  .cta {
    a {
      scale: 1;
      transition: scale 0.2s 0s, grid-template-columns 0.5s 0.6s var(--elastic);
      grid-template-columns: var(--content-size, auto) 36px;
    }
  }
}
/* Nav stuff */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  border-bottom: 1px solid gray;
  height: 52px;
  background: rgba(51, 51, 51, 0.75);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 2;
  a {
    text-decoration: none;
    background: #0073e6;
    color: #fafafa;
    font-weight: 400;
    padding: 0.5rem 1rem;
    border-radius: 100px;
    font-size: 0.875rem;
  }
  img {
    height: 50%;
    justify-self: start;
  }
}
.nav__content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 800px;
  max-width: 100vh;
  padding: 0 1rem;
  margin: 0 auto;
  height: 100%;
}
/* Heading */
:is(h1, h2) {
  font-size: clamp(2.5rem, 7vw + 1rem, 10rem);
  text-align: center;
  line-height: 1;
  margin: 0;
  width: 100%;
}
h1 {
  display: grid;
  position: fixed;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  span {
    &:first-of-type {
      display: inline-block;
      color: hsl(0 100% 50%);
      font-size: 0.35em;
      display: inline-block;
      animation: fade-away both linear;
      animation-timeline: --section;
      animation-range: entry-crossing 50% exit 50%;
    }
    &:last-of-type {
      display: inline-block;
      display: inline-block;
      animation: scale-up both cubic-bezier(0.1, 0.7, 0.9, 1.3),
        fade-away both linear;
      animation-timeline: --section;
      animation-range: entry-crossing 60% exit 70%, exit 10% exit 50%;
    }
  }
}
video {
  position: fixed;
  inset: 0;
  object-fit: cover;
  width: 100%;
  height: 100vh;
  z-index: -1;
  filter: saturate(0.1) brightness(0.5);
  opacity: 0;
  animation: fade-in both linear, fade-out both linear;
  animation-timeline: --section;
  animation-range: entry 10% entry 15%, exit 10% exit 15%;
}
@supports (animation-timeline: view()) {
  .support {
    display: none;
  }
}
@keyframes bg-move {
  to {
    background-position: 100% 200%;
  }
}
@keyframes fade-in {
  to {
    opacity: 0.2;
  }
}
@keyframes fade-out {
  to {
    opacity: 0;
  }
}
@keyframes scale-up {
  to {
    scale: 1.5;
  }
}
@keyframes grow {
  0% {
    scale: 0.5;
    opacity: 0;
  }
}
@keyframes fade-away {
  100% {
    opacity: 0;
  }
}

Last updated