# Netflix Intro

Motionboard shot name: Ribbon Intro

A violet letter K builds from three folded ribbon strokes. The camera dives into the stem, which splits into thin vertical strands of light that turn from violet to a full spectrum and streak across the frame. The strands lock into a colour bar, the camera pulls back to show the K again, and the Kite lockup holds at the end.

- Position in a launch film: Opening
- Slug: netflix-intro
- Preview video: https://media.motionboard.app/ribbon-intro.mp4
- Recipe page: https://motionboard.app/recipes/netflix-intro/
- License: MIT. Free to use in your own projects, including commercial launch films. https://github.com/krisyangdev/motionboard/blob/main/LICENSE

## How to use this recipe

You are a coding agent. The user wants this shot for their own product. Follow these steps.

1. **Know the product.** If the product is clear from the user's repo or conversation, ask nothing and start. Otherwise ask once for: product name, logo file, brand colors.
2. **Pick the output.** If the user's message says a video or their website, do that. Otherwise ask once which one they want.
   - **Video (HyperFrames).** Create a folder named `ribbon-intro`. Download every file under "Source files" below with the curl commands, keeping relative paths. Adapt `index.html` (see "What to adapt"). Run `npx --yes hyperframes@0.8.209 check` on the untouched copy first and note its result. Preview with `npx --yes hyperframes@0.8.209 preview`, render an MP4 with `npx --yes hyperframes@0.8.209 render` (into `renders/`, named with a timestamp). The same commands are in `package.json` as `dev`, `check`, `render`; pass flags after `--`, as in `npm run render -- --quality draft`. Rendering needs network access for web fonts and GSAP.
   - **Website motion.** Port the GSAP timeline in `index.html` into the user's site, using their stack (React, Vue, Svelte, plain HTML). Build the same DOM structure, keep the timeline's durations, delays and easings exactly, and start it when the element scrolls into view (IntersectionObserver or ScrollTrigger). Respect `prefers-reduced-motion: reduce`: show the final frame as a static state and skip the movement.
3. **What to adapt.**
   - **Brand layer** (product name, logo, colors, fonts, copy): replace directly with the user's.
   - **UI layer** (the product screens, cards, windows, controls shown in the shot): rebuild the user's real UI as clean DOM, from their codebase (components, design tokens) or from a screenshot used as reference only. Never paste a screenshot into the shot.
   - **Motion** (timing, easing, camera moves, layering, stagger, order of events): keep exactly as in the source. This is what the recipe is.
   - The timeline targets UI elements by id and class, and camera moves land on fixed coordinates. Keep the ids the timeline uses, keep row counts and text lengths close to the source, and when the layout moves, update the target coordinates without changing the times.
4. **Fonts.** HyperFrames fetches Google Fonts such as Inter on its own. Some sources use macOS local fonts (PingFang, Songti via `local()`). Use the user's brand font when it can be bundled; for a system font such as SF Pro, use Inter. Check that text still fits its boxes.
5. **Verify.** Compare the render with the preview video above at the beat times in the Timing row. The beats, timing and camera should match; only brand and UI content differ.

## Spec

| Item | Value |
| --- | --- |
| Timing | Film 10.5s. Stem rises 0.35–1.25s, arm unfolds 1.05–1.9s, leg unfolds 1.55–2.3s; light sheen crosses the K 2.3–3.1s; dive into the stem 3.0–4.5s; the stem fill breaks into strands 3.65–4.35s; violet turns to full spectrum 4.35–5.6s; strands streak and travel 4.4–6.4s; strands lock into a colour bar 6.4–7.0s with a white flash at 6.95–7.4s; pull-back to the K 7.0–7.85s; spectrum cools to violet 7.55–8.05s; wordmark 7.7–8.15s, tagline and spectrum rule 7.85–8.3s; lockup holds 8.3–10.5s with one soft sheen over the K at 8.6–9.5s |
| Easing | Stroke rise and unfold use expo.out; the 3D yaw uses expo.out; the dive is a cubic in-out (power3.inOut) on the logarithm of the zoom; the colour change and strand travel use power2.inOut; the lock into the colour bar uses power3.inOut; the pull-back is a quartic out (power4.out) on the logarithm of the zoom; the sheens and the cooling use power2.inOut; wordmark and tagline use power3.out for opacity and expo.out for the slide; the light streaks move linearly |
| Camera | Locked camera until 3.0s with a slow push from 0.9x to 1.0x over 0.2–3.0s. The K starts yawed 0.7 rad (about 40°) with 1400px perspective and levels out by 2.6s. The dive scales 1x to 16.4x over 3.0–4.5s toward a point in the middle of the stem, panning in screen-linear steps so the point stays on its line to the frame centre. The camera holds at 16.4x from 4.5s to 7.0s, then pulls back to 0.54x over 7.0–7.85s and lands with the K centre at x=718px so the wordmark fits to its right |
| Subject | A K of three ribbon strokes in a 440x560 box: stem 120px wide, arm and leg each about 115–120px wide, each stroke with a lit face and a darker fold face split at 58% of its width. Inside the stem, 64 main strands and 24 extra strands, 4–40px wide at 16.4x (0.2–2% of the stem width, extras 30% thinner), and 28 light streaks 2–5.5px wide and 220–740px long moving 1200–4000px/s. The colour bar is 64 contiguous bars of about 31px. Wordmark Kite at 232px, tagline Everything worth watching. at 44px, a 200x6px spectrum rule |
| Sync | Strands start to fade in at 3.65s, about 2.5x into the dive, and the stem is full of them when the dive lands at 4.5s; the colour change starts 0.15s before the landing. Streaks enter at 4.6–5.2s and leave at 6.2–6.8s. The flash peaks at 7.05s on the frame where the pull-back begins, so the cut from bar to K reads as one move. The cooling to violet starts at 7.55s while the pull-back is still settling, and the wordmark starts at 7.7s |
| Style | Background `#050507`, one brand colour violet `#6a4bff` (strokes in `#8466ff` to `#27187a`) and a spectrum from hue 262° down to -38° at 94% saturation and 55% lightness used only inside the dive; Inter 800 for the wordmark, tagline `#bdb7dd`; strands painted opaque over each other with a narrow additive glow at 16% opacity and a thin hot core on peaking strands; grain at 7% opacity, a vignette reaching 50% at the edges and a violet bloom at 13–16% |

## Why it works

The mark is its own tunnel. The K is made of ribbon strokes, so the dive has a surface to fall into: the camera scales into the stem until the stem is the whole frame, and the thin strands that appear are the stem's own fill coming apart. A dive on a flat logo would have nothing to split. The strands carry the film's only colour change, violet to a full spectrum, and the change starts 0.15s before the dive lands, so the eye is already looking at colour when the camera stops. The spectrum stays readable because the strands are painted opaque over each other with a narrow glow and a thin hot core, and 40–50% of the frame stays dark between them; strands that add up to white would turn the middle of the film into a flat wash. Light streaks cross at 1200–4000px/s so the screen keeps moving while the strands travel. The 64 strands then slide into 64 equal bars, a clean colour bar that reads as a pause, and the white flash lands on the frame where the pull-back starts. The pull-back shows that the bar was the stem all along, and arm and leg appear in the same colours before the whole mark cools to violet. That gives the lockup one brand colour, a violet K, and the spectrum belongs only to the dive.

## Prompt

> Build a 10.5-second, 1920x1080, 30 fps dark intro called Ribbon Intro for a fictional streaming app, Kite. Background #050507, brand colour violet #6a4bff, font Inter. Draw everything on one canvas 2D element redrawn by a single render(t) driven by one linear proxy tween from 0 to 10.5s, with a seeded mulberry32 PRNG and no CSS animations. The mark is a letter K built from three ribbon strokes in a 440x560 box, each a parallelogram with a lit face and a darker fold face split at 58% of its width: stem x -200..-80, y -280..280; arm from (-80,40)-(40,40) up to (120,-280)-(240,-280); leg from (-52,0)-(62,0) down to (96,280)-(210,280). Tones: stem #8466ff #6244f2 #3b25ab #27187a, arm lighter, leg darker, with a dark shade where each stroke starts. Timeline: stem rises 0.35–1.25s, arm unfolds 1.05–1.9s, leg unfolds 1.55–2.3s (expo.out, revealed along each stroke's length). Yaw the K 0.7 rad to 0 over 0.1–2.6s with 1400px perspective, push the camera 0.9x to 1.0x over 0.2–3.0s, cross the K with a light sheen 2.3–3.1s. Dive 3.0–4.5s: zoom 1x to 16.4x with a power3.inOut on the logarithm of the zoom, panning toward the middle of the stem so the stem is 1968px wide, the full frame, at the end. Inside the stem, draw 64 vertical strands (plus 24 extra strands 30% thinner) in screen space inside the stem rectangle, widths 4–40px at 16.4x, each with its own depth, shimmer phase and vertical fade at both ends. Fade the strands in 3.65–4.35s as the violet fill fades out. Shift the hue from violet 258° to a spectrum from 262° down to -38° over 4.35–5.6s (saturation 94%, lightness 55%). Over 4.4–6.4s travel each strand sideways with a parallax offset of (depth − 0.9) × 0.9 stem widths, wrapped, and spread them 30%; shimmer opacity with a sine per strand; add 28 light streaks, 2–5.5px wide and 220–740px long, moving 1200–4000px/s, from 4.6–5.2s to 6.2–6.8s. Never let strands add up to white: paint a narrow additive glow (2.2x width, 16% opacity) first, then paint every strand opaque in normal compositing so a strand on top hides the one below, then a thin core of 16% of the strand width on peaking strands. Keep 40–50% of the frame dark between strands. Lock into a colour bar over 6.4–7.0s (power3.inOut): 64 contiguous bars of about 31px in spectrum order, with a 28% white flash at 6.95–7.4s. Pull back 7.0–7.85s from 16.4x to 0.54x (power4.out on the logarithm of the zoom) so the K centre lands at x=718px; arm and leg carry the same spectrum strips. Cool the spectrum to the violet folded K over 7.55–8.05s. Lockup: wordmark Kite in Inter 800 at 232px, left at x=901px, fading and sliding 60px in 7.7–8.15s; a 200x6px spectrum rule and the tagline Everything worth watching. at 44px in #bdb7dd at 7.85–8.3s. Hold still 8.3–10.5s apart from one soft sheen over the K at 8.6–9.5s. Finish with 7% grain, a vignette reaching 50% at the edges and a violet bloom behind the mark. Use your own product's mark split into two or three strokes; do not copy any real brand's mark.

## Often confused with

- [3D Ribbon Text Animation](https://motionboard.app/r/3d-ribbon-text-animation.md): 3D Ribbon Text uses ribbons as a band that wipes across a title and opens onto a product screen; here the ribbons are the inside of a logo stroke, and the film ends on the logo.
- [Logo Wordmark Reveal](https://motionboard.app/r/logo-wordmark-reveal.md): Logo Wordmark Reveal moves a mark into the letters of a name; in this film the mark is entered by the camera, breaks into light strands and is reassembled by a pull-back before the name appears.

## Source files

Runnable HyperFrames project, 3 files.

- https://motionboard.app/source/ribbon-intro/hyperframes.json (318 B)
- https://motionboard.app/source/ribbon-intro/index.html (18.8 KB)
- https://motionboard.app/source/ribbon-intro/package.json (301 B)

Download all of them:

```sh
curl -fsSL --create-dirs -o "ribbon-intro/hyperframes.json" "https://motionboard.app/source/ribbon-intro/hyperframes.json"
curl -fsSL --create-dirs -o "ribbon-intro/index.html" "https://motionboard.app/source/ribbon-intro/index.html"
curl -fsSL --create-dirs -o "ribbon-intro/package.json" "https://motionboard.app/source/ribbon-intro/package.json"
```

## index.html

```html
<!doctype html>
<html lang="en" data-resolution="landscape">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=1920, height=1080" />
    <script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
    <style>
      :root {
        --bg: #050507;
        --ink: #f4f4f6;
        --acc: #6a4bff;
        --font-ui: "Inter", -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
      }
      * { margin: 0; padding: 0; box-sizing: border-box; }
      html, body { width: 1920px; height: 1080px; overflow: hidden; background: var(--bg); }
      #root {
        position: relative; width: 1920px; height: 1080px; overflow: hidden; background: var(--bg);
        font-family: var(--font-ui); color: var(--ink); -webkit-font-smoothing: antialiased;
      }
      .full { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; }
      canvas { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; display: block; }

      /* lockup text (the K itself is drawn on the canvas) */
      #lock { z-index: 5; pointer-events: none; }
      #wm {
        position: absolute; left: 901px; top: 383px; height: 232px; line-height: 232px; white-space: nowrap;
        font-weight: 800; font-size: 232px; letter-spacing: -0.04em; color: #f4f4f6; opacity: 0;
      }
      #spec {
        position: absolute; left: 909px; top: 598px; width: 200px; height: 6px; border-radius: 3px; opacity: 0;
        transform-origin: 0 50%;
        background: linear-gradient(90deg, hsl(262,85%,62%), hsl(215,90%,58%), hsl(180,90%,52%), hsl(130,80%,52%), hsl(60,95%,56%), hsl(20,95%,58%), hsl(335,88%,60%));
      }
      #tag {
        position: absolute; left: 905px; top: 628px; white-space: nowrap; opacity: 0;
        font-weight: 500; font-size: 44px; line-height: 1.2; letter-spacing: -0.01em; color: #bdb7dd;
      }

      /* finish */
      #grain {
        z-index: 8; pointer-events: none; opacity: 0.07; background-size: 256px 256px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)'/%3E%3C/svg%3E");
      }
      #vig { z-index: 9; pointer-events: none; background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 58%, rgba(0, 0, 0, 0.5) 100%); }
    </style>
  </head>
  <body>
    <div id="root" data-composition-id="main" data-start="0" data-duration="10.5" data-width="1920" data-height="1080">
      <div id="stage" class="clip full" data-start="0" data-duration="10.5" data-track-index="0">
        <canvas id="cv" width="1920" height="1080"></canvas>
      </div>
      <div id="lock" class="clip full" data-start="0" data-duration="10.5" data-track-index="1">
        <div id="wm" data-layout-allow-overflow>Kite</div>
        <div id="spec"></div>
        <div id="tag">Everything worth watching.</div>
      </div>
      <div id="grain" class="clip full" data-start="0" data-duration="10.5" data-track-index="2"></div>
      <div id="vig" class="clip full" data-start="0" data-duration="10.5" data-track-index="3"></div>
    </div>

    <script>
      /* ============================================================
         Kite ribbon intro. One canvas, one render(t); every value is a pure
         function of t (seeded PRNG, closed-form camera).
         0.30-2.30  K builds from three folded ribbon strokes (stem, arm, leg)
         2.30-3.00  sheen crosses the mark, camera settles
         3.00-4.50  camera dives into the stem
         3.65-6.40  stem splits into thin vertical light ribbons: violet ->
                    spectrum, streaks, shimmer, parallax travel
         6.40-7.00  ribbons resolve into a clean colour bar
         7.00-8.05  camera pulls back, bar is the K again, cools to violet
         7.70-8.30  wordmark + tagline; lockup holds to 10.5
         ============================================================ */
      const W = 1920, H = 1080, DUR = 10.5;
      const cv = document.getElementById("cv");
      const ctx = cv.getContext("2d");
      const wm = document.getElementById("wm");
      const spec = document.getElementById("spec");
      const tag = document.getElementById("tag");

      const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x));
      const seg = (t, a, b) => clamp((t - a) / (b - a));
      const lerp = (a, b, u) => a + (b - a) * u;
      const eOut3 = (u) => 1 - Math.pow(1 - u, 3);
      const eExpoOut = (u) => (u >= 1 ? 1 : 1 - Math.pow(2, -10 * u));
      const eIO2 = (u) => (u < 0.5 ? 2 * u * u : 1 - Math.pow(-2 * u + 2, 2) / 2);
      const eIO3 = (u) => (u < 0.5 ? 4 * u * u * u : 1 - Math.pow(-2 * u + 2, 3) / 2);
      const wrapR = (u, lo, hi) => { const d = hi - lo; return lo + (((u - lo) % d) + d) % d; };
      function mulberry32(a) {
        return function () {
          a |= 0; a = (a + 0x6d2b79f5) | 0;
          let t = Math.imul(a ^ (a >>> 15), 1 | a);
          t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
          return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
        };
      }

      /* ---------------- mark geometry (mark space, K bbox x -200..240, y -280..280) ---------------- */
      const MK = { cx: 20, cy: 0 };
      const SX0 = -200, SX1 = -80, SY0 = -280, SY1 = 280; /* stem rect */
      const STROKES = [
        { n: "stem", S0: [-200, 280], S1: [-80, 280], E0: [-200, -280], E1: [-80, -280], a: 0.35, b: 1.25,
          tone: ["#8466ff", "#6244f2", "#3b25ab", "#27187a"] },
        { n: "leg", S0: [-52, 0], S1: [62, 0], E0: [96, 280], E1: [210, 280], a: 1.55, b: 2.3,
          tone: ["#6a4df0", "#5236d8", "#2f1d8d", "#1f1366"] },
        { n: "arm", S0: [-80, 40], S1: [40, 40], E0: [120, -280], E1: [240, -280], a: 1.05, b: 1.9,
          tone: ["#9a84ff", "#7a5ffb", "#4a33c9", "#33219c"] },
      ];
      const FOLD = 0.58;

      function proj(pt, th) {
        const dx = pt[0] - MK.cx;
        const Z = dx * Math.sin(th);
        const q = 1400 / (1400 + Z);
        return [MK.cx + dx * Math.cos(th) * q, pt[1] * q];
      }
      const mid = (a, b) => [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
      const mix2 = (a, b, p) => [lerp(a[0], b[0], p), lerp(a[1], b[1], p)];

      function strokePoly(st, p, th) {
        const e0 = mix2(st.S0, st.E0, p), e1 = mix2(st.S1, st.E1, p);
        return [proj(st.S0, th), proj(e0, th), proj(e1, th), proj(st.S1, th)];
      }
      function pathPoly(P) {
        ctx.beginPath();
        ctx.moveTo(P[0][0], P[0][1]);
        for (let i = 1; i < P.length; i++) ctx.lineTo(P[i][0], P[i][1]);
        ctx.closePath();
      }
      function drawStroke(st, p, th, alpha) {
        if (p <= 0.001 || alpha <= 0.001) return;
        const P = strokePoly(st, p, th);
        const f0 = proj(st.S0, th), f1 = proj(st.S1, th), g0 = proj(st.E0, th), g1 = proj(st.E1, th);
        const A = mid(f0, g0), B = mid(f1, g1);
        const gx = ctx.createLinearGradient(A[0], A[1], B[0], B[1]);
        gx.addColorStop(0, st.tone[0]);
        gx.addColorStop(FOLD, st.tone[1]);
        gx.addColorStop(Math.min(FOLD + 0.002, 1), st.tone[2]);
        gx.addColorStop(1, st.tone[3]);
        ctx.globalAlpha = alpha;
        pathPoly(P);
        ctx.fillStyle = gx;
        ctx.fill();
        /* along-axis shade: darker where the ribbon starts, clear toward the free end */
        const C = mid(f0, f1), D = mid(g0, g1);
        const gy = ctx.createLinearGradient(C[0], C[1], D[0], D[1]);
        gy.addColorStop(0, "rgba(0,0,0,0.38)");
        gy.addColorStop(0.55, "rgba(0,0,0,0)");
        gy.addColorStop(1, "rgba(255,255,255,0.07)");
        pathPoly(P);
        ctx.fillStyle = gy;
        ctx.fill();
        ctx.globalAlpha = 1;
      }
      function unionPath() {
        ctx.beginPath();
        for (const st of STROKES) {
          const P = strokePoly(st, 1, 0);
          ctx.moveTo(P[0][0], P[0][1]);
          for (let i = 1; i < 4; i++) ctx.lineTo(P[i][0], P[i][1]);
          ctx.closePath();
        }
      }
      function drawSheen(sx, a) {
        if (a <= 0.001) return;
        ctx.save();
        unionPath();
        ctx.clip();
        ctx.globalCompositeOperation = "lighter";
        const g = ctx.createLinearGradient(sx - 90, 30, sx + 90, -30);
        g.addColorStop(0, "rgba(230,220,255,0)");
        g.addColorStop(0.5, "rgba(230,220,255," + a.toFixed(3) + ")");
        g.addColorStop(1, "rgba(230,220,255,0)");
        ctx.fillStyle = g;
        ctx.fillRect(sx - 120, -300, 240, 600);
        ctx.restore();
      }

      /* ---------------- ribbons ---------------- */
      const NM = 64, NX = 24;
      const HUE0 = 262, HUER = -300;
      const rb = [];
      {
        const r = mulberry32(2026);
        for (let i = 0; i < NM + NX; i++) {
          const ex = i >= NM;
          const k = ex ? i - NM : i;
          const slot = (k + 0.5) / NM;
          const wr = r();
          const wf = wr < 0.5 ? 0.002 + r() * 0.004 : wr < 0.85 ? 0.006 + r() * 0.006 : 0.012 + r() * 0.008;
          rb.push({
            ex,
            i: k,
            slot,
            u0: ex ? -0.08 + r() * 1.16 : clamp(slot + (r() - 0.5) * 1.4 / NM, 0, 1),
            wf: ex ? wf * 0.7 : wf,
            d: 0.35 + r() * 1.15,
            ph: r() * 6.283,
            om: 2 + r() * 4,
            b: ex ? 0.45 + r() * 0.35 : 0.6 + r() * 0.4,
            fT: 0.05 + r() * 0.25,
            fB: 0.05 + r() * 0.25,
            jit: (r() - 0.5) * 22,
            hueSpec: ex ? HUE0 + HUER * r() : HUE0 + HUER * (k / (NM - 1)),
          });
        }
      }
      const STK = [];
      {
        const r = mulberry32(4242);
        for (let i = 0; i < 28; i++) {
          STK.push({
            x: r() * W, w: 2 + r() * 3.5, len: 220 + r() * 520,
            sp: (1200 + r() * 2800) * (r() < 0.5 ? -1 : 1), y0: r() * 1700, hue: HUE0 + HUER * r(),
          });
        }
      }

      const settle = (t) => eIO2(seg(t, 7.55, 8.05));

      function drawRibbons(t, cam) {
        const st = settle(t);
        const ribA = seg(t, 3.65, 4.35) * (1 - st);
        if (ribA <= 0.001) return;
        const x0 = 960 + (SX0 - cam.cx) * cam.s, x1 = 960 + (SX1 - cam.cx) * cam.s;
        const y0 = 540 + (SY0 - cam.cy) * cam.s, y1 = 540 + (SY1 - cam.cy) * cam.s;
        const Y0 = Math.max(0, y0), Y1 = Math.min(H, y1), sw = x1 - x0;
        const trav = eIO2(seg(t, 4.4, 6.4));
        const rr = eIO3(seg(t, 6.4, 7.0));
        const hmix = eIO2(seg(t, 4.35, 5.6));
        const shimA = seg(t, 4.0, 4.8) * (1 - rr);
        const fadeS = seg(t, 3.9, 4.6) * (1 - rr);
        const kz = 1 + 0.3 * trav;
        const exA = seg(t, 4.4, 5.0) * (1 - rr);

        const items = [];
        for (const r of rb) {
          let u = wrapR(r.u0 + (r.d - 0.9) * 0.9 * trav, -0.12, 1.12);
          u = 0.5 + (u - 0.5) * kz;
          let w = r.wf * kz;
          let a = ribA;
          if (r.ex) a *= exA;
          else { u = lerp(u, r.slot, rr); w = lerp(w, 1.03 / NM, rr); }
          if (a <= 0.002) continue;
          const v = 0.5 + 0.5 * Math.sin(r.om * (t - 4) + r.ph);
          const br = lerp(1, 0.5 + 0.5 * v, shimA) * r.b;
          const peak = Math.pow(v, 4) * shimA;
          const h = lerp(258 + r.jit, r.hueSpec, hmix);
          const sat = lerp(78, 94, hmix);
          const l = lerp(58, 55, hmix);
          const xc = x0 + u * sw, ww = Math.max(w * sw, 1.5);
          const mk = (L, S, al) => {
            const col = (q) => "hsla(" + h.toFixed(1) + "," + S.toFixed(1) + "%," + L.toFixed(1) + "%," + q + ")";
            const g = ctx.createLinearGradient(0, Y0, 0, Y1);
            const a0 = 1 - fadeS;
            g.addColorStop(0, col(a0 * al));
            g.addColorStop(Math.min(r.fT, 0.49), col(al));
            g.addColorStop(Math.max(1 - r.fB, 0.51), col(al));
            g.addColorStop(1, col(a0 * al));
            return g;
          };
          items.push({ xc, ww, a, br, peak, mk, l, sat, rr });
        }

        ctx.save();
        ctx.beginPath();
        ctx.rect(x0, Y0, sw, Y1 - Y0);
        ctx.clip();
        /* pass 1: soft glow around each strand (additive, narrow, low) */
        ctx.globalCompositeOperation = "lighter";
        const glowK = 0.16 * (1 - rr);
        if (glowK > 0.002) {
          for (const it of items) {
            ctx.fillStyle = it.mk(it.l, it.sat, 1);
            ctx.globalAlpha = Math.min(1, it.a * it.br * glowK);
            ctx.fillRect(it.xc - it.ww * 1.1 - 4, Y0, it.ww * 2.2 + 8, Y1 - Y0);
          }
        }
        /* pass 2: opaque strands, painted over each other so overlaps never sum to white */
        ctx.globalCompositeOperation = "source-over";
        for (const it of items) {
          ctx.fillStyle = it.mk(it.l, it.sat, 1);
          ctx.globalAlpha = Math.min(1, it.a * (0.55 + 0.45 * it.br));
          ctx.fillRect(it.xc - it.ww / 2, Y0, it.ww, Y1 - Y0);
        }
        /* pass 3: thin hot core on the strands that are peaking */
        for (const it of items) {
          if (it.peak < 0.05) continue;
          ctx.fillStyle = it.mk(84, 70, 1);
          ctx.globalAlpha = Math.min(1, it.a * it.peak * 0.85);
          const cw = Math.max(1.5, it.ww * 0.16);
          ctx.fillRect(it.xc - cw / 2, Y0, cw, Y1 - Y0);
        }
        ctx.restore();

        /* fast light streaks across the whole frame while inside */
        const env = seg(t, 4.6, 5.2) * (1 - seg(t, 6.2, 6.8));
        if (env > 0.002) {
          ctx.save();
          ctx.globalCompositeOperation = "lighter";
          for (const k of STK) {
            const y = (((k.y0 + k.sp * (t - 4.4)) % 1700) + 1700) % 1700 - 300;
            const down = k.sp > 0;
            const ya = down ? y - k.len : y;
            const g = ctx.createLinearGradient(0, down ? y - k.len : y + k.len, 0, y);
            g.addColorStop(0, "hsla(" + k.hue.toFixed(0) + ",90%,60%,0)");
            g.addColorStop(0.85, "hsla(" + k.hue.toFixed(0) + ",90%,64%,0.9)");
            g.addColorStop(1, "hsla(" + k.hue.toFixed(0) + ",60%,92%,1)");
            ctx.globalAlpha = 0.6 * env;
            ctx.fillStyle = g;
            ctx.fillRect(k.x - k.w / 2, down ? ya : y, k.w, k.len);
          }
          ctx.restore();
        }
      }

      /* spectrum strips clipped to a stroke polygon (arm and leg during the pull-back) */
      function drawSpectrumStroke(st, alpha, t) {
        if (alpha <= 0.002) return;
        const P = strokePoly(st, 1, 0);
        const xs = P.map((p) => p[0]), ys = P.map((p) => p[1]);
        const bx = Math.min(...xs), bw = Math.max(...xs) - bx;
        const by = Math.min(...ys), bh = Math.max(...ys) - by;
        ctx.save();
        pathPoly(P);
        ctx.clip();
        ctx.globalAlpha = alpha;
        const sw = bw / NM;
        for (let i = 0; i < NM; i++) {
          const h = HUE0 + HUER * (i / (NM - 1));
          ctx.fillStyle = "hsl(" + h.toFixed(1) + ",92%,54%)";
          ctx.fillRect(bx + i * sw, by, sw + 0.8, bh);
        }
        ctx.restore();
      }

      /* ---------------- camera ---------------- */
      const SD = 16.4, SF = 0.54;
      const CAM_STEM = [-140, -20];
      const CAM_FINAL = [20 + (960 - 718) / SF, 0];
      function camera(t) {
        let s, cx, cy;
        if (t < 3.0) {
          s = lerp(0.9, 1.0, eOut3(seg(t, 0.2, 3.0)));
          cx = MK.cx; cy = MK.cy;
        } else if (t < 7.0) {
          const p = eIO3(seg(t, 3.0, 4.5));
          s = Math.exp(lerp(0, Math.log(SD), p));
          const g = (1 / s - 1) / (1 / SD - 1);
          cx = lerp(MK.cx, CAM_STEM[0], g); cy = lerp(MK.cy, CAM_STEM[1], g);
        } else {
          const p = 1 - Math.pow(1 - seg(t, 7.0, 7.85), 4);
          s = Math.exp(lerp(Math.log(SD), Math.log(SF), p));
          const g = (1 / s - 1 / SD) / (1 / SF - 1 / SD);
          cx = lerp(CAM_STEM[0], CAM_FINAL[0], g); cy = lerp(CAM_STEM[1], CAM_FINAL[1], g);
        }
        return { s, cx, cy };
      }

      /* ---------------- frame ---------------- */
      function render(t) {
        const cam = camera(t);
        const st = settle(t);
        ctx.setTransform(1, 0, 0, 1, 0, 0);
        ctx.globalAlpha = 1;
        ctx.globalCompositeOperation = "source-over";
        ctx.fillStyle = "#050507";
        ctx.fillRect(0, 0, W, H);

        /* soft violet bloom behind the mark */
        const bloom = 0.13 * seg(t, 0.5, 2.2) * (1 - seg(t, 3.2, 4.0)) + 0.16 * st;
        if (bloom > 0.002) {
          const bx = st > 0 ? 718 : 960;
          const g = ctx.createRadialGradient(bx, 540, 0, bx, 540, 760);
          g.addColorStop(0, "rgba(106,75,255," + bloom.toFixed(3) + ")");
          g.addColorStop(1, "rgba(106,75,255,0)");
          ctx.fillStyle = g;
          ctx.fillRect(0, 0, W, H);
        }

        /* world: the three strokes */
        ctx.save();
        ctx.setTransform(cam.s, 0, 0, cam.s, 960 - cam.cx * cam.s, 540 - cam.cy * cam.s);
        const th = 0.7 * (1 - eExpoOut(seg(t, 0.1, 2.6)));
        const kv = t < 5 ? 1 - seg(t, 3.6, 4.35) : st;
        const ak = t < 5.5 ? 1 - seg(t, 4.2, 4.8) : st;
        for (const s of STROKES) {
          const p = eExpoOut(seg(t, s.a, s.b));
          const al = s.n === "stem" ? kv : ak;
          drawStroke(s, p, th, al);
        }
        if (t > 6.0) {
          const sp = seg(t, 6.2, 6.8) * (1 - st);
          drawSpectrumStroke(STROKES[1], sp, t);
          drawSpectrumStroke(STROKES[2], sp, t);
        }
        const sheen1 = eIO2(seg(t, 2.3, 3.1));
        drawSheen(lerp(-330, 380, sheen1), 0.5 * Math.sin(Math.PI * sheen1) * (1 - seg(t, 3.0, 3.3)));
        const sheen2 = eIO2(seg(t, 8.6, 9.5));
        drawSheen(lerp(-330, 380, sheen2), 0.34 * Math.sin(Math.PI * sheen2));
        ctx.restore();

        ctx.setTransform(1, 0, 0, 1, 0, 0);
        drawRibbons(t, cam);

        /* flash when the ribbons lock into the colour bar */
        const fl = seg(t, 6.95, 7.05) * (1 - seg(t, 7.05, 7.4));
        if (fl > 0.002) {
          ctx.globalCompositeOperation = "lighter";
          ctx.fillStyle = "rgba(255,255,255," + (0.28 * fl).toFixed(3) + ")";
          ctx.fillRect(0, 0, W, H);
          ctx.globalCompositeOperation = "source-over";
        }

        /* lockup text */
        const wo = eOut3(seg(t, 7.7, 8.15));
        wm.style.opacity = wo.toFixed(3);
        wm.style.transform = "translateX(" + ((1 - eExpoOut(seg(t, 7.7, 8.3))) * 60).toFixed(2) + "px)";
        const to = eOut3(seg(t, 7.85, 8.3));
        tag.style.opacity = to.toFixed(3);
        tag.style.transform = "translateX(" + ((1 - eExpoOut(seg(t, 7.85, 8.3))) * 40).toFixed(2) + "px)";
        spec.style.opacity = to.toFixed(3);
        spec.style.transform = "scaleX(" + eExpoOut(seg(t, 7.85, 8.3)).toFixed(4) + ")";
      }

      /* ---------- timeline ---------- */
      const tl = gsap.timeline({ paused: true });
      render(0);
      tl.to({ v: 0 }, { v: 1, duration: DUR, ease: "none", onUpdate: () => render(tl.time()) }, 0);
      tl.set({}, {}, DUR);

      window.__timelines = window.__timelines || {};
      window.__timelines["main"] = tl;
    </script>
  </body>
</html>
```
