{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"word-stamped-into-wet-concrete-that-cures-pale-takes-finger-marks-and-is-trowelled-smooth-for-a-new-word","type":"registry:component","title":"Word Stamped Into Wet Concrete That Cures Pale, Takes Finger Marks and Is Trowelled Smooth for a New Word","description":"Text effect with a word stamped into wet concrete: it cures pale, takes finger marks and can be trowelled smooth. Free React and HTML code.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/word-stamped-into-wet-concrete-that-cures-pale-takes-finger-marks-and-is-trowelled-smooth-for-a-new-word.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** The word in the slab when the page loads. */\nconst START_WORD = \"SOLID\";\n/** Longest word the field accepts. */\nconst MAX_LETTERS = 8;\n/** How dry the slab is on load, from 0 (just poured) to 1 (cured). */\nconst CURE_START = 0.5;\n/** Seconds from poured to fully cured. */\nconst CURE_SECONDS = 34;\n/** Concrete colours as red, green, blue: wet, then cured. */\nconst WET: [number, number, number] = [64, 66, 68];\nconst DRY: [number, number, number] = [204, 198, 185];\n/** The ground around the formwork. */\nconst GROUND = \"#1d1b18\";\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\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\nconst ease = (t: number) => (t <= 0 ? 0 : t >= 1 ? 1 : t * t * (3 - 2 * t));\n\nexport default function WetConcreteStampedWord() {\n  const reduce = useReducedMotion();\n  const [word, setWord] = useState(START_WORD);\n  const [pour, setPour] = useState(0);\n  const [status, setStatus] = useState<\"wet\" | \"cured\" | \"working\">(reduce ? \"cured\" : \"wet\");\n  const slab = useRef<HTMLDivElement>(null);\n  const wetCv = useRef<HTMLCanvasElement>(null);\n  const dryCv = useRef<HTMLCanvasElement>(null);\n  const trowel = useRef<HTMLDivElement>(null);\n  const block = useRef<HTMLDivElement>(null);\n  const glint = useRef<HTMLDivElement>(null);\n  const first = useRef(true);\n  const cured = useRef(CURE_START);\n\n  useEffect(() => {\n    const el = slab.current, wc = wetCv.current, dc = dryCv.current;\n    if (!el || !wc || !dc) return;\n    const wctx = wc.getContext(\"2d\"), dctx = dc.getContext(\"2d\");\n    if (!wctx || !dctx) return;\n    const initial = first.current;\n    first.current = false;\n\n    let W = 0, Hh = 0, u = 1;\n    let base = new Float32Array(0), grain = new Float32Array(0), patch = new Float32Array(0), fleck = new Float32Array(0);\n    let inner = new Float32Array(0), lip = new Float32Array(0), scr = new Float32Array(0), H = new Float32Array(0);\n    let stamp = new Uint8Array(0);\n    let wetImg: ImageData | null = null, dryImg: ImageData | null = null;\n    let boxes: Array<[number, number, number, number]> = [];\n\n    // Light comes low from the top left, so pressed letters fill with shadow on that side.\n    const lx = -0.62, ly = -0.66, lz = 0.42;\n    const hl = Math.hypot(lx, ly, lz + 1);\n    const hx = lx / hl, hy = ly / hl, hz = (lz + 1) / hl;\n\n    const level = (x0: number, y0: number, x1: number, y1: number) => {\n      for (let y = y0; y < y1; y++) {\n        for (let x = x0; x < x1; x++) {\n          const i = y * W + x;\n          let v = base[i];\n          if (stamp[i]) {\n            const e = inner[i];\n            v += -13 * u * ease((e - 0.2) / 0.6) + 2.4 * u * lip[i] * (1 - e) + (patch[i] - 0.5) * 2 * u * e;\n          }\n          const s = scr[i];\n          if (s > 0) v += (-5.5 * s * s * s + 2.6 * s * (1 - s)) * u;\n          H[i] = v;\n        }\n      }\n    };\n    const shade = (ax0: number, ay0: number, ax1: number, ay1: number) => {\n      if (!wetImg || !dryImg) return;\n      const x0 = Math.max(1, Math.floor(ax0)), y0 = Math.max(1, Math.floor(ay0));\n      const x1 = Math.min(W - 1, Math.ceil(ax1)), y1 = Math.min(Hh - 1, Math.ceil(ay1));\n      if (x1 <= x0 || y1 <= y0) return;\n      const wd = wetImg.data, dd = dryImg.data;\n      const reach = Math.round(5 * u) * W + Math.round(4.5 * u);\n      for (let y = y0; y < y1; y++) {\n        const sky = 1 - y / Hh;\n        for (let x = x0; x < x1; x++) {\n          const i = y * W + x;\n          let nx = -(H[i + 1] - H[i - 1]) * 0.75;\n          let ny = -(H[i + W] - H[i - W]) * 0.75;\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 s = scr[i];\n          const floor = stamp[i] ? ease((inner[i] - 0.2) / 0.6) : 0;\n          // The wall nearest the lamp throws its shadow across the floor of each letter.\n          const cast = floor > 0 && i > reach * 3 ? floor * (1 - (ease((inner[i - reach] - 0.2) / 0.6) + ease((inner[i - reach * 2] - 0.2) / 0.6) + ease((inner[i - reach * 3] - 0.2) / 0.6)) / 3) : 0;\n          const sunk = Math.min(1, Math.max(floor * 0.3 + cast * 0.95, s * s * 0.55));\n          const o = i * 4;\n          // Cured: matt, pale, speckled with sand and the odd dark stone.\n          const stone = fleck[i] > 0.83 ? -26 * (fleck[i] - 0.83) * 6 : 0;\n          const dl = (0.3 + 1.63 * diff) * (1 - 0.5 * sunk);\n          const dn = grain[i] * 9 + (patch[i] - 0.5) * 20 + stone;\n          dd[o] = Math.min(255, Math.max(0, DRY[0] * dl + dn));\n          dd[o + 1] = Math.min(255, Math.max(0, DRY[1] * dl + dn));\n          dd[o + 2] = Math.min(255, Math.max(0, DRY[2] * dl + dn * 0.9));\n          dd[o + 3] = 255;\n          // Wet: dark, with a hard sheen and a little sky in every surface that faces up.\n          const wl = (0.28 + 1.37 * diff) * (1 - 0.62 * sunk);\n          const spec = Math.pow(nh, 22) * 0.3 + Math.pow(nz, 12) * (0.05 + 0.13 * sky);\n          const wn = grain[i] * 5 + (patch[i] - 0.5) * 16;\n          wd[o] = Math.min(255, Math.max(0, WET[0] * wl + 235 * spec + wn));\n          wd[o + 1] = Math.min(255, Math.max(0, WET[1] * wl + 242 * spec + wn));\n          wd[o + 2] = Math.min(255, Math.max(0, WET[2] * wl + 255 * spec + wn));\n          wd[o + 3] = 255;\n        }\n      }\n      wctx.putImageData(wetImg, 0, 0, x0, y0, x1 - x0, y1 - y0);\n      dctx.putImageData(dryImg, 0, 0, x0, y0, x1 - x0, y1 - y0);\n    };\n    const rework = (x0: number, y0: number, x1: number, y1: number) => {\n      const a = Math.max(0, Math.floor(x0)), b = Math.max(0, Math.floor(y0));\n      const c = Math.min(W, Math.ceil(x1)), d = Math.min(Hh, Math.ceil(y1));\n      level(a, b, c, d);\n      shade(a - 1, b - 1, c + 1, d + 1);\n    };\n\n    /** Sizes the canvases, lays the trowelled surface and cuts the word. Returns true if the canvases were reset. */\n    const prepare = () => {\n      const cw = el.clientWidth, ch = el.clientHeight;\n      const nW = Math.max(240, Math.min(1280, Math.round(cw * Math.min(2, window.devicePixelRatio || 1))));\n      const nH = Math.max(160, Math.round((nW * ch) / cw));\n      const resized = nW !== wc.width || nH !== wc.height;\n      W = nW;\n      Hh = nH;\n      u = W / 1000;\n      if (resized) {\n        wc.width = dc.width = W;\n        wc.height = dc.height = Hh;\n      }\n      wetImg = wctx.createImageData(W, Hh);\n      dryImg = dctx.createImageData(W, Hh);\n      const rnd = random(90210);\n      const n = W * Hh;\n      grain = new Float32Array(n);\n      for (let i = 0; i < n; i++) grain[i] = rnd() * 2 - 1;\n      patch = blotches(W, Hh, Math.round(90 * u), rnd);\n      fleck = blotches(W, Hh, Math.max(2, Math.round(3 * u)), rnd);\n      const soft = blotches(W, Hh, Math.round(34 * u), rnd);\n      base = new Float32Array(n);\n      // The float leaves long overlapping arcs. Three sets, each from a centre well off the slab.\n      const arcs = [\n        [-0.3 * W, 1.6 * Hh, 13 * u],\n        [1.25 * W, 1.9 * Hh, 17 * u],\n        [0.4 * W, -1.5 * Hh, 22 * u],\n      ];\n      for (let y = 0; y < Hh; y++) {\n        for (let x = 0; x < W; x++) {\n          const i = y * W + x;\n          let v = (soft[i] - 0.5) * 0.75 * u;\n          for (let k = 0; k < 3; k++) {\n            const d = Math.hypot(x - arcs[k][0], y - arcs[k][1]);\n            v += Math.sin(d / arcs[k][2]) * 0.3 * u * (k === 0 ? patch[i] : 1 - patch[i] * 0.6);\n          }\n          base[i] = v;\n        }\n      }\n      // Air holes.\n      for (let k = 0; k < Math.round(n / 16000); k++) {\n        const px = Math.floor(rnd() * (W - 8)) + 4, py = Math.floor(rnd() * (Hh - 8)) + 4, r = (0.8 + rnd() * 1.2) * u, deep = (1.5 + rnd() * 2.5) * u;\n        for (let y = py - 4; y <= py + 4; y++) for (let x = px - 4; x <= px + 4; x++) base[y * W + x] -= deep * Math.exp(-((x - px) ** 2 + (y - py) ** 2) / (r * r));\n      }\n\n      // The word, set by hand: each stamp a little off line and a little turned.\n      const letters = word.split(\"\");\n      const rows = Hh / W > 0.8 && letters.length > 4 ? 2 : 1;\n      const perRow = Math.ceil(letters.length / rows);\n      const mc = document.createElement(\"canvas\");\n      mc.width = W;\n      mc.height = Hh;\n      const m = mc.getContext(\"2d\", { willReadFrequently: true });\n      boxes = [];\n      inner = new Float32Array(n);\n      lip = new Float32Array(n);\n      if (m && letters.length) {\n        const face = (px: number) => `900 ${px}px \"Arial Black\", \"Helvetica Neue\", Helvetica, Arial, sans-serif`;\n        m.font = face(100);\n        const widths = letters.map((c) => m.measureText(c).width);\n        const track = 7;\n        const rowW = (r: number) => widths.slice(r * perRow, (r + 1) * perRow).reduce((a, b) => a + b + track, -track);\n        const widest = Math.max(1, rowW(0), rows > 1 ? rowW(1) : 0);\n        const fs = Math.min(((W * 0.8) / widest) * 100, ((rows > 1 ? 0.3 : 0.52) * Hh) / 0.72);\n        const k = fs / 100;\n        m.font = face(fs);\n        m.fillStyle = \"#fff\";\n        m.textBaseline = \"alphabetic\";\n        m.textAlign = \"center\";\n        const lineH = fs * 0.92;\n        const jit = random(word.length * 131 + (word.charCodeAt(0) || 1) * 17);\n        for (let r = 0; r < rows; r++) {\n          let x = W / 2 - (rowW(r) * k) / 2;\n          const baseY = Hh * 0.5 + fs * 0.36 - ((rows - 1) * lineH) / 2 + r * lineH;\n          letters.slice(r * perRow, (r + 1) * perRow).forEach((c, j) => {\n            const wdt = widths[r * perRow + j] * k;\n            const cx = x + wdt / 2, cy = baseY - fs * 0.36 + (jit() - 0.5) * fs * 0.05;\n            m.save();\n            m.translate(cx, cy);\n            m.rotate((jit() - 0.5) * 0.07);\n            m.fillText(c, 0, fs * 0.36);\n            m.restore();\n            const mg = 16 * u;\n            boxes.push([cx - wdt / 2 - mg, cy - fs * 0.42 - mg, cx + wdt / 2 + mg, cy + fs * 0.42 + mg]);\n            x += wdt + track * k;\n          });\n        }\n        const px = m.getImageData(0, 0, W, Hh).data;\n        const hard = new Float32Array(n);\n        for (let i = 0; i < n; i++) hard[i] = px[i * 4 + 3] / 255;\n        inner = boxBlur(hard, W, Hh, Math.max(1, Math.round(1.6 * u)));\n        lip = boxBlur(hard, W, Hh, Math.max(2, Math.round(6 * u)));\n      }\n      scr = new Float32Array(n);\n      stamp = new Uint8Array(n);\n      H = new Float32Array(n);\n      return resized;\n    };\n    const everything = () => {\n      stamp.fill(1);\n      level(0, 0, W, Hh);\n      shade(0, 0, W, Hh);\n    };\n\n    let cure = reduce ? 1 : initial ? CURE_START : cured.current;\n    let shown = -1;\n    let said: \"wet\" | \"cured\" | \"working\" | \"\" = \"\";\n    const say = (s: \"wet\" | \"cured\" | \"working\") => {\n      if (s !== said) {\n        said = s;\n        setStatus(s);\n      }\n    };\n    const dry = (force?: boolean) => {\n      cured.current = cure;\n      if (!force && Math.abs(cure - shown) < 0.004) return;\n      shown = cure;\n      // It dries from the edges in, so the dry picture is revealed through a closing ring.\n      const edge = (1 - ease(cure)) * 118;\n      const core = Math.pow(cure, 3);\n      const mask = cure >= 1 ? \"none\" : `radial-gradient(125% 125% at 47% 56%, rgba(0,0,0,${core.toFixed(3)}) ${Math.max(0, edge - 34).toFixed(1)}%, #000 ${edge.toFixed(1)}%)`;\n      dc.style.setProperty(\"-webkit-mask-image\", mask);\n      dc.style.setProperty(\"mask-image\", mask);\n      dc.style.opacity = cure <= 0 ? \"0\" : \"1\";\n      if (glint.current) glint.current.style.opacity = String(Math.max(0, 1 - cure * 1.5));\n    };\n\n    // The job list: trowel across, then press each letter, then leave it to cure.\n    type Mode = \"idle\" | \"wipe\" | \"stamp\";\n    let mode: Mode = \"idle\";\n    let t = 0, wiped = 0, next = 0;\n    const WIPE = 1.5, GAP = 0.36;\n\n    const resized = prepare();\n    if (initial || reduce || resized) {\n      everything();\n      say(cure >= 1 ? \"cured\" : \"wet\");\n    } else {\n      mode = \"wipe\";\n      level(0, 0, W, Hh);\n      say(\"working\");\n    }\n    dry(true);\n\n    const press = (k: number) => {\n      const b = boxes[k];\n      if (!b) return;\n      const x0 = Math.max(0, Math.floor(b[0])), y0 = Math.max(0, Math.floor(b[1])), x1 = Math.min(W, Math.ceil(b[2])), y1 = Math.min(Hh, Math.ceil(b[3]));\n      for (let y = y0; y < y1; y++) stamp.fill(1, y * W + x0, y * W + x1);\n      rework(x0, y0, x1, y1);\n    };\n    const showBlock = (k: number) => {\n      const b = boxes[k], node = block.current;\n      if (!b || !node || !node.animate) return;\n      const s = el.clientWidth / W;\n      node.style.left = `${(b[0] + 8 * u) * s}px`;\n      node.style.top = `${(b[1] + 8 * u) * s}px`;\n      node.style.width = `${(b[2] - b[0] - 16 * u) * s}px`;\n      node.style.height = `${(b[3] - b[1] - 16 * u) * s}px`;\n      node.animate(\n        [\n          { opacity: 0, transform: \"scale(1.22) rotate(-2deg)\", boxShadow: \"30px 40px 40px rgba(0,0,0,0.35)\" },\n          { opacity: 1, transform: \"scale(1) rotate(0deg)\", boxShadow: \"2px 3px 4px rgba(0,0,0,0.6)\", offset: 0.38 },\n          { opacity: 1, transform: \"scale(1) rotate(0deg)\", boxShadow: \"2px 3px 4px rgba(0,0,0,0.6)\", offset: 0.55 },\n          { opacity: 0, transform: \"scale(1.26) rotate(1.5deg)\", boxShadow: \"34px 44px 44px rgba(0,0,0,0.3)\" },\n        ],\n        { duration: 520, easing: \"ease-in-out\" },\n      );\n    };\n\n    let raf = 0, last = 0, visible = true;\n    const loop = (now: number) => {\n      raf = requestAnimationFrame(loop);\n      const dt = Math.min(0.05, last ? (now - last) / 1000 : 0.016);\n      last = now;\n      if (mode === \"wipe\") {\n        t += dt;\n        // Fresh mix goes down dark, so the dry picture fades as the float starts across.\n        cure = Math.max(0, cure - dt * 2.4);\n        const p = ease(t / WIPE);\n        const x = -0.16 * W + p * 1.32 * W;\n        const upTo = Math.min(W, Math.max(0, Math.floor(x)));\n        if (upTo > wiped) {\n          level(wiped, 0, upTo, Hh);\n          shade(wiped - 1, 0, upTo, Hh);\n          wiped = upTo;\n        }\n        if (trowel.current) {\n          const s = el.clientWidth / W;\n          trowel.current.style.opacity = t < 0.12 ? String(t / 0.12) : t > WIPE - 0.15 ? String(Math.max(0, (WIPE - t) / 0.15)) : \"1\";\n          trowel.current.style.transform = `translate3d(${x * s}px, ${Math.sin(p * 3.1416) * -10}px, 0) rotate(${-7 + p * 5}deg)`;\n        }\n        if (t >= WIPE) {\n          mode = \"stamp\";\n          t = 0;\n          next = 0;\n          cure = 0;\n          if (trowel.current) trowel.current.style.opacity = \"0\";\n        }\n      } else if (mode === \"stamp\") {\n        t += dt;\n        while (next < boxes.length * 2 && t >= Math.floor(next / 2) * GAP + (next % 2 ? 0.2 : 0)) {\n          if (next % 2) press((next - 1) / 2);\n          else showBlock(next / 2);\n          next++;\n        }\n        if (next >= boxes.length * 2 && t > (boxes.length - 1) * GAP + 0.6) {\n          mode = \"idle\";\n          say(\"wet\");\n        }\n      } else if (cure < 1) {\n        cure = Math.min(1, cure + dt / CURE_SECONDS);\n        say(cure > 0.8 ? \"cured\" : \"wet\");\n      }\n      dry();\n    };\n    const wake = () => {\n      cancelAnimationFrame(raf);\n      raf = 0;\n      if (visible && !document.hidden && !reduce) {\n        last = 0;\n        raf = requestAnimationFrame(loop);\n      }\n    };\n\n    // A finger in wet concrete.\n    let drawing = false, px = 0, py = 0;\n    const at = (e: PointerEvent) => {\n      const r = el.getBoundingClientRect();\n      return [((e.clientX - r.left) / r.width) * W, ((e.clientY - r.top) / r.height) * Hh];\n    };\n    const drag = (x: number, y: number) => {\n      const r = 10 * u;\n      const pad = r * 2.6;\n      const x0 = Math.max(0, Math.floor(Math.min(px, x) - pad)), x1 = Math.min(W, Math.ceil(Math.max(px, x) + pad));\n      const y0 = Math.max(0, Math.floor(Math.min(py, y) - pad)), y1 = Math.min(Hh, Math.ceil(Math.max(py, y) + pad));\n      const dx = x - px, dy = y - py;\n      const len = dx * dx + dy * dy || 1;\n      for (let yy = y0; yy < y1; yy++) {\n        for (let xx = x0; xx < x1; xx++) {\n          // Distance from this pixel to the stroke just made.\n          const k = Math.min(1, Math.max(0, ((xx - px) * dx + (yy - py) * dy) / len));\n          const ox = xx - (px + dx * k), oy = yy - (py + dy * k);\n          const v = Math.exp(-(ox * ox + oy * oy) / (r * r));\n          const i = yy * W + xx;\n          if (v > 0.01 && v > scr[i]) scr[i] = v;\n        }\n      }\n      rework(x0, y0, x1, y1);\n      px = x;\n      py = y;\n    };\n    const down = (e: PointerEvent) => {\n      if (mode !== \"idle\" || cure > 0.8) return;\n      drawing = true;\n      [px, py] = at(e);\n      drag(px + 0.01, py);\n    };\n    const move = (e: PointerEvent) => {\n      if (!drawing) return;\n      const [x, y] = at(e);\n      drag(x, y);\n    };\n    const up = () => {\n      drawing = false;\n    };\n    el.addEventListener(\"pointerdown\", down);\n    el.addEventListener(\"pointermove\", move);\n    window.addEventListener(\"pointerup\", up);\n    el.addEventListener(\"pointercancel\", up);\n\n    let settle = 0;\n    const ro = new ResizeObserver(() => {\n      window.clearTimeout(settle);\n      settle = window.setTimeout(() => {\n        const cw = el.clientWidth;\n        const nW = Math.max(240, Math.min(1280, Math.round(cw * Math.min(2, window.devicePixelRatio || 1))));\n        const nH = Math.max(160, Math.round((nW * el.clientHeight) / cw));\n        if (nW === W && nH === Hh) return;\n        prepare();\n        mode = \"idle\";\n        if (trowel.current) trowel.current.style.opacity = \"0\";\n        everything();\n        dry(true);\n      }, 160);\n    });\n    ro.observe(el);\n    const io = new IntersectionObserver(([entry]) => {\n      visible = entry.isIntersecting;\n      wake();\n    });\n    io.observe(el);\n    document.addEventListener(\"visibilitychange\", wake);\n    wake();\n    return () => {\n      cancelAnimationFrame(raf);\n      window.clearTimeout(settle);\n      ro.disconnect();\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", wake);\n      el.removeEventListener(\"pointerdown\", down);\n      el.removeEventListener(\"pointermove\", move);\n      window.removeEventListener(\"pointerup\", up);\n      el.removeEventListener(\"pointercancel\", up);\n    };\n  }, [word, pour, reduce]);\n\n  const board = \"repeating-linear-gradient(90deg, rgba(92,58,22,0) 0px, rgba(92,58,22,0.13) 1px, rgba(92,58,22,0) 3px, rgba(92,58,22,0) 11px, rgba(92,58,22,0.09) 12px, rgba(92,58,22,0) 17px), linear-gradient(180deg, #e2c08c 0%, #cfa568 45%, #b98d52 100%)\";\n  const post = \"repeating-linear-gradient(0deg, rgba(92,58,22,0) 0px, rgba(92,58,22,0.13) 1px, rgba(92,58,22,0) 3px, rgba(92,58,22,0) 13px, rgba(92,58,22,0.09) 14px, rgba(92,58,22,0) 19px), linear-gradient(90deg, #dcb983 0%, #c99f62 50%, #b3874d 100%)\";\n\n  return (\n    <section className=\"relative isolate flex min-h-[680px] w-full flex-col items-center overflow-hidden px-4 pt-12 sm:px-8\" style={{ backgroundColor: GROUND }}>\n      <style>{`\n        @keyframes word-stamped-into-wet-concrete-glint { from { transform: translate3d(-70%, 0, 0); } to { transform: translate3d(70%, 0, 0); } }\n        .word-stamped-into-wet-concrete-glint { animation: word-stamped-into-wet-concrete-glint 9s ease-in-out infinite alternate; }\n        @media (prefers-reduced-motion: reduce) { .word-stamped-into-wet-concrete-glint { animation: none; opacity: 0; } }\n      `}</style>\n      <div aria-hidden=\"true\" className=\"absolute inset-0 -z-10\" style={{ background: \"radial-gradient(80% 60% at 35% 25%, rgba(255,240,215,0.1) 0%, rgba(255,240,215,0) 65%), linear-gradient(180deg, rgba(0,0,0,0) 60%, rgba(0,0,0,0.35) 100%)\" }} />\n\n      <h2 className=\"sr-only\">{word}</h2>\n\n      {/* Timber formwork round the pour. */}\n      <div className=\"relative w-full max-w-[1080px] p-[18px] sm:p-[22px]\" style={{ filter: \"drop-shadow(0 34px 30px rgba(0,0,0,0.55))\" }}>\n        <div aria-hidden=\"true\" className=\"absolute inset-y-0 left-0 w-[18px] rounded-[3px] sm:w-[22px]\" style={{ background: post, boxShadow: \"inset 1px 0 0 rgba(255,255,255,0.35), inset -1px 0 0 rgba(60,36,10,0.5)\" }} />\n        <div aria-hidden=\"true\" className=\"absolute inset-y-0 right-0 w-[18px] rounded-[3px] sm:w-[22px]\" style={{ background: post, boxShadow: \"inset 1px 0 0 rgba(255,255,255,0.35), inset -1px 0 0 rgba(60,36,10,0.5)\" }} />\n        <div aria-hidden=\"true\" className=\"absolute inset-x-[18px] top-0 h-[18px] sm:inset-x-[22px] sm:h-[22px]\" style={{ background: board, boxShadow: \"inset 0 1px 0 rgba(255,255,255,0.4), inset 0 -1px 0 rgba(60,36,10,0.5)\" }} />\n        <div aria-hidden=\"true\" className=\"absolute inset-x-[18px] bottom-0 h-[18px] sm:inset-x-[22px] sm:h-[22px]\" style={{ background: board, boxShadow: \"inset 0 1px 0 rgba(255,255,255,0.4), inset 0 -1px 0 rgba(60,36,10,0.5)\" }} />\n        {[\"left-[5px] top-[5px]\", \"right-[5px] top-[5px]\", \"left-[5px] bottom-[5px]\", \"right-[5px] bottom-[5px]\"].map((p) => (\n          <span key={p} aria-hidden=\"true\" className={`absolute ${p} h-[8px] w-[8px] rounded-full sm:h-[10px] sm:w-[10px]`} style={{ background: \"radial-gradient(circle at 35% 30%, #f1f3f4 0%, #8b9094 55%, #3d4144 100%)\", boxShadow: \"1px 1.5px 1.5px rgba(40,24,6,0.6)\" }} />\n        ))}\n\n        <div ref={slab} className=\"relative h-[450px] w-full touch-pan-y select-none overflow-hidden sm:h-[420px]\" style={{ backgroundColor: \"#5c5e5f\", cursor: status === \"wet\" ? \"crosshair\" : \"default\" }}>\n          <canvas ref={wetCv} aria-hidden=\"true\" className=\"absolute inset-0 h-full w-full\" />\n          <canvas ref={dryCv} aria-hidden=\"true\" className=\"absolute inset-0 h-full w-full\" />\n          <div ref={glint} aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 overflow-hidden\" style={{ mixBlendMode: \"screen\" }}>\n            <div className=\"word-stamped-into-wet-concrete-glint absolute inset-y-0 left-0 w-full\" style={{ background: \"linear-gradient(104deg, rgba(210,225,240,0) 34%, rgba(210,225,240,0.12) 44%, rgba(235,244,255,0.2) 50%, rgba(210,225,240,0.12) 56%, rgba(210,225,240,0) 66%)\" }} />\n          </div>\n          {/* The boards stand proud of the pour and shade its top and left edges. */}\n          <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\" style={{ boxShadow: \"inset 9px 10px 12px -4px rgba(0,0,0,0.55), inset -2px -2px 3px rgba(255,255,255,0.12)\" }} />\n          <div ref={block} aria-hidden=\"true\" className=\"pointer-events-none absolute rounded-[5px] opacity-0\" style={{ background: post }}>\n            <span className=\"absolute left-1/2 top-1/2 h-[34%] w-[26%] -translate-x-1/2 -translate-y-1/2 rounded-[4px]\" style={{ background: \"linear-gradient(135deg, #8a5a2b 0%, #5e3a17 100%)\", boxShadow: \"3px 5px 6px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.25)\" }} />\n          </div>\n          <div ref={trowel} aria-hidden=\"true\" className=\"pointer-events-none absolute left-[-120px] top-[9%] h-[82%] w-[120px] opacity-0\">\n            <div className=\"absolute inset-0 rounded-[7px]\" style={{ background: \"linear-gradient(90deg, #6f7679 0%, #dfe4e6 14%, #aeb5b8 40%, #eef1f2 62%, #8d9497 100%)\", boxShadow: \"16px 20px 22px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.35)\" }} />\n            <div className=\"absolute left-1/2 top-[18%] h-[64%] w-[30px] -translate-x-1/2 rounded-[14px]\" style={{ background: \"linear-gradient(90deg, #5a3413 0%, #a56a30 35%, #c98a48 50%, #8a5424 80%, #4d2c10 100%)\", boxShadow: \"8px 10px 10px rgba(0,0,0,0.4)\" }} />\n          </div>\n        </div>\n      </div>\n\n      <div className=\"relative mt-auto flex w-full max-w-[1080px] flex-wrap items-center justify-between gap-x-6 gap-y-3 pb-8 pt-7 text-[13px]\">\n        <p className=\"text-[#cfc9bf]\" aria-live=\"polite\">\n          <span className=\"font-semibold text-white\">Stamped concrete</span>\n          <span className=\"mx-2 opacity-50\">/</span>\n          {status === \"working\" ? \"floating it off and stamping\" : status === \"wet\" ? \"still wet, drag a finger through it\" : \"cured, pour again to change it\"}\n        </p>\n        <div className=\"flex items-center gap-2\">\n          <label htmlFor=\"word-stamped-into-wet-concrete-word\" className=\"sr-only\">\n            Word to stamp into the concrete\n          </label>\n          <input\n            id=\"word-stamped-into-wet-concrete-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-[6px] border border-white/25 bg-[#12110f] px-4 text-[14px] font-semibold tracking-[0.18em] text-white outline-none focus-visible:ring-2 focus-visible:ring-[#f2b632]\"\n          />\n          <button\n            type=\"button\"\n            onClick={() => setPour((n) => n + 1)}\n            className=\"h-11 shrink-0 rounded-[6px] bg-[#f2b632] px-5 font-semibold text-[#1d1b18] shadow-[0_10px_20px_-10px_rgba(0,0,0,0.8)] transition-transform hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#f2b632] focus-visible:ring-offset-2 focus-visible:ring-offset-[#1d1b18] motion-reduce:transition-none\"\n          >\n            Pour again\n          </button>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
