{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"light-lift-card","type":"registry:component","title":"Light Lift Card","description":"A card that lifts toward the pointer with shadows that behave like light: a two-degree tilt, an ambient shadow that widens and drifts away from the side that rose, a contact line that thins, and a plate of light at a colour temperature.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/light-lift-card.tsx","content":"\"use client\";\n\nimport { useRef, useState, useSyncExternalStore } from \"react\";\nimport type { CSSProperties, PointerEvent as ReactPointerEvent } from \"react\";\n\n/**\n * LightLiftCard — a card that lifts toward the pointer, with shadows that behave like light.\n *\n * It tilts at most two degrees toward the pointer and lifts, and its two\n * shadows (a tight contact and a wide ambient, from one light above) move\n * the way a real card's would: the ambient widens and drifts away from the\n * side that rose. A faint paper sheen follows the pointer and the hairline\n * brightens. On it, a plate of light at a colour temperature. CSS only.\n *\n * Part of the Modern Minimal kit: a paper-white room (#f5f5f2, surfaces\n * #ffffff, ink #141412) and one light, dawn #ffa64d, only ever as light.\n * Two-layer shadows from one light above; scroll binds values directly,\n * with no easing. Inter Tight through var(--font-inter-tight) for display\n * over Geist. Respects prefers-reduced-motion. No dependencies beyond React.\n * Paste it as its own file: it repeats the kit's small helpers, which would\n * clash in one module. Load Inter Tight with next/font (variable:\n * \"--font-inter-tight\") on a parent, or from Google Fonts or @fontsource.\n */\n\nconst SANS = 'var(--font-sans, \"Geist\", \"Inter\", ui-sans-serif, system-ui, sans-serif)';\n\nconst MONO = 'var(--font-mono, \"Geist Mono\", ui-monospace, \"SFMono-Regular\", Menlo, Consolas, monospace)';\n\nconst DISPLAY = 'var(--font-inter-tight, \"Inter Tight\", var(--font-sans, \"Geist\"), ui-sans-serif, system-ui, sans-serif)';\n\nconst EASE = \"cubic-bezier(0.16, 1, 0.3, 1)\";\n\n/** A paper-white room and one light. */\nconst PAPER = {\n  ground: \"#f5f5f2\",\n  surface: \"#ffffff\",\n  well: \"#ecebe6\",\n  solid: \"#141412\",\n  ink: \"rgba(20,20,18,0.92)\",\n  ink2: \"rgba(20,20,18,0.6)\",\n  ink3: \"rgba(20,20,18,0.38)\",\n  line: \"rgba(20,20,18,0.08)\",\n  line2: \"rgba(20,20,18,0.14)\",\n  dawn: \"#ffa64d\",\n  night: \"#0e0f11\",\n} as const;\n\nfunction clamp(v: number, lo: number, hi: number): number {\n  return v < lo ? lo : v > hi ? hi : v;\n}\n\n/** Links: strip tabs and newlines, refuse backslashes, allow http(s), mailto, tel and same-site paths. */\nfunction safeHref(raw: string): string {\n  const v = raw.replace(/[\\t\\n\\r]/g, \"\").trim();\n  if (!v || v.includes(\"\\\\\")) return \"#\";\n  if (/^(https?:|mailto:|tel:)/i.test(v)) return v;\n  if (/^[/#?]/.test(v) && !/^\\/\\//.test(v)) return v;\n  return \"#\";\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// revert-layer keeps an element's own rounded corners when a host page's focus rule flattens them.\nconst FOCUS_CSS = \".mm-scope :focus-visible,.mm-scope:focus-visible{outline:2px solid var(--mm-ring,#141412)!important;outline-offset:3px;border-radius:revert-layer}\";\n\n/** A colour temperature as a CSS colour (sRGB), for swatches of light. */\nfunction mmKelvinCss(k: number, alpha = 1): string {\n  const t = clamp(k, 1000, 12000) / 100;\n  const r = t <= 66 ? 255 : clamp(329.7 * Math.pow(t - 60, -0.1332), 0, 255);\n  const g = t <= 66 ? clamp(99.47 * Math.log(t) - 161.12, 0, 255) : clamp(288.12 * Math.pow(t - 60, -0.0755), 0, 255);\n  const b = t >= 66 ? 255 : t <= 19 ? 0 : clamp(138.52 * Math.log(t - 10) - 305.04, 0, 255);\n  return `rgba(${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}, ${alpha})`;\n}\n\n/** A small plate of light at a colour temperature: the kit's code-drawn stand-in for a product shot. */\nfunction MmLightPlate({ kelvin = 3000, glow = 1, className = \"\" }: { kelvin?: number; glow?: number; className?: string }) {\n  const c = mmKelvinCss(kelvin, 0.9 * glow);\n  const soft = mmKelvinCss(kelvin, 0.28 * glow);\n  return (\n    <div aria-hidden className={\"relative overflow-hidden \" + className} style={{ background: `radial-gradient(120% 90% at 50% 38%, ${soft}, transparent 62%), linear-gradient(180deg, #f0efea 0%, #f7f6f2 62%, #e9e8e2 62.2%, #f1f0eb 100%)` }}>\n      <div className=\"absolute left-1/2 top-[38%] aspect-square w-[34%] -translate-x-1/2 -translate-y-1/2 rounded-full\" style={{ background: `radial-gradient(circle at 50% 44%, #fffaf2 0%, ${c} 58%, ${mmKelvinCss(kelvin, 0.55 * glow)} 100%)`, boxShadow: `0 0 60px 12px ${soft}` }} />\n      <div className=\"absolute left-1/2 top-[62%] h-[7%] w-[24%] -translate-x-1/2 -translate-y-full rounded-[3px]\" style={{ background: \"linear-gradient(180deg, #fbfbf8, #dedcd5)\", boxShadow: \"0 6px 10px -6px rgba(20,20,18,0.35)\" }} />\n    </div>\n  );\n}\n\n/**\n * LightLiftCard — a card that lifts toward the pointer, with shadows that\n * behave like light.\n *\n * It tilts at most two degrees toward the pointer and lifts, and its two\n * shadows (a tight contact and a wide ambient, both from one light above)\n * move the way a real card's would: the ambient widens and drifts away from\n * the side that rose, the contact thins. A paper sheen at 6% follows the\n * pointer and the hairline brightens. On it, a plate of light at a colour\n * temperature. Focus does the same as hover. CSS transforms only.\n */\nexport function LightLiftCard({\n  title,\n  kicker,\n  body,\n  kelvin = 2700,\n  meta,\n  href,\n  className = \"\",\n}: {\n  title: string;\n  kicker?: string;\n  body?: string;\n  /** The colour temperature of the plate's light. */\n  kelvin?: number;\n  meta?: string;\n  href?: string;\n  className?: string;\n}) {\n  const ref = useRef<HTMLDivElement>(null);\n  const reduced = useReducedMotion();\n  const [t, setT] = useState({ x: 0, y: 0, on: false });\n  const move = (e: ReactPointerEvent<HTMLElement>) => {\n    const r = e.currentTarget.getBoundingClientRect();\n    setT({ x: ((e.clientX - r.left) / Math.max(1, r.width) - 0.5) * 2, y: ((e.clientY - r.top) / Math.max(1, r.height) - 0.5) * 2, on: true });\n  };\n  const rest = () => setT({ x: 0, y: 0, on: false });\n  const lift = t.on ? 1 : 0;\n  const rx = reduced ? 0 : -t.y * 2;\n  const ry = reduced ? 0 : t.x * 2;\n  const shadow = `${Math.round(-t.x * 2)}px ${1 + lift}px ${2 + lift * 2}px rgba(20,20,18,${0.06 - lift * 0.01}), ${Math.round(-t.x * 10)}px ${24 + lift * 12 + Math.round(-t.y * 6)}px ${48 + lift * 24}px -12px rgba(20,20,18,${0.1 + lift * 0.04})`;\n  const inner = (\n    <>\n      <MmLightPlate kelvin={kelvin} className=\"aspect-[16/10] w-full rounded-[14px]\" />\n      <div className=\"flex flex-col gap-2 px-1 pb-1 pt-4\">\n        {kicker ? (\n          <span className=\"text-[11px] uppercase\" style={{ fontFamily: MONO, letterSpacing: \"0.14em\", color: PAPER.ink3 }}>\n            {kicker}\n          </span>\n        ) : null}\n        <h3 className=\"m-0 text-[22px] font-semibold leading-[1.15]\" style={{ fontFamily: DISPLAY, letterSpacing: \"-0.02em\", color: PAPER.solid }}>\n          {title}\n        </h3>\n        {body ? (\n          <p className=\"m-0 text-[14.5px] leading-[1.55]\" style={{ color: PAPER.ink2 }}>\n            {body}\n          </p>\n        ) : null}\n        {meta ? (\n          <span className=\"mt-1 text-[11px] uppercase tabular-nums\" style={{ fontFamily: MONO, letterSpacing: \"0.1em\", color: PAPER.ink3 }}>\n            {meta}\n          </span>\n        ) : null}\n      </div>\n      <span\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-[20px]\"\n        style={{ background: `radial-gradient(420px circle at ${50 + t.x * 50}% ${50 + t.y * 50}%, rgba(255,255,255,0.6), transparent 55%)`, opacity: t.on ? 0.1 : 0, mixBlendMode: \"soft-light\", transition: `opacity 260ms ${EASE}` }}\n      />\n    </>\n  );\n  const shell = \"mm-scope relative flex h-full flex-col rounded-[20px] p-3 no-underline outline-none \" + className;\n  const shellStyle: CSSProperties = {\n    background: PAPER.surface,\n    border: `1px solid ${t.on ? PAPER.line2 : PAPER.line}`,\n    boxShadow: shadow,\n    transform: `perspective(900px) rotateX(${rx}deg) rotateY(${ry}deg) translateY(${-lift * 2}px)`,\n    transition: reduced ? \"none\" : `transform 380ms ${EASE}, box-shadow 380ms ${EASE}, border-color 260ms ${EASE}`,\n    fontFamily: SANS,\n    color: PAPER.ink,\n  };\n  return (\n    <div ref={ref} className=\"h-full\">\n      <style>{FOCUS_CSS}</style>\n      {href ? (\n        <a href={safeHref(href)} className={shell} style={shellStyle} onPointerMove={move} onPointerLeave={rest} onFocus={() => setT({ x: 0.2, y: -0.3, on: true })} onBlur={rest}>\n          {inner}\n        </a>\n      ) : (\n        <article tabIndex={0} className={shell} style={shellStyle} onPointerMove={move} onPointerLeave={rest} onFocus={() => setT({ x: 0.2, y: -0.3, on: true })} onBlur={rest}>\n          {inner}\n        </article>\n      )}\n    </div>\n  );\n}\n","type":"registry:component","target":"components/viberdy/light-lift-card.tsx"}],"meta":{"tier":"free","tags":["card","tilt","shadow","hover","product","css"],"href":"https://viberdy.dev/library/light-lift-card","aiPrompt":"Build a React + Tailwind card, `LightLiftCard({ title, kicker, body, kelvin, meta, href, className })`.\n\nOn pointermove, x and y run -1 to 1 across the card: rotateX(-y x 2deg) rotateY(x x 2deg) translateY(-2px) in 900px perspective, 380ms; the contact shadow ${-x x 2}px ${1 + 1}px ${4}px at 5%, the ambient ${-x x 10}px ${36 - y x 6}px 72px -12px at 14% (at rest 0 1px 2px 6% and 0 24px 48px -12px 10%); the hairline from 8% to 14%; a soft-light sheen 420px wide at the pointer, 10% opacity. The plate: a table line at 62%, a wall gradient, a lamp orb whose radial gradient and glow take the colour of `kelvin` (a blackbody approximation in sRGB), a ceramic base with a contact shadow. Radius 20px, white on the paper ground.\n\nModern Minimal grammar: a paper-white room, ground #f5f5f2 (surfaces #ffffff that lift, a recessed well #ecebe6), ink #141412 at 92/60/38% (never grey-400 body copy), hairlines at 8% and 14%; one light, dawn #ffa64d, only ever as light (the lamp's glow, a lit state), never as a fill. Shadows come from one light above in two layers: a contact 0 1px 2px rgba(20,20,18,0.06) and an ambient 0 24px 48px -12px rgba(20,20,18,0.1), both falling the same way; a pressed thing loses the ambient, a lifted one widens it. Type: Inter Tight through var(--font-inter-tight, \"Inter Tight\", ...) for display at 600 with -0.035em tracking and 0.98 leading (tracking tightens only at display sizes), Geist for reading at 16-17px/1.55, Geist Mono uppercase at 11-12px for readouts. Radii 12px controls (pills for buttons), 20px cards, 28px media. Motion: scroll binds values directly with no easing (a value moves exactly with the scroll, like scrubbing film); discrete hover and press states take 150-260ms with a spring back past rest; ambient loops 40s or more. Respect prefers-reduced-motion (ambient scenes hold still; scroll-bound values still follow the scroll, which the visitor drives). No dependencies beyond React.","license":"https://viberdy.dev/license"}}