# Recreate this site as a single HTML file: Mara Quist — Vertical Film Director

## What it is

A one-page portfolio for **Mara Quist**, a fictional director of vertical (9:16) video ads ("I direct the first
three seconds"). It is set on warm ink with bone text and one tangerine accent, in Bricolage Grotesque with
JetBrains Mono labels. **Signature:** a textured 3D plaster bust of the director (`assets/bust.glb`) renders
live in three.js into an off-screen target. A field of about 18,000 dots samples that render every frame.
The result is a halftone sculpture that turns on a spring toward the cursor and relights as it turns, with a
tangerine rim light and a cool fill.

- **Arrival:** after a film-slate preloader counts to 100 and claps, the dots burn in row by row with a
  tangerine ember on the front.
- **Lens:** where the pointer passes, the dots part and the **real shaded 3D render shows through** a soft,
  decaying brush trail.
- **Scroll:** the same dots let go of the bust, scatter, and land in the outlines of six 9:16 phone frames.
  The footage develops inside them: real stills with a Ken Burns drift, and two real video loops. Next the
  dots become the three big numbers, and finally the words "Book the shoot." above a brief form that
  validates and builds a summary.

The dots follow live DOM rectangles, so all type stays real HTML.

## Page shell & libraries

- One `index.html`. CSS is inline. The site logic is a classic inline IIFE, and the stage is an inline
  `<script type="module">`.
- three.js **0.170.0** is the only library, loaded through an import map:
  - `"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/"`
  - addons: `loaders/GLTFLoader.js`, `libs/meshopt_decoder.module.js`, `environments/RoomEnvironment.js`
  - Load them with dynamic `import()` inside try/catch, so a CDN failure goes to the fallback.
- Google Fonts: `Bricolage Grotesque` (opsz 12..96; 400/600/800) and `JetBrains Mono` (400/600), `display=swap`.
- A one-line inline `<script>` adds `.js` to `<html>` (it gates the preloader). `<link rel=preload>` the
  portrait.
- Serve over http(s), not `file://`. The GLB and the canvas text sampling need same-origin.

## Tokens

```
--ink #14110f   --ink-2 #1d1916   --ink-3 #2a2420   --line #3a322c
--bone #f2ebe0  --muted #b0a596   --tang #ff5b1f    --err #ff8f7a
radii --r-s 8px · --r-m 14px · --r-l 28px (phone screens) · pills 99px
--gut clamp(16px,4vw,56px); section padding clamp(80px,12vh,140px) var(--gut); max-width 1600px
--ease-out cubic-bezier(.16,1,.3,1); slate lift cubic-bezier(.76,0,.24,1)
```
Contrast: muted on ink 7.8:1, tangerine on ink 6.1:1, error on ink-2 7.9:1.

Type:
- h1 `clamp(64px,10.4vw,168px)`/.86, -.045em, weight 800.
- h2 `clamp(40px,6vw,92px)`/.92.
- Stat numbers `clamp(76px,11vw,190px)`. Under 1100: `clamp(56px,8.6vw,120px)`. Under 640:
  `clamp(80px,26vw,130px)`.
- CTA word `clamp(64px,10vw,168px)`/.9.
- Mono labels 12px, uppercase, +.08em.

Film grain: a fixed `body::after` with an inline SVG `feTurbulence` tile (baseFrequency .9, 2 octaves) at
opacity .07, `mix-blend-mode: overlay`, z-index 40, `pointer-events: none`.

## Layout & structure

1. **Slate preloader** (`.slate`, fixed, ink, z 50, padding 56px gutter 28px). At the top is a 28px clapper
   bar of 45° bone/ink stripes (22px each) on a 3-column grid with Prod. / Scene / Take ("Mara Quist",
   "01 · Hero", "01"). At the bottom-left is a giant counter `clamp(120px,26vw,380px)` in tangerine. At the
   bottom-right: "Rolling · 24 fps".
2. **Skip link** and the **fixed canvas** `#field` (inset 0, z 0, `pointer-events: none`, aria-hidden).
3. **Nav**: fixed, `rgba(20,17,15,.78)` with a 10px backdrop blur and a hairline border. It holds the brand
   (with a tangerine-outlined 10×18 phone glyph), the links Work / Numbers / Brief (`aria-current` follows
   the section) and a hot "Send a brief" button.
4. **Hero**: grid `1.05fr .95fr`, areas `"name pic" "copy pic"`.
   - Eyebrow "Director · vertical film · Lisbon"; h1 "Mara / Quist." with a tangerine full stop.
   - The lead, with "sixty cuts" in tangerine.
   - "See the work ↓" (hot) and "Start a brief".
   - Right: `figure.portrait` 4:5 with tangerine viewfinder L-corners (28px, 2px, offset -10px). It contains
     the B&W photo `<img>` (fallback and alt text). The caption shows a blinking REC dot and, with WebGL,
     "Plaster cast, live 00:MM:SS:FF" (24 fps) plus "Move to look closer"; without WebGL it shows
     "Self-portrait, 2026".
5. **Work** `#work`: eyebrow "01 — Selected cuts", h2 "Made for the thumb.", a sub line, and filter chips
   (All / Product / Beauty & food / Lifestyle). `ul.phones` has 6 columns, with even items translated
   down 48px. Each item is a button wrapping `.screen` (9:16, radius 28px), which holds:
   - `<img>` (work-N.webp, lazy, with a Ken Burns `scale 1.04 → 1.18` plus a 2–3% drift over 11s,
     alternating);
   - for Slow Pour and Off Count, a `<video muted loop playsinline preload="none" poster>` (webm then mp4);
   - a pill "0:15 · 42 cuts";
   - a bottom UI on a gradient (`transparent → .7 at 40% → .94`): client, title, and a 3px tangerine
     progress bar (7s linear loop).
6. **Numbers**: h2 "Volume is the craft." and three stats with `data-dots` (1,240 · 72h · 38) and captions.
7. **Brief**: on the left, a decorative `span.cta-word` "Book the shoot." (`data-dots="d0"`, aria-hidden,
   with an sr-only h2), a sub line and contact details. On the right, a form card with:
   - name*, email*, brand*, live-by date (min = today+3);
   - cuts range 6–90, step 6, with an output;
   - format pill-checkboxes;
   - budget select;
   - textarea with a 0/600 counter;
   - live turnaround estimate and "Review my brief";
   - a summary region.
8. **Footer**: note that the studio is fictional, and a back-to-top link.
9. **Player** `<dialog>`: a 9:16 screen (img + video) at `min(82vh,760px)` tall, then client, title,
   description, Length / Versions / Result, Prev · Pause · Next, and Close.

## Behaviour & interaction

**Slate.** Count to 86 while assets load, at most +2.2 per frame, over a minimum of 1.3s. The page is ready
when the portrait image, the fonts and the bust are all ready, with a 7s safety timeout. Then count to 100,
rotate the bar -4° (.35s, clap), and after 320ms translate the slate -101% over 1s. Set `introAt` to now
+200ms, and hide the slate after 1.1s. `aria-hidden`; a sr-only status says "Loaded".

**Bust render (three.js).**
- Renderer: alpha, no AA, ACESFilmic tone mapping at exposure 1.05, sRGB output, DPR capped at 2, WebGL2
  required.
- Off-screen `WebGLRenderTarget`: 480×600 (320×400 on mobile), 4× MSAA.
- Camera: PerspectiveCamera 24°, z 6.
- Lighting:
  - environment: PMREM of `RoomEnvironment`, sigma 0.04, intensity .35;
  - key: `#fff1e0` at 3.4 from (-3.5, 2.2, 3);
  - **rim: `#ff5b1f` at 5.5 from (3.2, 1.2, -2.6)**;
  - fill: `#9fb4ff` at .25.
- GLB: meshopt-compressed, centred, scaled to 2.25 units tall. Materials get roughness ≥ .55, metalness 0
  and envMapIntensity .6.
- Motion: a spring rotates a pivot (k 38, damping 9, semi-implicit Euler, dt capped at 50ms).
  - target yaw = `(pointerX offset from the portrait centre / innerWidth) × 1.2 + sin(t·.35)·.22 − scrollP1·1.6`
  - target pitch = `(pointerY offset / innerHeight) × .45 + sin(t·.27)·.04`
- Render into the target only while the hero is on screen and P1 < .999.

**Dot field** (`THREE.Points` with a ShaderMaterial; it draws in screen pixels and ignores the camera).
N = GX × round(GX × 1.25), with GX = 120 (76 on mobile or coarse pointers): 18,000 dots on desktop.
Attributes:
- `aA` — a hex-staggered grid inside the portrait rect.
- `aB` — the dot's place in its phone. 28% walk a rounded perimeter (elliptical corners, rx .15,
  ry .15×9/16); the rest fill the rect.
- `aC` / `aD` — points sampled from the text of each `[data-dots]` element. Draw it into an offscreen canvas
  at the element's size, with the computed font, letter-spacing and line-height and word wrapping. Keep
  alpha > 128 on a step of `max(3, round(fontSize/34))`. Resample on resize (debounced 150ms).
- `aIdx` = (i%6, i%3), and `aR` = 4 seeded randoms (Park–Miller, seed 7).

Uniform rects (`uRA`, `uRB[6]`, `uRC[3]`, `uRD`) come from `getBoundingClientRect()` every frame.

In the vertex shader:
- **Stage A (bust):** sample the render target at `(aA.x, 1-aA.y)`. `lum = luma × alpha`, so the
  silhouette cuts out cleanly. `warm = clamp((r−b−.2)×3.5)`: the rim light reads as tangerine dots.
- Size = `cell × (.12 + 1.05·√lum)`, where cell = rectWidth/GX.
- Colour mixes `#473d35 → bone` by lum, then toward tangerine by warm, then by the brush.

**Brush.** Ten trail points. A new point is added when the pointer has moved more than 9px, and each one
decays as `z *= 0.2^dt`. Each dot sums `w = exp(−d²/R²)·z` (R 110px; 70 on mobile) and is pushed by
`dir·26 + tangent·14`. There is a ±0.6px idle shimmer.

**Lens.** A screen-space quad covers the portrait rect and samples the same render target. Its alpha is
`smoothstep(.25,.75, Σ exp(−d²/(.55R²))·z) × texAlpha × show`, where show = `(1−3·P1) × (2·intro−1)`. The
real shaded sculpture appears inside the brush, ringed by tangerine displaced dots.

**Burn-in.** intro = (now−introAt)/2200ms. Per dot, `sI = clamp((intro·1.7 − aA.y·.55 − r·.15)/.9)`, and
the dot moves from a scatter point (rect centre ± (1.3W, 1.1H)·random) to its place with
easeInOutCubic. Ember = `sin(π·sI)`: tangerine, +80% size, plus a soft halo in the fragment shader
(`+ glow·.35·exp(−r²·14)`).

**Scroll chain.** Three progress values:
- p1 = `(H − phonesTop)/(.45H)`
- p2 = `(.9H − statsTop)/(.55H)`
- p3 = `(.9H − ctaTop)/(.55H)`

Each is clamped and smoothed with `P += (target−P)·min(1, dt·5.2)`. Per dot, the stage is
`easeInOutCubic(clamp((P·1.25 − r·.45)/.55))`. Position, size and colour mix A→B→C→D. While a dot is in
flight (`fl = Σ sin(π·s)`), it scatters by `(sin(r.y·40+t·.6), cos(r.x·37+t·.5)) × (.16W, .12H) × fl` and
grows by `1+.35fl`. Perimeter dots are 2.2px tangerine and fill dots are 1.6–4px. In dimmed phones the
dots mix 70% toward dark. Middle stat is tangerine, the others bone, and the CTA is tangerine.

**Footage develops.** `--reveal = clamp((P1−.78)/.12) × (1−clamp((P2−.05)/.4))`, forced to 1 once P2 > .5.
**Ghost type:** with `.gl` on, the numbers and the CTA are transparent with a 1px bone stroke at 9% opacity,
and the dots fill them in.

**Media.** An IntersectionObserver (threshold .15) toggles `.playing` on the Ken Burns animation and the
progress bar, and plays or pauses each video, setting `preload = auto` on first view. Media also pauses on
`visibilitychange`.

**Filters.** Use `aria-pressed` chips. `.dim` sets grayscale and brightness .35. A polite status reports
the result count.

**Player.** `showModal()` loads the `-lg` image and, where there is one, the video. ←/→ keys cycle. Pause
toggles the video, the Ken Burns and the bar (`aria-pressed`). A backdrop click or Esc closes it and
returns focus.

**Form.**
- Validate on submit. Each error sets `aria-invalid` and fills a described-by error span, and the first
  invalid field gets focus.
- After a failed submit, re-check **on input**, so the errors never collapse while the user is clicking
  submit.
- Turnaround = `max(3, round(2 + cuts/12 + (formats−1)·.8))` days.
- On success, show a summary `dl`, a `mailto:` built from it, Copy (Clipboard API) and Edit.

## Responsive

- **≤1100:** 3 phone columns (middle one down 32px), smaller numbers.
- **≤900:** hero stacks name → bust → copy. The portrait is at most 440px wide with a 40px margin, and the
  hint is hidden. Nav links are hidden. Brief is one column.
- **≤640 (390):** 2 phone columns (even ones down 28px). Stats and the form go to one column. The player
  stacks.
- Mobile tier: 76-column dots and a 320px render target.
- There is no horizontal overflow at 390, 768 or 1440.

## Accessibility & reduced motion

- Landmarks, skip link, one h1, and h2 per section.
- The canvas is aria-hidden. The photo `<img>` carries the portrait's alt text, and the phone images carry
  descriptive alts. The decorative video is aria-hidden.
- Phone buttons name the title, client, length and cut count.
- Focus is a 2px tangerine ring. The dialog is native. Live regions announce the filter and copy results.
- **Reduced motion:** no slate animation (it hides immediately), no WebGL (fallback), no video autoplay, no
  Ken Burns or CSS animation.

## Fallbacks

Reduced motion, `?nogl`, no WebGL2, a failed import or GLB load, or a lost context all drop `.gl` and hide
the canvas. The B&W photo shows with its caption, the numbers and CTA show as solid type, and the footage
is visible from the start. The slate never waits more than 7s. The render loop stops on hidden tabs, and
the bust renders only while the hero is visible.

## Assets (`assets/`, about 2.8 MB in total)

- `bust.glb` (411 KB). Meshy image→3D of a generated matte plaster bust: a woman with a short crop in a high
  turtleneck, on a square plinth. About 30k vertices, optimised with gltf-transform (meshopt, webp
  textures at 1024).
- `portrait.webp`. B&W studio portrait of the fictional director in a black turtleneck, lit from the left.
- `work-1…6.webp` (640w) and `work-1…6-lg.webp` (1000w):
  1. a white sneaker over a water splash on orange;
  2. cold brew pour with cream;
  3. an amber dropper bottle in clear water;
  4. a man laughing at his phone on a neon street in the rain;
  5. a dancer leaping in a concrete studio;
  6. a golden retriever with an orange ball on a beach at sunset.
- `pour.mp4/.webm` and `dance.mp4/.webm`: 5s, 540×960, muted, about 250–340 KB each (image-to-video from
  stills 2 and 5).

## Make it yours

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

1. **Person and offer.** Swap "Mara Quist", "Lisbon" and "I direct the first three seconds" for your own name,
   city and one-line promise. Keep the name to two short words so the h1 stays on two lines, and keep the
   lead under 25 words.
2. **The sculpture.** The live object the dots sample is the signature. Generate your own: a bust of you in
   plaster, bronze or terracotta. Or swap the bust for an object that stands for your work, such as a
   camera, a microphone, a trophy or a product. Use a clean 3/4 studio shot on light grey, image→3D, then
   meshopt. Keep the 4:5 frame and the tangerine rim light so the dots still pick up a coloured edge.
3. **What the dots become.** Keep the four-stage chain, but re-aim the middle: 3:2 contact-sheet frames for a
   photographer, square cover tiles for a podcaster, or specimen cards for a type designer (change the B
   aspect and the corner radius). Swap the CTA word for your own two- or three-word call.
4. **Palette.** Replace `--ink`, `--bone` and `--tang`, and the rim light colour with them. Keep `--muted`
   on ink and the button text on the accent at ≥ 4.5:1. Examples: forest / chalk / signal yellow, or
   navy / paper / coral.
5. **Type pairing.** Swap Bricolage Grotesque + JetBrains Mono for another heavy grotesk and a mono, for
   example Familjen Grotesk + IBM Plex Mono, or Unbounded + Space Mono. The dots copy the computed font
   automatically.
6. **The work.** Use six of your own pieces. Keep exactly six, because the shader has six rect slots. Put
   real muted 9:16 clips in place of the stills where you have them, at 540w and under 400 KB each.
7. **Numbers and slate.** Put three true facts in the stats (a count, a speed, a loyalty figure, each under
   6 characters) and your own production names on the slate.
8. **Brief form.** Rename the fields to your intake questions and set the turnaround formula to your real
   lead times.

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/director-portfolio-halftone-portrait/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>Mara Quist — Vertical Film Director</title>
<meta name="description" content="Mara Quist directs vertical ads for brands that test everything: one shoot day, sixty cuts, every hook a hypothesis.">
<meta name="theme-color" content="#14110f">
<script>document.documentElement.classList.add('js')</script>
<link rel="preload" as="image" href="assets/portrait.webp">
<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=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,800&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet">
<style>
:root{
  --ink:#14110f; --ink-2:#1d1916; --ink-3:#2a2420; --line:#3a322c;
  --bone:#f2ebe0; --muted:#b0a596; --tang:#ff5b1f; --tang-2:#ff8a57; --ok:#9ad18b; --err:#ff8f7a;
  --display:"Bricolage Grotesque",system-ui,sans-serif; --mono:"JetBrains Mono",ui-monospace,monospace;
  --r-s:8px; --r-m:14px; --r-l:28px;
  --gut:clamp(16px,4vw,56px);
  --ease-out:cubic-bezier(.16,1,.3,1);
}
*{box-sizing:border-box}
html{background:var(--ink);color:var(--bone);-webkit-text-size-adjust:100%}
body{margin:0;font-family:var(--display);font-size:17px;line-height:1.5;background:var(--ink);overflow-x:hidden}
img{display:block;max-width:100%}
a{color:inherit}
:focus-visible{outline:2px solid var(--tang);outline-offset:3px;border-radius:4px}
.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.skip{position:fixed;left:12px;top:-60px;z-index:100;background:var(--tang);color:var(--ink);padding:10px 14px;border-radius:var(--r-s);font-weight:600;text-decoration:none;transition:top .2s}
.skip:focus{top:12px}
.mono{font-family:var(--mono);font-size:12px;letter-spacing:.08em;text-transform:uppercase}

/* the one canvas: fixed behind content */
#field{position:fixed;inset:0;width:100%;height:100%;z-index:0;pointer-events:none}
main,header,footer{position:relative;z-index:1}
/* film grain over everything: one tiny SVG noise tile */
body::after{content:"";position:fixed;inset:0;z-index:40;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")}

/* nav */
.nav{position:fixed;top:0;left:0;right:0;z-index:20;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px var(--gut);background:rgba(20,17,15,.78);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-bottom:1px solid rgba(58,50,44,.6)}
.brand{font-weight:800;text-decoration:none;font-size:18px;letter-spacing:-.01em;display:flex;align-items:center;gap:10px}
.brand i{width:10px;height:18px;border:2px solid var(--tang);border-radius:3px;display:inline-block}
.nav ul{display:flex;gap:4px;list-style:none;margin:0;padding:0}
.nav ul a{display:block;padding:8px 12px;border-radius:99px;text-decoration:none;font-size:15px;color:var(--muted);transition:color .2s,background .2s}
.nav ul a:hover,.nav ul a[aria-current="true"]{color:var(--bone);background:var(--ink-3)}
.btn{display:inline-flex;align-items:center;gap:10px;font:600 16px/1 var(--display);padding:14px 20px;border-radius:99px;border:1.5px solid var(--bone);color:var(--bone);background:transparent;text-decoration:none;cursor:pointer;transition:background .25s,color .25s,transform .25s var(--ease-out)}
.btn:hover{background:var(--bone);color:var(--ink)}
.btn.hot{background:var(--tang);border-color:var(--tang);color:var(--ink)}
.btn.hot:hover{background:var(--bone);border-color:var(--bone)}
.btn:active{transform:scale(.97)}
.btn.sm{padding:10px 16px;font-size:15px}

/* hero */
.hero{min-height:100svh;display:grid;grid-template-columns:1.05fr .95fr;grid-template-areas:"name pic" "copy pic";grid-template-rows:auto 1fr;align-items:end;gap:clamp(24px,4vw,64px);padding:96px var(--gut) 48px;max-width:1600px;margin:0 auto}
.hero h1{font-size:clamp(64px,10.4vw,168px);line-height:.86;letter-spacing:-.045em;font-weight:800;margin:18px 0 26px}
.hero h1 > span{display:block}
.hero h1 .o{color:var(--tang)}
.lead{font-size:clamp(18px,1.6vw,23px);line-height:1.4;max-width:30ch;color:var(--bone);margin:0 0 32px}
.lead em{font-style:normal;color:var(--tang)}
.ctas{display:flex;gap:12px;flex-wrap:wrap}
.h-name{grid-area:name}.h-copy{grid-area:copy;align-self:start}
.portrait{grid-area:pic;align-self:center;position:relative;margin:0;aspect-ratio:4/5;width:100%;max-height:calc(100svh - 150px);justify-self:center;max-width:min(100%,calc((100svh - 150px)*.8))}
.portrait img{width:100%;height:100%;object-fit:cover;border-radius:var(--r-m);transition:opacity .6s}
.gl .portrait img{opacity:0}
.portrait::before,.portrait::after{content:"";position:absolute;width:28px;height:28px;border:2px solid var(--tang);pointer-events:none;z-index:2}
.portrait::before{top:-10px;left:-10px;border-right:0;border-bottom:0}.portrait::after{bottom:-10px;right:-10px;border-left:0;border-top:0}
.rec{display:inline-flex;align-items:center;gap:8px}.rec i{width:8px;height:8px;border-radius:50%;background:var(--tang);animation:blink 1.2s steps(2) infinite}@keyframes blink{50%{opacity:.15}}
.portrait figcaption{position:absolute;left:0;right:0;bottom:-30px;display:flex;justify-content:space-between;color:var(--muted)}
.hint,.cap-gl{display:none}.gl .cap-photo{display:none}.gl .cap-gl{display:inline}
.gl .hint{display:inline}

/* section heads */
section{padding:clamp(80px,12vh,140px) var(--gut);max-width:1600px;margin:0 auto}
.eyebrow{color:var(--tang);margin:0 0 14px}
h2{font-size:clamp(40px,6vw,92px);line-height:.92;letter-spacing:-.035em;font-weight:800;margin:0 0 20px}
.sub{color:var(--muted);max-width:52ch;margin:0 0 36px;font-size:18px}

/* work */
.work-head{display:flex;justify-content:space-between;align-items:flex-end;gap:24px;flex-wrap:wrap}
.filters{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:36px}
.chip{font:600 14px/1 var(--display);padding:10px 14px;border-radius:99px;border:1.5px solid var(--line);background:var(--ink);color:var(--muted);cursor:pointer;transition:all .2s}
.chip[aria-pressed="true"]{border-color:var(--tang);color:var(--ink);background:var(--tang)}
.chip:hover{color:var(--bone);border-color:var(--bone)}
.chip[aria-pressed="true"]:hover{color:var(--ink)}
.phones{display:grid;grid-template-columns:repeat(6,1fr);gap:clamp(12px,1.6vw,24px);list-style:none;margin:0;padding:0}
.phone{--show:1}
.phone button{all:unset;display:block;width:100%;cursor:pointer;border-radius:var(--r-l)}
.phone button:focus-visible{outline:2px solid var(--tang);outline-offset:4px}
.screen{position:relative;aspect-ratio:9/16;border-radius:var(--r-l);overflow:hidden;background:transparent;box-shadow:0 0 0 1.5px rgba(242,235,224,.12)}
.screen img,.screen video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:var(--reveal,1);transition:filter .4s,opacity .2s}
.screen img{transform-origin:var(--o,50% 50%);animation:kb 11s ease-in-out infinite alternate;animation-play-state:paused}
.playing .screen img{animation-play-state:running}
@keyframes kb{from{transform:scale(1.04)}to{transform:scale(1.18) translate(var(--kx,-2%),var(--ky,-3%))}}
.screen .ui{position:absolute;inset:auto 0 0 0;padding:64px 12px 12px;background:linear-gradient(transparent,rgba(20,17,15,.7) 40%,rgba(20,17,15,.94));opacity:var(--reveal,1);transition:opacity .2s}
.screen .bar{height:3px;background:rgba(242,235,224,.25);border-radius:3px;overflow:hidden;margin-top:8px}
.screen .bar i{display:block;height:100%;width:100%;background:var(--tang);transform-origin:left;transform:scaleX(0);animation:bar 7s linear infinite;animation-play-state:paused}
.playing .screen .bar i{animation-play-state:running}
@keyframes bar{to{transform:scaleX(1)}}
.screen .t{font-weight:600;font-size:15px;line-height:1.15}
.screen .c{color:#d6ccbf;font-family:var(--mono);font-size:10.5px;letter-spacing:.06em;text-transform:uppercase}
.screen .pill{position:absolute;top:10px;left:10px;font-family:var(--mono);font-size:10px;letter-spacing:.06em;background:rgba(20,17,15,.7);padding:5px 8px;border-radius:99px;opacity:var(--reveal,1)}
.phone.dim .screen img,.phone.dim .screen video{filter:grayscale(1) brightness(.35)}
.phone.dim .ui,.phone.dim .pill{opacity:.35}
.phone:nth-child(even){transform:translateY(var(--stagger,48px))}

/* numbers */
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:clamp(16px,3vw,48px);list-style:none;margin:0;padding:0}
.stat{border-top:1.5px solid var(--line);padding-top:18px}
.num{display:block;font-weight:800;font-size:clamp(76px,11vw,190px);line-height:1;letter-spacing:-.05em;white-space:nowrap}
.gl .num,.gl .cta-word{color:transparent;-webkit-text-stroke:1px rgba(242,235,224,.09)}
.stat p{margin:8px 0 0;color:var(--muted);max-width:26ch}

/* brief */
.brief-grid{display:grid;grid-template-columns:1fr 1.15fr;gap:clamp(32px,5vw,80px);align-items:start}
.cta-word{font-size:clamp(64px,10vw,168px);line-height:.9;letter-spacing:-.045em;font-weight:800;margin:0 0 24px;display:block}
.contact-list{list-style:none;padding:0;margin:28px 0 0;display:grid;gap:10px}
.contact-list a{text-decoration:none;border-bottom:1px solid var(--line)}
.contact-list a:hover{color:var(--tang);border-color:var(--tang)}
form{background:var(--ink-2);border:1px solid var(--line);border-radius:var(--r-l);padding:clamp(20px,3vw,36px);display:grid;gap:18px;grid-template-columns:1fr 1fr}
.f{display:grid;gap:6px;min-width:0}
.f.full{grid-column:1/-1}
label,legend{font-weight:600;font-size:15px}
.f small{color:var(--muted);font-size:13px}
input[type=text],input[type=email],input[type=date],select,textarea{width:100%;font:16px/1.3 var(--display);color:var(--bone);background:var(--ink);border:1.5px solid var(--line);border-radius:var(--r-s);padding:12px 12px;transition:border-color .2s}
input:hover,select:hover,textarea:hover{border-color:var(--muted)}
input:focus-visible,select:focus-visible,textarea:focus-visible{outline:none;border-color:var(--tang);box-shadow:0 0 0 3px rgba(255,91,31,.25)}
textarea{min-height:96px;resize:vertical}
[aria-invalid="true"]{border-color:var(--err)!important}
.err{color:var(--err);font-size:13px}
.err:empty{display:none}
fieldset{border:0;padding:0;margin:0;display:grid;gap:8px}
.checks{display:flex;gap:8px;flex-wrap:wrap}
.checks label{display:flex;align-items:center;gap:8px;font-weight:400;border:1.5px solid var(--line);border-radius:99px;padding:8px 12px;cursor:pointer}
.checks input{accent-color:var(--tang);width:16px;height:16px;margin:0}
.checks label:has(input:checked){border-color:var(--tang)}
.checks label:has(input:focus-visible){outline:2px solid var(--tang);outline-offset:2px}
input[type=range]{width:100%;accent-color:var(--tang)}
.range-row{display:flex;justify-content:space-between;align-items:baseline}
.range-row output{font-family:var(--mono);color:var(--tang);font-size:15px}
.estimate{grid-column:1/-1;display:flex;justify-content:space-between;align-items:center;gap:16px;flex-wrap:wrap;border-top:1px solid var(--line);padding-top:18px}
.estimate p{margin:0;color:var(--muted);font-size:15px}
.estimate b{color:var(--bone);font-family:var(--mono)}
.summary{grid-column:1/-1;background:var(--ink);border:1.5px solid var(--tang);border-radius:var(--r-m);padding:20px}
.summary[hidden]{display:none}
.summary h3{margin:0 0 10px;font-size:22px}
.summary dl{display:grid;grid-template-columns:auto 1fr;gap:6px 16px;margin:0 0 16px;font-size:15px}
.summary dt{color:var(--muted)}
.summary dd{margin:0;overflow-wrap:anywhere}
.summary .row{display:flex;gap:10px;flex-wrap:wrap}

footer{padding:40px var(--gut) 48px;max-width:1600px;margin:0 auto;display:flex;justify-content:space-between;gap:16px;flex-wrap:wrap;color:var(--muted);border-top:1px solid var(--line)}

/* player dialog */
dialog{border:0;padding:0;background:transparent;color:var(--bone);max-width:none;max-height:none;width:100%;height:100%}
dialog::backdrop{background:rgba(10,8,7,.86);backdrop-filter:blur(6px)}
.player{height:100%;display:grid;grid-template-columns:auto minmax(0,380px);gap:32px;align-items:center;justify-content:center;padding:24px}
.player .screen{height:min(82vh,760px);aspect-ratio:9/16;width:auto;box-shadow:0 30px 80px rgba(0,0,0,.6)}
.player .screen img,.player .screen video{opacity:1}
.player.paused .bar i,.player.paused .screen img{animation-play-state:paused!important}
.player h3{font-size:clamp(32px,3.6vw,52px);line-height:.95;letter-spacing:-.03em;margin:8px 0 12px}
.player p{color:var(--muted)}
.player .meta{display:grid;grid-template-columns:auto 1fr;gap:6px 14px;margin:20px 0;font-size:15px}
.player .meta dt{color:var(--muted)}.player .meta dd{margin:0}
.player .controls{display:flex;gap:8px;flex-wrap:wrap}
.x{position:fixed;top:16px;right:16px}

/* preloader: a slate that counts in, then lifts */
.slate{position:fixed;inset:0;z-index:50;background:var(--ink);display:none;flex-direction:column;justify-content:space-between;padding:56px var(--gut) 28px;transition:transform 1s cubic-bezier(.76,0,.24,1)}
.js .slate{display:flex}
.slate.out{transform:translateY(-101%)}
.slate .bars{height:28px;background:repeating-linear-gradient(-45deg,var(--bone) 0 22px,var(--ink) 22px 44px);border-radius:4px;transform-origin:left bottom;transition:transform .35s cubic-bezier(.6,0,.4,1)}
.slate.clap .bars{transform:rotate(-4deg)}
.slate .grid{display:grid;grid-template-columns:repeat(3,1fr);border-top:1px solid var(--line);margin-top:18px}
.slate .grid div{border-right:1px solid var(--line);padding:12px 12px 0 0}.slate .grid div+div{padding-left:12px}.slate .grid div:last-child{border:0}
.slate .grid b{display:block;font:600 clamp(16px,2.4vw,30px)/1.1 var(--display);margin-top:6px;text-transform:none;letter-spacing:-.01em}
.slate .count{font:800 clamp(120px,26vw,380px)/.8 var(--display);letter-spacing:-.06em;color:var(--bone);font-variant-numeric:tabular-nums}
.slate .count span{color:var(--tang)}
.slate .foot{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;color:var(--muted)}
.reveal{opacity:0;transform:translateY(24px);transition:opacity .9s var(--ease-out),transform .9s var(--ease-out)}
.reveal.in{opacity:1;transform:none}

@media (max-width:1100px){
  .num{font-size:clamp(56px,8.6vw,120px)}
  .phones{grid-template-columns:repeat(3,1fr)}
  .phone:nth-child(even){--stagger:0px}
  .phone:nth-child(3n+2){transform:translateY(32px)}
}
@media (max-width:900px){
  .hero{grid-template-columns:1fr;grid-template-areas:"name" "pic" "copy";grid-template-rows:auto;padding-top:88px;gap:20px}
  .hero h1{margin-bottom:8px}
  .portrait{max-width:min(100%,440px);max-height:none;justify-self:start;margin:6px 0 40px}
  .portrait figcaption{font-size:10.5px;white-space:nowrap}
  .portrait .hint{display:none!important}
  .brief-grid{grid-template-columns:1fr}
  .nav ul{display:none}
}
@media (max-width:640px){
  body{font-size:16px}
  .phones{grid-template-columns:repeat(2,1fr)}
  .phone:nth-child(3n+2){transform:none}
  .phone:nth-child(even){transform:translateY(28px)}
  .stats{grid-template-columns:1fr;gap:28px}
  .num{font-size:clamp(80px,26vw,130px)}
  form{grid-template-columns:1fr}
  .player{grid-template-columns:1fr;align-content:start;justify-items:center;overflow:auto;gap:16px;padding:64px 16px 24px}
  .player .screen{height:min(62vh,560px)}
  .hero h1{font-size:clamp(64px,21vw,120px)}
}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}
  .reveal{opacity:1;transform:none}
}
</style>
</head>
<body>
<a class="skip" href="#main">Skip to content</a>
<div class="slate" id="slate" aria-hidden="true">
  <div><div class="bars"></div>
    <div class="grid mono"><div>Prod.<b>Mara Quist</b></div><div>Scene<b>01 · Hero</b></div><div>Take<b>01</b></div></div></div>
  <div class="foot"><div class="count"><span id="slateN">00</span></div><div class="mono">Rolling · 24 fps</div></div>
</div>
<p class="sr-only" role="status" id="loadStatus">Loading</p>
<canvas id="field" aria-hidden="true"></canvas>

<header class="nav">
  <a class="brand" href="#top"><i aria-hidden="true"></i>Mara Quist</a>
  <nav aria-label="Sections">
    <ul>
      <li><a href="#work">Work</a></li>
      <li><a href="#numbers">Numbers</a></li>
      <li><a href="#brief">Brief</a></li>
    </ul>
  </nav>
  <a class="btn sm hot" href="#brief">Send a brief</a>
</header>

<main id="main">
  <div class="hero" id="top">
    <div class="h-name">
      <p class="mono eyebrow">Director · vertical film · Lisbon</p>
      <h1><span>Mara</span><span>Quist<span class="o">.</span></span></h1>
    </div>
    <div class="h-copy">
      <p class="lead">I direct the first three seconds. One shoot day, <em>sixty cuts</em>, every hook a hypothesis your media buyer can test by Monday.</p>
      <div class="ctas">
        <a class="btn hot" href="#work">See the work <span aria-hidden="true">↓</span></a>
        <a class="btn" href="#brief">Start a brief</a>
      </div>
    </div>
    <figure class="portrait" id="portrait">
      <img src="assets/portrait.webp" width="1000" height="1241" alt="Black-and-white studio portrait of Mara Quist: short cropped hair, black turtleneck, calm direct gaze, lit from the left" fetchpriority="high">
      <figcaption class="mono"><span class="rec"><i aria-hidden="true"></i><span><span class="cap-photo">Self-portrait, 2026</span><span class="cap-gl">Plaster cast, live <span id="tc" aria-hidden="true">00:00:00:00</span></span></span></span><span class="hint" aria-hidden="true">Move to look closer</span></figcaption>
    </figure>
  </div>

  <section id="work" aria-labelledby="work-h">
    <div class="work-head">
      <div>
        <p class="mono eyebrow">01 — Selected cuts</p>
        <h2 id="work-h">Made for the thumb.</h2>
        <p class="sub">Six campaigns, shot 9:16 first. Each one shipped as a family of hooks, lengths and endings, not a single spot. Tap a frame to open the player.</p>
      </div>
      <div class="filters" role="group" aria-label="Filter work by category">
        <button class="chip" type="button" data-f="all" aria-pressed="true">All</button>
        <button class="chip" type="button" data-f="product" aria-pressed="false">Product</button>
        <button class="chip" type="button" data-f="beauty" aria-pressed="false">Beauty &amp; food</button>
        <button class="chip" type="button" data-f="life" aria-pressed="false">Lifestyle</button>
      </div>
    </div>
    <ul class="phones" id="phones"></ul>
    <p class="sr-only" id="filter-status" role="status" aria-live="polite"></p>
  </section>

  <section id="numbers" aria-labelledby="num-h">
    <p class="mono eyebrow">02 — The numbers</p>
    <h2 id="num-h" class="reveal">Volume is the craft.</h2>
    <ul class="stats">
      <li class="stat"><span class="num" data-dots="c0">1,240</span><p>cuts delivered in 2026, across six aspect ratios and four languages.</p></li>
      <li class="stat"><span class="num" data-dots="c1">72h</span><p>median from wrap to a full, captioned batch in your drive.</p></li>
      <li class="stat"><span class="num" data-dots="c2">38</span><p>brands that came back for a second shoot day.</p></li>
    </ul>
  </section>

  <section id="brief" aria-labelledby="brief-h">
    <div class="brief-grid">
      <div>
        <p class="mono eyebrow">03 — Brief</p>
        <h2 id="brief-h" class="sr-only">Book the shoot</h2>
        <span class="cta-word" data-dots="d0" aria-hidden="true">Book the shoot.</span>
        <p class="sub">Tell me the product, the number of cuts and the date it has to be live. You get a treatment and a fixed quote within one working day.</p>
        <ul class="contact-list">
          <li><span class="mono">Mail</span><br><a href="mailto:studio@maraquist.example">studio@maraquist.example</a></li>
          <li><span class="mono">Availability</span><br>Two shoot days open in January 2027</li>
        </ul>
      </div>
      <form id="briefForm" novalidate aria-describedby="form-note">
        <p id="form-note" class="sr-only">All fields marked required must be filled before the brief can be summarised.</p>
        <div class="f"><label for="fName">Your name (required)</label><input id="fName" name="name" type="text" autocomplete="name" required aria-describedby="eName"><span class="err" id="eName"></span></div>
        <div class="f"><label for="fEmail">Work email (required)</label><input id="fEmail" name="email" type="email" autocomplete="email" required aria-describedby="eEmail"><span class="err" id="eEmail"></span></div>
        <div class="f"><label for="fBrand">Brand / product (required)</label><input id="fBrand" name="brand" type="text" required aria-describedby="eBrand"><span class="err" id="eBrand"></span></div>
        <div class="f"><label for="fDate">Needs to be live by</label><input id="fDate" name="date" type="date" aria-describedby="eDate"><span class="err" id="eDate"></span></div>
        <div class="f full">
          <div class="range-row"><label for="fCuts">Number of cuts</label><output id="oCuts" for="fCuts">24</output></div>
          <input id="fCuts" name="cuts" type="range" min="6" max="90" step="6" value="24">
        </div>
        <fieldset class="f full" aria-describedby="eFormats">
          <legend>Formats (pick at least one)</legend>
          <div class="checks">
            <label><input type="checkbox" name="formats" value="9:16" checked> 9:16</label>
            <label><input type="checkbox" name="formats" value="4:5"> 4:5</label>
            <label><input type="checkbox" name="formats" value="1:1"> 1:1</label>
            <label><input type="checkbox" name="formats" value="16:9"> 16:9</label>
          </div>
          <span class="err" id="eFormats"></span>
        </fieldset>
        <div class="f full"><label for="fBudget">Budget range</label>
          <select id="fBudget" name="budget">
            <option value="8">€8k – €15k</option>
            <option value="15" selected>€15k – €30k</option>
            <option value="30">€30k – €60k</option>
            <option value="60">€60k +</option>
          </select>
        </div>
        <div class="f full"><label for="fMsg">What should the first three seconds do?</label><textarea id="fMsg" name="msg" maxlength="600" aria-describedby="cMsg"></textarea><small id="cMsg">0 / 600</small></div>
        <div class="estimate">
          <p>Estimated turnaround <b id="estDays">5 working days</b></p>
          <button class="btn hot" type="submit">Review my brief</button>
        </div>
        <div class="summary" id="summary" hidden tabindex="-1" role="region" aria-labelledby="sumH">
          <h3 id="sumH">Brief ready</h3>
          <dl id="sumList"></dl>
          <div class="row">
            <a class="btn sm hot" id="sumMail" href="#">Send by email</a>
            <button class="btn sm" type="button" id="sumCopy">Copy text</button>
            <button class="btn sm" type="button" id="sumEdit">Edit</button>
          </div>
          <p class="mono" id="copyStatus" role="status" aria-live="polite" style="margin:12px 0 0;color:var(--muted)"></p>
        </div>
      </form>
    </div>
  </section>
</main>

<footer>
  <span>© 2026 Mara Quist. Fictional studio, built as a design study.</span>
  <a href="#top">Back to top ↑</a>
</footer>

<dialog id="player" aria-labelledby="pTitle">
  <div class="player" id="playerBox">
    <div class="screen"><img id="pImg" src="" alt=""><video id="pVid" muted loop playsinline preload="none" hidden></video><span class="pill" id="pPill"></span><div class="ui"><div class="bar"><i></i></div></div></div>
    <div>
      <p class="mono eyebrow" id="pClient"></p>
      <h3 id="pTitle"></h3>
      <p id="pDesc"></p>
      <dl class="meta" id="pMeta"></dl>
      <div class="controls">
        <button class="btn sm" type="button" id="pPrev" aria-label="Previous cut">← Prev</button>
        <button class="btn sm hot" type="button" id="pToggle" aria-pressed="false">Pause</button>
        <button class="btn sm" type="button" id="pNext" aria-label="Next cut">Next →</button>
      </div>
    </div>
  </div>
  <button class="btn sm x" type="button" id="pClose">Close <span aria-hidden="true">✕</span></button>
</dialog>

<script>
(() => {
'use strict';
const WORK = [
  {img:1, t:'Puddle Test', c:'Strider Athletic', cat:'product', len:'0:15', cuts:42, lift:'+31% hook rate', o:'50% 40%', d:'A white runner over a column of water at 1/8000s. Forty-two cuts, each opening on a different splash.', alt:'A white running shoe floating above a column of splashing water on a bright orange backdrop'},
  {img:2, vid:'pour', t:'Slow Pour', c:'Kettle & Kin', cat:'beauty', len:'0:09', cuts:18, lift:'2.4× saves', o:'50% 60%', d:'Cold brew over ice in real time. The pour is the hook; the logo never shows before second six.', alt:'Cold brew pouring into a tall glass of ice as cream blooms through it, in morning window light'},
  {img:3, t:'Still Water', c:'Mareth Skin', cat:'beauty', len:'0:12', cuts:36, lift:'−22% CPA', o:'60% 55%', d:'An amber serum bottle standing in clear water. Shot once, graded six ways for six markets.', alt:'An amber dropper bottle standing in clear rippling water over pebbles'},
  {img:4, t:'Notification', c:'Loop Mobile', cat:'life', len:'0:20', cuts:60, lift:'+18% CTR', o:'40% 40%', d:'A man laughs at his phone in the rain. Sixty variants of what made him laugh.', alt:'A young man laughing at his phone on a rain-soaked neon street at night'},
  {img:5, vid:'dance', t:'Off Count', c:'Halden Apparel', cat:'life', len:'0:15', cuts:24, lift:'1.9× watch time', o:'55% 40%', d:'One dancer, one take, cut to twelve different tracks the media team could swap weekly.', alt:'A dancer in a rust-coloured outfit mid-leap in a sunlit concrete studio'},
  {img:6, t:'Fetch Cut', c:'Good Boy Kitchen', cat:'product', len:'0:10', cuts:30, lift:'+40% thumb-stop', o:'60% 35%', d:'A golden retriever, an orange ball, a beach at 7 pm. The catch lands on frame 24, every time.', alt:'A golden retriever leaping on a beach at sunset with an orange ball in its mouth'}
];
const $ = (s, r=document) => r.querySelector(s);
const $$ = (s, r=document) => [...r.querySelectorAll(s)];
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;

/* ---------- work grid ---------- */
const list = $('#phones');
list.innerHTML = WORK.map((w,i) => `
  <li class="phone" data-cat="${w.cat}" data-i="${i}">
    <button type="button" aria-label="Open ${w.t} for ${w.c}, ${w.len}, ${w.cuts} cuts">
      <div class="screen" data-rect="b${i}">
        <img src="assets/work-${w.img}.webp" alt="${w.alt}" width="640" height="1147" loading="lazy" decoding="async" style="--o:${w.o};animation-delay:${-i*1.7}s">${w.vid ? `<video muted loop playsinline preload="none" poster="assets/work-${w.img}.webp" aria-hidden="true"><source src="assets/${w.vid}.webm" type="video/webm"><source src="assets/${w.vid}.mp4" type="video/mp4"></video>` : ''}
        <span class="pill" aria-hidden="true">${w.len} · ${w.cuts} cuts</span>
        <div class="ui" aria-hidden="true"><div class="c">${w.c}</div><div class="t">${w.t}</div><div class="bar"><i style="animation-delay:${-i*1.1}s"></i></div></div>
      </div>
    </button>
  </li>`).join('');

// play only while on screen
const playVid = (v, on) => { if (!v) return; if (on && !reduce && !document.hidden) { v.preload = 'auto'; const pr = v.play(); pr && pr.catch(() => {}); } else v.pause(); };
const io = new IntersectionObserver(es => es.forEach(e => { e.target.classList.toggle('playing', e.isIntersecting); playVid(e.target.querySelector('video'), e.isIntersecting); }), {threshold:.15});
document.addEventListener('visibilitychange', () => $$('.phone').forEach(p => playVid(p.querySelector('video'), !document.hidden && p.classList.contains('playing'))));
$$('.phone').forEach(p => io.observe(p));

// filters
const status = $('#filter-status');
$$('.chip').forEach(ch => ch.addEventListener('click', () => {
  $$('.chip').forEach(c => c.setAttribute('aria-pressed', String(c === ch)));
  const f = ch.dataset.f; let n = 0;
  $$('.phone').forEach(p => { const on = f === 'all' || p.dataset.cat === f; p.classList.toggle('dim', !on); n += on; });
  status.textContent = `${n} of ${WORK.length} cuts match ${ch.textContent}`;
}));

/* ---------- preloader slate ---------- */
const slate = $('#slate'), slateN = $('#slateN');
const pimg = $('#portrait img');
const imgReady = new Promise(res => { if (pimg.complete && pimg.naturalWidth) res(); else { pimg.addEventListener('load', res, {once:true}); pimg.addEventListener('error', res, {once:true}); } });
const fontsReady = document.fonts ? document.fonts.ready : Promise.resolve();
let sceneReady = null; const sceneGate = new Promise(res => { sceneReady = res; });
window.__introAt = Infinity; // when the hero starts to burn in
(function runSlate(){
  const t0 = performance.now(), minT = reduce ? 0 : 1300; let done = false, shown = 0;
  Promise.all([imgReady, fontsReady, sceneGate]).then(() => { done = true; });
  setTimeout(() => { done = true; }, 7000); // never hold the page hostage
  function tick(now){
    const target = done ? 100 : 86, k = Math.min(1, (now - t0) / Math.max(1, minT));
    shown = Math.min(target * k, shown + 2.2); slateN.textContent = String(Math.floor(shown)).padStart(2, '0');
    if (done && k >= 1) { slateN.textContent = '100'; slate.classList.add('clap'); $('#loadStatus').textContent = 'Loaded';
      setTimeout(() => { slate.classList.add('out'); window.__introAt = performance.now() + 200; setTimeout(() => { slate.hidden = true; }, 1100); }, reduce ? 0 : 320); return; }
    requestAnimationFrame(tick);
  }
  requestAnimationFrame(tick);
})();

/* ---------- player ---------- */
const dlg = $('#player'), box = $('#playerBox');
let cur = 0, lastFocus = null;
function show(i){
  cur = (i + WORK.length) % WORK.length; const w = WORK[cur];
  const pi = $('#pImg'), pv = $('#pVid'); pi.src = `assets/work-${w.img}-lg.webp`; pi.alt = w.alt; pi.style.setProperty('--o', w.o);
  pv.pause(); pv.hidden = !w.vid;
  if (w.vid) { pv.poster = pi.src; pv.innerHTML = `<source src="assets/${w.vid}.webm" type="video/webm"><source src="assets/${w.vid}.mp4" type="video/mp4">`; pv.load(); if (!reduce && !box.classList.contains('paused')) { const pr = pv.play(); pr && pr.catch(() => {}); } }
  $('#pClient').textContent = w.c; $('#pTitle').textContent = w.t; $('#pDesc').textContent = w.d;
  $('#pPill').textContent = `${w.len} · ${w.cuts} cuts`;
  $('#pMeta').innerHTML = `<dt>Length</dt><dd>${w.len}</dd><dt>Versions</dt><dd>${w.cuts}</dd><dt>Result</dt><dd>${w.lift}</dd>`;
}
list.addEventListener('click', e => {
  const li = e.target.closest('.phone'); if (!li) return;
  lastFocus = document.activeElement; show(+li.dataset.i);
  box.classList.remove('paused'); $('#pToggle').textContent = 'Pause'; $('#pToggle').setAttribute('aria-pressed','false');
  box.querySelector('.screen').classList.add('playing'); box.classList.add('playing');
  dlg.showModal(); show(cur); $('#pClose').focus();
});
$('#pPrev').onclick = () => show(cur - 1);
$('#pNext').onclick = () => show(cur + 1);
$('#pToggle').onclick = e => { const p = box.classList.toggle('paused'); const pv = $('#pVid'); if (!pv.hidden) { if (p) pv.pause(); else { const pr = pv.play(); pr && pr.catch(() => {}); } } e.currentTarget.textContent = p ? 'Play' : 'Pause'; e.currentTarget.setAttribute('aria-pressed', String(p)); };
$('#pClose').onclick = () => dlg.close();
dlg.addEventListener('click', e => { if (e.target === dlg || e.target === box) dlg.close(); });
dlg.addEventListener('keydown', e => { if (e.key === 'ArrowRight') show(cur + 1); if (e.key === 'ArrowLeft') show(cur - 1); });
dlg.addEventListener('close', () => { $('#pVid').pause(); lastFocus && lastFocus.focus(); });

/* ---------- brief form ---------- */
const form = $('#briefForm'), cuts = $('#fCuts'), oCuts = $('#oCuts');
const BUDGET = {8:'€8k – €15k',15:'€15k – €30k',30:'€30k – €60k',60:'€60k +'};
const days = () => { const n = +cuts.value, fm = $$('input[name=formats]:checked').length || 1; return Math.max(3, Math.round(2 + n/12 + (fm-1)*0.8)); };
const upd = () => { oCuts.textContent = cuts.value; $('#estDays').textContent = days() + ' working days'; };
cuts.addEventListener('input', upd); $$('input[name=formats]').forEach(c => c.addEventListener('change', upd)); upd();
$('#fMsg').addEventListener('input', e => $('#cMsg').textContent = `${e.target.value.length} / 600`);
const today = new Date(); today.setHours(0,0,0,0);
$('#fDate').min = new Date(today.getTime() + 86400000*3).toISOString().slice(0,10);
function setErr(input, errEl, msg){ errEl.textContent = msg; if (input) input.setAttribute('aria-invalid', msg ? 'true' : 'false'); return !msg; }
function validate(){
  const name = $('#fName'), email = $('#fEmail'), brand = $('#fBrand'), date = $('#fDate');
  const ok = [
    setErr(name, $('#eName'), name.value.trim().length < 2 ? 'Please enter your name.' : ''),
    setErr(email, $('#eEmail'), !/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(email.value.trim()) ? 'Enter an email like name@company.com.' : ''),
    setErr(brand, $('#eBrand'), brand.value.trim().length < 2 ? 'Which brand or product is this for?' : ''),
    setErr(date, $('#eDate'), date.value && new Date(date.value) < new Date(date.min) ? 'I need at least three days from today.' : ''),
    setErr(null, $('#eFormats'), $$('input[name=formats]:checked').length ? '' : 'Pick at least one format.')
  ];
  return ok.every(Boolean);
}
['fName','fEmail','fBrand','fDate'].forEach(id => $('#'+id).addEventListener('input', () => { if ($('#'+id).getAttribute('aria-invalid') === 'true') validate(); }));
let summaryText = '';
form.addEventListener('submit', e => {
  e.preventDefault();
  if (!validate()) { const bad = $('[aria-invalid="true"]', form) || $('input[name=formats]'); bad.focus(); return; }
  const fd = new FormData(form), fm = fd.getAll('formats').join(', ');
  const rows = [['Name', fd.get('name')], ['Email', fd.get('email')], ['Brand', fd.get('brand')], ['Cuts', fd.get('cuts')], ['Formats', fm], ['Budget', BUDGET[fd.get('budget')]], ['Live by', fd.get('date') || 'Flexible'], ['Turnaround', days() + ' working days after the shoot'], ['First 3 seconds', fd.get('msg') || '—']];
  const dl = $('#sumList'); dl.innerHTML = '';
  rows.forEach(([k,v]) => { const dt = document.createElement('dt'), dd = document.createElement('dd'); dt.textContent = k; dd.textContent = v; dl.append(dt, dd); });
  summaryText = rows.map(([k,v]) => `${k}: ${v}`).join('\n');
  $('#sumMail').href = 'mailto:studio@maraquist.example?subject=' + encodeURIComponent('Brief: ' + fd.get('brand')) + '&body=' + encodeURIComponent(summaryText);
  const s = $('#summary'); s.hidden = false; s.focus(); $('#copyStatus').textContent = '';
});
$('#sumCopy').onclick = async () => { try { await navigator.clipboard.writeText(summaryText); $('#copyStatus').textContent = 'Copied to clipboard.'; } catch { $('#copyStatus').textContent = 'Copy blocked by the browser. Select the text above instead.'; } };
$('#sumEdit').onclick = () => { $('#summary').hidden = true; $('#fName').focus(); };

/* ---------- reveals & nav state ---------- */
const rio = new IntersectionObserver(es => es.forEach(e => { if (e.isIntersecting) { e.target.classList.add('in'); rio.unobserve(e.target); } }), {threshold:.2});
$$('.reveal').forEach(el => rio.observe(el));
const navLinks = $$('.nav ul a');
const sio = new IntersectionObserver(es => es.forEach(e => { if (e.isIntersecting) navLinks.forEach(a => a.setAttribute('aria-current', String(a.getAttribute('href') === '#' + e.target.id))); }), {rootMargin:'-45% 0px -45% 0px'});
$$('main section').forEach(s => sio.observe(s));

window.__site = { reduce, sceneReady };
})();
</script>
<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>
<script type="module">
/* ---------- the stage: a live 3D bust, re-drawn as ~15k dots that travel down the page ---------- */
const site = window.__site || {}; const $ = s => document.querySelector(s), $$ = s => [...document.querySelectorAll(s)];
const canvas = $('#field');
const noGL = site.reduce || /[?&]nogl/.test(location.search);
const fail = () => { document.documentElement.classList.remove('gl'); canvas.hidden = true; site.sceneReady && site.sceneReady(); };
let THREE, GLTFLoader, MeshoptDecoder, RoomEnvironment;
async function boot(){
  if (noGL) return fail();
  try {
    THREE = await import('three');
    ({ GLTFLoader } = await import('three/addons/loaders/GLTFLoader.js'));
    ({ MeshoptDecoder } = await import('three/addons/libs/meshopt_decoder.module.js'));
    ({ RoomEnvironment } = await import('three/addons/environments/RoomEnvironment.js'));
  } catch (e) { return fail(); }
  let renderer;
  try { renderer = new THREE.WebGLRenderer({ canvas, alpha: true, antialias: false, powerPreference: 'high-performance' }); }
  catch (e) { return fail(); }
  if (!renderer.capabilities.isWebGL2) { renderer.dispose(); return fail(); }
  document.documentElement.classList.add('gl');
  start(renderer);
}

function start(renderer){
  const mobile = innerWidth < 760 || matchMedia('(pointer:coarse)').matches;
  const GX = mobile ? 76 : 120, GY = Math.round(GX * 1.25), N = GX * GY;
  renderer.setClearColor(0x000000, 0); renderer.autoClear = false;
  renderer.toneMapping = THREE.ACESFilmicToneMapping; renderer.toneMappingExposure = 1.05;
  renderer.outputColorSpace = THREE.SRGBColorSpace;

  /* --- the bust, rendered off-screen into a 4:5 target --- */
  const RT_W = mobile ? 320 : 480, RT_H = Math.round(RT_W * 1.25);
  const rt = new THREE.WebGLRenderTarget(RT_W, RT_H, { samples: 4, colorSpace: THREE.SRGBColorSpace });
  const bustScene = new THREE.Scene();
  const pmrem = new THREE.PMREMGenerator(renderer);
  bustScene.environment = pmrem.fromScene(new RoomEnvironment(), 0.04).texture;
  bustScene.environmentIntensity = 0.35;
  const cam = new THREE.PerspectiveCamera(24, RT_W / RT_H, 0.1, 50); cam.position.set(0, 0, 6);
  const key = new THREE.DirectionalLight(0xfff1e0, 3.4); key.position.set(-3.5, 2.2, 3); bustScene.add(key);
  const rim = new THREE.DirectionalLight(0xff5b1f, 5.5); rim.position.set(3.2, 1.2, -2.6); bustScene.add(rim);
  const fill = new THREE.DirectionalLight(0x9fb4ff, 0.25); fill.position.set(2, -1, 3); bustScene.add(fill);
  const pivot = new THREE.Group(); bustScene.add(pivot);
  let haveBust = false;

  // photo texture: used for the dots until (or if never) the bust arrives
  const photoTex = new THREE.Texture($('#portrait img')); photoTex.colorSpace = THREE.SRGBColorSpace; photoTex.flipY = false;
  const imgEl = $('#portrait img'); const markPhoto = () => { photoTex.needsUpdate = true; };
  if (imgEl.complete && imgEl.naturalWidth) markPhoto(); else imgEl.addEventListener('load', markPhoto, { once: true });

  const loader = new GLTFLoader(); loader.setMeshoptDecoder(MeshoptDecoder);
  loader.load('assets/bust.glb', g => {
    const m = g.scene;
    m.traverse(o => { if (o.isMesh) { o.material.roughness = Math.max(.55, o.material.roughness ?? .8); o.material.metalness = 0; o.material.envMapIntensity = .6; } });
    const box = new THREE.Box3().setFromObject(m), size = box.getSize(new THREE.Vector3()), c = box.getCenter(new THREE.Vector3());
    m.position.sub(c); const sc = 2.25 / size.y; m.scale.setScalar(sc);
    pivot.add(m); haveBust = true; site.sceneReady && site.sceneReady();
  }, undefined, () => { running = false; fail(); });

  /* --- per-dot attributes --- */
  let seed = 7; const rnd = () => (seed = (seed * 16807) % 2147483647) / 2147483647;
  const A = new Float32Array(N*2), B = new Float32Array(N*2), R = new Float32Array(N*4), IDX = new Float32Array(N*2), C = new Float32Array(N*2), D = new Float32Array(N*2);
  for (let y = 0, i = 0; y < GY; y++) for (let x = 0; x < GX; x++, i++) {
    A[i*2] = (x + .5 + (y % 2) * .5) / (GX + .5); A[i*2+1] = (y + .5) / GY;
    R[i*4] = rnd(); R[i*4+1] = rnd(); R[i*4+2] = rnd(); R[i*4+3] = rnd();
    IDX[i*2] = i % 6; IDX[i*2+1] = i % 3;
    if (R[i*4+3] > .72) { // rounded phone perimeter
      const t = rnd() * 50; let [ux, uy] = t < 9 ? [t/9, 0] : t < 25 ? [1, (t-9)/16] : t < 34 ? [1-(t-25)/9, 1] : [0, 1-(t-34)/16];
      const rx = .15, ry = rx * 9/16, cx = Math.min(1-rx, Math.max(rx, ux)), cy = Math.min(1-ry, Math.max(ry, uy));
      if (cx !== ux && cy !== uy) { const a = Math.atan2((uy-cy)/ry, (ux-cx)/rx); ux = cx + Math.cos(a)*rx; uy = cy + Math.sin(a)*ry; }
      B[i*2] = ux; B[i*2+1] = uy;
    } else { B[i*2] = .04 + rnd()*.92; B[i*2+1] = .03 + rnd()*.94; }
  }
  const geo = new THREE.BufferGeometry();
  geo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(N*3), 3));
  geo.setAttribute('aA', new THREE.BufferAttribute(A, 2)); geo.setAttribute('aB', new THREE.BufferAttribute(B, 2));
  geo.setAttribute('aR', new THREE.BufferAttribute(R, 4)); geo.setAttribute('aIdx', new THREE.BufferAttribute(IDX, 2));
  const aC = new THREE.BufferAttribute(C, 2), aD = new THREE.BufferAttribute(D, 2); geo.setAttribute('aC', aC); geo.setAttribute('aD', aD);

  const V4 = () => new THREE.Vector4();
  const U = {
    tSrc: { value: photoTex }, uPhoto: { value: 1 }, uRes: { value: new THREE.Vector2() }, uDpr: { value: 1 }, uT: { value: 0 },
    uRA: { value: V4() }, uRB: { value: [V4(),V4(),V4(),V4(),V4(),V4()] }, uRC: { value: [V4(),V4(),V4()] }, uRD: { value: V4() },
    uP: { value: new THREE.Vector3() }, uIntro: { value: 0 }, uCell: { value: 4 }, uTextCell: { value: 4 }, uDim: { value: [0,0,0,0,0,0] },
    uTrail: { value: Array.from({ length: 10 }, () => new THREE.Vector3(-9999, -9999, 0)) }, uRad: { value: 110 }
  };
  const VS = `
  attribute vec2 aA; attribute vec2 aB; attribute vec2 aC; attribute vec2 aD; attribute vec4 aR; attribute vec2 aIdx;
  uniform sampler2D tSrc; uniform float uPhoto; uniform vec2 uRes; uniform float uDpr; uniform float uT;
  uniform vec4 uRA; uniform vec4 uRB[6]; uniform vec4 uRC[3]; uniform vec4 uRD; uniform vec3 uP; uniform float uIntro;
  uniform float uCell; uniform float uTextCell; uniform float uDim[6]; uniform vec3 uTrail[10]; uniform float uRad;
  varying vec3 vCol; varying float vAlpha; varying float vGlow;
  float e3(float x){ return x<.5 ? 4.*x*x*x : 1.-pow(-2.*x+2.,3.)/2.; }
  float stage(float p, float r){ return e3(clamp((p*1.25 - r*.45)/.55, 0., 1.)); }
  void main(){
    vec3 bone = vec3(.949,.922,.878), tang = vec3(1.,.357,.122), dark = vec3(.28,.24,.21);
    // A — the bust (or the photo) as halftone
    vec2 uv = aA; vec4 tex = texture2D(tSrc, uPhoto > .5 ? uv : vec2(uv.x, 1. - uv.y));
    float lum = dot(tex.rgb, vec3(.299,.587,.114));
    if (uPhoto > .5) { vec2 e = min(uv, 1. - uv) * 9.; lum = pow(clamp((lum - .06)/.9, 0., 1.), 1.2) * min(1., e.x) * min(1., e.y); }
    else lum *= tex.a;
    float warm = clamp((tex.r - tex.b - .2) * 3.5, 0., 1.) * (1. - uPhoto);
    vec2 pA = uRA.xy + aA * uRA.zw;
    float f = 0.; vec2 push = vec2(0.);
    for (int k = 0; k < 10; k++) { vec2 d = pA - uTrail[k].xy; float dd = dot(d,d); float w = exp(-dd/(uRad*uRad)) * uTrail[k].z; f += w; push += (dd > .01 ? d*inversesqrt(dd) : vec2(0.)) * w; }
    f = min(f, 1.2);
    pA += push * 26. + vec2(-push.y, push.x) * 14.;
    pA += vec2(sin(uT*.9 + aR.x*6.28), cos(uT*.7 + aR.y*6.28)) * .6;
    // burn-in: rows develop top to bottom, scattered dots land with an ember on the front
    float sI = clamp((uIntro*1.7 - aA.y*.55 - aR.x*.15) / .9, 0., 1.); float eI = e3(sI);
    vec2 from = uRA.xy + uRA.zw*.5 + (aR.yz - .5) * vec2(uRes.x*1.3, uRes.y*1.1);
    pA = mix(from, pA, eI);
    float ember = sin(3.14159*sI) * step(.001, sI) * step(sI, .999);
    float sA = uCell * (.12 + 1.05 * sqrt(lum)) * (1. + f*.5) * (.4 + .6*eI) * (1. + ember*.8);
    vec3 cA = mix(mix(dark, bone, smoothstep(.0,.85,lum)), tang, max(warm*.85, smoothstep(.15,.8,f)));
    cA = mix(cA, tang*1.15, ember);
    // B — phone frames
    int bi = int(aIdx.x + .5); vec4 rb = uRB[0]; float dim = uDim[0];
    if (bi==1){rb=uRB[1];dim=uDim[1];} else if (bi==2){rb=uRB[2];dim=uDim[2];} else if (bi==3){rb=uRB[3];dim=uDim[3];} else if (bi==4){rb=uRB[4];dim=uDim[4];} else if (bi==5){rb=uRB[5];dim=uDim[5];}
    vec2 pB = rb.xy + aB * rb.zw; float edge = step(.72, aR.w);
    float sB = edge > .5 ? 2.2 : 1.6 + lum*2.4;
    vec3 cB = mix(edge > .5 ? tang : mix(dark, bone, lum*.8), dark, dim*.7);
    // C — numbers, D — CTA word
    int ci = int(aIdx.y + .5); vec4 rc = ci==0 ? uRC[0] : (ci==1 ? uRC[1] : uRC[2]);
    vec2 pC = rc.xy + aC * rc.zw; float sC = uTextCell * (.75 + .35*aR.z); vec3 cC = ci==1 ? tang : bone;
    vec2 pD = uRD.xy + aD * uRD.zw; float sD = uTextCell * (.7 + .35*aR.y);
    float s1 = stage(uP.x, aR.x), s2 = stage(uP.y, aR.y), s3 = stage(uP.z, aR.z);
    vec2 p = mix(mix(mix(pA, pB, s1), pC, s2), pD, s3);
    float size = mix(mix(mix(sA, sB, s1), sC, s2), sD, s3);
    vec3 col = mix(mix(mix(cA, cB, s1), cC, s2), tang, s3);
    float fl = sin(3.14159*s1) + sin(3.14159*s2) + sin(3.14159*s3);
    p += vec2(sin(aR.y*40. + uT*.6), cos(aR.x*37. + uT*.5)) * vec2(uRes.x*.16, uRes.y*.12) * fl;
    size *= 1. + fl*.35;
    vCol = col; vGlow = max(ember, fl*.5); vAlpha = mix(.95, .8, fl*.5) * mix(1., eI, 1. - step(.5, s1 + s2 + s3));
    gl_Position = vec4(p.x/uRes.x*2.-1., 1.-p.y/uRes.y*2., 0., 1.);
    gl_PointSize = max(size, .8) * uDpr;
  }`;
  const FS = `
  varying vec3 vCol; varying float vAlpha; varying float vGlow;
  void main(){
    vec2 c = gl_PointCoord - .5; float r = length(c);
    float a = 1. - smoothstep(.34, .5, r);
    a += vGlow * .35 * exp(-r*r*14.);
    if (a < .01) discard;
    gl_FragColor = vec4(vCol, min(1., a) * vAlpha);
  }`;
  const mat = new THREE.ShaderMaterial({ vertexShader: VS, fragmentShader: FS, uniforms: U, transparent: true, depthTest: false, depthWrite: false });
  const pts = new THREE.Points(geo, mat); pts.frustumCulled = false;
  const dotScene = new THREE.Scene(); dotScene.add(pts);

  // the lens: where the pointer is, the real shaded bust shows through the dots
  const lensU = { tSrc: { value: rt.texture }, uRA: U.uRA, uRes: U.uRes, uDpr: U.uDpr, uTrail: U.uTrail, uRad: U.uRad, uShow: { value: 0 } };
  const lens = new THREE.Mesh(new THREE.PlaneGeometry(2, 2), new THREE.ShaderMaterial({ uniforms: lensU, transparent: true, depthTest: false, depthWrite: false,
    vertexShader: `uniform vec4 uRA; uniform vec2 uRes; varying vec2 vUv; void main(){ vUv = uv; vec2 px = uRA.xy + vec2(uv.x, 1.-uv.y) * uRA.zw; gl_Position = vec4(px.x/uRes.x*2.-1., 1.-px.y/uRes.y*2., 0., 1.); }`,
    fragmentShader: `uniform sampler2D tSrc; uniform vec2 uRes; uniform float uDpr; uniform vec3 uTrail[10]; uniform float uRad; uniform float uShow; varying vec2 vUv;
      void main(){ vec2 px = vec2(gl_FragCoord.x, uRes.y*uDpr - gl_FragCoord.y) / uDpr; float m = 0.;
        for (int k = 0; k < 10; k++) { vec2 d = px - uTrail[k].xy; m += exp(-dot(d,d)/(uRad*uRad*.55)) * uTrail[k].z; }
        vec4 t = texture2D(tSrc, vUv); float a = smoothstep(.25, .75, m) * t.a * uShow;
        gl_FragColor = vec4(t.rgb, a); }` }));
  lens.frustumCulled = false; dotScene.add(lens); lens.renderOrder = -1;
  const dummyCam = new THREE.Camera();

  /* --- text → dots --- */
  function sampleText(el){
    const r = el.getBoundingClientRect(), cs = getComputedStyle(el);
    const w = Math.max(1, Math.ceil(r.width)), h = Math.max(1, Math.ceil(r.height));
    const c = document.createElement('canvas'); c.width = w; c.height = h; const x = c.getContext('2d', { willReadFrequently: true });
    x.font = `${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`; x.fillStyle = '#fff'; x.textBaseline = 'middle'; x.letterSpacing = cs.letterSpacing;
    const words = el.textContent.split(' '), lh = parseFloat(cs.lineHeight) || parseFloat(cs.fontSize); const lines = []; let line = '';
    words.forEach(wd => { const t = line ? line + ' ' + wd : wd; if (x.measureText(t).width > w && line) { lines.push(line); line = wd; } else line = t; }); lines.push(line);
    // place the baseline exactly where CSS does: the font's content box is centred in each line box
    x.textBaseline = 'alphabetic'; const fm = x.measureText('Hg'), fa = fm.fontBoundingBoxAscent, fd = fm.fontBoundingBoxDescent;
    lines.forEach((ln, k) => x.fillText(ln, 0, lh * k + (lh - (fa + fd)) / 2 + fa));
    const d = x.getImageData(0, 0, w, h).data, pts = [], step = Math.max(3, Math.round(parseFloat(cs.fontSize) / 34));
    for (let yy = 0; yy < h; yy += step) for (let xx = 0; xx < w; xx += step) if (d[(yy*w + xx)*4 + 3] > 128) pts.push(xx / w, yy / h);
    return { pts, cell: step * 1.15 };
  }
  const cEls = [0,1,2].map(i => $(`[data-dots="c${i}"]`)), dEl = $('[data-dots="d0"]');
  function buildText(){
    const cs = cEls.map(sampleText), dd = sampleText(dEl);
    for (let i = 0; i < N; i++) {
      const p = cs[i % 3].pts, q = dd.pts;
      if (p.length) { const k = Math.floor(R[i*4+2] * p.length/2) * 2; C[i*2] = p[k]; C[i*2+1] = p[k+1]; }
      if (q.length) { const k = Math.floor(R[i*4+1] * q.length/2) * 2; D[i*2] = q[k]; D[i*2+1] = q[k+1]; }
    }
    aC.needsUpdate = aD.needsUpdate = true; U.uTextCell.value = cs[0].cell;
  }
  let W = 0, H = 0, dpr = 1;
  function resize(){
    dpr = Math.min(devicePixelRatio || 1, 2); W = innerWidth; H = innerHeight;
    renderer.setPixelRatio(dpr); renderer.setSize(W, H, false);
    U.uRes.value.set(W, H); U.uDpr.value = dpr; U.uRad.value = mobile ? 70 : 110; buildText();
  }
  let rtm; addEventListener('resize', () => { clearTimeout(rtm); rtm = setTimeout(resize, 150); });

  /* --- pointer: a decaying brush trail + a spring that turns the bust --- */
  const mouse = { x: -9999, y: -9999, on: false }; const trail = U.uTrail.value; let head = 0, lastX = -1e4, lastY = -1e4;
  addEventListener('pointermove', e => { mouse.x = e.clientX; mouse.y = e.clientY; mouse.on = true; }, { passive: true });
  document.addEventListener('pointerleave', () => { mouse.on = false; });
  const spring = { yaw: 0, pitch: 0, vy: 0, vp: 0 };

  const rectOf = (el, v) => { const r = el.getBoundingClientRect(); v.set(r.left, r.top, r.width, r.height); return v; };
  const portrait = $('#portrait'), screens = $$('[data-rect]'), phones = $$('.phone'), work = $('#work');
  const phonesEl = $('#phones'), statsEl = $('.stats'), tc = $('#tc');
  const clamp = v => Math.min(1, Math.max(0, v)); const P = [0,0,0];
  const t0 = performance.now(); let last = t0, running = true, visible = true;
  function frame(now){
    if (!running) return;
    const dt = Math.min(.05, (now - last) / 1000); last = now; const t = (now - t0) / 1000;
    const wt = phonesEl.getBoundingClientRect().top, nt = statsEl.getBoundingClientRect().top, bt = dEl.getBoundingClientRect().top;
    const tg = [clamp((H - wt) / (H*.45)), clamp((H*.9 - nt) / (H*.55)), clamp((H*.9 - bt) / (H*.55))];
    for (let k = 0; k < 3; k++) { P[k] += (tg[k] - P[k]) * Math.min(1, dt * 5.2); if (Math.abs(tg[k] - P[k]) < .0005) P[k] = tg[k]; }
    U.uP.value.set(P[0], P[1], P[2]);
    U.uIntro.value = clamp((now - (window.__introAt || 0)) / 2200);
    const rev = clamp((P[0] - .78) / .12) * (1 - clamp((P[1] - .05) / .4));
    work.style.setProperty('--reveal', P[1] > .5 ? 1 : rev.toFixed(3));
    const ra = rectOf(portrait, U.uRA.value);
    screens.forEach((s, i) => { rectOf(s, U.uRB.value[i]); U.uDim.value[i] = phones[i].classList.contains('dim') ? 1 : 0; });
    cEls.forEach((el, i) => rectOf(el, U.uRC.value[i])); rectOf(dEl, U.uRD.value);
    U.uCell.value = ra.z / GX; U.uT.value = t;
    // brush trail
    if (mouse.on && Math.hypot(mouse.x - lastX, mouse.y - lastY) > 9) { trail[head].set(mouse.x, mouse.y, 1); head = (head + 1) % trail.length; lastX = mouse.x; lastY = mouse.y; }
    trail.forEach(p => { p.z *= Math.pow(.2, dt); });
    // spring the bust toward the pointer (k 38, c 9) plus a slow idle sway
    const cx = ra.x + ra.z/2, cy = ra.y + ra.w/2;
    const tyaw = (mouse.on ? clamp((mouse.x - cx) / W + .5) - .5 : 0) * 1.2 + Math.sin(t*.35) * .22 - P[0] * 1.6;
    const tpitch = (mouse.on ? clamp((mouse.y - cy) / H + .5) - .5 : 0) * .45 + Math.sin(t*.27) * .04;
    spring.vy += ((tyaw - spring.yaw) * 38 - spring.vy * 9) * dt; spring.yaw += spring.vy * dt;
    spring.vp += ((tpitch - spring.pitch) * 38 - spring.vp * 9) * dt; spring.pitch += spring.vp * dt;
    pivot.rotation.set(spring.pitch, spring.yaw, 0);
    if (tc) { const f = Math.floor(t * 24); tc.textContent = `00:${String(Math.floor(f/1440)%60).padStart(2,'0')}:${String(Math.floor(f/24)%60).padStart(2,'0')}:${String(f%24).padStart(2,'0')}`; }
    const heroOn = ra.y + ra.w > -50 && P[0] < .999;
    if (haveBust) {
      if (heroOn) { renderer.setRenderTarget(rt); renderer.setClearColor(0, 0); renderer.clear(); renderer.render(bustScene, cam); renderer.setRenderTarget(null); }
      U.tSrc.value = rt.texture; U.uPhoto.value = 0;
    }
    lensU.uShow.value = haveBust ? (1 - clamp(P[0] * 3)) * clamp(U.uIntro.value * 2 - 1) : 0; lens.visible = lensU.uShow.value > .001;
    renderer.clear(); renderer.render(dotScene, dummyCam);
    requestAnimationFrame(frame);
  }
  document.addEventListener('visibilitychange', () => { const was = running; running = !document.hidden; if (running && !was) { last = performance.now(); requestAnimationFrame(frame); } });
  canvas.addEventListener('webglcontextlost', e => { e.preventDefault(); running = false; fail(); });
  (document.fonts ? document.fonts.ready : Promise.resolve()).then(() => { resize(); requestAnimationFrame(frame); });
}
boot();
</script>
</body>
</html>

````
