{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ray-marched-wireless-headphones-product-hero-in-matte-plastic-and-leather-on-a-paper-sweep-that-recolours-with-each-swatch","type":"registry:block","title":"Ray-Marched Wireless Headphones Product Hero in Matte Plastic and Leather on a Paper Sweep That Recolours With Each Swatch","description":"Free React product hero: wireless headphones traced in a WebGL shader, matte plastic and soft leather you turn by dragging, with swatches that restyle the set.","dependencies":[],"files":[{"path":"components/we-inc/ray-marched-wireless-headphones-product-hero-in-matte-plastic-and-leather-on-a-paper-sweep-that-recolours-with-each-swatch.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\n// Everything a visitor would edit first.\nconst product = {\n  maker: \"Ondelle Sound\",\n  kind: \"Over-ear, wireless\",\n  name: [\"Lull\", \"One\"],\n  price: \"$249\",\n  cta: \"Add to bag\",\n  note: \"Example price. Folding yokes, carry pouch included.\",\n};\n// The colourways. Each dresses the shell, the cushions and the paper behind them. Plain sRGB hex; the shader converts them.\nconst colourways = [\n  { name: \"Clay\", shell: \"#d0603f\", leather: \"#efe2cc\", paper: \"#eaa47c\" },\n  { name: \"Sage\", shell: \"#8aa585\", leather: \"#3a3a2c\", paper: \"#c4d4a0\" },\n  { name: \"Sky\", shell: \"#86acd6\", leather: \"#f2e9d8\", paper: \"#a8c6e6\" },\n  { name: \"Butter\", shell: \"#efcb5f\", leather: \"#6a472b\", paper: \"#f0cd66\" },\n  { name: \"Ink\", shell: \"#2b2e36\", leather: \"#1c1c1f\", paper: \"#bcb5a8\" },\n];\nconst HERO = 0.62; // resting turn in radians: three quarters, the left cushion toward the lens\nconst SWAP = 1.6; // seconds a new colour takes to sweep across the shell\nconst INK = \"#1a1612\";\nconst FONT = '\"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif';\nconst SERIF = '\"Iowan Old Style\", \"Palatino Linotype\", Palatino, \"Book Antiqua\", Georgia, serif';\n\nconst lin = (hex: string) => [1, 3, 5].map((i) => Math.pow(parseInt(hex.slice(i, i + 2), 16) / 255, 2.2));\n\n// Where the camera stands for a frame of this size.\nfunction frameOf(w: number, h: number) {\n  const desk = w >= 1024, wide = w >= 768, aspect = w / h;\n  const dist = 9, el = desk ? 0.24 : 0.27;\n  const foc = desk ? Math.min(2.55, 1.5 * aspect) : wide ? Math.min(2.3, 1.45 * aspect) : Math.min(2.0, (dist * aspect) / 3.35);\n  const tgt = [0, 1.08, 0];\n  const cam = [0, tgt[1] + dist * Math.sin(el), -dist * Math.cos(el)];\n  const fx = desk ? 0.665 : wide ? 0.64 : 0.5, fy = desk ? 0.46 : wide ? 0.44 : 0.255;\n  const shift = [(fx - 0.5) * aspect, 0.5 - fy];\n  const fw = [0, -Math.sin(el), Math.cos(el)], up = [0, Math.cos(el), Math.sin(el)];\n  const project = (x: number, y: number, z: number) => {\n    const v = [x - cam[0], y - cam[1], z - cam[2]];\n    const d = v[1] * fw[1] + v[2] * fw[2];\n    return { x: w / 2 + ((v[0] / d) * foc + shift[0]) * h, y: h / 2 - (((v[1] * up[1] + v[2] * up[2]) / d) * foc + shift[1]) * h, k: (foc / d) * h };\n  };\n  return { dist, el, foc, tgt, cam, shift, project };\n}\n\nconst VERT = `ATTR vec2 aPos; void main(){ gl_Position = vec4(aPos, 0.0, 1.0); }`;\n\nconst TONE = `\nvec3 tone(vec3 x){ vec3 c = 1.0 - exp(-max(x, 0.0) * 1.0); c = mix(c, c * c * (3.0 - 2.0 * c), 0.45); return pow(c, vec3(1.0 / 2.2)); }\n`;\n\n// The photograph: a paper sweep in daylight, a round card, and a pair of headphones standing on their cushions.\nconst SCENE = `\nprecision highp float;\nuniform vec2 uRes; uniform vec4 uJit; uniform float uSeed; uniform float uDirect;\nuniform vec3 uCam; uniform vec3 uTgt; uniform float uFoc; uniform vec2 uShift; uniform float uFocus;\nuniform float uRot; uniform float uLift; uniform vec3 uSun;\nuniform vec3 uOldS; uniform vec3 uNewS; uniform vec3 uOldL; uniform vec3 uNewL; uniform float uProg;\nuniform vec3 uPaper; uniform vec3 uCard;\nvec3 gRnd;\nconst float ZW = 3.6; const float RC = 1.3; const float TOP = 9.0; const float TOPR = 1.6;\nconst float PH = 0.1; const float PR = 1.48;\nconst float CX = 0.9; const float CY = 0.52; const float BC = 1.24; const float RB = 0.93; const float YTOP = 2.26;\nconst vec3 SUNC = vec3(1.0, 0.96, 0.9); const float SUNI = 2.6;\n${TONE}\nfloat h21(vec2 p){ vec3 q = fract(vec3(p.xyx) * 0.1031); q += dot(q, q.yzx + 33.33); return fract((q.x + q.y) * q.z); }\nfloat n2(vec2 x){ vec2 i = floor(x); vec2 f = fract(x); f = f * f * (3.0 - 2.0 * f);\n  return mix(mix(h21(i), h21(i + vec2(1.0, 0.0)), f.x), mix(h21(i + vec2(0.0, 1.0)), h21(i + vec2(1.0, 1.0)), f.x), f.y); }\nfloat smin(float a, float b, float k){ float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0); return mix(b, a, h) - k * h * (1.0 - h); }\nfloat smax(float a, float b, float k){ return -smin(-a, -b, k); }\nfloat rbox2(vec2 w, float r){ return min(max(w.x, w.y), 0.0) + length(max(w, 0.0)) - r; }\n\nvec3 toLocalDir(vec3 v){ float s = sin(uRot); float c = cos(uRot); return vec3(c * v.x + s * v.z, v.y, -s * v.x + c * v.z); }\nvec3 toWorldDir(vec3 v){ float s = sin(uRot); float c = cos(uRot); return vec3(c * v.x - s * v.z, v.y, s * v.x + c * v.z); }\nvec3 toLocal(vec3 p){ return toLocalDir(vec3(p.x, p.y - uLift - PH, p.z)); }\n\n// The parts, each in the headphones' own frame. a is the point folded onto the right-hand side.\nfloat ovalR(vec3 p){ return length(vec2(p.y * 0.94, p.z * 1.1)); }\nfloat dShell(vec3 a){ vec3 p = a - vec3(CX + 0.04, CY, 0.0); float r = ovalR(p);\n  // a soft dome on the outer face, flat where the cushion sits\n  float dome = 0.05 * (1.0 - smoothstep(0.0, 0.42, r));\n  float d = rbox2(vec2(r - 0.38, abs(p.x - 0.5 * dome) - 0.1 - 0.5 * dome), 0.075);\n  // a fine parting groove round the outer face, where the cap meets the cup\n  float g = length(vec2(r - 0.33, p.x - 0.19 - 0.5 * dome)) - 0.012;\n  return smax(d, -g, 0.006); }\nfloat dCush(vec3 a){ vec3 p = a - vec3(CX - 0.15, CY, 0.0); float r = ovalR(p);\n  return (length(vec2(r - 0.285, p.x * 1.25)) - 0.125) * 0.8; }\nfloat dFork(vec3 a){ vec3 p = a - vec3(CX + 0.04, CY, 0.0);\n  float ring = length(vec2(length(vec2(p.y * 0.94, p.z * 1.1)) - 0.5, p.x)) - 0.026;\n  float rod = length(vec2(p.x, p.z)) - 0.034; rod = max(rod, abs(p.y - 0.62) - 0.14);\n  return min(smax(ring, -p.y - 0.02, 0.03), rod); }\nfloat dBand(vec3 q){ vec3 p = q - vec3(0.0, BC, 0.0); float r = length(p.xy);\n  float b = rbox2(abs(vec2(r - RB, p.z)) - vec2(0.03, 0.105), 0.03);\n  // the slider block at each end, where the band takes the rod\n  vec3 e = abs(vec3(abs(p.x) - RB, p.y - 0.02, p.z)) - vec3(0.035, 0.07, 0.09);\n  float blk = length(max(e, 0.0)) + min(max(e.x, max(e.y, e.z)), 0.0) - 0.03;\n  return min(smax(b, -p.y + 0.06, 0.02), blk); }\nfloat dPad(vec3 q){ vec3 p = q - vec3(0.0, BC, 0.0); float r = length(p.xy);\n  float d = rbox2(abs(vec2(r - RB + 0.085, p.z)) - vec2(0.025, 0.07), 0.035);\n  return smax(smax(d, abs(p.x) - 0.6, 0.18), -p.y, 0.02); }\nfloat dHead(vec3 q){\n  vec3 a = vec3(abs(q.x), q.y, q.z);\n  float d = min(dShell(a), dCush(a));\n  d = min(d, dFork(a));\n  d = min(d, min(dBand(q), dPad(q)));\n  return d;\n}\nvec3 nHead(vec3 q){ vec2 e = vec2(0.0018, -0.0018); return normalize(e.xyy * dHead(q + e.xyy) + e.yyx * dHead(q + e.yyx) + e.yxy * dHead(q + e.yxy) + e.xxx * dHead(q + e.xxx)); }\n\n// The round card the headphones stand on, a finger thick.\nfloat dCard(vec3 p){ vec2 w = vec2(length(p.xz) - PR + 0.02, abs(p.y - 0.5 * PH) - 0.5 * PH + 0.02); return min(max(w.x, w.y), 0.0) + length(max(w, 0.0)) - 0.02; }\nvec3 nCard(vec3 p){ vec2 e = vec2(0.0016, -0.0016); return normalize(e.xyy * dCard(p + e.xyy) + e.yyx * dCard(p + e.yyx) + e.yxy * dCard(p + e.yxy) + e.xxx * dCard(p + e.xxx)); }\n\nvec2 bound(vec3 ro, vec3 rd){\n  float a = dot(rd.xz, rd.xz); float b = dot(ro.xz, rd.xz); float c = dot(ro.xz, ro.xz) - 1.5;\n  float h = b * b - a * c; if (h < 0.0 || a < 1e-6) return vec2(1.0, -1.0);\n  h = sqrt(h); float t0 = (-b - h) / a; float t1 = (-b + h) / a;\n  float y0 = PH + uLift - 0.01; float y1 = PH + uLift + YTOP;\n  if (abs(rd.y) > 1e-5) { float ya = (y0 - ro.y) / rd.y; float yb = (y1 - ro.y) / rd.y; t0 = max(t0, min(ya, yb)); t1 = min(t1, max(ya, yb)); }\n  else if (ro.y < y0 || ro.y > y1) return vec2(1.0, -1.0);\n  return vec2(max(t0, 0.0), t1);\n}\nfloat march(vec3 ro, vec3 rd){\n  vec2 tb = bound(ro, rd); if (tb.x > tb.y) return -1.0;\n  float t = tb.x;\n  for (int i = 0; i < 96; i++) { float d = dHead(toLocal(ro + rd * t)); if (d < 0.0008) return t; t += d * 0.9; if (t > tb.y) break; }\n  return -1.0;\n}\nfloat marchLo(vec3 ro, vec3 rd){\n  vec2 tb = bound(ro, rd); if (tb.x > tb.y) return -1.0;\n  float t = max(tb.x, 0.015);\n  for (int i = 0; i < 32; i++) { float d = dHead(toLocal(ro + rd * t)); if (d < 0.003) return t; t += d * 0.95; if (t > tb.y) break; }\n  return -1.0;\n}\nfloat marchCard(vec3 ro, vec3 rd){\n  if (rd.y > -1e-4) return -1.0;\n  float t = max((PH + 0.01 - ro.y) / rd.y, 0.0); float t1 = -ro.y / rd.y;\n  for (int i = 0; i < 24; i++) { float d = dCard(ro + rd * t); if (d < 0.0008) return t; t += d; if (t > t1) break; }\n  return -1.0;\n}\n\n// The studio: warm walls, a big window camera left, a strip light camera right, a scrim overhead and the sun.\nvec3 env(vec3 rd){\n  float el = asin(clamp(rd.y, -1.0, 1.0)); float az = atan(rd.x, -rd.z);\n  vec3 c = mix(uPaper * 0.35 + 0.04, vec3(0.55, 0.5, 0.44), smoothstep(-0.1, 0.6, rd.y));\n  c += vec3(1.0, 0.99, 0.97) * (0.5 * smoothstep(0.42, 0.8, el) + 1.8 * smoothstep(0.86, 1.2, el));\n  vec2 w = abs(vec2(az + 0.9, el - 0.45)) - vec2(0.42, 0.34);\n  c += vec3(1.0, 0.98, 0.95) * 5.0 * smoothstep(0.06, -0.06, max(w.x, w.y));\n  vec2 w2 = abs(vec2(az - 1.0, el - 0.4)) - vec2(0.12, 0.45);\n  c += vec3(0.95, 0.98, 1.0) * 3.2 * smoothstep(0.05, -0.05, max(w2.x, w2.y));\n  c += SUNC * 26.0 * smoothstep(0.9965, 0.9992, dot(rd, uSun));\n  return c;\n}\nvec3 ambient(vec3 n){ return mix(uCard * 1.2 + 0.03, vec3(1.0, 0.98, 0.95) * 0.72, 0.5 + 0.5 * n.y); }\n\n// How much sun reaches a point: soft where the blocker is far, crisp where it touches.\nfloat sunVis(vec3 p){\n  float res = 1.0;\n  vec2 tb = bound(p, uSun);\n  if (tb.x < tb.y) {\n    float t = max(tb.x, 0.02);\n    for (int i = 0; i < 30; i++) { float h = dHead(toLocal(p + uSun * t)); res = min(res, 8.0 * h / t); t += clamp(h, 0.02, 0.25); if (res < 0.004 || t > tb.y) break; }\n  }\n  res = clamp(res, 0.0, 1.0); return res * res * (3.0 - 2.0 * res);\n}\n\nfloat hitStage(vec3 ro, vec3 rd, float top, out vec3 n){\n  n = vec3(0.0, 1.0, 0.0);\n  if (rd.y < 0.0) { float tf = -ro.y / rd.y; float z = ro.z + rd.z * tf; if (z < ZW - RC) return tf; }\n  if (rd.z > 0.0) { float tw = (ZW - ro.z) / rd.z; float y = ro.y + rd.y * tw; if (y > top) return -1.0; if (y > RC) { n = vec3(0.0, 0.0, -1.0); return tw; } }\n  vec2 o = ro.yz - vec2(RC, ZW - RC); float a = dot(rd.yz, rd.yz); float b = dot(o, rd.yz); float h = b * b - a * (dot(o, o) - RC * RC);\n  if (h > 0.0 && a > 1e-7) { float tc = (-b + sqrt(h)) / a; vec2 pc = ro.yz + rd.yz * tc; if (tc > 0.0 && pc.x < RC + 0.02 && pc.y > ZW - RC - 0.02) { vec2 nn = (vec2(RC, ZW - RC) - pc) / RC; n = vec3(0.0, nn.x, nn.y); return tc; } }\n  return -1.0;\n}\nfloat paperTooth(vec2 pq){ return 0.5 * (n2(pq * 150.0) - 0.5) + 0.3 * (n2(pq * 61.0 + 7.0) - 0.5) + 0.3 * (n2(pq * vec2(9.0, 240.0)) - 0.5); }\nvec3 stage(vec3 ro, vec3 rd, float full){\n  vec3 n; float t = hitStage(ro, rd, full > 0.5 ? TOP : TOPR, n);\n  if (t < 0.0) return env(rd);\n  vec3 p = ro + rd * t;\n  vec2 pq = p.xy + p.z * vec2(0.37, 0.81);\n  vec3 alb = uPaper * (1.0 + 0.06 * paperTooth(pq) + 0.08 * (n2(pq * 1.7) - 0.5));\n  float ndl = max(dot(n, uSun), 0.0);\n  float vis = 1.0; float occ = 1.0;\n  if (full > 0.5) {\n    vis = ndl > 0.0 ? sunVis(p + n * 0.004) : 0.0;\n    float dc = dCard(p + n * 0.03);\n    occ = 0.55 + 0.45 * smoothstep(0.0, 0.14, dc);\n  } else {\n    if (n.y > 0.9) alb = mix(alb, uCard, smoothstep(PR + 0.1, PR - 0.1, length(p.xz)));\n    occ = 0.5 + 0.5 * smoothstep(0.4, 1.2, length(p.xz));\n  }\n  vec2 wq = p.xy - vec2(0.4, 1.2); float wash = exp(-dot(wq, wq) / 18.0);\n  vec3 fill = mix(uPaper * 1.2 + 0.04, vec3(0.9, 0.88, 0.85), 0.5 + 0.5 * n.y) * (1.0 + (1.2 * wash - 0.3) * (1.0 - n.y)) * 0.8;\n  ndl *= 1.0 - 0.45 * smoothstep(0.6, 2.8, p.y);\n  vec2 kq = p.xz - vec2(0.3, -0.2); float pool = 0.72 + 0.4 * exp(-dot(kq, kq) / 24.0);\n  return alb * (SUNC * SUNI * pool * ndl * vis + fill * occ * (1.0 - 0.2 * n.y));\n}\n\n// What the headphones are made of at a point. x: 0 shell plastic, 1 leather, 2 metal, 3 cloth over the driver.\nvec4 skin(vec3 q){\n  vec3 a = vec3(abs(q.x), q.y, q.z);\n  float ds = dShell(a), dc = dCush(a), df = dFork(a), db = dBand(q), dp = dPad(q);\n  // a new colour sweeps from the left cup, over the band, to the right one\n  float s = q.x + 0.12 * sin(q.y * 6.0 + q.z * 4.0);\n  float k = smoothstep(-0.03, 0.03, (uProg * 3.0 - 1.5) - s);\n  vec3 shell = mix(uOldS, uNewS, k); vec3 lea = mix(uOldL, uNewL, k);\n  float m = min(min(ds, dc), min(df, min(db, dp)));\n  if (m == df) return vec4(vec3(0.3, 0.29, 0.28), 2.0);\n  if (m == dc || m == dp) return vec4(lea, 1.0);\n  if (m == ds && a.x < CX - 0.06) return vec4(lea * 0.35 + 0.01, 3.0);\n  return vec4(shell, 0.0);\n}\n\n// A mirror ray: the headphones again (roughly lit), or the set.\nvec3 mirror(vec3 ro, vec3 rd){\n  float t = marchLo(ro, rd);\n  if (t > 0.0) {\n    vec3 q = toLocal(ro + rd * t); vec3 n = toWorldDir(nHead(q)); vec4 sk = skin(q);\n    return sk.rgb * (SUNC * SUNI * max(dot(n, uSun), 0.0) * 0.55 + ambient(n) * 0.6);\n  }\n  return stage(ro, rd, 0.0);\n}\nfloat aoHead(vec3 p, vec3 n){\n  float a = 0.0; float w = 1.0;\n  for (int i = 1; i <= 5; i++) { float d = 0.03 * float(i) + 0.012 * float(i * i); float h = min(dHead(toLocal(p + n * d)), p.y + n.y * d - PH); a += w * (d - h); w *= 0.6; }\n  return clamp(1.0 - 2.2 * a, 0.0, 1.0);\n}\n\nvec3 shadeHead(vec3 p, vec3 rd){\n  vec3 q = toLocal(p); vec3 nl = nHead(q);\n  vec4 sk = skin(q); float id = sk.a;\n  // surface texture: leather grain and stitched creases, a fine spark erosion on the plastic\n  vec3 aq = vec3(abs(q.x), q.y, q.z);\n  if (id == 1.0) {\n    float g = n2(aq.yz * 70.0 + aq.x * 31.0) + 0.5 * n2(aq.zy * 160.0 + aq.x * 11.0);\n    float ang = atan(q.z, q.y - CY); float cr = pow(n2(vec2(ang * 16.0, aq.x * 9.0)), 2.0) * smoothstep(0.42, 0.25, length(vec2(q.y - CY, q.z)));\n    nl = normalize(nl + 0.07 * (vec3(g, n2(aq.xz * 80.0), n2(aq.xy * 80.0)) - 0.6) + 0.16 * (cr - 0.2) * vec3(0.0, cos(ang), sin(ang)));\n  } else if (id == 0.0) {\n    nl = normalize(nl + 0.018 * (vec3(n2(aq.yz * 220.0), n2(aq.xz * 220.0), n2(aq.xy * 220.0)) - 0.5));\n  }\n  vec3 n = toWorldDir(nl);\n  float ndl = max(dot(n, uSun), 0.0);\n  float vis = ndl > 0.0 ? sunVis(p + n * 0.012) : 0.0;\n  float ao = aoHead(p, n);\n  vec3 alb = sk.rgb;\n  if (id == 1.0) alb *= 0.9 + 0.2 * n2(aq.yz * 9.0 + aq.x * 5.0);\n  if (id == 0.0) alb *= 0.97 + 0.06 * n2(aq.yz * 4.0 + aq.x * 3.0);\n  // matte plastic lets a little light into its skin, so the turned-away side never goes dead\n  float wrap = id == 0.0 ? 0.18 : (id == 1.0 ? 0.1 : 0.0);\n  float diff = max((dot(n, uSun) + wrap) / (1.0 + wrap), 0.0) * mix(vis, 1.0, wrap * 0.5);\n  vec3 col = alb * (SUNC * SUNI * diff + ambient(n) * ao);\n  float rough = id == 0.0 ? 0.42 : (id == 1.0 ? 0.55 : (id == 2.0 ? 0.3 : 0.9));\n  vec3 h = normalize(uSun - rd); float ndh = max(dot(n, h), 0.0);\n  float e = 2.0 / (rough * rough * rough * rough) - 2.0;\n  float nv = clamp(dot(-rd, n), 0.0, 1.0);\n  float f0 = id == 2.0 ? 0.6 : 0.045;\n  float f = f0 + (1.0 - f0) * pow(1.0 - nv, 5.0);\n  vec3 tint = id == 2.0 ? alb : vec3(1.0);\n  col += tint * SUNC * SUNI * vis * ndl * pow(ndh, e) * (e + 8.0) / 25.0 * f * (id == 3.0 ? 0.0 : 1.0);\n  // leather has a soft sheen at grazing angles\n  if (id == 1.0) col += alb * 0.35 * pow(1.0 - nv, 3.0) * ao;\n  vec3 r = normalize(reflect(rd, n) + gRnd * rough * 0.9);\n  vec3 refl = mirror(p + n * 0.012, r);\n  float kr = f * (1.0 - rough * 0.75) * (id == 3.0 ? 0.0 : 1.0);\n  return col * (1.0 - kr * (id == 2.0 ? 0.6 : 0.2)) + refl * tint * kr * (0.4 + 0.6 * ao);\n}\n\nvec3 shadeCard(vec3 p, vec3 rd){\n  vec3 n = nCard(p);\n  vec3 alb = uCard * (1.0 + 0.08 * paperTooth(p.xz) + 0.08 * (n2(p.xz * 2.3) - 0.5));\n  float ndl = max(dot(n, uSun), 0.0);\n  float vis = ndl > 0.0 ? sunVis(p + n * 0.004) : 0.0;\n  float dm = dHead(toLocal(p + n * 0.04));\n  float occ = (0.3 + 0.7 * smoothstep(0.0, 0.45, dm)) * (0.6 + 0.4 * smoothstep(0.0, 0.08, p.y + 0.05 * n.y));\n  vec3 bleed = mix(uOldS, uNewS, uProg) * 0.4 * exp(-max(dm, 0.0) * 6.0);\n  vec3 fill = mix(uPaper * 1.4 + 0.08, vec3(1.0, 0.98, 0.95), 0.5 + 0.5 * n.y);\n  return alb * (SUNC * SUNI * 1.05 * ndl * vis + fill * occ * (1.0 - 0.2 * n.y) + bleed);\n}\n\nvoid main(){\n  vec2 fc = gl_FragCoord.xy + uJit.xy;\n  vec2 uv = (fc - 0.5 * uRes) / uRes.y - uShift;\n  vec3 fw = normalize(uTgt - uCam); vec3 rt = normalize(cross(vec3(0.0, 1.0, 0.0), fw)); vec3 up = cross(fw, rt);\n  vec3 rd = normalize(fw * uFoc + rt * uv.x + up * uv.y);\n  vec3 ro = uCam;\n  vec3 fp = ro + rd * (uFocus / dot(rd, fw));\n  ro += rt * uJit.z + up * uJit.w; rd = normalize(fp - ro);\n  float ign = fract(52.9829189 * fract(dot(gl_FragCoord.xy, vec2(0.06711056, 0.00583715))) + uSeed);\n  gRnd = uSeed > 0.001 ? (vec3(h21(gl_FragCoord.xy + ign * 17.0), h21(gl_FragCoord.yx + ign * 31.0), ign) - 0.5) * 2.0 : vec3(0.0);\n  float tm = march(ro, rd); float tc = marchCard(ro, rd);\n  vec3 col;\n  if (tm > 0.0 && (tc < 0.0 || tm < tc)) col = shadeHead(ro + rd * tm, rd);\n  else if (tc > 0.0) col = shadeCard(ro + rd * tc, rd);\n  else col = stage(ro, rd, 1.0);\n  col = min(col, vec3(14.0));\n  if (uDirect > 0.5) col = tone(col);\n  outC = vec4(col, 1.0);\n}\n`;\n\n// Developing the negative: bloom off hot glints, the film curve, a soft vignette and grain.\nconst POST = `\nprecision highp float;\nuniform sampler2D uAcc; uniform vec2 uRes; uniform float uGrain; uniform vec2 uCentre;\n${TONE}\nfloat h21(vec2 p){ vec3 q = fract(vec3(p.xyx) * 0.1031); q += dot(q, q.yzx + 33.33); return fract((q.x + q.y) * q.z); }\nvoid main(){\n  vec2 uv = gl_FragCoord.xy / uRes;\n  vec3 c = texture2D(uAcc, uv).rgb;\n  vec2 px = 1.0 / uRes;\n  vec3 nb = texture2D(uAcc, uv + vec2(px.x, 0.0)).rgb + texture2D(uAcc, uv - vec2(px.x, 0.0)).rgb + texture2D(uAcc, uv + vec2(0.0, px.y)).rgb + texture2D(uAcc, uv - vec2(0.0, px.y)).rgb;\n  c = max(c + (c - nb * 0.25) * 0.35, 0.0);\n  vec3 b = vec3(0.0);\n  for (int i = 0; i < 16; i++) {\n    float a = float(i) * 2.39996; float r = sqrt((float(i) + 0.5) / 16.0);\n    vec3 s = texture2D(uAcc, uv + vec2(cos(a), sin(a)) * r * 0.02 * vec2(uRes.y / uRes.x, 1.0)).rgb;\n    b += min(max(s - 3.0, 0.0), vec3(8.0)) * (1.0 - 0.6 * r);\n  }\n  c += b * 0.016;\n  vec2 q = (uv - uCentre) * vec2(uRes.x / uRes.y, 1.0);\n  c *= 1.0 - 0.14 * smoothstep(0.4, 1.3, length(q));\n  c = tone(c);\n  float g = h21(gl_FragCoord.xy + uGrain * 91.7) - 0.5;\n  c += g * 0.016 * (1.0 - 0.4 * c.g);\n  outC = vec4(c, 1.0);\n}\n`;\n\ntype Spot = { x: number; y: number; k: number };\n\n// No WebGL: the same headphones drawn as a lit vector still at the same spot and scale (k pixels per scene unit).\nfunction Still({ at, sel }: { at: Spot; sel: number }) {\n  const c = colourways[sel];\n  const k = at.k;\n  return (\n    <svg aria-hidden=\"true\" className=\"absolute overflow-visible\" style={{ left: at.x - 1.6 * k, top: at.y - 2.5 * k, width: 3.2 * k, height: 2.9 * k }} viewBox=\"-1.6 -2.5 3.2 2.9\">\n      <defs>\n        <radialGradient id=\"hp-still-cup\" cx=\"0.35\" cy=\"0.3\" r=\"0.8\">\n          <stop offset=\"0\" stopColor=\"#fff\" stopOpacity=\"0.45\" />\n          <stop offset=\"0.5\" stopColor=\"#fff\" stopOpacity=\"0\" />\n          <stop offset=\"1\" stopColor=\"#000\" stopOpacity=\"0.35\" />\n        </radialGradient>\n        <radialGradient id=\"hp-still-shadow\" cx=\"0.5\" cy=\"0.5\" r=\"0.5\">\n          <stop offset=\"0\" stopColor=\"#000\" stopOpacity=\"0.35\" />\n          <stop offset=\"1\" stopColor=\"#000\" stopOpacity=\"0\" />\n        </radialGradient>\n      </defs>\n      <ellipse cx=\"0.25\" cy=\"0.04\" rx=\"1.5\" ry=\"0.3\" fill=\"url(#hp-still-shadow)\" />\n      <ellipse cx=\"0\" cy=\"0.02\" rx=\"1.45\" ry=\"0.32\" fill=\"#000\" fillOpacity=\"0.12\" />\n      <path d=\"M -0.62 -1.3 A 0.66 0.58 0 0 1 0.62 -1.3\" fill=\"none\" stroke={c.leather} strokeWidth=\"0.08\" strokeLinecap=\"round\" style={{ transition: \"stroke 600ms\" }} />\n      <path d=\"M -0.86 -0.9 A 0.88 1.05 0 0 1 0.86 -0.9\" fill=\"none\" stroke={c.shell} strokeWidth=\"0.15\" strokeLinecap=\"round\" style={{ transition: \"stroke 600ms\" }} />\n      <rect x=\"-0.92\" y=\"-1.05\" width=\"0.06\" height=\"0.3\" fill=\"#9b968f\" />\n      <rect x=\"0.86\" y=\"-1.05\" width=\"0.06\" height=\"0.3\" fill=\"#9b968f\" />\n      <ellipse cx=\"0.72\" cy=\"-0.5\" rx=\"0.3\" ry=\"0.5\" fill={c.leather} style={{ transition: \"fill 600ms\" }} />\n      <ellipse cx=\"-0.86\" cy=\"-0.5\" rx=\"0.26\" ry=\"0.5\" fill={c.shell} style={{ transition: \"fill 600ms\" }} />\n      <ellipse cx=\"-0.86\" cy=\"-0.5\" rx=\"0.26\" ry=\"0.5\" fill=\"url(#hp-still-cup)\" />\n      <ellipse cx=\"0.92\" cy=\"-0.5\" rx=\"0.24\" ry=\"0.49\" fill={c.shell} style={{ transition: \"fill 600ms\" }} />\n      <ellipse cx=\"0.92\" cy=\"-0.5\" rx=\"0.24\" ry=\"0.49\" fill=\"url(#hp-still-cup)\" />\n    </svg>\n  );\n}\n\nexport default function RayMarchedWirelessHeadphonesHero() {\n  const stage = useRef<HTMLDivElement>(null);\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const hit = useRef<HTMLDivElement>(null);\n  const [shown, setShown] = useState<\"wait\" | \"gl\" | \"still\">(\"wait\");\n  const [sel, setSel] = useState(0);\n  const [bag, setBag] = useState(0);\n  const [spot, setSpot] = useState<Spot | null>(null);\n  const api = useRef<{ swap: (i: number) => void; hop: () => void; turn: () => void } | null>(null);\n\n  useEffect(() => {\n    const box = stage.current;\n    if (!box) return;\n    const place = () => {\n      const r = box.getBoundingClientRect();\n      const f = frameOf(Math.max(1, r.width), Math.max(1, r.height));\n      setSpot(f.project(0, 0.1, 0));\n    };\n    place();\n    const ro = new ResizeObserver(place);\n    ro.observe(box);\n    return () => ro.disconnect();\n  }, []);\n\n  useEffect(() => {\n    const box = stage.current, cv = canvas.current, pad = hit.current;\n    if (!box || !cv || !pad) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const opts = { antialias: false, alpha: false, powerPreference: \"high-performance\" as const };\n    const gl2 = cv.getContext(\"webgl2\", opts) as WebGL2RenderingContext | null;\n    const gl = (gl2 ?? cv.getContext(\"webgl\", opts)) as WebGLRenderingContext | null;\n    if (!gl) { setShown(\"still\"); return; }\n    const canAcc = !!gl2 && (!!gl2.getExtension(\"EXT_color_buffer_float\") || !!gl2.getExtension(\"EXT_color_buffer_half_float\"));\n    const info = gl.getExtension(\"WEBGL_debug_renderer_info\");\n    const renderer = info ? String(gl.getParameter(info.UNMASKED_RENDERER_WEBGL)) : \"\";\n    const software = /swiftshader|llvmpipe|software|basic render/i.test(renderer);\n    const still = reduce || software;\n\n    const head = gl2 ? \"#version 300 es\\n#define ATTR in\\n\" : \"#define ATTR attribute\\n\";\n    const fhead = gl2 ? \"#version 300 es\\n#define texture2D texture\\nprecision highp float;\\nout vec4 outC;\\n\" : \"#define outC gl_FragColor\\n\";\n    const compile = (type: number, src: string) => {\n      const sh = gl.createShader(type);\n      if (!sh) return null;\n      gl.shaderSource(sh, src); gl.compileShader(sh);\n      if (!gl.getShaderParameter(sh, gl.COMPILE_STATUS)) { console.warn(gl.getShaderInfoLog(sh)); return null; }\n      return sh;\n    };\n    const link = (frag: string) => {\n      const v = compile(gl.VERTEX_SHADER, head + VERT), f = compile(gl.FRAGMENT_SHADER, fhead + frag);\n      const p = gl.createProgram();\n      if (!v || !f || !p) return null;\n      gl.attachShader(p, v); gl.attachShader(p, f); gl.bindAttribLocation(p, 0, \"aPos\"); gl.linkProgram(p);\n      return gl.getProgramParameter(p, gl.LINK_STATUS) ? p : null;\n    };\n    const scene = link(SCENE), post = canAcc ? link(POST) : null;\n    if (!scene || (canAcc && !post)) { setShown(\"still\"); return; }\n    const U = (p: WebGLProgram, n: string) => gl.getUniformLocation(p, n);\n    const su = Object.fromEntries([\"uRes\", \"uJit\", \"uSeed\", \"uDirect\", \"uCam\", \"uTgt\", \"uFoc\", \"uShift\", \"uFocus\", \"uRot\", \"uLift\", \"uSun\", \"uOldS\", \"uNewS\", \"uOldL\", \"uNewL\", \"uProg\", \"uPaper\", \"uCard\"].map((n) => [n, U(scene, n)]));\n    const pu = post ? Object.fromEntries([\"uAcc\", \"uRes\", \"uGrain\", \"uCentre\"].map((n) => [n, U(post, n)])) : {};\n\n    const quad = gl.createBuffer();\n    gl.bindBuffer(gl.ARRAY_BUFFER, quad);\n    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n    gl.enableVertexAttribArray(0); gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);\n\n    const acc = canAcc ? gl.createTexture() : null;\n    const fbo = canAcc ? gl.createFramebuffer() : null;\n    let W = 0, H = 0, scale = 1, cssW = 1, cssH = 1;\n    const size = () => {\n      const r = box.getBoundingClientRect();\n      cssW = Math.max(1, r.width); cssH = Math.max(1, r.height);\n      const dpr = Math.min(software ? 1 : 1.75, window.devicePixelRatio || 1) * scale;\n      // never more than about 1.8 million pixels of tracing\n      const k = Math.min(1, Math.sqrt(1.8e6 / (cssW * cssH * dpr * dpr)));\n      const w = Math.max(2, Math.round(cssW * dpr * k)), h = Math.max(2, Math.round(cssH * dpr * k));\n      if (w === W && h === H) return;\n      W = w; H = h; cv.width = W; cv.height = H;\n      if (gl2 && acc && fbo) {\n        gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, acc);\n        gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA16F, W, H, 0, gl.RGBA, gl2.HALF_FLOAT, null);\n        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n        gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\n        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, acc, 0);\n        gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n      }\n      s.count = 0; s.fresh = true;\n    };\n\n    const ways = colourways.map((c) => ({ shell: lin(c.shell), leather: lin(c.leather), paper: lin(c.paper) }));\n    const s = {\n      a: HERO, v: 0, rest: HERO as number | null, drag: false, spinT: -1, spinFrom: HERO, spinTo: HERO, spinLen: 1,\n      cur: 0, old: 0, prog: 1, paper: ways[0].paper.slice(),\n      ly: 0, lv: 0,\n      count: 0, fresh: true, frame: 0, slow: 0,\n      visible: true, raf: 0, last: 0, t0: 0, touched: false, demoAt: 0, first: true, alive: true,\n    };\n    const halton = (i: number, b: number) => { let f = 1, r = 0; while (i > 0) { f /= b; r += f * (i % b); i = Math.floor(i / b); } return r; };\n\n    const draw = (alpha: number, sample: number) => {\n      const f = frameOf(cssW, cssH);\n      const jx = sample ? halton(sample, 2) - 0.5 : 0, jy = sample ? halton(sample, 3) - 0.5 : 0;\n      const la = halton(sample, 5) * Math.PI * 2, lr = sample ? Math.sqrt(halton(sample, 7)) * 0.06 : 0;\n      const sj = sample ? 0.03 : 0, sa = -0.85 + (halton(sample, 11) - 0.5) * sj, se = 0.62 + (halton(sample, 13) - 0.5) * sj;\n      gl.useProgram(scene);\n      gl.bindFramebuffer(gl.FRAMEBUFFER, canAcc ? fbo : null);\n      gl.viewport(0, 0, W, H);\n      if (canAcc && alpha < 1) { gl.enable(gl.BLEND); gl.blendColor(0, 0, 0, alpha); gl.blendFunc(gl.CONSTANT_ALPHA, gl.ONE_MINUS_CONSTANT_ALPHA); } else gl.disable(gl.BLEND);\n      gl.uniform2f(su.uRes, W, H);\n      gl.uniform4f(su.uJit, canAcc ? jx : 0, canAcc ? jy : 0, canAcc ? Math.cos(la) * lr : 0, canAcc ? Math.sin(la) * lr : 0);\n      gl.uniform1f(su.uSeed, canAcc && sample ? (sample * 0.61803) % 1 || 0.5 : 0);\n      gl.uniform1f(su.uDirect, canAcc ? 0 : 1);\n      gl.uniform3f(su.uCam, f.cam[0], f.cam[1], f.cam[2]); gl.uniform3f(su.uTgt, f.tgt[0], f.tgt[1], f.tgt[2]);\n      gl.uniform1f(su.uFoc, f.foc);\n      gl.uniform2f(su.uShift, f.shift[0], f.shift[1]);\n      gl.uniform1f(su.uFocus, f.dist);\n      gl.uniform1f(su.uRot, s.a); gl.uniform1f(su.uLift, s.ly);\n      gl.uniform3f(su.uSun, Math.sin(sa) * Math.cos(se), Math.sin(se), -Math.cos(sa) * Math.cos(se));\n      const o = ways[s.old], n = ways[s.cur];\n      gl.uniform3fv(su.uOldS, o.shell); gl.uniform3fv(su.uNewS, n.shell);\n      gl.uniform3fv(su.uOldL, o.leather); gl.uniform3fv(su.uNewL, n.leather);\n      gl.uniform1f(su.uProg, s.prog);\n      gl.uniform3fv(su.uPaper, s.paper);\n      gl.uniform3fv(su.uCard, s.paper.map((x) => x * 0.62));\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n      if (canAcc && post) {\n        gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n        gl.disable(gl.BLEND);\n        gl.useProgram(post);\n        gl.uniform1i(pu.uAcc, 1); gl.uniform2f(pu.uRes, W, H);\n        gl.uniform1f(pu.uGrain, still ? 1 : s.frame % 64);\n        gl.uniform2f(pu.uCentre, cssW >= 768 ? 0.62 : 0.5, 0.5);\n        gl.drawArrays(gl.TRIANGLES, 0, 3);\n      }\n    };\n\n    const back = (x: number) => { const c = 1.1; return x < 0.5 ? (Math.pow(2 * x, 2) * ((c + 1) * 2 * x - c)) / 2 : (Math.pow(2 * x - 2, 2) * ((c + 1) * (x * 2 - 2) + c) + 2) / 2; };\n    const spin = (by: number, secs: number) => {\n      if (s.drag) return;\n      const from = s.spinT >= 0 ? s.spinTo : s.rest ?? s.a;\n      s.spinT = 0; s.spinFrom = s.a; s.spinTo = from + by; s.spinLen = secs; s.rest = s.spinTo;\n    };\n    const swap = (i: number, fromUser: boolean) => {\n      if (fromUser) s.touched = true;\n      if (i === s.cur) return;\n      s.old = s.cur; s.cur = i;\n      if (reduce) { s.prog = 1; s.paper = ways[i].paper.slice(); } else { s.prog = 0; spin(Math.PI * 2, 2.1); }\n      s.count = 0; s.fresh = reduce;\n      wake();\n    };\n    api.current = {\n      swap: (i) => swap(i, true),\n      hop: () => { s.touched = true; if (!reduce && s.ly < 0.01) { s.lv = 3.2; s.ly = 0.001; s.v += 2.0; wake(); } },\n      turn: () => { s.touched = true; if (reduce) { s.a += Math.PI / 2; s.rest = s.a; s.count = 0; s.fresh = true; } else spin(Math.PI / 2, 0.9); wake(); },\n    };\n\n    const frame = (now: number) => {\n      s.raf = 0;\n      if (!s.visible || !s.alive) return;\n      const dtRaw = s.last ? (now - s.last) / 1000 : 0.016;\n      const dt = Math.min(0.033, dtRaw);\n      s.last = now; s.frame++;\n      // opens finished and holds; then, until someone touches it, tries the next colour every few seconds\n      if (!s.t0) { s.t0 = now; s.demoAt = now + 4800; }\n      if (!still && !s.touched && now > s.demoAt) { const next = (s.cur + 1) % colourways.length; swap(next, false); setSel(next); s.demoAt = now + 6200; }\n\n      let moving = false;\n      if (!reduce) {\n        if (s.spinT >= 0) { s.spinT += dt / s.spinLen; if (s.spinT >= 1) s.spinT = -1; }\n        if (!s.drag) {\n          if (s.rest !== null) {\n            const want = s.spinT >= 0 ? s.spinFrom + (s.spinTo - s.spinFrom) * back(s.spinT) : s.rest;\n            const stiff = s.spinT >= 0 ? 150 : 46, damp = s.spinT >= 0 ? 22 : 8;\n            for (let i = 0; i < 3; i++) { s.v += (stiff * (want - s.a) - damp * s.v) * (dt / 3); s.a += s.v * (dt / 3); }\n            if (s.spinT < 0 && Math.abs(s.v) < 0.003 && Math.abs(want - s.a) < 0.0006) { s.a = want; s.v = 0; } else moving = true;\n          } else {\n            s.v *= Math.exp(-dt * 2.4); s.a += s.v * dt;\n            if (Math.abs(s.v) < 0.012) s.v = 0; else moving = true;\n          }\n        } else moving = true;\n        if (s.prog < 1) {\n          s.prog = Math.min(1, s.prog + dt / SWAP); moving = true;\n          // the paper follows a beat behind the shell\n          const p = ways[s.cur].paper, k = 1 - Math.exp(-dt * 3.2);\n          s.paper = s.paper.map((x, j) => x + (p[j] - x) * k);\n        } else {\n          const p = ways[s.cur].paper;\n          if (s.paper.some((x, j) => Math.abs(p[j] - x) > 0.002)) { s.paper = s.paper.map((x, j) => x + (p[j] - x) * (1 - Math.exp(-dt * 3.2))); moving = true; }\n          else s.paper = p.slice();\n        }\n        if (s.ly > 0 || s.lv !== 0) {\n          s.lv -= 24 * dt; s.ly += s.lv * dt;\n          if (s.ly <= 0) { s.ly = 0; s.lv = s.lv < -1.3 ? -s.lv * 0.28 : 0; }\n          moving = true;\n        }\n      }\n      if (s.fresh || !canAcc) { draw(1, 0); s.fresh = false; s.count = 1; }\n      else if (moving) { draw(0.6, 1 + (s.frame % 64)); s.count = 3; }\n      else if (s.count < 64) { s.count++; draw(1 / s.count, s.count); }\n      if (s.first) { s.first = false; setShown(\"gl\"); }\n\n      if (!still && moving && dtRaw > 0.026) s.slow++; else s.slow = Math.max(0, s.slow - 2);\n      if (s.slow > 40 && scale > 0.5) { scale *= 0.82; s.slow = 0; size(); }\n\n      if (moving || s.count < 64 || (!still && !s.touched)) s.raf = requestAnimationFrame(frame);\n    };\n    const wake = () => { if (!s.raf && s.visible && s.alive) { s.last = 0; s.raf = requestAnimationFrame(frame); } };\n\n    size();\n    const ro = new ResizeObserver(() => { size(); wake(); });\n    ro.observe(box);\n    const io = new IntersectionObserver(([e]) => { s.visible = e.isIntersecting && !document.hidden; if (s.visible) wake(); }, { threshold: 0.05 });\n    io.observe(box);\n    const vis = () => { s.visible = !document.hidden; if (s.visible) wake(); };\n    document.addEventListener(\"visibilitychange\", vis);\n\n    let downX = 0, id = -1, lastT = 0;\n    const down = (e: PointerEvent) => {\n      id = e.pointerId; downX = e.clientX; lastT = e.timeStamp; s.drag = true; s.touched = true; s.spinT = -1; s.v = 0; s.rest = null;\n      try { pad.setPointerCapture(id); } catch { /* the pointer is already gone */ }\n      wake();\n    };\n    const move = (e: PointerEvent) => {\n      if (!s.drag || e.pointerId !== id) return;\n      const dx = e.clientX - downX; downX = e.clientX;\n      const da = dx * 0.01, dtp = Math.max(0.008, (e.timeStamp - lastT) / 1000); lastT = e.timeStamp;\n      s.a += da; s.v = s.v * 0.5 + (da / dtp) * 0.5;\n      if (reduce) { s.count = 0; s.fresh = true; }\n      wake();\n    };\n    const upFn = (e: PointerEvent) => {\n      if (!s.drag || e.pointerId !== id) return;\n      s.drag = false;\n      s.v = reduce ? 0 : Math.max(-12, Math.min(12, s.v));\n      wake();\n    };\n    pad.addEventListener(\"pointerdown\", down);\n    pad.addEventListener(\"pointermove\", move);\n    pad.addEventListener(\"pointerup\", upFn);\n    pad.addEventListener(\"pointercancel\", upFn);\n    const lost = (e: Event) => { e.preventDefault(); setShown(\"still\"); };\n    cv.addEventListener(\"webglcontextlost\", lost);\n    wake();\n\n    return () => {\n      s.alive = false;\n      cancelAnimationFrame(s.raf); ro.disconnect(); io.disconnect();\n      document.removeEventListener(\"visibilitychange\", vis);\n      pad.removeEventListener(\"pointerdown\", down); pad.removeEventListener(\"pointermove\", move);\n      pad.removeEventListener(\"pointerup\", upFn); pad.removeEventListener(\"pointercancel\", upFn);\n      cv.removeEventListener(\"webglcontextlost\", lost);\n      api.current = null;\n    };\n  }, []);\n\n  const pick = (i: number) => { setSel(i); api.current?.swap(i); };\n  const add = () => { setBag((b) => b + 1); api.current?.hop(); };\n  const way = colourways[sel];\n\n  return (\n    <section className=\"relative isolate overflow-hidden transition-colors duration-1000 motion-reduce:transition-none\" style={{ fontFamily: FONT, color: INK, backgroundColor: way.paper }}>\n      <style>{`\n        @keyframes ray-marched-headphones-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }\n        .ray-marched-headphones-rise { animation: ray-marched-headphones-rise 700ms cubic-bezier(0.2, 0.9, 0.2, 1) both; }\n        @keyframes ray-marched-headphones-name { from { opacity: 0; transform: translateY(0.5em); } to { opacity: 1; transform: none; } }\n        .ray-marched-headphones-name { display: inline-block; animation: ray-marched-headphones-name 520ms cubic-bezier(0.2, 1.2, 0.3, 1) both; }\n        @keyframes ray-marched-headphones-count { 0% { transform: scale(1); } 35% { transform: scale(1.45); } 100% { transform: scale(1); } }\n        .ray-marched-headphones-count { animation: ray-marched-headphones-count 420ms cubic-bezier(0.2, 0.9, 0.2, 1) both; }\n        @media (prefers-reduced-motion: reduce) { .ray-marched-headphones-rise, .ray-marched-headphones-name, .ray-marched-headphones-count { animation: none; } }\n      `}</style>\n      <div ref={stage} className=\"relative mx-auto h-[780px] w-full max-w-[1600px] md:h-[760px]\">\n        {shown === \"still\" && spot && <Still at={spot} sel={sel} />}\n        <canvas ref={canvas} aria-hidden=\"true\" className={`absolute inset-0 h-full w-full transition-opacity duration-700 motion-reduce:transition-none ${shown === \"gl\" ? \"opacity-100\" : \"opacity-0\"}`} />\n        <div ref={hit} aria-hidden=\"true\" className=\"absolute inset-0 cursor-grab select-none active:cursor-grabbing\" style={{ touchAction: \"pan-y\" }} />\n\n        <div className=\"pointer-events-none absolute inset-0 flex flex-col px-6 pb-7 pt-6 md:px-10 md:pb-10 md:pt-8 lg:px-16 lg:pb-12 lg:pt-10\">\n          <p className=\"flex items-center justify-between text-[11px] font-semibold uppercase tracking-[0.32em]\">\n            <span>{product.maker}</span>\n            <span className=\"flex items-center gap-3\">\n              Bag\n              <span key={bag} className={`grid h-7 min-w-[28px] place-items-center rounded-full px-2 text-[12px] tracking-normal ${bag ? \"ray-marched-headphones-count\" : \"\"}`} style={{ backgroundColor: INK, color: way.paper }}>{bag}</span>\n            </span>\n          </p>\n          <div className=\"ray-marched-headphones-rise mt-auto md:mb-auto md:mt-[52px]\">\n            <p className=\"text-[17px] italic md:text-[19px] lg:text-[21px]\" style={{ fontFamily: SERIF }}>{product.kind}</p>\n            <h2 className=\"mt-1 text-[72px] font-extrabold leading-[0.82] tracking-[-0.06em] md:mt-3 md:text-[112px] lg:text-[156px]\">\n              {product.name.map((line) => <span key={line} className=\"block\">{line}</span>)}\n            </h2>\n            <p className=\"mt-3 text-[20px] italic leading-none md:mt-5 md:text-[25px] lg:mt-6 lg:text-[30px]\" style={{ fontFamily: SERIF }}>\n              finished in <span key={way.name} className=\"ray-marched-headphones-name not-italic font-extrabold tracking-[-0.03em]\" style={{ fontFamily: FONT }}>{way.name}</span>\n            </p>\n          </div>\n          <div className=\"ray-marched-headphones-rise mt-5 md:mt-0\">\n            <div role=\"group\" aria-label=\"Colour\" className=\"pointer-events-auto mb-4 flex gap-2 md:mb-6\">\n              {colourways.map((c, i) => (\n                <button key={c.name} type=\"button\" aria-pressed={i === sel} aria-label={c.name} onClick={() => pick(i)} className=\"group grid h-11 w-11 place-items-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-offset-2\" style={{ [\"--tw-ring-color\" as string]: INK, [\"--tw-ring-offset-color\" as string]: way.paper }}>\n                  <span className={`relative block h-8 w-8 rounded-full transition-transform duration-300 group-hover:scale-110 motion-reduce:transition-none ${i === sel ? \"scale-110\" : \"\"}`} style={{ background: `radial-gradient(circle at 34% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 38%), radial-gradient(circle at 60% 70%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.28) 100%), ${c.shell}`, boxShadow: i === sel ? `0 0 0 2px ${c.paper}, 0 0 0 4px ${INK}, 0 6px 10px -4px rgba(0,0,0,0.45)` : \"0 6px 10px -4px rgba(0,0,0,0.45), inset 0 -2px 3px rgba(0,0,0,0.18)\" }}>\n                    <span className=\"absolute bottom-[3px] right-[3px] h-3 w-3 rounded-full\" style={{ background: c.leather, boxShadow: \"0 0 0 1.5px rgba(0,0,0,0.12)\" }} />\n                  </span>\n                </button>\n              ))}\n            </div>\n            <div className=\"flex flex-wrap items-center gap-x-5 gap-y-3\">\n              <span className=\"text-[52px] font-extrabold leading-none tracking-[-0.055em] md:text-[64px] lg:text-[88px]\" style={{ fontVariantNumeric: \"tabular-nums\" }}>{product.price}</span>\n              <button type=\"button\" onClick={add} className=\"pointer-events-auto inline-flex h-[60px] items-center gap-3 whitespace-nowrap rounded-full pl-8 pr-7 text-[19px] font-bold tracking-[-0.02em] shadow-[0_1px_0_rgba(255,255,255,0.25)_inset,0_16px_30px_-14px_rgba(40,20,0,0.8)] outline-none transition-transform duration-200 hover:-translate-y-0.5 focus-visible:ring-2 focus-visible:ring-offset-2 active:translate-y-0.5 active:scale-[0.98] motion-reduce:transition-none lg:h-[68px] lg:text-[22px]\" style={{ backgroundColor: INK, color: way.paper, [\"--tw-ring-color\" as string]: INK, [\"--tw-ring-offset-color\" as string]: way.paper }}>\n                {product.cta}\n                <svg aria-hidden=\"true\" viewBox=\"0 0 20 20\" className=\"h-5 w-5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M4.5 7h11l-.8 9.5H5.3L4.5 7ZM7.3 7V5.7a2.7 2.7 0 0 1 5.4 0V7\" /></svg>\n              </button>\n              <span className=\"w-full text-[11px] font-semibold uppercase tracking-[0.22em] lg:mt-1\">{product.note}</span>\n            </div>\n          </div>\n        </div>\n        <p aria-live=\"polite\" className=\"sr-only\">{bag ? `${bag} in your bag. ${product.name.join(\" \")} in ${way.name} added.` : \"\"}</p>\n        {shown === \"gl\" && (\n          <button type=\"button\" onClick={() => api.current?.turn()} className=\"absolute right-3 top-[58px] flex h-10 items-center gap-2 rounded-full px-3 text-[10px] font-semibold uppercase tracking-[0.28em] outline-none hover:opacity-70 focus-visible:ring-2 md:right-7 md:top-[66px] md:text-[11px] lg:right-[52px] lg:top-[78px]\" style={{ [\"--tw-ring-color\" as string]: INK }}>\n            <svg aria-hidden=\"true\" viewBox=\"0 0 20 20\" className=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M16.5 10a6.5 6.5 0 1 1-2.2-4.9M16.6 3.2v3.4h-3.4\" /></svg>\n            <span><span className=\"hidden md:inline\">Drag or press to turn</span><span className=\"md:hidden\">Turn</span></span>\n          </button>\n        )}\n      </div>\n    </section>\n  );\n}\n"}]}
