{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"lathe-lacquer","type":"registry:block","title":"Lathe & Lacquer","description":"A filmed gouge cuts a spinning walnut blank as you scroll, then a live three.js lathe takes over: the bowl's profile carves itself pass by pass and a coat of oxblood lacquer spreads across the grain. Drag to walk round it, then orbit 4 finished pieces on a turntable and price a commission.","categories":["3d"],"dependencies":["@fontsource/azeret-mono@^5.3.0","@fontsource/red-hat-text@^5.3.0","@fontsource/young-serif@^5.3.0","@react-three/fiber@9.8.1","three@0.186.1"],"devDependencies":["@types/three@0.186.0"],"files":[{"path":"components/nightmarquee/lathe-lacquer/lathe-lacquer/demo.tsx","type":"registry:component","target":"components/nightmarquee/lathe-lacquer/lathe-lacquer/demo.tsx","content":"\"use client\";\n/* NightMarquee design \"Lathe & Lacquer\". Free for personal, portfolio, educational and non-commercial use; no republishing: nightmarquee.com/license */\n\n/* Self-hosted through @fontsource: no request to Google at build or run time. */\nimport \"@fontsource/young-serif/400.css\";\nimport \"@fontsource/red-hat-text/400.css\";\nimport \"@fontsource/red-hat-text/500.css\";\nimport \"@fontsource/azeret-mono/400.css\";\nimport \"@fontsource/azeret-mono/500.css\";\n\n/* Lathe & Lacquer, a bowl turner's site. One rAF loop: the opening film of a gouge\n   cutting a spinning walnut blank is scrubbed against chapter anchors, then the\n   lathe scene takes over (three.js through React Three Fiber, in ./scene) and the\n   same loop feeds it carve and lacquer progress from its own section's scroll.\n   Then a turntable shelf of 4 finished pieces and a commissions form over the\n   ambient loop. */\n\nimport dynamic from \"next/dynamic\";\nimport { useEffect, useRef, useState, useSyncExternalStore, type KeyboardEvent } from \"react\";\nimport { POSTER, SHOTS, pickVideo } from \"./media\";\nimport type { LatheProgress, OrbitApi, Piece } from \"./scene\";\n\nconst LatheScene = dynamic(() => import(\"./scene\").then((m) => m.LatheScene), { ssr: false });\nconst ShelfScene = dynamic(() => import(\"./scene\").then((m) => m.ShelfScene), { ssr: false });\n\nconst DUR = 10;\nconst STILL_T = 5;\n\nconst PIECES: (Piece & { name: string; woodName: string; mm: number; tall: number; finish: string; time: string; photo: string; alt: string })[] = [\n  {\n    name: \"No. 14, the walnut bowl\",\n    woodName: \"Black walnut\",\n    mm: 294,\n    tall: 123,\n    finish: \"Oxblood lacquer, 4 coats\",\n    time: \"6 h 40 min\",\n    shape: 0,\n    wood: \"walnut\",\n    tint: \"#a8323a\",\n    gloss: 0.12,\n    photo: \"https://media.nightmarquee.com/drops/lathe-lacquer/still-3.jpg\",\n    alt: \"A hollowed walnut bowl still on the lathe under a work lamp, shavings in its floor and a tin of red lacquer on the bench\",\n  },\n  {\n    name: \"No. 15, the deep bowl\",\n    woodName: \"Ash\",\n    mm: 270,\n    tall: 150,\n    finish: \"Oil and wax\",\n    time: \"4 h 15 min\",\n    shape: 1,\n    wood: \"ash\",\n    tint: \"#efe2cc\",\n    gloss: 0.42,\n    photo: \"https://media.nightmarquee.com/drops/lathe-lacquer/still-4.jpg\",\n    alt: \"A pale ash bowl seen face on in the lathe chuck, its turning rings running to the centre, a curl of ash lifting at the rim\",\n  },\n  {\n    name: \"No. 16, the platter\",\n    woodName: \"Black walnut\",\n    mm: 318,\n    tall: 39,\n    finish: \"Clear lacquer, 3 coats\",\n    time: \"5 h 30 min\",\n    shape: 2,\n    wood: \"walnut\",\n    tint: \"#f3e8da\",\n    gloss: 0.16,\n    photo: \"https://media.nightmarquee.com/drops/lathe-lacquer/still-1.jpg\",\n    alt: \"A wide turned bowl on a cast-iron lathe, a gouge resting across it and pale shavings on the tool rest\",\n  },\n  {\n    name: \"No. 17, the hollow form\",\n    woodName: \"Ash\",\n    mm: 255,\n    tall: 218,\n    finish: \"Clear lacquer, 2 coats\",\n    time: \"9 h 10 min\",\n    shape: 3,\n    wood: \"ash\",\n    tint: \"#f3e8da\",\n    gloss: 0.2,\n    photo: \"https://media.nightmarquee.com/drops/lathe-lacquer/still-2.jpg\",\n    alt: \"The workshop at night: a bowl on the lathe, a gouge on the rest and a pegboard of ash-handled tools behind\",\n  },\n];\n\nconst WOOD_OPTIONS = [\n  { id: \"walnut\", label: \"Black walnut\", add: 40 },\n  { id: \"cherry\", label: \"Cherry\", add: 25 },\n  { id: \"ash\", label: \"Ash\", add: 0 },\n];\nconst FINISH_OPTIONS = [\n  { id: \"oxblood\", label: \"Oxblood lacquer\", add: 60, mins: 70, weeks: 1 },\n  { id: \"clear\", label: \"Clear lacquer\", add: 35, mins: 60, weeks: 1 },\n  { id: \"oil\", label: \"Oil and wax\", add: 0, mins: 20, weeks: 0 },\n];\n\nconst lerpTable = (x: number, xs: number[], ys: number[]) => {\n  if (x <= xs[0]) return ys[0];\n  for (let i = 1; i < xs.length; i++) {\n    if (x <= xs[i]) {\n      const k = (x - xs[i - 1]) / (xs[i] - xs[i - 1] || 1);\n      return ys[i - 1] + (ys[i] - ys[i - 1]) * k;\n    }\n  }\n  return ys[ys.length - 1];\n};\nconst clamp01 = (v: number) => Math.min(1, Math.max(0, v));\n\nconst REDUCE_Q = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduce = (cb: () => void) => {\n  const m = window.matchMedia(REDUCE_Q);\n  m.addEventListener(\"change\", cb);\n  return () => m.removeEventListener(\"change\", cb);\n};\nconst getReduce = () => window.matchMedia(REDUCE_Q).matches;\nconst noSubscribe = () => () => {};\nlet webglKnown: boolean | null = null;\nconst getWebgl = () => {\n  if (webglKnown === null) {\n    try {\n      const c = document.createElement(\"canvas\");\n      const ctx = (c.getContext(\"webgl2\") || c.getContext(\"webgl\")) as WebGLRenderingContext | null;\n      webglKnown = !!ctx && typeof window.WebGLRenderingContext !== \"undefined\";\n      ctx?.getExtension(\"WEBGL_lose_context\")?.loseContext();\n    } catch {\n      webglKnown = false;\n    }\n  }\n  return webglKnown;\n};\nconst yes = () => true;\nconst no = () => false;\n\nconst fmtTime = (mins: number) => `${Math.floor(mins / 60)} h ${String(Math.round(mins % 60)).padStart(2, \"0\")} min`;\n\nexport function Demo() {\n  const rootRef = useRef<HTMLDivElement>(null);\n  const filmRef = useRef<HTMLVideoElement>(null);\n  const loopRef = useRef<HTMLVideoElement>(null);\n  const progressRef = useRef<LatheProgress>({ carve: 0, lacquer: 0 });\n  const latheApi = useRef<OrbitApi | null>(null);\n  const shelfApi = useRef<OrbitApi | null>(null);\n\n  const reduce = useSyncExternalStore(subscribeReduce, getReduce, no);\n  const webgl = useSyncExternalStore(noSubscribe, getWebgl, yes);\n\n  const [latheNear, setLatheNear] = useState(false);\n  const [latheLive, setLatheLive] = useState(false);\n  const [latheReady, setLatheReady] = useState(false);\n  const [shelfNear, setShelfNear] = useState(false);\n  const [shelfLive, setShelfLive] = useState(false);\n  const [shelfReady, setShelfReady] = useState(false);\n  const [piece, setPiece] = useState(0);\n\n  const [wood, setWood] = useState(0);\n  const [finish, setFinish] = useState(0);\n  const [diameter, setDiameter] = useState(280);\n  const [sent, setSent] = useState(false);\n\n  const pc = PIECES[piece];\n  const fo = FINISH_OPTIONS[finish];\n  const price = Math.round((120 + (diameter - 160) * 1.2 + WOOD_OPTIONS[wood].add + fo.add) / 5) * 5;\n  const mins = 150 + (diameter - 160) * 1.3 + fo.mins;\n  const weeks = 4 + fo.weeks;\n\n  const choosePiece = (i: number) => {\n    const n = (i + PIECES.length) % PIECES.length;\n    setPiece(n);\n    shelfApi.current?.setPiece?.(n);\n  };\n\n  const orbitKeys = (e: KeyboardEvent<HTMLDivElement>, which: \"lathe\" | \"shelf\") => {\n    const step: Record<string, [number, number]> = {\n      ArrowLeft: [0.2, 0],\n      ArrowRight: [-0.2, 0],\n      ArrowUp: [0, -0.08],\n      ArrowDown: [0, 0.08],\n    };\n    const s = step[e.key];\n    const api = which === \"lathe\" ? latheApi.current : shelfApi.current;\n    if (!s || !api) return;\n    e.preventDefault();\n    api.orbit(s[0], s[1]);\n  };\n\n  /* the film and the ambient loop get the file for this screen before anything plays or scrubs */\n  useEffect(() => {\n    const film = filmRef.current;\n    const loop = loopRef.current;\n    if (film) film.src = pickVideo(SHOTS.hero);\n    if (loop) loop.src = pickVideo(SHOTS.ambient);\n  }, []);\n\n  /* mount each canvas once it comes near, run it only while it is on screen */\n  useEffect(() => {\n    const root = rootRef.current;\n    if (!root) return;\n    const lathe = root.querySelector<HTMLElement>(\"[data-lathe]\")!;\n    const shelf = root.querySelector<HTMLElement>(\"[data-shelf]\")!;\n    const loopSec = root.querySelector<HTMLElement>(\"[data-commission]\")!;\n    const near = new IntersectionObserver(\n      (es) =>\n        es.forEach((e) => {\n          if (!e.isIntersecting) return;\n          if (e.target === lathe) setLatheNear(true);\n          if (e.target === shelf) setShelfNear(true);\n        }),\n      { rootMargin: \"120% 0px\" },\n    );\n    const live = new IntersectionObserver((es) =>\n      es.forEach((e) => {\n        if (e.target === lathe) setLatheLive(e.isIntersecting);\n        if (e.target === shelf) setShelfLive(e.isIntersecting);\n        if (e.target === loopSec) {\n          const v = loopRef.current;\n          if (!v || window.matchMedia(REDUCE_Q).matches) return;\n          if (e.isIntersecting) v.play().catch(() => {});\n          else v.pause();\n        }\n      }),\n    );\n    near.observe(lathe);\n    near.observe(shelf);\n    live.observe(lathe);\n    live.observe(shelf);\n    live.observe(loopSec);\n    return () => {\n      near.disconnect();\n      live.disconnect();\n    };\n  }, []);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    const video = filmRef.current;\n    if (!root || !video) return;\n    const still = window.matchMedia(REDUCE_Q).matches;\n    root.classList.add(\"js\");\n\n    let pending = Array.from(root.querySelectorAll<HTMLElement>(\"[data-reveal]\"));\n    pending.forEach((el) => {\n      const g = el.closest(\"[data-stagger]\");\n      if (g) el.style.setProperty(\"--d\", `${Array.from(g.querySelectorAll(\"[data-reveal]\")).indexOf(el) * 60}ms`);\n    });\n    const sweep = () => {\n      const vh = window.innerHeight;\n      for (let i = pending.length - 1; i >= 0; i--) {\n        const r = pending[i].getBoundingClientRect();\n        if (r.top < vh * 0.92 && r.bottom > 0) {\n          pending[i].classList.add(\"in\");\n          pending.splice(i, 1);\n        }\n      }\n    };\n\n    const film = root.querySelector<HTMLElement>(\"[data-film]\")!;\n    const wrap = root.querySelector<HTMLElement>(\"[data-chapters]\")!;\n    const heroCopy = root.querySelector<HTMLElement>(\"[data-hero-copy]\")!;\n    const nav = root.querySelector<HTMLElement>(\"[data-nav]\")!;\n    const passEl = root.querySelector<HTMLElement>(\"[data-pass]\")!;\n    const tcEl = root.querySelector<HTMLElement>(\"[data-tc]\")!;\n    const bar = root.querySelector<HTMLElement>(\"[data-bar]\")!;\n    const hud = root.querySelector<HTMLElement>(\"[data-hud]\")!;\n    const lathe = root.querySelector<HTMLElement>(\"[data-lathe]\")!;\n    const rPass = root.querySelector<HTMLElement>(\"[data-r-pass]\")!;\n    const rWall = root.querySelector<HTMLElement>(\"[data-r-wall]\")!;\n    const rDepth = root.querySelector<HTMLElement>(\"[data-r-depth]\")!;\n    const rCoat = root.querySelector<HTMLElement>(\"[data-r-coat]\")!;\n    const lBar = root.querySelector<HTMLElement>(\"[data-l-bar]\")!;\n    const steps = Array.from(root.querySelectorAll<HTMLElement>(\"[data-step]\"));\n    const chapters = Array.from(root.querySelectorAll<HTMLElement>(\"[data-t]\"));\n\n    let ax: number[] = [0];\n    let at: number[] = [0];\n    let span = 1;\n    const measure = () => {\n      const vh = window.innerHeight;\n      span = Math.max(1, film.offsetHeight - vh);\n      const pts = chapters\n        .map((ch) => ({ y: ch.offsetTop + ch.offsetHeight / 2 - vh / 2, t: parseFloat(ch.dataset.t || \"0\") }))\n        .map((p) => ({ y: Math.min(span, Math.max(0, p.y)), t: p.t }));\n      pts.push({ y: 0, t: 0 }, { y: span, t: DUR });\n      pts.sort((a, b) => a.y - b.y || a.t - b.t);\n      ax = pts.map((p) => p.y);\n      at = pts.map((p) => p.t);\n    };\n    measure();\n    const ro = new ResizeObserver(measure);\n    ro.observe(wrap);\n    window.addEventListener(\"resize\", measure);\n\n    const mark = () => video.classList.add(\"ready\");\n    if (video.readyState >= 3) mark();\n    else {\n      video.addEventListener(\"canplay\", mark, { once: true });\n      video.addEventListener(\"loadeddata\", mark, { once: true });\n    }\n    const kick = () => {\n      video.preload = \"auto\";\n      video.load();\n    };\n    if (!still) {\n      if (document.readyState === \"complete\") kick();\n      else window.addEventListener(\"load\", kick, { once: true });\n    }\n\n    /* readouts write text only when the value changes */\n    const last: Record<string, string> = {};\n    const put = (el: HTMLElement, key: string, v: string) => {\n      if (last[key] === v) return;\n      last[key] = v;\n      el.textContent = v;\n    };\n    const readouts = (carve: number, lacquer: number) => {\n      const pass = carve >= 1 ? 12 : Math.min(12, Math.floor(carve * 12) + 1);\n      const inner = clamp01((carve - 0.3) / 0.7);\n      put(rPass, \"pass\", `${String(pass).padStart(2, \"0\")} / 12`);\n      put(rWall, \"wall\", inner <= 0 ? \"solid\" : `${Math.round(135 - (135 - 6) * Math.pow(inner, 0.7))} mm`);\n      put(rDepth, \"depth\", `${Math.round(inner * 105)} mm`);\n      put(rCoat, \"coat\", `${Math.round(lacquer * 100)}%`);\n      const phase = lacquer > 0.02 ? 2 : carve < 0.36 ? 0 : 1;\n      if (last.phase !== String(phase)) {\n        last.phase = String(phase);\n        steps.forEach((s, i) => s.classList.toggle(\"on\", i === phase));\n      }\n      lBar.style.transform = `scaleX(${(carve * 0.8 + lacquer * 0.2).toFixed(4)})`;\n    };\n\n    let st = 0;\n    let carve = 0;\n    let lacquer = 0;\n    let raf = 0;\n    const tick = () => {\n      if (pending.length) sweep();\n      const vh = window.innerHeight;\n      const fr = film.getBoundingClientRect();\n      const s = -fr.top;\n\n      if (fr.bottom > 0) {\n        const target = lerpTable(Math.min(span, Math.max(0, s)), ax, at);\n        st += (target - st) * 0.1;\n        if (Math.abs(target - st) < 0.0005) st = target;\n        if (video.duration && video.classList.contains(\"ready\") && !video.seeking) {\n          const vt = Math.min(video.duration - 0.04, st);\n          if (Math.abs(video.currentTime - vt) > 0.01) video.currentTime = vt;\n        }\n        const ho = clamp01(s / (vh * 0.8));\n        heroCopy.style.transform = `translate3d(0,${(s * 0.3).toFixed(1)}px,0) scale(${(1 - ho * 0.05).toFixed(4)})`;\n        put(passEl, \"fpass\", String(Math.min(12, 1 + Math.floor((st / DUR) * 12))).padStart(2, \"0\"));\n        put(tcEl, \"tc\", `${st.toFixed(1)} s`);\n        bar.style.transform = `scaleX(${(st / DUR).toFixed(4)})`;\n        hud.style.opacity = (1 - clamp01((s - span) / (vh * 0.4))).toFixed(3);\n      }\n\n      const lr = lathe.getBoundingClientRect();\n      if (lr.top < vh && lr.bottom > 0) {\n        const p = clamp01(-lr.top / Math.max(1, lathe.offsetHeight - vh));\n        const tc = clamp01(p / 0.68);\n        const tl = clamp01((p - 0.74) / 0.2);\n        carve += (tc - carve) * 0.1;\n        lacquer += (tl - lacquer) * 0.1;\n        if (Math.abs(tc - carve) < 0.0004) carve = tc;\n        if (Math.abs(tl - lacquer) < 0.0004) lacquer = tl;\n        progressRef.current.carve = carve;\n        progressRef.current.lacquer = lacquer;\n        readouts(carve, lacquer);\n      }\n\n      nav.classList.toggle(\"solid\", s > span + vh * 0.2);\n      raf = requestAnimationFrame(tick);\n    };\n\n    if (still) {\n      const freeze = () => {\n        video.currentTime = STILL_T;\n      };\n      if (video.readyState >= 1) freeze();\n      video.addEventListener(\"loadedmetadata\", freeze);\n      pending.forEach((el) => el.classList.add(\"in\"));\n      pending = [];\n      progressRef.current.carve = 1;\n      progressRef.current.lacquer = 1;\n      readouts(1, 1);\n      passEl.textContent = \"07\";\n      tcEl.textContent = `${STILL_T.toFixed(1)} s`;\n      bar.style.transform = `scaleX(${STILL_T / DUR})`;\n      const onScroll = () => nav.classList.toggle(\"solid\", -film.getBoundingClientRect().top > span);\n      window.addEventListener(\"scroll\", onScroll, { passive: true });\n      return () => {\n        window.removeEventListener(\"scroll\", onScroll);\n        video.removeEventListener(\"loadedmetadata\", freeze);\n        window.removeEventListener(\"resize\", measure);\n        ro.disconnect();\n      };\n    }\n    raf = requestAnimationFrame(tick);\n    return () => {\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      window.removeEventListener(\"resize\", measure);\n    };\n  }, []);\n\n  return (\n    <div className=\"ll-page\" ref={rootRef}>\n      <style>{`\n        .ll-page{\n          --black:#0f0b08;--bark:#17110c;--bark-2:#21180f;--walnut:#5a3a22;--ash:#ece0c8;--ash-2:rgba(236,224,200,.76);\n          --lamp:#e8b366;--oxblood:#6d1a1f;--oxblood-2:#842329;--line:rgba(236,224,200,.14);--ease:cubic-bezier(.16,1,.3,1);\n          --serif:'Young Serif',Georgia,serif;--mono:'Azeret Mono',ui-monospace,monospace;\n          background:var(--black);color:var(--ash);font-family:'Red Hat Text',system-ui,sans-serif;font-weight:400;\n          overflow-x:clip;-webkit-font-smoothing:antialiased;\n        }\n        .ll-page ::selection{background:var(--lamp);color:var(--black)}\n        .ll-page :focus-visible{outline:2px solid var(--lamp);outline-offset:3px}\n        .ll-num{font-family:var(--mono);font-variant-numeric:tabular-nums}\n        .ll-vh{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n        .ll-skip{position:absolute;left:1rem;top:-4rem;z-index:80;background:var(--ash);color:var(--black);padding:.7rem 1rem;font-size:.9rem;text-decoration:none}\n        .ll-skip:focus{top:1rem}\n\n        .js [data-reveal]{transform:translateY(20px);transition:transform .9s var(--ease) var(--d,0ms)}\n        .js [data-reveal].in{transform:none}\n\n        .ll-nav{position:fixed;inset:0 0 auto 0;z-index:50;display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:1rem clamp(1rem,3.5vw,3rem);background:linear-gradient(rgba(15,11,8,.82),rgba(15,11,8,0));transition:background .6s}\n        .ll-nav.solid{background:rgba(15,11,8,.94)}\n        .ll-mark{display:flex;align-items:center;gap:.6rem;font-family:var(--serif);font-size:1.35rem;color:var(--ash);text-decoration:none;white-space:nowrap}\n        .ll-mark i{font-style:normal;color:var(--lamp)}\n        .ll-mark svg{width:22px;height:22px}\n        .ll-links{display:flex;gap:2rem;list-style:none;margin:0;padding:0}\n        .ll-links a{color:var(--ash);text-decoration:none;font-size:.9rem;position:relative;padding:.3rem 0}\n        .ll-links a::after{content:\"\";position:absolute;left:0;bottom:0;height:1px;width:100%;background:var(--lamp);transform:scaleX(0);transform-origin:right;transition:transform .5s var(--ease)}\n        .ll-links a:hover::after,.ll-links a:focus-visible::after{transform:scaleX(1);transform-origin:left}\n        .ll-btn{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;border:0;background:var(--oxblood);color:var(--ash);font:500 .9rem/1 'Red Hat Text',sans-serif;padding:.85rem 1.2rem;text-decoration:none;cursor:pointer;box-shadow:0 10px 24px -14px rgba(0,0,0,.8);transition:background .35s var(--ease)}\n        .ll-btn:hover,.ll-btn:focus-visible{background:var(--oxblood-2)}\n        .ll-ghost{display:inline-flex;align-items:center;gap:.5rem;border:1px solid rgba(236,224,200,.32);background:transparent;color:var(--ash);font:500 .9rem/1 'Red Hat Text',sans-serif;padding:.75rem 1rem;cursor:pointer;text-decoration:none;transition:border-color .3s,color .3s}\n        .ll-ghost:hover,.ll-ghost:focus-visible{border-color:var(--lamp);color:var(--lamp)}\n        @media(max-width:860px){.ll-links{display:none}}\n        @media(max-width:420px){.ll-nav .ll-btn{padding:.75rem .85rem;font-size:.82rem}.ll-mark{font-size:1.15rem}}\n\n        .ll-film{position:relative;background:var(--black)}\n        .ll-stage{position:sticky;top:0;height:100vh;height:100svh;overflow:hidden;z-index:0;background:var(--black) url(https://media.nightmarquee.com/drops/lathe-lacquer/poster.jpg) 50% 50%/cover no-repeat}\n        .ll-stage video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:56% 50%;opacity:0;transition:opacity .8s ease}\n        .ll-stage video.ready{opacity:1}\n        .ll-scrim{position:absolute;inset:0;pointer-events:none;background:\n          linear-gradient(rgba(15,11,8,.55),transparent 20%,transparent 58%,rgba(15,11,8,.8)),\n          radial-gradient(60% 50% at 0% 100%,rgba(15,11,8,.6),transparent)}\n        .ll-grain{position:absolute;inset:0;pointer-events:none;opacity:.18;mix-blend-mode:overlay;background-image:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence baseFrequency='.9' numOctaves='3'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>\")}\n\n        .ll-hud{position:absolute;right:clamp(1rem,3.5vw,3rem);bottom:clamp(1.2rem,4vh,2.4rem);z-index:3;width:230px;padding:1rem 1.1rem;background:rgba(15,11,8,.9);border:1px solid var(--line);display:grid;gap:.55rem;pointer-events:none}\n        .ll-hud-row{display:flex;justify-content:space-between;align-items:baseline;font-size:.8rem;color:var(--ash-2)}\n        .ll-hud-row b{font-family:var(--mono);font-weight:500;font-size:1.5rem;color:var(--ash);font-variant-numeric:tabular-nums}\n        .ll-hud-row b small{font-size:.8rem;color:var(--ash-2);margin-left:.3rem;font-weight:400}\n        .ll-track{height:2px;background:rgba(236,224,200,.16);overflow:hidden}\n        .ll-track i{display:block;height:100%;background:var(--lamp);transform-origin:left;transform:scaleX(0)}\n\n        .ll-chapters{position:relative;z-index:2;margin-top:-100vh;margin-top:-100svh}\n        .ll-ch{position:relative;min-height:115vh;display:flex;align-items:center;padding:0 clamp(1rem,4vw,3.5rem)}\n        .ll-ch.right{justify-content:flex-end}\n        .ll-hero{min-height:100vh;min-height:100svh;align-items:flex-end;padding-bottom:clamp(4.5rem,11vh,7rem)}\n        .ll-herocopy{max-width:760px;padding:clamp(1.4rem,3vw,2.4rem);background:rgba(15,11,8,.88);border:1px solid var(--line);box-shadow:0 40px 80px -40px rgba(0,0,0,.9);will-change:transform}\n        .ll-h1{font-family:var(--serif);font-weight:400;font-size:clamp(2.2rem,4.4vw,4.2rem);line-height:1.04;letter-spacing:-.02em;margin:0}\n        .ll-h1 em{font-style:normal;color:var(--lamp)}\n        .ll-lede{max-width:48ch;margin:1.4rem 0 0;line-height:1.65;color:var(--ash-2);font-size:clamp(.95rem,1.3vw,1.06rem)}\n        .ll-herorow{display:flex;flex-wrap:wrap;align-items:center;gap:1rem 2rem;margin-top:1.6rem}\n        .ll-cue{display:flex;align-items:center;gap:.8rem;font-size:.9rem;color:var(--ash-2)}\n        .ll-cue i{display:block;width:1px;height:40px;background:rgba(236,224,200,.2);position:relative;overflow:hidden}\n        .ll-cue i::after{content:\"\";position:absolute;left:0;top:0;width:1px;height:40%;background:var(--lamp);animation:ll-drop 2.4s var(--ease) infinite}\n        @keyframes ll-drop{from{transform:translateY(-100%)}to{transform:translateY(260%)}}\n        .ll-meta{margin:1.2rem 0 0;font-size:.9rem;color:var(--lamp);display:flex;align-items:center;gap:.8rem}\n        .ll-meta::before{content:\"\";width:30px;height:1px;background:var(--lamp)}\n\n        .ll-card{width:min(440px,100%);padding:clamp(1.3rem,2.6vw,2rem);background:rgba(23,17,12,.93);border:1px solid var(--line);box-shadow:0 40px 80px -40px rgba(0,0,0,.85)}\n        .ll-h2{font-family:var(--serif);font-weight:400;font-size:clamp(1.8rem,3vw,2.5rem);line-height:1.08;letter-spacing:-.01em;margin:0}\n        .ll-h2 em{font-style:normal;color:var(--lamp)}\n        .ll-date{display:flex;justify-content:space-between;gap:1rem;margin:.9rem 0 1.1rem;padding-top:.7rem;border-top:1px solid var(--line);font-family:var(--mono);font-size:.78rem;color:var(--lamp)}\n        .ll-date span:last-child{color:var(--ash-2)}\n        .ll-p{margin:0;color:var(--ash-2);line-height:1.68;font-size:.97rem}\n        .ll-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:1rem;margin-top:1.4rem;padding-top:1.2rem;border-top:1px solid var(--line)}\n        .ll-stat b{display:block;font-family:var(--mono);font-weight:500;font-size:1.65rem;line-height:1;font-variant-numeric:tabular-nums;color:var(--ash)}\n        .ll-stat span{display:block;margin-top:.4rem;font-size:.82rem;color:var(--ash-2)}\n        .ll-card .ll-btn{margin-top:1.4rem}\n\n        .ll-lathe{position:relative;height:460vh;background:var(--black)}\n        .ll-lstage{position:sticky;top:0;height:100vh;height:100svh;overflow:hidden}\n        .ll-canvas{position:absolute;inset:0 0 0 min(30vw,460px)}\n        .ll-fallback{position:absolute;inset:0;background:var(--black) url(https://media.nightmarquee.com/drops/lathe-lacquer/still-3.jpg) 60% 50%/cover no-repeat}\n        .ll-gl{position:absolute;inset:0;opacity:0;transition:opacity 1s ease;cursor:grab}\n        .ll-gl.on{opacity:1}\n        .ll-gl:active{cursor:grabbing}\n        .ll-gl:focus-visible{outline-offset:-6px}\n        .ll-lpad{position:absolute;left:clamp(1rem,3.5vw,3rem);top:50%;transform:translateY(-50%);z-index:2;width:min(400px,calc(100% - 2rem));padding:clamp(1.3rem,2.4vw,1.9rem);background:rgba(15,11,8,.92);border:1px solid var(--line);box-shadow:0 40px 80px -40px rgba(0,0,0,.9)}\n        .ll-read{display:grid;grid-template-columns:repeat(4,1fr);gap:.6rem;margin:1.2rem 0 0;padding:1rem 0 0;border-top:1px solid var(--line)}\n        .ll-read div{display:grid;gap:.3rem}\n        .ll-read dt{font-size:.8rem;color:var(--ash-2)}\n        .ll-read dd{margin:0;font-family:var(--mono);font-size:1.02rem;font-weight:500;color:var(--ash);font-variant-numeric:tabular-nums;white-space:nowrap}\n        .ll-lbar{height:2px;background:rgba(236,224,200,.16);margin-top:1rem;overflow:hidden}\n        .ll-lbar i{display:block;height:100%;background:var(--oxblood-2);transform-origin:left;transform:scaleX(0)}\n        .ll-steps{list-style:none;margin:1rem 0 0;padding:0;display:grid;gap:.15rem}\n        .ll-steps li{display:flex;gap:.8rem;align-items:baseline;padding:.35rem 0;font-size:.92rem;color:var(--ash-2);transition:color .4s}\n        .ll-steps li span{font-family:var(--mono);font-size:.78rem;color:var(--ash-2)}\n        .ll-steps li.on{color:var(--ash)}\n        .ll-steps li.on span{color:var(--lamp)}\n        .ll-hint{margin:1rem 0 0;font-size:.86rem;line-height:1.55;color:var(--ash-2)}\n        .ll-status{position:absolute;right:clamp(1rem,3.5vw,3rem);bottom:clamp(1rem,3vh,2rem);z-index:2;max-width:min(360px,calc(100% - 2rem));padding:.7rem .95rem;background:rgba(15,11,8,.92);border:1px solid var(--line);font-size:.86rem;color:var(--ash-2);transition:opacity .6s}\n        .ll-status.done{opacity:0}\n\n        .ll-sec{position:relative;padding:clamp(5rem,12vh,8rem) clamp(1rem,4vw,3.5rem);border-top:1px solid var(--line)}\n        .ll-shelf{background:var(--bark)}\n        .ll-shelf-grid{display:grid;grid-template-columns:1.25fr 1fr;gap:clamp(1.6rem,4vw,4rem);max-width:1280px;margin:0 auto;align-items:start}\n        .ll-shelf-head{max-width:1280px;margin:0 auto clamp(2rem,5vh,3rem)}\n        .ll-shelf-head .ll-h2{font-size:clamp(2.2rem,4.6vw,4rem)}\n        .ll-shelf-head .ll-p{max-width:56ch;margin-top:1rem}\n        .ll-turn{position:relative;aspect-ratio:4/3;background:var(--black);border:1px solid var(--line);overflow:hidden}\n        .ll-turn .ll-fallback{background-position:50% 50%}\n        .ll-turn-bar{display:flex;justify-content:space-between;align-items:center;gap:1rem;margin-top:.9rem}\n        .ll-turn-bar p{margin:0;font-size:.86rem;color:var(--ash-2)}\n        .ll-turn-bar div{display:flex;gap:.5rem}\n        .ll-list{list-style:none;margin:0;padding:0;border-top:1px solid var(--line)}\n        .ll-list button{width:100%;display:grid;grid-template-columns:2.2rem 1fr auto;gap:.8rem;align-items:baseline;text-align:left;background:transparent;border:0;border-bottom:1px solid var(--line);color:var(--ash-2);padding:1rem .2rem;cursor:pointer;font:inherit;transition:color .3s}\n        .ll-list button span{font-family:var(--mono);font-size:.8rem}\n        .ll-list button b{font-family:var(--serif);font-weight:400;font-size:1.3rem;color:inherit}\n        .ll-list button em{font-style:normal;font-family:var(--mono);font-size:.8rem}\n        .ll-list button:hover{color:var(--ash)}\n        .ll-list button[aria-pressed=\"true\"]{color:var(--ash)}\n        .ll-list button[aria-pressed=\"true\"] span{color:var(--lamp)}\n        .ll-spec{margin:1.6rem 0 0;display:grid;grid-template-columns:1fr 1fr;gap:0 1.2rem}\n        .ll-spec div{padding:.85rem 0;border-top:1px solid var(--line)}\n        .ll-spec dt{font-size:.8rem;color:var(--ash-2)}\n        .ll-spec dd{margin:.35rem 0 0;font-size:1rem;color:var(--ash)}\n\n        .ll-commission{min-height:100vh;min-height:100svh;display:flex;align-items:center;justify-content:flex-end;overflow:hidden;background:var(--black)}\n        .ll-loop{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:40% 50%}\n        .ll-commission .ll-scrim{background:linear-gradient(90deg,rgba(15,11,8,.25),rgba(15,11,8,.7) 60%,rgba(15,11,8,.85))}\n        .ll-form{position:relative;z-index:2;width:min(520px,100%);padding:clamp(1.4rem,3vw,2.2rem);background:rgba(15,11,8,.93);border:1px solid var(--line);box-shadow:0 40px 80px -40px rgba(0,0,0,.9)}\n        .ll-field{border:0;margin:1.2rem 0 0;padding:0}\n        .ll-field legend,.ll-label{display:block;font-size:.84rem;color:var(--ash-2);margin-bottom:.55rem;padding:0}\n        .ll-opts{display:flex;flex-wrap:wrap;gap:.45rem}\n        .ll-opt{background:transparent;border:1px solid rgba(236,224,200,.24);color:var(--ash);padding:.6rem .8rem;font:inherit;font-size:.9rem;cursor:pointer;transition:border-color .3s,background .3s}\n        .ll-opt:hover{border-color:rgba(232,179,102,.6)}\n        .ll-opt[aria-pressed=\"true\"]{border-color:var(--lamp);background:rgba(232,179,102,.12)}\n        .ll-range{display:flex;align-items:center;gap:1rem}\n        .ll-range input{flex:1;accent-color:var(--lamp)}\n        .ll-range output{font-family:var(--mono);font-size:1rem;min-width:5.5rem;text-align:right}\n        .ll-inputs{display:grid;grid-template-columns:1fr 1fr;gap:.7rem;margin-top:1.2rem}\n        .ll-inputs input{width:100%;box-sizing:border-box;background:var(--bark);border:1px solid rgba(236,224,200,.24);color:var(--ash);padding:.75rem .8rem;font:inherit;font-size:.95rem}\n        .ll-inputs input::placeholder{color:var(--ash-2)}\n        .ll-quote{display:flex;justify-content:space-between;align-items:flex-end;gap:1rem;margin:1.4rem 0 1.2rem;padding-top:1.1rem;border-top:1px solid var(--line)}\n        .ll-quote b{font-family:var(--mono);font-weight:500;font-size:clamp(2rem,4vw,2.8rem);line-height:1;font-variant-numeric:tabular-nums}\n        .ll-quote span{font-size:.86rem;color:var(--ash-2);text-align:right;line-height:1.55}\n        .ll-form .ll-btn{width:100%;padding:1rem}\n        .ll-sent{margin:.9rem 0 0;min-height:1.4em;font-size:.88rem;color:var(--lamp)}\n\n        .ll-foot{background:var(--black);padding:clamp(4rem,10vh,6rem) clamp(1rem,4vw,3.5rem) clamp(6rem,12vh,8rem);border-top:1px solid var(--line)}\n        .ll-foot-mark{max-width:1280px;margin:0 auto;font-family:var(--serif);font-size:clamp(3.2rem,12.5vw,11rem);line-height:.9;letter-spacing:-.03em;color:var(--ash)}\n        .ll-foot-mark i{font-style:normal;color:var(--lamp)}\n        .ll-foot-row{max-width:1280px;margin:2.4rem auto 0;display:flex;flex-wrap:wrap;justify-content:space-between;gap:1rem 2rem;font-size:.9rem;color:var(--ash-2)}\n        .ll-foot-row a{color:var(--ash-2);text-decoration:none;border-bottom:1px solid rgba(232,179,102,.4);padding-bottom:2px}\n        .ll-foot-row a:hover,.ll-foot-row a:focus-visible{color:var(--lamp)}\n\n        @media(max-width:760px){\n          .ll-ch,.ll-ch.right{justify-content:center;min-height:120vh}\n          .ll-hero{min-height:100svh;padding-bottom:4.5rem}\n          .ll-hud{left:1rem;right:1rem;top:4.6rem;bottom:auto;width:auto;padding:.7rem .9rem;gap:.4rem}\n          .ll-hud-row b{font-size:1.15rem}\n          .ll-stage video{object-position:62% 50%}\n          .ll-canvas{inset:0 0 50% 0}\n          .ll-lpad{top:auto;bottom:0;left:0;right:0;transform:none;width:auto;max-height:50%;overflow:auto;padding:.9rem 1rem 1rem;border-left:0;border-right:0;border-bottom:0}\n          .ll-lpad .ll-h2{font-size:1.45rem}\n          .ll-lpad .ll-date{margin:.6rem 0 .7rem;padding-top:.5rem}\n          .ll-lpad .ll-p{font-size:.95rem;line-height:1.5}\n          .ll-read{gap:.4rem;margin-top:.8rem;padding-top:.7rem}\n          .ll-read dd{font-size:.9rem}\n          .ll-steps{display:flex;flex-wrap:wrap;gap:0 1rem;margin-top:.6rem}\n          .ll-steps li{padding:.2rem 0;font-size:.86rem;gap:.4rem}\n          .ll-hint{margin-top:.5rem;font-size:.8rem}\n          .ll-status{top:4.6rem;bottom:auto;right:1rem;left:1rem;max-width:none}\n          .ll-shelf-grid{grid-template-columns:1fr}\n          .ll-inputs{grid-template-columns:1fr}\n          .ll-commission{justify-content:center}\n        }\n        @media(prefers-reduced-motion:reduce){\n          .ll-page *{animation:none!important;transition:none!important}\n          .js [data-reveal]{transform:none!important}\n        }\n      `}</style>\n\n      <a className=\"ll-skip\" href=\"#lathe\">Skip to the lathe</a>\n\n      <nav className=\"ll-nav\" data-nav aria-label=\"Lathe and Lacquer\">\n        <a className=\"ll-mark\" href=\"#top\">\n          <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n            <path d=\"M3 9h18c0 6-4 10-9 10S3 15 3 9Z\" fill=\"#6d1a1f\" stroke=\"#e8b366\" strokeWidth=\"1.2\" />\n            <path d=\"M2 9h20\" stroke=\"#e8b366\" strokeWidth=\"1.2\" />\n          </svg>\n          Lathe <i>&amp;</i> Lacquer\n        </a>\n        <ul className=\"ll-links\">\n          <li><a href=\"#lathe\">The lathe</a></li>\n          <li><a href=\"#pieces\">Pieces</a></li>\n          <li><a href=\"#commission\">Commissions</a></li>\n        </ul>\n        <a className=\"ll-btn\" href=\"#commission\">Commission a bowl</a>\n      </nav>\n\n      <section className=\"ll-film\" data-film aria-label=\"The cut, on film\">\n        <div className=\"ll-stage\">\n          <video ref={filmRef} muted playsInline preload=\"metadata\" poster={POSTER} aria-hidden=\"true\" tabIndex={-1} />\n          <div className=\"ll-scrim\" aria-hidden=\"true\" />\n          <div className=\"ll-grain\" aria-hidden=\"true\" />\n          <div className=\"ll-hud\" data-hud aria-hidden=\"true\">\n            <div className=\"ll-hud-row\">\n              <span>Film, pass</span>\n              <b><span data-pass>01</span><small>/ 12</small></b>\n            </div>\n            <div className=\"ll-track\"><i data-bar /></div>\n            <div className=\"ll-hud-row\">\n              <span>Gouge advancing</span>\n              <span className=\"ll-num\" data-tc>0.0 s</span>\n            </div>\n          </div>\n        </div>\n\n        <div className=\"ll-chapters\" data-chapters>\n          <div className=\"ll-ch ll-hero\" id=\"top\" data-t=\"0\">\n            <div className=\"ll-herocopy\" data-hero-copy>\n              <h1 className=\"ll-h1\">The bowl is in the blank. <em>Scroll cuts it out.</em></h1>\n              <p className=\"ll-lede\">A walnut blank on a cast-iron lathe, one work lamp and one gouge. Scroll drives the cut, drag walks round the piece, and the last pass is a coat of oxblood lacquer.</p>\n              <div className=\"ll-herorow\">\n                <span className=\"ll-cue\"><i aria-hidden=\"true\" />Scroll to start the cut</span>\n              </div>\n              <p className=\"ll-meta\">Bay 3, Tannery Yard. 6 commissions a month.</p>\n            </div>\n          </div>\n\n          <div className=\"ll-ch\" data-t=\"3.3\">\n            <article className=\"ll-card\" data-stagger>\n              <h2 className=\"ll-h2\" data-reveal>Walnut, <em>dried for 3 years.</em></h2>\n              <p className=\"ll-date\" data-reveal><span>01 · The blank</span><span>300 mm across</span></p>\n              <p className=\"ll-p\" data-reveal>Every blank is cut from one storm-felled tree, sealed at the ends and stacked under the bench until the moisture meter reads 12%. Then it goes on the chuck and the lamp comes down.</p>\n              <div className=\"ll-stats\" data-reveal>\n                <div className=\"ll-stat\"><b>300</b><span>mm across</span></div>\n                <div className=\"ll-stat\"><b>3</b><span>years drying</span></div>\n                <div className=\"ll-stat\"><b>12%</b><span>moisture</span></div>\n              </div>\n            </article>\n          </div>\n\n          <div className=\"ll-ch right\" data-t=\"6.6\">\n            <article className=\"ll-card\" data-stagger>\n              <h2 className=\"ll-h2\" data-reveal>The gouge <em>rides its bevel.</em></h2>\n              <p className=\"ll-date\" data-reveal><span>02 · The cut</span><span>800 rpm</span></p>\n              <p className=\"ll-p\" data-reveal>The edge never digs. The bevel rubs behind it and the curl lifts off clean, so the wall comes out smooth enough to finish without sanding past 240 grit.</p>\n              <div className=\"ll-stats\" data-reveal>\n                <div className=\"ll-stat\"><b>12</b><span>passes</span></div>\n                <div className=\"ll-stat\"><b>6</b><span>mm wall</span></div>\n                <div className=\"ll-stat\"><b>240</b><span>grit, last</span></div>\n              </div>\n            </article>\n          </div>\n\n          <div className=\"ll-ch\" data-t=\"9.4\">\n            <article className=\"ll-card\" data-stagger>\n              <h2 className=\"ll-h2\" data-reveal>Now take <em>the gouge yourself.</em></h2>\n              <p className=\"ll-date\" data-reveal><span>03 · Hand-over</span><span>live model below</span></p>\n              <p className=\"ll-p\" data-reveal>Below, the same blank as a live model. Scroll carves the profile pass by pass, drag walks round it, and the arrow keys do the same from a keyboard.</p>\n              <a className=\"ll-btn\" href=\"#lathe\" data-reveal>Go to the lathe</a>\n            </article>\n          </div>\n        </div>\n      </section>\n\n      <section className=\"ll-lathe\" id=\"lathe\" data-lathe aria-labelledby=\"ll-lathe-h\">\n        <div className=\"ll-lstage\">\n          <div className=\"ll-canvas\">\n            <div className=\"ll-fallback\" role=\"img\" aria-label=\"A hollowed walnut bowl on the lathe under a work lamp, shavings in its floor\" />\n            {webgl && latheNear ? (\n              <div\n                className={`ll-gl${latheReady ? \" on\" : \"\"}`}\n                tabIndex={0}\n                role=\"group\"\n                aria-label=\"Live lathe model. Drag, or use the arrow keys, to walk round the bowl.\"\n                onKeyDown={(e) => orbitKeys(e, \"lathe\")}\n              >\n                <LatheScene progressRef={progressRef} apiRef={latheApi} still={reduce} running={latheLive} onReady={() => setLatheReady(true)} />\n              </div>\n            ) : null}\n          </div>\n\n          <div className=\"ll-lpad\">\n            <h2 className=\"ll-h2\" id=\"ll-lathe-h\">Carve it. <em>Then coat it.</em></h2>\n            <p className=\"ll-date\"><span>04 · The lathe, live</span><span>three.js</span></p>\n            <p className=\"ll-p\">The same walnut blank, built in code. Scroll pushes the gouge in pass by pass until the wall is 6 mm, then oxblood lacquer spreads across the grain.</p>\n            <dl className=\"ll-read\">\n              <div><dt>Pass</dt><dd data-r-pass>01 / 12</dd></div>\n              <div><dt>Wall</dt><dd data-r-wall>solid</dd></div>\n              <div><dt>Depth</dt><dd data-r-depth>0 mm</dd></div>\n              <div><dt>Lacquer</dt><dd data-r-coat>0%</dd></div>\n            </dl>\n            <div className=\"ll-lbar\" aria-hidden=\"true\"><i data-l-bar /></div>\n            <ol className=\"ll-steps\">\n              <li data-step className=\"on\"><span>01</span>Rough out the outside</li>\n              <li data-step><span>02</span>Hollow the inside</li>\n              <li data-step><span>03</span>Lacquer, 4 coats</li>\n            </ol>\n            <p className=\"ll-hint\">Drag to walk round the bowl. Focus the lathe and the arrow keys do the same.</p>\n          </div>\n\n          <p className={`ll-status${webgl && latheReady ? \" done\" : \"\"}`} role=\"status\">\n            {!webgl\n              ? \"WebGL is off in this browser, so this is a photograph of a finished bowl.\"\n              : latheReady\n                ? \"Lathe ready.\"\n                : \"Loading the lathe: three.js, then the blank and its walnut shader.\"}\n          </p>\n        </div>\n      </section>\n\n      <section className=\"ll-sec ll-shelf\" id=\"pieces\" aria-labelledby=\"ll-pieces-h\">\n        <div className=\"ll-shelf-head\" data-stagger>\n          <h2 className=\"ll-h2\" id=\"ll-pieces-h\" data-reveal>4 pieces <em>that left the shop.</em></h2>\n          <p className=\"ll-date\" data-reveal><span>05 · The shelf</span><span>{String(piece + 1).padStart(2, \"0\")} / 04</span></p>\n          <p className=\"ll-p\" data-reveal>One at a time on a slow turntable, rebuilt from the same profiles they were turned to. Drag to look inside.</p>\n        </div>\n        <div className=\"ll-shelf-grid\">\n          <div>\n            <div className=\"ll-turn\" data-shelf>\n              <div className=\"ll-fallback\" role=\"img\" aria-label={pc.alt} style={{ backgroundImage: `url(${pc.photo})` }} />\n              {webgl && shelfNear ? (\n                <div\n                  className={`ll-gl${shelfReady ? \" on\" : \"\"}`}\n                  tabIndex={0}\n                  role=\"group\"\n                  aria-label={`${pc.name} on the turntable. Drag, or use the arrow keys, to orbit it.`}\n                  onKeyDown={(e) => orbitKeys(e, \"shelf\")}\n                >\n                  <ShelfScene pieces={PIECES} first={piece} apiRef={shelfApi} still={reduce} running={shelfLive} onReady={() => setShelfReady(true)} />\n                </div>\n              ) : null}\n            </div>\n            <div className=\"ll-turn-bar\">\n              <p>{webgl ? \"Turntable, 1 turn in 20 s\" : \"Photographed on the lathe\"}</p>\n              <div>\n                <button type=\"button\" className=\"ll-ghost\" aria-label=\"Previous piece\" onClick={() => choosePiece(piece - 1)}>Prev</button>\n                <button type=\"button\" className=\"ll-ghost\" aria-label=\"Next piece\" onClick={() => choosePiece(piece + 1)}>Next</button>\n              </div>\n            </div>\n          </div>\n          <div>\n            <ol className=\"ll-list\" aria-label=\"Pieces\">\n              {PIECES.map((p, i) => (\n                <li key={p.name}>\n                  <button type=\"button\" aria-pressed={piece === i} onClick={() => choosePiece(i)}>\n                    <span>{String(i + 1).padStart(2, \"0\")}</span>\n                    <b>{p.name}</b>\n                    <em>{p.mm} mm</em>\n                  </button>\n                </li>\n              ))}\n            </ol>\n            <dl className=\"ll-spec\" aria-live=\"polite\">\n              <div><dt>Wood</dt><dd>{pc.woodName}</dd></div>\n              <div><dt>Diameter</dt><dd className=\"ll-num\">{pc.mm} mm, {pc.tall} mm tall</dd></div>\n              <div><dt>Finish</dt><dd>{pc.finish}</dd></div>\n              <div><dt>On the lathe</dt><dd className=\"ll-num\">{pc.time}</dd></div>\n            </dl>\n          </div>\n        </div>\n      </section>\n\n      <section className=\"ll-sec ll-commission\" id=\"commission\" data-commission aria-labelledby=\"ll-com-h\">\n        <video ref={loopRef} className=\"ll-loop\" muted loop playsInline preload=\"none\" poster={POSTER} aria-hidden=\"true\" tabIndex={-1} />\n        <div className=\"ll-scrim\" aria-hidden=\"true\" />\n        <form\n          className=\"ll-form\"\n          onSubmit={(e) => {\n            e.preventDefault();\n            setSent(true);\n          }}\n        >\n          <h2 className=\"ll-h2\" id=\"ll-com-h\">Commission <em>a bowl.</em></h2>\n          <p className=\"ll-date\"><span>06 · Commissions</span><span>6 a month</span></p>\n          <p className=\"ll-p\">Turned in the order they arrive. Pick the wood, the size and the finish; the quote follows you.</p>\n\n          <fieldset className=\"ll-field\">\n            <legend>Wood</legend>\n            <div className=\"ll-opts\">\n              {WOOD_OPTIONS.map((w, i) => (\n                <button key={w.id} type=\"button\" className=\"ll-opt\" aria-pressed={wood === i} onClick={() => { setWood(i); setSent(false); }}>{w.label}</button>\n              ))}\n            </div>\n          </fieldset>\n\n          <div className=\"ll-field\">\n            <label className=\"ll-label\" htmlFor=\"ll-dia\">Diameter</label>\n            <div className=\"ll-range\">\n              <input id=\"ll-dia\" type=\"range\" min={160} max={400} step={10} value={diameter} onChange={(e) => { setDiameter(+e.target.value); setSent(false); }} />\n              <output htmlFor=\"ll-dia\">{diameter} mm</output>\n            </div>\n          </div>\n\n          <fieldset className=\"ll-field\">\n            <legend>Finish</legend>\n            <div className=\"ll-opts\">\n              {FINISH_OPTIONS.map((f, i) => (\n                <button key={f.id} type=\"button\" className=\"ll-opt\" aria-pressed={finish === i} onClick={() => { setFinish(i); setSent(false); }}>{f.label}</button>\n              ))}\n            </div>\n          </fieldset>\n\n          <div className=\"ll-inputs\">\n            <div>\n              <label className=\"ll-label\" htmlFor=\"ll-name\">Name</label>\n              <input id=\"ll-name\" name=\"name\" autoComplete=\"name\" placeholder=\"Your name\" required />\n            </div>\n            <div>\n              <label className=\"ll-label\" htmlFor=\"ll-mail\">Email</label>\n              <input id=\"ll-mail\" name=\"email\" type=\"email\" autoComplete=\"email\" placeholder=\"you@example.com\" required />\n            </div>\n          </div>\n\n          <div className=\"ll-quote\">\n            <b>£{price}</b>\n            <span>about {fmtTime(mins)} on the lathe<br />ready in {weeks} weeks</span>\n          </div>\n          <button type=\"submit\" className=\"ll-btn\">Ask for this bowl</button>\n          <p className=\"ll-sent\" aria-live=\"polite\">{sent ? `Noted: ${WOOD_OPTIONS[wood].label.toLowerCase()}, ${diameter} mm, ${fo.label.toLowerCase()}. A reply with a slot comes within 2 working days.` : \"\"}</p>\n        </form>\n      </section>\n\n      <footer className=\"ll-foot\">\n        <p className=\"ll-foot-mark\" aria-hidden=\"true\">Lathe <i>&amp;</i> Lacquer</p>\n        <div className=\"ll-foot-row\">\n          <span>Bay 3, Tannery Yard, Hebden Bridge</span>\n          <a href=\"#commission\">Commission a bowl</a>\n          <span>Open Thursday to Saturday, 10:00 to 17:00</span>\n        </div>\n      </footer>\n    </div>\n  );\n}\n"},{"path":"components/nightmarquee/lathe-lacquer/lathe-lacquer/media.ts","type":"registry:component","target":"components/nightmarquee/lathe-lacquer/lathe-lacquer/media.ts","content":"// Generated by scripts/drop/scaffold.mjs from drops/lathe-lacquer/drop.json. Do not edit; run the scaffold again.\nimport { mediaUrl } from \"../lib/media\";\n/* NightMarquee design \"Lathe & Lacquer\". Free for personal, portfolio, educational and non-commercial use; no republishing: nightmarquee.com/license */\nimport type { ShotFiles } from \"../lib/drop-media\";\n\nexport { pickVideo } from \"../lib/drop-media\";\n\n/** The 1920 poster frame, taken from the ambient loop. */\nexport const POSTER = \"https://media.nightmarquee.com/drops/lathe-lacquer/poster.jpg\";\n\n/**\n * Each video: `desktop` is the 1920 file, `mobile` the 1280 `-m` file and `xl` the 2560 `-xl`\n * file when the shot has them. In an effect, set a video's src to `pickVideo(SHOTS.<name>)`.\n */\nexport const SHOTS = {\n  hero: {\n    desktop: mediaUrl(\"/drops/lathe-lacquer/hero.mp4\"),\n    mobile: mediaUrl(\"/drops/lathe-lacquer/hero-m.mp4\"),\n  },\n  ambient: {\n    desktop: mediaUrl(\"/drops/lathe-lacquer/ambient.mp4\"),\n    mobile: mediaUrl(\"/drops/lathe-lacquer/ambient-m.mp4\"),\n  },\n} satisfies Record<string, ShotFiles>;\n"},{"path":"components/nightmarquee/lathe-lacquer/lathe-lacquer/scene.tsx","type":"registry:component","target":"components/nightmarquee/lathe-lacquer/lathe-lacquer/scene.tsx","content":"\"use client\";\n/* NightMarquee design \"Lathe & Lacquer\". Free for personal, portfolio, educational and non-commercial use; no republishing: nightmarquee.com/license */\n\n/* Lathe & Lacquer, the real-time part. Two small React Three Fiber canvases built\n   imperatively in onCreated: the lathe, where a LatheGeometry eases from blank to\n   bowl on scroll progress and a lacquer coat spreads across a procedural walnut\n   shader, and the shelf, one finished piece at a time on a slow turntable. Every\n   geometry is built in code; no models, no textures. Copy lives in demo.tsx. */\n\nimport { useEffect, useRef, type RefObject } from \"react\";\nimport { Canvas, useFrame, type RootState } from \"@react-three/fiber\";\nimport * as THREE from \"three\";\nimport { OrbitControls } from \"three/addons/controls/OrbitControls.js\";\n\nexport type LatheProgress = { carve: number; lacquer: number };\nexport type OrbitApi = { orbit: (dTheta: number, dPhi: number) => void; setPiece?: (i: number) => void };\n\ntype Pt = [number, number];\ntype Shape = { outer: (u: number) => Pt; inner: (v: number) => Pt; height: number };\n\nconst HALF = Math.PI / 2;\nconst clamp01 = (v: number) => Math.min(1, Math.max(0, v));\nconst smooth = (k: number) => k * k * (3 - 2 * k);\n\n/* Profiles in lathe units (1 unit = 150 mm): x is the radius, y runs from the foot to the rim. */\nexport const SHAPES: Shape[] = [\n  {\n    height: 0.9,\n    outer: (u) => [0.36 + 0.62 * Math.sin(u * HALF), 0.82 * (1 - Math.cos(u * HALF))],\n    inner: (v) => [0.92 * Math.cos(v * HALF), 0.82 - 0.7 * Math.sin(v * HALF)],\n  },\n  {\n    height: 1.05,\n    outer: (u) => [0.3 + 0.6 * Math.sin(u * HALF), 1.0 * (1 - Math.cos(u * HALF))],\n    inner: (v) => [0.84 * Math.cos(v * HALF), 1.0 - 0.88 * Math.sin(v * HALF)],\n  },\n  {\n    height: 0.32,\n    outer: (u) => [0.5 + 0.56 * Math.sin(u * HALF), 0.26 * (1 - Math.cos(u * HALF))],\n    inner: (v) => [1.0 * Math.cos(v * HALF), 0.26 - 0.17 * Math.sin(v * HALF)],\n  },\n  (() => {\n    const r = (u: number) => 0.2 + 0.08 * (1 - u) + 0.6 * Math.sin(Math.PI * Math.pow(u, 0.8));\n    return {\n      height: 1.5,\n      outer: (u: number): Pt => [r(u), 1.45 * u],\n      inner: (v: number): Pt => [Math.max(0.02, r(1 - v) - 0.06) * (v > 0.985 ? 0 : 1), Math.max(0.08, 1.45 * (1 - v))],\n    };\n  })(),\n];\n\n/* The blank: a 300 mm walnut cylinder 135 mm deep, walked in the same order as the bowl profile. */\nconst blankOuter = (u: number): Pt => {\n  const d = u * 1.54;\n  return d < 0.64 ? [0.36 + d, 0] : [1, d - 0.64];\n};\nconst blankInner = (v: number): Pt => [0.97 * (1 - v), 0.9];\n\nconst N = 30;\n\nfunction profile(shape: Shape, carve: number): THREE.Vector2[] {\n  const pts = [new THREE.Vector2(0, 0)];\n  /* 12 passes: the cut eases inside each pass and holds between them */\n  const c = carve * 12;\n  const pass = Math.floor(c);\n  const cq = carve >= 1 ? 1 : (pass + smooth(clamp01((c - pass) / 0.7))) / 12;\n  const outerK = clamp01(cq / 0.38);\n  const innerK = clamp01((cq - 0.3) / 0.7);\n  for (let i = 0; i <= N; i++) {\n    const u = i / N;\n    const [fr, fy] = shape.outer(u);\n    const [br, by] = blankOuter(u);\n    const k = smooth(clamp01(outerK * 1.4 - (1 - u) * 0.4));\n    pts.push(new THREE.Vector2(br + (fr - br) * k, by + (fy - by) * k));\n  }\n  for (let i = 0; i <= N; i++) {\n    const v = i / N;\n    const [fr, fy] = shape.inner(v);\n    const [br, by] = blankInner(v);\n    const k = smooth(clamp01(innerK * 1.5 - v * 0.5));\n    const r = br + (fr - br) * k;\n    pts.push(new THREE.Vector2(i === N ? 0 : Math.max(0.004, r), by + (fy - by) * k));\n  }\n  return pts;\n}\n\nfunction finished(shape: Shape): THREE.Vector2[] {\n  const pts = [new THREE.Vector2(0, 0)];\n  for (let i = 0; i <= N; i++) pts.push(new THREE.Vector2(...shape.outer(i / N)));\n  for (let i = 0; i <= N; i++) {\n    const [r, y] = shape.inner(i / N);\n    pts.push(new THREE.Vector2(i === N ? 0 : Math.max(0.004, r), y));\n  }\n  return pts;\n}\n\n/* Where the gouge touches the profile at this carve: the outer wall first, rim to foot, then the hollow. */\nfunction cutPoint(pts: THREE.Vector2[], carve: number): { p: THREE.Vector2; inside: boolean } {\n  if (carve < 0.36) {\n    const u = 1 - carve / 0.36;\n    return { p: pts[1 + Math.round(u * N)], inside: false };\n  }\n  const v = clamp01((carve - 0.3) / 0.7);\n  return { p: pts[N + 2 + Math.min(N - 2, Math.round(v * N))], inside: true };\n}\n\ntype WoodLook = { dark: string; mid: string; lite: string; tint: string; gloss: number; scale: number };\n\nexport const WOODS: Record<\"walnut\" | \"ash\", Pick<WoodLook, \"dark\" | \"mid\" | \"lite\">> = {\n  walnut: { dark: \"#3a2213\", mid: \"#6b4429\", lite: \"#9a6a44\" },\n  ash: { dark: \"#9c8360\", mid: \"#cdb791\", lite: \"#e6d6b6\" },\n};\n\nconst NOISE = /* glsl */ `\nvarying vec3 vLocal;\nuniform float uLacquer;\nuniform float uHeight;\nuniform float uGloss;\nuniform float uScale;\nuniform vec3 uDark;\nuniform vec3 uMid;\nuniform vec3 uLite;\nuniform vec3 uTint;\nfloat hash(vec3 p){p=fract(p*.3183099+.1);p*=17.;return fract(p.x*p.y*p.z*(p.x+p.y+p.z));}\nfloat vnoise(vec3 x){vec3 i=floor(x);vec3 f=fract(x);f=f*f*(3.-2.*f);\n  return mix(mix(mix(hash(i),hash(i+vec3(1,0,0)),f.x),mix(hash(i+vec3(0,1,0)),hash(i+vec3(1,1,0)),f.x),f.y),\n             mix(mix(hash(i+vec3(0,0,1)),hash(i+vec3(1,0,1)),f.x),mix(hash(i+vec3(0,1,1)),hash(i+vec3(1,1,1)),f.x),f.y),f.z);}\nfloat fbm(vec3 p){float a=.5,s=0.;for(int i=0;i<4;i++){s+=a*vnoise(p);p*=2.03;a*=.5;}return s;}\n`;\n\nfunction woodMaterial(look: WoodLook, lacquer: number) {\n  const uniforms = {\n    uLacquer: { value: lacquer },\n    uHeight: { value: 1 },\n    uGloss: { value: look.gloss },\n    uScale: { value: look.scale },\n    uDark: { value: new THREE.Color(look.dark) },\n    uMid: { value: new THREE.Color(look.mid) },\n    uLite: { value: new THREE.Color(look.lite) },\n    uTint: { value: new THREE.Color(look.tint) },\n  };\n  const mat = new THREE.MeshPhysicalMaterial({\n    color: 0xffffff,\n    roughness: 0.74,\n    metalness: 0,\n    clearcoat: 1,\n    clearcoatRoughness: 0.14,\n    side: THREE.DoubleSide,\n  });\n  mat.onBeforeCompile = (shader) => {\n    Object.assign(shader.uniforms, uniforms);\n    shader.vertexShader = shader.vertexShader\n      .replace(\"#include <common>\", \"#include <common>\\nvarying vec3 vLocal;\")\n      .replace(\"#include <begin_vertex>\", \"#include <begin_vertex>\\nvLocal = position;\");\n    shader.fragmentShader = shader.fragmentShader\n      .replace(\"#include <common>\", `#include <common>\\n${NOISE}`)\n      .replace(\n        \"#include <color_fragment>\",\n        `#include <color_fragment>\n        vec3 lp = vLocal * uScale;\n        float n = fbm(lp * vec3(2.6, 7.0, 2.6));\n        float ring = length(vec2(lp.x, lp.y * .32 + .7)) + n * .09;\n        float g = pow(.5 + .5 * sin(ring * 64.), 2.6);\n        float fleck = smoothstep(.62, .92, vnoise(lp * vec3(36., 3., 36.)));\n        vec3 wood = mix(uMid, uDark, g * .85);\n        wood = mix(wood, uLite, n * .45 + fleck * .18);\n        float reach = uLacquer * 1.14;\n        float across = 1. - vLocal.y / uHeight;\n        float coat = 1. - smoothstep(reach - .07, reach, across);\n        vec3 coated = wood * mix(vec3(1.), uTint, .55) * 1.2;\n        diffuseColor.rgb = mix(wood, coated, coat);`,\n      )\n      .replace(\n        \"#include <roughnessmap_fragment>\",\n        \"float roughnessFactor = mix(roughness, uGloss, coat);\",\n      )\n      .replace(\n        \"#include <lights_physical_fragment>\",\n        \"#include <lights_physical_fragment>\\nmaterial.clearcoat *= coat * step(uGloss, .3);\",\n      );\n  };\n  return { mat, uniforms };\n}\n\nfunction iron(color = \"#2b2622\") {\n  return new THREE.MeshStandardMaterial({ color, roughness: 0.78, metalness: 0.55 });\n}\n\nfunction workshop(scene: THREE.Scene, target: THREE.Vector3, lampAt: THREE.Vector3) {\n  scene.background = new THREE.Color(\"#0f0b08\");\n  scene.fog = new THREE.Fog(\"#0f0b08\", 9, 16);\n  scene.add(new THREE.HemisphereLight(\"#8a6340\", \"#0a0705\", 0.7));\n  const fill = new THREE.DirectionalLight(\"#f0d6b0\", 0.45);\n  fill.position.set(0.5, 1.2, 5);\n  scene.add(fill);\n  const lamp = new THREE.SpotLight(\"#ffd29a\", 70, 16, 0.62, 0.65, 2);\n  lamp.position.copy(lampAt);\n  lamp.target.position.copy(target);\n  lamp.castShadow = true;\n  lamp.shadow.mapSize.set(1024, 1024);\n  lamp.shadow.bias = -0.0004;\n  scene.add(lamp, lamp.target);\n  const rim = new THREE.DirectionalLight(\"#c9b59a\", 0.35);\n  rim.position.set(3, 2, -3);\n  scene.add(rim);\n  const wall = new THREE.Mesh(new THREE.PlaneGeometry(14, 7), new THREE.MeshStandardMaterial({ color: \"#1d140d\", roughness: 0.95 }));\n  wall.position.set(0, 0.6, -2.4);\n  wall.receiveShadow = true;\n  scene.add(wall);\n  /* the pegboard: ash handles hanging in a row */\n  const handles = new THREE.InstancedMesh(\n    new THREE.CylinderGeometry(0.05, 0.065, 0.62, 10),\n    new THREE.MeshStandardMaterial({ color: \"#b8935f\", roughness: 0.6 }),\n    13,\n  );\n  const m = new THREE.Matrix4();\n  for (let i = 0; i < 13; i++) {\n    m.makeTranslation(-3 + i * 0.5, 1.75 + (i % 3) * 0.04, -2.3);\n    handles.setMatrixAt(i, m);\n  }\n  scene.add(handles);\n}\n\nfunction controls(camera: THREE.Camera, el: HTMLElement, target: THREE.Vector3, minPolar: number, maxPolar: number, invalidate: () => void) {\n  const c = new OrbitControls(camera, el);\n  c.target.copy(target);\n  c.enableDamping = true;\n  c.dampingFactor = 0.07;\n  c.enableZoom = false;\n  c.enablePan = false;\n  c.minPolarAngle = minPolar;\n  c.maxPolarAngle = maxPolar;\n  c.rotateSpeed = 0.6;\n  c.addEventListener(\"change\", invalidate);\n  c.update();\n  const sph = new THREE.Spherical();\n  const off = new THREE.Vector3();\n  const orbit = (dTheta: number, dPhi: number) => {\n    off.copy(camera.position).sub(c.target);\n    sph.setFromVector3(off);\n    sph.theta += dTheta;\n    sph.phi = Math.min(maxPolar, Math.max(minPolar, sph.phi + dPhi));\n    off.setFromSpherical(sph);\n    camera.position.copy(c.target).add(off);\n    c.update();\n    invalidate();\n  };\n  return { c, orbit };\n}\n\ntype Rig = { tick: (dt: number) => void; dispose: () => void };\n\nfunction disposeScene(scene: THREE.Scene) {\n  scene.traverse((o) => {\n    const mesh = o as THREE.Mesh;\n    if (mesh.geometry) mesh.geometry.dispose();\n    const mat = mesh.material as THREE.Material | THREE.Material[] | undefined;\n    if (Array.isArray(mat)) mat.forEach((x) => x.dispose());\n    else mat?.dispose();\n  });\n}\n\nfunction buildLathe(state: RootState, progressRef: RefObject<LatheProgress>, apiRef: RefObject<OrbitApi | null>, still: boolean): Rig {\n  const { scene, camera, gl, invalidate } = state;\n  const target = new THREE.Vector3(-0.55, -0.15, 0);\n  workshop(scene, target, new THREE.Vector3(1.5, 3.4, 2.6));\n  camera.position.set(3.7, 1.55, 4.1);\n\n  /* the lathe: bed, headstock and spindle, tailstock */\n  const bed = new THREE.Mesh(new THREE.BoxGeometry(5.6, 0.22, 0.8), iron());\n  bed.position.set(0, -1.32, 0);\n  const head = new THREE.Mesh(new THREE.BoxGeometry(1.0, 1.25, 0.95), iron(\"#302a25\"));\n  head.position.set(-2.05, -0.6, 0);\n  const chuck = new THREE.Mesh(new THREE.CylinderGeometry(0.3, 0.3, 0.42, 32), new THREE.MeshStandardMaterial({ color: \"#8f8b85\", metalness: 0.9, roughness: 0.32 }));\n  chuck.rotation.z = HALF;\n  chuck.position.set(-1.36, 0, 0);\n  const tail = new THREE.Mesh(new THREE.BoxGeometry(0.7, 0.95, 0.7), iron(\"#302a25\"));\n  tail.position.set(2.5, -0.75, 0);\n  const quill = new THREE.Mesh(new THREE.CylinderGeometry(0.09, 0.12, 0.6, 20), chuck.material);\n  quill.rotation.z = HALF;\n  quill.position.set(1.95, 0, 0);\n  for (const m of [bed, head, chuck, tail, quill]) {\n    m.castShadow = true;\n    m.receiveShadow = true;\n    scene.add(m);\n  }\n\n  /* the blank turns about the lathe axis: local y of the LatheGeometry points at the tailstock */\n  const shape = SHAPES[0];\n  const { mat, uniforms } = woodMaterial({ ...WOODS.walnut, tint: \"#a8323a\", gloss: 0.12, scale: 1 }, 0);\n  uniforms.uHeight.value = 0.92;\n  const axis = new THREE.Group();\n  axis.rotation.z = -HALF;\n  axis.position.set(-1.15, 0, 0);\n  const bowl = new THREE.Mesh(new THREE.LatheGeometry(profile(shape, 0), 96), mat);\n  bowl.castShadow = true;\n  bowl.receiveShadow = true;\n  axis.add(bowl);\n  scene.add(axis);\n\n  /* the gouge: tip at the origin, the tool running up +y, then aimed by quaternion */\n  const gouge = new THREE.Group();\n  const steel = new THREE.MeshStandardMaterial({ color: \"#b9b6b0\", metalness: 0.95, roughness: 0.25 });\n  const shaft = new THREE.Mesh(new THREE.CylinderGeometry(0.024, 0.024, 0.62, 12), steel);\n  shaft.position.y = 0.31;\n  const ferrule = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.05, 0.08, 16), steel);\n  ferrule.position.y = 0.66;\n  const handle = new THREE.Mesh(new THREE.CylinderGeometry(0.052, 0.068, 0.95, 16), new THREE.MeshStandardMaterial({ color: \"#c49a64\", roughness: 0.55 }));\n  handle.position.y = 1.17;\n  gouge.add(shaft, ferrule, handle);\n  gouge.traverse((o) => (o.castShadow = true));\n  const rest = new THREE.Mesh(new THREE.BoxGeometry(0.08, 0.06, 0.9), iron(\"#4a433c\"));\n  rest.castShadow = true;\n  scene.add(gouge, rest);\n  const up = new THREE.Vector3(0, 1, 0);\n  const fromFront = new THREE.Vector3(0.3, -0.12, 1).normalize();\n  const fromMouth = new THREE.Vector3(1, -0.08, 0.32).normalize();\n  const dir = fromFront.clone();\n  const tip = new THREE.Vector3();\n  const want = new THREE.Vector3();\n\n  /* shavings: curled walnut and ash piling on the bed as the cut goes on */\n  const COUNT = 170;\n  const curls = new THREE.InstancedMesh(new THREE.TorusGeometry(0.04, 0.009, 6, 14, Math.PI * 1.5), new THREE.MeshStandardMaterial({ roughness: 0.7 }), COUNT);\n  const mm = new THREE.Matrix4();\n  const q = new THREE.Quaternion();\n  const e = new THREE.Euler();\n  const col = new THREE.Color();\n  let seed = 7;\n  const rnd = () => ((seed = (seed * 16807) % 2147483647) / 2147483647);\n  for (let i = 0; i < COUNT; i++) {\n    e.set(rnd() * 6.3, rnd() * 6.3, rnd() * 6.3);\n    q.setFromEuler(e);\n    const s = 0.7 + rnd() * 0.8;\n    mm.compose(new THREE.Vector3(-1.3 + rnd() * 1.9, -1.19 + rnd() * 0.04, -0.34 + rnd() * 0.68), q, new THREE.Vector3(s, s, s));\n    curls.setMatrixAt(i, mm);\n    curls.setColorAt(i, col.set(rnd() > 0.35 ? \"#8a5a36\" : \"#d9c39a\"));\n  }\n  curls.count = 0;\n  curls.castShadow = true;\n  scene.add(curls);\n\n  const { c, orbit } = controls(camera, gl.domElement, target, 0.55, 1.62, invalidate);\n  apiRef.current = { orbit };\n\n  let shown = -1;\n  let spin = 0;\n  const tick = (dt: number) => {\n    const p = progressRef.current;\n    const carve = still ? 1 : p.carve;\n    const lacquer = still ? 1 : p.lacquer;\n    if (Math.abs(carve - shown) > 0.0012) {\n      shown = carve;\n      bowl.geometry.dispose();\n      bowl.geometry = new THREE.LatheGeometry(profile(shape, carve), 96);\n    }\n    uniforms.uLacquer.value = lacquer;\n    curls.count = Math.round(clamp01(carve) * COUNT);\n    if (!still) {\n      spin += Math.min(dt, 0.05) * (lacquer > 0 ? 1.1 : 3.2);\n      bowl.rotation.y = spin;\n    }\n\n    /* aim the gouge at the point being cut; it leaves the rest as the lacquer goes on */\n    const pts = (bowl.geometry as THREE.LatheGeometry).parameters.points;\n    const cut = cutPoint(pts, carve);\n    want.set(axis.position.x + cut.p.y, -0.01, cut.p.x + 0.012);\n    dir.lerp(cut.inside ? fromMouth : fromFront, still ? 1 : 0.08).normalize();\n    if (tip.lengthSq() === 0 || still) tip.copy(want);\n    else tip.lerp(want, 0.18);\n    const away = lacquer * 3.2;\n    gouge.position.copy(tip).addScaledVector(dir, away);\n    gouge.quaternion.setFromUnitVectors(up, dir);\n    gouge.visible = lacquer < 0.55;\n    rest.visible = gouge.visible;\n    /* the rest sits under the tool just outside the work: past the mouth for the hollow, in front of the wall otherwise */\n    const along = cut.inside ? Math.max(0.2, (axis.position.x + 1.05 - tip.x) / Math.max(0.2, dir.x)) : 0.2;\n    rest.position.copy(tip).addScaledVector(dir, along + away);\n    rest.position.y -= 0.07;\n    rest.rotation.y = cut.inside ? 0 : HALF;\n    c.update();\n  };\n  if (still) invalidate();\n  return {\n    tick,\n    dispose: () => {\n      c.dispose();\n      apiRef.current = null;\n      disposeScene(scene);\n    },\n  };\n}\n\nexport type Piece = { shape: number; wood: \"walnut\" | \"ash\"; tint: string; gloss: number };\n\nfunction buildShelf(state: RootState, pieces: Piece[], apiRef: RefObject<OrbitApi | null>, still: boolean, first: number): Rig {\n  const { scene, camera, gl, invalidate } = state;\n  const target = new THREE.Vector3(0, 0.45, 0);\n  workshop(scene, target, new THREE.Vector3(-2.3, 3.6, 2.6));\n  camera.position.set(0, 1.55, 3.6);\n\n  const table = new THREE.Mesh(new THREE.CylinderGeometry(1.35, 1.42, 0.1, 64), new THREE.MeshStandardMaterial({ color: \"#21170f\", roughness: 0.6 }));\n  table.position.y = -0.05;\n  table.receiveShadow = true;\n  const plinth = new THREE.Mesh(new THREE.CylinderGeometry(1.5, 1.55, 0.5, 64), iron(\"#161210\"));\n  plinth.position.y = -0.36;\n  scene.add(table, plinth);\n\n  const turn = new THREE.Group();\n  scene.add(turn);\n  let mesh: THREE.Mesh | null = null;\n  let grow = 1;\n  const setPiece = (i: number) => {\n    const pc = pieces[i];\n    if (mesh) {\n      turn.remove(mesh);\n      mesh.geometry.dispose();\n      (mesh.material as THREE.Material).dispose();\n    }\n    const shape = SHAPES[pc.shape];\n    const { mat, uniforms } = woodMaterial({ ...WOODS[pc.wood], tint: pc.tint, gloss: pc.gloss, scale: 1 }, 1);\n    uniforms.uHeight.value = shape.height;\n    mesh = new THREE.Mesh(new THREE.LatheGeometry(finished(shape), 96), mat);\n    mesh.castShadow = true;\n    mesh.receiveShadow = true;\n    turn.add(mesh);\n    grow = still ? 1 : 0;\n    invalidate();\n  };\n  setPiece(first);\n\n  const { c, orbit } = controls(camera, gl.domElement, target, 0.6, 1.42, invalidate);\n  apiRef.current = { orbit, setPiece };\n\n  const tick = (dt: number) => {\n    if (!still) {\n      turn.rotation.y += Math.min(dt, 0.05) * 0.32;\n      grow = Math.min(1, grow + dt * 1.6);\n    }\n    const s = 0.9 + 0.1 * (1 - Math.pow(1 - grow, 3));\n    turn.scale.setScalar(s);\n    c.update();\n  };\n  return {\n    tick,\n    dispose: () => {\n      c.dispose();\n      apiRef.current = null;\n      disposeScene(scene);\n    },\n  };\n}\n\nfunction Ticker({ rigRef }: { rigRef: RefObject<Rig | null> }) {\n  useFrame((_, dt) => rigRef.current?.tick(dt));\n  return null;\n}\n\ntype Common = {\n  apiRef: RefObject<OrbitApi | null>;\n  still: boolean;\n  running: boolean;\n  onReady: () => void;\n};\n\nfunction Stage({ build, still, running, onReady }: { build: (s: RootState) => Rig; still: boolean; running: boolean; onReady: () => void }) {\n  const rigRef = useRef<Rig | null>(null);\n  useEffect(() => () => rigRef.current?.dispose(), []);\n  return (\n    <Canvas\n      shadows\n      dpr={[1, 1.75]}\n      frameloop={still ? \"demand\" : running ? \"always\" : \"never\"}\n      camera={{ fov: 34, near: 0.1, far: 40 }}\n      gl={{ antialias: true, powerPreference: \"high-performance\" }}\n      onCreated={(s) => {\n        s.gl.toneMappingExposure = 1.15;\n        rigRef.current = build(s);\n        s.gl.domElement.style.touchAction = \"pan-y\";\n        requestAnimationFrame(() => requestAnimationFrame(onReady));\n      }}\n    >\n      <Ticker rigRef={rigRef} />\n    </Canvas>\n  );\n}\n\nexport function LatheScene({ progressRef, apiRef, still, running, onReady }: Common & { progressRef: RefObject<LatheProgress> }) {\n  return <Stage build={(s) => buildLathe(s, progressRef, apiRef, still)} still={still} running={running} onReady={onReady} />;\n}\n\nexport function ShelfScene({ pieces, first, apiRef, still, running, onReady }: Common & { pieces: Piece[]; first: number }) {\n  return <Stage build={(s) => buildShelf(s, pieces, apiRef, still, first)} still={still} running={running} onReady={onReady} />;\n}\n"},{"path":"components/nightmarquee/lathe-lacquer/lib/drop-media.ts","type":"registry:component","target":"components/nightmarquee/lathe-lacquer/lib/drop-media.ts","content":"/**\n * Which encode of a drop's video a screen should load. Every drop video has a 1920 wide file;\n * shots encoded since the phone files have a 1280 `-m` file, and upscaled shots a 2560 `-xl`.\n * The scaffold writes each demo's `media.ts` with these entries (scripts/drop/lib/scaffold.mjs).\n */\nexport interface ShotFiles {\n  readonly desktop: string;\n  readonly mobile?: string;\n  readonly xl?: string;\n}\n/* NightMarquee design \"Lathe & Lacquer\". Free for personal, portfolio, educational and non-commercial use; no republishing: nightmarquee.com/license */\n\n/** A share of the frame, 0 to 1, from the cut-out's alpha (scripts/drop/lib/cutout.mjs). */\nexport interface Box {\n  readonly x: number;\n  readonly y: number;\n  readonly width: number;\n  readonly height: number;\n}\n\n/** A journey keyframe: its 1920 still and the second it lands on in the hero film. */\nexport interface Keyframe {\n  readonly src: string;\n  readonly t: number;\n}\n\n/** A chapter's start and end on the hero film, in seconds. */\nexport interface Chapter {\n  readonly start: number;\n  readonly end: number;\n}\n\n/** A cut-out and where it sits in its keyframe, so it lines up with the film at any size. */\nexport interface Cutout {\n  readonly src: string;\n  readonly box: Box;\n}\n\nexport interface Viewport {\n  /** True when PHONE_QUERY matches. */\n  phone: boolean;\n  /** CSS pixels, `window.innerWidth`. */\n  width: number;\n  /** `window.devicePixelRatio`. */\n  dpr: number;\n}\n\nexport const PHONE_QUERY = \"(max-width: 767px)\";\n/** Device pixels across the viewport above which the 2560 file is worth its bytes. */\nexport const XL_MIN_DEVICE_PX = 2200;\n\n/** The `-m` file on a phone, else the `-xl` file on a large or dense screen, else the 1920 file. */\nexport function chooseVideo(shot: ShotFiles, view: Viewport): string {\n  if (view.phone) return shot.mobile ?? shot.desktop;\n  if (shot.xl && view.width * view.dpr > XL_MIN_DEVICE_PX) return shot.xl;\n  return shot.desktop;\n}\n\n/** The current window's viewport. Browser only: call it in an effect, never during render. */\nexport function currentViewport(): Viewport {\n  return {\n    phone: window.matchMedia(PHONE_QUERY).matches,\n    width: window.innerWidth,\n    dpr: window.devicePixelRatio || 1,\n  };\n}\n\n/** The file this screen should load. Call it in an effect and set the video's src from it. */\nexport function pickVideo(shot: ShotFiles): string {\n  return chooseVideo(shot, currentViewport());\n}\n"},{"path":"components/nightmarquee/lathe-lacquer/lib/media-manifest.json","type":"registry:component","target":"components/nightmarquee/lathe-lacquer/lib/media-manifest.json","content":"{\n  \"base\": \"https://media.nightmarquee.com\",\n  \"files\": {\n    \"/drops/lathe-lacquer/ambient-m.mp4\": \"drops/lathe-lacquer/ambient-m.a6e1465471.mp4\",\n    \"/drops/lathe-lacquer/ambient.mp4\": \"drops/lathe-lacquer/ambient.37a1cf6422.mp4\",\n    \"/drops/lathe-lacquer/hero-m.mp4\": \"drops/lathe-lacquer/hero-m.82ac0f8bb9.mp4\",\n    \"/drops/lathe-lacquer/hero.mp4\": \"drops/lathe-lacquer/hero.744d8523d3.mp4\",\n    \"/drops/lathe-lacquer/preview.mp4\": \"drops/lathe-lacquer/preview.ca75292427.mp4\",\n    \"/drops/lathe-lacquer/site-hover.mp4\": \"drops/lathe-lacquer/site-hover.a951b23c84.mp4\",\n    \"/drops/lathe-lacquer/site-preview.mp4\": \"drops/lathe-lacquer/site-preview.1e5d5f8430.mp4\"\n  }\n}\n"},{"path":"components/nightmarquee/lathe-lacquer/lib/media.ts","type":"registry:component","target":"components/nightmarquee/lathe-lacquer/lib/media.ts","content":"import manifest from \"./media-manifest.json\";\n/* NightMarquee design \"Lathe & Lacquer\". Free for personal, portfolio, educational and non-commercial use; no republishing: nightmarquee.com/license */\n\nconst files: Record<string, string> = manifest.files;\nconst ORIGIN = \"https://media.nightmarquee.com\";\n\n/**\n * Where a drop's file is served from. Video plays from the content-hashed copy\n * named in the manifest, any other drop file from media.nightmarquee.com. Set\n * NEXT_PUBLIC_FOOTAGE_LOCAL=1 once the footage pack is in public/drops/<slug>/\n * and every path resolves to the local copy instead.\n */\nexport function mediaUrl(path: string): string {\n  // A design that builds paths from a folder constant hands over the origin's absolute address.\n  const drop = path.startsWith(`${ORIGIN}/drops/`) ? path.slice(ORIGIN.length) : path;\n  if (process.env.NEXT_PUBLIC_FOOTAGE_LOCAL) return drop;\n  const key = files[drop];\n  if (key) return `${manifest.base}/${key}`;\n  return drop.startsWith(\"/drops/\") ? `${ORIGIN}${drop}` : drop;\n}\n"},{"path":"app/lathe-lacquer/page.tsx","type":"registry:page","target":"app/lathe-lacquer/page.tsx","content":"import type { Metadata } from \"next\";\n/* NightMarquee design \"Lathe & Lacquer\". Free for personal, portfolio, educational and non-commercial use; no republishing: nightmarquee.com/license */\nimport { Demo } from \"../../components/nightmarquee/lathe-lacquer/lathe-lacquer/demo\";\n\nexport const metadata: Metadata = {\n  title: \"Lathe & Lacquer\",\n  description: \"A filmed gouge cuts a spinning walnut blank as you scroll, then a live three.js lathe takes over: the bowl's profile carves itself pass by pass and a coat of oxblood lacquer spreads across the grain. Drag to walk round it, then orbit 4 finished pieces on a turntable and price a commission.\",\n};\n\nexport default function Page() {\n  return <Demo />;\n}\n"}],"docs":"The page is at app/lathe-lacquer/page.tsx.\nIts footage streams from media.nightmarquee.com.\nUse is covered by the NightMarquee licence: nightmarquee.com/license","meta":{"mappingVersion":3}}