kitbash Sign in Connect agent
Components

Selection frame hero

The signature: a construction grid with plus marks that light up around the pointer and a yellow cursor square, a title, a selection frame with corner handles whose bicycle drawing crossfades every 3s, a prompt wheel under it and a joined email and join form.

Part of the style

Selection Frame Lab

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --paper: #f1f0f0;
  --ink: #091509;
  --muted: #867d7d;
  --hairline: #867d7d;
  --surface-active: #e6e4e4;
  --surface-inset: #eae8e8;
  --night: #3a453a;
  --night-line: #4f584f;
  --disabled: #d6d2d2;
  --grid-line: rgba(158, 149, 149, 0.16);
  --dot: rgba(158, 149, 149, 0.45);
  --accent: #888819;
  --accent-hover: #919119;
  --alert: #4b7b7f;
}
</style>

<section class="hero" aria-label="Truss: drawings from a sentence">
  <div class="hero__field" aria-hidden="true">
    <div class="hero__grid"></div>
    <div class="hero__marks"></div>
    <span class="hero__cursor"></span>
  </div>

  <h1 class="hero__title">Draw any frame.</h1>
  <p class="hero__lead">Truss turns a sentence into a measured bicycle drawing. Say what you ride and get a clean, editable SVG in seconds.</p>

  <div class="hero__frame">
    <span class="hero__handle hero__handle--nw"></span><span class="hero__handle hero__handle--ne"></span><span class="hero__handle hero__handle--sw"></span><span class="hero__handle hero__handle--se"></span>
    <div class="hero__board">

      <svg class="hero__drawing" viewBox="0 0 370 370" role="img" aria-label="Side view of a touring frame with stack, reach and angles">
        <text class="hero__h" x="24" y="40">Touring Frame</text>
        <text class="hero__t hero__t--mute" x="24" y="52">56 cm, 4130 steel, 700c</text>
        <text class="hero__t hero__t--mute" x="346" y="40" text-anchor="end">Sheet 01 / 05</text>
        <g class="hero__hair">
          <path d="M30 314H346"></path>
          <circle cx="100" cy="252" r="56"></circle><circle cx="292" cy="252" r="56"></circle>
          <path class="hero__dash" d="M254 146L306.97 314M168 264V106M254 146V106M168 264H334M254 146H334M100 252V338M292 252V338"></path>
          <path d="M168 264H140"></path>
        </g>
        <g class="hero__ink">
          <circle cx="100" cy="252" r="62"></circle><circle cx="292" cy="252" r="62"></circle>
          <circle cx="168" cy="264" r="15"></circle>
          <path d="M146 264A22 22 0 0 1 161.58 242.96M288.97 314A18 18 0 0 1 301.56 296.83"></path>
          <path d="M168 112H254M168 109v6M254 109v6M100 332H292M100 329v6M292 329v6"></path>
        </g>
        <g class="hero__tube">
          <path d="M168 264L132 146M134 152L254 150M168 264L261 168M168 264L100 252M134 157L100 252M263 174.5Q280 224 292 252"></path>
          <path class="hero__tube--thick" d="M254 146L263 174.5"></path>
          <path d="M131 146L129 136M116 134H146M254 146L266 140h10q8 0 8 8v10q0 6-6 6M168 264L180 292"></path>
        </g>
        <path class="hero__acc" d="M330 146V264M326 146h8M326 264h8"></path>
        <g class="hero__nodes">
          <circle cx="168" cy="264" r="2"></circle><circle cx="100" cy="252" r="2"></circle><circle cx="292" cy="252" r="2"></circle><circle cx="132" cy="146" r="2"></circle><circle cx="254" cy="146" r="2"></circle><rect x="175" y="290" width="10" height="4"></rect>
        </g>
        <g class="hero__t">
          <text x="153" y="240" text-anchor="end">73.0°</text>
          <text x="284" y="309" text-anchor="end">72.5°</text>
          <text x="211" y="104" text-anchor="middle">Reach 421</text>
          <text x="196" y="346" text-anchor="middle">Wheelbase 941</text>
          <text x="325" y="161" text-anchor="end">Stack 578</text>
        </g>
      </svg>

      <svg class="hero__drawing" viewBox="0 0 370 370" role="img" aria-label="Gear inches for every cog of a two by eleven drivetrain">
        <text class="hero__h" x="24" y="40">Gear Inches</text>
        <text class="hero__t hero__t--mute" x="24" y="52">2×11, 50/34 rings, 11–32 cassette</text>
        <g class="hero__t" text-anchor="end">
          <rect class="hero__fill" x="300" y="34" width="5" height="5"></rect><text x="346" y="39">50T ring</text>
          <rect class="hero__ink" x="300.5" y="44.5" width="4" height="4"></rect><text x="346" y="49">34T ring</text>
        </g>
        <g class="hero__hair">
          <path d="M52 260H334M52 220H334M52 180H334M52 140H334M52 100H334"></path>
        </g>
        <path class="hero__ink" d="M52 84V300H334"></path>
        <g class="hero__t hero__t--mute" text-anchor="end">
          <text x="46" y="262">40</text><text x="46" y="222">60</text><text x="46" y="182">80</text><text x="46" y="142">100</text><text x="46" y="102">120</text>
          <text x="46" y="80">in</text>
        </g>
        <g class="hero__t" text-anchor="middle">
          <text x="64" y="314">11</text><text x="89" y="314">12</text><text x="114" y="314">13</text><text x="139" y="314">14</text><text x="164" y="314">15</text><text x="189" y="314">17</text><text x="214" y="314">19</text><text x="239" y="314">21</text><text x="264" y="314">24</text><text x="289" y="314">28</text><text x="314" y="314">32</text>
          <text class="hero__t--mute" x="193" y="326">Cog teeth</text>
        </g>
        <path class="hero__ink" d="M64 94.6V173M89 115V187M114 132.4V198.8M139 147.2V208.8M164 160V217.6M189 181.2V232M214 197.8V243.4M239 211.4V252.6M264 227.4V263.4M289 243.6V274.4M314 255.6V282.6"></path>
        <g class="hero__fill">
          <rect x="61.5" y="92.1" width="5" height="5"></rect><rect x="86.5" y="112.5" width="5" height="5"></rect><rect x="111.5" y="129.9" width="5" height="5"></rect><rect x="136.5" y="144.7" width="5" height="5"></rect><rect x="161.5" y="157.5" width="5" height="5"></rect><rect x="186.5" y="178.7" width="5" height="5"></rect><rect x="211.5" y="195.3" width="5" height="5"></rect><rect x="236.5" y="208.9" width="5" height="5"></rect><rect x="261.5" y="224.9" width="5" height="5"></rect><rect x="286.5" y="241.1" width="5" height="5"></rect><rect x="311.5" y="253.1" width="5" height="5"></rect>
        </g>
        <g class="hero__ink hero__paper">
          <rect x="62" y="171" width="4" height="4"></rect><rect x="87" y="185" width="4" height="4"></rect><rect x="112" y="196.8" width="4" height="4"></rect><rect x="137" y="206.8" width="4" height="4"></rect><rect x="162" y="215.6" width="4" height="4"></rect><rect x="187" y="230" width="4" height="4"></rect><rect x="212" y="241.4" width="4" height="4"></rect><rect x="237" y="250.6" width="4" height="4"></rect><rect x="262" y="261.4" width="4" height="4"></rect><rect x="312" y="280.6" width="4" height="4"></rect>
        </g>
        <path class="hero__acc" d="M289 274.4L250 290H222"></path>
        <rect class="hero__acc-fill" x="285.5" y="270.9" width="7" height="7"></rect>
        <text class="hero__t" x="220" y="292" text-anchor="end">34×28, 32.8 in</text>
      </svg>

      <svg class="hero__drawing" viewBox="0 0 370 370" role="img" aria-label="A wheel laced three-cross with 32 spokes">
        <text class="hero__h" x="24" y="40">Three-Cross</text>
        <text class="hero__t hero__t--mute" x="24" y="52">32 spokes, 16 per flange</text>
        <text class="hero__t hero__t--mute" x="346" y="40" text-anchor="end">Drive side</text>
        <g class="hero__hair">
          <circle cx="185" cy="206" r="120"></circle>
          <path d="M194.2 183.8L305.0 206.0M198.3 186.0L118.3 106.2M202.0 189.0L295.9 251.9M205.0 192.7L161.6 88.3M207.2 196.8L269.9 290.9M208.5 201.3L208.4 88.3M209.0 206.0L230.9 316.9M208.5 210.7L251.7 106.2M207.2 215.2L185.0 326.0M205.0 219.3L284.8 139.3M202.0 223.0L139.1 316.9M198.3 226.0L302.7 182.6M194.2 228.2L100.1 290.9M189.7 229.5L302.7 229.4M185.0 230.0L74.1 251.9M180.3 229.5L284.8 272.7M175.8 228.2L65.0 206.0M171.7 226.0L251.7 305.8M168.0 223.0L74.1 160.1M165.0 219.3L208.4 323.7M162.8 215.2L100.1 121.1M161.5 210.7L161.6 323.7M161.0 206.0L139.1 95.1M161.5 201.3L118.3 305.8M162.8 196.8L185.0 86.0M165.0 192.7L85.2 272.7M168.0 189.0L230.9 95.1M171.7 186.0L67.3 229.4M175.8 183.8L269.9 121.1M180.3 182.5L67.3 182.6"></path>
          <path class="hero__dash" d="M65 206V352M305 206V352"></path>
        </g>
        <g class="hero__ink">
          <circle cx="185" cy="206" r="128"></circle>
          <circle cx="185" cy="206" r="24"></circle>
          <path d="M65 346H305M65 343v6M305 343v6"></path>
        </g>
        <path class="hero__tube" d="M189.7 182.5L85.2 139.3"></path>
        <path class="hero__acc hero__acc--spoke" d="M185 182L295.9 160.1"></path>
        <circle class="hero__fill" cx="185" cy="206" r="8"></circle>
        <circle class="hero__acc-fill" cx="295.9" cy="160.1" r="2.5"></circle>
        <circle class="hero__fill" cx="85.2" cy="139.3" r="2.5"></circle>
        <g class="hero__t">
          <text x="300" y="154">Leading</text>
          <text x="80" y="133" text-anchor="end">Trailing</text>
          <text x="185" y="342" text-anchor="middle">ERD 602</text>
          <text class="hero__t--mute" x="185" y="196" text-anchor="middle">Hub</text>
        </g>
      </svg>

      <svg class="hero__drawing" viewBox="0 0 370 370" role="img" aria-label="Tyre pressure against rider weight for three tyre widths">
        <text class="hero__h" x="24" y="40">Pressure by Weight</text>
        <text class="hero__t hero__t--mute" x="24" y="52">Tubeless, road and gravel</text>
        <g class="hero__hair">
          <path d="M56 270H336M56 230H336M56 190H336M56 150H336M56 110H336"></path>
          <path d="M102.7 290V86M149.3 290V86M196 290V86M242.7 290V86M289.3 290V86"></path>
        </g>
        <path class="hero__ink" d="M56 86V290H336"></path>
        <g class="hero__t hero__t--mute" text-anchor="end">
          <text x="50" y="272">2</text><text x="50" y="232">3</text><text x="50" y="192">4</text><text x="50" y="152">5</text><text x="50" y="112">6</text><text x="50" y="82">bar</text>
        </g>
        <g class="hero__t" text-anchor="middle">
          <text x="56" y="304">50</text><text x="102.7" y="304">60</text><text x="149.3" y="304">70</text><text x="196" y="304">80</text><text x="242.7" y="304">90</text><text x="289.3" y="304">100</text><text x="336" y="304">110</text>
          <text class="hero__t--mute" x="196" y="316">Rider and bike, kg</text>
        </g>
        <path class="hero__tube" d="M56 166Q196 138 336 102"></path>
        <path class="hero__line-mid" d="M56 194Q196 170 336 138"></path>
        <path class="hero__acc hero__acc--curve" d="M56 246Q196 224 336 194"></path>
        <path class="hero__dash hero__hair" d="M172.7 226.3V290M172.7 226.3H56"></path>
        <circle class="hero__fill" cx="172.7" cy="226.3" r="3"></circle>
        <g class="hero__t">
          <text x="340" y="104">28</text><text x="340" y="140">32</text><text x="340" y="196">40 mm</text>
          <text x="178" y="220">75 kg, 3.1 bar</text>
        </g>
      </svg>

      <svg class="hero__drawing" viewBox="0 0 370 370" role="img" aria-label="Build sheet for a randonneur with four numbered callouts">
        <text class="hero__h hero__h--big" x="22" y="48">Randonneur</text>
        <text class="hero__t hero__t--mute" x="24" y="62">Build sheet, 600 km brevet</text>
        <g class="hero__sheet" transform="translate(150 118) scale(0.58)">
          <g class="hero__ink"><circle cx="100" cy="252" r="62"></circle><circle cx="292" cy="252" r="62"></circle></g>
          <g class="hero__hair"><circle cx="100" cy="252" r="56"></circle><circle cx="292" cy="252" r="56"></circle><path d="M40 210Q100 172 158 214M232 210Q292 172 352 214"></path></g>
          <g class="hero__tube"><path d="M168 264L132 146M134 152L254 150M168 264L261 168M168 264L100 252M134 157L100 252M263 174.5Q280 224 292 252M254 146L263 174.5M131 146L129 136M116 134H146M254 146L266 140h10q8 0 8 8v10q0 6-6 6M168 264L180 292"></path></g>
          <path class="hero__acc hero__acc--thick" d="M248 132h44v-14h-44z"></path>
          <circle class="hero__fill" cx="292" cy="252" r="7"></circle>
        </g>
        <g class="hero__hair">
          <path d="M24 88H346M24 336H346"></path>
          <path d="M70 110H300M70 168H274M70 222H226M70 276H253"></path>
        </g>
        <g class="hero__nodes"><circle cx="300" cy="110" r="1.5"></circle><circle cx="274" cy="168" r="1.5"></circle><circle cx="226" cy="222" r="1.5"></circle><circle cx="253" cy="276" r="1.5"></circle></g>
        <g class="hero__num"><text x="24" y="114">01</text><text x="24" y="172">02</text><text x="24" y="226">03</text><text x="24" y="280">04</text></g>
        <g class="hero__t">
          <text x="24" y="124">Bag support</text><text x="24" y="182">Dynamo hub</text><text x="24" y="236">Fenders</text><text x="24" y="290">Low gear</text>
        </g>
        <g class="hero__micro">
          <text x="24" y="131">Front rack, 6 kg load</text><text x="24" y="189">6 V, 3 W, always on</text><text x="24" y="243">45 mm, full length</text><text x="24" y="297">30×36, 22 in</text>
        </g>
        <text class="hero__t hero__t--mute" x="346" y="350" text-anchor="end">Truss, drawn in 2.1 s</text>
      </svg>

    </div>
  </div>

  <div class="hero__prompts">
    <p class="hero__prompt">Draw a 56 cm steel touring frame with stack, reach and both angles marked.</p>
    <p class="hero__prompt">Chart gear inches for a 50/34 crankset and an 11–32 cassette, highlight the climbing gear.</p>
    <p class="hero__prompt">Explain three-cross lacing on a 32-spoke wheel, with one leading and one trailing spoke.</p>
    <p class="hero__prompt">Plot tyre pressure against rider weight for 28, 32 and 40 mm tubeless tyres.</p>
    <p class="hero__prompt">Lay out a build sheet for a randonneur bike with four numbered callouts.</p>
  </div>

  <form class="hero__form" novalidate>
    <label class="hero__label" for="hero-email">Email</label>
    <input class="hero__input" id="hero-email" type="email" name="email" placeholder="name@workshop.com" autocomplete="email" required>
    <button class="hero__join" type="submit">Join waitlist</button>
    <p class="hero__note" aria-live="polite"></p>
  </form>

  <p class="hero__scroll" aria-hidden="true">Scroll down<svg viewBox="0 0 10 6"><path d="M1 1l4 4 4-4"></path></svg></p>
</section>

<style>
  .hero {
    --board: clamp(240px, 26vw, 370px);
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    padding: clamp(88px, 8.4vw, 120px) var(--space-s) 22px;
    border-bottom: var(--rule) solid var(--hairline);
    background: var(--paper);
    text-align: center;
  }

  .hero__field { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
  .hero__grid {
    position: absolute;
    inset: 0;
    background-image:
      linear-gradient(to right, var(--grid-line) var(--rule), transparent var(--rule)),
      linear-gradient(var(--grid-line) var(--rule), transparent var(--rule));
    background-size: var(--grid-x) var(--grid-y);
    background-position: calc(50% + var(--grid-x) / 2) 0;
  }
  .hero__marks span {
    position: absolute;
    translate: -50% -50%;
    color: var(--muted);
    font-size: var(--text-s);
    line-height: 1;
    opacity: 0;
    transition: opacity var(--plus-time) var(--ease-out);
  }
  .hero__cursor {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--handle);
    height: var(--handle);
    background: var(--accent);
    opacity: 0;
    transition: opacity var(--plus-time) var(--ease-out);
  }
  .hero.is-ready .hero__cursor { opacity: 1; }

  .hero__title {
    margin: 0;
    font-size: var(--text-xl);
    font-weight: 400;
    line-height: var(--leading);
    letter-spacing: var(--track-xl);
  }
  .hero__lead {
    max-width: 310px;
    margin: 6px 0 0;
    color: var(--muted);
    font-size: var(--text-s);
    line-height: var(--leading-s);
  }

  .hero__frame {
    position: relative;
    margin: 42px 0 0;
    padding: var(--handle-gap-y) var(--handle-gap-x);
  }
  .hero__handle {
    position: absolute;
    width: var(--handle);
    height: var(--handle);
    translate: -50% -50%;
    border-radius: var(--radius-round);
    background: var(--ink);
  }
  .hero__handle--nw { top: 0; left: 0; }
  .hero__handle--ne { top: 0; left: 100%; }
  .hero__handle--sw { top: 100%; left: 0; }
  .hero__handle--se { top: 100%; left: 100%; }
  .hero__board {
    position: relative;
    width: var(--board);
    aspect-ratio: 1;
    border: var(--rule) solid var(--hairline);
    background: var(--paper);
  }
  .hero__drawing {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity var(--swap) var(--ease-std);
    font-family: var(--font-body);
    letter-spacing: var(--track-s);
  }
  .hero__drawing.is-current { opacity: 1; }
  .hero__drawing.is-first { transition: opacity var(--fade-in) var(--ease-out); }

  .hero__h { fill: var(--ink); font-size: 15px; letter-spacing: var(--track-xl); }
  .hero__h--big { font-size: 26px; font-weight: 500; letter-spacing: 0; }
  .hero__t { fill: var(--ink); font-size: var(--text-nano); }
  .hero__t--mute, .hero__t .hero__t--mute { fill: var(--muted); }
  .hero__num { fill: var(--ink); font-size: 13px; }
  .hero__micro { fill: var(--muted); font-size: var(--text-micro); }
  .hero__hair { fill: none; stroke: var(--hairline); stroke-width: 0.5; }
  .hero__dash { stroke-dasharray: 1.5 2; }
  .hero__ink { fill: none; stroke: var(--ink); stroke-width: 0.75; }
  .hero__paper { fill: var(--paper); }
  .hero__tube { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .hero__tube--thick { stroke-width: 4; stroke-linecap: butt; }
  .hero__line-mid { fill: none; stroke: var(--muted); stroke-width: 1.25; }
  .hero__acc { fill: none; stroke: var(--accent); stroke-width: 1.25; }
  .hero__acc--spoke { stroke-width: 1.75; }
  .hero__acc--curve { stroke-width: 2; }
  .hero__acc--thick { fill: var(--accent); stroke: var(--ink); stroke-width: 1; }
  .hero__acc-fill { fill: var(--accent); }
  .hero__fill, .hero__nodes { fill: var(--ink); }

  .hero__prompts {
    position: relative;
    width: min(393px, 100%);
    height: 132px;
    margin-top: clamp(30px, 2.6vw, 38px);
  }
  .hero__prompt {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    margin: 0;
    font-size: var(--text-m);
    line-height: var(--leading);
    letter-spacing: var(--track-s);
    transform-origin: 50% 0;
    opacity: 0;
    transition: transform var(--carousel) var(--ease-expo), opacity var(--carousel) var(--ease-expo);
  }

  .hero__form {
    position: relative;
    display: flex;
    width: min(396px, 100%);
    margin-top: 8px;
  }
  .hero__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .hero__input {
    flex: 1;
    min-width: 0;
    height: var(--cell-h);
    padding: 0 10px;
    border: var(--rule) solid var(--hairline);
    border-radius: 0;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    letter-spacing: inherit;
  }
  .hero__input::placeholder { color: var(--muted); opacity: 1; }
  .hero__input:hover { background: var(--surface-inset); }
  .hero__input:focus { outline: none; background: var(--paper); border-color: var(--ink); }
  .hero__input:disabled { background: var(--surface-inset); color: var(--muted); }
  .hero__join {
    flex: none;
    height: var(--cell-h);
    margin-left: calc(-1 * var(--rule));
    padding: 0 16px;
    border: var(--rule) solid var(--hairline);
    border-radius: 0;
    background: var(--accent);
    color: var(--ink);
    font: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    transition: background-color var(--quick) var(--ease-std);
  }
  .hero__join:hover { background: var(--accent-hover); }
  .hero__join:active { background: var(--accent); }
  .hero__join:focus-visible { outline: 1px solid var(--ink); outline-offset: -4px; }
  .hero__join:disabled { background: var(--disabled); cursor: default; }
  .hero__note {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    margin: 0;
    font-size: var(--text-xs);
    line-height: var(--leading);
    text-align: left;
  }
  .hero__form.is-wrong .hero__note { color: var(--alert); }
  .hero__form.is-wrong .hero__input { border-color: var(--alert); }

  .hero__scroll {
    display: grid;
    justify-items: center;
    gap: 2px;
    margin: 30px 0 0;
    color: var(--muted);
    font-size: var(--text-nano);
    line-height: 1.5;
  }
  .hero__scroll svg { width: 10px; height: 6px; fill: none; stroke: var(--muted); stroke-width: 0.75; }

  @media (max-width: 639px) {
    .hero { padding-top: 88px; }
    .hero__lead { max-width: 300px; font-size: var(--text-m); line-height: var(--leading); }
    .hero__frame { margin-top: 32px; }
    .hero__board { width: min(var(--board) + 40px, calc(100vw - 2 * var(--space-m) - 2 * var(--handle-gap-x))); }
    .hero__prompts { height: 128px; }
  }
</style>

<script>
(() => {
  const PERIOD = 3000;
  const FIRST_DRAWING = 300;
  const PROMPT_GAP = 15;
  const NEXT_SCALE = 0.75;
  const STEPS = [
    { scale: 1, opacity: 1 },
    { scale: NEXT_SCALE, opacity: 0.6 },
    { scale: NEXT_SCALE, opacity: 0.2 },
  ];
  const LENS = 150;
  const still = matchMedia('(prefers-reduced-motion: reduce)');

  function hash(x, y) {
    const s = Math.sin(x * 127.1 + y * 311.7) * 43758.5453;
    return s - Math.floor(s);
  }
  function noise(x, y) {
    const ix = Math.floor(x), iy = Math.floor(y);
    const fx = x - ix, fy = y - iy;
    const sx = fx * fx * (3 - 2 * fx), sy = fy * fy * (3 - 2 * fy);
    const top = hash(ix, iy) + (hash(ix + 1, iy) - hash(ix, iy)) * sx;
    const bottom = hash(ix, iy + 1) + (hash(ix + 1, iy + 1) - hash(ix, iy + 1)) * sx;
    return top + (bottom - top) * sy;
  }
  function restingOpacity(column, row, inCentre) {
    const n = noise(column / 2.6 + 3.1, row / 2.2 + 7.3);
    const patch = n > 0.66 ? 1 : n > 0.6 ? 0.5 : n > 0.53 ? 0.25 : 0;
    return inCentre ? Math.min(patch, 0.25) : patch;
  }

  function setUpField(hero) {
    const marksBox = hero.querySelector('.hero__marks');
    const cursor = hero.querySelector('.hero__cursor');
    const board = hero.querySelector('.hero__frame');
    let marks = [];
    let pointer = null;
    let frame = 0;

    const build = () => {
      const width = hero.clientWidth, height = hero.clientHeight;
      const style = getComputedStyle(hero);
      const stepX = parseFloat(style.getPropertyValue('--grid-x'));
      const stepY = parseFloat(style.getPropertyValue('--grid-y'));
      const originX = width / 2;
      const centreHalf = board.offsetWidth / 2 + stepX / 2;
      const fragment = document.createDocumentFragment();
      marks = [];
      const firstColumn = -Math.ceil(originX / stepX);
      const lastColumn = Math.ceil((width - originX) / stepX);
      for (let row = 1; row * stepY < height; row += 1) {
        for (let column = firstColumn; column <= lastColumn; column += 1) {
          const x = originX + column * stepX, y = row * stepY;
          const mark = document.createElement('span');
          mark.textContent = '+';
          mark.style.left = `${x}px`;
          mark.style.top = `${y}px`;
          const rest = restingOpacity(column, row, Math.abs(x - width / 2) < centreHalf);
          mark.style.opacity = rest;
          marks.push({ mark, x, y, rest, shown: rest });
          fragment.append(mark);
        }
      }
      marksBox.replaceChildren(fragment);
      const home = marks.find((m) => m.x > stepX * 0.3 && m.x < width / 2 - centreHalf && m.y > height * 0.7);
      if (home) placeCursor(home.x, home.y);
      hero.classList.toggle('is-ready', Boolean(home));
    };

    const placeCursor = (x, y) => {
      const half = cursor.offsetWidth / 2;
      cursor.style.transform = `translate(${x - half}px, ${y - half}px)`;
    };

    const paint = () => {
      frame = 0;
      let nearest = null, nearestDistance = Infinity;
      for (const item of marks) {
        let target = item.rest;
        if (pointer) {
          const distance = Math.hypot(item.x - pointer.x, item.y - pointer.y);
          if (distance < LENS) target = Math.max(target, 1 - distance / LENS);
          if (distance < nearestDistance) { nearest = item; nearestDistance = distance; }
        }
        target = Math.round(target * 20) / 20;
        if (target !== item.shown) { item.shown = target; item.mark.style.opacity = target; }
      }
      if (nearest) placeCursor(nearest.x, nearest.y);
    };
    const schedule = () => { if (!frame) frame = requestAnimationFrame(paint); };

    hero.addEventListener('pointermove', (event) => {
      const box = hero.getBoundingClientRect();
      pointer = { x: event.clientX - box.left, y: event.clientY - box.top };
      hero.classList.add('is-ready');
      schedule();
    });
    hero.addEventListener('pointerleave', () => { pointer = null; schedule(); });
    new ResizeObserver(build).observe(hero);
  }

  function setUpPrompts(hero) {
    const prompts = [...hero.querySelectorAll('.hero__prompt')];
    const drawings = [...hero.querySelectorAll('.hero__drawing')];
    const stage = hero.querySelector('.hero__frame');
    let current = 0;
    let timer = 0;
    let visible = false;
    let held = false;

    const layout = () => {
      const count = prompts.length;
      const heights = prompts.map((prompt) => prompt.offsetHeight);
      let y = 0;
      for (let step = 0; step < count; step += 1) {
        const index = (current + step) % count;
        const look = STEPS[step];
        let transform, opacity;
        if (step === count - 1) {
          transform = `translateY(${-heights[index] - 6}px)`;
          opacity = 0;
        } else if (look) {
          transform = `translateY(${y}px) scale(${look.scale})`;
          opacity = look.opacity;
          y += heights[index] * look.scale + PROMPT_GAP;
        } else {
          transform = `translateY(${y + 40}px) scale(${NEXT_SCALE})`;
          opacity = 0;
        }
        prompts[index].style.transform = transform;
        prompts[index].style.opacity = opacity;
        prompts[index].setAttribute('aria-hidden', String(step !== 0));
      }
      drawings.forEach((drawing, index) => drawing.classList.toggle('is-current', index === current));
    };

    const advance = () => {
      drawings[current].classList.remove('is-first');
      current = (current + 1) % prompts.length;
      layout();
    };
    const sync = () => {
      clearInterval(timer);
      timer = 0;
      if (visible && !held && !still.matches) timer = setInterval(advance, PERIOD);
    };

    drawings[0].classList.add('is-first');
    prompts.forEach((prompt) => { prompt.style.transition = 'none'; });
    layout();
    drawings[0].classList.remove('is-current');
    requestAnimationFrame(() => prompts.forEach((prompt) => { prompt.style.transition = ''; }));
    setTimeout(() => drawings[0].classList.add('is-current'), still.matches ? 0 : FIRST_DRAWING);

    stage.addEventListener('pointerenter', () => { held = true; sync(); });
    stage.addEventListener('pointerleave', () => { held = false; sync(); });
    new IntersectionObserver(([entry]) => { visible = entry.isIntersecting; sync(); }).observe(stage);
    new ResizeObserver(layout).observe(hero.querySelector('.hero__prompts'));
    still.addEventListener('change', sync);
  }

  function setUpForm(hero) {
    const form = hero.querySelector('.hero__form');
    const input = form.querySelector('.hero__input');
    const button = form.querySelector('.hero__join');
    const note = form.querySelector('.hero__note');
    form.addEventListener('submit', (event) => {
      event.preventDefault();
      const ok = input.validity.valid && input.value.includes('.');
      form.classList.toggle('is-wrong', !ok);
      if (!ok) { note.textContent = 'Enter a full email address.'; input.focus(); return; }
      note.textContent = 'You are on the list. We write when the first model ships.';
      button.textContent = 'Added';
      input.disabled = true;
      button.disabled = true;
    });
    input.addEventListener('input', () => { form.classList.remove('is-wrong'); note.textContent = ''; });
  }

  for (const hero of document.querySelectorAll('.hero')) {
    setUpField(hero);
    setUpPrompts(hero);
    setUpForm(hero);
  }
})();
</script>

Similar components

Ruled hero

Ruled hero

Exhibition feature

Exhibition feature

Cut-out hero

Cut-out hero

Masthead

Masthead

Screensaver deck

Screensaver deck

Tunnel heading

Tunnel heading

Film reel

Film reel

Glass word with falling stickers

Glass word with falling stickers