#097 style dark mobile: high Kinetic, Film & Creative Studio

Active Theory Spatial Lab

Experimental spatial and WebGL creative lab featuring a live reactive particle canvas, crosshair telemetry HUD, and shader modes.

Inspired by Active Theory ↗

Download .html
Fullscreen ↗

WHY THIS AESTHETIC IS UNIQUE

Turns the entire viewport into a responsive spatial instrument—combining a silky 60fps interactive 2D particle/wireframe canvas with surgical crosshair coordinates and precision telemetry.

BEST FOR

WebGL & interactive creative studiosSpatial computing & XR product launchesAudio-visual installation portfoliosExperimental developer labs & showcases

TAGS

COLOR PALETTE (CLICK TO COPY HEX)

TYPOGRAPHY

Display
Space Grotesk, sans-serif
Body
Inter, -apple-system, sans-serif
Mono
JetBrains Mono, ui-monospace, monospace
Scale
Precision geometric display titles (34–60px) framed by crisp 11px monospace live X/Y/Z coordinate telemetry and FPS/mode indicators.

Google Fonts Stylesheet ↗

ARCHITECTURE & MOBILE NOTES

LAYOUT

Full-viewport interactive canvas stage overlaid with corner-anchored hairline HUD reticles, mode-switching controls, and a sleek horizontal spatial project archive.

INTERACTION

Pointer and touch movement dynamically warps the live Canvas 2D particle/wireframe field and updates real-time X/Y telemetry; shader-mode buttons toggle Constellation, Terrain Grid, and Pulse Wave physics.

MOBILE

Touch-responsive canvas gracefully scales particle count for smooth 60fps performance at 390px, with >=44px mode pills docked cleanly above the archive cards.

AI AGENT GUARDRAILS

DO

  • Respect prefers-reduced-motion and keep canvas particle counts lightweight for smooth mobile framerates.
  • Anchor HUD telemetry to subtle corner hairlines so the interactive canvas stays the star.
  • Use surgical monochrome + single telemetry-cyan (#38BDF8) rather than busy rainbow glows.

DON'T

  • Do not block pointer events on the interactive canvas with unnecessary full-screen opaque overlays.
  • Do not use generic purple-blue SaaS gradient blobs.
STANDALONE SOURCE · demos/activetheory-spatial-lab.html (21.7 KB)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ACTIVE THEORY — Spatial Telemetry &amp; WebGL Lab</title>
<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@400;500;600&family=JetBrains+Mono:wght@400;500;700&family=Space+Grotesk:wght@400;500;700&display=swap" rel="stylesheet">
<style>
  :root {
    --bg: #07080B;
    --surface: #11131A;
    --surface-2: #171A24;
    --ink: #EEF2F6;
    --accent: #38BDF8;
    --accent-dim: rgba(56, 189, 248, 0.16);
    --muted: #727B8E;
    --line: rgba(238, 242, 246, 0.11);
    --display: 'Space Grotesk', system-ui, sans-serif;
    --sans: 'Inter', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
  }

  *, *::before, *::after { box-sizing: border-box; }
  html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
  }
  a { color: inherit; text-decoration: none; }
  button { font-family: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

  /* HUD Header */
  .hud-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(7, 8, 11, 0.86);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .hud-inner {
    max-width: 1360px;
    margin: 0 auto;
    padding: 0.65rem clamp(1rem, 3.5vw, 2.5rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }
  .lab-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 44px;
  }
  .reticle-icon {
    width: 24px;
    height: 24px;
    border: 1px solid var(--accent);
    display: grid;
    place-items: center;
    position: relative;
  }
  .reticle-icon::after {
    content: "";
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent);
  }
  .brand-text {
    font-family: var(--display);
    font-weight: 700;
    font-size: 0.98rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
  }
  .hud-nav {
    display: flex;
    align-items: center;
    gap: 1.4rem;
  }
  .hud-nav a {
    font-family: var(--mono);
    font-size: 0.74rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .hud-nav a:hover, .hud-nav a.active { color: var(--accent); }
  .menu-trigger {
    display: none;
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.75rem;
    border: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 0.72rem;
    align-items: center;
    justify-content: center;
  }
  .mobile-menu {
    display: none;
    flex-direction: column;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 0.5rem 1.25rem 1rem;
  }
  .mobile-menu.open { display: flex; }
  .mobile-menu a {
    min-height: 44px;
    display: flex;
    align-items: center;
    font-family: var(--mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
  }

  /* Main */
  .container {
    max-width: 1360px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 3.5vw, 2.5rem) 4rem;
  }

  /* Interactive Spatial Viewport */
  .spatial-stage {
    position: relative;
    border: 1px solid var(--line);
    background: #050609;
    min-height: clamp(440px, 64vh, 620px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  #spatialCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
  }

  /* Corner HUD brackets */
  .corner {
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--accent);
    border-style: solid;
    pointer-events: none;
    z-index: 4;
  }
  .c-tl { top: 10px; left: 10px; border-width: 1px 0 0 1px; }
  .c-tr { top: 10px; right: 10px; border-width: 1px 1px 0 0; }
  .c-bl { bottom: 10px; left: 10px; border-width: 0 0 1px 1px; }
  .c-br { bottom: 10px; right: 10px; border-width: 0 1px 1px 0; }

  .hud-overlay-top {
    position: relative;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 1.1rem 1.35rem;
    pointer-events: none;
  }
  .telemetry-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--accent);
    background: rgba(7, 8, 11, 0.72);
    border: 1px solid var(--line);
    padding: 0.45rem 0.8rem;
  }
  .telemetry-strip span b { color: var(--ink); font-weight: 500; }

  .hero-copy-float {
    position: relative;
    z-index: 5;
    padding: 1rem 1.35rem;
    max-width: 680px;
    pointer-events: none;
  }
  .hero-copy-float .eyebrow {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
  }
  .hero-copy-float h1 {
    margin: 0;
    font-family: var(--display);
    font-weight: 500;
    font-size: clamp(2rem, 4.8vw, 3.8rem);
    line-height: 1.02;
    letter-spacing: -0.02em;
  }
  .hero-copy-float p {
    margin: 0.85rem 0 0;
    font-size: 0.96rem;
    line-height: 1.6;
    color: rgba(238, 242, 246, 0.76);
    max-width: 52ch;
  }

  /* Shader Mode Dock */
  .shader-dock {
    position: relative;
    z-index: 6;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 0.9rem 1.35rem;
    background: rgba(17, 19, 26, 0.82);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(8px);
  }
  .mode-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .mode-btn {
    min-height: 44px;
    padding: 0 0.95rem;
    border: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 0.74rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    background: rgba(7, 8, 11, 0.65);
    transition: all 0.2s;
  }
  .mode-btn:hover { border-color: var(--accent); color: var(--ink); }
  .mode-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
  }
  .dock-hint {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    letter-spacing: 0.08em;
  }

  /* Telemetry Metrics Row */
  .metrics-row {
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
  }
  .metric-card {
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 1rem 1.15rem;
  }
  .metric-label {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }
  .metric-val {
    margin-top: 0.45rem;
    font-family: var(--display);
    font-size: 1.55rem;
    font-weight: 500;
    color: var(--ink);
  }
  .metric-val span {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--accent);
  }

  /* Spatial Project Archive */
  .archive {
    margin-top: 3rem;
  }
  .archive-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line);
  }
  .archive-head h2 {
    margin: 0;
    font-family: var(--display);
    font-weight: 500;
    font-size: clamp(1.45rem, 2.6vw, 2.1rem);
  }
  .archive-head span {
    font-family: var(--mono);
    font-size: 0.74rem;
    color: var(--muted);
  }
  .project-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.15rem;
  }
  .project-card {
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    transition: border-color 0.25s, background 0.25s;
  }
  .project-card:hover, .project-card.active {
    border-color: var(--accent);
    background: var(--surface-2);
  }
  .proj-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--accent);
    letter-spacing: 0.1em;
  }
  .proj-title {
    margin: 0;
    font-family: var(--display);
    font-size: 1.35rem;
    font-weight: 500;
  }
  .proj-desc {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--muted);
  }
  .proj-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .proj-tags span {
    font-family: var(--mono);
    font-size: 0.66rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--line);
    color: var(--ink);
  }

  footer {
    max-width: 1360px;
    margin: 0 auto;
    padding: 2rem clamp(1rem, 3.5vw, 2.5rem) 3rem;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--muted);
  }

  @media (max-width: 900px) {
    .metrics-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .project-grid { grid-template-columns: 1fr; }
  }
  @media (max-width: 640px) {
    .hud-nav { display: none; }
    .menu-trigger { display: inline-flex; }
    .dock-hint { display: none; }
  }
</style>
</head>
<body>
<header class="hud-header">
  <div class="hud-inner">
    <a href="#viewport" class="lab-brand">
      <span class="reticle-icon" aria-hidden="true"></span>
      <span class="brand-text">Active Theory</span>
    </a>
    <nav class="hud-nav" aria-label="Primary">
      <a href="#viewport" class="active">01 / Spatial Lab</a>
      <a href="#telemetry">02 / Telemetry</a>
      <a href="#archive">03 / Archive</a>
    </nav>
    <button class="menu-trigger" id="menuBtn" aria-expanded="false" aria-controls="mobileMenu">MENU</button>
  </div>
  <nav class="mobile-menu" id="mobileMenu" aria-label="Mobile Navigation">
    <a href="#viewport">01 / Spatial Lab</a>
    <a href="#telemetry">02 / Telemetry</a>
    <a href="#archive">03 / Spatial Archive</a>
  </nav>
</header>

<main class="container">
  <section class="spatial-stage" id="viewport" aria-label="Interactive spatial canvas">
    <canvas id="spatialCanvas"></canvas>
    <span class="corner c-tl" aria-hidden="true"></span>
    <span class="corner c-tr" aria-hidden="true"></span>
    <span class="corner c-bl" aria-hidden="true"></span>
    <span class="corner c-br" aria-hidden="true"></span>

    <div class="hud-overlay-top">
      <div class="telemetry-strip">
        <span>X:<b id="coordX">+0.000</b></span>
        <span>Y:<b id="coordY">+0.000</b></span>
        <span>Z:<b id="coordZ">1.420</b></span>
      </div>
      <div class="telemetry-strip">
        <span>MODE:<b id="modeReadout">CONSTELLATION</b></span>
        <span>NODES:<b id="nodeReadout">88</b></span>
      </div>
    </div>

    <div class="hero-copy-float">
      <div class="eyebrow">REALTIME GRAPHICS · CREATIVE ENGINEERING LAB</div>
      <h1>Spatial interfaces built at 60 frames per second.</h1>
      <p>Move your pointer or drag across the viewport to perturb the field. Switch shader topologies below to inspect live spatial geometry.</p>
    </div>

    <div class="shader-dock">
      <div class="mode-group" role="group" aria-label="Shader mode">
        <button class="mode-btn active" data-mode="constellation" aria-pressed="true">Constellation</button>
        <button class="mode-btn" data-mode="terrain" aria-pressed="false">Terrain Grid</button>
        <button class="mode-btn" data-mode="pulse" aria-pressed="false">Pulse Wave</button>
      </div>
      <span class="dock-hint">POINTER / TOUCH REACTIVE · CANVAS 2D ENGINE</span>
    </div>
  </section>

  <section class="metrics-row" id="telemetry" aria-label="Engine telemetry">
    <div class="metric-card">
      <div class="metric-label">Render Pipeline</div>
      <div class="metric-val">60 <span>FPS TARGET</span></div>
    </div>
    <div class="metric-card">
      <div class="metric-label">Active Field Vector</div>
      <div class="metric-val" id="velMetric">0.00 <span>PX/MS</span></div>
    </div>
    <div class="metric-card">
      <div class="metric-label">Shader Topology</div>
      <div class="metric-val" id="topoMetric">MESH <span>01</span></div>
    </div>
    <div class="metric-card">
      <div class="metric-label">Spatial Latency</div>
      <div class="metric-val">4.2 <span>MS</span></div>
    </div>
  </section>

  <section class="archive" id="archive">
    <div class="archive-head">
      <h2>Spatial Experiment Archive</h2>
      <span>CLICK ANY ENTRY TO LOAD ITS SHADER PRESET</span>
    </div>
    <div class="project-grid" id="projectGrid">
      <button class="project-card active" data-mode="constellation">
        <div class="proj-top"><span>EXP-01 · 2025</span><span>CONSTELLATION SHADER</span></div>
        <h3 class="proj-title">Hydra Neural Starfield</h3>
        <p class="proj-desc">Proximity-linked particle constellation reacting to pointer gravity and orbital drift across multi-device viewports.</p>
        <div class="proj-tags"><span>WEBGL2</span><span>PARTICLE GRAPH</span><span>60FPS</span></div>
      </button>
      <button class="project-card" data-mode="terrain">
        <div class="proj-top"><span>EXP-02 · 2025</span><span>TERRAIN WIREFRAME</span></div>
        <h3 class="proj-title">Aether Elevation Mesh</h3>
        <p class="proj-desc">Procedural perspective elevation grid sculpted in real time by pointer harmonics and elevation contour lines.</p>
        <div class="proj-tags"><span>GLSL</span><span>TOPOGRAPHY</span><span>SPATIAL AUDIO</span></div>
      </button>
      <button class="project-card" data-mode="pulse">
        <div class="proj-top"><span>EXP-03 · 2026</span><span>PULSE TELEMETRY</span></div>
        <h3 class="proj-title">Meridian Sonar Array</h3>
        <p class="proj-desc">Concentric phase-locked sonar rings and vector crosshairs calibrated for interactive exhibition walls.</p>
        <div class="proj-tags"><span>RADAR HUD</span><span>TOUCH WALL</span><span>VECTOR</span></div>
      </button>
      <button class="project-card" data-mode="constellation">
        <div class="proj-top"><span>EXP-04 · 2026</span><span>HYBRID FIELD</span></div>
        <h3 class="proj-title">Dreamwave Spatial Lobby</h3>
        <p class="proj-desc">Low-latency multiplayer exhibition space pairing spatial typography with reactive depth-sorted telemetry.</p>
        <div class="proj-tags"><span>WEBRTC</span><span>SPATIAL UI</span><span>CUSTOM ENGINE</span></div>
      </button>
    </div>
  </section>
</main>

<footer>
  <span>ACTIVE THEORY · LOS ANGELES / AMSTERDAM</span>
  <span>EXPERIMENTAL SPATIAL WEB LAB · BUILD 2026.04</span>
</footer>

<script>
const canvas = document.getElementById('spatialCanvas');
const ctx = canvas.getContext('2d');
const stage = document.getElementById('viewport');

let width = 0, height = 0, dpr = 1;
let mode = 'constellation';
let pointer = { x: 0.5, y: 0.5, px: 0, py: 0, active: false, vx: 0, vy: 0 };
let t = 0;

const particles = Array.from({ length: 88 }, (_, i) => ({
  x: Math.random(),
  y: Math.random(),
  vx: (Math.random() - 0.5) * 0.0008,
  vy: (Math.random() - 0.5) * 0.0008,
  r: 1.4 + (i % 3) * 0.9
}));

function resize() {
  const rect = stage.getBoundingClientRect();
  dpr = Math.min(window.devicePixelRatio || 1, 2);
  width = rect.width;
  height = rect.height;
  canvas.width = Math.round(width * dpr);
  canvas.height = Math.round(height * dpr);
  ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  pointer.px = pointer.x * width;
  pointer.py = pointer.y * height;
}
window.addEventListener('resize', resize);
resize();

function updatePointer(clientX, clientY) {
  const rect = stage.getBoundingClientRect();
  const nx = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
  const ny = Math.max(0, Math.min(1, (clientY - rect.top) / rect.height));
  const dx = (nx - pointer.x) * width;
  const dy = (ny - pointer.y) * height;
  pointer.vx = Math.hypot(dx, dy);
  pointer.x = nx;
  pointer.y = ny;
  pointer.px = nx * width;
  pointer.py = ny * height;
  pointer.active = true;

  document.getElementById('coordX').textContent = ((nx - 0.5) * 2).toFixed(3).replace(/^(?!-)/, '+');
  document.getElementById('coordY').textContent = ((0.5 - ny) * 2).toFixed(3).replace(/^(?!-)/, '+');
  document.getElementById('coordZ').textContent = (1.2 + Math.hypot(nx - 0.5, ny - 0.5)).toFixed(3);
  document.getElementById('velMetric').innerHTML = `${(pointer.vx * 0.12).toFixed(2)} <span>PX/MS</span>`;
}

stage.addEventListener('pointermove', (e) => updatePointer(e.clientX, e.clientY));
stage.addEventListener('pointerdown', (e) => updatePointer(e.clientX, e.clientY));

function drawCrosshair() {
  const cx = pointer.px;
  const cy = pointer.py;
  ctx.save();
  ctx.strokeStyle = 'rgba(56, 189, 248, 0.25)';
  ctx.lineWidth = 1;
  ctx.beginPath();
  ctx.moveTo(cx, 0); ctx.lineTo(cx, height);
  ctx.moveTo(0, cy); ctx.lineTo(width, cy);
  ctx.stroke();

  ctx.strokeStyle = '#38BDF8';
  ctx.beginPath();
  ctx.arc(cx, cy, 14, 0, Math.PI * 2);
  ctx.stroke();
  ctx.restore();
}

function drawConstellation() {
  const maxDist = Math.min(width, height) * 0.24;
  for (let i = 0; i < particles.length; i++) {
    const p = particles[i];
    p.x += p.vx;
    p.y += p.vy;
    if (p.x < 0 || p.x > 1) p.vx *= -1;
    if (p.y < 0 || p.y > 1) p.vy *= -1;

    const px = p.x * width;
    const py = p.y * height;
    const dx = pointer.px - px;
    const dy = pointer.py - py;
    const dist = Math.hypot(dx, dy);
    if (dist < 170 && dist > 8) {
      p.x += (dx / dist) * 0.00045;
      p.y += (dy / dist) * 0.00045;
    }

    for (let j = i + 1; j < particles.length; j++) {
      const q = particles[j];
      const qx = q.x * width;
      const qy = q.y * height;
      const d = Math.hypot(px - qx, py - qy);
      if (d < maxDist) {
        const alpha = (1 - d / maxDist) * 0.34;
        ctx.strokeStyle = `rgba(56, 189, 248, ${alpha.toFixed(3)})`;
        ctx.lineWidth = 0.85;
        ctx.beginPath();
        ctx.moveTo(px, py);
        ctx.lineTo(qx, qy);
        ctx.stroke();
      }
    }

    ctx.fillStyle = dist < 140 ? '#38BDF8' : 'rgba(238, 242, 246, 0.8)';
    ctx.beginPath();
    ctx.arc(px, py, p.r, 0, Math.PI * 2);
    ctx.fill();
  }
}

function drawTerrain() {
  const cols = 22;
  const rows = 14;
  const startY = height * 0.34;
  const spanY = height * 0.62;
  ctx.lineWidth = 1;

  for (let r = 0; r < rows; r++) {
    const v = r / (rows - 1);
    const yBase = startY + Math.pow(v, 1.35) * spanY;
    const spread = 0.55 + v * 0.72;
    ctx.beginPath();
    for (let c = 0; c <= cols; c++) {
      const u = c / cols;
      const x = width * 0.5 + (u - 0.5) * width * spread;
      const distP = Math.hypot(x - pointer.px, yBase - pointer.py);
      const lift = Math.exp(-distP / 150) * 48;
      const wave = Math.sin(u * 6 + t * 1.8 + r * 0.5) * 14 * (0.4 + v * 0.6);
      const y = yBase + wave - lift;
      if (c === 0) ctx.moveTo(x, y);
      else ctx.lineTo(x, y);
    }
    ctx.strokeStyle = `rgba(56, 189, 248, ${(0.14 + v * 0.48).toFixed(2)})`;
    ctx.stroke();
  }
}

function drawPulse() {
  const cx = pointer.px;
  const cy = pointer.py;
  const maxR = Math.hypot(width, height) * 0.55;
  for (let i = 0; i < 9; i++) {
    const prog = ((t * 0.28 + i / 9) % 1);
    const r = prog * maxR;
    const alpha = (1 - prog) * 0.58;
    ctx.strokeStyle = `rgba(56, 189, 248, ${alpha.toFixed(3)})`;
    ctx.lineWidth = 1.25;
    ctx.beginPath();
    ctx.arc(cx, cy, r, 0, Math.PI * 2);
    ctx.stroke();
  }
  for (let a = 0; a < 12; a++) {
    const ang = (a / 12) * Math.PI * 2 + t * 0.15;
    ctx.strokeStyle = 'rgba(238, 242, 246, 0.14)';
    ctx.beginPath();
    ctx.moveTo(cx + Math.cos(ang) * 24, cy + Math.sin(ang) * 24);
    ctx.lineTo(cx + Math.cos(ang) * 220, cy + Math.sin(ang) * 220);
    ctx.stroke();
  }
}

function animate() {
  t += 0.016;
  ctx.fillStyle = 'rgba(5, 6, 9, 0.34)';
  ctx.fillRect(0, 0, width, height);

  if (mode === 'constellation') drawConstellation();
  else if (mode === 'terrain') drawTerrain();
  else drawPulse();

  drawCrosshair();
  requestAnimationFrame(animate);
}
animate();

function setMode(newMode) {
  mode = newMode;
  document.getElementById('modeReadout').textContent = newMode.toUpperCase();
  const map = { constellation: 'MESH <span>01</span>', terrain: 'GRID <span>02</span>', pulse: 'SONAR <span>03</span>' };
  const nodes = { constellation: '88', terrain: '308', pulse: '108' };
  document.getElementById('topoMetric').innerHTML = map[newMode];
  document.getElementById('nodeReadout').textContent = nodes[newMode];
  document.querySelectorAll('.mode-btn').forEach(b => {
    const on = b.dataset.mode === newMode;
    b.classList.toggle('active', on);
    b.setAttribute('aria-pressed', on ? 'true' : 'false');
  });
}

document.querySelectorAll('.mode-btn').forEach(btn => {
  btn.addEventListener('click', () => setMode(btn.dataset.mode));
});

document.querySelectorAll('.project-card').forEach(card => {
  card.addEventListener('click', () => {
    document.querySelectorAll('.project-card').forEach(c => c.classList.remove('active'));
    card.classList.add('active');
    setMode(card.dataset.mode);
    stage.scrollIntoView({ behavior: 'smooth', block: 'start' });
  });
});

const menuBtn = document.getElementById('menuBtn');
const mobileMenu = document.getElementById('mobileMenu');
menuBtn.addEventListener('click', () => {
  const open = mobileMenu.classList.toggle('open');
  menuBtn.setAttribute('aria-expanded', open ? 'true' : 'false');
});
mobileMenu.querySelectorAll('a').forEach(a => a.addEventListener('click', () => {
  mobileMenu.classList.remove('open');
  menuBtn.setAttribute('aria-expanded', 'false');
}));
</script>
</body>
</html>