<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Design for Failure | Resilience Generator</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&family=Playfair+Display:ital,wght@0,600;0,700;1,400&display=swap" rel="stylesheet">
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
void: '#050505',
surface: '#0F0F11',
'surface-light': '#1A1A1E',
accent: '#FF3B30', // Swiss Red
primary: '#00A8FF', // Electric Blue
text: '#EAEAEA',
'text-dim': '#888890'
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif']
},
boxShadow: {
'glow': '0 0 20px rgba(0, 168, 255, 0.15)',
'card': '0 4px 20px rgba(0,0,0,0.3)'
}
}
}
}
</script>
<!-- GSAP -->
<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>
<!-- Icons -->
<script src="https://unpkg.com/lucide@latest"></script>
<style>
/* Base Styling */
body {
background-color: #050505;
color: #EAEAEA;
overflow-x: hidden;
-webkit-font-smoothing: antialiased;
}
/* Grain Texture Overlay */
.grain-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 9998;
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='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}
/* Custom Cursor */
.cursor-dot,
.cursor-outline {
position: fixed;
top: 0;
left: 0;
transform: translate(-50%, -50%);
border-radius: 50%;
z-index: 9999;
pointer-events: none;
}
.cursor-dot {
width: 8px;
height: 8px;
background-color: #FF3B30;
}
.cursor-outline {
width: 40px;
height: 40px;
border: 1px solid rgba(255, 255, 255, 0.5);
transition: width 0.2s, height 0.2s;
}
/* Selection Card Styles */
.select-card {
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
border: 1px solid rgba(255, 255, 255, 0.1);
background: rgba(255, 255, 255, 0.02);
backdrop-filter: blur(10px);
}
.select-card:hover {
transform: translateY(-5px);
border-color: rgba(0, 168, 255, 0.5);
box-shadow: 0 10px 30px -10px rgba(0, 168, 255, 0.2);
}
.select-card.active {
background: rgba(0, 168, 255, 0.1);
border-color: #00A8FF;
transform: scale(0.98);
}
/* Glitch Effect */
.glitch-wrapper {
position: relative;
}
.glitch-wrapper::before,
.glitch-wrapper::after {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #050505;
opacity: 0.9;
}
.glitch-wrapper::before {
left: 2px;
text-shadow: -1px 0 #FF3B30;
clip: rect(24px, 550px, 90px, 0);
animation: glitch-anim-2 3s infinite linear alternate-reverse;
}
.glitch-wrapper::after {
left: -2px;
text-shadow: -1px 0 #00A8FF;
clip: rect(85px, 550px, 140px, 0);
animation: glitch-anim 2.5s infinite linear alternate-reverse;
}
@keyframes glitch-anim {
0% { clip: rect(11px, 9999px, 89px, 0); }
20% { clip: rect(68px, 9999px, 19px, 0); }
40% { clip: rect(23px, 9999px, 6px, 0); }
60% { clip: rect(98px, 9999px, 34px, 0); }
80% { clip: rect(14px, 9999px, 77px, 0); }
100% { clip: rect(56px, 9999px, 23px, 0); }
}
@keyframes glitch-anim-2 {
0% { clip: rect(65px, 9999px, 100px, 0); }
100% { clip: rect(12px, 9999px, 87px, 0); }
}
/* Checkbox Styling */
input[type="checkbox"]:checked + div {
background-color: #00A8FF;
border-color: #00A8FF;
}
input[type="checkbox"]:checked + div svg {
opacity: 1;
}
/* 3D Canvas Container */
#canvas-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
z-index: -1;
opacity: 0.6;
}
/* Glassmorphism Utilities */
.glass-panel {
background: rgba(255, 255, 255, 0.03);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
</style>
</head>
<body class="selection:bg-accent selection:text-white">
<!-- Cursor -->
<div class="cursor-dot"></div>
<div class="cursor-outline"></div>
<!-- Grain -->
<div class="grain-overlay"></div>
<!-- 3D Background -->
<div id="canvas-container"></div>
<!-- Main Container -->
<div class="relative z-10 container mx-auto px-6 pt-32 pb-24 max-w-7xl">
<!-- Header -->
<header class="mb-32 text-center">
<a href="#" class="inline-block mb-4 px-4 py-1 border border-text-dim/30 rounded-full text-xs tracking-[0.15em] text-text-dim hover:border-accent hover:text-accent transition-colors">
RESILIENCE ENGINEERING TOOL
</a>
<h1 class="text-6xl md:text-8xl font-serif font-bold mb-6 leading-tight tracking-tight">
Design for <br>
<span class="italic text-accent">Failure</span>
</h1>
<p class="text-lg md:text-xl text-text-dim max-w-2xl mx-auto font-light leading-relaxed">
Generate a tailored chaos engineering checklist based on your
<span class="text-white border-b border-primary/50 pb-1">architecture</span>,
<span class="text-white border-b border-primary/50 pb-1">dependencies</span>, and
<span class="text-white border-b border-primary/50 pb-1">historical outages</span>.
</p>
</header>
<!-- Configuration Area -->
<main id="generator" class="max-w-5xl mx-auto">
<!-- Step 1: Architecture -->
<section class="mb-20 scroll-reveal">
<div class="flex items-center justify-between mb-8">
<h2 class="text-2xl font-serif border-l-4 border-accent pl-4">Architecture Pattern</h2>
<span class="text-xs text-text-dim uppercase tracking-widest">Step 1 of 3</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6" id="architecture-options">
<!-- Options injected by JS for easy management -->
</div>
</section>
<!-- Step 2: Dependencies -->
<section class="mb-20 scroll-reveal">
<div class="flex items-center justify-between mb-8">
<h2 class="text-2xl font-serif border-l-4 border-primary pl-4">Critical Dependencies</h2>
<span class="text-xs text-text-dim uppercase tracking-widest">Step 2 of 3</span>
</div>
<p class="text-text-dim mb-6 text-sm pl-5">Select all that apply to your system stack.</p>
<div class="flex flex-wrap gap-3" id="dependency-options">
<!-- Chips injected by JS -->
</div>
</section>
<!-- Step 3: Context -->
<section class="mb-20 scroll-reveal">
<div class="flex items-center justify-between mb-8">
<h2 class="text-2xl font-serif border-l-4 border-secondary pl-4" style="border-color:#A855F7">Historical Context</h2>
<span class="text-xs text-text-dim uppercase tracking-widest">Step 3 of 3</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 glass-panel p-8 rounded-2xl">
<!-- Toggles -->
<div>
<label class="flex justify-between items-center cursor-pointer group mb-4">
<span class="text-lg">Recent major outage?</span>
<div class="relative">
<input type="checkbox" id="outage-toggle" class="sr-only">
<div class="w-12 h-6 bg-surface-light rounded-full shadow-inner transition-colors duration-200 border border-white/10"></div>
<div class="dot absolute left-1 top-1 bg-white w-4 h-4 rounded-full shadow-md transition-transform duration-200"></div>
</div>
</label>
<label class="flex justify-between items-center cursor-pointer group mb-4">
<span class="text-lg tight SLA < 99.9%?</span>
<div class="relative">
<input type="checkbox" id="sla-toggle" class="sr-only">
<div class="w-12 h-6 bg-surface-light rounded-full shadow-inner transition-colors duration-200 border border-white/10"></div>
<div class="dot absolute left-1 top-1 bg-white w-4 h-4 rounded-full shadow-md transition-transform duration-200"></div>
</div>
</label>
</div>
<div>
<label class="block text-sm text-text-dim mb-2">Est. Downtime Cost / hour</label>
<input type="range" min="1" max="100" value="10" class="w-full h-2 bg-surface-light rounded-lg appearance-none cursor-pointer accent-primary mb-2" id="cost-slider">
<div class="flex justify-between text-xs text-text-dim">
<span>Low ($1k)</span>
<span>$<span id="cost-value">10k</span></span>
<span>Critical ($1M+)</span>
</div>
</div>
</div>
</section>
<!-- Action -->
<div class="flex justify-center mb-40 scroll-reveal">
<button id="generate-btn" class="magnetic-btn group relative px-12 py-5 bg-white text-black font-bold text-lg tracking-widest uppercase overflow-hidden rounded-sm transition-all hover:bg-accent hover:text-white">
<span class="relative z-10 flex items-center gap-3">
Generate Checklist
<i data-lucide="zap" class="w-5 h-5"></i>
</span>
<div class="absolute inset-0 h-full w-full bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover:animate-[shimmer_1.5s_infinite]"></div>
</button>
</div>
</main>
<!-- Results Section (Hidden Initially) -->
<section id="results-area" class="max-w-6xl mx-auto hidden pb-32">
<div class="flex flex-col md:flex-row justify-between items-end mb-12 border-b border-white/10 pb-6">
<div>
<h2 class="text-4xl md:text-5xl font-serif text-white mb-2">Your Checklist</h2>
<p class="text-text-dim">Tailored for <span id="res-arch" class="text-accent font-bold">Microservices</span>.</p>
</div>
<div class="flex gap-4 mt-6 md:mt-0">
<button id="export-btn" class="px-6 py-3 border border-white/20 hover:bg-white/10 rounded transition flex items-center gap-2 text-sm">
<i data-lucide="download" class="w-4 h-4"></i> Export JSON
</button>
<button onclick="window.print()" class="px-6 py-3 border border-white/20 hover:bg-white/10 rounded transition flex items-center gap-2 text-sm">
<i data-lucide="printer" class="w-4 h-4"></i> Print
</button>
</div>
</div>
<!-- Tabs -->
<div class="flex gap-8 mb-10 overflow-x-auto border-b border-white/5 pb-2" id="result-tabs">
<button class="tab-btn active font-bold text-accent border-b-2 border-accent pb-2" data-tab="all">All Questions</button>
<button class="tab-btn font-medium text-text-dim hover:text-white pb-2 transition" data-tab="resilience">Resilience Patterns</button>
<button class="tab-btn font-medium text-text-dim hover:text-white pb-2 transition" data-tab="observability">Observability</button>
<button class="tab-btn font-medium text-text-dim hover:text-white pb-2 transition" data-tab="recovery">Recovery & DR</button>
</div>
<!-- Checklist Grid -->
<div id="checklist-container" class="grid grid-cols-1 gap-4">
<!-- Checklist items injected by JS -->
</div>
</section>
</div>
<!-- Toast Notification -->
<div id="toast" class="fixed bottom-8 right-8 bg-surface border border-primary/30 text-white px-6 py-4 rounded shadow-2xl transform translate-y-24 opacity-0 transition-all duration-500 z-50 flex items-center gap-4">
<div class="bg-primary/20 p-2 rounded-full text-accent">
<i data-lucide="check-circle" class="w-5 h-5"></i>
</div>
<div>
<h4 class="font-bold text-sm">Success</h4>
<p class="text-xs text-text-dim" id="toast-msg">Checklist exported.</p>
</div>
</div>
<!-- Scripts -->
<script>
// Initialize Lucide Icons
lucide.createIcons();
/* -------------------------------------------------------------------------- */
/* RULE ENGINE */
/* -------------------------------------------------------------------------- */
const DB = {
questions: [
// General
{
id: 'g1',
text: "Do you have a defined SLA/SLO for system availability?",
category: 'observability',
tags: ['general']
},
{
id: 'g2',
text: "Is there a documented incident response runbook?",
category: 'recovery',
tags: ['general']
},
// Monolith
{
id: 'm1',
text: "Is the monolithic application containerized with resource constraints (CPU/Memory limits)?",
category: 'resilience',
tags: ['monolith']
},
{
id: 'm2',
text: "Do you implement a 'kill switch' or circuit breaker at the load balancer level?",
category: 'resilience',
tags: ['monolith']
},
{
id: 'm3',
text: "Is there a blue-green or canary deployment strategy?",
category: 'recovery',
tags: ['monolith']
},
// Microservices
{
id: 'ms1',
text: "Are services properly decoupled using a message queue (e.g., Kafka, RabbitMQ)?",
category: 'resilience',
tags: ['microservices']
},
{
id: 'ms2',
text: "Do you implement distributed tracing (e.g., Jaeger, Zipkin)?",
category: 'observability',
tags: ['microservices']
},
{
id: 'ms3',
text: "Is there a Service Mesh (Istio, Linkerd) handling retries and circuit breaking?",
category: 'resilience',
tags: ['microservices']
},
{
id: 'ms4',
text: "Are API contracts versioned and backward compatible?",
category: 'resilience',
tags: ['microservices']
},
// Serverless
{
id: 'sl1',
text: "Are cold start durations measured and included in timeout configurations?",
category: 'resilience',
tags: ['serverless']
},
{
id: 'sl2',
text: "Is function concurrency limited to prevent downstream overload?",
category: 'resilience',
tags: ['serverless']
},
{
id: 'sl3',
text: "Do you have dead letter queues (DLQ) for async invocations?",
category: 'recovery',
tags: ['serverless']
},
// Dependencies: SQL
{
id: 'sql1',
text: "Are connection pools configured with sensible max limits?",
category: 'resilience',
tags: ['sql']
},
{
id: 'sql2',
text: "Do you implement read replicas for scaling read traffic?",
category: 'resilience',
tags: ['sql']
},
{
id: 'sql3',
text: "Is there a separate failover strategy for the primary database node?",
category: 'recovery',
tags: ['sql']
},
// Dependencies: NoSQL
{
id: 'ns1',
text: "Have you tuned consistency levels (e.g., Quorum) for your use case?",
category: 'resilience',
tags: ['nosql']
},
{
id: 'ns2',
text: "Is data partitioned/sharded appropriately to avoid hot spots?",
category: 'resilience',
tags: ['nosql']
},
// Dependencies: Redis
{
id: 'rd1',
text: "Is there a cache invalidation strategy to prevent stale data?",
category: 'observability',
tags: ['redis']
},
{
id: 'rd2',
text: "Do you implement 'probabilistic early expiration' to prevent cache stampede?",
category: 'resilience',
tags: ['redis']
},
// Dependencies: Kafka
{
id: 'kf1',
text: "Are consumers configured to handle message retries without duplication?",
category: 'resilience',
tags: ['kafka']
},
{
id: 'kf2',
text: "Is consumer lag monitoring setup with critical alerts?",
category: 'observability',
tags: ['kafka']
},
// Dependencies: External API
{
id: 'api1',
text: "Do you implement bulkheads to isolate third-party API failures?",
category: 'resilience',
tags: ['external']
},
{
id: 'api2',
text: "Are timeouts explicitly set and significantly shorter than upstream timeouts?",
category: 'resilience',
tags: ['external']
},
{
id: 'api3',
text: "Is there a fallback mechanism (cached data or default response)?",
category: 'resilience',
tags: ['external']
},
// Historical Context
{
id: 'h1',
text: "Based on past outages, have you identified the single biggest source of failure?",
category: 'recovery',
tags: ['outage']
},
{
id: 'h2',
text: "Do you conduct regular 'Game Days' to practice failure scenarios?",
category: 'recovery',
tags: ['outage']
},
{
id: 'h3',
text: "Has the post-mortem process been formalized and shared with all teams?",
category: 'recovery',
tags: ['outage']
}
]
};
/* -------------------------------------------------------------------------- */
/* STATE MGMT */
/* -------------------------------------------------------------------------- */
const state = {
architecture: null,
dependencies: [],
hasOutage: false,
tightSLA: false
};
/* -------------------------------------------------------------------------- */
/* DOM ELEMENTS */
/* -------------------------------------------------------------------------- */
const els = {
archOptions: document.getElementById('architecture-options'),
depOptions: document.getElementById('dependency-options'),
generateBtn: document.getElementById('generate-btn'),
resultsArea: document.getElementById('results-area'),
checklistContainer: document.getElementById('checklist-container'),
resArch: document.getElementById('res-arch'),
tabs: document.querySelectorAll('.tab-btn'),
slider: document.getElementById('cost-slider'),
sliderVal: document.getElementById('cost-value'),
toast: document.getElementById('toast'),
toastMsg: document.getElementById('toast-msg')
};
/* -------------------------------------------------------------------------- */
/* SETUP */
/* -------------------------------------------------------------------------- */
function init() {
renderArchOptions();
renderDepOptions();
setupToggles();
setupSlider();
initThreeJS();
initCursor();
initAnimations();
}
function renderArchOptions() {
const options = [
{ id: 'monolith', label: 'Monolithic', desc: 'Single deployable unit, focus on resource exhaustion' },
{ id: 'microservices', label: 'Microservices', desc: 'Distributed system, focus on network & cascading failures' },
{ id: 'serverless', label: 'Serverless/FaaS', desc: 'Event-driven, focus on vendor limits & cold starts' },
{ id: 'hybrid', label: 'Hybrid Cloud', desc: 'Mix of on-prem & cloud, focus on interconnectivity' }
];
els.archOptions.innerHTML = options.map(opt => `
<div class="select-card p-6 rounded-xl cursor-pointer group relative overflow-hidden" data-value="${opt.id}">
<div class="absolute top-0 right-0 p-3 opacity-10 group-hover:opacity-20 transition-opacity transform translate-x-2 -translate-y-2">
<i data-lucide="box" class="w-8 h-8"></i>
</div>
<h3 class="text-xl font-bold mb-2 group-hover:text-primary transition-colors">${opt.label}</h3>
<p class="text-sm text-text-dim leading-snug">${opt.desc}</p>
</div>
`).join('');
// Add click listeners
document.querySelectorAll('#architecture-options .select-card').forEach(card => {
card.addEventListener('click', () => {
// Remove active class from all
document.querySelectorAll('#architecture-options .select-card').forEach(c => c.classList.remove('active'));
// Set active
card.classList.add('active');
state.architecture = card.dataset.value;
// Re-render dependency labels slightly to hint at relevance? Keep simple.
});
});
}
function renderDepOptions() {
const deps = [
{ id: 'sql', label: 'SQL (Postgres/MySQL)', icon: 'database' },
{ id: 'nosql', label: 'NoSQL (Cassandra/Mongo)', icon: 'layers' },
{ id: 'redis', label: 'Redis / Cache', icon: 'cpu' },
{ id: 'kafka', label: 'Kafka / Streaming', icon: 'activity' },
{ id: 'external', label: 'External APIs', icon: 'globe' }
];
els.depOptions.innerHTML = deps.map(dep => `
<button class="dep-chip glass-panel border border-white/10 px-5 py-3 rounded-full text-sm font-medium transition-all duration-300 hover:bg-surface-light focus:outline-none flex items-center gap-2" data-value="${dep.id}">
<div class="w-2 h-2 rounded-full bg-text-dim transition-colors"></div>
${dep.label}
</button>
`).join('');
// Chip click logic
document.querySelectorAll('.dep-chip').forEach(chip => {
chip.addEventListener('click', () => {
const val = chip.dataset.value;
if (state.dependencies.includes(val)) {
state.dependencies = state.dependencies.filter(d => d !== val);
chip.classList.remove('bg-primary/10', 'border-primary', 'text-primary');
chip.classList.add('bg-surface-light', 'border-white/10', 'text-text-dim');
chip.querySelector('div').classList.remove('bg-primary');
chip.querySelector('div').classList.add('bg-text-dim');
} else {
state.dependencies.push(val);
chip.classList.add('bg-primary/10', 'border-primary', 'text-primary');
chip.classList.remove('bg-surface-light', 'border-white/10', 'text-text-dim');
chip.querySelector('div').classList.add('bg-primary');
chip.querySelector('div').classList.remove('bg-text-dim');
}
});
});
}
function setupToggles() {
const toggleInputs = document.querySelectorAll('.shadow-inner');
toggleInputs.forEach(input => {
const dot = input.nextElementSibling;
input.addEventListener('click', () => {
const isChecked = input.previousElementSibling.checked;
input.previousElementSibling.checked = !isChecked;
if (!isChecked) {
input.parentElement.classList.add('bg-primary');
dot.classList.replace('translate-x-0', 'translate-x-6');
} else {
input.parentElement.classList.remove('bg-primary');
dot.classList.replace('translate-x-6', 'translate-x-0');
}
});
});
// Wire real checkboxes
document.getElementById('outage-toggle').addEventListener('change', (e) => state.hasOutage = e.target.checked);
document.getElementById('sla-toggle').addEventListener('change', (e) => state.tightSLA = e.target.checked);
}
function setupSlider() {
els.slider.addEventListener('input', (e) => {
els.sliderVal.innerText = e.target.value + 'k';
});
}
/* -------------------------------------------------------------------------- */
/* GENERATION LOGIC */
/* -------------------------------------------------------------------------- */
function generateChecklist() {
// Validation
if (!state.architecture) {
showToast('Please select an architecture pattern.', true);
return;
}
// 1. Filter questions based on tags
let selectedIds = new Set();
// Always add general questions
DB.questions.forEach(q => {
if (q.tags.includes('general')) selectedIds.add(q.id);
});
// Architecture specific
DB.questions.forEach(q => {
if (q.tags.includes(state.architecture)) selectedIds.add(q.id);
});
// Dependencies specific
state.dependencies.forEach(dep => {
DB.questions.forEach(q => {
if (q.tags.includes(dep)) selectedIds.add(q.id);
});
});
// Historical context
if (state.hasOutage) {
DB.questions.forEach(q => {
if (q.tags.includes('outage')) selectedIds.add(q.id);
});
}
if (state.tightSLA) {
// Add a few extra observability questions or stricter tolerances
DB.questions.forEach(q => {
if (q.category === 'observability') selectedIds.add(q.id);
});
}
// Convert to array and shuffle slightly for variety? Keep sorted by category for now.
const finalQuestions = DB.questions.filter(q => selectedIds.has(q.id));
return finalQuestions;
}
function renderResults(questions) {
els.resultsArea.classList.remove('hidden');
// Update header text
const archName = state.architecture.charAt(0).toUpperCase() + state.architecture.slice(1);
els.resArch.innerText = archName;
// Generate HTML
els.checklistContainer.innerHTML = questions.map(q => `
<div class="group relative flex items-start p-6 rounded-lg bg-surface border border-white/5 hover:border-primary/30 transition-colors checkbox-item" data-category="${q.category}">
<label class="flex items-start gap-4 w-full cursor-pointer">
<input type="checkbox" class="hidden" onchange="updateState(this)">
<div class="mt-1 w-6 h-6 border-2 border-white/20 rounded flex items-center justify-center transition-all duration-300 group-hover:border-primary">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" class="opacity-0 scale-50 transition-all duration-300 check-icon"><polyline points="20 6 9 17 4 12"></polyline></svg>
</div>
<div class="flex-1">
<p class="text-lg font-light leading-relaxed text-gray-200 group-hover:text-white transition-colors">${q.text}</p>
<span class="inline-block mt-3 text-xs font-bold tracking-wider uppercase text-text-dim border border-white/10 px-2 py-1 rounded">${q.category}</span>
</div>
</label>
</div>
`).join('');
// Re-animate in
gsap.fromTo('.checkbox-item',
{ y: 30, opacity: 0 },
{ y: 0, opacity: 1, duration: 0.5, stagger: 0.05, ease: 'power2.out' }
);
// Smooth scroll to results
els.resultsArea.scrollIntoView({ behavior: 'smooth' });
}
function updateState(checkbox) {
// Visual feedback handled by CSS sibling selector mostly, but we can track "completed" if needed.
// For this demo, visual toggle is enough.
const row = checkbox.closest('.checkbox-item');
const icon = row.querySelector('.check-icon');
const box = row.querySelector('div');
if (checkbox.checked) {
icon.classList.remove('opacity-0', 'scale-50');
icon.classList.add('opacity-100', 'scale-100');
box.classList.add('bg-primary/20', 'border-primary');
row.classList.add('opacity-60');
} else {
icon.classList.add('opacity-0', 'scale-50');
icon.classList.remove('opacity-100', 'scale-100');
box.classList.remove('bg-primary/20', 'border-primary');
row.classList.remove('opacity-60');
}
}
/* -------------------------------------------------------------------------- */
/* EXPORT */
/* -------------------------------------------------------------------------- */
function exportToJSON() {
const checked = [];
const unchecked = [];
document.querySelectorAll('.checkbox-item').forEach(item => {
const cb = item.querySelector('input');
const text = item.querySelector('p').innerText;
if (cb.checked) checked.push(text);
else unchecked.push(text);
});
// Mock export
const data = {
generated_at: new Date().toISOString(),
configuration: { ...state },
checklist: {
completed: checked,
pending: unchecked
}
};
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `resilience-checklist-${state.architecture}.json`;
a.click();
URL.revokeObjectURL(url);
showToast('Checklist exported successfully.');
}
function showToast(msg, isError = false) {
els.toastMsg.innerText = msg;
els.toast.classList.remove('translate-y-24', 'opacity-0');
if(isError) {
els.toast.querySelector('.bg-primary\\/20').classList.replace('bg-primary/20', 'bg-accent/20');
els.toast.querySelector('.text-accent').classList.replace('text-accent', 'text-accent');
} else {
els.toast.querySelector('.bg-primary\\/20').classList.replace('bg-accent/20', 'bg-primary/20');
}
setTimeout(() => {
els.toast.classList.add('translate-y-24', 'opacity-0');
}, 3000);
}
/* -------------------------------------------------------------------------- */
/* THREE.JS */
/* -------------------------------------------------------------------------- */
function initThreeJS() {
const container = document.getElementById('canvas-container');
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
container.appendChild(renderer.domElement);
// Particles
const particlesGeometry = new THREE.BufferGeometry();
const particlesCount = 300; // Low set point for performance/elegance
const posArray = new Float32Array(particlesCount * 3);
for(let i = 0; i < particlesCount * 3; i++) {
// Spread across larger area
posArray[i] = (Math.random() - 0.5) * 15;
}
particlesGeometry.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
// Material
const material = new THREE.PointsMaterial({
size: 0.03,
color: 0x00A8FF,
transparent: true,
opacity: 0.8
});
// Mesh
const particlesMesh = new THREE.Points(particlesGeometry, material);
scene.add(particlesMesh);
// Lines geometry connecting close particles
const lineMaterial = new THREE.LineBasicMaterial({
color: 0x00A8FF,
transparent: true,
opacity: 0.1
});
const lineGeometry = new THREE.BufferGeometry();
const linesMesh = new THREE.LineSegments(lineGeometry, lineMaterial);
scene.add(linesMesh);
// Ambient light
const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
scene.add(ambientLight);
camera.position.z = 3;
// Mouse interaction
let mouseX = 0;
let mouseY = 0;
let targetX = 0;
let targetY = 0;
document.addEventListener('mousemove', (event) => {
mouseX = event.clientX / window.innerWidth - 0.5;
mouseY = event.clientY / window.innerHeight - 0.5;
});
const clock = new THREE.Clock();
function animate() {
const elapsedTime = clock.getElapsedTime();
targetX = mouseX * 0.5;
targetY = mouseY * 0.5;
particlesMesh.rotation.y += 0.001;
particlesMesh.rotation.x += 0.0005;
// Mouse parallax
particlesMesh.rotation.y += 0.05 * (targetX - particlesMesh.rotation.y);
particlesMesh.rotation.x += 0.05 * (targetY - particlesMesh.rotation.x);
// Update lines
updateLines(particlesMesh);
// "Breathing" effect via sphere math (optional)
// ...
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
function updateLines(mesh) {
const positions = mesh.geometry.attributes.position.array;
const linePositions = [];
const connectDistance = 2.5;
for (let i = 0; i < particlesCount; i++) {
const particleA = new THREE.Vector3(
positions[i * 3],
positions[i * 3 + 1],
positions[i * 3 + 2]
);
for (let j = i + 1; j < particlesCount; j++) {
const particleB = new THREE.Vector3(
positions[j * 3],
positions[j * 3 + 1],
positions[j * 3 + 2]
);
if (particleA.distanceTo(particleB) < connectDistance) {
linePositions.push(
particleA.x, particleA.y, particleA.z,
particleB.x, particleB.y, particleB.z
);
}
}
}
lineGeometry.setAttribute('position', new THREE.Float32BufferAttribute(linePositions, 3));
}
animate();
// Resize
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
}
/* -------------------------------------------------------------------------- */
/* CUSTOM CURSOR */
/* -------------------------------------------------------------------------- */
function initCursor() {
const dot = document.querySelector('.cursor-dot');
const outline = document.querySelector('.cursor-outline');
window.addEventListener('mousemove', (e) => {
const posX = e.clientX;
const posY = e.clientY;
dot.style.left = `${posX}px`;
dot.style.top = `${posY}px`;
// Animate outline with delay
outline.animate({
left: `${posX}px`,
top: `${posY}px`
}, { duration: 500, fill: "forwards" });
});
}
/* -------------------------------------------------------------------------- */
/* ANIMATIONS */
/* -------------------------------------------------------------------------- */
function initAnimations() {
gsap.registerPlugin(ScrollTrigger);
// Fade in main content
gsap.from("header", {
y: 50,
opacity: 0,
duration: 1,
ease: "power3.out",
delay: 0.2
});
// Scroll section reveals
gsap.utils.toArray('.scroll-reveal').forEach(section => {
gsap.from(section, {
scrollTrigger: {
trigger: section,
start: "top 80%",
},
y: 30,
opacity: 0,
duration: 0.8,
ease: "power2.out"
});
});
// Magnetic Button
const magneticBtn = document.getElementById('generate-btn');
magneticBtn.addEventListener('mousemove', (e) => {
const rect = magneticBtn.getBoundingClientRect();
const x = e.clientX - rect.left - rect.width / 2;
const y = e.clientY - rect.top - rect.height / 2;
gsap.to(magneticBtn, {
duration: 0.3,
x: x * 0.3,
y: y * 0.3,
ease: "power2.out"
});
});
magneticBtn.addEventListener('mouseleave', () => {
gsap.to(magneticBtn, {
duration: 0.5,
x: 0,
y: 0,
ease: "elastic.out(1, 0.3)"
});
});
// Generate Click Glitch Effect
magneticBtn.addEventListener('click', () => {
// Trigger validation logic
if (!state.architecture) {
// Shake animation for error
gsap.to(els.archOptions, { x: -10, duration: 0.1, yoyo: true, repeat: 3 });
showToast('Please select an architecture first.', true);
return;
}
// Simulate processing
const btnOriginal = magneticBtn.innerHTML;
magneticBtn.classList.add('opacity-75', 'cursor-wait');
magneticBtn.innerHTML = `<span class="relative z-10 flex items-center gap-3"><i data-lucide="loader-2" class="w-5 h-5 animate-spin"></i> Analyzing...</span>`;
lucide.createIcons();
setTimeout(() => {
const checklist = generateChecklist();
renderResults(checklist);
magneticBtn.classList.remove('opacity-75', 'cursor-wait');
magneticBtn.innerHTML = btnOriginal;
lucide.createIcons();
}, 1200);
});
// Tab Switching
els.tabs.forEach(tab => {
tab.addEventListener('click', () => {
els.tabs.forEach(t => {
t.classList.remove('active', 'text-accent', 'border-b-2', 'border-accent');
t.classList.add('text-text-dim');
});
tab.classList.add('active', 'text-accent', 'border-b-2', 'border-accent');
tab.classList.remove('text-text-dim');
const filter = tab.dataset.tab;
const items = document.querySelectorAll('.checkbox-item');
items.forEach(item => {
if (filter === 'all') {
item.style.display = 'flex';
} else {
if (item.dataset.category === filter) {
item.style.display = 'flex';
} else {
item.style.display = 'none';
}
}
});
});
});
// Export click
document.getElementById('export-btn').addEventListener('click', exportToJSON);
}
// Run Init
window.addEventListener('DOMContentLoaded', init);
</script>
</body>
</html>