{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "fracture",
  "type": "registry:ui",
  "title": "Fracture",
  "description": "Text glitches with classic red and cyan channel ghosts sheared apart by jump-cut clip-path slices, sparking at each shear line. Hover, continuous, or timed-interval triggers; freezes static under reduced motion.",
  "dependencies": [],
  "registryDependencies": [
    "https://crucibleui.com/r/use-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/default/text/fracture/fracture.tsx",
      "type": "registry:ui",
      "target": "components/crucible/fracture.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { useReducedMotion } from \"@/hooks/use-reduced-motion\";\n\nexport interface FractureColors {\n  /** Color of the first channel ghost. @default classic glitch red */\n  ember?: string;\n  /** Color of the second channel ghost. @default classic glitch cyan */\n  violet?: string;\n  /** Color of the base (undisplaced) text. @default warm white */\n  base?: string;\n  /** Color of the spark-fleck particles fired at each shear line. @default white */\n  spark?: string;\n}\n\nexport interface FractureProps extends Omit<React.ComponentPropsWithoutRef<\"span\">, \"children\"> {\n  /** The text to render and glitch. */\n  children: string;\n  /** Element tag rendered. @default \"span\" */\n  as?: \"span\" | \"div\" | \"p\" | \"h1\" | \"h2\" | \"h3\";\n  /**\n   * What fires the glitch. \"always\" loops continuously (still bursty, not\n   * nonstop noise — one burst per `cadence`-second cycle, the burst taking\n   * the first ~17% of it); \"hover\" bursts rapidly while the pointer is over\n   * the text; \"interval\" fires one `burstDuration` burst every `cadence`\n   * seconds even without interaction. @default \"hover\"\n   */\n  trigger?: \"always\" | \"hover\" | \"interval\";\n  /** Channel-split offset and slice strength, 0-1. @default 0.6 */\n  intensity?: number;\n  /** Seconds between bursts for \"always\"/\"interval\" triggers. @default 3.2 */\n  cadence?: number;\n  /**\n   * Seconds per burst cycle for the \"hover\" and \"interval\" triggers (\"always\"\n   * derives its burst from `cadence` instead). @default 0.5\n   */\n  burstDuration?: number;\n  /** Ghost-layer, base, and spark colors. */\n  colors?: FractureColors;\n  /** Freeze the animation. @default false */\n  paused?: boolean;\n}\n\nconst DEFAULT_COLORS: Required<FractureColors> = {\n  ember: \"#ff2d2d\",\n  violet: \"#31e6ff\",\n  base: \"#fdf1e3\",\n  spark: \"#ffffff\",\n};\n\n/**\n * Fracture — text shears under stress: classic red and cyan channel ghosts\n * jump apart along clip-path slices, with a white spark-fleck particle\n * firing at each shear line. Reads as structural shear, not a VHS dropout.\n * Freezes static under reduced motion.\n */\nexport function Fracture({\n  children,\n  as = \"span\",\n  trigger = \"hover\",\n  intensity = 0.6,\n  cadence = 3.2,\n  burstDuration = 0.5,\n  colors,\n  paused = false,\n  className,\n  style,\n  ...props\n}: FractureProps) {\n  const reducedMotion = useReducedMotion();\n  const c = { ...DEFAULT_COLORS, ...colors };\n  const Tag = as;\n  const [burst, setBurst] = React.useState(false);\n\n  React.useEffect(() => {\n    if (reducedMotion || trigger !== \"interval\" || paused) return;\n    const cadenceMs = Math.max(cadence, 0.2) * 1000;\n    const burstMs = Math.max(burstDuration, 0.05) * 1000;\n    let timeoutId: ReturnType<typeof setTimeout>;\n    const intervalId = setInterval(() => {\n      setBurst(true);\n      timeoutId = setTimeout(() => setBurst(false), burstMs);\n    }, cadenceMs);\n    return () => {\n      clearInterval(intervalId);\n      clearTimeout(timeoutId);\n    };\n  }, [trigger, cadence, burstDuration, reducedMotion, paused]);\n\n  if (reducedMotion) {\n    return (\n      <Tag className={cn(\"inline-block\", className)} style={{ color: c.base, ...style }} {...props}>\n        {children}\n      </Tag>\n    );\n  }\n\n  return (\n    <Tag\n      data-crucible=\"fracture\"\n      data-trigger={trigger}\n      data-burst={burst ? \"\" : undefined}\n      aria-label={children}\n      className={cn(\"relative isolate inline-block\", className)}\n      style={\n        {\n          \"--fracture-intensity\": intensity,\n          \"--fracture-cadence\": `${cadence}s`,\n          \"--fracture-burst-duration\": `${burstDuration}s`,\n          ...(paused ? { \"--fracture-play\": \"paused\" } : {}),\n          color: c.base,\n          ...style,\n        } as React.CSSProperties\n      }\n      {...props}\n    >\n      <style>{`\n        /* Ghost layers only: sliced, displaced, and visible solely mid-burst. */\n        @keyframes crucible-fracture-glitch {\n          0%   { opacity: 0; transform: translate3d(0, 0, 0); clip-path: inset(0 0 0 0); }\n          4%   { opacity: 1; transform: translate3d(calc(var(--fracture-intensity) * var(--fracture-sign, 1) * -9px), calc(var(--fracture-intensity) * 2px), 0); clip-path: inset(6% 0 78% 0); }\n          8%   { opacity: 1; transform: translate3d(calc(var(--fracture-intensity) * var(--fracture-sign, 1) * 7px), 0, 0); clip-path: inset(42% 0 18% 0); }\n          12%  { opacity: 1; transform: translate3d(calc(var(--fracture-intensity) * var(--fracture-sign, 1) * -5px), calc(var(--fracture-intensity) * -2px), 0); clip-path: inset(70% 0 3% 0); }\n          17%  { opacity: 0; transform: translate3d(0, 0, 0); clip-path: inset(0 0 0 0); }\n          100% { opacity: 0; transform: translate3d(0, 0, 0); clip-path: inset(0 0 0 0); }\n        }\n        /* Base layer stays whole and legible: a 1-2px stress jitter, no slicing. */\n        @keyframes crucible-fracture-jitter {\n          0%   { transform: translate3d(0, 0, 0); }\n          4%   { transform: translate3d(calc(var(--fracture-intensity) * -1.5px), calc(var(--fracture-intensity) * 1px), 0); }\n          8%   { transform: translate3d(calc(var(--fracture-intensity) * 1.5px), 0, 0); }\n          12%  { transform: translate3d(calc(var(--fracture-intensity) * -1px), calc(var(--fracture-intensity) * -1px), 0); }\n          17%  { transform: translate3d(0, 0, 0); }\n          100% { transform: translate3d(0, 0, 0); }\n        }\n        @keyframes crucible-fracture-spark {\n          0%, 5% { opacity: 0; transform: scale(0.4); }\n          7%     { opacity: 1; transform: scale(1.2); }\n          11%    { opacity: 0; transform: scale(0.6); }\n          100%   { opacity: 0; }\n        }\n        [data-crucible=\"fracture\"] .fracture-layer { will-change: transform, clip-path, opacity; opacity: 0; }\n        [data-crucible=\"fracture\"] .fracture-base { will-change: transform; }\n        [data-crucible=\"fracture\"] .fracture-ember { --fracture-sign: -1; mix-blend-mode: screen; }\n        [data-crucible=\"fracture\"] .fracture-violet { --fracture-sign: 1; mix-blend-mode: screen; }\n        [data-crucible=\"fracture\"] .fracture-spark { opacity: 0; }\n\n        [data-crucible=\"fracture\"][data-trigger=\"always\"] .fracture-layer {\n          animation: crucible-fracture-glitch var(--fracture-cadence) steps(1, jump-end) infinite;\n          animation-play-state: var(--fracture-play, running);\n        }\n        [data-crucible=\"fracture\"][data-trigger=\"always\"] .fracture-base {\n          animation: crucible-fracture-jitter var(--fracture-cadence) steps(1, jump-end) infinite;\n          animation-play-state: var(--fracture-play, running);\n        }\n        [data-crucible=\"fracture\"][data-trigger=\"always\"] .fracture-spark {\n          animation: crucible-fracture-spark var(--fracture-cadence) steps(1, jump-end) infinite;\n          animation-play-state: var(--fracture-play, running);\n        }\n\n        [data-crucible=\"fracture\"][data-trigger=\"hover\"] .fracture-layer,\n        [data-crucible=\"fracture\"][data-trigger=\"hover\"] .fracture-base,\n        [data-crucible=\"fracture\"][data-trigger=\"hover\"] .fracture-spark {\n          animation: none;\n        }\n        [data-crucible=\"fracture\"][data-trigger=\"hover\"]:hover .fracture-layer {\n          animation: crucible-fracture-glitch var(--fracture-burst-duration) steps(1, jump-end) infinite;\n          animation-play-state: var(--fracture-play, running);\n        }\n        [data-crucible=\"fracture\"][data-trigger=\"hover\"]:hover .fracture-base {\n          animation: crucible-fracture-jitter var(--fracture-burst-duration) steps(1, jump-end) infinite;\n          animation-play-state: var(--fracture-play, running);\n        }\n        [data-crucible=\"fracture\"][data-trigger=\"hover\"]:hover .fracture-spark {\n          animation: crucible-fracture-spark var(--fracture-burst-duration) steps(1, jump-end) infinite;\n          animation-play-state: var(--fracture-play, running);\n        }\n\n        [data-crucible=\"fracture\"][data-trigger=\"interval\"] .fracture-layer,\n        [data-crucible=\"fracture\"][data-trigger=\"interval\"] .fracture-base,\n        [data-crucible=\"fracture\"][data-trigger=\"interval\"] .fracture-spark {\n          animation: none;\n        }\n        [data-crucible=\"fracture\"][data-trigger=\"interval\"][data-burst] .fracture-layer {\n          animation: crucible-fracture-glitch var(--fracture-burst-duration) steps(1, jump-end) 1;\n        }\n        [data-crucible=\"fracture\"][data-trigger=\"interval\"][data-burst] .fracture-base {\n          animation: crucible-fracture-jitter var(--fracture-burst-duration) steps(1, jump-end) 1;\n        }\n        [data-crucible=\"fracture\"][data-trigger=\"interval\"][data-burst] .fracture-spark {\n          animation: crucible-fracture-spark var(--fracture-burst-duration) steps(1, jump-end) 1;\n        }\n\n        @media (prefers-reduced-motion: reduce) {\n          [data-crucible=\"fracture\"] .fracture-layer,\n          [data-crucible=\"fracture\"] .fracture-base,\n          [data-crucible=\"fracture\"] .fracture-spark {\n            animation: none !important;\n          }\n        }\n      `}</style>\n      <span aria-hidden className=\"fracture-base relative z-10\">\n        {children}\n      </span>\n      <span\n        aria-hidden\n        className=\"fracture-layer fracture-ember pointer-events-none absolute inset-0 select-none\"\n        style={{ color: c.ember }}\n      >\n        {children}\n      </span>\n      <span\n        aria-hidden\n        className=\"fracture-layer fracture-violet pointer-events-none absolute inset-0 select-none\"\n        style={{ color: c.violet }}\n      >\n        {children}\n      </span>\n      <span\n        aria-hidden\n        className=\"fracture-spark pointer-events-none absolute rounded-full\"\n        style={{ top: \"28%\", left: \"18%\", width: 4, height: 4, background: c.spark, boxShadow: `0 0 8px 2px ${c.spark}` }}\n      />\n      <span\n        aria-hidden\n        className=\"fracture-spark pointer-events-none absolute rounded-full\"\n        style={{ top: \"62%\", left: \"78%\", width: 3, height: 3, background: c.spark, boxShadow: `0 0 6px 2px ${c.spark}` }}\n      />\n    </Tag>\n  );\n}\n"
    }
  ]
}