{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "card-border-glow",
  "type": "registry:component",
  "title": "Card Border Glow",
  "description": "A card whose border lights up in the segment nearest the pointer, with a soft bloom spilling both outside and inside. While idle the glow slowly circles the border.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "components",
    "card",
    "border",
    "glow",
    "bloom",
    "pointer",
    "hover"
  ],
  "docs": "https://hyperblur.dev/effects/card-border-glow",
  "files": [
    {
      "path": "registry/hyperblur/card-border-glow.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/card-border-glow.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface CardBorderGlowProps extends React.HTMLAttributes<HTMLDivElement> {\n  accent?: string;\n  radius?: number;\n  borderWidth?: number;\n  arc?: number;\n  bloom?: number;\n  speed?: number;\n  idle?: boolean;\n}\n\nconst css = `\n.hb-qv2 {\n  --hb-qv2-acc: #2f7bff;\n  --hb-qv2-r: 18px;\n  --hb-qv2-bw: 1.5px;\n  --hb-qv2-w: 38deg;\n  --hb-qv2-bl: 14px;\n  --hb-qv2-a: 0deg;\n  --hb-qv2-i: 0.7;\n  position: relative;\n  display: block;\n  box-sizing: border-box;\n  width: 100%;\n  border-radius: var(--hb-qv2-r);\n  background: #111111;\n  color: #ededed;\n  font: inherit;\n  isolation: isolate;\n}\n.hb-qv2 *, .hb-qv2 *::before, .hb-qv2 *::after { box-sizing: border-box; }\n.hb-qv2-ring {\n  position: absolute;\n  inset: 0;\n  border-radius: inherit;\n  padding: var(--hb-qv2-bw);\n  pointer-events: none;\n  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);\n  -webkit-mask-composite: xor;\n  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);\n}\n.hb-qv2-ln {\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  border-radius: inherit;\n  pointer-events: none;\n}\n.hb-qv2-ln .hb-qv2-ring { background: rgba(255, 255, 255, 0.09); }\n.hb-qv2-hot {\n  background: conic-gradient(\n    from calc(var(--hb-qv2-a) - var(--hb-qv2-w)) at 50% 50%,\n    transparent 0deg,\n    color-mix(in srgb, var(--hb-qv2-acc) 40%, transparent) calc(var(--hb-qv2-w) * 0.55),\n    color-mix(in srgb, var(--hb-qv2-acc) 40%, #ffffff) var(--hb-qv2-w),\n    color-mix(in srgb, var(--hb-qv2-acc) 40%, transparent) calc(var(--hb-qv2-w) * 1.45),\n    transparent calc(var(--hb-qv2-w) * 2),\n    transparent 360deg\n  );\n}\n.hb-qv2-lt {\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  border-radius: inherit;\n  pointer-events: none;\n  opacity: var(--hb-qv2-i);\n}\n.hb-qv2-bl {\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  border-radius: inherit;\n  pointer-events: none;\n  opacity: calc(var(--hb-qv2-i) * 0.85);\n  filter: blur(var(--hb-qv2-bl));\n}\n.hb-qv2-bl .hb-qv2-ring { padding: calc(var(--hb-qv2-bw) + 2px); }\n.hb-qv2-in {\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  border-radius: inherit;\n  pointer-events: none;\n  opacity: calc(var(--hb-qv2-i) * 0.32);\n  background: conic-gradient(\n    from calc(var(--hb-qv2-a) - var(--hb-qv2-w) * 1.4) at 50% 50%,\n    transparent 0deg,\n    var(--hb-qv2-acc) calc(var(--hb-qv2-w) * 1.4),\n    transparent calc(var(--hb-qv2-w) * 2.8),\n    transparent 360deg\n  );\n  -webkit-mask-image: radial-gradient(ellipse farthest-side at 50% 50%, transparent 48%, #000 100%);\n  mask-image: radial-gradient(ellipse farthest-side at 50% 50%, transparent 48%, #000 100%);\n}\n.hb-qv2-c {\n  position: relative;\n  z-index: 1;\n  border-radius: inherit;\n}\n`;\n\nexport function CardBorderGlow({\n  accent = \"#2f7bff\",\n  radius = 18,\n  borderWidth = 1.5,\n  arc = 76,\n  bloom = 14,\n  speed = 9,\n  idle = true,\n  className = \"\",\n  style,\n  children,\n  onPointerEnter,\n  onPointerMove,\n  onPointerLeave,\n  ...rest\n}: CardBorderGlowProps) {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const wake = React.useRef<(() => void) | null>(null);\n  const sim = React.useRef({ a: 20, i: 0.7, ta: 20, ti: 0.7, active: false, visible: true, running: false, raf: 0, t0: 0 });\n\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const s = sim.current;\n    const reduced = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\n    function write() {\n      if (!el) return;\n      el.style.setProperty(\"--hb-qv2-a\", `${s.a.toFixed(2)}deg`);\n      el.style.setProperty(\"--hb-qv2-i\", s.i.toFixed(3));\n    }\n\n    function tick(ts: number) {\n      s.running = false;\n      if (!s.visible) return;\n      if (!s.active) {\n        s.ta = ((ts / 1000) * (360 / Math.max(1, speed)) + 20) % 360;\n        s.ti = idle ? 0.7 : 0.18;\n      }\n      const delta = ((s.ta - s.a + 540) % 360) - 180;\n      s.a = (s.a + delta * 0.12 + 360) % 360;\n      s.i += (s.ti - s.i) * 0.1;\n      write();\n      const settling = Math.abs(delta) > 0.1 || Math.abs(s.ti - s.i) > 0.002;\n      if ((idle && !reduced) || s.active || settling) {\n        s.running = true;\n        s.raf = requestAnimationFrame(tick);\n      }\n    }\n\n    function ensure() {\n      if (reduced) {\n        s.a = s.ta;\n        s.i = s.ti;\n        write();\n        return;\n      }\n      if (s.running || !s.visible) return;\n      s.running = true;\n      s.raf = requestAnimationFrame(tick);\n    }\n\n    wake.current = ensure;\n    ensure();\n\n    const io = new IntersectionObserver(([entry]) => {\n      s.visible = entry.isIntersecting;\n      if (s.visible) ensure();\n    });\n    io.observe(el);\n\n    return () => {\n      wake.current = null;\n      io.disconnect();\n      cancelAnimationFrame(s.raf);\n      s.running = false;\n    };\n  }, [idle, speed]);\n\n  function aim(e: React.PointerEvent<HTMLDivElement>) {\n    const el = ref.current;\n    if (!el) return;\n    const r = el.getBoundingClientRect();\n    const dx = e.clientX - (r.left + r.width / 2);\n    const dy = e.clientY - (r.top + r.height / 2);\n    const s = sim.current;\n    s.active = true;\n    s.ti = 1;\n    s.ta = ((Math.atan2(dx, -dy) * 180) / Math.PI + 360) % 360;\n    wake.current?.();\n  }\n\n  const vars = {\n    \"--hb-qv2-acc\": accent,\n    \"--hb-qv2-r\": `${radius}px`,\n    \"--hb-qv2-bw\": `${borderWidth}px`,\n    \"--hb-qv2-w\": `${(arc / 2).toFixed(2)}deg`,\n    \"--hb-qv2-bl\": `${bloom}px`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-card-border-glow\" precedence=\"default\">{css}</style>\n      <div\n        ref={ref}\n        className={`hb-qv2 ${className}`}\n        style={vars}\n        onPointerEnter={(e) => {\n          onPointerEnter?.(e);\n          aim(e);\n        }}\n        onPointerMove={(e) => {\n          onPointerMove?.(e);\n          aim(e);\n        }}\n        onPointerLeave={(e) => {\n          onPointerLeave?.(e);\n          const s = sim.current;\n          s.active = false;\n          s.ti = idle ? 0.7 : 0.18;\n          wake.current?.();\n        }}\n        {...rest}\n      >\n        <span className=\"hb-qv2-ln\" aria-hidden=\"true\">\n          <span className=\"hb-qv2-ring\" />\n        </span>\n        <span className=\"hb-qv2-bl\" aria-hidden=\"true\">\n          <span className=\"hb-qv2-ring hb-qv2-hot\" />\n        </span>\n        <span className=\"hb-qv2-in\" aria-hidden=\"true\" />\n        <span className=\"hb-qv2-lt\" aria-hidden=\"true\">\n          <span className=\"hb-qv2-ring hb-qv2-hot\" />\n        </span>\n        <div className=\"hb-qv2-c\">{children}</div>\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}