Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

docs: add the demo page redesign spec and its design sample

matin2fbdc00f8ca2
diff --git a/docs/superpowers/specs/2026-09-25-demo-page-redesign-design.md b/docs/superpowers/specs/2026-09-25-demo-page-redesign-design.md
new file mode 100644
index 00000000..ed1331ed
--- /dev/null
+++ b/docs/superpowers/specs/2026-09-25-demo-page-redesign-design.md
@@ -0,0 +1,260 @@
+# Demo Page Redesign — Design Spec
+
+**Date:** 2026-09-25
+**Scope:** all 129 demo pages, shared site assets, site-wide fonts, the home page intro line, CLAUDE.md
+**Approved design sample:** `samples/demo-page-design.html` (Bounce In)
+
+---
+
+## Overview
+
+The handbook exists so people can *see* each type of web animation and *understand* it. The takeaway is a
+ready-to-copy AI prompt, not implementation code.
+
+Today a demo page shows a one-line summary, a demo that sometimes opens empty, a controls panel with a
+technical note, and "Copy source" / "Source ↗" buttons for the page's code. The explanations (about 81,000
+words across the READMEs) only exist on GitHub.
+
+After this redesign every demo page opens on a large, playing demo with a small column beside it: the title,
+compact settings, a short preview of the prompt with a **Copy prompt** button, and **Read more**. Read more
+reveals the plain-language explanation, the full prompt and related animations. No code appears anywhere on
+the site.
+
+---
+
+## Decisions made with the user
+
+| Topic | Decision |
+|---|---|
+| Where explanations come from | Loaded live from each demo's `README.md` by a shared script. No build step, no duplicated text. |
+| Page layout | The demo is the biggest thing on the first screen; settings, prompt preview and Read more sit beside it. |
+| Code on the site | None. "Copy source" and "Source ↗" are removed. README code sections are never rendered. |
+| Prompt and settings | The copied prompt ends with the demo's current settings, generated from its controls. |
+| Fonts | Schibsted Grotesk everywhere, replacing Bricolage Grotesque and IBM Plex Mono. |
+
+One refinement is proposed here for approval: **the prompt text lives in each `index.html`**, not in the
+README. The prompt is the page's main takeaway, so it should render without a network request, work when the
+page is opened from disk, and be readable by crawlers that don't run JavaScript (the site's `robots.txt`
+invites AI answer engines). The secondary explanation still loads live from the README.
+
+---
+
+## Page anatomy
+
+### First screen — desktop (≥ 1025px)
+
+- **Top bar** (48px, sticky): `← Animation Handbook` on the left; previous and next animation names on the
+ right. No copy or source buttons.
+- **Stage**: fills the viewport below the bar (`100dvh` minus the bar and page padding), about two thirds of
+ the width. A **↻ Replay** button sits in its bottom-right corner when the demo supports replaying.
+- **Side column** (`clamp(300px, 27vw, 370px)`, scrolls internally if needed), top to bottom:
+ 1. Category line, e.g. `02.02 · Entrance & Exit`, in the category's accent colour (written into each page;
+ the numbers match the home page cards)
+ 2. Title (`<h1>`) and the one-line description
+ 3. **Settings** — the demo's own controls, restyled compactly
+ 4. **Prompt** box — three-line preview, the live settings line, **Copy prompt**
+ 5. **Read more about <name> ↓**
+
+### After "Read more"
+
+A details section opens below the first screen and the page scrolls to it (instantly under reduced motion).
+The button becomes **Show less ↑**. Content, in a two-column grid on desktop and one column below 760px:
+
+- Left: **What it is**, **When to use it**, **What the controls do**
+- Right: **Full prompt** (with its own Copy prompt button), **Related animations** (cards)
+- A **↑ Back to the demo** link at the top
+
+Opening the page with `#details` in the URL opens the section directly.
+
+### Tablet (601–1024px) and phone (≤ 600px)
+
+- Tablet keeps the side-by-side layout with a 300px column.
+- Phone stacks: stage first (56% of the small viewport height, at least 320px), then the side column, then the
+ details when opened. The top bar shows `‹` and `›` only. All controls are at least 44×44px.
+
+---
+
+## Where each piece of content comes from
+
+| On the page | Source |
+|---|---|
+| Title, one-line description | The existing `<h1>` and `<p>` in `index.html` (moved into the side column) |
+| Settings | The demo's existing controls in `index.html` (moved into the side column) |
+| Prompt text | New, written into `index.html` inside `<div class="hb-prompt">` |
+| Settings line | Generated live from the controls by the shared script |
+| What it is | README `## What it is` |
+| When to use it | README `## When to use it` |
+| What the controls do | README `## Key parameters` table (Parameter, Default, Effect) |
+| Related animations | README `## See also` links and their descriptions |
+| Not shown on the site | README `## How it works` and `## Production notes` (they stay for GitHub readers) |
+
+Inline code in the rendered README sections is shown as plain text, never as code.
+
+---
+
+## README changes
+
+The six-section structure stays. Two sections get a plain-language pass because they now appear on the site:
+
+- **What it is**: describe the motion in everyday words. Technical detail moves to "How it works". Example —
+ Bounce In's second sentence ("a series of hand-placed `@keyframes` waypoints... one `cubic-bezier` can only
+ overshoot once") becomes "A real bounce isn't one smooth curve: it's a few hand-placed steps, each going a
+ little past the target and coming back."
+- **Key parameters**: the Parameter column uses the same names as the controls on the page, without code
+ (e.g. `Duration (--dur)` becomes `Duration`), and Effect is written in plain words.
+
+---
+
+## Prompts
+
+### Location and markup
+
+```html
+<section class="hb-prompt-box" aria-label="Prompt">
+ <div class="hb-prompt">Add a bounce-in entrance animation to [the element you want to animate]. …</div>
+</section>
+```
+
+There is one copy of the text per page. The shared script clamps the preview to three lines, shows the full
+text in the details section, and adds the settings line, Copy prompt and Read more. Without JavaScript the full
+prompt is simply visible.
+
+### Writing guide (applies to all 129)
+
+- Start with what to build and where: "Add a … animation to [the element you want to animate]". Use square
+ brackets for anything the reader must fill in.
+- Describe what the viewer sees: what moves, where it starts and ends, how it feels (snappy, springy, slow),
+ and what triggers it (page load, scroll, hover, tap, drag).
+- Include the one or two rules that make it look right, taken from the README (e.g. "keep it to one bounce").
+- Say how to keep it smooth in plain words (e.g. "animate only position, scale and opacity").
+- Say what to do when the visitor has reduced motion turned on.
+- For hover or drag effects, include the touch-screen equivalent.
+- Stay tool- and framework-neutral. No code, no library names unless the technique needs one.
+- 60–130 words.
+
+### Settings line
+
+Shown live under the preview as `+ your settings: …` and appended to the copied text as
+`Settings from the demo: Overshoot intensity 60%, Duration 1100ms, Bounces 1× Single, Combine with fade on.`
+
+Built from the controls in the side column:
+
+- Slider rows (`.sr`): the row's label plus its value readout (`.sv`)
+- Segmented groups (`.seg`): the group's label plus the active button's text
+- Toggles (`.tog`) and checkboxes: the label plus `on` / `off`
+- `<select>`: the label plus the selected option's text
+- Ignored: state readouts (`.kv`), action buttons, anything marked `data-hb-skip`
+- A control can override its label with `data-hb-label="overshoot"`
+
+---
+
+## Behaviour
+
+- **Plays on arrival:** demos whose stage is empty until a button is pressed play once about 400ms after load.
+ Confirmed so far: `blur-in`, `bounce-in`, `fade-in-out`, `flip-in`, `scale-in`, `slide-in`,
+ `enter-exit-typography`. To check during rollout: `counter-animation`, `reveal-on-scroll`,
+ `sticky-section`, `glitch-text`. Under reduced motion they show their end state instead.
+- **Replay:** the demo marks its existing play or replay control with `data-hb-replay`; the shared script then
+ shows the stage's ↻ Replay button and clicks that control. Continuous and interaction-driven demos (ambient
+ loops, hover, scroll) show no Replay button.
+- **Settings replay the demo:** where a demo only shows a change after pressing play, changing a setting
+ replays it (about 250ms after the last change), so the effect is visible immediately.
+- **Copy prompt:** copies the prompt plus the settings line; the button shows "Copied ✓" for 1.5s. If the
+ clipboard is unavailable, it selects the prompt text and shows the copy shortcut (Ctrl+C, or ⌘C on a Mac).
+- **Opened from disk (`file://`):** the demo, settings and prompt work. The README cannot be fetched there, so
+ Read more shows a link to `README.md` instead of the rendered sections.
+
+---
+
+## Shared assets (new)
+
+The animation code stays inside each `index.html`. What is shared is the site chrome around it:
+
+- `assets/css/handbook.css` — fonts, colour tokens, top bar, page grid, side column, compact styles for the
+ existing control classes (`.lbl`, `.sr`, `.sv`, `.seg`, `.tog`, `.kv`, `.div`, `.btn-row`, `.act`), prompt
+ box, details section, responsive rules, reduced-motion rules.
+- `assets/js/handbook.js` — README fetch and a small Markdown renderer for the subset the READMEs use
+ (paragraphs, bullet lists, tables, links, bold, inline code as plain text), the settings line, Copy prompt,
+ Read more, Replay, auto-play hook, related cards.
+
+Each demo page:
+
+- adds `<link rel="stylesheet" href="../../../assets/css/handbook.css">` and
+ `<script src="../../../assets/js/handbook.js" defer></script>`
+- replaces its inline `ah-bar` block (styles, markup and copy script) with the new top bar markup
+- moves its `<header>` into the side column and wraps the page in the new layout
+- drops the panel's explanatory `.note` (the README covers it) and any code readouts (6 demos show live code)
+- keeps its controls, state readouts and meaningful action buttons (e.g. Play out) inside **Settings**
+- sets its stage to fill the new stage area (117 demos already size it through `--stage-h`)
+
+---
+
+## Fonts
+
+- **Schibsted Grotesk** (SIL Open Font License), self-hosted as a variable WOFF2 (weights 400–900, Latin and
+ Latin Extended) in `assets/fonts/`. Downloaded from Google Fonts after the user approves the download.
+- Used for the whole home page (wordmark, headings, body, labels, chips, search) and the demo chrome. Stage
+ content that currently inherits Bricolage or Plex Mono inherits Schibsted Grotesk instead.
+- Unchanged: fonts a demo deliberately sets for its own content, such as Georgia, Times New Roman, Segoe UI
+ Variable or Recursive. Five demos use no Bricolage or Plex Mono at all (`scroll-image-sequence`,
+ `glitch-text`, `text-on-path`, `wavy-text`, `morphing-blob`); their stage fonts stay as they are.
+- `brico-*.woff2` and `plex-*.woff2` are deleted from `assets/fonts/` once nothing references them.
+ `samples/fonts/` is left alone.
+
+---
+
+## Home page
+
+- Switch to Schibsted Grotesk.
+- Update the intro line to: "See 129 web animations move, learn when to use each one, and copy a prompt to
+ build it."
+- Nothing else changes on the home page in this project.
+
+---
+
+## Rollout
+
+1. **Foundation:** download the font, build `handbook.css` and `handbook.js`, switch the home page font.
+2. **Pilot — 02 Entrance & Exit (13 demos):** convert the pages, write the 13 prompts, do the README
+ plain-language pass, add auto-play. The user reviews the pilot before anything else changes.
+3. **Remaining categories, one at a time:** 04 Micro-Interactions, 01 Scroll-Based, 03 Page Transitions,
+ 05 Text & Typography, 06 3D & Advanced, 07 Ambient & Background. Each category is verified before the next
+ starts.
+4. **Wrap-up:** update CLAUDE.md (page template, shared assets rule, prompt guide, fonts) and CONTRIBUTING.md,
+ delete the old font files, remove `samples/demo-page-design.html`.
+
+---
+
+## Verification
+
+For every converted demo, in headless Chrome at 1280×800, 768×1024 and 375×812, and again with reduced motion:
+
+- no console errors and no horizontal overflow
+- the stage is the largest element on the first screen
+- every control still changes the animation, and the animation looks and behaves as before
+- the settings line matches the controls, and Copy prompt copies the prompt plus that line
+- Read more shows the four sections, renders no code, and every related link resolves
+- touch targets are at least 44px on the phone size
+
+A site-wide check script confirms that every demo has a prompt, every README has the sections the page needs,
+and every related link points to an existing demo.
+
+---
+
+## Out of scope
+
+- Home page search, filters and the "start here" path
+- Quick jump from any page, favourites, recently viewed
+- A Next link that continues across categories
+- Prompt sentences that rewrite themselves as the sliders move
+
+---
+
+## Risks
+
+- **Bigger stages:** some demos were designed for a 620px stage and may look sparse or mis-scaled when larger.
+ The pilot shows how common this is; the fix is per demo (scale the content or cap the stage).
+- **129 hand edits:** consistency comes from the shared CSS for the common panel classes, the verification
+ script, and converting one category at a time.
+- **Canvas demos without resize handling:** the larger stage is set before they initialise; any that still
+ size wrongly are fixed individually.
diff --git a/samples/demo-page-design.html b/samples/demo-page-design.html
new file mode 100644
index 00000000..5b4d617a
--- /dev/null
+++ b/samples/demo-page-design.html
@@ -0,0 +1,280 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<title>Bounce In — demo page design sample</title>
+<link rel="icon" type="image/svg+xml" href="../favicon.svg">
+<style>
+@font-face{font-family:'Bricolage';src:url('fonts/brico-700.woff2') format('woff2');font-weight:700;font-display:swap}
+@font-face{font-family:'Bricolage';src:url('fonts/brico-800.woff2') format('woff2');font-weight:800;font-display:swap}
+@font-face{font-family:'PlexMono';src:url('fonts/plex-400.woff2') format('woff2');font-weight:400;font-display:swap}
+@font-face{font-family:'PlexMono';src:url('fonts/plex-500.woff2') format('woff2');font-weight:500;font-display:swap}
+:root{
+ --bg:#0b0b0d;--panel:#111114;--panel-2:#0d0d10;--stage:#08080a;
+ --ink:#f4f4f2;--ink-dim:#adadb2;--muted:#77777e;--line:rgba(255,255,255,.085);
+ --accent:#5fd88a;--accent-soft:rgba(95,216,138,.12);
+ --disp:'Bricolage','Arial Narrow',sans-serif;--mono:'PlexMono',ui-monospace,Menlo,Consolas,monospace;
+ --bar:48px;--dur:1100ms;
+}
+*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+html{scroll-behavior:smooth}
+body{background:var(--bg);color:var(--ink);font-family:var(--mono);font-size:13px;-webkit-font-smoothing:antialiased}
+a{color:inherit}
+button{font-family:var(--mono);cursor:pointer}
+:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
+
+.bar{position:sticky;top:0;z-index:10;height:var(--bar);display:flex;align-items:center;justify-content:space-between;
+ padding:0 clamp(6px,1.6vw,16px);background:rgba(11,11,13,.88);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
+ border-bottom:1px solid var(--line);font-size:11px;letter-spacing:.1em;text-transform:uppercase}
+.bar a{color:var(--muted);text-decoration:none;display:inline-flex;align-items:center;gap:6px;min-height:44px;min-width:44px;justify-content:center;padding:0 8px;border-radius:6px}
+.bar a:hover{color:var(--ink)}
+.bar .home{color:var(--ink);font-weight:500}
+.bar nav{display:flex}
+
+.view{display:grid;grid-template-columns:minmax(0,1fr) clamp(300px,27vw,370px);gap:clamp(10px,1.2vw,16px);
+ padding:clamp(10px,1.2vw,16px);height:calc(var(--vh,100dvh) - var(--bar));min-height:560px}
+.stage{position:relative;min-height:0;border:1px solid var(--line);border-radius:10px;background:var(--stage);
+ display:flex;align-items:center;justify-content:center;overflow:hidden}
+.stage::before{content:"";position:absolute;inset:0;pointer-events:none;
+ background-image:radial-gradient(rgba(255,255,255,.05) 1px,transparent 1.4px);background-size:24px 24px}
+.card{position:relative;background:#161b22;border:1px solid #30363d;border-radius:14px;padding:clamp(28px,4vw,48px);
+ text-align:center;max-width:300px;opacity:0;transform:scale(.3) translateY(40px)}
+.card.in{animation:bounce-in var(--dur) ease forwards}
+.card.still{opacity:1;transform:none}
+.card-icon{font-size:36px;margin-bottom:14px}
+.card-title{font-family:var(--disp);font-weight:700;font-size:clamp(18px,2vw,22px);margin-bottom:8px}
+.card-sub{font-size:11px;color:var(--muted);line-height:1.65}
+.replay{position:absolute;right:12px;bottom:12px;min-height:44px;padding:0 16px;border-radius:999px;border:1px solid var(--line);
+ background:rgba(17,17,20,.85);color:var(--ink-dim);font-size:12px;display:inline-flex;align-items:center;gap:8px}
+.replay:hover{color:var(--ink);border-color:rgba(255,255,255,.25)}
+
+.panel{min-height:0;overflow-y:auto;background:var(--panel);border:1px solid var(--line);border-radius:10px;
+ padding:18px;display:flex;flex-direction:column;gap:18px}
+.meta{font-size:10px;letter-spacing:.16em;text-transform:uppercase;color:var(--accent)}
+h1{font-family:var(--disp);font-weight:800;font-size:clamp(28px,2.6vw,36px);letter-spacing:-.02em;line-height:1;margin-top:8px}
+.lede{color:var(--ink-dim);font-size:12.5px;line-height:1.6;margin-top:8px}
+.sec-h{display:flex;justify-content:space-between;align-items:baseline;gap:8px;font-size:10px;letter-spacing:.16em;
+ text-transform:uppercase;color:var(--muted);margin-bottom:8px}
+.sec-h span{letter-spacing:.04em;text-transform:none;font-size:11px}
+.ctl+.ctl{margin-top:6px}
+.ctl-row{display:flex;justify-content:space-between;font-size:12px;color:var(--ink-dim)}
+.ctl-row b{color:var(--ink);font-weight:500}
+input[type=range]{width:100%;accent-color:var(--accent);min-height:30px;cursor:pointer}
+.seg{display:flex;gap:4px;margin-top:6px}
+.seg button{flex:1;min-height:36px;border:1px solid var(--line);border-radius:6px;background:none;color:var(--muted);font-size:12px}
+.seg button.on{border-color:var(--accent);color:var(--accent);background:var(--accent-soft)}
+.switch{display:flex;align-items:center;justify-content:space-between;min-height:40px;margin-top:6px;font-size:12px;color:var(--ink-dim);cursor:pointer}
+.switch input{appearance:none;-webkit-appearance:none;width:36px;height:20px;border-radius:999px;background:#2a2a30;position:relative;cursor:pointer;transition:background .2s}
+.switch input::after{content:"";position:absolute;top:3px;left:3px;width:14px;height:14px;border-radius:50%;background:var(--ink);transition:transform .2s}
+.switch input:checked{background:var(--accent)}
+.switch input:checked::after{transform:translateX(16px);background:#0b0b0d}
+
+.prompt{border:1px solid var(--line);border-radius:8px;padding:12px;background:var(--panel-2)}
+.brief{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;line-height:1.6;font-size:12.5px}
+.set{margin-top:8px;font-size:11px;line-height:1.5;color:var(--accent)}
+.copy{margin-top:10px;width:100%;min-height:44px;border:0;border-radius:6px;background:var(--ink);color:#0b0b0d;font-size:12px;font-weight:500;letter-spacing:.04em}
+.copy:hover{background:#fff}
+.more{width:100%;min-height:44px;border:1px solid var(--line);border-radius:6px;background:none;color:var(--ink-dim);font-size:12px}
+.more:hover{color:var(--ink);border-color:rgba(255,255,255,.25)}
+
+.details{border-top:1px solid var(--line);margin-top:8px}
+.d-in{max-width:1120px;margin:0 auto;padding:clamp(28px,4vw,56px) clamp(16px,3vw,32px) 96px;
+ display:grid;grid-template-columns:minmax(0,1.35fr) minmax(0,1fr);gap:clamp(28px,4vw,64px)}
+.back{grid-column:1/-1;justify-self:start;margin-bottom:calc(-1 * clamp(12px,2.5vw,40px));color:var(--muted);text-decoration:none;font-size:11px;letter-spacing:.1em;text-transform:uppercase;min-height:44px;display:inline-flex;align-items:center}
+.back:hover{color:var(--ink)}
+.d-in h2{font-family:var(--disp);font-weight:700;font-size:20px;letter-spacing:-.01em;margin-bottom:10px}
+.d-in section+section{margin-top:34px}
+.d-in p,.d-in li,.d-in dd{color:var(--ink-dim);line-height:1.75;font-size:13px}
+.d-in ul{list-style:none}
+.d-in li{padding-left:18px;position:relative}
+.d-in li+li{margin-top:4px}
+.d-in li::before{content:"–";position:absolute;left:0;color:var(--accent)}
+dl{display:grid;grid-template-columns:minmax(120px,auto) 1fr;gap:12px 20px}
+dt{color:var(--ink);line-height:1.5}
+dt small{display:block;color:var(--muted);font-size:11px}
+.full{border:1px solid var(--line);border-radius:10px;padding:16px;background:var(--panel)}
+.full p{color:var(--ink);line-height:1.7}
+.rel{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 14px;border:1px solid var(--line);border-radius:8px;text-decoration:none}
+.rel+.rel{margin-top:8px}
+.rel:hover{border-color:rgba(255,255,255,.25)}
+.rel b{font-family:var(--disp);font-weight:700;font-size:16px}
+.rel small{display:block;color:var(--muted);font-size:11.5px;margin-top:2px;line-height:1.5}
+.rel i{font-style:normal;color:var(--muted)}
+
+@media(max-width:1024px){.view{grid-template-columns:minmax(0,1fr) 300px}}
+@media(max-width:760px){.d-in{grid-template-columns:1fr}}
+@media(max-width:600px){
+ .bar .name{display:none}
+ .view{grid-template-columns:1fr;height:auto;min-height:0}
+ .stage{height:calc(var(--vhs,100svh) * .56);min-height:320px}
+ .panel{overflow:visible}
+ input[type=range]{min-height:44px}
+ .seg button{min-height:44px}
+ .switch{min-height:44px}
+}
+@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}.card.in{animation:none;opacity:1;transform:none}}
+</style>
+<style id="kf"></style>
+</head>
+<body>
+<div class="bar">
+ <a class="home" href="../">← <span>Animation Handbook</span></a>
+ <nav aria-label="Other animations">
+ <a href="../animations/02-entrance-and-exit/flip-in/" rel="prev" aria-label="Previous: Flip In">‹ <span class="name">Flip In</span></a>
+ <a href="../animations/02-entrance-and-exit/rotate-in/" rel="next" aria-label="Next: Rotate In"><span class="name">Rotate In</span> ›</a>
+ </nav>
+</div>
+
+<main class="view">
+ <div class="stage">
+ <div class="card" id="card">
+ <div class="card-icon">◈</div>
+ <div class="card-title">Bounce Landing</div>
+ <div class="card-sub">Overshoots, dips, then settles, like something landing with momentum.</div>
+ </div>
+ <button class="replay" id="replay" type="button">↻ Replay</button>
+ </div>
+
+ <aside class="panel">
+ <div>
+ <div class="meta">02.02 · Entrance &amp; Exit</div>
+ <h1>Bounce In</h1>
+ <p class="lede">Overshoots its final size and position, then springs back to rest.</p>
+ </div>
+
+ <section aria-label="Settings">
+ <div class="sec-h">Settings</div>
+ <div class="ctl"><div class="ctl-row"><label for="ov">Overshoot</label><b id="ov-v">60%</b></div><input type="range" id="ov" min="0" max="100" step="5" value="60"></div>
+ <div class="ctl"><div class="ctl-row"><label for="du">Duration</label><b id="du-v">1100 ms</b></div><input type="range" id="du" min="300" max="2000" step="100" value="1100"></div>
+ <div class="ctl"><div class="ctl-row"><span id="bo-l">Bounces</span></div>
+ <div class="seg" role="group" aria-labelledby="bo-l"><button type="button" data-b="1" class="on">1</button><button type="button" data-b="2">2</button><button type="button" data-b="3">3</button></div></div>
+ <label class="switch">Fade in while bouncing<input type="checkbox" id="fa" checked></label>
+ </section>
+
+ <section class="prompt" aria-label="Prompt">
+ <div class="sec-h">Prompt <span>paste into any AI tool</span></div>
+ <p class="brief" id="brief"></p>
+ <p class="set" id="set"></p>
+ <button class="copy" type="button" data-copy>Copy prompt</button>
+ </section>
+
+ <button class="more" id="more" type="button" aria-expanded="false" aria-controls="details">Read more about Bounce In ↓</button>
+ </aside>
+</main>
+
+<div class="details" id="details" hidden>
+ <div class="d-in">
+ <a class="back" href="#top" id="back">↑ Back to the demo</a>
+ <div>
+ <section>
+ <h2>What it is</h2>
+ <p>Bounce In brings an element up from small and low, overshoots its final size and position, then springs back to rest, like something landing with momentum. A real bounce isn't one smooth curve: it's a few hand-placed steps, each going a little past the target and coming back.</p>
+ </section>
+ <section>
+ <h2>When to use it</h2>
+ <ul>
+ <li>Playful confirmations: a success badge, a "message sent" check, an added-to-cart chip</li>
+ <li>Toasts, tooltips and popovers where a little life makes the appearance feel responsive</li>
+ <li>Game UI, kids' products and brands whose tone welcomes personality</li>
+ <li>Any single element small enough that an energetic entrance won't feel heavy</li>
+ </ul>
+ </section>
+ <section>
+ <h2>What the controls do</h2>
+ <dl>
+ <dt>Overshoot<small>default 60%</small></dt><dd>How far past full size it grows. 0% means no bounce, 100% is exaggerated.</dd>
+ <dt>Duration<small>default 1100 ms</small></dt><dd>Bounces need room to breathe. Too short and the spring reads as a jitter.</dd>
+ <dt>Bounces<small>default 1</small></dt><dd>How many times it overshoots. Almost always one; more looks cartoonish.</dd>
+ <dt>Fade in<small>default on</small></dt><dd>Whether it fades in while it bounces, or is visible from the start.</dd>
+ </dl>
+ </section>
+ </div>
+ <div>
+ <section>
+ <h2>Full prompt</h2>
+ <div class="full">
+ <p id="full"></p>
+ <p class="set" id="set2"></p>
+ <button class="copy" type="button" data-copy>Copy prompt</button>
+ </div>
+ </section>
+ <section>
+ <h2>Related animations</h2>
+ <a class="rel" href="../animations/02-entrance-and-exit/scale-in/"><span><b>Scale In</b><small>The same entrance without the overshoot</small></span><i>→</i></a>
+ <a class="rel" href="../animations/02-entrance-and-exit/rotate-in/"><span><b>Rotate In</b><small>A springy ease with a spin, good for icons</small></span><i>→</i></a>
+ <a class="rel" href="../animations/02-entrance-and-exit/slide-in/"><span><b>Slide In</b><small>Enters from the side and also suits a spring</small></span><i>→</i></a>
+ </section>
+ </div>
+ </div>
+</div>
+
+<script>
+const PROMPT = 'Add a bounce-in entrance animation to [the element you want to animate]. When it appears, it should start small and a little below its final spot, grow slightly past full size, dip just under it, then settle, as if it landed with a small spring. Fade it in at the same time. Keep it to one bounce, because more than that looks cartoonish. Animate only transform and opacity so it stays smooth. If the visitor has reduced motion turned on, show the element without the bounce.';
+const $ = id => document.getElementById(id);
+const card = $('card'), ov = $('ov'), du = $('du'), fa = $('fa');
+const reduce = matchMedia('(prefers-reduced-motion: reduce)');
+let bounces = 1, timer;
+
+function settings(sep, nbsp) {
+ const s = ['overshoot ' + ov.value + '%', 'duration ' + du.value + ' ms', bounces + (bounces > 1 ? ' bounces' : ' bounce'), 'fade ' + (fa.checked ? 'on' : 'off')];
+ return (nbsp ? s.map(x => x.replace(/ /g, ' ')) : s).join(sep);
+}
+function buildKeyframes() {
+ const t = ov.value / 100, stops = { 1: [55, 80], 2: [45, 65, 80, 90], 3: [40, 57, 70, 80, 88, 94] }[bounces];
+ const over = [.15, .06, .025], under = [.07, .03, .012], upY = [-8, -4, -2], downY = [3, 1.5, .8];
+ let k = '@keyframes bounce-in{0%{opacity:' + (fa.checked ? 0 : 1) + ';transform:scale(.3) translateY(40px)}';
+ stops.forEach((p, i) => {
+ const n = i >> 1, up = i % 2 === 0;
+ const s = up ? 1 + t * over[n] : 1 - t * under[n], y = (up ? upY[n] : downY[n]) * t;
+ k += p + '%{' + (i === 0 ? 'opacity:1;' : '') + 'transform:scale(' + s.toFixed(3) + ') translateY(' + y.toFixed(1) + 'px)}';
+ });
+ $('kf').textContent = k + '100%{opacity:1;transform:scale(1) translateY(0)}}';
+ document.documentElement.style.setProperty('--dur', du.value + 'ms');
+}
+function play() {
+ if (reduce.matches) { card.classList.add('still'); return; }
+ card.classList.remove('in', 'still'); void card.offsetWidth; card.classList.add('in');
+}
+function update(replay) {
+ $('ov-v').textContent = ov.value + '%';
+ $('du-v').textContent = du.value + ' ms';
+ $('set').textContent = $('set2').textContent = '+ your settings: ' + settings(' · ', true);
+ buildKeyframes();
+ if (replay) { clearTimeout(timer); timer = setTimeout(play, 250); }
+}
+[ov, du, fa].forEach(el => el.addEventListener('input', () => update(true)));
+document.querySelectorAll('.seg button').forEach(b => b.addEventListener('click', () => {
+ document.querySelectorAll('.seg button').forEach(x => x.classList.toggle('on', x === b));
+ bounces = +b.dataset.b; update(true);
+}));
+$('replay').addEventListener('click', play);
+
+$('brief').textContent = $('full').textContent = PROMPT;
+document.querySelectorAll('[data-copy]').forEach(btn => btn.addEventListener('click', () => {
+ const text = PROMPT + '\n\nSettings from the demo: ' + settings(', ') + '.';
+ const done = ok => { btn.textContent = ok ? 'Copied ✓' : 'Copy failed'; setTimeout(() => btn.textContent = 'Copy prompt', 1500); };
+ navigator.clipboard.writeText(text).then(() => done(true), () => done(false));
+}));
+
+const more = $('more'), details = $('details');
+function openDetails(open, scroll) {
+ details.hidden = !open;
+ more.setAttribute('aria-expanded', String(open));
+ more.textContent = open ? 'Show less ↑' : 'Read more about Bounce In ↓';
+ if (open && scroll) details.scrollIntoView({ block: 'start', behavior: scroll });
+}
+more.addEventListener('click', () => openDetails(details.hidden, reduce.matches ? 'instant' : 'smooth'));
+$('back').addEventListener('click', e => { e.preventDefault(); scrollTo({ top: 0 }); });
+
+update(false);
+if (location.hash === '#details') setTimeout(() => openDetails(true, 'instant'), 300);
+// Screenshot helpers for this design sample: ?frame=860 pins the viewport height, ?open shows the details without scrolling.
+const q = new URLSearchParams(location.search);
+if (q.has('frame')) ['--vh', '--vhs'].forEach(v => document.documentElement.style.setProperty(v, q.get('frame') + 'px'));
+if (q.has('open')) openDetails(true, false);
+if (q.has('still')) card.classList.add('still');
+setTimeout(play, 450);
+</script>
+</body>
+</html>