{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"shortbread-letters-cut-from-dough-that-rise-and-brown-on-a-baking-tray-and-lose-a-bite-when-tapped","type":"registry:component","title":"Shortbread Letters Cut From Dough That Rise and Brown on a Baking Tray and Lose a Bite When Tapped","description":"Text effect with a word as shortbread on a baking tray: retype it to watch the dough brown, then tap a letter to bite it. Free React and HTML code.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/shortbread-letters-cut-from-dough-that-rise-and-brown-on-a-baking-tray-and-lose-a-bite-when-tapped.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport type { MouseEvent as ReactMouseEvent } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** The word on the tray when the page loads. */\nconst START_WORD = \"THANKS\";\n/** Longest word the field accepts. */\nconst MAX_LETTERS = 8;\n/** Worktop colour around the tray. */\nconst WORKTOP = \"#27382f\";\n/** Baked biscuit: the pale middle and the browned rim. */\nconst GOLD: [number, number, number] = [229, 180, 106];\nconst BROWN: [number, number, number] = [166, 98, 40];\n/** Raw dough. */\nconst DOUGH: [number, number, number] = [238, 224, 190];\n/** Seconds the oven light stays on. */\nconst BAKE_SECONDS = 2.8;\n\n/** Height of a capital in the baked sprite, in pixels. */\nconst CAP = 200;\nconst PAD = 26;\n\nfunction boxBlur(src: Float32Array, w: number, h: number, r: number): Float32Array {\n  const out = new Float32Array(src.length);\n  const tmp = new Float32Array(src.length);\n  const span = 2 * r + 1;\n  let from = src;\n  for (let pass = 0; pass < 3; pass++) {\n    for (let y = 0; y < h; y++) {\n      const row = y * w;\n      let sum = 0;\n      for (let x = -r; x <= r; x++) sum += from[row + Math.min(w - 1, Math.max(0, x))];\n      for (let x = 0; x < w; x++) {\n        tmp[row + x] = sum / span;\n        sum += from[row + Math.min(w - 1, x + r + 1)] - from[row + Math.max(0, x - r)];\n      }\n    }\n    for (let x = 0; x < w; x++) {\n      let sum = 0;\n      for (let y = -r; y <= r; y++) sum += tmp[Math.min(h - 1, Math.max(0, y)) * w + x];\n      for (let y = 0; y < h; y++) {\n        out[y * w + x] = sum / span;\n        sum += tmp[Math.min(h - 1, y + r + 1) * w + x] - tmp[Math.max(0, y - r) * w + x];\n      }\n    }\n    from = out;\n  }\n  return out;\n}\n\nfunction random(seed: number) {\n  let s = seed >>> 0 || 1;\n  return () => {\n    s = (Math.imul(s, 1664525) + 1013904223) >>> 0;\n    return s / 4294967296;\n  };\n}\n\n/** Smooth blotches between 0 and 1, one value per pixel. */\nfunction blotches(w: number, h: number, cell: number, rnd: () => number): Float32Array {\n  const gw = Math.ceil(w / cell) + 2;\n  const gh = Math.ceil(h / cell) + 2;\n  const grid = new Float32Array(gw * gh);\n  for (let i = 0; i < grid.length; i++) grid[i] = rnd();\n  const out = new Float32Array(w * h);\n  for (let y = 0; y < h; y++) {\n    const gy = Math.floor(y / cell);\n    let fy = y / cell - gy;\n    fy = fy * fy * (3 - 2 * fy);\n    for (let x = 0; x < w; x++) {\n      const gx = Math.floor(x / cell);\n      let fx = x / cell - gx;\n      fx = fx * fx * (3 - 2 * fx);\n      const i = gy * gw + gx;\n      const top = grid[i] + (grid[i + 1] - grid[i]) * fx;\n      const bot = grid[i + gw] + (grid[i + gw + 1] - grid[i + gw]) * fx;\n      out[y * w + x] = top + (bot - top) * fy;\n    }\n  }\n  return out;\n}\n\ntype Baked = { w: number; h: number; bw: number; edges: Array<[number, number]>; tops: Array<[number, number]> };\n\n/**\n * Cuts one letter and draws it twice, as raw dough and as a baked biscuit.\n * The outline is roughened so no two edges match, puffed into a pillow,\n * pricked with a fork, and browned most where the dough is thinnest.\n */\nfunction cut(rawCv: HTMLCanvasElement, bakedCv: HTMLCanvasElement, ch: string, seed: number): Baked | null {\n  const face = `900 ${Math.round(CAP / 0.72)}px \"Arial Rounded MT Bold\", \"Helvetica Neue\", Helvetica, Arial, sans-serif`;\n  const probe = document.createElement(\"canvas\").getContext(\"2d\", { willReadFrequently: true });\n  if (!probe) return null;\n  probe.font = face;\n  const m = probe.measureText(ch);\n  const left = Math.ceil(m.actualBoundingBoxLeft);\n  const bw = Math.max(40, Math.ceil(m.actualBoundingBoxLeft + m.actualBoundingBoxRight));\n  const asc = Math.ceil(m.actualBoundingBoxAscent);\n  const bh = Math.max(40, Math.ceil(m.actualBoundingBoxAscent + m.actualBoundingBoxDescent));\n  const w = bw + PAD * 2;\n  const h = bh + PAD * 2;\n  probe.canvas.width = w;\n  probe.canvas.height = h;\n  probe.font = face;\n  probe.fillStyle = \"#fff\";\n  probe.strokeStyle = \"#fff\";\n  probe.lineJoin = \"round\";\n  probe.lineWidth = CAP * 0.06;\n  probe.strokeText(ch, PAD + left, PAD + asc);\n  probe.fillText(ch, PAD + left, PAD + asc);\n  const px = probe.getImageData(0, 0, w, h).data;\n  const hard = new Float32Array(w * h);\n  for (let i = 0; i < hard.length; i++) hard[i] = px[i * 4 + 3] / 255;\n\n  const rnd = random(seed);\n  const wobble = blotches(w, h, 15, rnd);\n  const lumps = blotches(w, h, 22, rnd);\n  const pores = blotches(w, h, 5, rnd);\n  const patch = blotches(w, h, 46, rnd);\n  // Dough spreads in the oven: soften the outline, then cut it again along a wandering line.\n  const softened = boxBlur(hard, w, h, 3);\n  const a = new Float32Array(w * h);\n  for (let i = 0; i < a.length; i++) {\n    const v = (softened[i] + (wobble[i] - 0.5) * 0.22 - 0.42) * 7;\n    a[i] = Math.min(1, Math.max(0, v));\n  }\n  const edge = boxBlur(a, w, h, 8);\n  const dome = boxBlur(a, w, h, 24);\n\n  // Fork holes, only where the stroke is wide enough to take one.\n  const holes: Array<[number, number]> = [];\n  const pitch = 30;\n  for (let gy = PAD; gy < h - PAD; gy += pitch) {\n    for (let gx = PAD; gx < w - PAD; gx += pitch) {\n      let best = 0, bx = 0, by = 0;\n      for (let k = 0; k < 14; k++) {\n        const x = Math.floor(gx + rnd() * pitch), y = Math.floor(gy + rnd() * pitch);\n        const v = x < w && y < h ? edge[y * w + x] : 0;\n        if (v > best) { best = v; bx = x; by = y; }\n      }\n      if (best > 0.968 && !holes.some(([hx, hy]) => Math.hypot(hx - bx, hy - by) < 21)) holes.push([bx, by]);\n    }\n  }\n  const pit = new Float32Array(w * h);\n  for (const [hx, hy] of holes) {\n    for (let y = hy - 9; y <= hy + 9; y++) {\n      for (let x = hx - 9; x <= hx + 9; x++) {\n        if (x < 0 || y < 0 || x >= w || y >= h) continue;\n        const d = Math.hypot(x - hx, y - hy);\n        pit[y * w + x] = Math.max(pit[y * w + x], Math.exp(-(d * d) / 11));\n      }\n    }\n  }\n\n  const edges: Array<[number, number]> = [];\n  const tops: Array<[number, number]> = [];\n  const lx = -0.46, ly = -0.56, lz = 0.69;\n  const hl = Math.hypot(lx, ly, lz + 1);\n  const hx = lx / hl, hy = ly / hl, hz = (lz + 1) / hl;\n\n  const paint = (cv: HTMLCanvasElement, baked: boolean) => {\n    cv.width = w;\n    cv.height = h;\n    const c = cv.getContext(\"2d\");\n    if (!c) return;\n    const rise = baked ? 1 : 0.55;\n    const hgt = new Float32Array(w * h);\n    for (let i = 0; i < hgt.length; i++) {\n      const t = Math.min(1, Math.max(0, (edge[i] - 0.5) * 2.05));\n      hgt[i] =\n        (Math.sqrt(1 - (1 - t) * (1 - t)) * 15 + dome[i] * 13) * rise +\n        (lumps[i] - 0.5) * (baked ? 3.6 : 1.4) +\n        (pores[i] - 0.5) * (baked ? 1.5 : 0.6) -\n        pit[i] * (baked ? 6.5 : 8.5);\n    }\n    const out = c.createImageData(w, h);\n    for (let y = 1; y < h - 1; y++) {\n      for (let x = 1; x < w - 1; x++) {\n        const i = y * w + x;\n        if (a[i] <= 0) continue;\n        let nx = -(hgt[i + 1] - hgt[i - 1]) * 0.6;\n        let ny = -(hgt[i + w] - hgt[i - w]) * 0.6;\n        const nl = Math.hypot(nx, ny, 1);\n        nx /= nl;\n        ny /= nl;\n        const nz = 1 / nl;\n        const diff = Math.max(0, nx * lx + ny * ly + nz * lz);\n        const nh = Math.max(0, nx * hx + ny * hy + nz * hz);\n        const rim = 1 - Math.min(1, Math.max(0, (edge[i] - 0.5) * 2.05));\n        let r: number, g: number, b: number;\n        if (baked) {\n          const k = Math.min(1, Math.pow(rim, 1.2) * 1.05 + (patch[i] - 0.45) * 0.34 + (pores[i] - 0.5) * 0.12);\n          const kk = Math.max(0, k);\n          r = GOLD[0] + (BROWN[0] - GOLD[0]) * kk;\n          g = GOLD[1] + (BROWN[1] - GOLD[1]) * kk;\n          b = GOLD[2] + (BROWN[2] - GOLD[2]) * kk;\n        } else {\n          const kk = rim * 0.12 + (patch[i] - 0.5) * 0.05;\n          r = DOUGH[0] * (1 - kk);\n          g = DOUGH[1] * (1 - kk);\n          b = DOUGH[2] * (1 - kk * 1.3);\n        }\n        const dark = 1 - pit[i] * (baked ? 0.42 : 0.3);\n        const shade = (0.47 + 0.78 * diff) * dark;\n        const spec = Math.pow(nh, 18) * (baked ? 0.1 : 0.05);\n        const grain = (rnd() - 0.5) * (baked ? 6 : 4);\n        const o = i * 4;\n        out.data[o] = Math.min(255, r * shade + 255 * spec + grain);\n        out.data[o + 1] = Math.min(255, g * shade + 255 * spec + grain);\n        out.data[o + 2] = Math.min(255, b * shade + 255 * spec + grain * 0.7);\n        out.data[o + 3] = a[i] * 255;\n        if (baked && edge[i] > 0.46 && edge[i] < 0.6 && a[i] > 0.9 && rnd() < 0.004) edges.push([x, y]);\n        if (baked && edge[i] > 0.9 && pit[i] < 0.05 && rnd() < 0.0012) tops.push([x / w, y / h]);\n      }\n    }\n    c.putImageData(out, 0, 0);\n    // Sugar on the baked ones, flour on the raw ones.\n    c.globalCompositeOperation = \"source-atop\";\n    const grains = Math.round((w * h) / (baked ? 900 : 900));\n    for (let n = 0; n < grains; n++) {\n      const x = rnd() * w, y = rnd() * h;\n      const s = baked ? 1.2 + rnd() * 1.8 : 0.8 + rnd() * 1.2;\n      c.fillStyle = baked ? `rgba(255,250,236,${0.5 + rnd() * 0.45})` : `rgba(255,255,255,${0.35 + rnd() * 0.3})`;\n      c.fillRect(x, y, s, s);\n      if (baked) {\n        c.fillStyle = \"rgba(110,60,20,0.3)\";\n        c.fillRect(x + s * 0.6, y + s, s * 0.8, 0.8);\n      }\n    }\n    c.globalCompositeOperation = \"source-over\";\n  };\n  paint(rawCv, false);\n  paint(bakedCv, true);\n  return { w, h, bw, edges, tops };\n}\n\ntype Crumb = { x: number; y: number; s: number; r: number };\n\nexport default function ShortbreadLetters() {\n  const reduce = useReducedMotion();\n  const [word, setWord] = useState(START_WORD);\n  const [batch, setBatch] = useState(0);\n  const [phase, setPhase] = useState<\"raw\" | \"baking\" | \"baked\">(\"baked\");\n  const [crumbs, setCrumbs] = useState<Crumb[]>([]);\n  const [bites, setBites] = useState(0);\n  const [glints, setGlints] = useState<Array<Array<[number, number]>>>([]);\n  const tray = useRef<HTMLDivElement>(null);\n  const sprites = useRef<Array<Baked & { el: HTMLButtonElement; scale: number }>>([]);\n  const first = useRef(true);\n  const letters = word.split(\"\");\n\n  useEffect(() => {\n    const el = tray.current;\n    if (!el) return;\n    const initial = first.current;\n    first.current = false;\n    setCrumbs([]);\n    setBites(0);\n    const buttons = Array.from(el.querySelectorAll<HTMLButtonElement>(\"[data-biscuit]\"));\n    const list: Array<Baked & { el: HTMLButtonElement; scale: number; seed: number }> = [];\n    buttons.forEach((b, i) => {\n      const cvs = b.querySelectorAll(\"canvas\");\n      const ch = b.dataset.biscuit || \"\";\n      const seed = (i + 1) * 7919 + ch.charCodeAt(0) * 104729 + batch * 31;\n      const size = cvs.length === 2 ? cut(cvs[0], cvs[1], ch, seed) : null;\n      if (size) list.push({ el: b, ...size, scale: 1, seed: random(seed)() });\n    });\n    sprites.current = list;\n    setGlints(list.map((b) => b.tops.slice(0, 3)));\n\n    const layout = () => {\n      const W = el.clientWidth, H = el.clientHeight;\n      const rows = W < 560 && list.length > 4 ? 2 : 1;\n      const perRow = Math.ceil(list.length / rows);\n      const gap = CAP * 0.16;\n      const rowWidth = (r: number) => list.slice(r * perRow, (r + 1) * perRow).reduce((sum, b) => sum + b.bw + gap, -gap);\n      const widest = Math.max(1, rowWidth(0), rows > 1 ? rowWidth(1) : 0);\n      const scale = Math.min((W * 0.84) / widest, (H * (rows > 1 ? 0.34 : 0.6)) / CAP, 1.1);\n      const lineH = CAP * 1.24 * scale;\n      const top = H * 0.5 - ((rows - 1) * lineH) / 2;\n      for (let r = 0; r < rows; r++) {\n        let x = W / 2 - (rowWidth(r) * scale) / 2;\n        list.slice(r * perRow, (r + 1) * perRow).forEach((b) => {\n          const cx = x + (b.bw * scale) / 2;\n          const cy = top + r * lineH + (b.seed - 0.5) * 18 * scale;\n          const turn = (((b.seed * 5.17) % 1) - 0.5) * 9;\n          x += (b.bw + gap) * scale;\n          b.scale = scale;\n          b.el.style.width = `${b.w * scale}px`;\n          b.el.style.height = `${b.h * scale}px`;\n          b.el.style.transform = `translate3d(${cx - (b.w * scale) / 2}px, ${cy - (b.h * scale) / 2}px, 0) rotate(${turn}deg)`;\n          b.el.style.opacity = \"1\";\n        });\n      }\n    };\n    layout();\n    const ro = new ResizeObserver(layout);\n    ro.observe(el);\n\n    // The first tray arrives baked. Every later one goes in raw and is baked while you watch.\n    const timers: number[] = [];\n    if (initial || reduce) {\n      setPhase(\"baked\");\n    } else {\n      setPhase(\"raw\");\n      timers.push(window.setTimeout(() => setPhase(\"baking\"), 950));\n      timers.push(window.setTimeout(() => setPhase(\"baked\"), 950 + BAKE_SECONDS * 1000));\n    }\n    return () => {\n      ro.disconnect();\n      timers.forEach((t) => window.clearTimeout(t));\n    };\n  }, [word, batch, reduce]);\n\n  function bite(i: number, e: ReactMouseEvent<HTMLButtonElement>) {\n    const b = sprites.current[i];\n    if (!b || phase !== \"baked\") return;\n    let x: number, y: number;\n    if (e.detail === 0 || !b.edges.length) {\n      // From the keyboard: bite somewhere on the rim.\n      const p = b.edges[(bites * 7 + i * 3) % Math.max(1, b.edges.length)] || [b.w / 2, b.h / 2];\n      x = p[0];\n      y = p[1];\n    } else {\n      // The sprite is rotated a few degrees; undo that to find the spot in its own pixels.\n      const r = b.el.getBoundingClientRect();\n      const turn = (parseFloat((b.el.style.transform.match(/rotate\\(([-\\d.]+)deg\\)/) || [\"\", \"0\"])[1]) * Math.PI) / 180;\n      const dx = e.clientX - (r.left + r.width / 2), dy = e.clientY - (r.top + r.height / 2);\n      x = b.w / 2 + (dx * Math.cos(-turn) - dy * Math.sin(-turn)) / b.scale;\n      y = b.h / 2 + (dx * Math.sin(-turn) + dy * Math.cos(-turn)) / b.scale;\n    }\n    const R = CAP * 0.17;\n    b.el.querySelectorAll(\"canvas\").forEach((cv, n) => {\n      const c = cv.getContext(\"2d\");\n      if (!c) return;\n      const teeth = (grow: number) => {\n        c.beginPath();\n        c.arc(x, y, R + grow, 0, 6.2832);\n        for (let k = 0; k < 6; k++) {\n          const t = (k / 6) * 6.2832 + i;\n          const tx = x + Math.cos(t) * R * 0.92, ty = y + Math.sin(t) * R * 0.92;\n          c.moveTo(tx + R * 0.36 + grow, ty);\n          c.arc(tx, ty, R * 0.36 + grow, 0, 6.2832);\n        }\n      };\n      // The pale crumb inside shows as a rim round the bite.\n      c.globalCompositeOperation = \"source-atop\";\n      c.fillStyle = \"rgba(96,54,18,0.45)\";\n      teeth(6.5);\n      c.fill();\n      c.fillStyle = n ? \"#f3dcae\" : \"#f4ecd6\";\n      teeth(4.5);\n      c.fill();\n      c.globalCompositeOperation = \"destination-out\";\n      c.fillStyle = \"#000\";\n      teeth(0);\n      c.fill();\n      c.globalCompositeOperation = \"source-over\";\n    });\n    const host = tray.current?.getBoundingClientRect();\n    const r = b.el.getBoundingClientRect();\n    if (host) {\n      const turn = (parseFloat((b.el.style.transform.match(/rotate\\(([-\\d.]+)deg\\)/) || [\"\", \"0\"])[1]) * Math.PI) / 180;\n      const ox = (x - b.w / 2) * b.scale, oy = (y - b.h / 2) * b.scale;\n      const cx = r.left + r.width / 2 - host.left + ox * Math.cos(turn) - oy * Math.sin(turn);\n      const cy = r.top + r.height / 2 - host.top + ox * Math.sin(turn) + oy * Math.cos(turn);\n      const rnd = random(bites * 97 + i * 13 + 5);\n      const fresh: Crumb[] = Array.from({ length: 7 }, () => {\n        const t = rnd() * 6.2832, d = (0.2 + rnd() * 1.1) * R * b.scale;\n        return { x: cx + Math.cos(t) * d, y: cy + Math.sin(t) * d, s: 2 + rnd() * 5, r: rnd() * 180 };\n      });\n      setCrumbs((c) => [...c.slice(-60), ...fresh]);\n    }\n    setBites((n) => n + 1);\n  }\n\n  return (\n    <section className=\"relative isolate flex min-h-[660px] w-full flex-col items-center overflow-hidden px-4 pt-14 sm:px-8\" style={{ backgroundColor: WORKTOP }}>\n      <style>{`\n        @keyframes shortbread-letters-cut-from-dough-land { 0% { transform: scale(1.14); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1); opacity: 1; } }\n        @keyframes shortbread-letters-cut-from-dough-steam { 0% { transform: translate3d(0, 30px, 0) scale(0.7, 0.8); opacity: 0; } 25% { opacity: 0.5; } 60% { transform: translate3d(14px, -70px, 0) scale(1.15, 1.25); opacity: 0.3; } 100% { transform: translate3d(-10px, -170px, 0) scale(1.6, 1.7); opacity: 0; } }\n        @keyframes shortbread-letters-cut-from-dough-glint { 0%, 62%, 100% { opacity: 0; transform: scale(0.3); } 80% { opacity: 1; transform: scale(1); } }\n        @keyframes shortbread-letters-cut-from-dough-crumb { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }\n        .shortbread-letters-b { position: absolute; left: 0; top: 0; opacity: 0; cursor: pointer; border-radius: 16px; -webkit-tap-highlight-color: transparent; }\n        .shortbread-letters-b .sl-land, .shortbread-letters-b .sl-puff { position: absolute; inset: 0; display: block; }\n        .shortbread-letters-b .sl-puff { filter: drop-shadow(0 2px 1.5px rgba(70,44,12,0.45)) drop-shadow(4px 9px 8px rgba(70,44,12,0.22)); transition: transform ${BAKE_SECONDS}s cubic-bezier(0.3, 0.7, 0.3, 1); }\n        .shortbread-letters-b canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }\n        .shortbread-letters-b .sl-done { transition: opacity ${BAKE_SECONDS}s ease-in-out; }\n        [data-phase=\"raw\"] .sl-done { opacity: 0; transition: none; }\n        [data-phase=\"raw\"] .sl-puff { transform: scale(0.94); transition: none; }\n        [data-phase=\"raw\"] .sl-land { animation: shortbread-letters-cut-from-dough-land 420ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both; animation-delay: calc(var(--i) * 80ms); }\n        .shortbread-letters-heat { opacity: 0; transition: opacity 900ms ease-in-out; }\n        [data-phase=\"baking\"] .shortbread-letters-heat { opacity: 1; }\n        .shortbread-letters-steam { opacity: 0; }\n        [data-phase=\"baked\"] .shortbread-letters-steam { animation: shortbread-letters-cut-from-dough-steam 5.2s ease-out infinite; }\n        .shortbread-letters-glint { position: absolute; width: 3px; height: 3px; margin: -1.5px; border-radius: 9999px; background: #fff; box-shadow: 0 0 5px 1.5px rgba(255,248,225,0.9); opacity: 0; pointer-events: none; }\n        [data-phase=\"baked\"] .shortbread-letters-glint { animation: shortbread-letters-cut-from-dough-glint 3.4s ease-in-out infinite; }\n        .shortbread-letters-crumb { animation: shortbread-letters-cut-from-dough-crumb 260ms ease-out both; }\n        @media (prefers-reduced-motion: reduce) {\n          .shortbread-letters-b .sl-puff, .shortbread-letters-b .sl-done, .shortbread-letters-heat { transition: none; }\n          [data-phase] .sl-land, [data-phase] .shortbread-letters-steam, [data-phase] .shortbread-letters-glint, .shortbread-letters-crumb { animation: none; }\n        }\n      `}</style>\n      <div aria-hidden=\"true\" className=\"absolute inset-0 -z-10\" style={{ background: \"radial-gradient(90% 70% at 38% 30%, rgba(255,255,255,0.13) 0%, rgba(255,255,255,0) 60%), linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.28) 100%)\" }} />\n\n      <h2 className=\"sr-only\">{word}</h2>\n\n      {/* The baking sheet: rolled steel rim, a dark well and a sheet of parchment. */}\n      <div\n        data-phase={phase}\n        className=\"relative w-full max-w-[1060px] rounded-[30px] p-[13px]\"\n        style={{\n          background: \"linear-gradient(145deg, #a9aeb1 0%, #6d7276 16%, #3c4043 50%, #25282a 84%, #54595c 100%)\",\n          boxShadow: \"0 50px 60px -30px rgba(0,0,0,0.65), 0 18px 24px -10px rgba(0,0,0,0.4), inset 0 1.5px 0 rgba(255,255,255,0.45), inset 0 -2px 3px rgba(0,0,0,0.5)\",\n        }}\n      >\n        <div className=\"relative rounded-[19px] p-[10px] sm:p-[16px]\" style={{ background: \"linear-gradient(160deg, #1b1d1f 0%, #2d3033 60%, #3a3e41 100%)\", boxShadow: \"inset 0 6px 10px rgba(0,0,0,0.65), inset 0 -1px 0 rgba(255,255,255,0.12)\" }}>\n          <div\n            ref={tray}\n            className=\"relative h-[470px] w-full overflow-hidden rounded-[4px] sm:h-[390px]\"\n            style={{\n              backgroundColor: \"#f0e7d3\",\n              backgroundImage:\n                \"linear-gradient(99deg, rgba(120,96,56,0) 23.7%, rgba(120,96,56,0.1) 24%, rgba(255,255,255,0.4) 24.3%, rgba(255,255,255,0) 26.5%), linear-gradient(83deg, rgba(120,96,56,0) 73.7%, rgba(120,96,56,0.08) 74%, rgba(255,255,255,0.35) 74.3%, rgba(255,255,255,0) 77%), radial-gradient(22% 30% at 12% 82%, rgba(190,150,80,0.16) 0%, rgba(190,150,80,0) 100%), radial-gradient(18% 24% at 86% 18%, rgba(190,150,80,0.13) 0%, rgba(190,150,80,0) 100%), linear-gradient(135deg, #f8f1e1 0%, #ebe0c8 100%)\",\n              boxShadow: \"0 2px 5px rgba(0,0,0,0.5), inset 0 0 40px rgba(150,120,70,0.14)\",\n            }}\n          >\n            {crumbs.map((c, i) => (\n              <span key={i} aria-hidden=\"true\" className=\"shortbread-letters-crumb absolute rounded-[40%]\" style={{ left: c.x, top: c.y, width: c.s, height: c.s * 0.8, rotate: `${c.r}deg`, background: \"radial-gradient(circle at 35% 30%, #edc98a, #b77a35)\", boxShadow: \"0.5px 1px 1px rgba(70,44,12,0.4)\" }} />\n            ))}\n            {letters.map((ch, i) => (\n              <button\n                key={`${word}-${batch}-${i}`}\n                type=\"button\"\n                data-biscuit={ch}\n                onClick={(e) => bite(i, e)}\n                aria-label={`Biscuit ${i + 1} of ${letters.length}, letter ${ch}. Press to take a bite.`}\n                className=\"shortbread-letters-b focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#27382f] focus-visible:ring-offset-2 focus-visible:ring-offset-[#f0e7d3]\"\n                style={{ [\"--i\" as string]: i }}\n              >\n                <span className=\"sl-land\">\n                  <span className=\"sl-puff\">\n                    <canvas aria-hidden=\"true\" />\n                    <canvas aria-hidden=\"true\" className=\"sl-done\" />\n                    {(glints[i] || []).map(([gx, gy], n) => (\n                      <span key={n} aria-hidden=\"true\" className=\"shortbread-letters-glint\" style={{ left: `${gx * 100}%`, top: `${gy * 100}%`, animationDelay: `${-((i * 0.83 + n * 1.37) % 3.4)}s` }} />\n                    ))}\n                  </span>\n                </span>\n              </button>\n            ))}\n            <div aria-hidden=\"true\" className=\"shortbread-letters-heat pointer-events-none absolute inset-0\" style={{ background: \"radial-gradient(80% 90% at 50% 45%, rgba(255,150,40,0.42) 0%, rgba(255,96,20,0.3) 60%, rgba(200,50,10,0.38) 100%)\", mixBlendMode: \"multiply\" }} />\n          </div>\n        </div>\n        {[18, 37, 55, 71, 86].map((x, i) => (\n          <span\n            key={x}\n            aria-hidden=\"true\"\n            className=\"shortbread-letters-steam pointer-events-none absolute top-[6%] h-[190px] w-[90px] rounded-full\"\n            style={{ left: `${x}%`, background: \"radial-gradient(closest-side, rgba(255,255,255,0.34), rgba(255,255,255,0))\", filter: \"blur(18px)\", animationDelay: `${-i * 1.07}s` }}\n          />\n        ))}\n      </div>\n\n      <div className=\"relative mt-auto flex w-full max-w-[1060px] flex-wrap items-center justify-between gap-x-6 gap-y-3 pb-8 pt-7 text-[13px]\">\n        <p className=\"text-[#c9d6cc]\" aria-live=\"polite\">\n          <span className=\"font-semibold text-white\">Shortbread letters</span>\n          <span className=\"mx-2 opacity-50\">/</span>\n          {phase === \"raw\" ? \"cut and on the tray\" : phase === \"baking\" ? \"in the oven\" : bites ? `${bites} ${bites === 1 ? \"bite\" : \"bites\"} gone` : \"warm from the oven, tap one to bite it\"}\n        </p>\n        <div className=\"flex items-center gap-2\">\n          <label htmlFor=\"shortbread-letters-word\" className=\"sr-only\">\n            Word to cut from the dough\n          </label>\n          <input\n            id=\"shortbread-letters-word\"\n            value={word}\n            maxLength={MAX_LETTERS}\n            onChange={(e) => setWord(e.target.value.toUpperCase().replace(/[^A-Z0-9!?&]/g, \"\").slice(0, MAX_LETTERS))}\n            autoComplete=\"off\"\n            spellCheck={false}\n            className=\"h-11 w-[150px] rounded-full border border-white/25 bg-[#1b2921] px-4 text-[14px] font-semibold tracking-[0.18em] text-white outline-none placeholder:text-white/50 focus-visible:ring-2 focus-visible:ring-[#f0d9a8]\"\n          />\n          <button\n            type=\"button\"\n            onClick={() => setBatch((n) => n + 1)}\n            className=\"h-11 shrink-0 rounded-full bg-[#f0d9a8] px-5 font-semibold text-[#2a1c0a] shadow-[0_10px_20px_-10px_rgba(0,0,0,0.7)] transition-transform hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#f0d9a8] focus-visible:ring-offset-2 focus-visible:ring-offset-[#27382f] motion-reduce:transition-none\"\n          >\n            Bake a fresh tray\n          </button>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
