# #044 — Seismic Hazard Monitor

> Mixed-theme geophysical telemetry console with tectonic fault-line map, magnitude filters, and live seismogram trace.

## Metadata

- **Index**: #044
- **Slug**: `seismic-hazard-monitor`
- **Kind**: `style`
- **Family**: Telemetry & Cartographic
- **Theme**: `mixed`
- **Mobile Strength**: `high`
- **Tags**: `telemetry`, `geophysics`, `seismic`, `live-feed`, `map-console`, `mixed-theme`
- **Best For**: Geophysical, volcanic, and environmental hazard monitors, Emergency operations and incident telemetry feeds, Real-time sensor event triage consoles
- **Real-World Inspiration**: [USGS Earthquake Hazards](https://earthquake.usgs.gov/)
- **Detail Page**: https://templates.michaelpitts.net/t/seismic-hazard-monitor
- **Live Demo**: https://templates.michaelpitts.net/demos/seismic-hazard-monitor.html
- **JSON API**: https://templates.michaelpitts.net/api/templates/seismic-hazard-monitor

## Why This Aesthetic Is Unique

Combines a high-contrast dark operational alert banner with a calm topographic stone workspace so severe M6.0+ seismic events pop immediately without visual fatigue.

## Color Palette

| Role | Name | Hex |
|------|------|-----|
| `canvas` | Topographic Stone | `#F1EFEA` |
| `surface` | Telemetry Card | `#FFFFFF` |
| `ink` | Tectonic Obsidian | `#181A1B` |
| `accent` | Seismic Vermilion | `#D9531E` |
| `muted` | Basalt Muted | `#5F666D` |

## Typography

- **Display**: `IBM Plex Sans`
- **Body**: `IBM Plex Sans`
- **Mono**: `IBM Plex Mono`
- **Scale Notes**: Bold numeric magnitude badges (18-22px mono) lead every event row, supported by compact 12px UTC timestamps and depth readouts.
- **Google Fonts**: https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap
  ```html
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap">
  ```

## Layout Architecture

Dark obsidian operational status header over a split console: interactive SVG fault-line epicenter map + Canvas seismogram alongside a filterable, clickable event feed.

## Interaction & Micro-Motion Rules

Filter seismic events by magnitude threshold (All, M2.5+, M4.5+, M6.0+); clicking any epicenter ring or feed row focuses its depth, P-wave arrival, and live waveform trace.

## Mobile & Responsive Rules

Stacks map, seismogram readout, and filterable event list vertically with 44px magnitude filter pills and tap-friendly list rows.

## Agent Guardrails

### DO
- Encode magnitude severity consistently across both map ring radius and list badges
- Display UTC timestamps, hypocenter depth in km, and coordinates in tabular monospace
- Keep the dark operational top strip concise so data cards dominate the viewport

### DON'T
- Do not use decorative animations that obscure actual event severity hierarchy
- Do not hide critical magnitude filter controls behind nested menus

## Complete Standalone Starter Code

File: `demos/seismic-hazard-monitor.html`

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>PNSN // Pacific Rim Seismic Hazard & Telemetry Console</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=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
  <style>
    :root {
      --canvas: #F1EFEA;
      --surface: #FFFFFF;
      --ink: #181A1B;
      --accent: #D9531E;
      --accent-soft: rgba(217, 83, 30, 0.12);
      --muted: #5F666D;
      --border: #DDD8CE;
      --status-bg: #15181C;
      --ok: #2BB673;
      --warn: #E6A23C;
      --sans: 'Inter', system-ui, -apple-system, sans-serif;
      --mono: 'IBM Plex Mono', ui-monospace, monospace;
    }

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

    body {
      margin: 0;
      background: var(--canvas);
      color: var(--ink);
      font-family: var(--sans);
      line-height: 1.5;
      overflow-x: hidden;
    }

    /* Dark Operational Top Status Strip */
    .status-strip {
      background: var(--status-bg);
      color: #E8ECEF;
      border-bottom: 2px solid var(--accent);
    }

    .status-inner {
      max-width: 1320px;
      margin: 0 auto;
      padding: 0 18px;
      min-height: 54px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .station-brand {
      display: flex;
      align-items: center;
      gap: 10px;
      font-weight: 700;
      font-size: 0.9rem;
      letter-spacing: 0.04em;
    }

    .live-beacon {
      width: 9px;
      height: 9px;
      border-radius: 50%;
      background: var(--ok);
      box-shadow: 0 0 8px var(--ok);
      flex-shrink: 0;
    }

    .telemetry-pills {
      display: flex;
      align-items: center;
      gap: 16px;
      font-family: var(--mono);
      font-size: 0.74rem;
      color: #AEB7C0;
    }

    .telemetry-pills strong {
      color: #FFFFFF;
    }

    .mobile-nav-btn {
      display: none;
      min-width: 44px;
      min-height: 44px;
      padding: 0 12px;
      background: #232830;
      border: 1px solid #3A414C;
      border-radius: 5px;
      color: #FFFFFF;
      font-family: var(--mono);
      font-size: 0.76rem;
      cursor: pointer;
    }

    .mobile-strip-drawer {
      display: none;
      background: #1C2026;
      padding: 12px 18px;
      border-top: 1px solid #2D333C;
      font-family: var(--mono);
      font-size: 0.78rem;
      color: #D2D9E0;
    }

    .mobile-strip-drawer.open {
      display: grid;
      gap: 10px;
    }

    .mobile-strip-drawer a {
      color: #FFFFFF;
      text-decoration: none;
      min-height: 44px;
      display: flex;
      align-items: center;
      border-bottom: 1px solid #2D333C;
    }

    /* Filter Toolbar */
    .filter-bar {
      background: var(--surface);
      border-bottom: 1px solid var(--border);
    }

    .filter-inner {
      max-width: 1320px;
      margin: 0 auto;
      padding: 12px 18px;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .pill-group {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
    }

    .mag-pill {
      min-height: 44px;
      padding: 0 14px;
      border-radius: 99px;
      border: 1px solid var(--border);
      background: var(--canvas);
      color: var(--ink);
      font-family: var(--mono);
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.15s ease;
    }

    .mag-pill.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #FFFFFF;
    }

    .sort-controls {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 0.82rem;
      color: var(--muted);
    }

    .sort-select {
      min-height: 44px;
      padding: 0 12px;
      border: 1px solid var(--border);
      border-radius: 6px;
      background: var(--surface);
      color: var(--ink);
      font-family: var(--sans);
      font-size: 0.84rem;
      font-weight: 500;
    }

    /* Console Grid */
    .console-grid {
      max-width: 1320px;
      margin: 0 auto;
      padding: 18px;
      display: grid;
      grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
      gap: 18px;
      align-items: start;
    }

    .panel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      overflow: hidden;
    }

    .panel-head {
      padding: 12px 16px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      background: #FAF9F6;
    }

    .panel-title {
      font-size: 0.82rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--ink);
    }

    .panel-meta {
      font-family: var(--mono);
      font-size: 0.74rem;
      color: var(--muted);
    }

    /* Pacific Rim SVG Map */
    .map-stage {
      background: #1B232C;
      position: relative;
    }

    #faultMap {
      width: 100%;
      height: auto;
      display: block;
    }

    .map-legend {
      padding: 10px 16px;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      font-family: var(--mono);
      font-size: 0.72rem;
      color: var(--muted);
      border-top: 1px solid var(--border);
    }

    .legend-items {
      display: flex;
      flex-wrap: wrap;
      gap: 14px;
    }

    .legend-dot {
      display: inline-block;
      width: 9px;
      height: 9px;
      border-radius: 50%;
      margin-right: 5px;
      vertical-align: middle;
    }

    /* Seismogram Canvas Panel */
    .seismo-panel {
      margin-top: 18px;
    }

    .seismo-body {
      padding: 14px 16px;
    }

    #seismoCanvas {
      width: 100%;
      height: 150px;
      display: block;
      background: #14181D;
      border-radius: 6px;
    }

    .selected-detail {
      margin-top: 12px;
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 10px;
    }

    .detail-cell {
      background: var(--canvas);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 8px 10px;
    }

    .detail-cell span {
      display: block;
      font-size: 0.68rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--muted);
    }

    .detail-cell strong {
      font-family: var(--mono);
      font-size: 0.9rem;
      color: var(--ink);
    }

    /* Event Feed List */
    .feed-list {
      list-style: none;
      margin: 0;
      padding: 0;
      max-height: 610px;
      overflow-y: auto;
    }

    .event-row {
      width: 100%;
      text-align: left;
      background: var(--surface);
      border: none;
      border-bottom: 1px solid var(--border);
      padding: 13px 16px;
      display: grid;
      grid-template-columns: 58px minmax(0, 1fr);
      gap: 12px;
      align-items: center;
      cursor: pointer;
      transition: background 0.14s;
    }

    .event-row:hover, .event-row.selected {
      background: var(--accent-soft);
    }

    .mag-badge {
      width: 54px;
      height: 44px;
      border-radius: 6px;
      display: grid;
      place-items: center;
      font-family: var(--mono);
      font-weight: 600;
      font-size: 0.96rem;
      color: #FFFFFF;
    }

    .event-title {
      font-weight: 600;
      font-size: 0.9rem;
      color: var(--ink);
      margin-bottom: 3px;
    }

    .event-meta {
      font-family: var(--mono);
      font-size: 0.72rem;
      color: var(--muted);
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
    }

    @media (max-width: 960px) {
      .console-grid {
        grid-template-columns: 1fr;
      }

      .telemetry-pills {
        display: none;
      }

      .mobile-nav-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
      }

      .selected-detail {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .feed-list {
        max-height: none;
      }
    }
  </style>
</head>
<body>
  <header class="status-strip">
    <div class="status-inner">
      <div class="station-brand">
        <span class="live-beacon" aria-hidden="true"></span>
        <span>USGS // PACIFIC RIM SEISMIC TELEMETRY</span>
      </div>
      <div class="telemetry-pills">
        <span>FEED: <strong>ANSS REAL-TIME</strong></span>
        <span>STATIONS: <strong>1,842 ONLINE</strong></span>
        <span>LAST SYNC: <strong>05:22:14 UTC</strong></span>
      </div>
      <button class="mobile-nav-btn" id="stripToggle" type="button" aria-expanded="false" aria-controls="mobileStripDrawer">STATUS</button>
    </div>
    <div class="mobile-strip-drawer" id="mobileStripDrawer">
      <div>FEED: ANSS REAL-TIME · 1,842 STATIONS ONLINE</div>
      <a href="#mapPanel">Pacific Rim Fault Map</a>
      <a href="#seismoSection">Live Broadband Seismogram</a>
      <a href="#feedSection">Event Catalog</a>
    </div>
  </header>

  <section class="filter-bar" aria-label="Earthquake magnitude filters and sorting">
    <div class="filter-inner">
      <div class="pill-group" role="group" aria-label="Minimum magnitude filter">
        <button class="mag-pill active" type="button" data-min="0">All Events</button>
        <button class="mag-pill" type="button" data-min="2.5">M2.5+</button>
        <button class="mag-pill" type="button" data-min="4.5">M4.5+</button>
        <button class="mag-pill" type="button" data-min="6.0">M6.0+</button>
      </div>
      <div class="sort-controls">
        <label for="sortSelect">Sort by:</label>
        <select class="sort-select" id="sortSelect">
          <option value="time">Most Recent</option>
          <option value="mag">Largest Magnitude</option>
          <option value="depth">Shallowest Depth</option>
        </select>
      </div>
    </div>
  </section>

  <main class="console-grid">
    <div>
      <section class="panel" id="mapPanel" aria-label="Pacific Rim fault-line epicenter map">
        <div class="panel-head">
          <span class="panel-title">Pacific Rim Subduction &amp; Transform Fault Map</span>
          <span class="panel-meta" id="visibleCount">9 EVENTS PLOTTED</span>
        </div>
        <div class="map-stage">
          <svg id="faultMap" viewBox="0 0 760 400" role="img" aria-label="Interactive SVG map of Pacific Rim fault lines and earthquake epicenters"></svg>
        </div>
        <div class="map-legend">
          <div class="legend-items">
            <span><i class="legend-dot" style="background:#D9531E"></i>M6.0+ Major</span>
            <span><i class="legend-dot" style="background:#E68A1E"></i>M4.5–5.9 Moderate</span>
            <span><i class="legend-dot" style="background:#38BDF8"></i>M2.5–4.4 Light</span>
          </div>
          <span>Click any epicenter ring to inspect waveform</span>
        </div>
      </section>

      <section class="panel seismo-panel" id="seismoSection" aria-label="Live station seismogram">
        <div class="panel-head">
          <span class="panel-title" id="seismoStation">BROADBAND TRACE // IU.MAJO.00.BHZ</span>
          <span class="panel-meta" id="seismoPga">PGA: 0.14 g · 20 Hz</span>
        </div>
        <div class="seismo-body">
          <canvas id="seismoCanvas" width="720" height="150" aria-label="Real-time vertical component seismogram trace"></canvas>
          <div class="selected-detail">
            <div class="detail-cell">
              <span>Magnitude</span>
              <strong id="detMag">M 6.4 Mw</strong>
            </div>
            <div class="detail-cell">
              <span>Hypocenter Depth</span>
              <strong id="detDepth">28.4 km</strong>
            </div>
            <div class="detail-cell">
              <span>Coordinates</span>
              <strong id="detCoord">38.12°N, 142.86°E</strong>
            </div>
            <div class="detail-cell">
              <span>Fault Regime</span>
              <strong id="detRegime">Megathrust</strong>
            </div>
          </div>
        </div>
      </section>
    </div>

    <aside class="panel" id="feedSection" aria-label="Sortable seismic event feed">
      <div class="panel-head">
        <span class="panel-title">Recent Seismic Events</span>
        <span class="panel-meta">PAST 24 HOURS</span>
      </div>
      <ul class="feed-list" id="eventFeed"></ul>
    </aside>
  </main>

  <script>
    (() => {
      const EVENTS = [
        { id: 'us7001', mag: 6.4, place: '84 km ESE of Sendai, Japan', depth: 28.4, minsAgo: 14, x: 186, y: 158, coord: '38.12°N, 142.86°E', station: 'IU.MAJO.00.BHZ', pga: '0.14 g', regime: 'Megathrust' },
        { id: 'us7002', mag: 6.1, place: '42 km WSW of Iquique, Chile', depth: 34.0, minsAgo: 47, x: 642, y: 318, coord: '20.34°S, 70.51°W', station: 'IU.LCO.00.BHZ', pga: '0.11 g', regime: 'Subduction' },
        { id: 'us7003', mag: 5.5, place: '112 km S of Unalaska, Alaska', depth: 21.8, minsAgo: 82, x: 355, y: 84, coord: '52.88°N, 166.40°W', station: 'AK.UNV.00.BHZ', pga: '0.07 g', regime: 'Aleutian Arc' },
        { id: 'us7004', mag: 5.1, place: '29 km NE of Hualien, Taiwan', depth: 16.5, minsAgo: 118, x: 138, y: 206, coord: '24.16°N, 121.80°E', station: 'IU.TATO.00.BHZ', pga: '0.06 g', regime: 'Reverse Oblique' },
        { id: 'us7005', mag: 4.8, place: '64 km W of Ferndale, California', depth: 11.2, minsAgo: 165, x: 528, y: 156, coord: '40.54°N, 125.02°W', station: 'BK.HUMO.00.BHZ', pga: '0.04 g', regime: 'Mendocino TF' },
        { id: 'us7006', mag: 4.6, place: '95 km E of Gisborne, New Zealand', depth: 39.2, minsAgo: 210, x: 266, y: 348, coord: '38.61°S, 179.04°E', station: 'IU.SNZO.00.BHZ', pga: '0.03 g', regime: 'Hikurangi' },
        { id: 'us7007', mag: 3.9, place: '18 km SSW of Oaxaca, Mexico', depth: 46.1, minsAgo: 254, x: 586, y: 236, coord: '16.92°N, 96.78°W', station: 'MX.OXIG.00.BHZ', pga: '0.02 g', regime: 'Normal Slab' },
        { id: 'us7008', mag: 3.2, place: '12 km E of Ridgecrest, California', depth: 7.4, minsAgo: 312, x: 544, y: 176, coord: '35.62°N, 117.54°W', station: 'CI.CLC.00.BHZ', pga: '0.01 g', regime: 'Strike-Slip' },
        { id: 'us7009', mag: 2.3, place: '9 km NW of Pahala, Hawaii', depth: 31.6, minsAgo: 380, x: 404, y: 218, coord: '19.24°N, 155.54°W', station: 'HV.PAHD.00.BHZ', pga: '0.01 g', regime: 'Volcanic Deep' }
      ];

      let minMag = 0;
      let sortBy = 'time';
      let selectedId = EVENTS[0].id;

      const faultMap = document.getElementById('faultMap');
      const eventFeed = document.getElementById('eventFeed');
      const visibleCount = document.getElementById('visibleCount');

      function magColor(m) {
        if (m >= 6.0) return '#D9531E';
        if (m >= 4.5) return '#E68A1E';
        return '#38BDF8';
      }

      function getFiltered() {
        const list = EVENTS.filter((e) => e.mag >= minMag);
        if (sortBy === 'mag') list.sort((a, b) => b.mag - a.mag);
        else if (sortBy === 'depth') list.sort((a, b) => a.depth - b.depth);
        else list.sort((a, b) => a.minsAgo - b.minsAgo);
        return list;
      }

      function selectEvent(id) {
        selectedId = id;
        const ev = EVENTS.find((e) => e.id === id) || EVENTS[0];
        document.getElementById('seismoStation').textContent = `BROADBAND TRACE // ${ev.station}`;
        document.getElementById('seismoPga').textContent = `PGA: ${ev.pga} · 20 Hz`;
        document.getElementById('detMag').textContent = `M ${ev.mag.toFixed(1)} Mw`;
        document.getElementById('detDepth').textContent = `${ev.depth.toFixed(1)} km`;
        document.getElementById('detCoord').textContent = ev.coord;
        document.getElementById('detRegime').textContent = ev.regime;
        renderMap();
        renderFeed();
      }

      function renderMap() {
        const ns = 'http://www.w3.org/2000/svg';
        const list = getFiltered();
        visibleCount.textContent = `${list.length} EVENTS PLOTTED`;
        faultMap.innerHTML = '';

        // Graticule grid
        for (let x = 76; x < 760; x += 76) {
          const l = document.createElementNS(ns, 'line');
          l.setAttribute('x1', x); l.setAttribute('x2', x);
          l.setAttribute('y1', 0); l.setAttribute('y2', 400);
          l.setAttribute('stroke', 'rgba(255,255,255,0.05)');
          faultMap.appendChild(l);
        }
        for (let y = 80; y < 400; y += 80) {
          const l = document.createElementNS(ns, 'line');
          l.setAttribute('x1', 0); l.setAttribute('x2', 760);
          l.setAttribute('y1', y); l.setAttribute('y2', y);
          l.setAttribute('stroke', 'rgba(255,255,255,0.05)');
          faultMap.appendChild(l);
        }

        // Stylized Pacific basin rim & subduction fault trenches
        const basinPath = document.createElementNS(ns, 'path');
        basinPath.setAttribute('d', 'M 90,340 Q 115,245 142,195 T 205,125 Q 290,68 380,76 T 518,136 Q 555,185 594,244 T 658,365');
        basinPath.setAttribute('fill', 'none');
        basinPath.setAttribute('stroke', '#D9531E');
        basinPath.setAttribute('stroke-width', '2');
        basinPath.setAttribute('stroke-dasharray', '6 5');
        basinPath.setAttribute('stroke-opacity', '0.68');
        faultMap.appendChild(basinPath);

        const nzFault = document.createElementNS(ns, 'path');
        nzFault.setAttribute('d', 'M 225,372 Q 258,342 292,295');
        nzFault.setAttribute('fill', 'none');
        nzFault.setAttribute('stroke', '#D9531E');
        nzFault.setAttribute('stroke-width', '1.8');
        nzFault.setAttribute('stroke-dasharray', '5 4');
        nzFault.setAttribute('stroke-opacity', '0.62');
        faultMap.appendChild(nzFault);

        // Basin label
        const lbl = document.createElementNS(ns, 'text');
        lbl.setAttribute('x', 370);
        lbl.setAttribute('y', 250);
        lbl.setAttribute('text-anchor', 'middle');
        lbl.setAttribute('fill', 'rgba(255,255,255,0.12)');
        lbl.setAttribute('font-size', '18');
        lbl.setAttribute('font-weight', '700');
        lbl.setAttribute('letter-spacing', '8');
        lbl.textContent = 'PACIFIC PLATE';
        faultMap.appendChild(lbl);

        // Epicenter rings
        list.forEach((ev) => {
          const isSel = ev.id === selectedId;
          const color = magColor(ev.mag);
          const r = Math.max(6, (ev.mag - 1.4) * 3.4);

          const g = document.createElementNS(ns, 'g');
          g.style.cursor = 'pointer';
          g.addEventListener('click', () => selectEvent(ev.id));

          if (isSel) {
            const halo = document.createElementNS(ns, 'circle');
            halo.setAttribute('cx', ev.x);
            halo.setAttribute('cy', ev.y);
            halo.setAttribute('r', r + 11);
            halo.setAttribute('fill', 'none');
            halo.setAttribute('stroke', '#FFFFFF');
            halo.setAttribute('stroke-width', '1.6');
            halo.setAttribute('stroke-dasharray', '3 3');
            g.appendChild(halo);
          }

          const outer = document.createElementNS(ns, 'circle');
          outer.setAttribute('cx', ev.x);
          outer.setAttribute('cy', ev.y);
          outer.setAttribute('r', r + 4);
          outer.setAttribute('fill', color);
          outer.setAttribute('fill-opacity', '0.24');
          g.appendChild(outer);

          const core = document.createElementNS(ns, 'circle');
          core.setAttribute('cx', ev.x);
          core.setAttribute('cy', ev.y);
          core.setAttribute('r', r * 0.65);
          core.setAttribute('fill', color);
          core.setAttribute('stroke', '#FFFFFF');
          core.setAttribute('stroke-width', isSel ? '2' : '1');
          g.appendChild(core);

          const tag = document.createElementNS(ns, 'text');
          tag.setAttribute('x', ev.x + r + 6);
          tag.setAttribute('y', ev.y + 4);
          tag.setAttribute('fill', '#E8ECEF');
          tag.setAttribute('font-family', 'IBM Plex Mono, monospace');
          tag.setAttribute('font-size', '11');
          tag.textContent = `M${ev.mag.toFixed(1)}`;
          g.appendChild(tag);

          faultMap.appendChild(g);
        });
      }

      function renderFeed() {
        const list = getFiltered();
        eventFeed.innerHTML = '';
        list.forEach((ev) => {
          const li = document.createElement('li');
          const btn = document.createElement('button');
          btn.type = 'button';
          btn.className = `event-row${ev.id === selectedId ? ' selected' : ''}`;
          btn.innerHTML = `
            <span class="mag-badge" style="background:${magColor(ev.mag)}">${ev.mag.toFixed(1)}</span>
            <div>
              <div class="event-title">${ev.place}</div>
              <div class="event-meta">
                <span>Depth ${ev.depth.toFixed(1)} km</span>
                <span>${ev.minsAgo}m ago</span>
                <span>${ev.regime}</span>
              </div>
            </div>`;
          btn.addEventListener('click', () => selectEvent(ev.id));
          li.appendChild(btn);
          eventFeed.appendChild(li);
        });
      }

      // Live Canvas Seismogram Trace
      const sCanvas = document.getElementById('seismoCanvas');
      const sctx = sCanvas.getContext('2d');
      const samples = new Array(240).fill(0);
      let phase = 0;

      function animateSeismo() {
        const ev = EVENTS.find((e) => e.id === selectedId) || EVENTS[0];
        const amp = Math.pow(ev.mag / 4.2, 2.2) * 14;
        phase += 0.28;

        // Synthesize P-wave / S-wave packet bursts
        const burst = Math.exp(-Math.pow(((phase % 28) - 10) / 3.4, 2));
        const val = (Math.sin(phase * 3.1) * 0.65 + Math.sin(phase * 7.3) * 0.35) * amp * (0.22 + burst * 1.45) + (Math.random() - 0.5) * 3.2;
        samples.shift();
        samples.push(val);

        const w = sCanvas.width;
        const h = sCanvas.height;
        sctx.fillStyle = '#14181D';
        sctx.fillRect(0, 0, w, h);

        // Grid
        sctx.strokeStyle = 'rgba(255,255,255,0.07)';
        sctx.lineWidth = 1;
        for (let i = 1; i < 4; i++) {
          const y = (h / 4) * i;
          sctx.beginPath();
          sctx.moveTo(0, y);
          sctx.lineTo(w, y);
          sctx.stroke();
        }

        // Trace
        sctx.beginPath();
        sctx.strokeStyle = '#D9531E';
        sctx.lineWidth = 1.7;
        for (let i = 0; i < samples.length; i++) {
          const x = (i / (samples.length - 1)) * w;
          const y = h / 2 + Math.max(-h * 0.44, Math.min(h * 0.44, samples[i]));
          if (i === 0) sctx.moveTo(x, y);
          else sctx.lineTo(x, y);
        }
        sctx.stroke();

        requestAnimationFrame(animateSeismo);
      }

      document.querySelectorAll('.mag-pill').forEach((btn) => {
        btn.addEventListener('click', () => {
          document.querySelectorAll('.mag-pill').forEach((b) => b.classList.remove('active'));
          btn.classList.add('active');
          minMag = parseFloat(btn.dataset.min);
          const filtered = getFiltered();
          if (filtered.length && !filtered.some((e) => e.id === selectedId)) {
            selectedId = filtered[0].id;
          }
          selectEvent(selectedId);
        });
      });

      document.getElementById('sortSelect').addEventListener('change', (e) => {
        sortBy = e.target.value;
        renderFeed();
      });

      const stripToggle = document.getElementById('stripToggle');
      const mobileStripDrawer = document.getElementById('mobileStripDrawer');
      stripToggle.addEventListener('click', () => {
        const open = mobileStripDrawer.classList.toggle('open');
        stripToggle.setAttribute('aria-expanded', String(open));
      });

      selectEvent(EVENTS[0].id);
      requestAnimationFrame(animateSeismo);
    })();
  </script>
</body>
</html>
```
