# Recreate this site as a single HTML file: Ombrine — Perfume Atelier

You are an expert creative front-end developer. Produce a **single self-contained `index.html`** (inline CSS and JS, no build step, no framework) for a fictional niche perfumer's atelier. Reproduce every part of it described below:
- the layout and sections;
- the live three.js flacon with its ray-traced crystal stopper;
- the Cycles-rendered plates it stands on;
- the scroll choreography;
- every working control.

Local images live in `assets/` next to the file. The reference implementation is appended after this spec; where the two seem to differ, the code wins.

## What it is

Ombrine is a small perfume atelier's landing page on a smoky night-plum ground. It has six blocks:
1. a pinned **scent pyramid**;
2. a filterable **collection**;
3. a three-question **scent finder**;
4. a pinned **shop strip** of live 3D flacons with sizes and a working bag;
5. an **atelier story**;
6. a footer with a validated newsletter.

A **preloader** with real progress opens the page.

**Signature: "Perfume is time, poured into glass."** A live three.js glass flacon stands on the travertine drum of a Blender Cycles render. As you scroll through a 520vh pinned stage, the scent is "worn":
- the rendered set behind the bottle, which the glass refracts, relights from morning sun to dusk rose to candlelight;
- the liquid turns from champagne to citrus, rose and amber, and its level drops;
- an "On skin" clock runs from 00h to 24h;
- nine ingredient photo cards orbit the bottle, three per tier, on a tilted ellipse with depth blur.

The flacon's faceted **crystal stopper is ray-traced in its own fragment shader**: refraction, internal bounces, total internal reflection and per-channel dispersion against a live cube map. The scroll is the timeline of a real scent, so the effect explains the product.

## Page shell & libraries

- Import map, exactly:
  ```html
  <script type="importmap">{"imports":{"three":"https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js","three/addons/":"https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"}}</script>
  ```
  - three.js **0.170.0** only (MeshPhysicalMaterial `dispersion`, `AgXToneMapping`, `RoomEnvironment`).
  - No BVH library, no GLB, no EXR.
  - Native scroll, CSS `position: sticky` pins and one rAF-throttled scroll handler.
- Google Fonts: **Fraunces** (ital, opsz 9..144, wght 300..600, SOFT 50), **Hanken Grotesk** 400/500/600 and **DM Mono** 400/500, all with `display=swap`.
- **Two scripts:**
  1. A classic `<script>` holds all the UI, scroll state, the plate mapping, the orbit and the preloader. It works with no WebGL.
  2. A `<script type="module">` dynamically imports three. On any failure it adds `.no-gl` to `<html>` and sets `PYR.glReady`.
- **Shared state:** `window.PYR = {p, k, intro, level, liquid, visible, plate, start, glReady}` and `window.layoutPlate()`.

## Tokens

| token | value | use |
|---|---|---|
| `--ink` | `#110d12` | page ground |
| `--night` | `#1a151c` | stages, cards |
| `--plum` | `#2a1f2b` | image placeholders, quiz gradient |
| `--vellum` | `#f1e8dc` | text, solid buttons |
| `--mute` | `#b9ada3` | secondary text (≈ 8.9:1 on ink) |
| `--saffron` | `#e3a54f` | the only accent: italic words, eyebrows, amber buttons, focus ring |
| `--line` | `rgba(241,232,220,.16)` | hairlines |
| `--liquid` | live | set from JS every frame; it tints the pyramid tiers and the card dots |

- **Liquid stops:** intro `#efe0a0`, top `#e9cf63`, heart `#e48ea4`, base `#d0801f`.
- **Products** (liquid / cap):
  - Lueur `#e9cf63` / `#e9e0d0`;
  - Rose Tacite `#e48ea4` / `#e7b9b2`;
  - Ambre Lent `#c46a25` / `#3b2618`;
  - Sous-Bois `#6f9a7e` / `#7f8782`.
- **Type:**
  - Display is Fraunces at weight 340, `opsz` 120, SOFT 50, letter-spacing −0.02em, line-height 0.98. Every heading has one italic saffron `<em>` word.
  - Sizes: acts `clamp(46px, 5.8vw, 88px)`, section headings `clamp(42px, 5.6vw, 84px)`.
  - UI is Hanken Grotesk 16/1.55.
  - Labels are DM Mono 11px, uppercase, tracking 0.14em.
- **Radii:** 10 / 18 / 28 px and pills at 999px. Gutter `clamp(16px, 4vw, 56px)`.
- **Easing:** `--ease: cubic-bezier(.22,.8,.24,1)`.
- **Grade:** an animated SVG `feTurbulence` grain at opacity 0.07 (overlay blend) plus a warm screen-blend halo over the hero, so the renders don't look sterile.

## Layout & structure

1. **Preloader** (fixed, ink): a glowing saffron drop falls on a 1.6 s loop above the italic "Ombrine" wordmark, a 1px hairline and a mono percentage.
2. **Header** (fixed):
   - the italic wordmark, with "Parfums d'atelier" beside it;
   - five anchors (hidden under 1100 px);
   - a "Bag" pill whose saffron badge bumps (1.35×, 500 ms) on add.
   - It turns into blurred ink once the pyramid pin ends.
3. **Pyramid** (`section` 520vh, its stage sticky at 100svh). The layers, bottom to top:
   - three DOM poster `<img>`s of the plates, as the fallback;
   - the WebGL canvas, which fades in on its first frame;
   - the SVG fallback flacon;
   - the scrim, halo and grain;
   - the ingredient orbit;
   - the copy, bottom-left (four stacked "acts": intro H1 "Perfume is *time*, / poured into glass."; "01 Top notes · 0–15 min — The first *light*."; "02 Heart — The *heart* opens."; "03 Base — What *stays*." with a "Lueur, from €42" CTA);
   - the pyramid index, on the right: a blurred ink panel with a 3-tier SVG triangle whose active tier fills with `--liquid`, the "On skin" clock and three jump buttons with `aria-current="step"`;
   - the scroll cue.
4. **Collection:**
   - The heading "Four scents. *Four* hours of day." and filter chips (All / Citrus / Floral / Amber / Woody) as `aria-pressed` toggles.
   - Four 4:5.6 cards showing the **Cycles product renders**.
   - On hover or focus: the notes reveal (`grid-template-rows 0fr → 1fr`, 600 ms), a 3 px swatch fills from 18 % to 100 %, and the image zooms 1.06× over 1.2 s.
   - The whole card links to that product in the shop strip.
5. **Scent finder:**
   - Three fieldsets of four radio tiles (When / Place / Carry) with a 3-segment progress bar.
   - Back and Next buttons; Next stays disabled until the step is answered.
   - The result shows the render, "NN% match · Family", a one-line reason, "Add 2 ml sample · €8", "View in shop" and "Start again".
   - Scoring: a 3×4×4 points table. Match = 68 + best/9 × 31.
6. **Shop strip** (pinned on ≥ 900 px):
   - The heading "Choose a *size*, keep the flacon." and a mono "01 —— 05" progress line.
   - Five cards `clamp(290px, 27vw, 400px)` wide.
   - Each card's 4:4.1 image area holds a **2D canvas with a live 3D flacon** in that scent's colour and cap, standing on that scent's plate. It turns, and its size springs to the chosen 10 / 50 / 100 ml (scale 0.70 / 0.86 / 1.00, spring 160/16).
   - The fifth card is the Discovery set (4 × 2 ml, €28), a photo with no 3D.
   - Each card has a live price and "Add to bag", which turns saffron with "Added ✓" for 1.6 s.
   - Prices:

     | perfume | 10 ml | 50 ml | 100 ml |
     |---|---|---|---|
     | Lueur | €42 | €145 | €210 |
     | Rose Tacite | €46 | €168 | €240 |
     | Ambre Lent | €52 | €184 | €265 |
     | Sous-Bois | €44 | €156 | €225 |
7. **Atelier:**
   - A 4:5 photo of the perfumer's organ (parallax ±30 px).
   - The heading "Slow is the *only* formula." and a Fraunces 300 lede.
   - Stats count up over 1.4 s: 312 raw materials, 400 flacons per batch, 6 weeks of maceration.
8. **Footer:** "Letters from the *organ*.", a newsletter pill (email + Subscribe), a consent checkbox, a status line, three link columns and a giant outlined italic "Ombrine".
9. **Bag drawer** (`role="dialog"`):
   - a free-shipping meter (€150);
   - lines with −/+, Remove and the subtotal;
   - a "demo, no payment" note at checkout;
   - the bag persists in `localStorage` (inside try/catch).

## Behaviour & interaction

**The plate mapping (the key to the composition).** The plates are 1600×900 Cycles renders. The drum's top centre is at `u = .586`, `v = .564` (from the top), and its top is `.2` of the image width across. `layoutPlate(W, H, {fx, fy, zoom, wf, maxW})`:
1. cover-fits the plate: `sx = min(1, aspect/16·9)/zoom` and `sy = min(1, (16/9)/aspect)/zoom`;
2. pans it so the drum lands at the requested `(fx, fy)`, clamped so the plate always covers the frame;
3. returns the drum's real screen position and `bottleW = min(drumPx·wf, maxW)`.

The same numbers drive:
- the GLSL backdrop (`uv = (vUv − .5)·s + .5 + pan`);
- the DOM posters' `object-position`;
- the SVG fallback;
- the orbit centre.

Per breakpoint:

| band | fx | fy | zoom | wf | maxW |
|---|---|---|---|---|---|
| desktop | .6 | .62 | 1 | .66 | 320 |
| tablet | .54 | .6 | 1.1 | .6 | 240 |
| phone | .5 | .5 | 1.25 | .5 | 150 |

**The pyramid timeline.** `p` = scroll progress through the section (the box is measured on resize, not per frame).
- `intro = 1 − smoothstep(.05, .13, p)`
- `k = smoothstep(.36, .44, p) + smoothstep(.64, .72, p)`, which runs 0..2
- `level = .92 − .4·smoothstep(.12, 1, p)`
- the clock is `1440·smoothstep(.1, .98, p)^2.2` minutes
- the jump buttons go to `p` = .26, .54 and .84
- the backdrop shader mixes the top, heart and base plates by `k`, and darkens toward plum by `intro·.7`

**The ingredient orbit.** Nine `<figure>` cards: a 4:5 image, a 14 px radius, and an italic caption with a `--liquid` dot.
- **Angle:** `a = p·2.4π + i·2π/3 + tier·.9 + t·.00011`.
- **Position:** `x = cx + cos a·rx` and `y = cy + (i−1)·bottleH·.28 + sin a·ry·.5`.
  - The centre is the middle of the bottle.
  - `rx = max(bottleW·1.05, min(19vw, 300))` and `ry = 70`.
  - On phones, `rx = min(36vw, 150)`, `ry = 34` and the cards are 74 px wide.
- **Weight:** `w = clamp(1 − |k − tier|·1.6)·(1 − intro)`.
- **Scale:** `(.72 + .28·depth)·(.82 + .18·w)`.
- **Blur:** `(1−w)·10 + max(0, −sin a − .2)·5` px.
- **Rotate:** `−4°·cos a`.
- **Behind the bottle:** opacity × .55, z-index 1.

**The flacon** (identical builder for the hero and the shop):
- **The liquid:** a lathe of unit height scaled to the level. Transmission 1, thickness 1.3, IOR 1.36. Its colour is the liquid lerped 22 % to white, with `attenuationColor` = the liquid at distance 1.5, and dispersion .45.
- **The heel and neck:** clear solid lathes with transmission 1, thickness 1.6, IOR 1.52 and dispersion .45.
- **The shell:** an outer lathe in black MeshPhysical with clearcoat .5, drawn with `AdditiveBlending` and `depthWrite: false`, so only the highlights add and nested transmission never hides the liquid.
- **The collar:** a knurled gold cylinder (192 segments, radius × (1 + .03·sign(cos 48θ))), two polished torus lips, and a contact-shadow blob plane behind the base.
- **The hero entrance spring** (tension 70, friction 14) starts 260 ms after the preloader lifts: the bottle rises .8 units and scales from .9.
- **Pointer spring** (tension 120, friction 20; fine pointers only): yaw `.35·x`, pitch `.08 + .06·y`, and a ±.006 UV parallax on the plate.
- **Idle:** a spin of .16 rad/s and a ±.015 float.

**The ray-traced crystal stopper** (a ShaderMaterial on a proxy box):
- **The shape:** 82 planes tangent to an ellipsoid (a = .34, b = .42), arranged in rings at 90, 62, 38, 14, −12, −38, −64 and −90° elevation with 1/8/16/16/16/16/8/1 facets, alternate rings offset half a step. The table and culet are cut at .9 and .86.
- **The trace:** the ray enters through the convex hull (max t_enter < min t_exit) and takes a Schlick reflection (r0 .06). Then, for each of R, G and B with IORs 1.58, 1.63 and 1.69:
  1. refract in;
  2. bounce up to 5 times (3 on phones), finding the exit facet and absorbing `exp(−.25·t)`;
  3. refract out, or reflect on total internal reflection;
  4. add the outgoing light, weighted by its Fresnel.
- **The environment** is a 192 px `WebGLCubeRenderTarget` updated every 2nd frame. It renders `RoomEnvironment` plus a plane that shares the backdrop material, so the gem refracts the current plate.
- The stopper is tinted 18 % toward the liquid colour and counter-rotates at −.6× the spin.

**The shop renderer.** One offscreen `WebGLRenderer`, DPR ≤ 1.5:
- for each card on screen it sets that card's plate texture, liquid, cap and spring size, renders, and `drawImage`s the result into the card's 2D canvas;
- plate mapping per card: `{fx:.5, fy:.83, zoom:2.1, wf:.5}`;
- it renders only cards inside the IntersectionObserver and skips hidden tabs.

**The preloader:**
- It counts the 3 plates, 9 ingredient cards, the fonts and `PYR.glReady`.
- The hairline is a spring (tension 140, friction 26). The real target is forced to 100 % after 5 s.
- Once the target hits 1, it finishes when the spring passes 98.5 % or after 700 ms, whichever comes first, then fades over 700 ms after a 190 ms beat and adds `.is-ready`: the hero lines rise from a 105 % mask over 1.2 s.

**Other details:** shop strip translate = −progress × overflow (section height = 100vh + overflow × 1.1). The newsletter validates empty, then format (`^[^\s@]+@[^\s@]+\.[^\s@]{2,}$`), then consent, and confirms success. The field takes `aria-invalid`, and the message is in a `role=status` line.

## Responsive

- **1440:** the full composition, with 4 collection columns and the strip pinned.
- **≤ 1100:** 2 collection columns, and the nav links hide.
- **≤ 899:**
  - The shop strip becomes a native scroll-snap row (cards `min(82vw, 360px)`, and the live canvases still render).
  - Finder, atelier and footer go to one column.
  - The pyramid index becomes a top-left pill (triangle + clock).
- **≤ 640:**
  - The scrim is bottom-up, the copy sits 72 px from the bottom, and headings are `clamp(40px, 12vw, 56px)`.
  - Orbit cards are 74 px with names only, and quiz tiles go to 1 column.
- Every grid child has `min-width: 0`. There is no horizontal scroll at 390, 768 or 1440.

## Accessibility & reduced motion

- **Structure:** a skip link, landmarks, one H1, and a 2 px saffron focus ring everywhere, including radio tiles and size pills through `input:focus-visible + span`.
- **ARIA:** `aria-pressed`, `aria-current` and `aria-live` statuses. The bag dialog traps Tab, closes on Esc and returns focus.
- **Hidden decoration:** the canvas, orbit, posters and preloader are `aria-hidden`. Every product image has alt text.
- **`prefers-reduced-motion`:**
  - transitions and animations drop to 0.001 ms;
  - the preloader snaps;
  - there is no entrance spring, spin, float, orbit drift, tilt or grain animation;
  - size changes snap.

  The pyramid still scrubs, because the scroll is user-driven.

## Fallbacks

- **No WebGL2, or the import fails:**
  - `.no-gl` shows an SVG flacon placed with the same plate mapping; its liquid fills with `--liquid` and follows the level;
  - the DOM plates crossfade per tier;
  - the orbit, clock, acts, index and the whole shop keep working, with the product renders in place of live canvases.
- **Render loops** run only while their section intersects the viewport and the tab is visible.
- **A missing texture** logs a warning, and the poster stays.

## Assets

The page carries about 0.6 MB of images in total.

| path | what it is |
|---|---|
| `assets/plate-top.webp`, `plate-heart.webp`, `plate-base.webp`, `plate-wood.webp` | 1600×900 Blender Cycles renders of one set: a travertine drum, a dark slab, a plaster column and a window-gobo sun on plaster, lit as morning sun / dusk rose / candlelight / overcast green |
| `assets/render-lueur.webp`, `render-rose.webp`, `render-ambre.webp`, `render-bois.webp` | 880×1100 Cycles product renders of the same flacon (hollow glass, absorbing liquid, gold collar, octagonal cap) on the drum |
| `assets/ing-bergamot.webp` … `ing-vanilla.webp` (9) | 360² macro photographs of each ingredient: bergamot, neroli, pink pepper, damask rose, orris, jasmine, oud, labdanum, vanilla |
| `assets/atelier.webp` | the perfumer's organ: tiered shelves of amber vials by a window |
| `assets/discovery-set.webp` | four sample vials on a linen pouch |

## Make it yours

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

1. **Brand and offer.** Swap "Ombrine" and its four scents for your own house and products, with names, notes and prices. Keep four products plus one set, so the 4-up grid and the five-card strip still balance.
2. **The vessel.** The flacon that drains and changes colour on a rendered plinth is the signature. Re-theme it with one vessel from your world, keeping the three-tier `k` timeline, the colour stops, the falling level and the ray-traced stopper (re-cut its facet rings):
   - a tea glass steeping from first flush to dark, with a faceted glass lid;
   - a wine decanter through three tasting notes, with a crystal stopper;
   - a candle burning down through its layers, with a cut-glass cloche;
   - a skincare dropper through morning / day / night, with a gem-cut bulb.

   The lathe profile is one array of points.
3. **The set.** Re-render the plates as your own space, built in Blender or hosted 3D: a marble plinth in a gallery, a wooden stool in a tea house, a bar top. Keep one camera and change only the light per tier, then measure the new plinth-top `u / v / w` and put them in `PLATE`.
4. **The three tiers and nine cards.** Replace top / heart / base and the nine ingredients with the three stages and nine ingredients your product really has, photographed or rendered in one consistent light and crop (square, centred, no text).
5. **Palette.** Replace `--ink`, `--night`, `--vellum` and the saffron accent with your brand colours, and set the four liquid stops to your product colours. Keep `--mute` at ≥ 4.5:1 on the ground.
6. **Type pairing.** Swap Fraunces + Hanken Grotesk + DM Mono for another expressive serif with italics (keep one italic accent word per heading), a plain sans and a mono.
7. **The finder.** Rewrite the three questions as the questions your customers ask before buying, and rebuild the 3×4×4 points table so every product can win.
8. **Copy.** Rewrite every heading in your own voice, specific to the product ("still on your scarf the next morning", not "an unforgettable experience").

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

---

## Reference implementation (use verbatim)

The complete working `index.html`. Every number in the spec above is in this file; if the two ever seem to differ, the code wins. Images and models referenced as `assets/...` can be downloaded from https://copytheprompt.design/demos/perfume-atelier-glass-flacon/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>Ombrine — Perfume Atelier</title>
<meta name="description" content="Ombrine is a small perfume atelier. Scroll to wear a scent: top, heart and base notes unfold inside a live glass flacon.">
<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=Fraunces:ital,opsz,wght,SOFT@0,9..144,300..600,50;1,9..144,300..600,50&family=Hanken+Grotesk:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap" rel="stylesheet">
<script type="importmap">{"imports":{"three":"https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js","three/addons/":"https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"}}</script>
<style>
:root{
  --ink:#110d12; --night:#1a151c; --plum:#2a1f2b; --line:rgba(241,232,220,.16);
  --vellum:#f1e8dc; --mute:#b9ada3; --saffron:#e3a54f; --saffron-ink:#1a1209;
  --liquid:#efe0a0;
  --f-display:"Fraunces", "Iowan Old Style", Georgia, serif;
  --f-ui:"Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono:"DM Mono", ui-monospace, Menlo, monospace;
  --gut:clamp(16px, 4vw, 56px);
  --r-s:10px; --r-m:18px; --r-l:28px; --r-pill:999px;
  --ease:cubic-bezier(.22,.8,.24,1);
  --ease-io:cubic-bezier(.65,0,.35,1);
  color-scheme:dark;
}
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--ink);color:var(--vellum);font:400 16px/1.55 var(--f-ui);overflow-x:clip;-webkit-font-smoothing:antialiased}
img{display:block;max-width:100%}
a{color:inherit}
button,input{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--saffron);outline-offset:3px;border-radius:6px}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.skip{position:fixed;left:12px;top:-60px;z-index:100;background:var(--saffron);color:var(--saffron-ink);padding:10px 16px;border-radius:var(--r-pill);font-weight:600;text-decoration:none;transition:top .2s}
.skip:focus{top:12px}
.mono{font:500 11px/1.3 var(--f-mono);letter-spacing:.14em;text-transform:uppercase}
.display{font-family:var(--f-display);font-weight:340;font-variation-settings:"SOFT" 50,"opsz" 120;letter-spacing:-.02em;line-height:.98;margin:0}
.display em{font-style:italic;font-weight:300;color:var(--saffron)}
.btn{display:inline-flex;align-items:center;gap:10px;min-height:46px;padding:0 22px;border-radius:var(--r-pill);border:1px solid var(--line);background:transparent;cursor:pointer;text-decoration:none;font-weight:500;font-size:15px;transition:background .3s var(--ease),color .3s var(--ease),border-color .3s,transform .3s var(--ease)}
.btn:hover{border-color:var(--vellum)}
.btn--solid{background:var(--vellum);color:var(--ink);border-color:var(--vellum)}
.btn--solid:hover{background:var(--saffron);border-color:var(--saffron);color:var(--saffron-ink)}
.btn--amber{background:var(--saffron);color:var(--saffron-ink);border-color:var(--saffron)}
.btn--amber:hover{background:var(--vellum);border-color:var(--vellum)}
.btn .arr{transition:transform .35s var(--ease)}
.btn:hover .arr{transform:translateX(4px)}

/* Header */
.hdr{position:fixed;inset:0 0 auto 0;z-index:40;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px var(--gut);transition:background .4s,backdrop-filter .4s}
.hdr.is-solid{background:rgba(17,13,18,.72);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px)}
.logo{font:400 26px/1 var(--f-display);font-style:italic;letter-spacing:-.02em;text-decoration:none}
.logo span{font-style:normal;font-size:11px;font-family:var(--f-mono);letter-spacing:.18em;vertical-align:middle;margin-left:10px;color:var(--mute)}
.nav{display:flex;gap:26px}
.nav a{text-decoration:none;font-size:14px;color:var(--mute);transition:color .25s}
.nav a:hover{color:var(--vellum)}
.bag-btn{display:inline-flex;align-items:center;gap:8px;min-height:40px;padding:0 16px;border-radius:var(--r-pill);border:1px solid var(--line);background:rgba(17,13,18,.4);cursor:pointer;font-size:14px}
.bag-btn b{display:inline-grid;place-items:center;min-width:22px;height:22px;border-radius:var(--r-pill);background:var(--saffron);color:var(--saffron-ink);font:600 12px/1 var(--f-ui);transition:transform .4s var(--ease)}
.bag-btn b.bump{animation:bump .5s var(--ease)}
@keyframes bump{40%{transform:scale(1.35)}}

/* ============ Pyramid (pinned) ============ */
.pyr{position:relative;height:520vh}
.pyr__stage{position:sticky;top:0;height:100vh;height:100svh;overflow:hidden;background:var(--night)}
.pyr__poster{position:absolute;inset:0}
.pyr__poster img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:0;transition:opacity .9s var(--ease)}
.pyr__poster img.on{opacity:.9}
.pyr canvas{position:absolute;inset:0;width:100%;height:100%;display:block;opacity:0;transition:opacity .9s var(--ease)}
.pyr canvas.live{opacity:1}
.pyr__scrim{position:absolute;inset:0;pointer-events:none;background:
  linear-gradient(90deg,rgba(17,13,18,.86) 0%,rgba(17,13,18,.62) 30%,rgba(17,13,18,0) 56%),
  linear-gradient(0deg,rgba(17,13,18,.7) 0%,rgba(17,13,18,0) 26%),
  linear-gradient(180deg,rgba(17,13,18,.55) 0%,rgba(17,13,18,0) 18%)}
.flacon-svg{position:absolute;left:54%;top:48%;width:min(26vw,300px);transform:translate(-50%,-50%);display:none}
.no-gl .flacon-svg{display:block}
.no-gl canvas{display:none}

.pyr__copy{position:absolute;left:var(--gut);bottom:clamp(90px,14vh,150px);width:min(580px,calc(100% - 2*var(--gut)))}
.act{position:absolute;left:0;bottom:0;width:100%;opacity:0;transform:translateY(24px);transition:opacity .7s var(--ease),transform .9s var(--ease);pointer-events:none}
.act.on{opacity:1;transform:none;pointer-events:auto}
.act .mono{color:var(--saffron);display:flex;gap:12px;align-items:center}
.act .mono i{font-style:normal;color:var(--mute)}
.act h1,.act h2{font-size:clamp(46px,5.8vw,88px);margin:16px 0 18px}
.act p{margin:0;color:#e1d6ca;font-size:clamp(15px,1.15vw,17px);max-width:42ch}
.act .ctas{display:flex;gap:12px;flex-wrap:wrap;margin-top:26px}
.hero-line{display:block;overflow:hidden;padding-bottom:.06em}
.hero-line > span{display:inline-block;transform:translateY(105%);transition:transform 1.2s var(--ease)}
.is-ready .hero-line > span{transform:none}
.is-ready .hero-line:nth-child(2) > span{transition-delay:.12s}

/* pyramid index */
.pidx{position:absolute;right:var(--gut);top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:flex-end;gap:16px;padding:20px 20px 14px;border-radius:var(--r-l);background:rgba(17,13,18,.55);border:1px solid var(--line);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
.pidx .clock{background:transparent;backdrop-filter:none}
.pidx__tri{width:132px;height:116px}
.pidx__tri path{fill:rgba(241,232,220,.06);stroke:rgba(241,232,220,.35);stroke-width:1;transition:fill .6s var(--ease)}
.pidx__tri path.on{fill:var(--liquid)}
.pidx ol{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px;align-items:flex-end}
.pidx button{background:none;border:0;cursor:pointer;display:flex;gap:12px;align-items:baseline;padding:6px 0;color:var(--mute);transition:color .3s}
.pidx button[aria-current="step"]{color:var(--vellum)}
.pidx button .mono{font-size:10px}
.pidx button strong{font:400 19px/1 var(--f-display);font-style:italic}
.clock{display:flex;gap:10px;align-items:center;padding:8px 14px;border:1px solid var(--line);border-radius:var(--r-pill);background:rgba(17,13,18,.45);backdrop-filter:blur(8px)}
.clock b{font:500 13px/1 var(--f-mono);color:var(--vellum);min-width:7ch;text-align:right}
.clock .mono{color:var(--mute);font-size:10px}

.notes{position:absolute;inset:0;pointer-events:none}
.note{position:absolute;left:0;top:0;width:128px;will-change:transform,opacity,filter;opacity:0;margin:0}
.note img{width:100%;height:auto;aspect-ratio:4/5;object-fit:cover;border-radius:14px;border:1px solid rgba(241,232,220,.22);box-shadow:0 18px 40px -12px rgba(0,0,0,.6),0 0 0 4px rgba(17,13,18,.18)}
.note figcaption{margin-top:9px;padding-left:2px}
.note strong{display:flex;align-items:center;gap:7px;font:400 17px/1.1 var(--f-display);font-style:italic;color:var(--vellum);text-shadow:0 1px 12px rgba(0,0,0,.6)}
.note strong::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--liquid);box-shadow:0 0 12px var(--liquid);flex:none}
.note span{display:block;margin-top:3px;font:400 9.5px/1.25 var(--f-mono);letter-spacing:.08em;color:#d6cabe;text-transform:uppercase;text-shadow:0 1px 10px rgba(0,0,0,.7)}
.grain{position:absolute;inset:-50%;pointer-events:none;opacity:.07;mix-blend-mode:overlay;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");animation:grain 1.2s steps(6) infinite}
@keyframes grain{0%{transform:translate(0,0)}20%{transform:translate(-4%,3%)}40%{transform:translate(3%,-2%)}60%{transform:translate(-2%,-4%)}80%{transform:translate(4%,2%)}100%{transform:translate(0,0)}}
.halo{position:absolute;inset:0;pointer-events:none;background:radial-gradient(60% 50% at var(--hx,60%) 40%,rgba(255,214,160,.10),transparent 70%);mix-blend-mode:screen}

/* preloader */
.pre{position:fixed;inset:0;z-index:90;background:var(--ink);display:grid;place-items:center;transition:opacity .7s var(--ease),visibility 0s linear .7s}
.pre.done{opacity:0;visibility:hidden}
.pre__in{display:grid;justify-items:center;gap:22px;width:min(320px,70vw)}
.pre__word{font:300 clamp(44px,7vw,72px)/1 var(--f-display);font-style:italic;letter-spacing:-.03em}
.pre__drop{width:10px;height:14px;border-radius:50% 50% 50% 50%/60% 60% 40% 40%;background:var(--saffron);box-shadow:0 0 24px var(--saffron);animation:drop 1.6s var(--ease-io) infinite}
@keyframes drop{0%{transform:translateY(-14px) scale(.6);opacity:0}40%{opacity:1}80%{transform:translateY(10px) scale(1);opacity:1}100%{transform:translateY(14px) scale(1.4,.3);opacity:0}}
.pre__line{width:100%;height:1px;background:rgba(241,232,220,.16);position:relative;overflow:hidden}
.pre__line i{position:absolute;inset:0;background:var(--vellum);transform-origin:left;transform:scaleX(0)}
.pre__pct{color:var(--mute)}
.cue{position:absolute;left:50%;bottom:22px;transform:translateX(-50%);display:flex;flex-direction:column;align-items:center;gap:8px;color:var(--mute);transition:opacity .5s}
.cue i{display:block;width:1px;height:38px;background:linear-gradient(var(--vellum),transparent);animation:cue 2.2s var(--ease-io) infinite;transform-origin:top}
@keyframes cue{0%{transform:scaleY(0)}50%{transform:scaleY(1)}100%{transform:scaleY(1);opacity:0}}
.gl-err{position:absolute;right:var(--gut);bottom:22px;font:400 11px/1.3 var(--f-mono);color:var(--mute);display:none}
.no-gl .gl-err{display:block}

/* ============ Sections ============ */
.sec,.strip{scroll-margin-top:0}
.q,.result{scroll-margin-top:90px}
.sec{padding:clamp(88px,12vw,168px) var(--gut)}
.sec__head{display:grid;grid-template-columns:1fr auto;align-items:end;gap:28px;margin-bottom:clamp(36px,5vw,64px)}
.sec__head h2{font-size:clamp(42px,5.6vw,84px)}
.sec__head p{margin:16px 0 0;color:var(--mute);max-width:46ch}
.eyebrow{color:var(--saffron);display:block;margin-bottom:18px}

.chips{display:flex;gap:8px;flex-wrap:wrap}
.chip{min-height:38px;padding:0 16px;border-radius:var(--r-pill);border:1px solid var(--line);background:transparent;cursor:pointer;font-size:14px;color:var(--mute);transition:all .3s var(--ease)}
.chip:hover{color:var(--vellum);border-color:rgba(241,232,220,.4)}
.chip[aria-pressed="true"]{background:var(--vellum);color:var(--ink);border-color:var(--vellum)}

.grid{display:grid;grid-template-columns:repeat(4,1fr);gap:clamp(12px,1.6vw,22px)}
.card{position:relative;border-radius:var(--r-l);overflow:hidden;background:var(--plum);aspect-ratio:4/5.6;isolation:isolate;transition:opacity .5s var(--ease),transform .6s var(--ease)}
.card[hidden]{display:none}
.card img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;transition:transform 1.2s var(--ease),filter .8s var(--ease)}
.card::after{content:"";position:absolute;inset:0;background:linear-gradient(180deg,rgba(17,13,18,0) 38%,rgba(17,13,18,.92) 100%);z-index:1;transition:opacity .6s}
.card__body{position:absolute;inset:auto 0 0 0;z-index:2;padding:22px}
.card__fam{position:absolute;top:18px;left:18px;z-index:2;padding:7px 12px;border-radius:var(--r-pill);background:rgba(17,13,18,.55);backdrop-filter:blur(6px);color:var(--vellum)}
.card h3{margin:0;font:400 clamp(28px,2.4vw,38px)/1 var(--f-display);letter-spacing:-.02em}
.card h3 em{font-style:italic}
.card__notes{display:grid;grid-template-rows:0fr;transition:grid-template-rows .6s var(--ease)}
.card__notes > div{overflow:hidden}
.card__notes p{margin:12px 0 0;color:#d9cdc0;font-size:14px}
.card__meta{display:flex;justify-content:space-between;align-items:center;margin-top:16px;gap:10px}
.card__price{font:500 13px/1 var(--f-mono)}
.card__swatch{position:relative;height:3px;flex:1;border-radius:3px;background:rgba(241,232,220,.16);overflow:hidden}
.card__swatch::after{content:"";position:absolute;inset:0;background:var(--c);transform:scaleX(.18);transform-origin:left;transition:transform .9s var(--ease)}
.card a.cover{position:absolute;inset:0;z-index:3;border-radius:inherit}
.card a.cover:focus-visible{outline-offset:-4px}
@media (hover:hover){
  .card:hover img{transform:scale(1.06)}
  .card:hover .card__notes{grid-template-rows:1fr}
  .card:hover .card__swatch::after{transform:scaleX(1)}
}
.card:focus-within .card__notes{grid-template-rows:1fr}
.card:focus-within .card__swatch::after{transform:scaleX(1)}
.empty{color:var(--mute)}

/* Finder */
.finder{display:grid;grid-template-columns:1.05fr 1fr;gap:clamp(24px,4vw,64px);align-items:stretch}
.finder__intro h2{font-size:clamp(42px,5.4vw,80px)}
.finder__intro p{color:var(--mute);max-width:40ch}
.quiz{position:relative;border:1px solid var(--line);border-radius:var(--r-l);padding:clamp(22px,3vw,40px);background:linear-gradient(160deg,rgba(42,31,43,.9),rgba(26,21,28,.9));min-height:470px;display:flex;flex-direction:column}
.quiz__bar{display:flex;gap:6px;margin-bottom:26px}
.quiz__bar i{flex:1;height:3px;border-radius:3px;background:rgba(241,232,220,.14);overflow:hidden;position:relative}
.quiz__bar i::after{content:"";position:absolute;inset:0;background:var(--saffron);transform:scaleX(0);transform-origin:left;transition:transform .6s var(--ease)}
.quiz__bar i.done::after{transform:scaleX(1)}
.q{border:0;margin:0;padding:0;display:none}
.q.on{display:block;animation:qin .6s var(--ease)}
@keyframes qin{from{opacity:0;transform:translateY(14px)}}
.q legend{font:400 clamp(26px,2.4vw,34px)/1.1 var(--f-display);margin-bottom:22px;padding:0}
.q legend small{display:block;font:500 11px/1 var(--f-mono);letter-spacing:.14em;color:var(--mute);margin-bottom:12px;text-transform:uppercase}
.opts{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.opt{position:relative}
.opt input{position:absolute;opacity:0;inset:0;cursor:pointer;margin:0}
.opt span{display:flex;flex-direction:column;gap:4px;min-height:84px;padding:16px;border-radius:var(--r-m);border:1px solid var(--line);transition:all .3s var(--ease);cursor:pointer}
.opt span b{font-weight:500}
.opt span small{color:var(--mute);font-size:13px}
.opt input:hover + span{border-color:rgba(241,232,220,.45)}
.opt input:checked + span{border-color:var(--saffron);background:rgba(227,165,79,.1)}
.opt input:focus-visible + span{outline:2px solid var(--saffron);outline-offset:2px}
.quiz__nav{display:flex;justify-content:space-between;margin-top:auto;padding-top:24px;gap:10px}
.quiz__nav .btn[disabled]{opacity:.35;cursor:not-allowed}
.result{display:none;grid-template-columns:150px 1fr;gap:22px;align-items:center}
.result.on{display:grid;animation:qin .7s var(--ease)}
.result img{width:150px;aspect-ratio:4/5;object-fit:cover;border-radius:var(--r-m)}
.result h3{margin:6px 0 8px;font:400 40px/1 var(--f-display)}
.result p{margin:0;color:#d9cdc0;font-size:15px}
.match{color:var(--saffron)}
.result .ctas{display:flex;gap:10px;flex-wrap:wrap;margin-top:18px}

/* Featured strip */
.strip{position:relative;padding:0}
.strip__stage{position:sticky;top:0;height:100vh;height:100svh;overflow:hidden;display:flex;flex-direction:column;justify-content:center;gap:28px;padding:70px 0 30px}
.strip__head{padding:0 var(--gut);display:flex;justify-content:space-between;align-items:end;gap:20px}
.strip__head h2{font-size:clamp(38px,4.6vw,68px)}
.strip__prog{display:flex;align-items:center;gap:12px;color:var(--mute)}
.strip__prog i{display:block;width:120px;height:2px;background:rgba(241,232,220,.16);position:relative;overflow:hidden}
.strip__prog i::after{content:"";position:absolute;inset:0;background:var(--vellum);transform:scaleX(var(--sp,0));transform-origin:left}
.track{display:flex;gap:clamp(14px,1.6vw,24px);padding:0 var(--gut);will-change:transform}
.prod{flex:none;width:clamp(290px,27vw,400px);border-radius:var(--r-l);background:var(--night);border:1px solid var(--line);overflow:hidden;display:flex;flex-direction:column}
.prod__img{position:relative;aspect-ratio:4/4.1;overflow:hidden;background:var(--plum)}
.prod__img img{width:100%;height:100%;object-fit:cover}
.prod__img canvas{position:absolute;inset:0;width:100%;height:100%;opacity:0;transition:opacity .8s var(--ease)}
.prod__img canvas.live{opacity:1}
.prod__img .mono{position:absolute;left:14px;top:14px;z-index:2;padding:6px 10px;border-radius:var(--r-pill);background:rgba(17,13,18,.6);backdrop-filter:blur(6px)}
.prod__img .mono.spin{left:auto;top:auto;right:14px;bottom:14px;font-size:9.5px}
.prod__body{padding:20px 22px 22px;display:flex;flex-direction:column;gap:14px;flex:1}
.prod h3{margin:0;font:400 30px/1 var(--f-display);letter-spacing:-.02em}
.prod h3 em{font-style:italic}
.prod .pnotes{margin:-6px 0 0;color:var(--mute);font-size:14px}
.sizes{display:flex;gap:6px}
.sizes label{position:relative;flex:1}
.sizes input{position:absolute;opacity:0;inset:0;margin:0;cursor:pointer}
.sizes span{display:grid;place-items:center;min-height:38px;border-radius:var(--r-pill);border:1px solid var(--line);font:500 12px/1 var(--f-mono);cursor:pointer;transition:all .25s}
.sizes input:checked + span{background:var(--vellum);color:var(--ink);border-color:var(--vellum)}
.sizes input:focus-visible + span{outline:2px solid var(--saffron);outline-offset:2px}
.prod__buy{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:auto}
.prod__price{font:400 26px/1 var(--f-display)}
.prod__price small{font:400 12px/1 var(--f-mono);color:var(--mute);margin-left:6px}
.add.added{background:var(--saffron);border-color:var(--saffron);color:var(--saffron-ink)}

/* Atelier */
.atelier{display:grid;grid-template-columns:1fr 1.1fr;gap:clamp(28px,5vw,88px);align-items:center}
.atelier__img{position:relative;border-radius:var(--r-l);overflow:hidden;aspect-ratio:4/5}
.atelier__img img{width:100%;height:118%;object-fit:cover;transform:translateY(var(--py,0))}
.atelier__img figcaption{position:absolute;left:16px;bottom:16px;padding:8px 12px;border-radius:var(--r-pill);background:rgba(17,13,18,.6);backdrop-filter:blur(6px)}
.atelier h2{font-size:clamp(40px,4.8vw,72px)}
.atelier .lede{font:300 clamp(20px,1.7vw,25px)/1.45 var(--f-display);color:#e7dccf;margin:26px 0}
.atelier p{color:var(--mute);max-width:52ch}
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:16px;margin-top:40px;padding-top:30px;border-top:1px solid var(--line)}
.stats b{display:block;font:300 clamp(36px,3.6vw,54px)/1 var(--f-display);color:var(--vellum)}
.stats span{display:block;margin-top:8px;color:var(--mute);font-size:13px}
.reveal{opacity:0;transform:translateY(28px);transition:opacity 1s var(--ease),transform 1.1s var(--ease)}
.reveal.in{opacity:1;transform:none}

/* Footer */
.ftr{padding:clamp(70px,9vw,120px) var(--gut) 28px;border-top:1px solid var(--line);background:linear-gradient(180deg,var(--ink),#0c090d)}
.ftr__top{display:grid;grid-template-columns:1.3fr 1fr;gap:clamp(36px,6vw,100px)}
.ftr__top>*,.finder>*,.atelier>*,.grid>*{min-width:0}
.news .btn{padding:0 18px;flex:none}
.ftr h2{font-size:clamp(40px,5vw,76px)}
.news{margin-top:28px;max-width:520px}
.news__row{display:flex;gap:8px;border:1px solid var(--line);border-radius:var(--r-pill);padding:6px;transition:border-color .3s}
.news__row:focus-within{border-color:var(--vellum)}
.news.err .news__row{border-color:#ff9a8a}
.news input[type=email]{flex:1;min-width:0;background:transparent;border:0;padding:0 16px;font-size:16px;outline:none}
.news input::placeholder{color:#8f847b}
.news__msg{min-height:22px;margin:10px 0 0 16px;font-size:14px;color:var(--mute)}
.news.err .news__msg{color:#ffb2a6}
.news.ok .news__msg{color:var(--saffron)}
.consent{display:flex;gap:10px;align-items:flex-start;margin:12px 0 0 16px;font-size:13px;color:var(--mute)}
.consent input{accent-color:var(--saffron);width:16px;height:16px;margin-top:2px}
.cols{display:grid;grid-template-columns:repeat(3,1fr);gap:24px}
.cols h3{color:var(--mute);margin:0 0 16px}
.cols ul{list-style:none;margin:0;padding:0;display:grid;gap:10px}
.cols a{text-decoration:none;color:#e1d6ca;transition:color .2s}
.cols a:hover{color:var(--saffron)}
.ftr__word{font:300 clamp(80px,21vw,330px)/.8 var(--f-display);font-style:italic;letter-spacing:-.05em;margin:clamp(40px,5vw,70px) 0 24px;color:transparent;-webkit-text-stroke:1px rgba(241,232,220,.28);user-select:none;text-align:center;white-space:nowrap;overflow:hidden}
.ftr__legal{display:flex;justify-content:space-between;flex-wrap:wrap;gap:12px;color:#968b82;padding-top:20px;border-top:1px solid var(--line)}

/* Bag drawer */
.scrim{position:fixed;inset:0;background:rgba(8,6,9,.6);z-index:60;opacity:0;pointer-events:none;transition:opacity .4s}
.scrim.on{opacity:1;pointer-events:auto}
.drawer{position:fixed;top:0;right:0;bottom:0;z-index:61;width:min(440px,100%);background:var(--night);border-left:1px solid var(--line);transform:translateX(100%);transition:transform .55s var(--ease);display:flex;flex-direction:column;visibility:hidden}
.drawer.on{transform:none;visibility:visible}
.drawer__hd{display:flex;justify-content:space-between;align-items:center;padding:22px 24px;border-bottom:1px solid var(--line)}
.drawer__hd h2{font:400 30px/1 var(--f-display);margin:0}
.x{width:42px;height:42px;border-radius:50%;border:1px solid var(--line);background:none;cursor:pointer;font-size:20px;line-height:1}
.ship{padding:16px 24px;border-bottom:1px solid var(--line);font-size:13px;color:var(--mute)}
.ship i{display:block;height:3px;background:rgba(241,232,220,.14);border-radius:3px;margin-top:10px;overflow:hidden}
.ship i b{display:block;height:100%;background:var(--saffron);transform-origin:left;transition:transform .6s var(--ease)}
.lines{flex:1;overflow:auto;padding:8px 24px;list-style:none;margin:0}
.line{display:grid;grid-template-columns:64px 1fr auto;gap:14px;align-items:center;padding:16px 0;border-bottom:1px solid var(--line)}
.line img{width:64px;height:76px;object-fit:cover;border-radius:10px}
.line h3{margin:0;font:400 20px/1.1 var(--f-display)}
.line small{color:var(--mute);font-family:var(--f-mono);font-size:11px}
.qty{display:inline-flex;align-items:center;gap:4px;margin-top:8px;border:1px solid var(--line);border-radius:var(--r-pill)}
.qty button{width:30px;height:30px;border:0;background:none;cursor:pointer;border-radius:50%}
.qty output{min-width:18px;text-align:center;font:500 13px/1 var(--f-mono)}
.rm{background:none;border:0;color:var(--mute);text-decoration:underline;cursor:pointer;font-size:12px;margin-top:6px}
.line .lp{font:500 13px/1 var(--f-mono);text-align:right}
.drawer__ft{padding:20px 24px 26px;border-top:1px solid var(--line);display:grid;gap:14px}
.sub{display:flex;justify-content:space-between;font:400 22px/1 var(--f-display)}
.drawer__ft .btn{justify-content:center}
.drawer__note{font-size:13px;color:var(--saffron);min-height:18px;margin:0}
.toast{position:fixed;left:50%;bottom:24px;max-width:calc(100% - 32px);text-align:center;z-index:70;transform:translate(-50%,20px);opacity:0;padding:12px 18px;border-radius:var(--r-pill);background:var(--vellum);color:var(--ink);font-size:14px;font-weight:500;transition:all .45s var(--ease);pointer-events:none}
.toast.on{opacity:1;transform:translate(-50%,0)}

/* ============ Responsive ============ */
@media (max-width:1100px){
  .grid{grid-template-columns:repeat(2,1fr)}
  .nav{display:none}
}
@media (max-width:899px){
  .strip{height:auto !important}
  .strip__stage{position:relative;height:auto;padding:88px 0}
  .track{overflow-x:auto;scroll-snap-type:x mandatory;transform:none !important;padding-bottom:12px;scrollbar-width:thin;scroll-padding:0 var(--gut)}
  .prod{scroll-snap-align:start;width:min(82vw,360px)}
  .strip__prog{display:none}
  .finder,.atelier,.ftr__top{grid-template-columns:1fr}
  .pidx{top:76px;transform:none;flex-direction:row;align-items:center;gap:10px;right:auto;left:var(--gut);padding:6px 6px 6px 12px;border-radius:999px}
  .pidx .clock{padding:6px 10px;border:0}
  .pidx ol{display:none}
  .pidx__tri{width:40px;height:35px}
  .flacon-svg{left:50%;top:34%;width:min(34vw,200px)}
}
@media (max-width:640px){
  .pyr__scrim{background:linear-gradient(0deg,rgba(17,13,18,.94) 0%,rgba(17,13,18,.72) 34%,rgba(17,13,18,0) 60%),linear-gradient(180deg,rgba(17,13,18,.6) 0%,rgba(17,13,18,0) 20%)}
  .pyr__copy{bottom:72px}
  .act h1,.act h2{font-size:clamp(40px,12vw,56px);margin:12px 0 12px}
  .act p{font-size:15px}
  .grid{grid-template-columns:1fr 1fr;gap:10px}
  .card{aspect-ratio:4/6;border-radius:var(--r-m)}
  .card__body{padding:14px}
  .card h3{font-size:24px}
  .card__fam{top:10px;left:10px;font-size:9px;padding:6px 9px}
  .card__meta{margin-top:10px}
  .sec__head{grid-template-columns:1fr}
  .opts{grid-template-columns:1fr}
  .opt span{min-height:64px}
  .result{grid-template-columns:96px 1fr}
  .result img{width:96px}
  .result h3{font-size:32px}
  .stats{grid-template-columns:1fr 1fr 1fr;gap:10px}
  .cols{grid-template-columns:1fr 1fr}
  .note{width:74px}
  .note img{border-radius:10px}
  .note strong{font-size:13px;gap:5px}
  .note span{display:none}
  .logo span{display:none}
  .cue{display:none}
  .strip__head{flex-direction:column;align-items:flex-start}
}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.001ms !important;animation-iteration-count:1 !important;transition-duration:.001ms !important;scroll-behavior:auto !important}
  .reveal{opacity:1;transform:none}
  .hero-line > span{transform:none}
}
</style>
</head>
<body>
<div class="pre" id="pre" aria-hidden="true"><div class="pre__in"><span class="pre__drop"></span><span class="pre__word">Ombrine</span><span class="pre__line"><i id="preBar"></i></span><span class="pre__pct mono" id="prePct">00%</span></div></div>
<a class="skip" href="#main">Skip to content</a>

<header class="hdr" id="hdr">
  <a class="logo" href="#top" aria-label="Ombrine, home">Ombrine<span>Parfums d’atelier</span></a>
  <nav class="nav" aria-label="Primary">
    <a href="#pyramid">The pyramid</a>
    <a href="#collection">Collection</a>
    <a href="#finder">Scent finder</a>
    <a href="#shop">Shop</a>
    <a href="#atelier">Atelier</a>
  </nav>
  <button class="bag-btn" id="bagBtn" aria-haspopup="dialog" aria-controls="drawer">Bag <b id="bagCount" aria-label="0 items">0</b></button>
</header>

<main id="main">
<!-- ============ PYRAMID ============ -->
<section class="pyr" id="pyramid" aria-label="The scent pyramid of Lueur, told in three acts">
  <span id="top"></span>
  <div class="pyr__stage" id="pyrStage">
    <div class="pyr__poster" aria-hidden="true">
      <img src="assets/plate-top.webp" alt="" class="on" data-k="0">
      <img src="assets/plate-heart.webp" alt="" data-k="1">
      <img src="assets/plate-base.webp" alt="" data-k="2">
    </div>
    <canvas id="gl" aria-hidden="true"></canvas>
    <svg class="flacon-svg" viewBox="0 0 200 300" aria-hidden="true">
      <defs>
        <clipPath id="fbody"><path d="M40 120 Q40 96 70 90 L84 86 L84 60 L116 60 L116 86 L130 90 Q160 96 160 120 L160 268 Q160 286 140 286 L60 286 Q40 286 40 268Z"/></clipPath>
        <linearGradient id="fsh" x1="0" x2="1"><stop offset="0" stop-color="#fff" stop-opacity=".35"/><stop offset=".18" stop-color="#fff" stop-opacity="0"/><stop offset=".82" stop-color="#fff" stop-opacity="0"/><stop offset="1" stop-color="#fff" stop-opacity=".25"/></linearGradient>
      </defs>
      <rect x="78" y="16" width="44" height="46" rx="8" fill="#e9dfd2"/>
      <rect x="82" y="56" width="36" height="8" fill="#c99a4c"/>
      <g clip-path="url(#fbody)">
        <rect x="0" y="0" width="200" height="300" fill="rgba(241,232,220,.12)"/>
        <rect id="svgLiquid" x="0" y="130" width="200" height="200" fill="var(--liquid)" opacity=".8"/>
        <rect x="0" y="0" width="200" height="300" fill="url(#fsh)"/>
      </g>
      <path d="M40 120 Q40 96 70 90 L84 86 L84 60 L116 60 L116 86 L130 90 Q160 96 160 120 L160 268 Q160 286 140 286 L60 286 Q40 286 40 268Z" fill="none" stroke="rgba(255,255,255,.6)" stroke-width="1.5"/>
    </svg>
    <div class="pyr__scrim"></div><div class="halo"></div><div class="grain"></div>
    <div class="notes" id="notes" aria-hidden="true"></div>

    <div class="pyr__copy">
      <div class="act on" data-act="-1">
        <span class="mono">Ombrine N°1 <i>— Lueur, eau de parfum</i></span>
        <h1 class="display"><span class="hero-line"><span>Perfume is <em>time</em>,</span></span><span class="hero-line"><span>poured into glass.</span></span></h1>
        <p>Scroll to wear it. A scent unfolds in three acts — from the bright first minutes to what your scarf still holds by morning.</p>
        <div class="ctas"><a class="btn btn--solid" href="#finder">Find your scent <span class="arr">→</span></a><a class="btn" href="#shop">Shop the collection</a></div>
      </div>
      <div class="act" data-act="0">
        <span class="mono">01 · Top notes <i>0 – 15 min</i></span>
        <h2 class="display">The first <em>light</em>.</h2>
        <p>Bergamot, neroli and pink pepper are the most volatile molecules in the bottle. They flash bright and leave first — the handshake, not the conversation.</p>
      </div>
      <div class="act" data-act="1">
        <span class="mono">02 · Heart notes <i>15 min – 4 h</i></span>
        <h2 class="display">The <em>heart</em> opens.</h2>
        <p>As the citrus lifts, damask rose, orris butter and jasmine sambac settle in. This is the character you will be remembered by.</p>
      </div>
      <div class="act" data-act="2">
        <span class="mono">03 · Base notes <i>4 – 24 h</i></span>
        <h2 class="display">What <em>stays</em>.</h2>
        <p>Aged oud, labdanum and Madagascan vanilla evaporate slowest of all. Warm, close, and still there the next morning.</p>
        <div class="ctas"><a class="btn btn--amber" href="#shop" data-scrollto="lueur">Lueur, from €42 <span class="arr">→</span></a></div>
      </div>
    </div>

    <div class="pidx">
      <svg class="pidx__tri" viewBox="0 0 132 116" aria-hidden="true">
        <path data-t="0" d="M66 2 L88 40 L44 40Z"/>
        <path data-t="1" d="M42 44 L90 44 L110 78 L22 78Z"/>
        <path data-t="2" d="M20 82 L112 82 L130 114 L2 114Z"/>
      </svg>
      <div class="clock" role="status" aria-live="off"><span class="mono">On skin</span><b id="clock">00h 00m</b></div>
      <ol aria-label="Jump to a note tier">
        <li><button data-go="0"><span class="mono">Top</span><strong>Bergamot</strong></button></li>
        <li><button data-go="1"><span class="mono">Heart</span><strong>Damask rose</strong></button></li>
        <li><button data-go="2"><span class="mono">Base</span><strong>Aged oud</strong></button></li>
      </ol>
    </div>
    <div class="cue" id="cue" aria-hidden="true"><span class="mono">Scroll to wear it</span><i></i></div>
    <p class="gl-err">3D unavailable — showing illustrated flacon</p>
  </div>
</section>

<!-- ============ COLLECTION ============ -->
<section class="sec" id="collection" aria-labelledby="colH">
  <div class="sec__head">
    <div>
      <span class="eyebrow mono">The wardrobe</span>
      <h2 class="display reveal" id="colH">Four scents. <em>Four</em> hours of day.</h2>
      <p class="reveal">Each one is composed on our organ, macerated for six weeks and filled by hand in batches of four hundred.</p>
    </div>
    <div class="chips" role="group" aria-label="Filter by family">
      <button class="chip" aria-pressed="true" data-f="all">All</button>
      <button class="chip" aria-pressed="false" data-f="citrus">Citrus</button>
      <button class="chip" aria-pressed="false" data-f="floral">Floral</button>
      <button class="chip" aria-pressed="false" data-f="amber">Amber</button>
      <button class="chip" aria-pressed="false" data-f="woody">Woody</button>
    </div>
  </div>
  <div class="grid" id="grid"></div>
  <p class="empty" id="empty" hidden>Nothing in this family yet.</p>
  <p class="sr-only" id="gridStatus" aria-live="polite"></p>
</section>

<!-- ============ FINDER ============ -->
<section class="sec" id="finder" aria-labelledby="finH">
  <div class="finder">
    <div class="finder__intro">
      <span class="eyebrow mono">Scent finder · 3 questions</span>
      <h2 class="display reveal" id="finH">Tell us a <em>place</em>, we’ll pour the scent.</h2>
      <p class="reveal">No blind buys. Three questions about light, place and presence, and we match you to one of our four — with a 2 ml sample to try first.</p>
    </div>
    <form class="quiz" id="quiz" novalidate aria-describedby="quizHelp">
      <p class="sr-only" id="quizHelp">Answer three questions. Use arrow keys to change the selected answer.</p>
      <div class="quiz__bar" aria-hidden="true"><i></i><i></i><i></i></div>
      <fieldset class="q on" data-q="0">
        <legend><small>Question 1 of 3</small>When do you reach for perfume?</legend>
        <div class="opts">
          <label class="opt"><input type="radio" name="q0" value="0"><span><b>Morning light</b><small>Coffee, open windows</small></span></label>
          <label class="opt"><input type="radio" name="q0" value="1"><span><b>Late afternoon</b><small>Walks, long lunches</small></span></label>
          <label class="opt"><input type="radio" name="q0" value="2"><span><b>After dark</b><small>Dinners, candles</small></span></label>
          <label class="opt"><input type="radio" name="q0" value="3"><span><b>Any weather</b><small>Rain included</small></span></label>
        </div>
      </fieldset>
      <fieldset class="q" data-q="1">
        <legend><small>Question 2 of 3</small>Pick a place to stand in.</legend>
        <div class="opts">
          <label class="opt"><input type="radio" name="q1" value="0"><span><b>A terrace by the sea</b><small>Salt, citrus trees</small></span></label>
          <label class="opt"><input type="radio" name="q1" value="1"><span><b>A walled rose garden</b><small>Petals, warm stone</small></span></label>
          <label class="opt"><input type="radio" name="q1" value="2"><span><b>A library by the fire</b><small>Leather, old paper</small></span></label>
          <label class="opt"><input type="radio" name="q1" value="3"><span><b>A forest after rain</b><small>Moss, wet bark</small></span></label>
        </div>
      </fieldset>
      <fieldset class="q" data-q="2">
        <legend><small>Question 3 of 3</small>How should it carry?</legend>
        <div class="opts">
          <label class="opt"><input type="radio" name="q2" value="0"><span><b>A bright hello</b><small>Noticed, then gone</small></span></label>
          <label class="opt"><input type="radio" name="q2" value="1"><span><b>A soft trail</b><small>Someone leans in</small></span></label>
          <label class="opt"><input type="radio" name="q2" value="2"><span><b>It fills a room</b><small>And lingers after</small></span></label>
          <label class="opt"><input type="radio" name="q2" value="3"><span><b>Close to skin</b><small>Only for me</small></span></label>
        </div>
      </fieldset>
      <div class="result" id="result" tabindex="-1" aria-live="polite">
        <img id="rImg" src="assets/render-lueur.webp" alt="">
        <div>
          <span class="mono match" id="rMatch">92% match</span>
          <h3 id="rName">Lueur</h3>
          <p id="rWhy"></p>
          <div class="ctas"><button type="button" class="btn btn--amber" id="rAdd">Add 2 ml sample · €8</button><button type="button" class="btn" id="rView">View in shop</button></div>
        </div>
      </div>
      <div class="quiz__nav">
        <button type="button" class="btn" id="qBack" disabled>← Back</button>
        <button type="button" class="btn btn--solid" id="qNext" disabled>Next <span class="arr">→</span></button>
      </div>
      <p class="sr-only" id="quizStatus" aria-live="polite"></p>
    </form>
  </div>
</section>

<!-- ============ SHOP STRIP ============ -->
<section class="strip" id="shop" aria-labelledby="shopH">
  <div class="strip__stage">
    <div class="strip__head">
      <div>
        <span class="eyebrow mono">The shop · autumn batch N°14</span>
        <h2 class="display" id="shopH">Choose a <em>size</em>, keep the flacon.</h2>
      </div>
      <div class="strip__prog mono" aria-hidden="true"><span id="spNum">01</span><i id="spBar"></i><span>05</span></div>
    </div>
    <div class="track" id="track" tabindex="0" aria-label="Products, scroll horizontally"></div>
  </div>
</section>

<!-- ============ ATELIER ============ -->
<section class="sec" id="atelier" aria-labelledby="atH">
  <div class="atelier">
    <figure class="atelier__img reveal" style="margin:0">
      <img id="atImg" src="assets/atelier.webp" alt="The perfumer's organ in the Ombrine atelier: tiered wooden shelves of small amber vials, a brass scale and blotter strips by a curtained window" loading="lazy" width="880" height="1100">
      <figcaption class="mono">The organ · 312 raw materials</figcaption>
    </figure>
    <div>
      <span class="eyebrow mono">The atelier</span>
      <h2 class="display reveal" id="atH">Slow is the <em>only</em> formula.</h2>
      <p class="lede reveal">Ombrine is two perfumers and an organ of amber vials in a former bindery. We weigh every batch by hand, let it rest six weeks in the dark, and never make more than we can fill ourselves.</p>
      <p class="reveal">Our materials are bought from growers we visit: bergamot from a cooperative on the Ionian coast, orris that has dried for three years before it reaches us, oud from a single plantation. Flacons are heavy, refillable glass — bring yours back and the refill is a third off.</p>
      <div class="stats reveal">
        <div><b data-count="312">0</b><span>raw materials on the organ</span></div>
        <div><b data-count="400">0</b><span>flacons per batch, numbered</span></div>
        <div><b data-count="6">0</b><span>weeks of maceration</span></div>
      </div>
    </div>
  </div>
</section>
</main>

<footer class="ftr" aria-labelledby="ftH">
  <div class="ftr__top">
    <div>
      <h2 class="display" id="ftH">Letters from the <em>organ</em>.</h2>
      <p style="color:var(--mute);max-width:44ch;margin:18px 0 0">One letter a season: new batches before they sell out, refill days, and the occasional formula note.</p>
      <form class="news" id="news" novalidate>
        <label class="sr-only" for="email">Email address</label>
        <div class="news__row">
          <input type="email" id="email" name="email" placeholder="your@email.com" autocomplete="email" aria-describedby="newsMsg" required>
          <button class="btn btn--solid" type="submit">Subscribe <span class="arr">→</span></button>
        </div>
        <label class="consent"><input type="checkbox" id="consent" aria-describedby="newsMsg"> I agree to receive one seasonal email. Unsubscribe anytime.</label>
        <p class="news__msg" id="newsMsg" role="status" aria-live="polite"></p>
      </form>
    </div>
    <nav class="cols" aria-label="Footer">
      <div><h3 class="mono">Shop</h3><ul><li><a href="#shop">All perfumes</a></li><li><a href="#shop">Discovery set</a></li><li><a href="#atelier">Refills</a></li></ul></div>
      <div><h3 class="mono">Atelier</h3><ul><li><a href="#atelier">Our story</a></li><li><a href="#pyramid">The pyramid</a></li><li><a href="#finder">Scent finder</a></li></ul></div>
      <div><h3 class="mono">Help</h3><ul><li><a href="#news">Contact</a></li><li><a href="#news">Shipping</a></li><li><a href="#news">Returns</a></li></ul></div>
    </nav>
  </div>
  <p class="ftr__word" aria-hidden="true">Ombrine</p>
  <div class="ftr__legal mono"><span>© 2026 Ombrine — a fictional atelier</span><span>Made slowly, filled by hand</span></div>
</footer>

<div class="scrim" id="scrim"></div>
<aside class="drawer" id="drawer" role="dialog" aria-modal="true" aria-labelledby="drawerH">
  <div class="drawer__hd"><h2 id="drawerH">Your bag</h2><button class="x" id="closeBag" aria-label="Close bag">×</button></div>
  <div class="ship" id="ship"><span id="shipTxt"></span><i><b id="shipBar"></b></i></div>
  <ul class="lines" id="lines"></ul>
  <div class="drawer__ft">
    <div class="sub"><span>Subtotal</span><span id="subtotal">€0</span></div>
    <button class="btn btn--solid" id="checkout">Checkout <span class="arr">→</span></button>
    <p class="drawer__note" id="coNote" role="status"></p>
  </div>
</aside>
<div class="toast" id="toast" role="status" aria-live="polite"></div>

<script>
/* ---------- data ---------- */
const PERFUMES=[
 {id:'lueur',name:'Lueur',em:'',fam:'citrus',famL:'Citrus',notes:'Bergamot · neroli · white musk',img:'assets/render-lueur.webp',alt:'Lueur: the glass flacon of pale citrus-yellow perfume on a travertine drum, window light raking the wall (Cycles render)',plate:'assets/plate-top.webp',cap:'#e9e0d0',color:'#e9cf63',prices:{10:42,50:145,100:210},why:'Bright and clean: bergamot and neroli for open windows and early starts, with a soft musk that keeps it close by noon.'},
 {id:'rose',name:'Rose',em:'Tacite',fam:'floral',famL:'Floral',notes:'Damask rose · orris · cashmere wood',img:'assets/render-rose.webp',alt:'Rose Tacite: the glass flacon of rose-pink perfume on a travertine drum in dusk-pink light (Cycles render)',plate:'assets/plate-heart.webp',cap:'#e7b9b2',color:'#e48ea4',prices:{10:46,50:168,100:240},why:'A quiet rose rather than a loud one: powdery orris and soft woods let it trail just behind you.'},
 {id:'ambre',name:'Ambre',em:'Lent',fam:'amber',famL:'Amber',notes:'Labdanum · vanilla · aged oud',img:'assets/render-ambre.webp',alt:'Ambre Lent: the glass flacon of amber perfume with a dark cap, lit low and warm like candlelight (Cycles render)',plate:'assets/plate-base.webp',cap:'#3b2618',color:'#c46a25',prices:{10:52,50:184,100:265},why:'Resin, vanilla and a thread of oud: made for candlelight, it fills a room and is still on your scarf tomorrow.'},
 {id:'bois',name:'Sous-',em:'Bois',fam:'woody',famL:'Woody',notes:'Vetiver · fig leaf · oakmoss',img:'assets/render-bois.webp',alt:'Sous-Bois: the glass flacon of pale green perfume on a travertine drum in soft overcast green light (Cycles render)',plate:'assets/plate-wood.webp',cap:'#7f8782',color:'#6f9a7e',prices:{10:44,50:156,100:225},why:'Green, damp and grounding: vetiver and fig leaf like a forest path after rain, worn close to the skin.'}
];
const SET={id:'set',name:'Discovery',em:'set',fam:'all',notes:'4 × 2 ml — one of each, in a linen pouch',img:'assets/discovery-set.webp',alt:'Discovery set: four corked sample vials in yellow, pink, amber and green on a linen pouch',color:'#e3a54f',prices:{set:28}};
const NOTES=[
 [ ['Bergamot','cold-pressed · Ionian coast','bergamot'],['Neroli','bitter-orange blossom','neroli'],['Pink pepper','sparkling · dry','pepper'] ],
 [ ['Damask rose','absolute · steam-distilled','rose'],['Orris butter','3-year dried iris root','orris'],['Jasmine sambac','night-picked','jasmine'] ],
 [ ['Aged oud','single plantation','oud'],['Labdanum','amber resin','labdanum'],['Vanilla','Madagascan pods','vanilla'] ]
];
const LIQUID=['#efe0a0','#e9cf63','#e48ea4','#d0801f']; // intro, top, heart, base
const reduce=matchMedia('(prefers-reduced-motion: reduce)');
const $=s=>document.querySelector(s), $$=s=>[...document.querySelectorAll(s)];
const clamp=(v,a=0,b=1)=>Math.min(b,Math.max(a,v));
const smooth=(a,b,v)=>{const t=clamp((v-a)/(b-a));return t*t*(3-2*t)};
const hex=h=>[parseInt(h.slice(1,3),16),parseInt(h.slice(3,5),16),parseInt(h.slice(5,7),16)];
const mixHex=(a,b,t)=>{const A=hex(a),B=hex(b);return '#'+A.map((v,i)=>Math.round(v+(B[i]-v)*t).toString(16).padStart(2,'0')).join('')};
const nm=(p,html)=>{const sep=p.name.endsWith('-')?'':' ';return p.em?(p.name+sep+(html?'<em>'+p.em+'</em>':p.em)):p.name};
const eur=n=>'€'+n.toLocaleString('en-IE');

/* ---------- plate geometry ----------
   The backdrop plates are Cycles renders (1600×900). The travertine drum's top centre sits at
   PLATE.u / PLATE.v (from the top); its top is PLATE.w of the image width across.
   layoutPlate() cover-fits a plate into a W×H box, pans/zooms so the drum lands where we want it,
   and returns where the drum top is on screen and how wide the bottle should be. The WebGL shader,
   the DOM posters, the SVG fallback and the ingredient orbit all use these same numbers. */
const PLATE={u:.586,v:.564,w:.2,aspect:16/9};
function layoutPlate(W,H,o){
  const aspect=W/H, z=o.zoom||1;
  let sx=aspect>PLATE.aspect?1:aspect/PLATE.aspect, sy=aspect>PLATE.aspect?PLATE.aspect/aspect:1;
  sx/=z; sy/=z;
  const vUp=1-PLATE.v;
  let pu=PLATE.u-.5-(o.fx-.5)*sx, pv=vUp-.5-((1-o.fy)-.5)*sy;
  const mu=(1-sx)/2, mv=(1-sy)/2;
  pu=clamp(pu,-mu,mu); pv=clamp(pv,-mv,mv);
  const fx=(PLATE.u-.5-pu)/sx+.5, fy=1-((vUp-.5-pv)/sy+.5);
  const drumPx=PLATE.w/sx*W;
  return {sx,sy,pu,pv,fx,fy,drumPx,bottleW:Math.min(drumPx*(o.wf||.56),o.maxW||9999)};
}
window.layoutPlate=layoutPlate;

/* ---------- pyramid state (shared with GL module) ---------- */
window.PYR={p:0,k:-1,intro:1,level:.92,liquid:LIQUID[0],visible:true,plate:null,start:0};
const stage=$('#pyrStage'), pyr=$('#pyramid'), notesEl=$('#notes');
NOTES.forEach((tier,t)=>tier.forEach((n,i)=>{
  const d=document.createElement('figure');d.className='note';d.dataset.t=t;d.dataset.i=i;
  d.innerHTML=`<img src="assets/ing-${n[2]}.webp" alt="" width="360" height="360" decoding="async"><figcaption><strong>${n[0]}</strong><span>${n[1]}</span></figcaption>`;
  notesEl.appendChild(d);
}));
const noteNodes=$$('.note');
let box={top:0,h:1,vh:innerHeight,vw:innerWidth};
const posters=$$('.pyr__poster img');
function measure(){
  const r=pyr.getBoundingClientRect();
  box={top:r.top+scrollY,h:pyr.offsetHeight-innerHeight,vh:innerHeight,vw:innerWidth};
  const W=stage.clientWidth||innerWidth,H=stage.clientHeight||innerHeight,mob=W<640,tab=W<900;
  const gl=!document.documentElement.classList.contains('no-gl');
  PYR.plate=layoutPlate(W,H,mob?{fx:.5,fy:.5,zoom:gl?1.25:1,wf:.5,maxW:150}:tab?{fx:.54,fy:.6,zoom:1.1,wf:.6,maxW:240}:{fx:.6,fy:.62,wf:.66,maxW:320});
  const L=PYR.plate;
  // DOM posters + SVG fallback use the same mapping
  const opx=L.sx<1?(.5+L.pu-L.sx/2)/(1-L.sx)*100:50, opy=L.sy<1?(.5-L.pv-L.sy/2)/(1-L.sy)*100:50;
  posters.forEach(im=>{im.style.objectPosition=`${opx.toFixed(2)}% ${opy.toFixed(2)}%`;im.style.transform=gl&&mob?'scale(1.25)':''});
  const svg=$('.flacon-svg'); if(svg){svg.style.left=(L.fx*100)+'%';svg.style.top=(L.fy*H-L.bottleW*1.43)+'px';svg.style.width=L.bottleW+'px';svg.style.transform='translateX(-50%)'}
  measureStrip();
}
function liquidAt(k,intro){
  let c=k<1?mixHex(LIQUID[1],LIQUID[2],clamp(k)):mixHex(LIQUID[2],LIQUID[3],clamp(k-1));
  return mixHex(c,LIQUID[0],intro);
}
let lastAct=null;
const acts=$$('.act'), tris=$$('.pidx__tri path'), goBtns=$$('[data-go]');
const STOPS=[.26,.54,.84];
function pyrUpdate(t){
  const p=clamp((scrollY-box.top)/box.h);
  const intro=1-smooth(.05,.13,p);
  const k=smooth(.36,.44,p)+smooth(.64,.72,p);
  PYR.p=p;PYR.k=k;PYR.intro=intro;PYR.level=.92-.4*smooth(.12,1,p);
  PYR.liquid=liquidAt(k,intro);
  document.documentElement.style.setProperty('--liquid',PYR.liquid);
  const act=intro>.5?-1:Math.round(k);
  if(act!==lastAct){
    lastAct=act;
    acts.forEach(a=>a.classList.toggle('on',+a.dataset.act===act));
    tris.forEach(tr=>tr.classList.toggle('on',+tr.dataset.t===act));
    goBtns.forEach(b=>b.toggleAttribute('aria-current',false));
    if(act>=0) goBtns[act].setAttribute('aria-current','step');
    posters.forEach(im=>im.classList.toggle('on',+im.dataset.k===Math.max(0,act)));
  }
  $('#cue').style.opacity=1-smooth(.02,.08,p);
  const mins=Math.round(24*60*Math.pow(smooth(.1,.98,p),2.2));
  $('#clock').textContent=String(Math.floor(mins/60)).padStart(2,'0')+'h '+String(mins%60).padStart(2,'0')+'m';
  const svgL=$('#svgLiquid'); if(svgL) svgL.setAttribute('y',130+(1-(PYR.level-.52)/.4)*110);
  // ingredient photo cards orbit the flacon on a tilted ellipse
  const vw=box.vw,vh=box.vh,mob=vw<640,L=PYR.plate; if(!L)return;
  const bh=L.bottleW*1.9, cx=L.fx*vw, cy=L.fy*vh-bh*.5;
  const rx=mob?Math.min(vw*.36,150):Math.max(L.bottleW*1.05,Math.min(vw*.19,300)), ry=mob?34:70;
  const cw=mob?74:128, ch=mob?110:200;
  const time=reduce.matches?0:t*.00011;
  noteNodes.forEach(n=>{
    const ti=+n.dataset.t,i=+n.dataset.i;
    const w=clamp(1-Math.abs(k-ti)*1.6)*(1-intro);
    const a=p*Math.PI*2.4+i*(Math.PI*2/3)+ti*.9+time;
    const z=Math.sin(a), depth=z*.5+.5;
    const x=cx+Math.cos(a)*rx, y=cy+(i-1)*(mob?58:bh*.28)+z*ry*.5;
    const sc=(.72+.28*depth)*(.82+.18*w);
    const tx=clamp(x-cw/2,6,vw-cw*sc-6), ty=y-ch/2;
    const blur=(1-w)*10+(z<-.2?(-z-.2)*5:0);
    n.style.transform=`translate3d(${tx.toFixed(1)}px,${ty.toFixed(1)}px,0) rotate(${(Math.cos(a)*-4).toFixed(2)}deg) scale(${sc.toFixed(3)})`;
    const cross=smooth(.05,.5,Math.abs(Math.cos(a))); // dissolve while passing in front of / behind the bottle
    n.style.opacity=(w*(z<-.35?.55:1)*(.08+.92*cross)).toFixed(3);
    n.style.filter=blur>.3?`blur(${blur.toFixed(1)}px)`:'none';
    n.style.zIndex=z>0?3:1;
  });
}
goBtns.forEach(b=>b.addEventListener('click',()=>{
  const y=box.top+STOPS[+b.dataset.go]*box.h;
  scrollTo({top:y,behavior:reduce.matches?'auto':'smooth'});
}));
new IntersectionObserver(([e])=>{PYR.visible=e.isIntersecting},{rootMargin:'100px'}).observe(stage);

/* ---------- collection ---------- */
const grid=$('#grid');
grid.innerHTML=PERFUMES.map((p,i)=>`
 <article class="card reveal" data-fam="${p.fam}" style="--c:${p.color};transition-delay:${i*80}ms">
  <img src="${p.img}" alt="${p.alt}" loading="lazy" width="880" height="1100">
  <span class="card__fam mono">0${i+1} · ${p.famL}</span>
  <div class="card__body">
    <h3>${nm(p,1)}</h3>
    <div class="card__notes"><div><p>${p.notes}</p></div></div>
    <div class="card__meta"><span class="card__swatch" aria-hidden="true"></span><span class="card__price">from ${eur(p.prices[10])}</span></div>
  </div>
  <a class="cover" href="#shop" data-scrollto="${p.id}"><span class="sr-only">${nm(p)} — ${p.notes}. Shop from ${eur(p.prices[10])}</span></a>
 </article>`).join('');
$$('.chip').forEach(c=>c.addEventListener('click',()=>{
  $$('.chip').forEach(x=>x.setAttribute('aria-pressed',x===c));
  const f=c.dataset.f;let n=0;
  $$('.card').forEach(card=>{const show=f==='all'||card.dataset.fam===f;card.hidden=!show;if(show){n++;card.classList.add('in')}});
  $('#empty').hidden=n>0;
  $('#gridStatus').textContent=`${n} perfume${n===1?'':'s'} shown`;
}));

/* ---------- shop strip ---------- */
const track=$('#track');
const ITEMS=[...PERFUMES,SET];
track.innerHTML=ITEMS.map((p,i)=>{
  const isSet=p.id==='set';
  const sizes=isSet?'':`<div class="sizes" role="radiogroup" aria-label="Size for ${nm(p)}">${[10,50,100].map(s=>`<label><input type="radio" name="sz-${p.id}" value="${s}" ${s===50?'checked':''}><span>${s} ml</span></label>`).join('')}</div>`;
  const live=isSet?'':` data-plate="${p.plate}" data-color="${p.color}" data-cap="${p.cap}"`;
  return `<article class="prod" id="prod-${p.id}" data-id="${p.id}"${live}>
   <div class="prod__img"><img src="${p.img}" alt="${p.alt}" loading="lazy" width="1100" height="1366">${isSet?'':'<canvas aria-hidden="true"></canvas><span class="mono spin">Live 3D · turns with size</span>'}<span class="mono">${String(i+1).padStart(2,'0')} / 05</span></div>
   <div class="prod__body">
    <h3>${nm(p,1)}</h3>
    <p class="pnotes">${p.notes}</p>
    ${sizes}
    <div class="prod__buy"><span class="prod__price" aria-live="polite">${eur(isSet?p.prices.set:p.prices[50])}<small>${isSet?'4 × 2 ml':'50 ml'}</small></span>
    <button class="btn btn--solid add" data-add="${p.id}">Add to bag</button></div>
   </div></article>`}).join('');
track.addEventListener('change',e=>{
  if(!e.target.matches('.sizes input'))return;
  const card=e.target.closest('.prod'),p=PERFUMES.find(x=>x.id===card.dataset.id),s=+e.target.value;
  card.querySelector('.prod__price').innerHTML=`${eur(p.prices[s])}<small>${s} ml</small>`;
});
track.addEventListener('click',e=>{
  const b=e.target.closest('[data-add]');if(!b)return;
  const id=b.dataset.add,card=b.closest('.prod');
  const size=id==='set'?'set':+card.querySelector('.sizes input:checked').value;
  addToBag(id,size);
  b.classList.add('added');b.textContent='Added ✓';
  setTimeout(()=>{b.classList.remove('added');b.textContent='Add to bag'},1600);
});
const strip=$('#shop'),stripStage=strip.querySelector('.strip__stage');
let sbox={top:0,dist:0,on:false};
function measureStrip(){
  const desk=matchMedia('(min-width: 900px)').matches;
  track.style.transform='';
  if(!desk){strip.style.height='';sbox.on=false;return}
  const dist=Math.max(0,track.scrollWidth-innerWidth);
  strip.style.height=(innerHeight+dist*1.1)+'px';
  sbox={top:strip.getBoundingClientRect().top+scrollY,dist,on:true};
}
function stripUpdate(){
  if(!sbox.on)return;
  const sp=clamp((scrollY-sbox.top)/(sbox.dist*1.1||1));
  track.style.transform=`translate3d(${(-sp*sbox.dist).toFixed(1)}px,0,0)`;
  stripStage.style.setProperty('--sp',sp.toFixed(3));
  $('#spNum').textContent=String(1+Math.round(sp*4)).padStart(2,'0');
}
function scrollToProduct(id){
  const el=document.getElementById('prod-'+id);if(!el)return;
  const i=ITEMS.findIndex(x=>x.id===id);
  if(sbox.on){
    const off=el.offsetLeft-parseFloat(getComputedStyle(track).paddingLeft);
    const sp=clamp(off/sbox.dist);
    scrollTo({top:sbox.top+sp*sbox.dist*1.1+2,behavior:reduce.matches?'auto':'smooth'});
  }else{
    strip.scrollIntoView({behavior:reduce.matches?'auto':'smooth'});
    track.scrollTo({left:el.offsetLeft-16,behavior:reduce.matches?'auto':'smooth'});
  }
  setTimeout(()=>el.querySelector('.add')?.focus({preventScroll:true}),reduce.matches?0:900);
}
document.addEventListener('click',e=>{
  const a=e.target.closest('[data-scrollto]');if(!a)return;
  e.preventDefault();scrollToProduct(a.dataset.scrollto);
});

/* ---------- bag ---------- */
let bag=[];
try{bag=JSON.parse(localStorage.getItem('ombrine-bag')||'[]')}catch(e){bag=[]}
const FREE=150;
function save(){try{localStorage.setItem('ombrine-bag',JSON.stringify(bag))}catch(e){}}
function priceOf(l){if(l.id==='sample')return 8;const p=ITEMS.find(x=>x.id===l.id);return l.size==='set'?p.prices.set:p.prices[l.size]}
function addToBag(id,size){
  const ex=bag.find(l=>l.id===id&&l.size===size);
  if(ex)ex.q++;else bag.push({id,size,q:1});
  save();renderBag();
  const c=$('#bagCount');c.classList.remove('bump');void c.offsetWidth;c.classList.add('bump');
  const p=ITEMS.find(x=>x.id===id)||PERFUMES.find(x=>x.id===size);
  toast(`${id==='sample'?'2 ml sample of '+nm(PERFUMES.find(x=>x.id===size)):nm(p)} added to your bag`);
}
function renderBag(){
  const n=bag.reduce((s,l)=>s+l.q,0),tot=bag.reduce((s,l)=>s+l.q*priceOf(l),0);
  $('#bagCount').textContent=n;$('#bagCount').setAttribute('aria-label',`${n} item${n===1?'':'s'}`);
  $('#subtotal').textContent=eur(tot);
  $('#shipTxt').textContent=tot>=FREE?'Free tracked shipping unlocked.':bag.length?`${eur(FREE-tot)} away from free shipping.`:`Free shipping from ${eur(FREE)}.`;
  $('#shipBar').style.transform=`scaleX(${clamp(tot/FREE)})`;
  $('#lines').innerHTML=bag.length?bag.map((l,i)=>{
    const isS=l.id==='sample',p=isS?PERFUMES.find(x=>x.id===l.size):ITEMS.find(x=>x.id===l.id);
    const lbl=isS?'2 ml sample':l.size==='set'?'4 × 2 ml':l.size+' ml';
    return `<li class="line"><img src="${p.img}" alt=""><div><h3>${nm(p)}</h3><small>${lbl}</small><br>
     <span class="qty"><button data-q="-1" data-i="${i}" aria-label="Decrease quantity of ${nm(p)}">−</button><output aria-live="polite">${l.q}</output><button data-q="1" data-i="${i}" aria-label="Increase quantity of ${nm(p)}">+</button></span>
     <br><button class="rm" data-rm="${i}">Remove</button></div><span class="lp">${eur(l.q*priceOf(l))}</span></li>`}).join('')
    :'<li style="padding:40px 0;color:var(--mute)">Your bag is empty. The scent finder is a good place to start.</li>';
  $('#checkout').disabled=!bag.length;
}
$('#lines').addEventListener('click',e=>{
  const q=e.target.closest('[data-q]'),r=e.target.closest('[data-rm]');
  if(q){const l=bag[+q.dataset.i];l.q+= +q.dataset.q;if(l.q<1)bag.splice(+q.dataset.i,1)}
  else if(r)bag.splice(+r.dataset.rm,1); else return;
  save();renderBag();$('#closeBag').focus();
});
let lastFocus=null;
function openBag(){lastFocus=document.activeElement;$('#drawer').classList.add('on');$('#scrim').classList.add('on');$('#coNote').textContent='';setTimeout(()=>$('#closeBag').focus(),50)}
function closeBag(){$('#drawer').classList.remove('on');$('#scrim').classList.remove('on');lastFocus&&lastFocus.focus&&lastFocus.focus({preventScroll:true})}
$('#bagBtn').addEventListener('click',openBag);$('#closeBag').addEventListener('click',closeBag);$('#scrim').addEventListener('click',closeBag);
document.addEventListener('keydown',e=>{
  if(!$('#drawer').classList.contains('on'))return;
  if(e.key==='Escape')closeBag();
  if(e.key==='Tab'){const f=$$('#drawer button:not([disabled])');const a=f[0],z=f[f.length-1];
    if(e.shiftKey&&document.activeElement===a){e.preventDefault();z.focus()}else if(!e.shiftKey&&document.activeElement===z){e.preventDefault();a.focus()}}
});
$('#checkout').addEventListener('click',()=>{$('#coNote').textContent='Demo atelier — no payment is taken. Your bag is saved on this device.'});
let tt;function toast(m){const t=$('#toast');t.textContent=m;t.classList.add('on');clearTimeout(tt);tt=setTimeout(()=>t.classList.remove('on'),2200)}
renderBag();

/* ---------- finder ---------- */
// points[question][option] -> [lueur, rose, ambre, bois]
const POINTS=[
 [[3,1,0,1],[1,3,1,1],[0,1,3,1],[1,0,1,3]],
 [[3,1,0,0],[0,3,1,0],[0,0,3,1],[0,0,1,3]],
 [[3,1,0,0],[1,3,0,1],[0,1,3,0],[1,0,1,3]]
];
let qi=0;const qs=$$('.q'),bars=$$('.quiz__bar i'),qNext=$('#qNext'),qBack=$('#qBack'),quiz=$('#quiz');
function answer(i){const c=quiz.querySelector(`input[name=q${i}]:checked`);return c?+c.value:null}
function showQ(){
  qs.forEach((q,i)=>q.classList.toggle('on',i===qi));
  $('#result').classList.toggle('on',qi===3);
  bars.forEach((b,i)=>b.classList.toggle('done',i<qi||(i===qi&&answer(i)!==null)));
  qBack.disabled=qi===0;
  if(qi===3){qNext.innerHTML='Start again ↺';qNext.disabled=false;return}
  qNext.innerHTML=(qi===2?'See my scent':'Next')+' <span class="arr">→</span>';
  qNext.disabled=answer(qi)===null;
}
quiz.addEventListener('change',()=>{showQ()});
let rec=null;
qNext.addEventListener('click',()=>{
  if(qi===3){quiz.reset();qi=0;showQ();qs[0].querySelector('input').focus();return}
  if(answer(qi)===null)return;
  qi++;
  if(qi===3){
    const sc=[0,0,0,0];[0,1,2].forEach(q=>POINTS[q][answer(q)].forEach((v,i)=>sc[i]+=v));
    const best=sc.indexOf(Math.max(...sc));rec=PERFUMES[best];
    const pct=Math.round(68+Math.max(...sc)/9*31);
    $('#rImg').src=rec.img;$('#rImg').alt=rec.alt;$('#rName').innerHTML=nm(rec,1).replace('<em>','<em style="font-style:italic">');
    $('#rMatch').textContent=`${pct}% match · ${rec.famL}`;$('#rWhy').textContent=rec.why;
    $('#quizStatus').textContent=`Your match is ${nm(rec)}, ${pct} percent.`;
    showQ();$('#result').focus({preventScroll:true});return;
  }
  showQ();qs[qi].querySelector('input').focus();
});
qBack.addEventListener('click',()=>{if(qi>0){qi--;showQ();(qs[qi].querySelector('input:checked')||qs[qi].querySelector('input')).focus()}});
$('#rAdd').addEventListener('click',()=>rec&&addToBag('sample',rec.id));
$('#rView').addEventListener('click',()=>rec&&scrollToProduct(rec.id));
showQ();

/* ---------- newsletter ---------- */
$('#news').addEventListener('submit',e=>{
  e.preventDefault();const f=e.currentTarget,em=$('#email'),v=em.value.trim(),msg=$('#newsMsg');
  f.classList.remove('err','ok');
  const ok=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(v);
  if(!v){f.classList.add('err');em.setAttribute('aria-invalid','true');msg.textContent='Please enter your email address.';em.focus();return}
  if(!ok){f.classList.add('err');em.setAttribute('aria-invalid','true');msg.textContent='That address looks incomplete — check the part after the @.';em.focus();return}
  if(!$('#consent').checked){f.classList.add('err');msg.textContent='Please tick the box so we may write to you.';$('#consent').focus();return}
  em.removeAttribute('aria-invalid');f.classList.add('ok');msg.textContent=`Thank you — the next letter goes to ${v}.`;em.value='';$('#consent').checked=false;
});

/* ---------- reveals, counters, parallax, header ---------- */
const io=new IntersectionObserver(es=>es.forEach(e=>{if(e.isIntersecting){e.target.classList.add('in');io.unobserve(e.target);
  e.target.querySelectorAll?.('[data-count]').forEach(countUp)}}),{rootMargin:'0px 0px -12% 0px'});
$$('.reveal').forEach(el=>io.observe(el));
function countUp(b){const to=+b.dataset.count;if(reduce.matches){b.textContent=to;return}const t0=performance.now();
  (function f(t){const k=clamp((t-t0)/1400);b.textContent=Math.round(to*(1-Math.pow(1-k,3)));if(k<1)requestAnimationFrame(f)})(t0)}
const atImg=$('#atImg'),hdr=$('#hdr');
let ticking=false;
function frame(t){
  ticking=false;
  pyrUpdate(t);stripUpdate();
  hdr.classList.toggle('is-solid',scrollY>box.top+box.h-40);
  if(!reduce.matches){const r=atImg.parentElement.getBoundingClientRect();if(r.bottom>0&&r.top<innerHeight){atImg.style.setProperty('--py',(((r.top+r.height/2)/innerHeight-.5)*-60-40).toFixed(1)+'px')}}
}
function req(){if(!ticking){ticking=true;requestAnimationFrame(frame)}}
addEventListener('scroll',req,{passive:true});
addEventListener('resize',()=>{measure();req()});
// keep the ingredient orbit drifting slowly while the stage is visible
(function idle(t){if(PYR.visible&&!document.hidden&&!reduce.matches)req();requestAnimationFrame(idle)})();
document.fonts?.ready.then(()=>{measure();req()});
measure();frame(performance.now());
/* ---------- preloader: real progress (fonts, plates, ingredient cards, the live scene), capped at 5 s ---------- */
(function(){
  const pre=$('#pre'),bar=$('#preBar'),pct=$('#prePct');
  const urls=['assets/plate-top.webp','assets/plate-heart.webp','assets/plate-base.webp',...NOTES.flat().map(n=>'assets/ing-'+n[2]+'.webp')];
  let done=0,total=urls.length+2,fontsOK=false;
  urls.forEach(u=>{const im=new Image();im.onload=im.onerror=()=>done++;im.src=u});
  (document.fonts?document.fonts.ready:Promise.resolve()).then(()=>{fontsOK=true});
  const t0=performance.now();let shown=0,v=0,last=t0,finished=false,reachedAt=0;
  function tick(t){
    const dt=Math.min(.05,(t-last)/1000);last=t;
    const real=(done+(fontsOK?1:0)+(PYR.glReady?1:0))/total;
    const target=t-t0>5000?1:real;
    // spring: tension 140, friction 26
    v+=((target-shown)*140-v*26)*dt;shown+=v*dt;if(reduce.matches)shown=target;
    bar.style.transform=`scaleX(${clamp(shown).toFixed(3)})`;pct.textContent=String(Math.round(clamp(shown)*100)).padStart(2,'0')+'%';
    if(target>=1&&!reachedAt)reachedAt=t;
    if(target>=1&&(shown>.985||t-reachedAt>700)&&!finished){finished=true;bar.style.transform='scaleX(1)';pct.textContent='100%';
      setTimeout(()=>{pre.classList.add('done');document.documentElement.classList.add('is-ready');setTimeout(()=>{PYR.start=performance.now()},reduce.matches?0:260)},reduce.matches?0:190);return}
    requestAnimationFrame(tick);
  }
  requestAnimationFrame(tick);
})();
</script>

<script type="module">
/* =====================================================================
   Live glass — three.js r170
   1. HERO: a lathe-built flacon (tinted transmissive liquid, clear heel and
      neck with dispersion, additive reflection shell, knurled gold collar)
      capped with a faceted crystal stopper that is RAY-TRACED in its own
      fragment shader: 82 analytic facet planes, refraction in, up to 5
      internal bounces with total internal reflection, three IORs traced
      separately for dispersion, exiting into a live cube map of the scene.
      It stands on the travertine drum of a Cycles-rendered plate.
   2. SHOP: one offscreen renderer draws each product's flacon on its own
      plate into the card's 2D canvas (only cards on screen, only while
      the shop is in view). The 10/50/100 ml choice scales the bottle.
   ===================================================================== */
const P=window.PYR;
const root=document.documentElement;
function fail(msg){console.warn('[Ombrine] 3D fallback:',msg);root.classList.add('no-gl');P.glReady=true;window.dispatchEvent(new Event('resize'))}
let THREE,RoomEnvironment;
try{
  const c=document.createElement('canvas');
  if(!(c.getContext('webgl2')))throw new Error('no webgl2');
  THREE=await import('three');
  ({RoomEnvironment}=await import('three/addons/environments/RoomEnvironment.js'));
}catch(e){fail(e.message)}

/* ---------- shared builders ---------- */
function plateMaterial(textures){
  return new THREE.ShaderMaterial({
    uniforms:{t0:{value:textures[0]},t1:{value:textures[1]||textures[0]},t2:{value:textures[2]||textures[0]},k:{value:0},intro:{value:0},
      s:{value:new THREE.Vector2(1,1)},pan:{value:new THREE.Vector2()},off:{value:new THREE.Vector2()}},
    vertexShader:`varying vec2 vUv;void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.);}`,
    fragmentShader:`uniform sampler2D t0,t1,t2;uniform float k,intro;uniform vec2 s,pan,off;varying vec2 vUv;
      void main(){vec2 uv=(vUv-.5)*s+.5+pan+off;
        vec3 a=texture2D(t0,uv).rgb,b=texture2D(t1,uv).rgb,c=texture2D(t2,uv).rgb;
        vec3 col=mix(a,b,smoothstep(0.,1.,clamp(k,0.,1.)));col=mix(col,c,smoothstep(0.,1.,clamp(k-1.,0.,1.)));
        col=mix(col,col*vec3(.30,.25,.30),intro*.7);
        gl_FragColor=vec4(col,1.);
        #include <colorspace_fragment>
      }`,depthWrite:false,toneMapped:false});
}
function loadTex(url){const t=new THREE.TextureLoader().load(url,undefined,undefined,()=>console.warn('[Ombrine] missing',url));t.colorSpace=THREE.SRGBColorSpace;t.anisotropy=4;return t}
const V=a=>a.map(([x,y])=>new THREE.Vector2(x,y));
function blobTexture(){
  const c=document.createElement('canvas');c.width=c.height=128;const g=c.getContext('2d');
  const r=g.createRadialGradient(64,64,4,64,64,64);r.addColorStop(0,'rgba(0,0,0,.75)');r.addColorStop(.5,'rgba(0,0,0,.35)');r.addColorStop(1,'rgba(0,0,0,0)');
  g.fillStyle=r;g.fillRect(0,0,128,128);const t=new THREE.CanvasTexture(c);return t;
}
function makeFlacon({stopper}){
  const DISP=m=>{if('dispersion' in m)m.dispersion=.45;return m};
  const group=new THREE.Group();
  const outer=V([[0,-1.3],[.56,-1.3],[.68,-1.25],[.73,-1.12],[.74,-.2],[.73,.22],[.67,.4],[.46,.55],[.25,.62],[.23,.74],[.25,.8],[.25,.9],[0,.9]]);
  const shell=new THREE.Mesh(new THREE.LatheGeometry(outer,128),new THREE.MeshPhysicalMaterial({color:0x000000,roughness:.04,clearcoat:.5,clearcoatRoughness:.04,envMapIntensity:1.25,specularIntensity:.8,transparent:true,blending:THREE.AdditiveBlending,depthWrite:false}));
  shell.renderOrder=3;group.add(shell);
  const clear=DISP(new THREE.MeshPhysicalMaterial({color:0xffffff,roughness:.02,transmission:1,thickness:1.6,ior:1.52,specularIntensity:1,envMapIntensity:1.3,attenuationColor:new THREE.Color('#eef2ea'),attenuationDistance:3}));
  group.add(new THREE.Mesh(new THREE.LatheGeometry(V([[0,-1.29],[.55,-1.29],[.67,-1.24],[.715,-1.12],[.715,-1.02],[0,-1.02]]),96),clear));
  group.add(new THREE.Mesh(new THREE.LatheGeometry(V([[0,.36],[.6,.38],[.45,.52],[.24,.6],[.22,.74],[.24,.8],[.24,.89],[0,.89]]),96),clear));
  const liqMat=DISP(new THREE.MeshPhysicalMaterial({color:0xffffff,roughness:.06,transmission:1,thickness:1.3,ior:1.36,attenuationColor:new THREE.Color('#e9cf63'),attenuationDistance:1.5,specularIntensity:.6}));
  const liquid=new THREE.Mesh(new THREE.LatheGeometry(V([[0,0],[.66,0],[.695,.03],[.7,.08],[.7,1],[0,1]]),96),liqMat);liquid.position.y=-1.02;group.add(liquid);
  // knurled gold collar + polished lip
  const gold=new THREE.MeshPhysicalMaterial({color:new THREE.Color(1,.66,.28),metalness:1,roughness:.26,envMapIntensity:1.1});
  const cg=new THREE.CylinderGeometry(.285,.285,.16,192,4,false);
  const pos=cg.attributes.position,v=new THREE.Vector3();
  for(let i=0;i<pos.count;i++){v.fromBufferAttribute(pos,i);const r=Math.hypot(v.x,v.z);if(r>.2&&Math.abs(v.y)<.075){const a=Math.atan2(v.z,v.x);const k=1+.03*Math.sign(Math.cos(a*48));v.x*=k;v.z*=k;pos.setXYZ(i,v.x,v.y,v.z)}}
  cg.computeVertexNormals();
  const collar=new THREE.Mesh(cg,gold);collar.position.y=.95;group.add(collar);
  const lip=new THREE.Mesh(new THREE.TorusGeometry(.29,.022,16,96),new THREE.MeshPhysicalMaterial({color:new THREE.Color(1,.78,.48),metalness:1,roughness:.08}));lip.rotation.x=Math.PI/2;lip.position.y=1.03;group.add(lip);
  const lip2=lip.clone();lip2.position.y=.87;group.add(lip2);
  let cap=null;
  if(stopper){cap=stopper;cap.position.y=1.04+.42;group.add(cap)}
  else{
    cap=new THREE.Mesh(new THREE.LatheGeometry(V([[0,0],[.3,0],[.34,.04],[.34,.5],[.3,.54],[0,.54]]),8),new THREE.MeshPhysicalMaterial({color:new THREE.Color('#e6d9c6'),roughness:.42,clearcoat:.7,clearcoatRoughness:.25,flatShading:true}));
    cap.position.y=1.04;cap.rotation.y=Math.PI/8;group.add(cap);
  }
  const shadow=new THREE.Mesh(new THREE.PlaneGeometry(1,1),new THREE.MeshBasicMaterial({map:blobTexture(),transparent:true,depthWrite:false,toneMapped:false}));
  shadow.scale.set(2.3,.42,1);shadow.position.set(0,-1.3,-.75);shadow.renderOrder=-1;group.add(shadow);
  return {group,liquid,liqMat,cap,shadow,setLevel(l){liquid.scale.y=Math.max(.05,l*1.36-.04)}};
}

/* ---------- the ray-traced crystal stopper ---------- */
function makeCrystalStopper(envTex){
  const A=.34,B=.42,planes=[];
  const rings=[[90,1,0,.9],[62,8,0,1],[38,16,.5,1],[14,16,0,1],[-12,16,.5,1],[-38,16,0,1],[-64,8,.5,1],[-90,1,0,.86]];
  for(const [el,n,off,cut] of rings){for(let i=0;i<n;i++){
    const e=el*Math.PI/180,az=(i+off)/n*Math.PI*2;
    const nv=new THREE.Vector3(Math.cos(e)*Math.cos(az),Math.sin(e),Math.cos(e)*Math.sin(az)).normalize();
    const d=Math.sqrt(A*A*(nv.x*nv.x+nv.z*nv.z)+B*B*nv.y*nv.y)*cut;
    planes.push(new THREE.Vector4(nv.x,nv.y,nv.z,d));
  }}
  const mat=new THREE.ShaderMaterial({
    defines:{NP:planes.length,BOUNCES:matchMedia('(max-width:640px)').matches?3:5},
    uniforms:{planes:{value:planes},camObj:{value:new THREE.Vector3()},env:{value:envTex},o2w:{value:new THREE.Matrix3()},tint:{value:new THREE.Color(1,1,1)},gain:{value:1.0}},
    vertexShader:`varying vec3 vObj;void main(){vObj=position;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.);}`,
    fragmentShader:`uniform vec4 planes[NP];uniform vec3 camObj;uniform samplerCube env;uniform mat3 o2w;uniform vec3 tint;uniform float gain;varying vec3 vObj;
      bool enter(vec3 ro,vec3 rd,out float tn,out vec3 nn){float tN=-1e9,tF=1e9;nn=vec3(0.,1.,0.);
        for(int i=0;i<NP;i++){vec3 n=planes[i].xyz;float den=dot(n,rd),dist=planes[i].w-dot(n,ro);
          if(abs(den)<1e-6){if(dist<0.)return false;continue;}
          float t=dist/den; if(den<0.){if(t>tN){tN=t;nn=n;}}else{tF=min(tF,t);}}
        tn=tN;return tN<tF&&tF>0.;}
      void leave(vec3 ro,vec3 rd,out float t,out vec3 nOut){t=1e9;nOut=vec3(0.,1.,0.);
        for(int i=0;i<NP;i++){vec3 n=planes[i].xyz;float den=dot(n,rd);if(den>1e-6){float tt=(planes[i].w-dot(n,ro))/den;if(tt<t){t=tt;nOut=n;}}}}
      vec3 envS(vec3 d){return textureCube(env,normalize(o2w*d)).rgb;}
      float fres(float c,float r0){return r0+(1.-r0)*pow(1.-clamp(c,0.,1.),5.);}
      void main(){
        vec3 ro=camObj,rd=normalize(vObj-camObj);float t;vec3 n;
        if(!enter(ro,rd,t,n))discard;
        vec3 p=ro+rd*t;
        float F=fres(dot(-rd,n),.06);
        vec3 col=envS(reflect(rd,n))*F;
        vec3 iors=vec3(1.58,1.63,1.69);
        for(int ch=0;ch<3;ch++){
          float ior=iors[ch];vec3 d=refract(rd,n,1./ior);vec3 q=p;float thr=1.-F,acc=0.;
          for(int b=0;b<BOUNCES;b++){
            float te;vec3 ne;leave(q,d,te,ne);q+=d*te;thr*=exp(-te*.25);
            vec3 o=refract(d,-ne,ior);
            if(dot(o,o)<1e-5){d=reflect(d,-ne);continue;}
            float Fr=fres(dot(o,ne),.06);
            acc+=thr*(1.-Fr)*envS(o)[ch];thr*=Fr;d=reflect(d,-ne);
          }
          acc+=thr*envS(d)[ch];
          col[ch]+=acc*tint[ch];
        }
        gl_FragColor=vec4(col*gain,1.);
        #include <tonemapping_fragment>
        #include <colorspace_fragment>
      }`});
  const mesh=new THREE.Mesh(new THREE.BoxGeometry(A*2.02,B*2.02,A*2.02),mat);
  const tmp=new THREE.Vector3();
  mesh.onBeforeRender=(r,s,cam)=>{
    mesh.updateMatrixWorld();
    mat.uniforms.camObj.value.copy(mesh.worldToLocal(tmp.setFromMatrixPosition(cam.matrixWorld)));
    mat.uniforms.o2w.value.setFromMatrix4(mesh.matrixWorld);
    mat.uniformsNeedUpdate=true;
  };
  return mesh;
}

/* ---------- HERO ---------- */
function initHero(){
  const canvas=document.getElementById('gl');
  const renderer=new THREE.WebGLRenderer({canvas,antialias:true,powerPreference:'high-performance'});
  renderer.setPixelRatio(Math.min(devicePixelRatio,1.75));
  renderer.toneMapping=THREE.AgXToneMapping;renderer.toneMappingExposure=1.05;
  const scene=new THREE.Scene();
  const camera=new THREE.PerspectiveCamera(30,1,.1,100);camera.position.set(0,0,9);
  const pm=new THREE.PMREMGenerator(renderer);
  scene.environment=pm.fromScene(new RoomEnvironment(),.04).texture;scene.environmentIntensity=.95;
  const tex=['assets/plate-top.webp','assets/plate-heart.webp','assets/plate-base.webp'].map(loadTex);
  const bdMat=plateMaterial(tex);
  const BD_Z=-4;
  const bd=new THREE.Mesh(new THREE.PlaneGeometry(1,1),bdMat);bd.position.z=BD_Z;scene.add(bd);

  // live environment for the crystal: the studio room + the same plate behind it
  const envScene=new RoomEnvironment();
  const envPlate=new THREE.Mesh(new THREE.PlaneGeometry(16,9),bdMat);envPlate.position.set(0,0,-3.2);envScene.add(envPlate);
  const cubeRT=new THREE.WebGLCubeRenderTarget(192,{type:THREE.HalfFloatType,generateMipmaps:false});
  const cubeCam=new THREE.CubeCamera(.05,60,cubeRT);envScene.add(cubeCam);
  const stopper=makeCrystalStopper(cubeRT.texture);
  const F=makeFlacon({stopper});scene.add(F.group);
  const key=new THREE.DirectionalLight(0xfff1dd,1.4);key.position.set(3,4,5);scene.add(key);
  const rim=new THREE.DirectionalLight(0xffe2c0,1.1);rim.position.set(-4,2,-3);scene.add(rim);

  let W=0,H=0,halfW=1,halfH=1,pxPerUnit=1;
  function resize(){
    W=canvas.clientWidth;H=canvas.clientHeight;if(!W||!H)return;
    renderer.setSize(W,H,false);camera.aspect=W/H;camera.updateProjectionMatrix();
    const d=camera.position.z-BD_Z;const h=2*Math.tan(THREE.MathUtils.degToRad(camera.fov/2))*d;
    bd.scale.set(h*camera.aspect,h,1);
    halfH=Math.tan(THREE.MathUtils.degToRad(camera.fov/2))*camera.position.z;halfW=halfH*camera.aspect;pxPerUnit=H/(2*halfH);
  }
  addEventListener('resize',()=>requestAnimationFrame(resize));resize();

  const reduce=matchMedia('(prefers-reduced-motion: reduce)'),fine=matchMedia('(pointer:fine)');
  const ptr={x:0,y:0},sp={x:0,y:0,vx:0,vy:0},rise={v:0,x:0};
  addEventListener('pointermove',e=>{if(!fine.matches)return;ptr.x=e.clientX/innerWidth*2-1;ptr.y=e.clientY/innerHeight*2-1},{passive:true});
  const col=new THREE.Color(),white=new THREE.Color(1,1,1);let prev=performance.now(),spin=0,frame=0;
  P.glReady=true;
  function loop(t){
    requestAnimationFrame(loop);
    if(!P.visible||document.hidden)return;
    const dt=Math.min(.05,(t-prev)/1000);prev=t;frame++;
    const L=P.plate;if(!L)return;
    // pointer spring (tension 120, friction 20) and the entrance spring (tension 70, friction 14)
    const tx=reduce.matches?0:ptr.x,ty=reduce.matches?0:ptr.y;
    sp.vx+=((tx-sp.x)*120-sp.vx*20)*dt;sp.x+=sp.vx*dt;sp.vy+=((ty-sp.y)*120-sp.vy*20)*dt;sp.y+=sp.vy*dt;
    const target=P.start?1:0;
    // fixed-step integration so a slow first frame cannot stall the entrance
    if(reduce.matches)rise.x=target;else{let left=Math.min(1,(t-(rise.t||t))/1000);rise.t=t;while(left>0){const h=Math.min(left,1/120);rise.v+=((target-rise.x)*70-rise.v*14)*h;rise.x+=rise.v*h;left-=h}}
    if(!reduce.matches)spin+=dt*.16;
    // place the bottle base on the drum top of the plate
    const s=L.bottleW/(1.48*pxPerUnit);
    F.group.scale.setScalar(s*(.9+.1*rise.x));
    F.group.position.x=(L.fx*2-1)*halfW;
    F.group.position.y=-(L.fy*2-1)*halfH+1.24*s+(1-rise.x)*-.8+(reduce.matches?0:Math.sin(t*.0009)*.015*rise.x);
    F.group.rotation.y=P.p*Math.PI*2.2+spin+sp.x*.35;
    F.group.rotation.x=.08+sp.y*.06;
    F.shadow.material.opacity=.85*rise.x;
    stopper.rotation.y=-spin*.6;
    F.setLevel(P.level);
    col.set(P.liquid);F.liqMat.color.copy(col).lerp(white,.22);F.liqMat.attenuationColor.copy(col);
    stopper.material.uniforms.tint.value.copy(col).lerp(white,.82);
    const u=bdMat.uniforms;u.k.value=P.k;u.intro.value=P.intro;u.s.value.set(L.sx,L.sy);u.pan.value.set(L.pu,L.pv);u.off.value.set(sp.x*-.006,sp.y*.006);
    if(frame%2===0){stopper.getWorldPosition(cubeCam.position);cubeCam.position.z=0;cubeCam.update(renderer,envScene)}
    renderer.render(scene,camera);
    if(!canvas.classList.contains('live'))canvas.classList.add('live');
  }
  requestAnimationFrame(loop);
}

/* ---------- SHOP ---------- */
function initShop(){
  const cards=[...document.querySelectorAll('.prod[data-plate]')];if(!cards.length)return;
  const renderer=new THREE.WebGLRenderer({antialias:true,alpha:false,preserveDrawingBuffer:false});
  renderer.toneMapping=THREE.AgXToneMapping;renderer.toneMappingExposure=1.05;
  const dpr=Math.min(devicePixelRatio,1.5);
  const scene=new THREE.Scene();
  const camera=new THREE.PerspectiveCamera(30,1,.1,100);camera.position.set(0,0,9);
  const pm=new THREE.PMREMGenerator(renderer);scene.environment=pm.fromScene(new RoomEnvironment(),.04).texture;
  const texCache={};const T=u=>texCache[u]||(texCache[u]=loadTex(u));
  const bdMat=plateMaterial([T('assets/plate-top.webp')]);
  const bd=new THREE.Mesh(new THREE.PlaneGeometry(1,1),bdMat);bd.position.z=-4;scene.add(bd);
  const F=makeFlacon({stopper:null});scene.add(F.group);F.setLevel(.86);
  const key=new THREE.DirectionalLight(0xfff1dd,1.4);key.position.set(3,4,5);scene.add(key);
  const items=cards.map(el=>({el,cv:el.querySelector('canvas'),plate:el.dataset.plate,color:new THREE.Color(el.dataset.color),cap:new THREE.Color(el.dataset.cap),
    size:{x:.88,v:0},rot:Math.random()*6,visible:false}));
  items.forEach(it=>{it.ctx=it.cv.getContext('2d')});
  const io=new IntersectionObserver(es=>es.forEach(e=>{const it=items.find(i=>i.el===e.target);if(it)it.visible=e.isIntersecting}),{rootMargin:'80px'});
  items.forEach(it=>io.observe(it.el));
  const SZ={10:.7,50:.86,100:1};
  const reduce=matchMedia('(prefers-reduced-motion: reduce)');
  const white=new THREE.Color(1,1,1);let prev=performance.now(),cw=0,ch=0;
  function loop(t){
    requestAnimationFrame(loop);
    if(document.hidden)return;
    const dt=Math.min(.05,(t-prev)/1000);prev=t;
    const vis=items.filter(i=>i.visible);if(!vis.length)return;
    const r=vis[0].cv.parentElement.getBoundingClientRect();const w=Math.round(r.width),h=Math.round(r.height);if(!w||!h)return;
    if(w!==cw||h!==ch){cw=w;ch=h;renderer.setPixelRatio(dpr);renderer.setSize(w,h,false);camera.aspect=w/h;camera.updateProjectionMatrix();
      const hh=Math.tan(THREE.MathUtils.degToRad(15))*13;bd.scale.set(hh*2*camera.aspect,hh*2,1);items.forEach(i=>{i.cv.width=w*dpr;i.cv.height=h*dpr})}
    const halfH=Math.tan(THREE.MathUtils.degToRad(15))*9,halfW=halfH*camera.aspect,ppu=h/(2*halfH);
    const L=window.layoutPlate(w,h,{fx:.5,fy:.83,zoom:2.1,wf:.5});
    for(const it of vis){
      const sel=it.el.querySelector('.sizes input:checked');const target=SZ[sel?sel.value:50]||.86;
      if(reduce.matches)it.size.x=target;else{it.size.v+=((target-it.size.x)*160-it.size.v*16)*dt;it.size.x+=it.size.v*dt}
      if(!reduce.matches)it.rot+=dt*.5;
      bdMat.uniforms.t0.value=T(it.plate);bdMat.uniforms.s.value.set(L.sx,L.sy);bdMat.uniforms.pan.value.set(L.pu,L.pv);
      const s=L.bottleW/(1.48*ppu)*it.size.x;
      F.group.scale.setScalar(s);F.group.position.set((L.fx*2-1)*halfW,-(L.fy*2-1)*halfH+1.22*s,0);
      F.group.rotation.set(.08,it.rot,0);
      F.liqMat.color.copy(it.color).lerp(white,.22);F.liqMat.attenuationColor.copy(it.color);F.cap.material.color.copy(it.cap);
      renderer.render(scene,camera);
      it.ctx.drawImage(renderer.domElement,0,0,it.cv.width,it.cv.height);
      if(!it.cv.classList.contains('live'))it.cv.classList.add('live');
    }
  }
  requestAnimationFrame(loop);
}
if(THREE){try{initHero();initShop()}catch(e){fail(e.message)}}
</script>
</body>
</html>

````
