{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"click-ripples-on-still-dark-water-canvas-background","type":"registry:block","title":"Click Ripples on Still Dark Water","description":"","dependencies":[],"files":[{"path":"components/we-inc/click-ripples-on-still-dark-water-canvas-background.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\n// Rings spread across dark, still water wherever you click or tap, seen at a low angle so\n// each ring is a flattened ellipse. A drop also falls on its own every so often, so the water\n// is never empty. Change these: ring colour (rgb), ring speed (px per second), lifetime, drop rate.\nconst RING = \"206,226,224\";\nconst SPEED = 70;\nconst LIFE = 6;\nconst DROP_EVERY = 1.8; // seconds between automatic drops\nconst TILT = 0.38; // ellipse height compared with width\n\nexport default function ClickRipplesOnStillWater() {\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  useEffect(() => {\n    const canvas = canvasRef.current;\n    const ctx = canvas?.getContext(\"2d\");\n    if (!canvas || !ctx) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    let w = 0;\n    let h = 0;\n    let raf = 0;\n    let onScreen = true;\n    const born = performance.now();\n    const cleanups: (() => void)[] = [];\n    const drops: number[][] = [[0.72, 0.62, 6.4], [0.3, 0.8, 8.2], [0.88, 0.86, 9.6]];\n    let nextDrop = 10.4;\n    let seed = 7;\n    const rand = () => {\n      seed = (seed * 16807) % 2147483647;\n      return seed / 2147483647;\n    };\n    const draw = (t: number) => {\n      ctx.clearRect(0, 0, w, h);\n      while (!reduce && t > nextDrop) {\n        drops.push([0.1 + rand() * 0.85, 0.5 + rand() * 0.45, nextDrop]);\n        nextDrop += DROP_EVERY * (0.6 + rand() * 0.8);\n      }\n      while (drops.length && t - drops[0][2] > LIFE) drops.shift();\n      for (const [fx, fy, born] of drops) {\n        const age = Math.max(0, t - born);\n        const fade = Math.pow(1 - age / LIFE, 2);\n        for (let k = 0; k < 4; k++) {\n          const r = age * SPEED - k * (10 + age * 5);\n          if (r <= 4) continue;\n          const a = fade * (0.42 - k * 0.09);\n          ctx.beginPath();\n          ctx.ellipse(fx * w, fy * h, r, r * TILT, 0, 0, Math.PI * 2);\n          ctx.strokeStyle = \"rgba(\" + RING + \",\" + a * 0.18 + \")\";\n          ctx.lineWidth = 7;\n          ctx.stroke();\n          ctx.strokeStyle = \"rgba(\" + RING + \",\" + a + \")\";\n          ctx.lineWidth = 1.1 - k * 0.15;\n          ctx.stroke();\n          ctx.beginPath();\n          ctx.ellipse(fx * w, fy * h + 2, r - 3, (r - 3) * TILT, 0, 0, Math.PI);\n          ctx.strokeStyle = \"rgba(4,10,14,\" + a * 0.9 + \")\";\n          ctx.lineWidth = 1.6;\n          ctx.stroke();\n        }\n      }\n    };\n    const now = () => 12 + (performance.now() - born) / 1000;\n    const frame = () => {\n      raf = 0;\n      draw(now());\n      if (onScreen && !reduce) raf = requestAnimationFrame(frame);\n    };\n    const resize = () => {\n      const r = canvas.getBoundingClientRect();\n      const dpr = Math.min(window.devicePixelRatio || 1, 1.5);\n      w = r.width;\n      h = r.height;\n      canvas.width = Math.max(1, Math.round(w * dpr));\n      canvas.height = Math.max(1, Math.round(h * dpr));\n      ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n      draw(reduce ? 12 : now());\n    };\n    const ro = new ResizeObserver(resize);\n    ro.observe(canvas);\n    resize();\n    const io = new IntersectionObserver((entries) => {\n      onScreen = entries[0].isIntersecting;\n      if (onScreen && !reduce && !raf) raf = requestAnimationFrame(frame);\n    });\n    io.observe(canvas);\n    const host = canvas.parentElement?.parentElement as HTMLElement;\n    const onDown = (e: PointerEvent) => {\n      if ((e.target as HTMLElement).closest(\"a, button\")) return;\n      const r = canvas.getBoundingClientRect();\n      drops.push([(e.clientX - r.left) / r.width, (e.clientY - r.top) / r.height, now()]);\n      if (reduce) draw(now());\n    };\n    host.addEventListener(\"pointerdown\", onDown);\n    cleanups.push(() => host.removeEventListener(\"pointerdown\", onDown));\n    return () => {\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n      cleanups.forEach((c) => c());\n    };\n  }, []);\n  return (\n    <section className=\"relative isolate min-h-[640px] cursor-crosshair overflow-hidden bg-[#121e24]\">\n      <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 -z-10\">\n        <div className=\"absolute inset-0 [background:linear-gradient(180deg,#0e171c_0%,#16262d_55%,#1d323a_100%)]\" />\n        <div className=\"absolute inset-x-0 top-[35%] h-[45%] [background:radial-gradient(60%_50%_at_65%_50%,rgba(120,160,165,.12),transparent)]\" />\n        <div className=\"absolute inset-x-0 bottom-0 h-[60%] [background:repeating-linear-gradient(180deg,transparent_0_13px,rgba(170,205,205,.035)_13px_14px)] [mask-image:linear-gradient(180deg,transparent,#000)]\" />\n        <canvas ref={canvasRef} aria-hidden=\"true\" className=\"absolute inset-0 h-full w-full\" />\n      </div>\n      <div className=\"mx-auto max-w-5xl px-6 pb-60 pt-20 sm:pt-28\">\n        <p className=\"text-sm font-medium uppercase tracking-[0.2em] text-[#9fc2c2]\">Stillwater Float Studio</p>\n        <h1 className=\"mt-4 max-w-xl cursor-auto text-4xl font-semibold leading-[1.08] tracking-tight text-[#eef4f3] sm:text-6xl\">Float for an hour. Leave the week behind.</h1>\n        <p className=\"mt-5 max-w-lg cursor-auto text-lg leading-relaxed text-[#b3c4c4]\">Warm salt-water pods in private rooms, with a quiet tea bar for afterwards.</p>\n        <div className=\"mt-8 flex flex-wrap items-center gap-5\">\n          <a href=\"#\" className=\"inline-flex h-12 items-center rounded-full bg-[#dbe9e7] px-7 text-sm font-semibold text-[#121e24] transition hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#9fc2c2] focus-visible:ring-offset-2 focus-visible:ring-offset-[#121e24]\">Book a first float</a>\n          <span aria-hidden=\"true\" className=\"text-sm text-[#8fa9aa]\">Tap the water</span>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
