{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"sortable-order-table-beside-a-webgl-oak-card-index-drawer-that-riffles-its-cards-into-the-new-order-and-lifts-the-hovered-row","type":"registry:block","title":"Sortable Order Table Beside a WebGL Oak Card Index Drawer That Riffles Its Cards into the New Order and Lifts the Hovered Row","description":"Free sortable React table of shop orders beside a WebGL oak card drawer. Sorting re-files the index cards and the hovered row lifts its card.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/sortable-order-table-beside-a-webgl-oak-card-index-drawer-that-riffles-its-cards-into-the-new-order-and-lifts-the-hovered-row.tsx","type":"registry:component","content":"import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** The shop and its orders. Demo data: replace with your own rows. */\nconst SHOP = \"Halden Paper Co.\";\ntype Status = \"Paid\" | \"Packed\" | \"Shipped\" | \"Delivered\";\ntype Order = { id: string; customer: string; item: string; placed: string; total: number; status: Status };\nconst orders: Order[] = [\n  { id: \"2041\", customer: \"Ilse Varga\", item: \"Linen notebook, A5\", placed: \"2026-10-03\", total: 48, status: \"Shipped\" },\n  { id: \"2042\", customer: \"Tomas Rehl\", item: \"Brass pen clips, set of 4\", placed: \"2026-10-03\", total: 22.5, status: \"Delivered\" },\n  { id: \"2043\", customer: \"Wren Osei\", item: \"Ruled index cards, 500\", placed: \"2026-10-04\", total: 16, status: \"Paid\" },\n  { id: \"2044\", customer: \"Marguerite Lund\", item: \"Oak desk tray\", placed: \"2026-10-05\", total: 118, status: \"Packed\" },\n  { id: \"2045\", customer: \"Arun Mehra\", item: \"Fountain pen ink, sepia\", placed: \"2026-10-06\", total: 31, status: \"Shipped\" },\n  { id: \"2046\", customer: \"Noor Haddad\", item: \"Wax seal kit\", placed: \"2026-10-07\", total: 64, status: \"Paid\" },\n  { id: \"2047\", customer: \"Pia Castell\", item: \"Kraft envelopes, 50\", placed: \"2026-10-08\", total: 12.75, status: \"Delivered\" },\n  { id: \"2048\", customer: \"Calum Frey\", item: \"Card file drawer, oak\", placed: \"2026-10-09\", total: 186, status: \"Packed\" },\n];\n\n/** Tab colours of the index cards, one per status (sRGB hex). */\nconst STATUS: Record<Status, { hex: string; rank: number }> = {\n  Paid: { hex: \"#d8b25c\", rank: 0 },\n  Packed: { hex: \"#cf8f78\", rank: 1 },\n  Shipped: { hex: \"#93ab86\", rank: 2 },\n  Delivered: { hex: \"#86a2bf\", rank: 3 },\n};\n\ntype Key = \"id\" | \"customer\" | \"item\" | \"placed\" | \"total\" | \"status\";\nconst columns: { key: Key; label: string; numeric?: boolean; wide?: boolean }[] = [\n  { key: \"id\", label: \"Order\" },\n  { key: \"customer\", label: \"Customer\" },\n  { key: \"item\", label: \"Item\", wide: true },\n  { key: \"placed\", label: \"Placed\", wide: true },\n  { key: \"total\", label: \"Total\", numeric: true },\n  { key: \"status\", label: \"Status\" },\n];\n\nconst RIFFLE_SECONDS = 0.9; // how long one card takes to travel to its new place\nconst RIFFLE_STAGGER = 0.07; // delay between cards, by their new position\nconst RIFFLE_HEIGHT = 1.02; // how high a moving card is pulled out of the drawer\nconst HOVER_LIFT = 0.74; // how far the hovered row's card rises\nconst DEMO = true; // plays a short sort-and-point demo until the visitor touches anything\n\nconst GROTESK = '\"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, sans-serif';\nconst SERIF = '\"Iowan Old Style\", \"Palatino Linotype\", Palatino, \"Book Antiqua\", Georgia, serif';\nconst TYPE = '\"Courier Prime\", \"Courier New\", Courier, ui-monospace, monospace';\nconst PAPER = \"#f3eee5\";\nconst INK = \"#1f1b16\";\n\nconst TAB_X = [-0.52, 0.0, 0.52];\nconst SLOT_Z = (s: number) => 0.92 - s * 0.255;\nconst CELL_W = 640, CELL_H = 456;\n\nconst money = (n: number) => `$${n.toFixed(2)}`;\nconst day = (iso: string) => {\n  const [, m, d] = iso.split(\"-\").map(Number);\n  return `${d} ${[\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"][m - 1]}`;\n};\nconst clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v));\nconst lin = (hex: string) => [1, 3, 5].map((i) => Math.pow(parseInt(hex.slice(i, i + 2), 16) / 255, 2.2));\n\nfunction compare(a: Order, b: Order, key: Key) {\n  if (key === \"total\") return a.total - b.total;\n  if (key === \"status\") return STATUS[a.status].rank - STATUS[b.status].rank || a.id.localeCompare(b.id);\n  return String(a[key]).localeCompare(String(b[key])) || a.id.localeCompare(b.id);\n}\n\nconst GLSL = `#version 300 es\nprecision highp float;\nuniform vec3 uCam, uRt, uUp, uFw;\nuniform float uTan, uAspect, uFocus, uAperture;\nuniform vec2 uShift;\nuniform vec4 uCard[8]; // z, lift, tilt, tab x\nuniform vec3 uTab[8];\nuniform sampler2D uInk;\nin vec2 vUv;\nout vec4 o;\n\nconst vec3 L = normalize(vec3(-0.62, 0.74, 0.30));\nconst float WALL = -2.7;\nconst vec3 SUN = vec3(1.0, 0.85, 0.66) * 3.1;\nconst vec3 SKY = vec3(0.70, 0.72, 0.78) * 0.7;\n\nfloat h21(vec2 p) { p = fract(p * vec2(123.34, 456.21)); p += dot(p, p + 45.32); return fract(p.x * p.y); }\nfloat vnoise(vec2 p) { vec2 i = floor(p), f = fract(p); f = f * f * (3.0 - 2.0 * f);\n  return mix(mix(h21(i), h21(i + vec2(1, 0)), f.x), mix(h21(i + vec2(0, 1)), h21(i + vec2(1, 1)), f.x), f.y); }\nfloat fbm(vec2 p) { float a = 0.5, s = 0.0; for (int i = 0; i < 4; i++) { s += a * vnoise(p); p = p * 2.03 + 17.1; a *= 0.5; } return s; }\n\nfloat sdBox(vec3 p, vec3 b) { vec3 q = abs(p) - b; return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0); }\nfloat sdRect(vec2 p, vec2 b, float r) { vec2 q = abs(p) - b + r; return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r; }\nfloat sdCap(vec3 p, vec3 a, vec3 b, float r) { vec3 pa = p - a, ba = b - a; float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0); return length(pa - ba * h) - r; }\n\nvec3 cardLocal(vec3 p, int k) {\n  vec4 c = uCard[k];\n  vec3 q = p - vec3(0.0, 0.065 + c.y, c.x);\n  float s = sin(c.z), co = cos(c.z);\n  q.yz = mat2(co, s, -s, co) * q.yz;\n  return q;\n}\nfloat sdCard(vec3 q, float tx) {\n  float d2 = min(sdRect(q.xy - vec2(0.0, 0.5), vec2(0.8, 0.5), 0.03), sdRect(q.xy - vec2(tx, 1.03), vec2(0.17, 0.11), 0.035));\n  vec2 w = vec2(d2, abs(q.z) - 0.0065);\n  return min(max(w.x, w.y), 0.0) + length(max(w, 0.0));\n}\n\n// 0 desk, 2 oak, 3 brass, 4 label, 10+k card k\nvec2 map(vec3 p, bool desk) {\n  vec2 r = vec2(desk ? p.y : 1e3, 0.0);\n  float outer = sdBox(p - vec3(0.0, 0.3, -0.02), vec3(0.95, 0.3, 1.2)) - 0.008;\n  float inner = sdBox(p - vec3(0.0, 0.76, -0.02), vec3(0.885, 0.71, 1.135));\n  float front = sdBox(p - vec3(0.0, 0.34, 1.215), vec3(1.0, 0.34, 0.045)) - 0.012;\n  float d = min(max(outer, -inner), front);\n  if (d < r.x) r = vec2(d, 2.0);\n  if (p.z > 1.18) {\n    float b = sdCap(p, vec3(-0.21, 0.47, 1.335), vec3(0.21, 0.47, 1.335), 0.024);\n    b = min(b, sdCap(p, vec3(-0.21, 0.47, 1.26), vec3(-0.21, 0.47, 1.335), 0.017));\n    b = min(b, sdCap(p, vec3(0.21, 0.47, 1.26), vec3(0.21, 0.47, 1.335), 0.017));\n    float fr = max(sdBox(p - vec3(0.0, 0.215, 1.268), vec3(0.22, 0.085, 0.01)) - 0.004, -sdBox(p - vec3(0.0, 0.215, 1.29), vec3(0.19, 0.058, 0.03)));\n    b = min(b, fr);\n    if (b < r.x) r = vec2(b, 3.0);\n    float lab = sdBox(p - vec3(0.0, 0.215, 1.263), vec3(0.2, 0.065, 0.004));\n    if (lab < r.x) r = vec2(lab, 4.0);\n  }\n  float bb = sdBox(p - vec3(0.0, 1.2, -0.05), vec3(0.86, 1.2, 1.3));\n  if (bb < r.x) {\n    for (int k = 0; k < 8; k++) {\n      float c = sdCard(cardLocal(p, k), uCard[k].w);\n      if (c < r.x) r = vec2(c, 10.0 + float(k));\n    }\n  }\n  return r;\n}\nvec3 nrm(vec3 p, bool desk) {\n  const vec2 e = vec2(0.0012, -0.0012);\n  return normalize(e.xyy * map(p + e.xyy, desk).x + e.yyx * map(p + e.yyx, desk).x + e.yxy * map(p + e.yxy, desk).x + e.xxx * map(p + e.xxx, desk).x);\n}\nfloat shadow(vec3 ro) {\n  float res = 1.0, t = 0.015;\n  for (int i = 0; i < 44; i++) {\n    float h = map(ro + L * t, false).x;\n    res = min(res, 9.0 * h / t);\n    t += clamp(h, 0.008, 0.22);\n    if (res < 0.003 || t > 4.5) break;\n  }\n  return clamp(res, 0.0, 1.0);\n}\nfloat occl(vec3 p, vec3 n) {\n  float o = 0.0, s = 1.0;\n  for (int i = 1; i <= 5; i++) { float h = 0.015 + 0.055 * float(i); o += (h - map(p + n * h, true).x) * s; s *= 0.72; }\n  return clamp(1.0 - 2.4 * o, 0.0, 1.0);\n}\n// a tall window off to the left: the sun comes through its glazing bars\nfloat gobo(vec3 p) {\n  float t = (-4.2 - p.x) / L.x;\n  vec3 h = p + L * t;\n  float s = 0.012 + 0.016 * t;\n  float win = smoothstep(-s, s, h.y - 0.3) * smoothstep(-s, s, 5.2 - h.y) * smoothstep(-s, s, h.z + 2.6) * smoothstep(-s, s, 3.4 - h.z);\n  float mz = abs(fract((h.z + 0.35) / 1.45 + 0.5) - 0.5) * 1.45;\n  float bars = smoothstep(0.035 - s, 0.035 + s, mz) * smoothstep(0.04 - s, 0.04 + s, abs(h.y - 3.05));\n  return win * bars;\n}\nvec3 env(vec3 r) {\n  vec3 c = mix(vec3(0.80, 0.74, 0.66), vec3(0.78, 0.84, 0.94), smoothstep(-0.2, 0.7, r.y));\n  c += vec3(2.6, 2.4, 2.1) * smoothstep(0.45, 0.7, -r.x) * smoothstep(0.0, 0.2, r.y) * smoothstep(0.95, 0.6, r.y);\n  return c;\n}\nfloat ggx(vec3 n, vec3 v, float rough) {\n  vec3 h = normalize(L + v); float a = rough * rough, nh = max(dot(n, h), 0.0);\n  float d = a * a / (3.14159 * pow(nh * nh * (a * a - 1.0) + 1.0, 2.0));\n  return d * max(dot(n, L), 0.0) * 0.25 / max(dot(n, v) * 0.5 + 0.5, 0.2);\n}\nvec3 oak(vec3 p, vec3 n) {\n  vec2 g = abs(n.x) > 0.5 ? p.zy : (abs(n.y) > 0.5 ? p.zx : p.xy);\n  float w = fbm(vec2(g.x * 0.45, g.y * 2.2)) * 16.0 + fbm(vec2(g.x * 2.0, g.y * 9.0)) * 2.5;\n  float ring = 0.5 + 0.5 * sin(g.y * 24.0 + w);\n  ring = pow(ring, 3.0);\n  float fibre = fbm(vec2(g.x * 3.0, g.y * 160.0));\n  float ray = smoothstep(0.82, 0.95, vnoise(vec2(g.x * 9.0, g.y * 40.0)));\n  vec3 a = mix(vec3(0.54, 0.34, 0.16), vec3(0.40, 0.23, 0.10), ring * 0.75);\n  a *= 0.88 + 0.2 * fibre;\n  return mix(a, vec3(0.70, 0.52, 0.30), ray * 0.25);\n}\n\nvec3 light(vec3 p, vec3 n, vec3 v, vec3 alb, float rough, float spec, bool desk) {\n  float sh = shadow(p + n * 0.004) * gobo(p);\n  float ao = occl(p, n);\n  float nl = max(dot(n, L), 0.0);\n  vec3 c = alb * (SUN * nl * sh + SKY * (0.55 + 0.45 * n.y) * ao + vec3(0.42, 0.32, 0.22) * (0.5 - 0.5 * n.y) * ao * 0.8);\n  float f = spec + (1.0 - spec) * pow(1.0 - max(dot(n, v), 0.0), 5.0);\n  c += SUN * ggx(n, v, rough) * sh * f * 1.2;\n  c += env(reflect(-v, n)) * f * ao * (1.0 - rough) * 0.35;\n  return c;\n}\n\nvec3 shadeCard(int k, vec3 p, vec3 v, vec3 n) {\n  vec3 q = cardLocal(p, k);\n  vec3 alb = vec3(0.90, 0.87, 0.80);\n  float tx = uCard[k].w;\n  bool tab = q.y > 0.985 && abs(q.x - tx) < 0.2;\n  vec3 ln = n;\n  float face = abs(q.z) > 0.004 ? 1.0 : 0.0;\n  if (tab) alb = uTab[k];\n  if (q.z > 0.004) {\n    // printed rules on the front of the card\n    if (!tab) {\n      float px = fwidth(q.y) * 1.2 + 0.0015;\n      float red = 1.0 - smoothstep(0.0, px + 0.002, abs(q.y - 0.86));\n      alb = mix(alb, vec3(0.70, 0.22, 0.20), red * 0.75);\n      float bl = 0.0;\n      for (int i = 0; i < 7; i++) bl = max(bl, 1.0 - smoothstep(0.0, px + 0.0015, abs(q.y - (0.74 - float(i) * 0.1))));\n      alb = mix(alb, vec3(0.42, 0.58, 0.80), bl * 0.6);\n    }\n    vec2 uv = vec2((q.x + 0.8) / 1.6, clamp(q.y / 1.14, 0.0, 1.0));\n    vec2 t = vec2(uv.x, 1.0 - (float(k) + 1.0 - uv.y) / 8.0);\n    vec4 ink = texture(uInk, t);\n    alb = mix(alb, uTab[k] * vec3(0.55, 0.42, 0.40), ink.g * 0.8);\n    alb = mix(alb, vec3(0.07, 0.07, 0.10), min(ink.r * 1.15, 1.0));\n  } else if (face < 0.5) {\n    alb *= 0.9;\n  }\n  float fib = vnoise(q.xy * vec2(240.0, 240.0)) * 0.05;\n  alb *= 0.97 + fib;\n  vec3 c = light(p, n, v, alb, 0.75, 0.03, false);\n  // thin card: sun that hits the back comes through, warmed by the paper\n  float back = max(dot(-n, L), 0.0);\n  if (back > 0.0) c += alb * vec3(1.0, 0.82, 0.6) * SUN * back * 0.16 * shadow(p - n * 0.01) * gobo(p);\n  return c;\n}\n\nvoid main() {\n  vec2 sp = vUv * 2.0 - 1.0 - uShift;\n  vec3 rd = normalize(uFw + uRt * sp.x * uTan * uAspect + uUp * sp.y * uTan);\n  float tD = rd.y < 0.0 ? -uCam.y / rd.y : 60.0;\n  float t = 0.0, id = -1.0;\n  float tmax = min(tD, 30.0);\n  for (int i = 0; i < 140; i++) {\n    vec2 h = map(uCam + rd * t, false);\n    if (h.x < 0.00035 * t) { id = h.y; break; }\n    t += h.x;\n    if (t > tmax) break;\n  }\n  vec3 v = -rd, col; float depth;\n  if (id >= 0.0 && t < tmax) {\n    vec3 p = uCam + rd * t;\n    vec3 n = nrm(p, false);\n    if (id >= 10.0) col = shadeCard(int(id - 10.0 + 0.5), p, v, n);\n    else if (id > 3.5) col = light(p, n, v, vec3(0.86, 0.82, 0.72) * (0.92 + 0.08 * vnoise(p.xy * 300.0)), 0.8, 0.03, false);\n    else if (id > 2.5) col = light(p, n, v, vec3(0.0), 0.28, 0.0, false) + vec3(0.95, 0.72, 0.38) * (env(reflect(rd, n)) * 0.6 * occl(p, n) + SUN * ggx(n, v, 0.28) * shadow(p + n * 0.004) * 2.2);\n    else col = light(p, n, v, oak(p, n), 0.36, 0.04, false);\n    depth = t;\n  } else if (rd.z < 0.0 && (WALL - uCam.z) / rd.z < tD) {\n    // the plaster wall behind the desk\n    float tw = (WALL - uCam.z) / rd.z;\n    vec3 p = uCam + rd * tw;\n    vec3 n = vec3(0.0, 0.0, 1.0);\n    vec3 alb = vec3(0.88, 0.80, 0.69) * (0.96 + 0.06 * fbm(p.xy * 9.0));\n    col = alb * (SUN * max(dot(n, L), 0.0) * gobo(p) + SKY * 0.8 + vec3(0.42, 0.32, 0.22) * 0.5 * exp(-p.y * 1.5));\n    col *= 1.0 - 0.35 * exp(-p.y * 9.0);\n    depth = tw;\n  } else {\n    vec3 p = uCam + rd * tD;\n    vec3 n = vec3(0.0, 1.0, 0.0);\n    float g = fbm(vec2(p.x * 0.6, p.z * 16.0));\n    vec3 alb = mix(vec3(0.74, 0.63, 0.49), vec3(0.83, 0.73, 0.59), g) * (0.95 + 0.06 * vnoise(vec2(p.x * 3.0, p.z * 140.0)));\n    col = light(p, n, v, alb, 0.5, 0.035, true);\n    col *= 1.0 - 0.3 * exp(-(p.z - WALL) * 6.0);\n    depth = tD;\n  }\n  float z = depth * dot(rd, uFw);\n  float coc = clamp(uAperture * (1.0 - uFocus / max(z, 0.05)), -1.0, 1.0);\n  vec3 x = col * 0.7;\n  x = clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);\n  o = vec4(pow(x, vec3(1.0 / 2.2)), 0.5 + 0.5 * coc);\n}`;\n\nconst VS = `#version 300 es\nout vec2 vUv;\nvoid main() { vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2)); vUv = p; gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0); }`;\n\nconst FS_LENS = `#version 300 es\nprecision highp float;\nuniform sampler2D uScene;\nuniform vec2 uPx;\nuniform float uMaxR, uTime;\nin vec2 vUv;\nout vec4 o;\nfloat ign(vec2 p) { return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); }\nvoid main() {\n  vec4 c0 = texture(uScene, vUv);\n  float s0 = c0.a * 2.0 - 1.0, coc0 = abs(s0);\n  vec3 acc = c0.rgb; float wsum = 1.0;\n  float rot = 6.2832 * ign(gl_FragCoord.xy);\n  for (int k = 1; k < 18; k++) {\n    float r = sqrt(float(k) / 18.0) * uMaxR;\n    float a = float(k) * 2.39996 + rot;\n    vec4 s = texture(uScene, vUv + vec2(cos(a), sin(a)) * r * uPx);\n    float sc = s.a * 2.0 - 1.0, cs = abs(sc);\n    if (sc > s0) cs = min(cs, coc0 * 1.6 + 0.02);\n    float w = smoothstep(r - 1.0, r + 1.0, cs * uMaxR);\n    acc += s.rgb * w; wsum += w;\n  }\n  vec3 col = acc / wsum;\n  const vec3 LU = vec3(0.299, 0.587, 0.114);\n  vec3 cNW = texture(uScene, vUv + vec2(-1.0, -1.0) * uPx).rgb, cNE = texture(uScene, vUv + vec2(1.0, -1.0) * uPx).rgb;\n  vec3 cSW = texture(uScene, vUv + vec2(-1.0, 1.0) * uPx).rgb, cSE = texture(uScene, vUv + vec2(1.0, 1.0) * uPx).rgb;\n  float lNW = dot(cNW, LU), lNE = dot(cNE, LU), lSW = dot(cSW, LU), lSE = dot(cSE, LU), lM = dot(c0.rgb, LU);\n  float lMin = min(lM, min(min(lNW, lNE), min(lSW, lSE))), lMax = max(lM, max(max(lNW, lNE), max(lSW, lSE)));\n  vec2 dir = vec2(-((lNW + lNE) - (lSW + lSE)), (lNW + lSW) - (lNE + lSE));\n  float rcp = 1.0 / (min(abs(dir.x), abs(dir.y)) + max((lNW + lNE + lSW + lSE) * 0.03125, 0.0078));\n  dir = clamp(dir * rcp, -8.0, 8.0) * uPx;\n  vec3 fa = 0.5 * (texture(uScene, vUv + dir * (1.0 / 3.0 - 0.5)).rgb + texture(uScene, vUv + dir * (2.0 / 3.0 - 0.5)).rgb);\n  vec3 fb = fa * 0.5 + 0.25 * (texture(uScene, vUv - dir * 0.5).rgb + texture(uScene, vUv + dir * 0.5).rgb);\n  float lB = dot(fb, LU);\n  vec3 fx = (lB < lMin || lB > lMax) ? fa : fb;\n  col = mix(fx, col, smoothstep(0.05, 0.3, coc0));\n  vec2 q = vUv - 0.5;\n  col *= 1.0 - 0.22 * dot(q, q);\n  col += (ign(gl_FragCoord.xy + fract(uTime) * 61.0) - 0.5) * 0.016;\n  o = vec4(col, 1.0);\n}`;\n\nfunction program(gl: WebGL2RenderingContext, vs: string, fs: string) {\n  const p = gl.createProgram()!;\n  for (const [type, src] of [[gl.VERTEX_SHADER, vs], [gl.FRAGMENT_SHADER, fs]] as const) {\n    const s = gl.createShader(type)!;\n    gl.shaderSource(s, src);\n    gl.compileShader(s);\n    if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) throw new Error(gl.getShaderInfoLog(s) || \"shader\");\n    gl.attachShader(p, s);\n  }\n  gl.linkProgram(p);\n  if (!gl.getProgramParameter(p, gl.LINK_STATUS)) throw new Error(gl.getProgramInfoLog(p) || \"link\");\n  return p;\n}\n\n/** What is typed on each card: red channel is typewriter ink, green is the status stamp. */\nfunction typeCards() {\n  const cv = document.createElement(\"canvas\");\n  cv.width = CELL_W;\n  cv.height = CELL_H * orders.length;\n  const ctx = cv.getContext(\"2d\")!;\n  ctx.fillStyle = \"#000\";\n  ctx.fillRect(0, 0, cv.width, cv.height);\n  const top = (CELL_H * 0.14) / 1.14;\n  const yOf = (v: number) => top + (1 - v) * (CELL_H - top);\n  orders.forEach((o, k) => {\n    ctx.save();\n    ctx.translate(0, k * CELL_H);\n    ctx.fillStyle = \"#ff0000\";\n    ctx.textBaseline = \"alphabetic\";\n    // the tab\n    const tx = ((TAB_X[k % 3] + 0.8) / 1.6) * CELL_W;\n    ctx.textAlign = \"center\";\n    ctx.font = `700 38px ${TYPE}`;\n    ctx.fillText(o.id, tx, top - 8);\n    // the heading line, above the red rule\n    ctx.textAlign = \"left\";\n    ctx.font = `700 40px ${TYPE}`;\n    ctx.fillText(o.customer.toUpperCase(), 34, yOf(0.86) - 12);\n    ctx.font = `600 31px ${TYPE}`;\n    ctx.fillText(o.item, 34, yOf(0.74) - 8);\n    ctx.fillText(`Placed ${day(o.placed)} 2026`, 34, yOf(0.64) - 8);\n    ctx.font = `700 34px ${TYPE}`;\n    ctx.fillText(`Total ${money(o.total)}`, 34, yOf(0.54) - 8);\n    // the rubber stamp\n    ctx.translate(CELL_W - 150, yOf(0.42));\n    ctx.rotate(-0.16);\n    ctx.strokeStyle = \"#00ff00\";\n    ctx.fillStyle = \"#00ff00\";\n    ctx.lineWidth = 5;\n    ctx.strokeRect(-110, -34, 220, 62);\n    ctx.font = `800 34px ${GROTESK}`;\n    ctx.textAlign = \"center\";\n    ctx.fillText(o.status.toUpperCase(), 0, 10);\n    ctx.restore();\n  });\n  return cv;\n}\n\ntype Sim = {\n  z: number[]; from: number[]; to: number[]; start: number[]; moving: boolean[];\n  tilt: number[]; tv: number[]; hov: number[]; hv: number[]; hover: number; dirty: boolean; touched: boolean; now: number;\n};\n\n/** The drawer drawn with plain elements, for browsers without WebGL 2. */\nfunction Still({ slots, hover }: { slots: number[]; hover: number | null }) {\n  const byFront = orders.map((_, k) => k).sort((a, b) => slots[b] - slots[a]);\n  return (\n    <div aria-hidden=\"true\" className=\"absolute inset-0 overflow-hidden\" style={{ background: \"linear-gradient(180deg, #e9e1d4 0%, #dccdb6 55%, #cdbb9f 100%)\" }}>\n      <div className=\"absolute inset-0\" style={{ background: \"repeating-linear-gradient(118deg, rgba(255,247,230,0) 0 70px, rgba(255,247,230,0.5) 70px 150px, rgba(255,247,230,0) 150px 165px)\" }} />\n      <div className=\"absolute left-1/2 top-[56%] h-[30%] w-[78%] -translate-x-1/2 rounded-md shadow-[18px_26px_40px_rgba(70,45,20,0.35)]\" style={{ background: \"linear-gradient(180deg, #8a5a2f, #6a4021)\" }} />\n      {byFront.map((k) => {\n        const s = slots[k];\n        const lifted = hover === k;\n        return (\n          <div key={k} className=\"absolute left-1/2 w-[70%] -translate-x-1/2 rounded-t-md border border-[#cfc5b2] shadow-[0_-2px_6px_rgba(60,40,20,0.12)]\" style={{ top: `${18 + (7 - s) * 4.6 - (lifted ? 9 : 0)}%`, height: \"44%\", background: \"#efe9dc\" }}>\n            <span className=\"absolute -top-[9%] h-[10%] w-[22%] rounded-t-md\" style={{ left: `${39 + TAB_X[k % 3] * 38}%`, background: STATUS[orders[k].status].hex }} />\n            <span className=\"absolute left-[5%] top-[6%] text-[11px] font-bold uppercase\" style={{ fontFamily: TYPE, color: INK }}>{orders[k].customer}</span>\n            <span className=\"absolute inset-x-0 top-[22%] h-px bg-[#b5413a]/70\" />\n          </div>\n        );\n      })}\n      <div className=\"absolute left-1/2 top-[66%] h-[26%] w-[82%] -translate-x-1/2 rounded-md shadow-[0_18px_30px_rgba(60,35,15,0.35)]\" style={{ background: \"linear-gradient(180deg, #9a6838, #7b4f29 60%, #6a4322)\" }}>\n        <span className=\"absolute left-1/2 top-[22%] h-[8%] w-[22%] -translate-x-1/2 rounded-full\" style={{ background: \"linear-gradient(180deg, #f1d18c, #a87a34)\" }} />\n        <span className=\"absolute left-1/2 top-[52%] h-[24%] w-[24%] -translate-x-1/2 rounded-sm border-2 border-[#c39a52] bg-[#e8e0cd]\" />\n      </div>\n    </div>\n  );\n}\n\nexport default function SortableOrderTableCardIndex() {\n  const reduce = useReducedMotion();\n  const wrapRef = useRef<HTMLDivElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const [sort, setSort] = useState<{ key: Key; dir: 1 | -1 }>({ key: \"id\", dir: 1 });\n  const [hover, setHover] = useState<number | null>(null);\n  const [mode, setMode] = useState<\"pending\" | \"gl\" | \"still\">(\"pending\");\n  const [said, setSaid] = useState(\"\");\n  const sim = useRef<Sim>({\n    z: orders.map((_, k) => SLOT_Z(k)), from: orders.map((_, k) => SLOT_Z(k)), to: orders.map((_, k) => SLOT_Z(k)),\n    start: orders.map(() => -10), moving: orders.map(() => false), tilt: orders.map(() => 0), tv: orders.map(() => 0),\n    hov: orders.map(() => 0), hv: orders.map(() => 0), hover: -1, dirty: true, touched: false, now: 0,\n  });\n  const demo = useRef<{ setSort: typeof setSort; setHover: typeof setHover }>({ setSort, setHover });\n\n  const rows = useMemo(() => orders.map((o, k) => ({ o, k })).sort((a, b) => compare(a.o, b.o, sort.key) * sort.dir), [sort]);\n  const slots = useMemo(() => {\n    const s = orders.map(() => 0);\n    rows.forEach((r, i) => (s[r.k] = i));\n    return s;\n  }, [rows]);\n\n  // a new order: every card is pulled up and dropped into its new place, front card first\n  useEffect(() => {\n    const s = sim.current;\n    orders.forEach((_, k) => {\n      const target = SLOT_Z(slots[k]);\n      if (Math.abs(target - s.to[k]) < 1e-4 && !s.moving[k]) return;\n      s.from[k] = s.z[k];\n      s.to[k] = target;\n      s.start[k] = s.now + slots[k] * RIFFLE_STAGGER;\n      s.moving[k] = true;\n    });\n    s.dirty = true;\n  }, [slots]);\n  useEffect(() => {\n    sim.current.hover = hover ?? -1;\n    sim.current.dirty = true;\n  }, [hover]);\n\n  // the self-playing demo: point at a card, sort, point again, until the visitor takes over\n  useEffect(() => {\n    if (!DEMO || reduce) return;\n    const script: [number, () => void][] = [\n      [0.5, () => setHover(2)],\n      [3.4, () => setHover(null)],\n      [0.5, () => setSort({ key: \"total\", dir: -1 })],\n      [2.6, () => setHover(6)],\n      [2.4, () => setHover(null)],\n      [0.5, () => setSort({ key: \"customer\", dir: 1 })],\n      [2.6, () => setHover(4)],\n      [2.4, () => setHover(null)],\n      [0.5, () => setSort({ key: \"id\", dir: 1 })],\n    ];\n    let step = 0, timer = 0;\n    const next = () => {\n      if (sim.current.touched) return;\n      const [wait, act] = script[step % script.length];\n      timer = window.setTimeout(() => {\n        if (sim.current.touched) return;\n        act();\n        step++;\n        next();\n      }, wait * 1000);\n    };\n    next();\n    return () => window.clearTimeout(timer);\n  }, [reduce]);\n\n  useEffect(() => {\n    const wrap = wrapRef.current;\n    const canvas = canvasRef.current;\n    if (!wrap || !canvas) return;\n    const gl = canvas.getContext(\"webgl2\", { antialias: false, alpha: false, powerPreference: \"high-performance\" });\n    if (!gl) {\n      setMode(\"still\");\n      return;\n    }\n    const s = sim.current;\n    let pScene: WebGLProgram, pLens: WebGLProgram;\n    try {\n      pScene = program(gl, VS, GLSL);\n      pLens = program(gl, VS, FS_LENS);\n    } catch (err) {\n      console.warn(err);\n      setMode(\"still\");\n      return;\n    }\n    setMode(\"gl\");\n\n    const ink = gl.createTexture();\n    gl.activeTexture(gl.TEXTURE0);\n    gl.bindTexture(gl.TEXTURE_2D, ink);\n    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);\n    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, typeCards());\n    gl.generateMipmap(gl.TEXTURE_2D);\n    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_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.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);\n    const tabs = orders.flatMap((o) => lin(STATUS[o.status].hex));\n\n    const vao = gl.createVertexArray();\n    const fbo = gl.createFramebuffer();\n    const tex = gl.createTexture();\n    let W = 0, H = 0, scale = Math.min(window.devicePixelRatio || 1, 1.5), cssW = 1, cssH = 1;\n    const TAN = Math.tan((17 * Math.PI) / 180);\n    const cam = { pos: [0, 2, 6], rt: [1, 0, 0], up: [0, 1, 0], fw: [0, 0, -1], shift: [0, 0], focus: 6 };\n    let view = [0, 0], pointer = [0, 0], focus = 6;\n\n    const aim = () => {\n      const aspect = cssW / cssH;\n      const half = Math.atan(Math.min(TAN, TAN * aspect));\n      const dist = (aspect > 1 ? 1.95 : 1.66) / Math.sin(half);\n      const az = 0.38 + view[0] * 0.12, el = 0.66 + view[1] * 0.06;\n      const target = [-0.12, 0.72, -0.02];\n      cam.pos = [target[0] + Math.sin(az) * Math.cos(el) * dist, target[1] + Math.sin(el) * dist, target[2] + Math.cos(az) * Math.cos(el) * dist];\n      let fw = [target[0] - cam.pos[0], target[1] - cam.pos[1], target[2] - cam.pos[2]];\n      const fl = Math.hypot(fw[0], fw[1], fw[2]);\n      fw = fw.map((v) => v / fl);\n      let rt = [-fw[2], 0, fw[0]];\n      const rl = Math.hypot(rt[0], rt[2]);\n      rt = rt.map((v) => v / rl);\n      cam.fw = fw;\n      cam.rt = rt;\n      cam.up = [rt[1] * fw[2] - rt[2] * fw[1], rt[2] * fw[0] - rt[0] * fw[2], rt[0] * fw[1] - rt[1] * fw[0]];\n      cam.shift = [0, -0.04];\n      return aspect;\n    };\n    const depthOf = (p: number[]) => (p[0] - cam.pos[0]) * cam.fw[0] + (p[1] - cam.pos[1]) * cam.fw[1] + (p[2] - cam.pos[2]) * cam.fw[2];\n    const project = (p: number[]) => {\n      const d = [p[0] - cam.pos[0], p[1] - cam.pos[1], p[2] - cam.pos[2]];\n      const z = depthOf(p);\n      const x = (d[0] * cam.rt[0] + d[1] * cam.rt[1] + d[2] * cam.rt[2]) / (z * TAN * (cssW / cssH)) + cam.shift[0];\n      const y = (d[0] * cam.up[0] + d[1] * cam.up[1] + d[2] * cam.up[2]) / (z * TAN) + cam.shift[1];\n      return [(x * 0.5 + 0.5) * cssW, (0.5 - y * 0.5) * cssH];\n    };\n\n    const resize = () => {\n      cssW = wrap.clientWidth;\n      cssH = wrap.clientHeight;\n      let k = scale;\n      if (cssW * cssH * k * k > 1.1e6) k = Math.sqrt(1.1e6 / (cssW * cssH));\n      const w = Math.max(2, Math.round(cssW * k)), h = Math.max(2, Math.round(cssH * k));\n      aim();\n      if (w === W && h === H) return;\n      W = w;\n      H = h;\n      canvas.width = W;\n      canvas.height = H;\n      gl.activeTexture(gl.TEXTURE1);\n      gl.bindTexture(gl.TEXTURE_2D, tex);\n      gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, W, H, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_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, tex, 0);\n      s.dirty = true;\n    };\n    resize();\n    const ro = new ResizeObserver(resize);\n    ro.observe(wrap);\n\n    const U = (p: WebGLProgram, n: string) => gl.getUniformLocation(p, n);\n    const REST = orders.map((_, k) => 0.075 + 0.025 * Math.sin(k * 2.3));\n    // where each card is right now: its depth in the drawer, how high it is and how far it leans\n    const pose = (k: number) => {\n      const t = s.now;\n      let lift = s.hov[k] * HOVER_LIFT, tilt = REST[k] + s.tilt[k] - s.hov[k] * 0.3;\n      if (s.moving[k]) {\n        const p = clamp((t - s.start[k]) / RIFFLE_SECONDS, 0, 1);\n        const far = clamp(Math.abs(s.to[k] - s.from[k]) / 0.5, 0.18, 1);\n        lift += RIFFLE_HEIGHT * far * Math.sin(Math.PI * Math.pow(p, 0.8)) ** 1.4;\n        tilt -= 0.42 * far * Math.sin(Math.PI * p) * (s.to[k] > s.from[k] ? 1 : -0.6);\n      }\n      return { lift, tilt };\n    };\n\n    const draw = () => {\n      const aspect = aim();\n      const C: number[] = [];\n      orders.forEach((_, k) => {\n        const q = pose(k);\n        C.push(s.z[k], q.lift, q.tilt, TAB_X[k % 3]);\n      });\n      // the lens follows the lifted card, or rests on the middle of the drawer\n      const h = s.hover >= 0 ? s.hover : -1;\n      const want = h >= 0 ? depthOf([0, 0.065 + pose(h).lift + 0.8, s.z[h]]) : depthOf([0, 0.9, 0.3]);\n      focus += (want - focus) * (reduce ? 1 : 0.12);\n      gl.bindVertexArray(vao);\n      gl.viewport(0, 0, W, H);\n      gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\n      gl.useProgram(pScene);\n      gl.uniform4fv(U(pScene, \"uCard\"), C);\n      gl.uniform3fv(U(pScene, \"uTab\"), tabs);\n      gl.uniform1i(U(pScene, \"uInk\"), 0);\n      gl.uniform3fv(U(pScene, \"uCam\"), cam.pos);\n      gl.uniform3fv(U(pScene, \"uRt\"), cam.rt);\n      gl.uniform3fv(U(pScene, \"uUp\"), cam.up);\n      gl.uniform3fv(U(pScene, \"uFw\"), cam.fw);\n      gl.uniform1f(U(pScene, \"uTan\"), TAN);\n      gl.uniform1f(U(pScene, \"uAspect\"), aspect);\n      gl.uniform2fv(U(pScene, \"uShift\"), cam.shift);\n      gl.uniform1f(U(pScene, \"uFocus\"), focus);\n      gl.uniform1f(U(pScene, \"uAperture\"), 1.5);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n      gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n      gl.useProgram(pLens);\n      gl.uniform1i(U(pLens, \"uScene\"), 1);\n      gl.uniform2f(U(pLens, \"uPx\"), 1 / W, 1 / H);\n      gl.uniform1f(U(pLens, \"uMaxR\"), H * 0.0065);\n      gl.uniform1f(U(pLens, \"uTime\"), reduce ? 0 : s.now);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n    };\n\n    const physics = (dt: number) => {\n      orders.forEach((_, k) => {\n        if (s.moving[k]) {\n          const p = clamp((s.now - s.start[k]) / RIFFLE_SECONDS, 0, 1);\n          const e = p < 0.22 ? 0 : p > 0.8 ? 1 : (1 - Math.cos(Math.PI * ((p - 0.22) / 0.58))) / 2;\n          s.z[k] = s.from[k] + (s.to[k] - s.from[k]) * e;\n          if (p >= 1) {\n            s.moving[k] = false;\n            s.z[k] = s.to[k];\n            s.tv[k] += 2.6; // the card slaps down and rocks against its neighbours\n          }\n        }\n        s.tv[k] += (-150 * s.tilt[k] - 7.5 * s.tv[k]) * dt;\n        s.tilt[k] += s.tv[k] * dt;\n        const want = s.hover === k ? 1 : 0;\n        s.hv[k] += (190 * (want - s.hov[k]) - 15 * s.hv[k]) * dt;\n        s.hov[k] += s.hv[k] * dt;\n      });\n    };\n    const settle = () => {\n      orders.forEach((_, k) => {\n        s.z[k] = s.to[k];\n        s.moving[k] = false;\n        s.tilt[k] = s.tv[k] = s.hv[k] = 0;\n        s.hov[k] = s.hover === k ? 1 : 0;\n      });\n    };\n\n    let raf = 0, visible = true, last = performance.now(), slow = 0, frames = 0;\n    const t0 = last;\n    const tick = (nowMs: number) => {\n      const real = nowMs - last;\n      const dt = clamp(real / 1000, 0, 0.05);\n      last = nowMs;\n      if (reduce) {\n        if (s.dirty) settle();\n      } else {\n        s.now += dt;\n        const sub = Math.max(1, Math.ceil(dt / 0.005));\n        for (let i = 0; i < sub; i++) physics(dt / sub);\n        const t = (nowMs - t0) / 1000;\n        view[0] += (pointer[0] + 0.25 * Math.sin(t * 0.23) - view[0]) * Math.min(1, dt * 2.5);\n        view[1] += (pointer[1] - view[1]) * Math.min(1, dt * 2.5);\n      }\n      if (!reduce || s.dirty) {\n        draw();\n        s.dirty = false;\n        if (!reduce && ++frames > 20) {\n          slow = slow * 0.92 + (real > 24 ? 1 : 0) * 0.08;\n          if (slow > 0.6 && scale > 0.5) {\n            scale *= 0.84;\n            slow = 0;\n            frames = 0;\n            resize();\n          }\n        }\n      }\n      if (visible && !document.hidden) raf = requestAnimationFrame(tick);\n    };\n    const io = new IntersectionObserver(([e]) => {\n      const was = visible;\n      visible = e.isIntersecting;\n      if (visible && !was) {\n        last = performance.now();\n        frames = 0;\n        cancelAnimationFrame(raf);\n        raf = requestAnimationFrame(tick);\n      }\n    });\n    io.observe(wrap);\n    const onVis = () => {\n      cancelAnimationFrame(raf);\n      if (!document.hidden && visible) {\n        last = performance.now();\n        raf = requestAnimationFrame(tick);\n      }\n    };\n    document.addEventListener(\"visibilitychange\", onVis);\n    raf = requestAnimationFrame(tick);\n\n    // pointing at a card in the drawer lights up its row: test front to back\n    const over = (e: PointerEvent) => {\n      const r = wrap.getBoundingClientRect();\n      const x = e.clientX - r.left, y = e.clientY - r.top;\n      const order = orders.map((_, k) => k).sort((a, b) => s.z[b] - s.z[a]);\n      for (const k of order) {\n        const q = pose(k);\n        const a = project([-0.8, 0.065 + q.lift + 1.0, s.z[k]]), b = project([0.8, 0.065 + q.lift + 0.1, s.z[k]]);\n        if (x > a[0] && x < b[0] && y > a[1] && y < b[1]) return k;\n      }\n      return -1;\n    };\n    const touch = () => {\n      s.touched = true;\n    };\n    const move = (e: PointerEvent) => {\n      const r = wrap.getBoundingClientRect();\n      pointer = [((e.clientX - r.left) / r.width - 0.5) * 2, ((e.clientY - r.top) / r.height - 0.5) * -2];\n      if (e.pointerType === \"mouse\") {\n        touch();\n        const k = over(e);\n        demo.current.setHover(k >= 0 ? k : null);\n        canvas.style.cursor = k >= 0 ? \"pointer\" : \"\";\n      }\n    };\n    const down = (e: PointerEvent) => {\n      touch();\n      const k = over(e);\n      demo.current.setHover(k >= 0 ? k : null);\n    };\n    const leave = () => {\n      pointer = [0, 0];\n      if (s.touched) demo.current.setHover(null);\n    };\n    const lost = (e: Event) => {\n      e.preventDefault();\n      setMode(\"still\");\n    };\n    const section = wrap.closest(\"section\") ?? wrap;\n    canvas.addEventListener(\"pointermove\", move);\n    canvas.addEventListener(\"pointerdown\", down);\n    canvas.addEventListener(\"pointerleave\", leave);\n    canvas.addEventListener(\"webglcontextlost\", lost);\n    section.addEventListener(\"keydown\", touch);\n    section.addEventListener(\"focusin\", touch);\n    section.addEventListener(\"pointerdown\", touch);\n\n    return () => {\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", onVis);\n      canvas.removeEventListener(\"pointermove\", move);\n      canvas.removeEventListener(\"pointerdown\", down);\n      canvas.removeEventListener(\"pointerleave\", leave);\n      canvas.removeEventListener(\"webglcontextlost\", lost);\n      section.removeEventListener(\"keydown\", touch);\n      section.removeEventListener(\"focusin\", touch);\n      section.removeEventListener(\"pointerdown\", touch);\n      gl.getExtension(\"WEBGL_lose_context\")?.loseContext();\n    };\n  }, [reduce]);\n\n  const sortBy = (key: Key) => {\n    sim.current.touched = true;\n    const next = { key, dir: (sort.key === key ? -sort.dir : key === \"total\" || key === \"placed\" ? -1 : 1) as 1 | -1 };\n    setSort(next);\n    const col = columns.find((c) => c.key === key)!;\n    setSaid(`Sorted by ${col.label.toLowerCase()}, ${next.dir === 1 ? \"ascending\" : \"descending\"}. The card file re-filed to match.`);\n  };\n\n  const arrow = (key: Key) => {\n    const on = sort.key === key;\n    return (\n      <svg aria-hidden=\"true\" width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" className={`shrink-0 transition-transform duration-300 ${on ? \"opacity-100\" : \"opacity-35\"} ${on && sort.dir === -1 ? \"rotate-180\" : \"\"}`}>\n        <path d=\"M6 2.5v7M3 5.5l3-3 3 3\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n      </svg>\n    );\n  };\n\n  return (\n    <section className=\"relative overflow-hidden\" style={{ fontFamily: GROTESK, background: PAPER, color: INK }}>\n      <div className=\"mx-auto grid max-w-[1380px] gap-6 px-4 py-8 sm:px-8 sm:py-12 lg:grid-cols-[minmax(0,1.32fr)_minmax(0,0.68fr)] lg:gap-10\">\n        <div className=\"order-2 min-w-0 lg:order-1\">\n          <p className=\"text-[11px] font-semibold uppercase tracking-[0.24em] text-[#5b5146]\">{SHOP} · demo data</p>\n          <h2 className=\"mt-2 text-[40px] leading-[0.95] sm:text-[56px]\" style={{ fontFamily: SERIF, letterSpacing: \"-0.035em\" }}>\n            The order book\n          </h2>\n          <p className=\"mt-3 max-w-[46ch] text-[15px] leading-relaxed text-[#4c443b]\">Sort any column and the card file on the counter re-files itself to match. Point at a row to pull its card.</p>\n\n          <div className=\"mt-6 overflow-x-auto rounded-xl border border-[#1f1b16]/12 bg-[#fbf8f2] shadow-[0_1px_0_rgba(255,255,255,0.8)_inset,0_18px_40px_-24px_rgba(60,40,20,0.35)]\">\n            <table className=\"w-full border-collapse text-left text-[13px] sm:text-[14.5px]\" onMouseLeave={() => setHover(null)}>\n              <caption className=\"sr-only\">Orders for {SHOP}, demo data. Column headers are buttons that sort the table.</caption>\n              <thead>\n                <tr className=\"border-b border-[#1f1b16]/12 bg-[#f1ebe0]\">\n                  {columns.map((c) => (\n                    <th\n                      key={c.key}\n                      scope=\"col\"\n                      aria-sort={sort.key === c.key ? (sort.dir === 1 ? \"ascending\" : \"descending\") : undefined}\n                      className={`p-0 ${c.wide ? \"hidden md:table-cell\" : \"\"} ${c.numeric ? \"text-right\" : \"\"}`}\n                    >\n                      <button\n                        type=\"button\"\n                        onClick={() => sortBy(c.key)}\n                        className={`flex h-11 w-full items-center gap-1 px-2 text-[10.5px] font-semibold uppercase tracking-[0.14em] transition-colors hover:bg-[#e8e0d1] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#1f1b16] sm:px-4 sm:text-[11px] ${c.numeric ? \"justify-end\" : \"\"} ${sort.key === c.key ? \"text-[#1f1b16]\" : \"text-[#5b5146]\"}`}\n                      >\n                        {c.label}\n                        {arrow(c.key)}\n                      </button>\n                    </th>\n                  ))}\n                </tr>\n              </thead>\n              <tbody>\n                {rows.map(({ o, k }) => {\n                  const on = hover === k;\n                  return (\n                    <tr\n                      key={o.id}\n                      tabIndex={0}\n                      onMouseEnter={() => {\n                        sim.current.touched = true;\n                        setHover(k);\n                      }}\n                      onFocus={() => setHover(k)}\n                      onBlur={() => setHover(null)}\n                      className={`border-b border-[#1f1b16]/8 transition-colors duration-200 last:border-b-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#1f1b16] ${on ? \"bg-[#efe5d2]\" : \"\"}`}\n                    >\n                      <th scope=\"row\" className=\"h-12 whitespace-nowrap px-2 font-medium tabular-nums sm:px-4\" style={{ fontFamily: TYPE }}>\n                        <span className=\"mr-2 inline-block h-3 w-1.5 rounded-sm align-[-1px]\" style={{ background: STATUS[o.status].hex, transform: on ? \"scaleY(1.6)\" : \"none\", transition: \"transform 300ms cubic-bezier(.3,1.6,.5,1)\" }} />\n                        {o.id}\n                      </th>\n                      <td className=\"max-w-[7.5rem] truncate px-2 sm:max-w-none sm:px-4\">{o.customer}</td>\n                      <td className=\"hidden whitespace-nowrap px-4 text-[#4c443b] md:table-cell\">{o.item}</td>\n                      <td className=\"hidden whitespace-nowrap px-4 tabular-nums text-[#4c443b] md:table-cell\">{day(o.placed)}</td>\n                      <td className=\"whitespace-nowrap px-2 text-right font-medium tabular-nums sm:px-4\">{money(o.total)}</td>\n                      <td className=\"px-2 sm:px-4\">\n                        <span className=\"inline-flex items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5 text-[11px] font-semibold sm:text-[12px]\" style={{ background: `${STATUS[o.status].hex}40`, color: INK }}>\n                          <span className=\"h-1.5 w-1.5 rounded-full\" style={{ background: STATUS[o.status].hex }} />\n                          {o.status}\n                        </span>\n                      </td>\n                    </tr>\n                  );\n                })}\n              </tbody>\n            </table>\n          </div>\n          <p className=\"mt-3 text-[12px] text-[#5b5146]\">\n            {orders.length} orders · {money(orders.reduce((a, o) => a + o.total, 0))} in total\n          </p>\n          <p className=\"sr-only\" aria-live=\"polite\">\n            {said}\n          </p>\n        </div>\n\n        <div ref={wrapRef} className=\"relative order-1 h-[380px] overflow-hidden rounded-2xl bg-[#d9ccb7] sm:h-[460px] lg:order-2 lg:h-auto lg:min-h-[600px]\">\n          <canvas ref={canvasRef} aria-hidden=\"true\" className={`absolute inset-0 h-full w-full touch-pan-y ${mode === \"still\" ? \"hidden\" : \"\"}`} />\n          {mode === \"still\" && <Still slots={slots} hover={hover} />}\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
