# Before and After Slider

Motionboard shot name: Grade Slider

A flat, noisy lake photo sits under a Before tag while a cursor takes the handle of a divider, drags it to the right edge to reveal the graded After, pulls it back part way and leaves it in the middle with two result chips, then the Prism lockup appears.

- Position in a launch film: Product reveal
- Slug: before-and-after-slider
- Preview video: https://media.motionboard.app/before-after.mp4
- Recipe page: https://motionboard.app/recipes/before-and-after-slider/
- 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 `before-after`. 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 11s. The frame settles 0–1.4s; the divider fades in 0.35–0.75s; the cursor appears at 0.6s (0.25s), reaches the handle by 1.4s (0.8s) and presses at 1.45s (0.08s); sweep to the right edge 1.55–3.15s (1.6s); hold 3.15–3.8s; back to x=330px 3.8–5.1s (1.3s); hold 5.1–5.35s; settle at x=780px 5.35–6.35s (1.0s); release at 6.4s (0.25s); cursor leaves 6.6–7.05s; chips at 6.45s and 6.65s (0.6s each); scene leaves 7.3–7.9s (0.6s); mark at 8.0s (0.6s), wordmark at 8.08s (0.6s), tagline at 8.2s (0.55s), held still 2.25s to the end |
| Easing | Sweep to the right edge and back power2.inOut; settle in the middle power3.inOut; settle-in of the frame, chips, mark, wordmark and tagline `cubic-bezier(0.16,1,0.3,1)` (expo.out); cursor approach power3.out, cursor exit power2.in; release `back.out(2)`; scene exit power2.in; Original/Enhanced pill cross-fade power2.out (0.25s) |
| Camera | Locked, flat frame. The only camera-like move is the frame settling from 1.035x to 1x over 0–1.4s, and the whole scene scaling to 0.965x while it fades 7.3–7.9s |
| Subject | Image frame 1560x810px at (180px, 150px), radius 28px. Two SVG layers of one mountain lake at dusk (horizon at y=465px, sun glow at x=400px, far peak near x=1100px, three ridges from seeds 7, 19 and 41, 15 left and 9 right pines from seed 88, 48 ripples from seed 311). The After layer sits on top with `clip-path: inset(0px Rpx 0px 0px)`, where R = 1560 − x, and starts fully clipped (R=1560px). Divider line 6px wide, handle a 112px white circle with two 6px chevrons. Tags 56px high with 30px 600 text: Before top right, After top left. Header 52px high: 48px mark, Prism 34px 700, file name 26px, pill 264x52px. Chips 60px high, 28px 600: Noise −82% and Sky recovered, at left 220px, top 790px and 864px |
| Sync | Divider, clip edge and cursor share one tween time and ease for every leg. The pill flips to Enhanced at 2.35s, the midpoint of the first sweep, when the divider is at x=780px. The After tag shows as the divider passes it. The handle is released at 6.4s, 0.05s after it settles, and the chips come in after the release (6.45s and 6.65s) |
| Style | Paper `#eceef1` (radial `#f6f7f9` to `#e2e5ea`), ink `#0d0f14`, one accent indigo `#5a4df5`; Inter only. After sky `#161447`, `#43308a`, `#a4468f`, `#f0745c`, `#ffb26b` with 24 stars, rim light `#ffc58a` and a vignette; Before sky `#5a5c64` to `#a39b94`, blurred 1.7px, a `#b9b4ae` haze at 0.16 and a 0.75-opacity overlay grain (fractal noise 0.9, 2 octaves, saturation 0.25). Mark is a 150px indigo-gradient rounded square with a white prism and rays, wordmark Prism 150px 700, tagline Every photo, finished. at 48px 500; 0.05 grain and a light vignette |

## Why it works

The divider is one object. The line, the round handle and the clip edge of the After layer all take the same x from tweens with the same duration and ease, and the cursor takes it too, so the thing the eye follows and the thing that changes never drift apart. Both versions are the same drawing with the same geometry, so the only difference between left and right is the grade, and the eye reads that difference as the product's work. The Before is grey, soft and noisy and the After has a saturated sky and sharp ridges, so the first half second of the sweep already shows a result. The sweep crosses the full width first so the viewer sees the whole After once, goes back part way to show the Before again, and settles in the middle, where both halves, both tags and the two result chips are in frame together. The cursor holds the handle for the whole move, which tells the viewer the slider can be dragged. The Original pill flips to Enhanced at the exact midpoint of the first sweep, so the label and the picture change at the same moment. The film has one accent, indigo #5a4df5, used for the After tag, the Enhanced pill, the chip ticks and the mark.

## Prompt

> Build an 11-second, 1920x1080, 30 fps light product film called Grade Slider: a before-and-after comparison slider over one photo, in the style of the standard web comparison widget. The fictional product is Prism, an AI photo editor. Background paper #eceef1 (radial #f6f7f9 to #e2e5ea), ink #0d0f14, one accent indigo #5a4df5, Inter only.
>
> Picture: draw one mountain lake at dusk twice as 1560x810 SVG (markup generated in JS with a seeded mulberry32 PRNG; no external images). Horizon y=465px, sun glow at x=400px, three ridges made by midpoint displacement (seeds 7, 19, 41; the far ridge has a peak near x=1100px, the mid ridge near x=820px), the ridges mirrored and blurred as a lake reflection, 48 horizontal ripple bars, sun streaks, a dark bank plus about 24 pines in the lower corners, clouds blurred 12px, three birds. Both versions use the same geometry. After: sky #161447, #43308a, #a4468f, #f0745c, #ffb26b, 24 stars, a thin rim light #ffc58a on the ridges, a vignette. Before: grey sky #5a5c64 to #a39b94, desaturated ridges and water, the whole drawing blurred 1.7px, a #b9b4ae haze at 0.16 opacity, and an overlay-blended fractal-noise layer (baseFrequency 0.9, 2 octaves, saturation 0.25, opacity 0.75).
>
> Frame: 1560x810px at (180px, 150px), radius 28px, overflow hidden, soft shadow. Before is the base layer; After sits on top with clip-path inset(0px 1560px 0px 0px) in CSS, so the film opens on the Before. Tags 56px high, 30px 600: Before top right (dark translucent), After top left (accent), each inside its own layer. Above the frame a 52px header: a 48px mark, Prism 34px 700, the file name dusk-lake.dng at 26px, and a 264x52px pill reading Original that cross-fades to Enhanced.
>
> Divider: a wrapper at the frame's top-left that GSAP moves in x, holding a 6px white line the full frame height and a 112px white circle handle with two 6px chevrons at mid-height. Every leg tweens three things with the same duration and ease: the divider x, the After layer clip-path inset(0px (1560 − x)px 0px 0px), and the cursor x (tip 16px right of and 20px below the handle centre). The frame settles from 1.035x to 1x over 0–1.4s (expo.out). The divider fades in at 0.35s; the cursor fades in at 0.6s and moves to the handle by 1.4s (power3.out), then presses at 1.45s (cursor scale 0.86, handle 0.92). Legs: 1.55–3.15s to x=1560 (power2.inOut); 3.8–5.1s to x=330 (power2.inOut); 5.35–6.35s to x=780 (power3.inOut). The pill flips to Enhanced at 2.35s over 0.25s. Release at 6.4s (back.out(2)); the cursor drifts 90px right and 80px down and fades 6.6–7.05s.
>
> Chips: two 60px-high white pills with an indigo tick and 28px 600 text, Noise −82% and Sky recovered, at left 220px, top 790px and 864px, rising 18px and fading in over 0.6s (expo.out) at 6.45s and 6.65s. The whole scene scales to 0.965x and fades 7.3–7.9s (power2.in).
>
> Lockup on the cleared paper, from 8.0s: a 150px indigo-gradient rounded-square mark with a white prism and rays (scale 0.82 to 1 over 0.6s), the wordmark Prism (150px, 700, tracking −0.045em, rising 22px from 8.08s over 0.6s) and the tagline Every photo, finished. (48px 500, the last word bold in #4a3fe0, rising 16px from 8.2s over 0.55s), all expo.out and held still to 11s. Add a 0.05 overlay grain and a light vignette.
>
> Constraints: deterministic, one paused GSAP timeline; hidden states in CSS; .to tweens with explicit end values; no CSS transform on GSAP-animated elements; no random, Date or requestAnimationFrame.

## Often confused with

- [Locked-Layout Reskin](https://motionboard.app/r/locked-layout-reskin.md): Locked-Layout Reskin keeps the layout fixed and hard-cuts between colour schemes every 6–10 frames; here one picture is revealed by an eased divider that moves continuously, so both versions stay on screen together.
- [X-Ray Effect](https://motionboard.app/r/x-ray-effect.md): X-ray Dissolve cross-dissolves two versions of a device from one camera position; here a hard vertical edge moves across a single picture and the viewer compares the two grades side by side.

## Source files

Runnable HyperFrames project, 3 files.

- https://motionboard.app/source/before-after/hyperframes.json (318 B)
- https://motionboard.app/source/before-after/index.html (24.4 KB)
- https://motionboard.app/source/before-after/package.json (301 B)

Download all of them:

```sh
curl -fsSL --create-dirs -o "before-after/hyperframes.json" "https://motionboard.app/source/before-after/hyperframes.json"
curl -fsSL --create-dirs -o "before-after/index.html" "https://motionboard.app/source/before-after/index.html"
curl -fsSL --create-dirs -o "before-after/package.json" "https://motionboard.app/source/before-after/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 {
        --paper: #eceef1;
        --ink: #0d0f14;
        --mut: #6a7080;
        --accent: #5a4df5;
        --accent-d: #4a3fe0;
        --font-ui: "Inter", -apple-system, "SF Pro Display", "Helvetica Neue", sans-serif;
      }
      * { margin: 0; padding: 0; box-sizing: border-box; }
      html, body { width: 1920px; height: 1080px; overflow: hidden; background: var(--paper); }
      #root { position: relative; width: 1920px; height: 1080px; overflow: hidden; background: var(--paper); font-family: var(--font-ui); color: var(--ink); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
      .full { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; }

      /* ---------- background ---------- */
      #bg { background: radial-gradient(ellipse 1500px 950px at 50% 42%, #f6f7f9 0%, #eceef1 55%, #e2e5ea 100%); }
      #fx { pointer-events: none; z-index: 5; }
      #fx .vig { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; background: radial-gradient(ellipse 88% 80% at 50% 48%, rgba(30,34,50,0) 58%, rgba(30,34,50,0.11) 100%); }
      #fx .grain { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; opacity: 0.05; mix-blend-mode: overlay; }

      /* ---------- scene ---------- */
      #sw { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 960px 540px; }

      #hdr { position: absolute; left: 180px; top: 54px; width: 1560px; height: 52px; }
      #hl { position: absolute; left: 0; top: 0; height: 52px; display: flex; align-items: center; gap: 16px; }
      #hl svg { width: 48px; height: 48px; display: block; }
      #hl b { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); }
      #hl i { display: block; width: 2px; height: 30px; background: #cfd3db; margin: 0 6px; }
      #hl span { font-size: 26px; font-weight: 500; color: var(--mut); }
      #pill { position: absolute; right: 0; top: 0; width: 264px; height: 52px; border-radius: 26px; background: #ffffff; box-shadow: 0 0 0 1px #d9dce3, 0 6px 18px rgba(20, 24, 40, 0.08); }
      #pill div { position: absolute; left: 0; top: 0; width: 264px; height: 52px; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 26px; font-weight: 600; }
      #pill .s1 { color: var(--mut); }
      #pill .s1 u { display: block; width: 12px; height: 12px; border-radius: 6px; background: #b4b9c4; }
      #pill .s2 { color: var(--accent-d); opacity: 0; }
      #pill .s2 svg { width: 24px; height: 24px; }

      #fw { position: absolute; left: 180px; top: 150px; width: 1560px; height: 810px; transform-origin: 780px 405px; }
      #frame { position: absolute; left: 0; top: 0; width: 1560px; height: 810px; border-radius: 28px; overflow: hidden; background: #8a8a90; box-shadow: 0 0 0 1px rgba(20, 24, 40, 0.1), 0 50px 110px rgba(20, 24, 40, 0.26), 0 12px 30px rgba(20, 24, 40, 0.14); }
      .lay { position: absolute; left: 0; top: 0; width: 1560px; height: 810px; }
      .lay > svg { position: absolute; left: 0; top: 0; display: block; }
      #sb, #sa { position: absolute; left: 0; top: 0; width: 1560px; height: 810px; }
      #sb svg, #sa svg { display: block; }
      #aft { clip-path: inset(0px 1560px 0px 0px); }
      #bnoise { position: absolute; left: 0; top: 0; width: 1560px; height: 810px; opacity: 0.75; mix-blend-mode: overlay; }
      .tag { position: absolute; top: 36px; height: 56px; padding: 0 28px; border-radius: 28px; display: flex; align-items: center; font-size: 30px; font-weight: 600; letter-spacing: -0.01em; color: #ffffff; }
      #tagB { right: 36px; background: rgba(16, 18, 26, 0.66); }
      #tagA { left: 36px; background: var(--accent); box-shadow: 0 8px 22px rgba(90, 77, 245, 0.4); }

      #dv { position: absolute; left: 180px; top: 150px; width: 0; height: 810px; }
      #ln { position: absolute; left: -3px; top: 0; width: 6px; height: 810px; background: #ffffff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 0 26px rgba(0, 0, 0, 0.3); }
      #hd { position: absolute; left: -56px; top: 349px; width: 112px; height: 112px; border-radius: 56px; background: #ffffff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 12px 34px rgba(0, 0, 0, 0.38); }
      #hd svg { position: absolute; left: 0; top: 0; width: 112px; height: 112px; }

      .chip { position: absolute; left: 220px; height: 60px; padding: 0 28px 0 16px; border-radius: 30px; display: flex; align-items: center; gap: 12px; background: rgba(255, 255, 255, 0.95); color: #14161d; font-size: 28px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3); opacity: 0; }
      .chip svg { width: 34px; height: 34px; display: block; flex: none; }
      #chip1 { top: 790px; }
      #chip2 { top: 864px; }

      #cur { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; z-index: 4; }
      #cs { position: absolute; left: -13px; top: -8px; width: 64px; height: 64px; transform-origin: 13px 8px; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3)); }

      /* ---------- lockup ---------- */
      #lk { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 44px; }
      .lrow { display: flex; align-items: center; gap: 38px; }
      #lmk { display: block; width: 150px; height: 150px; opacity: 0; }
      #lmk svg { width: 150px; height: 150px; display: block; filter: drop-shadow(0 14px 26px rgba(74, 63, 224, 0.32)); }
      #wm { display: block; font-size: 150px; line-height: 170px; font-weight: 700; letter-spacing: -0.045em; color: var(--ink); opacity: 0; }
      #tag { font-size: 48px; font-weight: 500; letter-spacing: -0.015em; color: var(--mut); opacity: 0; }
      #tag b { font-weight: 700; color: var(--accent-d); }
    </style>
  </head>
  <body>
    <div id="root" data-composition-id="main" data-start="0" data-duration="11" data-width="1920" data-height="1080">
      <svg width="0" height="0" style="position: absolute" aria-hidden="true">
        <defs>
          <linearGradient id="pg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#7f72ff" /><stop offset="1" stop-color="#4538dc" /></linearGradient>
          <symbol id="i-prism" viewBox="0 0 100 100">
            <rect width="100" height="100" rx="24" fill="url(#pg)" />
            <path d="M50 24 L76 70 L24 70 Z" fill="rgba(255,255,255,0.14)" stroke="#ffffff" stroke-width="5" stroke-linejoin="round" />
            <path d="M8 58 L38 50" stroke="#ffffff" stroke-width="4" stroke-linecap="round" fill="none" />
            <path d="M62 46 L92 32" stroke="#ffffff" stroke-opacity="0.95" stroke-width="4" stroke-linecap="round" fill="none" />
            <path d="M64 54 L93 52" stroke="#ffffff" stroke-opacity="0.7" stroke-width="4" stroke-linecap="round" fill="none" />
            <path d="M62 62 L92 72" stroke="#ffffff" stroke-opacity="0.45" stroke-width="4" stroke-linecap="round" fill="none" />
          </symbol>
        </defs>
      </svg>

      <div id="bg" class="clip full" data-start="0" data-duration="11" data-track-index="0" data-layout-ignore></div>

      <div id="scene" class="clip full" data-start="0" data-duration="8" data-track-index="1" data-layout-allow-overlap>
        <div id="sw" data-layout-allow-overlap>
          <div id="hdr" data-layout-allow-overlap>
            <div id="hl">
              <svg><use href="#i-prism" /></svg><b>Prism</b><i></i><span>dusk-lake.dng</span>
            </div>
            <div id="pill" data-layout-allow-overlap>
              <div class="s1"><u></u>Original</div>
              <div class="s2">
                <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="11" fill="#5a4df5" /><path d="M7 12.5l3.4 3.4L17 9" fill="none" stroke="#ffffff" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" /></svg>Enhanced
              </div>
            </div>
          </div>

          <div id="fw" data-layout-allow-overlap>
            <div id="frame" data-layout-allow-overlap>
              <div id="bef" class="lay" data-layout-allow-overlap>
                <div id="sb"></div>
                <svg id="bnoise" viewBox="0 0 1560 810" preserveAspectRatio="none" data-layout-ignore>
                  <filter id="bnz" x="0" y="0" width="100%" height="100%"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="2" seed="5" /><feColorMatrix type="saturate" values="0.25" /></filter>
                  <rect width="1560" height="810" filter="url(#bnz)" />
                </svg>
                <div class="tag" id="tagB" data-layout-ignore>Before</div>
              </div>
              <div id="aft" class="lay" data-layout-allow-overlap>
                <div id="sa"></div>
                <div class="tag" id="tagA" data-layout-ignore>After</div>
              </div>
            </div>
          </div>

          <div id="dv" data-layout-ignore>
            <div id="ln"></div>
            <div id="hd">
              <svg viewBox="0 0 112 112"><path d="M46 38 L28 56 L46 74" fill="none" stroke="#14161d" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" /><path d="M66 38 L84 56 L66 74" fill="none" stroke="#14161d" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" /></svg>
            </div>
          </div>

          <div class="chip" id="chip1" data-layout-ignore><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="11" fill="#5a4df5" /><path d="M7 12.5l3.4 3.4L17 9" fill="none" stroke="#ffffff" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" /></svg>Noise &minus;82%</div>
          <div class="chip" id="chip2" data-layout-ignore><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="11" fill="#5a4df5" /><path d="M7 12.5l3.4 3.4L17 9" fill="none" stroke="#ffffff" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" /></svg>Sky recovered</div>

          <div id="cur" data-layout-ignore>
            <svg id="cs" viewBox="0 0 24 24"><path d="M5 3l14 7.5-6.2 1.8L10 19z" fill="#111111" stroke="#ffffff" stroke-width="1.6" stroke-linejoin="round" /></svg>
          </div>
        </div>
      </div>

      <div id="lock" class="clip full" data-start="8" data-duration="3" data-track-index="2" data-layout-allow-overlap>
        <div id="lk" data-layout-allow-overlap>
          <div class="lrow" data-layout-allow-overlap>
            <span id="lmk"><svg><use href="#i-prism" /></svg></span>
            <span id="wm">Prism</span>
          </div>
          <div id="tag">Every photo, <b>finished.</b></div>
        </div>
      </div>

      <div id="fx" class="clip full" data-start="0" data-duration="11" data-track-index="5" data-layout-ignore>
        <div class="vig"></div>
        <svg class="grain" viewBox="0 0 1920 1080" preserveAspectRatio="none"><filter id="nz"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="2" seed="7" /><feColorMatrix type="saturate" values="0" /></filter><rect width="1920" height="1080" filter="url(#nz)" /></svg>
      </div>
    </div>

    <script>
      /* ================= the picture, drawn twice: same geometry, flat grade vs graded ================= */
      function mulberry(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;
        };
      }
      const W = 1560, H = 810, HZ = 465;
      const f1 = (n) => n.toFixed(1);
      const poly = (pts) => pts.map((p) => f1(p[0]) + "," + f1(p[1])).join(" ");

      function ridge(seed, amp, rough, lift, bump) {
        const r = mulberry(seed);
        let h = [r(), r()];
        let a = 1;
        for (let i = 0; i < 7; i++) {
          const n = [];
          for (let j = 0; j < h.length - 1; j++) {
            n.push(h[j]);
            n.push((h[j] + h[j + 1]) / 2 + (r() - 0.5) * a);
          }
          n.push(h[h.length - 1]);
          h = n;
          a *= rough;
        }
        if (bump) {
          h = h.map((v, i) => v + bump.a * Math.exp(-Math.pow((i * W / (h.length - 1) - bump.cx) / bump.w, 2)));
        }
        const mn = Math.min.apply(null, h), mx = Math.max.apply(null, h);
        return h.map((v, i) => [i * W / (h.length - 1), HZ - lift - amp * (v - mn) / (mx - mn)]);
      }
      const RF = ridge(7, 210, 0.55, 30, { cx: 1100, w: 260, a: 1.1 });
      const RM = ridge(19, 150, 0.5, 8, { cx: 820, w: 230, a: 0.7 });
      const RN = ridge(41, 80, 0.45, 0, null);

      function pine(x, by, h, w) {
        let d = "";
        for (let k = 0; k < 4; k++) {
          const ty = by - h + k * h * 0.2;
          const bot = ty + h * 0.34;
          const hw = (w * (0.3 + 0.19 * k)) / 2;
          d += "M" + f1(x) + "," + f1(ty) + "L" + f1(x + hw) + "," + f1(bot) + "L" + f1(x - hw) + "," + f1(bot) + "Z";
        }
        d += "M" + f1(x - w * 0.04) + "," + f1(by - h * 0.12) + "h" + f1(w * 0.08) + "v" + f1(h * 0.12) + "h" + f1(-w * 0.08) + "Z";
        return d;
      }
      let pr = mulberry(88);
      let PINES = "";
      for (let i = 0; i < 15; i++) {
        const x = 16 + pr() * 440;
        const by = 650 + (x / 450) * 100 + pr() * 28;
        const h = (190 + pr() * 190) * (1 - x / 1000);
        PINES += pine(x, by, h, h * 0.4);
      }
      for (let i = 0; i < 9; i++) {
        const x = 1340 + pr() * 210;
        const by = 740 + pr() * 40;
        const h = 140 + pr() * 130;
        PINES += pine(x, by, h, h * 0.4);
      }
      const BANKS = "M0,590 L60,600 C200,610 340,650 460,720 C520,755 560,785 600,810 L0,810Z M1560,660 C1480,665 1400,700 1330,760 L1290,810 L1560,810Z";

      let rr = mulberry(311);
      const RIPPLES = [];
      for (let i = 0; i < 48; i++) {
        const y = HZ + 12 + Math.pow(rr(), 1.25) * (H - HZ - 50);
        RIPPLES.push({ x: rr() * W, y: y, l: 50 + rr() * 230, h: 2 + (y - HZ) / 90 + rr() * 2, a: 0.1 + rr() * 0.22 });
      }
      const SUNCOL = [];
      for (let i = 0; i < 16; i++) {
        const y = HZ + 14 + i * 20 + rr() * 8;
        SUNCOL.push({ x: 400 + (rr() - 0.5) * 70, y: y, l: 90 + rr() * 230, h: 3 + i * 0.35, a: 0.3 + rr() * 0.4 });
      }
      const CLOUDS = [[360, 150, 310, 18], [430, 178, 220, 10], [1190, 118, 370, 20], [1260, 150, 260, 10], [800, 262, 430, 14], [300, 305, 270, 12], [1330, 290, 240, 11]];
      const BIRDS = [[640, 168, 1], [706, 204, 0.8], [584, 214, 0.7]];
      let sr = mulberry(55);
      const STARS = [];
      for (let i = 0; i < 24; i++) STARS.push([sr() * W, sr() * 210, 0.8 + sr() * 1.4, 0.35 + sr() * 0.5]);

      const PA = {
        sky: [[0, "#161447"], [0.3, "#43308a"], [0.55, "#a4468f"], [0.78, "#f0745c"], [1, "#ffb26b"]],
        glow: "#ffd89c", glowA: 0.95, farT: "#7a4fa8", farB: "#d8708a", midT: "#3d2f78", midB: "#7b3f84", nearT: "#1c1a45", nearB: "#2e2058",
        pine: "#0b0a22", water: [[0, "#e07a6b"], [0.18, "#8d4a8e"], [0.6, "#35296e"], [1, "#17143f"]],
        ripple: "#ffd9a8", ra: 1, sunStreak: "#ffe6b8", sa: 1, cloud: ["#c58ad8", "#ff9d7a", "#ffc08a"], ca: 0.6, refl: 0.5,
        mist: "#ffc09a", mistA: 0.5, rim: "#ffc58a", bird: "#1a1840"
      };
      const PB = {
        sky: [[0, "#5a5c64"], [0.35, "#6e6e74"], [0.65, "#85817f"], [0.85, "#98918b"], [1, "#a39b94"]],
        glow: "#d9d3c8", glowA: 0.5, farT: "#7b7882", farB: "#9a948f", midT: "#686770", midB: "#7d7a7c", nearT: "#58575e", nearB: "#625f65",
        pine: "#47464b", water: [[0, "#968f8b"], [0.3, "#777479"], [1, "#56555c"]],
        ripple: "#c8c2ba", ra: 0.55, sunStreak: "#cfc9c0", sa: 0.4, cloud: ["#8e8d93", "#928f91", "#979290"], ca: 0.5, refl: 0.4,
        mist: "#b9b4ae", mistA: 0.3, rim: null, bird: "#3f3f45"
      };

      function scene(p, P, A) {
        const stops = (arr) => arr.map((s) => '<stop offset="' + s[0] + '" stop-color="' + s[1] + '"/>').join("");
        const pg = (a, b) => '<stop offset="0" stop-color="' + a + '"/><stop offset="1" stop-color="' + b + '"/>';
        let s = '<svg width="' + W + '" height="' + H + '" viewBox="0 0 ' + W + " " + H + '" xmlns="http://www.w3.org/2000/svg">';
        s += "<defs>";
        s += '<linearGradient id="' + p + 'sky" x1="0" y1="0" x2="0" y2="1">' + stops(P.sky) + "</linearGradient>";
        s += '<linearGradient id="' + p + 'far" x1="0" y1="0" x2="0" y2="1">' + pg(P.farT, P.farB) + "</linearGradient>";
        s += '<linearGradient id="' + p + 'mid" x1="0" y1="0" x2="0" y2="1">' + pg(P.midT, P.midB) + "</linearGradient>";
        s += '<linearGradient id="' + p + 'nr" x1="0" y1="0" x2="0" y2="1">' + pg(P.nearT, P.nearB) + "</linearGradient>";
        s += '<linearGradient id="' + p + 'wat" x1="0" y1="0" x2="0" y2="1">' + stops(P.water) + "</linearGradient>";
        s += '<linearGradient id="' + p + 'mist" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="' + P.mist + '" stop-opacity="0"/><stop offset="0.55" stop-color="' + P.mist + '" stop-opacity="' + P.mistA + '"/><stop offset="1" stop-color="' + P.mist + '" stop-opacity="0"/></linearGradient>';
        s += '<radialGradient id="' + p + 'glow" gradientUnits="userSpaceOnUse" cx="400" cy="' + (HZ - 20) + '" r="580"><stop offset="0" stop-color="' + P.glow + '" stop-opacity="' + P.glowA + '"/><stop offset="0.35" stop-color="' + P.glow + '" stop-opacity="' + P.glowA * 0.45 + '"/><stop offset="1" stop-color="' + P.glow + '" stop-opacity="0"/></radialGradient>';
        s += '<radialGradient id="' + p + 'vig" cx="0.5" cy="0.5" r="0.75"><stop offset="0.6" stop-color="#0a0828" stop-opacity="0"/><stop offset="1" stop-color="#0a0828" stop-opacity="0.45"/></radialGradient>';
        s += '<filter id="' + p + 'cb" x="-20%" y="-60%" width="140%" height="220%"><feGaussianBlur stdDeviation="12"/></filter>';
        s += '<filter id="' + p + 'wb" x="-5%" y="-5%" width="110%" height="110%"><feGaussianBlur stdDeviation="1.5 6"/></filter>';
        if (!A) s += '<filter id="' + p + 'soft" x="-2%" y="-2%" width="104%" height="104%"><feGaussianBlur stdDeviation="1.7"/></filter>';
        s += '<clipPath id="' + p + 'lk"><rect x="0" y="' + HZ + '" width="' + W + '" height="' + (H - HZ) + '"/></clipPath>';
        s += "</defs>";

        s += A ? "<g>" : '<g filter="url(#' + p + 'soft)">';
        s += '<rect width="' + W + '" height="' + (HZ + 6) + '" fill="url(#' + p + 'sky)"/>';
        if (A) STARS.forEach((t) => { s += '<circle cx="' + f1(t[0]) + '" cy="' + f1(t[1]) + '" r="' + f1(t[2]) + '" fill="#ffffff" opacity="' + t[3].toFixed(2) + '"/>'; });
        s += '<rect width="' + W + '" height="' + (HZ + 6) + '" fill="url(#' + p + 'glow)"/>';
        s += '<g filter="url(#' + p + 'cb)">';
        CLOUDS.forEach((c, i) => { s += '<ellipse cx="' + c[0] + '" cy="' + c[1] + '" rx="' + c[2] + '" ry="' + c[3] + '" fill="' + P.cloud[i % P.cloud.length] + '" opacity="' + P.ca + '"/>'; });
        s += "</g>";
        BIRDS.forEach((b) => { s += '<path d="M' + b[0] + "," + b[1] + " q" + 10 * b[2] + "," + -9 * b[2] + " " + 20 * b[2] + ",0 q" + 10 * b[2] + "," + -9 * b[2] + " " + 20 * b[2] + ',0" fill="none" stroke="' + P.bird + '" stroke-width="2.5" stroke-linecap="round" opacity="0.8"/>'; });

        s += '<polygon points="0,' + (HZ + 4) + " " + poly(RF) + " " + W + "," + (HZ + 4) + '" fill="url(#' + p + 'far)"/>';
        if (P.rim) s += '<polyline points="' + poly(RF) + '" fill="none" stroke="' + P.rim + '" stroke-width="2" stroke-linejoin="round" opacity="0.4"/>';
        s += '<rect x="0" y="' + (HZ - 36) + '" width="' + W + '" height="60" fill="url(#' + p + 'mist)"/>';
        s += '<polygon points="0,' + (HZ + 4) + " " + poly(RM) + " " + W + "," + (HZ + 4) + '" fill="url(#' + p + 'mid)"/>';
        if (P.rim) s += '<polyline points="' + poly(RM) + '" fill="none" stroke="' + P.rim + '" stroke-width="2.5" stroke-linejoin="round" opacity="0.55"/>';
        s += '<polygon points="0,' + (HZ + 4) + " " + poly(RN) + " " + W + "," + (HZ + 4) + '" fill="url(#' + p + 'nr)"/>';

        s += '<rect x="0" y="' + HZ + '" width="' + W + '" height="' + (H - HZ) + '" fill="url(#' + p + 'wat)"/>';
        s += '<g clip-path="url(#' + p + 'lk)"><g filter="url(#' + p + 'wb)" opacity="' + P.refl + '"><g transform="translate(0 ' + 2 * HZ + ') scale(1 -1)">';
        s += '<polygon points="0,' + (HZ + 4) + " " + poly(RF) + " " + W + "," + (HZ + 4) + '" fill="url(#' + p + 'far)"/>';
        s += '<polygon points="0,' + (HZ + 4) + " " + poly(RM) + " " + W + "," + (HZ + 4) + '" fill="url(#' + p + 'mid)"/>';
        s += '<polygon points="0,' + (HZ + 4) + " " + poly(RN) + " " + W + "," + (HZ + 4) + '" fill="url(#' + p + 'nr)"/>';
        s += "</g></g></g>";
        RIPPLES.forEach((q) => { s += '<rect x="' + f1(q.x - q.l / 2) + '" y="' + f1(q.y) + '" width="' + f1(q.l) + '" height="' + f1(q.h) + '" rx="' + f1(q.h / 2) + '" fill="' + P.ripple + '" opacity="' + (q.a * P.ra).toFixed(2) + '"/>'; });
        SUNCOL.forEach((q) => { s += '<rect x="' + f1(q.x - q.l / 2) + '" y="' + f1(q.y) + '" width="' + f1(q.l) + '" height="' + f1(q.h) + '" rx="' + f1(q.h / 2) + '" fill="' + P.sunStreak + '" opacity="' + (q.a * P.sa).toFixed(2) + '"/>'; });

        s += '<path d="' + BANKS + '" fill="' + P.pine + '"/>';
        s += '<path d="' + PINES + '" fill="' + P.pine + '"/>';
        if (A) s += '<rect width="' + W + '" height="' + H + '" fill="url(#' + p + 'vig)"/>';
        else s += '<rect width="' + W + '" height="' + H + '" fill="#b9b4ae" opacity="0.16"/>';
        s += "</g></svg>";
        return s;
      }
      document.getElementById("sb").innerHTML = scene("b", PB, false);
      document.getElementById("sa").innerHTML = scene("a", PA, true);

      /* ================= timeline ================= */
      const EXPO = "expo.out";
      const FW = 1560, FL = 180, FT = 150;
      const CX = (x) => FL + x + 16;
      const CY = FT + 405 + 20;

      gsap.set("#dv", { x: 0 });
      gsap.set("#cur", { x: 1500, y: 930 });
      gsap.set("#fw", { scale: 1.035 });
      gsap.set(".chip", { y: 18 });
      gsap.set("#lmk", { scale: 0.82 });
      gsap.set("#wm", { y: 22 });
      gsap.set("#tag", { y: 16 });

      const tl = gsap.timeline({ paused: true });

      /* 0 - 1.4: frame settles in, the flat "before" picture is on screen */
      tl.to("#fw", { scale: 1, duration: 1.4, ease: EXPO }, 0);
      tl.to("#dv", { opacity: 1, duration: 0.4, ease: "power2.out" }, 0.35);

      /* cursor arrives on the handle, presses */
      tl.to("#cur", { opacity: 1, duration: 0.25, ease: "power2.out" }, 0.6);
      tl.to("#cur", { x: CX(0), y: CY, duration: 0.8, ease: "power3.out" }, 0.6);
      tl.to("#cs", { scale: 0.86, duration: 0.08, ease: "power2.out" }, 1.45);
      tl.to("#hd", { scale: 0.92, duration: 0.08, ease: "power2.out" }, 1.45);

      /* divider + reveal + cursor move as one */
      function leg(to, at, dur, ease) {
        tl.to("#dv", { x: to, duration: dur, ease: ease }, at);
        tl.to("#aft", { clipPath: "inset(0px " + (FW - to) + "px 0px 0px)", duration: dur, ease: ease }, at);
        tl.to("#cur", { x: CX(to), duration: dur, ease: ease }, at);
      }
      leg(FW, 1.55, 1.6, "power2.inOut");   /* 1.55 - 3.15: sweep to the right edge, after revealed */
      leg(330, 3.8, 1.3, "power2.inOut");   /* 3.8 - 5.1: back left part way */
      leg(780, 5.35, 1.0, "power3.inOut");  /* 5.35 - 6.35: settles in the middle */

      /* pill flips to Enhanced once the divider has crossed the middle */
      tl.to("#pill .s1", { opacity: 0, duration: 0.25, ease: "power2.out" }, 2.35);
      tl.to("#pill .s2", { opacity: 1, duration: 0.25, ease: "power2.out" }, 2.4);

      /* release, cursor leaves */
      tl.to("#cs", { scale: 1, duration: 0.25, ease: "back.out(2)" }, 6.4);
      tl.to("#hd", { scale: 1, duration: 0.25, ease: "back.out(2)" }, 6.4);
      tl.to("#cur", { x: CX(780) + 90, y: CY + 80, duration: 0.45, ease: "power2.in" }, 6.6);
      tl.to("#cur", { opacity: 0, duration: 0.3, ease: "power2.in" }, 6.75);

      /* what the grade did */
      tl.to("#chip1", { opacity: 1, y: 0, duration: 0.6, ease: EXPO }, 6.45);
      tl.to("#chip2", { opacity: 1, y: 0, duration: 0.6, ease: EXPO }, 6.65);

      /* 7.3 - 7.9: scene leaves */
      tl.to("#sw", { opacity: 0, scale: 0.965, duration: 0.6, ease: "power2.in" }, 7.3);

      /* 8.0 - 8.75: lockup, then still to 11 s */
      tl.to("#lmk", { opacity: 1, scale: 1, duration: 0.6, ease: EXPO }, 8.0);
      tl.to("#wm", { opacity: 1, y: 0, duration: 0.6, ease: EXPO }, 8.08);
      tl.to("#tag", { opacity: 1, y: 0, duration: 0.55, ease: EXPO }, 8.2);

      tl.set({}, {}, 11);

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