{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-spotlight",
  "type": "registry:component",
  "title": "Button Spotlight",
  "description": "A soft light follows the pointer across the face while the border brightens near the cursor. It drifts on its own until the pointer arrives.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "spotlight",
    "pointer",
    "glow",
    "hover",
    "cursor"
  ],
  "docs": "https://hyperblur.dev/effects/button-spotlight",
  "files": [
    {
      "path": "registry/hyperblur/button-spotlight.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-spotlight.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonSpotlightProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"color\"> {\n  variant?: \"solid\" | \"outline\";\n  accent?: string;\n  size?: \"sm\" | \"md\" | \"lg\";\n  loading?: boolean;\n}\n\nconst css = `\n.hb-qa1 {\n  --hb-qa1-c: #2f7bff;\n  --hb-qa1-x: 50%;\n  --hb-qa1-y: 50%;\n  --hb-qa1-i: 0.55;\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  gap: 0.6em;\n  box-sizing: border-box;\n  margin: 0;\n  padding: 0.8em 1.6em;\n  font: inherit;\n  font-size: 15px;\n  font-weight: 600;\n  line-height: 1.2;\n  color: #ededed;\n  background: #141414;\n  border: 0;\n  border-radius: 12px;\n  box-shadow: inset 0 0 0 1px #262626;\n  cursor: pointer;\n  isolation: isolate;\n  overflow: hidden;\n  user-select: none;\n  -webkit-tap-highlight-color: transparent;\n  touch-action: manipulation;\n  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s ease;\n}\n.hb-qa1[data-size=\"sm\"] { font-size: 13px; }\n.hb-qa1[data-size=\"lg\"] { font-size: 17px; }\n.hb-qa1[data-variant=\"outline\"] { background: transparent; box-shadow: inset 0 0 0 1px #333; }\n.hb-qa1-glow {\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  pointer-events: none;\n  opacity: var(--hb-qa1-i);\n  background: radial-gradient(150px circle at var(--hb-qa1-x) var(--hb-qa1-y), color-mix(in srgb, var(--hb-qa1-c) 42%, transparent), transparent 72%);\n}\n.hb-qa1-edge {\n  position: absolute;\n  inset: 0;\n  z-index: 1;\n  padding: 1px;\n  border-radius: inherit;\n  pointer-events: none;\n  opacity: var(--hb-qa1-i);\n  background: radial-gradient(110px circle at var(--hb-qa1-x) var(--hb-qa1-y), color-mix(in srgb, var(--hb-qa1-c) 35%, #ffffff), transparent 70%);\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-qa1-t { position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 0.6em; white-space: nowrap; }\n.hb-qa1:active:not(:disabled) { transform: scale(0.97); }\n.hb-qa1:focus-visible { outline: 2px solid var(--hb-qa1-c); outline-offset: 3px; }\n.hb-qa1:disabled { cursor: not-allowed; }\n.hb-qa1:disabled:not([aria-busy=\"true\"]) { opacity: 0.45; }\n.hb-qa1-sp {\n  width: 1em;\n  height: 1em;\n  flex: none;\n  border: 2px solid currentColor;\n  border-right-color: transparent;\n  border-radius: 50%;\n  animation: hb-qa1-spin 0.7s linear infinite;\n}\n@keyframes hb-qa1-spin { to { transform: rotate(360deg); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-qa1 { transition: none; }\n  .hb-qa1:active:not(:disabled) { transform: none; }\n  .hb-qa1-sp { animation-duration: 1.6s; }\n}\n`;\n\nexport function ButtonSpotlight({\n  children = \"Start building\",\n  variant = \"solid\",\n  accent = \"#2f7bff\",\n  size = \"md\",\n  loading = false,\n  disabled = false,\n  type = \"button\",\n  className = \"\",\n  style,\n  onPointerEnter,\n  onPointerMove,\n  onPointerLeave,\n  onFocus,\n  onBlur,\n  ...rest\n}: ButtonSpotlightProps) {\n  const ref = React.useRef<HTMLButtonElement>(null);\n  const live = React.useRef({ active: false, px: 0.5, py: 0.5, reduce: false });\n  const kickRef = React.useRef<() => void>(() => {});\n  const inert = disabled || loading;\n\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const mq = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    const state = live.current;\n    state.reduce = mq.matches;\n    let cx = 0.5;\n    let cy = 0.5;\n    let ci = 0.55;\n    let raf = 0;\n    let visible = true;\n\n    function apply() {\n      el!.style.setProperty(\"--hb-qa1-x\", `${(cx * 100).toFixed(1)}%`);\n      el!.style.setProperty(\"--hb-qa1-y\", `${(cy * 100).toFixed(1)}%`);\n      el!.style.setProperty(\"--hb-qa1-i\", ci.toFixed(3));\n    }\n\n    function step(now: number) {\n      raf = 0;\n      if (!visible) return;\n      const u = now / 1000;\n      const tx = state.active ? state.px : 0.5 + 0.36 * Math.sin(u * 0.85);\n      const ty = state.active ? state.py : 0.5 + 0.22 * Math.sin(u * 1.35 + 1);\n      const ti = state.active ? 1 : 0.6;\n      const k = state.active ? 0.22 : 0.06;\n      cx += (tx - cx) * k;\n      cy += (ty - cy) * k;\n      ci += (ti - ci) * 0.1;\n      apply();\n      raf = requestAnimationFrame(step);\n    }\n\n    function start() {\n      if (state.reduce) {\n        cx = state.px;\n        cy = state.py;\n        ci = state.active ? 1 : 0.55;\n        apply();\n        return;\n      }\n      if (!raf && visible) raf = requestAnimationFrame(step);\n    }\n\n    const io = new IntersectionObserver(([entry]) => {\n      visible = entry.isIntersecting;\n      if (visible) start();\n      else {\n        cancelAnimationFrame(raf);\n        raf = 0;\n      }\n    });\n    io.observe(el);\n\n    const onMq = () => {\n      state.reduce = mq.matches;\n      cancelAnimationFrame(raf);\n      raf = 0;\n      start();\n    };\n    mq.addEventListener(\"change\", onMq);\n    kickRef.current = start;\n    start();\n\n    return () => {\n      cancelAnimationFrame(raf);\n      io.disconnect();\n      mq.removeEventListener(\"change\", onMq);\n    };\n  }, []);\n\n  function kick() {\n    kickRef.current();\n  }\n\n  function track(e: React.PointerEvent<HTMLButtonElement>) {\n    const rect = e.currentTarget.getBoundingClientRect();\n    const state = live.current;\n    state.px = rect.width ? Math.min(1, Math.max(0, (e.clientX - rect.left) / rect.width)) : 0.5;\n    state.py = rect.height ? Math.min(1, Math.max(0, (e.clientY - rect.top) / rect.height)) : 0.5;\n    state.active = true;\n    kick();\n  }\n\n  function release() {\n    const state = live.current;\n    state.active = false;\n    state.px = 0.5;\n    state.py = 0.5;\n    kick();\n  }\n\n  const vars = { \"--hb-qa1-c\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-button-spotlight\" precedence=\"default\">{css}</style>\n      <button\n        ref={ref}\n        type={type}\n        className={`hb-qa1 ${className}`}\n        style={vars}\n        data-variant={variant}\n        data-size={size}\n        disabled={inert}\n        aria-busy={loading || undefined}\n        onPointerEnter={(e) => {\n          track(e);\n          onPointerEnter?.(e);\n        }}\n        onPointerMove={(e) => {\n          track(e);\n          onPointerMove?.(e);\n        }}\n        onPointerLeave={(e) => {\n          release();\n          onPointerLeave?.(e);\n        }}\n        onFocus={(e) => {\n          if (e.currentTarget.matches(\":focus-visible\")) {\n            live.current.active = true;\n            live.current.px = 0.5;\n            live.current.py = 0.5;\n            kick();\n          }\n          onFocus?.(e);\n        }}\n        onBlur={(e) => {\n          release();\n          onBlur?.(e);\n        }}\n        {...rest}\n      >\n        <span className=\"hb-qa1-glow\" aria-hidden=\"true\" />\n        <span className=\"hb-qa1-edge\" aria-hidden=\"true\" />\n        <span className=\"hb-qa1-t\">\n          {loading ? <span className=\"hb-qa1-sp\" aria-hidden=\"true\" /> : null}\n          {children}\n        </span>\n      </button>\n    </>\n  );\n}\n"
    }
  ]
}