# #041 — Atmospheric Vector Telemetry

> Full-bleed abyssal wind-streamline canvas with translucent instrument HUD and barometric altitude controls.

## Metadata

- **Index**: #041
- **Slug**: `atmospheric-vector-telemetry`
- **Kind**: `style`
- **Family**: Telemetry & Cartographic
- **Theme**: `dark`
- **Mobile Strength**: `high`
- **Tags**: `telemetry`, `weather`, `canvas-2d`, `cartography`, `hud-overlay`, `scientific`
- **Best For**: Real-time meteorological and atmospheric monitors, Oceanographic or geospatial vector-field explorers, Environmental sensor network live maps
- **Real-World Inspiration**: [earth.nullschool.net](https://earth.nullschool.net/)
- **Detail Page**: https://templates.michaelpitts.net/t/atmospheric-vector-telemetry
- **Live Demo**: https://templates.michaelpitts.net/demos/atmospheric-vector-telemetry.html
- **JSON API**: https://templates.michaelpitts.net/api/templates/atmospheric-vector-telemetry

## Why This Aesthetic Is Unique

Replaces conventional dashboard cards with a continuous animated fluid-field visualization where controls float as ultra-lightweight translucent instrument drawers.

## Color Palette

| Role | Name | Hex |
|------|------|-----|
| `canvas` | Abyssal Slate | `#091119` |
| `surface` | Instrument Deep | `#101D29` |
| `ink` | Vapor White | `#E4F0F6` |
| `accent` | Jetstream Cyan | `#2EE6C5` |
| `muted` | Radar Haze | `#6B879B` |

## Typography

- **Display**: `Space Grotesk`
- **Body**: `Inter`
- **Mono**: `IBM Plex Mono`
- **Scale Notes**: Compact monospace telemetry readouts (11-13px) paired with crisp 15-18px instrument headers so the canvas remains dominant.
- **Google Fonts**: https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Inter:wght@400;500;600&family=Space+Grotesk:wght@500;600&display=swap
  ```html
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Inter:wght@400;500;600&family=Space+Grotesk:wght@500;600&display=swap">
  ```

## Layout Architecture

Full-viewport Canvas 2D streamline field with anchored corner HUD controls, collapsible altitude/layer drawer, and pinned bottom-left coordinate readout.

## Interaction & Micro-Motion Rules

Click or tap anywhere on the field to inspect local wind vector speed and bearing; switch pressure levels (Surface, 850 hPa, 250 hPa) to dynamically alter particle velocity and curl.

## Mobile & Responsive Rules

HUD controls collapse into a thumb-friendly bottom drawer with 44px touch targets while keeping the live wind canvas unobstructed at 390px width.

## Agent Guardrails

### DO
- Keep HUD panels semi-translucent with crisp 1px borders so the live vector canvas breathes
- Format coordinates, pressure levels, and speeds in tabular monospace figures
- Provide an immediate interactive altitude or layer toggle that visibly changes the flow field

### DON'T
- Do not bury the visualization inside heavy opaque dashboard chrome
- Do not use neon green matrix cliches; stick to deep oceanic slate and cyan-amber velocity ramps

## Complete Standalone Starter Code

File: `demos/atmospheric-vector-telemetry.html`

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>AETHER // Global Atmospheric Vector Telemetry</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=IBM+Plex+Mono:wght@400;500;600&family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
  <style>
    :root {
      --canvas: #091119;
      --surface: #101D29;
      --surface-glass: rgba(16, 29, 41, 0.82);
      --border: rgba(228, 240, 246, 0.14);
      --border-strong: rgba(46, 230, 197, 0.42);
      --ink: #E4F0F6;
      --accent: #2EE6C5;
      --accent-dim: rgba(46, 230, 197, 0.15);
      --muted: #6B879B;
      --warn: #FFB454;
      --jet: #FF5D8F;
      --font-sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
      --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
    }

    *, *::before, *::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    html, body {
      width: 100%;
      height: 100%;
      overflow: hidden;
      background: var(--canvas);
      color: var(--ink);
      font-family: var(--font-sans);
      -webkit-font-smoothing: antialiased;
    }

    .viewport {
      position: relative;
      width: 100vw;
      height: 100vh;
      height: 100dvh;
      overflow: hidden;
      background: radial-gradient(circle at 52% 48%, #0f2030 0%, #091119 68%, #050a0f 100%);
    }

    #windCanvas {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      display: block;
      cursor: crosshair;
    }

    /* Top Telemetry Strip */
    .hud-top {
      position: absolute;
      top: 16px;
      left: 16px;
      right: 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      pointer-events: none;
      z-index: 20;
    }

    .brand-pill {
      pointer-events: auto;
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 16px;
      background: var(--surface-glass);
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
      border: 1px solid var(--border);
      border-radius: 6px;
    }

    .pulse-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--accent);
      box-shadow: 0 0 10px var(--accent);
      animation: pulse 2.2s infinite ease-in-out;
      flex-shrink: 0;
    }

    @keyframes pulse {
      0%, 100% { opacity: 1; transform: scale(1); }
      50% { opacity: 0.45; transform: scale(0.8); }
    }

    .brand-title {
      font-size: 0.92rem;
      font-weight: 700;
      letter-spacing: 0.12em;
      text-transform: uppercase;
    }

    .brand-meta {
      font-family: var(--font-mono);
      font-size: 0.72rem;
      color: var(--muted);
      border-left: 1px solid var(--border);
      padding-left: 12px;
      white-space: nowrap;
    }

    .top-actions {
      pointer-events: auto;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .hud-btn {
      min-height: 44px;
      min-width: 44px;
      padding: 0 14px;
      background: var(--surface-glass);
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--ink);
      font-family: var(--font-mono);
      font-size: 0.75rem;
      letter-spacing: 0.04em;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      transition: border-color 0.2s, background 0.2s, color 0.2s;
    }

    .hud-btn:hover, .hud-btn[aria-pressed="true"] {
      border-color: var(--border-strong);
      background: rgba(20, 39, 54, 0.94);
      color: var(--accent);
    }

    .mobile-menu-btn {
      display: none;
    }

    /* Left Instrument Drawer / Dock */
    .instrument-dock {
      position: absolute;
      left: 16px;
      bottom: 16px;
      width: 332px;
      max-width: calc(100vw - 32px);
      background: var(--surface-glass);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 16px;
      z-index: 25;
      display: flex;
      flex-direction: column;
      gap: 14px;
      box-shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
    }

    .dock-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: 1px solid var(--border);
      padding-bottom: 10px;
    }

    .dock-label {
      font-family: var(--font-mono);
      font-size: 0.7rem;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--muted);
    }

    .dock-close {
      display: none;
      background: transparent;
      border: 1px solid var(--border);
      color: var(--ink);
      border-radius: 4px;
      min-width: 44px;
      min-height: 44px;
      font-family: var(--font-mono);
      font-size: 0.85rem;
      cursor: pointer;
    }

    .pressure-group {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
    }

    .pressure-btn {
      min-height: 46px;
      padding: 8px 6px;
      background: rgba(9, 17, 25, 0.7);
      border: 1px solid var(--border);
      border-radius: 5px;
      color: var(--ink);
      cursor: pointer;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
      transition: all 0.18s ease;
    }

    .pressure-btn strong {
      font-family: var(--font-mono);
      font-size: 0.76rem;
      font-weight: 600;
    }

    .pressure-btn span {
      font-size: 0.64rem;
      color: var(--muted);
    }

    .pressure-btn.active {
      background: var(--accent-dim);
      border-color: var(--accent);
      color: var(--accent);
    }

    .pressure-btn.active span {
      color: var(--ink);
    }

    .overlay-row {
      display: flex;
      gap: 6px;
    }

    .chip-btn {
      flex: 1;
      min-height: 44px;
      background: rgba(9, 17, 25, 0.65);
      border: 1px solid var(--border);
      border-radius: 5px;
      color: var(--muted);
      font-family: var(--font-mono);
      font-size: 0.7rem;
      cursor: pointer;
      transition: all 0.18s ease;
    }

    .chip-btn.active {
      border-color: var(--border-strong);
      color: var(--ink);
      background: rgba(46, 230, 197, 0.12);
    }

    .control-slider {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .slider-head {
      display: flex;
      justify-content: space-between;
      font-family: var(--font-mono);
      font-size: 0.7rem;
      color: var(--muted);
    }

    .slider-head output {
      color: var(--ink);
    }

    input[type="range"] {
      width: 100%;
      accent-color: var(--accent);
      height: 6px;
      cursor: pointer;
    }

    .scale-bar {
      display: flex;
      flex-direction: column;
      gap: 5px;
    }

    .scale-gradient {
      height: 8px;
      border-radius: 99px;
      background: linear-gradient(90deg, #1b4d6e 0%, #2ee6c5 38%, #ffb454 72%, #ff5d8f 100%);
      border: 1px solid rgba(255, 255, 255, 0.12);
    }

    .scale-ticks {
      display: flex;
      justify-content: space-between;
      font-family: var(--font-mono);
      font-size: 0.66rem;
      color: var(--muted);
    }

    /* Right Coordinate & Wind Inspector */
    .inspector-card {
      position: absolute;
      right: 16px;
      bottom: 16px;
      width: 288px;
      max-width: calc(100vw - 32px);
      background: var(--surface-glass);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 14px 16px;
      z-index: 20;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .inspector-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .inspector-coord {
      font-family: var(--font-mono);
      font-size: 0.82rem;
      font-weight: 600;
      color: var(--accent);
    }

    .inspector-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 8px;
    }

    .metric-box {
      background: rgba(9, 17, 25, 0.65);
      border: 1px solid var(--border);
      border-radius: 5px;
      padding: 8px 10px;
    }

    .metric-box .k {
      display: block;
      font-family: var(--font-mono);
      font-size: 0.62rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--muted);
      margin-bottom: 3px;
    }

    .metric-box .v {
      font-family: var(--font-mono);
      font-size: 0.92rem;
      font-weight: 600;
      color: var(--ink);
    }

    .inspector-hint {
      font-size: 0.72rem;
      color: var(--muted);
      line-height: 1.4;
    }

    /* Mobile Drawer Backdrop */
    .drawer-backdrop {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(5, 10, 15, 0.65);
      z-index: 24;
    }

    @media (max-width: 820px) {
      .brand-meta {
        display: none;
      }

      .mobile-menu-btn {
        display: inline-flex;
      }

      .desktop-only {
        display: none;
      }

      .instrument-dock {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(320px, 88vw);
        max-width: 88vw;
        border-radius: 0 10px 10px 0;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        padding-top: 20px;
      }

      .instrument-dock.open {
        transform: translateX(0);
      }

      .drawer-backdrop.open {
        display: block;
      }

      .dock-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
      }

      .inspector-card {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        max-width: none;
        padding: 12px;
      }

      .hud-top {
        top: 12px;
        left: 12px;
        right: 12px;
      }
    }
  </style>
</head>
<body>
  <main class="viewport">
    <canvas id="windCanvas" aria-label="Interactive global atmospheric wind streamline field"></canvas>

    <header class="hud-top">
      <div class="brand-pill">
        <span class="pulse-dot" aria-hidden="true"></span>
        <span class="brand-title">AETHER // GFS-0.25°</span>
        <span class="brand-meta" id="utcClock">2026-12-06 05:20 UTC · CYCLE 00Z</span>
      </div>

      <div class="top-actions">
        <button class="hud-btn desktop-only" id="projBtn" type="button" aria-pressed="false">PROJ: ORTHO</button>
        <button class="hud-btn" id="pauseBtn" type="button" aria-pressed="false">PAUSE</button>
        <button class="hud-btn mobile-menu-btn" id="drawerOpenBtn" type="button" aria-expanded="false" aria-controls="instrumentDock">CONTROLS</button>
      </div>
    </header>

    <div class="drawer-backdrop" id="drawerBackdrop"></div>

    <aside class="instrument-dock" id="instrumentDock" aria-label="Atmospheric telemetry controls">
      <div class="dock-header">
        <span class="dock-label">ISOBARIC LAYER // WIND VECTOR</span>
        <button class="dock-close" id="drawerCloseBtn" type="button" aria-label="Close controls">✕</button>
      </div>

      <div class="pressure-group" role="group" aria-label="Pressure altitude levels">
        <button class="pressure-btn active" type="button" data-level="sfc">
          <strong>SFC</strong>
          <span>10m Surface</span>
        </button>
        <button class="pressure-btn" type="button" data-level="850">
          <strong>850 hPa</strong>
          <span>1.5 km Trade</span>
        </button>
        <button class="pressure-btn" type="button" data-level="250">
          <strong>250 hPa</strong>
          <span>10.5 km Jet</span>
        </button>
      </div>

      <div class="dock-label">OVERLAY FIELD</div>
      <div class="overlay-row" role="group" aria-label="Scalar overlay">
        <button class="chip-btn active" type="button" data-overlay="speed">WIND SPD</button>
        <button class="chip-btn" type="button" data-overlay="temp">TEMP ANOM</button>
        <button class="chip-btn" type="button" data-overlay="mslp">ISOBARS</button>
      </div>

      <div class="control-slider">
        <div class="slider-head">
          <label for="densitySlider">PARTICLE DENSITY</label>
          <output id="densityOut">1,100</output>
        </div>
        <input id="densitySlider" type="range" min="400" max="2000" step="100" value="1100">
      </div>

      <div class="scale-bar">
        <div class="dock-label" id="scaleLabel">VELOCITY SCALE (KM/H)</div>
        <div class="scale-gradient"></div>
        <div class="scale-ticks" id="scaleTicks">
          <span>0</span>
          <span>35</span>
          <span>75</span>
          <span>120</span>
          <span>180+</span>
        </div>
      </div>
    </aside>

    <section class="inspector-card" aria-live="polite" aria-label="Coordinate wind telemetry inspector">
      <div class="inspector-head">
        <span class="dock-label">PROBE TELEMETRY</span>
        <span class="inspector-coord" id="probeCoord">38.4°N, 142.6°W</span>
      </div>
      <div class="inspector-grid">
        <div class="metric-box">
          <span class="k">WIND SPEED</span>
          <span class="v" id="probeSpeed">64.2 km/h</span>
        </div>
        <div class="metric-box">
          <span class="k">AZIMUTH</span>
          <span class="v" id="probeBearing">258° WSW</span>
        </div>
        <div class="metric-box">
          <span class="k">AIR TEMP</span>
          <span class="v" id="probeTemp">9.4 °C</span>
        </div>
        <div class="metric-box">
          <span class="k">PRESSURE</span>
          <span class="v" id="probePressure">1004 hPa</span>
        </div>
      </div>
      <p class="inspector-hint" id="probeHint">Click or tap anywhere on the projection to drop the atmospheric sonde.</p>
    </section>
  </main>

  <script>
    (() => {
      const canvas = document.getElementById('windCanvas');
      const ctx = canvas.getContext('2d');

      const state = {
        level: 'sfc',
        overlay: 'speed',
        projection: 'ortho',
        paused: false,
        particleCount: 1100,
        width: window.innerWidth,
        height: window.innerHeight,
        dpr: Math.min(window.devicePixelRatio || 1, 2),
        probe: { lat: 38.4, lon: -142.6, x: 0.36, y: 0.38 },
        time: 0
      };

      const LEVEL_CFG = {
        sfc: { name: 'Surface 10m', speedMult: 1.0, baseTemp: 14, basePress: 1013, scaleMax: 120, jetBias: 0.25 },
        850: { name: '850 hPa', speedMult: 1.45, baseTemp: 4, basePress: 850, scaleMax: 160, jetBias: 0.55 },
        250: { name: '250 hPa Jet Stream', speedMult: 2.35, baseTemp: -48, basePress: 250, scaleMax: 260, jetBias: 1.15 }
      };

      // Stylized simplified continental polygons (lon, lat) for scientific graticule context
      const CONTINENTS = [
        [[-130,52],[-122,42],[-112,28],[-98,20],[-82,25],[-76,38],[-62,48],[-80,60],[-115,62]],
        [[-78,8],[-68,-8],[-54,-22],[-62,-46],[-72,-52],[-76,-28],[-80,-4]],
        [[-10,36],[4,44],[24,56],[36,64],[14,68],[-4,56],[-10,44]],
        [[-14,14],[10,32],[34,30],[44,8],[32,-26],[18,-34],[8,-12],[-8,4]],
        [[42,58],[74,66],[122,64],[142,46],[124,24],[102,14],[82,10],[66,24],[46,38]],
        [[114,-22],[134,-14],[152,-26],[146,-38],[124,-34]]
      ];

      let particles = [];

      function resize() {
        state.width = window.innerWidth;
        state.height = window.innerHeight;
        canvas.width = Math.floor(state.width * state.dpr);
        canvas.height = Math.floor(state.height * state.dpr);
        ctx.setTransform(state.dpr, 0, 0, state.dpr, 0, 0);
        ctx.fillStyle = '#091119';
        ctx.fillRect(0, 0, state.width, state.height);
        seedParticles();
      }

      function projectPoint(lon, lat) {
        const cx = state.width * 0.5;
        const cy = state.height * 0.48;
        if (state.projection === 'ortho') {
          const r = Math.min(state.width, state.height) * 0.41;
          const lam = ((lon + 35) * Math.PI) / 180;
          const phi = (lat * Math.PI) / 180;
          const cosC = Math.cos(phi) * Math.cos(lam);
          if (cosC < 0) return null;
          return {
            x: cx + r * Math.cos(phi) * Math.sin(lam),
            y: cy - r * Math.sin(phi),
            r
          };
        }
        return {
          x: ((lon + 180) / 360) * state.width,
          y: ((90 - lat) / 180) * state.height,
          r: Math.min(state.width, state.height) * 0.45
        };
      }

      function screenToLatLon(x, y) {
        const cx = state.width * 0.5;
        const cy = state.height * 0.48;
        if (state.projection === 'ortho') {
          const r = Math.min(state.width, state.height) * 0.41;
          const dx = (x - cx) / r;
          const dy = (cy - y) / r;
          const dist2 = dx * dx + dy * dy;
          if (dist2 > 1) return null;
          const z = Math.sqrt(1 - dist2);
          const lat = Math.asin(dy) * (180 / Math.PI);
          const lon = Math.atan2(dx, z) * (180 / Math.PI) - 35;
          return { lat, lon: ((lon + 540) % 360) - 180 };
        }
        return {
          lat: 90 - (y / state.height) * 180,
          lon: (x / state.width) * 360 - 180
        };
      }

      // Deterministic synoptic wind vector field (cyclones, anticyclones, jet stream)
      function sampleWind(nx, ny) {
        const cfg = LEVEL_CFG[state.level];
        const latRad = (0.5 - ny) * Math.PI;
        const lonRad = nx * Math.PI * 2;

        // Zonal jet + trade winds
        let u = Math.cos(latRad * 2.8) * 1.15 + cfg.jetBias * Math.exp(-Math.pow((Math.abs(latRad) - 0.65) / 0.24, 2)) * 2.1;
        let v = Math.sin(lonRad * 2.0 + state.time * 0.15) * 0.42 * Math.cos(latRad);

        // Two synoptic low/high vortices
        const vortices = [
          { x: 0.34, y: 0.34, s: 1.55, r: 0.16 },
          { x: 0.68, y: 0.42, s: -1.35, r: 0.18 },
          { x: 0.52, y: 0.66, s: 1.15, r: 0.15 }
        ];
        for (const vtx of vortices) {
          const dx = nx - vtx.x;
          const dy = ny - vtx.y;
          const d2 = dx * dx + dy * dy + 0.0025;
          const falloff = Math.exp(-d2 / (vtx.r * vtx.r));
          u += (-dy / Math.sqrt(d2)) * vtx.s * falloff;
          v += (dx / Math.sqrt(d2)) * vtx.s * falloff;
        }

        u *= cfg.speedMult;
        v *= cfg.speedMult;
        const mag = Math.hypot(u, v);
        return { u, v, mag };
      }

      function speedColor(mag) {
        const cfg = LEVEL_CFG[state.level];
        const t = Math.min(mag / (2.6 * cfg.speedMult), 1);
        if (state.overlay === 'temp') {
          if (t < 0.45) return `rgba(74, 159, 255, ${0.45 + t})`;
          if (t < 0.75) return `rgba(255, 180, 84, ${0.65 + t * 0.3})`;
          return `rgba(255, 93, 143, 0.92)`;
        }
        if (t < 0.35) return `rgba(46, 230, 197, ${0.38 + t * 1.2})`;
        if (t < 0.72) return `rgba(255, 180, 84, ${0.65 + t * 0.3})`;
        return `rgba(255, 93, 143, 0.94)`;
      }

      function spawnParticle() {
        return {
          x: Math.random() * state.width,
          y: Math.random() * state.height,
          age: Math.floor(Math.random() * 80),
          maxAge: 55 + Math.floor(Math.random() * 75)
        };
      }

      function seedParticles() {
        particles = Array.from({ length: state.particleCount }, spawnParticle);
      }

      function drawBackdropGeometry() {
        const cx = state.width * 0.5;
        const cy = state.height * 0.48;
        const r = Math.min(state.width, state.height) * 0.41;

        ctx.save();
        if (state.projection === 'ortho') {
          ctx.beginPath();
          ctx.arc(cx, cy, r, 0, Math.PI * 2);
          ctx.strokeStyle = 'rgba(46, 230, 197, 0.22)';
          ctx.lineWidth = 1.2;
          ctx.stroke();

          // Graticule rings
          ctx.strokeStyle = 'rgba(228, 240, 246, 0.05)';
          ctx.lineWidth = 1;
          for (let lat = -60; lat <= 60; lat += 30) {
            ctx.beginPath();
            let started = false;
            for (let lon = -180; lon <= 180; lon += 6) {
              const p = projectPoint(lon, lat);
              if (!p) { started = false; continue; }
              if (!started) { ctx.moveTo(p.x, p.y); started = true; }
              else ctx.lineTo(p.x, p.y);
            }
            ctx.stroke();
          }
        } else {
          ctx.strokeStyle = 'rgba(228, 240, 246, 0.06)';
          ctx.lineWidth = 1;
          for (let i = 1; i < 6; i++) {
            const y = (state.height / 6) * i;
            ctx.beginPath();
            ctx.moveTo(0, y);
            ctx.lineTo(state.width, y);
            ctx.stroke();
          }
          for (let i = 1; i < 12; i++) {
            const x = (state.width / 12) * i;
            ctx.beginPath();
            ctx.moveTo(x, 0);
            ctx.lineTo(x, state.height);
            ctx.stroke();
          }
        }

        // Simplified continental outlines
        ctx.strokeStyle = 'rgba(107, 135, 155, 0.34)';
        ctx.lineWidth = 1.1;
        for (const poly of CONTINENTS) {
          ctx.beginPath();
          let started = false;
          for (const [lon, lat] of poly) {
            const p = projectPoint(lon, lat);
            if (!p) { started = false; continue; }
            if (!started) { ctx.moveTo(p.x, p.y); started = true; }
            else ctx.lineTo(p.x, p.y);
          }
          if (started) ctx.closePath();
          ctx.stroke();
        }

        // Isobars overlay when active
        if (state.overlay === 'mslp') {
          ctx.strokeStyle = 'rgba(228, 240, 246, 0.14)';
          ctx.setLineDash([4, 4]);
          [0.34, 0.68].forEach((vx, idx) => {
            const px = vx * state.width;
            const py = (idx === 0 ? 0.34 : 0.42) * state.height;
            for (let rad = 36; rad <= 144; rad += 36) {
              ctx.beginPath();
              ctx.ellipse(px, py, rad * 1.25, rad * 0.85, 0.25, 0, Math.PI * 2);
              ctx.stroke();
            }
          });
          ctx.setLineDash([]);
        }

        // Probe reticle
        const px = state.probe.x * state.width;
        const py = state.probe.y * state.height;
        ctx.strokeStyle = '#2EE6C5';
        ctx.lineWidth = 1.5;
        ctx.beginPath();
        ctx.arc(px, py, 9, 0, Math.PI * 2);
        ctx.stroke();
        ctx.beginPath();
        ctx.moveTo(px - 15, py);
        ctx.lineTo(px - 5, py);
        ctx.moveTo(px + 5, py);
        ctx.lineTo(px + 15, py);
        ctx.moveTo(px, py - 15);
        ctx.lineTo(px, py - 5);
        ctx.moveTo(px, py + 5);
        ctx.lineTo(px, py + 15);
        ctx.stroke();
        ctx.restore();
      }

      function updateInspector() {
        const cfg = LEVEL_CFG[state.level];
        const vec = sampleWind(state.probe.x, state.probe.y);
        const speedKmh = Math.round(vec.mag * 36 * 10) / 10;
        const deg = Math.round(((Math.atan2(vec.u, -vec.v) * 180) / Math.PI + 360) % 360);
        const dirs = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW'];
        const cardinal = dirs[Math.round(deg / 22.5) % 16];
        const latFactor = Math.cos((state.probe.lat * Math.PI) / 180);
        const temp = (cfg.baseTemp + latFactor * 14 - vec.mag * 2.1).toFixed(1);
        const press = Math.round(cfg.basePress - vec.mag * 6.5);

        const latStr = `${Math.abs(state.probe.lat).toFixed(1)}°${state.probe.lat >= 0 ? 'N' : 'S'}`;
        const lonStr = `${Math.abs(state.probe.lon).toFixed(1)}°${state.probe.lon >= 0 ? 'E' : 'W'}`;

        document.getElementById('probeCoord').textContent = `${latStr}, ${lonStr}`;
        document.getElementById('probeSpeed').textContent = `${speedKmh.toFixed(1)} km/h`;
        document.getElementById('probeBearing').textContent = `${deg}° ${cardinal}`;
        document.getElementById('probeTemp').textContent = `${temp} °C`;
        document.getElementById('probePressure').textContent = `${press} hPa`;
      }

      function tick() {
        if (!state.paused) {
          state.time += 0.012;
          // Fade previous trails
          ctx.fillStyle = 'rgba(9, 17, 25, 0.085)';
          ctx.fillRect(0, 0, state.width, state.height);

          const cx = state.width * 0.5;
          const cy = state.height * 0.48;
          const r = Math.min(state.width, state.height) * 0.41;

          ctx.lineWidth = 1.25;
          for (let i = 0; i < particles.length; i++) {
            const p = particles[i];
            if (p.age >= p.maxAge || p.x < 0 || p.x > state.width || p.y < 0 || p.y > state.height) {
              particles[i] = spawnParticle();
              continue;
            }
            if (state.projection === 'ortho') {
              const dist = Math.hypot(p.x - cx, p.y - cy);
              if (dist > r) {
                const ang = Math.random() * Math.PI * 2;
                const rad = Math.sqrt(Math.random()) * r * 0.98;
                p.x = cx + Math.cos(ang) * rad;
                p.y = cy + Math.sin(ang) * rad;
                p.age = 0;
                continue;
              }
            }
            const vec = sampleWind(p.x / state.width, p.y / state.height);
            const nx = p.x + vec.u * 1.85;
            const ny = p.y + vec.v * 1.85;

            ctx.beginPath();
            ctx.strokeStyle = speedColor(vec.mag);
            ctx.moveTo(p.x, p.y);
            ctx.lineTo(nx, ny);
            ctx.stroke();

            p.x = nx;
            p.y = ny;
            p.age++;
          }
          drawBackdropGeometry();
        }
        requestAnimationFrame(tick);
      }

      // Event wiring
      canvas.addEventListener('click', (e) => {
        const rect = canvas.getBoundingClientRect();
        const x = e.clientX - rect.left;
        const y = e.clientY - rect.top;
        const ll = screenToLatLon(x, y);
        if (!ll) return;
        state.probe = { lat: ll.lat, lon: ll.lon, x: x / state.width, y: y / state.height };
        document.getElementById('probeHint').textContent = `Sonde locked on ${LEVEL_CFG[state.level].name} streamline vector.`;
        updateInspector();
      });

      document.querySelectorAll('.pressure-btn').forEach((btn) => {
        btn.addEventListener('click', () => {
          document.querySelectorAll('.pressure-btn').forEach((b) => b.classList.remove('active'));
          btn.classList.add('active');
          state.level = btn.dataset.level;
          const max = LEVEL_CFG[state.level].scaleMax;
          const ticks = document.getElementById('scaleTicks').children;
          [0, Math.round(max * 0.25), Math.round(max * 0.5), Math.round(max * 0.75), `${max}+`].forEach((v, idx) => {
            ticks[idx].textContent = v;
          });
          updateInspector();
        });
      });

      document.querySelectorAll('.chip-btn').forEach((btn) => {
        btn.addEventListener('click', () => {
          document.querySelectorAll('.chip-btn').forEach((b) => b.classList.remove('active'));
          btn.classList.add('active');
          state.overlay = btn.dataset.overlay;
          document.getElementById('scaleLabel').textContent =
            state.overlay === 'temp' ? 'THERMAL GRADIENT (°C)' : 'VELOCITY SCALE (KM/H)';
        });
      });

      document.getElementById('densitySlider').addEventListener('input', (e) => {
        state.particleCount = Number(e.target.value);
        document.getElementById('densityOut').textContent = state.particleCount.toLocaleString();
        seedParticles();
      });

      document.getElementById('pauseBtn').addEventListener('click', (e) => {
        state.paused = !state.paused;
        e.currentTarget.textContent = state.paused ? 'RESUME' : 'PAUSE';
        e.currentTarget.setAttribute('aria-pressed', String(state.paused));
      });

      document.getElementById('projBtn').addEventListener('click', (e) => {
        state.projection = state.projection === 'ortho' ? 'equirect' : 'ortho';
        e.currentTarget.textContent = state.projection === 'ortho' ? 'PROJ: ORTHO' : 'PROJ: EQUIRECT';
        e.currentTarget.setAttribute('aria-pressed', String(state.projection === 'equirect'));
        ctx.fillStyle = '#091119';
        ctx.fillRect(0, 0, state.width, state.height);
      });

      // Mobile drawer controls
      const dock = document.getElementById('instrumentDock');
      const backdrop = document.getElementById('drawerBackdrop');
      const openBtn = document.getElementById('drawerOpenBtn');
      const closeBtn = document.getElementById('drawerCloseBtn');

      function setDrawer(open) {
        dock.classList.toggle('open', open);
        backdrop.classList.toggle('open', open);
        openBtn.setAttribute('aria-expanded', String(open));
      }

      openBtn.addEventListener('click', () => setDrawer(true));
      closeBtn.addEventListener('click', () => setDrawer(false));
      backdrop.addEventListener('click', () => setDrawer(false));

      window.addEventListener('resize', resize);
      resize();
      updateInspector();
      requestAnimationFrame(tick);
    })();
  </script>
</body>
</html>
```
