{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"data-corruption-text-resolving-into-headline","type":"registry:block","title":"Data Corruption Text Resolving","description":"","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/data-corruption-text-resolving-into-headline.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\nconst headline = \"Your files, restored intact.\";\nconst NOISE = \"#%&*+=/<>?!01$@{}[]\";\nconst RESOLVE_MS = 1500; // time for the line to settle, left to right\nconst HOLD_MS = 4200; // how long the clean line stays before it breaks again\nconst BREAK_MS = 700; // how long the corruption takes to spread\n\nexport default function DataCorruptionTextResolvingIntoHeadline() {\n  const root = useRef<HTMLElement>(null);\n  const chars = useRef<(HTMLSpanElement | null)[]>([]);\n  const reduce = useReducedMotion();\n  const [visible, setVisible] = useState(true);\n\n  useEffect(() => {\n    const el = root.current;\n    if (!el) return;\n    const io = new IntersectionObserver(([entry]) => setVisible(entry.isIntersecting));\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  useEffect(() => {\n    const spans = chars.current;\n    const letters = headline.split(\"\");\n    const show = (i: number, clean: boolean) => {\n      const s = spans[i];\n      if (!s || letters[i] === \" \") return;\n      s.textContent = clean ? letters[i] : NOISE[Math.floor(Math.random() * NOISE.length)];\n      s.dataset.state = clean ? \"clean\" : \"noise\";\n    };\n    if (reduce || !visible) {\n      letters.forEach((_, i) => show(i, true));\n      return;\n    }\n    const n = letters.length;\n    const order = letters.map((_, i) => i / n);\n    const breakAt = letters.map(() => Math.random());\n    const cycle = RESOLVE_MS + HOLD_MS + BREAK_MS;\n    const start = performance.now();\n    let last = 0;\n    let frame = 0;\n    const tick = (now: number) => {\n      frame = requestAnimationFrame(tick);\n      if (now - last < 55) return;\n      last = now;\n      const t = (now - start) % cycle;\n      for (let i = 0; i < n; i += 1) {\n        let clean: boolean;\n        if (t < RESOLVE_MS) clean = t > 150 + order[i] * (RESOLVE_MS - 350);\n        else if (t < RESOLVE_MS + HOLD_MS) clean = true;\n        else clean = (t - RESOLVE_MS - HOLD_MS) / BREAK_MS < breakAt[i];\n        show(i, clean);\n      }\n    };\n    frame = requestAnimationFrame(tick);\n    return () => cancelAnimationFrame(frame);\n  }, [reduce, visible]);\n\n  return (\n    <section ref={root} className=\"w10dcr relative overflow-hidden bg-[#0b1322] px-5 py-20 sm:px-10 sm:py-28\">\n      <style>{`\n        .w10dcr-grid { background-image: linear-gradient(rgba(148,233,200,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(148,233,200,0.05) 1px, transparent 1px); background-size: 32px 32px; mask-image: radial-gradient(70% 70% at 50% 45%, #000, transparent); -webkit-mask-image: radial-gradient(70% 70% at 50% 45%, #000, transparent); }\n        .w10dcr-c[data-state=\"noise\"] { color: #3f8f78; }\n        .w10dcr-c[data-state=\"clean\"] { color: #b9f5dc; text-shadow: 0 0 18px rgba(120, 240, 190, 0.25); }\n        @media (prefers-reduced-motion: reduce) { .w10dcr-c { transition: none; } }\n      `}</style>\n      <div aria-hidden=\"true\" className=\"w10dcr-grid pointer-events-none absolute inset-0\" />\n      <div className=\"relative mx-auto max-w-4xl\">\n        <p className=\"font-mono text-xs uppercase tracking-[0.3em] text-[#7fb8a6]\">Coldvault · offsite backup</p>\n        <h1 className=\"mt-6 font-mono text-[clamp(32px,6.2vw,72px)] font-bold leading-[1.1] tracking-tight text-[#b9f5dc]\">\n          <span className=\"sr-only\">{headline}</span>\n          <span aria-hidden=\"true\">\n            {headline.split(\"\").map((ch, i) => (\n              <span key={i} ref={(el) => { chars.current[i] = el; }} className=\"w10dcr-c\" data-state=\"clean\">{ch}</span>\n            ))}\n          </span>\n        </h1>\n        <p className=\"mt-7 max-w-xl text-base leading-relaxed text-[#a9c4bb] sm:text-lg\">\n          Encrypted nightly copies of every laptop in the office, checked byte for byte each week so a restore is never a gamble.\n        </p>\n        <div className=\"mt-10 flex flex-wrap items-center gap-5\">\n          <a\n            href=\"#\"\n            className=\"inline-flex h-12 items-center rounded-md bg-[#b9f5dc] px-6 font-mono text-sm font-semibold text-[#0b1322] transition hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#b9f5dc] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0b1322]\"\n          >\n            Run a test restore\n          </a>\n          <span className=\"font-mono text-xs uppercase tracking-widest text-[#7fb8a6]\">Last check passed 06:00</span>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
