# Burn delete

> Hold to delete your account, and the page catches fire from the button and burns away to a black sign-in screen.

A white page asks “Delete your account?” over a dark pill, Hold to delete. Held down, the pill fills with heat from the left; let go early and it drains back. Held to the end, the page catches fire from the pill: a hole with a white-hot rim spreads out, flames climbing from its lower edge and charred flakes flying off its top, until the page is gone and a black screen with drifting embers says your account is gone. Restore my account burns it the other way, back onto the pill.

A React component by Bruno Delorence: https://brunodelorence.com/components/burn-delete. MIT License, Copyright (c) 2026 Bruno Delorence.

Category: Feedback.

## Anatomy

1. **Stage**: The page that burns, 4 : 3. Every length is a number of units from a 1198-unit layout, times one unit in px, from 0.5 to 0.82 by the stage’s width.
2. **Byline**: Who the account belongs to, in 20-unit grey type over the question.
3. **Question**: “Delete your account?” in 50-unit bold, with what goes with it on the line below.
4. **Hold pill**: A dark 258 × 66 pill. Held, it fills from the left with heat, dark red to white-hot at its leading edge, its words turning dark on it.
5. **Heat**: The filled part of the pill: one gradient across the share held so far, clipped at its edge.

## Properties

### Starting screen (`defaultPhase`)

1. **Page (default)**: The question and the hold pill: the account is still there.
2. **Gone**: The black sign-in screen, for an account already deleted and still restorable.

Start on the page. Start on `gone` only when the person comes back to an account deleted earlier, so Restore my account is the first thing they can do.

## When to use

- The last step of deleting an account or a workspace, where the loss is total and the moment deserves weight.
- A destructive action that must not happen by accident: the 1.8 s hold is the confirmation, with no dialog in front of it.
- A launch page, a product tour or a portfolio piece, where the burn is the point.
- A flow that can be undone for a while: the screen it leaves offers Restore my account, which burns the page back.

## When not to use

- Everyday deletes (a file, a message, a row). Use a plain button with an undo toast; a fire for each would wear thin by the third.
- Deletes that can’t be undone at all. The restore is half the story; without it, confirm with a dialog that names what is lost.
- Dense screens where the page under the button holds other work. The burn takes the whole stage with it.
- Pages that must stay calm. Reduced motion turns the burn into a cross-fade, but a quiet confirm dialog is lighter still.

### Holding to confirm

- **1.8 s, linear**, long enough that no click deletes by mistake, short enough not to feel like a chore.
- **Let go early and it drains** three times faster than it filled, so a second try starts where the first left off only for a moment.
- **Space and Enter hold the same way** as a pointer. A key tap, like a short press, says “Delete cancelled”.
- **One press with no hold**, as a screen reader or a switch sends, arms the pill instead: a second press within 5 s deletes.

### The burn

- **It starts at the pill** and spreads unevenly, slow at first and faster as it goes, until it is past the stage’s corners in 5.2 s.
- **The rim is white-hot**, through pink and salmon to an indigo glow on the black; the fire runs deep along the bottom edge, in tongues that climb.
- **Flakes fly off the front**, mostly from its upper half: charred scraps, some with a lit edge, a fifth of them glowing gold.
- **The restore runs it backwards** in 2.4 s onto the pill, the page scorched brown around the shrinking hole, and leaves smoke that clears in 4 s; the pill comes back hot and cools.

## Do’s and don’ts

- **Do**: Say what goes with the account, in numbers: “Your 412 links and 38 collections go with it.”
- **Don’t**: Ask a bare “Are you sure?”. A hold is a confirmation; the words still have to say what is confirmed.
- **Do**: Keep the way back on the screen the burn leaves, and say what it does: Restore my account.
- **Caution**: Keep it for the last, rare step. On a delete people make every day, the fire turns from weight into delay.

## Content

The words are the page’s question, what goes with the account, the pill, and the sign-in screen after.

- **A question that names the thing**: `Delete your account?`, not `Are you sure?`.
- **What is lost, in numbers**, on one line: `Your 412 links and 38 collections go with it.`
- **The pill says the gesture and the act**: `Hold to delete`. Armed by a single press it says `Press again to delete`.
- **After, plain facts**: `Your account is gone.`, and a way back that says what it does: `Restore my account`.

## Installation

Install it with the shadcn CLI, into components/burn-delete of any React project:

```sh
npx shadcn@latest add https://brunodelorence.com/r/burn-delete.json
```

Or add the registry to components.json once, as a namespace that coding agents and the shadcn MCP server search by name:

```json
{
  "registries": {
    "@brunodelorence": "https://brunodelorence.com/r/{name}.json"
  }
}
```

```sh
npx shadcn@latest add @brunodelorence/burn-delete
```

Or copy all the source files below into one folder of your project. Either way it needs React 19.2 and a bundler with CSS Modules (Next.js, Vite).

It has a dark colour scheme. Its colours are CSS light-dark() pairs, kept inside @supports so that builds which rewrite light-dark() for older browsers leave them alone: it follows your page’s color-scheme (light unless the page sets one) or its colorScheme prop, with nothing to configure. Browsers without light-dark() show it light.

## Usage

```tsx
import { BurnDelete } from './burn-delete';

export function DeleteAccount() {
  return (
    <BurnDelete
      name="Ines Navarro"
      onDelete={() => scheduleDeletion()}
      onRestore={() => cancelDeletion()}
      autoplay={false}
    />
  );
}
```

## States

- **Waiting**: The page and its question; the pill is dark and says Hold to delete.
- **Held part way**: Six tenths of the way: the heat has crossed the words, which turn dark on it. Let go now and it drains back three times faster.
- **Armed by a single press**: A screen reader’s or a switch’s press, with no hold, arms the pill: it says Press again to delete for 5 s.
- **Burning**: Half way through the 5.2 s burn: the hole, its white-hot rim and flames, the flakes flying off its top edge, the sign-in screen showing through.
- **Gone**: The screen the burn leaves: black, with drifting embers, Sign in, an email field, Continue and Restore my account.
- **Dark**: With `colorScheme="dark"`: the page turns graphite and the pill light; the burn and the black screen stay as they are.

## How it works

- The hold is 1.8 s and linear; released early, the heat drains three times faster. The heat is one gradient, dark red to white-hot, sized to the share held and clipped at its edge, with the pill’s words in dark ink on it.
- The burn is one fragment shader over the stage: each pixel’s distance from the pill against a radius roughened by two layers of value noise, big slow lobes and a fine flickering jag. That signed distance, in hundredths of the stage, picks every colour.
- Inside the edge, a band of fire from white-hot through pink and salmon to an indigo glow: 3 units deep along the top, up to 28 along the bottom, where it climbs in tongues of noise stretched tall and scrolling up. Past it, black, with sparks drifting up in grid cells.
- Outside the edge, a thin charred line, a pink-white heat haze and soft flames licking up the page above the hole; on the way back, a deeper brown scorch, and smoke that clears in 4.2 s.
- The radius grows from the pill to past the stage’s corners in 5.2 s on t^1.6, slow at first and faster as it goes; a restore shrinks it back onto the pill in 2.4 s, eased in and out, and the pill comes back hot and cools.
- Flakes fly off the front on a 2D canvas, up to 520 at once, mostly from its upper half: six-sided charred scraps, a third of them with a lit edge, a fifth glowing gold, each living one to three seconds, rising, fluttering and spinning.
- The sign-in screen’s words show through the hole as it grows: a radial mask follows the radius. One requestAnimationFrame loop runs it all, only while something moves and the stage is on screen; the WebGL context is asked for only when a burn first needs it.
- While on screen and untouched, a demo pointer holds the pill, waits out the burn and restores the account, in a loop; any input from the reader stops it.

## API reference

- **defaultPhase** (`'idle' | 'gone'`, default `'idle'`): Where it starts: on the page with the hold pill, or on the black screen the burn leaves.
- **onDelete** (`() => void`): Called once the hold completes and the burn starts.
- **onRestore** (`() => void`): Called when Restore my account is pressed.
- **name** (`string`, default `'Ines Navarro'`): The byline over the question: whose account it is.
- **still** (`{ hold: number } | { burn: number } | { armed: true }`): A still for docs and screenshots: the pill held part way, the burn stopped part way (0 to 1), or the pill armed by a single press. It turns the autoplay demo off.
- **autoplay** (`boolean`, default `true`): While on screen and untouched, a demo pointer deletes and restores, in a loop; any input from the reader stops it.
- **colorScheme** (`'light' | 'dark' | 'system'`): Light or dark colours for the page, or the reader’s; without it, the page’s color-scheme. The black screen is the same on both.
- **className** (`string`): A class for the stage.

## Accessibility

### Keyboard

- Tab reaches the pill. Holding Space or Enter fills it like a held pointer; releasing early drains it.
- Once the hold completes, the focus moves to the Sign in heading of the new screen; Tab goes on to the field, Continue and Restore my account.
- After a restore the focus goes back to the pill. The screen not shown is inert: out of the tab order and the accessibility tree.

### Screen readers and switches

- The pill is a button named Hold to delete, described as “Hold for 2 seconds, or press twice, to delete your account”.
- A press with no hold arms it (“Press again to delete your account.”); a second press within 5 s deletes, so nobody has to hold anything.
- A polite live region says what happened: “Delete cancelled”, “Account deleted”, “Account restored”. The canvases are hidden from screen readers.

### Motion

With reduced motion the burn, the flakes and the smoke are left out: the two screens cross-fade in 0.4 s. The heat still fills the pill, since it shows how long is left to hold, and the demo does not play. Without WebGL it falls back to the same cross-fade.

### Colour and contrast

The question is over 15 : 1 on the page in both schemes, and the pill’s words over 15 : 1 on the pill. On the heat the words turn dark with a pale halo under them, so they read over its darkest red as well as its white-hot edge. On the black screen, the heading and Continue are over 15 : 1, and the grey lines and the field’s hint over 4.5 : 1.

### In this build

- The pill is a button named Hold to delete and described as “Hold for 2 seconds, or press twice, to delete your account”. Holding Space or Enter fills it like a held pointer.
- A press with no hold, as a screen reader or a switch sends, arms the pill (“Press again to delete”); a second press within 5 s deletes, so nobody has to hold.
- A polite live region says “Delete cancelled”, “Account deleted” and “Account restored”. After a delete the focus moves to the Sign in heading; after a restore, back to the pill.
- The screen not shown is inert. The email field has a label; both canvases and the demo pointer are hidden from screen readers. Every control shows a focus ring on keyboard focus.
- With reduced motion, or without WebGL, the burn, flakes and smoke are left out and the two screens cross-fade in 0.4 s; the heat still fills the pill, and the demo does not play.

## Source

### burn-delete/burn-delete.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import {
  useEffect,
  useEffectEvent,
  useId,
  useRef,
  useState,
  type FormEvent,
  type KeyboardEvent as ReactKeyboardEvent,
  type PointerEvent as ReactPointerEvent,
} from 'react';
import { createBurn, fullRadius, unitOf, type BurnRenderer } from './burn-gl';
import { createFlakes, type Flakes } from './flakes';
import { DemoPointer, runDemo, type Point } from './demo-pointer';
import { useAutoplay } from './use-autoplay';
import styles from './burn-delete.module.css';

/*
 * Burn delete: a page asks “Delete your account?” over a dark pill, Hold to delete. Held down,
 * the pill fills from the left with heat; let go early and the heat drains back. Held to the
 * end, the page catches fire from the pill: a hole with a white-hot rim, flames and flying
 * flakes spreads out and eats the page, and leaves a black screen with drifting embers: Sign in,
 * your account is gone, and Restore my account, which burns the other way, back to the page.
 *
 * - The hold is 1.8 s, linear; released, the heat drains three times faster. Holding Space or
 *   Enter works the same. A press that comes with no hold at all (a screen reader's activation)
 *   arms the pill instead: a second press within 5 s deletes, so no one has to hold.
 * - The burn is a fragment shader (burn-gl.ts) over the page: a radius roughened by noise,
 *   grown from 0 to past the stage's corners in 5.2 s, slow at first and faster as it goes
 *   (t^1.6); a restore shrinks it back onto the pill in 2.4 s. The dark screen's words are masked
 *   to the hole's middle as it grows. Flakes and embers fly off the front on a 2D canvas.
 * - One requestAnimationFrame loop runs it all, only while something moves and the stage is on
 *   screen; it sleeps otherwise.
 * - Under reduced motion, or without WebGL, the two screens cross-fade in 0.4 s instead.
 * - While on screen and untouched, a demo pointer holds the pill, waits out the burn, and
 *   restores the account, in a loop. The reader's first input stops it for good.
 */

export type BurnPhase = 'idle' | 'burning' | 'gone' | 'restoring';

/** How long the pill is held, how much faster the heat drains, and how long each burn takes. */
const HOLD = 1800;
const DRAIN = 3;
const BURN = 5200;
const RESTORE = 2400;
/** How long the smoke lingers over the page after a restore. */
const SMOKE = 4200;
/** How long a press with no hold keeps the pill armed for a second one. */
const ARMED = 5000;

const burnEase = (t: number) => Math.pow(t, 1.6);
const restoreEase = (t: number) => (t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2);

/** An rgb() colour's grey, 0 to 1. */
const greyOf = (colour: string) => {
  const parts = colour
    .match(/[\d.]+/g)
    ?.slice(0, 3)
    .map(Number) ?? [140, 140, 140];
  return (parts[0] * 0.3 + parts[1] * 0.59 + parts[2] * 0.11) / 255;
};

export function BurnDelete({
  defaultPhase = 'idle',
  still,
  onDelete,
  onRestore,
  name = 'Ines Navarro',
  autoplay = true,
  colorScheme,
  className = '',
}: {
  /** Where it starts: on the page ('idle') or on the screen the burn leaves ('gone'). */
  defaultPhase?: 'idle' | 'gone';
  /**
   * A still for docs and screenshots: the pill held to a share of the way (`hold`, 0 to 1), the
   * burn stopped part way (`burn`, 0 to 1), or the pill armed by a single press (`armed`). It
   * turns the autoplay demo off; the reader's first press lets it go.
   */
  still?: { hold: number } | { burn: number } | { armed: true };
  /** Called once the hold completes and the burn starts. */
  onDelete?: () => void;
  /** Called when Restore my account is pressed. */
  onRestore?: () => void;
  /** The byline over the question. */
  name?: string;
  /** While on screen and untouched, a demo pointer deletes and restores, in a loop. */
  autoplay?: boolean;
  /** Light or dark colours, or the reader's ('system'); without it, the page's color-scheme. */
  colorScheme?: 'light' | 'dark' | 'system';
  className?: string;
}) {
  const { ref: root, playing, take } = useAutoplay<HTMLDivElement>();
  const startPhase: BurnPhase = still && 'burn' in still ? 'burning' : defaultPhase;
  const [phase, setPhase] = useState<BurnPhase>(startPhase);
  const [holding, setHolding] = useState(false);
  const [armed, setArmed] = useState(() => Boolean(still && 'armed' in still));
  const [plain, setPlain] = useState(false);
  const [message, setMessage] = useState('');
  const hintId = useId();
  const emailId = useId();

  const pill = useRef<HTMLButtonElement>(null);
  const heading = useRef<HTMLHeadingElement>(null);
  const gone = useRef<HTMLDivElement>(null);
  const burnCanvas = useRef<HTMLCanvasElement>(null);
  const flakeCanvas = useRef<HTMLCanvasElement>(null);
  const probe = useRef<HTMLSpanElement>(null);
  const pointer = useRef<HTMLSpanElement>(null);

  /** The loop's state, kept out of React: it changes every frame. */
  const run = useRef({
    phase: startPhase as BurnPhase,
    /** The still the stage is held in, until the reader's first press. */
    still: still && !('armed' in still) ? still : null,
    holding: false,
    /** The heat in the pill, 0 to 1. */
    fill: 0,
    /** Set by a key hold, so the click that follows its release isn't taken as an activation. */
    keyHeld: false,
    /** When a pointer last went down on the pill: its click is the end of a hold, not a press. */
    downAt: -Infinity,
    /** When the current burn or restore started, and the radius it started from. */
    start: 0,
    from: 0,
    radius: defaultPhase === 'gone' ? Infinity : 0,
    smoke: 0,
    smokeTone: 0.55,
    origin: { x: 0, y: 0 },
    plain: false,
    visible: false,
    frame: 0,
    last: 0,
    flakesAlive: 0,
    /** Starts the loop if it sleeps. */
    wake: () => {},
  });
  const armTimer = useRef(0);
  /** Set while the demo pointer holds the pill, so its delete isn't announced as the reader's. */
  const demoHolding = useRef(false);

  /** Repeats are made to differ, so screen readers announce them again. */
  const announce = (text: string) => setMessage((now) => (now === text ? `${text} ` : text));

  /** The pill's middle, in the stage's px: where the burn starts and where it ends. */
  const readOrigin = () => {
    const stage = root.current;
    const button = pill.current;
    if (!stage || !button) return;
    const frame = stage.getBoundingClientRect();
    const rect = button.getBoundingClientRect();
    const scale = frame.width / stage.offsetWidth || 1;
    run.current.origin = {
      x: (rect.left + rect.width / 2 - frame.left) / scale,
      y: (rect.top + rect.height / 2 - frame.top) / scale,
    };
  };

  const setLoopPhase = (next: BurnPhase) => {
    run.current.phase = next;
    setPhase(next);
  };

  const ignite = (by: 'reader' | 'demo') => {
    const state = run.current;
    if (state.phase !== 'idle') return;
    state.holding = false;
    // The key that held it is let go on the next screen: no click of its own will follow.
    state.keyHeld = false;
    state.fill = 1;
    setHolding(false);
    setArmed(false);
    window.clearTimeout(armTimer.current);
    readOrigin();
    if (probe.current) state.smokeTone = greyOf(getComputedStyle(probe.current).color);
    state.start = performance.now();
    state.from = 0;
    state.smoke = 0;
    onDelete?.();
    if (state.plain) {
      state.radius = Infinity;
      state.fill = 0;
      setLoopPhase('gone');
    } else {
      setLoopPhase('burning');
    }
    if (by === 'reader') {
      announce('Account deleted. Restore my account brings it back.');
      // The page goes inert; the focus waits on the new screen's heading.
      requestAnimationFrame(() => heading.current?.focus({ preventScroll: true }));
    }
    state.wake();
  };

  const restore = (by: 'reader' | 'demo') => {
    const state = run.current;
    state.still = null;
    if (state.phase !== 'gone' && state.phase !== 'burning') return;
    onRestore?.();
    const stage = root.current;
    readOrigin();
    const full = stage ? fullRadius(stage.offsetWidth, stage.offsetHeight, state.origin) : 0;
    state.from = Math.min(state.radius, full);
    state.start = performance.now();
    if (state.plain) {
      state.radius = 0;
      setLoopPhase('idle');
    } else {
      setLoopPhase('restoring');
    }
    if (by === 'reader') {
      announce('Account restored.');
      requestAnimationFrame(() => pill.current?.focus({ preventScroll: true }));
    }
    state.wake();
  };

  const startHold = () => {
    const state = run.current;
    state.still = null;
    if (state.phase !== 'idle') return;
    state.holding = true;
    setHolding(true);
    state.wake();
  };
  const endHold = (by: 'reader' | 'demo') => {
    const state = run.current;
    if (!state.holding) return;
    state.holding = false;
    setHolding(false);
    if (by === 'reader' && state.phase === 'idle' && state.fill > 0.08) {
      announce('Delete cancelled. Hold to the end to delete.');
    }
    state.wake();
  };

  /** The hold reached the end: called from the loop, with this render's props. */
  const onFull = useEffectEvent(() => ignite(demoHolding.current ? 'demo' : 'reader'));

  // The loop: the heat in the pill, the burn's radius, the flakes and the smoke.
  useEffect(() => {
    const stage = root.current;
    const glCanvas = burnCanvas.current;
    const flakeLayer = flakeCanvas.current;
    const button = pill.current;
    const screen = gone.current;
    if (!stage || !glCanvas || !flakeLayer || !button || !screen) return;
    const state = run.current;
    const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
    let burn: BurnRenderer | null = null;
    let flakes: Flakes | null = null;
    let drawn = false;
    let stillFlakes = false;

    let tried = false;

    const setup = () => {
      state.plain = motion.matches || (tried && !burn);
      setPlain(state.plain);
      if (state.plain && (state.phase === 'burning' || state.phase === 'restoring')) {
        // Mid-burn, a change to reduced motion lands on the burn's end at once.
        const next = state.phase === 'burning' ? 'gone' : 'idle';
        state.radius = next === 'gone' ? Infinity : 0;
        setLoopPhase(next);
      }
    };
    setup();

    // The shader's context is asked for only once a burn needs it: a docs page holds many of
    // these stages, and a browser keeps only about sixteen contexts alive at once.
    const ensureBurn = () => {
      if (burn || tried || state.plain) return;
      tried = true;
      burn = createBurn(glCanvas);
      flakes = createFlakes(flakeLayer);
      if (!burn) setup();
    };
    const onLost = (event: Event) => {
      event.preventDefault();
      burn = null;
      tried = true;
      setup();
    };
    glCanvas.addEventListener('webglcontextlost', onLost);

    const frame = (now: number) => {
      state.frame = 0;
      if (state.phase !== 'idle' || state.smoke > 0) ensureBurn();
      const dt = Math.min(0.05, (now - (state.last || now)) / 1000);
      state.last = now;
      const width = stage.offsetWidth;
      const height = stage.offsetHeight;
      const unit = unitOf(width, height);

      // The heat in the pill.
      const held = state.still;
      if (held && 'hold' in held) state.fill = held.hold;
      else if (state.phase === 'idle') {
        if (state.holding) state.fill = Math.min(1, state.fill + (dt * 1000) / HOLD);
        else state.fill = Math.max(0, state.fill - (dt * 1000 * DRAIN) / HOLD);
      }
      button.style.setProperty('--fill', state.fill.toFixed(4));
      if (state.phase === 'idle' && state.holding && state.fill >= 1) {
        onFull();
      }

      // The burn's radius.
      const full = fullRadius(width, height, state.origin);
      if (held && 'burn' in held) {
        state.radius = full * burnEase(held.burn);
        state.fill = 1;
      } else if (state.phase === 'burning') {
        const t = Math.min(1, (now - state.start) / BURN);
        state.radius = full * burnEase(t);
        if (t >= 1) {
          state.radius = Infinity;
          state.fill = 0;
          setLoopPhase('gone');
        }
      } else if (state.phase === 'restoring') {
        const span = RESTORE * Math.max(0.35, state.from / full);
        const t = Math.min(1, (now - state.start) / span);
        state.radius = state.from * (1 - restoreEase(t));
        state.smoke = Math.max(state.smoke, restoreEase(t));
        if (t >= 1) {
          state.radius = 0;
          // The pill comes back still hot, and cools.
          state.fill = 1;
          setLoopPhase('idle');
        }
      } else if (state.phase === 'idle') {
        state.smoke = Math.max(0, state.smoke - (dt * 1000) / SMOKE);
      }

      // The dark screen's words show through the hole's middle while it moves.
      const moving = state.phase === 'burning' || state.phase === 'restoring';
      if (moving) {
        const rx = Math.max(0, state.radius * 0.72 - unit * 4);
        const mask = `radial-gradient(ellipse ${rx}px ${rx / 1.14}px at ${state.origin.x}px ${state.origin.y}px, #000 75%, transparent 100%)`;
        screen.style.maskImage = mask;
        screen.style.webkitMaskImage = mask;
      } else {
        screen.style.maskImage = '';
        screen.style.webkitMaskImage = '';
      }

      // The shader, while there is anything to draw.
      if (burn && !state.plain) {
        if (state.radius > 0 || state.smoke > 0) {
          burn.draw({
            width,
            height,
            origin: state.origin,
            radius: Math.min(state.radius, full * 1.2),
            // A still is drawn at one fixed moment, so it looks the same every time.
            time: held ? 12.3 : now / 1000,
            smoke: state.smoke,
            smokeTone: state.smokeTone,
            scorch: state.phase === 'restoring' || state.phase === 'idle' ? 1 : 0,
          });
          drawn = true;
        } else if (drawn) {
          burn.clear();
          drawn = false;
        }
      }

      // The flakes, thrown from the front while it is on the stage.
      if (flakes && !state.plain) {
        if (moving && state.radius * 0.72 < full * 0.72 - unit * 10) {
          const rate = state.phase === 'burning' ? 220 : 160;
          const count = Math.floor(dt * rate + Math.random());
          if (state.radius > unit * 3) flakes.emit(count, state.origin, state.radius, unit);
        }
        if (held && 'burn' in held && !stillFlakes) {
          // A still's flakes: a second and a half of them, thrown and flown at once.
          stillFlakes = true;
          for (let i = 0; i < 90; i += 1) {
            flakes.emit(4, state.origin, state.radius, unit);
            flakes.step(1 / 60, width, height);
          }
        }
        state.flakesAlive = held ? 0 : flakes.step(dt, width, height);
      }

      const busy =
        (!held && state.fill > 0) ||
        state.holding ||
        (moving && !held) ||
        state.phase === 'gone' ||
        state.smoke > 0 ||
        state.flakesAlive > 0;
      if (busy && state.visible && !document.hidden) {
        state.frame = requestAnimationFrame(frame);
      } else {
        state.last = 0;
      }
    };

    state.wake = () => {
      if (state.frame) return;
      state.last = 0;
      state.frame = requestAnimationFrame(frame);
    };

    const observer = new IntersectionObserver(([entry]) => {
      state.visible = entry.isIntersecting;
      if (state.visible) state.wake();
    });
    observer.observe(stage);
    const resize = new ResizeObserver(() => {
      if (state.phase === 'idle' || state.phase === 'gone') readOrigin();
      state.wake();
    });
    resize.observe(stage);
    const onVisibility = () => state.wake();
    document.addEventListener('visibilitychange', onVisibility);
    const onMotion = () => {
      setup();
      state.wake();
    };
    motion.addEventListener('change', onMotion);
    readOrigin();

    return () => {
      observer.disconnect();
      resize.disconnect();
      document.removeEventListener('visibilitychange', onVisibility);
      motion.removeEventListener('change', onMotion);
      glCanvas.removeEventListener('webglcontextlost', onLost);
      cancelAnimationFrame(state.frame);
      state.frame = 0;
      state.wake = () => {};
      burn?.dispose();
    };
    // The loop reads refs; ignite and setLoopPhase only touch refs and setters.
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [root]);

  useEffect(() => () => window.clearTimeout(armTimer.current), []);

  // Without the shader, the two screens cross-fade in 0.4 s instead.
  const shownPhase = useRef(phase);
  useEffect(() => {
    const screen = gone.current;
    const before = shownPhase.current;
    shownPhase.current = phase;
    if (!plain || !screen || before === phase) return;
    const show = phase === 'gone';
    if (show === (before === 'gone' || before === 'burning')) return;
    const fade = screen.animate(
      [
        { opacity: show ? 0 : 1, visibility: 'visible' },
        { opacity: show ? 1 : 0, visibility: 'visible' },
      ],
      { duration: 400, easing: 'ease' },
    );
    return () => fade.cancel();
  }, [phase, plain]);

  // The reader's hold: the pointer down on the pill, or Space or Enter held on it.
  const onPillDown = (event: ReactPointerEvent<HTMLButtonElement>) => {
    if (event.button !== 0) return;
    event.currentTarget.setPointerCapture(event.pointerId);
    run.current.keyHeld = false;
    run.current.downAt = performance.now();
    startHold();
  };
  const onPillUp = () => endHold('reader');
  const onPillKeyDown = (event: ReactKeyboardEvent<HTMLButtonElement>) => {
    if (event.key !== ' ' && event.key !== 'Enter') return;
    event.preventDefault();
    if (event.repeat) return;
    run.current.keyHeld = true;
    startHold();
  };
  const onPillKeyUp = (event: ReactKeyboardEvent<HTMLButtonElement>) => {
    if (event.key !== ' ' && event.key !== 'Enter') return;
    event.preventDefault();
    endHold('reader');
    // The click a released key may still send is not an activation of its own.
    window.setTimeout(() => {
      run.current.keyHeld = false;
    }, 0);
  };
  // A click with no hold before it (no pointer down on the pill, no key held): a screen reader or
  // a switch. The first one arms the pill, a second one within 5 s deletes.
  const onPillClick = () => {
    const state = run.current;
    if (state.keyHeld || performance.now() - state.downAt < 4000) {
      state.keyHeld = false;
      return;
    }
    if (armed) {
      ignite('reader');
      return;
    }
    setArmed(true);
    announce('Press again to delete your account.');
    window.clearTimeout(armTimer.current);
    armTimer.current = window.setTimeout(() => setArmed(false), ARMED);
  };

  const onContinue = (event: FormEvent) => {
    event.preventDefault();
    announce('There is no account to sign in to. Restore it first.');
  };

  // The demo: the pointer holds the pill to the end, waits out the burn, restores, and again.
  const demoAct = useEffectEvent((act: 'press' | 'release' | 'restore') => {
    if (act === 'press') {
      demoHolding.current = true;
      startHold();
    } else if (act === 'release') {
      if (!demoHolding.current) return;
      demoHolding.current = false;
      endHold('demo');
    } else restore('demo');
  });
  const demo = autoplay && !still && playing;
  useEffect(() => {
    const stage = root.current;
    const arrow = pointer.current;
    if (!demo || !stage || !arrow) return;
    const stop = runDemo(stage, arrow, async ({ wait, glide, glyph }) => {
      /** The middle of `element`, a little low and right, in the stage's px. */
      const on = (element: Element | null): Point => {
        const frame = stage.getBoundingClientRect();
        const scale = frame.width / stage.offsetWidth || 1;
        const rect = element?.getBoundingClientRect() ?? frame;
        return {
          x: (rect.left + rect.width * 0.56 - frame.left) / scale,
          y: (rect.top + rect.height * 0.62 - frame.top) / scale,
        };
      };
      const rest = () => ({ x: stage.offsetWidth * 0.62, y: stage.offsetHeight * 0.8 });
      await glide(rest(), 700);
      for (;;) {
        if (run.current.phase === 'idle') {
          await wait(1200);
          await glide(on(pill.current), 760);
          glyph('hand');
          await wait(260);
          demoAct('press');
          await wait(HOLD + 120);
          demoAct('release');
          await wait(400);
          glyph('arrow');
          await glide(rest(), 900);
          await wait(BURN + 2600);
        }
        await glide(on(stage.querySelector('[data-part="restore"]')), 900);
        glyph('hand');
        await wait(400);
        demoAct('restore');
        await wait(300);
        glyph('arrow');
        await glide(rest(), 900);
        await wait(RESTORE + 1200);
      }
    });
    return () => {
      stop();
      demoAct('release');
    };
  }, [demo, root]);

  const side = phase === 'burning' || phase === 'gone' ? 'gone' : 'page';

  return (
    <div
      ref={root}
      className={`${styles.root} ${className}`}
      data-part="stage"
      data-phase={phase}
      data-plain={plain}
      data-color-scheme={colorScheme}
      onPointerDownCapture={take}
      onKeyDownCapture={take}
      onPointerMove={(event) => {
        if (event.pointerType !== 'touch') take();
      }}
    >
      <div className={styles.page} data-part="page" inert={side !== 'page'}>
        <div className={styles.column}>
          <p className={styles.byline} data-part="byline">
            {name}
          </p>
          <h2 className={styles.title} data-part="title">
            Delete your account?
          </h2>
          <p className={styles.lead}>Your 412 links and 38 collections go with it.</p>
          <button
            ref={pill}
            type="button"
            className={styles.hold}
            data-part="hold"
            data-holding={holding}
            aria-describedby={hintId}
            onPointerDown={onPillDown}
            onPointerUp={onPillUp}
            onPointerCancel={onPillUp}
            onLostPointerCapture={onPillUp}
            onKeyDown={onPillKeyDown}
            onKeyUp={onPillKeyUp}
            onBlur={() => endHold('reader')}
            onClick={onPillClick}
            onContextMenu={(event) => event.preventDefault()}
          >
            <span className={styles.holdText}>
              {armed ? 'Press again to delete' : 'Hold to delete'}
            </span>
            <span className={styles.heat} data-part="heat" aria-hidden="true">
              <span className={styles.holdText}>
                {armed ? 'Press again to delete' : 'Hold to delete'}
              </span>
            </span>
          </button>
          <span id={hintId} className={styles.hidden}>
            Hold for 2 seconds, or press twice, to delete your account.
          </span>
        </div>
      </div>

      <canvas ref={burnCanvas} className={styles.burn} aria-hidden="true" />

      <div ref={gone} className={styles.gone} data-part="gone" inert={side !== 'gone'}>
        <div className={styles.column}>
          <h2 ref={heading} className={styles.signIn} tabIndex={-1}>
            Sign in
          </h2>
          <p className={styles.goneLead}>Your account is gone.</p>
          <form className={styles.form} onSubmit={onContinue}>
            <label htmlFor={emailId} className={styles.hidden}>
              Email
            </label>
            <input
              id={emailId}
              className={styles.field}
              data-part="email"
              type="email"
              name="email"
              placeholder="Email"
              autoComplete="email"
            />
            <button type="submit" className={styles.cta} data-part="continue">
              Continue
            </button>
            <button
              type="button"
              className={styles.restore}
              data-part="restore"
              onClick={() => restore('reader')}
            >
              Restore my account
            </button>
          </form>
        </div>
      </div>

      <canvas ref={flakeCanvas} className={styles.flakes} aria-hidden="true" />
      <span
        ref={probe}
        className={styles.hidden}
        style={{ color: 'var(--smoke)' }}
        aria-hidden="true"
      />

      <p className={styles.hidden} aria-live="polite">
        {message}
      </p>
      <div className={styles.pointerLayer} aria-hidden="true">
        <DemoPointer
          ref={pointer}
          className={styles.pointer}
          arrowClass={styles.arrow}
          handClass={styles.hand}
        />
      </div>
    </div>
  );
}
```

### burn-delete/burn-delete.module.css

```css
/* Burn delete (burn-delete.tsx): a page that asks to delete your account, its dark pill held
   down to confirm; then the page burns away from the pill and leaves a black sign-in screen.

   Layers, bottom to top: the page; the burn canvas (the hole, its rim and flames, the dark
   screen's embers); the dark screen's words and fields, masked to the hole while it grows; the
   flakes canvas; the demo pointer.

   Sizes. Every length is a number of design units times --k, the px of one unit: the reference
   layout is 1198 units square, the pill 258 × 66, the heading 50. --k follows the stage's width
   (a container query unit), from 0.5 to 0.82 px.

   Colours are the tokens below, light-dark(light, dark) where the two differ: the page is white
   by day and graphite by night, its pill inverted; the screen the burn leaves is black on both.
   The burn's own colours live in the shader (burn-gl.ts). */

.root {
  /* The page. */
  --page: #fbfbfb;
  --line: rgb(0 0 0 / 0.06);
  --ink: #141416;
  --ink-soft: #6b6b70;
  --pill: #161618;
  --pill-ink: #fff;
  --pill-edge: rgb(0 0 0 / 0.12);
  /* The burnt pill's ink, dark on the heat whatever the scheme. */
  --heat-ink: #1a0905;
  /* The smoke the page is left with; read by the script for the shader. */
  --smoke: #8a8a8e;
  /* The screen the burn leaves: the same on both schemes. */
  --gone: #000;
  --gone-ink: #f4f4f5;
  --gone-soft: #8d8d93;
  --field: #18181b;
  --field-edge: rgb(255 255 255 / 0.06);
  --field-ink: #f4f4f5;
  --field-hint: #8a8a90;
  --cta: #f7f7f8;
  --cta-ink: #0b0b0c;
  --focus: #387bff;
  --pointer: #1c1c1e;
  --pointer-edge: #fff;
  --pointer-shadow: rgb(0 0 0 / 0.25);
  --k: clamp(0.5px, 100cqi / 1300, 0.82px);
  position: relative;
  container-type: inline-size;
  contain: layout paint;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 460px;
  max-height: 680px;
  overflow: hidden;
  overflow: clip;
  border-radius: 18px;
  background: var(--page);
  box-shadow: inset 0 0 0 1px var(--line);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
@supports (color: light-dark(#fff, #000)) {
  .root {
    --page: light-dark(#fbfbfb, #1b1b1e);
    --line: light-dark(rgb(0 0 0 / 0.06), rgb(255 255 255 / 0.07));
    --ink: light-dark(#141416, #f2f2f3);
    --ink-soft: light-dark(#6b6b70, #9a9aa0);
    --pill: light-dark(#161618, #f2f2f3);
    --pill-ink: light-dark(#fff, #121214);
    --pill-edge: light-dark(rgb(0 0 0 / 0.12), rgb(255 255 255 / 0.2));
    --smoke: light-dark(#8a8a8e, #c4c4c8);
  }
}
.root[data-color-scheme='light'] {
  color-scheme: light;
}
.root[data-color-scheme='dark'] {
  color-scheme: dark;
}
.root[data-color-scheme='system'] {
  color-scheme: light dark;
}

/* Both screens: their words in a column, centred on the stage. */
.page,
.gone {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
}
.column {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: calc(560 * var(--k));
  text-align: center;
}

/* The page. */
.byline {
  margin: 0;
  color: var(--ink-soft);
  font-size: max(12px, calc(20 * var(--k)));
  line-height: 1.3;
}
.title {
  margin: calc(14 * var(--k)) 0 0;
  color: var(--ink);
  font-size: calc(50 * var(--k));
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.lead {
  margin: calc(14 * var(--k)) 0 0;
  color: var(--ink-soft);
  font-size: max(13px, calc(21 * var(--k)));
  line-height: 1.35;
  text-wrap: balance;
}

/* The pill held to delete: dark, and filled from the left with heat while it is held. */
.hold {
  position: relative;
  display: grid;
  place-items: center;
  min-width: calc(258 * var(--k));
  min-height: max(40px, calc(66 * var(--k)));
  margin-top: calc(36 * var(--k));
  padding: 0 calc(40 * var(--k));
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--pill);
  box-shadow: inset 0 0 0 1px var(--pill-edge);
  color: var(--pill-ink);
  font: inherit;
  font-size: max(14px, calc(20 * var(--k)));
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  transition: transform 160ms ease;
}
.hold[data-holding='true'] {
  transform: scale(0.97);
}
.hold:focus-visible,
.field:focus-visible,
.cta:focus-visible,
.restore:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
.holdText {
  position: relative;
  white-space: nowrap;
}
/* The heat: the whole ramp spans the filled part, white-hot at its leading edge. */
.heat {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(
    90deg,
    #4f0904 0%,
    #9c1a08 28%,
    #d9420d 55%,
    #f38a2c 80%,
    #fcd27a 95%,
    #fff1c8 100%
  );
  background-size: calc(var(--fill, 0) * 100%) 100%;
  background-repeat: no-repeat;
  color: var(--heat-ink);
  /* A pale halo under the dark words, so they read over the darkest red too. */
  text-shadow:
    0 0 calc(6 * var(--k)) rgb(255 226 170 / 0.9),
    0 0 calc(14 * var(--k)) rgb(255 210 150 / 0.7);
  clip-path: inset(0 calc(100% - var(--fill, 0) * 100%) 0 0);
  pointer-events: none;
}

/* The screen the burn leaves. Its words come in through the hole: the script masks it to the
   hole's middle while it grows. */
.gone {
  visibility: hidden;
}
.root[data-phase='burning'] .gone,
.root[data-phase='gone'] .gone,
.root[data-phase='restoring'] .gone {
  visibility: visible;
}
.signIn {
  margin: 0;
  color: var(--gone-ink);
  font-size: calc(44 * var(--k));
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  outline: none;
}
.goneLead {
  margin: calc(16 * var(--k)) 0 0;
  color: var(--gone-soft);
  font-size: max(13px, calc(18 * var(--k)));
  line-height: 1.35;
}
.form {
  display: flex;
  flex-direction: column;
  width: min(100%, calc(480 * var(--k)));
  gap: calc(14 * var(--k));
  margin-top: calc(48 * var(--k));
}
.field,
.cta {
  box-sizing: border-box;
  width: 100%;
  min-height: max(40px, calc(64 * var(--k)));
  border-radius: 999px;
  font: inherit;
  font-size: max(14px, calc(18 * var(--k)));
  text-align: center;
}
.field {
  padding: 0 calc(24 * var(--k));
  border: 0;
  background: var(--field);
  box-shadow: inset 0 0 0 1px var(--field-edge);
  color: var(--field-ink);
}
.field::placeholder {
  color: var(--field-hint);
}
.cta {
  border: 0;
  background: var(--cta);
  color: var(--cta-ink);
  font-weight: 500;
  cursor: pointer;
}
.restore {
  align-self: center;
  margin-top: calc(34 * var(--k));
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--gone-soft);
  font: inherit;
  font-size: max(13px, calc(16 * var(--k)));
  cursor: pointer;
}
.restore:hover {
  color: var(--gone-ink);
}

.burn,
.flakes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Without the shader (reduced motion, or no WebGL): the screens cross-fade in 0.4 s, played by
   the script with the Web Animations API (the site turns CSS transitions off under reduced
   motion; a fade this short and soft is what replaces the burn there). */
.root[data-plain='true'] .gone {
  background: var(--gone);
}
.root[data-plain='true'] .burn,
.root[data-plain='true'] .flakes {
  display: none;
}

/* The demo pointer, over everything; one of its glyphs shows at a time. */
.pointerLayer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.pointer {
  width: clamp(20px, calc(34 * var(--k)), 28px);
  height: clamp(20px, calc(34 * var(--k)), 28px);
}
.hand {
  visibility: hidden;
}
.pointer[data-glyph='hand'] .arrow {
  visibility: hidden;
}
.pointer[data-glyph='hand'] .hand {
  visibility: visible;
}

.hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .hold {
    transition: none;
  }
}
```

### burn-delete/burn-gl.ts

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

/*
 * The burn, drawn by one fragment shader over the whole stage. Every pixel asks how far it is
 * from the burn's origin (the button), against a radius roughened by two layers of value noise:
 * big slow lobes, so the hole grows unevenly, and a fine jag that flickers, so its edge looks
 * torn. That signed distance f, in units of a hundredth of the stage, decides everything:
 *
 * - f < 0, burnt: first a band of fire, white-hot at the edge through pink and salmon to an
 *   indigo glow, 2 units deep along the top and up to 26 along the bottom, where it rises in
 *   tongues (noise stretched tall, scrolling up); past it, black.
 * - f > 0, the page still standing: a thin charred line on the edge, a scorched brown band
 *   (deeper as the page is restored), a white and pink heat haze, and soft flames licking up
 *   the page above the hole.
 * - Far inside, the dark screen's fine embers: a grid of cells, one spark in some of them,
 *   drifting up and twinkling.
 * - Out of the burn, the grey smoke the page is left with after a restore, fading away.
 *
 * It writes premultiplied alpha, so the page under the canvas shows wherever nothing is drawn.
 */

const VERTEX = `
attribute vec2 a;
void main() { gl_Position = vec4(a, 0.0, 1.0); }
`;

const FRAGMENT = `
precision highp float;
uniform vec2 uRes;      // the stage, css px
uniform float uDpr;
uniform vec2 uOrigin;   // css px, y down
uniform float uRadius;  // css px
uniform float uUnit;    // css px in a unit: a hundredth of the stage's shorter side
uniform float uTime;
uniform float uSmoke;
uniform float uSmokeTone;
uniform float uScorch;   // 0 on the way out, 1 on the way back

float hash(vec2 p) {
  p = fract(p * vec2(123.34, 456.21));
  p += dot(p, p + 45.32);
  return fract(p.x * p.y);
}
float noise(vec2 p) {
  vec2 i = floor(p);
  vec2 f = fract(p);
  vec2 u = f * f * (3.0 - 2.0 * f);
  return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),
             mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0)), u.x), u.y);
}
float fbm(vec2 p) {
  float v = 0.0;
  float a = 0.5;
  for (int i = 0; i < 4; i++) {
    v += a * noise(p);
    p = p * 2.03 + 17.1;
    a *= 0.5;
  }
  return v;
}
// The fire, from where it meets the black (0) to the white-hot edge (1).
vec3 flameRamp(float t) {
  vec3 c = mix(vec3(0.0), vec3(0.2, 0.15, 0.62), smoothstep(0.0, 0.14, t));
  c = mix(c, vec3(0.92, 0.3, 0.42), smoothstep(0.1, 0.35, t));
  c = mix(c, vec3(1.0, 0.66, 0.74), smoothstep(0.32, 0.6, t));
  return mix(c, vec3(1.0, 0.98, 0.98), smoothstep(0.55, 0.85, t));
}
float sparks(vec2 p, float cell, float speed, float seed) {
  vec2 g = p / cell + vec2(seed, uTime * speed);
  vec2 id = floor(g);
  vec2 fr = fract(g) - 0.5;
  float h = hash(id + seed);
  vec2 off = vec2(hash(id + 3.1), hash(id + 7.7)) - 0.5;
  float d = length((fr - off * 0.7) * cell);
  float on = step(0.55, h);
  float twinkle = 0.45 + 0.55 * sin(uTime * (1.5 + h * 3.0) + h * 40.0);
  return on * twinkle * smoothstep(1.4, 0.2, d);
}

void main() {
  vec2 p = vec2(gl_FragCoord.x, uRes.y * uDpr - gl_FragCoord.y) / uDpr;
  vec2 q = p / uUnit;
  vec2 d = p - uOrigin;
  // The hole is a little wider than it is tall, as in a page held upright.
  d.y *= 1.14;
  float r = length(d);
  float lobes = fbm(q * 0.045 + vec2(0.0, uTime * 0.04));
  float jag = fbm(q * 0.38 - vec2(0.0, uTime * 0.5));
  float grown = smoothstep(0.0, 12.0 * uUnit, uRadius);
  float edge = uRadius * (0.72 + 0.56 * lobes) + (jag - 0.5) * 3.2 * uUnit * grown;
  float f = (r - edge) / uUnit;
  // 1 below the origin, less above: the flames climb from the hole's lower lip.
  float below = smoothstep(-0.4, 0.5, d.y / max(r, 1.0));
  float above = 1.0 - smoothstep(-0.5, 0.3, d.y / max(r, 1.0));

  vec3 col = vec3(0.0);
  float alpha = 0.0;

  if (uRadius > 0.5) {
    // The fire's band inside the edge: thin along the top, deep along the bottom, where tongues
    // of it climb into the hole (noise stretched tall and scrolling up).
    float tongues = fbm(vec2(q.x * 0.075, q.y * 0.03 + uTime * 0.32));
    float band = mix(3.0, 4.0 + 24.0 * smoothstep(0.3, 0.66, tongues), below) * grown;
    if (f < 0.0) {
      float depth = -f;
      float h = 1.0 - depth / max(band, 0.001);
      if (h > 0.0) {
        col = flameRamp(h);
      } else {
        // Past the fire: black, an indigo glow just beyond it, and the drifting embers.
        col = vec3(0.24, 0.2, 0.8) * exp(h * band / 2.4) * 0.55;
        float dust = sparks(p, 26.0, 0.12, 0.0) * 0.7 + sparks(p, 41.0, 0.07, 9.0);
        float sparkTone = hash(floor(p / 26.0));
        col += dust * mix(vec3(0.55, 0.55, 0.6), vec3(1.0, 0.78, 0.4), step(0.7, sparkTone))
               * smoothstep(0.0, 3.0, -h * band);
      }
      alpha = 1.0;
    } else {
      // Still standing: a thin charred line on the edge, a scorched band (deeper on the way
      // back), a white and pink heat haze, and flames licking up the page above the hole.
      float charLine = exp(-abs(f - 0.5) / 0.35) * (0.5 + 0.5 * jag) * 0.85;
      float scorch = exp(-f / (1.5 + 3.0 * uScorch)) * (0.4 + 0.6 * jag) * (0.3 + 0.6 * uScorch);
      float halo = exp(-f / 3.2) * 0.85;
      float fl = fbm(vec2(q.x * 0.12, q.y * 0.045 + uTime * 0.7));
      float lick = smoothstep(0.42, 0.8, fl) * exp(-f / 5.0) * above * step(f, 30.0);
      vec4 acc = vec4(vec3(0.5, 0.25, 0.08) * scorch, scorch);
      vec4 hz = vec4(vec3(1.0, 0.82, 0.88) * halo, halo);
      acc = hz + acc * (1.0 - hz.a);
      vec4 lk = vec4(mix(vec3(0.78, 0.7, 1.0), vec3(1.0, 0.72, 0.85), fl) * lick, lick);
      acc = lk + acc * (1.0 - lk.a);
      vec4 ch = vec4(vec3(0.3, 0.14, 0.05) * charLine, charLine);
      acc = ch + acc * (1.0 - ch.a);
      col = acc.rgb;
      alpha = acc.a;
    }
  }

  // The smoke left over the page: soft grey wisps, outside the hole.
  if (uSmoke > 0.001 && f > 0.0) {
    float s = fbm(vec2(q.x * 0.035, q.y * 0.022 + uTime * 0.08));
    float wisp = smoothstep(0.45, 0.8, s) * uSmoke * 0.2;
    vec4 sm = vec4(vec3(uSmokeTone) * wisp, wisp);
    col = sm.rgb + col * (1.0 - sm.a);
    alpha = sm.a + alpha * (1.0 - sm.a);
  }

  gl_FragColor = vec4(col, alpha);
}
`;

export type BurnFrame = {
  width: number;
  height: number;
  origin: { x: number; y: number };
  radius: number;
  time: number;
  smoke: number;
  /** The smoke's grey: darker over a light page, lighter over a dark one. */
  smokeTone: number;
  /** How burnt the page around the hole looks: 0 as it burns, 1 as it is restored. */
  scorch: number;
};

export type BurnRenderer = {
  draw: (frame: BurnFrame) => void;
  clear: () => void;
  dispose: () => void;
};

/** The px a burn unit is on a stage this size: a hundredth of its shorter side. */
export const unitOf = (width: number, height: number) => Math.min(width, height) / 100;

/** How far the radius must go to burn the whole stage, its noisy edge included. */
export function fullRadius(width: number, height: number, origin: { x: number; y: number }) {
  const far = Math.max(
    Math.hypot(origin.x, origin.y * 1.14),
    Math.hypot(width - origin.x, origin.y * 1.14),
    Math.hypot(origin.x, (height - origin.y) * 1.14),
    Math.hypot(width - origin.x, (height - origin.y) * 1.14),
  );
  // The smallest the lobes make the edge is 0.72 of the radius; past that, the flames' reach.
  return far / 0.72 + unitOf(width, height) * 22;
}

/** Sets up the shader on `canvas`, or returns null where WebGL isn't there. */
export function createBurn(canvas: HTMLCanvasElement): BurnRenderer | null {
  const gl = canvas.getContext('webgl', { premultipliedAlpha: true, antialias: false });
  if (!gl) return null;
  const compile = (type: number, source: string) => {
    const shader = gl.createShader(type);
    if (!shader) return null;
    gl.shaderSource(shader, source);
    gl.compileShader(shader);
    return gl.getShaderParameter(shader, gl.COMPILE_STATUS) ? shader : null;
  };
  const vs = compile(gl.VERTEX_SHADER, VERTEX);
  const fs = compile(gl.FRAGMENT_SHADER, FRAGMENT);
  const program = gl.createProgram();
  if (!vs || !fs || !program) return null;
  gl.attachShader(program, vs);
  gl.attachShader(program, fs);
  gl.linkProgram(program);
  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) return null;
  gl.useProgram(program);

  // One triangle that covers the viewport.
  const buffer = gl.createBuffer();
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
  const a = gl.getAttribLocation(program, 'a');
  gl.enableVertexAttribArray(a);
  gl.vertexAttribPointer(a, 2, gl.FLOAT, false, 0, 0);

  const u = (name: string) => gl.getUniformLocation(program, name);
  const loc = {
    res: u('uRes'),
    dpr: u('uDpr'),
    origin: u('uOrigin'),
    radius: u('uRadius'),
    unit: u('uUnit'),
    time: u('uTime'),
    smoke: u('uSmoke'),
    smokeTone: u('uSmokeTone'),
    scorch: u('uScorch'),
  };

  // A burn has soft edges everywhere: up to 1.5 device px per css px is plenty, and cheaper.
  const dpr = () => Math.min(window.devicePixelRatio || 1, 1.5);

  const fit = (width: number, height: number) => {
    const k = dpr();
    const w = Math.max(1, Math.round(width * k));
    const h = Math.max(1, Math.round(height * k));
    if (canvas.width !== w || canvas.height !== h) {
      canvas.width = w;
      canvas.height = h;
    }
    gl.viewport(0, 0, w, h);
    return k;
  };

  return {
    draw(frame) {
      const k = fit(frame.width, frame.height);
      gl.uniform2f(loc.res, frame.width, frame.height);
      gl.uniform1f(loc.dpr, canvas.width / frame.width || k);
      gl.uniform2f(loc.origin, frame.origin.x, frame.origin.y);
      gl.uniform1f(loc.radius, frame.radius);
      gl.uniform1f(loc.unit, unitOf(frame.width, frame.height));
      gl.uniform1f(loc.time, frame.time);
      gl.uniform1f(loc.smoke, frame.smoke);
      gl.uniform1f(loc.smokeTone, frame.smokeTone);
      gl.uniform1f(loc.scorch, frame.scorch);
      gl.drawArrays(gl.TRIANGLES, 0, 3);
    },
    clear() {
      gl.clearColor(0, 0, 0, 0);
      gl.clear(gl.COLOR_BUFFER_BIT);
    },
    // The context stays with the canvas (a remount asks it for the same one again): only what
    // was made for it goes.
    dispose() {
      gl.deleteBuffer(buffer);
      gl.deleteProgram(program);
      gl.deleteShader(vs);
      gl.deleteShader(fs);
    },
  };
}
```

### burn-delete/flakes.ts

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

/*
 * The bits of page that fly off the burn front: charred flakes and glowing embers, drawn on a 2D
 * canvas over everything. They are thrown from the front, mostly from its upper half (the heat
 * rises), outwards and up, flutter as they climb, spin, and fade over one to three seconds.
 * A fifth glow gold; the rest are dark scraps, a third of them with a lit edge.
 */

type Flake = {
  x: number;
  y: number;
  vx: number;
  vy: number;
  spin: number;
  angle: number;
  size: number;
  life: number;
  age: number;
  kind: 'char' | 'edge' | 'glow';
  /** A rough six-sided scrap: each corner's distance, as a share of size. */
  shape: number[];
  phase: number;
};

/** No more flakes than this at once: enough to read as a shower, cheap to draw. */
const MAX = 520;

export type Flakes = {
  /** Throws `count` flakes from points on a front of radius `radius` around `origin`. */
  emit: (count: number, origin: { x: number; y: number }, radius: number, unit: number) => void;
  /** Moves and draws them; returns how many are still alive. */
  step: (dt: number, width: number, height: number) => number;
  clear: () => void;
};

export function createFlakes(canvas: HTMLCanvasElement): Flakes | null {
  const ctx = canvas.getContext('2d');
  if (!ctx) return null;
  let flakes: Flake[] = [];

  const fit = (width: number, height: number) => {
    const k = Math.min(window.devicePixelRatio || 1, 2);
    const w = Math.round(width * k);
    const h = Math.round(height * k);
    if (canvas.width !== w || canvas.height !== h) {
      canvas.width = w;
      canvas.height = h;
    }
    ctx.setTransform(k, 0, 0, k, 0, 0);
  };

  return {
    emit(count, origin, radius, unit) {
      for (let i = 0; i < count && flakes.length < MAX; i += 1) {
        // Mostly the upper half: an angle around straight up, spread wide.
        const up = Math.random() < 0.72;
        const angle = up
          ? -Math.PI / 2 + (Math.random() - 0.5) * Math.PI * 1.3
          : Math.random() * Math.PI * 2;
        const along = radius * (0.9 + Math.random() * 0.25);
        const dx = Math.cos(angle);
        const dy = Math.sin(angle) / 1.14;
        const speed = unit * (3 + Math.random() * 9);
        const roll = Math.random();
        flakes.push({
          x: origin.x + dx * along,
          y: origin.y + dy * along,
          vx: dx * speed,
          vy: dy * speed - unit * (4 + Math.random() * 8),
          spin: (Math.random() - 0.5) * 8,
          angle: Math.random() * Math.PI * 2,
          size: unit * (0.15 + Math.random() * Math.random() * 0.75),
          life: 1 + Math.random() * 2,
          age: 0,
          kind: roll < 0.2 ? 'glow' : roll < 0.45 ? 'edge' : 'char',
          shape: Array.from({ length: 6 }, () => 0.45 + Math.random() * 0.55),
          phase: Math.random() * Math.PI * 2,
        });
      }
    },
    step(dt, width, height) {
      fit(width, height);
      ctx.clearRect(0, 0, width, height);
      flakes = flakes.filter((flake) => flake.age < flake.life);
      for (const flake of flakes) {
        flake.age += dt;
        // Rising air: a little lift, drag, and a sideways flutter.
        flake.vy -= flake.size * 2.4 * dt;
        flake.vx *= 1 - 0.9 * dt;
        flake.vy *= 1 - 0.6 * dt;
        flake.x += (flake.vx + Math.sin(flake.age * 5 + flake.phase) * flake.size * 6) * dt;
        flake.y += flake.vy * dt;
        flake.angle += flake.spin * dt;
        const fade = 1 - flake.age / flake.life;
        if (flake.x < -20 || flake.x > width + 20 || flake.y < -20 || flake.y > height + 20) {
          flake.age = flake.life;
          continue;
        }
        ctx.save();
        ctx.translate(flake.x, flake.y);
        ctx.rotate(flake.angle);
        ctx.globalAlpha = Math.min(1, fade * 1.6);
        const s = flake.size;
        ctx.beginPath();
        flake.shape.forEach((reach, corner) => {
          const turn = (corner / flake.shape.length) * Math.PI * 2;
          ctx.lineTo(Math.cos(turn) * s * reach, Math.sin(turn) * s * reach);
        });
        ctx.closePath();
        if (flake.kind === 'glow') {
          ctx.fillStyle = fade > 0.5 ? '#ffe2a0' : '#f2a13c';
          ctx.fill();
        } else {
          ctx.fillStyle = '#1e1612';
          ctx.fill();
          if (flake.kind === 'edge') {
            ctx.lineWidth = Math.max(0.6, s * 0.28);
            ctx.strokeStyle = '#e0a24a';
            ctx.stroke();
          }
        }
        ctx.restore();
      }
      return flakes.length;
    },
    clear() {
      flakes = [];
      ctx.setTransform(1, 0, 0, 1, 0, 0);
      ctx.clearRect(0, 0, canvas.width, canvas.height);
    },
  };
}
```

### burn-delete/demo-pointer.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import type { CSSProperties, Ref } from 'react';

/*
 * The demo's pointer, and the steps that move it. A demo is a script of awaited steps: wait, or
 * glide the pointer somewhere. Stopping the demo (the reader takes over, or it scrolls away) ends
 * the step in progress at once: its promise rejects, which ends the script right there, and the
 * pointer fades out.
 *
 * Each glide is a curved flight played by the Web Animations API, so nothing runs frame by frame.
 * The points of the flight are handed to whoever wants to move along with it (nothing here uses
 * them yet). The arrow and the hand are HTML boxes
 * that swap by their visibility: a change of style inside an SVG would lay the SVG out again.
 */

export type Point = { x: number; y: number };

/** A glide's path and timing, for an animation that plays along with it. */
export type Flight = { points: Point[]; timing: KeyframeAnimationOptions };

export type Demo = {
  /** Resolves after `ms`. */
  wait: (ms: number) => Promise<void>;
  /** Glides the pointer to `to`, in the stage's own px, in `ms`; `along` gets the flight. */
  glide: (to: Point, ms: number, along?: (flight: Flight) => void) => Promise<void>;
  /** Shows the arrow, or the hand a link shows. */
  glyph: (name: 'arrow' | 'hand') => void;
};

/** What a stopped demo's pending step rejects with. */
class Stopped extends Error {}

/** Where the arrow's tip is, as shares of its box: the point the pointer stands on. */
const TIP: Point = { x: 0.15, y: 0.1 };

/** How many points a flight is drawn through. */
const SAMPLES = 24;

/** Plays `script` with the pointer over `stage`; returns the function that stops it. */
export function runDemo(
  stage: HTMLElement,
  pointer: HTMLElement,
  script: (demo: Demo) => Promise<void>,
): () => void {
  let alive = true;
  let flight: Animation | null = null;
  // The stylesheet sizes the pointer from the stage's width; its tip is where it stands.
  const tip = { x: pointer.offsetWidth * TIP.x, y: pointer.offsetHeight * TIP.y };
  const place = ({ x, y }: Point) => `translate(${x - tip.x}px, ${y - tip.y}px)`;
  const timers = new Set<number>();
  const pending = new Set<() => void>();
  // The pointer comes in from the lower right.
  let at: Point = { x: stage.offsetWidth * 0.8, y: stage.offsetHeight * 0.9 };

  /** Settles like `promise`, or rejects as soon as the demo stops. */
  const step = (promise: Promise<unknown>) =>
    new Promise<void>((resolve, reject) => {
      if (!alive) return reject(new Stopped());
      const cancel = () => reject(new Stopped());
      pending.add(cancel);
      promise.then(
        () => {
          pending.delete(cancel);
          if (alive) resolve();
        },
        () => {
          pending.delete(cancel);
          reject(new Stopped());
        },
      );
    });

  const wait = (ms: number) =>
    step(
      new Promise<void>((resolve) => {
        const timer = window.setTimeout(() => {
          timers.delete(timer);
          resolve();
        }, ms);
        timers.add(timer);
      }),
    );

  const glide: Demo['glide'] = (to, ms, along) => {
    const from = at;
    at = to;
    const dx = to.x - from.x;
    const dy = to.y - from.y;
    // A gentle curve, as a hand moves: the control point sits off the straight line.
    const bend = { x: (from.x + to.x) / 2 - dy * 0.18, y: (from.y + to.y) / 2 + dx * 0.18 };
    const points: Point[] = [];
    for (let i = 0; i <= SAMPLES; i += 1) {
      const t = i / SAMPLES;
      const u = 1 - t;
      points.push({
        x: u * u * from.x + 2 * u * t * bend.x + t * t * to.x,
        y: u * u * from.y + 2 * u * t * bend.y + t * t * to.y,
      });
    }
    const timing: KeyframeAnimationOptions = {
      duration: ms,
      easing: 'cubic-bezier(0.45, 0, 0.25, 1)',
    };
    flight?.cancel();
    // Where it rests once the flight is over.
    pointer.style.transform = place(to);
    flight = pointer.animate(
      points.map((point) => ({ transform: place(point) })),
      timing,
    );
    along?.({ points, timing });
    return step(flight.finished);
  };

  const glyph: Demo['glyph'] = (name) => {
    pointer.dataset.glyph = name;
  };

  pointer.dataset.glyph = 'arrow';
  pointer.style.transform = place(at);
  pointer.style.opacity = '1';
  script({ wait, glide, glyph }).catch((error: unknown) => {
    if (!(error instanceof Stopped)) throw error;
  });

  return () => {
    if (!alive) return;
    alive = false;
    timers.forEach((timer) => window.clearTimeout(timer));
    flight?.cancel();
    pending.forEach((cancel) => cancel());
    pointer.style.opacity = '0';
  };
}

/**
 * The pointer's box: it moves, on a layer of its own. Its size comes from its class, its colours
 * from the stage's tokens (burn-delete.module.css).
 */
const POINTER: CSSProperties = {
  position: 'absolute',
  top: 0,
  left: 0,
  zIndex: 2,
  display: 'block',
  pointerEvents: 'none',
  opacity: 0,
  transition: 'opacity 0.3s ease',
  filter: 'drop-shadow(0 1px 1.5px var(--pointer-shadow))',
  willChange: 'transform',
};

/** One glyph over the other, each filling the box. */
const GLYPH: CSSProperties = { position: 'absolute', inset: 0, display: 'block' };
const DRAWING: CSSProperties = {
  display: 'block',
  width: '100%',
  height: '100%',
  overflow: 'visible',
};
/** The arrow is dark on a white edge, the hand white on a dark one, as the system draws them. */
const ARROW: CSSProperties = { fill: 'var(--pointer)', stroke: 'var(--pointer-edge)' };
const HAND: CSSProperties = { fill: 'var(--pointer-edge)', stroke: 'var(--pointer)' };

/**
 * The pointer the demo moves around: an arrow, or a pointing hand over a control. It is
 * decorative: what it does shows on the control itself. The stylesheet shows one glyph at a time,
 * from the box's data-glyph.
 */
export function DemoPointer({
  ref,
  className,
  arrowClass,
  handClass,
}: {
  ref: Ref<HTMLSpanElement>;
  className?: string;
  arrowClass?: string;
  handClass?: string;
}) {
  return (
    <span ref={ref} className={className} style={POINTER} aria-hidden="true">
      <span className={arrowClass} style={GLYPH}>
        <svg viewBox="0 0 20 20" style={DRAWING}>
          <path
            d="M3 2v14.5l3.6-3.3 2.6 5.6 2.4-1.1-2.6-5.5h5.2z"
            style={ARROW}
            strokeWidth="1.3"
            strokeLinejoin="round"
          />
        </svg>
      </span>
      <span className={handClass} style={GLYPH}>
        <svg viewBox="0 0 20 20" style={DRAWING}>
          {/* The tip of the finger sits where the arrow's tip is. */}
          <path
            d="M6.4 3.3c0-.8.6-1.4 1.3-1.4S9 2.5 9 3.3v5.5c.2-.5.6-.8 1.2-.8.7 0 1.2.5 1.2 1.2v.5c.2-.5.6-.8 1.2-.8.7 0 1.2.5 1.2 1.2v.7c.2-.4.6-.7 1.1-.7.7 0 1.2.5 1.2 1.2v3.5c0 2.8-1.9 4.9-4.6 4.9h-1.2c-1.8 0-3.1-.8-4.1-2.3l-2.6-3.9c-.4-.6-.2-1.3.4-1.7.6-.3 1.3-.2 1.7.4l.6.9z"
            style={HAND}
            strokeWidth="1.1"
            strokeLinejoin="round"
            transform="translate(-4.7 0.1)"
          />
        </svg>
      </span>
    </span>
  );
}
```

### burn-delete/use-autoplay.ts

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import { useCallback, useEffect, useRef, useState } from 'react';

/*
 * When a demo may play on its own: while part of it is on screen and the tab is visible, never
 * under reduced motion, and never again once the reader has used it: `take()` hands it to the
 * reader for good (until the component mounts again), so it can't come back on its own.
 */
export function useAutoplay<T extends HTMLElement>() {
  const ref = useRef<T>(null);
  const [visible, setVisible] = useState(false);
  const [reduced, setReduced] = useState(true);
  const [taken, setTaken] = useState(false);

  useEffect(() => {
    const element = ref.current;
    if (!element) return;
    let onScreen = false;
    const update = () => setVisible(onScreen && !document.hidden);
    const observer = new IntersectionObserver(
      ([entry]) => {
        onScreen = entry.isIntersecting;
        update();
      },
      { threshold: 0.3 },
    );
    observer.observe(element);
    document.addEventListener('visibilitychange', update);
    const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
    const readMotion = () => setReduced(motion.matches);
    readMotion();
    motion.addEventListener('change', readMotion);
    return () => {
      observer.disconnect();
      document.removeEventListener('visibilitychange', update);
      motion.removeEventListener('change', readMotion);
    };
  }, []);

  const take = useCallback(() => setTaken(true), []);

  return { ref, take, playing: visible && !reduced && !taken };
}
```