<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebAuthn Ceremony | Passkey Sync & Recovery</title>
<!-- 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&family=Playfair+Display:ital,wght@0,600;0,700;1,600&display=swap" rel="stylesheet">
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif'],
},
colors: {
cyber: {
blue: '#00f3ff',
purple: '#bc13fe',
dark: '#050505',
surface: '#0f0f11'
}
},
boxShadow: {
'neon-blue': '0 0 20px rgba(0, 243, 255, 0.3)',
'neon-purple': '0 0 20px rgba(188, 19, 254, 0.3)',
}
}
}
}
</script>
<!-- Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Three.js & GSAP -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/studio-freight/lenis@1.0.29/bundled/lenis.min.js"></script>
<style>
/* Base Reset & Utilities */
body {
background-color: #050505;
color: #ffffff;
overflow-x: hidden;
margin: 0;
cursor: none; /* Custom cursor */
}
/* Custom Cursor */
#cursor {
position: fixed;
top: 0;
left: 0;
width: 20px;
height: 20px;
border: 1px solid rgba(255, 255, 255, 0.5);
border-radius: 50%;
pointer-events: none;
z-index: 9999;
transform: translate(-50%, -50%);
transition: width 0.3s, height 0.3s, background-color 0.3s;
mix-blend-mode: difference;
}
#cursor.active {
width: 50px;
height: 50px;
background-color: rgba(255, 255, 255, 0.1);
border-color: transparent;
}
/* Noise Texture Overlay */
.noise-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 50;
opacity: 0.04;
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");
}
/* Typography Hierarchy */
.display-text {
font-family: 'Playfair Display', serif;
line-height: 1;
}
.glass-card {
background: rgba(255, 255, 255, 0.03);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 1rem;
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}
/* Loader Animation */
.loader-ring {
border: 2px solid rgba(255,255,255,0.1);
border-left-color: #00f3ff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }
/* Gradient Text */
.text-gradient {
background: linear-gradient(to right, #00f3ff, #bc13fe);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
/* Vertical line for steps */
.step-line {
position: absolute;
left: 20px;
top: 40px;
bottom: -40px;
width: 1px;
background: linear-gradient(to bottom, #00f3ff, transparent);
}
</style>
</head>
<body>
<!-- Custom Cursor -->
<div id="cursor"></div>
<!-- Noise Overlay -->
<div class="noise-overlay"></div>
<!-- 3D Background -->
<canvas id="bg-canvas" class="fixed top-0 left-0 w-full h-full -z-10"></canvas>
<!-- Main Layout -->
<main class="relative z-10 container mx-auto px-6 md:px-12 pt-24 pb-32">
<!-- Header -->
<header class="flex justify-between items-center mb-32 opacity-0" id="header-anim">
<div class="text-sm tracking-[0.2em] uppercase font-bold text-gray-400">Secured by WebAuthn</div>
<nav class="hidden md:flex space-x-8 text-sm tracking-widest">
<a href="#" class="hover:text-cyber-blue transition-colors">Protocol</a>
<a href="#" class="hover:text-cyber-purple transition-colors">Recovery</a>
<a href="#" class="hover:text-cyber-blue transition-colors">Docs</a>
</nav>
<button class="magnetic-btn px-6 py-2 border border-white/20 hover:bg-white hover:text-black transition-all duration-300 text-xs uppercase tracking-widest font-semibold rounded-full">
Explore
</button>
</header>
<!-- Hero Section -->
<section class="min-h-[80vh] flex flex-col justify-center">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-16 items-center">
<div>
<h2 class="text-cyber-blue text-sm uppercase tracking-[0.2em] font-bold mb-4">The Future of Identity</h2>
<h1 class="display-text text-6xl md:text-8xl font-bold mb-8 leading-tight">
Passkey<br>Ceremony
</h1>
<p class="text-gray-400 text-lg md:text-xl leading-relaxed max-w-lg mb-12 font-serif">
A phishing-resistant, cross-device authentication flow. Experience the synergy of WebAuthn, synchronized credentials, and unbreakable recovery.
</p>
<div class="flex flex-col sm:flex-row gap-4">
<button id="start-ceremony-btn" class="group relative px-8 py-4 bg-white text-black font-bold uppercase tracking-widest overflow-hidden transition-all hover:scale-105 active:scale-95">
<span class="relative z-10">Start Ceremony</span>
<div class="absolute inset-0 h-full w-full bg-gradient-to-r from-cyber-blue to-cyber-purple opacity-0 group-hover:opacity-20 transition-opacity"></div>
</button>
<button class="px-8 py-4 border border-white/30 hover:bg-white/5 transition-all uppercase tracking-widest text-sm">
View Specs
</button>
</div>
</div>
<!-- 3D Visualization will reside here, controlled by Three.js -->
<div class="relative h-[500px] w-full flex items-center justify-center pointer-events-none">
<!-- Overlay interaction hints -->
<div class="absolute bottom-10 right-0 text-right text-xs text-gray-500 font-mono hidden md:block">
<div>RENDER: THREE.JS</div>
<div>FPS: <span id="fps-counter">60</span></div>
<div>PARTICLES: 2000</div>
</div>
</div>
</div>
</section>
<!-- Ceremony Stage (Hidden initially) -->
<section id="ceremony-stage" class="hidden py-20 relative">
<!-- Decorative BG Elements -->
<div class="absolute top-0 right-0 w-96 h-96 bg-cyber-blue/10 blur-[100px] rounded-full -z-10"></div>
<div class="absolute bottom-0 left-0 w-96 h-96 bg-cyber-purple/10 blur-[100px] rounded-full -z-10"></div>
<div class="max-w-4xl mx-auto">
<!-- Step Indicator -->
<div class="flex items-center justify-between mb-16 relative">
<div class="step-line hidden md:block"></div>
<!-- Step 1 -->
<div class="step-item z-10 flex flex-col items-center">
<div class="w-12 h-12 rounded-full border border-white/30 glass-card flex items-center justify-center mb-3 step-number" data-step="1">
<i class="fa-solid fa-mobile-screen-button text-xs"></i>
</div>
<span class="text-xs uppercase tracking-widest text-gray-400">Link Device</span>
</div>
<!-- Step 2 -->
<div class="step-item z-10 flex flex-col items-center">
<div class="w-12 h-12 rounded-full border border-white/30 glass-card flex items-center justify-center mb-3 step-number" data-step="2">
<i class="fa-solid fa-cloud-arrow-up text-xs"></i>
</div>
<span class="text-xs uppercase tracking-widest text-gray-400">Sync Key</span>
</div>
<!-- Step 3 -->
<div class="step-item z-10 flex flex-col items-center">
<div class="w-12 h-12 rounded-full border border-white/30 glass-card flex items-center justify-center mb-3 step-number" data-step="3">
<i class="fa-solid fa-fingerprint text-xs"></i>
</div>
<span class="text-xs uppercase tracking-widest text-gray-400">Biometric</span>
</div>
<!-- Step 4 -->
<div class="step-item z-10 flex flex-col items-center">
<div class="w-12 h-12 rounded-full border border-white/30 glass-card flex items-center justify-center mb-3 step-number" data-step="4">
<i class="fa-solid fa-shield-halved text-xs"></i>
</div>
<span class="text-xs uppercase tracking-widest text-gray-400">Recovery</span>
</div>
</div>
<!-- Content Card -->
<div class="glass-card p-8 md:p-16 min-h-[400px] flex flex-col justify-center items-center text-center relative overflow-hidden">
<!-- Background Glow -->
<div class="absolute top-0 left-1/2 -translate-x-1/2 w-64 h-32 bg-gradient-to-b from-cyber-blue/20 to-transparent blur-3xl -z-10"></div>
<!-- Scanning Line Animation -->
<div id="scan-line" class="absolute left-0 w-full h-1 bg-cyber-blue/50 shadow-[0_0_15px_#00f3ff] hidden z-20 transition-all duration-1000"></div>
<!-- Dynamic Content -->
<div id="step-content" class="w-full">
<!-- Injected via JS -->
</div>
<!-- Progress Bar -->
<div class="w-full h-1 bg-white/10 mt-8 rounded-full overflow-hidden">
<div id="progress-bar" class="h-full bg-gradient-to-r from-cyber-blue to-cyber-purple w-0 transition-all duration-700 ease-out"></div>
</div>
</div>
<!-- Controls -->
<div class="mt-8 flex justify-center gap-6">
<button id="prev-btn" class="px-6 py-3 border border-white/20 rounded-full text-sm uppercase tracking-widest hover:bg-white/10 disabled:opacity-30 disabled:cursor-not-allowed transition-all" disabled>
Previous
</button>
<button id="next-btn" class="px-10 py-3 bg-white text-black rounded-full font-bold text-sm uppercase tracking-widest hover:bg-cyber-blue hover:text-white hover:border hover:border-white transition-all duration-300">
Continue
</button>
</div>
</div>
</section>
<!-- Feature Grid (Bento) -->
<section class="mt-32 hidden" id="features-section">
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<!-- Card 1 -->
<div class="glass-card p-8 hover:border-cyber-blue/50 transition-colors duration-500">
<div class="text-cyber-blue text-3xl mb-6"><i class="fa-solid fa-wifi"></i></div>
<h3 class="text-xl font-bold mb-3">Cross-Device</h3>
<p class="text-gray-400 text-sm leading-relaxed">
Seamlessly authenticate from your phone to your laptop using Bluetooth Low Energy (BLE) or QR codes. No re-registration needed.
</p>
</div>
<!-- Card 2 -->
<div class="glass-card p-8 hover:border-cyber-purple/50 transition-colors duration-500">
<div class="text-cyber-purple text-3xl mb-6"><i class="fa-solid fa-key"></i></div>
<h3 class="text-xl font-bold mb-3">Encrypted Sync</h3>
<p class="text-gray-400 text-sm leading-relaxed">
Your private keys never leave your ecosystem via end-to-end encryption. Passkeys sync via Apple iCloud, Google Password Manager, or Microsoft Credential Manager.
</p>
</div>
<!-- Card 3 -->
<div class="glass-card p-8 hover:border-cyber-blue/50 transition-colors duration-500">
<div class="text-cyber-blue text-3xl mb-6"><i class="fa-solid fa-user-shield"></i></div>
<h3 class="text-xl font-bold mb-3">Phishing Resistant</h3>
<p class="text-gray-400 text-sm leading-relaxed">
WebAuthn is bound to the origin. A key registered on `example.com` will never work on `phishing-site.com`. Zero knowledge proof verification.
</p>
</div>
</div>
</section>
<!-- Footer -->
<footer class="mt-48 border-t border-white/10 pt-8 pb-12 flex flex-col md:flex-row justify-between text-xs text-gray-500 uppercase tracking-widest">
<div>© 2023 AuthCeremony Protocol.</div>
<div class="flex space-x-6 mt-4 md:mt-0">
<a href="#" class="hover:text-white transition-colors">Github</a>
<a href="#" class="hover:text-white transition-colors">Privacy</a>
<a href="#" class="hover:text-white transition-colors">Terms</a>
</div>
</footer>
</main>
<!-- Toast Notification Container -->
<div id="toast-container" class="fixed bottom-8 right-8 z-50 flex flex-col gap-3 pointer-events-none"></div>
<!-- TEMPLATES FOR STEPS -->
<template id="tpl-step-1">
<h2 class="text-3xl md:text-4xl serif font-bold mb-4">Connect Your Device</h2>
<p class="text-gray-300 max-w-md mx-auto mb-8">
We need to establish a cross-device handshake. Please ensure Bluetooth is enabled on both devices.
</p>
<div class="relative w-32 h-32 mx-auto mb-8">
<i class="fa-solid fa-bolt text-6xl text-cyber-blue absolute inset-0 animate-pulse"></i>
</div>
<div class="text-xs font-mono text-gray-500" id="status-text">Initializing BLE stack...</div>
</template>
<template id="tpl-step-2">
<h2 class="text-3xl md:text-4xl serif font-bold mb-4">Encrypt & Synchronize</h2>
<p class="text-gray-300 max-w-md mx-auto mb-8">
Your new public key pair is being generated and encrypted. The private key remains stored securely on your authenticator.
</p>
<div class="flex gap-4 justify-center mb-8">
<div class="w-16 h-16 border border-white/20 rounded-lg flex items-center justify-center text-xs text-gray-400">LAPTOP</div>
<div class="w-16 h-16 border border-cyber-blue/50 rounded-lg flex items-center justify-center text-cyber-blue">CLOUD</div>
<div class="w-16 h-16 border border-white/20 rounded-lg flex items-center justify-center text-xs text-gray-400">PHONE</div>
</div>
<div class="text-xs font-mono text-gray-500">Uploading public key chunk 4/4...</div>
</template>
<template id="tpl-step-3">
<h2 class="text-3xl md:text-4xl serif font-bold mb-4">User Verification</h2>
<p class="text-gray-300 max-w-md mx-auto mb-8">
Complete the biometric prompt on your device to finalize the binding of this credential.
</p>
<div class="relative w-24 h-24 mx-auto border-4 border-white/10 rounded-full flex items-center justify-center mb-8">
<div class="absolute inset-0 border-t-2 border-cyber-purple rounded-full animate-spin"></div>
<i class="fa-solid fa-fingerprint text-4xl text-cyber-purple"></i>
</div>
<div class="text-xs font-mono text-gray-500">Waiting for user gesture...</div>
</template>
<template id="tpl-step-4">
<h2 class="text-3xl md:text-4xl serif font-bold mb-4">Recovery Setup</h2>
<p class="text-gray-300 max-w-md mx-auto mb-4">
Passkeys are passwordless. However, to recover access across all devices, you must generate a single-use <strong>Recovery Key</strong>.
</p>
<div class="bg-black/40 border border-white/10 p-4 rounded font-mono text-sm text-center break-all w-full max-w-md mb-6" id="recovery-code">
<!-- Code injected here -->
</div>
<p class="text-xs text-cyber-blue italic">Store this code in a safe place. It cannot be recovered if lost.</p>
</template>
<template id="tpl-step-5">
<h2 class="text-3xl md:text-4xl serif font-bold mb-6 text-green-400">Ceremony Complete</h2>
<p class="text-gray-300 max-w-md mx-auto mb-8">
Your identity has been established. You are now protected against phishing,Man-in-the-Middle, and credential stuffing attacks.
</p>
<div class="flex justify-center gap-4 mb-8">
<div class="w-16 h-16 rounded-full bg-cyber-blue/20 flex items-center justify-center text-xl">✓</div>
</div>
<button onclick="location.reload()" class="px-8 py-3 border border-white/30 rounded-full hover:bg-white hover:text-black transition-all uppercase tracking-widest text-sm">
Start New Ceremony
</button>
</template>
<script>
/**
* 1. CONFIGURATION & STATE
*/
const state = {
currentStep: 0,
totalSteps: 5,
isProcessing: false,
recoveryCode: ''
};
const client = {
width: window.innerWidth,
height: window.innerHeight
};
/**
* 2. THREE.JS BACKGROUND SCENE
* Creates a dynamic wireframe geometry that reacts to mouse and scroll.
*/
const canvas = document.getElementById('bg-canvas');
const scene = new THREE.Scene();
// Fog to fade objects into background
scene.fog = new THREE.FogExp2(0x050505, 0.002);
const camera = new THREE.PerspectiveCamera(75, client.width / client.height, 0.1, 1000);
camera.position.z = 30;
const renderer = new THREE.WebGLRenderer({
canvas: canvas,
alpha: true,
antialias: true
});
renderer.setSize(client.width, client.height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
// Main Object: Complex Icosahedron (The "Authenticator Core")
const geometry = new THREE.IcosahedronGeometry(10, 2);
const wireframe = new THREE.WireframeGeometry(geometry);
const lineMaterial = new THREE.LineBasicMaterial({ color: 0x333333, transparent: true, opacity: 0.3 });
const sphereLines = new THREE.LineSegments(wireframe, lineMaterial);
scene.add(sphereLines);
// Inner glowing core
const coreGeo = new THREE.IcosahedronGeometry(4, 1);
const coreMat = new THREE.MeshBasicMaterial({ color: 0x00f3ff, wireframe: true, transparent: true, opacity: 0.6 });
const coreMesh = new THREE.Mesh(coreGeo, coreMat);
scene.add(coreMesh);
// Particle System (Ambient Data)
const particlesGeometry = new THREE.BufferGeometry();
const particlesCount = 2000;
const posArray = new Float32Array(particlesCount * 3);
for(let i = 0; i < particlesCount * 3; i++) {
posArray[i] = (Math.random() - 0.5) * 100;
}
particlesGeometry.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
const particlesMaterial = new THREE.PointsMaterial({
size: 0.15,
color: 0xbc13fe,
transparent: true,
opacity: 0.8,
blending: THREE.AdditiveBlending
});
const particlesMesh = new THREE.Points(particlesGeometry, particlesMaterial);
scene.add(particlesMesh);
// Mouse interaction
let mouseX = 0;
let mouseY = 0;
let targetRotationX = 0;
let targetRotationY = 0;
document.addEventListener('mousemove', (event) => {
mouseX = (event.clientX - client.width / 2) * 0.001;
mouseY = (event.clientY - client.height / 2) * 0.001;
});
/**
* 3. ANIMATION LOOP
*/
const clock = new THREE.Clock();
let time = 0;
function animate() {
const delta = clock.getDelta();
time += delta;
// Smooth rotation based on mouse
sphereLines.rotation.y += 0.002;
sphereLines.rotation.x += (mouseY - sphereLines.rotation.x) * 0.05;
sphereLines.rotation.y += (mouseX - sphereLines.rotation.y) * 0.05;
coreMesh.rotation.y -= 0.004;
coreMesh.rotation.x -= 0.002;
// Pulse effect based on step
if (state.currentStep === 2) { // Syncing
const scale = 1 + Math.sin(time * 5) * 0.1;
coreMesh.scale.set(scale, scale, scale);
} else if (state.currentStep === 3) { // Biometric
coreMesh.scale.set(1 + Math.sin(time * 10) * 0.2, 1 + Math.sin(time * 10) * 0.2, 1 + Math.sin(time * 10) * 0.2);
} else {
coreMesh.scale.lerp(new THREE.Vector3(1, 1, 1), 0.1);
}
// Color transition based on step
if (state.currentStep === 4) {
coreMat.color.setHex(0x00ff88); // Green for success
particlesMaterial.color.setHex(0x00ff88);
} else if (state.currentStep === 1) {
coreMat.color.setHex(0x00f3ff); // Blue for start
particlesMaterial.color.setHex(0xbc13fe); // Purple particles
} else if (state.currentStep === 2) {
coreMat.color.setHex(0xbc13fe); // Purple for sync
particlesMaterial.color.setHex(0x00f3ff); // Blue particles
} else {
coreMat.color.setHex(0x00f3ff);
particlesMaterial.color.setHex(0xbc13fe);
}
particlesMesh.rotation.y = time * 0.05;
particlesMesh.rotation.x = time * 0.02;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
// Resize handler
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
client.width = window.innerWidth;
client.height = window.innerHeight;
});
/**
* 4. CUSTOM MAGNETIC BUTTON & CURSOR
*/
const cursor = document.getElementById('cursor');
const magneticBtns = document.querySelectorAll('.magnetic-btn, #start-ceremony-btn, #next-btn, #prev-btn');
document.addEventListener('mousemove', (e) => {
cursor.style.left = e.clientX + 'px';
cursor.style.top = e.clientY + 'px';
});
magneticBtns.forEach(btn => {
btn.addEventListener('mouseenter', () => cursor.classList.add('active'));
btn.addEventListener('mouseleave', () => cursor.classList.remove('active'));
if(btn.classList.contains('magnetic-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)' });
});
}
});
/**
* 5. CEREMONY LOGIC
*/
const ceremonyStage = document.getElementById('ceremony-stage');
const stepContent = document.getElementById('step-content');
const progressBar = document.getElementById('progress-bar');
const prevBtn = document.getElementById('prev-btn');
const nextBtn = document.getElementById('next-btn');
const scanLine = document.getElementById('scan-line');
const stepNumbers = document.querySelectorAll('.step-number');
// Templates
const templates = [
document.getElementById('tpl-step-1'),
document.getElementById('tpl-step-2'),
document.getElementById('tpl-step-3'),
document.getElementById('tpl-step-4'),
document.getElementById('tpl-step-5')
];
// GSAP Animations for Header
gsap.to('#header-anim', { opacity: 1, duration: 1, delay: 0.5 });
// Start Button
document.getElementById('start-ceremony-btn').addEventListener('click', () => {
gsap.to('main', {
scrollTop: ceremonyStage.offsetTop - 100,
duration: 1.5,
ease: 'power4.inOut',
onComplete: () => {
ceremonyStage.classList.remove('hidden');
gsap.from(ceremonyStage, { opacity: 0, y: 50, duration: 1 });
}
});
// Animate 3D object zoom out slightly
gsap.to(camera.position, { z: 50, duration: 2, ease: "power2.out" });
});
// Step Functions
function updateCeremonyUI() {
// Update Progress Bar
const progress = (state.currentStep / (state.totalSteps - 1)) * 100;
progressBar.style.width = `${progress}%`;
// Update Step Indicators
stepNumbers.forEach(num => {
const stepIdx = parseInt(num.dataset.step);
if (stepIdx <= state.currentStep) {
num.classList.remove('border-white/30');
num.classList.add('bg-white', 'text-black', 'border-white');
num.innerHTML = '<i class="fa-solid fa-check"></i>';
} else {
num.classList.add('border-white/30');
num.classList.remove('bg-white', 'text-black', 'border-white');
// Reset icon
if(stepIdx===1) num.innerHTML = '<i class="fa-solid fa-mobile-screen-button text-xs"></i>';
if(stepIdx===2) num.innerHTML = '<i class="fa-solid fa-cloud-arrow-up text-xs"></i>';
if(stepIdx===3) num.innerHTML = '<i class="fa-solid fa-fingerprint text-xs"></i>';
if(stepIdx===4) num.innerHTML = '<i class="fa-solid fa-shield-halved text-xs"></i>';
}
});
// Inject Content
// Since we want to preserve animations, we clear and rebuild carefully
stepContent.innerHTML = '';
if (state.currentStep > 0 && state.currentStep < 4) {
const template = templates[state.currentStep - 1];
const clone = template.content.cloneNode(true);
stepContent.appendChild(clone);
// Simulate specific step behaviors
if (state.currentStep === 1) {
simulateBleConnection();
} else if (state.currentStep === 2) {
simulateSync();
} else if (state.currentStep === 3) {
simulateBiometric();
} else if (state.currentStep === 4) {
const codeEl = document.getElementById('recovery-code');
if (codeEl) {
state.recoveryCode = generateRecoveryCode();
codeEl.textContent = state.recoveryCode;
gsap.from(codeEl, { opacity: 0, y: 10, duration: 0.5, delay: 0.5 });
}
}
} else if (state.currentStep === 4) {
// Failure/End?
}
// Success Step
if (state.currentStep === 4) {
const template = templates[4];
const clone = template.content.cloneNode(true);
stepContent.appendChild(clone);
showToast("Ceremony Complete", "success");
}
// Button States
prevBtn.disabled = state.currentStep === 1;
if (state.currentStep === 4) nextBtn.textContent = "Finish";
else nextBtn.textContent = "Continue";
// Animate Content Entry
gsap.fromTo(stepContent.children,
{ opacity: 0, y: 20 },
{ opacity: 1, y: 0, duration: 0.6, ease: 'power2.out' }
);
}
// simulateStep Logic (Pseudo-async)
function simulateBleConnection() {
const status = document.getElementById('status-text');
let progress = 0;
const interval = setInterval(() => {
progress += 20;
const msgs = ["Scanning for BLE peripherals...", "Handshake initiated...", "Establishing encrypted channel...", "Verified."];
status.textContent = msgs[Math.floor(progress/33)];
if (progress >= 100) clearInterval(interval);
}, 800);
}
function simulateSync() {
// Simple feedback, no complex DOM needed yet
}
function simulateBiometric() {
const iconDiv = stepContent.querySelector('div.rounded-full');
if (iconDiv) {
// Shake effect
gsap.to(iconDiv, { x: -5, duration: 0.1, yoyo: true, repeat: 3 });
}
setTimeout(() => {
showToast("Biometric Verified", "info");
}, 1500);
}
function generateRecoveryCode() {
// Generate a realistic looking 32-char hex string
return '8f3a 2b1c 9e44 ' + Math.random().toString(16).slice(2, 8) + ' ' +
Math.random().toString(16).slice(2, 8) + ' ' +
Math.random().toString(16).slice(2, 8);
}
// Navigation
nextBtn.addEventListener('click', () => {
if (state.currentStep < state.totalSteps) {
if (state.currentStep < 4) {
state.currentStep++;
updateCeremonyUI();
// Reset scan line for step 1 visual
if(state.currentStep === 1) triggerScan();
} else if (state.currentStep === 4) {
state.currentStep++;
updateCeremonyUI();
}
}
});
prevBtn.addEventListener('click', () => {
if (state.currentStep > 1) {
state.currentStep--;
updateCeremonyUI();
}
});
function triggerScan() {
const line = document.getElementById('scan-line');
line.classList.remove('hidden');
line.style.top = '0%';
setTimeout(() => {
line.style.top = '100%';
}, 100);
}
/**
* 6. TOAST SYSTEM
*/
function showToast(message, type = 'info') {
const container = document.getElementById('toast-container');
const el = document.createElement('div');
const bgClass = type === 'success' ? 'bg-green-500/10 border-green-500/50 text-green-400'
: type === 'error' ? 'bg-red-500/10 border-red-500/50 text-red-400'
: 'bg-white/10 border-white/20 text-white';
el.className = `pointer-events-auto px-6 py-4 border rounded backdrop-blur-md shadow-lg text-sm font-mono transition-all duration-300 transform translate-y-10 opacity-0 ${bgClass}`;
el.innerHTML = `
<div class="flex items-center gap-3">
<i class="fa-solid ${type === 'success' ? 'fa-check' : 'fa-circle-info'}"></i>
<span>${message}</span>
</div>
`;
container.appendChild(el);
// Animate in
gsap.to(el, { y: 0, opacity: 1, duration: 0.4, ease: "back.out(1.7)" });
// Auto remove
setTimeout(() => {
gsap.to(el, { y: 20, opacity: 0, duration: 0.3, onComplete: () => el.remove() });
}, 4000);
}
/**
* 7. LENIS SMOOTH SCROLL
*/
const lenis = new Lenis({
duration: 1.2,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
direction: 'vertical',
gestureDirection: 'vertical',
smooth: true,
mouseMultiplier: 1,
smoothTouch: false,
touchMultiplier: 2,
});
function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
// Parallax effect on scroll
lenis.on('scroll', (e) => {
const scrollPct = e.scroll / (document.body.scrollHeight - window.innerHeight);
// Move particles slightly up/down
particlesMesh.position.y = scrollPct * 10;
});
</script>
</body>
</html>