kitbash Sign in Connect agent
Components

Spring headline

The signature: guides and box lines draw in, a label pair around a turning wireframe die, a black caps headline whose letters spring up one by one, one extruded word that wobbles out and pushes further where you point, a lead line and a key that lifts off its slab.

Part of the style

Pressed Key Grid

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --ink: #1d0c0c;
  --paper: #f7f7f7;
  --white: #fefefe;
  --pressed: #e9e8e7;
  --sand: #e9e9e8;
  --guide: #d6d5d2;
  --rule-dark: #413030;
  --muted: #86837c;
  --muted-dark: #b5b3ae;
  --glass: rgba(247, 247, 247, 0.64);
  --phosphor-deep: #1f0d0e;
  --ember: #4e8fb2;
  --ember-deep: #040e15;
  --plum: #d23349;
  --lilac: #fff2f2;
  --orchid: #b28575;
  --phosphor: #2b8ff3;
}
</style>

<section class="hero" aria-label="Tiltyard, arcade and game workshop">
  <div class="hero__guides" aria-hidden="true">
    <span class="hero__guide"></span><span class="hero__guide"></span><span class="hero__guide"></span><span class="hero__guide"></span><span class="hero__guide"></span>
  </div>

  <div class="hero__box">
    <span class="hero__rule hero__rule--left" aria-hidden="true"></span>
    <span class="hero__rule hero__rule--top" aria-hidden="true"></span>
    <span class="hero__rule hero__rule--right" aria-hidden="true"></span>
    <span class="hero__rule hero__rule--bottom" aria-hidden="true"></span>

    <p class="hero__label">
      <span class="hero__label-text">Never idle</span>
      <canvas class="hero__die" role="img" aria-label="A wireframe die turning slowly"></canvas>
      <span class="hero__label-text">Built to play</span>
    </p>
    <h1 class="hero__title" aria-label="We build machines that play back">
      <span class="hero__line">We build machines</span>
      <span class="hero__line">that <span class="hero__deep">play</span> back</span>
    </h1>
    <p class="hero__opening">We're an arcade and game workshop wiring cabinets, pinball tables and playable rooms for anyone who still likes a real button.</p>
  </div>

  <a class="hero__key" href="#">
    <span class="hero__key-panel">
      <svg class="hero__key-arrow" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12h17M14 6l6 6-6 6"></path></svg>
      <span class="hero__key-text">See the machines</span>
      <span class="hero__key-icon" aria-hidden="true">
        <svg viewBox="0 0 32 32"><path class="hero__key-stick" d="M16 21V9"></path><circle class="hero__key-knob" cx="16" cy="7.5" r="3.5"></circle><path d="M6.5 21.5h19v4.5h-19z"></path><path d="M21.5 18.5h2.5"></path></svg>
      </span>
    </span>
  </a>

  <div class="hero__tiles">
    <a class="hero__tile" href="#" aria-label="Grid view">
      <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 4h16v16H4z"></path><path d="M4 9.5h16M9.5 9.5V20"></path></svg>
    </a>
    <a class="hero__tile hero__tile--dark" href="#" aria-label="Tiltyard home">
      <svg viewBox="0 0 24 24" aria-hidden="true"><path class="hero__spark" d="M12 2.5c.6 5.3 4.2 8.9 9.5 9.5-5.3.6-8.9 4.2-9.5 9.5-.6-5.3-4.2-8.9-9.5-9.5 5.3-.6 8.9-4.2 9.5-9.5z"></path></svg>
    </a>
  </div>
</section>

<style>
  .hero {
    position: relative;
    padding: var(--space-l) var(--edge) calc(var(--cell) + var(--space-l));
    background: var(--paper);
    color: var(--ink);
    overflow: hidden;
  }

  .hero__guides {
    position: absolute;
    inset: 0 var(--edge);
    pointer-events: none;
  }
  .hero__guide {
    position: absolute;
    top: 0;
    bottom: 0;
    width: var(--hair);
    background: var(--guide);
    transform-origin: top;
    animation: hero-draw var(--t-draw) var(--ease-draw) both;
  }
  .hero__guide:nth-child(1) { left: 0; }
  .hero__guide:nth-child(2) { left: 25%; animation-delay: 0.1s; }
  .hero__guide:nth-child(3) { left: 50%; animation-delay: 0.2s; }
  .hero__guide:nth-child(4) { left: 75%; animation-delay: 0.3s; }
  .hero__guide:nth-child(5) { right: 0; animation-delay: 0.2s; }
  @keyframes hero-draw { from { transform: scaleY(0); } to { transform: scaleY(1); } }

  .hero__box {
    position: relative;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: var(--space-s);
    min-height: clamp(380px, 34.7vw, 500px);
    padding: var(--space-xl) var(--space-m);
    background: var(--paper);
    text-align: center;
  }
  .hero__rule {
    position: absolute;
    background: var(--ink);
    animation: 1.4s var(--ease-draw) both;
  }
  .hero__rule--left, .hero__rule--right { top: 0; bottom: 0; width: var(--hair); transform-origin: top; animation-name: hero-draw; }
  .hero__rule--top, .hero__rule--bottom { left: 0; right: 0; height: var(--hair); transform-origin: left; animation-name: hero-sweep; }
  .hero__rule--left { left: 0; }
  .hero__rule--top { top: 0; animation-delay: 0.05s; }
  .hero__rule--right { right: 0; animation-delay: 0.1s; }
  .hero__rule--bottom { bottom: 0; animation-delay: 0.15s; }
  @keyframes hero-sweep { from { transform: scaleX(0); } to { transform: scaleX(1); } }

  .hero__label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(6px, 0.6vw, 10px);
    width: min(100%, 30em);
    margin: 0;
    font: 600 var(--label)/1.7 var(--font-sans);
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  .hero__label-text { flex: 1 1 40%; }
  .hero__label-text:first-child { text-align: right; }
  .hero__label-text:last-child { text-align: left; }
  .hero__die {
    flex: none;
    width: 5em;
    height: 5em;
    color: var(--ink);
  }

  .hero__title {
    margin: 0;
    font: 900 var(--heading)/0.85 var(--font-sans);
    letter-spacing: -0.02em;
    text-transform: uppercase;
  }
  .hero__line { display: block; }
  .hero__word { display: inline-block; white-space: nowrap; }
  .hero__char { position: relative; display: inline-block; }
  .hero__glyph { display: inline-block; will-change: transform; }
  .hero.is-armed .hero__char--rise { contain: paint; }
  .hero.is-armed .hero__char--rise .hero__glyph { transform: translateY(100%); }

  .hero__char--deep { --depth: 0.08em; cursor: pointer; }
  .hero__char--deep > :not(.hero__glyph) {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    user-select: none;
  }
  .hero__faux {
    -webkit-text-stroke: max(3px, 0.05em) var(--ink);
    transform: translate(calc(var(--depth) * var(--i) / 8), calc(var(--depth) * var(--i) / -8));
  }
  .hero__face { transform: translate(var(--depth), calc(var(--depth) * -1)); }
  .hero__face > * { position: absolute; top: 0; left: 0; }
  .hero__face > .hero__light { color: var(--paper); }
  .hero.is-armed .hero__char--deep { opacity: 0; transition: opacity var(--t-quick) var(--ease-std); }
  .hero.is-armed .hero__char--deep.is-out { opacity: 1; }

  .hero__opening {
    max-width: 24em;
    margin: var(--space-s) 0 0;
    font: 520 var(--opening)/1.47 var(--font-sans);
    letter-spacing: 0.01em;
  }

  .hero.is-armed .hero__label,
  .hero.is-armed .hero__opening { opacity: 0; transition: opacity var(--t-panel) var(--ease-std); }
  .hero.is-armed.is-on .hero__label,
  .hero.is-armed.is-on .hero__opening { opacity: 1; }

  /* The key: a light panel over a black slab, lifting up and to the right when pointed at. */
  .hero__key {
    position: absolute;
    left: calc(var(--edge) + (100% - 2 * var(--edge)) * 0.25);
    top: calc(100% - var(--cell) - var(--space-l) - var(--hair));
    width: calc((100% - 2 * var(--edge)) * 0.25 + var(--hair));
    min-width: 18em;
    height: var(--cell);
    background: var(--ink);
    color: var(--ink);
    font: 700 var(--key)/1.5 var(--font-sans);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
  }
  .hero.is-armed .hero__key { opacity: 0; translate: 0 12px; transition: opacity var(--t-panel) var(--ease-expo), translate var(--t-slide) var(--ease-expo); }
  .hero.is-armed.is-keyed .hero__key { opacity: 1; translate: 0 0; }
  .hero__key-panel {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    padding-left: 2em;
    overflow: hidden;
    border: var(--hair) solid var(--ink);
    background: var(--paper);
    transform: translate(var(--lift-x, 0px), var(--lift-y, 0px));
    transition: transform var(--t-panel) var(--ease-expo), background-color var(--t-panel) var(--ease-expo);
  }
  .hero__key-arrow, .hero__key-text { transition: transform var(--t-slide) var(--ease-expo); }
  .hero__key-arrow {
    position: absolute;
    left: 2em;
    width: 1.5em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    transform: translateX(-4em);
    transition-delay: 0.1s;
  }
  .hero__key-text { flex: 1; white-space: nowrap; transition-delay: 0.05s; }
  .hero__key-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: var(--cell);
    height: 100%;
  }
  .hero__key-icon svg {
    width: 2em;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linejoin: round;
  }
  .hero__key-stick, .hero__key-knob {
    transform-origin: 16px 21px;
    transition: transform var(--t-panel) var(--ease-back);
  }
  @media (hover: hover) and (pointer: fine) {
    .hero__key:hover .hero__key-panel {
      --lift-x: calc(0.8em - var(--pointer-x, 0) * 0.5em);
      --lift-y: calc(-0.8em - var(--pointer-y, 0) * 0.5em);
    }
    .hero__key:hover .hero__key-arrow { transform: translateX(-0.2em); }
    .hero__key:hover .hero__key-text { transform: translateX(2em); }
    .hero__key:hover :is(.hero__key-stick, .hero__key-knob) { transform: rotate(-18deg); }
  }
  .hero__key:focus-visible .hero__key-panel { --lift-x: 0.8em; --lift-y: -0.8em; }
  .hero__key:focus-visible .hero__key-arrow { transform: translateX(-0.2em); }
  .hero__key:focus-visible .hero__key-text { transform: translateX(2em); }
  .hero__key:focus-visible .hero__key-panel { outline: 2px solid var(--ink); outline-offset: 3px; }
  .hero__key:active .hero__key-panel { --lift-x: 0px; --lift-y: 0px; background: var(--pressed); }

  .hero__tiles {
    position: absolute;
    right: var(--edge);
    top: calc(100% - var(--cell) - var(--space-l) - var(--hair));
    display: flex;
  }
  .hero__tile {
    display: grid;
    place-items: center;
    width: var(--cell);
    height: var(--cell);
    margin-left: calc(var(--hair) * -1);
    border: var(--hair) solid var(--ink);
    background: var(--paper);
    color: var(--ink);
    font-size: var(--unit);
    transition: background-color var(--t-quick) var(--ease-std);
  }
  .hero__tile--dark { background: var(--ink); color: var(--white); }
  .hero__tile svg {
    width: 1.1em;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.2;
  }
  .hero__tile path { transform-origin: center; transform-box: fill-box; transition: transform var(--t-panel) var(--ease-back); }
  .hero__tile--dark svg { animation: hero-spin var(--t-spin) linear infinite; }
  .hero__tile--dark .hero__spark { fill: currentColor; stroke: none; }
  .hero__tile:hover path, .hero__tile:focus-visible path { transform: scale(1.25); }
  .hero__tile:not(.hero__tile--dark):hover { background: var(--white); }
  .hero__tile:active path { transform: scale(0.9); }
  .hero__tile:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; position: relative; z-index: 1; }
  .hero.is-hidden .hero__tile--dark svg { animation-play-state: paused; }
  @keyframes hero-spin { from { transform: rotate(360deg); } to { transform: rotate(0deg); } }

  @media (max-width: 767px) {
    .hero__guide:nth-child(2), .hero__guide:nth-child(4) { display: none; }
    .hero { padding-bottom: calc(var(--cell) * 2 + var(--space-l)); }
    .hero__key { left: var(--edge); width: calc(100% - 2 * var(--edge)); min-width: 0; top: calc(100% - var(--cell) * 2 - var(--space-l) - var(--hair)); }
    .hero__tiles { top: auto; bottom: var(--space-l); }
  }
  @media (prefers-reduced-motion: reduce) {
    .hero__guide, .hero__rule { animation: none; }
    .hero__tile--dark svg { animation: none; }
  }
</style>

<script>
(() => {
  const still = matchMedia('(prefers-reduced-motion: reduce)');
  const DEPTH_REST = 0.08;
  const DEPTH_HOVER = 0.14;
  const DEPTH_NEAR = 0.105;

  const token = (root, name) => getComputedStyle(root).getPropertyValue(name).trim();
  const springOf = (root, name) => token(root, name).split(/\s+/).map(Number);

  function springLoop() {
    const springs = new Set();
    let frame = 0;
    let last = 0;
    const settle = (s) => Math.abs(s.x - s.target) < 1e-4 && Math.abs(s.v) < 1e-3;
    const tick = (now) => {
      const dt = Math.min(0.05, (now - last) / 1000);
      last = now;
      for (const s of springs) {
        if (now < s.startAt) continue;
        const steps = Math.ceil(dt * 240);
        const h = dt / steps;
        for (let i = 0; i < steps; i++) {
          s.v += (-s.k * (s.x - s.target) - s.c * s.v) * h;
          s.x += s.v * h;
        }
        if (settle(s)) { s.x = s.target; s.v = 0; springs.delete(s); }
        s.apply(s.x);
      }
      frame = springs.size ? requestAnimationFrame(tick) : 0;
    };
    return (s) => {
      springs.add(s);
      if (!frame) { last = performance.now(); frame = requestAnimationFrame(tick); }
    };
  }

  function charSpan(letter, deep) {
    const char = document.createElement('span');
    char.className = deep ? 'hero__char hero__char--deep' : 'hero__char hero__char--rise';
    const glyph = document.createElement('span');
    glyph.className = 'hero__glyph';
    glyph.textContent = letter;
    char.append(glyph);
    if (!deep) return char;
    for (let i = 0; i < 8; i++) {
      const faux = document.createElement('span');
      faux.className = 'hero__faux';
      faux.style.setProperty('--i', i);
      faux.textContent = letter;
      char.append(faux);
    }
    const face = document.createElement('span');
    face.className = 'hero__face';
    face.innerHTML = '<span class="hero__faux"></span><span class="hero__light"></span>';
    face.querySelectorAll('span').forEach((layer) => { layer.textContent = letter; });
    face.firstChild.style.setProperty('--i', 0);
    char.append(face);
    return char;
  }

  function wordSpan(text, deep) {
    const word = document.createElement('span');
    word.className = 'hero__word';
    const letters = [...text];
    letters.forEach((letter, n) => {
      const char = charSpan(letter, deep);
      char.style.zIndex = letters.length - n;
      word.append(char);
    });
    return word;
  }

  function split(title) {
    for (const line of title.querySelectorAll('.hero__line')) {
      const parts = [];
      for (const node of line.childNodes) {
        const deep = node.nodeType === 1 && node.classList.contains('hero__deep');
        node.textContent.split(/\s+/).filter(Boolean).forEach((text) => parts.push(wordSpan(text, deep)));
      }
      line.replaceChildren();
      parts.forEach((word, n) => { if (n) line.append(' '); line.append(word); });
      line.setAttribute('aria-hidden', 'true');
    }
  }

  function playIntro(root, add) {
    const charStep = parseFloat(token(root, '--stagger-char'));
    const wordStep = parseFloat(token(root, '--stagger-word'));
    const [riseK, riseC, riseV] = springOf(root, '--spring-rise');
    const [deepK, deepC, deepV] = springOf(root, '--spring-extrude');
    const start = performance.now() + 150;
    let index = 0;
    root.querySelectorAll('.hero__word').forEach((word, wordIndex) => {
      for (const char of word.children) {
        const at = start + index * charStep + wordIndex * wordStep;
        index++;
        if (char.classList.contains('hero__char--rise')) {
          const glyph = char.firstChild;
          add({ x: 0, v: riseV, target: 1, k: riseK, c: riseC, startAt: at,
            apply: (x) => { glyph.style.transform = `translateY(${(1 - x) * 100}%)`; } });
        } else {
          char.style.setProperty('--depth', '0em');
          const spring = { x: 0, v: deepV * DEPTH_REST, target: DEPTH_REST, k: deepK, c: deepC, startAt: at,
            apply: (x) => {
              if (!char.classList.contains('is-out')) char.classList.add('is-out');
              char.style.setProperty('--depth', `${x}em`);
            } };
          char.spring = spring;
          add(spring);
        }
      }
    });
    setTimeout(() => root.classList.add('is-on'), 100);
    setTimeout(() => root.classList.add('is-keyed'), start - performance.now() + 1000);
  }

  function pushOnHover(root, add) {
    const chars = [...root.querySelectorAll('.hero__char--deep')];
    const [deepK, deepC] = springOf(root, '--spring-extrude');
    const aim = (char, depth) => {
      if (still.matches) { char.style.setProperty('--depth', `${depth}em`); return; }
      const spring = char.spring || { x: DEPTH_REST, v: 0, k: deepK, c: deepC, startAt: 0,
        apply: (x) => char.style.setProperty('--depth', `${x}em`) };
      char.spring = spring;
      spring.k = deepK;
      spring.c = deepC;
      spring.startAt = 0;
      spring.target = depth;
      add(spring);
    };
    chars.forEach((char, n) => {
      char.addEventListener('pointerenter', () => {
        chars.forEach((other, m) => aim(other, m === n ? DEPTH_HOVER : Math.abs(m - n) === 1 ? DEPTH_NEAR : DEPTH_REST));
      });
    });
    const word = chars[0] && chars[0].parentElement;
    if (word) word.addEventListener('pointerleave', () => chars.forEach((char) => aim(char, DEPTH_REST)));
  }

  function drawDie(canvas) {
    const context = canvas.getContext('2d');
    const corners = [-1, 1].flatMap((x) => [-1, 1].flatMap((y) => [-1, 1].map((z) => [x, y, z])));
    const faces = [
      { n: [0, 0, 1], u: [1, 0, 0], v: [0, 1, 0], pips: [[0, 0]] },
      { n: [0, 0, -1], u: [-1, 0, 0], v: [0, 1, 0], pips: [[-0.5, -0.5], [0.5, -0.5], [-0.5, 0], [0.5, 0], [-0.5, 0.5], [0.5, 0.5]] },
      { n: [1, 0, 0], u: [0, 0, -1], v: [0, 1, 0], pips: [[-0.5, -0.5], [0.5, 0.5]] },
      { n: [-1, 0, 0], u: [0, 0, 1], v: [0, 1, 0], pips: [[-0.5, -0.5], [0.5, -0.5], [0, 0], [-0.5, 0.5], [0.5, 0.5]] },
      { n: [0, -1, 0], u: [1, 0, 0], v: [0, 0, 1], pips: [[-0.5, -0.5], [0, 0], [0.5, 0.5]] },
      { n: [0, 1, 0], u: [1, 0, 0], v: [0, 0, -1], pips: [[-0.5, -0.5], [0.5, -0.5], [-0.5, 0.5], [0.5, 0.5]] },
    ];
    const rotate = ([x, y, z], a, b) => {
      const x1 = x * Math.cos(a) + z * Math.sin(a);
      const z1 = -x * Math.sin(a) + z * Math.cos(a);
      return [x1, y * Math.cos(b) - z1 * Math.sin(b), y * Math.sin(b) + z1 * Math.cos(b)];
    };
    return (seconds) => {
      const size = canvas.clientWidth;
      const ink = getComputedStyle(canvas).color;
      const a = seconds * 0.52;
      const b = 0.5 + Math.sin(seconds * 0.31) * 0.25;
      const scale = size * 0.29;
      const project = (p) => {
        const [x, y, z] = rotate(p, a, b);
        const f = 4.2 / (4.2 + z);
        return [size / 2 + x * scale * f, size / 2 + y * scale * f];
      };
      context.clearRect(0, 0, size, size);
      context.strokeStyle = ink;
      context.fillStyle = ink;
      context.lineWidth = 1.25;
      context.lineJoin = 'round';
      for (const face of faces) {
        const facing = -rotate(face.n, a, b)[2];
        if (facing <= 0.02) continue;
        const at = (s, t) => project(face.n.map((n, i) => n + face.u[i] * s + face.v[i] * t));
        const outline = [[-1, -1], [1, -1], [1, 1], [-1, 1]].map(([s, t]) => at(s, t));
        context.beginPath();
        outline.forEach(([x, y], i) => (i ? context.lineTo(x, y) : context.moveTo(x, y)));
        context.closePath();
        context.stroke();
        for (const [s, t] of face.pips) {
          const [x, y] = at(s, t);
          context.beginPath();
          context.arc(x, y, Math.max(0.6, size * 0.022 * Math.sqrt(facing)), 0, Math.PI * 2);
          context.fill();
        }
      }
    };
  }

  function runDie(root, canvas) {
    const context = canvas.getContext('2d');
    const paint = drawDie(canvas);
    let frame = 0;
    const fit = () => {
      const density = Math.min(2, devicePixelRatio || 1);
      canvas.width = canvas.clientWidth * density;
      canvas.height = canvas.clientHeight * density;
      context.setTransform(density, 0, 0, density, 0, 0);
      paint(performance.now() / 1000);
    };
    const tick = (now) => { paint(now / 1000); frame = requestAnimationFrame(tick); };
    new ResizeObserver(fit).observe(canvas);
    new IntersectionObserver(([entry]) => {
      cancelAnimationFrame(frame);
      root.classList.toggle('is-hidden', !entry.isIntersecting);
      if (entry.isIntersecting && !still.matches) frame = requestAnimationFrame(tick);
    }).observe(canvas);
  }

  function tiltKey(key) {
    key.addEventListener('pointermove', (event) => {
      const box = key.getBoundingClientRect();
      key.style.setProperty('--pointer-x', ((event.clientX - box.left) / box.width - 0.5).toFixed(3));
      key.style.setProperty('--pointer-y', ((event.clientY - box.top) / box.height - 0.5).toFixed(3));
    });
  }

  for (const root of document.querySelectorAll('.hero')) {
    const add = springLoop();
    split(root.querySelector('.hero__title'));
    root.querySelectorAll('.hero__key').forEach(tiltKey);
    runDie(root, root.querySelector('.hero__die'));
    pushOnHover(root, add);
    if (still.matches) continue;
    root.classList.add('is-armed');
    const seen = new IntersectionObserver(([entry]) => {
      if (!entry.isIntersecting) return;
      seen.disconnect();
      playIntro(root, add);
    }, { threshold: 0.2 });
    seen.observe(root);
  }
})();
</script>

Similar components

Glass word with falling stickers

Glass word with falling stickers

Ruled hero

Ruled hero

Film reel

Film reel

Cut-out hero

Cut-out hero

Screensaver deck

Screensaver deck

Selection frame hero

Selection frame hero

Spread headline

Spread headline

Tunnel heading

Tunnel heading