{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "parallax-card",
  "type": "registry:component",
  "title": "Parallax Card",
  "description": "Real 3D layers (sky, stars, planet, ring, dunes, text and shine) that separate at different depths as the card tilts.",
  "author": "Marcelo Treviño Velázquez <https://furin.dev>",
  "dependencies": [],
  "categories": [
    "Cards"
  ],
  "docs": "Installed in components/furin/parallax-card/. Docs, live controls and props table: https://furin.dev/components/parallax-card/",
  "files": [
    {
      "path": "registry/parallax-card/ParallaxCard.tsx",
      "content": "\"use client\";\nimport { useCallback, useEffect, useId, useMemo, useRef } from \"react\";\nimport type { CSSProperties, PointerEvent, ReactNode } from \"react\";\nimport \"./ParallaxCard.css\";\n\nexport interface ParallaxCardProps {\n  /** Título grande de la tarjeta. */\n  children?: ReactNode;\n  /** Texto pequeño sobre el título. */\n  eyebrow?: string;\n  /** Texto de apoyo debajo del título. */\n  caption?: string;\n  /** Ancho máximo de la tarjeta, en px. */\n  width?: number;\n  /** Inclinación máxima bajo el cursor, en grados. */\n  tilt?: number;\n  /** Cuánto se separan las capas (1 = normal, 0 = planas). */\n  depth?: number;\n  /** Color del cielo, arriba. */\n  skyFrom?: string;\n  /** Color del cielo en el horizonte. */\n  skyTo?: string;\n  /** Color del sujeto (el planeta y su anillo). */\n  accent?: string;\n  /** Clase extra para el contenedor. */\n  className?: string;\n  /** Estilos extra para el contenedor. */\n  style?: CSSProperties;\n}\n\nconst REST_X = 5;\nconst REST_Y = -9;\nconst PERSPECTIVE = 900;\n\n/** PRNG determinista para que las estrellas no cambien entre servidor y cliente. */\nfunction rng(seed: number) {\n  let a = seed;\n  return () => { a = (a * 1664525 + 1013904223) % 4294967296; return a / 4294967296; };\n}\n\n/** Tarjeta con capas reales en 3D (cielo, estrellas, planeta, anillo, dunas, texto y brillo) que se separan al inclinar. */\nexport function ParallaxCard({\n  children = \"Explore\",\n  eyebrow = \"New world\",\n  caption = \"Layers at different depths.\",\n  width = 300,\n  tilt = 14,\n  depth = 1,\n  skyFrom = \"#12104a\",\n  skyTo = \"#ff7a8a\",\n  accent = \"#ffb36b\",\n  className = \"\",\n  style,\n}: ParallaxCardProps) {\n  const uid = useId().replace(/:/g, \"\");\n  const rootRef = useRef<HTMLDivElement>(null);\n  const tiltRef = useRef<HTMLDivElement>(null);\n  const shadowRef = useRef<HTMLDivElement>(null);\n  const st = useRef({ rx: REST_X, ry: REST_Y, vx: 0, vy: 0, tx: REST_X, ty: REST_Y });\n  const raf = useRef(0);\n  const reduced = useRef(false);\n  const tiltMax = useRef(tilt);\n  tiltMax.current = tilt;\n\n  const stars = useMemo(() => {\n    const r = rng(42);\n    return Array.from({ length: 70 }, () => ({ x: r() * 100, y: r() * 70, r: 0.12 + r() * r() * 0.42, o: 0.35 + r() * 0.65 }));\n  }, []);\n\n  const paint = useCallback(() => {\n    const s = st.current;\n    const el = tiltRef.current;\n    if (!el) return;\n    el.style.setProperty(\"--furin-parallax-card-rx\", `${s.rx.toFixed(2)}deg`);\n    el.style.setProperty(\"--furin-parallax-card-ry\", `${s.ry.toFixed(2)}deg`);\n    el.style.setProperty(\"--furin-parallax-card-px\", (s.ry / 16).toFixed(3));\n    el.style.setProperty(\"--furin-parallax-card-py\", (-s.rx / 16).toFixed(3));\n    el.style.setProperty(\"--furin-parallax-card-gx\", `${(50 - s.ry * 3).toFixed(1)}%`);\n    el.style.setProperty(\"--furin-parallax-card-gy\", `${(35 + s.rx * 3).toFixed(1)}%`);\n    rootRef.current?.style.setProperty(\"--furin-parallax-card-sh\", `${(-s.ry * 1.2).toFixed(1)}px`);\n  }, []);\n\n  const tick = useCallback(() => {\n    raf.current = 0;\n    const s = st.current;\n    const dt = 1 / 120;\n    for (let i = 0; i < 2; i++) {\n      s.vx += (120 * (s.tx - s.rx) - 15 * s.vx) * dt; s.rx += s.vx * dt;\n      s.vy += (120 * (s.ty - s.ry) - 15 * s.vy) * dt; s.ry += s.vy * dt;\n    }\n    const moving = Math.abs(s.tx - s.rx) + Math.abs(s.ty - s.ry) > 0.01 || Math.abs(s.vx) + Math.abs(s.vy) > 0.03;\n    if (!moving) { s.rx = s.tx; s.ry = s.ty; s.vx = s.vy = 0; }\n    paint();\n    if (moving) raf.current = requestAnimationFrame(tick);\n  }, [paint]);\n\n  const wake = useCallback(() => {\n    if (reduced.current) { const s = st.current; s.rx = s.tx; s.ry = s.ty; paint(); return; }\n    if (!raf.current) raf.current = requestAnimationFrame(tick);\n  }, [paint, tick]);\n\n  useEffect(() => {\n    reduced.current = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    paint();\n    return () => { cancelAnimationFrame(raf.current); raf.current = 0; };\n  }, [paint]);\n\n  const onMove = (e: PointerEvent<HTMLDivElement>) => {\n    const ref = shadowRef.current;\n    const root = rootRef.current;\n    if (!ref || !root || reduced.current) return;\n    // Se normaliza contra el tamaño de la tarjeta: a un pelo del borde ya está inclinada al máximo.\n    const r = root.getBoundingClientRect();\n    const nx = Math.max(-1, Math.min(1, (e.clientX - (r.left + r.width / 2)) / (ref.offsetWidth * 0.75)));\n    const ny = Math.max(-1, Math.min(1, (e.clientY - (r.top + r.height / 2)) / (ref.offsetHeight * 0.75)));\n    st.current.ty = nx * tiltMax.current;\n    st.current.tx = -ny * tiltMax.current;\n    wake();\n  };\n  const onLeave = () => { st.current.tx = REST_X; st.current.ty = REST_Y; wake(); };\n\n  const vars = {\n    \"--furin-parallax-card-w\": `${width}px`,\n    \"--furin-parallax-card-depth\": depth,\n    \"--furin-parallax-card-persp\": `${PERSPECTIVE}px`,\n    \"--furin-parallax-card-persp-n\": PERSPECTIVE,\n    \"--furin-parallax-card-from\": skyFrom,\n    \"--furin-parallax-card-to\": skyTo,\n    \"--furin-parallax-card-accent\": accent,\n  } as CSSProperties;\n\n  // z (px) de cada capa; la escala compensa la perspectiva para que en reposo todo encaje.\n  const z = (n: number) => ({ \"--furin-parallax-card-z\": n } as CSSProperties);\n  const ringPath = (rx: number, ry: number) => `M ${50 - rx} 52 A ${rx} ${ry} 0 1 0 ${50 + rx} 52 A ${rx} ${ry} 0 1 0 ${50 - rx} 52`;\n\n  return (\n    <div ref={rootRef} className={`furin-parallax-card ${className}`} style={{ ...vars, ...style }} onPointerMove={onMove} onPointerLeave={onLeave}>\n      <div ref={shadowRef} className=\"furin-parallax-card__shadow\" aria-hidden=\"true\" />\n      <div ref={tiltRef} className=\"furin-parallax-card__tilt\" role=\"img\" aria-label={`${typeof children === \"string\" ? children : \"Card\"}. ${caption}`}>\n        {/* Cielo */}\n        <div className=\"furin-parallax-card__layer furin-parallax-card__sky\" style={z(-70)} />\n        {/* Estrellas */}\n        <div className=\"furin-parallax-card__layer furin-parallax-card__clip\" style={z(-52)}>\n          <svg viewBox=\"0 0 100 133\" preserveAspectRatio=\"xMidYMid slice\" aria-hidden=\"true\">\n            {stars.map((s, i) => <circle key={i} cx={s.x} cy={s.y * 1.3} r={s.r} fill=\"#fff\" opacity={s.o} />)}\n          </svg>\n        </div>\n        {/* Montañas lejanas */}\n        <div className=\"furin-parallax-card__layer furin-parallax-card__clip\" style={z(-34)}>\n          <svg viewBox=\"0 0 100 133\" preserveAspectRatio=\"none\" aria-hidden=\"true\">\n            <defs>\n              <linearGradient id={`${uid}-m1`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stopColor=\"#7b3f8f\" /><stop offset=\"1\" stopColor=\"#2a1760\" /></linearGradient>\n            </defs>\n            <path d=\"M0 80 L12 70 L21 75 L34 59 L46 73 L58 63 L71 77 L84 61 L100 74 V133 H0Z\" fill={`url(#${uid}-m1)`} opacity=\"0.85\" />\n          </svg>\n        </div>\n        {/* Anillo (la mitad de atrás) */}\n        <div className=\"furin-parallax-card__layer\" style={z(-12)}>\n          <svg viewBox=\"0 0 100 133\" aria-hidden=\"true\">\n            <defs>\n              <linearGradient id={`${uid}-r`} x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\"><stop offset=\"0\" stopColor=\"var(--furin-parallax-card-accent)\" stopOpacity=\"0\" /><stop offset=\"0.25\" stopColor=\"var(--furin-parallax-card-accent)\" stopOpacity=\"0.9\" /><stop offset=\"0.75\" stopColor=\"#ffe6c4\" stopOpacity=\"0.95\" /><stop offset=\"1\" stopColor=\"var(--furin-parallax-card-accent)\" stopOpacity=\"0\" /></linearGradient>\n              <clipPath id={`${uid}-back`}><rect x=\"-60\" y=\"-80\" width=\"220\" height=\"132\" transform=\"rotate(-16 50 52)\" /></clipPath>\n            </defs>\n            <g clipPath={`url(#${uid}-back)`} fill=\"none\" stroke={`url(#${uid}-r)`}>\n              <path d={ringPath(40, 9.5)} transform=\"rotate(-16 50 52)\" strokeWidth=\"2.6\" opacity=\"0.9\" />\n              <path d={ringPath(35, 8)} transform=\"rotate(-16 50 52)\" strokeWidth=\"1.2\" opacity=\"0.7\" />\n              <path d={ringPath(31.5, 7)} transform=\"rotate(-16 50 52)\" strokeWidth=\"0.6\" opacity=\"0.6\" />\n            </g>\n          </svg>\n        </div>\n        {/* Sujeto: el planeta */}\n        <div className=\"furin-parallax-card__layer\" style={z(8)}>\n          <div className=\"furin-parallax-card__planet\" />\n        </div>\n        {/* Anillo (la mitad de adelante) */}\n        <div className=\"furin-parallax-card__layer\" style={z(26)}>\n          <svg viewBox=\"0 0 100 133\" aria-hidden=\"true\">\n            <defs>\n              <clipPath id={`${uid}-front`}><rect x=\"-60\" y=\"52\" width=\"220\" height=\"132\" transform=\"rotate(-16 50 52)\" /></clipPath>\n            </defs>\n            <g clipPath={`url(#${uid}-front)`} fill=\"none\" stroke={`url(#${uid}-r)`}>\n              <path d={ringPath(40, 9.5)} transform=\"rotate(-16 50 52)\" strokeWidth=\"2.6\" opacity=\"0.95\" />\n              <path d={ringPath(35, 8)} transform=\"rotate(-16 50 52)\" strokeWidth=\"1.2\" opacity=\"0.8\" />\n              <path d={ringPath(31.5, 7)} transform=\"rotate(-16 50 52)\" strokeWidth=\"0.6\" opacity=\"0.7\" />\n            </g>\n          </svg>\n        </div>\n        {/* Dunas de primer plano */}\n        <div className=\"furin-parallax-card__layer furin-parallax-card__clip\" style={z(46)}>\n          <svg viewBox=\"0 0 100 133\" preserveAspectRatio=\"none\" aria-hidden=\"true\">\n            <defs>\n              <linearGradient id={`${uid}-d`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stopColor=\"#1c0d44\" /><stop offset=\"1\" stopColor=\"#07031a\" /></linearGradient>\n              <linearGradient id={`${uid}-dl`} x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\"><stop offset=\"0\" stopColor=\"var(--furin-parallax-card-to)\" stopOpacity=\"0\" /><stop offset=\"0.55\" stopColor=\"var(--furin-parallax-card-to)\" stopOpacity=\"0.95\" /><stop offset=\"1\" stopColor=\"var(--furin-parallax-card-to)\" stopOpacity=\"0.1\" /></linearGradient>\n            </defs>\n            <path d=\"M0 88 C 18 79, 34 83, 52 88 S 86 80, 100 75 V133 H0Z\" fill={`url(#${uid}-d)`} />\n            <path d=\"M0 88 C 18 79, 34 83, 52 88 S 86 80, 100 75\" fill=\"none\" stroke={`url(#${uid}-dl)`} strokeWidth=\"0.45\" />\n          </svg>\n        </div>\n        {/* Texto */}\n        <div className=\"furin-parallax-card__layer furin-parallax-card__text\" style={z(86)}>\n          <span className=\"furin-parallax-card__eyebrow\">{eyebrow}</span>\n          <h3 className=\"furin-parallax-card__title\">{children}</h3>\n          <p className=\"furin-parallax-card__caption\">{caption}</p>\n        </div>\n        {/* Brillo */}\n        <div className=\"furin-parallax-card__layer furin-parallax-card__shine\" style={z(118)} />\n      </div>\n    </div>\n  );\n}\n\nexport default ParallaxCard;\n",
      "type": "registry:component",
      "target": "components/furin/parallax-card/ParallaxCard.tsx"
    },
    {
      "path": "registry/parallax-card/ParallaxCard.css",
      "content": ".furin-parallax-card {\n  --furin-parallax-card-sh: 0px;\n  position: relative;\n  width: 100%;\n  height: 100%;\n  min-height: 420px;\n  display: grid;\n  place-items: center;\n  perspective: var(--furin-parallax-card-persp);\n  touch-action: pan-y;\n  font-family: Geist, -apple-system, BlinkMacSystemFont, \"SF Pro Display\", system-ui, sans-serif;\n}\n.furin-parallax-card__shadow,\n.furin-parallax-card__tilt {\n  grid-area: 1 / 1;\n  width: min(var(--furin-parallax-card-w), calc(100% - 48px));\n  aspect-ratio: 3 / 4;\n}\n.furin-parallax-card__shadow {\n  border-radius: 8%;\n  background: #000;\n  filter: blur(26px);\n  opacity: 0.65;\n  transform: translate(var(--furin-parallax-card-sh), 6%) scale(0.88, 0.9);\n  pointer-events: none;\n}\n.furin-parallax-card__tilt {\n  position: relative;\n  transform-style: preserve-3d;\n  transform: rotateX(var(--furin-parallax-card-rx, 5deg)) rotateY(var(--furin-parallax-card-ry, -9deg));\n}\n.furin-parallax-card__layer {\n  position: absolute;\n  inset: 0;\n  border-radius: 7.5% / 5.6%;\n  container-type: inline-size;\n  pointer-events: none;\n  /* z en px; la escala 1 − z/perspectiva deja la composición intacta en reposo. */\n  --furin-parallax-card-zz: calc(var(--furin-parallax-card-z) * var(--furin-parallax-card-depth));\n  transform:\n    translate3d(calc(var(--furin-parallax-card-px, 0) * var(--furin-parallax-card-z) * var(--furin-parallax-card-depth) * -0.22px),\n                calc(var(--furin-parallax-card-py, 0) * var(--furin-parallax-card-z) * var(--furin-parallax-card-depth) * -0.22px),\n                calc(var(--furin-parallax-card-zz) * 1px))\n    scale(calc(1 - var(--furin-parallax-card-zz) / var(--furin-parallax-card-persp-n)));\n}\n.furin-parallax-card__sky,\n.furin-parallax-card__shine,\n.furin-parallax-card__clip { overflow: hidden; }\n.furin-parallax-card__layer svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }\n\n.furin-parallax-card__sky {\n  background:\n    radial-gradient(90% 45% at 50% 76%, color-mix(in srgb, var(--furin-parallax-card-to) 70%, #fff) 0%, transparent 70%),\n    linear-gradient(180deg, var(--furin-parallax-card-from) 0%, color-mix(in srgb, var(--furin-parallax-card-from) 55%, var(--furin-parallax-card-to)) 52%, var(--furin-parallax-card-to) 100%);\n  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12);\n}\n\n.furin-parallax-card__planet {\n  position: absolute;\n  left: 29%;\n  top: calc(52 / 133 * 100% - 21%);\n  width: 42%;\n  aspect-ratio: 1;\n  border-radius: 50%;\n  background:\n    radial-gradient(circle at 30% 26%, #fff1d6 0%, color-mix(in srgb, var(--furin-parallax-card-accent) 70%, #fff) 14%, var(--furin-parallax-card-accent) 34%, #d9506f 62%, #4a1668 100%);\n  box-shadow:\n    inset -4.2cqw -4.6cqw 8cqw rgb(28 4 70 / 0.75),\n    inset 1.6cqw 1.6cqw 4cqw rgb(255 238 205 / 0.35),\n    0 0 14cqw rgb(255 150 120 / 0.38);\n}\n.furin-parallax-card__planet::after {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  border-radius: 50%;\n  background: repeating-linear-gradient(-16deg, rgb(255 255 255 / 0.13) 0 2.4%, transparent 2.4% 6.5%, rgb(60 0 60 / 0.12) 6.5% 8.5%, transparent 8.5% 13%);\n  mix-blend-mode: soft-light;\n}\n\n.furin-parallax-card__text {\n  display: flex;\n  flex-direction: column;\n  justify-content: flex-end;\n  padding: 0 8cqw 7cqw;\n  color: #fff;\n}\n.furin-parallax-card__eyebrow {\n  align-self: flex-start;\n  margin-bottom: 3cqw;\n  padding: 1.4cqw 3cqw;\n  border-radius: 99px;\n  font: 600 3cqw/1 Geist, system-ui, sans-serif;\n  letter-spacing: 0.16em;\n  text-transform: uppercase;\n  background: rgb(255 255 255 / 0.14);\n  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.28);\n}\n.furin-parallax-card__title {\n  margin: 0;\n  font: 700 12cqw/1 Geist, -apple-system, system-ui, sans-serif;\n  letter-spacing: -0.035em;\n  text-shadow: 0 0.6cqw 2.2cqw rgb(25 6 70 / 0.65);\n}\n.furin-parallax-card__caption {\n  margin: 2.4cqw 0 0;\n  max-width: 78%;\n  font: 500 4.2cqw/1.4 Geist, system-ui, sans-serif;\n  color: rgb(255 255 255 / 0.82);\n  text-shadow: 0 0.3cqw 1.4cqw rgb(25 6 70 / 0.7);\n}\n.furin-parallax-card__shine {\n  background:\n    radial-gradient(circle at var(--furin-parallax-card-gx, 50%) var(--furin-parallax-card-gy, 35%), rgb(255 255 255 / 0.3), transparent 42%),\n    linear-gradient(118deg, rgb(255 255 255 / 0.16) 0%, transparent 26%, transparent 72%, rgb(255 255 255 / 0.07) 100%);\n  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.2), inset 0 1.2cqw 2cqw -1cqw rgb(255 255 255 / 0.35);\n}\n",
      "type": "registry:file",
      "target": "components/furin/parallax-card/ParallaxCard.css"
    }
  ]
}
