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.

feat(ambient): complete category 7 + finalize atlas

matin8cea3ad3767b
diff --git a/animations/07-ambient-background/README.md b/animations/07-ambient-background/README.md
new file mode 100644
index 00000000..9d61c272
--- /dev/null
+++ b/animations/07-ambient-background/README.md
@@ -0,0 +1,44 @@
+# 07 — Ambient & Background
+
+Passive, looping effects that hold visual interest without demanding attention. Ambient animations run continuously, cycle slowly, and look intentional after two minutes of watching.
+
+## Animations
+
+| Demo | Description |
+|------|-------------|
+| [Animated Gradient Background](animated-gradient-background/) | CSS gradient shifts hue and position — pure CSS, no JS, seamless loop |
+| [Mesh Gradient](mesh-gradient/) | Blurred radial gradient blobs drift slowly — the Stripe aesthetic |
+| [Aurora / Northern Lights](aurora/) | Tall color bands drift and skew — heavy blur fakes the curtain of light |
+| [Grain / Film Noise Overlay](grain-overlay/) | Animated noise at 5–10% opacity adds cinematic warmth |
+| [Scanline](scanline/) | CRT horizontal lines + optional sweep beam and phosphor glow |
+| [Light Leak](light-leak/) | Warm gradient fires at random irregular intervals — analog film aesthetic |
+| [Starfield](starfield/) | Stars drift outward from center with parallax depth — slow ambient speed |
+| [Breathing Glow](breathing-glow/) | Radial glow expands/contracts on a 5s breath cycle — calm resting state |
+| [Ambient Ripple](ambient-ripple/) | Concentric rings emit periodically from sources — passive, not click-driven |
+| [Floating Elements](floating-elements/) | Geometric shapes drift on independent sine-wave paths — SaaS hero pattern |
+| [Grid / Dot Pattern Parallax](grid-dot-pattern-parallax/) | Pattern shifts subtly opposite to mouse — depth felt, not seen |
+| [Abstract Geometric Motion](abstract-geometric-motion/) | Four hypnotic loops — polygons, rings, bars, flowing lines |
+
+## The ambient mindset
+
+**Passive**: runs continuously without user triggers. No events, no clicks, no narrative beats.
+
+**Long cycles**: 15–30 second loops are normal here. Below 8 seconds, the motion becomes distracting. Above 30 seconds, it's nearly imperceptible. 20 seconds is the sweet spot.
+
+**Intentional after 2 minutes**: unlike micro-interactions (brief and punchy), ambient effects must remain visually satisfying after extended watching. If you'd want to skip it after 30 seconds, it's too event-driven.
+
+**Seamless loops**: no visible reset point. The loop should be impossible to identify without external timing.
+
+**Subtlety is the technique**: grain at 8% opacity, parallax at 5% strength, glow at 0.6 opacity. Ambient effects work by being just barely perceptible — the user feels depth and life without being able to point to the source.
+
+## Implementation summary
+
+| Approach | Used by |
+|----------|---------|
+| Pure CSS keyframes | Animated gradient, mesh gradient, aurora, breathing glow, scanline |
+| CSS + JS (controls) | Light leak (random timing), grid parallax (mousemove) |
+| Canvas 2D | Grain, starfield, ambient ripple, floating elements, abstract geometric |
+
+## See also
+- [06 — 3D & Advanced](../06-3d-advanced/) — GPU-intensive effects; WebGL shaders and particles
+- [04 — Micro-Interactions](../04-micro-interactions/) — the opposite end: brief, triggered, reactive
diff --git a/animations/07-ambient-background/abstract-geometric-motion/README.md b/animations/07-ambient-background/abstract-geometric-motion/README.md
new file mode 100644
index 00000000..2be2c39b
--- /dev/null
+++ b/animations/07-ambient-background/abstract-geometric-motion/README.md
@@ -0,0 +1,83 @@
+# Abstract Geometric Motion
+
+## What it is
+Abstract geometric motion is a continuous, looping animation of pure geometric forms — rotating polygons, expanding rings, sliding bars, flowing lines — that exists purely to be watched. There is no narrative, no story, no user interaction required. The design intent is the same as a screensaver, a music visualizer, or an abstract painting: visually satisfying, optionally hypnotic, never demanding. Watch for 30 seconds and the mind quiets.
+
+## When to use it
+- "Now playing" and music player backgrounds where the visual should pulse with the content
+- Focus and meditation app backgrounds where motion guides attention inward
+- Digital art installations and kiosk displays where the screen must never show a static image
+- Empty states and loading screens where the environment should feel designed, not blank
+
+## How it works
+All four presets run on a shared `requestAnimationFrame` loop with a global time counter `t`. Each preset renders to a `<canvas>` element.
+
+**Rotating polygons** — regular polygons with increasing vertex counts, each rotating at a slightly different rate:
+
+```js
+function drawPolygons(t) {
+ for (let i = 0; i < complexity; i++) {
+ const sides = 3 + (i % 5); // 3 to 7 sides
+ const radius = 30 + i * 20;
+ const rotation = t * (0.2 + i * 0.08) + (i % 2 === 0 ? 0 : Math.PI);
+
+ ctx.beginPath();
+ for (let j = 0; j <= sides; j++) {
+ const a = j / sides * Math.PI * 2 + rotation;
+ ctx.lineTo(cx + Math.cos(a) * radius, cy + Math.sin(a) * radius);
+ }
+ ctx.strokeStyle = palette(i, 0.5 + 0.3 * Math.sin(t * 0.5 + i));
+ ctx.lineWidth = 0.8;
+ ctx.stroke();
+ }
+}
+```
+
+**Concentric expanding rings** — rings spawn from center, expand outward, and fade:
+
+```js
+// Spawn a new ring periodically
+if (Math.random() < 0.3) rings.push({ r: 0, color: randomColor() });
+
+// Update and draw each ring
+rings.forEach(ring => {
+ ring.r += speed;
+ const life = 1 - ring.r / Math.max(W, H);
+ ctx.strokeStyle = `rgba(..., ${life * 0.6})`;
+ ctx.arc(cx, cy, ring.r, 0, Math.PI * 2);
+ ctx.stroke();
+});
+rings = rings.filter(r => r.r < Math.max(W, H));
+```
+
+**Color-flow lines** — sine-wave curves with animated `lineDashOffset` so colors appear to travel along the path:
+
+```js
+ctx.setLineDash([40, 60]);
+ctx.lineDashOffset = -t * 30 * speed + i * 20; // advances per frame
+ctx.strokeStyle = palette(i, opacity);
+ctx.beginPath();
+// ... draw sine wave path ...
+ctx.stroke();
+ctx.setLineDash([]);
+```
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Speed | 0.6 | Lower = meditative; higher = energetic. Keep below 1.0 for ambient. |
+| Complexity | 6 | Number of shapes/lines. More = busier; fewer = minimal. |
+| Palette | Cool | Color family. All presets respect the same palette variable. |
+
+## Production notes
+- **Canvas vs SVG vs CSS**: canvas is ideal for complex animated geometry that changes every frame. SVG SMIL animation works for a few elements but becomes expensive with many independently animated paths. CSS is impractical for runtime-generated geometry.
+- **`t += speed * 0.01` not `Date.now()`**: relative time increments (adding to a counter) are frame-rate-independent in spirit and easier to control than absolute timestamps. For truly frame-rate-independent motion, multiply by the actual frame delta.
+- **Infinite seamless looping**: none of the presets use `%` modulo or restart conditions — they simply accumulate `t` continuously. This guarantees the loop is truly seamless; there is no "restart" moment.
+- **`lineDashOffset` for color flow**: animating `lineDashOffset` is a classic SVG/canvas trick for drawing paths that appear to have flowing color or motion along their length. The dash pattern stays fixed in the path's local coordinate space; the offset moves the starting point.
+- **Music visualizer pairing**: replace the time-based `t` with audio frequency data from the Web Audio API's `AnalyserNode`. The shapes then pulse and change size in response to the audio spectrum.
+- **Three.js equivalent**: `LineSegments`, `MeshLine`, and custom `ShaderMaterial` can recreate all four presets in a 3D context with camera movement adding the third dimension.
+
+## See also
+- [Ambient Ripple](../ambient-ripple/) — the "rings" preset abstracted as a standalone ambient effect
+- [WebGL Shader Animation](../../06-3d-advanced/webgl-shader-animation/) — GPU-powered shader patterns; more complex but higher visual ceiling
+- [Noise-Based Motion](../../06-3d-advanced/noise-based-motion/) — organic, non-geometric motion using Perlin/Simplex noise
diff --git a/animations/07-ambient-background/abstract-geometric-motion/index.html b/animations/07-ambient-background/abstract-geometric-motion/index.html
new file mode 100644
index 00000000..34593cbc
--- /dev/null
+++ b/animations/07-ambient-background/abstract-geometric-motion/index.html
@@ -0,0 +1,194 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Abstract Geometric Motion</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative}
+ canvas{display:block;width:100%;height:100%}
+ .preset-tabs{position:absolute;top:8px;left:8px;display:flex;gap:4px;z-index:5}
+ .ptab{background:rgba(13,17,23,.8);border:1px solid var(--ui-border);color:var(--ui-muted);font-family:monospace;font-size:9px;padding:5px 10px;border-radius:4px;cursor:pointer;min-height:36px;letter-spacing:.5px}
+ .ptab.active{border-color:var(--ui-accent);color:var(--ui-accent)}
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:40px;text-align:right;color:var(--ui-text)}
+ select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
+ @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:420px}}
+ @media(prefers-reduced-motion:reduce){canvas{display:none}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Abstract Geometric Motion</h1>
+ <p>Four hypnotic loops — polygons, rings, bars, color lines. Satisfying to watch, never demanding.</p>
+</header>
+<div class="layout">
+ <div class="stage" id="stage">
+ <canvas id="cvs"></canvas>
+ <div class="preset-tabs" id="tabs">
+ <button class="ptab active" data-idx="0">Polygons</button>
+ <button class="ptab" data-idx="1">Rings</button>
+ <button class="ptab" data-idx="2">Bars</button>
+ <button class="ptab" data-idx="3">Lines</button>
+ </div>
+ </div>
+ <aside>
+ <p class="note">Abstract geometric motion is the descendant of screensaver art. Visually satisfying, never demanding interaction. Watch for 30 seconds — the mind quiets.</p>
+ <div class="lbl">Speed</div>
+ <div class="sr"><input type="range" id="spd-sl" min="1" max="20" value="6" step="1"><span class="sv" id="spd-v">0.6</span></div>
+ <div class="lbl">Complexity</div>
+ <div class="sr"><input type="range" id="cx-sl" min="2" max="12" value="6" step="1"><span class="sv" id="cx-v">6</span></div>
+ <div class="lbl">Palette</div>
+ <select id="pal-sel">
+ <option value="cool" selected>Cool blue</option>
+ <option value="warm">Warm amber</option>
+ <option value="neon">Neon</option>
+ <option value="mono">Monochrome</option>
+ </select>
+ <div class="lbl">Background</div>
+ <select id="bg-sel">
+ <option value="#020408" selected>Near black</option>
+ <option value="#060a10">Dark blue</option>
+ <option value="#080510">Dark purple</option>
+ </select>
+ <label class="tog"><input type="checkbox" id="contrast-tog"><span>High contrast</span></label>
+ <div class="div"></div>
+ <button class="rst" id="pause-btn">⏸ Pause</button>
+ </aside>
+</div>
+<script>
+const cvs=document.getElementById('cvs'),ctx=cvs.getContext('2d');
+const stage=document.getElementById('stage');
+let W,H,paused=false,raf=null,lastT=0,t=0;
+let PRESET=0,SPD=0.6,CX=6,PAL='cool',BG='#020408',CONTRAST=false;
+
+function resize(){W=cvs.width=stage.clientWidth;H=cvs.height=stage.clientHeight;}
+resize();window.addEventListener('resize',resize);
+
+const PALETTES={
+ cool:c=>`hsla(${200+c*10},70%,65%,`,
+ warm:c=>`hsla(${30+c*8},80%,60%,`,
+ neon:c=>`hsla(${(c*60)%360},100%,65%,`,
+ mono:c=>`hsla(0,0%,${60+c*5}%,`
+};
+
+function col(c,a){return PALETTES[PAL](c)+a+')';}
+function lineW(){return CONTRAST?1.5:.8;}
+
+// PRESET 0: Rotating polygons
+function drawPolygons(){
+ const cx=W/2,cy=H/2;
+ for(let i=0;i<CX;i++){
+ const n=3+i%5; // 3 to 7 sides
+ const r=30+i*20;
+ const rot=t*(0.2+i*.08)+(i%2===0?0:Math.PI);
+ ctx.beginPath();
+ for(let j=0;j<=n;j++){const a=j/n*Math.PI*2+rot;ctx.lineTo(cx+Math.cos(a)*r,cy+Math.sin(a)*r);}
+ ctx.strokeStyle=col(i,.5+Math.sin(t*.5+i)*.3);
+ ctx.lineWidth=lineW()*(1+i*.1);ctx.stroke();
+ }
+}
+
+// PRESET 1: Concentric expanding rings
+let rings2=[];
+function updateRings(){
+ if(t-Math.floor(t)<.02&&Math.floor(t)%1===0&&Math.random()<.3)rings2.push({r:0,born:t,c:Math.floor(Math.random()*CX)});
+ rings2=rings2.filter(r=>r.r<Math.max(W,H));
+ rings2.forEach(r=>{r.r+=SPD*2;});
+}
+function drawRings(){
+ const cx=W/2,cy=H/2;
+ rings2.forEach(r=>{
+ const life=1-r.r/Math.max(W,H);
+ ctx.beginPath();ctx.arc(cx,cy,r.r,0,Math.PI*2);
+ ctx.strokeStyle=col(r.c,life*.6);ctx.lineWidth=lineW()*(1+life);ctx.stroke();
+ });
+}
+
+// PRESET 2: Sliding bars
+function drawBars(){
+ const count=CX;
+ for(let i=0;i<count;i++){
+ const x=(t*SPD*40+i*(W/count)*1.1)%W;
+ const barW=W/count*.5;
+ const op=.15+.1*Math.sin(t+i*.7);
+ ctx.fillStyle=col(i,op);
+ // Diagonal slant
+ ctx.save();ctx.translate(x,0);
+ ctx.beginPath();
+ ctx.moveTo(-barW*.2,0);ctx.lineTo(barW*.8,0);ctx.lineTo(barW*.6,H);ctx.lineTo(-barW*.4,H);ctx.closePath();
+ ctx.fill();ctx.restore();
+ }
+}
+
+// PRESET 3: Color-flow lines
+function drawLines(){
+ const count=CX*2;
+ for(let i=0;i<count;i++){
+ const y=H*(i+.5)/count;
+ const amp=15+i*3;
+ const phase=i*.4+t*.8;
+ ctx.beginPath();
+ for(let x=0;x<=W;x+=4){
+ const py=y+Math.sin(x/80+phase)*amp+Math.cos(x/120+phase*.7)*amp*.5;
+ x===0?ctx.moveTo(x,py):ctx.lineTo(x,py);
+ }
+ // Animated dash offset for color flow effect
+ const dashLen=40,gapLen=60;
+ ctx.setLineDash([dashLen,gapLen]);
+ ctx.lineDashOffset=-t*30*SPD+i*20;
+ ctx.strokeStyle=col(i%CX,.6+Math.sin(t+i)*.3);
+ ctx.lineWidth=lineW()*(1.5-i*.03);ctx.stroke();
+ ctx.setLineDash([]);
+ }
+}
+
+function loop(ts){
+ if(paused){raf=null;return;}
+ raf=requestAnimationFrame(loop);
+ const dt=ts-lastT;if(dt<16)return;lastT=ts;
+ t+=SPD*.01;
+ ctx.fillStyle=BG;ctx.fillRect(0,0,W,H);
+ if(PRESET===0)drawPolygons();
+ else if(PRESET===1){updateRings();drawRings();}
+ else if(PRESET===2)drawBars();
+ else drawLines();
+}
+
+raf=requestAnimationFrame(loop);
+
+document.querySelectorAll('.ptab').forEach(b=>{
+ b.addEventListener('click',()=>{
+ PRESET=+b.dataset.idx;
+ document.querySelectorAll('.ptab').forEach(x=>x.classList.remove('active'));
+ b.classList.add('active');rings2=[];
+ });
+});
+document.getElementById('spd-sl').addEventListener('input',e=>{SPD=e.target.value/10;document.getElementById('spd-v').textContent=SPD.toFixed(1);});
+document.getElementById('cx-sl').addEventListener('input',e=>{CX=+e.target.value;document.getElementById('cx-v').textContent=CX;});
+document.getElementById('pal-sel').addEventListener('change',e=>{PAL=e.target.value;});
+document.getElementById('bg-sel').addEventListener('change',e=>{BG=e.target.value;});
+document.getElementById('contrast-tog').addEventListener('change',e=>{CONTRAST=e.target.checked;});
+document.getElementById('pause-btn').addEventListener('click',()=>{
+ paused=!paused;document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
+ if(!paused){lastT=performance.now();raf=requestAnimationFrame(loop);}
+});
+</script>
+</body>
+</html>
diff --git a/animations/07-ambient-background/ambient-ripple/README.md b/animations/07-ambient-background/ambient-ripple/README.md
new file mode 100644
index 00000000..810ac098
--- /dev/null
+++ b/animations/07-ambient-background/ambient-ripple/README.md
@@ -0,0 +1,84 @@
+# Ambient Ripple Effect
+
+## What it is
+The ambient ripple is the passive, atmospheric version of a ripple — concentric circles that expand outward from fixed source points on a periodic timer, not in response to user clicks. Each ring grows from zero radius to a maximum, fading in opacity as it expands, and is replaced by a new ring before it fully disappears. Multiple overlapping rings from multiple sources create the sense of something gently pulsing beneath the surface, like water drops on a still pond or sonar pings from a distant source.
+
+## When to use it
+- Behind hero sections where "something is alive here" reinforces the product's value proposition
+- Status indicators for "connected" or "active" states that need visual presence without being alarming
+- Meditation and focus apps where gentle radial pulses guide attention
+- Map or location-based UIs where the pulsing ring indicates a point of interest
+
+## How it works
+Each ripple source has a timer that spawns new `Ring` objects at a configurable interval. Rings are updated and drawn each frame using a 2D canvas:
+
+```js
+class Ring {
+ constructor(x, y) {
+ this.x = x;
+ this.y = y;
+ this.r = 0;
+ this.born = performance.now();
+ this.duration = RING_LIFE_MS;
+ }
+
+ update(now) {
+ const progress = (now - this.born) / this.duration; // 0 → 1
+ this.r = MAX_RADIUS * progress;
+ this.opacity = (1 - progress) * 0.6; // fade out as it expands
+ }
+
+ draw(ctx) {
+ ctx.beginPath();
+ ctx.arc(this.x, this.y, this.r, 0, Math.PI * 2);
+ ctx.strokeStyle = `rgba(88, 166, 255, ${this.opacity})`;
+ ctx.lineWidth = THICKNESS * (1 - this.r / MAX_RADIUS * 0.3);
+ ctx.stroke();
+ }
+
+ isDead(now) { return now - this.born > this.duration; }
+}
+```
+
+Sources emit rings at irregular intervals to avoid a mechanical clock-like feel:
+
+```js
+function scheduleEmit(source) {
+ const baseInterval = EMIT_INTERVAL_MS;
+ const jitter = IRREGULAR ? (Math.random() - 0.5) * baseInterval * 0.8 : 0;
+ source.nextEmit = performance.now() + baseInterval + jitter;
+}
+```
+
+**Source drift** — sources slowly wander across the stage for additional organic feel:
+
+```js
+function updateSource(source) {
+ source.x += source.vx;
+ source.y += source.vy;
+ // Bounce at boundaries
+ if (source.x < W * 0.05 || source.x > W * 0.95) source.vx *= -1;
+ if (source.y < H * 0.1 || source.y > H * 0.9) source.vy *= -1;
+}
+```
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Source count | 3 | 1 = focused pulse; 3 = distributed field; 5 = active water surface |
+| Emit interval | 3s | How often a new ring is born from each source |
+| Max radius | 160px | Rings with large max radius need longer duration to avoid appearing to "rush" |
+| Ring duration | 2.5s | Should be long enough for 2–3 rings to overlap, creating continuity |
+| Irregular timing | On | ±40% random variance on the base interval — the most important toggle |
+
+## Production notes
+- **This is not the click ripple**: the click ripple ([Click / Tap Ripple](../../04-micro-interactions/click-ripple/)) responds to user input and confirms an action. The ambient ripple is passive and decorative — it fires automatically and continuously without any user interaction.
+- **Ring density calibration**: at 3 sources with a 3s interval and 2.5s ring duration, there are always ~3 rings on screen from each source simultaneously. This "continuous" effect is the sweet spot — single rings look like a clock; too many look frantic.
+- **Canvas vs SVG vs CSS**: canvas is best here because the ring count is variable and positions are dynamic. SVG animation for 15+ simultaneous animated elements creates expensive SMIL calculations. CSS `@keyframes` cannot easily spawn elements dynamically.
+- **IntersectionObserver pause**: these loops run continuously — always pause them when the element is off-screen to avoid draining battery on long pages.
+- **Accessibility**: the animation is purely decorative. Pause on `prefers-reduced-motion` and remove the canvas entirely if needed — no content is lost.
+
+## See also
+- [Click / Tap Ripple](../../04-micro-interactions/click-ripple/) — the user-triggered, action-confirming version of a ripple
+- [Breathing Glow](../breathing-glow/) — a pulsing glow rather than expanding rings
+- [Abstract Geometric Motion](../abstract-geometric-motion/) — the "concentric rings" preset in the geometric loop demo
diff --git a/animations/07-ambient-background/ambient-ripple/index.html b/animations/07-ambient-background/ambient-ripple/index.html
new file mode 100644
index 00000000..a8203aa4
--- /dev/null
+++ b/animations/07-ambient-background/ambient-ripple/index.html
@@ -0,0 +1,143 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Ambient Ripple Effect</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative;background:#020508}
+ canvas{display:block;width:100%;height:100%;position:absolute;inset:0}
+ .fg-card{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:clamp(180px,55%,280px);background:rgba(2,5,8,.7);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.1);border-radius:10px;padding:20px;z-index:10;text-align:center}
+ .fg-eyebrow{font-size:9px;letter-spacing:2px;text-transform:uppercase;color:var(--ui-accent);margin-bottom:8px}
+ .fg-title{font-family:Georgia,serif;font-size:clamp(14px,2vw,18px);color:#fff;margin-bottom:8px;font-style:italic;line-height:1.3}
+ .fg-body{font-size:10px;color:rgba(255,255,255,.45);line-height:1.6}
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:44px;text-align:right;color:var(--ui-text)}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ input[type=color]{border:none;background:none;width:44px;height:30px;cursor:pointer;border-radius:4px;padding:0}
+ button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
+ @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:420px}}
+ @media(prefers-reduced-motion:reduce){canvas{display:none}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Ambient Ripple Effect</h1>
+ <p>Concentric rings expand from idle sources — automatic, periodic, decorative. Not click-triggered.</p>
+</header>
+<div class="layout">
+ <div class="stage" id="stage">
+ <canvas id="cvs"></canvas>
+ <div class="fg-card">
+ <div class="fg-eyebrow">Ambient Ripple</div>
+ <div class="fg-title">Something is alive here</div>
+ <div class="fg-body">Like water drops on a still pond, ECG monitors, sonar pings — suggests presence without interaction.</div>
+ </div>
+ </div>
+ <aside>
+ <p class="note">Ambient ripples evoke "something alive" without requiring interaction. Keep timing IRREGULAR — perfectly periodic ripples feel mechanical, like a clock, not nature.</p>
+ <div class="lbl">Source Count</div>
+ <div class="sr"><input type="range" id="src-sl" min="1" max="5" value="3" step="1"><span class="sv" id="src-v">3</span></div>
+ <div class="lbl">Emit Interval (base)</div>
+ <div class="sr"><input type="range" id="int-sl" min="10" max="80" value="30" step="5"><span class="sv" id="int-v">3.0s</span></div>
+ <div class="lbl">Max Radius</div>
+ <div class="sr"><input type="range" id="rad-sl" min="50" max="300" value="160" step="10"><span class="sv" id="rad-v">160px</span></div>
+ <div class="lbl">Ring Life (duration)</div>
+ <div class="sr"><input type="range" id="life-sl" min="10" max="50" value="25" step="5"><span class="sv" id="life-v">2.5s</span></div>
+ <div class="lbl">Ring Thickness</div>
+ <div class="sr"><input type="range" id="thick-sl" min="1" max="4" value="1.5" step="0.5"><span class="sv" id="thick-v">1.5px</span></div>
+ <div class="lbl">Color</div>
+ <input type="color" id="color-pick" value="#58a6ff" aria-label="Ripple color">
+ <label class="tog"><input type="checkbox" id="irr-tog" checked><span>Irregular timing</span></label>
+ <label class="tog"><input type="checkbox" id="drift-tog"><span>Sources drift slowly</span></label>
+ <div class="div"></div>
+ <button class="rst" id="pause-btn">⏸ Pause</button>
+ </aside>
+</div>
+<script>
+const cvs=document.getElementById('cvs'),ctx=cvs.getContext('2d');
+const stage=document.getElementById('stage');
+let W,H,paused=false,raf=null,lastT=0;
+let SRCS=3,INTERVAL=3,MAX_R=160,LIFE=2.5,THICK=1.5,IRR=true,DRIFT=false;
+let COLOR=[88,166,255];
+let sources=[],rings=[];
+
+function resize(){W=cvs.width=stage.clientWidth;H=cvs.height=stage.clientHeight;initSources();}
+
+function initSources(){
+ sources=Array.from({length:SRCS},(_,i)=>({
+ x:W*(.2+i*.3/(Math.max(SRCS-1,1)))+W*.15,y:H*(.25+Math.random()*.5),
+ vx:(Math.random()-.5)*.2,vy:(Math.random()-.5)*.15,
+ nextEmit:performance.now()+Math.random()*INTERVAL*1000
+ }));
+}
+
+class Ring{
+ constructor(x,y){this.x=x;this.y=y;this.r=0;this.born=performance.now();this.dur=LIFE*1000;}
+ update(now){this.r=MAX_R*(now-this.born)/this.dur;}
+ isDead(now){return now-this.born>this.dur;}
+ draw(now){
+ const life=1-(now-this.born)/this.dur;
+ ctx.beginPath();ctx.arc(this.x,this.y,this.r,0,Math.PI*2);
+ ctx.strokeStyle=`rgba(${COLOR[0]},${COLOR[1]},${COLOR[2]},${(life*.5).toFixed(2)})`;
+ ctx.lineWidth=THICK*(1-this.r/MAX_R*.3);ctx.stroke();
+ }
+}
+
+function loop(ts){
+ if(paused){raf=null;return;}
+ raf=requestAnimationFrame(loop);
+ const dt=ts-lastT;if(dt<16)return;lastT=ts;
+ ctx.clearRect(0,0,W,H);
+ // Update sources
+ sources.slice(0,SRCS).forEach(s=>{
+ if(DRIFT){
+ s.x+=s.vx;s.y+=s.vy;
+ if(s.x<W*.05||s.x>W*.95)s.vx*=-1;
+ if(s.y<H*.1||s.y>H*.9)s.vy*=-1;
+ }
+ if(ts>=s.nextEmit){
+ rings.push(new Ring(s.x,s.y));
+ const jitter=IRR?(Math.random()-.5)*INTERVAL*1000*.8:0;
+ s.nextEmit=ts+INTERVAL*1000+jitter;
+ }
+ // Draw source dot
+ ctx.fillStyle=`rgba(${COLOR[0]},${COLOR[1]},${COLOR[2]},.4)`;
+ ctx.beginPath();ctx.arc(s.x,s.y,3,0,Math.PI*2);ctx.fill();
+ });
+ // Draw rings
+ rings=rings.filter(r=>!r.isDead(ts));
+ rings.forEach(r=>{r.update(ts);r.draw(ts);});
+}
+
+resize();raf=requestAnimationFrame(loop);window.addEventListener('resize',()=>{resize();});
+
+document.getElementById('src-sl').addEventListener('input',e=>{SRCS=+e.target.value;document.getElementById('src-v').textContent=SRCS;initSources();});
+document.getElementById('int-sl').addEventListener('input',e=>{INTERVAL=e.target.value/10;document.getElementById('int-v').textContent=INTERVAL.toFixed(1)+'s';});
+document.getElementById('rad-sl').addEventListener('input',e=>{MAX_R=+e.target.value;document.getElementById('rad-v').textContent=MAX_R+'px';});
+document.getElementById('life-sl').addEventListener('input',e=>{LIFE=e.target.value/10;document.getElementById('life-v').textContent=LIFE.toFixed(1)+'s';});
+document.getElementById('thick-sl').addEventListener('input',e=>{THICK=+e.target.value;document.getElementById('thick-v').textContent=THICK+'px';});
+document.getElementById('color-pick').addEventListener('input',e=>{const h=e.target.value;COLOR=[parseInt(h.slice(1,3),16),parseInt(h.slice(3,5),16),parseInt(h.slice(5,7),16)];});
+document.getElementById('irr-tog').addEventListener('change',e=>{IRR=e.target.checked;});
+document.getElementById('drift-tog').addEventListener('change',e=>{DRIFT=e.target.checked;});
+document.getElementById('pause-btn').addEventListener('click',()=>{
+ paused=!paused;document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
+ if(!paused){lastT=performance.now();raf=requestAnimationFrame(loop);}
+});
+</script>
+</body>
+</html>
diff --git a/animations/07-ambient-background/animated-gradient-background/README.md b/animations/07-ambient-background/animated-gradient-background/README.md
new file mode 100644
index 00000000..cba9f310
--- /dev/null
+++ b/animations/07-ambient-background/animated-gradient-background/README.md
@@ -0,0 +1,59 @@
+# Animated Gradient Background
+
+## What it is
+An animated gradient background slowly shifts its color stops, position, or hue over a long cycle — typically 15–30 seconds — creating a living, breathing backdrop that never quite repeats. It is the simplest ambient effect in the browser: pure CSS, no JavaScript, no canvas. The animation runs on the compositor thread and costs nothing beyond the initial paint.
+
+## When to use it
+- Hero sections that need subtle life without distracting from headline copy
+- SaaS landing pages where the brand palette should feel dynamic
+- Dark-mode dashboards that need warmth without photography
+- Any context where a static background feels flat but video would be too heavy
+
+## How it works
+**Position shift** — the most common variant. The gradient is much larger than the element (`background-size: 400% 400%`) and `background-position` is animated in a slow loop:
+
+```css
+.bg {
+ background: linear-gradient(135deg, #0d1a2e, #1a0d2e, #0d2e1a, #2e1a0d, #0d1a2e);
+ background-size: 400% 400%;
+ animation: grad-shift 20s ease infinite;
+}
+
+@keyframes grad-shift {
+ 0% { background-position: 0% 50%; }
+ 50% { background-position: 100% 50%; }
+ 100% { background-position: 0% 50%; }
+}
+```
+
+**Hue rotation** — apply a rotating filter to a static gradient for a simpler approach:
+
+```css
+.bg {
+ background: linear-gradient(135deg, #58a6ff, #d2a8ff, #56d364);
+ animation: hue-spin 20s linear infinite;
+}
+@keyframes hue-spin { to { filter: hue-rotate(360deg); } }
+```
+
+Note: `filter` on the gradient element also affects any children — wrap content in a separate `z-index` layer or apply the filter to a pseudo-element.
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Cycle duration | 20s | Under 8s = distracting; 15–30s = ambient; above 60s = nearly imperceptible |
+| Background size | 400% | Larger = more position range before the gradient repeats |
+| Color stop count | 5 | More stops = richer transitions; include the first stop repeated at the end for seamless loop |
+| Easing | ease | `ease` creates gentle acceleration at start/end; `linear` is uniform |
+
+## Production notes
+- **Pure CSS — no JavaScript needed**: the entire effect is a CSS animation. No `requestAnimationFrame`, no canvas, no paint calls beyond the initial setup.
+- **Compositor-thread animation**: `background-position` animation runs on the GPU compositor in modern browsers. It does not trigger layout or paint recalculation on each frame.
+- **Seamless loop**: repeat the first color stop at the end of the gradient to ensure the transition back to the start is smooth. Without this, there's a visible "snap" when the animation restarts.
+- **`@property` for smooth hue stop animation**: native CSS custom property interpolation (`@property` with `syntax: '<color>'`) allows animating individual color stops within a gradient — a newer approach that doesn't require the `background-size` hack.
+- **Performance**: on low-end devices, even CSS gradient animation can be slow if applied to large areas. Use `will-change: background-position` to hint the browser, but measure before adding it to every element.
+
+## See also
+- [Mesh Gradient](../mesh-gradient/) — the blurred-blob variant for organic multi-color fields
+- [Breathing Glow](../breathing-glow/) — radial gradient that expands and contracts
+- [Aurora](../aurora/) — directional color bands with horizontal drift
diff --git a/animations/07-ambient-background/animated-gradient-background/index.html b/animations/07-ambient-background/animated-gradient-background/index.html
new file mode 100644
index 00000000..9d4d8e40
--- /dev/null
+++ b/animations/07-ambient-background/animated-gradient-background/index.html
@@ -0,0 +1,115 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Animated Gradient Background</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px;--dur:20s}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative}
+ /* ── Gradient variants ── */
+ .grad-bg{position:absolute;inset:0}
+ .var-pos{background:linear-gradient(135deg,#0d1a2e,#1a0d2e,#0d2e1a,#2e1a0d,#0d1a2e);background-size:400% 400%;animation:grad-pos var(--dur) ease infinite}
+ .var-hue{background:linear-gradient(135deg,#58a6ff,#d2a8ff,#56d364,#ffa657);animation:grad-hue var(--dur) linear infinite}
+ .var-multi{background:linear-gradient(135deg,#0d1a2e 0%,#58a6ff 25%,#d2a8ff 50%,#56d364 75%,#0d1a2e 100%);background-size:300% 300%;animation:grad-pos calc(var(--dur)*1.5) ease infinite}
+ @keyframes grad-pos{0%{background-position:0% 50%}50%{background-position:100% 50%}100%{background-position:0% 50%}}
+ @keyframes grad-hue{to{filter:hue-rotate(360deg)}}
+ /* Palette overrides via JS class */
+ .pal-sunset .var-pos{background:linear-gradient(135deg,#1a0d05,#2e1505,#1a0518,#2e0505,#1a0d05);background-size:400% 400%}
+ .pal-sunset .var-hue{background:linear-gradient(135deg,#ffa657,#f85149,#d2a8ff,#ffa657)}
+ .pal-ocean .var-pos{background:linear-gradient(135deg,#05101a,#051a1a,#05101a,#0a0525,#05101a);background-size:400% 400%}
+ .pal-ocean .var-hue{background:linear-gradient(135deg,#58a6ff,#56d364,#0d3040,#58a6ff)}
+ .pal-mono .var-pos{background:linear-gradient(135deg,#050608,#0d1117,#1a1f28,#0d1117,#050608);background-size:400% 400%}
+ .pal-mono .var-hue{background:linear-gradient(135deg,#3a4050,#c9d1d9,#3a4050)}
+ /* Foreground card */
+ .fg-card{position:absolute;bottom:40px;left:50%;transform:translateX(-50%);width:clamp(200px,60%,320px);background:rgba(6,10,16,.75);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.12);border-radius:10px;padding:20px 22px;z-index:10}
+ .fg-eyebrow{font-size:9px;letter-spacing:2px;text-transform:uppercase;color:var(--ui-accent);margin-bottom:8px}
+ .fg-title{font-family:Georgia,serif;font-size:clamp(15px,2vw,20px);color:#fff;margin-bottom:8px;line-height:1.2}
+ .fg-body{font-size:11px;color:rgba(255,255,255,.6);line-height:1.6}
+ /* Panel */
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:44px;text-align:right;color:var(--ui-text)}
+ select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
+ @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:420px}}
+ @media(prefers-reduced-motion:reduce){.grad-bg{animation-duration:300s!important}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Animated Gradient Background</h1>
+ <p>CSS gradient shifts hue and position continuously — pure CSS, no JavaScript, seamless loop.</p>
+</header>
+<div class="layout">
+ <div class="stage" id="stage">
+ <div class="grad-bg var-pos" id="grad-bg"></div>
+ <div class="fg-card">
+ <div class="fg-eyebrow">Animated Gradient</div>
+ <div class="fg-title">Color that moves without demanding it</div>
+ <div class="fg-body">A long cycle duration makes the loop imperceptible. The color shifts; the eye barely notices.</div>
+ </div>
+ </div>
+ <aside>
+ <p class="note">Cycle 20s+: users don't perceive the loop. Below 8s the motion becomes distracting. 20s is the sweet spot for ambient without hypnotic.</p>
+ <div class="lbl">Variant</div>
+ <select id="var-sel">
+ <option value="var-pos" selected>Position shift</option>
+ <option value="var-hue">Hue rotation</option>
+ <option value="var-multi">Multi-stop cascade</option>
+ </select>
+ <div class="lbl">Cycle Duration</div>
+ <div class="sr"><input type="range" id="dur-sl" min="5" max="60" value="20" step="5"><span class="sv" id="dur-v">20s</span></div>
+ <div class="lbl">Palette</div>
+ <select id="pal-sel">
+ <option value="" selected>Default (dark blue)</option>
+ <option value="pal-sunset">Sunset</option>
+ <option value="pal-ocean">Ocean</option>
+ <option value="pal-mono">Monochrome</option>
+ </select>
+ <label class="tog"><input type="checkbox" id="subtle-tog"><span>Subtle (reduced saturation)</span></label>
+ <div class="div"></div>
+ <button class="rst" id="pause-btn">⏸ Pause</button>
+ </aside>
+</div>
+<script>
+ const bg=document.getElementById('grad-bg');
+ const stage=document.getElementById('stage');
+ let paused=false,curVar='var-pos',curPal='';
+
+ document.getElementById('var-sel').addEventListener('change',e=>{
+ bg.classList.remove('var-pos','var-hue','var-multi');
+ bg.classList.add(e.target.value);curVar=e.target.value;
+ });
+ document.getElementById('dur-sl').addEventListener('input',e=>{
+ document.getElementById('dur-v').textContent=e.target.value+'s';
+ document.documentElement.style.setProperty('--dur',e.target.value+'s');
+ });
+ document.getElementById('pal-sel').addEventListener('change',e=>{
+ if(curPal)stage.classList.remove(curPal);
+ curPal=e.target.value;if(curPal)stage.classList.add(curPal);
+ });
+ document.getElementById('subtle-tog').addEventListener('change',e=>{
+ bg.style.filter=e.target.checked?'saturate(0.3)':'';
+ });
+ document.getElementById('pause-btn').addEventListener('click',()=>{
+ paused=!paused;
+ bg.style.animationPlayState=paused?'paused':'running';
+ document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
+ });
+</script>
+</body>
+</html>
diff --git a/animations/07-ambient-background/aurora/README.md b/animations/07-ambient-background/aurora/README.md
new file mode 100644
index 00000000..c2cc4b10
--- /dev/null
+++ b/animations/07-ambient-background/aurora/README.md
@@ -0,0 +1,69 @@
+# Aurora / Northern Lights
+
+## What it is
+Aurora borealis is rendered in the browser as a set of tall, vertically-oriented color bands that drift horizontally and deform slightly as they move, simulating the curtain-like waviness of real auroras. The effect uses overlapping, heavily-blurred gradient divs whose positions are animated with CSS keyframes that include translation, skewing, and scaling — the combination produces the characteristic shimmer. No WebGL is required; pure CSS creates a convincing atmospheric illusion.
+
+## When to use it
+- Hero sections on apps with a Nordic, atmospheric, or space theme
+- Nature and travel brand backgrounds
+- Dark-theme product pages where the header needs a distinctive ambient identity
+- Music apps, ambient sound apps, or meditation tools where the visual atmosphere is part of the product
+
+## How it works
+Each aurora band is an element spanning the full stage width, positioned near the top half of the screen, with a tall linear gradient that fades from transparent at top and bottom through a peak opacity in the middle. A `filter: blur()` softens the hard gradient edges. CSS keyframes animate each band on a unique combination of `translateX`, `skewY`, and `scaleX`:
+
+```css
+.band {
+ position: absolute;
+ left: -30%; right: -30%; /* wider than stage for drift headroom */
+ filter: blur(35px);
+ opacity: 0.75;
+}
+
+.band-green {
+ top: 5%; height: 45%;
+ background: linear-gradient(
+ to bottom,
+ transparent 0%,
+ rgba(0, 220, 100, 0.5) 35%,
+ rgba(0, 180, 80, 0.6) 55%,
+ rgba(0, 100, 50, 0.2) 80%,
+ transparent 100%
+ );
+ animation: aurora-drift 30s ease-in-out infinite;
+}
+
+@keyframes aurora-drift {
+ 0% { transform: translateX(-8%) skewY(-1deg) scaleX(1); }
+ 33% { transform: translateX( 5%) skewY( 1.5deg) scaleX(1.1); }
+ 66% { transform: translateX(-3%) skewY(-0.5deg) scaleX(0.95);}
+ 100% { transform: translateX(-8%) skewY(-1deg) scaleX(1); }
+}
+```
+
+**Real aurora color chemistry**:
+- Green — oxygen atoms at ~100km altitude (most common)
+- Blue/purple — nitrogen molecules at lower altitudes
+- Red — oxygen atoms above 200km (rare, only in powerful solar storms)
+- Pink — a mix of red oxygen at top and green oxygen below
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Band count | 2–3 | 2 creates clarity; 5 creates a richer, more layered sky |
+| Blur amount | 35px | Lower = crisper band edges; higher = more diffuse wash |
+| Cycle duration | 30s | The ambient mindset: long cycle, imperceptible reset |
+| `skewY` range | ±1.5° | The subtle skew is what gives the "waving curtain" character |
+
+## Production notes
+- **No WebGL needed**: CSS keyframes are sufficient for this effect at desktop resolutions. For smooth animation on mobile, reduce blur and band count.
+- **`overflow: hidden` is mandatory**: bands extend 30% beyond each edge (for drift headroom). Without overflow clipping, they're visible outside the stage.
+- **`animation-delay` offsets**: give each band a unique negative delay so they start at different phases. Without this, all bands drift together, which looks mechanical.
+- **Star layer pairing**: adding a star background behind the aurora dramatically increases realism — the aurora appears to float in front of the night sky. See the demo's star toggle.
+- **Performance**: each blurred element creates a GPU compositing layer. 5 blurred bands + a star canvas is the practical limit on mid-range mobile.
+- **Three.js approach**: for fully custom aurora with 3D depth and noise-driven shapes, render a plane mesh with a custom GLSL shader that samples 3D noise for the waveform and color distribution.
+
+## See also
+- [Mesh Gradient](../mesh-gradient/) — similar blurred-layer approach, radial rather than vertical
+- [Starfield](../starfield/) — the star background that pairs naturally with aurora
+- [Animated Gradient Background](../animated-gradient-background/) — simpler single-gradient approach
diff --git a/animations/07-ambient-background/aurora/index.html b/animations/07-ambient-background/aurora/index.html
new file mode 100644
index 00000000..179af4e4
--- /dev/null
+++ b/animations/07-ambient-background/aurora/index.html
@@ -0,0 +1,159 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Aurora / Northern Lights</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px;--dur:30s}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative}
+ /* Sky gradient */
+ .sky{position:absolute;inset:0;background:linear-gradient(180deg,#010508 0%,#020a12 40%,#030e1a 100%)}
+ /* Star layer */
+ .stars-layer{position:absolute;inset:0;display:none}
+ /* Aurora bands — vertically tall, horizontally drifting */
+ .aurora-wrap{position:absolute;inset:0;overflow:hidden}
+ .band{
+ position:absolute;left:-30%;right:-30%;
+ filter:blur(35px);
+ opacity:.75;
+ transform-origin:center bottom;
+ }
+ .band1{top:5%;height:45%;background:linear-gradient(to bottom,transparent 0%,rgba(0,220,100,.5) 35%,rgba(0,180,80,.6) 55%,rgba(0,100,50,.2) 80%,transparent 100%);animation:drift1 var(--dur) ease-in-out infinite}
+ .band2{top:10%;height:55%;background:linear-gradient(to bottom,transparent 0%,rgba(50,150,255,.4) 30%,rgba(30,100,220,.5) 55%,rgba(20,50,150,.15) 80%,transparent 100%);animation:drift2 calc(var(--dur)*1.15) ease-in-out infinite}
+ .band3{top:0%;height:50%;background:linear-gradient(to bottom,transparent 0%,rgba(150,50,220,.35) 30%,rgba(100,30,180,.4) 55%,rgba(80,20,120,.1) 80%,transparent 100%);animation:drift3 calc(var(--dur)*0.85) ease-in-out infinite;display:none}
+ .band4{top:5%;height:40%;background:linear-gradient(to bottom,transparent 0%,rgba(255,100,180,.3) 35%,rgba(200,50,120,.35) 55%,rgba(150,30,80,.1) 80%,transparent 100%);animation:drift4 calc(var(--dur)*1.25) ease-in-out infinite;display:none}
+ .band5{top:15%;height:35%;background:linear-gradient(to bottom,transparent 0%,rgba(255,50,50,.3) 35%,rgba(200,20,20,.35) 55%,rgba(150,10,10,.1) 80%,transparent 100%);animation:drift5 calc(var(--dur)*1.1) ease-in-out infinite;display:none}
+ @keyframes drift1{0%{transform:translateX(-8%) skewY(-1deg) scaleX(1)}33%{transform:translateX(5%) skewY(1.5deg) scaleX(1.1)}66%{transform:translateX(-3%) skewY(-.5deg) scaleX(.95)}100%{transform:translateX(-8%) skewY(-1deg) scaleX(1)}}
+ @keyframes drift2{0%{transform:translateX(6%) skewY(.5deg) scaleX(1.05)}40%{transform:translateX(-7%) skewY(-1deg) scaleX(.92)}80%{transform:translateX(4%) skewY(1deg) scaleX(1.08)}100%{transform:translateX(6%) skewY(.5deg) scaleX(1.05)}}
+ @keyframes drift3{0%{transform:translateX(-5%) skewY(1deg)}50%{transform:translateX(8%) skewY(-1.5deg)}100%{transform:translateX(-5%) skewY(1deg)}}
+ @keyframes drift4{0%{transform:translateX(10%) skewY(-1deg)}50%{transform:translateX(-6%) skewY(1deg)}100%{transform:translateX(10%) skewY(-1deg)}}
+ @keyframes drift5{0%{transform:translateX(-4%) skewY(.5deg)}50%{transform:translateX(9%) skewY(-1deg)}100%{transform:translateX(-4%) skewY(.5deg)}}
+ /* Ground strip */
+ .horizon{position:absolute;bottom:0;left:0;right:0;height:28%;background:linear-gradient(to top,#01030a,transparent)}
+ /* Stars */
+ .star{position:absolute;border-radius:50%;background:#fff;animation:twinkle 3s ease-in-out infinite alternate}
+ @keyframes twinkle{0%{opacity:.2}100%{opacity:.9}}
+ /* Card */
+ .fg-card{position:absolute;bottom:36px;left:50%;transform:translateX(-50%);width:clamp(200px,60%,300px);background:rgba(2,5,10,.75);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.08);border-radius:10px;padding:18px 20px;z-index:10}
+ .fg-eyebrow{font-size:9px;letter-spacing:2px;text-transform:uppercase;color:rgba(0,220,100,.7);margin-bottom:6px}
+ .fg-title{font-family:Georgia,serif;font-size:clamp(14px,1.8vw,18px);color:#e8f4f0;margin-bottom:6px;line-height:1.3}
+ .fg-body{font-size:10px;color:rgba(255,255,255,.45);line-height:1.6}
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:44px;text-align:right;color:var(--ui-text)}
+ select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
+ @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:420px}}
+ @media(prefers-reduced-motion:reduce){.band{animation-duration:300s!important}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Aurora / Northern Lights</h1>
+ <p>Tall color bands drift and skew horizontally — blurred gradient layers faking the waving curtain of light.</p>
+</header>
+<div class="layout">
+ <div class="stage" id="stage">
+ <div class="sky"></div>
+ <div class="stars-layer" id="stars-layer"></div>
+ <div class="aurora-wrap">
+ <div class="band band1" id="band1"></div>
+ <div class="band band2" id="band2"></div>
+ <div class="band band3" id="band3"></div>
+ <div class="band band4" id="band4"></div>
+ <div class="band band5" id="band5"></div>
+ </div>
+ <div class="horizon"></div>
+ <div class="fg-card">
+ <div class="fg-eyebrow">Aurora Borealis</div>
+ <div class="fg-title">Charged particles. Magnetic fields. Light.</div>
+ <div class="fg-body">Green oxygen at 100km altitude, blue nitrogen below, rare red oxygen above 200km.</div>
+ </div>
+ </div>
+ <aside>
+ <p class="note">Aurora colors are chemistry: green = oxygen at ~100km, red = oxygen above 200km, blue/purple = nitrogen. The visual trick is tall, drifting, blurred vertical bands.</p>
+ <div class="lbl">Band Count</div>
+ <div class="sr"><input type="range" id="bands-sl" min="2" max="5" value="2" step="1"><span class="sv" id="bands-v">2</span></div>
+ <div class="lbl">Speed (cycle)</div>
+ <div class="sr"><input type="range" id="spd-sl" min="15" max="90" value="30" step="5"><span class="sv" id="spd-v">30s</span></div>
+ <div class="lbl">Brightness</div>
+ <div class="sr"><input type="range" id="bri-sl" min="30" max="100" value="75" step="5"><span class="sv" id="bri-v">0.75</span></div>
+ <div class="lbl">Palette</div>
+ <select id="pal-sel">
+ <option value="classic" selected>Classic (green/blue)</option>
+ <option value="vivid">Vivid (purple/pink)</option>
+ <option value="rare">Rare red aurora</option>
+ </select>
+ <label class="tog"><input type="checkbox" id="stars-tog"><span>Stars in background</span></label>
+ <div class="div"></div>
+ <button class="rst" id="pause-btn">⏸ Pause</button>
+ </aside>
+</div>
+<script>
+ const bands=[...document.querySelectorAll('.band')];
+ const starsLayer=document.getElementById('stars-layer');
+ let paused=false,starsBuilt=false;
+
+ function buildStars(){
+ if(starsBuilt)return;starsBuilt=true;
+ for(let i=0;i<120;i++){
+ const s=document.createElement('div');s.className='star';
+ const sz=Math.random()*2+0.5;
+ s.style.cssText=`width:${sz}px;height:${sz}px;top:${Math.random()*65}%;left:${Math.random()*100}%;opacity:${.2+Math.random()*.5};animation-delay:${Math.random()*4}s;animation-duration:${2+Math.random()*4}s`;
+ starsLayer.appendChild(s);
+ }
+ }
+
+ const PALETTES={
+ classic:[true,true,false,false,false],
+ vivid:[false,true,true,true,false],
+ rare:[false,false,false,false,true]
+ };
+
+ function applyPalette(name){
+ const vis=PALETTES[name];
+ const count=+document.getElementById('bands-sl').value;
+ bands.forEach((b,i)=>{b.style.display=(vis[i]&&i<count)?'block':'none';});
+ }
+
+ document.getElementById('bands-sl').addEventListener('input',e=>{
+ document.getElementById('bands-v').textContent=e.target.value;
+ applyPalette(document.getElementById('pal-sel').value);
+ });
+ document.getElementById('spd-sl').addEventListener('input',e=>{
+ document.getElementById('spd-v').textContent=e.target.value+'s';
+ document.documentElement.style.setProperty('--dur',e.target.value+'s');
+ });
+ document.getElementById('bri-sl').addEventListener('input',e=>{
+ const v=(e.target.value/100).toFixed(2);document.getElementById('bri-v').textContent=v;
+ bands.forEach(b=>b.style.opacity=v);
+ });
+ document.getElementById('pal-sel').addEventListener('change',e=>applyPalette(e.target.value));
+ document.getElementById('stars-tog').addEventListener('change',e=>{
+ if(e.target.checked){buildStars();starsLayer.style.display='block';}
+ else starsLayer.style.display='none';
+ });
+ document.getElementById('pause-btn').addEventListener('click',()=>{
+ paused=!paused;
+ bands.forEach(b=>b.style.animationPlayState=paused?'paused':'running');
+ document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
+ });
+
+ applyPalette('classic');
+</script>
+</body>
+</html>
diff --git a/animations/07-ambient-background/breathing-glow/README.md b/animations/07-ambient-background/breathing-glow/README.md
new file mode 100644
index 00000000..65bca5cd
--- /dev/null
+++ b/animations/07-ambient-background/breathing-glow/README.md
@@ -0,0 +1,89 @@
+# Breathing / Pulsing Glow
+
+## What it is
+A breathing glow is a radial gradient that slowly expands and contracts on a 4–6 second cycle, mimicking the rhythm of relaxed breathing. The expansion increases the gradient's scale; the contraction returns it. Optional opacity variation (1.0 → 0.7 → 1.0) reinforces the breathing sensation. The effect is used behind "resting" states — a paused music player, an idle AI assistant, a meditation timer — to communicate "alive but at rest."
+
+## When to use it
+- Idle or "rest" states for voice assistants, AI chat interfaces, and ambient computing products
+- Behind a paused or stopped media player where the visual should confirm "it's ready"
+- Meditation, focus, or breathing exercise apps where the visual guides the breath
+- Logo reveals and brand moments where a single element deserves presence and calm
+
+## How it works
+A radial gradient element is animated with a CSS `@keyframes` that varies its `transform: scale()`:
+
+```css
+:root {
+ --glow-dur: 5s;
+ --glow-min: 0.7;
+ --glow-max: 1.4;
+ --glow-color: #58a6ff;
+}
+
+.glow {
+ width: 280px; height: 280px;
+ border-radius: 50%;
+ background: radial-gradient(circle, var(--glow-color) 0%, transparent 70%);
+ filter: blur(40px);
+ opacity: 0.6;
+ animation: breathe var(--glow-dur) ease-in-out infinite;
+}
+
+@keyframes breathe {
+ 0%, 100% {
+ transform: scale(var(--glow-min));
+ opacity: 0.6;
+ }
+ 50% {
+ transform: scale(var(--glow-max));
+ opacity: 0.9;
+ }
+}
+```
+
+**Double-glow variant** — a second layer with a longer, slightly different cycle creates organic non-synchronization:
+
+```css
+.glow-outer {
+ width: 420px; height: 420px;
+ opacity: 0.3;
+ filter: blur(60px);
+ animation: breathe calc(var(--glow-dur) * 1.3) ease-in-out infinite reverse;
+}
+```
+
+The `reverse` direction and 1.3× duration ensures the outer glow is never in phase with the inner glow, making the combined effect feel more organic.
+
+**Paired element breathing** — the center element also scales slightly with its own animation:
+
+```css
+.center-icon {
+ animation: el-breathe var(--glow-dur) ease-in-out infinite;
+}
+@keyframes el-breathe {
+ 0%, 100% { transform: scale(1); opacity: 0.9; }
+ 50% { transform: scale(1.02); opacity: 1; }
+}
+```
+
+The 2% scale on the center element is intentionally subtle — the eye should not consciously notice the element moving.
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Cycle duration | 5s | 2s = anxious; 4–6s = relaxed breath; 8s+ = barely perceptible |
+| Min scale | 0.7 | Too low = the glow nearly disappears at minimum |
+| Max scale | 1.4 | Too high = the expansion looks alarming rather than calm |
+| Glow size | 280px | Base radius of the gradient — larger fills more of the background |
+
+## Production notes
+- **Why 4–6 seconds?** This range matches the respiratory rate of a relaxed adult (10–15 breaths per minute). Apple's Siri orb uses approximately this range. The match is not accidental — the timing creates a subconscious biofeedback of calm.
+- **`filter: blur()` vs `border-radius: 50%`**: the combination creates a round soft glow without needing an image. `filter: blur()` is GPU-accelerated and smooth at all scale values.
+- **Easing**: `ease-in-out` gives a slow start, gentle acceleration to the midpoint, and slow deceleration at the peak — matching how breathing actually feels (the inhale begins and ends slowly).
+- **`will-change: transform`**: adding this to the glow element hints the browser to allocate a compositing layer. Useful when multiple glows are stacked; unnecessary for a single glow.
+- **Framer Motion**: `<motion.div animate={{ scale: [0.7, 1.4, 0.7] }} transition={{ duration: 5, repeat: Infinity, ease: "easeInOut" }} />` — identical result with React.
+
+## See also
+- [Ambient Ripple](../ambient-ripple/) — pulsing outward rings rather than scaling inward glow
+- [Mesh Gradient](../mesh-gradient/) — drifting color wash for a larger-scale ambient background
+- [Floating Elements](../floating-elements/) — shapes that drift with subtle opacity pulse
diff --git a/animations/07-ambient-background/breathing-glow/index.html b/animations/07-ambient-background/breathing-glow/index.html
new file mode 100644
index 00000000..05b3da6f
--- /dev/null
+++ b/animations/07-ambient-background/breathing-glow/index.html
@@ -0,0 +1,131 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Breathing / Pulsing Glow</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px;--glow-dur:5s;--glow-color:#58a6ff;--glow-min:.6;--glow-max:1.5;--glow-size:260px}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative;background:#020408;display:flex;align-items:center;justify-content:center}
+ /* Glow layers */
+ .glow-wrap{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;pointer-events:none}
+ .glow{
+ width:var(--glow-size);height:var(--glow-size);border-radius:50%;
+ background:radial-gradient(circle,var(--glow-color) 0%,transparent 70%);
+ opacity:.6;filter:blur(40px);
+ animation:breathe var(--glow-dur) ease-in-out infinite
+ }
+ .glow2{
+ width:calc(var(--glow-size)*1.5);height:calc(var(--glow-size)*1.5);border-radius:50%;
+ background:radial-gradient(circle,var(--glow-color) 0%,transparent 60%);
+ opacity:.3;filter:blur(60px);
+ animation:breathe calc(var(--glow-dur)*1.3) ease-in-out infinite reverse;
+ display:none
+ }
+ @keyframes breathe{
+ 0%,100%{transform:scale(var(--glow-min));opacity:.6}
+ 50%{transform:scale(var(--glow-max));opacity:.9}
+ }
+ /* Center element */
+ .center-el{position:relative;z-index:2;display:flex;flex-direction:column;align-items:center;gap:16px;animation:el-breathe var(--glow-dur) ease-in-out infinite}
+ .center-icon{width:72px;height:72px;border-radius:50%;background:rgba(88,166,255,.15);border:1px solid rgba(88,166,255,.3);display:flex;align-items:center;justify-content:center;font-size:28px}
+ .center-label{font-size:10px;letter-spacing:3px;text-transform:uppercase;color:rgba(255,255,255,.4)}
+ .center-title{font-family:Georgia,serif;font-size:clamp(20px,3vw,28px);color:#fff;text-align:center;font-style:italic}
+ @keyframes el-breathe{
+ 0%,100%{transform:scale(1);opacity:.9}
+ 50%{transform:scale(1.02);opacity:1}
+ }
+ /* Panel */
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:44px;text-align:right;color:var(--ui-text)}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ input[type=color]{border:none;background:none;width:44px;height:30px;cursor:pointer;border-radius:4px;padding:0}
+ button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
+ @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:420px}}
+ @media(prefers-reduced-motion:reduce){.glow,.glow2,.center-el{animation-duration:60s!important}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Breathing / Pulsing Glow</h1>
+ <p>Radial gradient expands and contracts on a 5-second cycle — mimicking a slow, relaxed breath.</p>
+</header>
+<div class="layout">
+ <div class="stage">
+ <div class="glow-wrap">
+ <div class="glow" id="glow1"></div>
+ <div class="glow2" id="glow2"></div>
+ </div>
+ <div class="center-el" id="center-el">
+ <div class="center-icon">✦</div>
+ <div class="center-label">Breathing glow</div>
+ <div class="center-title">Rest state</div>
+ </div>
+ </div>
+ <aside>
+ <p class="note">The 4–6 second cycle matches a slow, relaxed breath. Faster = anxious; slower = imperceptible. Use behind idle UI elements, meditation timers, paused media players.</p>
+ <div class="lbl">Cycle Duration</div>
+ <div class="sr"><input type="range" id="dur-sl" min="2" max="12" value="5" step="0.5"><span class="sv" id="dur-v">5s</span></div>
+ <div class="lbl">Min Scale</div>
+ <div class="sr"><input type="range" id="min-sl" min="40" max="90" value="60" step="5"><span class="sv" id="min-v">0.60</span></div>
+ <div class="lbl">Max Scale</div>
+ <div class="sr"><input type="range" id="max-sl" min="100" max="200" value="150" step="10"><span class="sv" id="max-v">1.50</span></div>
+ <div class="lbl">Glow Size</div>
+ <div class="sr"><input type="range" id="size-sl" min="100" max="400" value="260" step="20"><span class="sv" id="size-v">260px</span></div>
+ <div class="lbl">Glow Color</div>
+ <input type="color" id="color-pick" value="#58a6ff" aria-label="Glow color">
+ <label class="tog"><input type="checkbox" id="double-tog"><span>Double glow (two layers)</span></label>
+ <label class="tog"><input type="checkbox" id="el-tog" checked><span>Element breathes too</span></label>
+ <div class="div"></div>
+ <button class="rst" id="pause-btn">⏸ Pause</button>
+ </aside>
+</div>
+<script>
+ let paused=false;
+ const allAnims=[document.getElementById('glow1'),document.getElementById('glow2'),document.getElementById('center-el')];
+ document.getElementById('dur-sl').addEventListener('input',e=>{
+ document.getElementById('dur-v').textContent=e.target.value+'s';
+ document.documentElement.style.setProperty('--glow-dur',e.target.value+'s');
+ });
+ document.getElementById('min-sl').addEventListener('input',e=>{
+ const v=(e.target.value/100).toFixed(2);document.getElementById('min-v').textContent=v;
+ document.documentElement.style.setProperty('--glow-min',v);
+ });
+ document.getElementById('max-sl').addEventListener('input',e=>{
+ const v=(e.target.value/100).toFixed(2);document.getElementById('max-v').textContent=v;
+ document.documentElement.style.setProperty('--glow-max',v);
+ });
+ document.getElementById('size-sl').addEventListener('input',e=>{
+ document.getElementById('size-v').textContent=e.target.value+'px';
+ document.documentElement.style.setProperty('--glow-size',e.target.value+'px');
+ });
+ document.getElementById('color-pick').addEventListener('input',e=>{
+ document.documentElement.style.setProperty('--glow-color',e.target.value);
+ });
+ document.getElementById('double-tog').addEventListener('change',e=>{
+ document.getElementById('glow2').style.display=e.target.checked?'block':'none';
+ });
+ document.getElementById('el-tog').addEventListener('change',e=>{
+ document.getElementById('center-el').style.animation=e.target.checked?'':'none';
+ });
+ document.getElementById('pause-btn').addEventListener('click',()=>{
+ paused=!paused;
+ allAnims.forEach(el=>el.style.animationPlayState=paused?'paused':'running');
+ document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
+ });
+</script>
+</body>
+</html>
diff --git a/animations/07-ambient-background/floating-elements/README.md b/animations/07-ambient-background/floating-elements/README.md
new file mode 100644
index 00000000..02c955a9
--- /dev/null
+++ b/animations/07-ambient-background/floating-elements/README.md
@@ -0,0 +1,83 @@
+# Floating Elements
+
+## What it is
+Floating elements are small geometric shapes — circles, squares, rings, triangles — that drift across a background on independent sine-wave paths. Each shape has a unique amplitude, frequency, and phase, so no two shapes ever move in synchrony. The effect is the canonical "SaaS landing page background particles" — tasteful, geometric, and ambient without being distracting. The critical design principle is independence: synchronized shapes look like a screensaver; independent shapes look like a living atmosphere.
+
+## When to use it
+- Hero backgrounds on SaaS, fintech, and tech product landing pages
+- App onboarding screens where the background adds life without competing with UI
+- Empty states and loading screens where the environment should feel "inhabited"
+- Dashboard hero areas where the background differentiates sections
+
+## How it works
+Each shape has a base position (`bx`, `by`) and sine-wave parameters. Per animation frame, current position is computed from base position plus sinusoidal offsets:
+
+```js
+function animate(t) {
+ elements.forEach(el => {
+ const x = el.bx + Math.sin(el.freq * t + el.phase) * el.amplitude;
+ const y = el.by + Math.cos(el.freq * t * 0.7 + el.phaseY) * el.amplitude * 0.6;
+
+ const rot = el.rotation ? el.rotSpeed * t : 0;
+ const opacity = el.pulse
+ ? 0.3 + 0.4 * Math.sin(el.pulsePhase + t * 0.5)
+ : 0.5;
+
+ el.dom.style.transform = `translate(${x}px, ${y}px) rotate(${rot}deg)`;
+ el.dom.style.opacity = opacity;
+ });
+}
+```
+
+**Key construction** — no two shapes share the same parameters:
+
+```js
+function createShape(count) {
+ const amp = 30 + Math.random() * 50; // 30–80px drift range
+ const freq = 0.3 + Math.random() * 0.5; // 0.3–0.8 Hz
+ const phase = Math.random() * Math.PI * 2; // random start phase
+ const phaseY = Math.random() * Math.PI * 2; // Y axis out-of-phase
+ // Y multiplier (0.6) makes motion elliptical rather than circular
+}
+```
+
+**CSS shape generation** — shapes without image assets:
+
+```css
+.shape-circle { border-radius: 50%; }
+.shape-square { /* default rect */ }
+.shape-ring { background: none; border: 2px solid currentColor; border-radius: 50%; }
+```
+
+**Mouse repulsion** — optional; shapes gently push away from the cursor:
+
+```js
+if (mouse.x > 0) {
+ const dx = x - mouse.x, dy = y - mouse.y;
+ const d = Math.sqrt(dx*dx + dy*dy);
+ if (d < 120) {
+ x += (dx / d) * (120 - d) * 0.08;
+ y += (dy / d) * (120 - d) * 0.08;
+ }
+}
+```
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Count | 8 | 4–12 is the ambient range; above 20 becomes visually busy |
+| Drift range | 50px | How far each shape wanders from its base position |
+| Drift speed | 0.5 | Higher = busier, more active; lower = barely noticeable |
+| Opacity pulse | On | Shapes fade slightly during their loop — adds organic depth |
+
+## Production notes
+- **`requestAnimationFrame` not CSS `animation`**: individual `@keyframes` per element would require generating unique keyframe names. The JS loop is cleaner for this parameterized approach.
+- **`will-change: transform`**: add to each floating element to promote it to its own compositing layer. With 12+ elements, measure whether this reduces or increases GPU memory pressure.
+- **Avoid SVGs in the DOM for many shapes**: `<svg>` elements with complex paths are more expensive to composite than simple CSS-styled `<div>`s. Stick to CSS-achievable shapes.
+- **Framer Motion**: `<motion.div animate={{ x: [0, amplitude, 0, -amplitude, 0], y: [0, amplitude*0.6, 0, -amplitude*0.6, 0] }} transition={{ duration: 1/freq, repeat: Infinity, ease: "easeInOut" }} />` — set unique props per element.
+- **Particle.js / tsParticles**: handles this effect with configuration options, collision detection, and network links. Use in production when you need more than basic floating.
+
+## See also
+- [Canvas Particle Effect](../../06-3d-advanced/canvas-particle-effect/) — physics-based particles with O(n²) connections
+- [Ambient Ripple](../ambient-ripple/) — radial expansion rather than freeform drift
+- [Noise-Based Motion](../../06-3d-advanced/noise-based-motion/) — Perlin noise driving organic field motion
diff --git a/animations/07-ambient-background/floating-elements/index.html b/animations/07-ambient-background/floating-elements/index.html
new file mode 100644
index 00000000..6674395f
--- /dev/null
+++ b/animations/07-ambient-background/floating-elements/index.html
@@ -0,0 +1,176 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Floating Elements</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative;background:#03050a}
+ .float-layer{position:absolute;inset:0;overflow:hidden}
+ .el{position:absolute;will-change:transform;opacity:.5}
+ /* Shapes via border/border-radius */
+ .shape-circle{border-radius:50%}
+ .shape-square{}
+ .shape-triangle{background:none!important;width:0!important;height:0!important;border-style:solid}
+ .shape-ring{background:none!important;border-radius:50%;border:2px solid currentColor}
+ /* Foreground */
+ .fg-card{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:clamp(200px,60%,320px);background:rgba(3,5,10,.8);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.1);border-radius:10px;padding:24px;z-index:10;text-align:center}
+ .fg-eyebrow{font-size:9px;letter-spacing:2px;text-transform:uppercase;color:var(--ui-accent);margin-bottom:10px}
+ .fg-title{font-family:Georgia,serif;font-size:clamp(16px,2.2vw,22px);color:#fff;margin-bottom:10px;font-style:italic;line-height:1.2}
+ .fg-body{font-size:11px;color:rgba(255,255,255,.45);line-height:1.6}
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:40px;text-align:right;color:var(--ui-text)}
+ select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
+ @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:420px}}
+ @media(prefers-reduced-motion:reduce){.el{animation:none!important;transform:none!important}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Floating Elements</h1>
+ <p>Geometric shapes drift on independent sine-wave paths — no two elements move in sync.</p>
+</header>
+<div class="layout">
+ <div class="stage" id="stage">
+ <div class="float-layer" id="float-layer"></div>
+ <div class="fg-card">
+ <div class="fg-eyebrow">Floating Elements</div>
+ <div class="fg-title">5–12 shapes is the sweet spot</div>
+ <div class="fg-body">Each shape has a unique amplitude, frequency, and phase. Synchronized motion would look mechanical.</div>
+ </div>
+ </div>
+ <aside>
+ <p class="note">5–12 shapes is the sweet spot. Each shape gets a unique amplitude, frequency, and phase for its sine-wave path. Synchronized shapes look mechanical; independence looks natural.</p>
+ <div class="lbl">Count</div>
+ <div class="sr"><input type="range" id="count-sl" min="4" max="20" value="8" step="1"><span class="sv" id="count-v">8</span></div>
+ <div class="lbl">Drift Speed</div>
+ <div class="sr"><input type="range" id="spd-sl" min="1" max="20" value="5" step="1"><span class="sv" id="spd-v">0.5</span></div>
+ <div class="lbl">Drift Range</div>
+ <div class="sr"><input type="range" id="range-sl" min="20" max="120" value="50" step="10"><span class="sv" id="range-v">50px</span></div>
+ <div class="lbl">Shape Mix</div>
+ <select id="shape-sel">
+ <option value="circles">Circles only</option>
+ <option value="squares">Squares only</option>
+ <option value="rings">Rings only</option>
+ <option value="mixed" selected>Mixed</option>
+ </select>
+ <div class="lbl">Palette</div>
+ <select id="pal-sel">
+ <option value="cool" selected>Cool (blues/purples)</option>
+ <option value="warm">Warm (oranges/reds)</option>
+ <option value="mono">Monochrome</option>
+ <option value="neon">Neon</option>
+ </select>
+ <label class="tog"><input type="checkbox" id="rot-tog" checked><span>Subtle rotation</span></label>
+ <label class="tog"><input type="checkbox" id="pulse-tog"><span>Opacity pulse</span></label>
+ <label class="tog"><input type="checkbox" id="react-tog"><span>Mouse repulsion</span></label>
+ <div class="div"></div>
+ <button class="rst" id="rebuild-btn">↺ Rebuild</button>
+ <button class="rst" id="pause-btn">⏸ Pause</button>
+ </aside>
+</div>
+<script>
+const layer=document.getElementById('float-layer');
+const stage=document.getElementById('stage');
+let W=stage.clientWidth,H=stage.clientHeight;
+let COUNT=8,SPD=0.5,RANGE=50,SHAPE='mixed',PAL='cool',ROT=true,PULSE=true,REACT=false;
+let elements=[],raf=null,paused=false,t=0,mouse={x:-999,y:-999};
+
+const PALETTES={
+ cool:['rgba(88,166,255,.3)','rgba(100,80,220,.3)','rgba(56,200,180,.25)'],
+ warm:['rgba(255,166,87,.3)','rgba(248,81,73,.3)','rgba(255,210,100,.25)'],
+ mono:['rgba(200,210,220,.15)','rgba(150,160,170,.12)','rgba(240,245,255,.1)'],
+ neon:['rgba(0,255,180,.4)','rgba(255,0,200,.35)','rgba(0,200,255,.4)']
+};
+
+const SHAPES=['circles','squares','rings'];
+
+function mkEl(){
+ const shapePick=SHAPE==='mixed'?SHAPES[Math.floor(Math.random()*SHAPES.length)]:SHAPE.replace(/s$/,'');
+ const sz=8+Math.random()*20;
+ const col=PALETTES[PAL][Math.floor(Math.random()*PALETTES[PAL].length)];
+ const el=document.createElement('div');el.className='el';
+ const bx=10+Math.random()*80,by=10+Math.random()*80;
+ const amp=RANGE*.5+Math.random()*RANGE*.5;
+ const freq=0.3+Math.random()*0.5;
+ const phase=Math.random()*Math.PI*2;
+ const phaseY=Math.random()*Math.PI*2;
+ const rotSpd=(Math.random()-.5)*0.3;
+ const pulsePhs=Math.random()*Math.PI*2;
+
+ if(shapePick==='ring'){
+ el.style.width=sz+'px';el.style.height=sz+'px';el.style.borderRadius='50%';el.style.border='2px solid '+col.replace(',.',',0.6,').replace('rgba(','rgba(').replace(/,[\d.]+\)$/,',0.6)');
+ el.style.background='none';
+ }else if(shapePick==='square'){
+ el.style.width=sz+'px';el.style.height=sz+'px';el.style.background=col;
+ }else{
+ el.style.width=sz+'px';el.style.height=sz+'px';el.style.borderRadius='50%';el.style.background=col;
+ }
+ el.style.position='absolute';
+ layer.appendChild(el);
+ return{el,bx,by,amp,freq,phase,phaseY,rotSpd,pulsePhs,rot:0,mx:bx,my:by};
+}
+
+function rebuild(){
+ layer.innerHTML='';
+ elements=Array.from({length:COUNT},mkEl);
+}
+
+function loop(ts){
+ if(paused){raf=null;return;}
+ raf=requestAnimationFrame(loop);
+ t+=SPD*.005;
+ elements.forEach(e=>{
+ const W=stage.clientWidth,H=stage.clientHeight;
+ let x=e.bx/100*W+Math.sin(e.freq*t+e.phase)*e.amp;
+ let y=e.by/100*H+Math.cos(e.freq*t*0.7+e.phaseY)*e.amp*.6;
+ // Mouse repulsion
+ if(REACT&&mouse.x>0){
+ const dx=x-mouse.x,dy=y-mouse.y,d=Math.sqrt(dx*dx+dy*dy);
+ if(d<120){const f=120-d;x+=dx/d*f*.08;y+=dy/d*f*.08;}
+ }
+ let rot=0;if(ROT){e.rot+=e.rotSpd;rot=e.rot;}
+ let op=0.5;if(PULSE)op=0.3+0.4*Math.sin(e.pulsePhs+t*.5);
+ e.el.style.transform=`translate(${x.toFixed(1)}px,${y.toFixed(1)}px) rotate(${rot.toFixed(1)}deg)`;
+ e.el.style.opacity=op;
+ });
+}
+
+rebuild();raf=requestAnimationFrame(loop);
+
+stage.addEventListener('mousemove',e=>{const r=stage.getBoundingClientRect();mouse.x=e.clientX-r.left;mouse.y=e.clientY-r.top;});
+stage.addEventListener('mouseleave',()=>{mouse.x=-999;});
+window.addEventListener('resize',()=>{W=stage.clientWidth;H=stage.clientHeight;});
+
+document.getElementById('count-sl').addEventListener('input',e=>{COUNT=+e.target.value;document.getElementById('count-v').textContent=COUNT;rebuild();});
+document.getElementById('spd-sl').addEventListener('input',e=>{SPD=e.target.value/10;document.getElementById('spd-v').textContent=SPD.toFixed(1);});
+document.getElementById('range-sl').addEventListener('input',e=>{RANGE=+e.target.value;document.getElementById('range-v').textContent=RANGE+'px';rebuild();});
+document.getElementById('shape-sel').addEventListener('change',e=>{SHAPE=e.target.value;rebuild();});
+document.getElementById('pal-sel').addEventListener('change',e=>{PAL=e.target.value;rebuild();});
+document.getElementById('rot-tog').addEventListener('change',e=>{ROT=e.target.checked;});
+document.getElementById('pulse-tog').addEventListener('change',e=>{PULSE=e.target.checked;});
+document.getElementById('react-tog').addEventListener('change',e=>{REACT=e.target.checked;});
+document.getElementById('rebuild-btn').addEventListener('click',rebuild);
+document.getElementById('pause-btn').addEventListener('click',()=>{
+ paused=!paused;document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
+ if(!paused){raf=requestAnimationFrame(loop);}
+});
+</script>
+</body>
+</html>
diff --git a/animations/07-ambient-background/grain-overlay/README.md b/animations/07-ambient-background/grain-overlay/README.md
new file mode 100644
index 00000000..e7aaf5fe
--- /dev/null
+++ b/animations/07-ambient-background/grain-overlay/README.md
@@ -0,0 +1,96 @@
+# Grain / Film Noise Overlay
+
+## What it is
+Film grain adds organic texture to clean digital design by layering an animated noise pattern over the content at low opacity. The effect mimics the silver-halide crystal randomness of analog film photography. At the right intensity (5–10% opacity), it is nearly invisible but improves perceived depth and warmth. Above 20%, it reads as a damaged screen. The key to film grain is subtlety — users should not notice it, only notice when it's removed.
+
+## When to use it
+- Hero sections and portfolio pages where a photographic, editorial aesthetic is desired
+- Video player overlays where the grain bridges the gap between digital and cinematic
+- Brand-identity-heavy pages where "analog warmth" is part of the positioning
+- Dark-themed dashboards where pure flat surfaces feel too cold
+
+## How it works
+**Canvas approach** — generate a new random noise texture each frame (or at a reduced rate for film-like cadence):
+
+```js
+function drawGrain(canvas, ctx, pixelSize = 2, colorNoise = false) {
+ const { width: W, height: H } = canvas;
+ const img = ctx.createImageData(W, H);
+ const data = img.data;
+
+ for (let y = 0; y < H; y += pixelSize) {
+ for (let x = 0; x < W; x += pixelSize) {
+ const v = Math.random() * 255 | 0;
+ for (let dy = 0; dy < pixelSize && y + dy < H; dy++) {
+ for (let dx = 0; dx < pixelSize && x + dx < W; dx++) {
+ const idx = ((y + dy) * W + (x + dx)) * 4;
+ data[idx] = colorNoise ? (Math.random() * 255 | 0) : v;
+ data[idx + 1] = colorNoise ? (Math.random() * 255 | 0) : v;
+ data[idx + 2] = colorNoise ? (Math.random() * 255 | 0) : v;
+ data[idx + 3] = 255;
+ }
+ }
+ }
+ }
+ ctx.putImageData(img, 0, 0);
+}
+
+// Regenerate at 24fps (film rate)
+let lastFrame = 0;
+function loop(ts) {
+ if (ts - lastFrame > 1000 / 24) {
+ drawGrain(canvas, ctx);
+ lastFrame = ts;
+ }
+ requestAnimationFrame(loop);
+}
+```
+
+**SVG `feTurbulence` approach** — the browser generates noise natively; cycling the `seed` attribute animates it:
+
+```html
+<svg style="display:none">
+ <defs>
+ <filter id="grain">
+ <feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3"
+ stitchTiles="stitch" id="turb"/>
+ <feColorMatrix type="saturate" values="0"/>
+ </filter>
+ </defs>
+</svg>
+
+<div style="
+ position: absolute; inset: 0;
+ filter: url(#grain);
+ opacity: 0.08;
+ mix-blend-mode: overlay;
+"></div>
+```
+
+```js
+let seed = 0;
+function loop() {
+ document.getElementById('turb').setAttribute('seed', seed++);
+ requestAnimationFrame(loop);
+}
+```
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Intensity (opacity) | 8% | 5–10% = invisible but impactful; 15% = noticeable; 30% = distracting |
+| Grain size (pixel size) | 2px | 1px = fine digital noise; 3px = coarse film grain; 4px+ = halftone |
+| Update rate | 24fps | 24fps = film; 12fps = lo-fi analog; 60fps = digital video noise |
+| Blend mode | overlay | `overlay` respects light/dark values; `screen` brightens; `soft-light` is subtler |
+
+## Production notes
+- **Canvas vs SVG feTurbulence**: canvas gives more control (pixel size, color noise) but is more CPU-intensive. SVG feTurbulence is GPU-accelerated and simpler but offers less control over grain character.
+- **Reduced update rate is intentional**: real film grain is 24fps, not 60fps. Generating a new canvas texture 60 times per second is wasted computation — 12–24fps matches the aesthetic and reduces CPU load.
+- **`mix-blend-mode: overlay`** is the standard for grain: it darkens dark areas slightly and brightens light areas slightly, matching how silver halide responds to exposure.
+- **CSS filter on a pseudo-element**: the cleanest production approach — add `::after { content:''; position:absolute; inset:0; background:url(grain.png); animation:grain 0.5s steps(1) infinite; }` with a spritesheet of pre-generated grain frames. This offloads grain generation entirely to a static asset.
+- **React libraries**: `react-noise` and various `css-grain` packages implement the SVG filter approach as zero-config drop-in components.
+
+## See also
+- [Scanline](../scanline/) — another retro-analog overlay technique for CRT aesthetics
+- [Chromatic Aberration](../../06-3d-advanced/chromatic-aberration/) — companion glitch effect for a degraded-media aesthetic
+- [Light Leak](../light-leak/) — another film-photography-inspired ambient overlay
diff --git a/animations/07-ambient-background/grain-overlay/index.html b/animations/07-ambient-background/grain-overlay/index.html
new file mode 100644
index 00000000..a1504a30
--- /dev/null
+++ b/animations/07-ambient-background/grain-overlay/index.html
@@ -0,0 +1,163 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Grain / Film Noise Overlay</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px;--grain-op:0.08;--grain-blend:overlay}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative}
+ /* Scene beneath grain */
+ .scene{position:absolute;inset:0;background:linear-gradient(135deg,#0a1520,#152035,#0a2520);display:flex;align-items:center;justify-content:center;padding:24px}
+ .hero-mock{text-align:center;max-width:360px}
+ .hero-label{font-size:10px;letter-spacing:3px;text-transform:uppercase;color:rgba(88,166,255,.5);margin-bottom:12px}
+ .hero-h{font-family:Georgia,serif;font-size:clamp(22px,3.5vw,36px);color:#fff;font-style:italic;line-height:1.2;margin-bottom:12px}
+ .hero-p{font-size:12px;color:rgba(255,255,255,.5);line-height:1.7;max-width:280px;margin:0 auto}
+ /* SVG grain filter approach */
+ .grain-svg{display:none}
+ /* Canvas grain overlay */
+ .grain-canvas{position:absolute;inset:0;pointer-events:none;z-index:5;opacity:var(--grain-op);mix-blend-mode:var(--grain-blend)}
+ canvas{display:block;width:100%;height:100%}
+ .fps-badge{position:absolute;top:8px;right:8px;font-size:9px;color:rgba(255,255,255,.4);background:rgba(0,0,0,.5);padding:3px 8px;border-radius:4px}
+ /* SVG filter grain */
+ .grain-filter-wrap{position:absolute;inset:0;pointer-events:none;z-index:5;opacity:var(--grain-op);mix-blend-mode:var(--grain-blend);display:none}
+ .grain-filter-wrap rect{width:100%;height:100%;filter:url(#grain-filter)}
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:44px;text-align:right;color:var(--ui-text)}
+ select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
+ @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:auto}.stage{height:auto;min-height:400px}}
+ @media(prefers-reduced-motion:reduce){canvas{display:none}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Grain / Film Noise Overlay</h1>
+ <p>Animated noise texture adds cinematic warmth — subtlety is everything. 5–10% opacity, not 30%.</p>
+</header>
+<div class="layout">
+ <div class="stage" id="stage">
+ <div class="scene">
+ <div class="hero-mock">
+ <div class="hero-label">Atlas Studio</div>
+ <div class="hero-h">Design without compromise</div>
+ <div class="hero-p">We craft digital products that earn attention and keep it. Every pixel, every frame, considered.</div>
+ </div>
+ </div>
+ <!-- SVG filter fallback -->
+ <svg class="grain-svg" style="display:none"><defs><filter id="grain-filter" x="0%" y="0%" width="100%" height="100%"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch" id="grain-turb"/><feColorMatrix type="saturate" values="0"/></filter></defs></svg>
+ <div class="grain-filter-wrap" id="grain-filter-wrap"><svg width="100%" height="100%"><rect width="100%" height="100%" filter="url(#grain-filter)"/></svg></div>
+ <!-- Canvas grain -->
+ <div class="grain-canvas" id="grain-canvas-wrap"><canvas id="grain-cvs"></canvas></div>
+ <div class="fps-badge" id="fps">— fps</div>
+ </div>
+ <aside>
+ <p class="note">Grain at 30%+ opacity looks like a broken screen. At 5–10% it improves perceived quality without being visible. Real film grain is 24fps — slower feels more cinematic.</p>
+ <div class="lbl">Implementation</div>
+ <select id="impl-sel">
+ <option value="canvas" selected>Canvas (regen)</option>
+ <option value="svgfilter">SVG feTurbulence</option>
+ </select>
+ <div class="lbl">Intensity</div>
+ <div class="sr"><input type="range" id="int-sl" min="2" max="30" value="8" step="1"><span class="sv" id="int-v">8%</span></div>
+ <div class="lbl">Grain Size</div>
+ <select id="size-sel">
+ <option value="1">Fine (1px)</option>
+ <option value="2" selected>Medium (2px)</option>
+ <option value="3">Coarse (3px)</option>
+ </select>
+ <div class="lbl">Update Rate</div>
+ <select id="rate-sel">
+ <option value="60" selected>60fps (digital)</option>
+ <option value="24">24fps (film)</option>
+ <option value="12">12fps (lo-fi)</option>
+ <option value="4">4fps (analog)</option>
+ </select>
+ <div class="lbl">Blend Mode</div>
+ <select id="blend-sel">
+ <option value="overlay" selected>Overlay</option>
+ <option value="screen">Screen</option>
+ <option value="soft-light">Soft-light</option>
+ </select>
+ <label class="tog"><input type="checkbox" id="color-tog"><span>Color noise (RGB)</span></label>
+ <div class="div"></div>
+ <div style="font-size:9px;color:var(--ui-muted)">Render: <span id="fps2">—</span> fps</div>
+ <button class="rst" id="pause-btn">⏸ Pause</button>
+ </aside>
+</div>
+<script>
+const cvs=document.getElementById('grain-cvs'),ctx=cvs.getContext('2d');
+const stage=document.getElementById('stage');
+const fpsEl=document.getElementById('fps'),fps2El=document.getElementById('fps2');
+let W,H,paused=false,raf=null,lastFrame=0,lastT=0;
+let IMPL='canvas',SIZE=2,RATE=60,COLOR_NOISE=false,INTENSITY=0.08;
+let frameInterval=1000/60;
+let svgTurb=document.getElementById('grain-turb');
+let seed=0;
+
+function resize(){W=cvs.width=stage.clientWidth;H=cvs.height=stage.clientHeight;}
+resize();window.addEventListener('resize',resize);
+
+function drawCanvasGrain(){
+ const img=ctx.createImageData(W,H);const data=img.data;
+ const step=SIZE;
+ for(let y=0;y<H;y+=step)for(let x=0;x<W;x+=step){
+ const v=Math.random()*255|0;
+ for(let dy=0;dy<step&&y+dy<H;dy++)for(let dx=0;dx<step&&x+dx<W;dx++){
+ const idx=(y+dy)*W*4+(x+dx)*4;
+ if(COLOR_NOISE){data[idx]=Math.random()*255|0;data[idx+1]=Math.random()*255|0;data[idx+2]=Math.random()*255|0;}
+ else{data[idx]=v;data[idx+1]=v;data[idx+2]=v;}
+ data[idx+3]=255;
+ }
+ }
+ ctx.putImageData(img,0,0);
+}
+
+function loop(ts){
+ if(paused){raf=null;return;}
+ raf=requestAnimationFrame(loop);
+ const dt=ts-lastT;if(dt<10)return;
+ const f=Math.round(1000/(dt||16));fpsEl.textContent=f+' fps';fps2El.textContent=f;lastT=ts;
+ if(ts-lastFrame>=frameInterval){
+ lastFrame=ts;
+ if(IMPL==='canvas')drawCanvasGrain();
+ else{seed++;svgTurb.setAttribute('seed',seed);}
+ }
+}
+
+loop(performance.now());
+
+document.getElementById('impl-sel').addEventListener('change',e=>{
+ IMPL=e.target.value;
+ document.getElementById('grain-canvas-wrap').style.display=IMPL==='canvas'?'block':'none';
+ document.getElementById('grain-filter-wrap').style.display=IMPL==='svgfilter'?'block':'none';
+});
+document.getElementById('int-sl').addEventListener('input',e=>{
+ INTENSITY=e.target.value/100;document.getElementById('int-v').textContent=e.target.value+'%';
+ document.documentElement.style.setProperty('--grain-op',INTENSITY);
+});
+document.getElementById('size-sel').addEventListener('change',e=>{SIZE=+e.target.value;});
+document.getElementById('rate-sel').addEventListener('change',e=>{frameInterval=1000/+e.target.value;});
+document.getElementById('blend-sel').addEventListener('change',e=>{document.documentElement.style.setProperty('--grain-blend',e.target.value);});
+document.getElementById('color-tog').addEventListener('change',e=>{COLOR_NOISE=e.target.checked;});
+document.getElementById('pause-btn').addEventListener('click',()=>{
+ paused=!paused;document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
+ if(!paused){lastT=performance.now();raf=requestAnimationFrame(loop);}
+});
+</script>
+</body>
+</html>
diff --git a/animations/07-ambient-background/grid-dot-pattern-parallax/README.md b/animations/07-ambient-background/grid-dot-pattern-parallax/README.md
new file mode 100644
index 00000000..7dbd76cc
--- /dev/null
+++ b/animations/07-ambient-background/grid-dot-pattern-parallax/README.md
@@ -0,0 +1,82 @@
+# Grid / Dot Pattern Parallax
+
+## What it is
+A grid or dot pattern parallax translates a subtle background pattern slightly in the opposite direction of the mouse cursor, creating a faint sense of depth between the pattern layer and the foreground content. The displacement is deliberately small — 3–8% of the cursor's position — so the effect is felt more than seen. This is the subtlest ambient effect in this category and one of the most professionally used: Linear's marketing site, Vercel's dashboard, and many developer-tool landing pages use this pattern.
+
+## When to use it
+- Technical and developer-tool landing pages where grid patterns signal "structured and precise"
+- Any hero section where a plain dark background is too flat but motion would be too distracting
+- Dashboard templates where the grid pattern subtly echoes the product's data-grid aesthetic
+- Portfolio hero sections where the pattern provides texture without competing with content
+
+## How it works
+The pattern is created using CSS `background-image` with a radial or linear gradient that tiles. The pattern layer is slightly larger than the container (10% overflow on each side) to provide drift headroom. Mouse position is tracked and mapped to a translation offset:
+
+```js
+stage.addEventListener('mousemove', e => {
+ const rect = stage.getBoundingClientRect();
+ const normX = (e.clientX - rect.left) / rect.width - 0.5; // -0.5 to 0.5
+ const normY = (e.clientY - rect.top) / rect.height - 0.5;
+
+ const STRENGTH = 0.05; // 5% of stage width/height
+ const dx = -normX * STRENGTH * rect.width;
+ const dy = -normY * STRENGTH * rect.height;
+
+ patternLayer.style.transform = `translate(${dx}px, ${dy}px)`;
+});
+```
+
+**CSS dot grid** using radial gradient:
+
+```css
+.dot-grid {
+ background-image: radial-gradient(
+ circle,
+ rgba(88, 166, 255, 0.25) 1.5px, /* dot size */
+ transparent 0
+ );
+ background-size: 28px 28px; /* dot spacing */
+}
+```
+
+**CSS line grid** using crossed linear gradients:
+
+```css
+.line-grid {
+ background-image:
+ linear-gradient(rgba(88, 166, 255, 0.15) 1px, transparent 1px),
+ linear-gradient(90deg, rgba(88, 166, 255, 0.15) 1px, transparent 1px);
+ background-size: 28px 28px;
+}
+```
+
+**Auto-drift fallback** for touch devices (no mouse hover):
+
+```js
+function autoLoop(t) {
+ const dx = -Math.sin(t * 0.0002) * STRENGTH * W * 0.4;
+ const dy = -Math.cos(t * 0.00014) * STRENGTH * H * 0.3;
+ patternLayer.style.transform = `translate(${dx}px, ${dy}px)`;
+ requestAnimationFrame(autoLoop);
+}
+```
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Parallax strength | 5% | Under 3% = unnoticeable; 5% = felt but not seen; above 10% = visually obvious |
+| Dot spacing | 28px | 16px = dense technical; 28px = balanced; 48px = sparse, airy |
+| Pattern opacity | 25% | Higher = more prominent pattern; lower = nearly invisible texture |
+| Two-layer | Off | Second sparse layer at half the speed adds genuine depth between layers |
+
+## Production notes
+- **`background-size` controls spacing, not dot size**: the dot size is the gradient stop value (e.g., `1.5px`). The `background-size` is the tile repeat interval.
+- **Touch devices have no mouse**: implement the `auto-drift` variant (slow sinusoidal drift) as a touch fallback. Detect via `(pointer: coarse)` media query.
+- **`will-change: transform`** on the pattern layer: useful when the layer is large and translation is frequent (every `mousemove` event). Add/remove dynamically on `mouseenter`/`mouseleave`.
+- **`transform: translate()` not `background-position`**: `translate` uses the compositor thread; `background-position` triggers paint. Always use `transform` for the parallax offset.
+- **SVG pattern alternative**: `<svg><pattern>` can define more complex repeating patterns (hexagons, triangles, etc.) as background images via `background-image: url("data:image/svg+xml,...")`. This keeps the pattern as pure CSS/SVG with no canvas overhead.
+
+## See also
+- [Floating Elements](../floating-elements/) — moving shapes rather than a static pattern with parallax
+- [2.5D / Pseudo-3D](../../06-3d-advanced/2-5d-pseudo-3d/) — multiple layers at genuinely different depths
+- [Parallax 3D Tilt](../../06-3d-advanced/parallax-3d-tilt/) — mouse-driven 3D rotation on cards
diff --git a/animations/07-ambient-background/grid-dot-pattern-parallax/index.html b/animations/07-ambient-background/grid-dot-pattern-parallax/index.html
new file mode 100644
index 00000000..fb85d783
--- /dev/null
+++ b/animations/07-ambient-background/grid-dot-pattern-parallax/index.html
@@ -0,0 +1,173 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Grid / Dot Pattern Parallax</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px;--dot-color:rgba(88,166,255,.25);--bg-color:#04060c;--dot-size:1.5px;--dot-gap:28px}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative;background:var(--bg-color);cursor:none}
+ /* Pattern layer */
+ .pattern-layer{position:absolute;inset:-10%;transition:transform 0ms linear;will-change:transform}
+ .pat-dots{
+ width:100%;height:100%;
+ background-image:radial-gradient(circle,var(--dot-color) var(--dot-size),transparent 0);
+ background-size:var(--dot-gap) var(--dot-gap)
+ }
+ .pat-lines{
+ width:100%;height:100%;
+ background-image:linear-gradient(var(--dot-color) 1px,transparent 1px),linear-gradient(90deg,var(--dot-color) 1px,transparent 1px);
+ background-size:var(--dot-gap) var(--dot-gap);
+ display:none
+ }
+ .pat-cross{
+ width:100%;height:100%;
+ background-image:
+ linear-gradient(var(--dot-color) 1px,transparent 1px),
+ linear-gradient(90deg,var(--dot-color) 1px,transparent 1px),
+ radial-gradient(circle,var(--dot-color) var(--dot-size),transparent 0);
+ background-size:var(--dot-gap) var(--dot-gap);
+ display:none
+ }
+ /* Spotlight on hover */
+ .spotlight{position:absolute;width:180px;height:180px;border-radius:50%;background:radial-gradient(circle,rgba(88,166,255,.06) 0%,transparent 70%);pointer-events:none;transform:translate(-50%,-50%);opacity:0;transition:opacity .2s;z-index:4}
+ /* Custom cursor */
+ .cursor{position:absolute;width:12px;height:12px;border-radius:50%;border:1.5px solid rgba(88,166,255,.5);pointer-events:none;transform:translate(-50%,-50%);z-index:10;display:none}
+ /* Auto-drift animation */
+ .auto-drift{animation:auto-pan 20s ease-in-out infinite alternate}
+ @keyframes auto-pan{0%{transform:translate(0,0)}50%{transform:translate(-3%,-2%)}100%{transform:translate(3%,2%)}}
+ /* Layer 2 (sparse) */
+ .pattern-layer2{position:absolute;inset:-10%;opacity:.4;display:none;transition:transform 0ms linear;will-change:transform}
+ .pat-layer2{width:100%;height:100%;background-image:radial-gradient(circle,var(--dot-color) calc(var(--dot-size)*1.5),transparent 0);background-size:calc(var(--dot-gap)*2.5) calc(var(--dot-gap)*2.5)}
+ /* Foreground */
+ .fg-card{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:clamp(200px,60%,320px);background:rgba(4,6,12,.8);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.1);border-radius:10px;padding:24px;z-index:10;text-align:center}
+ .fg-eyebrow{font-size:9px;letter-spacing:2px;text-transform:uppercase;color:var(--ui-accent);margin-bottom:10px}
+ .fg-title{font-family:Georgia,serif;font-size:clamp(16px,2vw,22px);color:#fff;margin-bottom:10px;font-style:italic;line-height:1.2}
+ .fg-body{font-size:11px;color:rgba(255,255,255,.5);line-height:1.6}
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:44px;text-align:right;color:var(--ui-text)}
+ select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ input[type=color]{border:none;background:none;width:44px;height:30px;cursor:pointer;border-radius:4px;padding:0;flex-shrink:0}
+ .color-row{display:flex;gap:8px;align-items:center;font-size:10px;color:var(--ui-muted)}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:420px}}
+ @media(prefers-reduced-motion:reduce){.pattern-layer{transition:none!important}.auto-drift{animation-duration:300s!important}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Grid / Dot Pattern Parallax</h1>
+ <p>Subtle background pattern translates opposite to mouse movement — imperceptible depth, very effective.</p>
+</header>
+<div class="layout">
+ <div class="stage" id="stage">
+ <div class="pattern-layer2" id="layer2"><div class="pat-layer2"></div></div>
+ <div class="pattern-layer" id="layer1">
+ <div class="pat-dots" id="pat-dots"></div>
+ <div class="pat-lines" id="pat-lines"></div>
+ <div class="pat-cross" id="pat-cross"></div>
+ </div>
+ <div class="spotlight" id="spotlight"></div>
+ <div class="cursor" id="cursor"></div>
+ <div class="fg-card">
+ <div class="fg-eyebrow">Dot Grid Parallax</div>
+ <div class="fg-title">Move your mouse across the stage</div>
+ <div class="fg-body">The pattern shifts slightly opposite to your cursor — a depth illusion so subtle you almost don't notice it.</div>
+ </div>
+ </div>
+ <aside>
+ <p class="note">Keep parallax under 10% of cursor movement. Higher values look like wallpaper sliding. Linear's marketing site uses this pattern beautifully.</p>
+ <div class="lbl">Pattern</div>
+ <select id="pat-sel">
+ <option value="dots" selected>Dot grid</option>
+ <option value="lines">Line grid</option>
+ <option value="cross">Cross-hatch</option>
+ </select>
+ <div class="lbl">Dot Spacing</div>
+ <div class="sr"><input type="range" id="gap-sl" min="16" max="60" value="28" step="4"><span class="sv" id="gap-v">28px</span></div>
+ <div class="lbl">Parallax Strength</div>
+ <div class="sr"><input type="range" id="str-sl" min="0" max="15" value="5" step="1"><span class="sv" id="str-v">5%</span></div>
+ <div class="lbl">Colors</div>
+ <div class="color-row"><span>Pattern</span><input type="color" id="dot-color" value="#58a6ff" aria-label="Pattern color"><span>Background</span><input type="color" id="bg-color" value="#04060c" aria-label="Background color"></div>
+ <label class="tog"><input type="checkbox" id="layer2-tog"><span>Two layers (depth)</span></label>
+ <label class="tog"><input type="checkbox" id="spot-tog" checked><span>Spotlight under cursor</span></label>
+ <div class="div"></div>
+ <p style="font-size:10px;color:var(--ui-muted)">No mouse? Auto-drifts on touch.</p>
+ </aside>
+</div>
+<script>
+ const layer1=document.getElementById('layer1');
+ const layer2=document.getElementById('layer2');
+ const spotlight=document.getElementById('spotlight');
+ const cursor=document.getElementById('cursor');
+ const stage=document.getElementById('stage');
+ let W=0,H=0,str=5,spotOn=true,hasMouse=false,raf=null,autoT=0;
+
+ function resize(){W=stage.clientWidth;H=stage.clientHeight;}
+ resize();window.addEventListener('resize',resize);
+
+ stage.addEventListener('mouseenter',()=>{hasMouse=true;cursor.style.display='block';if(raf){cancelAnimationFrame(raf);raf=null;}layer1.classList.remove('auto-drift');});
+ stage.addEventListener('mouseleave',()=>{hasMouse=false;cursor.style.display='none';spotlight.style.opacity='0';startAuto();});
+ stage.addEventListener('mousemove',e=>{
+ const r=stage.getBoundingClientRect();
+ const x=e.clientX-r.left,y=e.clientY-r.top;
+ const nx=x/W-.5,ny=y/H-.5;
+ const dx=(-nx*str*0.01*W).toFixed(1),dy=(-ny*str*0.01*H).toFixed(1);
+ layer1.style.transform=`translate(${dx}px,${dy}px)`;
+ if(document.getElementById('layer2-tog').checked)
+ layer2.style.transform=`translate(${(dx/2).toFixed(1)}px,${(dy/2).toFixed(1)}px)`;
+ cursor.style.left=x+'px';cursor.style.top=y+'px';
+ if(spotOn){spotlight.style.left=x+'px';spotlight.style.top=y+'px';spotlight.style.opacity='1';}
+ });
+ stage.addEventListener('touchmove',e=>{
+ const r=stage.getBoundingClientRect();
+ const x=e.touches[0].clientX-r.left,y=e.touches[0].clientY-r.top;
+ const nx=x/W-.5,ny=y/H-.5;
+ layer1.style.transform=`translate(${(-nx*str*0.01*W).toFixed(1)}px,${(-ny*str*0.01*H).toFixed(1)}px)`;
+ },{passive:true});
+
+ function startAuto(){
+ function loop(t){raf=requestAnimationFrame(loop);autoT=t*.0002;
+ const dx=(-Math.sin(autoT)*str*0.01*W*.4).toFixed(1);
+ const dy=(-Math.cos(autoT*.7)*str*0.01*H*.3).toFixed(1);
+ layer1.style.transform=`translate(${dx}px,${dy}px)`;
+ }
+ raf=requestAnimationFrame(loop);
+ }
+ startAuto();
+
+ const PAT_ELS={dots:document.getElementById('pat-dots'),lines:document.getElementById('pat-lines'),cross:document.getElementById('pat-cross')};
+ document.getElementById('pat-sel').addEventListener('change',e=>{
+ Object.values(PAT_ELS).forEach(el=>el.style.display='none');
+ PAT_ELS[e.target.value].style.display='block';
+ });
+ document.getElementById('gap-sl').addEventListener('input',e=>{
+ document.getElementById('gap-v').textContent=e.target.value+'px';
+ document.documentElement.style.setProperty('--dot-gap',e.target.value+'px');
+ });
+ document.getElementById('str-sl').addEventListener('input',e=>{str=+e.target.value;document.getElementById('str-v').textContent=str+'%';});
+ document.getElementById('dot-color').addEventListener('input',e=>{
+ const h=e.target.value;const r=parseInt(h.slice(1,3),16),g=parseInt(h.slice(3,5),16),b=parseInt(h.slice(5,7),16);
+ document.documentElement.style.setProperty('--dot-color',`rgba(${r},${g},${b},.25)`);
+ spotlight.style.background=`radial-gradient(circle,rgba(${r},${g},${b},.06) 0%,transparent 70%)`;
+ });
+ document.getElementById('bg-color').addEventListener('input',e=>{
+ document.documentElement.style.setProperty('--bg-color',e.target.value);
+ });
+ document.getElementById('layer2-tog').addEventListener('change',e=>{layer2.style.display=e.target.checked?'block':'none';});
+ document.getElementById('spot-tog').addEventListener('change',e=>{spotOn=e.target.checked;if(!spotOn)spotlight.style.opacity='0';});
+</script>
+</body>
+</html>
diff --git a/animations/07-ambient-background/light-leak/README.md b/animations/07-ambient-background/light-leak/README.md
new file mode 100644
index 00000000..9b4cb335
--- /dev/null
+++ b/animations/07-ambient-background/light-leak/README.md
@@ -0,0 +1,75 @@
+# Light Leak
+
+## What it is
+A light leak is a warm, glowing gradient that periodically sweeps across the screen from a corner, simulating the accidental light exposure that occurred in film cameras when the body seal was imperfect and stray light reached the film. In physical photography, light leaks happen at random intervals with varying intensity. Digitally recreating that randomness — irregular timing, varying peak opacity — is what makes the effect believable rather than mechanical.
+
+## When to use it
+- Editorial and photography portfolio sites where an analog aesthetic is intentional
+- Lifestyle brand pages where "film photography warmth" is part of the brand identity
+- Music video pages and creative agency sites
+- Any context where the sensation of "vintage film" enhances the brand narrative
+
+## How it works
+The leak is an absolutely-positioned overlay with a radial gradient pointing from a corner. CSS `transition` animates the `opacity` from 0 to the peak value, then back to 0. **JavaScript randomizes the timing** — this is the critical detail that separates convincing from mechanical:
+
+```js
+const leak = document.querySelector('.leak');
+
+function flash() {
+ const duration = 800 + Math.random() * 1200; // 800ms to 2000ms sweep
+ const intensity = 0.3 + Math.random() * 0.4; // 0.3 to 0.7 opacity
+
+ leak.style.transition = `opacity ${duration}ms ease-in-out`;
+ leak.style.opacity = intensity;
+
+ // Fade back out after peak, at same speed
+ setTimeout(() => {
+ leak.style.opacity = 0;
+ scheduleNext(); // schedule the next leak irregularly
+ }, duration);
+}
+
+function scheduleNext() {
+ const delay = 2000 + Math.random() * 10000; // 2s to 12s between leaks
+ setTimeout(flash, delay);
+}
+
+scheduleNext();
+```
+
+**Gradient for a top-left corner leak**:
+
+```css
+.leak {
+ position: absolute; inset: 0;
+ pointer-events: none;
+ opacity: 0;
+ background: radial-gradient(
+ ellipse at -10% -10%,
+ rgba(255, 165, 50, 0.9) 0%,
+ rgba(255, 165, 50, 0.5) 20%,
+ rgba(255, 165, 50, 0.1) 50%,
+ transparent 70%
+ );
+}
+```
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Min delay | 2s | The minimum gap between leaks — too short and it feels like strobe |
+| Max delay | 12s | The maximum gap — above 20s users may forget the effect exists |
+| Sweep duration | 1–2s | The speed of one fade-in/out cycle |
+| Peak intensity | 0.3–0.7 | Varies per leak to feel organic; consistent intensity = mechanical |
+
+## Production notes
+- **Irregularity is the entire effect**: a light leak that fires every 8 seconds at 0.5 opacity reads as a CSS animation loop, not a film defect. Randomizing both the delay and intensity per occurrence is what creates the analog feel.
+- **Color matters**: gold/amber is the classic light leak color. Cyan suggests a blue-light leak (cooler film stocks). Rose and magenta also exist. Pure white reads as a lens flare, not a leak.
+- **Multiple leaks simultaneously**: real cameras sometimes have multiple leak sources. Adding two or three leak elements with independent random timers increases verisimilitude.
+- **Pausing**: if the page is backgrounded (`document.visibilitychange`), cancel the pending `setTimeout`. Leaks firing when the tab isn't visible are wasted — and they can cause a jarring flash when the user returns.
+- **Framer Motion**: `<motion.div animate={{ opacity: [0, 0.5, 0] }} transition={{ times: [0, 0.5, 1], duration: 1.5 }}` on each flash. Trigger it imperatively with `controls.start()` from JavaScript.
+
+## See also
+- [Grain Overlay](../grain-overlay/) — film grain texture as the companion analog effect
+- [Scanline](../scanline/) — CRT-era retro overlay (different era, similar "analog" motivation)
+- [Glassmorphism Animated](../../06-3d-advanced/glassmorphism-animated/) — light-over-glass effect for digital UI
diff --git a/animations/07-ambient-background/light-leak/index.html b/animations/07-ambient-background/light-leak/index.html
new file mode 100644
index 00000000..b691f93b
--- /dev/null
+++ b/animations/07-ambient-background/light-leak/index.html
@@ -0,0 +1,170 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Light Leak</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px;--leak-dur:1.2s;--leak-op:.55;--leak-color:rgba(255,165,50,}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative;background:linear-gradient(135deg,#040608,#08111a)}
+ /* Scene content */
+ .scene{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:32px}
+ .photo-mock{width:100%;max-width:300px;height:200px;border-radius:8px;background:linear-gradient(135deg,#0d1a2e,#1a2e3a);border:1px solid rgba(255,255,255,.08);display:flex;align-items:flex-end;padding:16px}
+ .photo-cap{font-size:11px;color:rgba(255,255,255,.5)}
+ /* Leak overlay */
+ .leak{position:absolute;inset:0;pointer-events:none;z-index:5;opacity:0;transition:opacity .1s}
+ .leak.active{opacity:var(--leak-op)}
+ /* Direction variants */
+ .dir-tl{background:radial-gradient(ellipse at -10% -10%,var(--lc).9) 0%,var(--lc).5) 20%,var(--lc).1) 50%,transparent 70%)}
+ .dir-tr{background:radial-gradient(ellipse at 110% -10%,var(--lc).9) 0%,var(--lc).5) 20%,var(--lc).1) 50%,transparent 70%)}
+ .dir-bl{background:radial-gradient(ellipse at -10% 110%,var(--lc).9) 0%,var(--lc).5) 20%,var(--lc).1) 50%,transparent 70%)}
+ .dir-br{background:radial-gradient(ellipse at 110% 110%,var(--lc).9) 0%,var(--lc).5) 20%,var(--lc).1) 50%,transparent 70%)}
+ .dir-h{background:linear-gradient(90deg,transparent,var(--lc).6) 40%,var(--lc).8) 50%,var(--lc).6) 60%,transparent)}
+ /* Bokeh blobs */
+ .bokeh{position:absolute;border-radius:50%;pointer-events:none;z-index:4;animation:bokeh-float linear infinite;filter:blur(8px);display:none}
+ @keyframes bokeh-float{from{transform:translateY(100%) scale(0);opacity:0}20%{opacity:.8}80%{opacity:.5}to{transform:translateY(-120%) scale(1.5);opacity:0}}
+ /* Card */
+ .fg-card{position:absolute;bottom:28px;left:50%;transform:translateX(-50%);width:clamp(180px,55%,280px);background:rgba(4,6,8,.7);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.1);border-radius:10px;padding:16px 18px;z-index:10}
+ .fg-eyebrow{font-size:9px;letter-spacing:2px;text-transform:uppercase;color:rgba(255,165,50,.7);margin-bottom:6px}
+ .fg-title{font-family:Georgia,serif;font-size:clamp(13px,1.8vw,17px);color:#fff;margin-bottom:6px;font-style:italic}
+ .fg-body{font-size:10px;color:rgba(255,255,255,.45);line-height:1.6}
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .kv{display:flex;justify-content:space-between;font-size:10px;color:var(--ui-muted)}
+ .kv .v{color:var(--ui-text)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:44px;text-align:right;color:var(--ui-text)}
+ select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ input[type=color]{border:none;background:none;width:44px;height:30px;cursor:pointer;border-radius:4px;padding:0}
+ button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
+ @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:420px}}
+ @media(prefers-reduced-motion:reduce){.leak{transition:none!important}.bokeh{animation-duration:60s!important}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Light Leak</h1>
+ <p>Warm light sweeps across the scene with random irregular timing — evoking accidental film camera flares.</p>
+</header>
+<div class="layout">
+ <div class="stage" id="stage">
+ <div class="scene">
+ <div class="photo-mock"><div class="photo-cap">ambient · atmospheric · analog warmth</div></div>
+ </div>
+ <div class="leak dir-tl" id="leak"></div>
+ <div class="fg-card">
+ <div class="fg-eyebrow">Light Leak</div>
+ <div class="fg-title">Analog warmth, digital precision</div>
+ <div class="fg-body">Real film light leaks happen at random. Mechanical timing reads as fake.</div>
+ </div>
+ </div>
+ <aside>
+ <p class="note">KEY: irregularity. Mechanical, periodic light leaks look fake. Random timing and varying intensity per sweep is what makes them believable.</p>
+ <div class="lbl">Direction</div>
+ <select id="dir-sel">
+ <option value="dir-tl" selected>Top-left corner</option>
+ <option value="dir-tr">Top-right corner</option>
+ <option value="dir-bl">Bottom-left corner</option>
+ <option value="dir-br">Bottom-right corner</option>
+ <option value="dir-h">Horizontal center</option>
+ </select>
+ <div class="lbl">Sweep Duration</div>
+ <div class="sr"><input type="range" id="dur-sl" min="4" max="20" value="12" step="2"><span class="sv" id="dur-v">1.2s</span></div>
+ <div class="lbl">Min / Max Delay (s)</div>
+ <div class="sr"><input type="range" id="mindelay-sl" min="1" max="8" value="2" step="1"><span class="sv" id="mindelay-v">2s</span></div>
+ <div class="sr"><input type="range" id="maxdelay-sl" min="5" max="20" value="10" step="1"><span class="sv" id="maxdelay-v">10s</span></div>
+ <div class="lbl">Intensity</div>
+ <div class="sr"><input type="range" id="int-sl" min="10" max="90" value="55" step="5"><span class="sv" id="int-v">0.55</span></div>
+ <div class="lbl">Leak Color</div>
+ <input type="color" id="color-pick" value="#ffa532" aria-label="Leak color">
+ <label class="tog"><input type="checkbox" id="bokeh-tog"><span>Bokeh light blobs</span></label>
+ <div class="div"></div>
+ <div class="kv"><span>Next leak in</span><span class="v" id="next-v">—</span></div>
+ <button class="rst" id="pause-btn">⏸ Pause</button>
+ </aside>
+</div>
+<script>
+ const leak=document.getElementById('leak');
+ const nextV=document.getElementById('next-v');
+ let paused=false,leakTimer=null,countTimer=null,minDelay=2,maxDelay=10,intensity=.55;
+ let bokehOn=false;
+ const COLORS={gold:'rgba(255,165,50,',cyan:'rgba(100,200,255,',rose:'rgba(255,100,150,',white:'rgba(255,255,255,'};
+ let curColor='rgba(255,165,50,';
+
+ function applyColor(){
+ // Update CSS custom property for gradient in all direction classes
+ document.querySelectorAll('.leak,.dir-tl,.dir-tr,.dir-bl,.dir-br,.dir-h').forEach(el=>{
+ // Re-apply the background based on current dir class
+ });
+ const lc=curColor;
+ const dir=[...leak.classList].find(c=>c.startsWith('dir-'));
+ if(dir==='dir-tl')leak.style.background=`radial-gradient(ellipse at -10% -10%,${lc}.9) 0%,${lc}.5) 20%,${lc}.1) 50%,transparent 70%)`;
+ else if(dir==='dir-tr')leak.style.background=`radial-gradient(ellipse at 110% -10%,${lc}.9) 0%,${lc}.5) 20%,${lc}.1) 50%,transparent 70%)`;
+ else if(dir==='dir-bl')leak.style.background=`radial-gradient(ellipse at -10% 110%,${lc}.9) 0%,${lc}.5) 20%,${lc}.1) 50%,transparent 70%)`;
+ else if(dir==='dir-br')leak.style.background=`radial-gradient(ellipse at 110% 110%,${lc}.9) 0%,${lc}.5) 20%,${lc}.1) 50%,transparent 70%)`;
+ else leak.style.background=`linear-gradient(90deg,transparent,${lc}.6) 40%,${lc}.8) 50%,${lc}.6) 60%,transparent)`;
+ }
+
+ function flash(){
+ if(paused)return;
+ leak.classList.add('active');
+ const dur=+document.getElementById('dur-sl').value*100;
+ setTimeout(()=>leak.classList.remove('active'),dur+200);
+ if(bokehOn)spawnBokeh();
+ scheduleNext();
+ }
+
+ function scheduleNext(){
+ const delay=(minDelay+Math.random()*(maxDelay-minDelay))*1000;
+ let countdown=Math.round(delay/1000);
+ nextV.textContent=countdown+'s';
+ leakTimer=setTimeout(flash,delay);
+ countTimer=setInterval(()=>{countdown--;nextV.textContent=Math.max(0,countdown)+'s';},1000);
+ setTimeout(()=>clearInterval(countTimer),delay);
+ }
+
+ function spawnBokeh(){
+ const stage=document.getElementById('stage');
+ for(let i=0;i<3;i++){
+ const b=document.createElement('div');b.className='bokeh';
+ const sz=20+Math.random()*40;
+ b.style.cssText=`width:${sz}px;height:${sz}px;background:${curColor}.6);left:${20+Math.random()*60}%;bottom:0;animation-duration:${3+Math.random()*4}s;animation-delay:${Math.random()*.5}s;display:block`;
+ stage.appendChild(b);
+ setTimeout(()=>b.remove(),(8000));
+ }
+ }
+
+ document.getElementById('dir-sel').addEventListener('change',e=>{
+ leak.classList.remove('dir-tl','dir-tr','dir-bl','dir-br','dir-h');
+ leak.classList.add(e.target.value);applyColor();
+ });
+ document.getElementById('dur-sl').addEventListener('input',e=>{document.getElementById('dur-v').textContent=(e.target.value/10).toFixed(1)+'s';});
+ document.getElementById('mindelay-sl').addEventListener('input',e=>{minDelay=+e.target.value;document.getElementById('mindelay-v').textContent=minDelay+'s';});
+ document.getElementById('maxdelay-sl').addEventListener('input',e=>{maxDelay=+e.target.value;document.getElementById('maxdelay-v').textContent=maxDelay+'s';});
+ document.getElementById('int-sl').addEventListener('input',e=>{intensity=e.target.value/100;document.getElementById('int-v').textContent=intensity.toFixed(2);document.documentElement.style.setProperty('--leak-op',intensity);});
+ document.getElementById('color-pick').addEventListener('input',e=>{
+ const h=e.target.value;curColor=`rgba(${parseInt(h.slice(1,3),16)},${parseInt(h.slice(3,5),16)},${parseInt(h.slice(5,7),16)},`;applyColor();
+ });
+ document.getElementById('bokeh-tog').addEventListener('change',e=>{bokehOn=e.target.checked;});
+ document.getElementById('pause-btn').addEventListener('click',()=>{
+ paused=!paused;clearTimeout(leakTimer);clearInterval(countTimer);
+ document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
+ if(!paused)scheduleNext();else nextV.textContent='—';
+ });
+
+ applyColor();scheduleNext();
+</script>
+</body>
+</html>
diff --git a/animations/07-ambient-background/mesh-gradient/README.md b/animations/07-ambient-background/mesh-gradient/README.md
new file mode 100644
index 00000000..58f2bf2d
--- /dev/null
+++ b/animations/07-ambient-background/mesh-gradient/README.md
@@ -0,0 +1,69 @@
+# Mesh Gradient Animation
+
+## What it is
+A mesh gradient is a field of overlapping, heavily blurred radial gradients that create the appearance of hand-painted color washes. Individual gradient circles are invisible beneath the blur — what remains is pure color bleeding organically across the canvas. Slowly drifting these circles with CSS keyframes produces an ambient effect that looks like a living Impressionist painting. This is the visual language of Stripe, Linear, and many modern SaaS brands.
+
+## When to use it
+- Marketing hero sections where the brand palette must feel premium and hand-crafted
+- Dark-themed dashboards as an alternative to flat black backgrounds
+- SaaS product pages that need warmth and depth without imagery
+- App splash screens and loading states
+
+## How it works
+Each blob is an absolutely-positioned `<div>` with a radial gradient background and `filter: blur()`. The key is heavy blur — 80px or more — which dissolves the gradient's hard edges into pure color wash. CSS keyframes animate each blob on an independent path:
+
+```css
+.blob {
+ position: absolute;
+ border-radius: 50%;
+ filter: blur(80px);
+ opacity: 0.75;
+ animation: wander 40s ease-in-out infinite alternate;
+}
+
+.blob-1 {
+ width: 60%; height: 60%;
+ background: #1a3060; /* deep blue */
+ top: -10%; left: -10%;
+ animation-delay: 0s;
+}
+
+.blob-2 {
+ width: 55%; height: 55%;
+ background: #2e0a50; /* deep purple */
+ top: 20%; right: -15%;
+ animation-delay: -10s;
+}
+
+@keyframes wander {
+ 0% { transform: translate(0, 0) scale(1); }
+ 33% { transform: translate(15%, -20%) scale(1.1); }
+ 66% { transform: translate(-10%, 15%) scale(0.9); }
+ 100% { transform: translate(20%, 10%) scale(1.05); }
+}
+```
+
+**CSS blend modes** change the visual mixing of overlapping blobs:
+- `normal` — blobs layer on top of each other; later in DOM = on top
+- `screen` — adds RGB values, making overlaps brighter and more saturated
+- `overlay` — darkens darks, brightens brights; high contrast effect
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Blur amount | 80px | The central parameter — below 40px the circles show; above 120px is pure wash |
+| Blob count | 4–5 | More = richer; too many (8+) blend into uniformity |
+| Cycle duration | 40s | Long enough that users never see the loop; `alternate` direction doubles effective duration |
+| Opacity | 0.75 | Lower = more muted; higher = more vivid; `mix-blend-mode: screen` amplifies this |
+
+## Production notes
+- **`filter: blur()` on GPU**: heavy blur is GPU-accelerated in modern browsers but creates a compositing layer per blurred element. Four blurred blobs = four compositing layers. On low-RAM devices, this stacks up — test on mobile.
+- **Overflow clipping**: blobs extend beyond the container. Always `overflow: hidden` on the parent so blobs don't bleed into the rest of the page.
+- **Native CSS mesh gradients**: the CSS Working Group has a `mesh()` function specification in progress that would render true mesh gradients in CSS without the blur trick. It is not yet shipped in any browser.
+- **Figma / Sketch "mesh gradient" tools**: design tools generate mesh gradients as images. For web, the blur-div approach produces a similar aesthetic with full animation capability.
+- **`animation-delay` with negative values**: a negative delay (e.g., `-10s`) starts the animation mid-cycle, preventing all blobs from starting at the same position and looking synchronized.
+
+## See also
+- [Animated Gradient Background](../animated-gradient-background/) — the simpler, single-gradient animated approach
+- [Aurora](../aurora/) — directional vertical bands rather than radial blobs
+- [Breathing Glow](../breathing-glow/) — a single centered radial glow that pulses
diff --git a/animations/07-ambient-background/mesh-gradient/index.html b/animations/07-ambient-background/mesh-gradient/index.html
new file mode 100644
index 00000000..1e8777e3
--- /dev/null
+++ b/animations/07-ambient-background/mesh-gradient/index.html
@@ -0,0 +1,133 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Mesh Gradient Animation</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px;--blob-blur:80px;--dur:40s;--blend:normal}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative;background:#04060c}
+ .mesh-wrap{position:absolute;inset:0;overflow:hidden}
+ .blob{position:absolute;border-radius:50%;filter:blur(var(--blob-blur));opacity:.75;mix-blend-mode:var(--blend)}
+ .b1{width:60%;height:60%;background:#1a3060;top:-10%;left:-10%;animation:b1 var(--dur) ease-in-out infinite alternate}
+ .b2{width:55%;height:55%;background:#2e0a50;top:20%;right:-15%;animation:b2 calc(var(--dur)*1.1) ease-in-out infinite alternate}
+ .b3{width:50%;height:50%;background:#0a2e1a;bottom:-15%;left:15%;animation:b3 calc(var(--dur)*.9) ease-in-out infinite alternate}
+ .b4{width:45%;height:45%;background:#2e1a05;top:40%;left:30%;animation:b4 calc(var(--dur)*1.2) ease-in-out infinite alternate}
+ .b5{width:40%;height:40%;background:#1a0a2e;bottom:10%;right:5%;animation:b5 calc(var(--dur)*.8) ease-in-out infinite alternate;display:none}
+ @keyframes b1{0%{transform:translate(0,0) scale(1)}100%{transform:translate(20%,15%) scale(1.2)}}
+ @keyframes b2{0%{transform:translate(0,0) scale(1)}100%{transform:translate(-15%,20%) scale(0.85)}}
+ @keyframes b3{0%{transform:translate(0,0) scale(1)}100%{transform:translate(15%,-20%) scale(1.15)}}
+ @keyframes b4{0%{transform:translate(0,0) scale(1)}100%{transform:translate(-20%,-15%) scale(0.9)}}
+ @keyframes b5{0%{transform:translate(0,0) scale(1)}100%{transform:translate(10%,25%) scale(1.1)}}
+ .fg-card{position:absolute;bottom:40px;left:50%;transform:translateX(-50%);width:clamp(200px,60%,320px);background:rgba(6,10,16,.7);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.12);border-radius:10px;padding:20px 22px;z-index:10}
+ .fg-eyebrow{font-size:9px;letter-spacing:2px;text-transform:uppercase;color:var(--ui-accent);margin-bottom:8px}
+ .fg-title{font-family:Georgia,serif;font-size:clamp(15px,2vw,20px);color:#fff;margin-bottom:8px;line-height:1.2}
+ .fg-body{font-size:11px;color:rgba(255,255,255,.6);line-height:1.6}
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:44px;text-align:right;color:var(--ui-text)}
+ select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
+ button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
+ @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:420px}}
+ @media(prefers-reduced-motion:reduce){.blob{animation-duration:300s!important}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Mesh Gradient Animation</h1>
+ <p>Blurred radial gradients drift slowly — heavy blur dissolves edges into pure organic color washes.</p>
+</header>
+<div class="layout">
+ <div class="stage">
+ <div class="mesh-wrap" id="mesh">
+ <div class="blob b1" id="b1"></div>
+ <div class="blob b2" id="b2"></div>
+ <div class="blob b3" id="b3"></div>
+ <div class="blob b4" id="b4"></div>
+ <div class="blob b5" id="b5"></div>
+ </div>
+ <div class="fg-card">
+ <div class="fg-eyebrow">Mesh Gradient</div>
+ <div class="fg-title">Organic color without sharp edges</div>
+ <div class="fg-body">Heavy blur dissolves gradient boundaries into painterly washes. Popularized by Stripe's landing pages.</div>
+ </div>
+ </div>
+ <aside>
+ <p class="note">The key: blur 80px+. Below that, gradient circles are visible; above, pure color wash. Stripe's design uses this at 120–160px blur across large areas.</p>
+ <div class="lbl">Blob Count</div>
+ <div class="sr"><input type="range" id="count-sl" min="3" max="5" value="4" step="1"><span class="sv" id="count-v">4</span></div>
+ <div class="lbl">Blur Amount</div>
+ <div class="sr"><input type="range" id="blur-sl" min="40" max="150" value="80" step="10"><span class="sv" id="blur-v">80px</span></div>
+ <div class="lbl">Speed (cycle)</div>
+ <div class="sr"><input type="range" id="spd-sl" min="15" max="90" value="40" step="5"><span class="sv" id="spd-v">40s</span></div>
+ <div class="lbl">Palette</div>
+ <select id="pal-sel">
+ <option value="cool" selected>Cool (default)</option>
+ <option value="warm">Warm</option>
+ <option value="sunset">Sunset</option>
+ <option value="synthwave">Synthwave</option>
+ <option value="earth">Earth</option>
+ </select>
+ <div class="lbl">Blend Mode</div>
+ <select id="blend-sel">
+ <option value="normal" selected>Normal</option>
+ <option value="screen">Screen</option>
+ <option value="overlay">Overlay</option>
+ </select>
+ <div class="div"></div>
+ <button class="rst" id="pause-btn">⏸ Pause</button>
+ </aside>
+</div>
+<script>
+ const PALETTES={
+ cool:['#1a3060','#2e0a50','#0a2e1a','#2e1a05'],
+ warm:['#3a1010','#3a2a10','#3a1025','#2a1035'],
+ sunset:['#3a1510','#2a1040','#1a0540','#3a0520'],
+ synthwave:['#0a0a3a','#3a0050','#003a3a','#1a003a'],
+ earth:['#1a1505','#0a1a0a','#1a0a05','#0a1015']
+ };
+ const blobs=[...document.querySelectorAll('.blob')];
+ let paused=false;
+
+ function setPalette(name){
+ const cols=PALETTES[name];
+ blobs.forEach((b,i)=>{if(i<cols.length)b.style.background=cols[i%cols.length];});
+ }
+
+ document.getElementById('count-sl').addEventListener('input',e=>{
+ const n=+e.target.value;document.getElementById('count-v').textContent=n;
+ blobs.forEach((b,i)=>b.style.display=i<n?'':'none');
+ });
+ document.getElementById('blur-sl').addEventListener('input',e=>{
+ document.getElementById('blur-v').textContent=e.target.value+'px';
+ document.documentElement.style.setProperty('--blob-blur',e.target.value+'px');
+ });
+ document.getElementById('spd-sl').addEventListener('input',e=>{
+ document.getElementById('spd-v').textContent=e.target.value+'s';
+ document.documentElement.style.setProperty('--dur',e.target.value+'s');
+ });
+ document.getElementById('pal-sel').addEventListener('change',e=>setPalette(e.target.value));
+ document.getElementById('blend-sel').addEventListener('change',e=>{
+ document.documentElement.style.setProperty('--blend',e.target.value);
+ });
+ document.getElementById('pause-btn').addEventListener('click',()=>{
+ paused=!paused;
+ blobs.forEach(b=>b.style.animationPlayState=paused?'paused':'running');
+ document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
+ });
+ // Show 4 blobs by default
+ document.getElementById('b5').style.display='none';
+</script>
+</body>
+</html>
diff --git a/animations/07-ambient-background/scanline/README.md b/animations/07-ambient-background/scanline/README.md
new file mode 100644
index 00000000..b93a0955
--- /dev/null
+++ b/animations/07-ambient-background/scanline/README.md
@@ -0,0 +1,84 @@
+# Scanline Effect
+
+## What it is
+Scanlines are the horizontal dark lines produced by CRT (cathode-ray tube) monitors, where the electron beam sweeps left-to-right line by line, leaving a visible gap between each row of phosphor. In digital design, scanlines are added intentionally as a CSS repeating gradient pattern to evoke retrowave, '80s synthwave, or '90s sci-fi UI aesthetics. A moving sweep beam that brightens as it passes adds a dynamic cinematic quality.
+
+## When to use it
+- Retrowave, cyberpunk, or synthwave themed UIs
+- Gaming HUD overlays and retro arcade aesthetics
+- "Terminal" or "command line" styled interfaces
+- Music visualizers and media player interfaces with an analog vintage feel
+
+## How it works
+**Static scanlines** — a CSS `repeating-linear-gradient` creates the line pattern without any JavaScript:
+
+```css
+.scanlines {
+ position: absolute;
+ inset: 0;
+ pointer-events: none;
+ background: repeating-linear-gradient(
+ to bottom,
+ transparent 0px,
+ transparent 3px, /* visible row height */
+ rgba(0,0,0,0.15) 3px, /* dark line */
+ rgba(0,0,0,0.15) 4px /* line-gap = 4px total */
+ );
+}
+```
+
+The `line-gap` CSS custom property in the demo allows the density to be adjusted: `4px` is standard CRT density; `8px` is coarser and more stylized.
+
+**Moving sweep beam** — a tall gradient strip animated with `translateY`:
+
+```css
+.beam {
+ position: absolute;
+ left: 0; right: 0;
+ height: 120px;
+ top: -120px; /* starts above the visible area */
+ background: linear-gradient(
+ to bottom,
+ transparent 0%,
+ rgba(255, 255, 255, 0.08) 50%,
+ transparent 100%
+ );
+ animation: sweep 4s linear infinite;
+}
+
+@keyframes sweep {
+ from { top: -120px; }
+ to { top: 100%; }
+}
+```
+
+**CRT curvature** — a radial vignette overlay darkens the corners, simulating the slight convex curvature of a CRT screen:
+
+```css
+.vignette {
+ position: absolute;
+ inset: 0;
+ background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.5) 100%);
+}
+```
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Line gap | 4px | 2px = dense vintage CRT; 4px = standard; 8px = stylized/coarse |
+| Line darkness | 0.15 | 0.05 = barely visible; 0.25 = strong retro; 0.5 = overpowering |
+| Beam speed | 4s | Faster = action/alert; slower = cinematic sci-fi |
+| Beam brightness | 0.08–0.12 | Keep it subtle — the beam should be felt, not seen clearly |
+
+## Production notes
+- **Purely CSS**: no JavaScript required for the scanline or beam effects. Only the panel controls use JS.
+- **`pointer-events: none`**: the scanline overlay must not intercept mouse events. Always add `pointer-events: none` to overlay elements.
+- **Performance**: `repeating-linear-gradient` is composited as a texture on first render and cached. It does not repaint on each frame — it's essentially free. The `translateY` beam animation runs on the compositor thread.
+- **Phosphor glow**: real CRT phosphors emit light that spreads slightly, creating a soft "halo" around bright text. CSS `text-shadow: 0 0 8px currentColor` approximates this. Keep it subtle — heavy glow degrades legibility.
+- **Accessibility**: scanlines reduce contrast. Ensure all text meets WCAG contrast ratios *with* the scanline overlay applied. Test with the overlay at your intended darkness value.
+- **Retrowave aesthetic**: combines well with [Grain Overlay](../grain-overlay/) (for texture), [Chromatic Aberration](../../06-3d-advanced/chromatic-aberration/) (for color fringing), and dark neon color palettes.
+
+## See also
+- [Grain Overlay](../grain-overlay/) — texture overlay for analog warmth
+- [Light Leak](../light-leak/) — warm analog overlay for a film camera aesthetic
+- [Chromatic Aberration](../../06-3d-advanced/chromatic-aberration/) — RGB channel split for glitch/retro look
diff --git a/animations/07-ambient-background/scanline/index.html b/animations/07-ambient-background/scanline/index.html
new file mode 100644
index 00000000..15069f7b
--- /dev/null
+++ b/animations/07-ambient-background/scanline/index.html
@@ -0,0 +1,142 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Scanline Effect</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px;--line-gap:4px;--line-dark:.15;--beam-dur:4s;--beam-bright:.12}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative;background:#05080d}
+ /* Screen content */
+ .screen-content{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:32px}
+ .terminal{width:100%;max-width:420px;background:#040608;border:1px solid rgba(88,166,255,.2);border-radius:6px;padding:20px 24px;font-family:monospace}
+ .term-bar{display:flex;gap:6px;margin-bottom:14px}
+ .dot{width:10px;height:10px;border-radius:50%}
+ .dot.r{background:#f85149}.dot.y{background:#ffa657}.dot.g{background:#56d364}
+ .term-line{font-size:clamp(10px,1.3vw,12px);color:var(--ui-accent);line-height:1.7;opacity:.9}
+ .term-line.dim{opacity:.4}
+ .term-cursor{display:inline-block;width:8px;height:1em;background:var(--ui-accent);vertical-align:text-bottom;animation:blink 1s step-end infinite}
+ @keyframes blink{50%{opacity:0}}
+ /* Scanline overlay */
+ .scanlines{
+ position:absolute;inset:0;pointer-events:none;z-index:5;
+ background:repeating-linear-gradient(
+ to bottom,
+ transparent 0px,
+ transparent calc(var(--line-gap) - 1px),
+ rgba(0,0,0,var(--line-dark)) calc(var(--line-gap) - 1px),
+ rgba(0,0,0,var(--line-dark)) var(--line-gap)
+ )
+ }
+ /* Sweep beam */
+ .beam{
+ position:absolute;left:0;right:0;height:120px;top:-120px;z-index:6;pointer-events:none;
+ background:linear-gradient(to bottom,transparent 0%,rgba(255,255,255,var(--beam-bright)) 50%,transparent 100%);
+ animation:beam-sweep var(--beam-dur) linear infinite;
+ display:none
+ }
+ @keyframes beam-sweep{from{top:-120px}to{top:100%}}
+ /* CRT curvature (barrel distortion via border-radius on content) */
+ .crt-wrap{position:absolute;inset:0;border-radius:40%;overflow:hidden;pointer-events:none;display:none}
+ .crt-inner{position:absolute;inset:-5%;background:radial-gradient(ellipse at center,transparent 60%,rgba(0,0,0,.5) 100%)}
+ /* Phosphor glow on text (via CSS on terminal) */
+ .phosphor .term-line{text-shadow:0 0 8px var(--ui-accent),0 0 20px rgba(88,166,255,.3)}
+ /* Panel */
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:44px;text-align:right;color:var(--ui-text)}
+ select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
+ @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:auto}.stage{height:auto;min-height:420px}}
+ @media(prefers-reduced-motion:reduce){.beam{animation-duration:60s!important}.term-cursor{animation:none!important}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Scanline Effect</h1>
+ <p>Repeating dark lines over content create a CRT monitor aesthetic — optional sweep beam and phosphor glow.</p>
+</header>
+<div class="layout">
+ <div class="stage" id="stage">
+ <div class="screen-content">
+ <div class="terminal" id="terminal">
+ <div class="term-bar"><span class="dot r"></span><span class="dot y"></span><span class="dot g"></span></div>
+ <div class="term-line">$ initialize_system --mode ambient</div>
+ <div class="term-line dim">// scanning for motion patterns</div>
+ <div class="term-line">→ all systems nominal</div>
+ <div class="term-line dim">→ rendering 60fps continuous</div>
+ <div class="term-line">_ <span class="term-cursor"></span></div>
+ </div>
+ </div>
+ <div class="scanlines" id="scanlines"></div>
+ <div class="beam" id="beam"></div>
+ <div class="crt-wrap" id="crt-wrap"><div class="crt-inner"></div></div>
+ </div>
+ <aside>
+ <p class="note">Scanlines = nostalgic. Static + sweep beam = cinematic sci-fi. Add curvature + phosphor = full CRT simulation. Use sparingly — the look is dated by design.</p>
+ <div class="lbl">Line Density</div>
+ <select id="density-sel">
+ <option value="2">Dense (every 2px)</option>
+ <option value="4" selected>Medium (every 4px)</option>
+ <option value="8">Coarse (every 8px)</option>
+ </select>
+ <div class="lbl">Line Darkness</div>
+ <div class="sr"><input type="range" id="dark-sl" min="5" max="40" value="15" step="1"><span class="sv" id="dark-v">0.15</span></div>
+ <label class="tog"><input type="checkbox" id="beam-tog"><span>Moving beam sweep</span></label>
+ <div class="lbl">Beam Speed</div>
+ <div class="sr"><input type="range" id="beam-sl" min="2" max="15" value="4" step="1"><span class="sv" id="beam-v">4s</span></div>
+ <div class="lbl">Beam Brightness</div>
+ <div class="sr"><input type="range" id="bri-sl" min="5" max="30" value="12" step="1"><span class="sv" id="bri-v">0.12</span></div>
+ <label class="tog"><input type="checkbox" id="crt-tog"><span>CRT curvature vignette</span></label>
+ <label class="tog"><input type="checkbox" id="phos-tog"><span>Phosphor text glow</span></label>
+ <div class="div"></div>
+ <button class="rst" id="pause-btn">⏸ Pause</button>
+ </aside>
+</div>
+<script>
+ let paused=false;
+ document.getElementById('density-sel').addEventListener('change',e=>{
+ document.documentElement.style.setProperty('--line-gap',e.target.value+'px');
+ });
+ document.getElementById('dark-sl').addEventListener('input',e=>{
+ const v=(e.target.value/100).toFixed(2);document.getElementById('dark-v').textContent=v;
+ document.documentElement.style.setProperty('--line-dark',v);
+ });
+ document.getElementById('beam-tog').addEventListener('change',e=>{
+ document.getElementById('beam').style.display=e.target.checked?'block':'none';
+ });
+ document.getElementById('beam-sl').addEventListener('input',e=>{
+ document.getElementById('beam-v').textContent=e.target.value+'s';
+ document.documentElement.style.setProperty('--beam-dur',e.target.value+'s');
+ });
+ document.getElementById('bri-sl').addEventListener('input',e=>{
+ const v=(e.target.value/100).toFixed(2);document.getElementById('bri-v').textContent=v;
+ document.documentElement.style.setProperty('--beam-bright',v);
+ });
+ document.getElementById('crt-tog').addEventListener('change',e=>{
+ document.getElementById('crt-wrap').style.display=e.target.checked?'block':'none';
+ });
+ document.getElementById('phos-tog').addEventListener('change',e=>{
+ document.getElementById('terminal').classList.toggle('phosphor',e.target.checked);
+ });
+ document.getElementById('pause-btn').addEventListener('click',()=>{
+ paused=!paused;
+ document.getElementById('beam').style.animationPlayState=paused?'paused':'running';
+ document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
+ });
+</script>
+</body>
+</html>
diff --git a/animations/07-ambient-background/starfield/README.md b/animations/07-ambient-background/starfield/README.md
new file mode 100644
index 00000000..b14f91c7
--- /dev/null
+++ b/animations/07-ambient-background/starfield/README.md
@@ -0,0 +1,83 @@
+# Starfield / Space Particles
+
+## What it is
+A starfield renders many small white points on a dark canvas that drift outward from a central focal point — the "flying through space" illusion. The depth effect comes from coupling a star's apparent size and speed to its distance from center: stars close to the center are small and slow; stars near the edge are larger and fast, simulating perspective acceleration. The side-scrolling variant produces the slower "looking out a spacecraft window" effect where stars at different depths move at different speeds.
+
+## When to use it
+- Space, astronomy, or sci-fi themed applications
+- Ambient screensaver-style backgrounds for kiosk displays or focus apps
+- Hero sections on tech products where "infinite scale" or "beyond the horizon" is the message
+- Dark-themed landing pages that need a sense of depth and motion without complexity
+
+## How it works
+Each star tracks its angular position (`angle`), distance from center (`dist`), and speed. Per frame, distance increases and the star's canvas coordinates are computed from polar coordinates:
+
+```js
+class Star {
+ constructor(W, H) {
+ this.angle = Math.random() * Math.PI * 2;
+ this.dist = Math.random() * Math.max(W, H) * 0.5; // random start in field
+ this.speed = (Math.random() * 0.6 + 0.2) * BASE_SPEED;
+ this.size = Math.random() * 1.5 + 0.5;
+ }
+
+ update() {
+ const ratio = this.dist / MAX_DIST;
+ // Accelerate as the star "approaches" — perspective foreshortening
+ this.dist += this.speed * (1 + ratio * 2);
+ // Reset to center when off-screen
+ if (this.dist > MAX_DIST) {
+ this.dist = 0;
+ this.angle = Math.random() * Math.PI * 2;
+ }
+ }
+
+ draw(ctx, cx, cy) {
+ const ratio = this.dist / MAX_DIST;
+ const x = cx + Math.cos(this.angle) * this.dist;
+ const y = cy + Math.sin(this.angle) * this.dist;
+ const size = this.size * (1 + ratio * 2); // grow with distance
+ const opacity = 0.3 + ratio * 0.7; // brighten with distance
+
+ ctx.fillStyle = `rgba(255, 255, 255, ${opacity})`;
+ ctx.beginPath();
+ ctx.arc(x, y, size, 0, Math.PI * 2);
+ ctx.fill();
+ }
+}
+```
+
+**Side-drift variant** — stars have a fixed depth value that determines both size and speed:
+
+```js
+class DriftStar {
+ constructor(W, H) {
+ this.x = Math.random() * W;
+ this.y = Math.random() * H;
+ this.depth = Math.random() * 0.8 + 0.2; // 0.2 (far) to 1.0 (near)
+ this.size = this.depth * 2;
+ }
+ update() { this.x -= this.depth * SPEED; if (this.x < 0) this.x = W; }
+}
+```
+
+## Key parameters
+| Parameter | Default | Effect |
+|-----------|---------|--------|
+| Star count | 300 | 100 = sparse; 300 = balanced; 800 = dense (approaching FPS limit) |
+| Base speed | 0.4 | Keep it slow for ambient — fast starfields feel like hyperspace, not ambiance |
+| Twinkling | On | Sinusoidal opacity variation per star; adds life without changing position |
+| Acceleration factor | 2× | How much faster stars travel at the edge vs center; higher = more dramatic zoom |
+
+## Production notes
+- **Canvas vs DOM**: DOM elements at star counts above 50 cause heavy layout recalculation. Canvas is the right tool for this effect.
+- **`ctx.fillStyle` caching**: setting `fillStyle` per star is expensive. Group stars by opacity bucket and set fillStyle once per bucket (color batching) to reduce canvas state changes.
+- **`requestAnimationFrame` throttling**: on 120Hz displays, the loop runs twice as fast. Cap time delta to avoid stars moving at different speeds across devices.
+- **Nebula background pairing**: adding a subtle radial gradient (deep purple in one quadrant, deep blue in another) behind the stars dramatically increases realism with minimal performance cost.
+- **Three.js `Points` geometry**: production starfields use Three.js `BufferGeometry` with `PointsMaterial`. Each star is a vertex; the position buffer is updated each frame. This approach scales to 100,000+ stars.
+- **`prefers-reduced-motion`**: keep stars static (no animation loop) or limit to a very slow drift at 10% of normal speed.
+
+## See also
+- [Aurora](../aurora/) — the atmospheric companion to a starfield sky
+- [Canvas Particle Effect](../../06-3d-advanced/canvas-particle-effect/) — physics-based particles with connections
+- [Floating Elements](../floating-elements/) — geometric shapes drifting with sine-wave motion
diff --git a/animations/07-ambient-background/starfield/index.html b/animations/07-ambient-background/starfield/index.html
new file mode 100644
index 00000000..5fde322c
--- /dev/null
+++ b/animations/07-ambient-background/starfield/index.html
@@ -0,0 +1,171 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Starfield / Space Particles</title>
+ <style>
+ :root{--bg:#060a10;--ui-bg:#0d1117;--ui-border:#21262d;--ui-accent:#58a6ff;--ui-text:#c9d1d9;--ui-muted:#8b949e;--stage-h:620px}
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;padding:clamp(12px,3vw,24px)}
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+ .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;overflow:hidden;position:relative;background:#000}
+ canvas{display:block;width:100%;height:100%}
+ .fps-badge{position:absolute;top:8px;right:8px;font-size:9px;color:rgba(255,255,255,.4);background:rgba(0,0,0,.5);padding:3px 8px;border-radius:4px;pointer-events:none}
+ .fg-card{position:absolute;bottom:28px;left:50%;transform:translateX(-50%);width:clamp(180px,55%,280px);background:rgba(0,0,0,.65);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.08);border-radius:10px;padding:16px 18px;z-index:10;text-align:center}
+ .fg-eyebrow{font-size:9px;letter-spacing:2px;text-transform:uppercase;color:rgba(255,255,255,.4);margin-bottom:6px}
+ .fg-title{font-family:Georgia,serif;font-size:clamp(13px,1.8vw,17px);color:#fff;margin-bottom:6px;font-style:italic}
+ .fg-body{font-size:10px;color:rgba(255,255,255,.4);line-height:1.6}
+ aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
+ .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
+ .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .div{height:1px;background:var(--ui-border)}
+ .sr{display:flex;align-items:center;gap:6px;font-size:10px}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
+ .sv{width:40px;text-align:right;color:var(--ui-text)}
+ select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
+ @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
+ @media(max-width:600px){.layout{flex-direction:column}aside{width:100%}:root{--stage-h:380px}}
+ @media(prefers-reduced-motion:reduce){canvas{display:none}}
+ </style>
+</head>
+<body>
+<header>
+ <h1>Starfield / Space Particles</h1>
+ <p>Stars drift outward from center with parallax depth — slower near center, faster at edges.</p>
+</header>
+<div class="layout">
+ <div class="stage" id="stage">
+ <canvas id="cvs"></canvas>
+ <div class="fps-badge" id="fps">— fps</div>
+ <div class="fg-card">
+ <div class="fg-eyebrow">Starfield</div>
+ <div class="fg-title">Infinite depth from a single point</div>
+ <div class="fg-body">Stars start small at center, grow as they reach the edge — perspective through motion.</div>
+ </div>
+ </div>
+ <aside>
+ <p class="note">Depth illusion: couple size and speed to distance from center. Stars near center = slow, tiny. Stars at edge = fast, large. This single trick creates convincing 3D perspective.</p>
+ <div class="lbl">Mode</div>
+ <select id="mode-sel">
+ <option value="radial" selected>Radial (outward)</option>
+ <option value="drift">Side drift (parallax)</option>
+ </select>
+ <div class="lbl">Star Count</div>
+ <div class="sr"><input type="range" id="count-sl" min="50" max="800" value="300" step="50"><span class="sv" id="count-v">300</span></div>
+ <div class="lbl">Speed</div>
+ <div class="sr"><input type="range" id="spd-sl" min="1" max="20" value="4" step="1"><span class="sv" id="spd-v">0.4</span></div>
+ <div class="lbl">Star Color</div>
+ <select id="col-sel">
+ <option value="white" selected>White</option>
+ <option value="warm">Warm white</option>
+ <option value="color">Multi-color</option>
+ </select>
+ <label class="tog"><input type="checkbox" id="twinkle-tog" checked><span>Twinkling</span></label>
+ <label class="tog"><input type="checkbox" id="nebula-tog"><span>Nebula haze</span></label>
+ <div class="div"></div>
+ <div style="font-size:9px;color:var(--ui-muted)" id="fps-note">FPS: <span id="fps2">—</span></div>
+ <button class="rst" id="pause-btn">⏸ Pause</button>
+ </aside>
+</div>
+<script>
+const cvs=document.getElementById('cvs'),ctx=cvs.getContext('2d');
+const stage=document.getElementById('stage');
+const fpsEl=document.getElementById('fps'),fps2=document.getElementById('fps2');
+let W,H,paused=false,raf=null,lastT=0,MODE='radial',COUNT=300,SPD=0.4,TWINKLE=true,NEBULA=false,COL='white';
+let stars=[];
+
+function resize(){W=cvs.width=stage.clientWidth;H=cvs.height=stage.clientHeight;initStars();}
+
+class Star{
+ constructor(init){
+ if(MODE==='radial'){
+ this.angle=Math.random()*Math.PI*2;
+ this.dist=init?Math.random()*Math.max(W,H)*.5:0;
+ this.maxDist=Math.max(W,H)*.55;
+ this.speed=(Math.random()*.6+.2)*SPD;
+ this.size=Math.random()*1.5+.5;
+ this.twinklePhase=Math.random()*Math.PI*2;
+ }else{
+ this.x=Math.random()*W;this.y=Math.random()*H;
+ this.depth=Math.random()*.8+.2;
+ this.size=(Math.random()*1.5+.5)*this.depth;
+ this.twinklePhase=Math.random()*Math.PI*2;
+ }
+ this.hue=Math.random()*60;
+ }
+ update(){
+ if(MODE==='radial'){
+ this.dist+=this.speed;
+ const ratio=this.dist/this.maxDist;
+ this.speed=(ratio*.5+.2)*SPD*1.5;
+ if(this.dist>this.maxDist){this.dist=0;this.speed=(Math.random()*.6+.2)*SPD;this.angle=Math.random()*Math.PI*2;}
+ }else{
+ this.x-=this.depth*SPD*2;if(this.x<-2){this.x=W+2;}
+ }
+ this.twinklePhase+=.05;
+ }
+ draw(){
+ const ratio=MODE==='radial'?this.dist/this.maxDist:this.depth;
+ const r=parseInt('ff',16),g=parseInt('ff',16),b=parseInt('ff',16);
+ let col='rgba(255,255,255,';
+ if(COL==='warm')col=`rgba(255,240,200,`;
+ if(COL==='color')col=`hsla(${this.hue},80%,90%,`;
+ const sz=this.size*(1+ratio*1.5);
+ const twinkle=TWINKLE?(.7+Math.sin(this.twinklePhase)*.3):1;
+ const op=(ratio*.7+.3)*twinkle;
+ ctx.fillStyle=col+op+')';
+ ctx.beginPath();
+ if(MODE==='radial'){
+ const x=W/2+Math.cos(this.angle)*this.dist,y=H/2+Math.sin(this.angle)*this.dist;
+ ctx.arc(x,y,sz,0,Math.PI*2);
+ }else{
+ ctx.arc(this.x,this.y,sz,0,Math.PI*2);
+ }
+ ctx.fill();
+ }
+}
+
+function initStars(){stars=Array.from({length:COUNT},(_,i)=>new Star(true));}
+
+function drawNebula(){
+ const g=ctx.createRadialGradient(W*.3,H*.4,0,W*.3,H*.4,W*.5);
+ g.addColorStop(0,'rgba(50,20,100,.15)');g.addColorStop(1,'transparent');
+ ctx.fillStyle=g;ctx.fillRect(0,0,W,H);
+ const g2=ctx.createRadialGradient(W*.7,H*.6,0,W*.7,H*.6,W*.4);
+ g2.addColorStop(0,'rgba(20,50,80,.1)');g2.addColorStop(1,'transparent');
+ ctx.fillStyle=g2;ctx.fillRect(0,0,W,H);
+}
+
+function loop(ts){
+ if(paused){raf=null;return;}
+ raf=requestAnimationFrame(loop);
+ const dt=ts-lastT;if(dt<16)return;
+ const f=Math.round(1000/(dt||16));fpsEl.textContent=f+' fps';fps2.textContent=f;lastT=ts;
+ ctx.fillStyle='rgba(0,0,0,.85)';ctx.fillRect(0,0,W,H);
+ if(NEBULA)drawNebula();
+ stars.forEach(s=>{s.update();s.draw();});
+}
+
+resize();raf=requestAnimationFrame(loop);
+window.addEventListener('resize',resize);
+
+document.getElementById('mode-sel').addEventListener('change',e=>{MODE=e.target.value;initStars();});
+document.getElementById('count-sl').addEventListener('input',e=>{COUNT=+e.target.value;document.getElementById('count-v').textContent=COUNT;initStars();});
+document.getElementById('spd-sl').addEventListener('input',e=>{SPD=e.target.value/10;document.getElementById('spd-v').textContent=SPD.toFixed(1);});
+document.getElementById('col-sel').addEventListener('change',e=>{COL=e.target.value;});
+document.getElementById('twinkle-tog').addEventListener('change',e=>{TWINKLE=e.target.checked;});
+document.getElementById('nebula-tog').addEventListener('change',e=>{NEBULA=e.target.checked;});
+document.getElementById('pause-btn').addEventListener('click',()=>{
+ paused=!paused;document.getElementById('pause-btn').textContent=paused?'▶ Resume':'⏸ Pause';
+ if(!paused){lastT=performance.now();raf=requestAnimationFrame(loop);}
+});
+</script>
+</body>
+</html>
diff --git a/index.html b/index.html
index b3e221a1..8aac88a3 100644
--- a/index.html
+++ b/index.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animation Atlas</title>
<style>
- :root{--bg:#060a10;--ui-bg:#0d1117;--border:#21262d;--text:#c9d1d9;--muted:#8b949e;--c1:#58a6ff;--c2:#56d364;--c3:#d2a8ff;--c4:#ffa657;--c5:#f85149;--c6:#56d364}
+ :root{--bg:#060a10;--ui-bg:#0d1117;--border:#21262d;--text:#c9d1d9;--muted:#8b949e;--c1:#58a6ff;--c2:#56d364;--c3:#d2a8ff;--c4:#ffa657;--c5:#f85149;--c6:#56d364;--c7:#58a6ff}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
body{background:var(--bg);color:var(--text);font-family:monospace;padding:clamp(20px,4vw,56px) clamp(16px,4vw,48px);max-width:1100px;margin:0 auto}
.hero{margin-bottom:clamp(40px,6vw,72px);padding-bottom:32px;border-bottom:1px solid var(--border)}
@@ -34,6 +34,7 @@
.c4-cat .card:hover{border-color:var(--c4)}.c4-cat .card:hover .card-name{color:var(--c4)}
.c5-cat .card:hover{border-color:var(--c5)}.c5-cat .card:hover .card-name{color:var(--c5)}
.c6-cat .card:hover{border-color:var(--c6)}.c6-cat .card:hover .card-name{color:var(--c6)}
+ .c7-cat .card:hover{border-color:var(--c7)}.c7-cat .card:hover .card-name{color:var(--c7)}
.planned{margin-bottom:16px}
.planned h2{font-size:10px;text-transform:uppercase;letter-spacing:2.5px;color:var(--muted);margin-bottom:12px;opacity:.45}
.soon-list{display:flex;gap:8px;flex-wrap:wrap}
@@ -47,7 +48,7 @@
<p class="hero-sub">A visual reference of web animation techniques. Each entry is a self-contained demo with an explanation of the mechanic — open any HTML file and it runs offline, no build step.</p>
<div class="hero-meta">
<a class="hero-link" href="https://github.com/matinmonshizadeh/animation-handbook">github.com/matinmonshizadeh/animation-handbook →</a>
- <span class="badge">88 animations · 6 categories</span>
+ <span class="badge">100 animations · 7 categories</span>
</div>
</div>
<div id="root"></div>
@@ -182,6 +183,25 @@ const CATS=[
['cloth-simulation','Cloth Simulation','Verlet integration + distance constraints — draggable flag responds to gravity and wind.'],
['volumetric-smoke','Volumetric Smoke','Ray marching accumulates 3D noise density — light scattering, shadow rays, fBm clouds.'],
]
+ },
+ {
+ name:'Ambient & Background',cat:'c7-cat',dot:'#58a6ff',n:'07',
+ desc:'Passive, looping effects that hold visual interest without demanding attention — gradients, particles, grain, and glows.',
+ folder:'animations/07-ambient-background',
+ entries:[
+ ['animated-gradient-background','Animated Gradient Background','CSS gradient shifts hue and position continuously — pure CSS, no JavaScript, seamless loop.'],
+ ['mesh-gradient','Mesh Gradient Animation','Blurred radial gradient blobs drift slowly — organic color washes popularized by Stripe.'],
+ ['aurora','Aurora / Northern Lights','Tall color bands drift and skew horizontally — heavy blur fakes the curtain of light.'],
+ ['grain-overlay','Grain / Film Noise Overlay','Animated noise at 5–10% opacity adds cinematic warmth — subtlety is everything.'],
+ ['scanline','Scanline Effect','CRT horizontal lines with optional sweep beam, curvature, and phosphor glow.'],
+ ['light-leak','Light Leak','Warm gradient fires at random irregular intervals — analog film camera aesthetic.'],
+ ['starfield','Starfield / Space Particles','Stars drift outward from center with parallax depth — slow ambient speed, never hyperspace.'],
+ ['breathing-glow','Breathing / Pulsing Glow','Radial glow expands and contracts on a 5-second breath cycle — calm resting state.'],
+ ['ambient-ripple','Ambient Ripple Effect','Concentric rings emit periodically from idle sources — passive atmosphere, not click-driven.'],
+ ['floating-elements','Floating Elements','Geometric shapes drift on independent sine-wave paths — no two elements synchronized.'],
+ ['grid-dot-pattern-parallax','Grid / Dot Pattern Parallax','Pattern shifts subtly opposite to mouse movement — depth felt, barely seen.'],
+ ['abstract-geometric-motion','Abstract Geometric Motion','Four hypnotic loops: rotating polygons, expanding rings, sliding bars, flowing color lines.'],
+ ]
}
];
@@ -195,10 +215,6 @@ CATS.forEach(cat=>{
});
sec.appendChild(grid);root.appendChild(sec);
});
-
-const planned=document.createElement('div');planned.className='planned';
-planned.innerHTML=`<h2>Coming soon</h2><div class="soon-list"><span class="soon">07 — Ambient &amp; Background</span></div>`;
-root.appendChild(planned);
</script>
</body>
</html>