{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"jacquard-hall","type":"registry:block","title":"Jacquard Hall","description":"A brick mill opens on a filmed orbit of a jacquard loom, scrubbed by scroll, with a punch card you draw into on the first screen. A React Three Fiber loom lifts its warp threads from your card and weaves the cloth pick by pick, then 4 house cloths turn on their bolts. The mill-visit form arrives with your card attached as a weave draft.","categories":["3d"],"dependencies":["@fontsource/brygada-1918@^5.3.0","@fontsource/red-hat-text@^5.3.0","@react-three/fiber@9.8.1","three@0.186.1"],"devDependencies":["@types/three@0.186.0"],"files":[{"path":"components/nightmarquee/jacquard-hall/jacquard-hall/demo.tsx","type":"registry:component","target":"components/nightmarquee/jacquard-hall/jacquard-hall/demo.tsx","content":"\"use client\";\n/* NightMarquee design \"Jacquard Hall\". 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/brygada-1918/400.css\";\nimport \"@fontsource/brygada-1918/500.css\";\nimport \"@fontsource/red-hat-text/400.css\";\nimport \"@fontsource/red-hat-text/500.css\";\n\n/* Jacquard Hall, a working mill. The punch card is the thread of the page:\n   drawn in the hero (kept on this device), read pick by pick by the WebGL\n   loom, and attached to the mill-visit request as a weave draft. One rAF loop\n   scrubs the filmed orbit of the loom against chapter anchors. */\n\nimport dynamic from \"next/dynamic\";\nimport { useEffect, useRef, useState, useSyncExternalStore, type FormEvent, type KeyboardEvent, type PointerEvent as ReactPointerEvent } from \"react\";\nimport { POSTER, SHOTS, pickVideo } from \"./media\";\nimport { BLANK_CARD, CLOTHS, COLS, HOUSE_CARD, PRESETS, ROWS, bit, draftCode, holes, isCard, liftedOn, paintCloth, type Card } from \"./weave\";\n\nconst LoomScene = dynamic(() => import(\"./scene\").then((m) => m.LoomScene), { ssr: false });\nconst BoltScene = dynamic(() => import(\"./scene\").then((m) => m.BoltScene), { ssr: false });\n\nconst STILL_HERO = \"https://media.nightmarquee.com/drops/jacquard-hall/still-2.jpg\";\nconst STILL_LOOM = \"https://media.nightmarquee.com/drops/jacquard-hall/still-3.jpg\";\nconst STILL_CLOTH = \"https://media.nightmarquee.com/drops/jacquard-hall/still-4.jpg\";\nconst DAYS = [\"Tuesday\", \"Wednesday\", \"Thursday\"];\n\n/* ---------- the card, kept on this device ---------- */\n\nconst KEY = \"jacquard-hall-card\";\nlet stored: Card | null = null;\nconst listeners = new Set<() => void>();\nconst readCard = (): Card => {\n  if (stored === null) {\n    let saved: string | null = null;\n    try {\n      saved = window.localStorage.getItem(KEY);\n    } catch {\n      saved = null;\n    }\n    stored = isCard(saved) ? saved : HOUSE_CARD;\n  }\n  return stored;\n};\nconst writeCard = (card: Card) => {\n  stored = card;\n  try {\n    window.localStorage.setItem(KEY, card);\n  } catch {\n    /* private mode: the card still lives for this visit */\n  }\n  listeners.forEach((l) => l());\n};\nconst subscribeCard = (l: () => void) => {\n  listeners.add(l);\n  return () => {\n    listeners.delete(l);\n  };\n};\nconst serverCard = () => HOUSE_CARD;\n\nconst REDUCE_Q = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduce = (l: () => void) => {\n  const mq = window.matchMedia(REDUCE_Q);\n  mq.addEventListener(\"change\", l);\n  return () => mq.removeEventListener(\"change\", l);\n};\nconst readReduce = () => window.matchMedia(REDUCE_Q).matches;\nconst serverReduce = () => false;\n\nconst setHole = (card: Card, i: number, on: boolean) => (card[i] === (on ? \"1\" : \"0\") ? card : card.slice(0, i) + (on ? \"1\" : \"0\") + card.slice(i + 1));\nconst pad2 = (n: number) => String(n).padStart(2, \"0\");\n\n/* ---------- pieces ---------- */\n\nfunction PunchCard({ card }: { card: Card }) {\n  const grid = useRef<HTMLDivElement>(null);\n  const stroke = useRef<{ on: boolean; last: number } | null>(null);\n  const [focus, setFocus] = useState(0);\n\n  const cellAt = (e: ReactPointerEvent) => {\n    const r = grid.current?.getBoundingClientRect();\n    if (!r) return -1;\n    const x = Math.floor(((e.clientX - r.left) / r.width) * COLS);\n    const y = Math.floor(((e.clientY - r.top) / r.height) * ROWS);\n    return x < 0 || y < 0 || x >= COLS || y >= ROWS ? -1 : y * COLS + x;\n  };\n  const onDown = (e: ReactPointerEvent<HTMLDivElement>) => {\n    if (e.button !== 0) return;\n    const i = cellAt(e);\n    if (i < 0) return;\n    e.preventDefault();\n    const on = card[i] !== \"1\";\n    stroke.current = { on, last: i };\n    writeCard(setHole(readCard(), i, on));\n    setFocus(i);\n    e.currentTarget.setPointerCapture(e.pointerId);\n  };\n  const onMove = (e: ReactPointerEvent<HTMLDivElement>) => {\n    const s = stroke.current;\n    if (!s) return;\n    const i = cellAt(e);\n    if (i < 0 || i === s.last) return;\n    s.last = i;\n    writeCard(setHole(readCard(), i, s.on));\n  };\n  const onUp = () => {\n    stroke.current = null;\n  };\n  const onKey = (e: KeyboardEvent<HTMLDivElement>) => {\n    const x = focus % COLS;\n    const y = Math.floor(focus / COLS);\n    let next = focus;\n    if (e.key === \"ArrowRight\") next = y * COLS + Math.min(COLS - 1, x + 1);\n    else if (e.key === \"ArrowLeft\") next = y * COLS + Math.max(0, x - 1);\n    else if (e.key === \"ArrowDown\") next = Math.min(ROWS - 1, y + 1) * COLS + x;\n    else if (e.key === \"ArrowUp\") next = Math.max(0, y - 1) * COLS + x;\n    else if (e.key === \"Home\") next = y * COLS;\n    else if (e.key === \"End\") next = y * COLS + COLS - 1;\n    else if (e.key === \" \" || e.key === \"Enter\") {\n      e.preventDefault();\n      writeCard(setHole(readCard(), focus, card[focus] !== \"1\"));\n      return;\n    } else return;\n    e.preventDefault();\n    setFocus(next);\n    grid.current?.querySelector<HTMLElement>(`[data-i=\"${next}\"]`)?.focus();\n  };\n\n  return (\n    <div\n      ref={grid}\n      className=\"jh-grid\"\n      role=\"grid\"\n      aria-label=\"Punch card, 16 picks by 24 hooks. A selected cell is a punched hole.\"\n      aria-rowcount={ROWS}\n      aria-colcount={COLS}\n      onPointerDown={onDown}\n      onPointerMove={onMove}\n      onPointerUp={onUp}\n      onPointerCancel={onUp}\n      onKeyDown={onKey}\n    >\n      {Array.from({ length: ROWS }, (_, y) => (\n        <div key={y} role=\"row\" className=\"jh-row\" aria-rowindex={y + 1}>\n          {Array.from({ length: COLS }, (_, x) => {\n            const i = y * COLS + x;\n            const on = bit(card, x, y);\n            return (\n              <span\n                key={x}\n                data-i={i}\n                role=\"gridcell\"\n                aria-colindex={x + 1}\n                aria-selected={on}\n                aria-label={`Pick ${y + 1}, hook ${x + 1}`}\n                tabIndex={i === focus ? 0 : -1}\n                className={on ? \"jh-cell on\" : \"jh-cell\"}\n                onFocus={() => setFocus(i)}\n              />\n            );\n          })}\n        </div>\n      ))}\n    </div>\n  );\n}\n\nfunction Swatch({ card, warp = \"#1f3a6b\", weft = \"#d9cfbd\", label }: { card: Card; warp?: string; weft?: string; label: string }) {\n  const ref = useRef<HTMLCanvasElement>(null);\n  useEffect(() => {\n    const c = ref.current;\n    const ctx = c?.getContext(\"2d\");\n    if (!c || !ctx) return;\n    paintCloth(ctx, (x, y) => bit(card, x % COLS, y % ROWS), COLS * 2, ROWS * 2, 6, warp, weft);\n  }, [card, warp, weft]);\n  return <canvas ref={ref} className=\"jh-swatch\" width={COLS * 12} height={ROWS * 12} role=\"img\" aria-label={label} />;\n}\n\nfunction DraftSheet({ card }: { card: Card }) {\n  const cells = [];\n  for (let y = 0; y < ROWS; y++) for (let x = 0; x < COLS; x++) if (bit(card, x, y)) cells.push(<rect key={y * COLS + x} x={x * 10 + 1.5} y={y * 10 + 1.5} width={7} height={7} rx={3.5} />);\n  return (\n    <svg className=\"jh-draft-svg\" viewBox={`0 0 ${COLS * 10} ${ROWS * 10}`} aria-hidden=\"true\">\n      <rect className=\"jh-draft-ground\" x={0} y={0} width={COLS * 10} height={ROWS * 10} />\n      {cells}\n    </svg>\n  );\n}\n\n/* ---------- the page ---------- */\n\nexport function Demo() {\n  const card = useSyncExternalStore(subscribeCard, readCard, serverCard);\n  const reduce = useSyncExternalStore(subscribeReduce, readReduce, serverReduce);\n  const code = draftCode(card);\n  const punched = holes(card);\n\n  const rootRef = useRef<HTMLDivElement>(null);\n  const loomRef = useRef<HTMLElement>(null);\n  const clothRef = useRef<HTMLElement>(null);\n  const visitRef = useRef<HTMLElement>(null);\n  const ambient = useRef<HTMLVideoElement>(null);\n\n  const [loomNear, setLoomNear] = useState(false);\n  const [loomIn, setLoomIn] = useState(false);\n  const [loomReady, setLoomReady] = useState(false);\n  const [paused, setPaused] = useState(false);\n  const [pick, setPick] = useState(0);\n\n  const [boltNear, setBoltNear] = useState(false);\n  const [boltIn, setBoltIn] = useState(false);\n  const [boltReady, setBoltReady] = useState(false);\n  const [cloth, setCloth] = useState(0);\n  const [close, setClose] = useState(false);\n  const [swatches, setSwatches] = useState<string[]>([]);\n\n  const [day, setDay] = useState(DAYS[1]);\n  const [sent, setSent] = useState<string | null>(null);\n\n  const c = CLOTHS[cloth];\n  const lifted = liftedOn(card, pick);\n\n  /* film scrub, ambient loop and the scene mounts */\n  useEffect(() => {\n    const root = rootRef.current;\n    if (!root) return;\n    const still = window.matchMedia(REDUCE_Q).matches;\n    root.classList.add(\"js\");\n\n    const film = root.querySelector<HTMLElement>(\"[data-film]\")!;\n    const wrap = root.querySelector<HTMLElement>(\"[data-chapters]\")!;\n    const video = root.querySelector<HTMLVideoElement>(\"[data-scrub-video]\")!;\n    const nav = root.querySelector<HTMLElement>(\"[data-nav]\")!;\n    const chapters = Array.from(root.querySelectorAll<HTMLElement>(\"[data-t]\"));\n    video.src = pickVideo(SHOTS.hero);\n\n    let dur = 10;\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    const lookup = (x: number) => {\n      if (x <= ax[0]) return at[0];\n      for (let i = 1; i < ax.length; i++) {\n        if (x <= ax[i]) return at[i - 1] + (at[i] - at[i - 1]) * ((x - ax[i - 1]) / (ax[i] - ax[i - 1] || 1));\n      }\n      return at[at.length - 1];\n    };\n    measure();\n    const ro = new ResizeObserver(measure);\n    ro.observe(wrap);\n    window.addEventListener(\"resize\", measure);\n\n    let ready = false;\n    const mark = () => {\n      ready = true;\n      video.classList.add(\"ready\");\n    };\n    const onMeta = () => {\n      if (video.duration) dur = video.duration;\n      measure();\n      if (still) video.currentTime = Math.min(5, video.duration / 2);\n    };\n    video.addEventListener(\"loadedmetadata\", onMeta);\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 (document.readyState === \"complete\") kick();\n    else window.addEventListener(\"load\", kick, { once: true });\n\n    /* scenes mount a viewport early and only run while on screen */\n    const near = new IntersectionObserver(\n      (es) =>\n        es.forEach((e) => {\n          if (!e.isIntersecting) return;\n          if (e.target === loomRef.current) setLoomNear(true);\n          if (e.target === clothRef.current) setBoltNear(true);\n        }),\n      { rootMargin: \"100% 0px\" },\n    );\n    const inView = new IntersectionObserver((es) =>\n      es.forEach((e) => {\n        if (e.target === loomRef.current) setLoomIn(e.isIntersecting);\n        if (e.target === clothRef.current) setBoltIn(e.isIntersecting);\n        if (e.target === visitRef.current) {\n          const v = ambient.current;\n          if (!v || still) return;\n          if (e.isIntersecting) v.play().catch(() => undefined);\n          else v.pause();\n        }\n      }),\n    );\n    for (const el of [loomRef.current, clothRef.current]) if (el) near.observe(el);\n    for (const el of [loomRef.current, clothRef.current, visitRef.current]) if (el) inView.observe(el);\n\n    const amb = ambient.current;\n    const parkAmbient = () => {\n      if (amb) amb.currentTime = Math.min(2.5, (amb.duration || 5) / 2);\n    };\n    if (amb) {\n      amb.src = pickVideo(SHOTS.ambient);\n      if (still) amb.addEventListener(\"loadedmetadata\", parkAmbient);\n    }\n\n    let st = 0;\n    let raf = 0;\n    const tick = () => {\n      const fr = film.getBoundingClientRect();\n      const s = -fr.top;\n      if (fr.bottom > 0) {\n        const target = lookup(Math.min(span, Math.max(0, s)));\n        st += (target - st) * 0.1;\n        if (Math.abs(target - st) < 0.0005) st = target;\n        if (ready && video.duration && !video.seeking) {\n          const vt = Math.min(video.duration - 0.05, st);\n          if (Math.abs(video.currentTime - vt) > 0.01) video.currentTime = vt;\n        }\n      }\n      nav.classList.toggle(\"solid\", s > 40);\n      raf = requestAnimationFrame(tick);\n    };\n    const onScroll = () => nav.classList.toggle(\"solid\", -film.getBoundingClientRect().top > 40);\n    if (still) window.addEventListener(\"scroll\", onScroll, { passive: true });\n    else raf = requestAnimationFrame(tick);\n\n    return () => {\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      near.disconnect();\n      inView.disconnect();\n      window.removeEventListener(\"resize\", measure);\n      window.removeEventListener(\"scroll\", onScroll);\n      video.removeEventListener(\"loadedmetadata\", onMeta);\n      amb?.removeEventListener(\"loadedmetadata\", parkAmbient);\n    };\n  }, []);\n\n  const onPick = (n: number) => setPick(n);\n  const toggleSwatch = (id: string) => setSwatches((s) => (s.includes(id) ? s.filter((x) => x !== id) : [...s, id]));\n  const submit = (e: FormEvent<HTMLFormElement>) => {\n    e.preventDefault();\n    setSent(code);\n  };\n\n  const loomFallback = <p className=\"jh-nogl\">WebGL is off in this browser, so the loom stays a photograph. The woven preview beside your card still follows every hole.</p>;\n  const boltFallback = <p className=\"jh-nogl\">WebGL is off in this browser. The swatch below is woven from the same card.</p>;\n\n  return (\n    <div className=\"jh-page\" ref={rootRef}>\n      <style>{`\n        .jh-page{\n          --steel:#111417;--steel-2:#191d21;--steel-3:#22282d;--linen:#d9cfbd;--linen-2:rgba(217,207,189,.8);\n          --cream:#efe6cf;--ink:#1b1a17;--ink-2:#4a463d;--indigo:#1f3a6b;--indigo-dk:#142645;--indigo-lt:#9db3e6;\n          --brick:#9a4a33;--line:rgba(217,207,189,.16);--ease:cubic-bezier(.16,1,.3,1);\n          background:var(--steel);color:var(--linen);overflow-x:clip;\n          font-family:'Red Hat Text',system-ui,sans-serif;font-weight:400;font-size:1rem;line-height:1.6;\n          -webkit-font-smoothing:antialiased;\n        }\n        .jh-page ::selection{background:var(--indigo-lt);color:var(--steel)}\n        .jh-page :focus-visible{outline:2px solid var(--indigo-lt);outline-offset:3px}\n        .jh-serif{font-family:'Brygada 1918',Georgia,serif}\n        .jh-fig{font-family:'Brygada 1918',Georgia,serif;font-variant-numeric:oldstyle-nums proportional-nums}\n        .jh-skip{position:absolute;left:1rem;top:-4rem;z-index:80;background:var(--cream);color:var(--ink);padding:.6rem 1rem;text-decoration:none;font-weight:500}\n        .jh-skip:focus{top:1rem}\n\n        .jh-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(1.1rem,3.5vw,3rem);background:linear-gradient(rgba(17,20,23,.82),rgba(17,20,23,0));transition:background-color .5s var(--ease)}\n        .jh-nav.solid{background:rgba(17,20,23,.94);border-bottom:1px solid var(--line)}\n        .jh-mark{display:flex;align-items:center;gap:.6rem;font-family:'Brygada 1918',Georgia,serif;font-size:1.45rem;font-weight:500;color:var(--cream);text-decoration:none;letter-spacing:-.01em}\n        .jh-mark svg{width:22px;height:16px}\n        .jh-links{display:flex;gap:2rem;list-style:none;margin:0;padding:0}\n        .jh-links a{color:var(--linen);text-decoration:none;font-size:.9rem;padding:.3rem 0;border-bottom:1px solid transparent;transition:border-color .3s var(--ease),color .3s var(--ease)}\n        .jh-links a:hover,.jh-links a:focus-visible{border-color:var(--indigo-lt);color:var(--cream)}\n        .jh-btn{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;border:1px solid var(--cream);background:var(--cream);color:var(--ink);font:500 .9rem/1 'Red Hat Text',sans-serif;padding:.8rem 1.15rem;text-decoration:none;cursor:pointer;transition:background-color .3s var(--ease),color .3s var(--ease)}\n        .jh-btn:hover,.jh-btn:focus-visible{background:var(--linen)}\n        .jh-btn.ghost{background:transparent;color:var(--cream);border-color:rgba(217,207,189,.4)}\n        .jh-btn.ghost:hover,.jh-btn.ghost:focus-visible{background:rgba(217,207,189,.1)}\n        @media(max-width:860px){.jh-links{display:none}}\n\n        .jh-film{position:relative;background:var(--steel)}\n        .jh-stage{position:sticky;top:0;height:100vh;height:100svh;overflow:hidden;z-index:0;background:var(--steel) url(${STILL_HERO}) center/cover no-repeat}\n        .jh-stage video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:0;transition:opacity .8s var(--ease)}\n        .jh-stage video.ready{opacity:1}\n        .jh-scrim{position:absolute;inset:0;pointer-events:none;background:\n          linear-gradient(90deg,rgba(13,15,18,.72),rgba(13,15,18,.3) 46%,rgba(13,15,18,.45)),\n          linear-gradient(rgba(13,15,18,.5),transparent 22%,transparent 60%,rgba(13,15,18,.8))}\n        .jh-chapters{position:relative;z-index:2;margin-top:-100vh;margin-top:-100svh}\n        .jh-ch{position:relative;min-height:115vh;display:flex;align-items:center;padding:0 clamp(1.1rem,4vw,3.5rem)}\n        .jh-ch.right{justify-content:flex-end}\n\n        .jh-hero{min-height:100vh;min-height:100svh;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,560px);gap:clamp(1.5rem,4vw,4rem);align-items:end;padding-top:6.5rem;padding-bottom:clamp(2rem,6vh,4rem)}\n        .jh-pad{background:rgba(17,20,23,.9);border:1px solid var(--line);padding:clamp(1.3rem,2.6vw,2.2rem)}\n        .jh-h1{font-family:'Brygada 1918',Georgia,serif;font-weight:500;font-size:clamp(2.5rem,5.2vw,5rem);line-height:1;letter-spacing:-.025em;margin:0 0 1.2rem;color:var(--cream);max-width:13ch}\n        .jh-h1 em{font-style:normal;font-weight:400;color:var(--indigo-lt)}\n        .jh-lede{margin:0;max-width:44ch;color:var(--linen-2);font-size:clamp(1rem,1.2vw,1.1rem)}\n        .jh-meta{margin:1.4rem 0 0;display:flex;align-items:center;gap:.8rem;font-size:.9rem;color:var(--indigo-lt)}\n        .jh-meta::before{content:\"\";width:34px;height:1px;background:var(--indigo-lt)}\n\n        .jh-card{position:relative;background:var(--cream);color:var(--ink);padding:1.3rem 1.5rem 1.4rem;clip-path:polygon(26px 0,100% 0,100% 100%,0 100%,0 26px);box-shadow:0 40px 80px -40px rgba(0,0,0,.7)}\n        .jh-card-head{display:flex;justify-content:space-between;align-items:baseline;gap:1rem;margin:0 0 .3rem;padding-left:.8rem}\n        .jh-card h2{font-family:'Brygada 1918',Georgia,serif;font-weight:500;font-size:1.35rem;line-height:1.15;margin:0;letter-spacing:-.01em}\n        .jh-card-code{font-size:.85rem;color:var(--ink-2);white-space:nowrap}\n        .jh-card-help{margin:0 0 .9rem;padding-left:.8rem;font-size:.9rem;color:var(--ink-2)}\n        .jh-lace{position:absolute;top:50%;width:10px;height:10px;border-radius:50%;background:var(--steel);transform:translateY(-50%)}\n        .jh-lace.l{left:7px}.jh-lace.r{right:7px}\n        .jh-grid{display:grid;grid-template-rows:repeat(${ROWS},1fr);aspect-ratio:${COLS}/${ROWS};width:100%;touch-action:none;cursor:crosshair;user-select:none;background:\n          repeating-linear-gradient(90deg,transparent 0 calc(100%/${COLS} - 1px),rgba(27,26,23,.07) calc(100%/${COLS} - 1px) calc(100%/${COLS}))}\n        .jh-row{display:grid;grid-template-columns:repeat(${COLS},1fr)}\n        .jh-cell{position:relative;display:block}\n        .jh-cell::after{content:\"\";position:absolute;inset:22%;border-radius:50%;border:1px solid rgba(27,26,23,.2);transition:background-color .18s var(--ease),border-color .18s var(--ease),transform .18s var(--ease)}\n        .jh-cell.on::after{background:var(--indigo-dk);border-color:var(--steel);inset:16%;box-shadow:inset 0 1px 2px rgba(0,0,0,.6)}\n        .jh-cell:hover::after{border-color:var(--indigo)}\n        .jh-cell:focus-visible{outline:2px solid var(--indigo);outline-offset:0}\n        .jh-card-foot{display:grid;grid-template-columns:150px 1fr;gap:1.1rem;align-items:start;margin-top:1rem;padding-top:1rem;border-top:1px dashed rgba(27,26,23,.25)}\n        .jh-swatch{display:block;width:100%;height:auto;aspect-ratio:${COLS}/${ROWS};image-rendering:pixelated;border:1px solid rgba(27,26,23,.2)}\n        .jh-swatch-cap{display:block;margin-top:.35rem;font-size:.8rem;color:var(--ink-2)}\n        .jh-count{margin:0 0 .7rem;font-size:.9rem;color:var(--ink-2);line-height:1.45}\n        .jh-count b{font-family:'Brygada 1918',Georgia,serif;font-weight:500;font-size:1.6rem;color:var(--ink);font-variant-numeric:oldstyle-nums;margin-right:.3rem}\n        .jh-tools{display:flex;flex-wrap:wrap;gap:.4rem}\n        .jh-tool{border:1px solid rgba(27,26,23,.3);background:transparent;color:var(--ink);font:500 .82rem/1 'Red Hat Text',sans-serif;padding:.55rem .7rem;cursor:pointer;transition:background-color .25s var(--ease),border-color .25s var(--ease)}\n        .jh-tool:hover,.jh-tool:focus-visible{border-color:var(--indigo);background:rgba(31,58,107,.08)}\n\n        .jh-chap{width:min(470px,100%)}\n        .jh-h2{font-family:'Brygada 1918',Georgia,serif;font-weight:500;font-size:clamp(1.9rem,3vw,2.6rem);line-height:1.05;letter-spacing:-.015em;margin:0 0 1rem;color:var(--cream)}\n        .jh-h2 em{font-style:normal;font-weight:400;color:var(--indigo-lt)}\n        .jh-p{margin:0;color:var(--linen-2);line-height:1.65}\n        .jh-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:1rem;margin:1.5rem 0 0;padding-top:1.2rem;border-top:1px solid var(--line)}\n        .jh-stats b{display:block;font-family:'Brygada 1918',Georgia,serif;font-weight:500;font-size:2.1rem;line-height:1;color:var(--cream);font-variant-numeric:oldstyle-nums}\n        .jh-stats span{font-size:.85rem;color:var(--linen-2);line-height:1.35;display:block;margin-top:.35rem}\n\n        .jh-sec{position:relative;z-index:3;background:var(--steel);border-top:1px solid var(--line);padding:clamp(4.5rem,11vh,7rem) clamp(1.1rem,4vw,3.5rem)}\n        .jh-sec-head{max-width:1280px;margin:0 auto 2.2rem;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:2rem;align-items:end}\n        .jh-sec-head .jh-h2{margin:0;font-size:clamp(2.2rem,4.6vw,4rem)}\n\n        .jh-loom{max-width:1280px;margin:0 auto;display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:1.5rem;align-items:stretch}\n        .jh-view{position:relative;min-height:min(72vh,640px);background:var(--steel-2) url(${STILL_LOOM}) center/cover no-repeat;border:1px solid var(--line);overflow:hidden;cursor:grab;touch-action:pan-y}\n        .jh-view:active{cursor:grabbing}\n        .jh-gl{position:absolute;inset:0;opacity:0;transition:opacity .9s var(--ease)}\n        .jh-gl.on{opacity:1}\n        .jh-status{position:absolute;left:1rem;bottom:1rem;z-index:2;margin:0;background:rgba(17,20,23,.9);padding:.5rem .8rem;font-size:.85rem;color:var(--linen-2)}\n        .jh-nogl{position:absolute;left:1rem;right:1rem;bottom:1rem;z-index:2;margin:0;max-width:46ch;background:rgba(17,20,23,.92);padding:.8rem 1rem;font-size:.9rem;color:var(--linen)}\n        .jh-read{display:grid;align-content:start;gap:0;background:var(--steel-2);border:1px solid var(--line);padding:1.4rem}\n        .jh-read dl{margin:0 0 1.3rem;display:grid}\n        .jh-read dl>div{display:flex;justify-content:space-between;align-items:baseline;gap:1rem;padding:.75rem 0;border-bottom:1px solid var(--line)}\n        .jh-read dt{font-size:.9rem;color:var(--linen-2)}\n        .jh-read dd{margin:0;font-family:'Brygada 1918',Georgia,serif;font-size:1.5rem;line-height:1;color:var(--cream);font-variant-numeric:oldstyle-nums tabular-nums}\n        .jh-read dd small{font-family:'Red Hat Text',sans-serif;font-size:.85rem;color:var(--linen-2);margin-left:.25rem}\n        .jh-read .jh-btn{width:100%;margin-top:.5rem}\n        .jh-row-strip{display:grid;grid-template-columns:repeat(${COLS},1fr);gap:2px;margin:0 0 1.1rem}\n        .jh-row-strip i{display:block;aspect-ratio:1;border-radius:50%;border:1px solid rgba(217,207,189,.3)}\n        .jh-row-strip i.on{background:var(--indigo-lt);border-color:var(--indigo-lt)}\n        .jh-row-cap{font-size:.85rem;color:var(--linen-2);margin:0 0 .45rem}\n\n        .jh-cloths{max-width:1280px;margin:0 auto;display:grid;grid-template-columns:minmax(0,1.35fr) minmax(0,1fr);gap:1.5rem}\n        .jh-bolt{position:relative;min-height:min(64vh,560px);background:var(--steel-2) url(${STILL_CLOTH}) center/cover no-repeat;border:1px solid var(--line);overflow:hidden;cursor:grab;touch-action:pan-y}\n        .jh-tabs{display:grid;grid-template-columns:repeat(2,1fr);gap:.5rem;margin:0 0 1.3rem}\n        .jh-tab{display:flex;align-items:center;gap:.7rem;text-align:left;border:1px solid var(--line);background:transparent;color:var(--linen);font:500 .95rem/1.2 'Red Hat Text',sans-serif;padding:.75rem .8rem;cursor:pointer;transition:border-color .25s var(--ease),background-color .25s var(--ease)}\n        .jh-tab i{flex:none;width:22px;height:22px;border:1px solid rgba(217,207,189,.3)}\n        .jh-tab:hover{border-color:rgba(157,179,230,.6)}\n        .jh-tab[aria-pressed=\"true\"]{border-color:var(--indigo-lt);background:rgba(157,179,230,.1);color:var(--cream)}\n        .jh-spec{margin:0 0 1.3rem;display:grid}\n        .jh-spec div{display:grid;grid-template-columns:6.5rem 1fr;gap:1rem;padding:.7rem 0;border-top:1px solid var(--line)}\n        .jh-spec dt{font-size:.9rem;color:var(--linen-2)}\n        .jh-spec dd{margin:0;color:var(--cream)}\n        .jh-spec dd.jh-fig{font-size:1.15rem}\n        .jh-actions{display:flex;flex-wrap:wrap;gap:.6rem}\n        .jh-cloth-swatch{max-width:220px;margin:0 0 1.2rem}\n        .jh-cloth-swatch .jh-swatch{border-color:var(--line)}\n\n        .jh-visit{position:relative;z-index:3;overflow:hidden;border-top:1px solid var(--line);padding:clamp(4.5rem,12vh,8rem) clamp(1.1rem,4vw,3.5rem)}\n        .jh-visit video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}\n        .jh-visit-scrim{position:absolute;inset:0;background:linear-gradient(90deg,rgba(13,15,18,.86),rgba(13,15,18,.55) 60%,rgba(13,15,18,.7))}\n        .jh-visit-grid{position:relative;max-width:1280px;margin:0 auto;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,560px);gap:clamp(1.5rem,4vw,4rem);align-items:start}\n        .jh-visit-copy .jh-h2{font-size:clamp(2.2rem,4.6vw,4rem)}\n        .jh-form{display:grid;gap:1rem}\n        .jh-field{display:grid;gap:.35rem}\n        .jh-field label,.jh-legend{font-size:.9rem;color:var(--linen-2)}\n        .jh-field input{background:var(--steel);border:1px solid rgba(217,207,189,.3);color:var(--cream);font:400 1rem/1.3 'Red Hat Text',sans-serif;padding:.75rem .8rem;border-radius:0}\n        .jh-field input:focus-visible{outline:2px solid var(--indigo-lt);outline-offset:0;border-color:var(--indigo-lt)}\n        .jh-two{display:grid;grid-template-columns:1fr 1fr;gap:1rem}\n        .jh-days{display:flex;gap:.5rem;flex-wrap:wrap;border:0;margin:0;padding:0}\n        .jh-days legend{padding:0;margin-bottom:.35rem}\n        .jh-day{border:1px solid rgba(217,207,189,.3);background:transparent;color:var(--linen);font:500 .9rem/1 'Red Hat Text',sans-serif;padding:.65rem .9rem;cursor:pointer;transition:border-color .25s var(--ease),background-color .25s var(--ease)}\n        .jh-day[aria-pressed=\"true\"]{border-color:var(--indigo-lt);background:rgba(157,179,230,.12);color:var(--cream)}\n        .jh-attach{position:relative;background:var(--cream);color:var(--ink);padding:1rem 1.1rem 1.1rem;display:grid;grid-template-columns:132px 1fr;gap:1rem;align-items:start;clip-path:polygon(16px 0,100% 0,100% 100%,0 100%,0 16px)}\n        .jh-attach b{display:block;font-family:'Brygada 1918',Georgia,serif;font-weight:500;font-size:1.15rem;line-height:1.2}\n        .jh-attach p{margin:.3rem 0 0;font-size:.85rem;color:var(--ink-2);line-height:1.45}\n        .jh-attach a{color:var(--indigo);font-size:.85rem;font-weight:500}\n        .jh-draft-svg{display:block;width:100%;height:auto}\n        .jh-draft-svg rect{fill:var(--indigo-dk)}\n        .jh-draft-svg .jh-draft-ground{fill:#e4d9be}\n        .jh-chips{display:flex;flex-wrap:wrap;gap:.4rem;margin:0;padding:0;list-style:none}\n        .jh-chips li{font-size:.85rem;border:1px solid rgba(217,207,189,.3);padding:.3rem .6rem;color:var(--cream)}\n        .jh-none{font-size:.9rem;color:var(--linen-2);margin:0}\n        .jh-sent{margin:0;min-height:1.6em;font-size:.95rem;color:var(--cream)}\n\n        .jh-foot{position:relative;z-index:3;background:var(--steel);border-top:1px solid var(--line);padding:clamp(3rem,8vh,5rem) clamp(1.1rem,4vw,3.5rem) clamp(5.5rem,10vh,7rem)}\n        .jh-foot-in{max-width:1280px;margin:0 auto;display:grid;gap:1.8rem}\n        .jh-perf{display:grid;grid-template-columns:repeat(${COLS},1fr);gap:clamp(4px,1vw,14px);padding:1rem 1.4rem;background:var(--cream);clip-path:polygon(18px 0,100% 0,100% 100%,0 100%,0 18px)}\n        .jh-perf i{display:block;aspect-ratio:1;border-radius:50%;border:1px solid rgba(27,26,23,.2)}\n        .jh-perf i.on{background:var(--indigo-dk);border-color:var(--steel)}\n        .jh-word{font-family:'Brygada 1918',Georgia,serif;font-weight:500;font-size:clamp(3.6rem,13.5vw,13rem);line-height:.85;letter-spacing:-.035em;margin:0;color:var(--cream)}\n        .jh-word em{font-style:normal;font-weight:400;color:var(--indigo-lt)}\n        .jh-foot-row{display:flex;flex-wrap:wrap;justify-content:space-between;gap:1rem 2rem;font-size:.9rem;color:var(--linen-2)}\n        .jh-foot-row a{color:var(--linen);text-decoration:none;border-bottom:1px solid rgba(157,179,230,.5)}\n        .jh-foot-row a:hover,.jh-foot-row a:focus-visible{color:var(--cream);border-color:var(--indigo-lt)}\n\n        @media(max-width:960px){\n          .jh-hero{grid-template-columns:1fr;align-items:start;padding-top:5.5rem}\n          .jh-loom,.jh-cloths,.jh-visit-grid,.jh-sec-head{grid-template-columns:1fr}\n        }\n        @media(max-width:760px){\n          .jh-ch,.jh-ch.right{justify-content:center;min-height:110vh}\n          .jh-hero{min-height:100svh;gap:1rem;padding-top:5rem;padding-bottom:2.5rem}\n          .jh-h1{font-size:2.4rem;margin-bottom:.9rem}\n          .jh-meta{margin-top:1rem}\n          .jh-card{padding:1rem .9rem 1.1rem;clip-path:polygon(18px 0,100% 0,100% 100%,0 100%,0 18px)}\n          .jh-lace{display:none}\n          .jh-card-head,.jh-card-help{padding-left:.5rem}\n          .jh-card-foot{grid-template-columns:110px 1fr;gap:.8rem}\n          .jh-scrim{background:linear-gradient(rgba(13,15,18,.6),rgba(13,15,18,.5) 40%,rgba(13,15,18,.85))}\n          .jh-view{min-height:62vh}\n          .jh-bolt{min-height:52vh}\n          .jh-two{grid-template-columns:1fr}\n          .jh-attach{grid-template-columns:96px 1fr}\n          .jh-stats b{font-size:1.7rem}\n        }\n        @media(prefers-reduced-motion:reduce){\n          .jh-page *{transition:none!important;animation:none!important}\n        }\n      `}</style>\n\n      <a className=\"jh-skip\" href=\"#card\">Skip to the punch card</a>\n\n      <nav className=\"jh-nav\" data-nav aria-label=\"Jacquard Hall\">\n        <a className=\"jh-mark\" href=\"#top\">\n          <svg viewBox=\"0 0 22 16\" aria-hidden=\"true\">\n            <rect x=\"0.5\" y=\"0.5\" width=\"21\" height=\"15\" fill=\"#efe6cf\" />\n            <circle cx=\"5\" cy=\"5\" r=\"1.6\" fill=\"#142645\" />\n            <circle cx=\"11\" cy=\"5\" r=\"1.6\" fill=\"#142645\" />\n            <circle cx=\"8\" cy=\"11\" r=\"1.6\" fill=\"#142645\" />\n            <circle cx=\"17\" cy=\"11\" r=\"1.6\" fill=\"#142645\" />\n          </svg>\n          Jacquard Hall\n        </a>\n        <ul className=\"jh-links\">\n          <li><a href=\"#card\">The card</a></li>\n          <li><a href=\"#loom\">The loom</a></li>\n          <li><a href=\"#cloth\">Cloth</a></li>\n          <li><a href=\"#visit\">Visit</a></li>\n        </ul>\n        <a className=\"jh-btn\" href=\"#visit\">Book a mill visit</a>\n      </nav>\n\n      <main>\n        <section className=\"jh-film\" data-film aria-label=\"The card and the loom\">\n          <div className=\"jh-stage\" aria-hidden=\"true\">\n            <video data-scrub-video muted playsInline preload=\"metadata\" poster={STILL_HERO} />\n            <div className=\"jh-scrim\" />\n          </div>\n\n          <div className=\"jh-chapters\" data-chapters>\n            <div className=\"jh-ch jh-hero\" id=\"top\" data-t=\"0\">\n              <div className=\"jh-pad\">\n                <h1 className=\"jh-h1\">Punch the card. <em>The loom reads every hole.</em></h1>\n                <p className=\"jh-lede\">Jacquard Hall weaves indigo and undyed linen on 4 jacquard looms in a brick shed in Halifax. Every hole you punch lifts one warp thread on one pick. Draw a pattern, scroll, and watch it woven.</p>\n                <p className=\"jh-meta\">Shed 2, Calder Mills. 2,400 ends on every warp.</p>\n              </div>\n\n              <div className=\"jh-card\" id=\"card\">\n                <span className=\"jh-lace l\" aria-hidden=\"true\" />\n                <span className=\"jh-lace r\" aria-hidden=\"true\" />\n                <div className=\"jh-card-head\">\n                  <h2>Your card, 24 hooks by 16 picks</h2>\n                  <span className=\"jh-card-code jh-fig\">{code}</span>\n                </div>\n                <p className=\"jh-card-help\">Click or drag to punch holes. Arrow keys and Space work too.</p>\n                <PunchCard card={card} />\n                <div className=\"jh-card-foot\">\n                  <div>\n                    <Swatch card={card} label=\"Your card woven in indigo warp and linen weft, 2 repeats each way\" />\n                    <span className=\"jh-swatch-cap\">Woven, 2 repeats</span>\n                  </div>\n                  <div>\n                    <p className=\"jh-count\" aria-live=\"polite\">\n                      <b>{punched}</b>holes punched of {COLS * ROWS}. Kept on this device, and sent with your visit request.\n                    </p>\n                    <div className=\"jh-tools\" role=\"group\" aria-label=\"Card tools\">\n                      {PRESETS.map((p) => (\n                        <button key={p.id} type=\"button\" className=\"jh-tool\" onClick={() => writeCard(p.card)}>\n                          {p.name}\n                        </button>\n                      ))}\n                      <button type=\"button\" className=\"jh-tool\" onClick={() => writeCard(BLANK_CARD)}>\n                        Clear\n                      </button>\n                    </div>\n                  </div>\n                </div>\n              </div>\n            </div>\n\n            <div className=\"jh-ch\" data-t=\"3.6\">\n              <article className=\"jh-pad jh-chap\">\n                <h2 className=\"jh-h2\">One hole lifts <em>one thread.</em></h2>\n                <p className=\"jh-p\">On every pick the loom presses the next card against a bank of needles. Where the card has a hole, a needle passes through, its hook rises and the harness cord lifts one warp thread clear of the shuttle. Where there is none, the thread stays down.</p>\n                <div className=\"jh-stats\">\n                  <div><b>24</b><span>hooks on your card</span></div>\n                  <div><b>2,400</b><span>ends on a full warp</span></div>\n                  <div><b>42</b><span>picks a minute</span></div>\n                </div>\n              </article>\n            </div>\n\n            <div className=\"jh-ch right\" data-t=\"7.2\">\n              <article className=\"jh-pad jh-chap\">\n                <h2 className=\"jh-h2\">Two colours. <em>The rest is placement.</em></h2>\n                <p className=\"jh-p\">The warp is indigo, dyed in the yard. The weft is undyed linen. A lifted thread shows indigo on the face of the cloth; a lowered one lets the linen cross over it. Nothing is printed afterwards, so every line of the pattern was decided on the card.</p>\n                <div className=\"jh-stats\">\n                  <div><b>2</b><span>colours on the loom</span></div>\n                  <div><b>28</b><span>ends per centimetre</span></div>\n                  <div><b>0</b><span>printed after weaving</span></div>\n                </div>\n              </article>\n            </div>\n          </div>\n        </section>\n\n        <section className=\"jh-sec\" id=\"loom\" ref={loomRef} aria-labelledby=\"jh-loom-h\">\n          <div className=\"jh-sec-head\">\n            <h2 className=\"jh-h2\" id=\"jh-loom-h\">Your card, <em>on the loom.</em></h2>\n            <p className=\"jh-p\">The card you punched, read one pick at a time. Lifted threads rise, the shuttle crosses, the reed beats the weft in and a row of your cloth appears at the fell. Drag to walk round the loom.</p>\n          </div>\n          <div className=\"jh-loom\">\n            <div className=\"jh-view\">\n              {loomNear && (\n                <div className={loomReady ? \"jh-gl on\" : \"jh-gl\"}>\n                  <LoomScene card={card} active={loomIn} paused={paused} reduce={reduce} onReady={() => setLoomReady(true)} onPick={onPick} fallback={loomFallback} />\n                </div>\n              )}\n              {!loomReady && <p className=\"jh-status\">Threading the loom with your card</p>}\n            </div>\n            <aside className=\"jh-read\" aria-label=\"Loom readout\">\n              <p className=\"jh-row-cap\">Pick {pad2(pick + 1)} on the needles</p>\n              <div className=\"jh-row-strip\" aria-hidden=\"true\">\n                {Array.from({ length: COLS }, (_, x) => (\n                  <i key={x} className={bit(card, x, pick) ? \"on\" : undefined} />\n                ))}\n              </div>\n              <dl>\n                <div><dt>Pick</dt><dd>{pad2(pick + 1)}<small>of {ROWS}</small></dd></div>\n                <div><dt>Hooks lifted</dt><dd>{lifted}<small>of {COLS}</small></dd></div>\n                <div><dt>Ends across</dt><dd>72<small>3 repeats</small></dd></div>\n                <div><dt>Draft</dt><dd>{code}</dd></div>\n              </dl>\n              {!reduce && (\n                <button type=\"button\" className=\"jh-btn ghost\" aria-pressed={paused} onClick={() => setPaused((p) => !p)}>\n                  {paused ? \"Run the loom\" : \"Pause the loom\"}\n                </button>\n              )}\n              <a className=\"jh-btn ghost\" href=\"#card\">Change the card</a>\n            </aside>\n          </div>\n        </section>\n\n        <section className=\"jh-sec\" id=\"cloth\" ref={clothRef} aria-labelledby=\"jh-cloth-h\">\n          <div className=\"jh-sec-head\">\n            <h2 className=\"jh-h2\" id=\"jh-cloth-h\">4 cloths <em>on the bolt.</em></h2>\n            <p className=\"jh-p\">The house cloths, each woven from its own card. Drag a bolt to turn it, switch to the close-up to count the threads, and ask for a swatch to see on your visit.</p>\n          </div>\n          <div className=\"jh-cloths\">\n            <div className=\"jh-bolt\">\n              {boltNear && (\n                <div className={boltReady ? \"jh-gl on\" : \"jh-gl\"}>\n                  <BoltScene card={c.card} warp={c.warp} weft={c.weft} close={close} active={boltIn} reduce={reduce} onReady={() => setBoltReady(true)} fallback={boltFallback} />\n                </div>\n              )}\n            </div>\n            <div>\n              <div className=\"jh-tabs\" role=\"group\" aria-label=\"Cloth\">\n                {CLOTHS.map((x, i) => (\n                  <button key={x.id} type=\"button\" className=\"jh-tab\" aria-pressed={cloth === i} onClick={() => setCloth(i)}>\n                    <i aria-hidden=\"true\" style={{ background: `linear-gradient(135deg, ${x.warp} 50%, ${x.weft} 50%)` }} />\n                    {x.name}\n                  </button>\n                ))}\n              </div>\n              <div className=\"jh-cloth-swatch\">\n                <Swatch card={c.card} warp={c.warp} weft={c.weft} label={`${c.name}, woven swatch`} />\n              </div>\n              <dl className=\"jh-spec\">\n                <div><dt>Fibre</dt><dd>{c.fibre}</dd></div>\n                <div><dt>Weight</dt><dd className=\"jh-fig\">{c.weight} g/m²</dd></div>\n                <div><dt>Width</dt><dd className=\"jh-fig\">{c.width} cm</dd></div>\n                <div><dt>For</dt><dd>{c.use}</dd></div>\n              </dl>\n              <div className=\"jh-actions\">\n                <button type=\"button\" className=\"jh-btn ghost\" aria-pressed={close} onClick={() => setClose((v) => !v)}>\n                  {close ? \"Back to the bolt\" : \"Close-up weave\"}\n                </button>\n                <button type=\"button\" className=\"jh-btn\" aria-pressed={swatches.includes(c.id)} onClick={() => toggleSwatch(c.id)}>\n                  {swatches.includes(c.id) ? \"Swatch added to your visit\" : \"Ask for a swatch\"}\n                </button>\n              </div>\n            </div>\n          </div>\n        </section>\n\n        <section className=\"jh-visit\" id=\"visit\" ref={visitRef} aria-labelledby=\"jh-visit-h\">\n          <video ref={ambient} muted playsInline loop preload=\"metadata\" poster={POSTER} aria-hidden=\"true\" />\n          <div className=\"jh-visit-scrim\" aria-hidden=\"true\" />\n          <div className=\"jh-visit-grid\">\n            <div className=\"jh-pad jh-visit-copy\">\n              <h2 className=\"jh-h2\" id=\"jh-visit-h\">Come to the mill. <em>Your card comes too.</em></h2>\n              <p className=\"jh-p\">Visits run Tuesday to Thursday, 10:00 to 15:00, on the shed floor with the looms running. Your card travels with the request as a weave draft, so the weaver can have it on the sample loom when you arrive.</p>\n            </div>\n            <form className=\"jh-pad jh-form\" onSubmit={submit}>\n              <div className=\"jh-attach\">\n                <DraftSheet card={card} />\n                <div>\n                  <b>Attached: weave draft {code}</b>\n                  <p>24 ends on a straight draw, 16 picks, {punched} holes. Indigo warp, undyed linen weft.</p>\n                  <a href=\"#card\">Change the card</a>\n                </div>\n              </div>\n              <div className=\"jh-two\">\n                <div className=\"jh-field\">\n                  <label htmlFor=\"jh-name\">Name</label>\n                  <input id=\"jh-name\" name=\"name\" autoComplete=\"name\" required />\n                </div>\n                <div className=\"jh-field\">\n                  <label htmlFor=\"jh-studio\">Studio or company</label>\n                  <input id=\"jh-studio\" name=\"studio\" autoComplete=\"organization\" />\n                </div>\n              </div>\n              <div className=\"jh-field\">\n                <label htmlFor=\"jh-email\">Email</label>\n                <input id=\"jh-email\" name=\"email\" type=\"email\" autoComplete=\"email\" required />\n              </div>\n              <fieldset className=\"jh-days\">\n                <legend className=\"jh-legend\">Day you would like to come</legend>\n                {DAYS.map((d) => (\n                  <button key={d} type=\"button\" className=\"jh-day\" aria-pressed={day === d} onClick={() => setDay(d)}>\n                    {d}\n                  </button>\n                ))}\n              </fieldset>\n              <div className=\"jh-field\">\n                <span className=\"jh-legend\">Swatches to have ready</span>\n                {swatches.length ? (\n                  <ul className=\"jh-chips\">\n                    {swatches.map((id) => (\n                      <li key={id}>{CLOTHS.find((x) => x.id === id)?.name}</li>\n                    ))}\n                  </ul>\n                ) : (\n                  <p className=\"jh-none\">None yet. Ask for one from any cloth above.</p>\n                )}\n              </div>\n              <button type=\"submit\" className=\"jh-btn\">Request a {day} visit with {code}</button>\n              <p className=\"jh-sent\" aria-live=\"polite\">{sent ? `Sent. Draft ${sent} is with the weaver, who will reply with a time on ${day}.` : \"\"}</p>\n            </form>\n          </div>\n        </section>\n      </main>\n\n      <footer className=\"jh-foot\">\n        <div className=\"jh-foot-in\">\n          <div className=\"jh-perf\" aria-hidden=\"true\">\n            {Array.from({ length: COLS }, (_, x) => (\n              <i key={x} className={bit(card, x, 0) ? \"on\" : undefined} />\n            ))}\n          </div>\n          <p className=\"jh-word\" aria-hidden=\"true\">Jacquard <em>Hall</em></p>\n          <div className=\"jh-foot-row\">\n            <span>Shed 2, Calder Mills, Halifax</span>\n            <span>Swatches posted within 5 working days</span>\n            <a href=\"#card\">Back to your card, {code}</a>\n          </div>\n        </div>\n      </footer>\n    </div>\n  );\n}\n"},{"path":"components/nightmarquee/jacquard-hall/jacquard-hall/media.ts","type":"registry:component","target":"components/nightmarquee/jacquard-hall/jacquard-hall/media.ts","content":"// Generated by scripts/drop/scaffold.mjs from drops/jacquard-hall/drop.json. Do not edit; run the scaffold again.\nimport { mediaUrl } from \"../lib/media\";\n/* NightMarquee design \"Jacquard Hall\". 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/jacquard-hall/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/jacquard-hall/hero.mp4\"),\n    mobile: mediaUrl(\"/drops/jacquard-hall/hero-m.mp4\"),\n  },\n  ambient: {\n    desktop: mediaUrl(\"/drops/jacquard-hall/ambient.mp4\"),\n    mobile: mediaUrl(\"/drops/jacquard-hall/ambient-m.mp4\"),\n  },\n} satisfies Record<string, ShotFiles>;\n"},{"path":"components/nightmarquee/jacquard-hall/jacquard-hall/scene.tsx","type":"registry:component","target":"components/nightmarquee/jacquard-hall/jacquard-hall/scene.tsx","content":"\"use client\";\n/* NightMarquee design \"Jacquard Hall\". Free for personal, portfolio, educational and non-commercial use; no republishing: nightmarquee.com/license */\n\n/* Jacquard Hall, the two WebGL scenes. Every geometry is built here in code.\n   Loom: 72 warp ends as instanced cylinders (back and front halves), each\n   lifted by its hook when the current pick of the card has a hole there; a\n   harness cord per end runs up to the comber board; the shuttle lays the weft,\n   the reed beats it in and the cloth texture gains one row per pick, drawn\n   from the same card. Bolt: a roll of cloth and its draped tail on a slow\n   turntable. Both orbit with OrbitControls (rotate only). */\n\nimport { Canvas, useFrame, useThree } from \"@react-three/fiber\";\nimport { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport * as THREE from \"three\";\nimport { OrbitControls } from \"three/addons/controls/OrbitControls.js\";\nimport { COLS, ROWS, bit, liftedOn, paintCloth, type Card } from \"./weave\";\n\nconst REPEAT = 3;\nconst ENDS = COLS * REPEAT;\nconst W = 3;\nconst BACK_Z = -2.1;\nconst HEDDLE_Z = -0.75;\nconst FELL_Z = 0.25;\nconst FRONT_Z = 1.35;\nconst CLOTH_ROWS = 32;\nconst PICK_S = 0.55;\nconst CELL = 8;\n\nconst STEEL = \"#22282d\";\nconst INDIGO = \"#1f3a6b\";\nconst LINEN = \"#d9cfbd\";\nconst CREAM = \"#efe6cf\";\n\nconst endX = (e: number) => -W / 2 + (e + 0.5) * (W / ENDS);\nconst smooth = (k: number) => k * k * (3 - 2 * k);\nconst clamp01 = (v: number) => Math.min(1, Math.max(0, v));\n\nfunction hasWebGL() {\n  try {\n    const c = document.createElement(\"canvas\");\n    return !!(c.getContext(\"webgl2\") || c.getContext(\"webgl\"));\n  } catch {\n    return false;\n  }\n}\n\n/** Rotate-only orbit with damping; under reduced motion it renders on demand. */\nfunction Orbit({ target, auto, minPolar, maxPolar }: { target: [number, number, number]; auto: boolean; minPolar: number; maxPolar: number }) {\n  const camera = useThree((s) => s.camera);\n  const dom = useThree((s) => s.gl.domElement);\n  const invalidate = useThree((s) => s.invalidate);\n  const ref = useRef<OrbitControls | null>(null);\n  useEffect(() => {\n    const c = new OrbitControls(camera, dom);\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.target.set(target[0], target[1], target[2]);\n    c.update();\n    c.addEventListener(\"change\", () => invalidate());\n    ref.current = c;\n    return () => {\n      c.dispose();\n      ref.current = null;\n    };\n  }, [camera, dom, invalidate, target, minPolar, maxPolar]);\n  useEffect(() => {\n    const c = ref.current;\n    if (!c) return;\n    c.autoRotate = auto;\n    c.autoRotateSpeed = 0.35;\n  }, [auto]);\n  useFrame(() => ref.current?.update());\n  return null;\n}\n\n/* ---------- the loom ---------- */\n\ntype Loom = {\n  card: Card;\n  pick: number;\n  t: number;\n  lift: Float32Array;\n  /* woven picks, newest first, each kept as the holes it was woven with */\n  rows: string[];\n  canvas: HTMLCanvasElement;\n  texture: THREE.CanvasTexture;\n};\n\n/* the cloth window: row 0 is the newest pick, at the fell */\nfunction paintLoom(L: Loom) {\n  const ctx = L.canvas.getContext(\"2d\");\n  if (!ctx) return;\n  ctx.fillStyle = \"#0f1215\";\n  ctx.fillRect(0, 0, L.canvas.width, L.canvas.height);\n  const rows = L.rows;\n  paintCloth(ctx, (x, y) => rows[y].charCodeAt(x % COLS) === 49, ENDS, Math.min(rows.length, CLOTH_ROWS), CELL, INDIGO, LINEN);\n  L.texture.needsUpdate = true;\n}\n\n/* scratch objects for placing one warp segment between two points */\nconst TMP = {\n  m: new THREE.Matrix4(),\n  q: new THREE.Quaternion(),\n  up: new THREE.Vector3(0, 1, 0),\n  dir: new THREE.Vector3(),\n  mid: new THREE.Vector3(),\n  sc: new THREE.Vector3(1, 1, 1),\n};\nfunction seg(mesh: THREE.InstancedMesh, i: number, ax: number, ay: number, az: number, bx: number, by: number, bz: number) {\n  const { m, q, up, dir, mid, sc } = TMP;\n  dir.set(bx - ax, by - ay, bz - az);\n  const len = dir.length();\n  dir.divideScalar(len || 1);\n  q.setFromUnitVectors(up, dir);\n  mid.set((ax + bx) / 2, (ay + by) / 2, (az + bz) / 2);\n  sc.set(1, len, 1);\n  m.compose(mid, q, sc);\n  mesh.setMatrixAt(i, m);\n}\n\nconst pickRow = (card: Card, pick: number) => card.slice(pick * COLS, pick * COLS + COLS);\nconst fullCloth = (card: Card) => Array.from({ length: CLOTH_ROWS }, (_, i) => pickRow(card, (ROWS * 4 - 1 - i) % ROWS));\n\nfunction LoomRig({ card, running, finished, onPick }: { card: Card; running: boolean; finished: boolean; onPick: (pick: number, lifted: number, woven: number) => void }) {\n  const invalidate = useThree((s) => s.invalidate);\n  const back = useRef<THREE.InstancedMesh>(null);\n  const front = useRef<THREE.InstancedMesh>(null);\n  const cords = useRef<THREE.LineSegments>(null);\n  const shuttle = useRef<THREE.Mesh>(null);\n  const weft = useRef<THREE.Mesh>(null);\n  const reed = useRef<THREE.Group>(null);\n  const chain = useRef<THREE.Group>(null);\n  const clothMat = useRef<THREE.MeshStandardMaterial>(null);\n  const first = useRef(card);\n  const loom = useRef<Loom | null>(null);\n\n  /* the loom's own state, its cloth canvas and the harness cords, made once on mount */\n  useLayoutEffect(() => {\n    const canvas = document.createElement(\"canvas\");\n    canvas.width = ENDS * CELL;\n    canvas.height = CLOTH_ROWS * CELL;\n    const texture = new THREE.CanvasTexture(canvas);\n    texture.colorSpace = THREE.SRGBColorSpace;\n    texture.anisotropy = 4;\n    loom.current = { card: first.current, pick: 0, t: 0, lift: new Float32Array(ENDS), rows: fullCloth(first.current), canvas, texture };\n    if (clothMat.current) {\n      clothMat.current.map = texture;\n      clothMat.current.needsUpdate = true;\n    }\n    const g = new THREE.BufferGeometry();\n    g.setAttribute(\"position\", new THREE.BufferAttribute(new Float32Array(ENDS * 6), 3));\n    if (cords.current) cords.current.geometry = g;\n    return () => {\n      texture.dispose();\n      g.dispose();\n      loom.current = null;\n    };\n  }, []);\n\n  useLayoutEffect(() => {\n    const L = loom.current;\n    if (!L) return;\n    L.card = card;\n    if (finished) {\n      L.rows = fullCloth(card);\n      L.pick = 0;\n    }\n    paintLoom(L);\n    invalidate();\n  }, [finished, card, invalidate]);\n\n  useFrame((_, dt) => {\n    const b = back.current;\n    const f = front.current;\n    const cg = cords.current;\n    const s = loom.current;\n    if (!b || !f || !cg || !s) return;\n    if (running && !finished) {\n      s.t += Math.min(dt, 0.05) / PICK_S;\n      if (s.t >= 1) {\n        s.t -= 1;\n        s.rows.unshift(pickRow(s.card, s.pick));\n        if (s.rows.length > CLOTH_ROWS) s.rows.length = CLOTH_ROWS;\n        paintLoom(s);\n        s.pick = (s.pick + 1) % ROWS;\n        onPick(s.pick, liftedOn(s.card, s.pick), s.rows.length);\n      }\n    }\n    const k = finished ? 0.5 : s.t;\n    /* shed opens over the first 30% of the pick, holds, closes over the last 20% */\n    const open = finished ? 0.6 : smooth(clamp01(k / 0.3)) * (1 - smooth(clamp01((k - 0.8) / 0.2)));\n    const pos = cg.geometry.getAttribute(\"position\") as THREE.BufferAttribute | undefined;\n    if (!pos) return;\n    for (let e = 0; e < ENDS; e++) {\n      const lifted = bit(s.card, e % COLS, s.pick);\n      const target = (lifted ? 0.2 : -0.05) * open;\n      s.lift[e] += (target - s.lift[e]) * (finished ? 1 : 0.35);\n      const x = endX(e);\n      const h = s.lift[e];\n      seg(b, e, x, 0, BACK_Z, x, h, HEDDLE_Z);\n      seg(f, e, x, h, HEDDLE_Z, x, 0, FELL_Z);\n      pos.setXYZ(e * 2, x, h + 0.02, HEDDLE_Z);\n      pos.setXYZ(e * 2 + 1, x * 0.55, 1.65, HEDDLE_Z - 0.1);\n    }\n    b.instanceMatrix.needsUpdate = true;\n    f.instanceMatrix.needsUpdate = true;\n    pos.needsUpdate = true;\n\n    /* the shuttle crosses between 30% and 75% of the pick, laying weft behind it */\n    const run = clamp01((k - 0.3) / 0.45);\n    const dirSign = s.pick % 2 === 0 ? 1 : -1;\n    const sx = dirSign * (-W / 2 - 0.25 + run * (W + 0.5));\n    if (shuttle.current) {\n      shuttle.current.position.set(sx, 0.06, FELL_Z - 0.32);\n      shuttle.current.visible = !finished;\n    }\n    if (weft.current) {\n      const w = finished ? 0 : clamp01(run * 1.08);\n      weft.current.scale.set(Math.max(0.001, w), 1, 1);\n      weft.current.position.set(dirSign > 0 ? -W / 2 + (w * W) / 2 : W / 2 - (w * W) / 2, 0.01, FELL_Z - 0.06);\n    }\n    /* the reed beats the pick into the fell over the last 25% */\n    if (reed.current) {\n      const beat = finished ? 0 : Math.sin(clamp01((k - 0.75) / 0.25) * Math.PI);\n      reed.current.position.z = -0.42 + beat * 0.5;\n    }\n    if (chain.current) chain.current.position.y = ((s.pick + k) % 1) * 0.075;\n    if (!running || finished) invalidate();\n  });\n\n  const cards = Array.from({ length: 12 }, (_, i) => i);\n  return (\n    <group>\n      {/* warp ends, two halves meeting at the heddles */}\n      <instancedMesh ref={back} args={[undefined, undefined, ENDS]} frustumCulled={false}>\n        <cylinderGeometry args={[0.0075, 0.0075, 1, 5, 1, true]} />\n        <meshStandardMaterial color={INDIGO} roughness={0.85} />\n      </instancedMesh>\n      <instancedMesh ref={front} args={[undefined, undefined, ENDS]} frustumCulled={false}>\n        <cylinderGeometry args={[0.0075, 0.0075, 1, 5, 1, true]} />\n        <meshStandardMaterial color={INDIGO} roughness={0.85} />\n      </instancedMesh>\n      <lineSegments ref={cords} frustumCulled={false}>\n        <lineBasicMaterial color={LINEN} transparent opacity={0.55} />\n      </lineSegments>\n\n      {/* woven cloth from the fell to the front beam */}\n      <mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, 0, (FELL_Z + FRONT_Z) / 2]}>\n        <planeGeometry args={[W, FRONT_Z - FELL_Z]} />\n        <meshStandardMaterial ref={clothMat} roughness={0.95} side={THREE.DoubleSide} />\n      </mesh>\n      <mesh ref={weft} position={[0, 0.01, FELL_Z - 0.06]} rotation={[0, 0, Math.PI / 2]}>\n        <cylinderGeometry args={[0.012, 0.012, W, 6]} />\n        <meshStandardMaterial color={LINEN} roughness={0.9} />\n      </mesh>\n      <mesh ref={shuttle}>\n        <boxGeometry args={[0.34, 0.05, 0.07]} />\n        <meshStandardMaterial color=\"#6b4a2e\" roughness={0.45} metalness={0.1} />\n      </mesh>\n\n      {/* reed and batten */}\n      <group ref={reed} position={[0, 0, -0.42]}>\n        <mesh position={[0, 0.34, 0]}>\n          <boxGeometry args={[W + 0.4, 0.06, 0.06]} />\n          <meshStandardMaterial color=\"#5b3b24\" roughness={0.6} />\n        </mesh>\n        <mesh position={[0, -0.16, 0]}>\n          <boxGeometry args={[W + 0.4, 0.08, 0.12]} />\n          <meshStandardMaterial color=\"#5b3b24\" roughness={0.6} />\n        </mesh>\n      </group>\n\n      {/* beams and frame in oiled steel */}\n      {[BACK_Z, FRONT_Z].map((z) => (\n        <mesh key={z} position={[0, -0.06, z]} rotation={[0, 0, Math.PI / 2]}>\n          <cylinderGeometry args={[0.09, 0.09, W + 0.5, 20]} />\n          <meshStandardMaterial color={STEEL} roughness={0.35} metalness={0.7} />\n        </mesh>\n      ))}\n      <mesh position={[0, -0.2, FRONT_Z + 0.05]} rotation={[0, 0, Math.PI / 2]}>\n        <cylinderGeometry args={[0.16, 0.16, W + 0.2, 24]} />\n        <meshStandardMaterial color={INDIGO} roughness={0.95} />\n      </mesh>\n      {[-1, 1].map((side) => (\n        <group key={side} position={[side * (W / 2 + 0.3), 0, 0]}>\n          <mesh position={[0, -0.45, -0.4]}>\n            <boxGeometry args={[0.1, 0.1, 4]} />\n            <meshStandardMaterial color={STEEL} roughness={0.4} metalness={0.6} />\n          </mesh>\n          {[BACK_Z, HEDDLE_Z, FRONT_Z].map((z) => (\n            <mesh key={z} position={[0, z === HEDDLE_Z ? 0.55 : -0.05, z]}>\n              <boxGeometry args={[0.1, z === HEDDLE_Z ? 2.1 : 0.9, 0.1]} />\n              <meshStandardMaterial color={STEEL} roughness={0.4} metalness={0.6} />\n            </mesh>\n          ))}\n        </group>\n      ))}\n      {/* comber board, where the harness cords gather */}\n      <mesh position={[0, 1.67, HEDDLE_Z - 0.1]}>\n        <boxGeometry args={[W * 0.62, 0.04, 0.3]} />\n        <meshStandardMaterial color=\"#5b3b24\" roughness={0.6} />\n      </mesh>\n      <mesh position={[0, 1.6, HEDDLE_Z]}>\n        <boxGeometry args={[W + 0.7, 0.08, 0.08]} />\n        <meshStandardMaterial color={STEEL} roughness={0.4} metalness={0.6} />\n      </mesh>\n\n      {/* the card chain, climbing one card per pick */}\n      <group position={[W / 2 + 0.36, 1.05, HEDDLE_Z - 0.45]}>\n        <group ref={chain}>\n          {cards.map((i) => (\n            <mesh key={i} position={[0, i * 0.075 - 0.4, (i % 2) * 0.02]}>\n              <boxGeometry args={[0.3, 0.065, 0.01]} />\n              <meshStandardMaterial color={CREAM} roughness={0.8} />\n            </mesh>\n          ))}\n        </group>\n      </group>\n\n      {/* mill floor */}\n      <mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, -0.52, -0.3]}>\n        <planeGeometry args={[14, 12]} />\n        <meshStandardMaterial color=\"#1a1512\" roughness={1} />\n      </mesh>\n    </group>\n  );\n}\n\nfunction GLGate({ children, fallback }: { children: ReactNode; fallback: ReactNode }) {\n  const [ok] = useState(hasWebGL);\n  return ok ? <>{children}</> : <>{fallback}</>;\n}\n\nconst LOOM_TARGET: [number, number, number] = [0, 0.25, -0.35];\n\nexport function LoomScene({\n  card,\n  active,\n  paused,\n  reduce,\n  onReady,\n  onPick,\n  fallback,\n}: {\n  card: Card;\n  active: boolean;\n  paused: boolean;\n  reduce: boolean;\n  onReady: () => void;\n  onPick: (pick: number, lifted: number, woven: number) => void;\n  fallback: ReactNode;\n}) {\n  const running = active && !paused && !reduce;\n  /* a portrait screen stands further back so the whole width of the warp fits */\n  const [cam] = useState<[number, number, number]>(() => (window.innerWidth < window.innerHeight ? [4.9, 3.5, 5.6] : [3.5, 2.5, 3.9]));\n  return (\n    <GLGate fallback={fallback}>\n      <Canvas\n        dpr={[1, 1.75]}\n        camera={{ position: cam, fov: 36, near: 0.1, far: 40 }}\n        frameloop={reduce || !active ? \"demand\" : \"always\"}\n        gl={{ antialias: true, powerPreference: \"high-performance\" }}\n        onCreated={({ scene }) => {\n          scene.background = new THREE.Color(\"#111417\");\n          scene.fog = new THREE.Fog(\"#111417\", 6, 14);\n          requestAnimationFrame(onReady);\n        }}\n        aria-hidden=\"true\"\n      >\n        <hemisphereLight args={[\"#cdd6e8\", \"#2a1a14\", 0.9]} />\n        <directionalLight position={[-4, 4, 2]} intensity={2.4} color=\"#f3ecdf\" />\n        <directionalLight position={[3, 2, -3]} intensity={0.5} color=\"#9db3e6\" />\n        <LoomRig card={card} running={running} finished={reduce} onPick={onPick} />\n        <Orbit target={LOOM_TARGET} auto={running} minPolar={0.55} maxPolar={1.42} />\n      </Canvas>\n    </GLGate>\n  );\n}\n\n/* ---------- the bolt ---------- */\n\nfunction Bolt({ card, warp, weft, close, spin }: { card: Card; warp: string; weft: string; close: boolean; spin: boolean }) {\n  const invalidate = useThree((s) => s.invalidate);\n  const group = useRef<THREE.Group>(null);\n  const rollMat = useRef<THREE.MeshStandardMaterial>(null);\n  const drapeMat = useRef<THREE.MeshStandardMaterial>(null);\n  const tex = useRef<{ canvas: HTMLCanvasElement; drape: THREE.CanvasTexture; roll: THREE.CanvasTexture } | null>(null);\n\n  /* one canvas of cloth, mapped onto the roll and the drape at their own repeats */\n  useLayoutEffect(() => {\n    const canvas = document.createElement(\"canvas\");\n    canvas.width = COLS * 12;\n    canvas.height = ROWS * 12;\n    const make = () => {\n      const t = new THREE.CanvasTexture(canvas);\n      t.colorSpace = THREE.SRGBColorSpace;\n      t.wrapS = THREE.RepeatWrapping;\n      t.wrapT = THREE.RepeatWrapping;\n      t.anisotropy = 8;\n      return t;\n    };\n    const drape = make();\n    const roll = make();\n    tex.current = { canvas, drape, roll };\n    if (rollMat.current) {\n      rollMat.current.map = roll;\n      rollMat.current.needsUpdate = true;\n    }\n    if (drapeMat.current) {\n      drapeMat.current.map = drape;\n      drapeMat.current.needsUpdate = true;\n    }\n    return () => {\n      drape.dispose();\n      roll.dispose();\n      tex.current = null;\n    };\n  }, []);\n\n  useLayoutEffect(() => {\n    const t = tex.current;\n    const ctx = t?.canvas.getContext(\"2d\");\n    if (!t || !ctx) return;\n    paintCloth(ctx, (x, y) => bit(card, x, y), COLS, ROWS, 12, warp, weft);\n    const r = close ? 1.2 : 3.6;\n    t.drape.repeat.set(r * 1.6, r * 1.4);\n    t.roll.repeat.set(r * 2.2, r * 1.6);\n    t.drape.needsUpdate = true;\n    t.roll.needsUpdate = true;\n    invalidate();\n  }, [card, warp, weft, close, invalidate]);\n\n  /* the drape: a sheet falling from the front of the roll, curling onto the table */\n  const drape = useMemo(() => {\n    const g = new THREE.PlaneGeometry(2.2, 1.7, 1, 24);\n    const p = g.getAttribute(\"position\") as THREE.BufferAttribute;\n    for (let i = 0; i < p.count; i++) {\n      const v = (0.85 - p.getY(i)) / 1.7;\n      const y = 0.0 - Math.sin(Math.min(v, 0.62) / 0.62 * (Math.PI / 2)) * 0.62;\n      const z = 0.38 + Math.max(0, v - 0.18) * 1.15 + Math.sin(v * Math.PI) * 0.05;\n      p.setXYZ(i, p.getX(i), y, z);\n    }\n    g.computeVertexNormals();\n    return g;\n  }, []);\n\n  useFrame((_, dt) => {\n    if (spin && group.current) group.current.rotation.y += Math.min(dt, 0.05) * 0.22;\n  });\n\n  return (\n    <group ref={group} position={[0, 0, -0.2]}>\n      <mesh rotation={[0, 0, Math.PI / 2]}>\n        <cylinderGeometry args={[0.38, 0.38, 2.2, 48, 1]} />\n        <meshStandardMaterial ref={rollMat} roughness={0.92} />\n      </mesh>\n      <mesh rotation={[0, 0, Math.PI / 2]}>\n        <cylinderGeometry args={[0.07, 0.07, 2.5, 16]} />\n        <meshStandardMaterial color={STEEL} roughness={0.35} metalness={0.7} />\n      </mesh>\n      <mesh geometry={drape}>\n        <meshStandardMaterial ref={drapeMat} roughness={0.95} side={THREE.DoubleSide} />\n      </mesh>\n      <mesh position={[0, -0.64, 0.5]} rotation={[-Math.PI / 2, 0, 0]}>\n        <planeGeometry args={[6, 5]} />\n        <meshStandardMaterial color=\"#1a1512\" roughness={1} />\n      </mesh>\n    </group>\n  );\n}\n\nconst BOLT_TARGET: [number, number, number] = [0, -0.15, 0.2];\n\nexport function BoltScene({\n  card,\n  warp,\n  weft,\n  close,\n  active,\n  reduce,\n  onReady,\n  fallback,\n}: {\n  card: Card;\n  warp: string;\n  weft: string;\n  close: boolean;\n  active: boolean;\n  reduce: boolean;\n  onReady: () => void;\n  fallback: ReactNode;\n}) {\n  const spin = active && !reduce;\n  const [cam] = useState<[number, number, number]>(() => (window.innerWidth < window.innerHeight ? [3.4, 2, 4.9] : [2.5, 1.45, 3.6]));\n  return (\n    <GLGate fallback={fallback}>\n      <Canvas\n        dpr={[1, 1.75]}\n        camera={{ position: cam, fov: 36, near: 0.1, far: 30 }}\n        frameloop={spin ? \"always\" : \"demand\"}\n        gl={{ antialias: true }}\n        onCreated={({ scene }) => {\n          scene.background = new THREE.Color(\"#191d21\");\n          scene.fog = new THREE.Fog(\"#191d21\", 4, 10);\n          requestAnimationFrame(onReady);\n        }}\n        aria-hidden=\"true\"\n      >\n        <hemisphereLight args={[\"#cdd6e8\", \"#2a1a14\", 1]} />\n        <directionalLight position={[-3, 3, 2]} intensity={2.6} color=\"#f3ecdf\" />\n        <directionalLight position={[2, 1, -2]} intensity={0.6} color=\"#9db3e6\" />\n        <Bolt card={card} warp={warp} weft={weft} close={close} spin={spin} />\n        <Orbit target={BOLT_TARGET} auto={false} minPolar={0.7} maxPolar={1.5} />\n      </Canvas>\n    </GLGate>\n  );\n}\n"},{"path":"components/nightmarquee/jacquard-hall/jacquard-hall/weave.ts","type":"registry:component","target":"components/nightmarquee/jacquard-hall/jacquard-hall/weave.ts","content":"/* Jacquard Hall weave model, shared by the page and the 3D scenes.\n   A card is COLS hooks by ROWS picks, stored row-major as a string of\n   \"1\" (punched: the hook lifts its warp thread, indigo shows) and \"0\"\n   (blank: the thread stays down, the linen weft shows). */\n\nexport const COLS = 24;\n/* NightMarquee design \"Jacquard Hall\". Free for personal, portfolio, educational and non-commercial use; no republishing: nightmarquee.com/license */\nexport const ROWS = 16;\nexport const SIZE = COLS * ROWS;\n\nexport type Card = string;\n\nconst make = (fn: (x: number, y: number) => boolean): Card => {\n  let s = \"\";\n  for (let y = 0; y < ROWS; y++) for (let x = 0; x < COLS; x++) s += fn(x, y) ? \"1\" : \"0\";\n  return s;\n};\n\n/* 2/2 twill: each pick steps the float one hook to the right. */\nconst twill = (x: number, y: number) => (x - y + 64) % 4 < 2;\n/* Lozenge: nested diamonds, 12 hooks by 8 picks, on a twill ground at the centre. */\nconst lozenge = (x: number, y: number) => {\n  const d = Math.abs((x % 12) - 5.5) / 6 + Math.abs((y % 8) - 3.5) / 4;\n  const ring = Math.floor(d * 3);\n  return ring === 0 ? twill(x, y) : ring % 2 === 1;\n};\n/* Bird's eye: a small diamond with a dot at its heart, 6 by 6. */\nconst birdseye = (x: number, y: number) => {\n  const d = Math.abs((x % 6) - 2.5) + Math.abs((y % 6) - 2.5);\n  return d <= 1 || d === 3;\n};\n/* Hopsack: pairs of threads working together. */\nconst hopsack = (x: number, y: number) => ((x >> 1) + (y >> 1)) % 2 === 0;\n/* Damask: a large lozenge in warp face on a weft-faced ground. */\nconst damask = (x: number, y: number) => {\n  const d = Math.abs(x - 11.5) / 12 + Math.abs(y - 7.5) / 8;\n  if (d < 0.62) return (x * 3 + y) % 5 !== 0;\n  return (x * 2 + y) % 5 === 0;\n};\n\nexport const PRESETS: { id: string; name: string; card: Card }[] = [\n  { id: \"lozenge\", name: \"Lozenge\", card: make(lozenge) },\n  { id: \"twill\", name: \"Twill\", card: make(twill) },\n  { id: \"birdseye\", name: \"Bird's eye\", card: make(birdseye) },\n];\n\nexport const HOUSE_CARD = PRESETS[0].card;\nexport const BLANK_CARD = \"0\".repeat(SIZE);\n\nexport const bit = (card: Card, x: number, y: number) => card.charCodeAt(y * COLS + x) === 49;\nexport const holes = (card: Card) => {\n  let n = 0;\n  for (let i = 0; i < card.length; i++) if (card.charCodeAt(i) === 49) n++;\n  return n;\n};\nexport const liftedOn = (card: Card, pick: number) => {\n  let n = 0;\n  for (let x = 0; x < COLS; x++) if (bit(card, x, pick)) n++;\n  return n;\n};\n\n/** The draft number a card travels under: FNV-1a over its holes, 4 hex digits. */\nexport function draftCode(card: Card) {\n  let h = 0x811c9dc5;\n  for (let i = 0; i < card.length; i++) {\n    h ^= card.charCodeAt(i);\n    h = Math.imul(h, 0x01000193) >>> 0;\n  }\n  return `JH-${(h & 0xffff).toString(16).toUpperCase().padStart(4, \"0\")}`;\n}\n\nexport const isCard = (s: unknown): s is Card => typeof s === \"string\" && s.length === SIZE && /^[01]+$/.test(s);\n\n/** The house cloths: each has its own card, warp and weft. */\nexport const CLOTHS = [\n  {\n    id: \"hall-twill\",\n    name: \"Hall twill\",\n    card: make(twill),\n    warp: \"#1f3a6b\",\n    weft: \"#d9cfbd\",\n    fibre: \"Linen warp, linen weft\",\n    weight: 290,\n    width: 150,\n    use: \"Upholstery and heavy curtains\",\n  },\n  {\n    id: \"birdseye\",\n    name: \"Bird's eye\",\n    card: make(birdseye),\n    warp: \"#142645\",\n    weft: \"#efe6cf\",\n    fibre: \"Cotton warp, linen weft\",\n    weight: 210,\n    width: 140,\n    use: \"Shirting and table linen\",\n  },\n  {\n    id: \"madder-hopsack\",\n    name: \"Madder hopsack\",\n    card: make(hopsack),\n    warp: \"#d9cfbd\",\n    weft: \"#9a4a33\",\n    fibre: \"Linen warp, wool weft\",\n    weight: 340,\n    width: 150,\n    use: \"Jackets and cushion covers\",\n  },\n  {\n    id: \"calder-damask\",\n    name: \"Calder damask\",\n    card: make(damask),\n    warp: \"#1f3a6b\",\n    weft: \"#efe6cf\",\n    fibre: \"Cotton warp, linen weft\",\n    weight: 260,\n    width: 137,\n    use: \"Wall panels and drapery\",\n  },\n];\n\n/**\n * Paints cloth into a 2D context: a warp float (lifted thread) is a vertical stroke in the\n * warp colour, a weft float a horizontal stroke in the weft colour, each with its own shade\n * and highlight so the cells read as threads, not pixels.\n */\nexport function paintCloth(\n  ctx: CanvasRenderingContext2D,\n  up: (x: number, y: number) => boolean,\n  cols: number,\n  rows: number,\n  cell: number,\n  warp: string,\n  weft: string,\n) {\n  const c = cell;\n  const t = Math.max(1, Math.round(c * 0.16));\n  for (let y = 0; y < rows; y++) {\n    for (let x = 0; x < cols; x++) {\n      const px = x * c;\n      const py = y * c;\n      if (up(x, y)) {\n        ctx.fillStyle = warp;\n        ctx.fillRect(px, py, c, c);\n        ctx.fillStyle = \"rgba(255,255,255,.16)\";\n        ctx.fillRect(px + Math.round(c * 0.3), py + 1, t, c - 2);\n        ctx.fillStyle = \"rgba(0,0,0,.32)\";\n        ctx.fillRect(px + c - t, py, t, c);\n      } else {\n        ctx.fillStyle = weft;\n        ctx.fillRect(px, py, c, c);\n        ctx.fillStyle = \"rgba(255,255,255,.2)\";\n        ctx.fillRect(px + 1, py + Math.round(c * 0.3), c - 2, t);\n        ctx.fillStyle = \"rgba(0,0,0,.24)\";\n        ctx.fillRect(px, py + c - t, c, t);\n      }\n    }\n  }\n}\n"},{"path":"components/nightmarquee/jacquard-hall/lib/drop-media.ts","type":"registry:component","target":"components/nightmarquee/jacquard-hall/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 \"Jacquard Hall\". 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/jacquard-hall/lib/media-manifest.json","type":"registry:component","target":"components/nightmarquee/jacquard-hall/lib/media-manifest.json","content":"{\n  \"base\": \"https://media.nightmarquee.com\",\n  \"files\": {\n    \"/drops/jacquard-hall/ambient-m.mp4\": \"drops/jacquard-hall/ambient-m.c06d993096.mp4\",\n    \"/drops/jacquard-hall/ambient.mp4\": \"drops/jacquard-hall/ambient.c5f0638410.mp4\",\n    \"/drops/jacquard-hall/hero-m.mp4\": \"drops/jacquard-hall/hero-m.8e18e4a131.mp4\",\n    \"/drops/jacquard-hall/hero.mp4\": \"drops/jacquard-hall/hero.333b22f652.mp4\",\n    \"/drops/jacquard-hall/preview.mp4\": \"drops/jacquard-hall/preview.aa10828efc.mp4\",\n    \"/drops/jacquard-hall/site-hover.mp4\": \"drops/jacquard-hall/site-hover.e2a50324f3.mp4\",\n    \"/drops/jacquard-hall/site-preview.mp4\": \"drops/jacquard-hall/site-preview.80c4f3b2b8.mp4\"\n  }\n}\n"},{"path":"components/nightmarquee/jacquard-hall/lib/media.ts","type":"registry:component","target":"components/nightmarquee/jacquard-hall/lib/media.ts","content":"import manifest from \"./media-manifest.json\";\n/* NightMarquee design \"Jacquard Hall\". 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/jacquard-hall/page.tsx","type":"registry:page","target":"app/jacquard-hall/page.tsx","content":"import type { Metadata } from \"next\";\n/* NightMarquee design \"Jacquard Hall\". Free for personal, portfolio, educational and non-commercial use; no republishing: nightmarquee.com/license */\nimport { Demo } from \"../../components/nightmarquee/jacquard-hall/jacquard-hall/demo\";\n\nexport const metadata: Metadata = {\n  title: \"Jacquard Hall\",\n  description: \"A brick mill opens on a filmed orbit of a jacquard loom, scrubbed by scroll, with a punch card you draw into on the first screen. A React Three Fiber loom lifts its warp threads from your card and weaves the cloth pick by pick, then 4 house cloths turn on their bolts. The mill-visit form arrives with your card attached as a weave draft.\",\n};\n\nexport default function Page() {\n  return <Demo />;\n}\n"}],"docs":"The page is at app/jacquard-hall/page.tsx.\nIts footage streams from media.nightmarquee.com.\nUse is covered by the NightMarquee licence: nightmarquee.com/license","meta":{"mappingVersion":3}}