{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"aurora-rim-card","type":"registry:component","title":"Aurora Rim Card","description":"A night-glass card with a slow aurora rim that turns once every 52 seconds, feathered into light, brightening near the pointer while the card tilts a hair toward it.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/aurora-rim-card.tsx","content":"\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\nimport type { CSSProperties, PointerEvent as ReactPointerEvent, ReactNode } from \"react\";\n\n/**\n * AuroraRimCard — a card with a slow aurora rim.\n *\n * A conic sweep through the sky's colours turns once every 52s around a\n * night-glass card, feathered so it reads as light on an edge, with a faint\n * halo outside it. Near the pointer the rim runs brighter and the halo\n * lifts (380ms), and the card tilts at most 1.5 degrees toward the pointer.\n * Content goes in as children.\n *\n * Part of the Aurora kit: a near-black night (#050608) lit by curtains of\n * aurora in mint #7cf5c4 and sky #38bdf8, a violet #a78bfa blend, a rose\n * #f472b6 crown and an indigo #5b6cc4 fringe, all on one 60s clock; Bricolage\n * Grotesque through var(--font-bricolage) for lit display type over Geist.\n * Respects prefers-reduced-motion. No dependencies beyond React. Paste it as\n * its own file: it repeats the kit's small helpers, which would clash in one\n * module. For the display face, load Bricolage Grotesque with next/font\n * (variable: \"--font-bricolage\") on a parent; elsewhere, load it with a\n * Google Fonts link or @fontsource and set --font-bricolage yourself.\n */\n\nconst SANS = 'var(--font-sans, \"Geist\", \"Inter\", ui-sans-serif, system-ui, sans-serif)';\n\nconst HEX = /^#[0-9a-fA-F]{6}$/;\n\n/** The night the kit is set in. */\nconst SKY = {\n  ground: \"#050608\",\n  panel: \"#0a0d12\",\n  raised: \"#0f141a\",\n  ink: \"rgba(236,244,248,0.94)\",\n  ink2: \"rgba(236,244,248,0.64)\",\n  ink3: \"rgba(236,244,248,0.42)\",\n  line: \"rgba(236,244,248,0.08)\",\n  line2: \"rgba(236,244,248,0.16)\",\n  shadow: \"0 40px 100px -30px rgba(0,0,0,0.7)\",\n} as const;\n\n/**\n * The sky's colours by altitude: the core low in the curtain (two hues it\n * drifts between on the aurora clock), a violet blend above it, a rose crown\n * seen only in a strong display, and an indigo fringe under the lower border.\n */\nexport type AuPalette = { core: string; core2: string; blend: string; high: string; fringe: string };\n\nexport const AU_PALETTES = {\n  boreal: { core: \"#7cf5c4\", core2: \"#38bdf8\", blend: \"#a78bfa\", high: \"#f472b6\", fringe: \"#5b6cc4\" },\n  verdant: { core: \"#6ee7a0\", core2: \"#7cf5c4\", blend: \"#8fb4f0\", high: \"#e879b9\", fringe: \"#5b6cc4\" },\n  violet: { core: \"#a78bfa\", core2: \"#38bdf8\", blend: \"#c4a6fb\", high: \"#f472b6\", fringe: \"#4c5bb8\" },\n} as const satisfies Record<string, AuPalette>;\n\nexport type AuPaletteName = keyof typeof AU_PALETTES;\n\nfunction own<T extends object>(map: T, key: string): key is Extract<keyof T, string> {\n  return Object.prototype.hasOwnProperty.call(map, key);\n}\n\n/** A named palette, or boreal. */\nfunction paletteOf(name: string): AuPalette {\n  return own(AU_PALETTES, name) ? AU_PALETTES[name] : AU_PALETTES.boreal;\n}\n\nfunction rgbOf(hex: string): [number, number, number] {\n  const n = parseInt((HEX.test(hex) ? hex : \"#7cf5c4\").slice(1), 16);\n  return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n}\n\nfunction rgba(hex: string, a: number): string {\n  const [r, g, b] = rgbOf(hex);\n  return `rgba(${r},${g},${b},${a})`;\n}\n\n/**\n * A ref callback that starts an element's CSS animation where the clock\n * already is, so parts that mount at different moments stay in step.\n */\nfunction syncClock(periodS: number) {\n  return (el: HTMLElement | null) => {\n    if (el) el.style.animationDelay = `${(-(performance.now() / 1000) % periodS).toFixed(3)}s`;\n  };\n}\n\nfunction subscribeMotion(cb: () => void) {\n  const m = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n  m.addEventListener(\"change\", cb);\n  return () => m.removeEventListener(\"change\", cb);\n}\n\n/** True when the visitor asked for reduced motion. False on the server. */\nfunction useReducedMotion(): boolean {\n  return useSyncExternalStore(\n    subscribeMotion,\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\n// Each part carries only the CSS it needs, so any one of them works on its own.\n// Nothing is interpolated into these sheets; colours arrive as CSS variables.\n// revert-layer keeps an element's own rounded corners when a host page's focus rule flattens them.\nconst FOCUS_CSS = \".au-scope :focus-visible,.au-scope:focus-visible{outline:2px solid var(--au-ring,#7cf5c4);outline-offset:3px;border-radius:revert-layer}\";\n\n/** The palette as CSS variables, for the parts drawn in CSS. */\nfunction paletteVars(p: AuPalette): CSSProperties {\n  return { \"--au-core\": p.core, \"--au-core2\": p.core2, \"--au-blend\": p.blend, \"--au-high\": p.high, \"--au-ring\": p.core } as CSSProperties;\n}\n\nconst RIM_CSS =\n  \"@property --au-rim{syntax:'<angle>';inherits:true;initial-value:0deg}\" +\n  \"@keyframes au-rim{to{--au-rim:360deg}}\" +\n  \".au-rimcard{animation:au-rim 52s linear infinite;transition:transform 380ms cubic-bezier(0.22,1,0.36,1)}\" +\n  \".au-rimcard .au-rim-hot{opacity:0;transition:opacity 380ms cubic-bezier(0.22,1,0.36,1)}\" +\n  \".au-rimcard:hover .au-rim-hot,.au-rimcard:focus-within .au-rim-hot{opacity:1}\" +\n  \".au-rim-halo{opacity:.16}.au-rimcard:hover .au-rim-halo,.au-rimcard:focus-within .au-rim-halo{opacity:.34}\" +\n  \"@media (prefers-reduced-motion: reduce){.au-rimcard{animation:none;transition:none;transform:none!important}}\";\n\nconst RING_MASK: CSSProperties = {\n  padding: 1.5,\n  WebkitMask: \"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\nexport type AuroraRimCardProps = {\n  children: ReactNode;\n  palette?: AuPaletteName;\n  /** Tilt a hair toward the pointer. */\n  tilt?: boolean;\n  className?: string;\n  style?: CSSProperties;\n};\n\n/**\n * A night-glass card with a slow aurora rim: a conic sweep through the sky's\n * colours turning once every 52s, feathered so it reads as light on an edge\n * rather than a coloured border, with a faint halo of the same light outside\n * it. Near the pointer the rim runs brighter and the halo lifts (380ms), and\n * the card tilts at most 1.5 degrees toward the pointer. Content goes in as\n * children; the rim, halo and tilt never touch it.\n */\nexport function AuroraRimCard({ children, palette = \"boreal\", tilt = true, className, style }: AuroraRimCardProps) {\n  const p = paletteOf(palette);\n  const reduced = useReducedMotion();\n  const cone = `conic-gradient(from var(--au-rim), ${p.core}, ${p.core2}, ${p.blend}, ${rgba(p.high, 0.7)}, ${p.core2}, ${p.core})`;\n  const onMove = (e: ReactPointerEvent<HTMLDivElement>) => {\n    const el = e.currentTarget;\n    const r = el.getBoundingClientRect();\n    const x = (e.clientX - r.left) / (r.width || 1);\n    const y = (e.clientY - r.top) / (r.height || 1);\n    el.style.setProperty(\"--mx\", `${(x * 100).toFixed(1)}%`);\n    el.style.setProperty(\"--my\", `${(y * 100).toFixed(1)}%`);\n    if (tilt && !reduced) el.style.transform = `perspective(900px) rotateX(${((0.5 - y) * 3).toFixed(2)}deg) rotateY(${((x - 0.5) * 3).toFixed(2)}deg)`;\n  };\n  const onLeave = (e: ReactPointerEvent<HTMLDivElement>) => {\n    e.currentTarget.style.transform = \"\";\n  };\n  return (\n    <div\n      ref={syncClock(52)}\n      onPointerMove={onMove}\n      onPointerLeave={onLeave}\n      className={\"au-scope au-rimcard relative isolate rounded-[22px]\" + (className ? \" \" + className : \"\")}\n      style={{ ...paletteVars(p), \"--mx\": \"50%\", \"--my\": \"0%\", color: SKY.ink, fontFamily: SANS, boxShadow: SKY.shadow, ...style } as CSSProperties}\n    >\n      <style>{FOCUS_CSS + RIM_CSS}</style>\n      {/* A faint halo of the rim's light outside the card. */}\n      <span aria-hidden className=\"au-rim-halo pointer-events-none absolute -inset-[2px] rounded-[24px] transition-opacity duration-300\" style={{ background: cone, filter: \"blur(16px)\" }} />\n      {/* The card's own surface, over the halo, so the light stays outside it. */}\n      <span aria-hidden className=\"pointer-events-none absolute inset-0 rounded-[22px]\" style={{ background: SKY.panel }} />\n      {/* The rim itself, feathered. */}\n      <span aria-hidden className=\"pointer-events-none absolute inset-0 rounded-[22px]\" style={{ ...RING_MASK, background: cone, opacity: 0.8, filter: \"blur(0.6px)\" }} />\n      {/* Brighter where the pointer is. */}\n      <span\n        aria-hidden\n        className=\"au-rim-hot pointer-events-none absolute inset-0 rounded-[22px]\"\n        style={{ WebkitMaskImage: \"radial-gradient(180px circle at var(--mx) var(--my), #000, transparent 70%)\", maskImage: \"radial-gradient(180px circle at var(--mx) var(--my), #000, transparent 70%)\" }}\n      >\n        <span className=\"absolute inset-0 rounded-[22px]\" style={{ ...RING_MASK, padding: 2, background: cone, filter: \"blur(1px) brightness(1.4)\" }} />\n      </span>\n      <div className=\"relative\">{children}</div>\n    </div>\n  );\n}\n","type":"registry:component","target":"components/viberdy/aurora-rim-card.tsx"}],"meta":{"tier":"free","tags":["card","rim","border","aurora","conic","tilt","testimonial"],"href":"https://viberdy.dev/library/aurora-rim-card","aiPrompt":"Build a React + Tailwind card, `AuroraRimCard({ children, palette, tilt, className, style })`.\n\nRegister --au-rim (<angle>, inherited) and turn it over 52s on the card, synced to the page clock with a negative delay from performance.now(). The ring: an absolutely positioned span with 1.5px padding, a conic-gradient(from var(--au-rim), core, core2, blend, high at 70%, core2, core) background, masked to its border (a content-box mask excluded from a full one), blur 0.6px, opacity 0.8. A halo behind the card (inset -2px, blur 16px, 0.16, 0.34 on hover or focus-within). A brighter copy of the ring inside a wrapper masked by radial-gradient(180px circle at var(--mx) var(--my)), shown on hover or focus-within over 380ms. On pointermove write --mx and --my and, when tilt is on, a perspective(900px) rotation of at most 1.5 degrees; reset on leave. Dark panel #0a0d12, radius 22px.\n\nAurora grammar: a near-black night #050608 (panels #0a0d12, raised #0f141a; ink #ecf4f8 at 94/64/42%; hairlines at 8% and 16%). The light is real aurora, coloured by altitude: a core in mint #7cf5c4 drifting toward sky #38bdf8 on one shared 60s clock, a violet #a78bfa blend above it, a rose #f472b6 crown seen only in a strong display, and an indigo #5b6cc4 fringe under the lower border (palettes: boreal, verdant #6ee7a0, violet). Never a hue-rotate cycle, never full-saturation rainbow; colour is a function of position and altitude, blended through noise. Curtains have a bright lower border, rays that rise and fray, folds that brighten where a sheet turns edge-on, and stretches that are lit and gone; layers are phase-offset, never in unison. A static 2% dither against banding (not re-seeded). Text never sits on bare aurora: frosted glass (blur 14-18px) or the dark between curtains. Bricolage Grotesque through var(--font-bricolage, \"Bricolage Grotesque\", ...) at 600-650 for lit display type only, Geist for UI, Geist Mono uppercase captions. Radii 20-24px on panels, pills for controls. Motion: the 60s aurora clock, ambient drifts of 30s and longer, discrete hover or focus changes under 450ms, pointer chases that settle over 600-900ms (1 - e^(-4dt)); WebGL runs at 30fps and only on screen. Every CSS-animated glow is started where the clock already is (a negative animation-delay from performance.now()), so parts mounted at different moments stay in step. Nothing interpolated into the small static <style> each part renders; colours arrive as CSS variables. Respect prefers-reduced-motion (still sky, no chases). No dependencies beyond React.","license":"https://viberdy.dev/license"}}