{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"holo-badge","type":"registry:ui","title":"Holo Badge","description":"Holographic profile card that tilts toward the pointer while rainbow foil, glitter and glare slide across it, with a glass contact bar.","dependencies":[],"registryDependencies":["utils"],"files":[{"path":"registry/ui/holo-badge.tsx","type":"registry:ui","content":"\"use client\";\n\n/* eslint-disable @next/next/no-img-element */\nimport { useEffect, useRef } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface HoloBadgeProps {\n  name?: string;\n  title?: string;\n  handle?: string;\n  status?: string;\n  /** Portrait that fills the card. */\n  avatarUrl?: string;\n  /** Small avatar in the contact bar. Defaults to `avatarUrl`. */\n  miniAvatarUrl?: string;\n  contactText?: string;\n  onContactClick?: () => void;\n  /** Max tilt in degrees. */\n  maxTilt?: number;\n  /** Strength of the holographic foil, 0 to 1. */\n  foil?: number;\n  /** Show the bottom contact bar. */\n  showUserInfo?: boolean;\n  className?: string;\n}\n\nconst RAINBOW =\n  \"repeating-linear-gradient(115deg, hsl(340 95% 58%) 0px, hsl(35 100% 58%) 22px, hsl(90 85% 55%) 44px, hsl(175 90% 50%) 66px, hsl(220 95% 62%) 88px, hsl(285 90% 64%) 110px, hsl(340 95% 58%) 132px)\";\n\nconst FOIL_SHIFT = \"translate3d(calc(var(--nx, 0) * -40%), calc(var(--ny, 0) * -40%), 0)\";\n\nexport function HoloBadge({\n  name = \"Maya Laurent\",\n  title = \"Product Designer\",\n  handle = \"mayalaurent\",\n  status = \"Available for work\",\n  avatarUrl,\n  miniAvatarUrl,\n  contactText = \"Contact\",\n  onContactClick,\n  maxTilt = 14,\n  foil = 0.8,\n  showUserInfo = true,\n  className,\n}: HoloBadgeProps) {\n  const wrap = useRef<HTMLDivElement>(null);\n  const card = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    const el = wrap.current!;\n    const c = card.current!;\n    const reduce = matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    // Pointer position in 0..1 (target) and the smoothed value we render.\n    const target = { x: 0.5, y: 0.5, a: 0 };\n    const cur = { x: 0.5, y: 0.5, a: 0 };\n    let raf = 0;\n    let intro = 0;\n\n    const apply = () => {\n      const dx = cur.x - 0.5;\n      const dy = cur.y - 0.5;\n      c.style.transform = `rotateX(${-dy * 2 * maxTilt}deg) rotateY(${dx * 2 * maxTilt}deg)`;\n      c.style.setProperty(\"--px\", `${cur.x * 100}%`);\n      c.style.setProperty(\"--py\", `${cur.y * 100}%`);\n      c.style.setProperty(\"--nx\", dx.toFixed(4));\n      c.style.setProperty(\"--ny\", dy.toFixed(4));\n      c.style.setProperty(\"--pa\", `${cur.a}`);\n    };\n\n    const tick = () => {\n      let moving = false;\n      for (const k of [\"x\", \"y\", \"a\"] as const) {\n        const d = target[k] - cur[k];\n        cur[k] += d * 0.12;\n        if (Math.abs(d) > 0.0005) moving = true;\n      }\n      apply();\n      raf = moving ? requestAnimationFrame(tick) : 0;\n    };\n    const kick = () => {\n      if (reduce) {\n        Object.assign(cur, target);\n        apply();\n      } else if (!raf) raf = requestAnimationFrame(tick);\n    };\n\n    const move = (e: PointerEvent) => {\n      cancelAnimationFrame(intro);\n      intro = 0;\n      const r = el.getBoundingClientRect();\n      target.x = Math.min(1, Math.max(0, (e.clientX - r.left) / r.width));\n      target.y = Math.min(1, Math.max(0, (e.clientY - r.top) / r.height));\n      target.a = 1;\n      kick();\n    };\n    const leave = () => {\n      target.x = 0.5;\n      target.y = 0.5;\n      target.a = 0;\n      kick();\n    };\n\n    // A short intro sweep so the foil catches the light once when the card appears.\n    const io = new IntersectionObserver(([e]) => {\n      if (!e.isIntersecting || reduce) return;\n      io.disconnect();\n      const t0 = performance.now();\n      const sweep = (now: number) => {\n        const t = Math.min(1, (now - t0) / 1600);\n        const s = Math.sin(t * Math.PI);\n        target.x = 0.5 + Math.cos(t * Math.PI * 2 - Math.PI / 2) * 0.35 * s;\n        target.y = 0.5 + Math.sin(t * Math.PI * 2) * 0.2 * s;\n        target.a = s * 0.9;\n        kick();\n        intro = t < 1 ? requestAnimationFrame(sweep) : 0;\n      };\n      intro = requestAnimationFrame(sweep);\n    });\n\n    apply();\n    io.observe(el);\n    el.addEventListener(\"pointermove\", move);\n    el.addEventListener(\"pointerleave\", leave);\n    return () => {\n      cancelAnimationFrame(raf);\n      cancelAnimationFrame(intro);\n      io.disconnect();\n      el.removeEventListener(\"pointermove\", move);\n      el.removeEventListener(\"pointerleave\", leave);\n    };\n  }, [maxTilt]);\n\n  const f = Math.max(0, Math.min(1, foil));\n\n  return (\n    <div ref={wrap} className={cn(\"relative w-[21rem] max-w-full\", className)} style={{ perspective: 900 }}>\n      <div\n        ref={card}\n        className=\"relative aspect-[5/7] w-full overflow-hidden rounded-[2rem] bg-neutral-950 shadow-[0_40px_80px_-30px_rgba(0,0,0,.8)] will-change-transform\"\n\n      >\n        {/* Backdrop: deep gradient behind the portrait. */}\n        <div\n          aria-hidden\n          className=\"absolute inset-0\"\n          style={{\n            background:\n              \"radial-gradient(120% 80% at 50% 0%, #3b2d7a 0%, transparent 60%), radial-gradient(90% 60% at 100% 100%, #0f5f6b 0%, transparent 70%), #0b0b14\",\n          }}\n        />\n        {avatarUrl && (\n          <img\n            src={avatarUrl}\n            alt={name}\n            draggable={false}\n            className=\"absolute inset-0 size-full object-cover\"\n            style={{ maskImage: \"linear-gradient(to bottom, #000 45%, transparent 92%)\" }}\n          />\n        )}\n\n        {/* Holographic foil: an oversized rainbow sheet that slides against the tilt (no tiling seams). */}\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute inset-0 overflow-hidden mix-blend-color-dodge\"\n          style={{\n            opacity: `calc(${f * 0.1} + var(--pa, 0) * ${f * 0.42})`,\n            maskImage: \"radial-gradient(farthest-corner at var(--px, 50%) var(--py, 50%), #000 5%, rgba(0,0,0,.3) 80%)\",\n          }}\n        >\n          <div className=\"absolute inset-[-50%]\" style={{ backgroundImage: RAINBOW, transform: FOIL_SHIFT }} />\n        </div>\n        {/* Same bands in overlay so the color also reads on the dark parts of the photo. */}\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute inset-0 overflow-hidden mix-blend-overlay\"\n          style={{ opacity: `calc(${f * 0.06} + var(--pa, 0) * ${f * 0.28})` }}\n        >\n          <div className=\"absolute inset-[-50%]\" style={{ backgroundImage: RAINBOW, transform: FOIL_SHIFT }} />\n        </div>\n        {/* Fine etched lines, barely there, like the texture of a real foil card. */}\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute inset-0 mix-blend-soft-light\"\n          style={{\n            opacity: `calc(var(--pa, 0) * ${f * 0.6})`,\n            backgroundImage: \"repeating-linear-gradient(-35deg, rgba(255,255,255,.35) 0 1px, transparent 1px 4px)\",\n          }}\n        />\n        {/* Glitter: two offset dot grids that twinkle as the angle changes. */}\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute inset-0 mix-blend-screen\"\n          style={{\n            opacity: `calc(var(--pa, 0) * ${f * 0.42})`,\n            backgroundImage:\n              \"radial-gradient(circle at 30% 30%, rgba(255,255,255,.9) 0 0.6px, transparent 1.2px), radial-gradient(circle at 70% 60%, rgba(200,230,255,.8) 0 0.5px, transparent 1px)\",\n            backgroundSize: \"7px 7px, 11px 11px\",\n            backgroundPosition: \"calc(var(--px, 50%) * -0.2) calc(var(--py, 50%) * -0.2), calc(var(--px, 50%) * 0.3) 0\",\n            maskImage: \"radial-gradient(circle at var(--px, 50%) var(--py, 50%), #000, transparent 55%)\",\n          }}\n        />\n        {/* Glare that follows the pointer. */}\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute inset-0 mix-blend-overlay\"\n          style={{\n            opacity: \"calc(.2 + var(--pa, 0) * .8)\",\n            background:\n              \"radial-gradient(farthest-corner circle at var(--px, 50%) var(--py, 50%), rgba(255,255,255,.85) 0%, rgba(255,255,255,.25) 25%, rgba(0,0,0,.45) 90%)\",\n          }}\n        />\n\n        {/* Header */}\n        <div className=\"absolute inset-x-0 top-0 p-7 text-center\">\n          <h3 className=\"text-3xl font-semibold tracking-tight text-white [text-shadow:0_2px_20px_rgba(0,0,0,.45)]\">{name}</h3>\n          <p className=\"mt-1 text-sm font-medium text-white/75\">{title}</p>\n        </div>\n\n        {showUserInfo && (\n          <div\n            className=\"absolute inset-x-4 bottom-4 flex items-center gap-3 rounded-2xl border border-white/15 bg-white/10 p-2.5 pr-2.5 backdrop-blur-xl\"\n          >\n            {(miniAvatarUrl ?? avatarUrl) && (\n              <img src={miniAvatarUrl ?? avatarUrl} alt=\"\" draggable={false} className=\"size-10 rounded-full border border-white/20 object-cover\" />\n            )}\n            <div className=\"min-w-0 flex-1\">\n              <p className=\"truncate text-sm font-semibold text-white\">@{handle}</p>\n              <p className=\"flex items-center gap-1.5 truncate text-xs text-white/65\">\n                <span className=\"relative flex size-1.5\">\n                  <span className=\"absolute inset-0 animate-ping rounded-full bg-emerald-400/70 motion-reduce:animate-none\" />\n                  <span className=\"relative size-1.5 rounded-full bg-emerald-400\" />\n                </span>\n                {status}\n              </p>\n            </div>\n            <button\n              type=\"button\"\n              onClick={onContactClick}\n              className=\"shrink-0 rounded-xl bg-white px-3.5 py-2 text-sm font-semibold text-neutral-950 outline-none transition-transform hover:scale-[1.04] active:scale-95 focus-visible:ring-2 focus-visible:ring-white/70 focus-visible:ring-offset-2 focus-visible:ring-offset-neutral-900\"\n            >\n              {contactText}\n            </button>\n          </div>\n        )}\n\n        {/* Rim light */}\n        <div aria-hidden className=\"pointer-events-none absolute inset-0 rounded-[inherit] ring-1 ring-inset ring-white/15\" />\n      </div>\n    </div>\n  );\n}\n"}]}