{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"breathing-letter-spacing-display-headline","type":"registry:component","title":"Breathing Letter Spacing Display Line","description":"","dependencies":[],"files":[{"path":"components/we-inc/breathing-letter-spacing-display-headline.tsx","type":"registry:component","content":"import { Fragment, useEffect, useRef } from \"react\";\nimport type { CSSProperties } from \"react\";\n\nconst BUSINESS = \"Nightjar Reading Room\";\nconst HEADLINE = \"Quiet hours\";\nconst COPY = \"A members' library on Fenner Street, open until midnight from Thursday to Sunday. Phones rest in a basket by the door.\";\n\nconst CSS = `\n/* Edit these first: colours, and how long one full cycle takes. */\n.ls-root {\n  --ls-bg: #0c1322;\n  --ls-ink: #e9edf5;\n  --ls-muted: #a3aec2;\n  --ls-accent: #f4d9a6;\n  --ls-speed: 7s;\n  position: relative;\n  overflow: hidden;\n  box-sizing: border-box;\n  min-height: 480px;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  padding: 72px 20px;\n  background: var(--ls-bg);\n  color: var(--ls-ink);\n  font-family: \"Inter Tight\", Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif;\n  -webkit-font-smoothing: antialiased;\n}\n.ls-root *, .ls-root *::before, .ls-root *::after { box-sizing: border-box; }\n.ls-inner { position: relative; z-index: 1; width: 100%; max-width: 1040px; text-align: center; }\n.ls-eyebrow { margin: 0 0 22px; font-family: \"Inter Tight\", Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif; font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ls-muted); }\n.ls-h { margin: 0; font-size: clamp(34px, 9vw, 128px); font-weight: 700; line-height: 1; letter-spacing: .05em; }\n.ls-copy { margin: 28px auto 0; max-width: 34em; font-family: \"Inter Tight\", Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif; font-size: clamp(16px, 1.5vw, 19px); line-height: 1.6; color: var(--ls-muted); }\n.ls-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n.ls-w { display: inline-block; white-space: nowrap; }\n.ls-l { display: inline-block; }\n/* Paused while scrolled out of view (the script sets data-paused). */\n.ls-root[data-paused=\"true\"] *, .ls-root[data-paused=\"true\"] *::before, .ls-root[data-paused=\"true\"] *::after { animation-play-state: paused !important; }\n@media (prefers-reduced-motion: reduce) {\n  .ls-root *, .ls-root *::before, .ls-root *::after { animation: none !important; }\n}\n\n.ls-root { background: radial-gradient(ellipse 60% 55% at 50% 48%, #1d2b49 0%, var(--ls-bg) 70%); }\n.ls-h { text-transform: uppercase; white-space: nowrap; text-shadow: 0 0 40px rgba(244, 217, 166, .18); }\n.ls-l {\n  /* --c is the middle letter, so the line opens and closes around its centre. */\n  animation: ls-breathe var(--ls-speed) cubic-bezier(.45, 0, .55, 1) infinite;\n}\n.ls-lamp { display: block; width: 6px; height: 6px; margin: 0 auto 26px; border-radius: 50%; background: var(--ls-accent); box-shadow: 0 0 18px 4px rgba(244, 217, 166, .45); animation: ls-glow var(--ls-speed) ease-in-out infinite; }\n@keyframes ls-breathe {\n  0%, 100% { transform: translateX(calc((var(--i) - var(--c)) * -.02em)); opacity: .8; }\n  50% { transform: translateX(calc((var(--i) - var(--c)) * .09em)); opacity: 1; }\n}\n@keyframes ls-glow { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }\n`;\n\n/** Splits text into words (so lines still wrap) and letters, each letter numbered with --i. */\nfunction Letters({ text }: { text: string }) {\n  let i = 0;\n  return (\n    <span aria-hidden=\"true\">\n      {text.split(\" \").map((word, w) => (\n        <Fragment key={w}>\n          {w > 0 && \" \"}\n          <span className=\"ls-w\">\n            {[...word].map((ch, c) => (\n              <span key={c} className=\"ls-l\" style={{ \"--i\": i++ } as CSSProperties}>\n                {ch}\n              </span>\n            ))}\n          </span>\n        </Fragment>\n      ))}\n    </span>\n  );\n}\n\nexport default function BreathingLetterSpacing() {\n  const rootRef = useRef<HTMLElement>(null);\n\n  // Pause the CSS animation while the section is off screen.\n  useEffect(() => {\n    const el = rootRef.current;\n    if (!el || typeof IntersectionObserver === \"undefined\") return;\n    const io = new IntersectionObserver(([entry]) => {\n      el.dataset.paused = entry.isIntersecting ? \"false\" : \"true\";\n    });\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  return (\n    <section ref={rootRef} data-paused=\"false\" className=\"ls-root w-full\">\n      <style>{CSS}</style>\n      <div className=\"ls-inner\">\n        <p className=\"ls-eyebrow\">{BUSINESS}</p>\n        <span className=\"ls-lamp\" aria-hidden=\"true\" />\n        <h2 className=\"ls-h\" style={{ \"--c\": (HEADLINE.replace(/ /g, \"\").length - 1) / 2 } as CSSProperties}>\n          <span className=\"ls-sr\">{HEADLINE}</span>\n          <Letters text={HEADLINE} />\n        </h2>\n        <p className=\"ls-copy\">{COPY}</p>\n      </div>\n    </section>\n  );\n}\n"}]}
