Here's a thinking process that leads to the suggested file processing pipeline simulation:
-
Analyze the Request:
- User Goal: "Build a file processing pipeline: antivirus, MIME, and lifecycle."
- Context: The user wants a single-page HTML application that visualizes a process where files go through Antivirus scanning, MIME type detection, and lifecycle management (archiving/deleting/moving).
- Role: Top-tier creative frontend engineer + UI/UX designer (10 years experience). Aesthetic: Minimalism, Swiss Design, avant-garde digital interaction.
- Design Principles: Deep typography hierarchy, negative space, color psychology (60-30-10), micro-interactions, non-linear layout (maybe), parallax/scroll, Bento Grids.
- Technical Stack: Tailwind CSS (preferred), GSAP/Framer Motion for animations, SVG filters, glassmorphism, mesh gradients, grain texture. No native alerts. 3D/Canvas if appropriate.
- Constraint: Single self-contained HTML file. No external build steps (must include CDN links).
-
Interpret the "Pipeline" Concept:
- This is a simulation or visualization of a backend process. Since I cannot actually run server-side AV scans in a static HTML file, I must build a frontend UI that simulates this behavior.
- Core Features:
- Upload area (Drag & Drop).
- Visual representation of the pipeline stages:
- Ingress (Queue).
- Antivirus (Scanning, status: Safe/Threat).
- MIME Detection (Identifying type).
- Lifecycle (Routing: Archive, Delete, Process).
- Real-time logs/status updates.
- Analytics dashboard (Success vs. Threat rates, throughput).
- Aesthetic Approach:
- Dark mode base for that "cyber/security" feel but clean (Swiss style = clean lines, strong typography).
- Use a mesh gradient background (cool blues/purples for tech, reds for threats, greens for safe).
- The pipeline should be visualized as a flow of cards or a 3D tunnel. Given the aversion to standard carousels, maybe a "conveyor belt" style or a vertical/horizontal flow where files physically move between stations.
-
Technical Architecture (Single HTML):
- Libraries (CDN):
- Tailwind CSS (script tag).
- GSAP (for animations).
- Font Awesome (for icons).
- Google Fonts (Inter, Playfair Display for contrast).
- Lenis (for smooth scrolling) – optional but nice.
- Three.js (maybe overkill, but could be used for background particles/network). Decision: Let's use HTML5 Canvas for a particle network background to keep it performant but "techy."
- Structure:
header: Logo/Title.
section#hero: Big typography, "Secure File Processing Pipeline".
section#pipeline: The core interactive area. A grid representing stations. Draggable items (files) moving from station to station? Or an automated queue?
- Better approach for "Pipeline": A dashboard view.
- Left side: Current File Queue (List of files).
- Center: Visual Pipeline (Station icons with moving file icons traveling between them).
- Right side: Logs/inspector.
section#stats: Bento Grid showing stats (Total Processed, Threats Found, Throughput).
section#upload: Drag & drop zone.
footer.
-
Detailed Design & Interactions:
-
Color Palette: Dark background (#0f0f11 or near black). Accents:
- Primary: Electric Blue (
#3b82f6).
- Success: Neon Green (
#10b981).
- Threat: Glowing Red (
#ef4444).
- Background: Mesh Gradient using CSS
radial-gradient blobs.
-
Typography: Inter for UI, Playfair Display for headers (elegant touch in a technical context).
-
Animation Logic (GSAP):
- When a file is "uploaded", it enters a "queued" array.
- A timer/interval triggers the next file to start processing.
- Stage 1 (AV): File icon moves to AV station. Spinner icon appears. Random duration (1-3s). Then result: Safe (Green check) or Threat (Red X). If Threat, file moves to "Quarantine" station and stops. If Safe, moves to MIME.
- Stage 2 (MIME): File moves to MIME station. Icon changes based on file type (document, image, video) detected. Short duration.
- Stage 3 (Lifecycle): File moves to final station. Action determined by rules (e.g., Move to Archive, Delete). Visual feedback: file fades out or moves to an "Archive" box.
-
Step-by-Step Implementation Plan:
- Step 1: Skeleton & CSS: Set up Tailwind, Fonts. Define custom CSS for grain texture, glassmorphism (
backdrop-filter: blur), and mesh background.
- Step 2: Background: Create a canvas drawing moving nodes/connections (data flow). Subtle.
- Step 3: Header & Hero: Big text, "The Guardian Pipeline".
- Step 4: Upload Zone: Functional drag-and-drop (listening to
drop event). Generates a file object with random properties (size, type) for simulation.
- Step 5: The Pipeline Visualization:
- Layout: Three main vertical or horizontal bars. Let's go Horizontal for a "flow" feel, but responsive to become vertical on mobile. Actually, a horizontal process road is classic and effective.
- "Files" will be DOM elements moving across using GSAP
to() and set.
- Step 6: Libraries Dashboard (Bento Grid): Top of page or bottom? Let's put top or integrated. A Bento grid is perfect for stats.
- Step 7: Logs: A terminal-like window showing textual output of actions (e.g.,
[INFO] Scanning file_req_223.dat..., [WARN] Heuristics triggered: Suspicious entropy).
- Step 8: Refinement: Add hover effects, custom cursor maybe? Keep it clean. Ensure "No native alerts" – use a custom toast notification system.
-
Refining the Code Structure (Mental Draft):
<html>
<head>: Tailwind CDN, GSAP CDN, Google Fonts.
<style>: Custom animations, scrollbar hiding, grain overlay.
<body>:
<canvas id="bg-canvas">: Background.
<div id="app" class="relative z-10">:
<nav>: Minimal logo, "System Ready".
<main>:
section#dashboard: Bento Grid (Stats).
section#pipeline-container:
- Columns: Upload -> AV -> MIME -> Lifecycle.
- Active elements floating here.
section#logs: Terminal window.
section#controls: Buttons to add test files, clear.
<div id="toast-container">.
<script>:
- Particle System: Class creating dots/lines.
- State:
files = [], stats = { processed: 0, threats: 0, ... }.
- File Class: Constructor(name, size, type). Methods:
render() (creates DOM element), moveTo(station), finish().
- Simulation Loop:
processNextFile() function using setTimeout.
- GSAP Animations: Moving file elements between DOM nodes (stations).
- Log Renderer: Append lines to log div, auto-scroll.
-
Addressing "Swiss Design" & "Negative Space":
- Use generous padding (
py-20, px-10).
- Borders: Thin, crisp (
border-white/10).
- Typography: Large headings (e.g.,
text-6xl), uppercase tracking-widest for labels.
- Functional, stark contrasts.
-
Implementation Details & Edge Cases:
- File Types: Randomize .exe, .pdf, .jpg, .dll.
- Threat Probability: 10% maybe.
- MIME Logic: Map ext to generic icon.
- Lifecycle Logic: If image -> High Quality Archive; If PDF -> Storage; If .exe -> Sandbox -> Delete (depending on threat). Or keep simple: All safe -> Archive; All High Risk -> Quarantine.
- Responsive: Use Tailwind
grid-cols-1 md:grid-cols-4.
-
Self-Correction/Optimization during thought process:
- Critique: Horizontal movement on mobile is hard.
- Fix: The pipeline should perhaps be a vertical stack on mobile (
flex-col) and horizontal on desktop. GSAP's Flip plugin would be great for responsive movement, but I can't use plugins easily in a single file without complex imports. I'll simply recalculate coordinates based on station positions using getBoundingClientRect and move the element to the next container absolute positioned? That's messy.
- Better approach: Keep it simple. The "file icons" are just visual markers. I'll have a central "track". On mobile, the track bends? Too complex.
- Simpler: Use a dashboard where files jump into "Active Processing" and then disappear to logs. But the user asked for a pipeline.
- Compromise: The pipeline is conceptual. I will render it as a horizontal row of 4 distinct zones. The "File" element will be a small card. I'll use GSAP to animate
left/top properties based on the centers of the zones. Since zones are fixed relative to container on desktop, it works. On mobile (<768px), I will switch to a vertical layout using CSS Flexbox flex-col. I will use JS to detect resize and recalculate positions or simply restart the queue on resize (acceptable for a demo). Or better: I'll make the zones stack vertically on mobile and stick to top-down motion. I'll detect the direction in JS.
-
Writing the Code (Mental Sandbox):
-
Refining Visuals:
- Mesh Gradient: Use fixed position
divs with blur-3xl and low opacity, moving slightly in background.
- Glassmorphism:
bg-white/5 backdrop-blur-md border border-white/10 for panels.
- Noise: Base64 noise image or CSS generation (SVG filter). I'll use a small CSS pattern
background-image: url("data:image/svg+xml...") for noise.
-
Final Polish:
- Add a "Terminal" at the bottom for that "hacker/security" vibe.
- Make sure "Upload" actually parses the file list and adds them to the queue.
- Add "Controls" to add random files if user doesn't have any handy.
- Ensure all text is English as requested.
-
Output Generation:
- Combine all into the final HTML string.
- Double-check CDN links (Tailwind v3.4, GSAP v3).
- Verify no
alert() is used.
- Check contrast ratios.
(Self-Correction during drafting code): I initially thought about using Three.js for 3D. But the user wants a "pipeline". A 2D flow using GSAP is cleaner and fits the "Swiss Design" precision better than a potentially janky 3D scene. However, to satisfy the "3D or shader" trigger, I can add a subtle canvas particle background that looks like connecting neurons, giving depth without overwhelming the UI. That fits the "data flow" theme perfectly.
Let's proceed with:
- Canvas Background: Auto-moving connections.
- Main UI: Glassmorphism panels.
- Pipeline: 3D-ish depth using
box-shadow and scaling (elements closer to viewer scale up). I'll use perspective on the container and rotateX for a slight isometric or tilted look? No, Swiss design is flat. I'll keep it flat but use Z-index layering and maybe subtle shadows to denote "active" processing.
- Typography: Inter (body), Space Grotesk (for tech data/numbers), Playfair Display (headings).
Let's refine the "Pipeline" layout. A horizontal line with vertical cards? Or a card flow?
Idea: A "Conveyor Belt" container. Files are cards. They move left to right.
Left to Right:
- Ingress: Drop zone lives here too? Maybe separate.
- Antivirus: Station shows a Shield.
- MIME: Station shows a Document/File Icon.
- Lifecycle: Station shows a lifecycle icon (recycle/archive).
Actually, it's better to separate the "Upload" (action) from the "Pipeline" (status). The pipeline visualizes active files moving through fixed points.
Let's build it.
(Drafting the Code - Mental Check of specific libraries)
- Tailwind CDN:
https://cdn.tailwindcss.com
- GSAP:
https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js
- Fonts: Google Fonts URL.
- Icons: FontAwesome CDN or inline SVGs. Inline SVGs are more robust (no font loading lag). I'll use a few inline SVGs for critical icons (Shield, File, Trash, Check, Alert).
(Detailed File Logic)
-
files array.
-
processFile(file) function:
- Create DOM element (a small "card" with filename, status icon).
- Append to
#pipeline-track.
- Add to a "currently processing" set.
- Define
steps array.
- Function
runStep(index):
- Move file to
steps[index].zone
- Wait for "action" (duration).
- Update file state (change icon/color).
- If last step, finish: remove file, update stats, log.
- Else:
runStep(index+1).
-
This ensures only one file is processed at a time? Or multiple? Real pipelines are concurrent. I should allow multiple files. I'll use a queue pointer. processQueue() pulls from queue, if activeCount < MAX_CONCURRENCY (say 5), start file.
Let's handle concurrency simply: processNextFile() checks if we have capacity. If yes, takes next from queue array, creates it, starts its animation chain. The chain is independent per file.
(Animation Details)
- Move file DOM element from one zone's center to the next.
- While moving, the file inside could rotate or pulse.
- When inside a zone, the file should "dock" (align left or center). Let's align center of the zone.
- Zones are
divs with position: relative. The file will be absolute.
- I need to calculate positions relative to the main track.
- GSAP:
gsap.to(fileEl, { left: targetX, top: targetY, duration: 1 ... }). targetX = zone.offsetLeft + zone.offsetWidth/2 - fileWidth/2.
(Safety/MIME detection simulation)
- Randomly assign a "danger" flag (0.1 probability).
- If danger: AV result = "Threat". Simulation: file turns red, maybe a shake animation. Then skip MIME? Actually, security pipeline often sends threats to quarantine immediately. I'll define: If threat -> go to Lifecycle -> "Quarantine". Else -> MIME -> Lifecycle -> "Archive".
- MIME detection: based on file extension (faked) or random category (Image, Doc, Executable).
(Bento Grid)
- Grid of 2x2 or 1x3 cards.
- Cards: "Total Scanned", "Threats Detected", "Avg Scan Time", "Queue Size".
- Values update in real-time.
(Logs)
- A
div with monospace font, black/green background.
- Prepend new lines.
(Selection of Colors - Swiss/Tech)
- Bg:
#080808 (almost black).
- Text:
#ededed, #a1a1aa.
- Primary:
#3b82f6 (Blue).
- Success:
#10b981 (Green).
- Danger:
#ef4444 (Red).
- Colors in gradients: Blue to Purple.
(Micro-interactions)
- Hover over a file in the active queue? Not needed, it's moving.
- Hover over stats: scale up slightly, shadow increase.
- Upload button: Magnetic effect? Maybe a simple GSAP hover effect (scale).
- Buttons: "Add Random File", "Clear Logs".
(Final Code Assembly)
I will write the complete HTML with embedded CSS/JS.
Let's start coding the background canvas first. Simple particles.
Then Tailwind config (colors, fonts).
Then DOM structure.
Then JS logic.
I need to ensure the pipeline zones are clearly visible. I'll use borders and labels.
Double check "No native alerts": Use a custom function showToast(message, type) that creates a fixed div and fades it out.
Check "Responsive": Tailwind md:flex-row vs flex-col.
Check "Images & Icons": Use inline SVGs for reliability.
Check "Semantic HTML": Use <main>, <section>, <header>.
Check "Content Language": English (as requested).
Let's go.
(Self-Correction during code generation): The prompt says "Research and output requirements... determine whether... is needed." I don't need to discuss, just output. But the system instruction says "Think step by step...". I will proceed directly to writing the solution.
Pipeline Visualization specific:
The "track" needs a perspective? Maybe I'll add a transform: perspective(1000px) rotateX(5deg) to give it a slight "floor" look, very subtle. Elements moving across will appear to have depth. This adds that "3D" feel requested without full Three.js.
Zones:
- Ingress (Upload): Icon is "upload".
- AV: Icon is "shield".
- MIME: Icon is "file-code".
- Lifecycle: Icon is "arrows-rotate" (for archiving) or "database".
I will implement "Lifecycle" as "Destination" (Archive or Delete).
Let's refine the "Swiss Design" aspect:
- Use a strong monochromatic base with one accent color.
- Use a massive font size for the main title:
text-7xl or text-8xl.
- Use a "Grid" layout for the main content that feels rigid yet balanced.
Okay, writing code.
(Final check on libraries):
- Tailwind script:
src="https://cdn.tailwindcss.com"
- GSAP:
src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"
- Fonts:
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&family=Playfair+Display:wght@700&family=Space+Grotesk:wght@300;500;700&display=swap" rel="stylesheet">
I'll configure Tailwind inside the script tag to use these fonts and custom colors if needed.
Let's create the showToast function.
Ready.
Here is the complete, self-contained HTML file implementing a high-end, visually striking, and fully interactive file processing pipeline simulation.
The design adheres to Swiss Minimalism with a dark-tech aesthetic, featuring a real-time particle background, a GSAP-powered conveyor belt pipeline, live logs, and a Bento-grid dashboard. It supports drag-and-drop file uploads and simulates AV scanning, MIME detection, and lifecycle management with concurrency.
Save this code as pipeline.html and open it in any modern browser.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NEXUS | Secure Pipeline Visualizer</title>
<!-- Google Fonts: Inter (UI), Playfair Display (Headings), Space Grotesk (Data) -->
<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:wght@700;800&family=Space+Grotesk:wght@300;500;700&display=swap" rel="stylesheet">
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- GSAP Animation -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<!-- Tailwind Config -->
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
display: ['Playfair Display', 'serif'],
mono: ['Space Grotesk', 'monospace'],
},
colors: {
'dg-black': '#050505',
'dg-gray': '#121212',
'dg-surface': 'rgba(255, 255, 255, 0.03)',
'dg-border': 'rgba(255, 255, 255, 0.1)',
'dg-accent': '#3b82f6', // Electric Blue
'dg-success': '#10b981',
'dg-danger': '#ef4444',
'dg-warn': '#f59e0b',
},
backgroundImage: {
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
}
}
}
}
</script>
<style>
/* Base Styles */
body {
background-color: #050505;
color: #ededed;
overflow-x: hidden;
-webkit-font-smoothing: antialiased;
}
/* Grain 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)' opacity='1'/%3E%3C/svg%3E");
}
/* Mesh Gradient Orbs */
.mesh-orb {
position: absolute;
border-radius: 50%;
filter: blur(80px);
z-index: 0;
opacity: 0.4;
animation: pulseOrb 10s infinite alternate;
}
@keyframes pulseOrb {
0% { transform: scale(1); opacity: 0.3; }
100% { transform: scale(1.2); opacity: 0.5; }
}
/* Glassmorphism */
.glass-panel {
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);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}
/* Custom Scrollbar */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: #000;
}
::-webkit-scrollbar-thumb {
background: #333;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Terminal Styles */
.terminal-text {
font-family: 'Space Grotesk', monospace;
text-shadow: 0 0 5px rgba(16, 185, 129, 0.3);
}
/* Pipeline File Card */
.pipeline-file {
position: absolute;
width: 80px;
height: 60px;
background: rgba(30,30,30,0.9);
border: 1px solid rgba(255,255,255,0.15);
border-radius: 8px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 10px;
color: #aaa;
box-shadow: 0 4px 12px rgba(0,0,0,0.6);
z-index: 10;
transform-origin: center center;
will-change: transform, left, top;
}
.pipeline-file.processing {
border-color: var(--tw-text-opacity, #3b82f6);
box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}
.pipeline-file::after {
content: '';
position: absolute;
bottom: 4px;
width: 6px;
height: 6px;
background: #555;
border-radius: 50%;
}
.pipeline-file.safe::after { background: #10b981; }
.pipeline-file.threat::after { background: #ef4444; }
/* Zone Highlight (Active) */
.zone.active .zone-label {
color: #fff;
text-shadow: 0 0 10px currentColor;
}
.zone.active .zone-icon {
transform: scale(1.2);
filter: drop-shadow(0 0 8px currentColor);
}
/* Magnetic Button Effect Class */
.magnetic-area {
transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
</style>
</head>
<body class="min-h-screen flex flex-col texture-bg">
<!-- Noise Overlay -->
<div class="noise-overlay"></div>
<!-- Dynamic Background Canvas -->
<canvas id="particle-canvas" class="fixed inset-0 w-full h-full pointer-events-none z-0"></canvas>
<!-- Lighting Orbs -->
<div class="mesh-orb bg-blue-600 top-0 left-1/4 w-96 h-96 mix-blend-screen"></div>
<div class="mesh-orb bg-purple-600 bottom-0 right-1/4 w-80 h-80 mix-blend-screen animation-delay-2000"></div>
<!-- Main Content -->
<div class="relative z-10 container mx-auto px-4 md:px-8 py-8 max-w-7xl flex-1 flex flex-col">
<!-- Header -->
<header class="flex flex-col md:flex-row justify-between items-end mb-12 border-b border-dg-border pb-6">
<div>
<div class="text-xs font-mono text-dg-accent uppercase tracking-widest mb-2">System v2.4.0 // Online</div>
<h1 class="text-5xl md:text-7xl font-display font-bold leading-none tracking-tight">
NEXUS<br><span class="text-2xl md:text-4xl text-gray-400 font-sans font-light mt-2 block">Intelligence Pipeline</span>
</h1>
</div>
<div class="mt-6 md:mt-0">
<button id="add-random-btn" class="magnetic-btn group relative px-6 py-3 bg-dg-accent text-white font-mono text-sm font-bold uppercase tracking-wider rounded-none overflow-hidden">
<span class="absolute inset-0 w-full h-full bg-white/10 translate-y-full group-hover:translate-y-0 transition-transform duration-300"></span>
<span class="relative flex items-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path></svg>
Ingest Random
</span>
</button>
</div>
</header>
<!-- Bento Dashboard Stats -->
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
<!-- Stat 1 -->
<div class="glass-panel p-6 rounded-2xl relative overflow-hidden group hover:border-dg-accent/50 transition-colors duration-300">
<div class="absolute top-0 right-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity">
<svg class="w-16 h-16 text-dg-accent" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/></svg>
</div>
<div class="text-sm text-gray-500 font-mono uppercase">Processed</div>
<div class="text-4xl font-mono font-bold text-white mt-2" id="stat-processed">0</div>
</div>
<!-- Stat 2 -->
<div class="glass-panel p-6 rounded-2xl relative overflow-hidden group hover:border-dg-danger/50 transition-colors duration-300">
<div class="absolute top-0 right-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity">
<svg class="w-16 h-16 text-dg-danger" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>
</div>
<div class="text-sm text-gray-500 font-mono uppercase">Threats Found</div>
<div class="text-4xl font-mono font-bold text-dg-danger mt-2" id="stat-threats">0</div>
</div>
<!-- Stat 3 -->
<div class="glass-panel p-6 rounded-2xl relative overflow-hidden group hover:border-dg-success/50 transition-colors duration-300">
<div class="absolute top-0 right-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity">
<svg class="w-16 h-16 text-dg-success" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>
</div>
<div class="text-sm text-gray-500 font-mono uppercase">Queue</div>
<div class="text-4xl font-mono font-bold text-dg-success mt-2" id="stat-queue">0</div>
</div>
<!-- Stat 4 -->
<div class="glass-panel p-6 rounded-2xl relative overflow-hidden group hover:border-white/50 transition-colors duration-300">
<div class="absolute top-0 right-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity">
<svg class="w-16 h-16 text-white" fill="currentColor" viewBox="0 0 24 24"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z"/></svg>
</div>
<div class="text-sm text-gray-500 font-mono uppercase">Avg Time</div>
<div class="text-4xl font-mono font-bold text-white mt-2"><span id="stat-avg-time">0.0</span><span class="text-sm ml-1">ms</span></div>
</div>
</div>
<!-- Main Pipeline Visualization -->
<div class="glass-panel rounded-2xl p-1 mb-8 flex-1 flex flex-col min-h-[400px] relative overflow-hidden" id="main-panel">
<!-- Header inside Panel -->
<div class="flex justify-between items-center p-4 border-b border-dg-border">
<h3 class="font-mono text-xs uppercase text-gray-400 tracking-widest">Pipeline Stream</h3>
<div class="flex gap-4 text-xs font-mono">
<span class="flex items-center gap-2 text-dg-success"><span class="w-2 h-2 rounded-full bg-dg-success animate-pulse"></span> Live</span>
</div>
</div>
<!-- Track Area -->
<div class="flex-1 relative p-8 flex items-center" id="pipeline-track">
<!-- Connection Lines (SVG) -->
<svg class="absolute inset-0 w-full h-full pointer-events-none stroke-dg-border stroke-1" id="pipeline-svg">
<line id="line-1" x1="0" y1="0" x2="0" y2="0" />
<line id="line-2" x1="0" y1="0" x2="0" y2="0" />
<line id="line-3" x1="0" y1="0" x2="0" y2="0" />
</svg>
<!-- Station 1: Ingress -->
<div class="station zone-enter relative w-1/4 h-full flex flex-col items-center justify-center z-20" id="station-1">
<div class="absolute top-8 left-1/2 -translate-x-1/2 zone-icon transition-all duration-500">
<svg class="w-8 h-8 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path></svg>
</div>
<div class="zone-label font-mono text-xs uppercase text-gray-500 mt-12 text-center">Ingress</div>
<div class="w-px h-16 bg-dg-border mt-2"></div>
</div>
<!-- Station 2: Antivirus -->
<div class="station zone-av relative w-1/4 h-full flex flex-col items-center justify-center z-20 border-l border-r border-dg-border" id="station-2">
<div class="absolute top-8 left-1/2 -translate-x-1/2 zone-icon transition-all duration-500">
<svg class="w-8 h-8 text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"></path></svg>
</div>
<div class="zone-label font-mono text-xs uppercase text-gray-500 mt-12 text-center">Antivirus</div>
<div class="w-px h-16 bg-dg-border mt-2"></div>
</div>
<!-- Station 3: MIME -->
<div class="station zone-mime relative w-1/4 h-full flex flex-col items-center justify-center z-20 border-r border-dg-border" id="station-3">
<div class="absolute top-8 left-1/2 -translate-x-1/2 zone-icon transition-all duration-500">
<svg class="w-8 h-8 text-yellow-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
</div>
<div class="zone-label font-mono text-xs uppercase text-gray-500 mt-12 text-center">MIME Detect</div>
<div class="w-px h-16 bg-dg-border mt-2"></div>
</div>
<!-- Station 4: Lifecycle -->
<div class="station zone-life relative w-1/4 h-full flex flex-col items-center justify-center z-20" id="station-4">
<div class="absolute top-8 left-1/2 -translate-x-1/2 zone-icon transition-all duration-500">
<svg class="w-8 h-8 text-purple-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 8l-4 4h3c0 3.31-2.69 6-6 6-1.01 0-1.97-.25-2.8-.7l-1.46 1.46C8.97 19.54 10.43 20 12 20c4.97 0 9-4.03 9-9 0-1.42-.56-2.75-1.53-3.73L19 8z"></path></svg>
</div>
<div class="zone-label font-mono text-xs uppercase text-gray-500 mt-12 text-center">Lifecycle</div>
<div class="w-px h-8 bg-dg-border mt-2"></div>
</div>
<!-- File elements will be injected here via JS -->
</div>
<!-- Tooltip / Context Area -->
<div id="context-info" class="absolute bottom-4 right-4 glass-panel px-4 py-2 rounded text-xs font-mono text-gray-500 pointer-events-none opacity-0 transition-opacity duration-300">
Waiting for file...
</div>
</div>
<!-- Terminal / Logs -->
<div class="glass-panel rounded-2xl p-0 mb-8 flex flex-col overflow-hidden border-l-4 border-l-dg-accent">
<div class="bg-black/40 px-4 py-2 border-b border-dg-border flex justify-between items-center">
<span class="text-xs font-mono text-gray-400">System Logs</span>
<button id="clear-logs" class="text-xs text-gray-500 hover:text-white transition-colors uppercase">Clear</button>
</div>
<div id="terminal" class="h-32 md:h-48 overflow-y-auto p-4 font-mono text-xs leading-relaxed text-gray-300 bg-gradient-to-b from-transparent to-black/20">
<div class="text-gray-500 mb-2">--- Session Started ---</div>
</div>
</div>
</div>
<!-- Custom Toast Container -->
<div id="toast-container" class="fixed top-6 right-6 z-50 flex flex-col gap-3"></div>
<!-- Footer -->
<footer class="relative z-10 border-t border-dg-border py-6 text-center text-gray-600 text-xs font-mono uppercase">
© 2023 NEXUS Secure Systems. All operations logged.
</footer>
<!-- JAVASCRIPT LOGIC -->
<script>
// --- 1. CONFIGURATION & STATE ---
const CONFIG = {
colors: {
primary: '#3b82f6',
success: '#10b981',
danger: '#ef4444'
},
scanTimes: {
avg: 1500,
variance: 800
},
concurrency: 5, // Max files processed at once
threatProb: 0.15, // 15% chance of threat
fileTypes: [
{ ext: '.pdf', mime: 'PDF Document', icon: '📄', risk: 0.02 },
{ ext: '.exe', mime: 'Windows Executable', icon: '⚙️', risk: 0.4 },
{ ext: '.dll', mime: 'Dynamic Library', icon: '🧩', risk: 0.3 },
{ ext: '.jpg', mime: 'Image JPEG', icon: '🖼️', risk: 0.01 },
{ ext: '.zip', mime: 'Archive ZIP', icon: '📁', risk: 0.1 },
{ ext: '.js', mime: 'JavaScript Source', icon: '📜', risk: 0.05 },
{ ext: '.docx', mime: 'Word Doc', icon: '📘', risk: 0.02 },
{ ext: '.bin', mime: 'Binary Data', icon: '💾', risk: 0.2 }
]
};
const state = {
queue: [],
activeFiles: [],
stats: {
processed: 0,
threats: 0,
totalScanTime: 0,
scanCount: 0
}
};
// --- 2. BACKGROUND CANVAS (PARTICLES) ---
const canvas = document.getElementById('particle-canvas');
const ctx = canvas.getContext('2d');
let width, height;
const particles = [];
function resize() {
width = canvas.width = window.innerWidth;
height = canvas.height = window.innerHeight;
}
class Particle {
constructor() {
this.x = Math.random() * width;
this.y = Math.random() * height;
this.vx = (Math.random() - 0.5) * 0.5;
this.vy = (Math.random() - 0.5) * 0.5;
this.size = Math.random() * 2;
this.opacity = Math.random() * 0.5 + 0.1;
}
update() {
this.x += this.vx;
this.y += this.vy;
if (this.x < 0) this.x = width;
if (this.x > width) this.x = 0;
if (this.y < 0) this.y = height;
if (this.y > height) this.y = 0;
}
draw() {
ctx.fillStyle = `rgba(100, 150, 255, ${this.opacity})`;
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fill();
}
}
function initParticles() {
resize();
for(let i=0; i<60; i++) particles.push(new Particle());
animateParticles();
}
function animateParticles() {
ctx.clearRect(0, 0, width, height);
// Draw connections
ctx.strokeStyle = 'rgba(100, 150, 255, 0.05)';
ctx.lineWidth = 1;
for (let i = 0; i < particles.length; i++) {
const p1 = particles[i];
p1.update();
p1.draw();
for (let j = i + 1; j < particles.length; j++) {
const p2 = particles[j];
const dx = p1.x - p2.x;
const dy = p1.y - p2.y;
const dist = Math.sqrt(dx*dx + dy*dy);
if (dist < 150) {
ctx.beginPath();
ctx.moveTo(p1.x, p1.y);
ctx.lineTo(p2.x, p2.y);
ctx.stroke();
}
}
}
requestAnimationFrame(animateParticles);
}
window.addEventListener('resize', resize);
initParticles();
// --- 3. DOM ELEMENTS & UTILS ---
const els = {
track: document.getElementById('pipeline-track'),
stations: [
document.getElementById('station-1'),
document.getElementById('station-2'),
document.getElementById('station-3'),
document.getElementById('station-4')
],
svgLines: [
document.getElementById('line-1'),
document.getElementById('line-2'),
document.getElementById('line-3')
],
stats: {
processed: document.getElementById('stat-processed'),
threats: document.getElementById('stat-threats'),
queue: document.getElementById('stat-queue'),
avg: document.getElementById('stat-avg-time')
},
terminal: document.getElementById('terminal'),
toastContainer: document.getElementById('toast-container'),
contextInfo: document.getElementById('context-info'),
addBtn: document.getElementById('add-random-btn')
};
const randomId = () => Math.random().toString(36).substr(2, 9).toUpperCase();
function log(msg, type = 'info') {
const div = document.createElement('div');
const time = new Date().toLocaleTimeString('en-US', { hour12: false, hour: 'numeric', minute: 'numeric', second: 'numeric' });
let color = 'text-gray-300';
if (type === 'warn') color = 'text-dg-warn';
if (type === 'danger') color = 'text-dg-danger';
if (type === 'success') color = 'text-dg-success';
div.className = `terminal-text ${color} mb-1`;
div.innerHTML = `<span class="opacity-50">[${time}]</span> ${msg}`;
els.terminal.appendChild(div);
els.terminal.scrollTop = els.terminal.scrollHeight;
}
function showToast(msg, type = 'info') {
const toast = document.createElement('div');
const colors = type === 'error' ? 'bg-red-500/20 border-red-500/50 text-red-200' :
type === 'success' ? 'bg-green-500/20 border-green-500/50 text-green-200' :
'bg-blue-500/20 border-blue-500/50 text-blue-200';
toast.className = `glass-panel px-4 py-3 rounded-lg text-sm font-mono border ${colors} shadow-lg transform transition-all duration-300 translate-x-10 opacity-0`;
toast.innerText = msg;
els.toastContainer.appendChild(toast);
// Animate in
gsap.to(toast, { x: 0, opacity: 1, duration: 0.3, ease: "back.out(1.7)" });
// Remove after delay
setTimeout(() => {
gsap.to(toast, { x: 20, opacity: 0, duration: 0.3, onComplete: () => toast.remove() });
}, 3000);
}
function updateStats() {
gsap.to(els.stats.processed, {
innerText: state.stats.processed,
duration: 1,
snap: { innerText: 1 }
});
gsap.to(els.stats.threats, {
innerText: state.stats.threats,
duration: 1,
snap: { innerText: 1 }
});
gsap.utils.toArray('#stat-queue')[0].innerText = state.queue.length + state.activeFiles.length;
const avg = state.stats.scanCount > 0
? Math.round(state.stats.totalScanTime / state.stats.scanCount)
: 0;
animateValue(els.stats.avg, avg);
}
function animateValue(obj, end) {
let start = parseInt(obj.innerText) || 0;
if (start === end) return;
gsap.to(obj, {
innerText: end,
duration: 0.5,
snap: { innerText: 1 },
onUpdate: () => obj.innerText = Math.round(parseFloat(obj.innerText))
});
}
// --- 4. FILE CLASS & PIPELINE LOGIC ---
class PipelineFile {
constructor(fileData) {
this.id = randomId();
this.data = fileData;
this.element = null;
this.currentStation = -1; // -1 before track, 0..3 indices
this.threat = false;
this.scanDuration = 0;
this.startTime = Date.now();
this.mimeType = null;
this.createDOM();
}
createDOM() {
const el = document.createElement('div');
el.className = 'pipeline-file';
el.id = this.id;
el.innerHTML = `
<div class="text-lg mb-1">${this.data.icon}</div>
<div class="truncate max-w-[60px]">${this.data.name}</div>
`;
els.track.appendChild(el);
this.element = el;
// Initial position: centered below track (queue area)
gsap.set(this.element, {
top: els.track.offsetHeight + 20,
left: '50%',
xPercent: -50
});
}
async start() {
state.activeFiles.push(this);
this.moveToStation(0);
}
moveToStation(stationIndex) {
this.currentStation = stationIndex;
const station = els.stations[stationIndex];
const stationRect = station.getBoundingClientRect();
const trackRect = els.track.getBoundingClientRect();
// Target: Center of station relative to track
const targetLeft = stationRect.left - trackRect.left + stationRect.width / 2 - 40; // 40 is half file width
const targetTop = stationRect.top - trackRect.top + stationRect.height / 2 - 30; // 30 is half file height
// Update visual line on SVG
this.updateLines();
// Animate
gsap.to(this.element, {
left: targetLeft,
top: targetTop,
duration: 1,
ease: "power2.inOut",
onComplete: () => this.onArrive(stationIndex)
});
}
updateLines() {
// If moving from i to i+1, highlight line i
if (this.currentStation < 3 && this.currentStation >= 0) {
els.svgLines[this.currentStation].setAttribute('stroke', CONFIG.colors.primary);
els.svgLines[this.currentStation].setAttribute('stroke-width', '2');
} else if (this.currentStation > 0) {
// Arrived, dim previous line
els.svgLines[this.currentStation-1].setAttribute('stroke', 'rgba(100,150,255,0.1)');
els.svgLines[this.currentStation-1].setAttribute('stroke-width', '1');
}
}
async onArrive(stationIndex) {
// Highlight station
els.stations[stationIndex].classList.add('active');
this.element.classList.add('processing');
// Log entry
const stationNames = ['Ingress', 'Antivirus', 'MIME Detection', 'Lifecycle'];
log(`File [${this.data.name}] arrived at ${stationNames[stationIndex]}.`, 'info');
// Process based on station
let duration = 0;
if (stationIndex === 0) {
// Ingress: Just a pause
duration = 500;
} else if (stationIndex === 1) {
// Antivirus
this.element.querySelector('div:first-child').innerHTML = '<svg class="w-6 h-6 animate-spin text-dg-accent" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>';
duration = CONFIG.scanTimes.avg + Math.random() * CONFIG.scanTimes.variance;
this.scanDuration = duration;
// Randomly decide threat after "thinking"
await this.sleep(duration);
this.threat = Math.random() < CONFIG.threatProb;
if (this.threat) {
this.element.classList.add('threat');
this.element.classList.remove('processing');
state.stats.threats++;
log(`!! THREAT DETECTED: ${this.data.name} [Heur.ID:${randomId()}]`, 'danger');
showToast(`Threat Blocked: ${this.data.name}`, 'error');
// Skip MIME, go to Lifecycle (Quarantine)
this.element.querySelector('div:first-child').innerText = '🛡️';
setTimeout(() => this.moveToStation(3), 1000);
return;
} else {
this.element.classList.add('safe');
state.stats.scanCount++;
state.stats.totalScanTime += duration;
log(`File ${this.data.name} verified clean.`, 'success');
this.element.querySelector('div:first-child').innerText = '✅';
setTimeout(() => this.moveToStation(2), 1000);
return;
}
} else if (stationIndex === 2) {
// MIME Detection
this.element.querySelector('div:first-child').innerHTML = '<svg class="w-6 h-6 text-yellow-400 animate-pulse" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 21h7a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v11m0 5l4.879-4.879m0 0a3 3 0 104.243-4.242 3 3 0 00-4.243 4.242z"></path></svg>';
// Determine MIME
const typeInfo = CONFIG.fileTypes[Math.floor(Math.random() * CONFIG.fileTypes.length)];
this.mimeType = typeInfo;
// Adjust icon if not matching? For now just generic scan
duration = 800;
await this.sleep(duration);
this.element.querySelector('div:last-child').innerText = typeInfo.mime.substr(0, 8);
log(`MIME identified: ${typeInfo.mime} (${typeInfo.ext})`, 'info');
this.element.querySelector('div:first-child').innerText = '🔍';
setTimeout(() => this.moveToStation(3), 1000);
return;
} else if (stationIndex === 3) {
// Lifecycle
this.element.classList.remove('processing');
const isThreat = this.element.classList.contains('threat');
const action = isThreat ? 'Quarantine ➔ Delete' : `Archive ➔ S3/${this.data.name}`;
this.element.querySelector('div:first-child').innerHTML = isThreat
? '<svg class="w-6 h-6 text-dg-danger" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path></svg>'
: '<svg class="w-6 h-6 text-dg-success" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"></path></svg>';
this.element.querySelector('div:last-child').innerText = isThreat ? 'QUARANTINE' : 'ARCHIVED';
log(`File lifecycle complete: ${action}`, isThreat ? 'warn' : 'success');
// Finished
state.stats.processed++;
this.finish();
}
}
finish() {
// Remove from active
state.activeFiles = state.activeFiles.filter(f => f.id !== this.id);
updateStats();
// Fade out and remove DOM
gsap.to(this.element, {
opacity: 0,
scale: 0.5,
duration: 0.5,
onComplete: () => this.element.remove()
});
// Process next in queue
processQueue();
}
sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
}
// --- 5. QUEUE MANAGEMENT ---
async processQueue() {
while (state.queue.length > 0 && state.activeFiles.length < CONFIG.concurrency) {
const fileData = state.queue.shift();
updateStats();
const file = new PipelineFile(fileData);
await file.start();
}
}
function addFile(fileData) {
// Validate or generate fileData
const data = fileData || generateRandomFile();
state.queue.push(data);
log(`File queued: ${data.name} (${(data.size / 1024).toFixed(1)} KB)`, 'info');
updateStats();
showToast(`File added: ${data.name}`, 'info');
processQueue();
}
function generateRandomFile() {
const type = CONFIG.fileTypes[Math.floor(Math.random() * CONFIG.fileTypes.length)];
const size = Math.floor(Math.random() * 5000) + 100; // KB
return {
name: `${randomId().toLowerCase()}${type.ext}`,
size: size,
type: type.ext,
mime: type.mime,
icon: type.icon,
risk: type.risk
};
}
// --- 6. DRAG & DROP UPLOAD ---
const uploadArea = document.body; // Global drop
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
uploadArea.addEventListener(eventName, preventDefaults, false);
});
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
uploadArea.addEventListener('drop', (e) => {
const dt = e.dataTransfer;
const files = dt.files;
handleFiles(files);
});
function handleFiles(files) {
([...files]).forEach(file => {
// We create fake metadata based on real file, but ignore content for safety
// The simulation just cares about the name and size to look real
const ext = '.' + file.name.split('.').pop().toLowerCase();
const typeInfo = CONFIG.fileTypes.find(t => t.ext === ext) || CONFIG.fileTypes[0];
addFile({
name: file.name,
size: file.size / 1024, // convert bytes to kb approx
type: ext,
mime: typeInfo.mime,
icon: typeInfo.icon,
risk: typeInfo.risk
});
});
}
// --- 7. UI EVENT LISTENERS ---
els.addBtn.addEventListener('click', () => addFile());
document.getElementById('clear-logs').addEventListener('click', () => {
els.terminal.innerHTML = '';
log('Logs cleared.');
});
// Magnetic Button Effect
document.querySelectorAll('.magnetic-btn').forEach(btn => {
btn.addEventListener('mousemove', (e) => {
const rect = btn.getBoundingClientRect();
const x = e.clientX - rect.left - rect.width / 2;
const y = e.clientY - rect.top - rect.height / 2;
gsap.to(btn, { x: x * 0.3, y: y * 0.3, duration: 0.2 });
});
btn.addEventListener('mouseleave', () => {
gsap.to(btn, { x: 0, y: 0, duration: 0.5, ease: "elastic.out(1, 0.3)" });
});
});
// --- 8. INITIALIZATION ---
// Pre-populate queue with a few files
window.addEventListener('load', () => {
log('System initialized.');
log('Pipelines connecting...');
// Add 2 random files to start
addFile(generateRandomFile());
setTimeout(() => addFile(generateRandomFile()), 1000);
});
// Initial SVG line positioning
function layoutSvgLines() {
const trackRect = els.track.getBoundingClientRect();
// We need to position lines based on stations
const stationsRect = els.stations.map(s => {
const r = s.getBoundingClientRect();
return {
centerX: r.left - trackRect.left + r.width / 2,
y: r.top - trackRect.top
};
});
// Line 1: from Stat1 bottom to Stat2 top
// But we keep it simple: Horizontal lines at y = (StationTop + Height/2)
// Actually the track is flex row, so they are side by side.
// Let's draw horizontal lines in the middle.
const y = 50; // arbitrary middle relative to track height
els.svgLines.forEach((line, i) => {
const x1 = stationsRect[i].centerX;
const x2 = stationsRect[i+1].centerX;
line.setAttribute('x1', x1);
line.setAttribute('y1', y);
line.setAttribute('x2', x2);
line.setAttribute('y2', y);
});
}
// Wait for rendering then layout
setTimeout(layoutSvgLines, 500);
window.addEventListener('resize', layoutSvgLines);
</script>
</body>
</html>