# Depth System Reference The 2.5D illusion is built entirely on a **6-level depth model**. Every element on the page belongs to exactly one depth level. Depth controls four automatic properties: parallax speed, blur, scale, and shadow intensity. Together these four signals trick the human visual system into perceiving genuine spatial depth from flat assets. --- ## The 6-Level Depth Table | Level | Name | Parallax | Blur | Scale | Shadow | Z-Index | |-------|-------------------|----------|-------|-------|---------|---------| | 0 | Far Background | 0.10x | 8px | 0.70 | 0.05 | 0 | | 1 | Glow / Atmosphere | 0.25x | 4px | 0.85 | 0.10 | 1 | | 2 | Mid Decorations | 0.50x | 0px | 1.00 | 0.20 | 2 | | 3 | Main Objects | 0.80x | 0px | 1.05 | 0.35 | 3 | | 4 | UI / Text | 1.00x | 0px | 1.00 | 0.00 | 4 | | 5 | Foreground FX | 1.20x | 0px | 1.10 | 0.50 | 5 | **Parallax formula:** ``` element_translateY = scroll_position * depth_factor * -1 ``` A depth-0 element at scroll position 500px moves only -50px (barely moves — feels far away). A depth-5 element at 500px moves -600px (moves fast — feels close). --- ## CSS Implementation ### CSS Custom Properties Foundation ```css :root { /* Depth parallax factors */ --depth-0-factor: 0.10; --depth-1-factor: 0.25; --depth-2-factor: 0.50; --depth-3-factor: 0.80; --depth-4-factor: 1.00; --depth-5-factor: 1.20; /* Depth blur values */ --depth-0-blur: 8px; --depth-1-blur: 4px; --depth-2-blur: 0px; --depth-3-blur: 0px; --depth-4-blur: 0px; --depth-5-blur: 0px; /* Depth scale values */ --depth-0-scale: 0.70; --depth-1-scale: 0.85; --depth-2-scale: 1.00; --depth-3-scale: 1.05; --depth-4-scale: 1.00; --depth-5-scale: 1.10; /* Live scroll value (updated by JS) */ --scroll-y: 0; } /* Base layer class */ .layer { position: absolute; inset: 0; will-change: transform; transform-origin: center center; } /* Depth-specific classes */ .depth-0 { filter: blur(var(--depth-0-blur)); transform: scale(var(--depth-0-scale)) translateY(calc(var(--scroll-y) * var(--depth-0-factor) * -1px)); z-index: 0; } .depth-1 { filter: blur(var(--depth-1-blur)); transform: scale(var(--depth-1-scale)) translateY(calc(var(--scroll-y) * var(--depth-1-factor) * -1px)); z-index: 1; mix-blend-mode: screen; /* glow layers blend additively */ } .depth-2 { transform: scale(var(--depth-2-scale)) translateY(calc(var(--scroll-y) * var(--depth-2-factor) * -1px)); z-index: 2; } .depth-3 { transform: scale(var(--depth-3-scale)) translateY(calc(var(--scroll-y) * var(--depth-3-factor) * -1px)); z-index: 3; filter: drop-shadow(0 20px 40px rgba(0,0,0,0.35)); } .depth-4 { transform: translateY(calc(var(--scroll-y) * var(--depth-4-factor) * -1px)); z-index: 4; } .depth-5 { transform: scale(var(--depth-5-scale)) translateY(calc(var(--scroll-y) * var(--depth-5-factor) * -1px)); z-index: 5; } ``` ### JavaScript — Scroll Driver ```javascript // Throttled scroll listener using requestAnimationFrame let ticking = false; let lastScrollY = 0; function updateDepthLayers() { const scrollY = window.scrollY; document.documentElement.style.setProperty('--scroll-y', scrollY); ticking = false; } window.addEventListener('scroll', () => { lastScrollY = window.scrollY; if (!ticking) { requestAnimationFrame(updateDepthLayers); ticking = true; } }, { passive: true }); ``` --- ## Asset Assignment Rules ### What Goes in Each Depth Level **Depth 0 — Far Background** - Full-width background images (sky, gradient, texture) - Very large PNGs (1920×1080+), file size 80–150KB max - Heavily blurred by CSS — low detail is fine and preferred - Examples: skyscape, abstract color wash, noise texture **Depth 1 — Glow / Atmosphere** - Radial gradient blobs, lens flare PNGs, soft light overlays - Size: 600–1000px, file size: 30–60KB max - Always use `mix-blend-mode: screen` or `mix-blend-mode: lighten` - Always `filter: blur(40px–100px)` applied on top of CSS blur - Examples: orange glow blob behind product, atmospheric haze **Depth 2 — Mid Decorations** - Abstract shapes, geometric patterns, floating decorative elements - Size: 200–400px, file size: 20–50KB max - Moderate shadow, no blur - Examples: floating geometric shapes, brand pattern elements **Depth 3 — Main Objects (The Star)** - Hero product images, characters, featured illustrations - Size: 800–1200px, file size: 50–120KB max - High detail, clean cutout (transparent PNG background) - Strong drop shadow: `filter: drop-shadow(0 30px 60px rgba(0,0,0,0.4))` - This is the element users look at — give it the most visual weight - Examples: juice bottle, product shot, hero character **Depth 4 — UI / Text** - Headlines, body copy, buttons, cards, navigation - Always crisp, never blurred - Text elements get animation data attributes (see text-animations.md) - Examples: `

`, `

`, `