{
  "id": "rapid-layers-intro",
  "kind": "element",
  "title": "Rapid layers intro",
  "summary": "A stack of full-bleed colour layers wipes in quickly one after another, then wipes away to reveal a headline, with a replay button.",
  "url": "https://enrichr.dev/elements/rapid-layers-intro.html",
  "section": "hero",
  "techniques": [
    "reveal",
    "stagger"
  ],
  "stack": [
    "Vanilla JS",
    "CSS"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "bold",
    "energetic",
    "modern"
  ],
  "intents": [
    "staggered colour layer wipe intro",
    "fast clip-path page reveal",
    "layered curtain reveal animation",
    "hero intro with wiping colour bars",
    "replayable intro animation"
  ],
  "status": "tested",
  "params": [
    {
      "key": "title",
      "label": "Headline",
      "type": "text",
      "value": "Make it move"
    },
    {
      "key": "direction",
      "label": "Wipe direction",
      "type": "select",
      "options": [
        [
          "right",
          "Left to right"
        ],
        [
          "left",
          "Right to left"
        ],
        [
          "down",
          "Top to bottom"
        ],
        [
          "up",
          "Bottom to top"
        ]
      ],
      "value": "right"
    },
    {
      "key": "layers",
      "label": "Layers",
      "type": "range",
      "min": 3,
      "max": 8,
      "step": 1,
      "value": 5
    },
    {
      "key": "colorA",
      "label": "First layer colour",
      "type": "color",
      "value": "#005236"
    },
    {
      "key": "colorB",
      "label": "Last layer colour",
      "type": "color",
      "value": "#e6ff55"
    }
  ],
  "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 \"Rapid layers intro\" element to this project.\n\nThis is the \"Rapid layers intro\" element from the Enrichr Library: A stack of full-bleed colour layers wipes in quickly one after another, then wipes away to reveal a headline, with a replay button.\nPage: https://enrichr.dev/elements/rapid-layers-intro.html\nMachine-readable spec: https://enrichr.dev/elements/rapid-layers-intro.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/rapid-layers-intro.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 \"Rapid layers intro\" 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 \"Rapid layers intro\" element from the Enrichr Library: A stack of full-bleed colour layers wipes in quickly one after another, then wipes away to reveal a headline, with a replay button.\nPage: https://enrichr.dev/elements/rapid-layers-intro.html\nMachine-readable spec: https://enrichr.dev/elements/rapid-layers-intro.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 \"Rapid layers intro\" element to this codebase.\n\nThis is the \"Rapid layers intro\" element from the Enrichr Library: A stack of full-bleed colour layers wipes in quickly one after another, then wipes away to reveal a headline, with a replay button.\nPage: https://enrichr.dev/elements/rapid-layers-intro.html\nMachine-readable spec: https://enrichr.dev/elements/rapid-layers-intro.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-rapid-layers-intro.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Rapid layers intro 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 \"Rapid layers intro\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Rapid layers intro\" element from the Enrichr Library: A stack of full-bleed colour layers wipes in quickly one after another, then wipes away to reveal a headline, with a replay button.\nPage: https://enrichr.dev/elements/rapid-layers-intro.html\nMachine-readable spec: https://enrichr.dev/elements/rapid-layers-intro.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- rapid-layers-intro.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 \"./rapid-layers-intro\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function RapidLayersIntro(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 \"Rapid layers intro\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Rapid layers intro\" element from the Enrichr Library: A stack of full-bleed colour layers wipes in quickly one after another, then wipes away to reveal a headline, with a replay button.\nPage: https://enrichr.dev/elements/rapid-layers-intro.html\nMachine-readable spec: https://enrichr.dev/elements/rapid-layers-intro.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- rapid-layers-intro.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/RapidLayersIntro.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./rapid-layers-intro\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function RapidLayersIntro(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 \"Rapid layers intro\" element.\n\nThis is the \"Rapid layers intro\" element from the Enrichr Library: A stack of full-bleed colour layers wipes in quickly one after another, then wipes away to reveal a headline, with a replay button.\nPage: https://enrichr.dev/elements/rapid-layers-intro.html\nMachine-readable spec: https://enrichr.dev/elements/rapid-layers-intro.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), rapid-layers-intro.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 \"Rapid layers intro\" element. No packages, no server code.\n\nThis is the \"Rapid layers intro\" element from the Enrichr Library: A stack of full-bleed colour layers wipes in quickly one after another, then wipes away to reveal a headline, with a replay button.\nPage: https://enrichr.dev/elements/rapid-layers-intro.html\nMachine-readable spec: https://enrichr.dev/elements/rapid-layers-intro.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 rapid-layers-intro.js and then main.js), style.css (the CSS below), rapid-layers-intro.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 \"Rapid layers intro\" 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 \"Rapid layers intro\" element from the Enrichr Library: A stack of full-bleed colour layers wipes in quickly one after another, then wipes away to reveal a headline, with a replay button.\nPage: https://enrichr.dev/elements/rapid-layers-intro.html\nMachine-readable spec: https://enrichr.dev/elements/rapid-layers-intro.json\n\nWhat it does: Each layer is a full-size block whose clip-path starts as an empty inset. The Web Animations API animates it to a full inset, with each layer delayed a little more than the one below, so the colours stack up. After a short hold the layers animate out to an empty inset on the far side, starting with the top layer, so the wipe keeps travelling in the same direction and reveals the headline underneath. Layer colours are mixed between the two colour params with color-mix. The text rises in as the last layers clear. The animation plays once when the element scrolls into view, and again from the Replay button or when you change the direction.\nAccessibility: The headline is real text and is present in the document from the start, only its opacity is animated. The layers are decorative and hidden from assistive technology, and they never receive pointer events. With reduced motion the headline is shown immediately with no wipe, and Replay only performs a soft fade. The Replay control is a native button with a visible focus ring.\n\nTunable settings:\n- Headline: text, default Make it move\n- Wipe direction: select (Left to right / Right to left / Top to bottom / Bottom to top), default right\n- Layers: range 3 to 8, step 1, default 5\n- First layer colour: color, default #005236\n- Last layer colour: color, default #e6ff55\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/rapid-layers-intro.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 \"Rapid layers intro\" 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 \"Rapid layers intro\" element from the Enrichr Library: A stack of full-bleed colour layers wipes in quickly one after another, then wipes away to reveal a headline, with a replay button.\nPage: https://enrichr.dev/elements/rapid-layers-intro.html\nMachine-readable spec: https://enrichr.dev/elements/rapid-layers-intro.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 RapidLayersIntro.\n2. Paste the JavaScript below into a separate code file named rapid-layers-intro.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 \"./rapid-layers-intro\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function RapidLayersIntro(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(RapidLayersIntro, {\n  title: { type: ControlType.String, title: \"Headline\", defaultValue: \"Make it move\" },\n  direction: { type: ControlType.Enum, title: \"Wipe direction\", options: [\"right\",\"left\",\"down\",\"up\"], optionTitles: [\"Left to right\",\"Right to left\",\"Top to bottom\",\"Bottom to top\"], defaultValue: \"right\" },\n  layers: { type: ControlType.Number, title: \"Layers\", min: 3, max: 8, step: 1, defaultValue: 5 },\n  colorA: { type: ControlType.Color, title: \"First layer colour\", defaultValue: \"#005236\" },\n  colorB: { type: ControlType.Color, title: \"Last layer colour\", defaultValue: \"#e6ff55\" },\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 \"Rapid layers intro\" 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 \"Rapid layers intro\" element from the Enrichr Library: A stack of full-bleed colour layers wipes in quickly one after another, then wipes away to reveal a headline, with a replay button.\nPage: https://enrichr.dev/elements/rapid-layers-intro.html\nMachine-readable spec: https://enrichr.dev/elements/rapid-layers-intro.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-rapid-layers-intro\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-rapid-layers-intro\"), { ...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 headline is real text and is present in the document from the start, only its opacity is animated. The layers are decorative and hidden from assistive technology, and they never receive pointer events. With reduced motion the headline is shown immediately with no wipe, and Replay only performs a soft fade. The Replay control is a native button with a visible focus ring.",
  "performance": "Clip-path animations on a handful of full-size layers. For large screens keep the layer count at eight or fewer. Animations are cancelled when the element is destroyed or replayed.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-rli\">\n  <div class=\"ef-rli__stage\">\n    <div class=\"ef-rli__copy\">\n      <p class=\"ef-rli__eye\">Introducing</p>\n      <h3 class=\"ef-rli__t\"></h3>\n      <button type=\"button\" class=\"ef-rli__btn\">Replay</button>\n    </div>\n    <div class=\"ef-rli__layers\" aria-hidden=\"true\"></div>\n  </div>\n</div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-rli { width: 100%; }\n.ef-rli__stage { position: relative; isolation: isolate; overflow: hidden; width: 100%; min-height: 18rem; border-radius: 1rem; background: #0c1e18; color: #fbf8f1; display: flex; align-items: center; font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; }\n.ef-rli__copy { position: relative; z-index: 1; box-sizing: border-box; width: 100%; padding: 1.6rem clamp(1.2rem, 5vw, 3rem); display: flex; flex-direction: column; align-items: flex-start; gap: 0.9rem; }\n.ef-rli__eye { margin: 0; font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.65; }\n.ef-rli__t { margin: 0; font-size: clamp(2rem, 8vw, 4.6rem); font-weight: 800; line-height: 0.98; letter-spacing: -0.03em; max-width: 12ch; text-wrap: balance; }\n.ef-rli__btn { appearance: none; margin-top: 0.4rem; background: transparent; color: inherit; border: 1.5px solid currentColor; border-radius: 999px; font: inherit; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.04em; padding: 0.55rem 1.2rem; cursor: pointer; transition: background-color 200ms, color 200ms; }\n.ef-rli__btn:hover { background: #fbf8f1; color: #0c1e18; }\n.ef-rli__btn:focus-visible { outline: 2px solid #e6ff55; outline-offset: 3px; }\n.ef-rli__layers { position: absolute; inset: 0; z-index: 2; pointer-events: none; }\n.ef-rli__layer { position: absolute; inset: 0; will-change: clip-path; }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Rapid layers intro: a stack of full-bleed colour layers wipes in one after another, then wipes back out in the same direction to reveal a headline.\n// Built with clip-path and the Web Animations API. Plays when scrolled into view and again from the Replay button.\n// Reduced motion shows the headline straight away and the button only does a soft fade.\n// mount(root, { title, direction (\"right\", \"left\", \"up\" or \"down\"), layers (3-8), colorA, colorB })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var stage = root.querySelector(\".ef-rli__stage\");\n  var holder = root.querySelector(\".ef-rli__layers\");\n  var titleEl = root.querySelector(\".ef-rli__t\");\n  var copy = root.querySelector(\".ef-rli__copy\");\n  var eye = root.querySelector(\".ef-rli__eye\");\n  var btn = root.querySelector(\".ef-rli__btn\");\n  var opts = {}, layers = [], anims = [], io = null, played = false, timer = 0;\n  var FULL = \"inset(0% 0% 0% 0%)\";\n  var SHAPES = {\n    right: [\"inset(0% 100% 0% 0%)\", \"inset(0% 0% 0% 100%)\"],\n    left: [\"inset(0% 0% 0% 100%)\", \"inset(0% 100% 0% 0%)\"],\n    down: [\"inset(0% 0% 100% 0%)\", \"inset(100% 0% 0% 0%)\"],\n    up: [\"inset(100% 0% 0% 0%)\", \"inset(0% 0% 100% 0%)\"]\n  };\n  function shape() { return SHAPES[opts.direction] || SHAPES.right; }\n\n  function clearAnims() { anims.forEach(function (a) { try { a.cancel(); } catch (e) {} }); anims = []; clearTimeout(timer); }\n  function build() {\n    clearAnims();\n    holder.textContent = \"\";\n    layers = [];\n    var n = opts.layers;\n    for (var i = 0; i < n; i++) {\n      var d = document.createElement(\"div\");\n      d.className = \"ef-rli__layer\";\n      var m = n > 1 ? Math.round((i / (n - 1)) * 100) : 100;\n      var m2 = Math.min(100, m + 14);\n      d.style.background = \"linear-gradient(135deg, color-mix(in srgb, \" + opts.colorB + \" \" + m + \"%, \" + opts.colorA + \"), color-mix(in srgb, \" + opts.colorB + \" \" + m2 + \"%, \" + opts.colorA + \"))\";\n      holder.appendChild(d);\n      layers.push(d);\n    }\n    rest();\n  }\n  function rest() {\n    if (reduce) { holder.style.display = \"none\"; copy.style.opacity = \"1\"; return; }\n    holder.style.display = \"\";\n    layers.forEach(function (l) { l.style.clipPath = played ? shape()[1] : shape()[0]; });\n    copy.style.opacity = played ? \"1\" : \"0\";\n  }\n  function play() {\n    clearAnims();\n    if (reduce) {\n      copy.style.opacity = \"1\";\n      if (copy.animate) anims.push(copy.animate([{ opacity: 0.2 }, { opacity: 1 }], { duration: 420, easing: \"ease-out\" }));\n      return;\n    }\n    played = true;\n    var s = shape(), n = layers.length;\n    var dIn = 520, stag = Math.max(40, Math.round(420 / n)), hold = 120, dOut = 520;\n    var inTotal = dIn + stag * (n - 1);\n    var outStart = inTotal + hold;\n    var ease = \"cubic-bezier(.76,0,.2,1)\";\n    layers.forEach(function (l, i) {\n      l.style.clipPath = s[0];\n      anims.push(l.animate([{ clipPath: s[0] }, { clipPath: FULL }], { duration: dIn, delay: i * stag, easing: ease, fill: \"both\" }));\n      anims.push(l.animate([{ clipPath: FULL }, { clipPath: s[1] }], { duration: dOut, delay: outStart + (n - 1 - i) * stag, easing: ease, fill: \"forwards\" }));\n    });\n    copy.style.opacity = \"1\";\n    var ch = [eye, titleEl, btn];\n    ch.forEach(function (el, i) {\n      anims.push(el.animate([{ opacity: 0, transform: \"translateY(36px)\" }, { opacity: 1, transform: \"translateY(0)\" }], { duration: 700, delay: outStart + stag * (n - 1) * 0.6 + i * 110, easing: \"cubic-bezier(.2,.8,.2,1)\", fill: \"both\" }));\n    });\n  }\n  function onBtn() { play(); }\n  function update(next) {\n    var prev = opts;\n    opts = Object.assign({ title: \"Make it move\", direction: \"right\", layers: 5, colorA: \"#005236\", colorB: \"#e6ff55\" }, opts, next || {});\n    opts.layers = Math.max(3, Math.min(8, Math.round(opts.layers)));\n    titleEl.textContent = opts.title;\n    var rebuild = prev.layers !== opts.layers || prev.colorA !== opts.colorA || prev.colorB !== opts.colorB;\n    if (rebuild) build();\n    if (prev.direction !== undefined && (rebuild || prev.direction !== opts.direction)) { played = false; play(); }\n  }\n  update(o);\n  btn.addEventListener(\"click\", onBtn);\n  if (\"IntersectionObserver\" in window && !reduce) {\n    io = new IntersectionObserver(function (en) { if (en[0].isIntersecting && !played) { play(); io.disconnect(); io = null; } }, { threshold: 0.35 });\n    io.observe(stage);\n  } else if (!reduce) { play(); }\n  return { update: update, destroy: function () { clearAnims(); if (io) io.disconnect(); btn.removeEventListener(\"click\", onBtn); } };\n}"
  }
}