{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-specular",
  "type": "registry:component",
  "title": "Specular Button",
  "description": "A metallic, glass or blue button with a specular highlight that slides across its surface, a lit edge bevel and a subtle tilt that follow the pointer. A scripted highlight plays until the pointer arrives.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "metallic",
    "glass",
    "specular",
    "tilt",
    "pointer"
  ],
  "docs": "https://hyperblur.dev/effects/button-specular",
  "files": [
    {
      "path": "registry/hyperblur/button-specular.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-specular.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type ButtonSpecularTone = \"chrome\" | \"glass\" | \"blue\";\n\nexport interface ButtonSpecularProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n  tone?: ButtonSpecularTone;\n  tilt?: number;\n  shine?: number;\n  idle?: boolean;\n}\n\nconst css = `\n.hb-qv1 {\n  --hb-qv1-x: 50%;\n  --hb-qv1-y: 30%;\n  --hb-qv1-rx: 0deg;\n  --hb-qv1-ry: 0deg;\n  --hb-qv1-k: 1;\n  --hb-qv1-b1: #50535c;\n  --hb-qv1-b2: #17181c;\n  --hb-qv1-fg: #f3f5f9;\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  gap: 0.55em;\n  box-sizing: border-box;\n  margin: 0;\n  padding: 0.85em 1.7em;\n  font: inherit;\n  font-weight: 600;\n  letter-spacing: -0.005em;\n  line-height: 1.1;\n  color: var(--hb-qv1-fg);\n  background: linear-gradient(180deg, var(--hb-qv1-b1), var(--hb-qv1-b2));\n  border: 0;\n  border-radius: 14px;\n  cursor: pointer;\n  overflow: hidden;\n  isolation: isolate;\n  user-select: none;\n  -webkit-user-select: none;\n  -webkit-tap-highlight-color: transparent;\n  transform: perspective(520px) rotateX(var(--hb-qv1-rx)) rotateY(var(--hb-qv1-ry));\n  scale: 1;\n  transition: scale 0.18s cubic-bezier(0.3, 1.4, 0.5, 1), filter 0.2s ease, box-shadow 0.2s ease;\n  box-shadow:\n    inset 0 1px 0 rgba(255, 255, 255, 0.34),\n    inset 0 -2px 4px rgba(0, 0, 0, 0.38),\n    0 12px 24px -12px rgba(0, 0, 0, 0.8),\n    0 2px 3px rgba(0, 0, 0, 0.45);\n}\n.hb-qv1 *, .hb-qv1 *::before, .hb-qv1 *::after { box-sizing: border-box; }\n.hb-qv1[data-tone=\"glass\"] {\n  --hb-qv1-b1: rgba(255, 255, 255, 0.16);\n  --hb-qv1-b2: rgba(255, 255, 255, 0.04);\n  -webkit-backdrop-filter: blur(14px) saturate(1.4);\n  backdrop-filter: blur(14px) saturate(1.4);\n}\n.hb-qv1[data-tone=\"blue\"] {\n  --hb-qv1-b1: #639fff;\n  --hb-qv1-b2: #1a4ccb;\n  --hb-qv1-fg: #ffffff;\n  box-shadow:\n    inset 0 1px 0 rgba(255, 255, 255, 0.45),\n    inset 0 -2px 4px rgba(8, 24, 90, 0.45),\n    0 14px 28px -12px rgba(47, 123, 255, 0.65),\n    0 2px 3px rgba(0, 0, 0, 0.4);\n}\n.hb-qv1:hover:not(:disabled) { filter: brightness(1.07); }\n.hb-qv1:active:not(:disabled) {\n  scale: 0.962;\n  filter: brightness(0.94);\n  box-shadow:\n    inset 0 2px 6px rgba(0, 0, 0, 0.55),\n    inset 0 -1px 0 rgba(255, 255, 255, 0.12),\n    0 4px 10px -6px rgba(0, 0, 0, 0.8);\n}\n.hb-qv1:focus-visible { outline: 2px solid #7fb3ff; outline-offset: 3px; }\n.hb-qv1:disabled { opacity: 0.5; cursor: not-allowed; }\n.hb-qv1-gl, .hb-qv1-st, .hb-qv1-bv {\n  position: absolute;\n  inset: 0;\n  border-radius: inherit;\n  pointer-events: none;\n}\n.hb-qv1-gl {\n  z-index: 0;\n  mix-blend-mode: screen;\n  background: radial-gradient(\n    ellipse 62% 150% at var(--hb-qv1-x) var(--hb-qv1-y),\n    rgba(255, 255, 255, calc(0.5 * var(--hb-qv1-k))),\n    rgba(255, 255, 255, 0) 100%\n  );\n}\n.hb-qv1-st {\n  z-index: 0;\n  background:\n    linear-gradient(\n      105deg,\n      transparent calc(var(--hb-qv1-x) - 13%),\n      rgba(255, 255, 255, calc(0.3 * var(--hb-qv1-k))) var(--hb-qv1-x),\n      transparent calc(var(--hb-qv1-x) + 13%)\n    ),\n    linear-gradient(\n      105deg,\n      transparent calc(100% - var(--hb-qv1-x) - 4%),\n      rgba(255, 255, 255, calc(0.16 * var(--hb-qv1-k))) calc(100% - var(--hb-qv1-x)),\n      transparent calc(100% - var(--hb-qv1-x) + 4%)\n    );\n}\n.hb-qv1-bv {\n  z-index: 1;\n  padding: 1px;\n  background: radial-gradient(\n    ellipse 75% 190% at var(--hb-qv1-x) var(--hb-qv1-y),\n    rgba(255, 255, 255, calc(0.95 * var(--hb-qv1-k))),\n    rgba(255, 255, 255, 0.2) 55%,\n    rgba(255, 255, 255, 0.07)\n  );\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-qv1-tx {\n  position: relative;\n  z-index: 2;\n  display: inline-flex;\n  align-items: center;\n  gap: 0.55em;\n  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.42);\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qv1 { transition: none; }\n  .hb-qv1:active:not(:disabled) { scale: 1; }\n}\n`;\n\nexport function ButtonSpecular({\n  tone = \"chrome\",\n  tilt = 6,\n  shine = 1,\n  idle = true,\n  type = \"button\",\n  className = \"\",\n  style,\n  children,\n  onPointerEnter,\n  onPointerMove,\n  onPointerLeave,\n  ...rest\n}: ButtonSpecularProps) {\n  const ref = React.useRef<HTMLButtonElement>(null);\n  const wake = React.useRef<(() => void) | null>(null);\n  const sim = React.useRef({ x: 0.5, y: 0.3, tx: 0.5, ty: 0.3, active: false, visible: true, running: false, raf: 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      const k = s.active ? 1 : 0.4;\n      el.style.setProperty(\"--hb-qv1-x\", `${(s.x * 100).toFixed(2)}%`);\n      el.style.setProperty(\"--hb-qv1-y\", `${(s.y * 100).toFixed(2)}%`);\n      el.style.setProperty(\"--hb-qv1-rx\", `${((0.5 - s.y) * 2 * tilt * k).toFixed(2)}deg`);\n      el.style.setProperty(\"--hb-qv1-ry\", `${((s.x - 0.5) * 2 * tilt * k).toFixed(2)}deg`);\n    }\n\n    function tick(ts: number) {\n      s.running = false;\n      if (!s.visible) return;\n      if (!s.active && idle) {\n        const t = ts / 1000;\n        s.tx = 0.5 + 0.38 * Math.sin(t * 0.9);\n        s.ty = 0.36 + 0.16 * Math.sin(t * 1.4 + 1);\n      }\n      s.x += (s.tx - s.x) * 0.14;\n      s.y += (s.ty - s.y) * 0.14;\n      write();\n      const moving = Math.abs(s.tx - s.x) > 0.001 || Math.abs(s.ty - s.y) > 0.001;\n      if (idle || s.active || moving) {\n        s.running = true;\n        s.raf = requestAnimationFrame(tick);\n      }\n    }\n\n    function ensure() {\n      if (reduced) {\n        s.x = s.tx;\n        s.y = s.ty;\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, tilt]);\n\n  function aim(e: React.PointerEvent<HTMLButtonElement>) {\n    const el = ref.current;\n    if (!el) return;\n    const r = el.getBoundingClientRect();\n    const s = sim.current;\n    s.active = true;\n    s.tx = Math.min(1, Math.max(0, (e.clientX - r.left) / Math.max(1, r.width)));\n    s.ty = Math.min(1, Math.max(0, (e.clientY - r.top) / Math.max(1, r.height)));\n    wake.current?.();\n  }\n\n  const vars = { \"--hb-qv1-k\": shine, ...style } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-button-specular\" precedence=\"default\">{css}</style>\n      <button\n        ref={ref}\n        type={type}\n        data-tone={tone}\n        className={`hb-qv1 ${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          if (!idle) {\n            s.tx = 0.5;\n            s.ty = 0.3;\n          }\n          wake.current?.();\n        }}\n        {...rest}\n      >\n        <span className=\"hb-qv1-gl\" aria-hidden=\"true\" />\n        <span className=\"hb-qv1-st\" aria-hidden=\"true\" />\n        <span className=\"hb-qv1-bv\" aria-hidden=\"true\" />\n        <span className=\"hb-qv1-tx\">{children}</span>\n      </button>\n    </>\n  );\n}\n"
    }
  ]
}