{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ray-marched-paper-pop-up-book-scroll-story-where-a-tea-hillside-a-drying-barn-and-a-tin-unfold-from-the-spread","type":"registry:block","title":"Ray Marched Paper Pop-Up Book Scroll Story Where a Tea Hillside, a Drying Barn and a Tin Unfold from the Spread","description":"Free scroll story in React: a cloth book opens on a table as you scroll and paper hills, a barn and a tin stand up, one per heading. Copy the code.","dependencies":[],"files":[{"path":"components/we-inc/ray-marched-paper-pop-up-book-scroll-story-where-a-tea-hillside-a-drying-barn-and-a-tin-unfold-from-the-spread.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\n// The story. Each beat is one fold of the pop-up: where the page has to reach for it to stand.\nconst beats = [\n  { fold: \"Ridge\", title: \"Grown on the ridge\", body: \"Fernmoor leaves are picked by hand on the terraces above the river, only the bud and the top two leaves, before the morning mist has lifted.\", at: 0.64 },\n  { fold: \"Barn\", title: \"Withered in the barn\", body: \"They rest overnight on slatted racks in the old drying barn and are turned twice by hand, so every leaf softens at the same pace.\", at: 0.83 },\n  { fold: \"Tin\", title: \"Sealed in the tin\", body: \"Rolled, fired and packed the same week into a lined paper tin, so the cup you pour still tastes of the hillside it came from.\", at: 1 },\n];\nconst BRAND = \"Fernmoor Tea\";\nconst STORY = \"Spring picking, told in three folds\";\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\n// When each paper piece stands, as a share of the story (0 closed, 1 fully open).\nconst COVER = [0, 0.3];\nconst RISE = [[0.3, 0.5], [0.36, 0.56], [0.42, 0.62], [0.64, 0.8], [0.84, 0.98]];\nconst beatOf = (p: number) => (p < 0.735 ? 0 : p < 0.915 ? 1 : 2);\nconst sm = (a: number, b: number, x: number) => { const t = Math.max(0, Math.min(1, (x - a) / (b - a))); return t * t * (3 - 2 * t); };\n\nconst VERT = `ATTR vec2 aPos; void main(){ gl_Position = vec4(aPos, 0.0, 1.0); }`;\nconst TONE = `\nvec3 tone(vec3 x){ x *= 0.92; vec3 a = x * (2.51 * x + 0.03); vec3 b = x * (2.43 * x + 0.59) + 0.14; return pow(clamp(a / b, 0.0, 1.0), vec3(1.0 / 2.2)); }\n`;\n\n// A cloth-bound book lying open on a linen table in low afternoon light from the left and behind.\n// Three cut-paper ridges, a drying barn and a tea tin stand up out of the spread.\nconst SCENE = `\nprecision highp float;\nuniform vec2 uRes; uniform vec4 uJit; uniform float uSeed;\nuniform vec3 uCam; uniform vec3 uTgt; uniform float uFoc; uniform vec2 uShift; uniform float uFocus;\nuniform float uTh; uniform vec4 uA; uniform float uTin; uniform vec3 uL;\nuniform sampler2D uTex; uniform float uDirect;\nconst float YT = 0.17;\nconst vec3 SUN = vec3(1.0, 0.86, 0.68);\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 sdBox(vec3 p, vec3 b, float r){ vec3 q = abs(p) - b + r; return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0) - r; }\nfloat sdCyl(vec3 p, float r, float h, float rr){ vec2 d = vec2(length(p.xz) - r + rr, abs(p.y) - h + rr); return min(max(d.x, d.y), 0.0) + length(max(d, 0.0)) - rr; }\n\n// the page surface sinks into the gutter\nfloat topY(float x){ return YT - 0.075 * exp(-abs(x) * 6.0); }\n// the left half of the book, swung about the spine by uTh, seen in its own (mirrored) frame\nvec3 toLeft(vec3 p){\n  vec2 r = vec2(p.x, p.y - YT); float c = cos(uTh), s = sin(uTh);\n  vec2 l = vec2(r.x * c - r.y * s, r.x * s + r.y * c);\n  return vec3(-l.x, l.y + YT, p.z);\n}\nvec2 halfBook(vec3 q){\n  float b = sdBox(q - vec3(1.07, 0.024, 0.0), vec3(1.07, 0.024, 1.52), 0.014);\n  float pg = sdBox(q - vec3(1.04, 0.11, 0.0), vec3(1.0, 0.07, 1.45), 0.008);\n  pg = max(pg, (q.y - topY(q.x)) * 0.9);\n  return b < pg ? vec2(b, 1.0) : vec2(pg, 2.0);\n}\n// ---- cut paper ridges, hinged at their foot, lying forward when folded ----\nfloat ridgeH(float X, float i){\n  float h;\n  if (i < 0.5) h = 0.9 + 0.18 * sin(X * 1.3 + 0.5) + 0.07 * sin(X * 3.7 + 1.0);\n  else if (i < 1.5) h = 0.64 + 0.15 * sin(X * 1.8 + 2.3) + 0.05 * sin(X * 5.3 + 1.0);\n  else { h = 0.4 + 0.11 * sin(X * 2.3 + 4.1); h += 0.028 * sqrt(abs(sin(X * 13.0))); }\n  return h * smoothstep(1.97, 1.5, abs(X));\n}\nvec2 ridgeUV(vec3 q, float a, float zb){\n  float h = q.y - topY(q.x); float dz = q.z - zb;\n  float ph = (1.0 - a) * 1.5708; float c = cos(ph), s = sin(ph);\n  vec2 vw = vec2(h * c + dz * s, -h * s + dz * c);\n  // stiff card still bows a little between its folds\n  vw.y += vw.x * (0.05 * vw.x + 0.035 * sin(q.x * 2.1 + zb * 5.0)) * smoothstep(0.0, 0.3, vw.x);\n  return vw;\n}\nfloat ridge(vec3 q, float sg, float i, float a, float zb){\n  if (a < 0.002) return 1e3;\n  vec2 vw = ridgeUV(q, a, zb);\n  float X = sg * q.x;\n  float d2 = max(vw.x - ridgeH(X, i), -vw.x) * 0.65;\n  if (i < 0.5) d2 = min(d2, max(length(vec2(X - 0.72, vw.x - 1.14)) - 0.27, -vw.x));\n  d2 = max(d2, max(-q.x, q.x - 1.98));\n  vec2 e = vec2(d2, (abs(vw.y) - 0.007) * 0.85);\n  return min(max(e.x, e.y), 0.0) + length(max(e, 0.0));\n}\n// ---- the barn on the right page: a pop-up box that rises out of the paper ----\nvec3 barnP(vec3 q){ vec3 r = q - vec3(1.02, topY(1.02) - 0.004, 0.66); r.y /= clamp(uA.w, 0.03, 1.2); return r; }\nfloat barn(vec3 q){\n  if (uA.w < 0.01) return 1e3;\n  vec3 r = barnP(q);\n  float body = sdBox(r - vec3(0.0, 0.2, 0.0), vec3(0.34, 0.2, 0.2), 0.004);\n  vec2 rz = vec2(abs(r.z), r.y - 0.4);\n  float roof = max(abs(r.x) - 0.4, max(dot(rz, vec2(0.6, 0.8)) - 0.15, -rz.y));\n  float ch = sdBox(r - vec3(0.22, 0.56, -0.05), vec3(0.035, 0.1, 0.035), 0.003);\n  return min(min(body, roof), ch) * min(uA.w, 1.0) * 0.9;\n}\n// ---- the tea tin on the left page ----\nvec3 tinP(vec3 q){ vec3 r = q - vec3(1.0, topY(1.0) - 0.004, 0.72); r.y /= clamp(uTin, 0.03, 1.2); return r; }\nfloat tin(vec3 q){\n  if (uTin < 0.01) return 1e3;\n  vec3 r = tinP(q);\n  float body = sdCyl(r - vec3(0.0, 0.25, 0.0), 0.24, 0.25, 0.012);\n  float lid = sdCyl(r - vec3(0.0, 0.47, 0.0), 0.252, 0.06, 0.012);\n  return min(body, lid) * min(uTin, 1.0) * 0.9;\n}\nconst vec3 ZB = vec3(-0.95, -0.42, 0.06);\nvec2 map(vec3 p){\n  vec3 L = toLeft(p);\n  vec2 r = halfBook(p);\n  vec2 l = halfBook(L); if (l.x < r.x) r = l;\n  float d = min(ridge(p, 1.0, 0.0, uA.x, ZB.x), ridge(L, -1.0, 0.0, uA.x, ZB.x)); if (d < r.x) r = vec2(d, 3.0);\n  d = min(ridge(p, 1.0, 1.0, uA.y, ZB.y), ridge(L, -1.0, 1.0, uA.y, ZB.y)); if (d < r.x) r = vec2(d, 4.0);\n  d = min(ridge(p, 1.0, 2.0, uA.z, ZB.z), ridge(L, -1.0, 2.0, uA.z, ZB.z)); if (d < r.x) r = vec2(d, 5.0);\n  d = barn(p); if (d < r.x) r = vec2(d, 6.0);\n  d = tin(L); if (d < r.x) r = vec2(d, 7.0);\n  return r;\n}\nvec3 calcN(vec3 p){\n  vec2 e = vec2(0.0007, -0.0007);\n  return normalize(e.xyy * map(p + e.xyy).x + e.yyx * map(p + e.yyx).x + e.yxy * map(p + e.yxy).x + e.xxx * map(p + e.xxx).x);\n}\nvec2 boxSpan(vec3 ro, vec3 rd, vec3 lo, vec3 hi){\n  vec3 inv = 1.0 / (rd + vec3(1e-6)); vec3 a = (lo - ro) * inv; vec3 b = (hi - ro) * inv;\n  vec3 mn = min(a, b); vec3 mx = max(a, b);\n  return vec2(max(max(mn.x, mn.y), max(mn.z, 0.0)), min(mx.x, min(mx.y, mx.z)));\n}\nconst vec3 BLO = vec3(-2.3, -0.01, -1.7); const vec3 BHI = vec3(2.3, 2.45, 1.7);\nfloat shadow(vec3 ro){\n  vec2 tb = boxSpan(ro, uL, BLO, BHI);\n  if (tb.x > tb.y) return 1.0;\n  float res = 1.0; float t = max(tb.x, 0.012);\n  for (int i = 0; i < 44; i++) {\n    float h = map(ro + uL * t).x;\n    res = min(res, 14.0 * h / t);\n    t += clamp(h, 0.01, 0.25);\n    if (res < 0.002 || t > tb.y) break;\n  }\n  res = clamp(res, 0.0, 1.0);\n  return res * res * (3.0 - 2.0 * res);\n}\nfloat calcAO(vec3 p, vec3 n){\n  float o = 0.0; float s = 1.0;\n  for (int i = 1; i <= 5; i++) {\n    float h = 0.012 + 0.05 * float(i); float d = min(map(p + n * h).x, p.y + n.y * h);\n    o += (h - d) * s; s *= 0.7;\n  }\n  return clamp(1.0 - 2.0 * o, 0.0, 1.0);\n}\nvec3 sky(vec3 r){\n  vec3 c = mix(vec3(0.82, 0.76, 0.68), vec3(0.72, 0.78, 0.88), smoothstep(-0.1, 0.9, r.y));\n  c += SUN * 3.0 * pow(max(dot(r, uL), 0.0), 24.0);\n  return c * 0.8;\n}\nvec3 light(vec3 p, vec3 n, float occ, float sh){\n  float ndl = max(dot(n, uL), 0.0);\n  vec3 amb = mix(vec3(0.5, 0.45, 0.4), vec3(0.62, 0.68, 0.8), 0.5 + 0.5 * n.y) * occ;\n  // the table throws warm light back up into the undersides\n  vec3 bounce = vec3(0.7, 0.58, 0.44) * clamp(0.6 - 0.5 * n.y, 0.0, 1.0) * 0.32 * occ;\n  return SUN * 3.4 * ndl * sh + amb * 0.42 + bounce;\n}\n// ---- what each surface is made of ----\nvec3 albedo(float m, vec3 p, vec3 n, inout float gloss, out float thin){\n  thin = 0.0;\n  if (m < 1.5) {\n    // book cloth: a fine linen weave in ink blue\n    vec3 q = p; float w = n2(q.xz * 260.0) * 0.5 + n2(q.zy * 260.0) * 0.5;\n    gloss = 0.18;\n    vec3 c = vec3(0.03, 0.05, 0.1) * (0.8 + 0.4 * w);\n    // the title blocked in gold on the front board, which is the underside of the left half\n    vec3 L = toLeft(p);\n    if (L.y < 0.006 && halfBook(L).x < halfBook(p).x + 0.001) {\n      float g = texture2D(uTex, vec2(0.5 - L.x / 4.1, (L.z + 1.45) / 2.9)).g;\n      c = mix(c, vec3(0.5, 0.34, 0.12), g); gloss = mix(gloss, 0.9, g);\n    }\n    return c;\n  }\n  if (m < 2.5) {\n    vec3 R = p; float sg = 1.0;\n    if (halfBook(toLeft(p)).x < halfBook(p).x) { R = toLeft(p); sg = -1.0; }\n    vec3 a = vec3(0.86, 0.82, 0.73);\n    if (R.y < topY(R.x) - 0.006) a *= 0.86 + 0.14 * sin(R.y * 1700.0 + n2(R.xz * 40.0) * 3.0); // the edges of the leaves\n    else {\n      float ink = texture2D(uTex, vec2(0.5 + sg * R.x / 4.1, (R.z + 1.45) / 2.9)).r;\n      a = mix(a, vec3(0.14, 0.12, 0.1), ink * 0.85);\n    }\n    a *= 0.95 + 0.07 * n2(p.xz * 90.0);\n    return a;\n  }\n  if (m < 5.5) {\n    float i = m - 3.0;\n    vec3 R = p; float sg = 1.0;\n    float z = i < 0.5 ? ZB.x : i < 1.5 ? ZB.y : ZB.z;\n    float a = i < 0.5 ? uA.x : i < 1.5 ? uA.y : uA.z;\n    vec2 vr = ridgeUV(p, a, z), vl = ridgeUV(toLeft(p), a, z);\n    if (abs(vl.y) < abs(vr.y)) { R = toLeft(p); sg = -1.0; }\n    vec2 vw = ridgeUV(R, a, z); float X = sg * R.x;\n    float ph = (1.0 - a) * 1.5708; float ly = -sin(ph);\n    vec3 pn = sg > 0.0 ? vec3(0.0, ly, cos(ph)) : vec3(ly * sin(uTh), ly * cos(uTh), cos(ph));\n    vec3 c = i < 0.5 ? vec3(0.5, 0.58, 0.45) : i < 1.5 ? vec3(0.24, 0.4, 0.27) : vec3(0.08, 0.22, 0.14);\n    if (i < 0.5 && length(vec2(X - 0.72, vw.x - 1.14)) < 0.27 && vw.x > ridgeH(X, 0.0) - 0.002) c = vec3(0.78, 0.46, 0.17);\n    // rows of tea bushes printed on the front ridge\n    if (i > 1.5) c *= 0.82 + 0.25 * smoothstep(0.2, 0.8, sin(vw.x * 70.0 + sin(X * 3.0) * 2.0));\n    // a cut edge shows the paler core of the coloured card\n    float edge = 1.0 - smoothstep(0.55, 0.85, abs(dot(n, pn)));\n    c = mix(c, vec3(0.88, 0.85, 0.76), edge * 0.75);\n    thin = 1.0 - edge;\n    c *= 0.94 + 0.1 * n2(vec2(X, vw.x) * 120.0);\n    return c;\n  }\n  if (m < 6.5) {\n    vec3 r = barnP(p);\n    if (r.y > 0.4 || (r.y > 0.45 && abs(r.x) < 0.3)) {\n      float tile = smoothstep(0.35, 0.5, abs(fract(r.y * 26.0) - 0.5));\n      return vec3(0.1, 0.095, 0.09) * (0.85 + 0.3 * tile);\n    }\n    if (abs(r.x - 0.22) < 0.04 && r.y > 0.45) return vec3(0.42, 0.18, 0.11);\n    vec3 c = vec3(0.6, 0.2, 0.1);\n    float boards = smoothstep(0.42, 0.5, abs(fract(r.x * 30.0) - 0.5));\n    c *= 0.9 + 0.12 * boards;\n    if (r.z > 0.19 && abs(r.x) < 0.09 && r.y < 0.25) c = vec3(0.17, 0.08, 0.05);\n    if (r.z > 0.19 && abs(abs(r.x) - 0.22) < 0.05 && abs(r.y - 0.24) < 0.05) c = vec3(0.95, 0.8, 0.52);\n    if (r.z > 0.19 && abs(r.x) < 0.25 && abs(r.y - 0.34) < 0.012) c = vec3(0.86, 0.82, 0.72);\n    return c * (0.95 + 0.08 * n2(p.xy * 140.0));\n  }\n  vec3 r = tinP(p);\n  vec3 c = vec3(0.03, 0.22, 0.24);\n  if (r.y > 0.41) c = vec3(0.3, 0.17, 0.08);\n  else if (abs(r.y - 0.23) < 0.1) {\n    c = vec3(0.88, 0.82, 0.68);\n    float ang = atan(r.x, r.z);\n    if (abs(r.y - 0.23) > 0.082) c = vec3(0.3, 0.17, 0.08);\n    else if (abs(ang) < 0.55 && abs(r.y - 0.24) < 0.022) c = vec3(0.05, 0.2, 0.2);\n    else if (abs(ang) < 0.32 && abs(r.y - 0.19) < 0.008) c = vec3(0.4, 0.3, 0.2);\n  }\n  gloss = 0.1;\n  return c * (0.95 + 0.08 * n2(p.xy * 140.0));\n}\nvec3 shade(vec3 p, vec3 n, vec3 rd, float m){\n  float occ = calcAO(p, n);\n  float gloss = 0.03; float thin;\n  vec3 a = albedo(m, p, n, gloss, thin);\n  float sh = shadow(p + n * 0.006);\n  vec3 col = a * light(p, n, occ, sh);\n  // light coming through thin card from behind\n  if (thin > 0.0) {\n    float back = max(dot(-n, uL), 0.0);\n    if (back > 0.0) col += a * a * SUN * 3.4 * back * shadow(p - n * 0.02) * thin;\n  }\n  vec3 r = reflect(rd, n);\n  float F = 0.03 + 0.97 * pow(1.0 - clamp(dot(-rd, n), 0.0, 1.0), 5.0);\n  col += F * sky(r) * gloss * (0.4 + 0.6 * occ) * (0.4 + 0.6 * sh);\n  return col;\n}\nvec3 backdrop(vec3 rd){ return mix(vec3(0.9, 0.84, 0.76), vec3(0.72, 0.66, 0.58), smoothstep(-0.25, 0.25, rd.y)); }\nvec3 floorCol(vec3 p, float t, vec3 rd){\n  float w = n2(vec2(p.x * 160.0, p.z * 9.0)) * 0.5 + n2(vec2(p.x * 9.0, p.z * 160.0)) * 0.5;\n  vec3 a = vec3(0.7, 0.63, 0.53) * (0.92 + 0.12 * w) * (0.96 + 0.06 * n2(p.xz * 1.5));\n  vec3 n = vec3(0.0, 1.0, 0.0);\n  float occ = calcAO(p, n);\n  float sh = shadow(p + n * 0.004);\n  vec3 c = a * light(p, n, occ, sh);\n  return mix(c, backdrop(rd), smoothstep(9.0, 26.0, t));\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(fw, vec3(0.0, 1.0, 0.0))); vec3 up = cross(rt, fw);\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 tf = rd.y < 0.0 ? -ro.y / rd.y : 1e9;\n  vec2 tb = boxSpan(ro, rd, BLO, BHI);\n  float t = -1.0; float m = 0.0;\n  if (tb.x < tb.y) {\n    float s = tb.x;\n    for (int i = 0; i < 140; i++) {\n      vec2 h = map(ro + rd * s);\n      if (h.x < 0.0003 * s) { t = s; m = h.y; break; }\n      s += h.x; if (s > tb.y) break;\n    }\n  }\n  vec3 col;\n  if (t > 0.0) { vec3 p = ro + rd * t; col = shade(p, calcN(p), rd, m); }\n  else if (tf < 1e8) col = floorCol(ro + rd * tf, tf, rd);\n  else col = backdrop(rd);\n  col = min(col, vec3(24.0));\n  if (uDirect > 0.5) col = tone(col);\n  outC = vec4(col, 1.0);\n}\n`;\n\n// Developing: a soft bloom, the filmic curve, a vignette and a little 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  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.018 * vec2(uRes.y / uRes.x, 1.0)).rgb;\n    b += max(s - 1.6, 0.0) * (1.0 - 0.6 * r);\n  }\n  c += b * 0.012 * vec3(1.0, 0.9, 0.78);\n  vec2 q = (uv - uCentre) * vec2(uRes.x / uRes.y, 1.0);\n  c *= 1.0 - 0.2 * smoothstep(0.4, 1.3, length(q));\n  c = tone(c);\n  c += (h21(gl_FragCoord.xy + uGrain * 91.7) - 0.5) * 0.02;\n  outC = vec4(c, 1.0);\n}\n`;\n\n// The type printed on the spread, drawn once. Left half of the canvas is the left page.\nfunction spreadPrint() {\n  const W = 2048, H = 1440;\n  const cv = document.createElement(\"canvas\");\n  cv.width = W; cv.height = H;\n  const g = cv.getContext(\"2d\");\n  if (!g) return cv;\n  g.fillStyle = \"#000\"; g.fillRect(0, 0, W, H);\n  g.fillStyle = \"#f00\"; g.textBaseline = \"alphabetic\";\n  const px = (x: number) => W / 2 + (x / 2.05) * (W / 2); // scene x on the page to canvas x\n  const pz = (z: number) => ((z + 1.45) / 2.9) * H;\n  g.font = `600 30px ${FONT}`; g.textAlign = \"left\";\n  g.fillText(\"FERNMOOR\", px(-1.82), pz(-1.24));\n  g.textAlign = \"right\"; g.fillText(\"SPRING PICKING\", px(1.82), pz(-1.24));\n  g.font = `italic 44px ${SERIF}`; g.textAlign = \"left\";\n  const lines = [\"The mist sits in the valley until nine.\", \"By then the first baskets are full and\", \"the pickers walk them down to the barn.\"];\n  lines.forEach((l, i) => g.fillText(l, px(-1.82), pz(1.02) + i * 58));\n  g.textAlign = \"right\";\n  [\"Nothing is hurried. A leaf that is rushed\", \"tastes of the hurry, the old growers say.\"].forEach((l, i) => g.fillText(l, px(1.82), pz(1.1) + i * 58));\n  // the cover title, in green so the shader can tell it from the page ink\n  g.fillStyle = \"#0f0\"; g.textAlign = \"center\";\n  g.font = `700 104px ${FONT}`;\n  g.save(); g.translate(px(-1.02), pz(-0.25)); g.scale(-1, 1); g.fillText(\"FERNMOOR\", 0, 0);\n  g.font = `italic 56px ${SERIF}`; g.fillText(\"A spring picking\", 0, 96); g.restore();\n  g.fillStyle = \"#f00\";\n  g.font = `500 30px ${FONT}`;\n  g.textAlign = \"left\"; g.fillText(\"14\", px(-1.82), pz(1.36));\n  g.textAlign = \"right\"; g.fillText(\"15\", px(1.82), pz(1.36));\n  return cv;\n}\n\n// No WebGL: the open book drawn flat, at its finished state.\nfunction Still() {\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 800 520\" className=\"absolute inset-x-4 bottom-[34%] mx-auto w-[calc(100%-2rem)] max-w-[760px] lg:bottom-[12%] lg:left-[38%] lg:right-[3%] lg:w-auto\">\n      <defs>\n        <linearGradient id=\"ppb-page\" x1=\"0\" x2=\"1\"><stop offset=\"0\" stopColor=\"#efe7d6\" /><stop offset=\"0.47\" stopColor=\"#e2d7c1\" /><stop offset=\"0.5\" stopColor=\"#c9bca3\" /><stop offset=\"0.53\" stopColor=\"#e4dac5\" /><stop offset=\"1\" stopColor=\"#f2ebdc\" /></linearGradient>\n        <filter id=\"ppb-soft\" x=\"-20%\" y=\"-100%\" width=\"140%\" height=\"300%\"><feGaussianBlur stdDeviation=\"14\" /></filter>\n      </defs>\n      <ellipse cx=\"420\" cy=\"470\" rx=\"380\" ry=\"40\" fill=\"#5b4a36\" opacity=\"0.28\" filter=\"url(#ppb-soft)\" />\n      <path d=\"M70 460 L120 300 L680 300 L740 460 Z\" fill=\"#1d2a44\" />\n      <path d=\"M84 446 L130 306 L670 306 L726 446 Z\" fill=\"url(#ppb-page)\" />\n      <circle cx=\"560\" cy=\"150\" r=\"58\" fill=\"#e08b2c\" />\n      <path d=\"M150 330 C210 180 300 150 400 210 C480 120 600 120 660 330 Z\" fill=\"#8c9d7c\" />\n      <path d=\"M140 360 C220 250 320 230 400 280 C480 220 590 230 670 360 Z\" fill=\"#4a6a4d\" />\n      <path d=\"M128 400 C220 330 320 330 400 350 C480 320 600 320 690 400 Z\" fill=\"#1f3d2c\" />\n      <path d=\"M470 330 L470 395 L590 395 L590 330 L530 290 Z\" fill=\"#9c3b20\" />\n      <path d=\"M462 334 L530 284 L598 334 L590 338 L530 296 L470 338 Z\" fill=\"#232120\" />\n      <rect x=\"520\" y=\"358\" width=\"20\" height=\"37\" fill=\"#2c140b\" />\n      <rect x=\"210\" y=\"348\" width=\"74\" height=\"78\" rx=\"6\" fill=\"#0d3d40\" />\n      <rect x=\"210\" y=\"368\" width=\"74\" height=\"30\" fill=\"#e6dac0\" />\n      <rect x=\"206\" y=\"340\" width=\"82\" height=\"16\" rx=\"4\" fill=\"#b8843a\" />\n    </svg>\n  );\n}\n\nexport default function PaperPopUpBookScrollStory() {\n  const stage = useRef<HTMLDivElement>(null);\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const [beat, setBeat] = useState(2);\n  const [shown, setShown] = useState<\"wait\" | \"gl\" | \"still\">(\"wait\");\n  const beatRef = useRef(2);\n  const api = useRef<{ go: (p: number) => void } | null>(null);\n\n  useEffect(() => {\n    const box = stage.current, cv = canvas.current;\n    if (!box || !cv) 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      return gl.getShaderParameter(sh, gl.COMPILE_STATUS) ? sh : null;\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\", \"uCam\", \"uTgt\", \"uFoc\", \"uShift\", \"uFocus\", \"uTh\", \"uA\", \"uTin\", \"uL\", \"uTex\", \"uDirect\"].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 tex = gl.createTexture();\n    gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, tex);\n    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, spreadPrint());\n    gl.generateMipmap(gl.TEXTURE_2D);\n    const aniso = gl.getExtension(\"EXT_texture_filter_anisotropic\");\n    if (aniso) gl.texParameterf(gl.TEXTURE_2D, aniso.TEXTURE_MAX_ANISOTROPY_EXT, 8);\n    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_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\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    // It opens already open: the finished spread is what the first second shows.\n    const s = {\n      p: 1, T: 1, th: 0, thv: 0, a: RISE.map(() => 1), av: RISE.map(() => 0),\n      px: 0, py: 0, sx: 0, sy: 0, count: 0, fresh: true, frame: 0, slow: 0,\n      visible: true, raf: 0, last: 0, t0: 0, touched: false, first: true, fpsN: 0, fpsT: 0,\n    };\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.5, window.devicePixelRatio || 1) * scale;\n      const k = Math.min(1, Math.sqrt(1.2e6 / (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    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    // A three-quarter view from the front and a little to the right, as if the book lay on your desk.\n    const camera = () => {\n      const wide = cssW >= 1024, aspect = cssW / cssH;\n      const el = (wide ? 0.6 : 0.68) - s.sy * 0.03, az = 0.2 + s.sx * 0.08, dist = 11;\n      const tgt = [0.0, 0.42, 0.05];\n      const cam = [tgt[0] + dist * Math.sin(az) * Math.cos(el), tgt[1] + dist * Math.sin(el), tgt[2] + dist * Math.cos(az) * Math.cos(el)];\n      const foc = wide ? 1.9 * Math.min(1, aspect / 1.65) : 1.04 * Math.min(1.5, aspect / 0.5);\n      const shift = wide ? [0.24 * aspect / 1.68, -0.03] : [0.0, 0.15];\n      return { cam, tgt, foc, shift, wide };\n    };\n\n    const draw = (alpha: number, sample: number) => {\n      const c = camera();\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      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.uniform3f(su.uCam, c.cam[0], c.cam[1], c.cam[2]); gl.uniform3f(su.uTgt, c.tgt[0], c.tgt[1], c.tgt[2]);\n      gl.uniform1f(su.uFoc, c.foc);\n      gl.uniform2f(su.uShift, c.shift[0], c.shift[1]);\n      gl.uniform1f(su.uFocus, Math.hypot(c.cam[0], c.cam[1] - 0.4, c.cam[2] - 0.2));\n      gl.uniform1f(su.uTh, s.th);\n      gl.uniform4f(su.uA, s.a[0], s.a[1], s.a[2], s.a[3]);\n      gl.uniform1f(su.uTin, s.a[4]);\n      const lx = -0.7, ly = 0.72, lz = -0.36, ll = Math.hypot(lx, ly, lz);\n      gl.uniform3f(su.uL, lx / ll, ly / ll, lz / ll);\n      gl.uniform1i(su.uTex, 0);\n      gl.uniform1f(su.uDirect, canAcc ? 0 : 1);\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, c.wide ? 0.62 : 0.5, c.wide ? 0.45 : 0.62);\n        gl.drawArrays(gl.TRIANGLES, 0, 3);\n      }\n    };\n\n    // Every target follows from one number: how far through the story the reader is.\n    const targets = (p: number) => ({ th: Math.PI * (1 - sm(COVER[0], COVER[1], p)), a: RISE.map(([a, b]) => sm(a, b, p)) });\n    const snap = () => { const t = targets(s.p); s.th = t.th; s.thv = 0; s.a = t.a; s.av = RISE.map(() => 0); s.count = 0; };\n    const setP = (p: number) => {\n      s.T = Math.max(0, Math.min(1, p));\n      if (reduce) { s.p = s.T; snap(); }\n      const b = beatOf(reduce ? s.p : s.T);\n      if (b !== beatRef.current) { beatRef.current = b; setBeat(b); }\n      wake();\n    };\n    api.current = { go: (p: number) => { s.touched = true; setP(p); } };\n\n    // The self-running demo: hold the open spread, close it, then open it a fold at a time.\n    const demo = (ms: number) => {\n      if (ms < 5200) return 1;\n      const t = ((ms - 5200) / 1000) % 14;\n      return t < 2 ? 0 : t < 4.8 ? beats[0].at : t < 7.6 ? beats[1].at : 1;\n    };\n\n    const frame = (now: number) => {\n      s.raf = 0;\n      if (!s.visible) 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      if (!s.t0) s.t0 = now;\n      if (!still && !s.touched) { const d = demo(now - s.t0); if (d !== s.T) setP(d); }\n\n      let moving = false;\n      if (!reduce) {\n        s.p += (s.T - s.p) * (1 - Math.exp(-dt * 2.6));\n        if (Math.abs(s.T - s.p) < 0.0005) s.p = s.T;\n        const tg = targets(s.p);\n        const sub = 4, h = dt / sub;\n        for (let k = 0; k < sub; k++) {\n          // the board is heavy: it lands, bounces once off the table and settles\n          s.thv += (62 * (tg.th - s.th) - 8.5 * s.thv) * h; s.th += s.thv * h;\n          if (s.th < 0) { s.th = 0; if (s.thv < 0) s.thv *= -0.22; }\n          // card springs up past upright and sways back\n          for (let i = 0; i < RISE.length; i++) {\n            s.av[i] += (150 * (tg.a[i] - s.a[i]) - 9 * s.av[i]) * h; s.a[i] = Math.max(0, s.a[i] + s.av[i] * h);\n          }\n        }\n        if (Math.abs(s.T - s.p) > 0 || Math.abs(s.thv) > 0.002 || Math.abs(tg.th - s.th) > 0.001 || s.av.some((v, i) => Math.abs(v) > 0.002 || Math.abs(tg.a[i] - s.a[i]) > 0.001)) moving = true;\n      }\n      if (!still) {\n        const ox = s.sx, oy = s.sy;\n        s.sx += (s.px - s.sx) * (1 - Math.exp(-dt * 3)); s.sy += (s.py - s.sy) * (1 - Math.exp(-dt * 3));\n        if (Math.abs(s.sx - ox) + Math.abs(s.sy - oy) > 1e-4) moving = true;\n      }\n\n      if (s.fresh || !canAcc) { draw(1, 0); s.fresh = false; s.count = 1; }\n      else if (moving) { draw(0.55, 1 + (s.frame % 64)); s.count = 3; }\n      else if (s.count < 36) { s.count++; draw(1 / s.count, s.count); }\n      if (s.first) { s.first = false; setShown(\"gl\"); }\n\n      if (!still && dtRaw > 0.026) s.slow++; else s.slow = Math.max(0, s.slow - 2);\n      if (s.slow > 45 && scale > 0.5) { scale *= 0.82; s.slow = 0; size(); }\n      s.fpsN++; if (now - s.fpsT > 1000) { box.dataset.fps = String(Math.round((s.fpsN * 1000) / (now - s.fpsT))); s.fpsN = 0; s.fpsT = now; }\n\n      if (moving || s.count < 36 || (!still && !s.touched)) s.raf = requestAnimationFrame(frame);\n    };\n    const wake = () => { if (!s.raf && s.visible) { s.last = 0; s.raf = requestAnimationFrame(frame); } };\n\n    // Scrolling drives the story once the reader starts to scroll: closed as the book enters the\n    // window, fully open by the time it sits in the middle.\n    const onScroll = () => {\n      const r = box.getBoundingClientRect(), vh = window.innerHeight || 800;\n      if (r.bottom < 0 || r.top > vh) return;\n      s.touched = true;\n      setP((vh * 0.95 - r.top) / (vh * 0.95 - Math.max(0, (vh - r.height) / 2) + 1));\n    };\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.02 });\n    io.observe(box);\n    const vis = () => { s.visible = !document.hidden; if (s.visible) wake(); };\n    document.addEventListener(\"visibilitychange\", vis);\n    window.addEventListener(\"scroll\", onScroll, { passive: true });\n    const move = (e: PointerEvent) => {\n      const r = box.getBoundingClientRect();\n      s.px = ((e.clientX - r.left) / r.width) * 2 - 1; s.py = ((e.clientY - r.top) / r.height) * 2 - 1;\n      if (!still) wake();\n    };\n    const leave = () => { s.px = 0; s.py = 0; };\n    box.addEventListener(\"pointermove\", move);\n    box.addEventListener(\"pointerleave\", leave);\n    const lost = (e: Event) => { e.preventDefault(); setShown(\"still\"); };\n    cv.addEventListener(\"webglcontextlost\", lost);\n    wake();\n\n    return () => {\n      cancelAnimationFrame(s.raf); ro.disconnect(); io.disconnect();\n      document.removeEventListener(\"visibilitychange\", vis);\n      window.removeEventListener(\"scroll\", onScroll);\n      box.removeEventListener(\"pointermove\", move); box.removeEventListener(\"pointerleave\", leave);\n      cv.removeEventListener(\"webglcontextlost\", lost);\n      api.current = null;\n    };\n  }, []);\n\n  const choose = (i: number) => {\n    if (api.current) api.current.go(beats[i].at); else { beatRef.current = i; setBeat(i); }\n  };\n  const keys = (e: React.KeyboardEvent, i: number) => {\n    const next = e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? i + 1 : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? i - 1 : e.key === \"Home\" ? 0 : e.key === \"End\" ? beats.length - 1 : -9;\n    if (next === -9) return;\n    e.preventDefault();\n    const k = Math.max(0, Math.min(beats.length - 1, next));\n    choose(k);\n    document.getElementById(`ppb-fold-${k}`)?.focus();\n  };\n  const b = beats[beat];\n\n  return (\n    <section className=\"relative isolate overflow-hidden bg-[#e7ddcd] text-[#1d1a15]\" style={{ fontFamily: FONT }}>\n      <div ref={stage} className=\"relative mx-auto h-[840px] w-full max-w-[1600px] sm:h-[860px] lg:h-[760px]\" style={{ background: \"radial-gradient(90% 80% at 62% 55%, #efe6d8 0%, #e2d6c3 60%, #d3c4ad 100%)\" }}>\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        {shown === \"still\" && <Still />}\n\n        <div className=\"pointer-events-none absolute inset-x-0 bottom-0 px-6 pb-8 sm:px-10 lg:bottom-auto lg:top-0 lg:w-[44%] lg:px-16 lg:pt-16\">\n          <p className=\"text-[11px] font-medium uppercase tracking-[0.32em] text-[#1d1a15]/65\">{BRAND}<span className=\"mx-2 text-[#1d1a15]/30\">/</span>{STORY}</p>\n          <div aria-live=\"polite\" className=\"mt-5 lg:mt-10\">\n            <p className=\"flex items-baseline gap-3 text-[13px] font-medium tabular-nums tracking-[-0.01em] text-[#8a4a1c]\">\n              <span>Fold {String(beat + 1).padStart(2, \"0\")} of {String(beats.length).padStart(2, \"0\")}</span>\n              <span className=\"h-px w-8 bg-[#8a4a1c]/40\" />\n              <span>{b.fold}</span>\n            </p>\n            <h2 key={b.title} className=\"mt-3 max-w-[9ch] animate-[ppb-rise_0.7s_cubic-bezier(0.2,0.9,0.25,1.15)_both] text-[44px] font-semibold leading-[0.92] tracking-[-0.045em] motion-reduce:animate-none sm:text-[58px] lg:text-[78px]\">{b.title}</h2>\n            <p key={b.body} className=\"mt-4 max-w-[25rem] animate-[ppb-fade_0.9s_ease-out_0.12s_both] text-[17px] italic leading-snug text-[#1d1a15]/75 motion-reduce:animate-none lg:mt-6 lg:text-[21px]\" style={{ fontFamily: SERIF }}>{b.body}</p>\n          </div>\n          <div role=\"group\" aria-label=\"Story folds\" className=\"pointer-events-auto mt-6 flex gap-2 lg:mt-12\">\n            {beats.map((x, i) => (\n              <button\n                key={x.fold}\n                id={`ppb-fold-${i}`}\n                type=\"button\"\n                aria-pressed={i === beat}\n                tabIndex={i === beat ? 0 : -1}\n                onClick={() => choose(i)}\n                onKeyDown={(e) => keys(e, i)}\n                className={`flex min-h-[44px] items-center gap-2 rounded-full border px-4 text-[14px] font-medium tracking-[-0.01em] outline-none transition-colors duration-300 focus-visible:ring-2 focus-visible:ring-[#8a4a1c] focus-visible:ring-offset-2 focus-visible:ring-offset-[#e7ddcd] motion-reduce:transition-none ${i === beat ? \"border-[#1d1a15] bg-[#1d1a15] text-[#f3ece0]\" : \"border-[#1d1a15]/25 text-[#1d1a15]/75 hover:border-[#1d1a15]/60 hover:text-[#1d1a15]\"}`}\n              >\n                <span className=\"text-[11px] tabular-nums opacity-70\">{String(i + 1).padStart(2, \"0\")}</span>\n                {x.fold}\n              </button>\n            ))}\n          </div>\n        </div>\n      </div>\n      <style>{`\n        @keyframes ppb-rise { from { opacity: 0; transform: translateY(18px) rotateX(55deg); transform-origin: 50% 100%; } to { opacity: 1; transform: none; } }\n        @keyframes ppb-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }\n      `}</style>\n    </section>\n  );\n}\n"}]}
