{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "gloss-button",
  "title": "Gloss Button",
  "description": "A glossy button with a sheen, a pointer hotspot, and a press that squishes.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "components/ui/gloss-button.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n  animate,\n  motion,\n  useMotionTemplate,\n  useMotionValue,\n  useReducedMotion,\n  type HTMLMotionProps,\n} from \"motion/react\"\n\nimport { afterglow, spring } from \"@/lib/afterglow\"\nimport { cn } from \"@/lib/utils\"\n\nconst surfaces = {\n  ember:\n    \"bg-linear-to-b from-[color-mix(in_oklch,var(--glow),white_22%)] via-glow to-[color-mix(in_oklch,var(--glow),var(--glow-2)_35%)] shadow-gloss inset-shadow-[0_1px_0_0_oklch(1_0_0/45%)]\",\n  glass: \"bg-glass shadow-glass backdrop-blur-md backdrop-saturate-150\",\n}\n\nconst sizes = {\n  sm: \"h-8 gap-1.5 px-3.5 text-[13px] [&_svg]:size-3.5\",\n  md: \"h-10 gap-2 px-5 text-sm [&_svg]:size-4\",\n  lg: \"h-12 gap-2.5 px-6 text-[15px] [&_svg]:size-[18px]\",\n}\n\ntype GlossButtonProps = Omit<HTMLMotionProps<\"button\">, \"children\"> & {\n  variant?: keyof typeof surfaces\n  size?: keyof typeof sizes\n  children?: React.ReactNode\n}\n\nfunction GlossButton({\n  variant = \"ember\",\n  size = \"md\",\n  className,\n  children,\n  type = \"button\",\n  onPointerEnter,\n  onPointerMove,\n  onPointerLeave,\n  ...props\n}: GlossButtonProps) {\n  const reduceMotion = useReducedMotion()\n  const x = useMotionValue(0)\n  const y = useMotionValue(0)\n  const shine = useMotionValue(0)\n\n  const ember = variant === \"ember\"\n  const hotspot = useMotionTemplate`radial-gradient(80px circle at ${x}px ${y}px, ${\n    ember ? \"oklch(1 0 0 / 40%)\" : \"color-mix(in oklch, var(--glow) 30%, transparent)\"\n  }, transparent 70%)`\n\n  function track(event: React.PointerEvent<HTMLButtonElement>) {\n    const rect = event.currentTarget.getBoundingClientRect()\n    x.set(event.clientX - rect.left)\n    y.set(event.clientY - rect.top)\n  }\n\n  return (\n    <motion.button\n      data-slot=\"gloss-button\"\n      data-variant={variant}\n      type={type}\n      className={cn(\n        \"group relative isolate inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full font-medium whitespace-nowrap outline-none select-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50\",\n        ember ? \"text-glow-foreground\" : \"text-foreground\",\n        sizes[size],\n        className\n      )}\n      whileTap={{ scale: reduceMotion ? 1 : 0.96 }}\n      transition={spring(\"snappy\")}\n      onPointerEnter={(event) => {\n        onPointerEnter?.(event)\n        track(event)\n        animate(shine, 1, { duration: 0.2 })\n      }}\n      onPointerMove={(event) => {\n        onPointerMove?.(event)\n        track(event)\n      }}\n      onPointerLeave={(event) => {\n        onPointerLeave?.(event)\n        // the hotspot stays where the pointer left and fades out slowly\n        animate(shine, 0, { duration: afterglow.linger, ease: afterglow.ease })\n      }}\n      {...props}\n    >\n      {ember && (\n        <span\n          aria-hidden\n          className=\"absolute inset-x-2 top-1.5 -bottom-1 -z-10 rounded-[inherit] bg-glow opacity-45 blur-lg transition-opacity duration-300 group-hover:opacity-75 group-active:opacity-55\"\n        />\n      )}\n      <span\n        aria-hidden\n        className={cn(\"absolute inset-0 -z-10 rounded-[inherit]\", surfaces[variant])}\n      />\n      {/* specular sheen across the upper half, dims while pressed */}\n      <span\n        aria-hidden\n        className={cn(\n          \"pointer-events-none absolute inset-x-[3px] top-px h-[48%] rounded-[inherit] bg-linear-to-b to-transparent transition-opacity duration-150 group-active:opacity-50\",\n          ember ? \"from-white/40\" : \"from-gloss-highlight\"\n        )}\n      />\n      <motion.span\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-[inherit]\"\n        style={{ background: hotspot, opacity: shine }}\n      />\n      <span className=\"relative inline-flex items-center gap-[inherit]\">\n        {children}\n      </span>\n    </motion.button>\n  )\n}\n\nexport { GlossButton, type GlossButtonProps }\n",
      "type": "registry:ui"
    },
    {
      "path": "lib/afterglow.ts",
      "content": "import type { CSSProperties } from \"react\"\nimport type { TargetAndTransition, Transition } from \"motion/react\"\n\n// shared spring presets, every component picks from these\nexport const springs = {\n  snappy: { stiffness: 520, damping: 34, mass: 0.6 },\n  soft: { stiffness: 260, damping: 26, mass: 0.8 },\n  glide: { stiffness: 120, damping: 20, mass: 1 },\n} as const\n\nexport type SpringName = keyof typeof springs\n\nexport function spring(name: SpringName): Transition {\n  return { type: \"spring\", ...springs[name] }\n}\n\n// how a glow fades once its source moves away: slow, with a long tail\nexport const afterglow = {\n  linger: 0.9,\n  ease: [0.22, 1, 0.36, 1],\n} as const satisfies { linger: number; ease: Transition[\"ease\"] }\n\n// paints only the padding ring of an element, used for glowing borders\nexport const ringMask: CSSProperties = {\n  WebkitMask:\n    \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n  WebkitMaskComposite: \"xor\",\n  mask: \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n  maskComposite: \"exclude\",\n}\n\n// small icon gestures, played when a control is pressed or selected\nexport const iconGestures = {\n  pop: { scale: [1, 1.2, 1] },\n  ring: { rotate: [0, -18, 14, -9, 4, 0], scale: [1, 1.12, 1] },\n  // a gear looks the same after half a turn, so it can rest there and snap back unseen\n  turn: { rotate: [0, 180], scale: [1, 1.12, 1] },\n  hop: { y: [0, -3, 0], scale: [1, 1.1, 1] },\n  nudge: { x: [0, 2.5, 0], scale: [1, 1.1, 1] },\n} satisfies Record<string, TargetAndTransition>\n\nexport type IconGesture = keyof typeof iconGestures\n\n// leaving a gesture is instant: every gesture already ends at, or looks like, its resting pose\nexport const iconRest: TargetAndTransition = { scale: 1, rotate: 0, x: 0, y: 0, transition: { duration: 0 } }\n",
      "type": "registry:lib"
    }
  ],
  "cssVars": {
    "theme": {
      "color-glow": "var(--glow)",
      "color-glow-foreground": "var(--glow-foreground)",
      "color-glow-2": "var(--glow-2)",
      "color-glow-3": "var(--glow-3)",
      "color-glass": "var(--glass)",
      "color-gloss-highlight": "var(--gloss-highlight)",
      "shadow-gloss": "inset 0 1px 0 0 var(--gloss-highlight), inset 0 -1px 0 0 var(--gloss-shade), 0 0 0 1px var(--gloss-edge), 0 1px 2px 0 var(--gloss-depth), 0 4px 12px -4px var(--gloss-depth)",
      "shadow-glass": "inset 0 1px 0 0 var(--gloss-highlight), inset 0 -10px 24px -18px var(--gloss-shade), inset 0 0 0 1px var(--gloss-edge), 0 2px 6px -1px var(--gloss-depth), 0 18px 40px -12px var(--gloss-depth)",
      "shadow-well": "inset 0 1px 3px 0 var(--gloss-depth), inset 0 0 0 1px var(--gloss-edge), 0 1px 0 0 var(--gloss-highlight)"
    },
    "light": {
      "glow": "oklch(0.7 0.19 45)",
      "glow-foreground": "oklch(0.22 0.05 40)",
      "glow-2": "oklch(0.64 0.22 12)",
      "glow-3": "oklch(0.56 0.21 300)",
      "glass": "oklch(1 0 0 / 55%)",
      "gloss-highlight": "oklch(1 0 0 / 95%)",
      "gloss-shade": "oklch(0.3 0.03 285 / 10%)",
      "gloss-depth": "oklch(0.32 0.03 285 / 20%)",
      "gloss-edge": "oklch(0.22 0.02 285 / 10%)",
      "liquid-tint": "oklch(1 0 0 / 18%)",
      "liquid-fallback": "oklch(1 0 0 / 55%)",
      "liquid-rim": "oklch(1 0 0 / 95%)",
      "liquid-edge": "oklch(0.2 0.02 285 / 10%)",
      "liquid-shadow": "oklch(0.22 0.02 285 / 26%)",
      "liquid-glow": "oklch(1 0 0 / 55%)",
      "liquid-shade": "oklch(0.25 0.03 285 / 14%)"
    },
    "dark": {
      "glow": "oklch(0.8 0.16 55)",
      "glow-foreground": "oklch(0.22 0.05 40)",
      "glow-2": "oklch(0.7 0.2 15)",
      "glow-3": "oklch(0.65 0.2 300)",
      "glass": "oklch(0.19 0 0 / 55%)",
      "gloss-highlight": "oklch(1 0 0 / 16%)",
      "gloss-shade": "oklch(0 0 0 / 30%)",
      "gloss-depth": "oklch(0.04 0 0 / 60%)",
      "gloss-edge": "oklch(1 0 0 / 9%)",
      "liquid-tint": "oklch(0.2 0 0 / 22%)",
      "liquid-fallback": "oklch(0.2 0 0 / 45%)",
      "liquid-rim": "oklch(1 0 0 / 60%)",
      "liquid-edge": "oklch(1 0 0 / 10%)",
      "liquid-shadow": "oklch(0 0 0 / 50%)",
      "liquid-glow": "oklch(1 0 0 / 24%)",
      "liquid-shade": "oklch(0 0 0 / 28%)"
    }
  },
  "type": "registry:ui"
}