{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"index-card-checklist-where-a-pencil-draws-each-tick-in-graphite-and-its-eraser-rubs-it-out","type":"registry:block","title":"Index Card Checklist Where a Pencil Draws Each Tick in Graphite and Its Eraser Rubs It Out","description":"Checklist on a ruled index card: a pencil ticks and strikes each line in grainy graphite, then turns round and rubs it out. Free React and HTML to copy.","dependencies":[],"files":[{"path":"components/we-inc/index-card-checklist-where-a-pencil-draws-each-tick-in-graphite-and-its-eraser-rubs-it-out.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\n// The lines on the card. `done` is how each one starts.\nconst tasks = [\n  { text: \"Proof the cover in daylight\", done: true },\n  { text: \"Order the cream 80 gsm stock\", done: true },\n  { text: \"Trim the test sheets\", done: false },\n  { text: \"Send the plates to Marit\", done: false },\n];\nconst CARD = { title: \"Before the print run\", date: \"Mon 12 Oct\" };\nconst LACQUER: [number, number, number] = [214, 62, 38]; // the paint on the pencil\nconst FOIL = \"ALDER & FINCH   2B\"; // stamped along the top flat\n\nconst SW = 480, SH = 486; // scene, in design pixels\nconst CX = 40, CY = 52, CW = 400, HEAD = 78, ROW = 56; // the card\nconst CH = HEAD + ROW * tasks.length + 22;\nconst PAD = 150; // spare canvas round the scene so the pencil is never cut off\nconst LEN = 250, THICK = 13, PS = 1.2, G = LEN * PS; // the pencil as drawn, how much it is enlarged, and its real length\nconst REST = { x: 70, y: CY + CH + 66, a: -0.23, tl: 0, el: 0 };\n\ntype Seg = { dur: number; start?: () => void; step: (k: number) => void; end?: () => void };\ntype Crumb = { x: number; y: number; vx: number; vy: number; r: number; len: number; tone: number; life: number };\n\nconst ease = (k: number) => (k < 0.5 ? 2 * k * k : 1 - Math.pow(-2 * k + 2, 2) / 2);\nconst mix = (a: number[], b: number[], t: number) => `rgb(${a.map((v, i) => Math.round(v + (b[i] - v) * Math.max(0, Math.min(1, t)))).join(\",\")})`;\nconst shade = (c: number[], k: number) => c.map((v) => Math.max(0, Math.min(255, v * k)));\n\nexport default function PencilAndEraserIndexCard() {\n  const [done, setDone] = useState(tasks.map((t) => t.done));\n  const doneRef = useRef(tasks.map((t) => t.done));\n  const [scale, setScale] = useState(1);\n  const root = useRef<HTMLElement>(null);\n  const marks = useRef<HTMLCanvasElement>(null);\n  const over = useRef<HTMLCanvasElement>(null);\n  const texts = useRef<(HTMLSpanElement | null)[]>([]);\n  const api = useRef<{ toggle: (i: number, fromUser: boolean) => void } | null>(null);\n\n  useEffect(() => {\n    const node = root.current;\n    if (!node) return;\n    const fit = () => setScale(Math.max(0.6, Math.min(1.16, (node.clientWidth - 24) / SW)));\n    fit();\n    const ro = new ResizeObserver(fit);\n    ro.observe(node);\n    return () => ro.disconnect();\n  }, []);\n\n  useEffect(() => {\n    const mc = marks.current, oc = over.current, node = root.current;\n    if (!mc || !oc || !node) return;\n    const g = mc.getContext(\"2d\"), o = oc.getContext(\"2d\");\n    if (!g || !o) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const px = Math.min(2, window.devicePixelRatio || 1) * 1.16;\n    mc.width = CW * px; mc.height = CH * px;\n    oc.width = (SW + PAD * 2) * px; oc.height = (SH + PAD * 2) * px;\n    g.setTransform(px, 0, 0, px, 0, 0);\n\n    let seed = 11;\n    const rand = () => { seed = (seed * 16807) % 2147483647; return seed / 2147483647; };\n    const tooth = (x: number, y: number) => { const n = Math.sin(Math.floor(x * 1.6) * 12.9898 + Math.floor(y * 1.6) * 78.233) * 43758.5453; return n - Math.floor(n); };\n\n    // Geometry of a row, in card pixels.\n    const rowY = (i: number) => HEAD + ROW * i + ROW / 2;\n    const tickPath = (i: number) => {\n      const bx = 35, by = rowY(i), pts: number[][] = [];\n      for (let k = 0; k <= 8; k++) { const t = k / 8; pts.push([bx - 8.5 + 7 * t, by - 1 + 10 * t * (0.7 + 0.3 * t)]); }\n      for (let k = 1; k <= 18; k++) { const t = k / 18; pts.push([bx - 1.5 + 22 * t + 2 * Math.sin(t * Math.PI), by + 9 - 31 * t + 3 * Math.sin(t * Math.PI)]); }\n      return pts;\n    };\n    const strikePath = (i: number) => {\n      const w = texts.current[i]?.offsetWidth ?? 220, x0 = 56, x1 = 62 + w + 8, y = rowY(i) + 1.5, pts: number[][] = [];\n      const lift = 1.5 + rand() * 2.5, ph = rand() * 6;\n      for (let k = 0; k <= 40; k++) { const t = k / 40; pts.push([x0 + (x1 - x0) * t, y - lift * t + 0.9 * Math.sin(t * 7 + ph) + 0.5 * Math.sin(t * 19 + ph)]); }\n      return pts;\n    };\n    const measure = (pts: number[][]) => { const acc = [0]; for (let i = 1; i < pts.length; i++) acc.push(acc[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1])); return acc; };\n    const at = (pts: number[][], acc: number[], d: number) => {\n      let i = 1; while (i < acc.length - 1 && acc[i] < d) i++;\n      const t = Math.max(0, Math.min(1, (d - acc[i - 1]) / Math.max(0.0001, acc[i] - acc[i - 1])));\n      return [pts[i - 1][0] + (pts[i][0] - pts[i - 1][0]) * t, pts[i - 1][1] + (pts[i][1] - pts[i - 1][1]) * t];\n    };\n\n    // Graphite is laid as specks that skip the low spots in the paper.\n    const speck = (x: number, y: number, press: number, wide: number) => {\n      for (let n = 0; n < 9; n++) {\n        const dx = (rand() + rand() - 1) * wide, dy = (rand() + rand() - 1) * wide;\n        if (tooth(x + dx, y + dy) < 0.2) continue;\n        const s = 0.5 + rand() * 0.6;\n        g.fillStyle = `rgba(50,52,60,${((0.07 + 0.25 * rand()) * press).toFixed(3)})`;\n        g.fillRect(x + dx - s / 2, y + dy - s / 2, s, s);\n      }\n    };\n    const lay = (pts: number[][], acc: number[], from: number, to: number, wide = 1.05) => {\n      const total = acc[acc.length - 1];\n      for (let d = from; d < to; d += 0.45) { const p = at(pts, acc, d), t = d / total; speck(p[0], p[1], 0.7 + 0.5 * Math.sin(Math.min(1, t * 1.15) * Math.PI) ** 0.6, wide); }\n    };\n    const layAll = (i: number) => { [tickPath(i), strikePath(i)].forEach((pts, n) => { const acc = measure(pts); lay(pts, acc, 0, acc[acc.length - 1], n ? 1.05 : 1.5); }); };\n    const rub = (x: number, y: number, power: number) => {\n      g.save(); g.globalCompositeOperation = \"destination-out\";\n      const r = g.createRadialGradient(x, y, 0, x, y, 11);\n      r.addColorStop(0, `rgba(0,0,0,${power})`); r.addColorStop(0.6, `rgba(0,0,0,${power * 0.7})`); r.addColorStop(1, \"rgba(0,0,0,0)\");\n      g.fillStyle = r; g.fillRect(x - 12, y - 12, 24, 24); g.restore();\n    };\n    const wipeRow = (i: number, alpha: number) => { g.save(); g.globalCompositeOperation = \"destination-out\"; g.fillStyle = `rgba(0,0,0,${alpha})`; g.fillRect(0, rowY(i) - ROW / 2 - 2, CW, ROW + 2); g.restore(); };\n\n    const pose = { ...REST };\n    const light = { x: -0.5, y: -0.86, to: -0.5 };\n    const crumbs: Crumb[] = [];\n    let sweep = 0;\n\n    const drawPencil = () => {\n      const { x, y, a, tl, el } = pose, c = Math.cos(a), s = Math.sin(a), h = THICK / 2;\n      // Shadow: it parts from the pencil at whichever end is lifted off the card.\n      o.save();\n      o.shadowColor = \"rgba(8,14,12,0.5)\"; o.shadowBlur = (2.5 + (tl + el) * 0.1) * px; o.shadowOffsetX = 4000 * px; o.shadowOffsetY = 0;\n      o.lineCap = \"round\"; o.lineWidth = THICK * PS - 3; o.strokeStyle = \"#000\";\n      o.beginPath(); o.moveTo(x + c * 9 + (tl + 1.5) * 0.55 - 4000, y + s * 9 + (tl + 1.5) * 0.9); o.lineTo(x + c * (G - 8) + (el + 1.5) * 0.55 - 4000, y + s * (G - 8) + (el + 1.5) * 0.9); o.stroke();\n      o.restore();\n\n      o.save(); o.translate(x, y); o.rotate(a); o.scale(PS, PS);\n      // How much each long side faces the lamp. The lamp does not turn with the pencil.\n      const up = 0.5 + 0.5 * (s * light.x - c * light.y), dn = 1 - up;\n      const band = (col: number[], f: number) => mix(shade(col, 0.52), shade(col, 1.22), f);\n      const across = (col: number[]) => { const gr = o.createLinearGradient(0, -h, 0, h); gr.addColorStop(0, band(col, up)); gr.addColorStop(0.5, mix(col, [255, 255, 255], 0.1)); gr.addColorStop(1, band(col, dn)); return gr; };\n\n      // Eraser, a little grey at the working end.\n      o.beginPath(); o.moveTo(LEN - 20, -h + 0.4); o.lineTo(LEN - 6, -h + 0.4); o.quadraticCurveTo(LEN, -h + 0.4, LEN, 0); o.quadraticCurveTo(LEN, h - 0.4, LEN - 6, h - 0.4); o.lineTo(LEN - 20, h - 0.4); o.closePath();\n      o.fillStyle = across([226, 142, 140]); o.fill();\n      const grime = o.createLinearGradient(LEN - 9, 0, LEN, 0); grime.addColorStop(0, \"rgba(70,62,66,0)\"); grime.addColorStop(1, \"rgba(70,62,66,0.42)\"); o.fillStyle = grime; o.fill();\n\n      // Ferrule: brass tube with two crimped rings.\n      const brass = o.createLinearGradient(0, -h - 0.7, 0, h + 0.7);\n      brass.addColorStop(0, band([196, 150, 62], up)); brass.addColorStop(0.2 + 0.25 * dn, \"#fff3c4\"); brass.addColorStop(0.55, \"#c9a04a\"); brass.addColorStop(1, band([150, 106, 34], dn));\n      o.fillStyle = brass; o.fillRect(LEN - 42, -h - 0.7, 23, THICK + 1.4);\n      for (const fx of [LEN - 38, LEN - 34.5, LEN - 27, LEN - 23.5]) { o.fillStyle = \"rgba(60,36,6,0.5)\"; o.fillRect(fx, -h - 0.7, 1, THICK + 1.4); o.fillStyle = \"rgba(255,244,200,0.55)\"; o.fillRect(fx + 1, -h - 0.7, 0.7, THICK + 1.4); }\n      o.fillStyle = \"rgba(40,20,0,0.35)\"; o.fillRect(LEN - 42.6, -h, 0.9, THICK);\n\n      // Hexagonal body: three flats, each one colour.\n      o.fillStyle = band(LACQUER, up); o.fillRect(27, -h, LEN - 69, h / 2);\n      o.fillStyle = band(LACQUER, dn); o.fillRect(27, h / 2, LEN - 69, h / 2);\n      const flat = o.createLinearGradient(0, -h / 2, 0, h / 2); flat.addColorStop(0, mix(LACQUER, [255, 255, 255], 0.2)); flat.addColorStop(0.5, mix(LACQUER, [255, 255, 255], 0.04)); flat.addColorStop(1, mix(shade(LACQUER, 0.86), [0, 0, 0], 0));\n      o.fillStyle = flat; o.fillRect(27, -h / 2, LEN - 69, h);\n      o.fillStyle = \"rgba(0,0,0,0.16)\"; o.fillRect(27, (up > dn ? h / 2 : -h / 2) - 0.3, LEN - 69, 0.6);\n      o.fillStyle = \"rgba(255,255,255,0.3)\"; o.fillRect(27, (up > dn ? -h / 2 : h / 2) - 0.3, LEN - 69, 0.6);\n      // Lamp streak on the top flat, and the foil stamp.\n      const streakY = -h / 2 + 1.4 + (up > dn ? 0 : h - 2.8);\n      const streak = o.createLinearGradient(40, 0, LEN - 46, 0); streak.addColorStop(0, \"rgba(255,255,255,0)\"); streak.addColorStop(0.12, \"rgba(255,255,255,0.75)\"); streak.addColorStop(0.5, \"rgba(255,255,255,0.38)\"); streak.addColorStop(0.9, \"rgba(255,255,255,0.7)\"); streak.addColorStop(1, \"rgba(255,255,255,0)\");\n      o.fillStyle = streak; o.fillRect(40, streakY - 0.55, LEN - 86, 1.1);\n      o.font = \"700 4.6px ui-sans-serif, system-ui, Helvetica, Arial, sans-serif\"; o.textBaseline = \"middle\"; o.textAlign = \"right\";\n      o.fillStyle = \"rgba(60,14,4,0.55)\"; o.fillText(FOIL, LEN - 52, 1.5);\n      o.fillStyle = \"#f6dc93\"; o.fillText(FOIL, LEN - 52, 1.1);\n\n      // Sharpened wood: the paint ends in scallops, one to a flat.\n      o.beginPath(); o.moveTo(7, -1.3); o.lineTo(29, -h); o.lineTo(37, -h);\n      o.quadraticCurveTo(26, -h * 0.75, 37, -h / 2); o.quadraticCurveTo(19, 0, 37, h / 2); o.quadraticCurveTo(26, h * 0.75, 37, h);\n      o.lineTo(29, h); o.lineTo(7, 1.3); o.closePath();\n      o.fillStyle = across([228, 190, 140]); o.fill();\n      o.lineWidth = 0.7; o.strokeStyle = \"rgba(70,24,8,0.45)\"; o.beginPath(); o.moveTo(37, -h); o.quadraticCurveTo(26, -h * 0.75, 37, -h / 2); o.quadraticCurveTo(19, 0, 37, h / 2); o.quadraticCurveTo(26, h * 0.75, 37, h); o.stroke();\n      o.lineWidth = 0.4; o.strokeStyle = \"rgba(120,76,30,0.3)\";\n      for (let k = -3; k <= 3; k++) { o.beginPath(); o.moveTo(8, k * 0.3); o.lineTo(27 + Math.abs(k), k * 1.75); o.stroke(); }\n      // Graphite point.\n      o.beginPath(); o.moveTo(0, 0); o.lineTo(7.4, -1.45); o.lineTo(7.4, 1.45); o.closePath(); o.fillStyle = \"#34353b\"; o.fill();\n      o.lineWidth = 0.5; o.strokeStyle = \"rgba(255,255,255,0.4)\"; o.beginPath(); o.moveTo(1.5, up > dn ? -0.2 : 0.2); o.lineTo(7, up > dn ? -1 : 1); o.stroke();\n      o.restore();\n    };\n\n    const drawOver = () => {\n      o.setTransform(px, 0, 0, px, PAD * px, PAD * px);\n      o.clearRect(-PAD, -PAD, SW + PAD * 2, SH + PAD * 2);\n      for (const cr of crumbs) {\n        const dx = Math.cos(cr.r) * cr.len, dy = Math.sin(cr.r) * cr.len, al = Math.min(1, cr.life);\n        o.lineCap = \"round\";\n        o.lineWidth = 1.5; o.strokeStyle = `rgba(20,20,24,${0.26 * al})`; o.beginPath(); o.moveTo(cr.x - dx + 0.8, cr.y - dy + 1.2); o.lineTo(cr.x + dx + 0.8, cr.y + dy + 1.2); o.stroke();\n        o.lineWidth = 1.35; o.strokeStyle = `rgba(${Math.round(158 + cr.tone * 44)},${Math.round(132 + cr.tone * 14)},${Math.round(134 + cr.tone * 12)},${al})`; o.beginPath(); o.moveTo(cr.x - dx, cr.y - dy); o.lineTo(cr.x + dx, cr.y + dy); o.stroke();\n      }\n      drawPencil();\n    };\n\n    // A small queue of timed moves; the pencil does one thing at a time.\n    const queue: Seg[] = [];\n    let cur: (Seg & { t: number }) | null = null;\n    const jobs: { i: number; on: boolean }[] = [];\n    let busy = false;\n\n    const glide = (to: () => { x: number; y: number; a: number; tl: number; el: number }, dur: number): Seg => {\n      let from = { ...pose }, target = { ...pose };\n      return {\n        dur,\n        start: () => { from = { ...pose }; target = to(); let d = target.a - from.a; while (d > Math.PI) d -= Math.PI * 2; while (d < -Math.PI) d += Math.PI * 2; target.a = from.a + d; },\n        step: (k) => { const e = ease(k); pose.x = from.x + (target.x - from.x) * e; pose.y = from.y + (target.y - from.y) * e; pose.a = from.a + (target.a - from.a) * e; pose.tl = from.tl + (target.tl - from.tl) * e + Math.sin(k * Math.PI) * 6; pose.el = from.el + (target.el - from.el) * e + Math.sin(k * Math.PI) * 6; },\n      };\n    };\n        const write = (pts: number[][], dur: number, wide: number): Seg[] => {\n      const acc = measure(pts), total = acc[acc.length - 1]; let laid = 0;\n      const lean = (x: number) => 0.92 + 0.36 * Math.max(0, Math.min(1, (x - 40) / 320));\n      return [\n        glide(() => ({ x: CX + pts[0][0], y: CY + pts[0][1], a: lean(pts[0][0]), tl: 9, el: 44 }), 300),\n        { dur: 70, step: (k) => { pose.tl = 9 * (1 - k); } },\n        { dur, step: (k) => { const d = total * ease(k); lay(pts, acc, laid, d, wide); laid = d; const p = at(pts, acc, d); pose.x = CX + p[0]; pose.y = CY + p[1]; pose.a = lean(p[0]) + 0.025 * Math.sin(d * 0.5); pose.tl = 0; pose.el = 44; } },\n        { dur: 90, step: (k) => { pose.tl = 9 * k; } },\n      ];\n    };\n    const home = (): Seg => glide(() => ({ ...REST }), 460);\n    const finish = (): Seg => ({ dur: 1, step: () => {}, end: () => { busy = false; next(); } });\n\n    const tick = (i: number) => { queue.push(...write(tickPath(i), 240, 1.5), ...write(strikePath(i), 360, 1.05), home(), finish()); };\n    const erase = (i: number) => {\n      const strike = strikePath(i), acc = measure(strike), total = acc[acc.length - 1], by = rowY(i);\n      // The rubbing end is the eraser, so the point is worked out from where the eraser touches.\n      const place = (ex: number, ey: number, a: number) => { pose.a = a; pose.x = CX + ex - Math.cos(a) * G; pose.y = CY + ey - Math.sin(a) * G; pose.el = 0; pose.tl = 46; };\n      const lean = (x: number) => Math.PI + 0.92 + 0.36 * Math.max(0, Math.min(1, (x - 40) / 320));\n      let spawn = 0;\n      queue.push(\n        glide(() => { const a = lean(strike[strike.length - 1][0]); return { x: CX + strike[strike.length - 1][0] - Math.cos(a) * G, y: CY + strike[strike.length - 1][1] - Math.sin(a) * G, a, tl: 46, el: 8 }; }, 520),\n        {\n          dur: 1150,\n          step: (k) => {\n            // Work back along the line in short scrubbing strokes, then finish on the tick.\n            const run = Math.min(1, k / 0.72), d = total * (1 - run) + 14 * Math.sin(k * 46), p = at(strike, acc, Math.max(0, Math.min(total, d)));\n            const onTick = k > 0.72, tk = (k - 0.72) / 0.28;\n            const ex = onTick ? 37 + 9 * Math.sin(tk * 30) : p[0], ey = onTick ? by - 4 + 9 * Math.cos(tk * 19) : p[1] + 4 * Math.sin(k * 71);\n            rub(ex, ey, 0.34); place(ex, ey, lean(ex) + 0.03 * Math.sin(k * 46));\n            if (++spawn % 3 === 0 && crumbs.length < 46) { const dir = rand() * Math.PI * 2, v = 30 + rand() * 70; crumbs.push({ x: CX + ex + (rand() - 0.5) * 10, y: CY + ey + (rand() - 0.5) * 8, vx: Math.cos(dir) * v, vy: Math.sin(dir) * v * 0.7 + 14, r: rand() * Math.PI, len: 0.4 + rand() * 1.3, tone: rand(), life: 1 }); }\n          },\n          end: () => { wipeRow(i, 0.9); },\n        },\n        home(),\n        { dur: 1, step: () => {}, end: () => { sweep = 1; busy = false; next(); } },\n      );\n    };\n    const next = () => {\n      if (busy) return;\n      const job = jobs.shift();\n      if (!job) return;\n      busy = true;\n      if (job.on) tick(job.i); else erase(job.i);\n      wake();\n    };\n\n    let raf = 0, last = 0, seen = true;\n    const frame = (now: number) => {\n      raf = 0;\n      const dt = Math.min(0.034, (now - last) / 1000); last = now;\n      if (!cur && queue.length) { cur = { ...(queue.shift() as Seg), t: 0 }; cur.start?.(); }\n      if (cur) { cur.t += dt * 1000; const k = Math.min(1, cur.t / cur.dur); cur.step(k); if (k >= 1) { const ended = cur; cur = null; ended.end?.(); } }\n      let moving = false;\n      for (let n = crumbs.length - 1; n >= 0; n--) {\n        const cr = crumbs[n];\n        if (sweep > 0) { cr.vx += 900 * dt; cr.vy += 260 * dt; cr.life -= dt * 1.5; }\n        cr.x += cr.vx * dt; cr.y += cr.vy * dt; cr.vx *= Math.pow(0.002, dt); cr.vy *= Math.pow(0.002, dt); cr.r += cr.vx * dt * 0.08;\n        if (Math.abs(cr.vx) + Math.abs(cr.vy) > 2) moving = true;\n        if (cr.life <= 0) crumbs.splice(n, 1);\n      }\n      if (sweep > 0 && crumbs.length === 0) sweep = 0;\n      const lamp = light.to - light.x; light.x += lamp * Math.min(1, dt * 5); light.y = -Math.sqrt(Math.max(0.05, 1 - light.x * light.x));\n      drawOver();\n      if ((cur || queue.length || moving || sweep > 0 || Math.abs(lamp) > 0.01) && seen && !document.hidden) raf = requestAnimationFrame(frame);\n    };\n    const wake = () => { if (!raf) { last = performance.now(); raf = requestAnimationFrame(frame); } };\n\n    let touched = false;\n    api.current = {\n      toggle: (i, fromUser) => {\n        if (fromUser) touched = true;\n        const on = !doneRef.current[i];\n        doneRef.current = doneRef.current.map((v, n) => (n === i ? on : v));\n        setDone(doneRef.current);\n        if (reduce) { if (on) layAll(i); else wipeRow(i, 1); return; }\n        jobs.push({ i, on }); next();\n      },\n    };\n\n    tasks.forEach((_, i) => { if (doneRef.current[i]) layAll(i); });\n    drawOver();\n\n    // Until someone clicks, it works down the card by itself.\n    let step = 0;\n    const order = [2, 0, 3, 1];\n    const demo = () => { if (touched || reduce || !seen || document.hidden || busy) return; api.current?.toggle(order[step++ % order.length] % tasks.length, false); };\n    const first = window.setTimeout(demo, 380);\n    const loop = window.setInterval(demo, 3900);\n\n    const onMove = (e: PointerEvent) => { const b = node.getBoundingClientRect(); light.to = -0.5 + ((e.clientX - b.left) / b.width - 0.5) * 0.9; wake(); };\n    node.addEventListener(\"pointermove\", onMove);\n    const io = new IntersectionObserver(([entry]) => { seen = entry.isIntersecting; if (seen) wake(); });\n    io.observe(node);\n    const onVis = () => { if (!document.hidden) wake(); };\n    document.addEventListener(\"visibilitychange\", onVis);\n    return () => {\n      cancelAnimationFrame(raf); window.clearTimeout(first); window.clearInterval(loop); api.current = null;\n      node.removeEventListener(\"pointermove\", onMove); io.disconnect(); document.removeEventListener(\"visibilitychange\", onVis);\n    };\n  }, []);\n\n  const left = done.filter((v) => !v).length;\n\n  return (\n    <section\n      ref={root}\n      className=\"relative flex min-h-[640px] w-full flex-col items-center justify-center overflow-hidden bg-[#1c2a27] px-3 py-10 sm:min-h-[760px]\"\n      style={{ backgroundImage: \"radial-gradient(110% 80% at 50% 36%,rgba(120,170,150,0.2) 0%,rgba(0,0,0,0) 55%,rgba(0,0,0,0.42) 100%),linear-gradient(rgba(214,240,226,0.085) 1px,transparent 1px),linear-gradient(90deg,rgba(214,240,226,0.085) 1px,transparent 1px),linear-gradient(rgba(214,240,226,0.04) 1px,transparent 1px),linear-gradient(90deg,rgba(214,240,226,0.04) 1px,transparent 1px)\", backgroundSize: \"100% 100%,120px 120px,120px 120px,24px 24px,24px 24px\", backgroundPosition: \"0 0,center,center,center,center\" }}\n    >\n      <div className=\"relative z-10\" style={{ width: SW * scale, height: SH * scale }}>\n        <div className=\"relative\" style={{ width: SW, height: SH, transform: `scale(${scale})`, transformOrigin: \"0 0\" }}>\n          {/* a spare card under the one in use */}\n          <div aria-hidden=\"true\" className=\"absolute rounded-[5px]\" style={{ left: CX + 6, top: CY + 5, width: CW, height: CH, background: \"#e9e3d3\", transform: \"rotate(2.4deg)\", boxShadow: \"0 1px 0 #cfc8b6, 0 14px 22px -8px rgba(0,0,0,0.55)\" }} />\n          <div\n            className=\"absolute overflow-hidden rounded-[5px] text-[#2b2d33]\"\n            style={{ left: CX, top: CY, width: CW, height: CH, background: \"linear-gradient(168deg,#fbf8ef 0%,#f4efe2 62%,#ebe5d5 100%)\", boxShadow: \"0 1px 0 #fffdf6 inset, 0 1.5px 0 #cdc6b3, 0 3px 4px rgba(0,0,0,0.25), 0 22px 34px -12px rgba(0,0,0,0.6)\" }}\n          >\n            <svg aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 h-full w-full opacity-[0.16] mix-blend-multiply\">\n              <filter id=\"index-card-pencil-grain\"><feTurbulence type=\"fractalNoise\" baseFrequency=\"0.9\" numOctaves=\"2\" seed=\"4\" /><feColorMatrix values=\"0 0 0 0 0.35  0 0 0 0 0.3  0 0 0 0 0.22  0 0 0 0.9 0\" /></filter>\n              <rect width=\"100%\" height=\"100%\" filter=\"url(#index-card-pencil-grain)\" />\n            </svg>\n            <div className=\"flex items-end justify-between px-[26px] pt-[26px]\">\n              <h2 className=\"font-serif text-[23px] italic leading-none tracking-[-0.01em]\">{CARD.title}</h2>\n              <span className=\"font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-[#6b6f78]\">{CARD.date}</span>\n            </div>\n            <div aria-hidden=\"true\" className=\"absolute left-0 w-full\" style={{ top: HEAD - 13, height: 1.5, background: \"#d5604e\" }} />\n            {tasks.map((t, i) => (\n              <button\n                key={t.text}\n                type=\"button\"\n                role=\"checkbox\"\n                aria-checked={done[i]}\n                onClick={() => api.current?.toggle(i, true)}\n                className=\"absolute left-0 flex w-full cursor-pointer items-center text-left outline-none focus-visible:bg-[#2b6cb0]/10 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#2b6cb0]\"\n                style={{ top: HEAD + ROW * i, height: ROW, borderBottom: \"1px solid rgba(92,140,190,0.42)\" }}\n              >\n                <span aria-hidden=\"true\" className=\"absolute rounded-[2px]\" style={{ left: 26, top: ROW / 2 - 9, width: 18, height: 18, border: \"1.4px solid #6c7f96\" }} />\n                <span ref={(el) => { texts.current[i] = el; }} className=\"absolute whitespace-nowrap font-serif text-[18px]\" style={{ left: 62 }}>{t.text}</span>\n              </button>\n            ))}\n            <canvas ref={marks} aria-hidden=\"true\" className=\"pointer-events-none absolute left-0 top-0 mix-blend-multiply\" style={{ width: CW, height: CH }} />\n          </div>\n          <canvas ref={over} aria-hidden=\"true\" className=\"pointer-events-none absolute\" style={{ left: -PAD, top: -PAD, width: SW + PAD * 2, height: SH + PAD * 2 }} />\n        </div>\n      </div>\n      <p className=\"relative mt-8 max-w-[340px] text-center font-mono text-[11px] uppercase leading-5 tracking-[0.16em] text-[#a9c4b8]\">\n        Tick a line and the pencil writes it. Untick it and the eraser takes it back.\n      </p>\n      <p className=\"sr-only\" aria-live=\"polite\">{left === 0 ? \"Everything is done\" : `${left} of ${tasks.length} still to do`}</p>\n    </section>\n  );\n}\n"}]}
