# Motion Sandbox: replication prompt

Paste this into Claude Code, Cursor, Replit, Lovable or v0. It rebuilds the sandbox as one self-contained HTML file.

```text
Build a single self-contained index.html called "Motion Sandbox" (inline CSS and vanilla JS, Google Fonts only, no libraries). It is a design tool for trying UI motion on a real app screen and handing developers the code.

LAYOUT
- 52px top bar: brand mark + "Motion Sandbox", breadcrumb "Dispatch / Upgrade flow", a centered Desktop/Mobile segmented toggle, a "Reduced motion" switch and an accent "Play all" button.
- Left: canvas with a dotted backdrop (radial-gradient dots, 18px grid). It holds a device frame that is scaled with a CSS transform to fit the space (compute scale = min(1, availableW / frameW, availableH / frameH) and size a wrapper to the scaled box). Under the canvas, a "Layers" strip with one chip per component plus a zoom percentage.
- Right: 340px inspector, scrollable. Under 1000px wide, stack the inspector below the canvas and fit the frame by width only.

MOCK SCREEN ("Dispatch", a newsletter paid-upgrade flow)
- Top bar (logo, nav, search, avatar), article teaser card (SVG sunset cover, Instrument Serif headline with an italic accent phrase, byline, fading excerpt, lock line), paywall card (label pill, serif title, Monthly/Annual segmented toggle with a sliding pill that changes the price, check list, full-width orange "Upgrade to Pro" button, fine print), dark success toast, and a "Unlocked with Pro" list of 3 perk rows.
- Desktop: 960px browser window frame with traffic lights and a URL pill; two columns (teaser + perks left, paywall + toast right).
- Mobile: 390px screen inside a dark rounded phone bezel with a dynamic island and a status bar; the columns use display: contents so every card reflows into one scrolling column.
- Each selectable component has data-comp="id". Clicking selects the closest one.

SELECTION
- A blue (#3b5bfd) 1.5px outline with four corner handles and a name tag ("Upgrade button 360 x 44") placed inside the scroll content using offsetLeft/offsetTop walking (so transforms do not distort it). A lighter hover outline on other components.

INSPECTOR
- Component name, kind and a reset button.
- Preset chips: Fade up, Scale pop, Slide in, Spring bounce, Blur in, Stagger list (only enabled for the list). Clicking a chip loads that preset's recommended values and plays it.
- Sliders: duration (100-2000ms), delay (0-1200ms), distance (0-120px, relabelled "Blur radius" for Blur in), scale start (0.5-1), overshoot (0-100%), stagger (0-300ms). Irrelevant sliders dim and disable. Filled tracks via a --p custom property.
- Easing select: Ease out (0.16, 1, 0.3, 1), Ease in-out (0.65, 0, 0.35, 1), Spring-like (0.34, 1.56, 0.64, 1), Custom bezier with 4 number inputs (typing switches to Custom). A 112px SVG curve preview with control handles redraws live, and an orange dot travels the curve when the motion plays.
- Play (Space key) replays the selected component; Play all choreographs every component with fixed offsets.
- Dark code panel (#151513) with tabs CSS and JS and "Copy CSS" / "Copy JS" buttons that show a green "Copied" state.

MOTION ENGINE
- One function turns a preset + settings into a keyframe array: { offset, opacity, transform, filter? }. Overshoot adds intermediate keyframes (spring bounce adds three damped ones).
- Preview with element.animate(frames, { duration, delay, fill: 'both' }), putting the easing on every keyframe except the last so it matches CSS animation-timing-function, which also applies per segment.
- Generate CSS (@keyframes + animation shorthand + nth-child delays for stagger + a prefers-reduced-motion fade fallback) and an equivalent Web Animations API snippet from the same array. Highlight with a single-pass regex.
- The Reduced motion switch swaps every preview for a 200ms opacity fade and shows a "Previewing prefers-reduced-motion" pill.

RECORDING MODE
- With ?autoplay=1, run a scripted 17 second tour with a large custom cursor (eased movement on a slight arc, press scale, orange click ripple): select the Upgrade button, pick Scale pop, then Spring bounce, drag the Overshoot slider, press Play, switch to Mobile, press Play all, scroll to the code and press Copy CSS. Set window.DEMO_DURATION = 17 and window.DEMO_DONE = true at the end.

DESIGN TOKENS
- Chrome #F4F3EF, panels white, borders #E3E1DA, ink #151513, muted #77756f, accent #ff5a1f, selection #3b5bfd. Fonts: Geist (UI), Geist Mono (values and code), Instrument Serif (mock headlines). Calm, Figma or Linear-like, but warm. No em dashes in copy.
```

## Adapt it to your own product screen

1. Replace the markup inside `#scrollInner` with your own screen. Keep the `data-comp="id"` attribute on every element you want to be selectable.
2. Add each id to `COMPS` (display name, kind, CSS selector used in the generated code, keyframe name prefix) and to `ORDER`.
3. Give each component a starting motion in `DEFAULTS` and a start time in `CHOREO` so Play all tells your story in the right order (header first, primary action last).
4. If a component has repeating children, set `list: true` and `listSel` to the child container so Stagger list becomes available.
5. Swap colors in `:root` and the mock styles to match your brand. Keep the tool chrome neutral so your product stays the hero.
6. Record a demo: open `index.html?autoplay=1` at 1440 x 900 and capture `window.DEMO_DURATION` seconds. Edit the steps in `tour()` to point the cursor at your own components.

## Hand-off tip

Agree on motion in the sandbox, then paste the copied CSS or JS straight into the ticket. Every snippet already ships with a `prefers-reduced-motion` fallback, so accessibility is part of the spec instead of a follow-up bug.
