{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bg-grain-gradient",
  "type": "registry:component",
  "title": "Grain Gradient",
  "description": "Warm color fields that drift and blend under a heavy, tactile grain with soft mottling, like a risograph print. The grain can flicker like film or stay still.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "overlay",
    "background",
    "grain",
    "noise",
    "gradient",
    "css",
    "editorial"
  ],
  "docs": "https://hyperblur.dev/effects/bg-grain-gradient",
  "files": [
    {
      "path": "registry/hyperblur/bg-grain-gradient.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/bg-grain-gradient.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface BgGrainGradientProps extends React.HTMLAttributes<HTMLDivElement> {\n  colors?: string[];\n  background?: string;\n  grain?: number;\n  animateGrain?: boolean;\n  speed?: number;\n  children?: React.ReactNode;\n}\n\nconst css = `\n.hb-vd6 { position: absolute; inset: 0; overflow: hidden; pointer-events: none; box-sizing: border-box; background: var(--hb-vd6-bg); isolation: isolate; }\n.hb-vd6 *, .hb-vd6 *::before, .hb-vd6 *::after { box-sizing: border-box; }\n.hb-vd6-field { position: absolute; inset: -12%; filter: blur(34px) saturate(1.15); }\n.hb-vd6-blob { position: absolute; width: var(--s); aspect-ratio: 1; left: var(--x); top: var(--y); border-radius: 50%; background: radial-gradient(circle at 50% 50%, var(--c) 0%, color-mix(in srgb, var(--c) 55%, transparent) 38%, transparent 68%); mix-blend-mode: screen; animation: hb-vd6-drift calc(var(--d) * var(--hb-vd6-k)) cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite; animation-delay: var(--dl); }\n.hb-vd6-floor { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 40%, color-mix(in srgb, var(--hb-vd6-bg) 70%, transparent) 100%), radial-gradient(90% 60% at 50% 0%, rgba(255,255,255,0.08), transparent 70%); }\n.hb-vd6-grain { position: absolute; inset: -60px; width: calc(100% + 120px); height: calc(100% + 120px); display: block; mix-blend-mode: overlay; }\n.hb-vd6-grain.hb-vd6-live { animation: hb-vd6-jitter 0.9s steps(6) infinite; }\n.hb-vd6-dust { position: absolute; inset: -60px; width: calc(100% + 120px); height: calc(100% + 120px); display: block; mix-blend-mode: soft-light; }\n.hb-vd6-in { position: relative; z-index: 1; width: 100%; height: 100%; pointer-events: auto; font-family: inherit; }\n@keyframes hb-vd6-drift {\n  0% { transform: translate(0, 0) scale(1); }\n  33% { transform: translate(var(--x1), var(--y1)) scale(1.18); }\n  66% { transform: translate(var(--x2), var(--y2)) scale(0.88); }\n  100% { transform: translate(0, 0) scale(1); }\n}\n@keyframes hb-vd6-jitter {\n  0% { transform: translate(0, 0); }\n  20% { transform: translate(-23px, 11px); }\n  40% { transform: translate(17px, -29px); }\n  60% { transform: translate(-9px, 31px); }\n  80% { transform: translate(29px, 7px); }\n  100% { transform: translate(0, 0); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-vd6-blob, .hb-vd6-grain.hb-vd6-live { animation: none; }\n}\n`;\n\nconst defaultColors = [\"#ff6a3d\", \"#2f7bff\", \"#ffb38a\", \"#2a1f8f\"];\n\nfunction hash(i: number) {\n  let x = Math.imul(i ^ 0x1f83d9ab, 0x5be0cd19);\n  x ^= x >>> 14;\n  x = Math.imul(x, 0x9b05688c);\n  x ^= x >>> 15;\n  return (x >>> 0) / 4294967296;\n}\n\nexport function BgGrainGradient({\n  colors = defaultColors,\n  background = \"#0b0a10\",\n  grain = 0.42,\n  animateGrain = true,\n  speed = 1,\n  children,\n  className = \"\",\n  style,\n  ...rest\n}: BgGrainGradientProps) {\n  const rawId = React.useId();\n  const id = `hb-vd6-${rawId.replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  const palette = colors.length ? colors : defaultColors;\n  const spots = [\n    [-8, -18],\n    [48, -10],\n    [8, 38],\n    [52, 44],\n    [24, 12],\n    [70, 18],\n  ];\n  const blobs = palette.slice(0, 6).map((c, i) => ({\n    c,\n    x: spots[i][0] + (hash(i * 8 + 1) - 0.5) * 10,\n    y: spots[i][1] + (hash(i * 8 + 2) - 0.5) * 10,\n    s: 62 + 26 * hash(i * 8 + 3),\n    x1: (hash(i * 8 + 4) - 0.5) * 36,\n    y1: (hash(i * 8 + 5) - 0.5) * 30,\n    x2: (hash(i * 8 + 6) - 0.5) * 36,\n    y2: (hash(i * 8 + 7) - 0.5) * 30,\n    d: 18 + 10 * hash(i * 8 + 8),\n    dl: -hash(i * 8 + 9) * 24,\n  }));\n  const g = Math.max(0, Math.min(1, grain));\n\n  return (\n    <div\n      className={`hb-vd6 ${className}`}\n      style={{ \"--hb-vd6-bg\": background, \"--hb-vd6-k\": (1 / Math.max(0.05, speed)).toFixed(3), ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-bg-grain-gradient\" precedence=\"default\">{css}</style>\n      <div className=\"hb-vd6-field\" aria-hidden=\"true\">\n        {blobs.map((b, i) => (\n          <span\n            key={i}\n            className=\"hb-vd6-blob\"\n            style={\n              {\n                \"--c\": b.c,\n                \"--x\": `${b.x.toFixed(2)}%`,\n                \"--y\": `${b.y.toFixed(2)}%`,\n                \"--s\": `${b.s.toFixed(2)}%`,\n                \"--x1\": `${b.x1.toFixed(2)}%`,\n                \"--y1\": `${b.y1.toFixed(2)}%`,\n                \"--x2\": `${b.x2.toFixed(2)}%`,\n                \"--y2\": `${b.y2.toFixed(2)}%`,\n                \"--d\": `${b.d.toFixed(2)}s`,\n                \"--dl\": `${b.dl.toFixed(2)}s`,\n              } as React.CSSProperties\n            }\n          />\n        ))}\n      </div>\n      <div className=\"hb-vd6-floor\" aria-hidden=\"true\" />\n      {g > 0 ? (\n        <>\n          <svg className={`hb-vd6-grain${animateGrain ? \" hb-vd6-live\" : \"\"}`} style={{ opacity: g }} aria-hidden=\"true\">\n            <filter id={`${id}-n`} x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">\n              <feTurbulence type=\"fractalNoise\" baseFrequency=\"1.15\" numOctaves=\"3\" stitchTiles=\"stitch\" />\n              <feColorMatrix type=\"saturate\" values=\"0\" />\n              <feComponentTransfer>\n                <feFuncR type=\"linear\" slope=\"1.9\" intercept=\"-0.45\" />\n                <feFuncG type=\"linear\" slope=\"1.9\" intercept=\"-0.45\" />\n                <feFuncB type=\"linear\" slope=\"1.9\" intercept=\"-0.45\" />\n              </feComponentTransfer>\n            </filter>\n            <rect width=\"100%\" height=\"100%\" filter={`url(#${id}-n)`} />\n          </svg>\n          <svg className=\"hb-vd6-dust\" style={{ opacity: g * 0.7 }} aria-hidden=\"true\">\n            <filter id={`${id}-d`} x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">\n              <feTurbulence type=\"turbulence\" baseFrequency=\"0.012 0.02\" numOctaves=\"2\" seed=\"7\" />\n              <feColorMatrix type=\"saturate\" values=\"0\" />\n            </filter>\n            <rect width=\"100%\" height=\"100%\" filter={`url(#${id}-d)`} />\n          </svg>\n        </>\n      ) : null}\n      {children ? <div className=\"hb-vd6-in\">{children}</div> : null}\n    </div>\n  );\n}\n"
    }
  ]
}