# Animations & Scroll Motion

## Animations & Scroll Motion

**Files:** `src/config/config.toml`, section components in `src/layouts/components/sections/`, `src/lib/motion/`, `src/styles/motion.css` · **Skill level:** Beginner for the switches, developer for the attributes

Covena's motion plays as visitors scroll: headings rise word by word from behind a mask, photos wipe open, cards come in one after another, a few steps stay pinned while each one lights up, and on Home 1 the page slides up off the footer. Every pattern is shown at the end of `/components/` on your own copy (run `npm run dev` and open `http://localhost:4321/components/`).

### Turn Motion On Or Off
```toml
# src/config/config.toml
[effects]
  motion       = true   # false: no motion script, every section renders as plain markup
  smoothScroll = false  # true loads Lenis smooth scrolling
```

With `motion = false` the motion script isn't loaded at all, and every section shows in its final state. Smooth scrolling is a separate switch. See [Smooth Scroll](/covena/features/smooth-scroll/).

### How It Behaves
- Reveals play once, when an element is 10% into the window, and take 700 to 900 ms.
- Nothing is hidden at first paint or without JavaScript. Anything on screen when the page loads shows at once.
- Screen readers read the full heading while it is split into words.
- Headings split by line or by word, never by letter, so Arabic stays joined.
- Visitors who ask their system for reduced motion get a still page: everything in its final state, nothing pinned, no parallax, no footer reveal.
- Only `transform`, `opacity`, and `clip-path` animate, so nothing shifts the layout.
- On Arabic pages the motion mirrors, so `data-motion-from="end"` wipes from the left.

### The Motion Attributes
The motion is set with `data-motion` attributes in the section components. The script in `src/lib/motion/` finds them on its own, so there is nothing to import.

| Attribute | Put it on | What happens |
| --- | --- | --- |
| `data-motion="heading"` | an `h1` to `h6` | Each line slides up from behind a mask. `data-motion-split="word"` moves a word at a time (`"line"` is the default) |
| `data-motion="image"` | the frame around an image | The frame wipes open from the bottom while the image settles from a slight zoom. `data-motion-from="end"` wipes from the inline end instead |
| `data-motion="stagger"` | a grid or list | The children rise and fade in one after another |
| `data-motion="parallax"` | an image inside an `overflow-hidden` frame | It moves a little slower than the page. `data-motion-amount` sets how far, from `0` to `0.1` (default `0.08`) |
| `data-motion="pin-steps"` | a wrapper whose first child has `data-motion-stage` | From 768 px wide, the stage stays on screen while each step (`data-motion-step`) lights up in turn. Set the number of steps with `style="--motion-steps: 4"` |
| `data-motion="stack"` | the parent of a set of cards | Each card sticks a little lower than the one before and shrinks slightly as the next covers it. `style="--motion-stack-top: 6rem"` sets where the first card sticks. Give the cards a solid background |
| `data-motion="band"` | a section with its own background | While it fills half the screen, the page background changes to match it. `data-motion-band="dark"` (navy, default) or `"secondary"` (cream) |
| `data-motion="marquee"` | the element around a marquee (`widgets/Marquee.astro`) | Scrolling speeds the marquee up, then it eases back |
| `data-motion-lcp` | the hero, its `h1`, or its main image | Never animated. Use it on the largest thing that loads first |

```astro
<h2 data-motion="heading" data-motion-split="word">{title}</h2>

<div data-motion="image" class="aspect-4/3">
  <OptimizedImage src={image} alt={alt} width={720} height={540} class="h-full w-full object-cover" />
</div>

<div data-motion="stagger" class="grid gap-6 md:grid-cols-3">
  {items.map((item) => <Card {...item} />)}
</div>
```

To stop one pattern on one element, remove its attribute from the component.

### Footer Reveal
On Home 1 the page slides up off the footer, which waits underneath. It is set in the page's frontmatter:

```yaml
# src/content/homepage/english/-index.md
footerReveal: true
```

Set it to `false` to turn it off. It runs from 768 px wide, and only when the footer is shorter than the window.

### Count-Up Numbers
Figures such as "42", "1,800+", and "4.9" count up from zero when they scroll into view, and are written in the page language's format (see [Internationalization](/covena/customization/internationalization/)).

```toml
[settings.animatedNumbers]
  enable   = true   # false shows every figure at its final value
  duration = 1.6    # seconds
```

### Cursor Follower
On desktop, a small ring follows the mouse and grows over links and buttons. It shows only with a fine pointer (a mouse or trackpad), from 1024 px wide, and never for visitors who ask for reduced motion.

```toml
[settings.cursor]
  enable      = true   # false turns it off
  size        = 20     # px
  hoverSize   = 70     # px, over links and buttons
  opacity     = 0.5
  borderWidth = 2
  followRatio = 0.15   # how quickly it catches up, from 0.05 to 0.5
```

An element with `data-cursor="View"` makes the ring grow and show that word. `data-cursor-ignore` keeps the ring plain over an element.

### Keyboard Jumps
```toml
[settings.keyboardScroll]
  enable   = true
  duration = 0.9   # seconds
```

<kbd>⌘</kbd> + <kbd>↑</kbd> / <kbd>↓</kbd> on macOS, or <kbd>Ctrl</kbd> + <kbd>Home</kbd> / <kbd>End</kbd> on Windows, glides to the top or bottom of the page. It works only while smooth scrolling runs (`[effects] smoothScroll = true`). Otherwise the browser's own shortcuts do the same jump without the glide.

### Change The Easing
Every animation uses the `--ease-motion` token in `src/styles/theme.css`:

```css
--ease-motion: cubic-bezier(0.2, 0.7, 0.1, 1);
```

The motion styles themselves are in `src/styles/motion.css`.

<Aside type="note">
  Menus, accordions, and tabs have their own open and close animation, built into
  each component. It is not part of the scroll motion, so it stays when you set
  `motion = false`.
</Aside>

### Do It With AI
```text
In this Covena theme, make the headings in [SECTION COMPONENT FILE] reveal word by word:
add data-motion-split="word" to each element that has data-motion="heading". Don't add
motion to the hero or to anything with data-motion-lcp. Then check the page at /
and at /ar/, and with reduced motion turned on.
```