# Recreate this site as a single HTML file: Ostra Field One — Speaker Product Page

## What it is

A premium, scroll-driven **product page for a portable speaker**, the *Ostra Field One* from a fictional audio brand. The speaker is a 20 cm cylinder with a woven fabric sleeve, turned aluminium end caps, a leather carry loop and an amber light ring on its top. **Signature:** the product is shown as **real Blender Cycles renders played back as image sequences on a `<canvas>`, scrubbed by scroll**. The hero turntable turns the speaker a full 360° behind a giant masked "Field One" wordmark while four material chapters fade in. A dark **exploded view** slides the sleeve off and separates seven internal parts along one axis. Labels for the parts are **projected with the render camera's own maths**, so they stay pinned to the parts as they move. After that come a giant word-by-word statement reveal, a weather-proof feature grid with small live motion in each tile, a **live WebAudio demo** (a synthesised groove, three DSP profiles and a light-ring visualiser), a **colour picker that swaps the turntable frame set** (drag to turn), a spec table with a battery-life estimator, a three-model compare, a muted lifestyle film, an FAQ, a sticky buy bar and a working bag with a validated checkout. It is a warm cream studio page with one dark chapter, not a black "tech" page.

## Page shell & libraries

- One `index.html`, inline `<style>` and one inline `<script>` (an IIFE, `'use strict'`). **No JS libraries.**
- Google Fonts: `Funnel Display` (wght 300–800, display), `Funnel Sans` (300–800 + italics, body), `Spline Sans Mono` (400/500, labels and numbers), with `display=swap`.
- `<link rel="preload" as="image">` for the first hero frame, with one link per breakpoint (`media="(min-width:700px)"` → desktop frame, `(max-width:699.98px)` → mobile frame) and `fetchpriority="high"`.
- Semantic landmarks: skip link, `<header class="nav">`, `<main>`, sections with `aria-labelledby`, `<footer>`, `<dialog>` for the bag.

## Tokens

- **Colour:** `--paper #ebe0cf` (this matches the rendered studio sweep at the frame edge, so the canvas blends into the page), `--paper-2 #e2d5c1`, `--card #f4ece0`, `--ink #1b1915`, `--muted #5d554a`, `--line rgba(27,25,21,.14)`. Accent `--amber #e9792f` is the light-ring colour, used for fills only. Accent text is `--amber-ink #9c4512`. Dark chapter: `--night #141311`, `--night-ink #efe8de`, `--night-muted #a69d90`. Colourway chips: Moss `#56634b`, Clay `#b85c3c`, Slate `#3a414c`.
- **Type scale:** hero word `clamp(84px, 21vw, 360px)` weight 800, tracking −0.06em, line-height .8. h2 `clamp(40px, 7vw, 104px)` weight 600, tracking −0.025em. Statement `clamp(34px, 5.6vw, 84px)` weight 500. Body 17px/1.55 (16px under 700px). Mono labels 12px, tracking .12–.14em, uppercase.
- **Radii:** 10 / 18 / 28 px. Pills are 999px. **Gutter:** `clamp(16px, 4vw, 56px)`. **Easing:** `cubic-bezier(.2,.7,.1,1)`.

## Layout & structure

1. **Nav** (fixed, 56px, translucent paper with `backdrop-filter: saturate(1.4) blur(14px)`): a logo (a small amber ring + "Ostra"), seven anchor links, "Field One · €249" in mono, an amber "Add to bag" pill and a bag icon with a count badge. Over dark sections it switches to a night background. A 2px amber **loader bar** under the nav shows the real frame-loading progress.
2. **Hero** `height: 420vh` with a sticky 100svh stage. The full-bleed `<canvas>` draws the turntable frame with *cover* fit. On top of it sits the giant word "Field One" with a vertical gradient fill (ink → transparent) and a horizontal **mask** (`linear-gradient(90deg,#000 0 38%, rgba(0,0,0,.08) 43% 60%, #000 65%)`) that fades the letters where the product stands, so the product reads *in front of* the type. Also on the stage: a mono readout "ROTATION 088° · FRAME 23/90" at top right, four chapter cards that alternate left and right ("Woven, not moulded." / "Turned from one billet." / "Carried by a single loop." / "A ring that answers."), and a bottom row with the one-line pitch, "From €249" + "Add to bag", and a "Scroll to turn it" cue.
3. **Statement**: "Built like a field instrument. Tuned like a studio monitor. Wrapped like your favourite coat." Each word is a span that goes from 16% ink to full ink as it scrolls past. The words "instrument / monitor / coat" turn `--amber-ink`.
4. **Exploded view** (dark, `height: 460vh`, sticky stage). The canvas plays the exploded sequence. Top left: eyebrow "Inside · 7 parts, 1 axis", h2 "Take it apart.", a short paragraph. Seven labels (dot + leader line + name/sub-line) alternate right and left of the stack. A footer row has a phase word (ASSEMBLED → SLEEVE OFF → SEPARATING → 7 PARTS · 1 AXIS), an amber progress bar and "690 g · Ø 84 × 205 mm".
5. **Features** "Made for weather." on a 12-column grid with 14px gaps:
   - Battery tile (7 cols, ink): "24 h" plus 24 amber cells that drain hour by hour on a loop, with a clock readout ("20:00 — evening").
   - IP67 tile (5 cols, pale blue-grey) with falling CSS rain streaks.
   - Light-ring tile (4): an SVG top-down view of the cap with a segmented control for Charge, Pairing and Night.
   - Shore photo (4).
   - Stereo-pair tile (4): two CSS speakers with expanding amber sound rings that alternate.
   - Power-out tile (4): a dashed amber "cable" that flows and a phone battery that fills.
   - Kitchen photo (8).
6. **Sound** (dark): a left column with an eyebrow, h2 "Hear the tuning.", a lede, a profile segmented control (Outdoor / Indoor / Night), a volume range, a live profile note and a mono meter (BPM, PEAK dB, BAR n/4). The right column holds a square canvas visualiser with a 118px round play button in its centre.
7. **Colourways**: a square spin stage (2:3 on mobile, `touch-action: pan-y`) with a canvas, a "drag to turn" pill and a load-status label. Next to it are an eyebrow, h2 "Three weaves. One loop.", a `role="radiogroup"` of three swatch cards (chip, name, note, stock status: IN STOCK / SHIPS IN 3 DAYS / PRE-ORDER · MARCH) and an amber add button.
8. **Specs**: h2 "Specs.", ARIA tabs (Power / Rugged / Audio & size) and a battery estimator card (a volume range → an estimated playtime number) above a `<table>` with `th scope=row`.
9. **Compare** "Pick a size.": three cards (Mini €169 / One €249 "This page" / Max €349), each with a CSS silhouette scaled to the model, a spec `<dl>` and an add button.
10. **Film**: a full-bleed muted loop with poster, the heading "Rain, on purpose.", copy and a Pause/Play toggle, over a left-to-right dark gradient.
11. **FAQ**: six `<details>` items with chevrons.
12. **Buy bar**: a fixed pill at the bottom centre with a colour dot, "Field One · Moss", mini swatches, the price and an amber add button. It appears after the hero and hides over the exploded stage and near the page end.
13. **Bag**: a `<dialog>` drawer from the right with line items (chip, model, colour, quantity stepper, remove), a free-delivery progress bar (€300 threshold), the subtotal and a reserve form (email + postcode, validated).

## Behaviour & interaction

- **Frame sequences (core):** a `Seq` class per canvas. Frames are `assets/seq/<name>/<d|m>/NNN.webp`. Frames load **coarse to fine** (every 8th, then every 4th, every 2nd, then all), six at a time, each `decode()`d before use. `set(i)` stores the target index. `draw()` finds the **nearest loaded frame** and repaints **only if that index changed**. It fills the paper colour and then draws with cover math: `s = max(cw/iw, ch/ih) * zoom`. The canvas is sized to the element × `min(devicePixelRatio, 2)`.
- **Scroll engine:** one passive scroll listener sets a flag. One `requestAnimationFrame` runs every scrubber, and nothing runs while you are not scrolling. Section progress = `clamp(−rect.top / (rect.height − innerHeight))`.
- **Hero:** index = `p × (count−1)`. The word scales 1 → 0.62 and moves up 18vh over p 0–0.14 (smoothstep), and its opacity falls to 0 over p 0.04–0.16. Chapter *n* (centres 0.16 / 0.36 / 0.56 / 0.76) has opacity `clamp((1−|d|)·2.2)` with `d = (p − at)/0.1` and moves `−d·22px` in y.
- **Exploded:** 72 frames. The label anchors are computed in JS with the same pinhole projection as the render (camera (0, −2.45, 0.58) aimed at (0, 0, 0.265), 85 mm lens on a 36 mm sensor, 1280×720). Each part's height follows the Blender keys, a Bezier ease between frames 128 and 165, which is exactly smoothstep. Labels appear from frame 38, staggered by 3 frames from the bottom up. Mobile frames are a 480 px centre crop, so the anchors are offset by −400 px.
- **Statement:** the share of words switched on is `(0.85·vh − top)/(height + 0.35·vh)`.
- **Battery tile:** a 120 ms tick and a 34-step cycle (24 h draining, then a recharge pause), animated only while the tile is visible.
- **Sound (WebAudio, no files):** 96 BPM, 16th-note scheduler (25 ms interval, 120 ms lookahead). Kick: sine 140→42 Hz in 120 ms. Snare: band-passed noise at 1.9 kHz plus a 185 Hz triangle. Hats: noise high-passed at 7.5 kHz, open hat on step 14. Bass: a saw through a low-pass sweeping 900→160 Hz on a 16-step line. Pad: a four-note sine/triangle chord per bar, detuned ±9 cents. The chain is master → low-shelf 120 Hz → peaking 3 kHz → high-shelf 8 kHz → low-pass → compressor (−14 dB, 3:1) → analyser (FFT 512) → out. The profiles set shelf/peak/low-pass and ramp with `setTargetAtTime` (τ 0.25 s): Outdoor (+7/0/+2.5 dB, 18 kHz), Indoor (+1/+2/0 dB, 16 kHz), Night (−6/+1/−6 dB, 5.2 kHz, volume capped at 60%). The visualiser draws 96 radial amber bars on a log-ish bin map, mirrored, around a ring, plus a radial glow that scales with level. Playback stops on a hidden tab or when the section leaves the screen.
- **Colour picker:** a radiogroup with arrow-key roving focus. Picking a colour swaps the spin canvas to that colour's frame set (and the hero, too, if it has a turntable), saves the choice in `localStorage` (inside try/catch) and updates the buy bar. Drag: 0.6°/px, release velocity ×0.25 with 0.92 friction, an idle auto-turn of 0.35°/frame while visible, and ←/→ turn it 12°. A colour with only a preview render shows a still and a "PREVIEW RENDER" label.
- **Bag:** every `[data-add]` button adds the current colour, and the same model + colour stacks (maximum 9). The badge does a bump animation and a toast confirms the add. The bag persists in `localStorage`. Validation shows inline errors and sets `aria-invalid`. Success shows a reference number and empties the bag.
- **Film:** plays only while on screen and when the tab is visible, never under reduced motion, and the user can pause it.

## Responsive

- **1440:** as described. The hero chapters sit in the left and right thirds.
- **≤1000:** nav links are hidden, the sound, colour and FAQ grids stack, tiles go to 6 or 12 columns, and the compare cards stack (max 560px).
- **≤700 (390 tested):** the canvases load **portrait 480×720 frames** (the `m` set). The hero draws at zoom 0.8, lifted 7%, and its canvas fades to paper at the bottom with `mask-image: linear-gradient(#000 0 70%, transparent 84%)`. The exploded title fades out as the labels arrive. Chapter cards become a frosted card above the bottom pitch. Exploded labels shrink to the part name with a 26px leader. The nav shows only the logo and bag, and the buy bar hides its mini swatches. There is no horizontal scroll at any width: `overflow-x: clip` on body, and every grid uses `minmax`.

## Accessibility & reduced motion

- Every canvas has `role="img"` and a descriptive `aria-label`, and the hero label updates with the colour. Decorative layers are `aria-hidden`.
- The bag is a native `<dialog>`, so it traps focus and closes on Esc. The specs are ARIA tabs with arrow keys. Swatches are `role=radio` with roving tabindex. The sound profile, the light ring and the play button use `aria-pressed`. The profile note and the battery estimate are `aria-live`.
- Visible 2px amber focus rings. AA contrast for all text: muted text is ≥ 4.5:1 on paper, and amber appears only as fills and large accents.
- **`prefers-reduced-motion: reduce`:** the sticky scrubbed sections become static. The hero shows its first still frame with the chapters laid out as a grid below it. The exploded section shows its final frame with every label visible. The statement is fully inked, all CSS animations are off, the film shows its poster and there is no auto-turn.

## Fallbacks & performance

- Sequences start loading when their section is within 120% of a viewport, and each colour set only when it is picked.
- `navigator.connection.saveData` or a 2g/3g `effectiveType` loads every 2nd frame only, and nearest-frame drawing hides the gaps.
- The first frame of every sequence draws immediately. Frames that fail to load are skipped, never left blank.
- A breakpoint change rebuilds the sequences with the right frame set, and a resize redraws without reloading.

## Assets

- `assets/seq/hero/moss/{d,m}/000–089.webp`: Cycles turntable of the Moss speaker on a cream studio sweep (desktop 1280×720, mobile 480×720). Render only the product region (`use_border`) and extend the background from the region's averaged edge columns, so every frame shares one seamless backdrop. Fill missing in-between frames with motion-compensated interpolation, and keep the real renders at their exact indices. Frames are webp at q82, about 17 KB each.
- `assets/seq/hero/clay/{d,m}/000–044.webp`: Clay colourway turntable (8° steps).
- `assets/seq/hero/slate/{d,m}/000.webp`: Slate preview still.
- `assets/seq/expl/{d,m}/000–071.webp`: exploded view on a dark sweep. The sleeve rises away, then the base cap, two passive radiators, battery, board, woofer and top cap separate along the vertical axis.
- `assets/life-shore.webp`: the speaker on a granite boulder at a lake shore. `assets/life-kitchen.webp`: the speaker on an oak kitchen shelf.
- `assets/camp-loop.webm` / `.mp4` + `assets/camp-poster.webp`: a locked-off dusk forest shot, drizzle, the light ring breathing (4.4 s seamless loop).

## Make it yours

This prompt rebuilds one exact page. 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, and the structure and interactions stay the same.

1. **Product and brand.** Swap "Ostra Field One" for your own physical product: a kettle, a camera, a lamp, a bottle, a watch. Keep one hero object that can turn on a turntable and has 5–8 inner or layered parts for the exploded chapter. Keep four material chapters and three models in the compare so the layout balances.
2. **The signature sequence.** Re-render it in your own world. Use a stone plinth instead of a paper sweep, a turntable that tilts 15° as it turns, or an exploded view that opens radially (petals) instead of along one axis. Keep the scroll-to-frame mapping, the nearest-frame drawing and the projected labels.
3. **The dark chapter.** Replace the near-black exploded stage with a deep colour that suits your product (oxblood, petrol, forest). Keep `--night-ink` at ≥ 7:1 against it.
4. **Palette.** Replace `--paper`, `--ink` and `--amber` with your brand colours. Sample `--paper` from your render's background edge so the canvas melts into the page, and keep `--muted` at ≥ 4.5:1 on `--paper`.
5. **Type pairing.** Swap Funnel Display + Funnel Sans for a different display grotesk or serif and a plain body face. Keep a mono for every number and label.
6. **The sound demo.** Turn the synthesised groove into your product's live demo: a kettle's boil curve, a camera shutter, a lamp's dimming curve on the visualiser ring. Keep it file-free, so it is generated in the browser.
7. **Imagery.** Regenerate the two lifestyle photos and the film loop of *your* product in *your* setting. Use one lens, one light and one grade for the set, put no text in the images, and make the loop locked-off with one slow natural motion.
8. **Copy voice.** Rewrite the headlines as short, factual claims you can stand behind ("Turned from one billet."), not slogans.

*"Build exactly as specified, but with these changes: …"*

---

## 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/speaker-product-page-scroll-sequence/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">
<title>Ostra Field One — portable speaker</title>
<meta name="description" content="Ostra Field One: a woven, aluminium-capped portable speaker with a leather loop and a ring of light. 24 hours, IP67.">
<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=Funnel+Display:wght@300..800&family=Funnel+Sans:ital,wght@0,300..800;1,300..800&family=Spline+Sans+Mono:wght@400;500&display=swap" rel="stylesheet">
<link rel="preload" as="image" href="assets/seq/hero/moss/d/000.webp" media="(min-width: 700px)" fetchpriority="high">
<link rel="preload" as="image" href="assets/seq/hero/moss/m/000.webp" media="(max-width: 699.98px)" fetchpriority="high">
<style>
:root{
  --paper:#ebe0cf; --paper-2:#e2d5c1; --card:#f4ece0; --ink:#1b1915; --muted:#5d554a; --line:rgba(27,25,21,.14);
  --amber:#e9792f; --amber-ink:#9c4512; --night:#141311; --night-2:#1d1b18; --night-ink:#efe8de; --night-muted:#a69d90; --night-line:rgba(239,232,222,.14);
  --moss:#56634b; --clay:#9a5539; --slate:#3a414c; --chalk:#d9d3c8;
  --r-s:10px; --r-m:18px; --r-l:28px;
  --f-display:"Funnel Display", "Helvetica Neue", Arial, sans-serif;
  --f-body:"Funnel Sans", "Helvetica Neue", Arial, sans-serif;
  --f-mono:"Spline Sans Mono", ui-monospace, Menlo, monospace;
  --ease:cubic-bezier(.2,.7,.1,1);
  --gutter:clamp(16px, 4vw, 56px);
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;overflow-x:clip}
body{margin:0;background:var(--paper);color:var(--ink);font-family:var(--f-body);font-size:17px;line-height:1.55;-webkit-font-smoothing:antialiased;overflow-x:clip}
img,video,canvas{display:block;max-width:100%}
a{color:inherit}
button{font:inherit;color:inherit;cursor:pointer}
:focus-visible{outline:2px solid var(--amber);outline-offset:3px;border-radius:6px}
.sr{position:absolute!important;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.skip{position:absolute;left:12px;top:-60px;z-index:100;background:var(--ink);color:var(--paper);padding:10px 14px;border-radius:8px}
.skip:focus{top:12px}
.wrap{max-width:1240px;margin:0 auto;padding:0 var(--gutter)}
.eyebrow{font-family:var(--f-mono);font-size:12px;letter-spacing:.14em;text-transform:uppercase;color:var(--muted)}
.night .eyebrow{color:var(--night-muted)}
h1,h2,h3{font-family:var(--f-display);font-weight:600;letter-spacing:-.025em;line-height:1;margin:0}
h2{font-size:clamp(40px,7vw,104px)}
h3{font-size:clamp(22px,2.2vw,30px);letter-spacing:-.015em}
p{margin:0}

/* ---------- top nav ---------- */
.nav{position:fixed;inset:0 0 auto 0;z-index:40;display:flex;align-items:center;gap:22px;height:56px;padding:0 var(--gutter);
  background:color-mix(in srgb,var(--paper) 78%,transparent);backdrop-filter:saturate(1.4) blur(14px);-webkit-backdrop-filter:saturate(1.4) blur(14px);border-bottom:1px solid transparent;transition:border-color .3s, background .3s}
.nav.scrolled{border-bottom-color:var(--line)}
.nav.on-night{background:color-mix(in srgb,var(--night) 80%,transparent);color:var(--night-ink)}
.logo{font-family:var(--f-display);font-weight:700;font-size:21px;letter-spacing:-.04em;text-decoration:none;display:flex;align-items:center;gap:8px}
.logo i{width:14px;height:14px;border-radius:50%;border:2.5px solid var(--amber);box-shadow:0 0 10px rgba(233,121,47,.55)}
.nav ul{display:flex;gap:20px;list-style:none;margin:0 auto;padding:0}
.nav ul a{text-decoration:none;font-size:14px;opacity:.78}
.nav ul a:hover{opacity:1}
.nav .price{font-family:var(--f-mono);font-size:13px;opacity:.8}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:999px;padding:11px 20px;font-weight:600;font-size:15px;background:var(--ink);color:var(--paper);text-decoration:none;transition:transform .2s var(--ease), background .2s}
.btn:hover{transform:translateY(-1px)}
.btn:active{transform:translateY(1px) scale(.98)}
.btn.amber{background:var(--amber);color:#1b1208}
.btn.ghost{background:transparent;color:inherit;box-shadow:inset 0 0 0 1.5px currentColor}
.btn.small{padding:8px 15px;font-size:14px}
.on-night .btn:not(.amber){background:var(--night-ink);color:var(--night)}
.bag-btn{position:relative;background:none;border:0;padding:8px;display:grid;place-items:center}
.bag-btn svg{width:22px;height:22px}
.bag-count{position:absolute;top:0;right:-2px;min-width:18px;height:18px;border-radius:9px;background:var(--amber);color:#1b1208;font:600 11px/18px var(--f-mono);text-align:center;transform:scale(0);transition:transform .35s var(--ease)}
.bag-count.has{transform:scale(1)}
.bag-count.bump{animation:bump .45s var(--ease)}
@keyframes bump{40%{transform:scale(1.45)}}

/* ---------- loader ---------- */
.loader{position:fixed;left:0;right:0;top:56px;height:2px;z-index:41;pointer-events:none}
.loader span{display:block;height:100%;width:0;background:var(--amber);transition:width .25s linear, opacity .6s .3s}
.loader.done span{opacity:0}

/* ---------- hero (scroll scrubbed turntable) ---------- */
.hero{position:relative;height:420vh;background:var(--paper)}
.stage{position:sticky;top:0;height:100vh;height:100svh;overflow:hidden}
.stage canvas{position:absolute;inset:0;width:100%;height:100%}
.hero-type{position:absolute;inset:0;display:grid;place-items:center;pointer-events:none}
.hero-type{-webkit-mask-image:linear-gradient(90deg,#000 0 38%,rgba(0,0,0,.08) 43%,rgba(0,0,0,.08) 60%,#000 65%);mask-image:linear-gradient(90deg,#000 0 38%,rgba(0,0,0,.08) 43%,rgba(0,0,0,.08) 60%,#000 65%)}
.hero-word{font-family:var(--f-display);font-weight:800;font-size:clamp(84px,21vw,360px);letter-spacing:-.06em;line-height:.8;white-space:nowrap;
  background:linear-gradient(180deg,var(--ink) 0%,var(--ink) 40%,rgba(27,25,21,0) 92%);-webkit-background-clip:text;background-clip:text;color:transparent;
  transform-origin:50% 60%;will-change:transform,opacity}
.hero-meta{position:absolute;left:var(--gutter);right:var(--gutter);bottom:clamp(20px,5vh,48px);display:flex;justify-content:space-between;align-items:flex-end;gap:24px}
.hero-meta p{max-width:30ch;font-size:clamp(15px,1.3vw,18px);color:var(--muted)}
.hero-meta .buy{display:flex;align-items:center;gap:14px}
.hero-meta .buy small{font-family:var(--f-mono);font-size:13px;color:var(--muted)}
.scroll-cue{font-family:var(--f-mono);font-size:12px;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);display:flex;align-items:center;gap:10px}
.scroll-cue i{width:1px;height:34px;background:linear-gradient(var(--muted),transparent);animation:cue 2.2s var(--ease) infinite}
@keyframes cue{0%{transform:scaleY(0);transform-origin:top}50%{transform:scaleY(1);transform-origin:top}51%{transform-origin:bottom}100%{transform:scaleY(0);transform-origin:bottom}}
.chapters{position:absolute;inset:0;pointer-events:none}
.chapter{position:absolute;max-width:min(380px,40vw);opacity:0;transform:translateY(24px);transition:none}
.chapter .n{font-family:var(--f-mono);font-size:12px;color:var(--amber-ink);letter-spacing:.1em}
.chapter h3{font-size:clamp(28px,3.2vw,48px);margin:8px 0 10px}
.chapter p{color:var(--muted);font-size:16px}
.chapter.l{left:var(--gutter);top:30%}
.chapter.r{right:var(--gutter);top:30%;text-align:right}
.degree{position:absolute;right:var(--gutter);top:76px;font-family:var(--f-mono);font-size:12px;color:var(--muted);letter-spacing:.08em}
.degree b{font-weight:500;color:var(--ink)}

/* ---------- statement ---------- */
.statement{padding:clamp(90px,16vh,180px) 0}
.statement p{font-family:var(--f-display);font-weight:500;font-size:clamp(34px,5.6vw,84px);line-height:1.02;letter-spacing:-.035em;max-width:16ch}
.statement .w{color:rgba(27,25,21,.16);transition:color .25s}
.statement .w.on{color:var(--ink)}
.statement .w.hl.on{color:var(--amber-ink)}

/* ---------- exploded ---------- */
.night{background:var(--night);color:var(--night-ink)}
.explode{position:relative;height:460vh}
.explode .stage{background:var(--night)}
.explode-head{position:absolute;left:var(--gutter);top:clamp(80px,13vh,130px);max-width:34ch;z-index:2}
.explode-head h2{font-size:clamp(38px,5.4vw,80px)}
.explode-head p{color:var(--night-muted);margin-top:14px;max-width:34ch}
.labels{position:absolute;inset:0;pointer-events:none;overflow:hidden}
.lab{position:absolute;left:0;top:0;display:flex;align-items:center;gap:10px;opacity:0;will-change:transform,opacity;transition:opacity .35s}
.lab .dot{width:7px;height:7px;border-radius:50%;background:var(--amber);box-shadow:0 0 0 4px rgba(233,121,47,.18);flex:none}
.lab .ln{height:1px;width:var(--len,60px);background:linear-gradient(90deg,rgba(239,232,222,.55),rgba(239,232,222,.15));flex:none}
.lab .tx{font-size:14px;line-height:1.3;width:max-content;max-width:200px}
.lab .tx b{display:block;font-weight:600;font-size:15px}
.lab .tx span{color:var(--night-muted);font-size:13px}
.lab.left{flex-direction:row-reverse;text-align:right}
.lab.left .ln{background:linear-gradient(270deg,rgba(239,232,222,.55),rgba(239,232,222,.15))}
.explode-foot{position:absolute;left:var(--gutter);right:var(--gutter);bottom:clamp(18px,4vh,40px);display:flex;justify-content:space-between;gap:20px;font-family:var(--f-mono);font-size:12px;color:var(--night-muted);letter-spacing:.06em}
.explode-foot .bar{flex:1;max-width:320px;height:2px;background:var(--night-line);align-self:center;position:relative;overflow:hidden}
.explode-foot .bar i{position:absolute;inset:0;background:var(--amber);transform-origin:left;transform:scaleX(0)}

/* ---------- features ---------- */
.features{padding:clamp(90px,14vh,160px) 0 clamp(60px,10vh,120px)}
.sec-head{display:flex;justify-content:space-between;align-items:flex-end;gap:30px;margin-bottom:clamp(30px,5vw,60px)}
.sec-head p{max-width:40ch;color:var(--muted)}
.grid{display:grid;grid-template-columns:repeat(12,1fr);gap:14px}
.tile{position:relative;border-radius:var(--r-l);background:var(--card);overflow:hidden;padding:clamp(20px,2.4vw,32px);min-height:280px;display:flex;flex-direction:column;justify-content:space-between;border:1px solid var(--line)}
.tile .k{font-family:var(--f-mono);font-size:12px;letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
.tile .big{font-family:var(--f-display);font-weight:700;font-size:clamp(64px,8vw,124px);letter-spacing:-.05em;line-height:.85}
.tile p{color:var(--muted);max-width:34ch;font-size:15.5px}
.t-batt{grid-column:span 7;background:var(--ink);color:var(--paper);border:0}
.t-batt .k,.t-batt p{color:#b6ad9f}
.cells{display:grid;grid-template-columns:repeat(24,1fr);gap:4px;margin:22px 0 18px}
.cells i{height:44px;border-radius:4px;background:#2d2a25;transition:background .2s}
.cells i.on{background:linear-gradient(#f39a58,var(--amber))}
.t-batt .readout{display:flex;justify-content:space-between;font-family:var(--f-mono);font-size:13px;color:#b6ad9f}
.t-ip{grid-column:span 5;background:#d9dfe0;color:#16211f;border:0}
.t-ip .k,.t-ip p{color:#3d4b4a}
.rain{position:absolute;inset:0;pointer-events:none;overflow:hidden}
.rain i{position:absolute;top:-20%;width:1.5px;height:46px;background:linear-gradient(transparent,rgba(22,33,31,.45));animation:rain linear infinite}
@keyframes rain{to{transform:translateY(160vh)}}
.t-ring{grid-column:span 4}
.ring-demo{width:168px;height:168px;margin:14px auto;display:block;overflow:visible}
.ring-demo .arc{fill:none;stroke:var(--amber);stroke-width:7;stroke-linecap:round;transform:rotate(-90deg);transform-origin:84px 84px;transition:stroke-dasharray .8s var(--ease);filter:drop-shadow(0 0 6px rgba(233,121,47,.8))}
.ring-demo .spinner{transform-origin:84px 84px;opacity:0}
.ring-demo.pair .arc{opacity:0}.ring-demo.pair .spinner{opacity:1;animation:spin 1.3s linear infinite}
.ring-demo.night .arc{stroke-dasharray:400 0!important;stroke:#f3a46a;animation:breathe 4s ease-in-out infinite}
@keyframes breathe{50%{opacity:.25}}
@keyframes spin{to{transform:rotate(1turn)}}
.seg{display:inline-flex;background:rgba(27,25,21,.07);border-radius:999px;padding:4px;gap:2px}
.seg button{border:0;background:none;border-radius:999px;padding:7px 13px;font-size:13.5px;font-weight:500;color:var(--muted)}
.seg button[aria-pressed="true"]{background:var(--ink);color:var(--paper)}
.t-photo{grid-column:span 4;padding:0;min-height:420px;border:0}
.t-photo img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.t-photo figcaption{position:relative;margin-top:auto;padding:22px;color:#fff;background:linear-gradient(transparent,rgba(0,0,0,.55));font-size:15px}
.t-photo figcaption b{display:block;font-family:var(--f-display);font-size:24px;font-weight:600;letter-spacing:-.02em}
.t-pair{grid-column:span 4}
.t-wide{grid-column:span 8}
.t-wide img{object-position:72% 58%}
.pair{display:flex;justify-content:center;gap:34px;margin:26px 0}
.pair span{width:62px;height:120px;border-radius:31px;background:linear-gradient(#56634b,#3f4a37);position:relative;box-shadow:0 14px 30px -14px rgba(0,0,0,.5)}
.pair span::before,.pair span::after{content:"";position:absolute;left:4px;right:4px;height:16px;border-radius:12px;background:linear-gradient(#ddd4c4,#a9a090)}
.pair span::before{top:-2px}.pair span::after{bottom:-2px}
.pair span i{position:absolute;left:50%;top:50%;width:62px;height:62px;margin:-31px;border-radius:50%;border:1.5px solid var(--amber);opacity:0;animation:wave 2s var(--ease) infinite}
.pair span:nth-child(2) i{animation-delay:1s}
@keyframes wave{0%{transform:scale(.6);opacity:.9}100%{transform:scale(2.3);opacity:0}}
.t-out{grid-column:span 4;background:var(--paper-2)}
.out{display:flex;align-items:center;gap:14px;margin:24px 0;font-family:var(--f-mono);font-size:13px;color:var(--muted)}
.out .cable{flex:1;height:2px;background:repeating-linear-gradient(90deg,var(--amber) 0 10px,transparent 10px 18px);background-size:18px 2px;animation:flow .6s linear infinite}
@keyframes flow{to{background-position:18px 0}}
.out .dev{width:34px;height:60px;border-radius:8px;border:2px solid var(--ink);position:relative}
.out .dev::after{content:"";position:absolute;left:6px;right:6px;bottom:6px;height:var(--lvl,40%);background:var(--amber);border-radius:2px;transition:height .4s}

/* ---------- sound ---------- */
.sound{padding:clamp(90px,14vh,170px) 0;position:relative;overflow:hidden}
.sound-grid{display:grid;grid-template-columns:1.05fr 1fr;gap:clamp(30px,5vw,80px);align-items:center}
.sound h2{font-size:clamp(40px,6vw,92px)}
.sound .lede{color:var(--night-muted);margin:20px 0 30px;max-width:42ch}
.viz-wrap{position:relative;aspect-ratio:1;max-width:520px;width:100%;margin-left:auto}
.viz-wrap canvas{width:100%;height:100%}
.play{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:118px;height:118px;border-radius:50%;border:0;background:var(--night-ink);color:var(--night);display:grid;place-items:center;font-weight:600;font-size:14px;transition:transform .3s var(--ease), background .3s}
.play:hover{transform:translate(-50%,-50%) scale(1.05)}
.play svg{width:30px;height:30px}
.play[aria-pressed="true"]{background:var(--amber);color:#1b1208}
.controls{display:grid;gap:18px}
.controls .row{display:flex;flex-wrap:wrap;align-items:center;gap:14px}
.night .seg{background:rgba(239,232,222,.08)}
.night .seg button{color:var(--night-muted)}
.night .seg button[aria-pressed="true"]{background:var(--night-ink);color:var(--night)}
.vol{display:flex;align-items:center;gap:12px;font-family:var(--f-mono);font-size:12px;color:var(--night-muted)}
input[type=range]{accent-color:var(--amber);width:180px}
.profile-note{font-size:14.5px;color:var(--night-muted);min-height:3em;max-width:44ch}
.meter{font-family:var(--f-mono);font-size:12px;color:var(--night-muted);display:flex;gap:18px}
.meter b{color:var(--night-ink);font-weight:500}

/* ---------- colourways ---------- */
.colours{padding:clamp(90px,14vh,160px) 0}
.col-grid{display:grid;grid-template-columns:1.35fr 1fr;gap:clamp(24px,4vw,60px);align-items:center}
.spin{position:relative;aspect-ratio:1/1;border-radius:var(--r-l);overflow:hidden;background:var(--paper);touch-action:pan-y;cursor:grab;border:1px solid var(--line)}
.spin:active{cursor:grabbing}
.spin canvas{position:absolute;inset:0;width:100%;height:100%}
.spin .hint{position:absolute;left:16px;top:16px;font-family:var(--f-mono);font-size:12px;color:var(--muted);background:rgba(239,228,211,.8);padding:6px 12px;border-radius:999px;display:flex;gap:8px;align-items:center}
.spin .loading{position:absolute;top:16px;right:16px;font-family:var(--f-mono);font-size:11px;color:var(--muted)}
.swatches{display:grid;gap:10px;margin:26px 0}
.sw{display:grid;grid-template-columns:44px 1fr auto;align-items:center;gap:14px;padding:12px 16px 12px 12px;border-radius:var(--r-m);border:1.5px solid var(--line);background:transparent;text-align:left;transition:border-color .2s, background .2s}
.sw[aria-checked="true"]{border-color:var(--ink);background:var(--card)}
.sw .chip{width:44px;height:44px;border-radius:50%;background:var(--c);box-shadow:inset 0 0 0 5px var(--cap)}
.sw b{display:block;font-size:16px}
.sw span{font-size:13.5px;color:var(--muted)}
.sw em{font-style:normal;font-family:var(--f-mono);font-size:12px;color:var(--muted)}

/* ---------- specs ---------- */
.specs{padding:clamp(80px,12vh,140px) 0;border-top:1px solid var(--line)}
.spec-tabs{margin-bottom:28px}
table{width:100%;border-collapse:collapse}
.spec-table th,.spec-table td{text-align:left;padding:16px 0;border-bottom:1px solid var(--line);vertical-align:top}
.spec-table th{width:34%;font-weight:500;color:var(--muted);font-size:15px;padding-right:20px}
.spec-table td{font-size:16.5px}
.spec-table td small{display:block;color:var(--muted);font-size:13.5px;margin-top:2px}
.spec-panel[hidden]{display:none}
.batt-calc{display:grid;grid-template-columns:1fr auto;gap:20px;align-items:center;padding:22px;border-radius:var(--r-m);background:var(--card);margin-bottom:26px;border:1px solid var(--line)}
.batt-calc output{font-family:var(--f-display);font-size:44px;font-weight:700;letter-spacing:-.04em}
.batt-calc label{display:block;font-size:14px;color:var(--muted);margin-bottom:6px}
.batt-calc input{width:100%}

/* ---------- compare ---------- */
.compare{padding:clamp(80px,12vh,140px) 0;background:var(--paper-2)}
.cmp{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}
.model{border-radius:var(--r-l);background:var(--card);padding:28px;display:flex;flex-direction:column;gap:18px;border:1.5px solid transparent;position:relative}
.model.current{border-color:var(--ink)}
.model .tag{position:absolute;top:18px;right:18px;font-family:var(--f-mono);font-size:11px;letter-spacing:.1em;text-transform:uppercase;background:var(--ink);color:var(--paper);padding:5px 9px;border-radius:999px}
.model .sil{height:150px;display:flex;align-items:flex-end;justify-content:center}
.model .sil i{display:block;border-radius:16px 16px 12px 12px;background:linear-gradient(90deg,#3f4a37,#6b7a5e 45%,#3f4a37);position:relative}
.model .sil i::before,.model .sil i::after{content:"";position:absolute;left:-1px;right:-1px;height:12%;background:linear-gradient(90deg,#a69c8a,#e0d7c8 45%,#a69c8a);border-radius:10px}
.model .sil i::before{top:0}.model .sil i::after{bottom:0}
.model h3{font-size:30px}
.model .pr{font-family:var(--f-mono);font-size:15px}
.model dl{display:grid;grid-template-columns:auto 1fr;gap:9px 14px;margin:0;font-size:14.5px}
.model dt{color:var(--muted)}
.model dd{margin:0;text-align:right}
.model .btn{margin-top:auto}

/* ---------- film ---------- */
.film{position:relative;min-height:88vh;display:grid;align-items:end;overflow:hidden;color:#f3eee6;background:#0e1311}
.film video,.film img.poster{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.film::after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,rgba(8,12,10,.72),rgba(8,12,10,.05) 60%),linear-gradient(transparent 60%,rgba(8,12,10,.6))}
.film .wrap{position:relative;z-index:1;padding-bottom:clamp(40px,8vh,90px);width:100%}
.film h2{max-width:10ch}
.film p{max-width:38ch;margin-top:16px;color:#d6d0c5}
.film .ctl{margin-top:22px}

/* ---------- faq ---------- */
.faq{padding:clamp(80px,12vh,140px) 0}
.faq-grid{display:grid;grid-template-columns:1fr 1.5fr;gap:clamp(30px,5vw,80px)}
details{border-bottom:1px solid var(--line)}
summary{list-style:none;display:flex;justify-content:space-between;align-items:center;gap:20px;padding:22px 0;font-size:clamp(17px,1.6vw,21px);font-weight:500;cursor:pointer}
summary::-webkit-details-marker{display:none}
summary::after{content:"";width:12px;height:12px;flex:none;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:rotate(45deg) translateY(-4px);transition:transform .3s var(--ease)}
details[open] summary::after{transform:rotate(225deg)}
details .a{padding:0 0 22px;color:var(--muted);max-width:60ch}

footer{padding:60px 0 140px;border-top:1px solid var(--line);font-size:14px;color:var(--muted)}
footer .wrap{display:flex;justify-content:space-between;gap:30px;flex-wrap:wrap}

/* ---------- buy bar ---------- */
.buybar{position:fixed;left:50%;bottom:16px;z-index:45;transform:translate(-50%,140%);transition:transform .5s var(--ease);display:flex;align-items:center;gap:16px;padding:10px 10px 10px 18px;border-radius:999px;background:var(--ink);color:var(--paper);box-shadow:0 20px 50px -18px rgba(0,0,0,.6);width:max-content;max-width:calc(100vw - 32px)}
.buybar.show{transform:translate(-50%,0)}
.buybar .dot{width:22px;height:22px;border-radius:50%;background:var(--c,var(--moss));box-shadow:inset 0 0 0 3px #cfc5b2;flex:none}
.buybar .nm{font-weight:600;white-space:nowrap}
.buybar .nm span{font-weight:400;opacity:.7}
.buybar .pr{font-family:var(--f-mono);font-size:14px;opacity:.85}
.buybar .mini-sw{display:flex;gap:6px}
.buybar .mini-sw button{width:20px;height:20px;border-radius:50%;border:0;background:var(--c);box-shadow:0 0 0 2px var(--ink);padding:0}
.buybar .mini-sw button[aria-pressed="true"]{box-shadow:0 0 0 2px var(--ink),0 0 0 4px var(--paper)}

/* ---------- bag drawer ---------- */
dialog.bag{margin:0 0 0 auto;height:100dvh;max-height:100dvh;width:min(440px,100vw);max-width:100vw;border:0;padding:0;background:var(--card);color:var(--ink);box-shadow:-30px 0 60px -30px rgba(0,0,0,.4)}
dialog.bag::backdrop{background:rgba(20,19,17,.4);backdrop-filter:blur(3px)}
dialog.bag[open]{animation:slide .45s var(--ease)}
@keyframes slide{from{transform:translateX(100%)}}
.bag-in{display:flex;flex-direction:column;height:100%}
.bag-head{display:flex;justify-content:space-between;align-items:center;padding:22px 24px;border-bottom:1px solid var(--line)}
.bag-head h2{font-size:28px}
.x{width:40px;height:40px;border-radius:50%;border:1px solid var(--line);background:none;font-size:20px;line-height:1}
.bag-items{flex:1;overflow:auto;padding:8px 24px;margin:0;list-style:none}
.bag-items li{display:grid;grid-template-columns:52px 1fr auto;gap:14px;align-items:center;padding:16px 0;border-bottom:1px solid var(--line)}
.bag-items .chip{width:52px;height:52px;border-radius:14px;background:var(--c);box-shadow:inset 0 0 0 6px #cfc5b2}
.bag-items b{display:block}
.bag-items small{color:var(--muted)}
.qty{display:inline-flex;align-items:center;border:1px solid var(--line);border-radius:999px;margin-top:6px}
.qty button{width:30px;height:30px;border:0;background:none;font-size:16px}
.qty span{min-width:22px;text-align:center;font-family:var(--f-mono);font-size:13px}
.rm{border:0;background:none;color:var(--muted);font-size:13px;text-decoration:underline;padding:4px}
.bag-empty{padding:40px 24px;color:var(--muted)}
.bag-foot{padding:20px 24px 26px;border-top:1px solid var(--line);display:grid;gap:12px}
.bag-foot .row{display:flex;justify-content:space-between}
.bag-foot .ship{font-size:13.5px;color:var(--muted)}
.ship-bar{height:4px;border-radius:2px;background:var(--line);overflow:hidden}
.ship-bar i{display:block;height:100%;background:var(--amber);transition:width .4s var(--ease)}
.checkout{display:grid;gap:10px}
.checkout label{font-size:13.5px;color:var(--muted)}
.checkout input{width:100%;padding:12px 14px;border-radius:12px;border:1.5px solid var(--line);background:#fff;font:inherit}
.checkout input[aria-invalid="true"]{border-color:#b3261e}
.err{color:#b3261e;font-size:13px;min-height:1em}
.ok{background:#e3ecd9;color:#26361d;border-radius:12px;padding:14px;font-size:14.5px}
.toast{position:fixed;left:50%;top:70px;transform:translate(-50%,-20px);opacity:0;z-index:60;background:var(--ink);color:var(--paper);padding:10px 16px;border-radius:999px;font-size:14px;transition:.35s var(--ease);pointer-events:none}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* ---------- reveal ---------- */
.rv{opacity:0;transform:translateY(28px);transition:opacity .9s var(--ease), transform .9s var(--ease)}
.rv.in{opacity:1;transform:none}

/* ---------- responsive ---------- */
@media (max-width:1000px){
  .nav ul{display:none}
  .nav .price{margin-left:auto}
  .t-batt,.t-ip{grid-column:span 12}
  .t-ring,.t-pair,.t-out,.t-photo{grid-column:span 6}
  .t-wide{grid-column:span 12}
  .sound-grid,.col-grid,.faq-grid{grid-template-columns:1fr}
  .viz-wrap{margin:0 auto}
  .cmp{grid-template-columns:1fr;max-width:560px}
}
@media (max-width:699.98px){
  body{font-size:16px}
  .nav{gap:12px}
  .nav .price{display:none}
  .nav .btn{display:none}
  .nav .bag-btn{margin-left:auto}
  .hero{height:380vh}
  #heroCanvas{-webkit-mask-image:linear-gradient(#000 0 70%,transparent 84%);mask-image:linear-gradient(#000 0 70%,transparent 84%)}
  .hero-meta{flex-direction:column;align-items:flex-start;gap:14px}
  .hero-meta .scroll-cue{display:none}
  .chapter{max-width:none;left:var(--gutter)!important;right:var(--gutter)!important;top:auto!important;bottom:150px;text-align:left!important;background:rgba(239,228,211,.86);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);padding:16px 18px;border-radius:18px}
  .chapter h3{font-size:26px}
  .chapter p{font-size:14.5px}
  .degree{display:none}
  .explode-head{top:76px;right:var(--gutter)}
  .explode-head p{display:none}
  .lab{gap:6px}
  .lab .ln{display:none}
  .lab .tx{max-width:112px;font-size:12px}
  .lab .tx b{font-size:12.5px}
  .lab .tx span{display:none}
  .t-ring,.t-pair,.t-out,.t-photo,.t-wide{grid-column:span 12}
  .t-photo{min-height:360px}
  .sec-head{flex-direction:column;align-items:flex-start}
  .buybar{gap:10px;padding:8px 8px 8px 14px;bottom:10px}
  .buybar .mini-sw{display:none}
  .buybar .nm span{display:none}
  .batt-calc{grid-template-columns:1fr}
  .spin{aspect-ratio:2/3;max-height:78vh;margin:0 auto}
}

/* ---------- reduced motion: scrubbed sections become stills ---------- */
@media (prefers-reduced-motion:reduce){
  *{animation:none!important;scroll-behavior:auto!important}
  .rv{opacity:1;transform:none;transition:none}
  .hero{height:auto}
  .hero .stage{position:relative;height:100svh}
  .chapters{position:relative;inset:auto;display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:24px;padding:40px var(--gutter);background:var(--paper)}
  .chapter{position:static;opacity:1!important;transform:none!important;max-width:none;text-align:left!important;background:none!important;padding:0!important}
  .explode{height:auto}
  .explode .stage{position:relative;height:100svh}
  .lab{opacity:1}
  .statement .w{color:var(--ink)}
  .statement .w.hl{color:var(--amber-ink)}
}
</style>
</head>
<body>
<a class="skip" href="#main">Skip to content</a>

<header class="nav" id="nav">
  <a class="logo" href="#top" aria-label="Ostra home"><i aria-hidden="true"></i>Ostra</a>
  <ul>
    <li><a href="#design">Design</a></li>
    <li><a href="#inside">Inside</a></li>
    <li><a href="#sound">Sound</a></li>
    <li><a href="#colours">Colours</a></li>
    <li><a href="#specs">Specs</a></li>
    <li><a href="#compare">Compare</a></li>
    <li><a href="#faq">FAQ</a></li>
  </ul>
  <span class="price">Field One · €249</span>
  <button class="btn small amber" data-add="one">Add to bag</button>
  <button class="bag-btn" id="bagBtn" aria-label="Open bag, 0 items" aria-haspopup="dialog">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" aria-hidden="true"><path d="M5 8h14l-1.2 12.2a1 1 0 0 1-1 .8H7.2a1 1 0 0 1-1-.8z"/><path d="M9 8V6.5a3 3 0 0 1 6 0V8"/></svg>
    <span class="bag-count" id="bagCount">0</span>
  </button>
</header>
<div class="loader" id="loader" aria-hidden="true"><span></span></div>

<main id="main">
<!-- HERO -->
<section class="hero" id="top" aria-labelledby="heroTitle">
  <div class="stage" id="heroStage">
    <canvas id="heroCanvas" role="img" aria-label="Ostra Field One speaker in Moss turning a full circle on a cream studio sweep"></canvas>
    <div class="hero-type" aria-hidden="true"><div class="hero-word" id="heroWord">Field One</div></div>
    <p class="degree" aria-hidden="true">ROTATION <b id="deg">000°</b> · FRAME <b id="frm">01</b>/90</p>
    <div class="chapters" id="design">
      <div class="chapter l" data-at="0.16"><div class="n">01 / SLEEVE</div><h3>Woven, not moulded.</h3><p>A 1.5&nbsp;mm twill of recycled wool and polyester. It sheds rain, hides scuffs and slides off for a 30&nbsp;°C wash.</p></div>
      <div class="chapter r" data-at="0.36"><div class="n">02 / END CAPS</div><h3>Turned from one billet.</h3><p>6063 aluminium, CNC-turned, bead-blasted and anodised a shade warmer than the weave.</p></div>
      <div class="chapter l" data-at="0.56"><div class="n">03 / LOOP</div><h3>Carried by a single loop.</h3><p>Vegetable-tanned leather on a stainless lug rated to 25&nbsp;kg. It darkens where your hand goes.</p></div>
      <div class="chapter r" data-at="0.76"><div class="n">04 / LIGHT RING</div><h3>A ring that answers.</h3><p>Forty-eight LEDs under the top cap show charge, pairing and volume, then breathe slowly at night.</p></div>
    </div>
    <div class="hero-meta">
      <div>
        <h1 id="heroTitle" class="sr">Ostra Field One portable speaker</h1>
        <p>Twenty centimetres of woven sound. 24&nbsp;hours, IP67, and one ring of light that tells you everything.</p>
      </div>
      <div class="buy">
        <small>From €249</small>
        <button class="btn" data-add="one">Add to bag</button>
      </div>
      <div class="scroll-cue" aria-hidden="true"><i></i>Scroll to turn it</div>
    </div>
  </div>
</section>

<section class="statement wrap" aria-label="Design statement">
  <p id="statement">Built like a field instrument. Tuned like a studio monitor. Wrapped like your favourite coat.</p>
</section>

<!-- EXPLODED -->
<section class="explode night" id="inside" aria-labelledby="insideTitle">
  <div class="stage" id="explStage">
    <canvas id="explCanvas" role="img" aria-label="Exploded view: the sleeve slides off and the internal parts separate along the vertical axis"></canvas>
    <div class="explode-head">
      <div class="eyebrow">Inside · 7 parts, 1 axis</div>
      <h2 id="insideTitle">Take it apart.</h2>
      <p>Everything stacks on one axis, so every part can be replaced with a single screwdriver. Scroll to separate.</p>
    </div>
    <div class="labels" id="labels"></div>
    <div class="explode-foot" aria-hidden="true"><span id="explPhase">ASSEMBLED</span><span class="bar"><i id="explBar"></i></span><span>690 g · Ø 84 × 205 mm</span></div>
  </div>
</section>

<!-- FEATURES -->
<section class="features wrap" aria-labelledby="featTitle">
  <div class="sec-head rv">
    <h2 id="featTitle">Made for weather.</h2>
    <p>Rated, dropped, rinsed and left out overnight. The numbers below are what we test to, not what we hope for.</p>
  </div>
  <div class="grid">
    <article class="tile t-batt rv" aria-labelledby="battT">
      <div class="k">Battery</div>
      <div>
        <div class="big" id="battT"><span id="hrs">24</span>&nbsp;h</div>
        <div class="cells" id="cells" aria-hidden="true"></div>
        <div class="readout"><span id="clock">06:00 — sunrise</span><span>5,200 mAh · 30 W USB-C</span></div>
      </div>
      <p>A full day and the night after it at half volume. Ten minutes on a charger buys two more hours.</p>
    </article>
    <article class="tile t-ip rv" aria-labelledby="ipT">
      <div class="rain" id="rain" aria-hidden="true"></div>
      <div class="k">Ingress</div>
      <div class="big" id="ipT">IP67</div>
      <p>Thirty minutes under a metre of water. It floats speaker-side up, so the ring stays visible.</p>
    </article>
    <article class="tile t-ring rv" aria-labelledby="ringT">
      <div class="k">Light ring</div>
      <svg class="ring-demo" id="ringDemo" viewBox="0 0 168 168" aria-hidden="true">
        <defs><radialGradient id="alu" cx="40%" cy="35%" r="75%"><stop offset="0" stop-color="#efe7d9"/><stop offset=".6" stop-color="#c9bea9"/><stop offset="1" stop-color="#8f8574"/></radialGradient></defs>
        <circle cx="84" cy="84" r="82" fill="url(#alu)"/>
        <circle cx="84" cy="84" r="64" fill="#2b2925"/>
        <circle cx="84" cy="84" r="57" fill="none" stroke="#3d3a34" stroke-width="7"/>
        <circle class="arc" id="ringArc" cx="84" cy="84" r="57" stroke-dasharray="258 400"/>
        <g class="spinner"><circle cx="84" cy="84" r="57" fill="none" stroke="#e9792f" stroke-width="7" stroke-linecap="round" stroke-dasharray="60 119"/></g>
        <circle cx="84" cy="84" r="40" fill="#1f1d1a"/>
        <circle cx="66" cy="84" r="6" fill="#2f2c28"/><circle cx="84" cy="84" r="7.5" fill="#2f2c28"/><circle cx="102" cy="84" r="6" fill="#2f2c28"/>
      </svg>
      <div>
        <h3 id="ringT">Read it from across the room.</h3>
        <div class="seg" role="group" aria-label="Light ring mode" style="margin-top:14px">
          <button aria-pressed="true" data-ring="batt">Charge</button><button aria-pressed="false" data-ring="pair">Pairing</button><button aria-pressed="false" data-ring="night">Night</button>
        </div>
      </div>
    </article>
    <figure class="tile t-photo rv" style="margin:0">
      <img src="assets/life-shore.webp" alt="The speaker in Moss standing on a mossy granite boulder at a grey lake shore, pines behind" loading="lazy" width="960" height="1192">
      <figcaption><b>Shore, 7 °C.</b>Left on a rock for an afternoon. Still at 61%.</figcaption>
    </figure>
    <article class="tile t-pair rv" aria-labelledby="pairT">
      <div class="k">Stereo pair</div>
      <div class="pair" aria-hidden="true"><span><i></i></span><span><i></i></span></div>
      <div><h3 id="pairT">Two make a room.</h3><p style="margin-top:8px">Hold both ring buttons for two seconds. Left and right are set by which one you pick up first.</p></div>
    </article>
    <article class="tile t-out rv" aria-labelledby="outT">
      <div class="k">Power out</div>
      <div class="out" aria-hidden="true"><span>FIELD</span><span class="cable"></span><span class="dev" id="dev"></span></div>
      <div><h3 id="outT">Charges your phone, too.</h3><p style="margin-top:8px">The USB-C port runs both ways at up to 15&nbsp;W.</p></div>
    </article>
    <figure class="tile t-photo t-wide rv" style="margin:0">
      <img src="assets/life-kitchen.webp" alt="The speaker on a worn oak kitchen shelf beside stacked stoneware bowls and a linen towel" loading="lazy" width="960" height="1192">
      <figcaption><b>Kitchen, Sunday.</b>The loop hangs off a shelf edge or a cupboard knob.</figcaption>
    </figure>
  </div>
</section>

<!-- SOUND -->
<section class="sound night" id="sound" aria-labelledby="soundTitle">
  <div class="wrap sound-grid">
    <div>
      <div class="eyebrow">Tuning · 3 profiles</div>
      <h2 id="soundTitle" style="margin-top:14px">Hear the tuning.</h2>
      <p class="lede">Press play for a short groove generated live in your browser: a kick, a bassline, hats and a warm pad. Switch profiles to hear what the DSP does outdoors, indoors and after dark.</p>
      <div class="controls">
        <div class="row">
          <div class="seg" role="group" aria-label="Sound profile">
            <button aria-pressed="false" data-prof="outdoor">Outdoor</button><button aria-pressed="true" data-prof="indoor">Indoor</button><button aria-pressed="false" data-prof="night">Night</button>
          </div>
          <label class="vol" for="vol">VOLUME <input type="range" id="vol" min="0" max="100" value="60"></label>
        </div>
        <p class="profile-note" id="profNote" aria-live="polite">Indoor: flat from 80 Hz up, with a gentle lift at 3 kHz so voices sit forward.</p>
        <div class="meter" aria-hidden="true"><span>BPM <b>96</b></span><span>PEAK <b id="peak">-∞</b> dB</span><span>BAR <b id="barN">–</b></span></div>
      </div>
    </div>
    <div class="viz-wrap">
      <canvas id="viz" aria-hidden="true"></canvas>
      <button class="play" id="play" aria-pressed="false" aria-label="Play demo groove">
        <svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path id="playIcon" d="M8 5.5v13l11-6.5z"/></svg>
      </button>
    </div>
  </div>
</section>

<!-- COLOURWAYS -->
<section class="colours wrap" id="colours" aria-labelledby="colTitle">
  <div class="col-grid">
    <div class="spin" id="spin" tabindex="0" role="img" aria-label="Turntable view of the selected colour. Drag, or use the left and right arrow keys, to turn it.">
      <canvas id="spinCanvas"></canvas>
      <span class="loading" id="spinLoad" aria-hidden="true"></span>
      <span class="hint" aria-hidden="true">⟵ drag to turn ⟶</span>
    </div>
    <div>
      <div class="eyebrow">Colourways</div>
      <h2 id="colTitle" style="margin-top:14px;font-size:clamp(40px,5.6vw,84px)">Three weaves. One loop.</h2>
      <div class="swatches" role="radiogroup" aria-label="Colour" id="swatches"></div>
      <div style="display:flex;gap:12px;flex-wrap:wrap;align-items:center">
        <button class="btn amber" data-add="one">Add Field One to bag — €249</button>
      </div>
    </div>
  </div>
</section>

<!-- SPECS -->
<section class="specs wrap" id="specs" aria-labelledby="specTitle">
  <div class="sec-head">
    <h2 id="specTitle">Specs.</h2>
    <div class="seg spec-tabs" role="tablist" aria-label="Spec groups">
      <button role="tab" aria-selected="true" aria-pressed="true" aria-controls="sp-power" id="tab-power">Power</button><button role="tab" aria-selected="false" aria-pressed="false" aria-controls="sp-rugged" id="tab-rugged" tabindex="-1">Rugged</button><button role="tab" aria-selected="false" aria-pressed="false" aria-controls="sp-audio" id="tab-audio" tabindex="-1">Audio &amp; size</button>
    </div>
  </div>
  <div class="spec-panel" id="sp-power" role="tabpanel" aria-labelledby="tab-power">
    <div class="batt-calc">
      <div>
        <label for="battVol">Listening volume: <b id="volPct">50%</b></label>
        <input type="range" id="battVol" min="10" max="100" step="5" value="50">
      </div>
      <div aria-live="polite"><output id="battOut" for="battVol">24 h</output><div style="font-size:13px;color:var(--muted)">estimated playtime</div></div>
    </div>
    <table class="spec-table"><caption class="sr">Battery and power</caption><tbody>
      <tr><th scope="row">Battery</th><td>5,200 mAh lithium-ion<small>Rated for 800 full cycles to 80% capacity</small></td></tr>
      <tr><th scope="row">Playtime</th><td>24 h at 50% · 11 h at 80% · 6 h at full</td></tr>
      <tr><th scope="row">Charging</th><td>USB-C PD, 30 W in · 0–100% in 2 h 40 min<small>10 minutes = about 2 hours of play</small></td></tr>
      <tr><th scope="row">Power out</th><td>USB-C, up to 15 W</td></tr>
      <tr><th scope="row">Standby</th><td>Up to 90 days, ring off</td></tr>
    </tbody></table>
  </div>
  <div class="spec-panel" id="sp-rugged" role="tabpanel" aria-labelledby="tab-rugged" hidden>
    <table class="spec-table"><caption class="sr">Durability</caption><tbody>
      <tr><th scope="row">Ingress rating</th><td>IP67 — dust-tight, 30 min at 1 m fresh water</td></tr>
      <tr><th scope="row">Floats</th><td>Yes, top-cap up</td></tr>
      <tr><th scope="row">Drop</th><td>1.2 m onto oak and concrete, 26 orientations</td></tr>
      <tr><th scope="row">Operating range</th><td>−10 °C to 45 °C<small>Charges between 0 °C and 40 °C</small></td></tr>
      <tr><th scope="row">Sleeve care</th><td>Removable, 30 °C gentle wash, air dry</td></tr>
    </tbody></table>
  </div>
  <div class="spec-panel" id="sp-audio" role="tabpanel" aria-labelledby="tab-audio" hidden>
    <table class="spec-table"><caption class="sr">Audio and dimensions</caption><tbody>
      <tr><th scope="row">Drivers</th><td>58 mm full-range driver, two 52 mm passive radiators (up and down)</td></tr>
      <tr><th scope="row">Output</th><td>20 W RMS · 92 dB SPL at 1 m</td></tr>
      <tr><th scope="row">Frequency response</th><td>55 Hz – 20 kHz (−6 dB)</td></tr>
      <tr><th scope="row">Wireless</th><td>Bluetooth 5.4, LE Audio, broadcast · AAC, SBC, LC3 · two devices at once</td></tr>
      <tr><th scope="row">Size &amp; weight</th><td>Ø 84 × 205 mm · 690 g</td></tr>
    </tbody></table>
  </div>
</section>

<!-- COMPARE -->
<section class="compare" id="compare" aria-labelledby="cmpTitle">
  <div class="wrap">
    <div class="sec-head"><h2 id="cmpTitle">Pick a size.</h2><p>Same weave, same ring, same loop. The difference is how big the room — or the field — is.</p></div>
    <div class="cmp">
      <article class="model" aria-labelledby="m-mini">
        <div class="sil" aria-hidden="true"><i style="width:56px;height:96px"></i></div>
        <div><h3 id="m-mini">Field Mini</h3><div class="pr">€169</div></div>
        <dl><dt>Playtime</dt><dd>12 h</dd><dt>Drivers</dt><dd>40 mm + 1 radiator</dd><dt>Ingress</dt><dd>IP67</dd><dt>Weight</dt><dd>380 g</dd><dt>Stereo pair</dt><dd>Yes</dd><dt>Power out</dt><dd>—</dd></dl>
        <button class="btn ghost" data-add="mini">Add Mini</button>
      </article>
      <article class="model current" aria-labelledby="m-one">
        <span class="tag">This page</span>
        <div class="sil" aria-hidden="true"><i style="width:64px;height:140px"></i></div>
        <div><h3 id="m-one">Field One</h3><div class="pr">€249</div></div>
        <dl><dt>Playtime</dt><dd>24 h</dd><dt>Drivers</dt><dd>58 mm + 2 radiators</dd><dt>Ingress</dt><dd>IP67</dd><dt>Weight</dt><dd>690 g</dd><dt>Stereo pair</dt><dd>Yes</dd><dt>Power out</dt><dd>15 W</dd></dl>
        <button class="btn" data-add="one">Add Field One</button>
      </article>
      <article class="model" aria-labelledby="m-max">
        <div class="sil" aria-hidden="true"><i style="width:84px;height:150px"></i></div>
        <div><h3 id="m-max">Field Max</h3><div class="pr">€349</div></div>
        <dl><dt>Playtime</dt><dd>30 h</dd><dt>Drivers</dt><dd>2 × 58 mm stereo + 2 radiators</dd><dt>Ingress</dt><dd>IP67</dd><dt>Weight</dt><dd>1.4 kg</dd><dt>Stereo pair</dt><dd>Built in</dd><dt>Power out</dt><dd>18 W</dd></dl>
        <button class="btn ghost" data-add="max">Add Max</button>
      </article>
    </div>
  </div>
</section>

<!-- FILM -->
<section class="film" aria-labelledby="filmTitle">
  <img class="poster" src="assets/camp-poster.webp" alt="" aria-hidden="true">
  <video id="film" muted loop playsinline preload="none" poster="assets/camp-poster.webp" aria-label="Drizzle falling on the speaker beside a tent at dusk, its light ring breathing">
    <source src="assets/camp-loop.webm" type="video/webm">
    <source src="assets/camp-loop.mp4" type="video/mp4">
  </video>
  <div class="wrap">
    <div class="eyebrow" style="color:#c9c2b6">Night mode</div>
    <h2 id="filmTitle" style="margin-top:12px">Rain, on purpose.</h2>
    <p>At dusk the ring drops to a slow amber breath you can find without a torch. Drizzle runs off the weave; the sound doesn't change.</p>
    <div class="ctl"><button class="btn ghost small" id="filmBtn" aria-pressed="false">Pause film</button></div>
  </div>
</section>

<!-- FAQ -->
<section class="faq wrap" id="faq" aria-labelledby="faqTitle">
  <div class="faq-grid">
    <div><h2 id="faqTitle">Questions.</h2><p style="color:var(--muted);margin-top:18px;max-width:30ch">Something else? Our support team answers within a working day.</p></div>
    <div>
      <details><summary>Can I take it in the shower or the sea?</summary><div class="a">Yes to both. IP67 covers 30 minutes at one metre in fresh water. After salt water or a chlorinated pool, rinse it under the tap and let the sleeve dry off the body.</div></details>
      <details><summary>How do I wash the sleeve?</summary><div class="a">Unscrew the top cap a quarter turn, slide the sleeve off upwards, and wash it at 30 °C on a gentle cycle. Dry it flat. Replacement sleeves in all three colours cost €29.</div></details>
      <details><summary>Does it work with two phones?</summary><div class="a">It stays connected to two devices at once and plays from whichever started last. Broadcast mode lets any number of nearby phones listen in.</div></details>
      <details><summary>What do the light ring colours mean?</summary><div class="a">Amber arc: battery level. Spinning arcs: pairing. One white pulse: volume step. A slow breath: night mode, which also caps volume at 60%.</div></details>
      <details><summary>Can I replace the battery?</summary><div class="a">Yes. The stack comes apart with one T6 screwdriver. A replacement battery costs €39 and the steps are printed inside the bottom cap.</div></details>
      <details><summary>What is the warranty?</summary><div class="a">Three years on the speaker, one year on the battery's capacity above 80%, and free repairs for anything we find was our fault.</div></details>
    </div>
  </div>
</section>
</main>

<footer>
  <div class="wrap">
    <span>© Ostra Sound Works — a fictional brand for a design template.</span>
    <span>Renders: Blender Cycles · Lifestyle images and film generated for this template.</span>
  </div>
</footer>

<!-- buy bar -->
<div class="buybar" id="buybar" role="region" aria-label="Quick buy">
  <span class="dot" id="bbDot" aria-hidden="true"></span>
  <span class="nm">Field One <span id="bbCol">· Moss</span></span>
  <div class="mini-sw" id="bbSw" role="group" aria-label="Colour"></div>
  <span class="pr">€249</span>
  <button class="btn amber small" data-add="one">Add to bag</button>
</div>

<!-- bag -->
<dialog class="bag" id="bag" aria-labelledby="bagTitle">
  <div class="bag-in">
    <div class="bag-head"><h2 id="bagTitle">Your bag</h2><button class="x" id="bagClose" aria-label="Close bag">×</button></div>
    <ul class="bag-items" id="bagItems"></ul>
    <p class="bag-empty" id="bagEmpty">Your bag is empty. The Field One in Moss is a good place to start.</p>
    <div class="bag-foot" id="bagFoot">
      <div class="ship" id="shipNote"></div>
      <div class="ship-bar"><i id="shipBar" style="width:0"></i></div>
      <div class="row"><span>Subtotal</span><b id="subtotal">€0</b></div>
      <form class="checkout" id="checkout" novalidate>
        <label for="email">Email for your order confirmation</label>
        <input id="email" type="email" autocomplete="email" placeholder="you@example.com" required>
        <label for="post">Postcode</label>
        <input id="post" type="text" autocomplete="postal-code" placeholder="e.g. 1012 AB" required minlength="3">
        <p class="err" id="coErr" role="alert"></p>
        <button class="btn" type="submit">Reserve and send payment link</button>
      </form>
      <div class="ok" id="coOk" hidden></div>
    </div>
  </div>
</dialog>
<div class="toast" id="toast" role="status" aria-live="polite"></div>

<script>
(() => {
'use strict';
const $ = (s, r = document) => r.querySelector(s);
const $$ = (s, r = document) => [...r.querySelectorAll(s)];
const clamp = (v, a = 0, b = 1) => Math.min(b, Math.max(a, v));
const lerp = (a, b, t) => a + (b - a) * t;
const smooth = t => t * t * (3 - 2 * t);
const RM = matchMedia('(prefers-reduced-motion: reduce)');
let reduced = RM.matches;
const store = {
  get(k, d) { try { const v = localStorage.getItem(k); return v ? JSON.parse(v) : d; } catch (e) { return d; } },
  set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch (e) {} }
};

/* ---------------- config ---------------- */
const BP = () => (innerWidth < 700 ? 'm' : 'd');
const conn = navigator.connection || {};
const SLOW = !!(conn.saveData || /(^|-)2g|3g/.test(conn.effectiveType || ''));
const pad = n => String(n).padStart(3, '0');
const COLOURS = {
  moss:  { name: 'Moss',  c: '#56634b', cap: '#cfc5b2', note: 'Sage weave, champagne caps', frames: 90 },
  clay:  { name: 'Clay',  c: '#b85c3c', cap: '#d9d1c4', note: 'Terracotta weave, natural caps', frames: 45 },
  slate: { name: 'Slate', c: '#3a414c', cap: '#6b6d72', note: 'Blue-black weave, graphite caps', frames: 1, still: true }
};
const EXPL_FRAMES = 72;
let colour = store.get('ostra-colour', 'moss');
if (!COLOURS[colour]) colour = 'moss';

/* ---------------- frame sequence ---------------- */
// Loads frames in a coarse-to-fine order (every 8th, 4th, 2nd, then all) so scrubbing works
// before the set is complete; draws the nearest loaded frame; only redraws when the index changes.
const loaderBar = $('#loader span');
const loadTotals = new Map();
function updateLoader() {
  let got = 0, want = 0;
  loadTotals.forEach(v => { got += v.got; want += v.want; });
  const p = want ? got / want : 1;
  loaderBar.style.width = (p * 100).toFixed(1) + '%';
  $('#loader').classList.toggle('done', p >= 1);
}
class Seq {
  constructor({ canvas, count, url, bg, step = 1 }) {
    this.canvas = canvas; this.ctx = canvas.getContext('2d', { alpha: false });
    this.count = count; this.url = url; this.bg = bg; this.step = step;
    this.imgs = new Array(count); this.ok = new Uint8Array(count);
    this.idx = -1; this.drawn = -1; this.started = false; this.id = Math.random();
    this.resize();
  }
  resize() {
    const r = this.canvas.getBoundingClientRect();
    const dpr = Math.min(devicePixelRatio || 1, 2);
    const w = Math.max(1, Math.round(r.width * dpr)), h = Math.max(1, Math.round(r.height * dpr));
    if (w !== this.canvas.width || h !== this.canvas.height) { this.canvas.width = w; this.canvas.height = h; this.drawn = -1; }
  }
  order() {
    const o = [], seen = new Set();
    for (const s of [8, 4, 2, 1]) for (let i = 0; i < this.count; i += s * this.step) if (!seen.has(i)) { seen.add(i); o.push(i); }
    return o;
  }
  loadOne(i) {
    return new Promise(res => {
      const im = new Image(); im.decoding = 'async';
      im.onload = () => { (im.decode ? im.decode() : Promise.resolve()).catch(() => {}).then(() => { this.imgs[i] = im; this.ok[i] = 1; this.bump(); if (i === this.idx || this.drawn === -1) this.draw(true); res(); }); };
      im.onerror = () => res();
      im.src = this.url(i);
    });
  }
  bump() { const t = loadTotals.get(this.id); if (t) { t.got++; updateLoader(); } }
  async first() { if (!this.ok[0]) await this.loadOne(0); this.draw(true); }
  async start() {
    if (this.started) return; this.started = true;
    const list = this.order().filter(i => !this.ok[i]);
    loadTotals.set(this.id, { got: 0, want: list.length }); updateLoader();
    let k = 0; const N = 6;
    const worker = async () => { while (k < list.length && !this.dead) { const i = list[k++]; await this.loadOne(i); } };
    await Promise.all(Array.from({ length: N }, worker));
  }
  nearest(i) {
    if (this.ok[i]) return i;
    for (let d = 1; d < this.count; d++) { if (this.ok[i - d]) return i - d; if (this.ok[i + d]) return i + d; }
    return -1;
  }
  set(i) { this.idx = clamp(Math.round(i), 0, this.count - 1); this.draw(); }
  draw(force) {
    const j = this.nearest(Math.max(0, this.idx));
    if (j < 0 || (!force && j === this.drawn)) return;
    const im = this.imgs[j], c = this.canvas, ctx = this.ctx;
    const s = Math.max(c.width / im.naturalWidth, c.height / im.naturalHeight) * (this.zoom || 1);
    const w = im.naturalWidth * s, h = im.naturalHeight * s;
    ctx.fillStyle = this.bg; ctx.fillRect(0, 0, c.width, c.height);
    ctx.drawImage(im, (c.width - w) / 2, (c.height - h) / 2 + (this.dy || 0) * c.height, w, h);
    this.drawn = j; this.fit = { s, ox: (c.width - w) / 2, oy: (c.height - h) / 2 + (this.dy || 0) * c.height, iw: im.naturalWidth, ih: im.naturalHeight };
    this.onDraw && this.onDraw(j);
  }
  destroy() { this.dead = true; loadTotals.delete(this.id); }
}
const seqUrl = (name, bp) => i => `assets/seq/${name}/${bp}/${pad(i)}.webp`;

/* lazy start per section */
function lazy(el, fn, margin = '120% 0px') {
  if (!('IntersectionObserver' in window)) { fn(); return; }
  const io = new IntersectionObserver(es => { if (es.some(e => e.isIntersecting)) { io.disconnect(); fn(); } }, { rootMargin: margin });
  io.observe(el);
}

/* ---------------- scroll engine: rAF only while scrolling ---------------- */
const scrubbers = [];
let ticking = false;
function onScroll() { if (!ticking) { ticking = true; requestAnimationFrame(frame); } }
function frame() { ticking = false; for (const s of scrubbers) s(); }
function progressOf(section) {
  const r = section.getBoundingClientRect();
  const span = r.height - innerHeight;
  return span > 0 ? clamp(-r.top / span) : 0;
}
addEventListener('scroll', onScroll, { passive: true });

/* ---------------- nav + buybar ---------------- */
const nav = $('#nav'), buybar = $('#buybar');
scrubbers.push(() => {
  nav.classList.toggle('scrolled', scrollY > 10);
  const heroEnd = $('#top').offsetHeight - innerHeight * 0.6;
  const nearEnd = scrollY + innerHeight > document.documentElement.scrollHeight - 160;
  const ir = $('#inside').getBoundingClientRect(), sr = $('#sound').getBoundingClientRect();
  const inExpl = ir.top < innerHeight * 0.5 && ir.bottom > innerHeight * 0.5;
  buybar.classList.toggle('show', scrollY > heroEnd && !nearEnd && !inExpl);
  nav.classList.toggle('on-night', (ir.top < 56 && ir.bottom > 56) || (sr.top < 56 && sr.bottom > 56));
});

/* ---------------- HERO ---------------- */
const hero = $('#top'), heroCanvas = $('#heroCanvas'), word = $('#heroWord');
const chapters = $$('.chapter');
let heroSeq;
function makeHero() {
  heroSeq && heroSeq.destroy();
  const hc = COLOURS[colour].still ? 'moss' : colour, C = COLOURS[hc];
  heroSeq = new Seq({ canvas: heroCanvas, count: C.frames, url: seqUrl('hero/' + hc, BP()), bg: getComputedStyle(document.body).getPropertyValue('--paper').trim() || '#efe4d3', step: SLOW ? 2 : 1 });
  if (BP() === 'm') { heroSeq.zoom = 0.8; heroSeq.dy = -0.07; }
  heroSeq.onDraw = j => {
    const deg = Math.round(j / C.frames * 360);
    $('#deg').textContent = pad(deg) + '°';
    $('#frm').textContent = String(Math.round(j / C.frames * 90) + 1).padStart(2, '0');
  };
  heroSeq.first().then(() => { if (!reduced) heroSeq.start(); });
  heroCanvas.setAttribute('aria-label', `Ostra Field One speaker in ${C.name} turning a full circle on a cream studio sweep`);
  heroScrub();
}
function heroScrub() {
  if (!heroSeq) return;
  if (reduced) { heroSeq.set(0); word.style.transform = 'none'; word.style.opacity = 1; return; }
  const p = progressOf(hero);
  heroSeq.set(p * (heroSeq.count - 1));
  // giant word: scales down and fades behind the product, masked by its gradient
  const t = smooth(clamp(p / 0.14));
  word.style.transform = `translateY(${lerp(0, -18, t)}vh) scale(${lerp(1, 0.62, t)})`;
  word.style.opacity = String(lerp(1, 0, smooth(clamp((p - 0.04) / 0.12))));
  for (const ch of chapters) {
    const at = +ch.dataset.at, d = (p - at) / 0.1;
    const vis = clamp((1 - Math.abs(d)) * 2.2);
    ch.style.opacity = vis.toFixed(3);
    ch.style.transform = `translateY(${(-d * 22).toFixed(1)}px)`;
  }
}
scrubbers.push(heroScrub);

/* ---------------- statement (word fill) ---------------- */
const st = $('#statement');
st.innerHTML = st.textContent.split(' ').map(w => `<span class="w${/instrument|monitor|coat/.test(w) ? ' hl' : ''}">${w}</span>`).join(' ');
const words = $$('.w', st);
scrubbers.push(() => {
  if (reduced) return;
  const r = st.getBoundingClientRect();
  const p = clamp((innerHeight * 0.85 - r.top) / (r.height + innerHeight * 0.35));
  const n = Math.round(p * words.length);
  words.forEach((w, i) => w.classList.toggle('on', i < n));
});

/* ---------------- EXPLODED ---------------- */
const expl = $('#inside'), explCanvas = $('#explCanvas');
// Anchor points for the labels, projected with the same camera as the Cycles render
// (85 mm lens, 36 mm sensor, camera (0,-2.45,0.58) aimed at (0,0,0.265), 1280x720).
// Part heights follow the Blender keys: Bezier ease between frames 128 and 165 (= smoothstep).
const EXPL_LABELS = (() => {
  const C = [0, -2.45, 0.58], T = [0, 0, 0.265], FP = 85 / 36 * 1280;
  const d = [T[0] - C[0], T[1] - C[1], T[2] - C[2]], L = Math.hypot(...d), f = d.map(v => v / L);
  const up = [0, -f[2], f[1]].map(v => v); // perpendicular to forward in the y/z plane
  const proj = (x, y, z) => { const p = [x - C[0], y - C[1], z - C[2]]; const zc = p[0] * f[0] + p[1] * f[1] + p[2] * f[2]; const yc = p[1] * up[1] + p[2] * up[2]; return [640 + p[0] / zc * FP, 360 - yc / zc * FP]; };
  const P = { base: [0.012, 0], prl: [0.037, 0.035], batt: [0.074, 0.085], board: [0.11, 0.135], woof: [0.135, 0.19], prh: [0.163, 0.25], top: [0.193, 0.32] };
  const side = { top: 1, prh: -1, woof: 1, board: -1, batt: 1, prl: -1, base: 1 };
  const out = {};
  for (const k in P) { out[k] = []; for (let j = 0; j < 72; j++) { const fr = 100 + j, t = clamp((fr - 128) / 37), e = t * t * (3 - 2 * t); out[k].push(proj(side[k] * 0.043, 0, P[k][0] + P[k][1] * e)); } }
  return out;
})();
window.EXPL_LABELS = EXPL_LABELS;
const PARTS = [
  { k: 'top', t: 'Top cap & light ring', s: '48 LEDs, capacitive keys', side: 'right' },
  { k: 'prh', t: 'Upper passive radiator', s: '52 mm, fires up', side: 'left' },
  { k: 'woof', t: '58 mm full-range driver', s: 'Neodymium, 20 W', side: 'right' },
  { k: 'board', t: 'Main board', s: 'DSP · Bluetooth 5.4', side: 'left' },
  { k: 'batt', t: '5,200 mAh battery', s: 'Swappable, T6 screws', side: 'right' },
  { k: 'prl', t: 'Lower passive radiator', s: 'Couples to the table', side: 'left' },
  { k: 'base', t: 'Base cap', s: 'USB-C in/out, rubber foot', side: 'right' }
];
const labelsEl = $('#labels');
labelsEl.innerHTML = PARTS.map(p => `<div class="lab ${p.side === 'left' ? 'left' : ''}" data-k="${p.k}"><span class="dot"></span><span class="ln"></span><span class="tx"><b>${p.t}</b><span>${p.s}</span></span></div>`).join('');
const labEls = $$('.lab', labelsEl);
let explSeq;
function makeExpl() {
  explSeq && explSeq.destroy();
  explSeq = new Seq({ canvas: explCanvas, count: EXPL_FRAMES, url: seqUrl('expl', BP()), bg: '#0b0a08', step: SLOW ? 2 : 1 });
  explSeq.zoom = BP() === 'm' ? 0.9 : 0.96; explSeq.dy = 0.06;
  explSeq.onDraw = placeLabels;
  explSeq.first();
  lazy(expl, () => { if (!reduced) explSeq.start(); else explSeq.loadOne(EXPL_FRAMES - 1).then(() => explSeq.set(EXPL_FRAMES - 1)); });
}
function placeLabels(j) {
  const f = explSeq.fit; if (!f || !window.EXPL_LABELS) return;
  const dpr = explCanvas.width / explCanvas.getBoundingClientRect().width;
  const ox = BP() === 'm' ? 400 : 0;
  const show = j >= 38;
  const narrow = innerWidth < 700;
  labEls.forEach((el, n) => {
    const pt = window.EXPL_LABELS[PARTS[n].k][j];
    if (!pt) return;
    const x = (f.ox + (pt[0] - ox) * f.s) / dpr, y = (f.oy + pt[1] * f.s) / dpr;
    const side = PARTS[n].side;
    const len = narrow ? 26 : 70;
    el.style.setProperty('--len', len + 'px');
    const w = el.offsetWidth;
    const tx = side === 'left' ? x - w + 4 : x - 4;
    el.style.transform = `translate(${tx.toFixed(1)}px, ${(y - el.offsetHeight / 2).toFixed(1)}px)`;
    el.style.opacity = show ? clamp((j - 38 - (6 - n) * 3) / 8).toFixed(2) : 0;
  });
}
function explScrub() {
  if (!explSeq) return;
  if (reduced) { explSeq.set(EXPL_FRAMES - 1); return; }
  const p = progressOf(expl);
  explSeq.set(p * (EXPL_FRAMES - 1));
  $('#explBar').style.transform = `scaleX(${p.toFixed(3)})`;
  if (innerWidth < 700) $('.explode-head').style.opacity = String(1 - clamp((p - 0.42) / 0.1));
  $('#explPhase').textContent = p < 0.08 ? 'ASSEMBLED' : p < 0.4 ? 'SLEEVE OFF' : p < 0.72 ? 'SEPARATING' : '7 PARTS · 1 AXIS';
}
scrubbers.push(explScrub);

/* ---------------- tiles ---------------- */
const cells = $('#cells');
cells.innerHTML = '<i></i>'.repeat(24);
const cellEls = $$('i', cells);
let battT = 0, battRun = false, battLast = 0;
function battTick(ts) {
  if (!battRun) return;
  if (ts - battLast > 120) {
    battLast = ts; battT = (battT + 1) % 34;
    const lit = battT > 24 ? 24 : 24 - battT;
    cellEls.forEach((c, i) => c.classList.toggle('on', i < lit));
    $('#hrs').textContent = String(lit);
    const hr = (6 + (24 - lit)) % 24;
    $('#clock').textContent = `${String(hr).padStart(2, '0')}:00 — ${lit === 24 ? 'sunrise' : lit > 14 ? 'afternoon' : lit > 6 ? 'evening' : lit > 0 ? 'small hours' : 'recharge'}`;
  }
  requestAnimationFrame(battTick);
}
function visLoop(el, on, off) {
  if (!('IntersectionObserver' in window)) { on(); return; }
  new IntersectionObserver(es => es.forEach(e => (e.isIntersecting ? on() : off()))).observe(el);
}
visLoop($('.t-batt'), () => { if (reduced) { cellEls.forEach(c => c.classList.add('on')); return; } if (!battRun) { battRun = true; requestAnimationFrame(battTick); } }, () => { battRun = false; });
const rain = $('#rain');
for (let i = 0; i < 26; i++) { const d = document.createElement('i'); d.style.left = (Math.random() * 100) + '%'; d.style.animationDuration = (0.9 + Math.random() * 0.9) + 's'; d.style.animationDelay = (-Math.random() * 2) + 's'; d.style.opacity = 0.35 + Math.random() * 0.5; rain.appendChild(d); }
visLoop($('.t-ip'), () => rain.style.display = '', () => rain.style.display = 'none');
const ringDemo = $('#ringDemo');
$$('[data-ring]').forEach(b => b.addEventListener('click', () => {
  $$('[data-ring]').forEach(x => x.setAttribute('aria-pressed', String(x === b)));
  ringDemo.setAttribute('class', 'ring-demo ' + (b.dataset.ring === 'batt' ? '' : b.dataset.ring));
  if (b.dataset.ring === 'batt') $('#ringArc').setAttribute('stroke-dasharray', `${(0.45 + Math.random() * 0.5) * 358} 400`);
}));
let devLvl = 20; const dev = $('#dev');
visLoop($('.t-out'), () => { if (reduced) return; dev._t = setInterval(() => { devLvl = devLvl >= 90 ? 20 : devLvl + 10; dev.style.setProperty('--lvl', devLvl + '%'); }, 700); }, () => clearInterval(dev._t));

/* ---------------- SOUND (WebAudio, synthesised) ---------------- */
const PROF = {
  outdoor: { low: 7, mid: 0, high: 2.5, lp: 18000, note: 'Outdoor: +7 dB below 120 Hz and a brighter top end, because nothing reflects the bass back to you outside.' },
  indoor: { low: 1, mid: 2, high: 0, lp: 16000, note: 'Indoor: flat from 80 Hz up, with a gentle lift at 3 kHz so voices sit forward.' },
  night: { low: -6, mid: 1, high: -6, lp: 5200, note: 'Night: bass tucked in, highs rolled off at 5 kHz, volume capped at 60% — for when someone is asleep next door.' }
};
let ac, master, lowS, midP, highS, lpF, analyser, comp, playing = false, nextT = 0, step16 = 0, schedTimer = null, prof = 'indoor';
const BPM = 96, SPB = 60 / BPM / 4;
const bassLine = [43, 0, 43, 0, 46, 0, 43, 0, 41, 0, 41, 0, 38, 0, 41, 43];
const padChords = [[55, 58, 62, 65], [53, 57, 60, 64], [50, 53, 57, 60], [51, 55, 58, 62]];
const mtof = m => 440 * 2 ** ((m - 69) / 12);
function initAudio() {
  ac = new (window.AudioContext || window.webkitAudioContext)();
  master = ac.createGain(); master.gain.value = 0;
  lowS = ac.createBiquadFilter(); lowS.type = 'lowshelf'; lowS.frequency.value = 120;
  midP = ac.createBiquadFilter(); midP.type = 'peaking'; midP.frequency.value = 3000; midP.Q.value = 0.9;
  highS = ac.createBiquadFilter(); highS.type = 'highshelf'; highS.frequency.value = 8000;
  lpF = ac.createBiquadFilter(); lpF.type = 'lowpass'; lpF.Q.value = 0.5;
  comp = ac.createDynamicsCompressor(); comp.threshold.value = -14; comp.ratio.value = 3;
  analyser = ac.createAnalyser(); analyser.fftSize = 512; analyser.smoothingTimeConstant = 0.78;
  master.connect(lowS); lowS.connect(midP); midP.connect(highS); highS.connect(lpF); lpF.connect(comp); comp.connect(analyser); analyser.connect(ac.destination);
  applyProfile(prof, true);
}
function applyProfile(k, now) {
  prof = k; const P = PROF[k];
  $('#profNote').textContent = P.note;
  if (!ac) return;
  const t = ac.currentTime, r = now ? 0.01 : 0.25;
  lowS.gain.setTargetAtTime(P.low, t, r); midP.gain.setTargetAtTime(P.mid, t, r); highS.gain.setTargetAtTime(P.high, t, r); lpF.frequency.setTargetAtTime(P.lp, t, r);
  setVol();
}
function setVol() {
  if (!ac) return;
  let v = $('#vol').value / 100; if (prof === 'night') v = Math.min(v, 0.6);
  master.gain.setTargetAtTime(playing ? v * 0.7 : 0, ac.currentTime, 0.08);
}
let noiseBuf;
function noise() {
  if (noiseBuf) return noiseBuf;
  noiseBuf = ac.createBuffer(1, ac.sampleRate * 0.5, ac.sampleRate);
  const d = noiseBuf.getChannelData(0); for (let i = 0; i < d.length; i++) d[i] = Math.random() * 2 - 1;
  return noiseBuf;
}
function kick(t) { const o = ac.createOscillator(), g = ac.createGain(); o.frequency.setValueAtTime(140, t); o.frequency.exponentialRampToValueAtTime(42, t + 0.12); g.gain.setValueAtTime(1, t); g.gain.exponentialRampToValueAtTime(0.001, t + 0.42); o.connect(g); g.connect(master); o.start(t); o.stop(t + 0.45); }
function hat(t, open) { const s = ac.createBufferSource(), f = ac.createBiquadFilter(), g = ac.createGain(); s.buffer = noise(); f.type = 'highpass'; f.frequency.value = 7500; g.gain.setValueAtTime(open ? 0.22 : 0.12, t); g.gain.exponentialRampToValueAtTime(0.001, t + (open ? 0.22 : 0.05)); s.connect(f); f.connect(g); g.connect(master); s.start(t); s.stop(t + 0.25); }
function snare(t) { const s = ac.createBufferSource(), f = ac.createBiquadFilter(), g = ac.createGain(); s.buffer = noise(); f.type = 'bandpass'; f.frequency.value = 1900; f.Q.value = 0.8; g.gain.setValueAtTime(0.38, t); g.gain.exponentialRampToValueAtTime(0.001, t + 0.18); s.connect(f); f.connect(g); g.connect(master); s.start(t); s.stop(t + 0.2);
  const o = ac.createOscillator(), og = ac.createGain(); o.type = 'triangle'; o.frequency.value = 185; og.gain.setValueAtTime(0.25, t); og.gain.exponentialRampToValueAtTime(0.001, t + 0.09); o.connect(og); og.connect(master); o.start(t); o.stop(t + 0.1); }
function bass(t, m) { const o = ac.createOscillator(), f = ac.createBiquadFilter(), g = ac.createGain(); o.type = 'sawtooth'; o.frequency.value = mtof(m - 12); f.type = 'lowpass'; f.frequency.setValueAtTime(900, t); f.frequency.exponentialRampToValueAtTime(160, t + 0.22); g.gain.setValueAtTime(0.0001, t); g.gain.exponentialRampToValueAtTime(0.42, t + 0.01); g.gain.exponentialRampToValueAtTime(0.001, t + 0.28); o.connect(f); f.connect(g); g.connect(master); o.start(t); o.stop(t + 0.3); }
function padC(t, notes, len) { notes.forEach((m, i) => { const o = ac.createOscillator(), g = ac.createGain(); o.type = i % 2 ? 'triangle' : 'sine'; o.frequency.value = mtof(m); o.detune.value = (i - 1.5) * 6; g.gain.setValueAtTime(0.0001, t); g.gain.linearRampToValueAtTime(0.05, t + 0.4); g.gain.linearRampToValueAtTime(0.0001, t + len); o.connect(g); g.connect(master); o.start(t); o.stop(t + len + 0.05); }); }
function schedule() {
  while (nextT < ac.currentTime + 0.12) {
    const s = step16 % 16, bar = Math.floor(step16 / 16) % 4;
    if (s % 4 === 0) kick(nextT);
    if (s === 4 || s === 12) snare(nextT);
    if (s % 2 === 0) hat(nextT, s === 14);
    if (bassLine[s]) bass(nextT, bassLine[s] + (bar === 3 ? -2 : 0));
    if (s === 0) { padC(nextT, padChords[bar], SPB * 16); $('#barN').textContent = (bar + 1) + '/4'; }
    nextT += SPB; step16++;
  }
}
const playBtn = $('#play');
function setPlaying(on) {
  if (on && !ac) initAudio();
  if (on && ac.state === 'suspended') ac.resume();
  playing = on;
  playBtn.setAttribute('aria-pressed', String(on));
  playBtn.setAttribute('aria-label', on ? 'Pause demo groove' : 'Play demo groove');
  $('#playIcon').setAttribute('d', on ? 'M7 5h3.5v14H7zM13.5 5H17v14h-3.5z' : 'M8 5.5v13l11-6.5z');
  if (on) { nextT = ac.currentTime + 0.06; clearInterval(schedTimer); schedTimer = setInterval(schedule, 25); vizStart(); }
  else { clearInterval(schedTimer); }
  setVol();
}
playBtn.addEventListener('click', () => setPlaying(!playing));
$$('[data-prof]').forEach(b => b.addEventListener('click', () => { $$('[data-prof]').forEach(x => x.setAttribute('aria-pressed', String(x === b))); applyProfile(b.dataset.prof); }));
$('#vol').addEventListener('input', setVol);
document.addEventListener('visibilitychange', () => { if (document.hidden && playing) setPlaying(false); });
visLoop($('#sound'), () => {}, () => { if (playing) setPlaying(false); });
// visualiser: the light ring, drawn from the analyser spectrum
const viz = $('#viz'), vctx = viz.getContext('2d');
let vizOn = false, fbuf;
function vizSize() { const r = viz.getBoundingClientRect(), d = Math.min(devicePixelRatio || 1, 2); viz.width = r.width * d; viz.height = r.height * d; }
function drawViz(levels) {
  const w = viz.width, h = viz.height, cx = w / 2, cy = h / 2, R = Math.min(w, h) * 0.33;
  vctx.clearRect(0, 0, w, h);
  vctx.lineCap = 'round';
  const N = 96;
  for (let i = 0; i < N; i++) {
    const a = i / N * Math.PI * 2 - Math.PI / 2;
    const v = levels ? levels[i] : 0.04 + 0.03 * Math.sin(i * 0.5);
    const l1 = R * 1.02, l2 = R * (1.06 + v * 0.42);
    vctx.strokeStyle = `rgba(233,121,47,${0.25 + v * 0.75})`;
    vctx.lineWidth = Math.max(2, R * 0.022);
    vctx.beginPath(); vctx.moveTo(cx + Math.cos(a) * l1, cy + Math.sin(a) * l1); vctx.lineTo(cx + Math.cos(a) * l2, cy + Math.sin(a) * l2); vctx.stroke();
  }
  const glow = levels ? levels.reduce((s, v) => s + v, 0) / levels.length : 0.05;
  const g = vctx.createRadialGradient(cx, cy, R * 0.7, cx, cy, R * 1.25);
  g.addColorStop(0, 'rgba(233,121,47,0)'); g.addColorStop(0.55, `rgba(233,121,47,${0.08 + glow * 0.5})`); g.addColorStop(1, 'rgba(233,121,47,0)');
  vctx.fillStyle = g; vctx.beginPath(); vctx.arc(cx, cy, R * 1.25, 0, Math.PI * 2); vctx.fill();
  vctx.strokeStyle = 'rgba(239,232,222,.16)'; vctx.lineWidth = 1.5; vctx.beginPath(); vctx.arc(cx, cy, R * 0.92, 0, Math.PI * 2); vctx.stroke();
}
function vizStart() { if (vizOn) return; vizOn = true; requestAnimationFrame(vizLoop); }
function vizLoop() {
  if (!playing || document.hidden) { vizOn = false; drawViz(null); $('#peak').textContent = '-∞'; return; }
  fbuf = fbuf || new Uint8Array(analyser.frequencyBinCount);
  analyser.getByteFrequencyData(fbuf);
  const N = 96, lv = new Array(N);
  for (let i = 0; i < N; i++) { const k = Math.floor(Math.pow(i / N, 1.7) * (fbuf.length * 0.7)) + 1; lv[i] = fbuf[k] / 255; }
  const mirrored = lv.map((v, i) => Math.max(v, lv[N - 1 - i] * 0.85));
  drawViz(reduced ? mirrored.map(v => v * 0.5) : mirrored);
  const pk = Math.max(...fbuf) / 255; $('#peak').textContent = pk > 0 ? (20 * Math.log10(pk)).toFixed(1) : '-∞';
  requestAnimationFrame(vizLoop);
}
vizSize(); drawViz(null);

/* ---------------- COLOURWAYS ---------------- */
const spin = $('#spin'), spinCanvas = $('#spinCanvas');
let spinSeq, spinAngle = 0, spinVel = 0, spinAuto = true, spinRun = false, dragging = false;
const swWrap = $('#swatches'), bbSw = $('#bbSw');
swWrap.innerHTML = Object.entries(COLOURS).map(([k, C]) => `<button class="sw" role="radio" aria-checked="${k === colour}" tabindex="${k === colour ? 0 : -1}" data-col="${k}" style="--c:${C.c};--cap:${C.cap}"><span class="chip" aria-hidden="true"></span><span><b>${C.name}</b><span>${C.note}</span></span><em>${C.still ? 'PRE-ORDER · MARCH' : C.frames === 90 ? 'IN STOCK' : 'SHIPS IN 3 DAYS'}</em></button>`).join('');
bbSw.innerHTML = Object.entries(COLOURS).map(([k, C]) => `<button aria-pressed="${k === colour}" aria-label="${C.name}" data-col="${k}" style="--c:${C.c}"></button>`).join('');
function makeSpin() {
  spinSeq && spinSeq.destroy();
  const C = COLOURS[colour];
  spinSeq = new Seq({ canvas: spinCanvas, count: C.frames, url: seqUrl('hero/' + colour, BP()), bg: getComputedStyle(document.body).getPropertyValue('--paper').trim(), step: 1 });
  spinSeq.zoom = BP() === 'd' ? 1.06 : 1.0; spinSeq.dy = BP() === 'd' ? 0.01 : 0;
  $('#spinLoad').textContent = C.still ? 'PREVIEW RENDER · TURNTABLE WHEN IT SHIPS' : 'LOADING ' + C.name.toUpperCase();
  spinSeq.first().then(() => { spinSeq.set(angleToIdx()); spinSeq.start().then(() => { if (!C.still) $('#spinLoad').textContent = ''; }); });
}
const angleToIdx = () => ((spinAngle % 360 + 360) % 360) / 360 * spinSeq.count;
function spinTick() {
  if (!spinRun) return;
  if (!dragging) { if (spinAuto && !reduced) spinAngle += 0.35; spinAngle += spinVel; spinVel *= 0.92; }
  spinSeq && spinSeq.set(Math.floor(angleToIdx()) % spinSeq.count);
  requestAnimationFrame(spinTick);
}
visLoop(spin, () => { if (!spinRun) { spinRun = true; requestAnimationFrame(spinTick); } }, () => { spinRun = false; });
let lastX = 0;
spin.addEventListener('pointerdown', e => { dragging = true; spinAuto = false; lastX = e.clientX; spin.setPointerCapture(e.pointerId); });
spin.addEventListener('pointermove', e => { if (!dragging) return; const dx = e.clientX - lastX; lastX = e.clientX; spinAngle -= dx * 0.6; spinVel = -dx * 0.25; });
const endDrag = () => { dragging = false; };
spin.addEventListener('pointerup', endDrag); spin.addEventListener('pointercancel', endDrag);
spin.addEventListener('keydown', e => { if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') { e.preventDefault(); spinAuto = false; spinAngle += e.key === 'ArrowLeft' ? 12 : -12; } });
function setColour(k, quiet) {
  if (!COLOURS[k] || k === colour && !quiet) return;
  colour = k; store.set('ostra-colour', k);
  $$('.sw').forEach(b => { const on = b.dataset.col === k; b.setAttribute('aria-checked', String(on)); b.tabIndex = on ? 0 : -1; });
  $$('button', bbSw).forEach(b => b.setAttribute('aria-pressed', String(b.dataset.col === k)));
  $('#bbCol').textContent = '· ' + COLOURS[k].name; $('#bbDot').style.setProperty('--c', COLOURS[k].c);
  if (quiet) return;
  if (spinSeq) makeSpin();
  makeHero();
}
swWrap.addEventListener('click', e => { const b = e.target.closest('.sw'); if (b) setColour(b.dataset.col); });
swWrap.addEventListener('keydown', e => {
  const keys = Object.keys(COLOURS); let i = keys.indexOf(colour);
  if (['ArrowDown', 'ArrowRight'].includes(e.key)) i = (i + 1) % keys.length; else if (['ArrowUp', 'ArrowLeft'].includes(e.key)) i = (i + keys.length - 1) % keys.length; else return;
  e.preventDefault(); setColour(keys[i]); $(`.sw[data-col="${keys[i]}"]`).focus();
});
bbSw.addEventListener('click', e => { const b = e.target.closest('button'); if (b) setColour(b.dataset.col); });

/* ---------------- specs tabs + battery estimate ---------------- */
const tabs = $$('[role=tab]');
tabs.forEach(t => t.addEventListener('click', () => selTab(t)));
tabs.forEach((t, i) => t.addEventListener('keydown', e => { if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') { const n = tabs[(i + (e.key === 'ArrowRight' ? 1 : tabs.length - 1)) % tabs.length]; selTab(n); n.focus(); } }));
function selTab(t) { tabs.forEach(x => { const on = x === t; x.setAttribute('aria-selected', String(on)); x.setAttribute('aria-pressed', String(on)); x.tabIndex = on ? 0 : -1; $('#' + x.getAttribute('aria-controls')).hidden = !on; }); }
const bv = $('#battVol');
function battEst() { const v = +bv.value; const h = v <= 50 ? 24 + (50 - v) * 0.18 : 24 * Math.pow(50 / v, 2.1); $('#battOut').textContent = (h >= 10 ? Math.round(h) : h.toFixed(1)) + ' h'; $('#volPct').textContent = v + '%'; }
bv.addEventListener('input', battEst); battEst();

/* ---------------- bag ---------------- */
const MODELS = { mini: { n: 'Field Mini', p: 169 }, one: { n: 'Field One', p: 249 }, max: { n: 'Field Max', p: 349 } };
let bag = store.get('ostra-bag', []);
const FREE = 300;
const fmt = n => '€' + n.toLocaleString('en-IE');
function renderBag() {
  const items = $('#bagItems'); items.innerHTML = '';
  let count = 0, sum = 0;
  bag.forEach((it, i) => {
    count += it.q; sum += it.q * MODELS[it.m].p;
    const C = COLOURS[it.c];
    const li = document.createElement('li');
    li.innerHTML = `<span class="chip" style="--c:${C.c}" aria-hidden="true"></span><div><b>${MODELS[it.m].n}</b><small>${C.name}${C.still ? ' (pre-order)' : ''} · ${fmt(MODELS[it.m].p)}</small><div class="qty" role="group" aria-label="Quantity of ${MODELS[it.m].n} ${C.name}"><button data-q="-1" data-i="${i}" aria-label="Decrease quantity">−</button><span aria-live="polite">${it.q}</span><button data-q="1" data-i="${i}" aria-label="Increase quantity">+</button></div></div><button class="rm" data-rm="${i}">Remove</button>`;
    items.appendChild(li);
  });
  $('#bagEmpty').hidden = bag.length > 0; $('#bagFoot').hidden = bag.length === 0;
  $('#subtotal').textContent = fmt(sum);
  const left = FREE - sum;
  $('#shipNote').textContent = left > 0 ? `Add ${fmt(left)} more for free express delivery.` : 'Free express delivery unlocked.';
  $('#shipBar').style.width = clamp(sum / FREE) * 100 + '%';
  const bc = $('#bagCount'); bc.textContent = count; bc.classList.toggle('has', count > 0);
  $('#bagBtn').setAttribute('aria-label', `Open bag, ${count} item${count === 1 ? '' : 's'}`);
  store.set('ostra-bag', bag);
}
function add(m) {
  const f = bag.find(x => x.m === m && x.c === colour);
  if (f) f.q = Math.min(9, f.q + 1); else bag.push({ m, c: colour, q: 1 });
  renderBag();
  const bc = $('#bagCount'); bc.classList.remove('bump'); void bc.offsetWidth; bc.classList.add('bump');
  toast(`${MODELS[m].n} in ${COLOURS[colour].name} added to your bag`);
}
document.addEventListener('click', e => { const b = e.target.closest('[data-add]'); if (b) add(b.dataset.add); });
$('#bagItems').addEventListener('click', e => {
  const q = e.target.closest('[data-q]'), r = e.target.closest('[data-rm]');
  if (q) { const it = bag[+q.dataset.i]; it.q = clamp(it.q + +q.dataset.q, 0, 9); if (!it.q) bag.splice(+q.dataset.i, 1); renderBag(); }
  if (r) { bag.splice(+r.dataset.rm, 1); renderBag(); }
});
const dlg = $('#bag');
$('#bagBtn').addEventListener('click', () => { $('#coOk').hidden = true; $('#checkout').hidden = false; dlg.showModal(); });
$('#bagClose').addEventListener('click', () => dlg.close());
dlg.addEventListener('click', e => { if (e.target === dlg) dlg.close(); });
$('#checkout').addEventListener('submit', e => {
  e.preventDefault();
  const em = $('#email'), po = $('#post'); let msg = '';
  const okE = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(em.value.trim()), okP = po.value.trim().length >= 3;
  em.setAttribute('aria-invalid', String(!okE)); po.setAttribute('aria-invalid', String(!okP));
  if (!okE) msg = 'Enter an email address like name@example.com.'; else if (!okP) msg = 'Enter your postcode so we can check delivery.';
  $('#coErr').textContent = msg;
  if (msg) { (okE ? po : em).focus(); return; }
  const ref = 'OS-' + Math.random().toString(36).slice(2, 7).toUpperCase();
  $('#coOk').innerHTML = `<b>Reserved — ${ref}.</b><br>We have held your items for 48 hours and sent a payment link to ${em.value.trim().replace(/[<>&"]/g, '')}.`;
  $('#coOk').hidden = false; $('#checkout').hidden = true;
  bag = []; renderBag(); $('#bagFoot').hidden = false;
});
let toastT;
function toast(t) { const el = $('#toast'); el.textContent = t; el.classList.add('show'); clearTimeout(toastT); toastT = setTimeout(() => el.classList.remove('show'), 2200); }
renderBag();

/* ---------------- film: plays only on screen ---------------- */
const film = $('#film'), filmBtn = $('#filmBtn');
let filmUserPaused = reduced;
function filmPlay(on) { if (on && !filmUserPaused && !document.hidden) { film.preload = 'auto'; film.play().catch(() => {}); } else film.pause(); }
visLoop(film, () => filmPlay(true), () => filmPlay(false));
filmBtn.textContent = filmUserPaused ? 'Play film' : 'Pause film';
filmBtn.addEventListener('click', () => { filmUserPaused = !filmUserPaused; filmBtn.textContent = filmUserPaused ? 'Play film' : 'Pause film'; filmBtn.setAttribute('aria-pressed', String(filmUserPaused)); filmPlay(!filmUserPaused); });
document.addEventListener('visibilitychange', () => { if (document.hidden) film.pause(); });

/* ---------------- reveal ---------------- */
if ('IntersectionObserver' in window) {
  const ro = new IntersectionObserver(es => es.forEach(e => { if (e.isIntersecting) { e.target.classList.add('in'); ro.unobserve(e.target); } }), { rootMargin: '0px 0px -8% 0px' });
  $$('.rv').forEach(el => ro.observe(el));
} else $$('.rv').forEach(el => el.classList.add('in'));

/* ---------------- boot / resize ---------------- */
let bpNow = BP();
makeHero(); makeExpl();
lazy(spin, makeSpin, '60% 0px');
setColour(colour, true);
let rz;
addEventListener('resize', () => {
  clearTimeout(rz);
  rz = setTimeout(() => {
    vizSize(); drawViz(null);
    if (BP() !== bpNow) { bpNow = BP(); makeHero(); makeExpl(); }
    [heroSeq, explSeq, spinSeq].forEach(s => s && (s.resize(), s.draw(true)));
    frame();
  }, 120);
});
RM.addEventListener && RM.addEventListener('change', e => { reduced = e.matches; frame(); });
frame();
})();
</script>
</body>
</html>

````
