{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text-depth-layers",
  "type": "registry:component",
  "title": "Depth Layers",
  "description": "Text built from many stacked layers that shift with the pointer for real parallax depth, with a shadow stack for volume. It drifts on its own until the pointer arrives.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "text",
    "3d",
    "parallax",
    "depth",
    "extrude",
    "pointer",
    "typography"
  ],
  "docs": "https://hyperblur.dev/effects/text-depth-layers",
  "files": [
    {
      "path": "registry/hyperblur/text-depth-layers.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/text-depth-layers.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface DepthLayersProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n  children: string;\n  layers?: number;\n  depth?: number;\n  tilt?: number;\n  color?: string;\n  accent?: string;\n  idle?: boolean;\n}\n\nconst css = `\n.hb-qs7 {\n  --hb-qs7-c: #2f7bff;\n  --hb-qs7-f: #f2f2f2;\n  --hb-qs7-x: 0;\n  --hb-qs7-y: 0;\n  position: relative;\n  box-sizing: border-box;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  width: 100%;\n  padding: 0.35em 0.2em;\n  font: inherit;\n  touch-action: pan-y;\n  perspective: 800px;\n}\n.hb-qs7 *, .hb-qs7 *::before, .hb-qs7 *::after { box-sizing: border-box; }\n.hb-qs7-s {\n  display: inline-grid;\n  transform-style: preserve-3d;\n  transform: rotateX(calc(var(--hb-qs7-y) * var(--hb-qs7-tilt) * -1deg)) rotateY(calc(var(--hb-qs7-x) * var(--hb-qs7-tilt) * 1deg));\n  will-change: transform;\n}\n.hb-qs7-l {\n  grid-area: 1 / 1;\n  display: block;\n  font: inherit;\n  font-weight: inherit;\n  letter-spacing: inherit;\n  line-height: 1;\n  text-align: center;\n  white-space: pre-wrap;\n  pointer-events: none;\n  user-select: none;\n  -webkit-user-select: none;\n  color: color-mix(in srgb, var(--hb-qs7-c) var(--hb-qs7-m), #05060a);\n  transform: translate(\n    calc(var(--hb-qs7-x) * var(--hb-qs7-i) * var(--hb-qs7-step) * -1px),\n    calc(var(--hb-qs7-y) * var(--hb-qs7-i) * var(--hb-qs7-step) * -1px + var(--hb-qs7-i) * var(--hb-qs7-step) * 0.55px)\n  );\n}\n.hb-qs7-l[data-deep=\"true\"] { text-shadow: 0 0.12em 0.22em rgba(0, 0, 0, 0.55), 0 0.35em 0.6em rgba(0, 0, 0, 0.35); }\n.hb-qs7-t {\n  position: relative;\n  grid-area: 1 / 1;\n  display: block;\n  font: inherit;\n  font-weight: inherit;\n  letter-spacing: inherit;\n  line-height: 1;\n  text-align: center;\n  white-space: pre-wrap;\n  color: var(--hb-qs7-f);\n  text-shadow: 0 0 0.35em color-mix(in srgb, var(--hb-qs7-c) 35%, transparent);\n  transform: translate(calc(var(--hb-qs7-x) * var(--hb-qs7-step) * 0.5px), calc(var(--hb-qs7-y) * var(--hb-qs7-step) * 0.5px)) translateZ(1px);\n}\n`;\n\nexport function DepthLayers({\n  children,\n  layers = 10,\n  depth = 14,\n  tilt = 10,\n  color = \"#f2f2f2\",\n  accent = \"#2f7bff\",\n  idle = true,\n  className = \"\",\n  style,\n  onPointerMove,\n  onPointerLeave,\n  onPointerEnter,\n  ...rest\n}: DepthLayersProps) {\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const target = React.useRef({ x: 0, y: 0, active: false });\n  const visible = React.useRef(true);\n  const count = Math.max(2, Math.min(24, Math.round(layers)));\n  const step = depth / (count - 1);\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const reduced = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const cur = { x: 0, y: 0 };\n    function paint() {\n      el!.style.setProperty(\"--hb-qs7-x\", cur.x.toFixed(3));\n      el!.style.setProperty(\"--hb-qs7-y\", cur.y.toFixed(3));\n    }\n    if (reduced) {\n      cur.x = 0.4;\n      cur.y = -0.25;\n      paint();\n      return;\n    }\n    const io = new IntersectionObserver((entries) => {\n      visible.current = entries.some((e) => e.isIntersecting);\n    });\n    io.observe(el);\n    let raf = 0;\n    let last = 0;\n    let t = 0;\n    function tick(now: number) {\n      raf = requestAnimationFrame(tick);\n      const dt = last ? Math.min(0.05, (now - last) / 1000) : 0.016;\n      last = now;\n      if (!visible.current) return;\n      t += dt;\n      const tg = target.current;\n      const wantX = tg.active ? tg.x : idle ? Math.sin(t * 0.9) * 0.85 : 0;\n      const wantY = tg.active ? tg.y : idle ? Math.cos(t * 0.65) * 0.55 : 0;\n      const k = 1 - Math.exp(-dt * (tg.active ? 9 : 3));\n      cur.x += (wantX - cur.x) * k;\n      cur.y += (wantY - cur.y) * k;\n      paint();\n    }\n    raf = requestAnimationFrame(tick);\n    return () => {\n      cancelAnimationFrame(raf);\n      io.disconnect();\n    };\n  }, [idle]);\n\n  function point(e: React.PointerEvent<HTMLDivElement>) {\n    const box = e.currentTarget.getBoundingClientRect();\n    const x = ((e.clientX - box.left) / Math.max(1, box.width)) * 2 - 1;\n    const y = ((e.clientY - box.top) / Math.max(1, box.height)) * 2 - 1;\n    target.current.x = Math.max(-1, Math.min(1, x));\n    target.current.y = Math.max(-1, Math.min(1, y));\n    target.current.active = true;\n  }\n\n  const stack = Array.from({ length: count - 1 }, (_, n) => {\n    const i = count - 1 - n;\n    const mixPct = 18 + (1 - i / (count - 1)) * 62;\n    return (\n      <span\n        key={i}\n        className=\"hb-qs7-l\"\n        aria-hidden=\"true\"\n        data-deep={i === count - 1}\n        style={{ \"--hb-qs7-i\": i, \"--hb-qs7-m\": `${mixPct.toFixed(1)}%` } as React.CSSProperties}\n      >\n        {children}\n      </span>\n    );\n  });\n\n  const vars = {\n    \"--hb-qs7-c\": accent,\n    \"--hb-qs7-f\": color,\n    \"--hb-qs7-step\": step.toFixed(3),\n    \"--hb-qs7-tilt\": tilt,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-text-depth-layers\" precedence=\"default\">{css}</style>\n      <div\n        ref={rootRef}\n        className={`hb-qs7 ${className}`}\n        style={vars}\n        onPointerEnter={(e) => {\n          onPointerEnter?.(e);\n          point(e);\n        }}\n        onPointerMove={(e) => {\n          onPointerMove?.(e);\n          point(e);\n        }}\n        onPointerLeave={(e) => {\n          onPointerLeave?.(e);\n          target.current.active = false;\n        }}\n        {...rest}\n      >\n        <span className=\"hb-qs7-s\">\n          {stack}\n          <span className=\"hb-qs7-t\">{children}</span>\n        </span>\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}