{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"sheen-card","type":"registry:ui","title":"Sheen Card","description":"Polished metal or glass card whose streaks, specular band and hotspot slide across the surface as the pointer tilts it.","dependencies":[],"registryDependencies":["utils"],"files":[{"path":"registry/ui/sheen-card.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useRef, type CSSProperties, type ReactNode } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type ReflectiveFinish = \"silver\" | \"gold\" | \"graphite\" | \"rose\" | \"glass\";\n\nexport interface SheenCardProps {\n  children?: ReactNode;\n  /** Surface material. */\n  finish?: ReflectiveFinish;\n  /** Max tilt in degrees. */\n  maxTilt?: number;\n  /** Brightness of the moving reflections, 0 to 1. */\n  sheen?: number;\n  /** Fine brushed-metal lines. */\n  brushed?: boolean;\n  className?: string;\n}\n\n// base gradient, text color, reflection tint\nconst FINISHES: Record<ReflectiveFinish, [string, string, string]> = {\n  silver: [\"linear-gradient(135deg,#8d9299 0%,#d9dde2 28%,#7b8087 52%,#c9ced4 76%,#6c7178 100%)\", \"#1d2127\", \"255,255,255\"],\n  gold: [\"linear-gradient(135deg,#8a6a2f 0%,#e8cf8a 28%,#a07a34 52%,#f2dc9b 76%,#7a5a22 100%)\", \"#2b1d05\", \"255,244,214\"],\n  graphite: [\"linear-gradient(135deg,#17181b 0%,#3a3d44 28%,#1b1c20 52%,#34373d 76%,#111214 100%)\", \"#e7e9ec\", \"210,220,235\"],\n  rose: [\"linear-gradient(135deg,#9a6a63 0%,#efc9bf 28%,#a8756b 52%,#f3d2c9 76%,#8a5b54 100%)\", \"#2e1512\", \"255,236,230\"],\n  glass: [\"linear-gradient(135deg,rgba(255,255,255,.14),rgba(255,255,255,.04) 45%,rgba(255,255,255,.1))\", \"#f5f7fa\", \"255,255,255\"],\n};\n\nexport function SheenCard({\n  children,\n  finish = \"silver\",\n  maxTilt = 10,\n  sheen = 0.8,\n  brushed = true,\n  className,\n}: SheenCardProps) {\n  const card = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    const el = card.current!;\n    const reduce = matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const target = { x: 0.5, y: 0.35, h: 0 };\n    const cur = { ...target };\n    let raf = 0;\n\n    const apply = () => {\n      el.style.setProperty(\"--mx\", cur.x.toFixed(4));\n      el.style.setProperty(\"--my\", cur.y.toFixed(4));\n      el.style.setProperty(\"--mh\", cur.h.toFixed(4));\n      const t = reduce ? 0 : maxTilt;\n      el.style.transform = `perspective(1000px) rotateX(${(0.5 - cur.y) * 2 * t}deg) rotateY(${(cur.x - 0.5) * 2 * t}deg) scale(${1 + cur.h * 0.02})`;\n    };\n    const tick = () => {\n      let moving = false;\n      for (const k of [\"x\", \"y\", \"h\"] as const) {\n        const d = target[k] - cur[k];\n        cur[k] += d * 0.14;\n        if (Math.abs(d) > 0.0005) moving = true;\n      }\n      apply();\n      raf = moving ? requestAnimationFrame(tick) : 0;\n    };\n    const kick = () => {\n      if (!raf) raf = requestAnimationFrame(tick);\n    };\n    const move = (e: PointerEvent) => {\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.h = 1;\n      kick();\n    };\n    const leave = () => {\n      target.x = 0.5;\n      target.y = 0.35;\n      target.h = 0;\n      kick();\n    };\n    // Keyboard focus inside the card lifts it like a hover.\n    const focus = () => {\n      target.h = 1;\n      kick();\n    };\n\n    apply();\n    el.addEventListener(\"pointermove\", move);\n    el.addEventListener(\"pointerleave\", leave);\n    el.addEventListener(\"focusin\", focus);\n    el.addEventListener(\"focusout\", leave);\n    return () => {\n      cancelAnimationFrame(raf);\n      el.removeEventListener(\"pointermove\", move);\n      el.removeEventListener(\"pointerleave\", leave);\n      el.removeEventListener(\"focusin\", focus);\n      el.removeEventListener(\"focusout\", leave);\n    };\n  }, [maxTilt]);\n\n  const [base, ink, tint] = FINISHES[finish];\n  const s = Math.max(0, Math.min(1, sheen));\n  const glass = finish === \"glass\";\n\n  return (\n    <div\n      ref={card}\n      className={cn(\n        \"relative isolate aspect-[1.586] w-[22rem] max-w-full overflow-hidden rounded-[1.4rem] will-change-transform\",\n        glass && \"backdrop-blur-xl\",\n        className,\n      )}\n      style={\n        {\n          background: base,\n          color: ink,\n          boxShadow: `inset 0 1px 0 rgba(255,255,255,${glass ? 0.35 : 0.6}), inset 0 -1px 0 rgba(0,0,0,.35), 0 30px 60px -25px rgba(0,0,0,.75), 0 0 0 1px rgba(${tint},${glass ? 0.18 : 0.25})`,\n        } as CSSProperties\n      }\n    >\n      {brushed && (\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute inset-0 -z-10 mix-blend-overlay\"\n          style={{\n            opacity: glass ? 0.25 : 0.55,\n            backgroundImage:\n              \"repeating-linear-gradient(90deg, rgba(255,255,255,.18) 0 1px, rgba(0,0,0,.12) 1px 2px, transparent 2px 4px), repeating-linear-gradient(90deg, rgba(0,0,0,.08) 0 13px, rgba(255,255,255,.06) 13px 29px)\",\n          }}\n        />\n      )}\n      {/* Anisotropic streaks: broad light and dark bands along the brushing that roll with the pointer. */}\n      <div\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 -z-10 mix-blend-soft-light\"\n        style={{\n          opacity: s,\n          backgroundImage: `linear-gradient(90deg, rgba(0,0,0,.4) 0%, rgba(${tint},.85) 16%, rgba(0,0,0,.45) 31%, rgba(${tint},.6) 47%, rgba(0,0,0,.35) 63%, rgba(${tint},.9) 80%, rgba(0,0,0,.4) 100%)`,\n          backgroundSize: \"300% 100%\",\n          backgroundPosition: \"calc(var(--mx) * 100%) 0\",\n        }}\n      />\n      {/* Specular band that sweeps across as the angle changes. */}\n      <div\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 -z-10 mix-blend-screen\"\n        style={{\n          opacity: `calc(${s * 0.55} + var(--mh) * ${s * 0.45})`,\n          backgroundImage: `linear-gradient(calc(100deg + var(--my) * 20deg), transparent 35%, rgba(${tint},.08) 42%, rgba(${tint},.65) 49%, rgba(${tint},.12) 54%, transparent 62%)`,\n          backgroundSize: \"260% 100%\",\n          backgroundPosition: \"calc(100% - var(--mx) * 100%) 0\",\n        }}\n      />\n      {/* Hotspot directly under the light. */}\n      <div\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 -z-10 mix-blend-overlay\"\n        style={{\n          opacity: `calc(var(--mh) * ${s})`,\n          background: `radial-gradient(40% 55% at calc(var(--mx) * 100%) calc(var(--my) * 100%), rgba(${tint},.9), transparent 70%)`,\n        }}\n      />\n      <div className=\"relative size-full [text-shadow:0_1px_0_rgba(255,255,255,.25),0_-1px_0_rgba(0,0,0,.25)]\">{children}</div>\n    </div>\n  );\n}\n"}]}