{
  "id": "layered-wave-generator",
  "kind": "element",
  "title": "Layered wave generator",
  "summary": "Stacked SVG waves rolling sideways along the bottom of a panel, redrawn every frame from real wave maths, with sliders for every part of the shape.",
  "url": "https://enrichr.dev/elements/layered-wave-generator.html",
  "section": "svg-bg",
  "techniques": [
    "parallax"
  ],
  "stack": [
    "Vanilla JS",
    "SVG"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "calm",
    "fluid"
  ],
  "intents": [
    "animated svg waves",
    "wave divider generator",
    "layered wave background",
    "animated wave section divider",
    "svg waves footer animation"
  ],
  "status": "tested",
  "params": [
    {
      "key": "height",
      "label": "Wave height",
      "type": "range",
      "min": 0,
      "max": 120,
      "step": 1,
      "value": 40
    },
    {
      "key": "width",
      "label": "Wave width",
      "type": "range",
      "min": 60,
      "max": 800,
      "step": 1,
      "value": 300
    },
    {
      "key": "speed",
      "label": "Speed",
      "type": "range",
      "min": 0,
      "max": 5,
      "step": 0.1,
      "value": 1
    },
    {
      "key": "warp",
      "label": "Warp (lean of the crests)",
      "type": "range",
      "min": -1,
      "max": 1,
      "step": 0.05,
      "value": 0
    },
    {
      "key": "turbulence",
      "label": "Turbulence (chop)",
      "type": "range",
      "min": 0,
      "max": 100,
      "step": 1,
      "value": 0
    },
    {
      "key": "layers",
      "label": "Layers",
      "type": "range",
      "min": 1,
      "max": 6,
      "step": 1,
      "value": 3
    },
    {
      "key": "depth",
      "label": "Layer depth (fade of back layers)",
      "type": "range",
      "min": 0,
      "max": 100,
      "step": 1,
      "value": 50
    },
    {
      "key": "roundness",
      "label": "Roundness (0 is sharp corners)",
      "type": "range",
      "min": 0,
      "max": 100,
      "step": 1,
      "value": 70
    },
    {
      "key": "area",
      "label": "Wave strip height (px)",
      "type": "range",
      "min": 80,
      "max": 600,
      "step": 10,
      "value": 220
    },
    {
      "key": "color",
      "label": "Wave colour",
      "type": "color",
      "value": "#fbf8f1"
    },
    {
      "key": "background",
      "label": "Background",
      "type": "color",
      "value": "#005236"
    }
  ],
  "license": "Free to use in personal and client projects during the preview. Final licence terms will be published here before any paid tier starts; ask before reselling the code as a collection.",
  "contract": "function mount(root, opts) -> { update(partialOpts), destroy() }; root must contain the element markup",
  "exports": {
    "claude": "Add the \"Layered wave generator\" element to this project.\n\nThis is the \"Layered wave generator\" element from the Enrichr Library: Stacked SVG waves rolling sideways along the bottom of a panel, redrawn every frame from real wave maths, with sliders for every part of the shape.\nPage: https://enrichr.dev/elements/layered-wave-generator.html\nMachine-readable spec: https://enrichr.dev/elements/layered-wave-generator.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nSteps:\n1. Look at the project first to see its framework and where components, styles and static files live. Follow its conventions.\n2. Fetch https://enrichr.dev/elements/layered-wave-generator.json if you can read URLs (fields: source.markup, source.css, source.js, params); otherwise use the source at the end of this message.\n3. Add the files, mount it where I tell you (default: the top of the home page), and pass the settings below as the opts.\n4. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n5. Run the dev server and check it. with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "chatgpt": "I want the \"Layered wave generator\" element on my website. Below is its complete source. Please:\n1. Build one self-contained index.html that I can open locally to see it working (put the CSS in a <style> tag and the JavaScript in a <script> tag, with the markup in the body).\n2. Then explain, step by step, which parts go where in my own site, and how to mount it. My stack is: [tell me yours, or say \"plain HTML\"].\n3. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nThis is the \"Layered wave generator\" element from the Enrichr Library: Stacked SVG waves rolling sideways along the bottom of a panel, redrawn every frame from real wave maths, with sliders for every part of the shape.\nPage: https://enrichr.dev/elements/layered-wave-generator.html\nMachine-readable spec: https://enrichr.dev/elements/layered-wave-generator.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.",
    "cursor": "Add the \"Layered wave generator\" element to this codebase.\n\nThis is the \"Layered wave generator\" element from the Enrichr Library: Stacked SVG waves rolling sideways along the bottom of a panel, redrawn every frame from real wave maths, with sliders for every part of the shape.\nPage: https://enrichr.dev/elements/layered-wave-generator.html\nMachine-readable spec: https://enrichr.dev/elements/layered-wave-generator.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nUse Composer / agent mode. First search the repo for how components, styles and scripts are organised, then add the files in the matching places, mount it on the page I name, and run the app to confirm it works. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.\n\nOptional: save this as .cursor/rules/enrichr-layered-wave-generator.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Layered wave generator element\nalwaysApply: false\n---\nmount(root, opts) expects the element markup inside root and returns { update, destroy }. Always call destroy() on unmount and never edit the ef- class names.",
    "v0": "Create a Next.js (App Router) client component for the \"Layered wave generator\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Layered wave generator\" element from the Enrichr Library: Stacked SVG waves rolling sideways along the bottom of a panel, redrawn every frame from real wave maths, with sliders for every part of the shape.\nPage: https://enrichr.dev/elements/layered-wave-generator.html\nMachine-readable spec: https://enrichr.dev/elements/layered-wave-generator.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles to create:\n- layered-wave-generator.js : the JavaScript below, with one line appended at the end: export { mount };  (and the markup exported as: export const markup = \"<the markup string>\";). If the project uses TypeScript and does not allow JS imports, put // @ts-nocheck on the first line.\n- the CSS below goes in your global stylesheet (or a plain .css file imported once at the app root). The class names are global and start with ef-.\n\nUse this component as the wrapper (adjust the import paths):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./layered-wave-generator\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function LayeredWaveGenerator(props: Record<string, unknown>) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n```\n\nRender it on the home page so I can see it. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "lovable": "Add the \"Layered wave generator\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Layered wave generator\" element from the Enrichr Library: Stacked SVG waves rolling sideways along the bottom of a panel, redrawn every frame from real wave maths, with sliders for every part of the shape.\nPage: https://enrichr.dev/elements/layered-wave-generator.html\nMachine-readable spec: https://enrichr.dev/elements/layered-wave-generator.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles to create:\n- layered-wave-generator.js : the JavaScript below, with one line appended at the end: export { mount };  (and the markup exported as: export const markup = \"<the markup string>\";). If the project uses TypeScript and does not allow JS imports, put // @ts-nocheck on the first line.\n- the CSS below goes in your global stylesheet (or a plain .css file imported once at the app root). The class names are global and start with ef-.\n\nWrapper component (src/components/LayeredWaveGenerator.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./layered-wave-generator\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function LayeredWaveGenerator(props: Record<string, unknown>) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n```\n\nRemove the \"use client\" line if it is not needed. Show it on the home page. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "bolt": "Create a small Vite project (vanilla JavaScript, no framework unless I already have one) that shows the \"Layered wave generator\" element.\n\nThis is the \"Layered wave generator\" element from the Enrichr Library: Stacked SVG waves rolling sideways along the bottom of a panel, redrawn every frame from real wave maths, with sliders for every part of the shape.\nPage: https://enrichr.dev/elements/layered-wave-generator.html\nMachine-readable spec: https://enrichr.dev/elements/layered-wave-generator.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles: index.html (a container element, then a script tag), style.css (the CSS below), layered-wave-generator.js (the JavaScript below) and main.js that sets the container's innerHTML to the markup and calls mount(container, opts) with the settings below. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.",
    "replit": "Create a new HTML, CSS and JavaScript Repl that shows the \"Layered wave generator\" element. No packages, no server code.\n\nThis is the \"Layered wave generator\" element from the Enrichr Library: Stacked SVG waves rolling sideways along the bottom of a panel, redrawn every frame from real wave maths, with sliders for every part of the shape.\nPage: https://enrichr.dev/elements/layered-wave-generator.html\nMachine-readable spec: https://enrichr.dev/elements/layered-wave-generator.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles: index.html (a container element, link style.css, load layered-wave-generator.js and then main.js), style.css (the CSS below), layered-wave-generator.js (the JavaScript below), main.js (sets the container's innerHTML to the markup, then calls mount(container, opts) with the settings below). Press Run to preview. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "figma": "Designer handoff notes for the \"Layered wave generator\" element (Enrichr Library). Figma cannot run this JavaScript inside a design file, so use it as a motion reference and hand the code to a developer.\n\nThis is the \"Layered wave generator\" element from the Enrichr Library: Stacked SVG waves rolling sideways along the bottom of a panel, redrawn every frame from real wave maths, with sliders for every part of the shape.\nPage: https://enrichr.dev/elements/layered-wave-generator.html\nMachine-readable spec: https://enrichr.dev/elements/layered-wave-generator.json\n\nWhat it does: The waves live in one SVG with a 1000 by 300 viewBox stretched to the panel width, anchored to the bottom. Each frame, every layer samples 49 points across the width around a line 40% of the way down: a sine of the chosen wave width, plus an optional second harmonic at 1.7 times the phase speed (warp, which leans the crests), plus two short, fast sines (turbulence, for chop). Back layers are 40% flatter, run 0.6 radians behind the one in front and fade with the depth setting. The points are joined with quadratic curves through their midpoints and closed along the bottom. The phase moves one full cycle every 8 seconds at speed 1, the same rate as the original GSAP ticker.\nAccessibility: The SVG is decorative and has a text label. With prefers-reduced-motion it draws one still frame and never animates. The motion is a slow sideways roll with nothing flashing. Nothing needs keyboard input.\n\nTunable settings:\n- Wave height: range 0 to 120, step 1, default 40\n- Wave width: range 60 to 800, step 1, default 300\n- Speed: range 0 to 5, step 0.1, default 1\n- Warp (lean of the crests): range -1 to 1, step 0.05, default 0\n- Turbulence (chop): range 0 to 100, step 1, default 0\n- Layers: range 1 to 6, step 1, default 3\n- Layer depth (fade of back layers): range 0 to 100, step 1, default 50\n- Roundness (0 is sharp corners): range 0 to 100, step 1, default 70\n- Wave strip height (px): range 80 to 600, step 10, default 220\n- Wave colour: color, default #fbf8f1\n- Background: color, default #005236\n\nCurrent settings:\n{{SETTINGS}}\n\nFor the developer: Element contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nIn Figma:\n- Draw the resting state as a frame and the end state as a second frame; link them with Smart Animate to show the motion in a prototype.\n- Put the settings above in the frame's notes or Dev Mode annotations so the developer matches them.\n- Link https://enrichr.dev/elements/layered-wave-generator.html in the handoff: the live demo and the copy-ready code are there. Developers can paste the prompts for Claude, Cursor or v0 from the Export menu.\nNothing is copied from another designer's file; this is original code from Enrichr.",
    "framer": "Add the \"Layered wave generator\" element to Framer as a code component. Framer code components are React, so wrap the vanilla code like this. Check it in the Framer editor, as Framer's component API can change.\n\nThis is the \"Layered wave generator\" element from the Enrichr Library: Stacked SVG waves rolling sideways along the bottom of a panel, redrawn every frame from real wave maths, with sliders for every part of the shape.\nPage: https://enrichr.dev/elements/layered-wave-generator.html\nMachine-readable spec: https://enrichr.dev/elements/layered-wave-generator.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\n1. In Framer: Assets > Code > New component. Name it LayeredWaveGenerator.\n2. Paste the JavaScript below into a separate code file named layered-wave-generator.js in the same project, with  export { mount };  and  export const markup = \"<the markup string>\";  added. Put the CSS into the component as a <style> tag.\n3. Component:\n```tsx\nimport { addPropertyControls, ControlType } from \"framer\"\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./layered-wave-generator\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function LayeredWaveGenerator(props: any) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n\naddPropertyControls(LayeredWaveGenerator, {\n  height: { type: ControlType.Number, title: \"Wave height\", min: 0, max: 120, step: 1, defaultValue: 40 },\n  width: { type: ControlType.Number, title: \"Wave width\", min: 60, max: 800, step: 1, defaultValue: 300 },\n  speed: { type: ControlType.Number, title: \"Speed\", min: 0, max: 5, step: 0.1, defaultValue: 1 },\n  warp: { type: ControlType.Number, title: \"Warp\", min: -1, max: 1, step: 0.05, defaultValue: 0 },\n  turbulence: { type: ControlType.Number, title: \"Turbulence\", min: 0, max: 100, step: 1, defaultValue: 0 },\n  layers: { type: ControlType.Number, title: \"Layers\", min: 1, max: 6, step: 1, defaultValue: 3 },\n  depth: { type: ControlType.Number, title: \"Layer depth\", min: 0, max: 100, step: 1, defaultValue: 50 },\n  roundness: { type: ControlType.Number, title: \"Roundness\", min: 0, max: 100, step: 1, defaultValue: 70 },\n  area: { type: ControlType.Number, title: \"Wave strip height\", min: 80, max: 600, step: 10, defaultValue: 220 },\n  color: { type: ControlType.Color, title: \"Wave colour\", defaultValue: \"#fbf8f1\" },\n  background: { type: ControlType.Color, title: \"Background\", defaultValue: \"#005236\" },\n})\n```\n4. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "webflow": "Add the \"Layered wave generator\" element to a Webflow site with an Embed element. Test it on the published or preview site: scripts in embeds may not run inside the Designer canvas.\n\nThis is the \"Layered wave generator\" element from the Enrichr Library: Stacked SVG waves rolling sideways along the bottom of a panel, redrawn every frame from real wave maths, with sliders for every part of the shape.\nPage: https://enrichr.dev/elements/layered-wave-generator.html\nMachine-readable spec: https://enrichr.dev/elements/layered-wave-generator.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\n1. Add an Embed element where it should appear. Paste a <style> block with the CSS, one container <div id=\"enrichr-layered-wave-generator\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-layered-wave-generator\"), { ...your settings... });\n   (set the container's innerHTML to the markup first, as in the contract).\n2. Embed elements have a size limit (check Webflow's current number). If the code is longer, host the JS and CSS as files and link them from Custom code in the page settings, then keep only the container and the mount call in the Embed.\n3. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}"
  },
  "exportTools": [
    "claude",
    "chatgpt",
    "cursor",
    "v0",
    "lovable",
    "bolt",
    "replit",
    "figma",
    "framer",
    "webflow"
  ],
  "accessibility": "The SVG is decorative and has a text label. With prefers-reduced-motion it draws one still frame and never animates. The motion is a slow sideways roll with nothing flashing. Nothing needs keyboard input.",
  "performance": "A frame rebuilds one short path string per layer, at most six paths of 49 points, and sets it as the d attribute. The loop stops at speed 0, while the panel is off screen and in hidden tabs.",
  "dependencies": [],
  "codepen": "https://codepen.io/Enrichr-Dev/pen/JoWwBwy",
  "source": {
    "markup": "<div class=\"ef-lwg\">\n  <svg class=\"ef-lwg__svg\" viewBox=\"0 0 1000 300\" preserveAspectRatio=\"none\" role=\"img\" aria-label=\"Layered waves rolling sideways along the bottom of the panel\"></svg>\n</div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-lwg { --ef-lwg-area: 220px; position: relative; width: 100%; height: 100%; min-height: 20rem; overflow: hidden; border-radius: 1rem; background: #005236; }\n.ef-lwg .ef-lwg__svg { position: absolute; left: 0; bottom: 0; display: block; width: 100%; height: min(var(--ef-lwg-area), 100%); }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Layered wave generator: stacked SVG waves that roll sideways, redrawn every frame from real wave maths, no keyframes.\n// Each layer samples 49 points across a 1000 by 300 viewBox around a line 40% down: a sine of the chosen wavelength,\n// plus an optional second harmonic (warp, which leans the crests one way) and two faster, shorter sines (turbulence,\n// for chop). Back layers are 40% flatter, start 0.6 radians later and fade by the depth setting. The points are joined\n// with quadratic curves through their midpoints (roundness blends from straight corners to fully round) and closed along\n// the bottom. The phase advances one full cycle every 8 seconds at speed 1, as the original GSAP ticker did.\n// Reduced motion draws one still frame. The loop pauses off screen and in hidden tabs, and stops at speed 0.\n// mount(root, { height (wave height), width (wavelength, viewBox units), speed, warp (-1 to 1), turbulence (0-100),\n//               layers (1-6), depth (0-100), roundness (0-100), color (waves), background, area (wave strip height, px) })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var wrap = root.querySelector(\".ef-lwg\");\n  var svg = root.querySelector(\".ef-lwg__svg\");\n  var NS = \"http://www.w3.org/2000/svg\", VBW = 1000, VBH = 300, STEPS = 48, TAU = 6.283;\n  var opts = {}, paths = [], phase = 0, raf = 0, last = 0, visible = true, io = null, destroyed = false;\n\n  function num(v, d) { v = Number(v); return isFinite(v) ? v : d; }\n  function r2(v) { return Math.round(v * 100) / 100; }\n\n  function buildLayers() {\n    svg.textContent = \"\";\n    paths = [];\n    var n = opts.layers;\n    for (var i = 0; i < n; i++) {\n      var p = document.createElementNS(NS, \"path\");\n      svg.appendChild(p); // layer 0 (\"front\", fully opaque) is painted first, as in the original\n      paths.push({ el: p, depthT: 0 });\n    }\n    styleLayers();\n  }\n  function styleLayers() {\n    var n = paths.length;\n    paths.forEach(function (layer, i) {\n      layer.depthT = n === 1 ? 1 : i / (n - 1); // 0 = front, 1 = back\n      var opacity = 1 - layer.depthT * (opts.depth / 100) * 0.85;\n      layer.el.setAttribute(\"fill\", opts.color);\n      layer.el.setAttribute(\"opacity\", Math.max(0.08, opacity).toFixed(2));\n    });\n  }\n\n  function computeY(x, ph, depthT) {\n    var wl = Math.max(20, opts.width);\n    var amp = opts.height * (1 - depthT * 0.4); // back layers slightly flatter\n    var warp = opts.warp, turb = opts.turbulence / 100;\n    var base = Math.sin((x / wl) * Math.PI * 2 + ph);\n    var harmonic = Math.sin((x / wl) * Math.PI * 4 + ph * 1.7) * Math.abs(warp) * (warp >= 0 ? 1 : -1) * 0.5;\n    var chop = turb > 0 ? (Math.sin((x / (wl * 0.31)) * Math.PI * 2 + ph * 3.1) * 0.35 + Math.sin((x / (wl * 0.13)) * Math.PI * 2 - ph * 4.7) * 0.25) * turb : 0;\n    return amp * (base + harmonic) + amp * chop * 0.6;\n  }\n  // The original joins midpoints with Q curves whose control is each sample (full rounding). Here roundness t shrinks\n  // that rounding toward each corner: t = 1 is the original curve, t = 0 is straight lines through the samples.\n  function toPath(pts, t) {\n    var d = \"M\" + r2(pts[0][0]) + \",\" + r2(pts[0][1]), i;\n    if (pts.length < 3 || t <= 0) {\n      for (i = 1; i < pts.length; i++) d += \" L\" + r2(pts[i][0]) + \",\" + r2(pts[i][1]);\n      return d;\n    }\n    for (i = 1; i < pts.length - 1; i++) {\n      var p = pts[i], a = pts[i - 1], b = pts[i + 1];\n      var ax = p[0] + ((a[0] + p[0]) / 2 - p[0]) * t, ay = p[1] + ((a[1] + p[1]) / 2 - p[1]) * t;\n      var bx = p[0] + ((b[0] + p[0]) / 2 - p[0]) * t, by = p[1] + ((b[1] + p[1]) / 2 - p[1]) * t;\n      d += \" L\" + r2(ax) + \",\" + r2(ay) + \" Q\" + r2(p[0]) + \",\" + r2(p[1]) + \" \" + r2(bx) + \",\" + r2(by);\n    }\n    var lastPt = pts[pts.length - 1];\n    return d + \" L\" + r2(lastPt[0]) + \",\" + r2(lastPt[1]);\n  }\n  function draw() {\n    var midY = VBH * 0.4, t = Math.max(0, Math.min(1, opts.roundness / 100));\n    paths.forEach(function (layer, idx) {\n      var lp = phase + idx * 0.6, pts = [];\n      for (var s = 0; s <= STEPS; s++) { var x = (s / STEPS) * VBW; pts.push([x, midY + computeY(x, lp, layer.depthT)]); }\n      layer.el.setAttribute(\"d\", toPath(pts, t) + \" L\" + VBW + \",\" + VBH + \" L0,\" + VBH + \" Z\");\n    });\n  }\n\n  function loop(now) {\n    raf = 0;\n    if (destroyed || reduce || opts.speed <= 0) return;\n    raf = requestAnimationFrame(loop);\n    var dt = (now - last) / 1000; last = now;\n    if (dt > 0.5 || dt < 0) dt = 0.033;\n    if (!visible || document.hidden) return;\n    phase += dt * TAU * opts.speed / 8; // one cycle (6.283) every 8 / speed seconds, linear\n    draw();\n  }\n  function kick() { if (!raf && !destroyed && !reduce && opts.speed > 0) { last = performance.now(); raf = requestAnimationFrame(loop); } }\n\n  function update(partial) {\n    var prevLayers = opts.layers;\n    opts = Object.assign({ height: 40, width: 300, speed: 1, warp: 0, turbulence: 0, layers: 3, depth: 50, roundness: 70, color: \"#fbf8f1\", background: \"#005236\", area: 220 }, opts, partial || {});\n    opts.height = Math.max(0, num(opts.height, 40)); opts.width = num(opts.width, 300); opts.speed = Math.max(0, num(opts.speed, 1));\n    opts.warp = Math.max(-1, Math.min(1, num(opts.warp, 0))); opts.turbulence = Math.max(0, num(opts.turbulence, 0));\n    opts.layers = Math.max(1, Math.min(6, Math.round(num(opts.layers, 3)))); opts.depth = num(opts.depth, 50); opts.roundness = num(opts.roundness, 70);\n    opts.area = Math.max(40, num(opts.area, 220));\n    wrap.style.background = opts.background;\n    wrap.style.setProperty(\"--ef-lwg-area\", opts.area + \"px\");\n    if (opts.layers !== prevLayers || !paths.length) buildLayers(); else styleLayers();\n    draw();\n    kick();\n  }\n\n  update(o);\n  if (!reduce && \"IntersectionObserver\" in window) { io = new IntersectionObserver(function (e) { visible = e[0].isIntersecting; }); io.observe(wrap); }\n  return {\n    update: update,\n    destroy: function () { destroyed = true; cancelAnimationFrame(raf); raf = 0; if (io) io.disconnect(); }\n  };\n}"
  }
}