{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"edit-sentence-that-gathers-into-a-bead-of-wet-paint-and-falls-onto-a-lacquered-page-model","type":"registry:block","title":"Edit Sentence That Gathers into a Bead of Wet Paint and Falls onto a Lacquered Page Model","description":"Demo of editing a site by saying it: the sentence gathers into a bead of paint that falls onto a page model and spreads. Free React and HTML code.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/edit-sentence-that-gathers-into-a-bead-of-wet-paint-and-falls-onto-a-lacquered-page-model.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** Everything painted on the board. Change the business here. */\nconst site = {\n  brand: \"Halloway Flowers\",\n  links: [\"Bouquets\", \"Weddings\", \"Visit\"],\n  headline: [\"Flowers cut\", \"this morning.\"],\n  sub: \"Hand-tied in the shop on Mill Lane, ready by noon.\",\n  cta: \"Order a bouquet\",\n  photo: { src: \"https://images.pexels.com/photos/8127839/pexels-photo-8127839.jpeg?auto=compress&cs=tinysrgb&w=600\", alt: \"Deep red peonies in a steel vase against a grey wall\" },\n};\n\nconst BLUE = \"#4F98FB\";\nconst INK = \"#0B0D12\";\nconst PAPER = \"#FBFAF7\";\nconst WARM = \"#DC7440\";\nconst COOL = \"#E3E6EA\";\nconst NIGHT = \"#12151C\";\nconst sans = '\"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, sans-serif';\n\ntype Look = { header: 0 | 1; button: 0 | 1; body: 0 | 1 };\ntype Part = \"header\" | \"button\" | \"body\" | \"reset\";\nconst FRESH: Look = { header: 0, button: 0, body: 0 };\n\n// Design pixels. The board is drawn at this size and the scene is scaled to fit.\nconst W = 560;\nconst H = 390;\nconst SCENE_W = 900;\nconst SCENE_H = 420;\n/** Where each coat lands, and the shape it has to stay inside. */\nconst zones: Record<Part, { x: number; y: number; w: number; h: number; radius: string; cx: number; cy: number }> = {\n  header: { x: 0, y: 0, w: W, h: 58, radius: \"14px 14px 0 0\", cx: 300, cy: 29 },\n  button: { x: 36, y: 300, w: 184, h: 52, radius: \"26px\", cx: 128, cy: 326 },\n  body: { x: 0, y: 0, w: W, h: H, radius: \"14px\", cx: 250, cy: 210 },\n  reset: { x: 0, y: 0, w: W, h: H, radius: \"14px\", cx: 280, cy: 190 },\n};\nconst chips: { part: Part; label: string }[] = [\n  { part: \"header\", label: \"Header\" },\n  { part: \"button\", label: \"Button\" },\n  { part: \"body\", label: \"Page\" },\n  { part: \"reset\", label: \"Start again\" },\n];\n\n/** What saying it does: the sentence, the look afterwards and the colour of the bead. */\nfunction plan(look: Look, part: Part): { say: string; next: Look; paint: string } {\n  if (part === \"header\") return look.header ? { say: \"Cool the header down.\", next: { ...look, header: 0 }, paint: look.body ? \"#232936\" : COOL } : { say: \"Make the header warmer.\", next: { ...look, header: 1 }, paint: WARM };\n  if (part === \"button\") return look.button ? { say: \"Make the button plain.\", next: { ...look, button: 0 }, paint: look.body ? PAPER : INK } : { say: \"Turn the button blue.\", next: { ...look, button: 1 }, paint: BLUE };\n  if (part === \"body\") return look.body ? { say: \"Make the page light.\", next: { ...look, body: 0 }, paint: PAPER } : { say: \"Make the page dark.\", next: { ...look, body: 1 }, paint: NIGHT };\n  return { say: \"Start again in white.\", next: FRESH, paint: PAPER };\n}\n\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\nconst easeOut = (t: number) => 1 - Math.pow(1 - t, 3);\n\n/** The page as it is painted on the board, for one look. */\nfunction Face({ look, hidden }: { look: Look; hidden?: boolean }) {\n  const dark = look.body === 1;\n  const text = dark ? \"#F6F4EF\" : INK;\n  const soft = dark ? \"#A9B0BF\" : \"#565B66\";\n  const head = look.header ? WARM : dark ? \"#232936\" : COOL;\n  const headText = look.header ? INK : text;\n  const btn = look.button ? BLUE : dark ? PAPER : INK;\n  const btnText = look.button ? INK : dark ? INK : \"#FFFFFF\";\n  const Title = hidden ? \"p\" : \"h2\";\n  return (\n    <div aria-hidden={hidden ? \"true\" : undefined} className=\"absolute inset-0\" style={{ background: dark ? NIGHT : PAPER }}>\n      <div className=\"absolute inset-x-0 top-0 flex items-center justify-between px-[26px]\" style={{ height: 58, background: head, color: headText }}>\n        <span className=\"flex items-center gap-[9px] text-[15px] font-extrabold tracking-[-0.025em]\">\n          <span aria-hidden=\"true\" className=\"h-[10px] w-[10px] rounded-full\" style={{ background: look.header ? INK : BLUE }} />\n          {site.brand}\n        </span>\n        <span className=\"flex items-center gap-[20px] text-[11.5px] font-bold\">\n          {site.links.map((l) => (\n            <span key={l}>{l}</span>\n          ))}\n        </span>\n      </div>\n      <Title className=\"absolute left-[36px] top-[98px] text-[50px] font-black leading-[0.95] tracking-[-0.055em]\" style={{ color: text }}>\n        {site.headline.map((l) => (\n          <span key={l} className=\"block\">\n            {l}\n          </span>\n        ))}\n      </Title>\n      <p className=\"absolute left-[38px] top-[216px] w-[250px] text-[13.5px] font-semibold leading-snug\" style={{ color: soft }}>\n        {site.sub}\n      </p>\n      <span className=\"absolute flex items-center justify-center gap-2 text-[15px] font-extrabold tracking-[-0.02em]\" style={{ left: 36, top: 300, width: 184, height: 52, borderRadius: 26, background: btn, color: btnText }}>\n        {site.cta}\n        <svg aria-hidden=\"true\" width=\"14\" height=\"14\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n          <path d=\"M4 10h12M11 5l5 5-5 5\" />\n        </svg>\n      </span>\n      <div className=\"absolute overflow-hidden\" style={{ left: 352, top: 86, width: 176, height: 270, borderRadius: 12, background: \"#8d8f93\", boxShadow: dark ? \"0 0 0 1px rgba(255,255,255,0.10)\" : \"0 0 0 1px rgba(11,13,18,0.08)\" }}>\n        <img src={site.photo.src} alt={hidden ? \"\" : site.photo.alt} width={176} height={270} draggable={false} className=\"h-full w-full object-cover\" />\n      </div>\n    </div>\n  );\n}\n\nexport default function PaintBeadPageEdit() {\n  const reduce = useReducedMotion();\n  const stageRef = useRef<HTMLDivElement>(null);\n  const pillRef = useRef<HTMLDivElement>(null);\n  const typedRef = useRef<HTMLSpanElement>(null);\n  const swatchRef = useRef<HTMLSpanElement>(null);\n  const wrapRef = useRef<HTMLDivElement>(null);\n  const sceneRef = useRef<HTMLDivElement>(null);\n  const boardRef = useRef<HTMLDivElement>(null);\n  const coatRef = useRef<HTMLDivElement>(null);\n  const rimBoxRef = useRef<HTMLDivElement>(null);\n  const rimRef = useRef<SVGSVGElement>(null);\n  const spotRef = useRef<HTMLDivElement>(null);\n  const wetRef = useRef<HTMLDivElement>(null);\n  const beadRef = useRef<HTMLDivElement>(null);\n  const first = plan(FRESH, \"header\");\n  const [cur, setCur] = useState<Look>(reduce ? first.next : FRESH);\n  const [next, setNext] = useState<Look>(first.next);\n  const [status, setStatus] = useState(\"\");\n  const api = useRef<{ say: (p: Part) => void } | null>(null);\n\n  useEffect(() => {\n    const stage = stageRef.current, pill = pillRef.current, typed = typedRef.current, swatch = swatchRef.current, wrap = wrapRef.current, scene = sceneRef.current;\n    const board = boardRef.current, coat = coatRef.current, rimBox = rimBoxRef.current, rim = rimRef.current, spot = spotRef.current, bead = beadRef.current, wet = wetRef.current;\n    if (!stage || !pill || !typed || !swatch || !wrap || !scene || !board || !coat || !rimBox || !rim || !spot || !bead || !wet) return;\n\n    // one coat of paint from sentence to dry\n    const s = {\n      look: reduce ? first.next : FRESH, // what is dry on the board\n      to: first.next,\n      part: \"header\" as Part,\n      say: first.say,\n      paint: first.paint,\n      phase: reduce ? \"rest\" : \"swell\",\n      t0: performance.now() + 500,\n      slow: 2.3, // the first coat runs slower so a still picture catches it half way\n      x0: 0, y0: 0, x1: 0, y1: 0,\n      R: 0,\n      dip: 0, vdip: 0,\n      px: 0, py: 0, tx: 0, ty: 0,\n      scale: 1,\n      demo: 0,\n      user: -1e9,\n      held: false,\n      ph: [0.4, 2.1, 4.4],\n    };\n    let raf = 0;\n    let visible = true;\n    let last = performance.now();\n    const TYPE = 26, SWELL = 400, FALL = 380, SPREAD = 1500, DRY = 1900, GAP = 650;\n\n    const measure = () => {\n      const sc = clamp(wrap.clientWidth / 700, 0.42, 1.2);\n      s.scale = sc;\n      wrap.style.height = `${Math.round(SCENE_H * sc)}px`;\n      scene.style.transform = `translateX(-50%) scale(${sc.toFixed(4)})`;\n    };\n    measure();\n    const ro = new ResizeObserver(measure);\n    ro.observe(wrap);\n\n    const lips = rim.querySelectorAll(\"path\");\n    /** The coat is a puddle, not a compass circle: its edge runs ahead in some directions and lags in others. */\n    const setCoat = (r: number, wetness: number) => {\n      const z = zones[s.part];\n      const lag = 0.11 * (1 - (r / (s.R || 1)) * 0.6);\n      let d = \"\";\n      for (let i = 0; i < 44; i++) {\n        const a = (i / 44) * Math.PI * 2;\n        const rr = r * (1 + lag * (Math.sin(3 * a + s.ph[0]) * 0.5 + Math.sin(5 * a + s.ph[1]) * 0.32 + Math.sin(8 * a + s.ph[2]) * 0.18));\n        d += `${i ? \"L\" : \"M\"}${(z.cx + Math.cos(a) * rr).toFixed(1)} ${(z.cy + Math.sin(a) * rr).toFixed(1)}`;\n      }\n      d += \"Z\";\n      coat.style.clipPath = `path(\"${d}\")`;\n      wet.style.clipPath = `path(\"${d}\")`;\n      wet.style.opacity = wetness.toFixed(3);\n      lips.forEach((l) => l.setAttribute(\"d\", d));\n    };\n    const aim = () => {\n      const z = zones[s.part];\n      rimBox.style.left = `${z.x}px`;\n      rimBox.style.top = `${z.y}px`;\n      rimBox.style.width = `${z.w}px`;\n      rimBox.style.height = `${z.h}px`;\n      rimBox.style.borderRadius = z.radius;\n      rim.style.left = `${-z.x}px`;\n      rim.style.top = `${-z.y}px`;\n      wet.style.left = `${-z.x}px`;\n      wet.style.top = `${-z.y}px`;\n      s.ph = [Math.random() * 6.3, Math.random() * 6.3, Math.random() * 6.3];\n      spot.style.left = `${z.cx}px`;\n      spot.style.top = `${z.cy}px`;\n      s.R = Math.hypot(Math.max(z.cx - z.x, z.x + z.w - z.cx), Math.max(z.cy - z.y, z.y + z.h - z.cy)) * 1.14 + 8;\n      swatch.style.background = s.paint;\n      bead.style.setProperty(\"--paint\", s.paint);\n    };\n    /** Where the bead leaves the bar and where it lands, in stage pixels. */\n    const sight = () => {\n      const sr = stage.getBoundingClientRect(), pr = pill.getBoundingClientRect(), tr = spot.getBoundingClientRect();\n      s.x1 = tr.left + tr.width / 2 - sr.left;\n      s.y1 = tr.top + tr.height / 2 - sr.top;\n      s.x0 = clamp(s.x1, pr.left - sr.left + 44, pr.right - sr.left - 44);\n      s.y0 = pr.bottom - sr.top;\n    };\n\n    const begin = (part: Part, now: number, typeIt: boolean) => {\n      // whatever was wet becomes the dry coat underneath\n      s.look = s.to;\n      setCur(s.to);\n      const p = plan(s.look, part);\n      s.part = part;\n      s.to = p.next;\n      s.say = p.say;\n      s.paint = p.paint;\n      aim();\n      setCoat(0, 0);\n      rim.style.opacity = \"0\";\n      setNext(p.next);\n      setStatus(p.say);\n      if (reduce) {\n        typed.textContent = p.say;\n        s.look = p.next;\n        setCur(p.next);\n        s.phase = \"rest\";\n        return;\n      }\n      s.slow = 1;\n      s.phase = typeIt ? \"type\" : \"swell\";\n      s.t0 = now;\n    };\n    aim();\n    setCoat(0, 0);\n    typed.textContent = s.say;\n\n    const tick = (now: number) => {\n      const dt = Math.min(0.033, (now - last) / 1000);\n      last = now;\n      const t = now - s.t0;\n      const size = 40 * s.scale + 10;\n\n      if (s.phase === \"type\") {\n        const n = Math.min(s.say.length, Math.floor(t / TYPE));\n        if (typed.dataset.n !== `${s.part}${n}`) {\n          typed.dataset.n = `${s.part}${n}`;\n          typed.textContent = s.say.slice(0, n);\n        }\n        if (n >= s.say.length && t > s.say.length * TYPE + 160) {\n          s.phase = \"swell\";\n          s.t0 = now;\n        }\n      } else if (s.phase === \"swell\" && t >= 0) {\n        if (t < 20 || !s.x0) sight();\n        const k = clamp(t / SWELL, 0, 1);\n        const g = easeOut(k);\n        const sway = Math.sin(t / 60) * (1 - k) * 0.06;\n        bead.style.opacity = \"1\";\n        bead.style.width = `${size}px`;\n        bead.style.height = `${size}px`;\n        bead.style.transform = `translate(${(s.x0 - size / 2).toFixed(1)}px, ${(s.y0 - size * (1 - 0.72 * g)).toFixed(1)}px) scale(${(0.35 + 0.65 * g + sway).toFixed(3)}, ${(0.35 + 0.65 * g + 0.22 * k * k).toFixed(3)})`;\n        if (k >= 1) {\n          sight();\n          s.phase = \"fall\";\n          s.t0 = now;\n        }\n      } else if (s.phase === \"fall\") {\n        const k = clamp(t / FALL, 0, 1);\n        const y = s.y0 - size * 0.28 + (s.y1 - size * 0.5 - (s.y0 - size * 0.28)) * k * k;\n        const x = s.x0 + (s.x1 - s.x0) * k;\n        bead.style.transform = `translate(${(x - size / 2).toFixed(1)}px, ${y.toFixed(1)}px) scale(${(1 - 0.16 * k).toFixed(3)}, ${(1.1 + 0.34 * k).toFixed(3)})`;\n        spot.style.opacity = (0.5 * k * k).toFixed(3);\n        spot.style.transform = `translate(-50%, -50%) scale(${(2.6 - 1.6 * k).toFixed(3)})`;\n        if (k >= 1) {\n          bead.style.opacity = \"0\";\n          spot.style.opacity = \"0\";\n          s.vdip = -230;\n          s.phase = \"spread\";\n          s.t0 = now;\n        }\n      } else if (s.phase === \"spread\") {\n        const k = clamp(t / (SPREAD * s.slow), 0, 1);\n        // fast out of the splash, then slow like something thick\n        const r = s.R * (0.14 * easeOut(clamp(k * 9 * s.slow, 0, 1)) + 0.86 * (1 - Math.pow(1 - k, s.slow > 1 ? 1.25 : 2)));\n        setCoat(r, 1);\n        rim.style.opacity = clamp((1 - k) * 5, 0, 1).toFixed(3);\n        if (k >= 1) {\n          s.look = s.to;\n          setCur(s.to);\n          s.phase = \"dry\";\n          s.t0 = now;\n        }\n      } else if (s.phase === \"dry\") {\n        const k = clamp(t / DRY, 0, 1);\n        setCoat(s.R, 1 - easeOut(k));\n        if (k >= 1) {\n          s.phase = \"rest\";\n          s.t0 = now;\n        }\n      } else if (s.phase === \"rest\" && !reduce && t > GAP && now - s.user > 9000) {\n        s.demo = (s.demo + 1) % chips.length;\n        begin(chips[s.demo].part, now, true);\n      }\n\n      // the board takes the hit and settles; the gloss follows the pointer\n      s.vdip += (-430 * s.dip - 17 * s.vdip) * dt;\n      s.dip += s.vdip * dt;\n      s.px += (s.tx - s.px) * 0.07;\n      s.py += (s.ty - s.py) * 0.07;\n      const idle = reduce ? 0 : Math.sin(now / 2400) * 1.4;\n      board.style.transform = `rotateX(${(55 - s.py * 3).toFixed(2)}deg) rotateZ(${(-17 + s.px * 4 + idle).toFixed(2)}deg) translateZ(${s.dip.toFixed(2)}px)`;\n      board.style.setProperty(\"--gx\", `${(74 + s.px * 22 + idle * 3).toFixed(1)}%`);\n      if (visible) raf = requestAnimationFrame(tick);\n    };\n\n    const io = new IntersectionObserver(([e]) => {\n      const was = visible;\n      visible = e.isIntersecting;\n      if (visible && !was) {\n        last = performance.now();\n        raf = requestAnimationFrame(tick);\n      }\n    });\n    io.observe(stage);\n    raf = requestAnimationFrame(tick);\n\n    const move = (e: PointerEvent) => {\n      const r = stage.getBoundingClientRect();\n      s.tx = clamp(((e.clientX - r.left) / r.width - 0.5) * 2, -1, 1);\n      s.ty = clamp(((e.clientY - r.top) / r.height - 0.5) * 2, -1, 1);\n    };\n    const leave = () => {\n      s.tx = 0;\n      s.ty = 0;\n      s.held = false;\n    };\n    const enter = () => {\n      s.held = true;\n    };\n    stage.addEventListener(\"pointermove\", move);\n    stage.addEventListener(\"pointerleave\", leave);\n    stage.addEventListener(\"pointerenter\", enter);\n\n    api.current = {\n      say: (part) => {\n        const now = performance.now();\n        s.user = now;\n        s.demo = chips.findIndex((c) => c.part === part);\n        bead.style.opacity = \"0\";\n        spot.style.opacity = \"0\";\n        begin(part, now, true);\n      },\n    };\n\n    return () => {\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n      stage.removeEventListener(\"pointermove\", move);\n      stage.removeEventListener(\"pointerleave\", leave);\n      stage.removeEventListener(\"pointerenter\", enter);\n      api.current = null;\n    };\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [reduce]);\n\n  return (\n    <section className=\"relative overflow-hidden bg-[#F6F4EF] px-4 pb-10 pt-10 sm:pb-14 sm:pt-14\" style={{ fontFamily: sans }}>\n      <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\" style={{ background: \"radial-gradient(70% 62% at 50% 58%, #FFFFFF 0%, #F6F4EF 46%, #E9E5DC 100%)\" }} />\n      <div ref={stageRef} className=\"relative mx-auto w-full max-w-[900px]\">\n        {/* the sentence */}\n        <div className=\"relative z-30 flex justify-center\">\n          <div ref={pillRef} className=\"flex h-[58px] w-full max-w-[470px] items-center gap-3 rounded-full pl-[10px] pr-6 sm:h-[64px]\" style={{ background: \"linear-gradient(180deg, #1d212b 0%, #0B0D12 60%)\", boxShadow: \"inset 0 1px 0 rgba(255,255,255,0.16), inset 0 -1px 0 rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.9), 0 18px 30px -14px rgba(11,13,18,0.45)\" }}>\n            <span aria-hidden=\"true\" className=\"relative h-[38px] w-[38px] shrink-0 rounded-full sm:h-[44px] sm:w-[44px]\" style={{ background: \"#07080b\", boxShadow: \"inset 0 2px 5px rgba(0,0,0,0.9), 0 1px 0 rgba(255,255,255,0.12)\" }}>\n              <span ref={swatchRef} className=\"absolute inset-[5px] rounded-full\" style={{ background: WARM, boxShadow: \"inset 0 3px 4px rgba(255,255,255,0.45), inset 0 -4px 6px rgba(0,0,0,0.3)\" }} />\n            </span>\n            <p className=\"min-w-0 flex-1 truncate text-[18px] font-extrabold tracking-[-0.03em] text-white sm:text-[22px]\">\n              <span ref={typedRef}>{first.say}</span>\n              <span aria-hidden=\"true\" className=\"edit-sentence-paint-bead-caret ml-[3px] inline-block h-[20px] w-[3px] translate-y-[3px] rounded-full sm:h-[24px]\" style={{ background: BLUE }} />\n            </p>\n          </div>\n        </div>\n\n        {/* the bead of paint, in stage pixels */}\n        <div\n          ref={beadRef}\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute left-0 top-0 z-20\"\n          style={{\n            width: 40,\n            height: 40,\n            opacity: 0,\n            transformOrigin: \"50% 0%\",\n            borderRadius: \"50% 50% 50% 50% / 58% 58% 42% 42%\",\n            background: \"radial-gradient(circle at 34% 30%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.9) 6%, rgba(255,255,255,0.22) 15%, rgba(255,255,255,0) 30%), radial-gradient(circle at 62% 80%, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 34%), radial-gradient(circle at 50% 45%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.30) 100%), var(--paint, #DC7440)\",\n            boxShadow: \"0 0 0 0.5px rgba(11,13,18,0.18), 0 10px 14px -6px rgba(11,13,18,0.35)\",\n          }}\n        />\n\n        <div ref={wrapRef} className=\"relative z-10 mt-2 w-full sm:mt-4\" style={{ height: SCENE_H }}>\n          <div ref={sceneRef} className=\"absolute left-1/2 top-0\" style={{ width: SCENE_W, height: SCENE_H, transformOrigin: \"50% 0\", transform: \"translateX(-50%)\", perspective: \"1500px\", perspectiveOrigin: \"50% 20%\" }}>\n            <div ref={boardRef} className=\"absolute\" style={{ left: SCENE_W / 2, top: 204, width: 0, height: 0, transformStyle: \"preserve-3d\", transform: \"rotateX(55deg) rotateZ(-17deg)\", [\"--gx\" as string]: \"74%\" }}>\n              {/* shadow on the table */}\n              <div aria-hidden=\"true\" className=\"absolute\" style={{ left: -W / 2 + 26, top: -H / 2 + 44, width: W, height: H, borderRadius: 30, background: \"rgba(60,48,26,0.5)\", filter: \"blur(38px)\", transform: \"translateZ(-70px)\" }} />\n              <div aria-hidden=\"true\" className=\"absolute\" style={{ left: -W / 2 + 4, top: -H / 2 + 8, width: W, height: H, borderRadius: 16, background: \"rgba(40,30,12,0.55)\", filter: \"blur(9px)\", transform: \"translateZ(-24px)\" }} />\n              {/* the thickness of the board: raw edge under a painted face */}\n              {[11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1].map((i) => (\n                <div key={i} aria-hidden=\"true\" className=\"absolute\" style={{ left: -W / 2, top: -H / 2, width: W, height: H, borderRadius: 14, background: i > 9 ? \"#a39a88\" : i % 2 ? \"#d9d2c3\" : \"#cdc5b4\", transform: `translateZ(${-i * 2}px)` }} />\n              ))}\n              <div className=\"absolute overflow-hidden\" style={{ left: -W / 2, top: -H / 2, width: W, height: H, borderRadius: 14 }}>\n                <Face look={cur} />\n                {/* the new coat, let out from where the bead landed */}\n                <div ref={coatRef} className=\"absolute inset-0\" style={{ clipPath: \"circle(0px at 0px 0px)\" }}>\n                  <Face look={next} hidden />\n                </div>\n                {/* the thick wet lip at the edge of the coat */}\n                <div ref={rimBoxRef} aria-hidden=\"true\" className=\"pointer-events-none absolute overflow-hidden\">\n                  <div ref={wetRef} className=\"absolute\" style={{ width: W, height: H, opacity: 0, background: \"linear-gradient(100deg, rgba(255,255,255,0) 20%, rgba(255,255,255,0.34) 37%, rgba(255,255,255,0.04) 47%, rgba(255,255,255,0) 58%, rgba(255,255,255,0.14) 80%, rgba(255,255,255,0) 92%), linear-gradient(180deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0) 40%, rgba(0,0,0,0.10) 100%)\" }} />\n                  <svg ref={rimRef} className=\"absolute\" width={W} height={H} viewBox={`0 0 ${W} ${H}`} fill=\"none\" style={{ opacity: 0, overflow: \"visible\" }}>\n                    <path stroke=\"rgba(11,13,18,0.30)\" strokeWidth=\"7\" transform=\"translate(3 4)\" style={{ filter: \"blur(3px)\" }} />\n                    <path stroke=\"rgba(255,255,255,0.20)\" strokeWidth=\"16\" />\n                    <path stroke=\"rgba(255,255,255,0.78)\" strokeWidth=\"2.2\" />\n                  </svg>\n                </div>\n                <div ref={spotRef} aria-hidden=\"true\" className=\"pointer-events-none absolute h-[34px] w-[34px] rounded-full\" style={{ opacity: 0, transform: \"translate(-50%, -50%)\", background: \"radial-gradient(circle, rgba(11,13,18,0.75) 0%, rgba(11,13,18,0) 68%)\" }} />\n                {/* lacquer: one broad band of studio light and a hard top edge */}\n                <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\" style={{ background: \"linear-gradient(104deg, rgba(255,255,255,0) calc(var(--gx) - 30%), rgba(255,255,255,0.13) calc(var(--gx) - 6%), rgba(255,255,255,0.03) calc(var(--gx) + 4%), rgba(255,255,255,0) calc(var(--gx) + 26%))\" }} />\n                <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\" style={{ borderRadius: 14, boxShadow: \"inset 0 1.5px 0 rgba(255,255,255,0.8), inset 1.5px 0 0 rgba(255,255,255,0.45), inset 0 -2px 0 rgba(11,13,18,0.14), inset -2px 0 0 rgba(11,13,18,0.10)\" }} />\n              </div>\n            </div>\n          </div>\n        </div>\n\n        {/* say it yourself */}\n        <div className=\"relative z-30 mt-6 flex flex-wrap items-center justify-center gap-2 sm:mt-8\">\n          {chips.map((c) => (\n            <button\n              key={c.part}\n              type=\"button\"\n              onClick={() => api.current?.say(c.part)}\n              aria-label={plan(cur, c.part).say}\n              className=\"inline-flex h-11 items-center gap-2 rounded-full border border-[#0B0D12]/10 bg-white px-5 text-[13px] font-extrabold tracking-[-0.01em] text-[#0B0D12] shadow-[0_1px_0_rgba(255,255,255,0.9)_inset,0_6px_14px_-8px_rgba(11,13,18,0.35)] transition hover:-translate-y-px hover:border-[#0B0D12]/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#4F98FB] focus-visible:ring-offset-2 focus-visible:ring-offset-[#F6F4EF] active:translate-y-0\"\n            >\n              <span aria-hidden=\"true\" className=\"h-[10px] w-[10px] rounded-full\" style={{ background: plan(cur, c.part).paint, boxShadow: \"inset 0 0 0 1px rgba(11,13,18,0.18)\" }} />\n              {c.label}\n            </button>\n          ))}\n        </div>\n        <p aria-live=\"polite\" className=\"sr-only\">\n          {status}\n        </p>\n      </div>\n      <style>{`\n        @keyframes edit-sentence-paint-bead-caret-blink { 0%, 55% { opacity: 1 } 56%, 100% { opacity: 0 } }\n        .edit-sentence-paint-bead-caret { animation: edit-sentence-paint-bead-caret-blink 1.1s steps(1) infinite; }\n        @media (prefers-reduced-motion: reduce) { .edit-sentence-paint-bead-caret { animation: none; } }\n      `}</style>\n    </section>\n  );\n}\n"}]}
