<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aegis | Model Evaluation Cockpit</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
'aegis-bg': '#050505',
'aegis-card': 'rgba(20, 20, 25, 0.6)',
'aegis-accent-cyan': '#00f3ff',
'aegis-accent-purple': '#bc13fe',
'aegis-accent-lime': '#a4ff00',
'aegis-text-muted': '#8b9bb4',
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif'],
},
boxShadow: {
'neon-cyan': '0 0 20px rgba(0, 243, 255, 0.3)',
'neon-purple': '0 0 20px rgba(188, 19, 254, 0.3)',
}
}
}
}
</script>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&family=Playfair+Display:wght@700&display=swap" rel="stylesheet">
<!-- 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>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<style>
body {
background-color: #050505;
color: #ffffff;
overflow-x: hidden;
cursor: crosshair; /* Cockpit feel */
}
/* Noise Texture 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.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}
/* Glassmorphism Card Base */
.glass-card {
background: rgba(255, 255, 255, 0.03);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.glass-card:hover {
border-color: rgba(0, 243, 255, 0.4);
background: rgba(255, 255, 255, 0.07);
transform: translateY(-5px);
box-shadow: 0 12px 40px 0 rgba(0, 243, 255, 0.15);
}
/* Custom Scrollbar */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: #0a0a0a;
}
::-webkit-scrollbar-thumb {
background: #333;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Scanline Effect for "Monitors" */
.scanline {
background: linear-gradient(
to bottom,
rgba(255,255,255,0),
rgba(255,255,255,0) 50%,
rgba(0,0,0,0.2) 50%,
rgba(0,0,0,0.2)
);
background-size: 100% 4px;
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
pointer-events: none;
z-index: 1;
}
/* Utility for animated gradients */
.mesh-gradient {
background: radial-gradient(circle at 20% 20%, rgba(188, 19, 254, 0.15), transparent 40%),
radial-gradient(circle at 80% 80%, rgba(0, 243, 255, 0.15), transparent 40%);
}
/* Drift Canvas */
#driftCanvas {
width: 100%;
height: 150px;
}
.attribution {
font-family: 'Inter', monospace;
font-size: 0.75rem;
color: #555;
letter-spacing: 1px;
text-transform: uppercase;
}
</style>
</head>
<body class="font-sans antialiased selection:bg-aegis-accent-cyan selection:text-black">
<!-- Visual Overlays -->
<div class="noise-overlay"></div>
<div id="vignette" class="fixed inset-0 pointer-events-none z-0 bg-[radial-gradient(circle_at_center,transparent_0%,#000_120%)]"></div>
<!-- 3D Background Container -->
<div id="canvas-container" class="fixed inset-0 z-0 pointer-events-none opacity-40 mix-blend-screen"></div>
<div class="relative z-10 container mx-auto px-6 py-8 min-h-screen">
<!-- HEADER -->
<header class="flex justify-between items-end mb-12 border-b border-white/10 pb-6">
<div>
<h1 class="font-serif text-4xl md:text-6xl font-bold tracking-tighter mb-2 text-transparent bg-clip-text bg-gradient-to-r from-white to-gray-500">
AEGIS<span class="text-aegis-accent-cyan">.ctl</span>
</h1>
<p class="attribution text-aegis-text-muted">Intelligent Model Governance & Drift Detection</p>
</div>
<div class="hidden md:flex flex-col items-end">
<div class="flex items-center gap-2 mb-1">
<div class="w-2 h-2 rounded-full bg-aegis-accent-lime animate-pulse shadow-[0_0_10px_#a4ff00]"></div>
<span class="text-sm font-semibold tracking-widest text-aegis-accent-lime">SYSTEMS OPERATIONAL</span>
</div>
<div id="clock" class="attribution text-xs font-mono">00:00:00 UTC</div>
</div>
</header>
<!-- MAIN GRID (Bento Style) -->
<div class="grid grid-cols-1 md:grid-cols-12 md:grid-rows-6 gap-6 h-[calc(100vh-180px)]"> <!-- Aspect ratio controlled height -->
<!-- 1. KPI Overview (Large Card, spans 4 cols, 2 rows) -->
<section class="col-span-1 md:col-span-4 md:row-span-2 glass-card rounded-2xl p-8 flex flex-col justify-between relative group overflow-hidden">
<div class="absolute top-0 right-0 p-4 opacity-20 group-hover:opacity-40 transition-opacity">
<svg class="w-32 h-32 text-aegis-accent-cyan" fill="currentColor" viewBox="0 0 24 24"><path d="M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z"/></svg>
</div>
<div>
<h2 class="text-aegis-text-muted text-xs font-bold uppercase tracking-widest mb-4">Business Impact</h2>
<div class="space-y-8">
<!-- KPI 1 -->
<div>
<div class="flex justify-between items-end mb-2">
<span class="text-sm text-gray-400">Conversion Rate</span>
<span class="font-mono text-xl font-bold text-white">4.8%</span>
</div>
<div class="w-full bg-gray-800/50 h-1 rounded-full overflow-hidden">
<div class="h-full bg-aegis-accent-cyan shadow-neon-cyan transition-all duration-1000" style="width: 78%"></div>
</div>
</div>
<!-- KPI 2 -->
<div>
<div class="flex justify-between items-end mb-2">
<span class="text-sm text-gray-400">Customer Retention</span>
<span class="font-mono text-xl font-bold text-white">92.1%</span>
</div>
<div class="w-full bg-gray-800/50 h-1 rounded-full overflow-hidden">
<div class="h-full bg-aegis-accent-purple shadow-neon-purple transition-all duration-1000" style="width: 92%"></div>
</div>
</div>
<!-- KPI 3 -->
<div>
<div class="flex justify-between items-end mb-2">
<span class="text-sm text-gray-400">False Positive Rate</span>
<span class="font-mono text-xl font-bold text-aegis-accent-lime">0.12%</span>
</div>
<div class="w-full bg-gray-800/50 h-1 rounded-full overflow-hidden">
<div class="h-full bg-aegis-accent-lime shadow-[0_0_10px_#a4ff00] transition-all duration-1000" style="width: 12%"></div>
</div>
</div>
</div>
</div>
<div class="mt-auto pt-6 border-t border-white/10 flex justify-between items-center">
<button id="simulateBtn" class="bg-white/5 hover:bg-white/10 border border-white/20 text-xs px-4 py-2 rounded uppercase tracking-widest transition-colors text-aegis-text-muted hover:text-white">
Simulate Traffic Spike
</button>
<span class="text-[10px] text-gray-500">LIVE DATA STREAM</span>
</div>
</section>
<!-- 2. Fairness Lenses (Spans 3 cols, 2 rows) -->
<section class="col-span-1 md:col-span-3 md:row-span-2 glass-card rounded-2xl p-6 flex flex-col">
<div class="flex justify-between items-center mb-6">
<h2 class="text-white font-bold text-lg tracking-wide">Fairness Lenses</h2>
<div class="flex gap-2">
<button class="lens-tab active text-xs bg-aegis-accent-cyan/20 text-aegis-accent-cyan px-2 py-1 rounded" data-lens="gender">Gender</button>
<button class="lens-tab text-xs bg-white/5 text-gray-400 hover:text-white px-2 py-1 rounded transition-colors" data-lens="age">Age</button>
</div>
</div>
<div class="flex-1 flex flex-col justify-between">
<!-- Visual Bar Chart Representation -->
<div class="space-y-6" id="fairness-chart">
<!-- Injected via JS -->
</div>
<div class="mt-6 pt-4 border-t border-white/10">
<div class="flex justify-between text-xs font-mono text-gray-400 mb-1">
<span>Disparity Index</span>
<span id="disparity-value" class="text-aegis-accent-cyan">0.12 (Low)</span>
</div>
<div class="w-full bg-gray-800 h-2 rounded overflow-hidden">
<div id="disparity-bar" class="h-full bg-gradient-to-r from-aegis-accent-lime via-aegis-accent-cyan to-aegis-accent-purple w-[12%]"></div>
</div>
</div>
</div>
</section>
<!-- 3. Drift Scope (Spans 5 cols, 2 rows) -->
<section class="col-span-1 md:col-span-5 md:row-span-2 glass-card rounded-2xl p-6 relative flex flex-col">
<div class="flex justify-between items-start absolute top-6 right-6">
<div class="text-right">
<div class="text-xs text-aegis-text-muted uppercase">PSI Score</div>
<div id="psi-score" class="text-2xl font-mono font-bold text-white">0.04</div>
</div>
<div class="w-10 h-10 rounded-full border border-white/20 flex items-center justify-center bg-black/40">
<div class="w-2 h-2 rounded-full bg-aegis-accent-cyan animate-ping"></div>
</div>
</div>
<h2 class="text-white font-bold text-lg tracking-wide mt-4 mb-2">Concept Drift Detection</h2>
<p class="text-xs text-gray-400 mb-6 max-w-md">Monitoring feature distribution shift between training set (T-30) and current inference stream.</p>
<!-- SVG Chart Area -->
<div class="flex-1 w-full relative bg-black/20 rounded border border-white/5 overflow-hidden">
<canvas id="driftCanvas"></canvas>
<!-- Grid Lines (SVG) -->
<svg class="absolute inset-0 w-full h-full pointer-events-none opacity-20">
<line x1="0" y1="25%" x2="100%" y2="25%" stroke="white" stroke-width="1" stroke-dasharray="4"/>
<line x1="0" y1="50%" x2="100%" y2="50%" stroke="white" stroke-width="1" stroke-dasharray="4"/>
<line x1="0" y1="75%" x2="100%" y2="75%" stroke="white" stroke-width="1" stroke-dasharray="4"/>
</svg>
</div>
<div class="flex gap-4 mt-4 text-xs text-gray-500 font-mono">
<span class="flex items-center gap-1"><span class="w-2 h-2 bg-aegis-accent-cyan rounded-full"></span> Input Distribution</span>
<span class="flex items-center gap-1"><span class="w-2 h-2 bg-white/30 rounded-full"></span> Baseline</span>
</div>
</section>
<!-- 4. Feature Attribution & Health (Spans 4 cols, 3 rows) -->
<section class="col-span-1 md:col-span-4 md:row-span-3 glass-card rounded-2xl p-6 overflow-hidden flex flex-col relative">
<h2 class="text-white font-bold text-lg tracking-wide mb-6">Feature Health Matrix</h2>
<div class="grid grid-cols-3 gap-2 text-xs mb-4" id="feature-grid">
<!-- JS Generated Feature Cubes -->
</div>
<div class="mt-auto">
<div class="glass-card bg-black/40 p-4 rounded-xl border-l-4 border-aegis-accent-lime">
<div class="flex justify-between items-center">
<div>
<h4 class="text-gray-400 text-[10px] uppercase tracking-wider">Top Anomaly</h4>
<p class="text-white font-serif italic">user_income_level</p>
</div>
<div class="text-right">
<h4 class="text-gray-400 text-[10px] uppercase tracking-wider">Drift Type</h4>
<p class="text-aegis-accent-lime font-mono">SCALING SHIFT</p>
</div>
</div>
</div>
</div>
<!-- 3D Tilt Effect Background -->
<div id="feature-glow" class="absolute -bottom-10 -right-10 w-64 h-64 bg-aegis-accent-purple/20 blur-[80px] rounded-full pointer-events-none"></div>
</section>
<!-- 5. Live Logs (Spans 3 cols, 3 rows) -->
<section class="col-span-1 md:col-span-3 md:row-span-3 glass-card rounded-2xl p-0 flex flex-col overflow-hidden">
<div class="bg-black/40 px-4 py-3 border-b border-white/10 flex justify-between items-center">
<span class="text-xs font-bold uppercase tracking-widest text-aegis-text-muted">System Log</span>
<span class="text-[10px] text-green-500 animate-pulse">● RECORDING</span>
</div>
<div class="flex-1 overflow-y-auto p-4 font-mono text-[11px] space-y-3" id="log-container">
<!-- Logs injected by JS -->
</div>
<!-- Gradient Fade at bottom -->
<div class="h-8 bg-gradient-to-t from-aegis-card to-transparent"></div>
</section>
</div>
</div>
<!-- Toast Notification -->
<div id="toast" class="fixed bottom-8 left-1/2 transform -translate-x-1/2 bg-white text-black px-6 py-3 rounded-full shadow-neon-cyan opacity-0 transition-opacity duration-300 z-[100] font-bold text-sm pointer-events-none flex items-center gap-2">
<svg class="w-4 h-4 text-aegis-accent-cyan" 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>
<span>Alert: Drift Threshold Exceeded</span>
</div>
<!-- JAVASCRIPT -->
<script>
/**
* AEGIS COCKPIT LOGIC
* 1. Three.js Background (Particle Sphere)
* 2. GSAP Animations
* 3. DOM Manipulation & Mock Data Stream
* 4. Canvas Drift Chart
*/
// --- CONFIG & STATE ---
const state = {
fairness: {
gender: [
{ group: 'Male', accept: 0.78, reject: 0.22 },
{ group: 'Female', accept: 0.45, reject: 0.55 }, // Disparity
{ group: 'Other', accept: 0.60, reject: 0.40 }
],
age: [
{ group: '<25', accept: 0.55, reject: 0.45 },
{ group: '25-40', accept: 0.62, reject: 0.38 },
{ group: '>40', accept: 0.58, reject: 0.42 }
]
},
currentLens: 'gender',
drift: {
history: new Array(100).fill(0).map(() => 0.5 + (Math.random() * 0.2 - 0.1)), // baseline data
psi: 0.04
},
features: [
{ name: 'credit_score', health: 0.92, type: 'num' },
{ name: 'debt_ratio', health: 0.88, type: 'num' },
{ name: 'utilization', health: 0.95, type: 'num' },
{ name: 'age', health: 0.99, type: 'num' },
{ name: 'emp_length', health: 0.73, type: 'num' },
{ name: 'zip_code', health: 0.45, type: 'cat' }, // Low health (drift)
{ name: 'purpose', health: 0.88, type: 'cat' },
{ name: 'earnings', health: 0.92, type: 'num' }
]
};
// --- THREE.JS BACKGROUND ---
const initThreeJS = () => {
const container = document.getElementById('canvas-container');
const scene = new THREE.Scene();
// Fog to blend deep
scene.fog = new THREE.FogExp2(0x050505, 0.002);
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 30;
const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
container.appendChild(renderer.domElement);
// Particles
const particlesGeometry = new THREE.BufferGeometry();
const particlesCount = 2000;
const posArray = new Float32Array(particlesCount * 3);
for(let i = 0; i < particlesCount * 3; i++) {
// Sphere distribution
posArray[i] = (Math.random() - 0.5) * 60;
}
particlesGeometry.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
// Material
const material = new THREE.PointsMaterial({
size: 0.15,
color: 0x00f3ff,
transparent: true,
opacity: 0.6,
blending: THREE.AdditiveBlending
});
const particlesMesh = new THREE.Points(particlesGeometry, material);
scene.add(particlesMesh);
// Interaction
let mouseX = 0;
let mouseY = 0;
let targetX = 0;
let targetY = 0;
const windowHalfX = window.innerWidth / 2;
const windowHalfY = window.innerHeight / 2;
document.addEventListener('mousemove', (event) => {
mouseX = (event.clientX - windowHalfX);
mouseY = (event.clientY - windowHalfY);
});
// Animation Loop
const clock = new THREE.Clock();
const animate = () => {
const elapsedTime = clock.getElapsedTime();
targetX = mouseX * 0.001;
targetY = mouseY * 0.001;
particlesMesh.rotation.y += 0.001;
particlesMesh.rotation.x += 0.05 * (targetY - particlesMesh.rotation.x);
particlesMesh.rotation.z += 0.05 * (targetX - particlesMesh.rotation.z);
// Pulsating color based on system "stress" (drift)
const stress = state.drift.psi > 0.5 ? 1.0 : 0.0;
const time = Date.now() * 0.001;
const r = 0 + stress * Math.sin(time * 5);
const b = 0.95 + (1-stress) * Math.cos(time);
// Interpolate color slowly
material.color.setHSL(0.5 + Math.sin(elapsedTime * 0.5) * 0.1, 0.8, 0.5);
renderer.render(scene, camera);
requestAnimationFrame(animate);
};
animate();
// Resize
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
};
// --- FAIRNESS CHART RENDERER ---
const renderFairnessChart = () => {
const container = document.getElementById('fairness-chart');
const data = state.fairness[state.currentLens];
container.innerHTML = '';
data.forEach((d, i) => {
// Calculate total 100%
const acceptPct = d.accept * 100;
// Determine color based on simulation (simple hue shift)
let barColor = 'bg-aegis-accent-cyan';
if(state.currentLens === 'gender' && d.group === 'Female') barColor = 'bg-aegis-accent-purple';
if(state.currentLens === 'gender' && d.group === 'Other') barColor = 'bg-aegis-accent-lime';
// HTML Structure
const groupDiv = document.createElement('div');
groupDiv.innerHTML = `
<div class="flex justify-between text-xs mb-1 font-mono">
<span style="color: ${d.group === 'Female' ? '#bc13fe' : d.group === 'Other' ? '#a4ff00' : '#00f3ff'}">${d.group}</span>
<span>${(d.accept*100).toFixed(1)}% Accept</span>
</div>
<div class="w-full bg-gray-800 h-3 relative rounded-full overflow-hidden">
<div class="absolute top-0 left-0 h-full ${barColor} transition-all duration-[2000ms] ease-out" style="width: ${acceptPct}%"></div>
</div>
`;
container.appendChild(groupDiv);
});
// Update disparity bar
const disparity = Math.abs(data[0].accept - data[1].accept); // Simple diff
document.getElementById('disparity-value').innerText = `${disparity.toFixed(2)} (${disparity < 0.2 ? 'Low' : disparity < 0.5 ? 'Med' : 'High'})`;
document.getElementById('disparity-bar').style.width = `${disparity * 100}%`;
};
// --- DRIFT CANVAS (Custom Draw) ---
let driftCtx;
let driftCanvas;
const initDriftChart = () => {
driftCanvas = document.getElementById('driftCanvas');
// Resize to fit parent width
const rect = driftCanvas.parentElement.getBoundingClientRect();
driftCanvas.width = rect.width;
driftCanvas.height = rect.height;
driftCtx = driftCanvas.getContext('2d');
drawDrift();
};
const drawDrift = () => {
if(!driftCtx) return;
const w = driftCanvas.width;
const h = driftCanvas.height;
const data = state.drift.history;
driftCtx.clearRect(0, 0, w, h);
// Draw Baseline (center)
driftCtx.beginPath();
driftCtx.strokeStyle = 'rgba(255,255,255,0.1)';
driftCtx.lineWidth = 1;
driftCtx.moveTo(0, h/2);
driftCtx.lineTo(w, h/2);
driftCtx.stroke();
// Draw Data
driftCtx.beginPath();
driftCtx.strokeStyle = '#00f3ff';
driftCtx.lineWidth = 2;
const step = w / (data.length - 1);
for(let i=0; i<data.length; i++) {
const val = data[i]; // 0 to 1 scale roughly
// Map 0.3-0.7 to height
const y = h - (val * h);
if(i===0) driftCtx.moveTo(0, y);
else driftCtx.lineTo(i * step, y);
}
driftCtx.stroke();
// Fill area
driftCtx.lineTo(w, h);
driftCtx.lineTo(0, h);
driftCtx.fillStyle = 'rgba(0, 243, 255, 0.1)';
driftCtx.fill();
};
// Simulate Drift Data Stream
const streamDrift = () => {
const last = state.drift.history[state.drift.history.length - 1];
// Random walk
let change = (Math.random() - 0.5) * 0.1;
let newVal = Math.max(0.1, Math.min(0.9, last + change));
// Inject occasional "drift event"
if(Math.random() > 0.95) newVal += 0.2;
state.drift.history.shift();
state.drift.history.push(newVal);
// Calc PSI (mock)
const baseline = 0.5;
const psi = Math.abs(newVal - baseline) * (Math.random() * 0.5 + 0.5);
state.drift.psi = psi.toFixed(3);
// Update DOM
const psiEl = document.getElementById('psi-score');
psiEl.innerText = state.drift.psi;
psiEl.className = `text-2xl font-mono font-bold ${psi > 0.5 ? 'text-red-500' : psi > 0.3 ? 'text-yellow-400' : 'text-white'}`;
drawDrift();
};
// --- FEATURE GRID ---
const renderFeatureGrid = () => {
const grid = document.getElementById('feature-grid');
grid.innerHTML = '';
state.features.forEach(f => {
const isBad = f.health < 0.6;
const color = isBad ? 'border-red-500/50 bg-red-500/10' : (f.health > 0.9 ? 'border-aegis-accent-lime/50 bg-aegis-accent-lime/10' : 'border-white/5 bg-white/5');
const textColor = isBad ? 'text-red-400' : (f.health > 0.9 ? 'text-aegis-accent-lime' : 'text-gray-400');
const cell = document.createElement('div');
cell.className = `p-2 rounded border ${color} flex flex-col items-center justify-center transition-transform hover:scale-105 cursor-help`;
cell.innerHTML = `
<div class="text-[10px] uppercase mb-1 ${textColor}">${f.name}</div>
<div class="w-full bg-gray-700 h-1 rounded-full overflow-hidden">
<div class="h-full ${textColor} transition-all duration-1000" style="width: ${f.health * 100}%"></div>
</div>
`;
grid.appendChild(cell);
});
};
// --- LOG HANDLER ---
const addLog = (msg, type='info') => {
const container = document.getElementById('log-container');
const time = new Date().toISOString().split('T')[1].split('.')[0] + ' UTC';
const color = type === 'warn' ? 'text-yellow-500' : (type === 'error' ? 'text-red-500' : 'text-aegis-accent-cyan');
const line = document.createElement('div');
line.className = `flex gap-3 border-b border-white/5 pb-2 animate-[fadeIn_0.3s_ease-out]`;
line.innerHTML = `
<span class="text-gray-600">[${time}]</span>
<span class="${color}">${msg}</span>
`;
container.appendChild(line);
container.scrollTop = container.scrollHeight;
// Keep only last 50
if(container.children.length > 50) {
container.removeChild(container.children[0]);
}
};
// --- MAIN INITIALIZATION ---
window.addEventListener('DOMContentLoaded', () => {
// 1. Three.js
initThreeJS();
// 2. GSAP Entrance
gsap.from("header", { y: -30, opacity: 0, duration: 1, ease: "power3.out" });
gsap.from(".glass-card", {
y: 50,
opacity: 0,
duration: 0.8,
stagger: 0.1,
ease: "back.out(1.7)",
delay: 0.2
});
// 3. Setup Charts
renderFairnessChart();
initDriftChart(); // Initial draw
renderFeatureGrid();
// Set Interval for Data Stream
setInterval(streamDrift, 800); // Fast updates for drift feel
setInterval(() => {
// Randomly update some features
const idx = Math.floor(Math.random() * state.features.length);
state.features[idx].health = Math.max(0.1, Math.min(1.0, state.features[idx].health + (Math.random() - 0.5) * 0.1));
renderFeatureGrid();
}, 3000);
// 4. Clock
setInterval(() => {
const now = new Date();
document.getElementById('clock').innerText = now.toISOString().split('T')[1].split('.')[0] + ' UTC';
}, 1000);
// 5. Traffic Simulator Button
const simBtn = document.getElementById('simulateBtn');
simBtn.addEventListener('click', () => {
gsap.to("body", { backgroundColor: "#111", duration: 0.2, yoyo: true, repeat: 1 });
addLog("USER ACTION: Traffic spike simulation initiated...", "warn");
// Spike Drift temporarily
state.drift.history.forEach((v, i) => {
state.drift.history[i] = Math.min(1, v + 0.3);
});
drawDrift();
// Visual feedback
const btn = simBtn;
btn.innerText = "SIMULATING...";
btn.classList.add('bg-aegis-accent-cyan', 'text-black');
setTimeout(() => {
btn.innerText = "Simulate Traffic Spike";
btn.classList.remove('bg-aegis-accent-cyan', 'text-black');
addLog("Traffic spike normalized.", "info");
}, 2000);
});
// 6. Lens Tabs
document.querySelectorAll('.lens-tab').forEach(btn => {
btn.addEventListener('click', (e) => {
// UI Toggle
document.querySelectorAll('.lens-tab').forEach(b => {
b.classList.remove('bg-aegis-accent-cyan/20', 'text-aegis-accent-cyan', 'active');
b.classList.add('bg-white/5', 'text-gray-400');
});
e.target.classList.remove('bg-white/5', 'text-gray-400');
e.target.classList.add('bg-aegis-accent-cyan/20', 'text-aegis-accent-cyan', 'active');
// Logic
state.currentLens = e.target.dataset.lens;
renderFairnessChart();
addLog(`Fairness lens switched to: ${state.currentLens.toUpperCase()}`);
});
});
// 7. Initial Logs
setTimeout(() => addLog("Aegis Core v2.4.0 initialized.", "info"), 500);
setTimeout(() => addLog("Connected to inference stream port 9090.", "info"), 1000);
setTimeout(() => addLog("Drift detector calibration complete.", "info"), 1500);
});
// Handle Window Resize for Canvas
let resizeTimer;
window.addEventListener('resize', () => {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
if(driftCanvas) {
const rect = driftCanvas.parentElement.getBoundingClientRect();
driftCanvas.width = rect.width;
driftCanvas.height = rect.height;
drawDrift();
}
}, 200);
});
</script>
</body>
</html>