# motion-background

Three drop-in motion backgrounds behind real content (CSS gradient mesh, WebGL fbm-noise shader with fallback and capped DPR, seamless video loop) that pause off-screen and in hidden tabs, stop under reduced motion and share one Pause motion control.

- **Space:** web-development-public (https://github.com/Tech-Realm/space-web-development-public/tree/main/motion-background)
- **Level:** L1 (as the registry reports it)
- **Keys it needs (names only):** none
- **Tools:** python3, playwright-python, chromium, ffmpeg (optional)
- **Routes:** static-local; checks: 1
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use web-development-public/motion-background` or MCP `get_pack web-development-public/motion-background`
- **Files:** CHANGELOG.md, code/_shots/shot-1280-rm.png, code/_shots/shot-1280.png, code/_shots/shot-390-rm.png, code/_shots/shot-390.png, code/backgrounds.js, code/index.html, code/media/loop-poster.jpg, code/media/loop.mp4, code/media/loop.webm, code/style.css, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/fixtures/steps.json, outcome/results.json, pack.yaml, refs/refs.yaml, spec/SPEC.md, spec/source.md

## Purpose (spec/SPEC.md)

## Goal
Give a section mood with motion that costs little: no layout jank, no battery drain off-screen, readable text on top, and an off switch. Pick the cheapest variant that achieves the look.

## Steps
1. Choose a variant:
   - CSS mesh (`.mesh`): no JS, transform-only keyframes, blur on the container. Default choice.
   - WebGL shader (`#shader-canvas`): when you need organic flow; renders at 0.75x size with DPR capped at 1.5.
   - Video loop (`[data-bg-video]`): when you have footage (e.g. a NovaMotion background loop, downloaded and re-encoded to WebM + MP4, <= 3 MB).
2. Copy the section markup, the matching CSS block and `backgrounds.js` (each part is independent; delete the parts you do not use).
3. Content sits above the background (`isolation: isolate` on the section, background at `z-index: -1/-2`, scrim for video).
4. Keep the lifecycle: IntersectionObserver marks sections `is-offscreen`; shader rAF and video playback only run while visible, tab visible, and motion is on. The shader always draws one still frame so it never shows blank.
5. Keep the Pause motion control (aria-pressed) when anything moves for more than 5 seconds.
6. Run the outcome checks.

## Edge cases
- No WebGL (old devices, blocked GPU): canvas keeps its CSS gradient (`data-mode="fallback"`).
- Low-end Android: lower the shader scale (0.5) or the fbm octaves (5 -> 3).
- Safari blend modes: `mix-blend-mode: screen` on blurred blobs is fine; avoid `backdrop-filter` stacked on top of the mesh.
- Light themes: drop blob opacity to ~0.45 and use multiply instead of screen.

## Don'ts
- Never animate width/height/top/left or filter values per frame; transform and opacity only.
- No full-DPR shader canvases on 3x phones.
- Do not run more than one heavy background in view at the same time.



---

Canonical URL: https://logicpacks.io/packs/web-development-public/motion-background

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
