{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-tilt-glare",
  "type": "registry:component",
  "title": "Button Tilt Glare",
  "description": "A chunky 3D button that tilts toward the pointer with a moving glare and a shadow that shifts opposite the tilt. It sways on its own until touched.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "tilt",
    "3d",
    "glare",
    "shadow",
    "pointer"
  ],
  "docs": "https://hyperblur.dev/effects/button-tilt-glare",
  "files": [
    {
      "path": "registry/hyperblur/button-tilt-glare.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-tilt-glare.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonTiltGlareProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"color\"> {\n  variant?: \"solid\" | \"light\" | \"dark\";\n  accent?: string;\n  size?: \"sm\" | \"md\" | \"lg\";\n  tilt?: number;\n  sway?: boolean;\n  loading?: boolean;\n}\n\ninterface Pose {\n  rx: number;\n  ry: number;\n  gx: number;\n  gy: number;\n  ga: number;\n}\n\nconst css = `\n.hb-ya6 {\n  --hb-ya6-fs: 1.0625rem;\n  --hb-ya6-rx: 0deg;\n  --hb-ya6-ry: 0deg;\n  --hb-ya6-gx: 50%;\n  --hb-ya6-gy: 30%;\n  --hb-ya6-ga: 0.3;\n  --hb-ya6-sx: 0px;\n  --hb-ya6-sy: 0px;\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  box-sizing: border-box;\n  margin: 0 0 8px;\n  padding: 0.95em 2.1em;\n  font: inherit;\n  font-size: var(--hb-ya6-fs);\n  font-weight: 700;\n  letter-spacing: 0.01em;\n  line-height: 1;\n  white-space: nowrap;\n  border: 1px solid var(--hb-ya6-rim);\n  border-radius: 18px;\n  cursor: pointer;\n  user-select: none;\n  -webkit-user-select: none;\n  -webkit-tap-highlight-color: transparent;\n  touch-action: manipulation;\n  transform-style: preserve-3d;\n  transform: perspective(560px) rotateX(var(--hb-ya6-rx)) rotateY(var(--hb-ya6-ry));\n  will-change: transform;\n  box-shadow:\n    inset 0 1px 0 rgba(255, 255, 255, 0.35),\n    0 7px 0 var(--hb-ya6-edge),\n    var(--hb-ya6-sx) calc(20px + var(--hb-ya6-sy)) 28px -6px rgba(0, 0, 0, 0.65);\n  transition: translate 0.14s ease, box-shadow 0.14s ease, filter 0.2s ease;\n}\n.hb-ya6 *, .hb-ya6 *::before, .hb-ya6 *::after { box-sizing: border-box; }\n.hb-ya6[data-size=\"sm\"] { --hb-ya6-fs: 0.875rem; }\n.hb-ya6[data-size=\"lg\"] { --hb-ya6-fs: 1.25rem; }\n.hb-ya6[data-variant=\"solid\"] {\n  --hb-ya6-edge: color-mix(in srgb, var(--hb-ya6-c) 52%, #000);\n  --hb-ya6-rim: color-mix(in srgb, var(--hb-ya6-c) 70%, #fff);\n  color: #fff;\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-ya6-c) 80%, #fff), var(--hb-ya6-c));\n  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);\n}\n.hb-ya6[data-variant=\"light\"] {\n  --hb-ya6-edge: #8d8d95;\n  --hb-ya6-rim: #ffffff;\n  color: #0a0a0a;\n  background: linear-gradient(180deg, #ffffff, #dcdce0);\n}\n.hb-ya6[data-variant=\"dark\"] {\n  --hb-ya6-edge: #000000;\n  --hb-ya6-rim: #34343a;\n  color: #ededed;\n  background: linear-gradient(180deg, #26262a, #151517);\n}\n.hb-ya6:not(:disabled):active {\n  translate: 0 5px;\n  box-shadow:\n    inset 0 1px 0 rgba(255, 255, 255, 0.25),\n    0 2px 0 var(--hb-ya6-edge),\n    0 8px 14px -4px rgba(0, 0, 0, 0.6);\n}\n.hb-ya6:focus-visible { outline: 2px solid var(--hb-ya6-c); outline-offset: 5px; }\n.hb-ya6:disabled { opacity: 0.45; cursor: not-allowed; filter: saturate(0.6); }\n.hb-ya6[aria-busy=\"true\"] { cursor: progress; }\n.hb-ya6-glare {\n  position: absolute;\n  inset: 0;\n  z-index: 1;\n  overflow: hidden;\n  border-radius: inherit;\n  pointer-events: none;\n  background: radial-gradient(circle at var(--hb-ya6-gx) var(--hb-ya6-gy), rgba(255, 255, 255, var(--hb-ya6-ga)) 0, rgba(255, 255, 255, 0) 58%);\n  mix-blend-mode: soft-light;\n}\n.hb-ya6-sheen {\n  position: absolute;\n  inset: 0;\n  z-index: 1;\n  border-radius: inherit;\n  pointer-events: none;\n  background: radial-gradient(circle at var(--hb-ya6-gx) var(--hb-ya6-gy), rgba(255, 255, 255, calc(var(--hb-ya6-ga) * 0.35)) 0, rgba(255, 255, 255, 0) 38%);\n}\n.hb-ya6-label {\n  position: relative;\n  z-index: 2;\n  display: inline-flex;\n  align-items: center;\n  gap: 0.6em;\n  transform: translateZ(16px);\n}\n.hb-ya6-spin {\n  width: 1em;\n  height: 1em;\n  border: 2px solid currentColor;\n  border-right-color: transparent;\n  border-radius: 50%;\n  animation: hb-ya6-turn 0.7s linear infinite;\n}\n@keyframes hb-ya6-turn {\n  to { transform: rotate(360deg); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-ya6 { transition: none; transform: none; }\n  .hb-ya6-label { transform: none; }\n  .hb-ya6-spin { animation-duration: 2s; }\n}\n`;\n\nexport function ButtonTiltGlare({\n  variant = \"solid\",\n  accent = \"#2f7bff\",\n  size = \"md\",\n  tilt = 14,\n  sway = true,\n  loading = false,\n  disabled = false,\n  type = \"button\",\n  className = \"\",\n  style,\n  children,\n  onPointerEnter,\n  onPointerMove,\n  onPointerLeave,\n  onClick,\n  ...rest\n}: ButtonTiltGlareProps) {\n  const ref = React.useRef<HTMLButtonElement>(null);\n  const hover = React.useRef(false);\n  const target = React.useRef<Pose>({ rx: 0, ry: 0, gx: 50, gy: 30, ga: 0.3 });\n\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    const cur: Pose = { rx: 0, ry: 0, gx: 50, gy: 30, ga: 0.3 };\n    const amp = Math.max(0, tilt);\n    let raf = 0;\n    let visible = true;\n\n    function frame(now: number) {\n      if (!el) return;\n      const goal = target.current;\n      if (!hover.current) {\n        goal.rx = sway ? Math.sin(now * 0.0013) * amp * 0.35 : 0;\n        goal.ry = sway ? Math.sin(now * 0.001 + 1.2) * amp * 0.6 : 0;\n        goal.gx = 50 + (sway ? Math.sin(now * 0.001 + 1.2) * 34 : 0);\n        goal.gy = 32 + (sway ? Math.cos(now * 0.0013) * 18 : 0);\n        goal.ga = 0.38;\n      }\n      const k = 0.13;\n      cur.rx += (goal.rx - cur.rx) * k;\n      cur.ry += (goal.ry - cur.ry) * k;\n      cur.gx += (goal.gx - cur.gx) * k;\n      cur.gy += (goal.gy - cur.gy) * k;\n      cur.ga += (goal.ga - cur.ga) * k;\n      el.style.setProperty(\"--hb-ya6-rx\", `${cur.rx.toFixed(2)}deg`);\n      el.style.setProperty(\"--hb-ya6-ry\", `${cur.ry.toFixed(2)}deg`);\n      el.style.setProperty(\"--hb-ya6-gx\", `${cur.gx.toFixed(1)}%`);\n      el.style.setProperty(\"--hb-ya6-gy\", `${cur.gy.toFixed(1)}%`);\n      el.style.setProperty(\"--hb-ya6-ga\", cur.ga.toFixed(3));\n      el.style.setProperty(\"--hb-ya6-sx\", `${(-cur.ry * 1.1).toFixed(1)}px`);\n      el.style.setProperty(\"--hb-ya6-sy\", `${(cur.rx * 1.1).toFixed(1)}px`);\n      raf = requestAnimationFrame(frame);\n    }\n\n    const observer = new IntersectionObserver(([entry]) => {\n      const next = entry.isIntersecting;\n      if (next === visible) return;\n      visible = next;\n      cancelAnimationFrame(raf);\n      if (visible) raf = requestAnimationFrame(frame);\n    });\n    observer.observe(el);\n    raf = requestAnimationFrame(frame);\n    return () => {\n      observer.disconnect();\n      cancelAnimationFrame(raf);\n    };\n  }, [tilt, sway]);\n\n  function aim(e: React.PointerEvent<HTMLButtonElement>) {\n    const rect = e.currentTarget.getBoundingClientRect();\n    if (rect.width === 0 || rect.height === 0) return;\n    const nx = Math.min(1, Math.max(0, (e.clientX - rect.left) / rect.width));\n    const ny = Math.min(1, Math.max(0, (e.clientY - rect.top) / rect.height));\n    const amp = Math.max(0, tilt);\n    const goal = target.current;\n    goal.rx = -(ny - 0.5) * 2 * amp * 0.7;\n    goal.ry = (nx - 0.5) * 2 * amp;\n    goal.gx = nx * 100;\n    goal.gy = ny * 100;\n    goal.ga = 0.85;\n  }\n\n  const vars = { \"--hb-ya6-c\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-button-tilt-glare\" precedence=\"default\">{css}</style>\n      <button\n        ref={ref}\n        type={type}\n        className={`hb-ya6 ${className}`}\n        style={vars}\n        data-variant={variant}\n        data-size={size}\n        disabled={disabled}\n        aria-busy={loading || undefined}\n        onPointerEnter={(e) => {\n          onPointerEnter?.(e);\n          if (disabled || e.pointerType === \"touch\") return;\n          hover.current = true;\n          aim(e);\n        }}\n        onPointerMove={(e) => {\n          onPointerMove?.(e);\n          if (!hover.current) return;\n          aim(e);\n        }}\n        onPointerLeave={(e) => {\n          onPointerLeave?.(e);\n          hover.current = false;\n        }}\n        onClick={(e) => {\n          if (loading) {\n            e.preventDefault();\n            return;\n          }\n          onClick?.(e);\n        }}\n        {...rest}\n      >\n        <span className=\"hb-ya6-glare\" aria-hidden=\"true\" />\n        <span className=\"hb-ya6-sheen\" aria-hidden=\"true\" />\n        <span className=\"hb-ya6-label\">\n          {loading ? <span className=\"hb-ya6-spin\" aria-hidden=\"true\" /> : null}\n          {children}\n        </span>\n      </button>\n    </>\n  );\n}\n"
    }
  ]
}