kitbash Sign in Connect agent
Components

Screensaver deck

The signature first screen: a deck of drawn ceramic pictures pops in and cascades away, the giant wordmark rises out of a blur, and the last picture bounces around the screen under the wordmark, which inverts it through difference blend. Click it to stamp a copy and fire the next picture; a round difference cursor follows the pointer.

Part of the style

Difference Deck

6 parts that belong together, with their tokens, type and rules.

Preview

Code
<style>
/* Goes after the pack's base.css */
@import url("https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;800&family=Newsreader:opsz,wght@6..72,400;6..72,600&display=swap");
:root {
  --paper: #dbdbdb;
  --ink: #0a1508;
  --mute: #625f58;
  --dim: #495248;
  --hairline: rgba(219, 219, 219, 0.15);
  --glow: rgba(219, 219, 219, 0.9);
  --glow-dark: rgba(10, 21, 8, 0.55);
  --art-bone: #d0d0cf;
  --art-soot: #283227;
  --art-tangerine: #1f9525;
  --art-coral: #209125;
  --art-sand: #698567;
  --art-red: #079818;
  --art-ember: #059517;
  --art-ochre: #279c2c;
  --art-cobalt: #5a6e57;
  --art-blue: #586c54;
  --art-celadon: #718a6f;
  --art-lilac: #1f9525;
  --art-rose: #71856d;
  --font-text: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-logo: "Newsreader", "Iowan Old Style", "Times New Roman", serif;
}
</style>

<section class="hero" aria-label="TERRON, ceramics by Mira Holt">
  <div class="hero__deck" aria-hidden="true"></div>
  <div class="hero__stamps" aria-hidden="true"></div>
  <button class="hero__card" type="button" aria-label="Show the next piece"><span class="hero__frame"></span></button>

  <svg class="hero__mark" role="img" aria-label="TERRON" viewBox="0 25.9 420 75.5" preserveAspectRatio="xMidYMax meet">
    <text class="hero__word" x="0" y="100">TERRON</text>
  </svg>

  <div class="hero__cursor" aria-hidden="true"><span class="hero__cursor-label">Go on, fire another</span></div>

  <div class="hero__library" hidden>
    <!-- Night jar: a cobalt jar against a lilac to ember sky. The piece that stays and bounces. -->
    <svg class="hero__art" viewBox="0 0 300 410" data-name="Night jar">
      <defs>
        <linearGradient id="hero-jar-sky" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stop-color="#b04dff"/>
          <stop offset="0.5" stop-color="#ff6fae"/>
          <stop offset="0.72" stop-color="#ff8a4a"/>
          <stop offset="0.8" stop-color="#ff4d12"/>
          <stop offset="1" stop-color="#ff3a08"/>
        </linearGradient>
        <radialGradient id="hero-jar-body" cx="0.36" cy="0.42" r="0.78">
          <stop offset="0" stop-color="#8fa0ff"/>
          <stop offset="0.38" stop-color="#1d3cff"/>
          <stop offset="0.8" stop-color="#0a1797"/>
          <stop offset="1" stop-color="#050b55"/>
        </radialGradient>
        <linearGradient id="hero-jar-rim" x1="0" y1="0" x2="1" y2="0">
          <stop offset="0" stop-color="#ff7a3d" stop-opacity="0"/>
          <stop offset="0.82" stop-color="#ff7a3d" stop-opacity="0"/>
          <stop offset="1" stop-color="#ff7a3d" stop-opacity="0.75"/>
        </linearGradient>
        <filter id="hero-jar-soft" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="6"/></filter>
        <filter id="hero-jar-shine" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="2.4"/></filter>
      </defs>
      <rect width="300" height="410" fill="url(#hero-jar-sky)"/>
      <rect y="296" width="300" height="22" fill="#ffd2a6" opacity="0.4" filter="url(#hero-jar-soft)"/>
      <ellipse cx="152" cy="353" rx="78" ry="10" fill="#5c0c00" opacity="0.55" filter="url(#hero-jar-soft)"/>
      <path d="M124 108 H176 Q170 112 168 122 Q166 140 172 150 C214 168 232 214 226 256 C220 300 196 330 182 344 L182 350 H118 L118 344 C104 330 80 300 74 256 C68 214 86 168 128 150 Q134 140 132 122 Q130 112 124 108 Z" fill="url(#hero-jar-body)"/>
      <path d="M124 108 H176 Q170 112 168 122 Q166 140 172 150 C214 168 232 214 226 256 C220 300 196 330 182 344 L182 350 H118 L118 344 C104 330 80 300 74 256 C68 214 86 168 128 150 Q134 140 132 122 Q130 112 124 108 Z" fill="url(#hero-jar-rim)"/>
      <ellipse cx="150" cy="108" rx="26" ry="4.5" fill="#050b55"/>
      <path d="M125 107.5 Q150 102 175 107.5" fill="none" stroke="#c9d1ff" stroke-width="1.4" opacity="0.8"/>
      <ellipse cx="108" cy="238" rx="8" ry="58" fill="#ffffff" opacity="0.6" filter="url(#hero-jar-shine)"/>
      <ellipse cx="130" cy="171" rx="15" ry="5" fill="#ffffff" opacity="0.5" transform="rotate(-24 130 171)" filter="url(#hero-jar-shine)"/>
      <rect x="118" y="346" width="64" height="4" fill="#03072f"/>
    </svg>

    <!-- Kiln mouth: the glowing arch of a fired kiln in a cobalt wall. -->
    <svg class="hero__art" viewBox="0 0 300 375" data-name="Kiln mouth">
      <defs>
        <radialGradient id="hero-kiln-heat" cx="0.5" cy="0.64" r="0.62">
          <stop offset="0" stop-color="#fff4c2"/>
          <stop offset="0.22" stop-color="#ffb000"/>
          <stop offset="0.58" stop-color="#ff4d12"/>
          <stop offset="1" stop-color="#4a0a00"/>
        </radialGradient>
        <radialGradient id="hero-kiln-wall" cx="0.5" cy="0.55" r="0.75">
          <stop offset="0.5" stop-color="#1d3cff"/>
          <stop offset="1" stop-color="#0b1a9e"/>
        </radialGradient>
        <filter id="hero-kiln-spill" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="14"/></filter>
      </defs>
      <rect width="300" height="375" fill="url(#hero-kiln-wall)"/>
      <path d="M62 336 V176 A88 88 0 0 1 238 176 V336 Z" fill="#ff4d12" opacity="0.55" filter="url(#hero-kiln-spill)"/>
      <path d="M70 330 V178 A80 80 0 0 1 230 178 V330 Z" fill="url(#hero-kiln-heat)"/>
      <path d="M70 330 V178 A80 80 0 0 1 230 178 V330" fill="none" stroke="#160f0c" stroke-width="9" opacity="0.9"/>
      <g fill="#160f0c" opacity="0.82">
        <rect x="80" y="252" width="140" height="5"/>
        <rect x="80" y="318" width="140" height="5"/>
        <path d="M96 252 C92 236 98 226 104 222 H112 C118 226 124 236 120 252 Z"/>
        <path d="M134 252 V232 C134 226 162 226 162 232 V252 Z"/>
        <path d="M178 252 C174 240 182 230 192 230 C202 230 208 240 204 252 Z"/>
        <path d="M104 318 C100 300 112 290 124 290 C136 290 146 300 142 318 Z"/>
        <path d="M168 318 V296 H200 V318 Z"/>
      </g>
      <rect x="52" y="330" width="196" height="12" fill="#160f0c" opacity="0.9"/>
    </svg>

    <!-- Test tiles: a board of glaze tests on bare clay. -->
    <svg class="hero__art" viewBox="0 0 480 320" data-name="Glaze tests">
      <rect width="480" height="320" fill="#f4efe4"/>
      <g font-family="Inter, Arial, sans-serif" font-weight="600" font-size="9" fill="#160f0c" letter-spacing="-0.1">
        <text x="18" y="30">Glaze tests, cone 10, reduction</text>
        <text x="462" y="30" text-anchor="end">Sheet 14</text>
      </g>
      <g>
        <rect x="18" y="52" width="64" height="64" rx="4" fill="#1d3cff"/><rect x="94" y="52" width="64" height="64" rx="4" fill="#9fd8c4"/><rect x="170" y="52" width="64" height="64" rx="4" fill="#ffb000"/><rect x="246" y="52" width="64" height="64" rx="4" fill="#160f0c"/><rect x="322" y="52" width="64" height="64" rx="4" fill="#ff4d12"/><rect x="398" y="52" width="64" height="64" rx="4" fill="#b04dff"/>
        <rect x="18" y="128" width="64" height="64" rx="4" fill="#ff6fae"/><rect x="94" y="128" width="64" height="64" rx="4" fill="#b59f7e"/><rect x="170" y="128" width="64" height="64" rx="4" fill="#0a1797"/><rect x="246" y="128" width="64" height="64" rx="4" fill="#ff1f0f"/><rect x="322" y="128" width="64" height="64" rx="4" fill="#d9e9c8"/><rect x="398" y="128" width="64" height="64" rx="4" fill="#ff8b35"/>
        <rect x="18" y="204" width="64" height="64" rx="4" fill="#4f9c86"/><rect x="94" y="204" width="64" height="64" rx="4" fill="#ffd36b"/><rect x="170" y="204" width="64" height="64" rx="4" fill="#6b3b2a"/><rect x="246" y="204" width="64" height="64" rx="4" fill="#8fa0ff"/><rect x="322" y="204" width="64" height="64" rx="4" fill="#f4efe4" stroke="#160f0c" stroke-opacity="0.15"/><rect x="398" y="204" width="64" height="64" rx="4" fill="#1238ff"/>
      </g>
      <g fill="#000000" opacity="0.18">
        <rect x="18" y="96" width="64" height="20" rx="4"/><rect x="170" y="96" width="64" height="20" rx="4"/><rect x="322" y="96" width="64" height="20" rx="4"/>
        <rect x="94" y="172" width="64" height="20" rx="4"/><rect x="246" y="172" width="64" height="20" rx="4"/><rect x="398" y="172" width="64" height="20" rx="4"/>
        <rect x="18" y="248" width="64" height="20" rx="4"/><rect x="170" y="248" width="64" height="20" rx="4"/><rect x="322" y="248" width="64" height="20" rx="4"/>
      </g>
      <g font-family="Inter, Arial, sans-serif" font-weight="600" font-size="8" fill="#160f0c" opacity="0.7">
        <text x="18" y="290">01 to 18, two dips on the lower third</text>
        <text x="462" y="290" text-anchor="end">MH</text>
      </g>
    </svg>

    <!-- Celadon bowl: a bowl seen from above on a red ground. -->
    <svg class="hero__art" viewBox="0 0 380 380" data-name="Celadon bowl">
      <defs>
        <radialGradient id="hero-bowl-glaze" cx="0.46" cy="0.44" r="0.6">
          <stop offset="0" stop-color="#e8f7f0"/>
          <stop offset="0.45" stop-color="#9fd8c4"/>
          <stop offset="0.9" stop-color="#4f9c86"/>
          <stop offset="1" stop-color="#2d6b5a"/>
        </radialGradient>
        <radialGradient id="hero-bowl-well" cx="0.5" cy="0.5" r="0.5">
          <stop offset="0" stop-color="#5fb39b"/>
          <stop offset="1" stop-color="#9fd8c4"/>
        </radialGradient>
        <filter id="hero-bowl-shadow" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="12"/></filter>
      </defs>
      <rect width="380" height="380" fill="#ff1f0f"/>
      <circle cx="204" cy="208" r="132" fill="#7a0600" opacity="0.6" filter="url(#hero-bowl-shadow)"/>
      <circle cx="190" cy="190" r="132" fill="url(#hero-bowl-glaze)"/>
      <circle cx="190" cy="190" r="112" fill="none" stroke="#ffffff" stroke-opacity="0.35" stroke-width="2"/>
      <circle cx="190" cy="190" r="50" fill="url(#hero-bowl-well)"/>
      <path d="M96 112 A124 124 0 0 1 182 66" fill="none" stroke="#ffffff" stroke-width="5" stroke-linecap="round" opacity="0.7"/>
      <circle cx="176" cy="176" r="9" fill="#ffffff" opacity="0.55"/>
    </svg>

    <!-- Speckled cup: a stoneware cup with a cobalt dip on ash yellow. -->
    <svg class="hero__art" viewBox="0 0 305 324" data-name="Speckled cup">
      <defs>
        <filter id="hero-cup-grain" x="0" y="0" width="100%" height="100%">
          <feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="1" seed="7"/>
          <feColorMatrix values="0 0 0 0 0.09  0 0 0 0 0.06  0 0 0 0 0.05  0 0 0 -9 4.6"/>
        </filter>
        <linearGradient id="hero-cup-body" x1="0" y1="0" x2="1" y2="0">
          <stop offset="0" stop-color="#cfc6b4"/>
          <stop offset="0.35" stop-color="#f4efe4"/>
          <stop offset="1" stop-color="#a99d86"/>
        </linearGradient>
        <filter id="hero-cup-shadow" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="7"/></filter>
      </defs>
      <rect width="305" height="324" fill="#ffb000"/>
      <ellipse cx="160" cy="262" rx="88" ry="10" fill="#7a4a00" opacity="0.5" filter="url(#hero-cup-shadow)"/>
      <path d="M206 140 C252 136 254 214 204 210" fill="none" stroke="#e6dfd0" stroke-width="15" stroke-linecap="round"/>
      <path d="M92 112 H212 V236 C212 252 200 260 186 260 H118 C104 260 92 252 92 236 Z" fill="url(#hero-cup-body)"/>
      <path d="M92 112 H212 V150 C204 150 202 168 196 168 C190 168 190 152 180 152 C168 152 170 176 160 176 C150 176 152 150 140 150 C128 150 130 164 120 164 C110 164 108 150 92 150 Z" fill="#1d3cff"/>
      <ellipse cx="152" cy="112" rx="60" ry="9" fill="#0a1797"/>
      <rect x="92" y="104" width="120" height="160" fill="#000000" filter="url(#hero-cup-grain)" opacity="0.5"/>
      <rect x="104" y="160" width="6" height="84" rx="3" fill="#ffffff" opacity="0.45"/>
    </svg>
  </div>
</section>

<style>
  .hero {
    position: relative;
    isolation: isolate;
    height: var(--stage-height);
    overflow: hidden;
    background: var(--paper);
    --card-w: clamp(8.5rem, 20.5vw, 18.5rem);
  }
  @media (hover: hover) and (pointer: fine) {
    .hero,
    .hero__card { cursor: none; }
  }

  /* Intro cards stack in the centre, pop in one by one and leave in a cascade. */
  .hero__deck,
  .hero__stamps {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }
  .hero__block,
  .hero__stamp {
    position: absolute;
    top: 50%;
    left: 50%;
    width: calc(var(--card-w) * var(--size, 1));
    translate: -50% -50%;
  }
  .hero__block {
    opacity: 0;
    animation:
      hero-pop var(--time-pop) var(--ease-pop) var(--in) both,
      hero-drop var(--time-drop) ease-out var(--out) forwards;
  }
  .hero__stamp {
    opacity: 0.9;
  }
  .hero__stamp.is-leaving {
    animation: hero-drop var(--time-drop) ease-out forwards;
  }
  .hero__art {
    width: 100%;
    height: auto;
  }

  /* The piece that stays: pops in last, then drifts and bounces off the edges. */
  .hero__card {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    width: var(--card-w);
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    translate: -50% -50%;
    will-change: transform;
  }
  .hero__frame {
    display: block;
    opacity: 0;
  }
  .hero.is-started .hero__frame {
    animation: hero-pop var(--time-pop) var(--ease-pop) var(--final) both;
  }
  .hero.is-started .hero__frame.is-popping {
    animation: hero-pop var(--time-pop) var(--ease-pop) both;
  }
  .hero__card:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 4px;
  }

  /* The wordmark sits on top in difference: black on white, the inverse of any picture under it. */
  .hero__mark {
    position: absolute;
    right: 1%;
    bottom: var(--edge);
    left: 1%;
    z-index: 2;
    width: 98%;
    height: auto;
    overflow: visible;
    mix-blend-mode: difference;
    pointer-events: none;
    opacity: 0;
    transform: translateY(45%);
    filter: blur(16px);
  }
  .hero__word {
    fill: var(--paper);
    font-family: var(--font-text);
    font-size: 100px;
    font-weight: var(--weight-mark);
    font-variation-settings: var(--optical);
    letter-spacing: var(--tracking-mark);
  }
  .hero.is-started .hero__mark {
    opacity: 1;
    transform: none;
    filter: blur(0);
    transition:
      opacity var(--time-media) var(--ease-fade) var(--rise),
      transform var(--time-media) var(--ease-fade) var(--rise),
      filter var(--time-media) var(--ease-fade) var(--rise);
  }

  /* The round cursor, in difference too, with a note when it is over the piece. */
  .hero__cursor {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    width: var(--cursor);
    height: var(--cursor);
    margin: calc(var(--cursor) / -2) 0 0 calc(var(--cursor) / -2);
    border-radius: var(--radius-round);
    background: var(--paper);
    mix-blend-mode: difference;
    pointer-events: none;
    opacity: 0;
    scale: 0.4;
    transition: opacity var(--time-dim) var(--ease-dim), scale var(--time-dim) var(--ease-dim);
  }
  .hero.is-pointing .hero__cursor {
    opacity: 1;
    scale: 1;
  }
  .hero__cursor-label {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    color: var(--paper);
    font-size: var(--text-s);
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, 8px);
    transition: opacity var(--time-fade) var(--ease-fade), transform var(--time-fade) var(--ease-fade);
  }
  .hero.is-over-card .hero__cursor-label {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  @keyframes hero-pop {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
  }
  @keyframes hero-drop {
    to { opacity: 0; transform: scale(0.96); }
  }

  @media (max-width: 52rem) {
    .hero { --card-w: clamp(8.5rem, 40vw, 18.5rem); }
  }
  @media (hover: none), (pointer: coarse) {
    .hero__cursor { display: none; }
  }

  @media (prefers-reduced-motion: reduce) {
    .hero__block { display: none; }
    .hero .hero__frame,
    .hero.is-started .hero__frame { opacity: 1; animation: none; }
    .hero .hero__mark,
    .hero.is-started .hero__mark { opacity: 1; transform: none; filter: none; transition: none; }
  }
</style>

<script>
(() => {
  const STILL = matchMedia('(prefers-reduced-motion: reduce)');
  const START = 100;
  const DECK = [{ art: 2, size: 1.63 }, { art: 3, size: 1.29 }, { art: 1, size: 1.28 }];
  const FINAL_ART = 0;
  const MOST_STAMPS = 5;
  const CURSOR_PULL = 18;
  const CAP_HEIGHT = 72.7;
  const OVERSHOOT = 1.4;
  let serial = 0;

  const seconds = (root, name) => parseFloat(getComputedStyle(root).getPropertyValue(name)) * 1000;

  function cloneArt(library, index) {
    const copy = library[index].cloneNode(true);
    const tag = `-${++serial}`;
    const renamed = [...copy.querySelectorAll('[id]')].map((node) => {
      const old = node.id;
      node.id = old + tag;
      return old;
    });
    for (const node of copy.querySelectorAll('[fill], [stroke], [filter]')) {
      for (const name of ['fill', 'stroke', 'filter']) {
        const value = node.getAttribute(name);
        const match = value && value.match(/^url\(#(.+)\)$/);
        if (match && renamed.includes(match[1])) node.setAttribute(name, `url(#${match[1]}${tag})`);
      }
    }
    copy.removeAttribute('hidden');
    return copy;
  }

  function fitWordmark(mark) {
    const word = mark.querySelector('.hero__word');
    const box = word.getBBox();
    const top = 100 - CAP_HEIGHT - OVERSHOOT;
    mark.setAttribute('viewBox', `${box.x} ${top} ${box.width} ${CAP_HEIGHT + 2 * OVERSHOOT}`);
  }

  function setUp(root) {
    const library = [...root.querySelectorAll('.hero__library .hero__art')];
    const deck = root.querySelector('.hero__deck');
    const stamps = root.querySelector('.hero__stamps');
    const card = root.querySelector('.hero__card');
    const frame = root.querySelector('.hero__frame');
    const mark = root.querySelector('.hero__mark');
    const cursor = root.querySelector('.hero__cursor');
    const motion = { x: 0, y: 0, vx: 1, vy: 1 };
    const pointer = { x: 0, y: 0, shownX: 0, shownY: 0, inside: false };
    let current = FINAL_ART;
    let running = false;
    let visible = false;
    let frameId = 0;
    let last = 0;

    function showArt(index) {
      frame.replaceChildren(cloneArt(library, index));
      card.setAttribute('aria-label', `${library[index].dataset.name}. Show the next piece`);
    }

    function buildDeck() {
      const pop = seconds(root, '--stagger-pop');
      const drop = seconds(root, '--stagger-drop');
      const settle = START + DECK.length * pop + seconds(root, '--time-pop');
      DECK.forEach(({ art, size }, order) => {
        const block = document.createElement('div');
        block.className = 'hero__block';
        block.style.setProperty('--size', size);
        block.style.setProperty('--in', `${START + order * pop}ms`);
        block.style.setProperty('--out', `${settle + order * drop}ms`);
        block.append(cloneArt(library, art));
        deck.append(block);
      });
      root.style.setProperty('--final', `${START + DECK.length * pop}ms`);
      root.style.setProperty('--rise', `${START + DECK.length * pop}ms`);
      return settle + DECK.length * drop + seconds(root, '--time-drop');
    }

    function bounds() {
      return {
        x: Math.max(0, (root.clientWidth - card.offsetWidth) / 2),
        y: Math.max(0, (root.clientHeight - card.offsetHeight) / 2),
      };
    }

    function place() {
      card.style.transform = `translate(${motion.x}px, ${motion.y}px)`;
    }

    function restOverWordmark() {
      const limit = bounds();
      const markTop = mark.getBoundingClientRect().top - root.getBoundingClientRect().top;
      motion.x = limit.x * 0.5;
      motion.y = Math.min(limit.y, markTop + mark.clientHeight * 0.45 - root.clientHeight / 2 - card.offsetHeight / 2);
      place();
    }

    function drift(dt) {
      const speed = parseFloat(getComputedStyle(root).getPropertyValue('--drift')) || 96;
      const limit = bounds();
      motion.x += motion.vx * speed * dt;
      motion.y += motion.vy * speed * dt;
      if (motion.x > limit.x) { motion.x = limit.x; motion.vx = -1; }
      if (motion.x < -limit.x) { motion.x = -limit.x; motion.vx = 1; }
      if (motion.y > limit.y) { motion.y = limit.y; motion.vy = -1; }
      if (motion.y < -limit.y) { motion.y = -limit.y; motion.vy = 1; }
      place();
    }

    function follow(dt) {
      const pull = 1 - Math.exp(-dt * CURSOR_PULL);
      pointer.shownX += (pointer.x - pointer.shownX) * pull;
      pointer.shownY += (pointer.y - pointer.shownY) * pull;
      cursor.style.transform = `translate(${pointer.shownX}px, ${pointer.shownY}px)`;
    }

    function tick(now) {
      const dt = Math.min(0.05, (now - last) / 1000 || 0);
      last = now;
      if (running && !STILL.matches) drift(dt);
      if (pointer.inside) follow(dt);
      frameId = requestAnimationFrame(tick);
    }

    function play() {
      if (frameId || !visible) return;
      last = performance.now();
      frameId = requestAnimationFrame(tick);
    }

    function pause() {
      cancelAnimationFrame(frameId);
      frameId = 0;
    }

    function stamp() {
      const copy = document.createElement('div');
      copy.className = 'hero__stamp';
      copy.style.width = `${card.offsetWidth}px`;
      copy.style.transform = card.style.transform;
      copy.append(cloneArt(library, current));
      stamps.append(copy);
      const kept = stamps.querySelectorAll('.hero__stamp:not(.is-leaving)');
      if (kept.length > MOST_STAMPS) {
        kept[0].classList.add('is-leaving');
        kept[0].addEventListener('animationend', () => kept[0].remove(), { once: true });
      }
    }

    function fire() {
      if (!running && !STILL.matches) return;
      stamp();
      current = (current + 1) % library.length;
      showArt(current);
      frame.classList.remove('is-popping');
      void frame.offsetWidth;
      frame.classList.add('is-popping');
    }

    function trackPointer(event) {
      const box = root.getBoundingClientRect();
      pointer.x = event.clientX - box.left;
      pointer.y = event.clientY - box.top;
      if (!pointer.inside) {
        pointer.shownX = pointer.x;
        pointer.shownY = pointer.y;
      }
      pointer.inside = true;
      root.classList.add('is-pointing');
      root.classList.toggle('is-over-card', card.contains(event.target));
    }

    function leave() {
      pointer.inside = false;
      root.classList.remove('is-pointing', 'is-over-card');
    }

    showArt(current);
    root.addEventListener('pointermove', trackPointer);
    root.addEventListener('pointerleave', leave);
    card.addEventListener('click', fire);

    new IntersectionObserver(([entry]) => {
      visible = entry.isIntersecting;
      if (visible) play();
      else pause();
    }).observe(root);

    document.fonts.ready.then(() => {
      fitWordmark(mark);
      if (STILL.matches) {
        restOverWordmark();
        return;
      }
      const runAt = buildDeck();
      root.classList.add('is-started');
      setTimeout(() => {
        deck.replaceChildren();
        running = true;
      }, runAt);
    });
  }

  document.querySelectorAll('.hero').forEach(setUp);
})();
</script>

Similar components

Ruled hero

Ruled hero

Red clock field

Red clock field

Film reel

Film reel

Error screen

Error screen

Sticker headline hero

Sticker headline hero

Tunnel heading

Tunnel heading

Glass word with falling stickers

Glass word with falling stickers

Selection frame hero

Selection frame hero