---
name: motion
description: Add or review animation on the ai-for-dummies site — transitions, state changes, view transitions. Use when any element moves, fades, or transforms, or when auditing existing motion for performance and reduced-motion support.
---

# Motion

This is an editorial-print design. Motion is punctuation. Read
[`../../rules/animation.md`](../../rules/animation.md) — it is binding; this is
the procedure.

## Decide it should move

Answer out loud: **what does this motion tell the user that the static state
does not?** Valid answers: something changed, attention needs directing to what
changed, a layout shift needs smoothing. "It feels more polished" is not an
answer — on this design it reads as generic.

If there is no answer, ship it static. That is a legitimate, common outcome.

## Build it

```css
.panel {
  transition: opacity 180ms cubic-bezier(.2,0,0,1),
              transform 180ms cubic-bezier(.2,0,0,1);
}
.panel[data-state='entering'] { opacity: 0; transform: translateY(6px); }
```

- **`transform` and `opacity` only.** Animating `width`/`height`/`top`/`left`
  forces layout every frame and shows up as a failed INP (budget: 200ms).
- 150–250ms for UI feedback; up to 400ms for a page transition.
- One thing moves at a time. No staggered card cascades.
- `will-change` only immediately before animating, removed after.
- No animation library. This site's thesis is having no runtime dependencies.

## Reduced motion is not optional

```css
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
      transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
```

Then **test it**: DevTools → Rendering → Emulate `prefers-reduced-motion:
reduce`. The end state must still be correct and the UI still usable. Reduced,
not broken.

## Page transitions

Astro's `<ClientRouter />` is the only sanctioned motion dependency. Before
enabling it, verify:

- JS disabled → full navigation still works
- browser back/forward still works
- the review desk's query-param deep links survive
- `prefers-reduced-motion` is honoured

## Audit an existing animation

```bash
grep -rn "transition\|animation\|@keyframes\|transform" src/ --include="*.astro" --include="*.css"
```

For each hit ask: does it animate a layout property? does it respect reduced
motion? is there a stated purpose? Three questions, three possible fixes.
