<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CoSync | Realtime Collaboration Reimagined</title>
<!-- Tailwind CSS (Via CDN) -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;800&family=Playfair+Display:ital,wght@0,600;1,600&display=swap" rel="stylesheet">
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<!-- GSAP & ScrollTrigger -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
<!-- Lenis (Smooth Scroll) -->
<script src="https://cdn.jsdelivr.net/gh/studio-freight/lenis@1.0.29/bundled/lenis.min.js"></script>
<!-- Configure Tailwind -->
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif'],
},
colors: {
'void': '#050505',
'glass': 'rgba(255, 255, 255, 0.03)',
'glass-hover': 'rgba(255, 255, 255, 0.08)',
'accent-blue': '#3b82f6',
'accent-purple': '#8b5cf6',
},
boxShadow: {
'glow': '0 0 40px -10px rgba(59, 130, 246, 0.15)',
'inner-glow': 'inset 0 0 20px -5px rgba(255,255,255,0.05)',
}
}
}
}
</script>
<style>
/* Custom Utilities & Base Styles */
body {
background-color: #050505;
color: #e5e5e5;
overflow-x: hidden;
cursor: none; /* Custom cursor implementation */
}
/* Noise Grain Overlay */
.noise-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 50;
opacity: 0.05;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}
/* Custom Cursor */
.cursor-dot,
.cursor-circle {
position: fixed;
top: 0;
left: 0;
transform: translate(-50%, -50%);
border-radius: 50%;
pointer-events: none;
z-index: 9999;
mix-blend-mode: difference;
}
.cursor-dot {
width: 8px;
height: 8px;
background-color: white;
}
.cursor-circle {
width: 40px;
height: 40px;
border: 1px solid rgba(255, 255, 255, 0.5);
transition: width 0.2s, height 0.2s;
}
/* Glassmorphism Utilities */
.glass-panel {
background: rgba(20, 20, 25, 0.6);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}
/* Custom Scrollbar hidden */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
.no-scrollbar {
-ms-overflow-style: none;
scrollbar-width: none;
}
/* Typography tweaks */
.text-display {
line-height: 1.1;
letter-spacing: -0.03em;
}
/* Presence Cursor Simulation */
.presence-cursor {
position: absolute;
pointer-events: none;
transition: transform 0.1s linear;
z-index: 10;
}
.presence-avatar {
position: absolute;
bottom: 20px;
right: 4px;
width: 24px;
height: 24px;
border-radius: 50%;
border: 2px solid rgba(15, 23, 42, 0.8);
display: flex;
align-items: center;
justify-content: center;
font-size: 10px;
font-weight: bold;
color: white;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
/* Magnetic Button Class */
.magnetic-area {
display: inline-block;
transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}
/* Hide canvas initially to prevent flash */
#bg-canvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
opacity: 0;
transition: opacity 1s ease-out;
}
</style>
</head>
<body class="antialiased selection:bg-accent-blue selection:text-white">
<!-- Custom Cursor Elements -->
<div class="cursor-dot"></div>
<div class="cursor-circle"></div>
<!-- Background layered elements -->
<canvas id="bg-canvas"></canvas>
<div class="noise-overlay"></div>
<!-- Navigation -->
<nav class="fixed top-0 w-full z-40 px-6 py-4 flex justify-between items-center mix-blend-difference text-white">
<div class="text-2xl font-extrabold tracking-tighter logo-magnetic magnetic-area">
CoSync.
</div>
<div class="flex items-center gap-6">
<span class="hidden md:block text-sm font-medium opacity-80">v2.4.0 (Stable)</span>
<div class="flex -space-x-2">
<!-- Presence Avatars -->
<div class="presence-avatar !border-none relative w-10 h-10 bg-gray-800 border border-gray-700" title="You">
<span class="text-xs">ME</span>
</div>
<div class="presence-avatar bg-blue-500 border-blue-400" title="Sarah - Editing">S</div>
<div class="presence-avatar bg-emerald-500 border-emerald-400" title="Mike - Viewing">M</div>
<div class="presence-avatar bg-purple-500 border-purple-400" title="Jen - Commenting">J</div>
</div>
</div>
</nav>
<!-- Main Content -->
<main class="relative z-10 pt-32 pb-20 px-6 md:px-12 max-w-7xl mx-auto">
<!-- Hero Section -->
<section class="min-h-[80vh] flex flex-col justify-center mb-32">
<div class="overflow-hidden mb-6">
<p class="text-accent-blue font-mono text-sm tracking-widest uppercase hero-reveal">
Real-time Collaboration Engine
</p>
</div>
<h1 class="text-display text-5xl md:text-7xl lg:text-8xl font-extrabold text-white mb-8 leading-[0.9] hero-reveal">
DOCUMENTS <br>
<span class="text-transparent bg-clip-text bg-gradient-to-r from-blue-400 via-purple-400 to-pink-400 italic font-serif">Have Memory</span>
</h1>
<p class="max-w-xl text-lg md:text-xl text-gray-400 mb-10 leading-relaxed hero-reveal">
Experience the next evolution of teamwork. Presence, conflict resolution, and version storytelling woven into a single, fluid interface.
</p>
<div class="flex gap-4 hero-reveal">
<button id="demoBtn" class="magnetic-area group relative px-8 py-4 bg-white text-black font-bold rounded-none overflow-hidden">
<span class="relative z-10 group-hover:text-white transition-colors duration-300">Start Creating</span>
<div class="absolute inset-0 bg-accent-blue transform scale-x-0 group-hover:scale-x-100 transition-transform origin-left duration-300 ease-out"></div>
</button>
<button class="magnetic-area px-8 py-4 border border-gray-600 text-white hover:bg-white/10 transition-colors duration-300 rounded-none">
View Specs
</button>
</div>
</section>
<!-- Feature 1: Presence Indicators -->
<section class="min-h-screen py-20 relative mb-20">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-16 items-center">
<div class="space-y-8">
<div class="badge bg-blue-500/10 text-blue-400 px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wider w-fit">
Feature 01
</div>
<h2 class="text-4xl md:text-5xl font-bold text-white">Feel the <br>Presence.</h2>
<p class="text-gray-400 text-lg leading-relaxed">
Never wonder if someone is looking at the document again. Our low-latency cursor streaming shows exactly where your team is focusing in real-time. See selections, edits, and even the hesitation before the keystroke.
</p>
<ul class="space-y-4 text-gray-300">
<li class="flex items-center gap-3">
<span class="w-2 h-2 bg-accent-blue rounded-full"></span> Live cursor telemetry
</li>
<li class="flex items-center gap-3">
<span class="w-2 h-2 bg-accent-blue rounded-full"></span> Selection highlighting
</li>
<li class="flex items-center gap-3">
<span class="w-2 h-2 bg-accent-blue rounded-full"></span> User identity badges
</li>
</ul>
</div>
<!-- Interactive Demo Area -->
<div id="presence-demo" class="h-[400px] glass-panel rounded-2xl relative overflow-hidden border border-white/5 transition-all duration-500">
<!-- Fake doc content -->
<div class="absolute inset-0 p-12 font-serif text-lg text-gray-500 leading-loose pointer-events-none select-none opacity-30">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
<div id="active-doc-text" class="absolute top-12 left-12 right-12 text-xl text-gray-200 font-mono leading-relaxed">
<p class="mb-4">Project Genesis: Q4 Roadmap</p>
<p><span class="text-blue-400 font-bold">>></span> <span id="typing-text">Research indicates a 40% increase in engagement...</span><span class="animate-pulse">|</span></p>
<p class="mt-4 text-gray-500">...</p>
</div>
<!-- Simulated Cursors -->
<div id="cursor-sarah" class="presence-cursor pointer-events-none opacity-0">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#3b82f6" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"></path></svg>
<div class="presence-avatar bg-blue-500 !border-blue-400">S</div>
</div>
<div id="cursor-mike" class="presence-cursor pointer-events-none opacity-0">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#10b981" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"></path></svg>
<div class="presence-avatar bg-emerald-500 !border-emerald-400">M</div>
</div>
<!-- Scroll hint -->
<div class="absolute bottom-4 right-4 text-xs text-gray-600 font-mono">
SCROLL FOR MORE
</div>
</div>
</div>
</section>
<!-- Feature 2: Conflict Resolution -->
<section class="min-h-screen py-20 mb-20 relative">
<div class="absolute inset-0 bg-gradient-to-b from-transparent via-purple-900/10 to-transparent pointer-events-none"></div>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-16 items-center relative">
<!-- Visual Element -->
<div class="order-2 lg:order-1 h-[500px] glass-panel rounded-2xl p-1 relative flex items-center justify-center perspective-1000">
<div class="absolute inset-0 flex items-center justify-center bg-gradient-to-br from-gray-900 to-black opacity-50"></div>
<!-- Conflict Cards -->
<div id="conflict-container" class="relative w-full max-w-md h-[300px] preserve-3d">
<!-- Common Origin -->
<div class="absolute w-full h-full bg-gray-900 border border-gray-700 rounded-xl p-6 flex items-center justify-center opacity-0 translate-z-0" data-depth="0">
<p class="text-gray-500 font-mono text-sm">Base Document...</p>
</div>
<!-- Branch A (Left) -->
<div class="absolute w-[48%] h-[90%] left-0 top-5 bg-gray-900 border border-blue-500/50 rounded-xl p-4 transform rotate-y-15 opacity-0 transition-all duration-700 shadow-[0_0_30px_rgba(59,130,246,0.1)]" data-depth="-1">
<div class="text-blue-400 text-xs font-bold mb-2">PROPOSAL BY SARAH</div>
<p class="text-sm text-gray-300">"Aggressive monetization strategy risks alienating early adopters. We should prioritize retention."</p>
</div>
<!-- Branch B (Right) -->
<div class="absolute w-[48%] h-[90%] right-0 top-5 bg-gray-900 border border-purple-500/50 rounded-xl p-4 transform -rotate-y-15 opacity-0 transition-all duration-700 shadow-[0_0_30px_rgba(139,92,246,0.1)]" data-depth="1">
<div class="text-purple-400 text-xs font-bold mb-2">PROPOSAL BY MIKE</div>
<p class="text-sm text-gray-300">"Growth requires investment. We need to push ads immediately to hit Q4 targets."</p>
</div>
<!-- Merge State (Center) -->
<div id="merged-state" class="absolute w-full h-full bg-gradient-to-br from-blue-900/20 to-purple-900/20 border border-accent-blue/30 rounded-xl p-6 flex flex-col justify-center items-center opacity-0 transform scale-90 transition-all duration-700 shadow-[0_0_50px_rgba(59,130,246,0.2)]">
<div class="text-white font-bold mb-2 text-xl">Consensus Reached</div>
<p class="text-center text-gray-300 text-sm">"Implement phased approach: retain early users while exploring ad-pilot programs."</p>
<div class="mt-4 flex gap-2">
<span class="px-2 py-1 bg-blue-500/20 text-blue-300 rounded text-xs">Sarah Approved</span>
<span class="px-2 py-1 bg-purple-500/20 text-purple-300 rounded text-xs">Mike Approved</span>
</div>
</div>
</div>
</div>
<div class="order-1 lg:order-2 space-y-8">
<div class="badge bg-purple-500/10 text-purple-400 px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wider w-fit">
Feature 02
</div>
<h2 class="text-4xl md:text-5xl font-bold text-white">Resolve Conflicts <br>Without Chaos.</h2>
<p class="text-gray-400 text-lg leading-relaxed">
When edits diverge, CoSync visualizes the branching paths. Users can see the intent behind changes, compare diffs spatially, and merge directly in the 3D space—turning friction into alignment.
</p>
<button id="resolveBtn" class="magnetic-area px-8 py-4 bg-gradient-to-r from-purple-600 to-blue-600 text-white font-bold rounded-full shadow-glow hover:shadow-lg transition-all transform hover:scale-105">
Simulate Merge
</button>
</div>
</div>
</section>
<!-- Feature 3: Document Version Storytelling -->
<section class="min-h-[120vh] py-20 mb-20 relative">
<div class="text-center max-w-2xl mx-auto mb-32">
<div class="badge bg-pink-500/10 text-pink-400 px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wider w-fit mx-auto mb-4">
Feature 03
</div>
<h2 class="text-4xl md:text-6xl font-bold text-white mb-6">The Document's <br>Memory.</h2>
<p class="text-gray-400 text-lg">
Every keystroke is a moment in time. Scroll through the timeline to see the document evolve, not just as text, but as a living artifact of your team's thought process.
</p>
</div>
<!-- Version Scrubber Interface -->
<div class="relative w-full h-[600px] flex items-center justify-center perspective-container">
<!-- Timeline Track -->
<div class="absolute w-full max-w-4xl h-1 bg-gray-800 top-1/2 -translate-y-1/2 rounded-full overflow-visible left-0 right-0 mx-auto">
<!-- Tick Marks -->
<div class="absolute left-[0%] -translate-x-1/2 -translate-y-2 text-xs text-gray-500 font-mono">V1</div>
<div class="absolute left-[25%] -translate-x-1/2 -translate-y-2 text-xs text-gray-500 font-mono">V2</div>
<div class="absolute left-[50%] -translate-x-1/2 -translate-y-2 text-xs text-gray-500 font-mono">V3</div>
<div class="absolute left-[75%] -translate-x-1/2 -translate-y-2 text-xs text-gray-500 font-mono">V4</div>
<div class="absolute left-[100%] -translate-x-1/2 -translate-y-2 text-xs text-gray-500 font-mono">NOW</div>
</div>
<!-- Slider Handle -->
<input type="range" min="0" max="100" value="100" id="version-slider"
class="absolute z-20 w-full max-w-4xl h-1 opacity-0 cursor-pointer top-1/2 -translate-y-1/2">
<!-- Custom Thumb Visual -->
<div id="slider-thumb" class="absolute z-10 w-6 h-6 bg-white rounded-full shadow-[0_0_20px_rgba(255,255,255,0.8)] top-1/2 -translate-y-1/2 border-4 border-black pointer-events-none transition-all duration-75 ease-out"></div>
<!-- 3D Stack of Documents Versions -->
<div id="version-stack" class="absolute w-[300px] h-[400px] preserve-3d" style="transform-style: preserve-3d;">
<!-- We will inject these via JS for precise positioning based on slider -->
</div>
</div>
<div class="text-center mt-12 opacity-60 text-sm text-gray-500">
Drag the slider to travel through the document's history
</div>
</section>
<!-- CTA Section -->
<section class="py-32 text-center relative overflow-hidden">
<div class="absolute inset-0 bg-gradient-radial from-blue-900/20 to-transparent"></div>
<h2 class="text-5xl md:text-7xl font-bold text-white mb-10 relative z-10">Ready to evolve?</h2>
<button class="magnetic-area relative z-10 px-12 py-5 bg-white text-black text-xl font-bold rounded-full hover:bg-accent-blue hover:text-white transition-all duration-300 shadow-[0_0_40px_-10px_rgba(255,255,255,0.5)]">
Start Free Trial
</button>
<p class="mt-6 text-gray-500 text-sm relative z-10">No credit card required • Works in any browser</p>
</section>
</main>
<footer class="border-t border-gray-800 py-12 text-center text-gray-600 text-sm">
© 2024 CoSync Inc. Designed for the future of work.
</footer>
<!-- LOGIC -->
<script>
// --- 1. Custom Cursor ---
const cursorDot = document.querySelector('.cursor-dot');
const cursorCircle = document.querySelector('.cursor-circle');
let mouseX = -100, mouseY = -100;
let circleX = -100, circleY = -100;
document.addEventListener('mousemove', (e) => {
mouseX = e.clientX;
mouseY = e.clientY;
// Immediate update for dot
cursorDot.style.left = mouseX + 'px';
cursorDot.style.top = mouseY + 'px';
});
// Smooth follow for ring
function animateCursor() {
const dt = 0.15; // easing factor
circleX += (mouseX - circleX) * dt;
circleY += (mouseY - circleY) * dt;
cursorCircle.style.left = circleX + 'px';
cursorCircle.style.top = circleY + 'px';
requestAnimationFrame(animateCursor);
}
animateCursor();
// Magnetic Buttons Effect
const magneticBtns = document.querySelectorAll('.magnetic-area');
magneticBtns.forEach(btn => {
btn.addEventListener('mousemove', (e) => {
const rect = btn.getBoundingClientRect();
const x = e.clientX - rect.left - rect.width / 2;
const y = e.clientY - rect.top - rect.height / 2;
gsap.to(btn, {
x: x * 0.3,
y: y * 0.3,
duration: 0.3,
ease: 'power2.out'
});
});
btn.addEventListener('mouseleave', () => {
gsap.to(btn, {
x: 0,
y: 0,
duration: 0.5,
ease: 'elastic.out(1, 0.3)'
});
});
});
// --- 2. Three.js Background (Digital Aurora) ---
const initThreeJS = () => {
const canvas = document.getElementById('bg-canvas');
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer({ canvas: canvas, alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
// Particles
const particlesGeometry = new THREE.BufferGeometry();
const particlesCount = 700;
const posArray = new Float32Array(particlesCount * 3);
for(let i = 0; i < particlesCount * 3; i++) {
// Spread wide
posArray[i] = (Math.random() - 0.5) * 20;
}
particlesGeometry.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
// Material with custom colors
const particlesMaterial = new THREE.PointsMaterial({
size: 0.03,
color: 0x3b82f6, // Blue
transparent: true,
opacity: 0.6,
blending: THREE.AdditiveBlending
});
// Add larger colored particles (some purple/pink)
const colors = [];
const color1 = new THREE.Color(0x3b82f6);
const color2 = new THREE.Color(0x8b5cf6);
for(let i=0; i<particlesCount; i++) {
const mixed = color1.clone().lerp(color2, Math.random());
colors.push(mixed.r, mixed.g, mixed.b);
}
particlesGeometry.setAttribute('color', new THREE.Float32BufferAttribute(colors, 3));
particlesMaterial.vertexColors = true;
const particlesMesh = new THREE.Points(particlesGeometry, particlesMaterial);
scene.add(particlesMesh);
// Floating Mesh Lines (Grid)
const wireframeGeo = new THREE.IcosahedronGeometry(4, 1);
const wireframeMat = new THREE.MeshBasicMaterial({
color: 0x3b82f6,
wireframe: true,
transparent: true,
opacity: 0.05
});
const wireframeMesh = new THREE.Mesh(wireframeGeo, wireframeMat);
scene.add(wireframeMesh);
camera.position.z = 5;
// Animation Loop
const clock = new THREE.Clock();
const animate = () => {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
// Gentle rotation
particlesMesh.rotation.y = elapsed * 0.05;
particlesMesh.rotation.x = elapsed * 0.02;
wireframeMesh.rotation.x = elapsed * 0.1;
wireframeMesh.rotation.y = elapsed * 0.15;
// Wave effect
const positions = particlesGeometry.attributes.position.array;
for(let i = 0; i < particlesCount; i++) {
const i3 = i * 3;
const x = particlesGeometry.attributes.position.array[i3];
// Modify Y slightly based on X and Time
particlesGeometry.attributes.position.array[i3 + 1] = Math.sin(elapsed + x) * 0.5 + (Math.random() - 0.5) * 0.01;
}
particlesGeometry.attributes.position.needsUpdate = true;
renderer.render(scene, camera);
};
animate();
// Reveal canvas
setTimeout(() => {
canvas.style.opacity = 1;
}, 500);
// Resize handling
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
};
// --- 3. Presence Simulation (Cursors) ---
const initPresence = () => {
const container = document.getElementById('presence-demo');
const cursorS = document.getElementById('cursor-sarah');
const cursorM = document.getElementById('cursor-mike');
const textSpan = document.getElementById('typing-text');
const phrases = [
"Research indicates a 40% increase in engagement...",
"Wait, we forgot to update the Q3 numbers.",
"I think we should pivot to subscription model.",
"Does anyone have the latest Figma link?",
"Approved. Moving to production.",
"Can we table this for the retro?"
];
// Phrase typing simulation
let phraseIndex = 0;
let charIndex = 0;
let isDeleting = false;
function typeLoop() {
const currentPhrase = phrases[phraseIndex];
if (isDeleting) {
textSpan.textContent = currentPhrase.substring(0, charIndex - 1);
charIndex--;
} else {
textSpan.textContent = currentPhrase.substring(0, charIndex + 1);
charIndex++;
}
if (!isDeleting && charIndex === currentPhrase.length) {
isDeleting = true;
setTimeout(typeLoop, 2000); // Pause at end
} else if (isDeleting && charIndex === 0) {
isDeleting = false;
phraseIndex = (phraseIndex + 1) % phrases.length;
setTimeout(typeLoop, 500);
} else {
setTimeout(typeLoop, isDeleting ? 30 : 50);
}
}
// Start typing after scroll into view trigger
// Cursor movement random targets
function animateCursor(element, xMin, xMax, yMin, yMax, speed) {
let tx = Math.random() * (xMax - xMin) + xMin;
let ty = Math.random() * (yMax - yMin) + yMin;
gsap.to(element, {
x: tx,
y: ty,
duration: speed,
ease: "none",
onComplete: () => {
tx = Math.random() * (xMax - xMin) + xMin;
ty = Math.random() * (yMax - yMin) + yMin;
// Random speed variation
gsap.to(element, {
x: tx,
y: ty,
duration: Math.random() * 2 + 1,
ease: "none",
onComplete: arguments.callee // recursion
});
}
});
}
// ScrollTrigger to start animation when visible
gsap.to(cursorS, { opacity: 1, duration: 1 });
gsap.to(cursorM, { opacity: 1, duration: 1, delay: 0.5 });
// Start loops
animateCursor(cursorS, 50, 300, 100, 250, 2);
animateCursor(cursorM, 320, 550, 100, 250, 2.5);
// Hook typing to visibility
ScrollTrigger.create({
trigger: "#presence-demo",
start: "top 60%",
onEnter: () => typeLoop()
});
};
// --- 4. Conflict Resolution Animation ---
const initConflict = () => {
const resolveBtn = document.getElementById('resolveBtn');
const container = document.querySelector('#conflict-container');
const branches = container.querySelectorAll('[data-depth]');
const merged = document.getElementById('merged-state');
let resolved = false;
// Initial state: branches apart
gsap.set(branches[0], { opacity: 1, transform: "translateX(-40%) rotateY(15deg)" });
gsap.set(branches[1], { opacity: 1, transform: "translateX(40%) rotateY(-15deg)" });
resolveBtn.addEventListener('click', () => {
if (resolved) {
// Reset
gsap.to(branches[0], { opacity: 1, x: '-40%', rotateY: 15, duration: 0.8, ease: "power2.inOut" });
gsap.to(branches[1], { opacity: 1, x: '40%', rotateY: -15, duration: 0.8, ease: "power2.inOut" });
gsap.to(merged, { opacity: 0, scale: 0.9, duration: 0.5, onComplete: () => gsap.set(merged, { display: 'none' }) });
resolveBtn.textContent = "Simulate Merge";
resolveBtn.classList.remove('bg-green-600', 'hover:bg-green-700');
resolveBtn.classList.add('from-purple-600', 'to-blue-600');
resolved = false;
} else {
// Merge Action
gsap.to(branches[0], { opacity: 0, x: '-20%', rotateY: 0, duration: 0.8, ease: "power2.inOut" });
gsap.to(branches[1], { opacity: 0, x: '20%', rotateY: 0, duration: 0.8, ease: "power2.inOut" });
setTimeout(() => {
gsap.set(merged, { display: 'flex' });
gsap.to(merged, { opacity: 1, scale: 1, duration: 0.8, ease: "back.out(1.7)" });
}, 400);
resolveBtn.textContent = "Reset Conflict";
resolveBtn.classList.remove('from-purple-600', 'to-blue-600');
resolveBtn.classList.add('bg-green-600', 'hover:bg-green-700');
resolved = true;
}
});
};
// --- 5. Version Storytelling (Slider + 3D Stack) ---
const initVersionStory = () => {
const slider = document.getElementById('version-slider');
const thumb = document.getElementById('slider-thumb');
const stack = document.getElementById('version-stack');
// Version Data
const versions = [
{ id: 1, label: "V1", content: "Project Kickoff\n- Define goals\n- Assign roles", color: "bg-gray-800", z: -200, rot: -10 },
{ id: 2, label: "V2", content: "Research Phase\n- User interviews\n- Competitive anal.", color: "bg-gray-900", z: -100, rot: -5 },
{ id: 3, label: "V3", content: "Design Sprint\n- Wireframes\n- Prototyping", color: "bg-gray-800", z: 0, rot: 0 },
{ id: 4, label: "NOW", content: "Active Build\n- Frontend dev\n- Backend APIs", color: "bg-blue-900/40 border-blue-500/50", z: 100, rot: 5, glow: true }
];
// Construct DOM for each version
versions.forEach((v, index) => {
const el = document.createElement('div');
el.className = `absolute w-full h-full glass-panel rounded-xl p-6 flex flex-col justify-between transition-all duration-100 ease-linear`;
el.dataset.index = index;
// Style specific version
el.style.background = v.color.includes('bg-') ? '' : 'rgba(0,0,0,0.5)';
el.style.border = v.color.includes('border') ? '' : '1px solid rgba(255,255,255,0.1)';
if (v.glow) el.style.boxShadow = `0 0 30px -5px rgba(59, 130, 246, 0.3)`;
el.innerHTML = `
<div class="flex justify-between items-start border-b border-gray-700/50 pb-2">
<span class="font-bold text-white text-sm tracking-widest opacity-80">${v.label}</span>
<span class="text-xs text-gray-500 font-mono">23 Oct 2024</span>
</div>
<div class="font-mono text-sm leading-relaxed text-gray-300 whitespace-pre-wrap flex-1 overflow-hidden">
${v.content}
</div>
<div class="mt-4 flex items-center gap-2 opacity-50">
<div class="w-2 h-2 rounded-full ${index === 0 ? 'bg-blue-500' : index===1 ? 'bg-emerald-500' : index===2 ? 'bg-orange-500' : 'bg-purple-500'}"></div>
<div class="h-1 flex-1 bg-gray-800 rounded-full overflow-hidden">
<div class="h-full bg-current w-[${index * 25 + 10}%]"></div>
</div>
</div>
`;
stack.appendChild(el);
});
// Function to update positions based on slider value (0-100)
const updatePositions = (val) => {
const normalized = val / 100; // 0 to 1
// Move Thumb
const thumbPos = normalized * 100; // percentage of track
thumb.style.left = `calc(${thumbPos}% - 12px)`; // center offset
// Position and rotate stack items
const items = stack.querySelectorAll('div');
// Logic:
// If val is near 100 (Now), items spread out evenly.
// If val is low, items stack tightly.
const baseZ = 200; // compression depth offset
items.forEach((item, i) => {
const v = versions[i];
// Determine offsetX for each version relative to center
// Range: -300px to +300px depending on spread
// Use a spread multiplier.
// Intuition: As slider moves right, we "look" at the future, so the stack should align to show the most recent clearly.
// Let's make slider control the Z-index and X offset.
const targetX = (i * 150) - 225; // -225, -75, 75, 225 for 4 items centered
// Scale opacity based on distance? No, just stacking.
// Apply transform
item.style.transform = `translateX(${targetX}px) translateZ(${v.z}px) rotateY(${v.rot}deg)`;
// Opacity based on focus
const dist = Math.abs(i - (normalized * (versions.length-1)));
item.style.opacity = Math.max(0.3, 1 - dist);
item.style.filter = dist < 0.5 ? 'blur(0px)' : 'blur(2px)';
});
};
// Initial state: Show 'NOW' (Slider 100)
gsap.set(stack, { transformPerspective: 1000, transformStyle: "preserve-3d" });
updatePositions(100);
// Event Listener
slider.addEventListener('input', (e) => {
gsap.to(stack, { duration: 0.1 }); // trigger update smooth
updatePositions(e.target.value);
});
// Animate on scroll into view
ScrollTrigger.create({
trigger: "#version-stack",
start: "top 70%",
onEnter: () => {
gsap.fromTo(stack,
{ rotationX: 20, opacity: 0 },
{ rotationX: 0, opacity: 1, duration: 1.5, ease: "power3.out" }
);
}
});
};
// --- 6. Lenis Smooth Scroll & Init ---
const initApp = () => {
// Init Three
initThreeJS();
// Init Sections
initPresence();
initConflict();
initVersionStory();
// GSAP Register
gsap.registerPlugin(ScrollTrigger);
// Hero Reveal
gsap.from('.hero-reveal', {
y: 100,
opacity: 0,
duration: 1.2,
stagger: 0.2,
ease: "power3.out",
delay: 0.5
});
// Lenis Smooth Scroll
const lenis = new Lenis({
duration: 1.2,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
orientation: 'vertical',
gestureOrientation: 'vertical',
smoothWheel: true,
});
function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
};
// Boot
document.addEventListener('DOMContentLoaded', initApp);
</script>
</body>
</html>