{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"variable-font-weight-wave-across-a-headline","type":"registry:component","title":"Variable Font Weight Wave Across a Headline","description":"","dependencies":[],"files":[{"path":"components/we-inc/variable-font-weight-wave-across-a-headline.tsx","type":"registry:component","content":"import { Fragment, useEffect, useRef } from \"react\";\nimport type { CSSProperties } from \"react\";\n\nconst BUSINESS = \"Bellows Records & Listening Bar\";\nconst HEADLINE = \"Turn it up on Friday nights.\";\nconst COPY = \"New arrivals on the front wall, a different guest selector every week, and the good speakers stay on until one.\";\n\nconst CSS = `\n/* Edit these first: colours, and how long one full cycle takes. */\n.vw-root {\n  --vw-bg: #efe3d0;\n  --vw-ink: #2a1b12;\n  --vw-muted: #5e4433;\n  --vw-accent: #a8401f;\n  --vw-speed: 2.6s;\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(--vw-bg);\n  color: var(--vw-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.vw-root *, .vw-root *::before, .vw-root *::after { box-sizing: border-box; }\n.vw-inner { position: relative; z-index: 1; width: 100%; max-width: 1040px; }\n.vw-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(--vw-muted); }\n.vw-h { margin: 0; font-size: clamp(44px, 8vw, 104px); font-weight: 300; line-height: 1; letter-spacing: -.025em; }\n.vw-copy { margin: 28px 0 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(--vw-muted); }\n.vw-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n.vw-w { display: inline-block; white-space: nowrap; }\n.vw-l { display: inline-block; }\n/* Paused while scrolled out of view (the script sets data-paused). */\n.vw-root[data-paused=\"true\"] *, .vw-root[data-paused=\"true\"] *::before, .vw-root[data-paused=\"true\"] *::after { animation-play-state: paused !important; }\n@media (prefers-reduced-motion: reduce) {\n  .vw-root *, .vw-root *::before, .vw-root *::after { animation: none !important; }\n}\n\n.vw-h { max-width: 11em; }\n/* Each letter reserves the width of its boldest version, so the line never shifts as weights change. */\n.vw-l { display: inline-grid; justify-items: center; }\n.vw-l::after { content: attr(data-ch); grid-area: 1 / 1; font-weight: 900; visibility: hidden; }\n.vw-g {\n  grid-area: 1 / 1;\n  font-weight: 560;\n  animation: vw-pulse var(--vw-speed) ease-in-out infinite;\n  animation-delay: calc(var(--i) * 55ms - 3s); /* wave spacing */\n}\n/* font-variation-settings drives variable fonts; font-weight covers fonts without a wght axis. */\n@keyframes vw-pulse {\n  0%, 100% { font-weight: 260; font-variation-settings: \"wght\" 260; color: var(--vw-ink); }\n  50% { font-weight: 900; font-variation-settings: \"wght\" 900; color: var(--vw-accent); }\n}\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=\"vw-w\">\n            {[...word].map((ch, c) => (\n              <span key={c} className=\"vw-l\" data-ch={ch} style={{ \"--i\": i++ } as CSSProperties}>\n                <span className=\"vw-g\">{ch}</span>\n              </span>\n            ))}\n          </span>\n        </Fragment>\n      ))}\n    </span>\n  );\n}\n\nexport default function VariableWeightWave() {\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=\"vw-root w-full\">\n      <style>{CSS}</style>\n      <div className=\"vw-inner\">\n        <p className=\"vw-eyebrow\">{BUSINESS}</p>\n        <h2 className=\"vw-h\">\n          <span className=\"vw-sr\">{HEADLINE}</span>\n          <Letters text={HEADLINE} />\n        </h2>\n        <p className=\"vw-copy\">{COPY}</p>\n      </div>\n    </section>\n  );\n}\n"}]}
