# #008 — The Pudding Visual Essay

> Tactile newsprint paired with playful data-viz spot colors, scrollytelling narrative steps, and annotated charts.

## Metadata

- **Index**: #008
- **Slug**: `pudding-visual-essay`
- **Kind**: `style`
- **Family**: Editorial & Data Journalism
- **Theme**: `light`
- **Mobile Strength**: `high`
- **Tags**: `visual-essay`, `scrollytelling`, `data-journalism`, `editorial-viz`, `interactive-chart`, `narrative`
- **Best For**: Visual journalism & data essays, Interactive research reports, Cultural analytics & explainers, Educational storytelling
- **Real-World Inspiration**: [The Pudding](https://pudding.cool)
- **Detail Page**: https://templates.michaelpitts.net/t/pudding-visual-essay
- **Live Demo**: https://templates.michaelpitts.net/demos/pudding-visual-essay.html
- **JSON API**: https://templates.michaelpitts.net/api/templates/pudding-visual-essay

## Why This Aesthetic Is Unique

Bridges magazine storytelling and interactive data visualization: narrative prose steps directly drive a sticky custom SVG/Canvas graphic with hand-tuned editorial callouts and zero corporate dashboard bloat.

## Color Palette

| Role | Name | Hex |
|------|------|-----|
| `canvas` | Warm Newsprint | `#F8F6F1` |
| `surface` | Chart Matte | `#EFECE4` |
| `ink` | Editorial Charcoal | `#1E1E24` |
| `accent` | Data Teal | `#0E8A8A` |
| `muted` | Axis Slate | `#64646E` |

## Typography

- **Display**: `Fraunces, Georgia, serif`
- **Body**: `Public Sans, -apple-system, sans-serif`
- **Mono**: `JetBrains Mono, ui-monospace, monospace`
- **Scale Notes**: Expressive soft-serif Fraunces display headlines paired with crisp Public Sans prose and monospace data labels.
- **Google Fonts**: https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,600;0,9..144,700;1,9..144,400&family=JetBrains+Mono:wght@400;500&family=Public+Sans:wght@400;500;600&display=swap
  ```html
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,600;0,9..144,700;1,9..144,400&family=JetBrains+Mono:wght@400;500&family=Public+Sans:wght@400;500;600&display=swap">
  ```

## Layout Architecture

Centered editorial opener leading into a split scrollytelling stage (sticky interactive data graphic alongside clickable/scrollable narrative steps), followed by an interactive explorer table.

## Interaction & Micro-Motion Rules

Step buttons and scroll-aware triggers morph the live SVG chart state across eras, accompanied by genre filter pills, hover/tap data tooltips, and color-coded inline prose highlights.

## Mobile & Responsive Rules

Split scrollytelling converts into a compact top-pinned or cleanly stacked chart above tappable narrative step pills so 390px readers can scrub the story with one thumb.

## Agent Guardrails

### DO
- Color-code key prose phrases to match the exact data series colors in the chart
- Keep charts uncluttered with direct annotations instead of detached legend boxes
- Pair expressive editorial headlines with clean sans-serif data labels

### DON'T
- Do not turn the visual essay into a generic SaaS KPI dashboard with 6 chart cards
- Do not rely on hover-only tooltips that fail on touch devices

## Complete Standalone Starter Code

File: `demos/pudding-visual-essay.html`

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>How Song Intros Shrank Across 50 Years of Pop — The Visual Essay</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=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&family=Fraunces:ital,opsz,wght@0,9..144,600;0,9..144,800;1,9..144,500&family=IBM+Plex+Mono:wght@400;500;600&display=swap" rel="stylesheet">
  <style>
    :root {
      --canvas: #F8F6F1;
      --surface: #EFECE4;
      --ink: #1E1E24;
      --accent: #0E8A8A;
      --coral: #E05A47;
      --mustard: #D99B26;
      --muted: #64646E;
      --line: #DCD7CB;
      --font-display: 'Fraunces', Georgia, serif;
      --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
      --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
    }

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

    html {
      background: var(--canvas);
      color: var(--ink);
      scroll-behavior: smooth;
      -webkit-font-smoothing: antialiased;
    }

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

    a { color: inherit; text-decoration: none; }
    button { font-family: inherit; color: inherit; cursor: pointer; }

    /* Top Bar */
    .topbar {
      border-bottom: 1px solid var(--line);
      background: rgba(248, 246, 241, 0.94);
      position: sticky;
      top: 0;
      z-index: 40;
      backdrop-filter: blur(8px);
    }

    .topbar-inner {
      max-width: 1200px;
      margin: 0 auto;
      padding: 0 20px;
      height: 58px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .pub-mark {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      font-family: var(--font-display);
      font-weight: 800;
      font-size: 1.1rem;
      letter-spacing: -0.02em;
    }

    .pub-dot {
      width: 12px;
      height: 12px;
      border-radius: 50%;
      background: var(--accent);
      box-shadow: 10px 0 0 var(--coral), 20px 0 0 var(--mustard);
      margin-right: 22px;
    }

    .top-meta {
      font-family: var(--font-mono);
      font-size: 0.75rem;
      color: var(--muted);
      display: flex;
      align-items: center;
      gap: 16px;
    }

    .top-meta a {
      padding: 8px 4px;
      text-decoration: underline;
      text-underline-offset: 3px;
    }

    /* Hero */
    .hero {
      max-width: 840px;
      margin: 0 auto;
      padding: 52px 20px 36px;
      text-align: center;
    }

    .kicker {
      display: inline-block;
      font-family: var(--font-mono);
      font-size: 0.74rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      padding: 5px 12px;
      border-radius: 999px;
      background: var(--surface);
      border: 1px solid var(--line);
      color: var(--accent);
      margin-bottom: 18px;
    }

    .hero h1 {
      margin: 0;
      font-family: var(--font-display);
      font-size: clamp(2.2rem, 5.5vw, 3.85rem);
      font-weight: 800;
      line-height: 1.07;
      letter-spacing: -0.025em;
    }

    .hero-sub {
      margin: 18px auto 0;
      max-width: 630px;
      font-size: 1.12rem;
      color: var(--muted);
    }

    .hero-byline {
      margin-top: 20px;
      font-family: var(--font-mono);
      font-size: 0.78rem;
      color: var(--muted);
    }

    /* KPI Strip */
    .kpi-strip {
      max-width: 960px;
      margin: 0 auto 36px;
      padding: 0 20px;
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 14px;
    }

    .kpi-card {
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 16px 18px;
    }

    .kpi-val {
      font-family: var(--font-display);
      font-size: clamp(1.6rem, 3vw, 2.2rem);
      font-weight: 800;
      line-height: 1.1;
    }

    .kpi-val.teal { color: var(--accent); }
    .kpi-val.coral { color: var(--coral); }
    .kpi-val.mustard { color: var(--mustard); }

    .kpi-label {
      margin-top: 4px;
      font-size: 0.82rem;
      color: var(--muted);
    }

    /* Inline Editorial Annotations */
    .tag-teal {
      background: rgba(14, 138, 138, 0.14);
      color: #096464;
      padding: 1px 6px;
      border-radius: 4px;
      font-weight: 600;
    }

    .tag-coral {
      background: rgba(224, 90, 71, 0.15);
      color: #B43928;
      padding: 1px 6px;
      border-radius: 4px;
      font-weight: 600;
    }

    .tag-mustard {
      background: rgba(217, 155, 38, 0.18);
      color: #8F620F;
      padding: 1px 6px;
      border-radius: 4px;
      font-weight: 600;
    }

    /* Scrollytelling Interactive Stage */
    .scrolly-wrap {
      max-width: 1200px;
      margin: 0 auto;
      padding: 12px 20px 64px;
      display: grid;
      grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.9fr);
      gap: 28px;
      align-items: start;
    }

    .viz-panel {
      position: sticky;
      top: 74px;
      background: #FFFFFF;
      border: 1px solid var(--line);
      border-radius: 14px;
      padding: 20px;
      box-shadow: 0 8px 28px rgba(30, 30, 36, 0.04);
    }

    .viz-header {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      margin-bottom: 14px;
    }

    .viz-title {
      margin: 0;
      font-family: var(--font-display);
      font-size: 1.2rem;
      font-weight: 700;
    }

    .filter-pills {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 14px;
    }

    .pill-btn {
      min-height: 44px;
      padding: 0 14px;
      border-radius: 999px;
      border: 1px solid var(--line);
      background: var(--canvas);
      font-size: 0.82rem;
      font-weight: 500;
      color: var(--muted);
      transition: all 0.15s ease;
    }

    .pill-btn:hover { border-color: var(--ink); color: var(--ink); }

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

    .chart-box {
      position: relative;
      width: 100%;
    }

    .chart-svg {
      width: 100%;
      height: auto;
      display: block;
      overflow: visible;
    }

    .chart-caption-bar {
      margin-top: 12px;
      padding: 12px 14px;
      background: var(--surface);
      border-radius: 8px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      font-size: 0.84rem;
    }

    .chart-caption-bar strong {
      font-family: var(--font-mono);
      color: var(--accent);
    }

    /* Narrative Step Switcher */
    .steps-col {
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .step-nav-bar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 8px;
    }

    .step-btn {
      min-height: 44px;
      padding: 0 16px;
      border-radius: 8px;
      border: 1px solid var(--line);
      background: var(--surface);
      font-size: 0.84rem;
      font-weight: 600;
    }

    .step-btn:hover { border-color: var(--accent); color: var(--accent); }

    .step-card {
      text-align: left;
      width: 100%;
      background: var(--surface);
      border: 2px solid transparent;
      border-radius: 12px;
      padding: 20px;
      transition: background 0.18s, border-color 0.18s, transform 0.18s;
    }

    .step-card:hover { background: #FFFFFF; }

    .step-card.active {
      background: #FFFFFF;
      border-color: var(--accent);
      box-shadow: 0 6px 20px rgba(14, 138, 138, 0.08);
    }

    .step-num {
      font-family: var(--font-mono);
      font-size: 0.74rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--accent);
      margin-bottom: 6px;
      display: block;
    }

    .step-card h3 {
      margin: 0 0 8px;
      font-family: var(--font-display);
      font-size: 1.25rem;
      line-height: 1.25;
    }

    .step-card p {
      margin: 0;
      font-size: 0.94rem;
      color: var(--muted);
    }

    /* Editorial Closing & Methodology */
    .essay-wrap {
      max-width: 740px;
      margin: 0 auto;
      padding: 12px 20px 72px;
    }

    .essay-wrap h2 {
      font-family: var(--font-display);
      font-size: 1.8rem;
      margin: 1.6em 0 0.6em;
    }

    .essay-wrap p {
      font-size: 1.04rem;
      margin: 0 0 1.3em;
    }

    .method-box {
      margin-top: 32px;
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 22px;
      font-size: 0.88rem;
      color: var(--muted);
    }

    .method-box h3 {
      margin: 0 0 8px;
      font-family: var(--font-mono);
      font-size: 0.8rem;
      text-transform: uppercase;
      color: var(--ink);
    }

    @media (max-width: 920px) {
      .scrolly-wrap { grid-template-columns: 1fr; }
      .viz-panel { position: static; }
    }

    @media (max-width: 640px) {
      .kpi-strip { grid-template-columns: 1fr; }
      .hero { padding: 36px 20px 24px; }
      .top-meta span { display: none; }
    }
  </style>
</head>
<body>
  <header class="topbar">
    <div class="topbar-inner">
      <a href="#" class="pub-mark">
        <span class="pub-dot" aria-hidden="true"></span>
        <span>Visual Essay Lab</span>
      </a>
      <div class="top-meta">
        <span>DATA JOURNALISM · VOL. 09</span>
        <a href="#methodology">Methodology</a>
      </div>
    </div>
  </header>

  <main>
    <section class="hero">
      <span class="kicker">Music Data Analysis · 1975–2025</span>
      <h1>How Song Intros Shrank Across 50 Years of Pop</h1>
      <p class="hero-sub">
        We timed the arrival of the first sung syllable across 5,000 Hot 100 hits. In 1984, listeners waited 23 seconds for a voice. Today, streaming skip economics leave artists less than six.
      </p>
      <div class="hero-byline">By Maya Chen &amp; Jonah Morales · Interactive Dataset</div>
    </section>

    <section class="kpi-strip" aria-label="Key dataset metrics">
      <div class="kpi-card">
        <div class="kpi-val teal" id="kpiPeak">23.4s</div>
        <div class="kpi-label">Peak median intro length (1985)</div>
      </div>
      <div class="kpi-card">
        <div class="kpi-val coral" id="kpiNow">5.8s</div>
        <div class="kpi-label">Current median intro length (2025)</div>
      </div>
      <div class="kpi-card">
        <div class="kpi-val mustard" id="kpiDrop">-75%</div>
        <div class="kpi-label">Compression since the synth era</div>
      </div>
    </section>

    <section class="scrolly-wrap" aria-label="Interactive scrollytelling chart">
      <div class="viz-panel">
        <div class="viz-header">
          <h2 class="viz-title" id="chartHeading">Median Seconds Before First Vocal</h2>
          <span style="font-family:var(--font-mono);font-size:0.74rem;color:var(--muted);">Tap any point to inspect</span>
        </div>

        <div class="filter-pills" role="group" aria-label="Genre filter">
          <button type="button" class="pill-btn active" data-genre="all">All Hot 100</button>
          <button type="button" class="pill-btn" data-genre="pop">Pop</button>
          <button type="button" class="pill-btn" data-genre="hiphop">Hip-Hop</button>
          <button type="button" class="pill-btn" data-genre="rock">Rock / Alt</button>
        </div>

        <div class="chart-box">
          <svg id="introChart" class="chart-svg" viewBox="0 0 600 340" role="img" aria-label="Line chart of song intro lengths from 1975 to 2025"></svg>
        </div>

        <div class="chart-caption-bar" id="chartInspect">
          <span>Click a narrative step or chart node to inspect era details.</span>
          <strong id="inspectVal">1985 · 23.4s</strong>
        </div>
      </div>

      <div class="steps-col">
        <div class="step-nav-bar">
          <button type="button" class="step-btn" id="prevStep">← Prev Step</button>
          <span style="font-family:var(--font-mono);font-size:0.78rem;color:var(--muted);" id="stepCounter">Step 1 / 4</span>
          <button type="button" class="step-btn" id="nextStep">Next Step →</button>
        </div>

        <button type="button" class="step-card active" data-step="0">
          <span class="step-num">01 · 1975–1985 · The FM Ramp</span>
          <h3>Slow Builds &amp; Radio DJ Talk-Ups</h3>
          <p>
            During the <span class="tag-teal">vinyl &amp; FM radio era</span>, long instrumental ramps were functional: DJs talked over the opening 18–25 seconds right up to the vocal "post" without stepping on the chorus.
          </p>
        </button>

        <button type="button" class="step-card" data-step="1">
          <span class="step-num">02 · 1985–1995 · Drum Machine Peak</span>
          <h3>Synthesizer Overatures Hit 23 Seconds</h3>
          <p>
            The mid-1980s marked the <span class="tag-mustard">all-time intro peak</span>. Producers layered gated snare fills, bass ostinatos, and synth brass fanfare before a singer ever entered the mix.
          </p>
        </button>

        <button type="button" class="step-card" data-step="2">
          <span class="step-num">03 · 2000–2015 · The MP3 &amp; Hook Shift</span>
          <h3>The Chorus Moves to the Front Door</h3>
          <p>
            Portable players and 30-second digital previews compressed intros into the <span class="tag-teal">10–14 second band</span>. Songwriters began opening with stripped-back pre-choruses to establish identity fast.
          </p>
        </button>

        <button type="button" class="step-card" data-step="3">
          <span class="step-num">04 · 2016–2025 · The Streaming Cliff</span>
          <h3>Five Seconds to Beat the Skip Button</h3>
          <p>
            Because streaming royalties trigger only after 30 seconds of play, modern pop drops into the <span class="tag-coral">5-second cliff</span>—often starting on beat one with vocals already in motion.
          </p>
        </button>
      </div>
    </section>

    <article class="essay-wrap">
      <h2>What Disappears When the Prelude Vanishes?</h2>
      <p>
        An intro is more than acoustic throat-clearing. In arrangement terms, it establishes tempo, harmonic center, and spatial depth—a musical foyer that lets the listener adjust to a track's room tone before language arrives. When tracks open immediately with a vocal hook, the song behaves less like a short story and more like a billboard seen at highway speed.
      </p>
      <p>
        Yet compression has also bred invention. Producers now pack harmonic tension into two-bar vocal chops, reverse-reverb swells, and micro-intros that announce an artist's sonic signature in under three seconds. The runway has shrunk, but the takeoff has become an art form of its own.
      </p>

      <aside class="method-box" id="methodology">
        <h3>Methodology &amp; Audio Timing Notes</h3>
        <p style="margin:0;">
          We sampled 100 year-end charting singles per year from 1975 through 2025 (5,100 tracks total). Intro duration is measured from first audible audio onset (-48 dBFS) to first lead vocal syllable, excluding non-lexical ad-libs or producer tags. Genre buckets reflect primary Billboard chart classification.
        </p>
      </aside>
    </article>
  </main>

  <script>
    (function () {
      const years = [1975, 1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2020, 2025];
      const seriesData = {
        all:    [19.2, 21.5, 23.4, 20.1, 18.4, 15.8, 13.6, 11.4, 9.2, 6.8, 5.8],
        pop:    [17.5, 20.4, 22.8, 19.2, 16.5, 14.0, 11.8, 9.5, 7.6, 5.4, 4.6],
        hiphop: [16.0, 18.2, 19.6, 18.0, 17.2, 15.4, 13.9, 12.1, 10.4, 8.2, 7.1],
        rock:   [22.4, 24.8, 26.2, 23.5, 21.0, 18.6, 16.4, 14.2, 12.5, 10.1, 8.9]
      };

      const steps = [
        { range: [0, 2], color: '#0E8A8A', note: 'FM DJs talked over 20s+ ramps right up to the vocal post.' },
        { range: [2, 4], color: '#D99B26', note: 'Peak synth & drum-machine preludes averaged over 23s.' },
        { range: [5, 8], color: '#0E8A8A', note: 'Digital downloads & 30s previews pulled intros under 12s.' },
        { range: [8, 10], color: '#E05A47', note: 'Streaming skip rates pushed modern pop to a 5.8s median.' }
      ];

      let currentGenre = 'all';
      let currentStep = 0;

      const svg = document.getElementById('introChart');
      const inspectBar = document.getElementById('chartInspect');
      const kpiPeak = document.getElementById('kpiPeak');
      const kpiNow = document.getElementById('kpiNow');
      const kpiDrop = document.getElementById('kpiDrop');
      const stepCounter = document.getElementById('stepCounter');
      const stepCards = document.querySelectorAll('.step-card');

      const pad = { l: 44, r: 24, t: 24, b: 36 };
      const W = 600, H = 340;
      const plotW = W - pad.l - pad.r;
      const plotH = H - pad.t - pad.b;

      const xScale = i => pad.l + (i / (years.length - 1)) * plotW;
      const yScale = v => pad.t + plotH - (v / 30) * plotH;

      function updateKPIs(vals) {
        const peak = Math.max(...vals);
        const now = vals[vals.length - 1];
        const drop = Math.round(((now - peak) / peak) * 100);
        kpiPeak.textContent = peak.toFixed(1) + 's';
        kpiNow.textContent = now.toFixed(1) + 's';
        kpiDrop.textContent = drop + '%';
      }

      function renderChart() {
        const vals = seriesData[currentGenre];
        updateKPIs(vals);
        const st = steps[currentStep];
        const x1 = xScale(st.range[0]);
        const x2 = xScale(st.range[1]);

        let html = '';

        // Highlighted narrative band
        html += `<rect x="${x1}" y="${pad.t}" width="${Math.max(24, x2 - x1)}" height="${plotH}" fill="${st.color}" fill-opacity="0.11" rx="6"/>`;

        // Horizontal gridlines
        [0, 10, 20, 30].forEach(tick => {
          const y = yScale(tick);
          html += `<line x1="${pad.l}" y1="${y}" x2="${W - pad.r}" y2="${y}" stroke="#E5E0D4" stroke-dasharray="${tick === 0 ? '' : '3 4'}"/>`;
          html += `<text x="${pad.l - 10}" y="${y + 4}" text-anchor="end" font-family="IBM Plex Mono, monospace" font-size="11" fill="#64646E">${tick}s</text>`;
        });

        // X-axis labels
        years.forEach((yr, i) => {
          if (i % 2 === 0) {
            html += `<text x="${xScale(i)}" y="${H - 10}" text-anchor="middle" font-family="IBM Plex Mono, monospace" font-size="11" fill="#64646E">${yr}</text>`;
          }
        });

        // Area fill
        const pts = vals.map((v, i) => `${xScale(i)},${yScale(v)}`);
        const areaD = `M ${xScale(0)},${yScale(0)} L ${pts.join(' L ')} L ${xScale(vals.length - 1)},${yScale(0)} Z`;
        html += `<path d="${areaD}" fill="#0E8A8A" fill-opacity="0.08"/>`;

        // Main polyline
        html += `<polyline points="${pts.join(' ')}" fill="none" stroke="#1E1E24" stroke-width="2.5" stroke-linejoin="round" stroke-linecap="round"/>`;

        // Highlighted segment
        const segPts = vals.slice(st.range[0], st.range[1] + 1).map((v, k) => `${xScale(st.range[0] + k)},${yScale(v)}`);
        html += `<polyline points="${segPts.join(' ')}" fill="none" stroke="${st.color}" stroke-width="4.5" stroke-linecap="round" stroke-linejoin="round"/>`;

        // Interactive data nodes
        vals.forEach((v, i) => {
          const inBand = i >= st.range[0] && i <= st.range[1];
          const cx = xScale(i), cy = yScale(v);
          html += `<circle class="data-node" data-idx="${i}" cx="${cx}" cy="${cy}" r="${inBand ? 6.5 : 4.5}" fill="${inBand ? st.color : '#FFFFFF'}" stroke="${inBand ? '#FFFFFF' : '#1E1E24'}" stroke-width="2" style="cursor:pointer"/>`;
        });

        // Peak annotation
        const focusIdx = st.range[1];
        const fx = xScale(focusIdx), fy = yScale(vals[focusIdx]);
        html += `<text x="${Math.min(W - 60, Math.max(pad.l + 30, fx))}" y="${Math.max(pad.t + 16, fy - 14)}" text-anchor="middle" font-family="IBM Plex Mono, monospace" font-size="11" font-weight="600" fill="${st.color}">${years[focusIdx]}: ${vals[focusIdx].toFixed(1)}s</text>`;

        svg.innerHTML = html;

        // Bind node clicks
        svg.querySelectorAll('.data-node').forEach(node => {
          node.addEventListener('click', () => {
            const idx = Number(node.dataset.idx);
            inspectBar.innerHTML = `<span><strong>${years[idx]}</strong> (${currentGenre.toUpperCase()}) — Median vocal entry at <strong>${vals[idx].toFixed(1)}s</strong>.</span><strong>${vals[idx].toFixed(1)}s</strong>`;
          });
        });

        inspectBar.innerHTML = `<span>${st.note}</span><strong>${years[focusIdx]} · ${vals[focusIdx].toFixed(1)}s</strong>`;
      }

      function setStep(idx) {
        currentStep = (idx + steps.length) % steps.length;
        stepCards.forEach((c, i) => c.classList.toggle('active', i === currentStep));
        stepCounter.textContent = `Step ${currentStep + 1} / ${steps.length}`;
        renderChart();
      }

      stepCards.forEach(card => {
        card.addEventListener('click', () => setStep(Number(card.dataset.step)));
      });

      document.getElementById('prevStep').addEventListener('click', () => setStep(currentStep - 1));
      document.getElementById('nextStep').addEventListener('click', () => setStep(currentStep + 1));

      document.querySelectorAll('.pill-btn').forEach(btn => {
        btn.addEventListener('click', () => {
          document.querySelectorAll('.pill-btn').forEach(b => b.classList.remove('active'));
          btn.classList.add('active');
          currentGenre = btn.dataset.genre;
          renderChart();
        });
      });

      renderChart();
    })();
  </script>
</body>
</html>
```
