*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--bg: #070a12;
--text: #f0f4fb;
--muted: #8a95a8;
--accent: #86e8ff;
--neon-purple: #ae52ff;
--neon-pink: #ff40d6;
--warm: #ffcc66;
}
html {
background: var(--bg);
color: var(--text);
font-family: 'Inter', 'SF Pro Display', system-ui, sans-serif;
}
body {
overflow-x: hidden;
}
/* ── Sections ── */
.section {
position: relative;
width: 100%;
min-height: 100vh;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
/* ── Layers for parallax ── */
.layer {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
will-change: transform;
}
.layer-fg {
position: relative;
z-index: 3;
}
.layer-mid { z-index: 2; }
.layer-bg { z-index: 1; }
/* ── Content ── */
.content {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
padding: 2rem;
max-width: 800px;
}
.eyebrow {
display: inline-block;
font-size: 0.72rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.18em;
color: var(--accent);
margin-bottom: 1rem;
opacity: 0;
}
.hero-title, .reveal-text {
font-size: clamp(2.5rem, 8vw, 6rem);
font-weight: 700;
letter-spacing: -0.03em;
line-height: 1.05;
opacity: 0;
}
.hero-title {
background: linear-gradient(135deg, #fff 0%, var(--accent) 60%, var(--neon-purple) 100%);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.reveal-text {
color: var(--text);
}
.hero-sub, .reveal-body {
font-size: clamp(0.95rem, 2vw, 1.15rem);
color: var(--muted);
max-width: 440px;
margin-top: 1.2rem;
line-height: 1.6;
opacity: 0;
}
/* ── Scroll hint ── */
.scroll-hint {
margin-top: 3rem;
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
color: var(--muted);
font-size: 0.75rem;
letter-spacing: 0.08em;
text-transform: uppercase;
opacity: 0;
}
.scroll-arrow {
width: 1px;
height: 32px;
background: linear-gradient(to bottom, var(--accent), transparent);
animation: arrow-pulse 1.8s ease-in-out infinite;
}
@keyframes arrow-pulse {
0%, 100% { opacity: 0.3; transform: scaleY(0.6); }
50% { opacity: 1; transform: scaleY(1); }
}
.reduced-motion .scroll-arrow { animation: none; opacity: 0.5; }
/* ── Gradient orbs ── */
.gradient-orb {
position: absolute;
border-radius: 50%;
filter: blur(80px);
will-change: transform;
}
.orb-1 {
width: 500px; height: 500px;
background: radial-gradient(circle, rgba(134, 232, 255, 0.2), transparent 70%);
top: 10%; right: 10%;
}
.orb-2 {
width: 400px; height: 400px;
background: radial-gradient(circle, rgba(174, 82, 255, 0.15), transparent 70%);
bottom: 20%; left: 5%;
}
.orb-3 {
width: 600px; height: 600px;
background: radial-gradient(circle, rgba(255, 64, 214, 0.12), transparent 70%);
top: 50%; left: 50%;
transform: translate(-50%, -50%);
}
.orb-4 {
width: 450px; height: 450px;
background: radial-gradient(circle, rgba(174, 82, 255, 0.18), transparent 70%);
top: 20%; left: 20%;
}
.orb-5 {
width: 350px; height: 350px;
background: radial-gradient(circle, rgba(255, 204, 102, 0.12), transparent 70%);
bottom: 30%; right: 15%;
}
.orb-6 {
width: 500px; height: 500px;
background: radial-gradient(circle, rgba(134, 232, 255, 0.15), transparent 70%);
top: 50%; left: 50%;
transform: translate(-50%, -50%);
}
/* ── Floating rings ── */
.floating-ring {
position: absolute;
border-radius: 50%;
border: 1px solid rgba(134, 232, 255, 0.15);
will-change: transform;
}
.ring-1 {
width: 300px; height: 300px;
top: 20%; left: 15%;
}
.ring-2 {
width: 200px; height: 200px;
bottom: 25%; right: 20%;
border-color: rgba(174, 82, 255, 0.15);
}
/* ── Depth grid ── */
.depth-grid {
position: absolute;
inset: 0;
background-image:
linear-gradient(rgba(134, 232, 255, 0.04) 1px, transparent 1px),
linear-gradient(90deg, rgba(134, 232, 255, 0.04) 1px, transparent 1px);
background-size: 60px 60px;
}
/* ── Depth cards ── */
.depth-card {
position: absolute;
width: 180px;
height: 100px;
border-radius: 12px;
background: rgba(18, 26, 43, 0.6);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(134, 232, 255, 0.12);
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
will-change: transform;
}
.card-inner {
font-size: 0.85rem;
font-weight: 600;
color: var(--accent);
text-transform: uppercase;
letter-spacing: 0.08em;
}
.card-1 { top: 25%; left: 10%; }
.card-2 { top: 40%; right: 8%; }
.card-3 { bottom: 20%; left: 30%; }
/* ── Back button ── */
.btn-back {
display: inline-block;
margin-top: 2.5rem;
padding: 0.7rem 2rem;
border-radius: 999px;
border: 1px solid rgba(134, 232, 255, 0.3);
color: var(--accent);
text-decoration: none;
font: 600 0.85rem/1 'Inter', system-ui, sans-serif;
transition: all 0.25s ease;
opacity: 0;
}
.btn-back:hover {
background: rgba(134, 232, 255, 0.08);
border-color: var(--accent);
}
/* ── Reduced motion ── */
.reduced-motion .layer-bg,
.reduced-motion .layer-mid {
transform: none !important;
}
.reduced-motion .eyebrow,
.reduced-motion .hero-title,
.reduced-motion .reveal-text,
.reduced-motion .hero-sub,
.reduced-motion .reveal-body,
.reduced-motion .scroll-hint,
.reduced-motion .depth-card,
.reduced-motion .btn-back {
opacity: 1 !important;
transform: none !important;
}
@media (max-width: 640px) {
.depth-card { width: 140px; height: 80px; }
.card-inner { font-size: 0.75rem; }
.gradient-orb { transform: scale(0.6); }
}
if (!window.MotionPreference) {
const __mql = window.matchMedia("(prefers-reduced-motion: reduce)");
const __listeners = new Set();
const MotionPreference = {
prefersReducedMotion() {
return __mql.matches;
},
setOverride(value) {
const reduced = Boolean(value);
document.documentElement.classList.toggle("reduced-motion", reduced);
window.dispatchEvent(new CustomEvent("motion-preference", { detail: { reduced } }));
for (const listener of __listeners) {
try {
listener({ reduced, override: reduced, systemReduced: __mql.matches });
} catch {}
}
},
onChange(listener) {
__listeners.add(listener);
try {
listener({
reduced: __mql.matches,
override: null,
systemReduced: __mql.matches,
});
} catch {}
return () => __listeners.delete(listener);
},
getState() {
return { reduced: __mql.matches, override: null, systemReduced: __mql.matches };
},
};
window.MotionPreference = MotionPreference;
}
function prefersReducedMotion() {
return window.MotionPreference.prefersReducedMotion();
}
function initDemoShell() {
// No-op shim in imported standalone snippets.
}
import gsap from 'gsap';
import { ScrollTrigger } from 'gsap/ScrollTrigger';
import Lenis from 'lenis';
gsap.registerPlugin(ScrollTrigger);
// ── Demo shell ──
initDemoShell({
title: 'Smooth Scroll Story',
category: 'scroll',
tech: ['gsap', 'lenis', 'scrolltrigger'],
});
// ── Lenis smooth scroll ──
const lenis = new Lenis({
lerp: 0.1,
smoothWheel: true,
});
lenis.on('scroll', ScrollTrigger.update);
gsap.ticker.add((time) => lenis.raf(time * 1000));
gsap.ticker.lagSmoothing(0);
// ── Respect reduced motion ──
const reduced = prefersReducedMotion();
if (reduced) {
document.documentElement.classList.add('reduced-motion');
}
// ── Listen for toggle ──
window.addEventListener('motion-preference', (e) => {
document.documentElement.classList.toggle('reduced-motion', e.detail.reduced);
// Rebuild ScrollTrigger on toggle
ScrollTrigger.refresh();
});
// ── Parallax layers ──
document.querySelectorAll('.section').forEach((section) => {
const bg = section.querySelector('.layer-bg');
const mid = section.querySelector('.layer-mid');
if (bg && !reduced) {
gsap.to(bg, {
yPercent: -15,
ease: 'none',
scrollTrigger: {
trigger: section,
start: 'top bottom',
end: 'bottom top',
scrub: 1,
},
});
}
if (mid && !reduced) {
gsap.to(mid, {
yPercent: -30,
ease: 'none',
scrollTrigger: {
trigger: section,
start: 'top bottom',
end: 'bottom top',
scrub: 1,
},
});
}
});
// ── Hero section entrance ──
const heroTl = gsap.timeline({ defaults: { ease: 'expo.out' } });
heroTl
.to('.section-hero .eyebrow', {
opacity: 1, y: 0, duration: reduced ? 0 : 0.8,
delay: 0.3,
})
.to('.hero-title', {
opacity: 1, y: 0, duration: reduced ? 0 : 1,
}, '-=0.5')
.to('.hero-sub', {
opacity: 1, y: 0, duration: reduced ? 0 : 0.8,
}, '-=0.6')
.to('.scroll-hint', {
opacity: 1, duration: reduced ? 0 : 0.6,
}, '-=0.3');
// Set initial positions
if (!reduced) {
gsap.set('.section-hero .eyebrow', { y: 20 });
gsap.set('.hero-title', { y: 40 });
gsap.set('.hero-sub', { y: 30 });
}
// ── Scroll-triggered reveals ──
document.querySelectorAll('.section:not(.section-hero)').forEach((section) => {
const eyebrow = section.querySelector('.eyebrow');
const heading = section.querySelector('.reveal-text');
const body = section.querySelector('.reveal-body');
const btn = section.querySelector('.btn-back');
const tl = gsap.timeline({
scrollTrigger: {
trigger: section,
start: 'top 70%',
end: 'top 20%',
toggleActions: 'play none none reverse',
},
defaults: { ease: 'expo.out' },
});
if (eyebrow) {
gsap.set(eyebrow, { y: reduced ? 0 : 20 });
tl.to(eyebrow, { opacity: 1, y: 0, duration: reduced ? 0 : 0.7 });
}
if (heading) {
gsap.set(heading, { y: reduced ? 0 : 50 });
tl.to(heading, { opacity: 1, y: 0, duration: reduced ? 0 : 0.9 }, '-=0.4');
}
if (body) {
gsap.set(body, { y: reduced ? 0 : 30 });
tl.to(body, { opacity: 1, y: 0, duration: reduced ? 0 : 0.7 }, '-=0.5');
}
if (btn) {
gsap.set(btn, { y: reduced ? 0 : 20 });
tl.to(btn, { opacity: 1, y: 0, duration: reduced ? 0 : 0.6 }, '-=0.3');
}
});
// ── Depth cards entrance ──
document.querySelectorAll('.depth-card').forEach((card, i) => {
if (!reduced) {
gsap.set(card, { y: 60, scale: 0.9 });
}
gsap.to(card, {
opacity: 1,
y: 0,
scale: 1,
duration: reduced ? 0 : 0.8,
ease: 'back.out(1.4)',
scrollTrigger: {
trigger: '.section-depth',
start: 'top 60%',
toggleActions: 'play none none reverse',
},
delay: i * 0.15,
});
});
// ── Floating ring rotation (continuous, subtle) ──
if (!reduced) {
gsap.to('.ring-1', {
rotation: 360,
duration: 30,
ease: 'none',
repeat: -1,
});
gsap.to('.ring-2', {
rotation: -360,
duration: 25,
ease: 'none',
repeat: -1,
});
}
// ── Fade scroll hint on scroll ──
ScrollTrigger.create({
trigger: '.section-hero',
start: 'top top',
end: '20% top',
onUpdate: (self) => {
gsap.set('.scroll-hint', { opacity: 1 - self.progress * 3 });
},
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Smooth Scroll Story — stealthisdesign</title>
<link rel="stylesheet" href="style.css">
<script type="importmap">{"imports":{"gsap":"/vendor/gsap/index.js","gsap/ScrollTrigger":"/vendor/gsap/ScrollTrigger.js","gsap/SplitText":"/vendor/gsap/SplitText.js","gsap/Flip":"/vendor/gsap/Flip.js","gsap/ScrambleTextPlugin":"/vendor/gsap/ScrambleTextPlugin.js","gsap/TextPlugin":"/vendor/gsap/TextPlugin.js","gsap/all":"/vendor/gsap/all.js","gsap/":"/vendor/gsap/","lenis":"/vendor/lenis/dist/lenis.mjs","three":"/vendor/three/build/three.module.js","three/addons/":"/vendor/three/examples/jsm/"}}</script>
<style>html.lenis,
html.lenis body {
height: auto;
}
.lenis:not(.lenis-autoToggle).lenis-stopped {
overflow: clip;
}
.lenis [data-lenis-prevent],
.lenis [data-lenis-prevent-wheel],
.lenis [data-lenis-prevent-touch] {
overscroll-behavior: contain;
}
.lenis.lenis-smooth iframe {
pointer-events: none;
}
.lenis.lenis-autoToggle {
transition-property: overflow;
transition-duration: 1ms;
transition-behavior: allow-discrete;
}</style>
</head>
<body>
<!-- Section 1: Hero -->
<section class="section section-hero" data-bg="#070a12">
<div class="layer layer-bg">
<div class="gradient-orb orb-1"></div>
<div class="gradient-orb orb-2"></div>
</div>
<div class="layer layer-mid">
<div class="floating-ring ring-1"></div>
<div class="floating-ring ring-2"></div>
</div>
<div class="layer layer-fg content">
<span class="eyebrow">Demo 01</span>
<h1 class="hero-title">Smooth<br>Scroll Story</h1>
<p class="hero-sub">Parallax layers driven by Lenis + GSAP ScrollTrigger</p>
<div class="scroll-hint">
<span>Scroll to explore</span>
<div class="scroll-arrow"></div>
</div>
</div>
</section>
<!-- Section 2: Reveal -->
<section class="section section-reveal" data-bg="#0a0e1a">
<div class="layer layer-bg">
<div class="gradient-orb orb-3"></div>
</div>
<div class="layer layer-fg content">
<span class="eyebrow">Chapter One</span>
<h2 class="reveal-text">Motion tells<br>a story.</h2>
<p class="reveal-body">Every scroll triggers a new layer of depth. Parallax creates the illusion of space, guiding the viewer through a cinematic narrative.</p>
</div>
</section>
<!-- Section 3: Depth -->
<section class="section section-depth" data-bg="#0e0818">
<div class="layer layer-bg">
<div class="depth-grid"></div>
</div>
<div class="layer layer-mid">
<div class="depth-card card-1">
<div class="card-inner">Performance</div>
</div>
<div class="depth-card card-2">
<div class="card-inner">Elegance</div>
</div>
<div class="depth-card card-3">
<div class="card-inner">Precision</div>
</div>
</div>
<div class="layer layer-fg content">
<span class="eyebrow">Chapter Two</span>
<h2 class="reveal-text">Layers of<br>meaning.</h2>
</div>
</section>
<!-- Section 4: Color -->
<section class="section section-color" data-bg="#12061a">
<div class="layer layer-bg">
<div class="gradient-orb orb-4"></div>
<div class="gradient-orb orb-5"></div>
</div>
<div class="layer layer-fg content">
<span class="eyebrow">Chapter Three</span>
<h2 class="reveal-text">Color shifts<br>with rhythm.</h2>
<p class="reveal-body">Ambient gradients flow as you scroll, responding to the narrative pace. Each section carries its own atmosphere.</p>
</div>
</section>
<!-- Section 5: Finale -->
<section class="section section-finale" data-bg="#070a12">
<div class="layer layer-bg">
<div class="gradient-orb orb-6"></div>
</div>
<div class="layer layer-fg content">
<span class="eyebrow">Finale</span>
<h2 class="reveal-text">The scroll<br>is the story.</h2>
<a href="/" class="btn-back">Back to Gallery</a>
</div>
</section>
<script type="module" src="script.js"></script>
</body>
</html>