{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"deep-sea-teal-mesh-gradient-background","type":"registry:block","title":"Deep Sea Teal Mesh Gradient","description":"","dependencies":[],"files":[{"path":"components/we-inc/deep-sea-teal-mesh-gradient-background.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\n// Colour pools that drift through the mesh. Each one is [r, g, b].\nconst POOLS = [\n  [9, 58, 72],\n  [18, 96, 98],\n  [36, 122, 114],\n  [6, 40, 60],\n  [52, 132, 124],\n  [4, 28, 44],\n];\n// Water colour between the pools.\nconst DEPTH = [3, 22, 32];\n// Bigger is slower.\nconst SLOWNESS = 9000;\n\nconst css = `\n.dsm-grain{background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23g%29'/%3E%3C/svg%3E\");mix-blend-mode:overlay;opacity:.28}\n`;\n\nexport default function DeepSeaTealMeshGradient() {\n  const rootRef = useRef<HTMLElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    const canvas = canvasRef.current;\n    const ctx = canvas?.getContext(\"2d\");\n    if (!root || !canvas || !ctx) return;\n    const still = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    // The mesh is drawn small and the browser stretches it smoothly, so a frame stays cheap.\n    const W = 120;\n    let H = 72;\n    let aspect = 1.6;\n    let img = ctx.createImageData(W, H);\n    let raf = 0;\n    let onScreen = true;\n    const start = performance.now() - 26000;\n    const pools = POOLS.map((col, i) => ({ col, fx: 0.7 + i * 0.23, fy: 0.9 + i * 0.17, px: i * 1.9, py: i * 2.7, r: 0.34 + (i % 3) * 0.08 }));\n\n    const draw = (now: number) => {\n      const t = (now - start) / SLOWNESS;\n      const pos = pools.map((p) => ({\n        x: (0.5 + 0.46 * Math.sin(t * p.fx + p.px)) * aspect,\n        y: 0.5 + 0.44 * Math.cos(t * p.fy + p.py),\n        k: 1 / (p.r * p.r),\n        col: p.col,\n      }));\n      const d = img.data;\n      let o = 0;\n      for (let y = 0; y < H; y++) {\n        const ny = y / (H - 1);\n        for (let x = 0; x < W; x++) {\n          const nx = (x / (W - 1)) * aspect;\n          let r = DEPTH[0] * 0.35, g = DEPTH[1] * 0.35, b = DEPTH[2] * 0.35, s = 0.35;\n          for (const p of pos) {\n            const dx = nx - p.x, dy = ny - p.y;\n            const w = Math.exp(-(dx * dx + dy * dy) * p.k);\n            r += p.col[0] * w; g += p.col[1] * w; b += p.col[2] * w; s += w;\n          }\n          // Darker toward the bottom, like looking down into deeper water.\n          const shade = 1 - ny * 0.35;\n          d[o] = (r / s) * shade; d[o + 1] = (g / s) * shade; d[o + 2] = (b / s) * shade; d[o + 3] = 255;\n          o += 4;\n        }\n      }\n      ctx.putImageData(img, 0, 0);\n    };\n\n    const loop = (now: number) => {\n      draw(now);\n      if (onScreen && !still) raf = requestAnimationFrame(loop);\n    };\n    const resize = () => {\n      const box = root.getBoundingClientRect();\n      aspect = Math.max(0.4, box.width / Math.max(1, box.height));\n      H = Math.max(24, Math.min(160, Math.round(W / aspect)));\n      canvas.width = W; canvas.height = H;\n      img = ctx.createImageData(W, H);\n      draw(performance.now());\n    };\n    const ro = new ResizeObserver(resize);\n    ro.observe(root);\n    const io = new IntersectionObserver(([e]) => {\n      onScreen = e.isIntersecting;\n      cancelAnimationFrame(raf);\n      if (onScreen && !still) raf = requestAnimationFrame(loop);\n    });\n    io.observe(root);\n    resize();\n    return () => { cancelAnimationFrame(raf); ro.disconnect(); io.disconnect(); };\n  }, []);\n\n  return (\n    <section ref={rootRef} className=\"dsm-root relative isolate flex min-h-[600px] items-center overflow-hidden bg-[#031620]\">\n      <style>{css}</style>\n      <canvas ref={canvasRef} aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 -z-10 h-full w-full\" />\n      <div aria-hidden=\"true\" className=\"dsm-grain pointer-events-none absolute inset-0 -z-10\" />\n      <div className=\"mx-auto w-full max-w-5xl px-6 py-24 sm:px-10\">\n        <p className=\"text-sm font-medium uppercase tracking-[0.2em] text-teal-100/80\">Kelpline Dive School</p>\n        <h1 className=\"mt-5 max-w-2xl text-4xl font-semibold leading-tight text-white sm:text-6xl\">Learn to breathe slowly at eighteen metres.</h1>\n        <p className=\"mt-6 max-w-xl text-lg leading-relaxed text-teal-50/85\">Small groups, warm wetsuits and an instructor who stays within arm's reach from the first giant stride to the last safety stop.</p>\n        <a href=\"#\" className=\"mt-10 inline-flex h-12 items-center rounded-full bg-[#e6f4f1] px-7 text-sm font-semibold text-[#06303a] transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-teal-200 focus-visible:ring-offset-2 focus-visible:ring-offset-[#04202a]\">Book a try dive</a>\n      </div>\n    </section>\n  );\n}\n"}]}
