<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Personalization Orchestration Layer</title>
<!-- Fonts: Inter (Sans) & Playfair Display (Serif) -->
<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;700&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&display=swap" rel="stylesheet">
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- GSAP -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<!-- Tailwind Config for Custom Colors/Fonts -->
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif'],
},
colors: {
dark: '#0a0a0a',
surface: '#141414',
'surface-light': '#1f1f1f',
primary: '#06b6d4', // cyan-500
secondary: '#a855f7', // purple-500
accent: '#10b981', // emerald-500
},
boxShadow: {
'glow-cyan': '0 0 20px -2px rgba(6, 182, 212, 0.3)',
'glow-purple': '0 0 20px -2px rgba(168, 85, 247, 0.3)',
'glow-emerald': '0 0 20px -2px rgba(16, 185, 129, 0.3)',
}
}
}
}
</script>
<style>
/* Custom Base Styles */
body {
background-color: #0a0a0a;
color: #e2e8f0;
overflow-x: hidden;
}
/* Grain Noise Overlay */
.grain {
position: fixed;
top: 0; left: 0; width: 100%; height: 100%;
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)' opacity='0.05'/%3E%3C/svg%3E");
pointer-events: none;
z-index: 50;
mix-blend-mode: overlay;
}
/* Custom Scrollbar */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: #0a0a0a;
}
::-webkit-scrollbar-thumb {
background: #334155;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #475569;
}
/* Glassmorphism Utilities */
.glass {
background: rgba(20, 20, 20, 0.6);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.08);
}
.glass-dynamic {
background: rgba(20, 20, 20, 0.4);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.06);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}
/* Range Slider Styling */
input[type=range] {
-webkit-appearance: none;
background: transparent;
height: 4px;
border-radius: 2px;
outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 4px;
cursor: pointer;
background: #334155;
border-radius: 2px;
}
input[type=range]::-webkit-slider-thumb {
height: 16px;
width: 16px;
border-radius: 50%;
background: #e2e8f0;
cursor: pointer;
-webkit-appearance: none;
margin-top: -6px;
box-shadow: 0 0 10px rgba(255,255,255,0.5);
}
/* Glow effect for active elements */
.glow-active {
box-shadow: 0 0 15px -2px currentColor;
}
/* Typography utility */
.text-balance {
text-wrap: balance;
}
</style>
</head>
<body class="antialiased min-h-screen flex flex-col">
<!-- Grain Texture -->
<div class="grain"></div>
<!-- Three.js Background -->
<canvas id="bg-canvas" class="fixed inset-0 z-0"></canvas>
<!-- Main Application Container -->
<div class="relative z-10 container mx-auto px-6 py-8 flex-grow flex flex-col gap-8">
<!-- Header -->
<header class="flex flex-col md:flex-row justify-between items-end gap-4 animate-fade-in-up">
<div>
<h1 class="text-4xl md:text-5xl font-serif font-bold bg-clip-text text-transparent bg-gradient-to-r from-cyan-400 via-purple-400 to-emerald-400 pb-2">
Personalization Orchestration
</h1>
<p class="text-slate-400 text-sm md:text-base mt-1 max-w-2xl">
Fusing segment definitions, model scores, and eligibility rules in real-time to determine user experience.
</p>
</div>
<div class="flex items-center gap-3">
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">
<span class="w-2 h-2 rounded-full bg-emerald-500 mr-2 animate-pulse"></span>
System Operational
</span>
<div class="text-xs text-slate-500 font-mono">v2.4.0</div>
</div>
</header>
<!-- Main Workspace - Bento Grid Layout -->
<main class="grid grid-cols-1 lg:grid-cols-12 gap-6 flex-grow">
<!-- Left Column: Inputs (7 cols on large) -->
<section class="lg:col-span-7 flex flex-col gap-6">
<!-- Segment Definitions -->
<div class="glass rounded-2xl p-6 border-l-4 border-cyan-500 relative overflow-hidden group transition-all duration-300 hover:bg-slate-900/60">
<div class="absolute top-0 right-0 w-24 h-24 bg-cyan-500/5 blur-3xl rounded-full -mr-10 -mt-10 group-hover:bg-cyan-500/10 transition-all"></div>
<h2 class="text-lg font-semibold text-cyan-400 flex items-center mb-4">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path></svg>
Segment Definitions
</h2>
<p class="text-sm text-slate-400 mb-4">Define user cohorts using static attributes.</p>
<div class="space-y-4">
<!-- Segment Toggles -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<label class="flex items-center justify-between p-3 rounded-xl bg-slate-900/50 border border-slate-700/50 cursor-pointer hover:border-cyan-500/50 transition-colors">
<span class="text-sm font-medium text-slate-300">High Value (LTV > 1k)</span>
<input type="checkbox" class="segment-cb w-5 h-5 rounded text-cyan-500 focus:ring-cyan-500 bg-slate-800 border-slate-600" value="high_value">
</label>
<label class="flex items-center justify-between p-3 rounded-xl bg-slate-900/50 border border-slate-700/50 cursor-pointer hover:border-cyan-500/50 transition-colors">
<span class="text-sm font-medium text-slate-300">Churn Risk (>90 days)</span>
<input type="checkbox" class="segment-cb w-5 h-5 rounded text-cyan-500 focus:ring-cyan-500 bg-slate-800 border-slate-600" value="churn_risk">
</label>
<label class="flex items-center justify-between p-3 rounded-xl bg-slate-900/50 border border-slate-700/50 cursor-pointer hover:border-cyan-500/50 transition-colors">
<span class="text-sm font-medium text-slate-300">New Engager (lt 30d)</span>
<input type="checkbox" class="segment-cb w-5 h-5 rounded text-cyan-500 focus:ring-cyan-500 bg-slate-800 border-slate-600" value="new_engager">
</label>
<label class="flex items-center justify-between p-3 rounded-xl bg-slate-900/50 border border-slate-700/50 cursor-pointer hover:border-cyan-500/50 transition-colors">
<span class="text-sm font-medium text-slate-300">Premium Age (45+)</span>
<input type="checkbox" class="segment-cb w-5 h-5 rounded text-cyan-500 focus:ring-cyan-500 bg-slate-800 border-slate-600" value="premium_age">
</label>
</div>
</div>
</div>
<!-- Model Scores -->
<div class="glass rounded-2xl p-6 border-l-4 border-purple-500 relative overflow-hidden group transition-all duration-300 hover:bg-slate-900/60">
<div class="absolute top-0 right-0 w-24 h-24 bg-purple-500/5 blur-3xl rounded-full -mr-10 -mt-10 group-hover:bg-purple-500/10 transition-all"></div>
<h2 class="text-lg font-semibold text-purple-400 flex items-center mb-4">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path></svg>
Predictive Model Scores
</h2>
<p class="text-sm text-slate-400 mb-4">Real-time output from machine learning models.</p>
<div class="space-y-6">
<!-- Propensity -->
<div>
<div class="flex justify-between text-xs text-slate-400 mb-2">
<span>Propensity to Convert</span>
<span id="propensity-val" class="font-mono text-purple-400">0</span>
</div>
<input type="range" id="propensity" min="0" max="100" value="50" class="w-full">
</div>
<!-- Churn Risk -->
<div>
<div class="flex justify-between text-xs text-slate-400 mb-2">
<span>Churn Risk Score</span>
<span id="churn-val" class="font-mono text-purple-400">0</span>
</div>
<input type="range" id="churn" min="0" max="100" value="20" class="w-full">
</div>
<!-- Upsell Potential -->
<div>
<div class="flex justify-between text-xs text-slate-400 mb-2">
<span>Upsell Potential</span>
<span id="upsell-val" class="font-mono text-purple-400">0</span>
</div>
<input type="range" id="upsell" min="0" max="100" value="30" class="w-full">
</div>
</div>
</div>
<!-- Eligibility Layer -->
<div class="glass rounded-2xl p-6 border-l-4 border-emerald-500 relative overflow-hidden group transition-all duration-300 hover:bg-slate-900/60">
<div class="absolute top-0 right-0 w-24 h-24 bg-emerald-500/5 blur-3xl rounded-full -mr-10 -mt-10 group-hover:bg-emerald-500/10 transition-all"></div>
<h2 class="text-lg font-semibold text-emerald-400 flex items-center mb-4">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
Eligibility & Compliance
</h2>
<p class="text-sm text-slate-400 mb-4">Hard constraints that gate personalization.</p>
<div class="space-y-3">
<label class="flex items-center p-3 rounded-xl bg-slate-900/50 border border-slate-700/50 cursor-pointer hover:border-emerald-500/50 transition-colors">
<input type="checkbox" id="elig-active" checked class="elig-cb w-5 h-5 rounded text-emerald-500 focus:ring-emerald-500 bg-slate-800 border-slate-600">
<span class="ml-3 text-sm text-slate-300">Active Customer</span>
</label>
<label class="flex items-center p-3 rounded-xl bg-slate-900/50 border border-slate-700/50 cursor-pointer hover:border-emerald-500/50 transition-colors">
<input type="checkbox" id="elig-geo" checked class="elig-cb w-5 h-5 rounded text-emerald-500 focus:ring-emerald-500 bg-slate-800 border-slate-600">
<span class="ml-3 text-sm text-slate-300">Allowed Region (US/EU)</span>
</label>
<label class="flex items-center p-3 rounded-xl bg-slate-900/50 border border-slate-700/50 cursor-pointer hover:border-emerald-500/50 transition-colors">
<input type="checkbox" id="elig-optin" checked class="elig-cb w-5 h-5 rounded text-emerald-500 focus:ring-emerald-500 bg-slate-800 border-slate-600">
<span class="ml-3 text-sm text-slate-300">Marketing Consent</span>
</label>
</div>
</div>
</section>
<!-- Right Column: Visualization (5 cols on large) -->
<section class="lg:col-span-5 flex flex-col gap-6">
<!-- Fusion Core -->
<div class="glass-dynamic rounded-2xl p-8 flex flex-col items-center justify-center relative overflow-hidden min-h-[400px]">
<!-- Background Mesh Gradient -->
<div class="absolute inset-0 opacity-30" style="background: radial-gradient(circle at 50% 50%, rgba(6,182,212,0.15), transparent 60%), radial-gradient(circle at 80% 20%, rgba(168,85,247,0.15), transparent 50%), radial-gradient(circle at 20% 80%, rgba(16,185,129,0.15), transparent 50%)"></div>
<!-- Core Visualization -->
<div class="relative z-20 w-48 h-48 flex items-center justify-center">
<!-- Outer Glow Ring -->
<div id="core-ring" class="absolute inset-0 rounded-full border-2 border-transparent transition-all duration-500 ease-out" style="box-shadow: 0 0 0 0 rgba(6, 182, 212, 0);"></div>
<!-- Core Circle -->
<div id="core-circle" class="w-32 h-32 rounded-full flex items-center justify-center bg-slate-900/80 backdrop-blur border border-slate-600 relative overflow-hidden transition-all duration-500">
<div id="core-gradient" class="absolute inset-0 opacity-20 transition-all duration-500" style="background: conic-gradient(from 0deg, #06b6d4, #a855f7, #10b981, #06b6d4);"></div>
<div class="relative z-10 text-center">
<div id="score-display" class="text-4xl font-mono font-bold text-white drop-shadow-lg">0</div>
<div class="text-xs text-slate-400 uppercase tracking-widest mt-1">Fusion</div>
</div>
</div>
</div>
<!-- Result Label -->
<div class="mt-8 text-center z-20">
<div class="inline-block px-4 py-1 rounded-full bg-slate-800/50 border border-slate-700 mb-2">
<span class="text-xs text-slate-400 uppercase tracking-wide"> Orchestration Outcome</span>
</div>
<h3 id="tier-display" class="text-2xl font-serif font-bold text-transparent bg-clip-text bg-gradient-to-r from-slate-400 to-slate-200">No Decision</h3>
<p id="experience-desc" class="text-sm text-slate-500 mt-2 max-w-xs mx-auto">Adjust inputs to evaluate the fusion logic.</p>
</div>
<!-- Decorative Elements -->
<div class="absolute -bottom-4 -right-4 w-24 h-24 border-b-2 border-r-2 border-cyan-500/20 rounded-br-2xl"></div>
<div class="absolute -top-4 -left-4 w-16 h-16 border-t-2 border-l-2 border-purple-500/20 rounded-tl-xl"></div>
</div>
<!-- Live Logs / Audit Trail -->
<div class="glass rounded-xl p-4 flex flex-col h-48">
<h3 class="text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2 flex justify-between">
<span>Event Log</span>
<button onclick="clearLog()" class="hover:text-white transition-colors">Clear</button>
</h3>
<div id="log-container" class="flex-grow overflow-y-auto font-mono text-xs space-y-2 pr-2">
<div class="text-slate-500 italic">System initialized. Waiting for input...</div>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="border-t border-slate-800/50 pt-6 mt-8 flex justify-between items-center text-xs text-slate-600">
<div>© 2023 Personalization Engine. All rights reserved.</div>
<div class="flex gap-4">
<a href="#" class="hover:text-cyan-400 transition-colors">Documentation</a>
<a href="#" class="hover:text-purple-400 transition-colors">API</a>
<a href="#" class="hover:text-emerald-400 transition-colors">Settings</a>
</div>
</footer>
</div>
<script>
// ==========================================
// THREE.JS BACKGROUND (Subtle Particle Field)
// ==========================================
const initThreeJS = () => {
const canvas = document.getElementById('bg-canvas');
const renderer = new THREE.WebGLRenderer({ canvas, alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
const scene = new THREE.Scene();
// Fog for depth
scene.fog = new THREE.FogExp2(0x0a0a0a, 0.001);
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.z = 400;
// Particles
const particleCount = 600;
const positions = new Float32Array(particleCount * 3);
const sizes = new Float32Array(particleCount);
for (let i = 0; i < particleCount; i++) {
positions[i * 3] = (Math.random() - 0.5) * 800;
positions[i * 3 + 1] = (Math.random() - 0.5) * 800;
positions[i * 3 + 2] = (Math.random() - 0.5) * 800;
sizes[i] = Math.random() * 2 + 0.5;
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
geometry.setAttribute('size', new THREE.BufferAttribute(sizes, 1));
// Custom shader material for soft glowing points
const material = new THREE.PointsMaterial({
size: 2,
color: 0x06b6d4, // cyan
transparent: true,
opacity: 0.6,
blending: THREE.AdditiveBlending,
sizeAttenuation: true
});
const particles = new THREE.Points(geometry, material);
scene.add(particles);
// Subtle floating lines (grid) - optional
// We'll keep it performant with just particles for now.
// Mouse interaction
let mouseX = 0, mouseY = 0;
document.addEventListener('mousemove', (e) => {
mouseX = (e.clientX / window.innerWidth) * 2 - 1;
mouseY = -(e.clientY / window.innerHeight) * 2 + 1;
});
// Animation loop
const animate = () => {
requestAnimationFrame(animate);
// Rotate entire system slowly
particles.rotation.y += 0.0005;
particles.rotation.z += 0.0002;
// Mouse influence (parallax)
particles.rotation.x += mouseY * 0.0001;
particles.rotation.y += mouseX * 0.0001;
// Wave effect on particles (vertex manipulation)
// Doing this manually every frame is heavy, we'll skip for 600 particles.
// Instead, we just pulse opacity
const time = Date.now() * 0.001;
material.opacity = 0.6 + Math.sin(time) * 0.1;
renderer.render(scene, camera);
};
animate();
// Resize handler
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
};
// ==========================================
// APPLICATION LOGIC
// ==========================================
// State
const state = {
segments: {
high_value: false,
churn_risk: false,
new_engager: false,
premium_age: false
},
models: {
propensity: 50,
churn: 20,
upsell: 30
},
eligibility: {
active: true,
geo: true,
optin: true
}
};
// Configuration weights
const WEIGHTS = {
segmentContribution: 0.4, // 40% of final score
modelContribution: 0.6 // 60%
};
// DOM Elements
const els = {
propensity: document.getElementById('propensity'),
churn: document.getElementById('churn'),
upsell: document.getElementById('upsell'),
propensityVal: document.getElementById('propensity-val'),
churnVal: document.getElementById('churn-val'),
upsellVal: document.getElementById('upsell-val'),
segmentCbs: document.querySelectorAll('.segment-cb'),
eligCbs: document.querySelectorAll('.elig-cb'),
scoreDisplay: document.getElementById('score-display'),
tierDisplay: document.getElementById('tier-display'),
expDesc: document.getElementById('experience-desc'),
coreRing: document.getElementById('core-ring'),
coreCircle: document.getElementById('core-circle'),
coreGradient: document.getElementById('core-gradient'),
logContainer: document.getElementById('log-container')
};
// Format time
const getTime = () => {
const now = new Date();
return now.toLocaleTimeString('en-US', { hour12: false, hour: '2-digit', minute:'2-digit', second:'2-digit' }) + '.' + String(now.getMilliseconds()).padStart(3, '0');
};
// Logging
function log(msg, type='info') {
const div = document.createElement('div');
div.className = "border-l-2 pl-2 " +
(type === 'error' ? 'border-red-500 text-red-200' :
type === 'success' ? 'border-emerald-500 text-emerald-200' :
'border-slate-700 text-slate-300');
div.innerHTML = `<span class="text-slate-600">[${getTime()}]</span> ${msg}`;
els.logContainer.insertBefore(div, els.logContainer.firstChild);
// Limit logs
if (els.logContainer.children.length > 20) {
els.logContainer.removeChild(els.logContainer.lastChild);
}
}
window.clearLog = () => els.logContainer.innerHTML = '<div class="text-slate-500 italic">Log cleared.</div>';
// Orchestration Logic
function orchestrate() {
// 1. Check Eligibility (All must pass)
const eligPass = Object.values(state.eligibility).every(v => v === true);
if (!eligPass) {
updateOutput(0, 'Ineligible', 'User fails compliance constraints.', 'no');
log('Eligibility check failed. Orchestration blocked.', 'error');
return;
}
// 2. Segment Score Calculation
// Each active segment adds weight. Max segments = 4. Score = (active / 4) * 100 * weightSegment
const activeSegments = Object.values(state.segments).filter(v => v).length;
const segmentScore = (activeSegments / 4) * 100 * WEIGHTS.segmentContribution;
// 3. Model Score Calculation (Weighted Average)
// Weights: Propensity 50%, Churn 20% (inverted: lower risk is better), Upsell 30%
// Normalize churn: risk lower = better score. Use (100 - churn)
const normChurn = 100 - state.models.churn;
const modelScore =
(state.models.propensity * 0.5) +
(normChurn * 0.2) +
(state.models.upsell * 0.3);
const weightedModelScore = modelScore * WEIGHTS.modelContribution;
// 4. Final Fusion Score
const finalScore = Math.round(segmentScore + weightedModelScore);
// Determine Tier
let tier, experience;
if (finalScore >= 80) {
tier = 'Elite';
experience = 'Deliver white-glove concierge service with exclusive offers.';
} else if (finalScore >= 60) {
tier = 'Premium';
experience = 'Show premium dashboard, fast-track support, and relevant upsells.';
} else if (finalScore >= 30) {
tier = 'Standard';
experience = 'Present standard UI with targeted content blocks.';
} else {
tier = 'Minimal';
experience = 'Show generic homepage with no personalization.';
}
// Update UI
const colorMap = {
'Elite': 'from-emerald-400 to-emerald-600',
'Premium': 'from-purple-400 to-purple-600',
'Standard': 'from-cyan-400 to-blue-500',
'Minimal': 'from-slate-500 to-slate-700'
};
const glowColorMap = {
'Elite': 'rgba(16, 185, 129, 0.6)', // emerald
'Premium': 'rgba(168, 85, 247, 0.6)', // purple
'Standard': 'rgba(6, 182, 212, 0.6)', // cyan
'Minimal': 'rgba(100, 116, 139, 0.6)' // slate
};
updateOutput(finalScore, tier, experience, colorMap[tier], glowColorMap[tier]);
// Log
log(`Eval passed. Segments: ${activeSegments} | Model Comp: ${Math.round(modelScore)} | Final: ${finalScore} -> ${tier}`, 'success');
}
function updateOutput(score, tier, desc, gradientClass, glowColor) {
// Animate number
const currentDisplay = parseInt(els.scoreDisplay.innerText);
gsap.to({ val: currentDisplay }, {
val: score,
duration: 0.8,
ease: "power2.out",
onUpdate: function() {
els.scoreDisplay.innerText = Math.round(this.targets()[0].val);
}
});
// Animate ring glow
gsap.to(els.coreRing, {
boxShadow: `0 0 30px 5px ${glowColor}`,
borderColor: glowColor.replace('0.6', '0.8'),
duration: 0.5
});
// Update Gradient on circle
els.coreGradient.style.background = `conic-gradient(from 0deg, ${tier==='Elite'?'#10b981':tier==='Premium'?'#a855f7':tier==='Standard'?'#06b6d4':'#64748b'}, rgba(0,0,0,0.1) 100%)`;
// Text updates
if (els.tierDisplay.innerText !== tier) {
gsap.fromTo(els.tierDisplay,
{ opacity: 0, y: 10 },
{ opacity: 1, y: 0, duration: 0.4, onComplete: () => {
els.tierDisplay.innerText = tier;
els.tierDisplay.className = `text-2xl font-serif font-bold text-transparent bg-clip-text bg-gradient-to-r ${gradientClass}`;
}}
);
}
els.expDesc.innerText = desc;
}
// Event Listeners Setup
function initEvents() {
// Segment Checkboxes
els.segmentCbs.forEach(cb => {
cb.addEventListener('change', (e) => {
state.segments[e.target.value] = e.target.checked;
orchestrate();
});
});
// Eligibility Checkboxes
els.eligCbs.forEach(cb => {
cb.addEventListener('change', (e) => {
const id = e.target.id;
if (id === 'elig-active') state.eligibility.active = e.target.checked;
if (id === 'elig-geo') state.eligibility.geo = e.target.checked;
if (id === 'elig-optin') state.eligibility.optin = e.target.checked;
orchestrate();
});
});
// Model Sliders
const sliders = ['propensity', 'churn', 'upsell'];
sliders.forEach(name => {
const el = document.getElementById(name);
const valEl = document.getElementById(`${name}-val`);
el.addEventListener('input', (e) => {
const val = parseInt(e.target.value);
state.models[name] = val;
valEl.innerText = val;
// Debounce or not? For immediate feedback we can call directly but maybe throttle is better for perf. We'll keep direct for simplicity.
// Using requestAnimationFrame for update
window.requestAnimationFrame(orchestrate);
});
});
}
// Entry Point
window.onload = () => {
initThreeJS();
initEvents();
// Initial GSAP Animations
gsap.from("header", { y: -30, opacity: 0, duration: 1, ease: "power3.out", delay: 0.2 });
gsap.from(".glass", {
y: 40,
opacity: 0,
duration: 0.8,
stagger: 0.15,
ease: "power3.out",
delay: 0.5
});
gsap.from("#core-circle", {
scale: 0,
rotation: -180,
duration: 1.2,
ease: "elastic.out(1, 0.5)",
delay: 1
});
// Initial orchestration
orchestrate();
log('Personalization Orchestration Layer started.');
};
</script>
</body>
</html>