{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"wavy-baseline-ripple-through-a-word","type":"registry:component","title":"Wavy Baseline Ripple Through a Word","description":"","dependencies":[],"files":[{"path":"components/we-inc/wavy-baseline-ripple-through-a-word.tsx","type":"registry:component","content":"import { Fragment, useEffect, useRef } from \"react\";\nimport type { CSSProperties } from \"react\";\n\nconst BUSINESS = \"Kettle Cove Swim Club\";\nconst WORD = \"Saltwater\";\nconst REST = \"mornings, all year.\";\nconst COPY = \"We meet by the slipway at eight every Sunday, whatever the weather. Bring a bright hat; the flask of tea is on us.\";\n\nconst CSS = `\n/* Edit these first: colours, and how long one full cycle takes. */\n.wv-root {\n  --wv-bg: #d6ebe3;\n  --wv-ink: #0d3b3a;\n  --wv-muted: #2b5a56;\n  --wv-accent: #0d3b3a;\n  --wv-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(--wv-bg);\n  color: var(--wv-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.wv-root *, .wv-root *::before, .wv-root *::after { box-sizing: border-box; }\n.wv-inner { position: relative; z-index: 1; width: 100%; max-width: 1040px; }\n.wv-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(--wv-muted); }\n.wv-h { margin: 0; font-size: clamp(44px, 7.4vw, 92px); font-weight: 800; line-height: 1.02; letter-spacing: -.035em; }\n.wv-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(--wv-muted); }\n.wv-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n.wv-w { display: inline-block; white-space: nowrap; }\n.wv-l { display: inline-block; }\n/* Paused while scrolled out of view (the script sets data-paused). */\n.wv-root[data-paused=\"true\"] *, .wv-root[data-paused=\"true\"] *::before, .wv-root[data-paused=\"true\"] *::after { animation-play-state: paused !important; }\n@media (prefers-reduced-motion: reduce) {\n  .wv-root *, .wv-root *::before, .wv-root *::after { animation: none !important; }\n}\n\n.wv-root { background: linear-gradient(180deg, #e3f2ec 0%, var(--wv-bg) 70%, #c7e2d8 100%); }\n.wv-word { display: block; font-size: 1.32em; letter-spacing: -.04em; }\n.wv-rest { display: block; }\n.wv-l {\n  animation: wv-ripple var(--wv-speed) ease-in-out infinite;\n  animation-delay: calc(var(--i) * 110ms - 3s); /* distance between crests */\n}\n.wv-sea { display: block; width: 100%; max-width: 560px; height: 14px; margin-top: 26px; overflow: hidden; color: var(--wv-accent); opacity: .45; }\n.wv-sea svg { display: block; width: 200%; height: 100%; animation: wv-drift 7s linear infinite; }\n@keyframes wv-ripple {\n  0%, 100% { transform: translateY(0) rotate(0); }\n  25% { transform: translateY(-.15em) rotate(-4deg); }\n  50% { transform: translateY(0) rotate(0); }\n  75% { transform: translateY(.06em) rotate(3deg); }\n}\n@keyframes wv-drift { to { transform: translateX(-50%); } }\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=\"wv-w\">\n            {[...word].map((ch, c) => (\n              <span key={c} className=\"wv-l\" style={{ \"--i\": i++ } as CSSProperties}>\n                {ch}\n              </span>\n            ))}\n          </span>\n        </Fragment>\n      ))}\n    </span>\n  );\n}\n\nexport default function WavyBaselineRipple() {\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=\"wv-root w-full\">\n      <style>{CSS}</style>\n      <div className=\"wv-inner\">\n        <p className=\"wv-eyebrow\">{BUSINESS}</p>\n        <h2 className=\"wv-h\">\n          <span className=\"wv-sr\">{`${WORD} ${REST}`}</span>\n          <span className=\"wv-word\">\n            <Letters text={WORD} />\n          </span>\n          <span className=\"wv-rest\" aria-hidden=\"true\">{REST}</span>\n        </h2>\n        <span className=\"wv-sea\" aria-hidden=\"true\">\n          <svg viewBox=\"0 0 400 14\" preserveAspectRatio=\"none\" focusable=\"false\">\n            <path d=\"M0 7 Q 25 1 50 7 T 100 7 T 150 7 T 200 7 T 250 7 T 300 7 T 350 7 T 400 7\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" />\n          </svg>\n        </span>\n        <p className=\"wv-copy\">{COPY}</p>\n      </div>\n    </section>\n  );\n}\n"}]}
