{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"drifting-wave-section-divider-top-and-bottom","type":"registry:block","title":"Drifting Wave Section Divider","description":"","dependencies":[],"files":[{"path":"components/we-inc/drifting-wave-section-divider-top-and-bottom.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\n// A dark band between two paper sections, with a two-layer wave on its top and bottom edges.\n// The paler back layer and the solid front layer drift at different speeds, so the edge never\n// repeats in an obvious way. Copy the Divider component to use the edge on any block.\nconst PAPER = \"#f4efe6\";\nconst BAND = \"#1f2e33\";\nconst BACK_TINT = \"#7fa29e\";\nconst SECONDS = { back: 34, front: 22 };\nconst BACK = [[9,2,1.2],[5,5,0.3]];\nconst FRONT = [[11,3,0.2],[4,7,2.1]];\nconst facts = [\"Oak, ash and walnut from British mills\", \"Drawings agreed before any deposit\", \"A two-year guarantee on every finish\"];\n\n// One wave edge across 2880 units: two copies of a 1440-unit period, so sliding the SVG left by\n// half its width loops with no seam. Each harm entry is [amplitude, waves per period, phase,\n// sharpness?]; with a sharpness the crests come to narrow peaks over broad troughs, like real swell.\nfunction wavePath(base: number, harm: number[][], h: number, close: \"bottom\" | \"top\" | \"none\" = \"bottom\", step = 36, env?: [number, number]) {\n  const pts: number[][] = [];\n  for (let x = -step; x <= 2880 + step; x += step) {\n    const e = env ? 1 - env[0] + env[0] * Math.abs(Math.sin((Math.PI * env[1] * x) / 1440)) : 1;\n    let y = base;\n    for (const [a, c, ph, k] of harm) {\n      const t = (2 * Math.PI * c * x) / 1440 + ph;\n      y += k ? e * (a - 2 * a * Math.pow((1 + Math.cos(t)) / 2, k)) : a * e * Math.sin(t);\n    }\n    pts.push([x, y]);\n  }\n  const r = (n: number) => Math.round(n * 10) / 10;\n  let d = \"M0 \" + r(pts[1][1]);\n  for (let i = 1; i < pts.length - 2; i++) {\n    const [p0, p1, p2, p3] = [pts[i - 1], pts[i], pts[i + 1], pts[i + 2]];\n    d += \"C\" + r(p1[0] + (p2[0] - p0[0]) / 6) + \" \" + r(p1[1] + (p2[1] - p0[1]) / 6) + \" \" + r(p2[0] - (p3[0] - p1[0]) / 6) + \" \" + r(p2[1] - (p3[1] - p1[1]) / 6) + \" \" + r(p2[0]) + \" \" + r(p2[1]);\n  }\n  if (close === \"bottom\") d += \"L2880 \" + h + \"L0 \" + h + \"Z\";\n  if (close === \"top\") d += \"L2880 0L0 0Z\";\n  return d;\n}\n\nfunction useOnScreen<T extends Element>() {\n  const ref = useRef<T>(null);\n  const [onScreen, setOnScreen] = useState(true);\n  useEffect(() => {\n    const el = ref.current;\n    if (!el || !(\"IntersectionObserver\" in window)) return;\n    const io = new IntersectionObserver(([e]) => setOnScreen(e.isIntersecting));\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n  return [ref, onScreen] as const;\n}\n\nconst css = `\n@keyframes wvdv-slide { from { transform: translate3d(0,0,0); } to { transform: translate3d(-50%,0,0); } }\n.wvdv-slide { animation: wvdv-slide linear infinite; will-change: transform; }\n.wvdv-root[data-paused=\"true\"] .wvdv-slide { animation-play-state: paused; }\n@media (prefers-reduced-motion: reduce) { .wvdv-slide { animation: none !important; } }\n`;\n\nfunction Divider({ edge }: { edge: \"top\" | \"bottom\" }) {\n  const top = edge === \"top\";\n  return (\n    <div aria-hidden=\"true\" className={`pointer-events-none absolute inset-x-0 h-[70px] overflow-hidden sm:h-[100px] ${top ? \"bottom-full -mb-px\" : \"top-full -mt-px\"}`}>\n      <svg className=\"wvdv-slide absolute left-0 top-0 h-full w-[200%] min-w-[1800px]\" style={{ animationDuration: `${SECONDS.back}s` }} viewBox=\"0 0 2880 100\" preserveAspectRatio=\"none\">\n        <path d={wavePath(top ? 46 : 54, BACK, 100, top ? \"bottom\" : \"top\")} fill={BACK_TINT} fillOpacity=\".55\" />\n      </svg>\n      <svg className=\"wvdv-slide absolute left-0 top-0 h-full w-[200%] min-w-[1800px]\" style={{ animationDuration: `${SECONDS.front}s`, animationDirection: \"reverse\" }} viewBox=\"0 0 2880 100\" preserveAspectRatio=\"none\">\n        <path d={wavePath(top ? 58 : 42, FRONT, 100, top ? \"bottom\" : \"top\")} fill={BAND} />\n      </svg>\n    </div>\n  );\n}\n\nexport default function DriftingWaveDivider() {\n  const [ref, onScreen] = useOnScreen<HTMLElement>();\n  return (\n    <section ref={ref} data-paused={!onScreen} className=\"wvdv-root relative overflow-hidden\" style={{ background: PAPER }}>\n      <style>{css}</style>\n      <div className=\"mx-auto max-w-5xl px-6 pb-[110px] pt-16 sm:pb-[140px]\">\n        <p className=\"text-sm font-semibold uppercase tracking-[0.16em] text-[#6b4e2e]\">Hollin and Pike Joinery</p>\n        <h2 className=\"mt-3 max-w-xl text-3xl font-semibold leading-tight tracking-tight text-[#231a12] sm:text-4xl\">Furniture that starts with a tape measure.</h2>\n      </div>\n      <div className=\"relative\" style={{ background: BAND }}>\n        <Divider edge=\"top\" />\n        <div className=\"mx-auto grid max-w-5xl gap-8 px-6 py-14 sm:grid-cols-[1.4fr_1fr] sm:items-end sm:py-16\">\n          <div>\n            <h2 className=\"text-3xl font-semibold leading-tight tracking-tight text-[#f4efe6] sm:text-5xl\">Built to fit the room you already have.</h2>\n            <p className=\"mt-4 max-w-lg text-lg leading-relaxed text-[#c3cfcc]\">Fitted shelving, window seats and kitchens made in our workshop and installed in a single day.</p>\n          </div>\n          <div className=\"sm:text-right\">\n            <a href=\"#\" className=\"inline-flex h-12 items-center rounded-md bg-[#e9dcc4] px-7 text-sm font-semibold text-[#1f2e33] transition hover:bg-[#f4ead8] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#e9dcc4] focus-visible:ring-offset-2 focus-visible:ring-offset-[#1f2e33]\">Request a site visit</a>\n          </div>\n        </div>\n        <Divider edge=\"bottom\" />\n      </div>\n      <ul className=\"mx-auto grid max-w-5xl gap-4 px-6 pb-16 pt-[110px] sm:grid-cols-3 sm:pt-[140px]\">\n        {facts.map((f) => (\n          <li key={f} className=\"border-t border-[#d8ccb8] pt-4 text-base text-[#3d2f22]\">{f}</li>\n        ))}\n      </ul>\n    </section>\n  );\n}\n"}]}
