# Recreate this site as a single HTML file: Eight Hours After Dusk

You are an expert creative front-end developer. Build one self-contained `index.html` (inline CSS and JS) with local images in `assets/` next to it. The only remote code is Google Fonts and three.js **0.160.0** from jsDelivr through an import map. No build step, no framework.

## What it is

This is a WebGL exhibition for a fictional photography festival, the *Blue Hour Biennale*, and its show *Eight Hours After Dusk*. Eight night photographs by eight (fictional) photographers, one for each hour from 19:40 to 02:50, hang as **real framed objects** (anodised moulding, cotton mat board with a white bevel, glass with a reflection sheen, a backing box with depth). They sit on a **rising spiral staircase** inside a concrete stairwell rendered in Blender Cycles. Climbing the stair moves you through the night.

**Signature:** scroll, drag or press the arrow keys to travel up the helix with eased inertia and a snap to each level. The focused print is sharp and full colour. The others blur (mip-bias depth of field), desaturate and sink into the fog. A glowing amber handrail traces the helix. At the foot of the stair is a glossy **planar-reflection pool**, which mirrors the hall, the stair and the prints. Its reflection is refracted by **pointer ripples** and an ambient drip. Click a print and the camera **flies to it** while an accessible detail panel slides in, with title, artist, year, medium, size, location, notes, earlier/later navigation and "Add to my route". A DOM index of all works is the source of truth, a screen-reader path and the no-WebGL fallback.

## Page shell & libraries

- `<html lang="en">`, viewport `width=device-width, initial-scale=1, viewport-fit=cover`, `theme-color #070a12`.
- Fonts (Google): `Instrument Serif` (regular + italic), `Geist` 300/400/500/600, `Geist Mono` 400/500, `display=swap`.
- Import map: `"three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js"` and `"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"`. Import `Reflector` (`objects/Reflector.js`) and `RoundedBoxGeometry` (`geometries/RoundedBoxGeometry.js`).
- Two scripts:
  1. A **classic script** (the app shell). It parses works from the DOM list, builds the hour rail and minimap, and runs the caption, the detail dialog, the route (localStorage), the index view and filters, the keyboard handling and the WebGL detection and fallback. It exposes `window.App`.
  2. A **module script** (the 3D stair). It registers `App.gl = { travel(i, {zoom}), zoom(on), setActive(on), setSaved(arr), screenOf(i) }`. If the module never registers within 9 s, or `webgl2` is unavailable, the shell calls `App.fallback()`.
- Body is `overflow:hidden`. The page is one full-viewport stage. Only the index layer and the detail panel scroll.

## Tokens

| Token | Value | Use |
|---|---|---|
| `--ink` | `#070a12` | page / clear |
| `--ink-2` | `#0d1320` | image placeholders |
| fog | `#0b1120` | renderer clear + `FogExp2(…, 0.06)` |
| `--text` | `#eeece6` | primary text (≈17:1) |
| `--muted` | `#b4b9c6` | secondary (≈9.6:1) |
| `--dim` | `#8c93a3` | labels (≈6.3:1) |
| `--amber` | `#f3a95e` | sodium-lamp accent, focus ring, rail |
| `--cyan` | `#9fd6ff` | "saved to route" marks |
| `--line` / `--line-2` | `rgba(214,222,240,.16 / .28)` | hairlines, chip borders |
| `--panel` | `rgba(10,14,24,.86)` + `blur(18px) saturate(1.2)` | detail panel |

- Type scale: h1 `400 clamp(34px,4.6vw,64px)/.95 Instrument Serif`, with "After Dusk" in italic amber. Caption title is italic `clamp(34px,4.2vw,58px)/1`. Detail title is italic `clamp(38px,5vw,52px)`. Kickers and labels are `500 11–12px Geist Mono`, `letter-spacing .12–.18em`, uppercase. Body is 15px/1.55 Geist.
- Radii: 6 / 12 / 20 px, and 999px for pills. Gutter `--gut: clamp(16px,3.2vw,40px)`. Easing `--ease: cubic-bezier(.22,.61,.36,1)` and `--ease-out: cubic-bezier(.16,1,.3,1)`.
- Focus: `:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px }`.
- Overlays: a radial and linear vignette `.shade`, plus a fixed SVG `feTurbulence` grain at `opacity .07`, `mix-blend-mode: overlay`.

## Layout & structure

1. **Skip link** ("Skip to the list of works"). It opens the index and focuses the list.
2. **Loader** (full-screen ink). "Opening Harbour Hall" in mono, with a 160px hairline bar that fills as the 8 textures load. It fades out over .9s. A 6 s safety timeout starts the scene anyway.
3. **Stage**: `<canvas id="gl">` (`touch-action:none`, `cursor: grab` / `grabbing` / `pointer` over a print). It fades in over 1.2s when ready. The canvas wrapper is `aria-hidden`.
4. **HUD** (`.hud`, z 5):
   - Top-left masthead: a kicker with a half-filled amber circle mark, "Blue Hour Biennale · 2026", the h1 and a 34ch lede.
   - Top-right: two chips, `Index` (aria-pressed) and `My route` with a count badge.
   - **Hour rail**, right-centre. Eight buttons labelled 19:40…02:50, bottom to top, each with a 15px dot. The current one is amber with a glow and `aria-current="true"`, saved ones get a 4px cyan dot, and an amber fill line grows with progress.
   - **Caption**, bottom-left: hour (amber), a 28px rule, "Level 0N / 08", the italic title, "Artist · Year", then `‹` (44px round), `View work →` (cream pill) and `›`. The title and artist re-animate with `rise .6s` (translateY 10px + blur 4px → none).
   - **Minimap**, bottom-right, 112px SVG. It shows a top-down spiral (`r = 18 + p·4.6`, angle `p·0.95`), 8 dots (the current one amber r4, passed ones bronze), an amber trail drawn up to the current position, a camera arrow rotated with the helix angle and the hour in the centre. Next to it is a hint, "Scroll or drag to climb · ← → step · Enter open", which fades out after the first interaction.
5. **Index** (`<section id="index">`, z 4, under the HUD so the header stays). The heading is "Index of works" with a lede and a segmented filter, `All 8` / `My route n`, both aria-pressed. A `<ul id="works">` grid uses `repeat(auto-fill,minmax(250px,1fr))`, gap `28px 22px`. Each `<li>` carries `data-id/img/hour/year/artist/medium/size/place` and contains a 3:4 image (lazy, alt text), an hour tag, an "On route" tag when saved, an italic h3 title, "Artist · Year", a hidden `.desc-src` paragraph, and the buttons `Open` and `Show on stair`. An empty state shows for an empty route. **This list is the data source for everything else.**
6. **Detail panel** (`<aside role="dialog" aria-modal="true">`). It is a right sheet `min(440px,100%)` on desktop and a bottom sheet `max-height 56dvh` with 20px top radii at ≤ 900px (92dvh in flat/list mode). It contains: the level line ("**22:15** · Level 04") and a close button (44px, "Close details (Esc)"), a 3:4 thumbnail (only in flat/list/no-GL mode), the italic h2, the artist, a `dl` (Year / Medium / Size / Made at), the description, the `Add to my route` toggle (aria-pressed; it turns amber "On your route ✓"), and a footer grid with `← Earlier <title>` / `n / 8` / `Later → <title>`.

## The 3D scene (module)

- Renderer: antialias, DPR `min(devicePixelRatio, 1.75)`, `SRGBColorSpace`, `ACESFilmicToneMapping`, exposure 1. The print shader **skips** tone mapping so the photographs keep their true colour. Clear colour is the fog colour.
- **Hall:** a `SphereGeometry(24, 64, 32)`, BackSide, `fog:false`, textured with `assets/hall-360.webp` (equirect) at colour .62. The same texture goes through `PMREMGenerator.fromEquirectangular` → `scene.environment`, so the frames and glass reflect the real room.
- **Helix constants:** `STEP = 0.95 rad` per level, `R = 3.3` (print centre radius), `RISE = 1.15`, `FLOOR = -1.42`. `helixAt(p) = (sin(p·STEP)·R, p·RISE, cos(p·STEP)·R)`. Each print group faces outward (`rotation.y = i·STEP`).
- **Framed object** (per work):
  - Print plane `1.3 × 1.733`.
  - Mat `0.13`: a `BoxGeometry` board, `#e6e1d6`, roughness .92, emissive `#6f6b63`.
  - Bevel: four 12mm strips, `#f6f2ea`, emissive `#a8a398`.
  - Moulding `0.055`, depth `0.075`: four `RoundedBoxGeometry` (radius .012), `#0d0e11`, metalness .7, roughness .32, envMapIntensity 1.6.
  - Backing box `#08090c`.
  - Glass plane at z .034: `MeshStandardMaterial` white, metalness 1, roughness .04, **additive**, opacity .11, envMapIntensity 2.2. This gives a moving sheen.
  - Halo plane behind (+0.9 larger), tinted with the print's **average colour**: sample the image into an 8×8 canvas, luminance-weighted, saturation ×1.5 + .15, lightness .55. Alpha is `pow(smoothstep(1,.7,maxAxis),1.6)·uA·.5`.
  - Under the frame, a mono label strip (CanvasTexture 512×64): hour in amber and "LVL 0N". Redraw it after `document.fonts.ready`.
- **Print shader** (ShaderMaterial with fog chunks):
  - `texture2D(map, uv, uBlur)` (mip bias = depth of field).
  - Desaturate toward cool grey by `uDim·.55`, darken by `1-uDim·.5`, brighten by `1+uHover·.14`.
  - 5% edge vignette, a cyan 1.2% hairline when saved, fade-in `uLoaded`.
  - Animated hash grain at ±0.7% (×(1-uDim)), then `colorspace_fragment` and `fog_fragment`.
  - Per frame, for distance `d = |i - cur|`: `uBlur = min(4.5, d·1.9)`, `uDim = min(1, d·.62)`, halo `uA = max(0, 1-d·1.4)·(.7+.3·zoom)`, label opacity `max(.15, 1-d·.7)`. Hover eases with `1-exp(-dt·10)` and scales the group to 1.035.
- **Stair:**
  - An open cylinder spine (r .55, `#1a2233`).
  - Five treads per level from p = −1.6 to N−1+1.2. Each is an `InstancedMesh` box `0.5 × 0.08 × 2.55` (offset .55 out from the axis), `#2c3649`, at `y = p·RISE − frameH/2 − .32`.
  - An amber lamp strip on each tread end (`#f3a95e ×1.6`).
  - **Handrail:** a `TubeGeometry` (radius .014, 600 segments) along a CatmullRom through the helix at radius 4.0, `y = p·RISE − frameH/2 − .2`, amber ×1.25. It must pass *below* the prints, never across them.
- **Water:**
  - `Reflector(CircleGeometry(40,96))` at `FLOOR` with a custom shader.
  - A ring buffer of 24 ripples `vec4(x, -z, t0, strength)`. For each ripple: `front = dist − age·1.35`, `env = exp(−front²·9)·(1−age/3.2)·strength/(1+dist·.6)`, `wave = sin(front·18)·env`. Offset the projective UV by `Σ dir·wave · .085 · w` plus a slow swell, `.012·(sin(y·2.1+t·.6), cos(x·1.7−t·.5))`.
  - Colour is `base·.82 + warm·crest·.07`, then tone mapping and colorspace.
  - Above it sits a **veil** disc (transparent): fog colour, alpha `mix(.28, 1, smoothstep(3.5,19,d))`, a brass inlay ring at r 4.15, and a slow ±4% shimmer.
  - Ripples come from the pointer (raycast against the floor plane, a new ring when the pointer has moved more than .45u, or more than .08u after .25s) and from an ambient drip every .7–1.8s.
- **Dust:** 520 additive points (260 on phones) in a cylinder that drift up `.04–.1 u/s` and sway, sized by depth.

## Behaviour & interaction (numbers)

- **Travel state:** `cur` eases toward `target` with `1 − exp(−dt·3.6)` (`·9` while dragging). The focus index is `round(cur)`, which updates the caption, rail, minimap and live region (debounced 450ms).
- **Camera:** it orbits an outer helix at angle `cur·STEP`, radius `R + dist`, and height `cur·RISE + .28 − zoom·.22 + sway`.
  - `dist = lerp(4.35, 3.75, zoom) · max(1, .72/aspect)`.
  - It looks at `(sin, cur·RISE − .05, cos)·R·.86`.
  - Idle sway is `sin(t·.45)·.06`.
  - `setViewOffset` raises the composition by `H·.035` on desktop and 64px on phones. When the detail panel is open it shifts by `zoom·min(440,W)/2` on desktop (the print centres in the free area) or `zoom·H·.26` when the panel is a bottom sheet (≤ 900px).
  - Zoom eases with `1 − exp(−dt·3.2)`.
- **Intro:** 2.6s easeOutCubic. The camera starts 2.6 lower, 4.5 further out and 0.9 rad behind, then rises to level 1.
- **Wheel:** `target += clamp(delta, ±120)·.0032`, clamped to `[−.3, N−1+.3]`, snapping to the nearest level after 160ms idle. Ignore wheel events inside the panel or index.
- **Drag:** `Δ = −(dx + dy·1.25)·1.6 / max(320, min(W,H)·.62)`, clamped to `[−.35, N−1+.35]`. On release, `target += velocity·6`, then snap. Dragging or scrolling closes an open panel.
- **Click** (moved ≤ 6px) on the front face of a print: travel there, then open the panel when `|cur − i| < .06`, or after 1.5s at most. Click on empty space closes the panel.
- **Keyboard:** `→ / ↑ / PageUp` next, `← / ↓ / PageDown` previous, `Home / End`, `Enter / Space` (when not on a button) opens. In the panel, `← / →` step earlier/later and `Esc` closes. `Esc` in the index returns to the stair. Steps are relative to the *target* level, so repeated key presses queue correctly.
- **Detail panel:** `transform .7s var(--ease-out)`. It traps focus with Tab/Shift+Tab, focuses Close on open and restores the previous focus on close. While it is open, the caption, rail and minimap (and the masthead on desktop) fade out.
- **Route:** a toggle per work, stored in `localStorage['bhb-route']` (read and write in try/catch). It updates the chip count, the rail cyan dots, the "On route" tags, the print hairline and the filter count.
- **Index view:** `Index` toggles list and stair. `My route` opens the list filtered. `Show on stair` returns to 3D and travels. Rendering is **paused** while the index is open.

## Responsive

- **1440:** everything as above. The rail is visible and the minimap is 112px.
- **≤ 900 (768):** the rail is hidden, the minimap shrinks to 84px and its hint is hidden, and the detail panel becomes a bottom sheet so the framed print stays visible above it.
- **≤ 600 (390):** the lede is hidden, h1 is 32px, the year in the kicker is hidden, and the chips are icon-only 40px with the count badge. The minimap is hidden. The caption spans both gutters and its title is 36px. The index grid is 2 columns. Camera `aspectF = max(1, .72/aspect)` keeps the whole frame in view. Dust is halved.
- There is no horizontal scroll at any width. Safe-area insets are respected.

## Accessibility & reduced motion

- The DOM list is the real content: alt text for every photo, headings, buttons. The canvas is `aria-hidden`.
- `aria-live="polite"` announces "Level 4 of 8, 22:15: Deep End by Kwame Aldous." and route changes.
- Every control is a `<button>` with a 44px target, a visible amber focus ring, and aria-pressed/current where relevant.
- `prefers-reduced-motion`: travel jumps (`cur = target`), there is no inertia, intro, sway, dust motion, pointer ripples or ambient drips, hover and load fades are instant, and CSS animations collapse to .01ms. The scene still renders and stays fully usable.

## Fallbacks & performance

- No WebGL2, or the module fails to register within 9 s: add `-noGL` and `-flat`, hide the stage, rail, minimap, caption and Index chip, and show the list. The detail panel then shows the image thumbnail.
- The render loop stops on `visibilitychange` (hidden) and while the index view is open, and restarts with `kick()`.
- The reflection target is `min(1024, max(W,H)·DPR·.5)` square. There is no post-processing.
- Total weight is about 0.7 MB of images plus three.js from the CDN.

## Assets (relative paths)

All photos are 900×1200 WebP, under 120 KB each, shot in one consistent "medium-format film, night, fine grain" language:

- `assets/h1-laundromat.webp`: a corner laundromat glowing through its window onto a wet street at blue hour.
- `assets/h2-ferry.webp`: a lone figure in a dark coat at a ferry's rear rail, harbour lights over black water.
- `assets/h3-greenhouse.webp`: a Victorian glasshouse lit from inside, condensation, tropical leaves.
- `assets/h4-pool.webp`: an empty outdoor pool lit turquoise from below, diving board, night.
- `assets/h5-neon.webp`: red and magenta motel neon reflected in a rippling puddle in rain.
- `assets/h6-bakery.webp`: flour-dusted hands shaping dough under one tungsten bulb.
- `assets/h7-pitch.webp`: mist over an empty football pitch under floodlights.
- `assets/h8-lighthouse.webp`: a lighthouse beam through sea mist, star trails, long exposure.
- `assets/hall-360.webp`: a 2048×1024 equirectangular **Blender Cycles** render (AgX) of the stairwell.
  - The room: an open concrete cylinder r 15 m with 72 board-form ribs and a wet glossy floor.
  - Light: 6 tall cool slit windows, 40 brass wall sconces climbing in a helix (warm emission plus point lights) and a dim blue oculus.
  - Camera: panoramic at 3 m. The poles are darkened in post.

## Make it yours

This prompt rebuilds one exact design. If everyone ships it unchanged, the sites will look alike. Before you paste it, change these lines so the result is yours. Each change is one edit to the prompt; the structure and the interactions stay intact.

1. **Exhibition and premise.** Replace the Blue Hour Biennale and "one photograph per hour of the night" with your own show and an ordering idea that suits a climb. Examples: twelve months of a year, the floors of a building, a river from source to sea, chapters of a book, a career from first job to last. Keep 6–10 works so the helix stays legible, and keep a short ordered label per level in place of the hour (month, floor, km, chapter).
2. **The stair itself.** The rising helix is the signature. Re-theme it without changing the travel maths. Some options:
   - A library spiral: oak treads, a brass rail and `STEP 0.7` for a tighter turn.
   - A lighthouse interior: whitewashed treads, a red rail and a cyan lamp strip.
   - A gallery ramp, Guggenheim-style: `RISE 0.6`, `STEP 0.5`, a continuous tube in place of treads.
   - A mine shaft: rusted grating and a yellow rail.

   Change the rail colour, tread colour and the `STEP/RISE` pair together.
3. **The room.** Render your own 360° plate in Blender Cycles (equirect, about 2048×1024, low samples plus denoise) that matches the new theme: library stacks, a tiled lighthouse shaft, a white museum rotunda, a brick mill. The same file lights the frames and fills the reflection, so a warmer or brighter room changes the whole mood.
4. **Frames.** Swap the black anodised moulding and white mat to fit your work. Options: natural oak with no mat for prints, gilded moulding for paintings, a borderless float mount with a 2 cm shadow gap for contemporary photos, or a lightbox (emissive print, no glass) for transparencies.
5. **Palette.** Replace `--amber`, the fog colour and `--ink` with your brand's lamp colour and night colour. Keep `--muted` at 4.5:1 or better on `--ink`, and keep the accent readable as text on the panel.
6. **Type pairing.** Swap Instrument Serif + Geist + Geist Mono for another display serif and grotesk with a monospace for labels. For example: Fraunces + Inter Tight + IBM Plex Mono, or Cormorant + Manrope + JetBrains Mono.
7. **The works.** Replace the eight images and their `data-*` fields with your own collection. If you generate them, shoot the series in one language: one lens, one grade, the same grain, real places and objects, nothing symmetrical or glossy. Write alt text that says what is in the frame.
8. **Copy voice.** Rewrite the lede, the work notes and the empty state in your curator's voice. Be specific about who, where and why ("eleven minutes before someone switched them off"), not generic ("a stunning exploration of light").

Tell your AI: *"Build exactly as specified, but with these changes: …"*, then list your edits.

---

## Reference implementation (use verbatim)

The complete working `index.html`. Every number in the spec above is in this file; if the two ever seem to differ, the code wins. Images and models referenced as `assets/...` can be downloaded from https://copytheprompt.design/demos/webgl-photo-exhibition-gallery/assets/ or replaced with your own (see Make it yours).

````html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>Eight Hours After Dusk · Blue Hour Biennale</title>
<meta name="description" content="A spiral-staircase WebGL gallery: eight night photographs, one for each hour from dusk to the edge of dawn.">
<meta name="theme-color" content="#070a12">
<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=Instrument+Serif:ital@0;1&family=Geist:wght@300;400;500;600&family=Geist+Mono:wght@400;500&display=swap" rel="stylesheet">
<link rel="preload" as="image" href="assets/h1-laundromat.webp" type="image/webp">
<script type="importmap">
{
  "imports": {
    "three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",
    "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"
  }
}
</script>
<style>
  :root {
    --ink: #070a12;
    --ink-2: #0d1320;
    --fog: #0b1120;
    --line: rgba(214, 222, 240, .16);
    --line-2: rgba(214, 222, 240, .28);
    --text: #eeece6;
    --muted: #b4b9c6;           /* 9.6:1 on --ink */
    --dim: #8c93a3;             /* 6.3:1 on --ink */
    --amber: #f3a95e;           /* sodium lamp */
    --amber-soft: rgba(243, 169, 94, .16);
    --cyan: #9fd6ff;
    --panel: rgba(10, 14, 24, .86);
    --r-s: 6px; --r-m: 12px; --r-l: 20px;
    --gut: clamp(16px, 3.2vw, 40px);
    --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
    --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    --ease: cubic-bezier(.22, .61, .36, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
  }
  *, *::before, *::after { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); }
  body { font: 400 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; }
  button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
  img { display: block; max-width: 100%; }
  :focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 4px; }
  .sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .skip { position: fixed; left: var(--gut); top: 10px; z-index: 50; padding: 10px 14px; background: var(--amber); color: #1a1006; border-radius: var(--r-s); font-weight: 600; transform: translateY(-160%); transition: transform .2s var(--ease); }
  .skip:focus { transform: none; }

  /* ---------- stage ---------- */
  #stage { position: fixed; inset: 0; }
  #gl { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; opacity: 0; transition: opacity 1.2s var(--ease); }
  #gl.-on { opacity: 1; }
  #gl.-drag { cursor: grabbing; }
  #gl.-hover { cursor: pointer; }
  .shade { position: fixed; inset: 0; pointer-events: none;
    background:
      radial-gradient(120% 80% at 50% 45%, transparent 55%, rgba(4,6,11,.7) 100%),
      linear-gradient(180deg, rgba(4,6,11,.72) 0%, transparent 24%, transparent 64%, rgba(4,6,11,.82) 100%); }
  .grain { position: fixed; inset: -50%; pointer-events: none; opacity: .07; mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

  /* ---------- HUD ---------- */
  .hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
  .hud > * { pointer-events: auto; }
  .top { position: absolute; left: var(--gut); right: var(--gut); top: calc(var(--gut) + env(safe-area-inset-top)); display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; pointer-events: none; }
  .top > * { pointer-events: auto; }
  .mast .kicker { display: flex; align-items: center; gap: 10px; font: 500 11px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
  .mast .kicker .mark { width: 18px; height: 18px; flex: none; }
  .mast h1 { margin: 14px 0 0; font: 400 clamp(34px, 4.6vw, 64px)/.95 var(--serif); letter-spacing: -.01em; }
  .mast h1 em { color: var(--amber); }
  .mast p { margin: 10px 0 0; max-width: 34ch; color: var(--muted); font-size: 13.5px; }
  .tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .chip { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(9,13,22,.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font: 500 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text); transition: border-color .25s, background .25s; }
  .chip:hover { border-color: rgba(243,169,94,.6); }
  .chip[aria-pressed="true"] { background: var(--amber); color: #1a1006; border-color: var(--amber); }
  .chip .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center; background: var(--amber-soft); color: var(--amber); font-size: 11px; }
  .chip[aria-pressed="true"] .count { background: rgba(26,16,6,.16); color: #1a1006; }
  .chip svg { width: 14px; height: 14px; }

  /* hour rail */
  .rail { position: absolute; right: var(--gut); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column-reverse; gap: 4px; padding: 6px 0; }
  .rail::before { content: ''; position: absolute; right: 7px; top: 14px; bottom: 14px; width: 1px; background: var(--line); }
  .rail .fill { position: absolute; right: 7px; bottom: 14px; width: 1px; height: 0; background: var(--amber); box-shadow: 0 0 10px var(--amber); }
  .rail button { position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 12px; height: 34px; padding-left: 10px; font: 500 12px/1 var(--mono); letter-spacing: .06em; color: var(--dim); transition: color .3s; }
  .rail button::after { content: ''; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--ink); transition: background .35s var(--ease), border-color .35s, transform .35s var(--ease); transform: scale(.6); }
  .rail button:hover { color: var(--text); }
  .rail button[aria-current="true"] { color: var(--amber); }
  .rail button[aria-current="true"]::after { background: var(--amber); border-color: var(--amber); transform: scale(1); box-shadow: 0 0 14px rgba(243,169,94,.7); }
  .rail button.saved::before { content: ''; position: absolute; left: 0; width: 4px; height: 4px; border-radius: 50%; background: var(--cyan); }

  /* caption */
  .caption { position: absolute; left: var(--gut); bottom: calc(var(--gut) + env(safe-area-inset-bottom)); max-width: min(560px, 60vw); }
  .caption .meta { display: flex; gap: 14px; align-items: center; font: 500 12px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
  .caption .meta .hour { color: var(--amber); }
  .caption .meta .sep { width: 28px; height: 1px; background: var(--line-2); }
  .caption h2 { margin: 12px 0 0; font: italic 400 clamp(34px, 4.2vw, 58px)/1 var(--serif); letter-spacing: -.01em; text-shadow: 0 2px 30px rgba(0,0,0,.6); }
  .caption .by { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
  body.-detail .caption, body.-detail .rail, body.-detail .mini { opacity: 0; visibility: hidden; transition: opacity .4s, visibility 0s linear .4s; }
  .caption, .rail, .mini { transition: opacity .5s var(--ease) .2s; }
  @media (min-width: 601px) { body.-detail .mast { opacity: .0; transition: opacity .4s; } .mast { transition: opacity .5s .2s; } }
  .caption .swap { animation: rise .6s var(--ease-out) both; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
  .caption .actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
  .btn { display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 18px; border-radius: 999px; font-weight: 500; font-size: 14px; transition: transform .25s var(--ease), background .25s, border-color .25s; }
  .btn-primary { background: var(--text); color: var(--ink); }
  .btn-primary:hover { background: #fff; transform: translateY(-1px); }
  .btn-ghost { border: 1px solid var(--line-2); background: rgba(9,13,22,.5); }
  .btn-ghost:hover { border-color: var(--text); }
  .btn svg { width: 16px; height: 16px; }
  .iconbtn { width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; border: 1px solid var(--line-2); background: rgba(9,13,22,.5); transition: border-color .25s, opacity .25s; }
  .iconbtn:hover { border-color: var(--text); }
  .iconbtn:disabled { opacity: .35; cursor: default; }
  .iconbtn svg { width: 18px; height: 18px; }

  /* minimap */
  .mini { position: absolute; right: var(--gut); bottom: calc(var(--gut) + env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 14px; pointer-events: none; }
  .mini svg { width: 112px; height: 112px; overflow: visible; }
  .mini .hint { font: 500 11px/1.6 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); text-align: right; transition: opacity .6s; }
  .mini .hint kbd { font: inherit; color: var(--muted); padding: 1px 5px; border: 1px solid var(--line-2); border-radius: 4px; }
  .mini .hint.-gone { opacity: 0; }

  /* ---------- detail panel ---------- */
  .detail { position: fixed; z-index: 20; top: 0; right: 0; bottom: 0; width: min(440px, 100%); display: flex; flex-direction: column; background: var(--panel); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2); border-left: 1px solid var(--line); transform: translateX(102%); visibility: hidden; transition: transform .7s var(--ease-out), visibility 0s linear .7s; }
  .detail.-open { transform: none; visibility: visible; transition: transform .7s var(--ease-out), visibility 0s; }
  .detail .scroll { flex: 1; overflow-y: auto; padding: calc(var(--gut) + 8px) var(--gut) 24px; overscroll-behavior: contain; }
  .detail .head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .detail .head .lvl { font: 500 12px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
  .detail .head .lvl b { color: var(--amber); font-weight: 500; }
  .detail .thumb { margin: 22px 0 0; border-radius: var(--r-m); overflow: hidden; aspect-ratio: 3 / 4; background: var(--ink-2); display: none; }
  .detail .thumb img { width: 100%; height: 100%; object-fit: cover; }
  body.-flat .detail .thumb { display: block; }
  .detail h2 { margin: 22px 0 0; font: italic 400 clamp(38px, 5vw, 52px)/1 var(--serif); letter-spacing: -.01em; }
  .detail .artist { margin: 10px 0 0; font-size: 16px; color: var(--text); }
  .detail dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 20px; margin: 22px 0 0; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13.5px; }
  .detail dt { font: 500 11px/1.9 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
  .detail dd { margin: 0; color: var(--muted); }
  .detail .desc { margin: 20px 0 0; color: var(--muted); font-size: 15px; line-height: 1.65; max-width: 46ch; }
  .detail .save { margin-top: 24px; width: 100%; justify-content: center; }
  .detail .save[aria-pressed="true"] { background: var(--amber); color: #1a1006; border-color: var(--amber); }
  .detail .foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 14px var(--gut) calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .detail .foot button.step { display: flex; flex-direction: column; gap: 3px; min-height: 44px; justify-content: center; text-align: left; padding: 4px 0; }
  .detail .foot button.step.next { text-align: right; align-items: flex-end; }
  .detail .foot button.step small { font: 500 10.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
  .detail .foot button.step span { font: italic 400 19px/1.1 var(--serif); color: var(--text); }
  .detail .foot button.step:disabled { opacity: .3; cursor: default; }
  .detail .foot .pos { font: 500 12px/1 var(--mono); color: var(--muted); letter-spacing: .1em; }

  /* ---------- index (DOM list, fallback + screen readers) ---------- */
  .index { position: fixed; inset: 0; z-index: 4; overflow-y: auto; background: radial-gradient(120% 70% at 50% 0%, #101a2c 0%, var(--ink) 60%); padding: calc(var(--gut) + 150px) var(--gut) 64px; opacity: 0; visibility: hidden; transition: opacity .45s var(--ease), visibility 0s linear .45s; }
  body.-list .index { opacity: 1; visibility: visible; transition: opacity .45s var(--ease), visibility 0s; }
  body.-list .hud::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: calc(var(--gut) + 118px); pointer-events: none; background: linear-gradient(180deg, #0a0f1b 72%, rgba(10,15,27,0)); }
  body.-list .mast p { display: none; }
  .index-head { max-width: 1240px; margin: 0 auto 28px; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-end; }
  .index-head h2 { margin: 0; font: 400 clamp(30px, 3.6vw, 44px)/1 var(--serif); }
  .index-head p { margin: 8px 0 0; color: var(--muted); max-width: 52ch; }
  .seg { display: inline-flex; padding: 4px; border-radius: 999px; border: 1px solid var(--line-2); }
  .seg button { height: 36px; padding: 0 16px; border-radius: 999px; font: 500 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .seg button[aria-pressed="true"] { background: var(--text); color: var(--ink); }
  .works { list-style: none; margin: 0 auto; padding: 0; max-width: 1240px; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 28px 22px; }
  .works li[hidden] { display: none; }
  .work { display: flex; flex-direction: column; }
  .work .ph { position: relative; aspect-ratio: 3 / 4; border-radius: var(--r-m); overflow: hidden; background: var(--ink-2); }
  .work .ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease-out); }
  .work:hover .ph img { transform: scale(1.03); }
  .work .ph .tag { position: absolute; left: 12px; top: 12px; padding: 6px 9px; border-radius: 6px; background: rgba(7,10,18,.78); font: 500 11px/1 var(--mono); letter-spacing: .1em; color: var(--amber); }
  .work .ph .tag.saved-tag { left: auto; right: 12px; color: var(--cyan); display: none; }
  .work.is-saved .ph .tag.saved-tag { display: block; }
  .work h3 { margin: 14px 0 0; font: italic 400 26px/1.05 var(--serif); }
  .work .who { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
  .work .desc-src { display: none; }
  .work .row { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
  .work .row .btn { height: 38px; padding: 0 14px; font-size: 13px; }
  body.-noGL .work .row .goto, body.-noGL #viewToggle, body.-noGL .rail, body.-noGL .mini, body.-noGL .caption { display: none; }
  .empty { max-width: 1240px; margin: 40px auto 0; padding: 32px; border: 1px dashed var(--line-2); border-radius: var(--r-l); color: var(--muted); text-align: center; }

  .loader { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--ink); transition: opacity .9s var(--ease), visibility 0s linear .9s; font: 500 11px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--dim); }
  .loader.-done { opacity: 0; visibility: hidden; }
  .loader .bar { width: 160px; height: 1px; margin-top: 16px; background: var(--line); overflow: hidden; }
  .loader .bar i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .3s; }

  /* ---------- responsive ---------- */
  @media (max-width: 900px) {
    .rail { display: none; }
    .mini svg { width: 84px; height: 84px; }
    .mini .hint { display: none; }
    .caption { max-width: calc(100% - var(--gut) * 2 - 100px); }
    .detail { top: auto; width: 100%; max-height: 56vh; max-height: 56dvh; border-left: 0; border-top: 1px solid var(--line); border-radius: var(--r-l) var(--r-l) 0 0; transform: translateY(102%); }
    body.-flat .detail { max-height: 92vh; max-height: 92dvh; }
    .detail .scroll { padding-top: 20px; }
    .detail h2 { margin-top: 14px; }
  }
  @media (max-width: 600px) {
    .mast p { display: none; }
    .mast h1 { font-size: 32px; margin-top: 10px; }
    .tools .chip .lbl { display: none; }
    .tools .chip { padding: 0 12px; height: 40px; }
    .caption { right: var(--gut); max-width: none; }
    .caption h2 { font-size: 36px; }
    .caption .by { font-size: 13px; }
    .mini { display: none; }
    .mast .kicker .yr { display: none; }
    .detail .foot button.step span { font-size: 16px; }
    .index { padding-top: 150px; }
    .works { grid-template-columns: 1fr 1fr; gap: 22px 12px; }
    .work h3 { font-size: 20px; }
    .work .who { font-size: 12.5px; }
    .work .row .btn { padding: 0 12px; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  }
</style>
</head>
<body>
<a class="skip" href="#works" id="skipLink">Skip to the list of works</a>

<div class="loader" id="loader" aria-hidden="true"><div><div>Opening Harbour Hall</div><div class="bar"><i id="loadBar"></i></div></div></div>

<div id="stage" aria-hidden="true">
  <canvas id="gl"></canvas>
</div>
<div class="shade" aria-hidden="true"></div>
<div class="grain" aria-hidden="true"></div>

<div class="hud" id="hud">
  <header class="top">
    <div class="mast">
      <div class="kicker">
        <svg class="mark" viewBox="0 0 18 18" aria-hidden="true"><circle cx="9" cy="9" r="8" fill="none" stroke="#f3a95e" stroke-width="1"/><path d="M9 1a8 8 0 0 1 0 16" fill="#f3a95e"/></svg>
        Blue Hour Biennale<span class="yr">· 2026</span>
      </div>
      <h1>Eight Hours <em>After Dusk</em></h1>
      <p>Eight photographers, one hour each, 19:40 to 02:50. Climb the stair to move through the night.</p>
    </div>
    <nav class="tools" aria-label="Views">
      <button class="chip" id="viewToggle" aria-pressed="false" aria-controls="index">
        <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 3h12M2 8h12M2 13h12" stroke="currentColor" stroke-width="1.4" fill="none"/></svg>
        <span class="lbl">Index</span>
      </button>
      <button class="chip" id="routeBtn" aria-pressed="false" aria-controls="index">
        <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 14s-5-3.2-5-7.2A3 3 0 0 1 8 5a3 3 0 0 1 5 1.8C13 10.8 8 14 8 14z" stroke="currentColor" stroke-width="1.4" fill="none"/></svg>
        <span class="lbl">My route</span><span class="count" id="routeCount">0</span>
      </button>
    </nav>
  </header>

  <nav class="rail" id="rail" aria-label="Hours of the night">
    <span class="fill" id="railFill" aria-hidden="true"></span>
  </nav>

  <section class="caption" id="caption" aria-label="Current work">
    <div class="meta"><span class="hour" id="capHour">19:40</span><span class="sep" aria-hidden="true"></span><span id="capLvl">Level 01 / 08</span></div>
    <h2 id="capTitle">Rinse Cycle, Blue</h2>
    <p class="by" id="capBy">Maren Okafor · 2025</p>
    <div class="actions">
      <button class="iconbtn" id="prevBtn" aria-label="Previous hour"><svg viewBox="0 0 18 18" aria-hidden="true"><path d="M11 4 6 9l5 5" stroke="currentColor" stroke-width="1.5" fill="none"/></svg></button>
      <button class="btn btn-primary" id="openBtn">View work <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h10M9 4l4 4-4 4" stroke="currentColor" stroke-width="1.5" fill="none"/></svg></button>
      <button class="iconbtn" id="nextBtn" aria-label="Next hour"><svg viewBox="0 0 18 18" aria-hidden="true"><path d="m7 4 5 5-5 5" stroke="currentColor" stroke-width="1.5" fill="none"/></svg></button>
    </div>
  </section>

  <div class="mini" aria-hidden="true">
    <div class="hint" id="hint">Scroll or drag to climb<br><kbd>←</kbd> <kbd>→</kbd> step · <kbd>Enter</kbd> open</div>
    <svg viewBox="-60 -60 120 120" id="miniSvg">
      <circle r="56" fill="none" stroke="rgba(214,222,240,.14)"/>
      <path id="miniPath" fill="none" stroke="rgba(214,222,240,.32)" stroke-width="1"/>
      <path id="miniTrail" fill="none" stroke="#f3a95e" stroke-width="1.6" stroke-linecap="round"/>
      <g id="miniDots"></g>
      <g id="miniCam"><path d="M0 -6 L5 5 L0 2.5 L-5 5 Z" fill="#eeece6"/></g>
      <text id="miniTxt" y="4" text-anchor="middle" font-family="Geist Mono, monospace" font-size="11" fill="#eeece6">19:40</text>
    </svg>
  </div>
</div>

<p class="sr-only" id="live" aria-live="polite"></p>

<!-- Source of truth for the exhibition: real, readable DOM. The 3D stair is built from this list. -->
<section class="index" id="index" aria-labelledby="indexTitle">
  <div class="index-head">
    <div>
      <h2 id="indexTitle">Index of works</h2>
      <p>Harbour Hall, levels 1 to 8. Each level holds the photograph made in that hour. Open a work for notes, or add it to your route for the night.</p>
    </div>
    <div class="seg" role="group" aria-label="Filter works">
      <button id="fAll" aria-pressed="true">All <span id="fAllN">8</span></button>
      <button id="fRoute" aria-pressed="false">My route <span id="fRouteN">0</span></button>
    </div>
  </div>
  <ul class="works" id="works" tabindex="-1">
    <li class="work" data-id="rinse" data-img="assets/h1-laundromat.webp" data-hour="19:40" data-year="2025" data-artist="Maren Okafor" data-medium="Archival pigment print" data-size="90 × 120 cm, edition of 5" data-place="Corner of Pier Row, 7:40 pm">
      <div class="ph"><img src="assets/h1-laundromat.webp" alt="A corner laundromat glows through its big window onto an empty wet street at blue hour; rows of washing machines inside, cobalt sky above." loading="lazy" width="900" height="1200"><span class="tag">19:40</span><span class="tag saved-tag">On route</span></div>
      <h3>Rinse Cycle, Blue</h3>
      <p class="who">Maren Okafor · 2025</p>
      <p class="desc-src">The first hour belongs to the people who wash things. Okafor waited three weeks for a night when the machines were running and nobody was inside, so the room seems to work on its own while the sky goes from cobalt to ink.</p>
      <div class="row"><button class="btn btn-ghost open">Open</button><button class="btn btn-ghost goto">Show on stair</button></div>
    </li>
    <li class="work" data-id="crossing" data-img="assets/h2-ferry.webp" data-hour="20:55" data-year="2024" data-artist="Tomás Lindqvist-Arce" data-medium="Chromogenic print" data-size="80 × 106 cm, edition of 7" data-place="Night ferry, outer harbour">
      <div class="ph"><img src="assets/h2-ferry.webp" alt="A lone figure in a dark coat stands at the rail of a ferry's rear deck, harbour lights blurring into soft dots over black water." loading="lazy" width="900" height="1200"><span class="tag">20:55</span><span class="tag saved-tag">On route</span></div>
      <h3>Last Crossing</h3>
      <p class="who">Tomás Lindqvist-Arce · 2024</p>
      <p class="desc-src">Shot on the final sailing of the evening, the only time the deck empties enough to see the wake. The figure is the photographer's brother, who has made the crossing every working day for nineteen years.</p>
      <div class="row"><button class="btn btn-ghost open">Open</button><button class="btn btn-ghost goto">Show on stair</button></div>
    </li>
    <li class="work" data-id="palmhouse" data-img="assets/h3-greenhouse.webp" data-hour="21:30" data-year="2026" data-artist="Ines Vaucher" data-medium="Archival pigment print on cotton rag" data-size="100 × 133 cm, edition of 3" data-place="Botanic gardens, north lawn">
      <div class="ph"><img src="assets/h3-greenhouse.webp" alt="An old glass greenhouse lit warmly from inside in a dark garden, its panes fogged with condensation and tropical leaves pressed against the glass." loading="lazy" width="900" height="1200"><span class="tag">21:30</span><span class="tag saved-tag">On route</span></div>
      <h3>Palm House, Breathing</h3>
      <p class="who">Ines Vaucher · 2026</p>
      <p class="desc-src">The heating comes on at nine and the glass fogs from the inside out. Vaucher calls it the building exhaling. Made with a single long exposure while the gardeners' lamps were still on.</p>
      <div class="row"><button class="btn btn-ghost open">Open</button><button class="btn btn-ghost goto">Show on stair</button></div>
    </li>
    <li class="work" data-id="deepend" data-img="assets/h4-pool.webp" data-hour="22:15" data-year="2025" data-artist="Kwame Aldous" data-medium="Chromogenic print, face-mounted" data-size="120 × 160 cm, edition of 3" data-place="Lido, closed for the season">
      <div class="ph"><img src="assets/h4-pool.webp" alt="An empty outdoor swimming pool lit from below, glowing turquoise with ripple patterns, lane ropes and a dark diving board against the night." loading="lazy" width="900" height="1200"><span class="tag">22:15</span><span class="tag saved-tag">On route</span></div>
      <h3>Deep End</h3>
      <p class="who">Kwame Aldous · 2025</p>
      <p class="desc-src">The lido keeps its lights on after closing so the night guard can see the water. Aldous photographed it from the high board, the only place where the caustics resolve into a pattern instead of noise.</p>
      <div class="row"><button class="btn btn-ghost open">Open</button><button class="btn btn-ghost goto">Show on stair</button></div>
    </li>
    <li class="work" data-id="vacancy" data-img="assets/h5-neon.webp" data-hour="23:05" data-year="2023" data-artist="Saoirse Delamere" data-medium="Archival pigment print" data-size="90 × 120 cm, edition of 5" data-place="Coast road motel, in rain">
      <div class="ph"><img src="assets/h5-neon.webp" alt="Red and magenta motel neon reflected in a large rippling puddle on wet asphalt in the rain, the sign cut off at the top edge and a parked car behind." loading="lazy" width="900" height="1200"><span class="tag">23:05</span><span class="tag saved-tag">On route</span></div>
      <h3>Vacancy (Puddle)</h3>
      <p class="who">Saoirse Delamere · 2023</p>
      <p class="desc-src">Delamere never shows the sign, only what the rain makes of it. The puddle is about a metre across; at this hour the road is quiet enough for the surface to settle between cars.</p>
      <div class="row"><button class="btn btn-ghost open">Open</button><button class="btn btn-ghost goto">Show on stair</button></div>
    </li>
    <li class="work" data-id="firstbatch" data-img="assets/h6-bakery.webp" data-hour="00:20" data-year="2026" data-artist="Yuki Morandi" data-medium="Silver gelatin print, selenium toned" data-size="60 × 80 cm, edition of 9" data-place="Bakery on Saltgate, back room">
      <div class="ph"><img src="assets/h6-bakery.webp" alt="Close-up of a baker's flour-dusted hands shaping dough on a wooden bench under one warm bulb, flour drifting in the air." loading="lazy" width="900" height="1200"><span class="tag">00:20</span><span class="tag saved-tag">On route</span></div>
      <h3>First Batch</h3>
      <p class="who">Yuki Morandi · 2026</p>
      <p class="desc-src">Just after midnight the town's first working shift begins. Morandi spent a winter in the back room and kept only the frames where the flour hangs in the air long enough to catch the bulb.</p>
      <div class="row"><button class="btn btn-ghost open">Open</button><button class="btn btn-ghost goto">Show on stair</button></div>
    </li>
    <li class="work" data-id="floodlit" data-img="assets/h7-pitch.webp" data-hour="01:45" data-year="2024" data-artist="Piotr Halvorsen" data-medium="Archival pigment print" data-size="100 × 133 cm, edition of 5" data-place="Municipal ground, east stand">
      <div class="ph"><img src="assets/h7-pitch.webp" alt="Dense white mist drifting over an empty grass football pitch under tall floodlights, beams visible in the haze, a goal frame far off." loading="lazy" width="900" height="1200"><span class="tag">01:45</span><span class="tag saved-tag">On route</span></div>
      <h3>Floodlit, Nobody</h3>
      <p class="who">Piotr Halvorsen · 2024</p>
      <p class="desc-src">A timer fault left the floodlights burning until two on a foggy Tuesday. Halvorsen lives opposite the ground and had eleven minutes before someone noticed and switched them off.</p>
      <div class="row"><button class="btn btn-ghost open">Open</button><button class="btn btn-ghost goto">Show on stair</button></div>
    </li>
    <li class="work" data-id="keeper" data-img="assets/h8-lighthouse.webp" data-hour="02:50" data-year="2025" data-artist="Adaeze Brennan" data-medium="Chromogenic print" data-size="120 × 160 cm, edition of 3" data-place="Skerry light, from the causeway">
      <div class="ph"><img src="assets/h8-lighthouse.webp" alt="A lone lighthouse on dark coastal rocks, its beam cutting through sea mist under faint star trails, the sea smoothed by a long exposure." loading="lazy" width="900" height="1200"><span class="tag">02:50</span><span class="tag saved-tag">On route</span></div>
      <h3>Keeper's Hour</h3>
      <p class="who">Adaeze Brennan · 2025</p>
      <p class="desc-src">The top of the stair and the last hour before the sky turns. A forty-minute exposure: the stars drag into short arcs, the sea flattens to glass, and the beam sweeps the mist more than two thousand times.</p>
      <div class="row"><button class="btn btn-ghost open">Open</button><button class="btn btn-ghost goto">Show on stair</button></div>
    </li>
  </ul>
  <p class="empty" id="empty" hidden>Your route is empty. Open any work and choose “Add to my route” to plan the night.</p>
</section>

<aside class="detail" id="detail" role="dialog" aria-modal="true" aria-labelledby="dTitle" aria-describedby="dDesc">
  <div class="scroll">
    <div class="head">
      <span class="lvl" id="dLvl"><b>19:40</b> · Level 01</span>
      <button class="iconbtn" id="dClose" aria-label="Close details (Esc)"><svg viewBox="0 0 18 18" aria-hidden="true"><path d="M4 4l10 10M14 4 4 14" stroke="currentColor" stroke-width="1.5"/></svg></button>
    </div>
    <div class="thumb"><img id="dImg" alt="" width="900" height="1200"></div>
    <h2 id="dTitle">Rinse Cycle, Blue</h2>
    <p class="artist" id="dArtist">Maren Okafor</p>
    <dl>
      <dt>Year</dt><dd id="dYear">2025</dd>
      <dt>Medium</dt><dd id="dMedium"></dd>
      <dt>Size</dt><dd id="dSize"></dd>
      <dt>Made at</dt><dd id="dPlace"></dd>
    </dl>
    <p class="desc" id="dDesc"></p>
    <button class="btn btn-ghost save" id="dSave" aria-pressed="false">Add to my route</button>
  </div>
  <div class="foot">
    <button class="step prev" id="dPrev"><small>← Earlier</small><span id="dPrevT"></span></button>
    <span class="pos" id="dPos">1 / 8</span>
    <button class="step next" id="dNext"><small>Later →</small><span id="dNextT"></span></button>
  </div>
</aside>

<!-- App shell (classic script): data, DOM UI, state. Works with or without WebGL. -->
<script>
(function () {
  'use strict';
  var $ = function (s, r) { return (r || document).querySelector(s); };
  var items = Array.prototype.slice.call(document.querySelectorAll('#works > li'));
  var works = items.map(function (li, i) {
    return {
      i: i, id: li.dataset.id, img: li.dataset.img, hour: li.dataset.hour, year: li.dataset.year,
      artist: li.dataset.artist, medium: li.dataset.medium, size: li.dataset.size, place: li.dataset.place,
      title: $('h3', li).textContent, alt: $('img', li).alt, desc: $('.desc-src', li).textContent, el: li
    };
  });
  var N = works.length;
  var pad = function (n) { return String(n).padStart(2, '0'); };
  var reduced = matchMedia('(prefers-reduced-motion: reduce)');

  // ---- saved route (per-viewer convenience) ----
  var saved = {};
  try { saved = JSON.parse(localStorage.getItem('bhb-route') || '{}') || {}; } catch (e) { saved = {}; }
  function persist() { try { localStorage.setItem('bhb-route', JSON.stringify(saved)); } catch (e) {} }

  var App = window.App = {
    works: works, N: N, index: 0, detailOpen: false, view: '3d', gl: null, reduced: reduced.matches,
    listeners: []
  };
  reduced.addEventListener && reduced.addEventListener('change', function (e) { App.reduced = e.matches; });

  // ---- rail + minimap ----
  var rail = $('#rail');
  works.forEach(function (w) {
    var b = document.createElement('button');
    b.type = 'button'; b.textContent = w.hour;
    b.setAttribute('aria-label', w.hour + ', level ' + (w.i + 1) + ': ' + w.title);
    b.addEventListener('click', function () { App.go(w.i); });
    rail.appendChild(b); w.railBtn = b;
  });
  // minimap spiral geometry mirrors the 3D helix (angle step and radius growth)
  App.STEP = 0.95;
  var miniPt = function (p) { var a = p * App.STEP, r = 18 + p * 4.6; return [Math.sin(a) * r, -Math.cos(a) * r]; };
  var d = '', dt = '';
  for (var s = 0; s <= (N - 1) * 10; s++) { var q = miniPt(s / 10); d += (s ? 'L' : 'M') + q[0].toFixed(1) + ' ' + q[1].toFixed(1); }
  $('#miniPath').setAttribute('d', d);
  var dots = $('#miniDots');
  works.forEach(function (w) {
    var q = miniPt(w.i), c = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
    c.setAttribute('cx', q[0]); c.setAttribute('cy', q[1]); c.setAttribute('r', 2.6);
    c.setAttribute('fill', '#0d1320'); c.setAttribute('stroke', 'rgba(214,222,240,.6)');
    dots.appendChild(c); w.miniDot = c;
  });
  App.updateMini = function (p) {
    var q = miniPt(p), a = p * App.STEP;
    $('#miniCam').setAttribute('transform', 'translate(' + q[0].toFixed(2) + ' ' + q[1].toFixed(2) + ') rotate(' + (a * 180 / Math.PI + 180).toFixed(1) + ')');
    var t = ''; for (var s = 0; s <= Math.round(p * 10); s++) { var r = miniPt(s / 10); t += (s ? 'L' : 'M') + r[0].toFixed(1) + ' ' + r[1].toFixed(1); }
    $('#miniTrail').setAttribute('d', t);
    $('#railFill').style.height = 'calc((100% - 28px) * ' + (p / (N - 1)).toFixed(4) + ')';
  };

  // ---- focus caption ----
  var liveTimer;
  App.setFocus = function (i, force) {
    if (i === App.index && !force) return;
    App.index = i;
    var w = works[i];
    $('#capHour').textContent = w.hour;
    $('#capLvl').textContent = 'Level ' + pad(i + 1) + ' / ' + pad(N);
    var t = $('#capTitle'), b = $('#capBy');
    t.textContent = w.title; b.textContent = w.artist + ' · ' + w.year;
    [t, b].forEach(function (el) { el.classList.remove('swap'); void el.offsetWidth; el.classList.add('swap'); });
    $('#miniTxt').textContent = w.hour;
    works.forEach(function (x) {
      x.railBtn.setAttribute('aria-current', x.i === i ? 'true' : 'false');
      x.miniDot.setAttribute('fill', x.i === i ? '#f3a95e' : (x.i < i ? '#6b5a44' : '#0d1320'));
      x.miniDot.setAttribute('r', x.i === i ? 4 : 2.6);
    });
    $('#prevBtn').disabled = i === 0; $('#nextBtn').disabled = i === N - 1;
    clearTimeout(liveTimer);
    liveTimer = setTimeout(function () {
      if (!App.detailOpen) $('#live').textContent = 'Level ' + (i + 1) + ' of ' + N + ', ' + w.hour + ': ' + w.title + ' by ' + w.artist + '.';
    }, 450);
  };

  // go = travel on the stair (3D handles the camera; without GL this just updates the caption)
  App.go = function (i, opts) {
    i = Math.max(0, Math.min(N - 1, i));
    App.targetIndex = i;
    if (App.gl) App.gl.travel(i, opts); else App.setFocus(i);
    hideHint();
  };

  // ---- detail dialog ----
  var detail = $('#detail'), lastFocus = null;
  function fillDetail(i) {
    var w = works[i];
    $('#dLvl').innerHTML = '<b>' + w.hour + '</b> · Level ' + pad(i + 1);
    $('#dTitle').textContent = w.title;
    $('#dArtist').textContent = w.artist;
    $('#dYear').textContent = w.year; $('#dMedium').textContent = w.medium; $('#dSize').textContent = w.size; $('#dPlace').textContent = w.place;
    $('#dDesc').textContent = w.desc;
    var img = $('#dImg'); img.src = w.img; img.alt = w.alt;
    $('#dPos').textContent = (i + 1) + ' / ' + N;
    var p = works[i - 1], n = works[i + 1];
    $('#dPrev').disabled = !p; $('#dPrevT').textContent = p ? p.title : '—';
    $('#dNext').disabled = !n; $('#dNextT').textContent = n ? n.title : '—';
    $('#dPrev').setAttribute('aria-label', p ? 'Earlier: ' + p.hour + ', ' + p.title : 'No earlier work');
    $('#dNext').setAttribute('aria-label', n ? 'Later: ' + n.hour + ', ' + n.title : 'No later work');
    syncSave();
  }
  App.openDetail = function (i) {
    if (i == null) i = App.index;
    if (!App.detailOpen) lastFocus = document.activeElement;
    App.detailOpen = true; App.detailIndex = i;
    fillDetail(i);
    if (App.gl) App.gl.travel(i, { zoom: true }); else App.setFocus(i);
    detail.classList.add('-open');
    document.body.classList.add('-detail');
    var f = function () { if (App.detailOpen && !detail.contains(document.activeElement)) $('#dClose').focus({ preventScroll: true }); };
    setTimeout(f, 30); setTimeout(f, 350);
    $('#live').textContent = 'Opened ' + works[i].title + '.';
  };
  App.closeDetail = function () {
    if (!App.detailOpen) return;
    App.detailOpen = false;
    detail.classList.remove('-open');
    document.body.classList.remove('-detail');
    if (App.gl) App.gl.zoom(false);
    if (lastFocus && document.contains(lastFocus) && lastFocus.offsetParent !== null) lastFocus.focus({ preventScroll: true });
    else $('#openBtn').focus({ preventScroll: true });
  };
  App.stepDetail = function (d) {
    var i = App.detailIndex + d;
    if (i < 0 || i >= N) return;
    App.detailIndex = i; fillDetail(i);
    if (App.gl && App.view === '3d') App.gl.travel(i, { zoom: true }); else App.setFocus(i);
    $('#live').textContent = works[i].hour + ': ' + works[i].title + ' by ' + works[i].artist + '.';
  };
  $('#dClose').addEventListener('click', App.closeDetail);
  $('#dPrev').addEventListener('click', function () { App.stepDetail(-1); });
  $('#dNext').addEventListener('click', function () { App.stepDetail(1); });
  detail.addEventListener('keydown', function (e) {
    if (e.key === 'Tab') { // focus trap
      var f = Array.prototype.filter.call(detail.querySelectorAll('button:not(:disabled)'), function (b) { return b.offsetParent !== null; });
      var first = f[0], last = f[f.length - 1];
      if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
      else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
    }
  });

  // ---- route (saved) ----
  function syncSave() {
    var w = works[App.detailIndex], on = !!saved[w.id], b = $('#dSave');
    b.setAttribute('aria-pressed', on ? 'true' : 'false');
    b.textContent = on ? 'On your route ✓' : 'Add to my route';
  }
  function syncRoute() {
    var n = 0;
    works.forEach(function (w) { var on = !!saved[w.id]; if (on) n++; w.el.classList.toggle('is-saved', on); w.railBtn.classList.toggle('saved', on); });
    $('#routeCount').textContent = n; $('#fRouteN').textContent = n;
    $('#routeBtn').setAttribute('aria-label', 'My route, ' + n + ' saved');
    applyFilter();
    if (App.gl) App.gl.setSaved(works.map(function (w) { return !!saved[w.id]; }));
  }
  $('#dSave').addEventListener('click', function () {
    var w = works[App.detailIndex];
    if (saved[w.id]) delete saved[w.id]; else saved[w.id] = 1;
    persist(); syncSave(); syncRoute();
    $('#live').textContent = saved[w.id] ? w.title + ' added to your route.' : w.title + ' removed from your route.';
  });

  // ---- index view + filter ----
  var filter = 'all';
  function applyFilter() {
    var shown = 0;
    works.forEach(function (w) { var vis = filter === 'all' || saved[w.id]; w.el.hidden = !vis; if (vis) shown++; });
    $('#empty').hidden = shown > 0;
    $('#fAll').setAttribute('aria-pressed', filter === 'all'); $('#fRoute').setAttribute('aria-pressed', filter === 'route');
    $('#routeBtn').setAttribute('aria-pressed', App.view === 'list' && filter === 'route' ? 'true' : 'false');
    $('#viewToggle').setAttribute('aria-pressed', App.view === 'list' && filter === 'all' ? 'true' : 'false');
  }
  App.setView = function (v, f) {
    if (f) filter = f;
    App.view = v;
    document.body.classList.toggle('-list', v === 'list');
    document.body.classList.toggle('-flat', v === 'list' || !App.gl);
    $('#hud').querySelectorAll('.rail, .caption, .mini').forEach(function (el) { el.inert = v === 'list'; el.style.visibility = v === 'list' ? 'hidden' : ''; });
    $('#index').inert = v !== 'list' && !!App.gl;
    applyFilter();
    if (App.gl) App.gl.setActive(v === '3d');
  };
  $('#viewToggle').addEventListener('click', function () {
    var toList = !(App.view === 'list' && filter === 'all');
    App.setView(toList ? 'list' : '3d', 'all');
    if (toList) $('#works').focus({ preventScroll: true });
  });
  $('#routeBtn').addEventListener('click', function () {
    var on = !(App.view === 'list' && filter === 'route');
    if (!App.gl) { filter = on ? 'route' : 'all'; applyFilter(); return; }
    App.setView(on ? 'list' : '3d', on ? 'route' : 'all');
  });
  $('#fAll').addEventListener('click', function () { filter = 'all'; applyFilter(); });
  $('#fRoute').addEventListener('click', function () { filter = 'route'; applyFilter(); });
  works.forEach(function (w) {
    $('.open', w.el).addEventListener('click', function () { App.openDetail(w.i); });
    $('.goto', w.el).addEventListener('click', function () { App.setView('3d', 'all'); App.go(w.i); $('#openBtn').focus({ preventScroll: true }); });
  });
  $('#skipLink').addEventListener('click', function (e) { e.preventDefault(); App.setView('list', 'all'); $('#works').focus(); });

  // ---- caption controls ----
  $('#prevBtn').addEventListener('click', function () { App.go(App.targetIndex - 1); });
  $('#nextBtn').addEventListener('click', function () { App.go(App.targetIndex + 1); });
  $('#openBtn').addEventListener('click', function () { App.openDetail(App.index); });

  // ---- keyboard ----
  document.addEventListener('keydown', function (e) {
    if (e.altKey || e.ctrlKey || e.metaKey) return;
    if (e.key === 'Escape') {
      if (App.detailOpen) { e.preventDefault(); App.closeDetail(); }
      else if (App.view === 'list' && App.gl) { e.preventDefault(); App.setView('3d', 'all'); $('#viewToggle').focus(); }
      return;
    }
    if (App.detailOpen) {
      if (e.key === 'ArrowLeft') { e.preventDefault(); App.stepDetail(-1); }
      else if (e.key === 'ArrowRight') { e.preventDefault(); App.stepDetail(1); }
      return;
    }
    if (App.view !== '3d') return;
    var tag = (document.activeElement && document.activeElement.tagName) || '';
    var k = e.key;
    if (k === 'ArrowRight' || k === 'ArrowUp' || k === 'PageUp') { e.preventDefault(); App.go(App.targetIndex + 1); }
    else if (k === 'ArrowLeft' || k === 'ArrowDown' || k === 'PageDown') { e.preventDefault(); App.go(App.targetIndex - 1); }
    else if (k === 'Home') { e.preventDefault(); App.go(0); }
    else if (k === 'End') { e.preventDefault(); App.go(N - 1); }
    else if ((k === 'Enter' || k === ' ') && tag !== 'BUTTON' && tag !== 'A') { e.preventDefault(); App.openDetail(App.index); }
  });

  var hintGone = false;
  function hideHint() { if (hintGone) return; hintGone = true; $('#hint').classList.add('-gone'); }
  App.hideHint = hideHint;

  // ---- WebGL availability + fallback ----
  function hasGL() {
    try { var c = document.createElement('canvas'); return !!(window.WebGL2RenderingContext && c.getContext('webgl2')); } catch (e) { return false; }
  }
  App.fallback = function (why) {
    if (App.gl) return;
    App.noGL = true;
    document.body.classList.add('-noGL', '-flat');
    $('#stage').style.display = 'none';
    $('#loader').classList.add('-done');
    App.setView('list', 'all');
    $('#viewToggle').hidden = true;
    if (why) console.info('[gallery] list view:', why);
  };
  App.ready = function () { $('#loader').classList.add('-done'); };
  App.progress = function (f) { $('#loadBar').style.width = Math.round(f * 100) + '%'; };

  App.setFocus(0, true); App.updateMini(0); syncRoute();
  App.detailIndex = 0; App.targetIndex = 0;
  $('#index').inert = true;
  if (!hasGL()) App.fallback('WebGL2 unavailable');
  else setTimeout(function () { if (!App.gl) App.fallback('3D engine did not load'); }, 9000);
})();
</script>

<!-- 3D stair (module). If it fails to load, the shell above falls back to the list view. -->
<script type="module">
import * as THREE from 'three';
import { Reflector } from 'three/addons/objects/Reflector.js';
import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js';
import { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js';

const App = window.App;
if (!App.noGL) start();

function start() {
  const canvas = document.getElementById('gl');
  let renderer;
  try {
    renderer = new THREE.WebGLRenderer({ canvas, antialias: true, powerPreference: 'high-performance' });
  } catch (e) { App.fallback('renderer failed'); return; }
  renderer.setPixelRatio(Math.min(devicePixelRatio, 1.75));
  renderer.outputColorSpace = THREE.SRGBColorSpace;
  renderer.toneMapping = THREE.ACESFilmicToneMapping;   // frames, glass, hall; prints bypass it
  renderer.toneMappingExposure = 1.0;
  let active = App.view === '3d', raf = 0, lastT = performance.now(), time = 0, lastFocus = -1;
  const FOG = new THREE.Color('#0b1120');
  renderer.setClearColor(FOG, 1);

  const scene = new THREE.Scene();
  scene.fog = new THREE.FogExp2(FOG, 0.06);
  // Harbour Hall: a Cycles-rendered 360° plate of the concrete stairwell (Blender, baked offline).
  // It is the room you see, the room the water reflects, and the light the frames and glass pick up.
  const pmrem = new THREE.PMREMGenerator(renderer);
  const hall = new THREE.Mesh(new THREE.SphereGeometry(24, 64, 32), new THREE.MeshBasicMaterial({ side: THREE.BackSide, fog: false, color: 0x000000 }));
  scene.add(hall);
  loader_hall();
  function loader_hall() {
    new THREE.TextureLoader().load('assets/hall-360.webp', t => {
      t.mapping = THREE.EquirectangularReflectionMapping; t.colorSpace = THREE.SRGBColorSpace;
      scene.environment = pmrem.fromEquirectangular(t).texture;
      hall.material.map = t; hall.material.color.setScalar(.62); hall.material.needsUpdate = true;
    });
  }
  const camera = new THREE.PerspectiveCamera(40, 1, 0.1, 80);

  // ---- helix constants ----
  const N = App.N, STEP = App.STEP;        // radians between levels
  const R = 3.3;                            // card-centre radius
  const RISE = 1.15;                        // height between levels
  const PW = 1.3, PH = 1.733;               // the print (3:4)
  const MAT = 0.13, MOULD = 0.055, DEPTH = 0.075;
  const CW = PW + MAT * 2 + MOULD * 2, CH = PH + MAT * 2 + MOULD * 2; // framed object
  const FLOOR = -1.42;
  const helixAt = (p, r = R) => new THREE.Vector3(Math.sin(p * STEP) * r, p * RISE, Math.cos(p * STEP) * r);

  // ---- materials ----
  const loader = new THREE.TextureLoader();
  let loaded = 0;
  const cardMats = [], cards = [], hits = [];
  const cardGeo = new THREE.PlaneGeometry(PW, PH);
  // shared framed-object parts: anodised moulding, cotton mat board with a bevel, glass, backing
  const mouldMat = new THREE.MeshStandardMaterial({ color: '#0d0e11', metalness: .7, roughness: .32, envMapIntensity: 1.6 });
  const boardMat = new THREE.MeshStandardMaterial({ color: '#e6e1d6', roughness: .92, emissive: '#6f6b63', envMapIntensity: 1.2 });
  const bevelMat = new THREE.MeshStandardMaterial({ color: '#f6f2ea', roughness: .8, emissive: '#a8a398' });
  const glassMat = new THREE.MeshStandardMaterial({ color: '#ffffff', metalness: 1, roughness: .04, transparent: true, opacity: .11, blending: THREE.AdditiveBlending, depthWrite: false, envMapIntensity: 2.2 });
  const mouldGeoH = new RoundedBoxGeometry(CW, MOULD, DEPTH, 2, .012);
  const mouldGeoV = new RoundedBoxGeometry(MOULD, CH - MOULD * 2, DEPTH, 2, .012);
  const boardGeo = new THREE.BoxGeometry(CW - MOULD * 2, CH - MOULD * 2, .012);
  const bevelGeoH = new THREE.BoxGeometry(PW + .024, .012, .016), bevelGeoV = new THREE.BoxGeometry(.012, PH + .024, .016);
  const glassGeo = new THREE.PlaneGeometry(CW - MOULD * 2, CH - MOULD * 2);
  // one merged moulding and one merged bevel geometry, shared by all eight frames (4 draw calls per frame)
  const place = (geo, x, y, z) => geo.clone().translate(x, y, z);
  const zf = -DEPTH / 2 + .03;
  const mouldGeo = mergeGeometries([
    place(mouldGeoH, 0, (CH - MOULD) / 2, zf), place(mouldGeoH, 0, -(CH - MOULD) / 2, zf),
    place(mouldGeoV, (CW - MOULD) / 2, 0, zf), place(mouldGeoV, -(CW - MOULD) / 2, 0, zf)]);
  const bevelGeo = mergeGeometries([
    place(bevelGeoH, 0, PH / 2 + .006, .004), place(bevelGeoH, 0, -PH / 2 - .006, .004),
    place(bevelGeoV, PW / 2 + .006, 0, .004), place(bevelGeoV, -PW / 2 - .006, 0, .004)]);
  function buildFrame(g) {
    const parts = [[mouldGeo, mouldMat, 0], [boardGeo, boardMat, -.004], [bevelGeo, bevelMat, 0], [glassGeo, glassMat, .034]];
    for (const [geo, m, z] of parts) { const o = new THREE.Mesh(geo, m); o.position.z = z; g.add(o); }
  }
  const vert = `
    varying vec2 vUv;
    #include <fog_pars_vertex>
    void main(){
      vUv = uv;
      vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
      gl_Position = projectionMatrix * mvPosition;
      #include <fog_vertex>
    }`;
  const frag = `
    uniform sampler2D map; uniform float uBlur, uDim, uHover, uLoaded, uSaved, uTime;
    varying vec2 vUv;
    #include <fog_pars_fragment>
    void main(){
      vec3 c = texture2D(map, vUv, uBlur).rgb;
      float g = dot(c, vec3(.299,.587,.114));
      c = mix(c, vec3(g) * vec3(.82,.9,1.05), uDim * .55);
      c *= (1.0 - uDim * .5) * (1.0 + uHover * .14);
      vec2 e = smoothstep(0.0, .05, vUv) * smoothstep(0.0, .05, 1.0 - vUv);
      c *= mix(.72, 1.0, e.x * e.y);
      // thin warm hairline when saved to route
      float edge = 1.0 - step(.012, min(min(vUv.x, 1.0 - vUv.x), min(vUv.y, 1.0 - vUv.y) * .75));
      c = mix(c, vec3(.62,.84,1.0), edge * uSaved);
      c = mix(vec3(.035,.05,.08), c, uLoaded);
      // film grain so the prints read as paper, not screens
      float n = fract(sin(dot(vUv * 1024.0 + fract(uTime) * 61.0, vec2(12.9898, 78.233))) * 43758.5453);
      c += (n - .5) * .014 * (1.0 - uDim);
      gl_FragColor = vec4(c, 1.0);
      #include <colorspace_fragment>
      #include <fog_fragment>
    }`;

  // ---- spine, treads, landing lights ----
  const stair = new THREE.Group(); scene.add(stair);
  const top = (N - 1) * RISE;
  const spine = new THREE.Mesh(new THREE.CylinderGeometry(0.55, 0.55, top + 14, 40, 1, true),
    new THREE.MeshBasicMaterial({ color: '#1a2233' }));
  spine.position.y = FLOOR + (top + 14) / 2; stair.add(spine);
  const treadGeo = new THREE.BoxGeometry(0.5, 0.08, 2.55);
  treadGeo.translate(0, 0, 0.55 + 2.55 / 2);
  const treadMat = new THREE.MeshBasicMaterial({ color: '#2c3649' });
  const lampGeo = new THREE.BoxGeometry(0.34, 0.025, 0.05);
  const lampMat = new THREE.MeshBasicMaterial({ color: new THREE.Color('#f3a95e').multiplyScalar(1.6) });
  const SUB = 5; // treads per level
  const tStart = -1.6, tEnd = N - 1 + 1.2;
  const treadCount = Math.ceil((tEnd - tStart) * SUB);
  const treads = new THREE.InstancedMesh(treadGeo, treadMat, treadCount);
  const lamps = new THREE.InstancedMesh(lampGeo, lampMat, treadCount);
  const m4 = new THREE.Matrix4(), q = new THREE.Quaternion(), sc = new THREE.Vector3(1, 1, 1), up = new THREE.Vector3(0, 1, 0);
  for (let k = 0; k < treadCount; k++) {
    const p = tStart + k / SUB;
    const y = p * RISE - CH / 2 - 0.32;
    q.setFromAxisAngle(up, p * STEP);
    m4.compose(new THREE.Vector3(0, y, 0), q, sc); treads.setMatrixAt(k, m4);
    const lp = new THREE.Vector3(Math.sin(p * STEP) * 3.98, y + 0.05, Math.cos(p * STEP) * 3.98);
    m4.compose(lp, q, sc); lamps.setMatrixAt(k, m4);
  }
  stair.add(treads, lamps);
  // glowing handrail: the line that makes the helix legible at a glance
  const railPts = [];
  for (let p = tStart; p <= tEnd; p += 0.05) railPts.push(new THREE.Vector3(Math.sin(p * STEP) * 4.0, p * RISE - CH / 2 - 0.2, Math.cos(p * STEP) * 4.0));
  const railCurve = new THREE.CatmullRomCurve3(railPts);
  const railMat = new THREE.MeshBasicMaterial({ color: new THREE.Color('#f3a95e').multiplyScalar(1.25) });
  stair.add(new THREE.Mesh(new THREE.TubeGeometry(railCurve, 600, 0.014, 6, false), railMat));

  // ---- cards ----
  const timeTex = (w) => {
    const c = document.createElement('canvas'); c.width = 512; c.height = 64;
    const x = c.getContext('2d');
    x.font = '500 30px "Geist Mono", ui-monospace, monospace';
    x.fillStyle = '#f3a95e'; x.textBaseline = 'middle'; x.fillText(w.hour, 4, 34);
    x.fillStyle = 'rgba(214,222,240,.72)'; x.font = '400 24px "Geist Mono", ui-monospace, monospace';
    x.textAlign = 'right'; x.fillText('LVL ' + String(w.i + 1).padStart(2, '0'), 508, 34);
    const t = new THREE.CanvasTexture(c); t.colorSpace = THREE.SRGBColorSpace; t.anisotropy = 4; return t;
  };
  App.works.forEach((w, i) => {
    const g = new THREE.Group();
    const pos = helixAt(i); g.position.copy(pos); g.rotation.y = i * STEP;
    const tex = loader.load(w.img, t => { mat.uniforms.uLoaded.value = 0; tintFrom(t.image, glow.material.uniforms.uC.value); loadedOne(mat); }, undefined, () => loadedOne(null));
    tex.colorSpace = THREE.SRGBColorSpace; tex.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
    tex.generateMipmaps = true; tex.minFilter = THREE.LinearMipmapLinearFilter;
    const mat = new THREE.ShaderMaterial({
      uniforms: THREE.UniformsUtils.merge([THREE.UniformsLib.fog, {
        map: { value: null }, uBlur: { value: 0 }, uDim: { value: 0 }, uHover: { value: 0 }, uLoaded: { value: 0 }, uSaved: { value: 0 }, uTime: { value: 0 }
      }]),
      vertexShader: vert, fragmentShader: frag, fog: true
    });
    mat.uniforms.map.value = tex;
    const mesh = new THREE.Mesh(cardGeo, mat); mesh.userData.i = i;
    // frame / mat board behind the print
    const frame = new THREE.Mesh(new THREE.BoxGeometry(CW - .02, CH - .02, DEPTH - .01), new THREE.MeshStandardMaterial({ color: '#08090c', roughness: .7 }));
    frame.position.z = -DEPTH / 2 - .006; frame.userData.i = i;
    const glow = new THREE.Mesh(new THREE.PlaneGeometry(CW + 0.9, CH + 0.9), new THREE.ShaderMaterial({
      transparent: true, depthWrite: false, uniforms: { uA: { value: 0 }, uC: { value: new THREE.Color(1, .72, .42) } },
      vertexShader: 'varying vec2 vUv; void main(){ vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); }',
      fragmentShader: 'uniform float uA; uniform vec3 uC; varying vec2 vUv; void main(){ vec2 d = abs(vUv - .5) * 2.0; float r = max(d.x, d.y); float a = pow(smoothstep(1.0, .7, r), 1.6) * uA * .5; gl_FragColor = vec4(uC * a, a); }'
    }));
    glow.position.z = -DEPTH - .02;
    const label = new THREE.Mesh(new THREE.PlaneGeometry(CW, CW / 8), new THREE.MeshBasicMaterial({ map: timeTex(w), transparent: true, fog: true }));
    label.position.set(0, -CH / 2 - 0.13, 0);
    mesh.position.z = .006;
    g.add(glow, frame, mesh, label);
    buildFrame(g);
    g.userData = { mesh, mat, glow, label, hover: 0 };
    stair.add(g); cards.push(g); cardMats.push(mat); hits.push(mesh, frame);
    w.labelMesh = label;
  });
  document.fonts && document.fonts.ready.then(() => App.works.forEach(w => { w.labelMesh.material.map = timeTex(w); w.labelMesh.material.needsUpdate = true; }));

  // average colour of a print, boosted: its light spills onto the mat board halo and the water
  function tintFrom(img, out) {
    try {
      const c = document.createElement('canvas'); c.width = c.height = 8;
      const x = c.getContext('2d'); x.drawImage(img, 0, 0, 8, 8);
      const d = x.getImageData(0, 0, 8, 8).data; let r = 0, g = 0, b = 0, wsum = 0;
      for (let k = 0; k < d.length; k += 4) { const l = (d[k] + d[k+1] + d[k+2]) / 765, w = l * l + .02; r += d[k] * w; g += d[k+1] * w; b += d[k+2] * w; wsum += w; }
      out.setRGB(r / wsum / 255, g / wsum / 255, b / wsum / 255, THREE.SRGBColorSpace);
      const hsl = {}; out.getHSL(hsl); out.setHSL(hsl.h, Math.min(1, hsl.s * 1.5 + .15), .55);
    } catch (e) {}
  }

  function loadedOne(mat) {
    loaded++;
    App.progress(loaded / N);
    if (mat) mat.userData.fadeIn = true;
    if (loaded === N) begin();
  }

  // ---- floor: planar reflection + fog falloff ----
  // custom Reflector shader: the mirror image is refracted by a ring buffer of 24 ripples
  // (pointer trail on the water + an ambient "drip" every ~1 s) and lit by their crests.
  const RIPPLES = 24;
  const rippleData = Array.from({ length: RIPPLES }, () => new THREE.Vector4(0, 0, -99, 0));
  let rippleHead = 0;
  const waterShader = {
    name: 'StairwellWater',
    uniforms: { color: { value: null }, tDiffuse: { value: null }, textureMatrix: { value: null }, uTime: { value: 0 }, uR: { value: rippleData } },
    vertexShader: `uniform mat4 textureMatrix; varying vec4 vUv; varying vec2 vP;
      void main(){ vP = position.xy; vUv = textureMatrix * vec4(position, 1.0); gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }`,
    fragmentShader: `uniform sampler2D tDiffuse; uniform float uTime; uniform vec4 uR[${RIPPLES}];
      varying vec4 vUv; varying vec2 vP;
      void main(){
        vec2 off = vec2(0.0); float crest = 0.0;
        for (int i = 0; i < ${RIPPLES}; i++) {
          vec4 r = uR[i]; float age = uTime - r.z;
          if (age < 0.0 || age > 3.2) continue;
          vec2 d = vP - r.xy; float dist = length(d);
          float front = dist - age * 1.35;                       // ring travels at 1.35 u/s
          float env = exp(-front * front * 9.0) * (1.0 - age / 3.2) * r.w / (1.0 + dist * .6);
          float wave = sin(front * 18.0) * env;
          off += (d / max(dist, 1e-3)) * wave; crest += max(wave, 0.0);
        }
        // slow standing swell so the pool never looks frozen
        off += vec2(sin(vP.y * 2.1 + uTime * .6), cos(vP.x * 1.7 - uTime * .5)) * .012;
        vec4 uv = vUv; uv.xy += off * .085 * uv.w;
        vec3 base = texture2DProj(tDiffuse, uv).rgb;
        vec3 c = base * .82 + vec3(.95, .78, .58) * crest * .07;
        gl_FragColor = vec4(c, 1.0);
        #include <tonemapping_fragment>
        #include <colorspace_fragment>
      }`
  };
  const reflector = new Reflector(new THREE.CircleGeometry(40, 96), {
    textureWidth: 1024, textureHeight: 1024, clipBias: 0.003, shader: waterShader
  });
  const waterU = reflector.material.uniforms;
  const floorPlane = new THREE.Plane(new THREE.Vector3(0, 1, 0), -FLOOR), hitP = new THREE.Vector3();
  function ripple(x, z, strength) {
    // circle is rotated -90° about X: local (x, y) = world (x, -z)
    rippleData[rippleHead].set(x, -z, time, strength);
    rippleHead = (rippleHead + 1) % RIPPLES;
  }
  let lastRip = { x: 1e9, z: 1e9, t: 0 }, nextDrip = 1.2;
  reflector.rotation.x = -Math.PI / 2; reflector.position.y = FLOOR;
  scene.add(reflector);
  const veil = new THREE.Mesh(new THREE.CircleGeometry(40, 64), new THREE.ShaderMaterial({
    transparent: true, depthWrite: false,
    uniforms: { uColor: { value: FOG }, uTime: { value: 0 } },
    vertexShader: 'varying vec2 vP; void main(){ vP = position.xy; gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); }',
    fragmentShader: `uniform vec3 uColor; uniform float uTime; varying vec2 vP;
      void main(){
        float d = length(vP);
        float ring = smoothstep(.04, 0.0, abs(d - 4.15)) * .5;           // brass inlay ring under the stair
        float a = mix(.28, 1.0, smoothstep(3.5, 19.0, d)) - ring;
        float n = sin(vP.x * 1.7 + uTime * .2) * sin(vP.y * 1.3 - uTime * .15) * .04;
        vec3 c = uColor + vec3(.95,.66,.37) * ring * .9;
        gl_FragColor = vec4(c, clamp(a + n, 0.0, 1.0));
        #include <colorspace_fragment>
      }`
  }));
  veil.rotation.x = -Math.PI / 2; veil.position.y = FLOOR + 0.004;
  scene.add(veil);

  // ---- dust ----
  const DUST = matchMedia('(max-width: 600px)').matches ? 260 : 520;
  const dpos = new Float32Array(DUST * 3), dsd = new Float32Array(DUST);
  for (let k = 0; k < DUST; k++) {
    const a = Math.random() * Math.PI * 2, r = 1 + Math.random() * 9;
    dpos[k * 3] = Math.sin(a) * r; dpos[k * 3 + 1] = Math.random() * 14 - 2; dpos[k * 3 + 2] = Math.cos(a) * r; dsd[k] = Math.random();
  }
  const dgeo = new THREE.BufferGeometry();
  dgeo.setAttribute('position', new THREE.BufferAttribute(dpos, 3));
  dgeo.setAttribute('aSeed', new THREE.BufferAttribute(dsd, 1));
  const dmat = new THREE.ShaderMaterial({
    transparent: true, depthWrite: false, blending: THREE.AdditiveBlending,
    uniforms: { uTime: { value: 0 }, uPx: { value: renderer.getPixelRatio() } },
    vertexShader: `attribute float aSeed; uniform float uTime, uPx; varying float vA;
      void main(){
        vec3 p = position;
        p.y = mod(p.y + uTime * (.04 + aSeed * .06) + 2.0, 14.0) - 2.0;
        p.x += sin(uTime * .3 + aSeed * 20.0) * .2;
        vec4 mv = modelViewMatrix * vec4(p, 1.0);
        gl_Position = projectionMatrix * mv;
        gl_PointSize = (1.0 + aSeed * 2.2) * uPx * (6.0 / -mv.z);
        vA = (.25 + .55 * aSeed) * smoothstep(22.0, 3.0, -mv.z);
      }`,
    fragmentShader: `varying float vA; void main(){ float d = length(gl_PointCoord - .5); float a = smoothstep(.5, 0.0, d) * vA; gl_FragColor = vec4(vec3(1.0,.82,.6) * a, a); }`
  });
  scene.add(new THREE.Points(dgeo, dmat));

  // ---- travel state ----
  let cur = -1.4, target = 0, zoomT = 0, zoomC = 0, intro = 0, started = false;
  let pendingAt = 0, vel = 0, wheelTimer = null, dragging = false, moved = 0, last = { x: 0, y: 0, t: 0 }, pendingOpen = -1;
  const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
  const snap = () => { target = clamp(Math.round(target), 0, N - 1); App.targetIndex = target; };
  App.gl = {
    travel(i, opts = {}) {
      target = i;
      if (opts.zoom) zoomT = 1;
      if (App.reduced) cur = target;
      if (!opts.keepOpen && !opts.zoom && App.detailOpen) {}
    },
    zoom(on) { zoomT = on ? 1 : 0; },
    setActive(on) { active = on; if (on) kick(); },
    screenOf(i) { const v = cards[i].position.clone().project(camera); return [(v.x + 1) / 2 * W, (1 - v.y) / 2 * H]; },
    setSaved(arr) { arr.forEach((s, i) => cardMats[i].uniforms.uSaved.value = s ? 1 : 0); }
  };
  App.setView(App.view);
  App.gl.setSaved(App.works.map(w => document.querySelector('[data-id="' + w.id + '"]').classList.contains('is-saved')));

  function begin() {
    if (started) return; started = true;
    canvas.classList.add('-on');
    App.ready();
    if (App.reduced) { cur = 0; intro = 1; }
  }
  setTimeout(begin, 6000); // never hang on a slow image

  // ---- input ----
  const pointer = new THREE.Vector2(), ray = new THREE.Raycaster();
  let hoverI = -1;
  function setRay(e) {
    const r = canvas.getBoundingClientRect();
    pointer.set(((e.clientX - r.left) / r.width) * 2 - 1, -((e.clientY - r.top) / r.height) * 2 + 1);
    ray.setFromCamera(pointer, camera);
  }
  function pick(e) {
    setRay(e);
    const h = ray.intersectObjects(hits, false).find(x => x.face && x.object.material && x.face.normal);
    if (!h) return -1;
    // only the front face of a print is clickable
    const n = h.face.normal.clone().transformDirection(h.object.matrixWorld);
    return n.dot(ray.ray.direction) < 0 ? h.object.userData.i : -1;
  }
  canvas.addEventListener('pointerdown', e => {
    if (!started) return;
    dragging = true; moved = 0; vel = 0;
    last = { x: e.clientX, y: e.clientY, t: performance.now() };
    canvas.setPointerCapture(e.pointerId);
  });
  canvas.addEventListener('pointermove', e => {
    if (dragging) {
      const dx = e.clientX - last.x, dy = e.clientY - last.y, now = performance.now();
      moved += Math.abs(dx) + Math.abs(dy);
      if (moved > 6) {
        canvas.classList.add('-drag');
        const k = 1 / Math.max(320, Math.min(innerWidth, innerHeight) * .62);
        const d = -(dx * 1.0 + dy * 1.25) * k * 1.6;
        target = clamp(target + d, -0.35, N - 1 + 0.35);
        vel = d / Math.max(8, now - last.t) * 16;
        if (App.detailOpen) App.closeDetail();
        App.hideHint();
      }
      last = { x: e.clientX, y: e.clientY, t: now };
    } else if (e.pointerType === 'mouse') {
      hoverI = pick(e);
      canvas.classList.toggle('-hover', hoverI >= 0);
    }
    // pointer trail on the water
    setRay(e);
    if (!App.reduced && hoverI < 0 && ray.ray.intersectPlane(floorPlane, hitP) && hitP.length() < 30) {
      const dd = Math.hypot(hitP.x - lastRip.x, hitP.z - lastRip.z);
      if (dd > 0.45 || time - lastRip.t > 0.25 && dd > 0.08) { ripple(hitP.x, hitP.z, 1); lastRip = { x: hitP.x, z: hitP.z, t: time }; }
    }
  });
  const endDrag = e => {
    if (!dragging) return;
    dragging = false; canvas.classList.remove('-drag');
    if (moved <= 6) {
      const i = pick(e);
      if (i >= 0) {
        if (App.detailOpen && i === App.detailIndex) return;
        App.go(i); pendingOpen = i; pendingAt = performance.now();
        if (App.reduced) { App.openDetail(i); pendingOpen = -1; }
      } else if (App.detailOpen) App.closeDetail();
      return;
    }
    target += App.reduced ? 0 : vel * 6;
    snap();
  };
  canvas.addEventListener('pointerup', endDrag);
  canvas.addEventListener('pointercancel', endDrag);
  canvas.addEventListener('pointerleave', () => { if (!dragging) { hoverI = -1; canvas.classList.remove('-hover'); } });
  addEventListener('wheel', e => {
    if (App.view !== '3d' || !started) return;
    if (e.target.closest && e.target.closest('.detail, .index')) return;
    e.preventDefault();
    const dy = (e.deltaMode === 1 ? e.deltaY * 16 : e.deltaY) + (e.deltaMode === 1 ? e.deltaX * 16 : e.deltaX);
    target = clamp(target + clamp(dy, -120, 120) * 0.0032, -0.3, N - 1 + 0.3);
    if (App.detailOpen) App.closeDetail();
    App.hideHint();
    clearTimeout(wheelTimer);
    wheelTimer = setTimeout(snap, App.reduced ? 0 : 160);
    if (App.reduced) { snap(); cur = target; }
  }, { passive: false });

  // ---- resize ----
  let W = 0, H = 0, isPhone = false, isSheet = false;
  function resize() {
    W = innerWidth; H = innerHeight; isPhone = W <= 600; isSheet = W <= 900;
    renderer.setSize(W, H, false);
    camera.aspect = W / H; camera.updateProjectionMatrix();
    const s = Math.min(1024, Math.round(Math.max(W, H) * renderer.getPixelRatio() * .5));
    reflector.getRenderTarget().setSize(s, s);
  }
  addEventListener('resize', resize); resize();

  // ---- loop (pauses when hidden, list view, or off-screen) ----
  function kick() { if (!raf && active && !document.hidden) { lastT = performance.now(); raf = requestAnimationFrame(frame); } }
  document.addEventListener('visibilitychange', kick);
  const look = new THREE.Vector3(), camPos = new THREE.Vector3();
  const easeOut = t => 1 - Math.pow(1 - t, 3);

  function frame(now) {
    raf = 0;
    if (!active || document.hidden) return;
    const dt = Math.min(0.05, (now - lastT) / 1000); lastT = now;
    const rm = App.reduced;
    if (started) {
      time += rm ? 0 : dt;
      intro = rm ? 1 : Math.min(1, intro + dt / 2.6);
      if (!dragging && !wheelTimer) {}
      const k = rm ? 1 : 1 - Math.exp(-dt * (dragging ? 9 : 3.6));
      cur += (target - cur) * k;
      zoomC += (zoomT - zoomC) * (rm ? 1 : 1 - Math.exp(-dt * 3.2));
    }
    const ei = easeOut(intro);

    // focus + click-to-open once we arrive
    const fi = clamp(Math.round(cur), 0, N - 1);
    if (fi !== lastFocus && started) { lastFocus = fi; App.setFocus(fi); }
    if (pendingOpen >= 0 && (Math.abs(cur - pendingOpen) < 0.06 || now - pendingAt > 1500)) { App.openDetail(pendingOpen); pendingOpen = -1; }
    App.updateMini(clamp(cur, 0, N - 1));

    // camera on an outer helix, eased in from the floor during the intro
    const aspectF = Math.max(1, 0.72 / camera.aspect);
    const dist = (THREE.MathUtils.lerp(4.35, 3.75, zoomC) + (1 - ei) * 4.5) * aspectF;
    const ang = cur * STEP - (1 - ei) * 0.9;
    const sway = rm ? 0 : Math.sin(time * .45) * .06;
    camPos.set(Math.sin(ang) * (R + dist), cur * RISE + 0.28 - zoomC * 0.22 - (1 - ei) * 2.6 + sway, Math.cos(ang) * (R + dist));
    camera.position.copy(camPos);
    look.set(Math.sin(cur * STEP) * R * 0.86, cur * RISE - 0.05 - (1 - ei) * 0.6, Math.cos(cur * STEP) * R * 0.86);
    camera.lookAt(look);
    // make room for the detail panel (desktop: right side; phone: bottom sheet)
    let ox = 0, oy = isPhone ? 64 : H * 0.035;
    if (zoomC > 0.001) {
      if (isSheet) oy += zoomC * H * 0.26; else ox += zoomC * Math.min(440, W) / 2;
    }
    if (ox || oy) camera.setViewOffset(W, H, ox, oy, W, H); else camera.clearViewOffset();

    // per-card depth of field (mip-bias blur), dimming, hover swell
    for (let i = 0; i < N; i++) {
      const c = cards[i], u = c.userData.mat.uniforms, d = Math.abs(i - cur);
      u.uBlur.value = Math.min(4.5, d * 1.9);
      u.uDim.value = Math.min(1, d * 0.62);
      const h = (i === hoverI && !dragging) ? 1 : 0;
      c.userData.hover += (h - c.userData.hover) * (rm ? 1 : 1 - Math.exp(-dt * 10));
      u.uHover.value = c.userData.hover; u.uTime.value = time;
      if (c.userData.mat.userData.fadeIn) u.uLoaded.value = Math.min(1, u.uLoaded.value + dt * (rm ? 99 : 1.6));
      const s = 1 + c.userData.hover * 0.035;
      c.scale.setScalar(s);
      c.userData.glow.material.uniforms.uA.value = Math.max(0, 1 - d * 1.4) * (0.7 + 0.3 * zoomC);
      c.userData.label.material.opacity = Math.max(0.15, 1 - d * 0.7);
    }
    veil.material.uniforms.uTime.value = time;
    waterU.uTime.value = time;
    if (!rm && time > nextDrip) {   // ambient drip from the stair lamps
      const a = Math.random() * Math.PI * 2, r = 1.2 + Math.random() * 6;
      ripple(Math.sin(a) * r, Math.cos(a) * r, .55 + Math.random() * .4);
      nextDrip = time + .7 + Math.random() * 1.1;
    }
    dmat.uniforms.uTime.value = time;

    renderer.render(scene, camera);
    if (!window.__galleryFrame) window.__galleryFrame = 0;
    window.__galleryFrame++;
    raf = requestAnimationFrame(frame);
  }
  kick();
}
</script>
</body>
</html>

````
