kitbash Sign in Connect agent
Components

Glass word with falling stickers

The signature: a haze of drifting light, a giant script word rendered as pale glass that slides in from the right, and drawn die-cut stickers that fall, collide and settle on its letters. Grab and throw them. Credentials box, lede, scroll hint and a glass ring sit in the corners.

Part of the style

Glass Garden

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --stone: #91816b;
  --stone-light: #80715b;
  --stone-shade: #746550;
  --paper: #0e0600;
  --mist: #7f705a;
  --ink: #1c0d06;
  --ink-soft: #2e1d14;
  --charcoal: #25140b;
  --graphite: #25140b;
  --ash: #5c4f3b;
  --sage-mid: #776956;
  --sage-pale: #6f614c;
  --forest: #25140b;
  --line: rgba(28, 13, 6, 0.1);
  --grid-line: rgba(28, 13, 6, 0.045);
  --spot: rgba(133, 118, 96, 0.15);
  --shadow: rgba(28, 13, 6, 0.1);
  --glass: rgba(128, 113, 90, 0.55);
  --linen: #7d6e58;
  --sand: #746550;
  --pool: #6e604a;
  --stone-deep: #6e604b;
  --glass-light: #80715b;
  --glass-shadow: #544734;
  --sage: #8a745c;
  --lime: #d18823;
  --pearl-1: #b3844e;
  --sticker-leaf: #4a2d06;
  --mint-card: #997b5b;
  --pearl-4: #978068;
  --sand-deep: #90857a;
  --sticker-lemon: #a77c4a;
  --horn: #917c66;
  --pearl-2: #978068;
  --sticker-rose: #a4815b;
  --rose-light: #9b8164;
  --pearl-3: #978068;
  --sticker-terracotta: #978068;
  --sticker-azul: #7e6951;
}
</style>

<section class="hero" aria-label="Pátio Norte, landscape and garden architecture in Porto">
  <canvas class="hero__haze" aria-hidden="true"></canvas>
  <div class="hero__grid" aria-hidden="true"></div>

  <svg class="hero__glass" aria-hidden="true">
    <defs>
      <filter class="hero__filter" id="hero-glass" x="-15%" y="-30%" width="130%" height="160%" color-interpolation-filters="sRGB">
        <feGaussianBlur in="SourceAlpha" stdDeviation="7" result="bump" data-scale="0.026"/>
        <feSpecularLighting in="bump" surfaceScale="5" specularConstant="1.25" specularExponent="26" result="shine" style="lighting-color: var(--paper)">
          <feDistantLight azimuth="235" elevation="34"/>
        </feSpecularLighting>
        <feComposite in="shine" in2="SourceAlpha" operator="in" result="shineInside"/>
        <feDiffuseLighting in="bump" surfaceScale="4" diffuseConstant="1.05" result="light" style="lighting-color: var(--glass-light)">
          <feDistantLight azimuth="70" elevation="58"/>
        </feDiffuseLighting>
        <feComposite in="light" in2="SourceAlpha" operator="in" result="lit"/>
        <feColorMatrix in="lit" type="matrix" values="0.9 0 0 0 0.02  0 0.94 0 0 0.04  0 0 0.9 0 0.03  0 0 0 0.5 0" result="body"/>
        <feMorphology in="SourceAlpha" operator="erode" radius="2" result="thin" data-scale="0.008"/>
        <feComposite in="SourceAlpha" in2="thin" operator="out" result="rimShape"/>
        <feFlood flood-opacity="0.75" style="flood-color: var(--paper)"/>
        <feComposite in2="rimShape" operator="in" result="rim"/>
        <feGaussianBlur in="SourceAlpha" stdDeviation="12" result="soft" data-scale="0.045"/>
        <feOffset in="soft" dx="8" dy="18" result="dropped" data-scale-dx="0.03" data-scale-dy="0.065"/>
        <feFlood flood-opacity="0.26" style="flood-color: var(--glass-shadow)"/>
        <feComposite in2="dropped" operator="in" result="shadow"/>
        <feMerge>
          <feMergeNode in="shadow"/>
          <feMergeNode in="body"/>
          <feMergeNode in="rim"/>
          <feMergeNode in="shineInside"/>
        </feMerge>
      </filter>
    </defs>
    <g class="hero__word-slide">
      <text class="hero__word" filter="url(#hero-glass)">jardins</text>
    </g>
  </svg>

  <canvas class="hero__stickers" aria-hidden="true"></canvas>

  <div class="hero__signature">
    <div class="hero__credentials">
      <div class="hero__cell hero__cell--year">
        <svg class="hero__globe" viewBox="0 0 24 16" aria-hidden="true"><ellipse cx="12" cy="8" rx="11" ry="7"/><ellipse cx="12" cy="8" rx="4.6" ry="7"/><path d="M1 8h22M3 4.2h18M3 11.8h18"/></svg>
        <span>Est. 2016</span>
      </div>
      <div class="hero__cell">10+ years shaping<br>outdoor rooms.</div>
    </div>
    <p class="hero__lede">Landscape and garden architecture in Porto: courtyards, roof terraces and public squares that grow into themselves.</p>
  </div>

  <p class="hero__hint"><span class="hero__orb" aria-hidden="true"></span>Scroll to discover</p>

  <svg class="hero__ring" viewBox="0 0 98 69" aria-hidden="true">
    <defs>
      <filter id="hero-glass-small" x="-20%" y="-20%" width="140%" height="140%" color-interpolation-filters="sRGB">
        <feGaussianBlur in="SourceAlpha" stdDeviation="1.4" result="bump"/>
        <feSpecularLighting in="bump" surfaceScale="2.4" specularConstant="1.2" specularExponent="20" result="shine" style="lighting-color: var(--paper)"><feDistantLight azimuth="235" elevation="36"/></feSpecularLighting>
        <feComposite in="shine" in2="SourceAlpha" operator="in" result="shineInside"/>
        <feFlood flood-opacity="0.85" style="flood-color: var(--sage-pale)"/>
        <feComposite in2="SourceAlpha" operator="in" result="body"/>
        <feGaussianBlur in="SourceAlpha" stdDeviation="2" result="soft"/>
        <feOffset in="soft" dx="1" dy="3" result="dropped"/>
        <feFlood flood-opacity="0.22" style="flood-color: var(--glass-shadow)"/>
        <feComposite in2="dropped" operator="in" result="shadow"/>
        <feMerge><feMergeNode in="shadow"/><feMergeNode in="body"/><feMergeNode in="shineInside"/></feMerge>
      </filter>
    </defs>
    <g filter="url(#hero-glass-small)">
      <ellipse cx="49" cy="36" rx="42" ry="23" fill="none" stroke="#000" stroke-width="3.2" transform="rotate(-8 49 36)"/>
      <path d="M49 18c1.6 10 4.6 13 14.5 15-9.9 2-12.9 5-14.5 15-1.6-10-4.6-13-14.5-15 9.9-2 12.9-5 14.5-15z"/>
      <path d="M78 6c.8 5 2.3 6.5 7.2 7.4-4.9.9-6.4 2.4-7.2 7.4-.8-5-2.3-6.5-7.2-7.4 4.9-.9 6.4-2.4 7.2-7.4z"/>
      <path d="M19 47c.7 4.2 2 5.5 6 6.2-4 .7-5.3 2-6 6.2-.7-4.2-2-5.5-6-6.2 4-.7 5.3-2 6-6.2z"/>
    </g>
  </svg>
</section>

<style>
  .hero {
    position: relative;
    height: clamp(600px, 62.5vw, 900px);
    overflow: hidden;
    background: var(--stone);
    color: var(--ink);
    isolation: isolate;
  }
  .hero__haze,
  .hero__stickers,
  .hero__glass {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
  }
  .hero__haze { z-index: 0; filter: blur(14px); transform: scale(1.06); mask: linear-gradient(var(--ink) 82%, transparent); }
  .hero__grid {
    position: absolute;
    inset: 0 0 auto;
    z-index: 1;
    height: calc(var(--grid-step) * 2);
    background:
      linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / var(--grid-step) var(--grid-step),
      linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / var(--grid-step) var(--grid-step);
    mask: linear-gradient(var(--ink), transparent);
    pointer-events: none;
  }
  .hero__glass { z-index: 2; overflow: visible; pointer-events: none; }
  .hero__word {
    font-family: var(--font-script);
    fill: var(--ink);
    text-anchor: middle;
  }
  .hero__word-slide {
    opacity: 0;
    transform: translateX(46%);
    transition: transform 1.1s var(--ease-reveal), opacity 0.6s var(--ease);
  }
  .hero.is-ready .hero__word-slide { opacity: 1; transform: none; }
  .hero__stickers { z-index: 3; touch-action: pan-y; cursor: grab; }
  .hero__stickers.is-grabbing { cursor: grabbing; }

  .hero__signature {
    position: absolute;
    z-index: 4;
    left: var(--edge);
    bottom: 30px;
    width: min(280px, calc(100% - 2 * var(--edge)));
    pointer-events: none;
  }
  .hero__signature > * {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity var(--time-icon) var(--ease), transform var(--time-icon) var(--ease);
  }
  .hero__signature > .hero__lede { transition-delay: 0.13s; }
  .hero.is-ready .hero__signature > * { opacity: 1; transform: none; }
  .hero__credentials {
    display: grid;
    grid-template-columns: 96px 1fr;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.18);
    font: 500 10px/1.25 var(--font-body);
    text-transform: uppercase;
  }
  .hero__cell { padding: 10px 14px; }
  .hero__cell--year {
    display: grid;
    justify-items: center;
    gap: 6px;
    border-right: 1px solid rgba(0, 0, 0, 0.14);
    font-weight: 400;
  }
  .hero__globe { width: 26px; fill: none; stroke: var(--ink); stroke-width: 1; }
  .hero__lede {
    margin: 10px 0 0;
    font: 400 var(--text-s)/1.2 var(--font-body);
    letter-spacing: -0.012em;
  }

  .hero__hint {
    position: absolute;
    z-index: 4;
    left: 50%;
    bottom: 30px;
    display: grid;
    justify-items: center;
    gap: 12px;
    margin: 0;
    translate: -50% 0;
    color: var(--sage-mid);
    font: 400 var(--text-xs)/1 var(--font-body);
    letter-spacing: 0.1em;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--time-icon) var(--ease) 0.26s;
  }
  .hero.is-ready .hero__hint { opacity: 1; }
  .hero__orb {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--pearl-1), var(--pearl-2), var(--pearl-3), var(--pearl-4), var(--pearl-1));
    box-shadow: 0 0 0 1px rgba(82, 99, 84, 0.35);
    animation: hero-orb 5.533s var(--ease) infinite;
    animation-play-state: paused;
  }
  .hero.is-live .hero__orb { animation-play-state: running; }
  @keyframes hero-orb {
    0%, 12% { transform: translateY(-8px); opacity: 0; }
    30% { opacity: 1; }
    62% { transform: translateY(6px); opacity: 1; }
    80%, 100% { transform: translateY(10px); opacity: 0; }
  }

  .hero__ring {
    position: absolute;
    z-index: 4;
    right: calc(var(--edge) - 6px);
    bottom: 54px;
    width: 98px;
    height: 69px;
    opacity: 0;
    transition: opacity var(--time-icon) var(--ease) 0.26s;
  }
  .hero.is-ready .hero__ring { opacity: 1; }

  @media (max-width: 600px) {
    .hero { height: clamp(620px, 170vw, 760px); }
    .hero__hint { display: none; }
    .hero__ring { bottom: auto; top: 96px; right: 10px; transform: scale(0.8); }
    .hero__signature { bottom: 24px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .hero__word-slide { transform: none; }
    .hero__orb { animation: none; opacity: 1; }
  }
</style>

<script>
(() => {
  const still = matchMedia('(prefers-reduced-motion: reduce)');
  const GRAVITY = 2600;
  const STEP = 1 / 120;
  const MASK_CELL = 3;

  function readColour(root, name) {
    return getComputedStyle(root).getPropertyValue(name).trim();
  }

  function clear(hex) {
    const value = parseInt(hex.replace('#', ''), 16);
    return `rgba(${value >> 16}, ${(value >> 8) & 255}, ${value & 255}, 0)`;
  }

  /* ---------- the haze: soft diagonal light streaks, drawn small and blurred ---------- */
  function startHaze(root, canvas) {
    const context = canvas.getContext('2d');
    const light = readColour(root, '--stone-light');
    const shade = readColour(root, '--stone-shade');
    const base = readColour(root, '--stone');
    const streaks = Array.from({ length: 11 }, (_, index) => ({
      x: (index * 0.137 + 0.05) % 1.1,
      y: ((index * 0.383) % 1) * 1.1 - 0.05,
      length: 0.35 + ((index * 7) % 5) * 0.08,
      width: 0.05 + ((index * 3) % 4) * 0.018,
      bright: index % 3 !== 0,
      phase: index * 1.7,
    }));
    const SCALE = 0.16;

    function paint(seconds) {
      const width = canvas.width;
      const height = canvas.height;
      context.fillStyle = base;
      context.fillRect(0, 0, width, height);
      for (const streak of streaks) {
        const drift = Math.sin(seconds * 0.12 + streak.phase) * 0.03;
        const cx = (streak.x + drift) * width;
        const cy = (streak.y - drift * 0.6) * height;
        const rx = streak.length * Math.max(width, height) * 0.5;
        const ry = streak.width * Math.max(width, height) * 0.5;
        context.save();
        context.translate(cx, cy);
        context.rotate(-0.95);
        context.scale(1, ry / rx);
        const glow = context.createRadialGradient(0, 0, 0, 0, 0, rx);
        const tone = streak.bright ? light : shade;
        glow.addColorStop(0, tone);
        glow.addColorStop(1, clear(tone));
        context.globalAlpha = streak.bright ? 0.85 : 0.14;
        context.fillStyle = glow;
        context.beginPath();
        context.arc(0, 0, rx, 0, Math.PI * 2);
        context.fill();
        context.restore();
      }
      context.globalAlpha = 1;
    }

    let frame = 0;
    const fit = () => {
      canvas.width = Math.max(1, Math.round(canvas.clientWidth * SCALE));
      canvas.height = Math.max(1, Math.round(canvas.clientHeight * SCALE));
      paint(performance.now() / 1000);
    };
    const tick = (now) => {
      paint(now / 1000);
      frame = requestAnimationFrame(tick);
    };
    new ResizeObserver(fit).observe(canvas);
    return (running) => {
      cancelAnimationFrame(frame);
      if (running && !still.matches) frame = requestAnimationFrame(tick);
    };
  }

  /* ---------- stickers: drawn once into sprites, white die-cut edge, soft shadow ---------- */
  function makeArtist(root) {
    const colour = {
      leaf: readColour(root, '--sticker-leaf'),
      terracotta: readColour(root, '--sticker-terracotta'),
      lemon: readColour(root, '--sticker-lemon'),
      azul: readColour(root, '--sticker-azul'),
      rose: readColour(root, '--sticker-rose'),
      ink: readColour(root, '--ink'),
      paper: readColour(root, '--paper'),
      sage: readColour(root, '--sage'),
      roseLight: readColour(root, '--rose-light'),
      sand: readColour(root, '--sand'),
      horn: readColour(root, '--horn'),
    };
    let cut = false;
    let context = null;
    const fill = (paint) => {
      if (cut) { context.fill(); context.stroke(); return; }
      context.fillStyle = paint;
      context.fill();
    };
    const ellipse = (x, y, rx, ry, turn = 0) => { context.beginPath(); context.ellipse(x, y, rx, ry, turn, 0, Math.PI * 2); };
    const shape = (points) => {
      context.beginPath();
      context.moveTo(points[0], points[1]);
      for (let index = 2; index < points.length; index += 6) {
        context.bezierCurveTo(points[index], points[index + 1], points[index + 2], points[index + 3], points[index + 4], points[index + 5]);
      }
      context.closePath();
    };
    const line = (paint, width, draw) => {
      if (cut) return;
      context.save();
      context.strokeStyle = paint;
      context.lineWidth = width;
      context.lineCap = 'round';
      context.beginPath();
      draw();
      context.stroke();
      context.restore();
    };
    const detail = (paint, draw) => {
      if (cut) return;
      context.fillStyle = paint;
      context.beginPath();
      draw();
      context.fill();
    };
    const face = (x, y, size = 1) => {
      detail(colour.ink, () => { context.arc(x - 7 * size, y, 2.6 * size, 0, Math.PI * 2); context.arc(x + 7 * size, y, 2.6 * size, 0, Math.PI * 2); });
      line(colour.ink, 2.2 * size, () => { context.arc(x, y + 3 * size, 5 * size, 0.25 * Math.PI, 0.75 * Math.PI); });
    };

    const drawings = {
      lemon() {
        ellipse(50, 52, 34, 25, -0.35); fill(colour.lemon);
        ellipse(18, 64, 6, 5, -0.35); fill(colour.lemon);
        ellipse(83, 40, 6, 5, -0.35); fill(colour.lemon);
        shape([62, 26, 70, 8, 88, 6, 92, 12, 86, 24, 74, 30, 62, 26]); fill(colour.leaf);
        line('rgba(255,255,255,0.55)', 2, () => { context.moveTo(66, 24); context.quadraticCurveTo(78, 14, 89, 11); });
        detail('rgba(255,255,255,0.6)', () => context.ellipse(38, 42, 11, 5, -0.5, 0, Math.PI * 2));
        detail('rgba(160,110,10,0.22)', () => context.ellipse(58, 64, 22, 9, -0.35, 0, Math.PI * 2));
        face(52, 52, 0.9);
      },
      tile() {
        context.beginPath(); context.roundRect(14, 14, 72, 72, 8); fill(colour.paper);
        if (!cut) { context.save(); context.beginPath(); context.roundRect(14, 14, 72, 72, 8); context.clip(); }
        detail(colour.azul, () => {
          for (const [x, y] of [[14, 14], [86, 14], [14, 86], [86, 86]]) { context.moveTo(x, y); context.arc(x, y, 17, 0, Math.PI * 2); }
        });
        detail(colour.azul, () => {
          for (let petal = 0; petal < 4; petal += 1) {
            const turn = petal * Math.PI / 2;
            context.ellipse(50 + Math.cos(turn) * 13, 50 + Math.sin(turn) * 13, 11, 7, turn, 0, Math.PI * 2);
          }
        });
        if (!cut) context.restore();
        detail(colour.lemon, () => context.arc(50, 50, 6, 0, Math.PI * 2));
        line(colour.azul, 2.4, () => { context.roundRect(19, 19, 62, 62, 5); });
        detail('rgba(255,255,255,0.35)', () => context.ellipse(34, 28, 14, 4, -0.6, 0, Math.PI * 2));
      },
      pot() {
        shape([46, 50, 30, 46, 16, 30, 20, 20, 34, 18, 44, 34, 46, 50]); fill(colour.leaf);
        shape([54, 50, 56, 32, 70, 12, 82, 16, 88, 30, 70, 44, 54, 50]); fill(colour.leaf);
        line('rgba(255,255,255,0.5)', 2, () => { context.moveTo(44, 46); context.quadraticCurveTo(32, 34, 24, 24); context.moveTo(56, 46); context.quadraticCurveTo(68, 30, 80, 20); });
        context.beginPath(); context.moveTo(24, 58); context.lineTo(76, 58); context.lineTo(68, 92); context.lineTo(32, 92); context.closePath(); fill(colour.terracotta);
        context.beginPath(); context.roundRect(18, 48, 64, 14, 4); fill(colour.terracotta);
        detail('rgba(0,0,0,0.16)', () => context.rect(26, 62, 48, 4));
        detail('rgba(255,255,255,0.35)', () => context.roundRect(24, 51, 22, 4, 2));
        face(50, 75, 0.85);
      },
      leaf() {
        shape([50, 92, 14, 78, 8, 30, 34, 14, 44, 8, 56, 8, 66, 14, 92, 30, 86, 78, 50, 92]); fill(colour.leaf);
        if (!cut) {
          context.save();
          context.globalCompositeOperation = 'destination-out';
          context.lineCap = 'round';
          context.lineWidth = 5;
          context.beginPath();
          for (const [x, y, ex, ey] of [[22, 40, 38, 50], [18, 62, 38, 64], [78, 40, 62, 50], [82, 62, 62, 64]]) { context.moveTo(x, y); context.lineTo(ex, ey); }
          context.stroke();
          context.restore();
        }
        line('rgba(255,255,255,0.55)', 2.4, () => { context.moveTo(50, 90); context.quadraticCurveTo(52, 50, 50, 16); });
        line(colour.sage, 3, () => { context.moveTo(50, 92); context.lineTo(50, 98); });
      },
      sun() {
        context.beginPath();
        for (let ray = 0; ray < 12; ray += 1) {
          const turn = ray * Math.PI / 6;
          const inner = turn - 0.16;
          const outer = turn + 0.16;
          context.moveTo(50 + Math.cos(inner) * 30, 50 + Math.sin(inner) * 30);
          context.lineTo(50 + Math.cos(turn) * 46, 50 + Math.sin(turn) * 46);
          context.lineTo(50 + Math.cos(outer) * 30, 50 + Math.sin(outer) * 30);
        }
        fill(colour.terracotta);
        ellipse(50, 50, 31, 31); fill(colour.lemon);
        detail('rgba(255,255,255,0.5)', () => context.ellipse(40, 38, 9, 5, -0.6, 0, Math.PI * 2));
        detail(colour.rose, () => { context.arc(36, 57, 4.4, 0, Math.PI * 2); context.arc(64, 57, 4.4, 0, Math.PI * 2); });
        face(50, 50, 1.1);
      },
      can() {
        shape([70, 40, 82, 34, 90, 22, 94, 18, 98, 22, 92, 36, 76, 52, 70, 50]); fill(colour.azul);
        context.beginPath(); context.ellipse(95, 20, 5, 7, 0.6, 0, Math.PI * 2); fill(colour.azul);
        line(colour.azul, 7, () => { context.moveTo(28, 42); context.bezierCurveTo(18, 18, 52, 10, 56, 38); });
        context.beginPath(); context.roundRect(18, 36, 56, 50, 10); fill(colour.azul);
        detail('rgba(255,255,255,0.32)', () => context.roundRect(24, 42, 8, 36, 4));
        detail('rgba(0,0,0,0.16)', () => context.rect(18, 74, 56, 4));
        face(48, 58, 0.95);
      },
      daisy() {
        for (let petal = 0; petal < 9; petal += 1) {
          const turn = petal * Math.PI * 2 / 9;
          ellipse(50 + Math.cos(turn) * 24, 50 + Math.sin(turn) * 24, 15, 9, turn); fill(petal % 2 ? colour.rose : colour.roseLight);
        }
        ellipse(50, 50, 17, 17); fill(colour.lemon);
        detail('rgba(160,110,10,0.25)', () => { for (const [x, y] of [[44, 56], [55, 58], [58, 47]]) { context.moveTo(x, y); context.arc(x, y, 2, 0, Math.PI * 2); } });
        face(50, 48, 0.8);
      },
      snail() {
        shape([10, 84, 14, 72, 34, 70, 60, 72, 74, 64, 80, 52, 86, 50, 92, 52, 92, 62, 88, 70, 80, 84, 60, 88, 10, 84]); fill(colour.sand);
        ellipse(46, 54, 28, 28); fill(colour.terracotta);
        line('rgba(255,255,255,0.7)', 3.2, () => {
          for (let step = 0; step < 60; step += 1) {
            const turn = step * 0.2;
            const radius = 22 - step * 0.34;
            const x = 46 + Math.cos(turn) * radius;
            const y = 54 + Math.sin(turn) * radius;
            if (step === 0) context.moveTo(x, y); else context.lineTo(x, y);
          }
        });
        line(colour.horn, 2.4, () => { context.moveTo(84, 52); context.lineTo(82, 38); context.moveTo(90, 52); context.lineTo(94, 40); });
        detail(colour.ink, () => { context.arc(82, 37, 2.6, 0, Math.PI * 2); context.arc(94, 39, 2.6, 0, Math.PI * 2); });
      },
    };

    return function sprite(kind, radius) {
      const density = Math.min(2, devicePixelRatio || 1);
      const size = Math.ceil(radius * 2.6);
      const canvas = document.createElement('canvas');
      canvas.width = canvas.height = Math.ceil(size * density);
      context = canvas.getContext('2d');
      const unit = (radius * 2) / 100;
      context.setTransform(density * unit, 0, 0, density * unit, density * (size / 2 - radius), density * (size / 2 - radius));
      context.lineJoin = 'round';
      cut = true;
      context.save();
      context.shadowColor = 'rgba(40, 40, 30, 0.22)';
      context.shadowBlur = 6 * density;
      context.shadowOffsetY = 3 * density;
      context.fillStyle = colour.paper;
      context.strokeStyle = colour.paper;
      context.lineWidth = 11;
      drawings[kind]();
      context.restore();
      cut = false;
      drawings[kind]();
      return { canvas, size };
    };
  }

  /* ---------- physics: circles that fall, land on the glass word, and can be flicked ---------- */
  function startStickers(root, canvas, word) {
    const context = canvas.getContext('2d');
    const sprite = makeArtist(root);
    const kinds = ['lemon', 'tile', 'pot', 'leaf', 'sun', 'can', 'daisy', 'snail'];
    let width = 0;
    let height = 0;
    let bodies = [];
    let mask = null;
    let maskColumns = 0;
    let frame = 0;
    let last = 0;
    let pointer = null;
    let held = null;
    let born = 0;
    let wordShown = false;

    function solid(x, y) {
      if (!mask || !wordShown) return false;
      const column = Math.floor(x / MASK_CELL);
      const row = Math.floor(y / MASK_CELL);
      if (column < 0 || row < 0 || column >= maskColumns) return false;
      return mask[row * maskColumns + column] === 1;
    }

    function buildMask(layout) {
      const scratch = document.createElement('canvas');
      maskColumns = Math.ceil(width / MASK_CELL);
      const rows = Math.ceil(height / MASK_CELL);
      scratch.width = maskColumns;
      scratch.height = rows;
      const paint = scratch.getContext('2d');
      paint.scale(1 / MASK_CELL, 1 / MASK_CELL);
      paint.font = `${layout.size}px ${getComputedStyle(word).fontFamily}`;
      paint.textAlign = 'center';
      paint.fillText(word.textContent, layout.x, layout.y);
      const pixels = paint.getImageData(0, 0, maskColumns, rows).data;
      mask = new Uint8Array(maskColumns * rows);
      for (let index = 0; index < mask.length; index += 1) mask[index] = pixels[index * 4 + 3] > 110 ? 1 : 0;
    }

    function spawn(count) {
      const radius = Math.max(20, Math.min(30, width * 0.02));
      const sprites = Object.fromEntries(kinds.map((kind) => [kind, sprite(kind, radius)]));
      bodies = Array.from({ length: count }, (_, index) => {
        const kind = kinds[index % kinds.length];
        return {
          kind,
          art: sprites[kind],
          r: radius,
          x: width * (0.12 + ((index * 0.6180339) % 1) * 0.76),
          y: -radius - (index % 5) * radius * 2.2 - Math.floor(index / 5) * radius * 1.4,
          vx: (((index * 37) % 11) - 5) * 18,
          vy: 260,
          a: index * 0.7,
          va: (((index * 13) % 7) - 3) * 0.8,
        };
      });
    }

    function dropAgain(body) {
      body.x = body.r + Math.random() * (width - body.r * 2);
      body.y = -body.r * (1.5 + Math.random() * 4);
      body.vx = (Math.random() - 0.5) * 120;
      body.vy = 120;
    }

    function settleOnWord(body) {
      let pushX = 0;
      let pushY = 0;
      const probe = () => {
        pushX = 0;
        pushY = 0;
        let hits = 0;
        for (let spoke = 0; spoke < 16; spoke += 1) {
          const turn = spoke * Math.PI / 8;
          const px = body.x + Math.cos(turn) * body.r * 0.9;
          const py = body.y + Math.sin(turn) * body.r * 0.9;
          if (solid(px, py)) { pushX -= Math.cos(turn); pushY -= Math.sin(turn); hits += 1; }
        }
        return hits;
      };
      if (!probe()) return;
      const length = Math.hypot(pushX, pushY) || 1;
      const nx = pushX / length;
      const ny = pushY / length;
      for (let tries = 0; tries < 14 && probe(); tries += 1) { body.x += nx * 1.5; body.y += ny * 1.5; }
      const along = body.vx * nx + body.vy * ny;
      if (along < 0) {
        body.vx -= 1.35 * along * nx;
        body.vy -= 1.35 * along * ny;
      }
      body.vx *= 0.97;
      body.va += (body.vx * -ny + body.vy * nx) / body.r * 0.02;
    }

    function step(dt) {
      for (const body of bodies) {
        if (body === held) continue;
        body.vy += GRAVITY * dt;
        body.vx *= 0.9995;
        body.x += body.vx * dt;
        body.y += body.vy * dt;
        body.a += body.va * dt;
        body.va *= 0.995;
        if (body.x < body.r) { body.x = body.r; body.vx = Math.abs(body.vx) * 0.4; }
        if (body.x > width - body.r) { body.x = width - body.r; body.vx = -Math.abs(body.vx) * 0.4; }
        if (body.y > height + body.r * 2) dropAgain(body);
        settleOnWord(body);
      }
      for (let first = 0; first < bodies.length; first += 1) {
        for (let second = first + 1; second < bodies.length; second += 1) {
          const a = bodies[first];
          const b = bodies[second];
          const dx = b.x - a.x;
          const dy = b.y - a.y;
          const reach = a.r + b.r;
          const distance = Math.hypot(dx, dy);
          if (distance === 0 || distance >= reach) continue;
          const nx = dx / distance;
          const ny = dy / distance;
          const overlap = (reach - distance) / 2;
          if (a !== held) { a.x -= nx * overlap; a.y -= ny * overlap; }
          if (b !== held) { b.x += nx * overlap; b.y += ny * overlap; }
          const closing = (b.vx - a.vx) * nx + (b.vy - a.vy) * ny;
          if (closing < 0) {
            const impulse = -1.3 * closing / 2;
            a.vx -= impulse * nx; a.vy -= impulse * ny;
            b.vx += impulse * nx; b.vy += impulse * ny;
            a.va -= impulse * 0.004; b.va += impulse * 0.004;
          }
        }
      }
    }

    function draw() {
      context.clearRect(0, 0, width, height);
      for (const body of bodies) {
        context.save();
        context.translate(body.x, body.y);
        context.rotate(body.a);
        if (body === held) context.scale(1.08, 1.08);
        context.drawImage(body.art.canvas, -body.art.size / 2, -body.art.size / 2, body.art.size, body.art.size);
        context.restore();
      }
    }

    function tick(now) {
      const elapsed = Math.min(0.05, (now - last) / 1000);
      last = now;
      if (now - born > 520) {
        for (let time = 0; time < elapsed; time += STEP) step(STEP);
      }
      draw();
      frame = requestAnimationFrame(tick);
    }

    function fit(layout) {
      const density = Math.min(2, devicePixelRatio || 1);
      width = canvas.clientWidth;
      height = canvas.clientHeight;
      canvas.width = Math.round(width * density);
      canvas.height = Math.round(height * density);
      context.setTransform(density, 0, 0, density, 0, 0);
      buildMask(layout);
      spawn(width < 600 ? 10 : 15);
      if (still.matches) {
        wordShown = true;
        for (let time = 0; time < 6; time += STEP) step(STEP);
      }
      draw();
    }

    function bodyAt(x, y) {
      return bodies.find((body) => Math.hypot(body.x - x, body.y - y) < body.r);
    }
    function local(event) {
      const box = canvas.getBoundingClientRect();
      return { x: event.clientX - box.left, y: event.clientY - box.top, t: performance.now() };
    }
    canvas.addEventListener('pointerdown', (event) => {
      const point = local(event);
      held = bodyAt(point.x, point.y) || null;
      if (!held) return;
      canvas.setPointerCapture(event.pointerId);
      canvas.classList.add('is-grabbing');
      pointer = point;
      held.vx = 0; held.vy = 0;
    });
    canvas.addEventListener('pointermove', (event) => {
      const point = local(event);
      if (held) {
        const seconds = Math.max(0.008, (point.t - pointer.t) / 1000);
        held.vx = (point.x - pointer.x) / seconds;
        held.vy = (point.y - pointer.y) / seconds;
        held.x = point.x; held.y = point.y;
        pointer = point;
        draw();
        return;
      }
      canvas.style.cursor = bodyAt(point.x, point.y) ? '' : 'default';
    });
    const release = () => {
      if (!held) return;
      held.vx = Math.max(-2400, Math.min(2400, held.vx));
      held.vy = Math.max(-2400, Math.min(2400, held.vy));
      held.va = held.vx / held.r * 0.4;
      held = null;
      canvas.classList.remove('is-grabbing');
    };
    canvas.addEventListener('pointerup', release);
    canvas.addEventListener('pointercancel', release);

    return {
      fit,
      showWord() { wordShown = true; },
      run(running) {
        cancelAnimationFrame(frame);
        if (!running || still.matches) return;
        last = performance.now();
        frame = requestAnimationFrame(tick);
      },
      restart() { born = performance.now(); },
    };
  }

  function layoutWord(root, svg, word) {
    const width = root.clientWidth;
    const height = root.clientHeight;
    const size = Math.min(width * (width < 600 ? 0.28 : 0.24), height * 0.46);
    const layout = { x: width / 2, y: height * (width < 600 ? 0.5 : 0.56), size };
    svg.setAttribute('viewBox', `0 0 ${width} ${height}`);
    word.setAttribute('x', layout.x);
    word.setAttribute('y', layout.y);
    word.setAttribute('font-size', size);
    for (const node of svg.querySelectorAll('.hero__filter [data-scale]')) {
      const value = Math.max(0.6, size * Number(node.dataset.scale));
      node.setAttribute(node.tagName === 'feMorphology' ? 'radius' : 'stdDeviation', value.toFixed(2));
    }
    for (const node of svg.querySelectorAll('.hero__filter [data-scale-dx]')) {
      node.setAttribute('dx', (size * Number(node.dataset.scaleDx)).toFixed(2));
      node.setAttribute('dy', (size * Number(node.dataset.scaleDy)).toFixed(2));
    }
    return layout;
  }

  function setUp(root, order) {
    const svg = root.querySelector('.hero__glass');
    const word = root.querySelector('.hero__word');
    const filterId = `hero-glass-${order}`;
    root.querySelector('.hero__filter').id = filterId;
    word.setAttribute('filter', `url(#${filterId})`);
    const smallId = `hero-glass-small-${order}`;
    root.querySelector('#hero-glass-small').id = smallId;
    root.querySelector('.hero__ring > g').setAttribute('filter', `url(#${smallId})`);

    const haze = startHaze(root, root.querySelector('.hero__haze'));
    const stickers = startStickers(root, root.querySelector('.hero__stickers'), word);
    let visible = false;

    let fitted = '';
    const refit = () => {
      const size = `${root.clientWidth}x${root.clientHeight}`;
      if (size === fitted) return;
      fitted = size;
      stickers.fit(layoutWord(root, svg, word));
    };

    document.fonts.load(`100px ${getComputedStyle(word).fontFamily}`).finally(() => {
      refit();
      stickers.restart();
      requestAnimationFrame(() => root.classList.add('is-ready'));
      setTimeout(() => stickers.showWord(), 420);
      new ResizeObserver(() => refit()).observe(root);
      stickers.run(visible);
    });

    new IntersectionObserver(([entry]) => {
      visible = entry.isIntersecting;
      root.classList.toggle('is-live', visible);
      haze(visible);
      stickers.run(visible);
    }).observe(root);
  }

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

Similar components

Spring headline

Spring headline

Cut-out hero

Cut-out hero

Film reel

Film reel

Tunnel heading

Tunnel heading

Screensaver deck

Screensaver deck

Selection frame hero

Selection frame hero

Sticker headline hero

Sticker headline hero

Spread headline

Spread headline