{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"glass-card","type":"registry:ui","title":"Glass Card","description":"A frosted glass card with a lit rim and a soft shine that follows the pointer, with a solid fallback where blur isn't supported.","dependencies":[],"registryDependencies":["https://ui.mekaigames.com/r/theme.json"],"files":[{"path":"components/ui/glass-card.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useRef, useSyncExternalStore, type HTMLAttributes, type PointerEvent, type ReactNode } from \"react\";\n\ntype GlassCardProps = Omit<HTMLAttributes<HTMLDivElement>, \"children\"> & {\n  children?: ReactNode;\n  /** Background blur in pixels. */\n  blur?: number;\n  /** Color boost for what shows through, 1 is unchanged. */\n  saturation?: number;\n  /** Glass tint color, as hex. */\n  tint?: string;\n  /** Tint strength, 0 to 1. */\n  opacity?: number;\n  /** Border highlight strength, 0 to 1. */\n  borderOpacity?: number;\n  /** A soft light that follows the pointer inside the glass. */\n  shine?: boolean;\n  /** Corner radius in pixels. */\n  radius?: number;\n};\n\nconst noSubscribe = () => () => {};\n\nfunction supportsBackdrop() {\n  return typeof CSS !== \"undefined\" && (CSS.supports(\"backdrop-filter\", \"blur(1px)\") || CSS.supports(\"-webkit-backdrop-filter\", \"blur(1px)\"));\n}\n\nfunction rgba(hex: string, alpha: number) {\n  const clean = hex.replace(\"#\", \"\");\n  const full = clean.length === 3 ? clean.replace(/./g, (c) => c + c) : clean.slice(0, 6);\n  const n = parseInt(full, 16);\n  if (Number.isNaN(n)) return `rgba(255,255,255,${alpha})`;\n  return `rgba(${(n >> 16) & 255},${(n >> 8) & 255},${n & 255},${alpha})`;\n}\n\nexport function GlassCard({\n  children,\n  blur = 18,\n  saturation = 1.6,\n  tint = \"#ffffff\",\n  opacity = 0.08,\n  borderOpacity = 0.18,\n  shine = true,\n  radius = 28,\n  className = \"\",\n  style,\n  onPointerMove,\n  onPointerLeave,\n  ...rest\n}: GlassCardProps) {\n  const card = useRef<HTMLDivElement>(null);\n  // Checked once on the client; the server assumes support and the client corrects it.\n  const glass = useSyncExternalStore(noSubscribe, supportsBackdrop, () => true);\n  const a = Math.max(0, Math.min(1, opacity));\n  const b = Math.max(0, Math.min(1, borderOpacity));\n  const filter = `blur(${blur}px) saturate(${saturation})`;\n\n  function handleMove(e: PointerEvent<HTMLDivElement>) {\n    onPointerMove?.(e);\n    const el = card.current;\n    if (!el || !shine) return;\n    const box = el.getBoundingClientRect();\n    el.style.setProperty(\"--sx\", `${e.clientX - box.left}px`);\n    el.style.setProperty(\"--sy\", `${e.clientY - box.top}px`);\n    el.style.setProperty(\"--shine\", \"1\");\n  }\n\n  function handleLeave(e: PointerEvent<HTMLDivElement>) {\n    onPointerLeave?.(e);\n    card.current?.style.setProperty(\"--shine\", \"0\");\n  }\n\n  return (\n    <div\n      {...rest}\n      ref={card}\n      onPointerMove={handleMove}\n      onPointerLeave={handleLeave}\n      className={`relative isolate overflow-hidden ${className}`}\n      style={{\n        borderRadius: radius,\n        // Without backdrop-filter the glass turns into a frosted, mostly opaque panel so text stays readable.\n        background: glass ? rgba(tint, a) : `linear-gradient(${rgba(tint, Math.min(1, a + 0.1))}, ${rgba(tint, Math.min(1, a + 0.1))}), rgba(23,20,18,0.92)`,\n        backdropFilter: glass ? filter : undefined,\n        WebkitBackdropFilter: glass ? filter : undefined,\n        boxShadow: `inset 0 1px 0 ${rgba(\"#ffffff\", Math.min(1, b + 0.12))}, inset 0 0 0 1px ${rgba(\"#ffffff\", b)}, 0 24px 60px -24px rgba(0,0,0,0.65)`,\n        ...style,\n      }}\n    >\n      {/* Top-left edge highlight, like light catching the rim of the glass. */}\n      <span\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-0 -z-10 rounded-[inherit]\"\n        style={{ background: `linear-gradient(135deg, ${rgba(\"#ffffff\", b * 0.9)} 0%, transparent 38%)` }}\n      />\n      {shine ? (\n        <span\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-0 -z-10 rounded-[inherit] transition-opacity duration-500\"\n          style={{\n            opacity: \"var(--shine, 0)\",\n            background: `radial-gradient(360px circle at var(--sx, 50%) var(--sy, 0%), ${rgba(\"#ffffff\", 0.16)}, transparent 55%)`,\n          }}\n        />\n      ) : null}\n      {children}\n    </div>\n  );\n}\n"}]}