{
  "id": "scroll-layout-flip",
  "kind": "element",
  "title": "Scroll layout flip",
  "summary": "A pinned row of tiles that re-flows into a grid, a feature view or a fanned stack as you scroll inside the panel, with the art cropped rather than stretched.",
  "url": "https://enrichr.dev/elements/scroll-layout-flip.html",
  "section": "gallery",
  "techniques": [
    "scroll-driven",
    "stagger"
  ],
  "stack": [
    "Vanilla JS",
    "CSS"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "modern",
    "polished",
    "immersive"
  ],
  "intents": [
    "scroll layout switch animation",
    "row of images becomes a grid on scroll",
    "flip animation tied to scroll",
    "pinned gallery that rearranges",
    "scroll scrubbed layout transition without gsap"
  ],
  "status": "tested",
  "params": [
    {
      "key": "layout",
      "label": "Final layout",
      "type": "select",
      "options": [
        [
          "grid",
          "Grid"
        ],
        [
          "feature",
          "Feature"
        ],
        [
          "stack",
          "Fanned stack"
        ]
      ],
      "value": "grid"
    },
    {
      "key": "length",
      "label": "Scroll length (screens)",
      "type": "range",
      "min": 1,
      "max": 6,
      "step": 0.5,
      "value": 2.5
    },
    {
      "key": "smooth",
      "label": "Smoothing",
      "type": "range",
      "min": 0,
      "max": 1,
      "step": 0.05,
      "value": 0.6
    },
    {
      "key": "count",
      "label": "Tiles",
      "type": "range",
      "min": 5,
      "max": 9,
      "step": 1,
      "value": 7
    },
    {
      "key": "accent",
      "label": "Accent 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 \"Scroll layout flip\" element to this project.\n\nThis is the \"Scroll layout flip\" element from the Enrichr Library: A pinned row of tiles that re-flows into a grid, a feature view or a fanned stack as you scroll inside the panel, with the art cropped rather than stretched.\nPage: https://enrichr.dev/elements/scroll-layout-flip.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-layout-flip.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/scroll-layout-flip.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 \"Scroll layout flip\" 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 \"Scroll layout flip\" element from the Enrichr Library: A pinned row of tiles that re-flows into a grid, a feature view or a fanned stack as you scroll inside the panel, with the art cropped rather than stretched.\nPage: https://enrichr.dev/elements/scroll-layout-flip.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-layout-flip.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 \"Scroll layout flip\" element to this codebase.\n\nThis is the \"Scroll layout flip\" element from the Enrichr Library: A pinned row of tiles that re-flows into a grid, a feature view or a fanned stack as you scroll inside the panel, with the art cropped rather than stretched.\nPage: https://enrichr.dev/elements/scroll-layout-flip.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-layout-flip.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-scroll-layout-flip.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Scroll layout flip 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 \"Scroll layout flip\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Scroll layout flip\" element from the Enrichr Library: A pinned row of tiles that re-flows into a grid, a feature view or a fanned stack as you scroll inside the panel, with the art cropped rather than stretched.\nPage: https://enrichr.dev/elements/scroll-layout-flip.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-layout-flip.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- scroll-layout-flip.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 \"./scroll-layout-flip\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function ScrollLayoutFlip(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 \"Scroll layout flip\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Scroll layout flip\" element from the Enrichr Library: A pinned row of tiles that re-flows into a grid, a feature view or a fanned stack as you scroll inside the panel, with the art cropped rather than stretched.\nPage: https://enrichr.dev/elements/scroll-layout-flip.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-layout-flip.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- scroll-layout-flip.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/ScrollLayoutFlip.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./scroll-layout-flip\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function ScrollLayoutFlip(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 \"Scroll layout flip\" element.\n\nThis is the \"Scroll layout flip\" element from the Enrichr Library: A pinned row of tiles that re-flows into a grid, a feature view or a fanned stack as you scroll inside the panel, with the art cropped rather than stretched.\nPage: https://enrichr.dev/elements/scroll-layout-flip.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-layout-flip.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), scroll-layout-flip.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 \"Scroll layout flip\" element. No packages, no server code.\n\nThis is the \"Scroll layout flip\" element from the Enrichr Library: A pinned row of tiles that re-flows into a grid, a feature view or a fanned stack as you scroll inside the panel, with the art cropped rather than stretched.\nPage: https://enrichr.dev/elements/scroll-layout-flip.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-layout-flip.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 scroll-layout-flip.js and then main.js), style.css (the CSS below), scroll-layout-flip.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 \"Scroll layout flip\" 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 \"Scroll layout flip\" element from the Enrichr Library: A pinned row of tiles that re-flows into a grid, a feature view or a fanned stack as you scroll inside the panel, with the art cropped rather than stretched.\nPage: https://enrichr.dev/elements/scroll-layout-flip.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-layout-flip.json\n\nWhat it does: This is a vanilla port, with no GSAP, Flip or ScrollTrigger. The element owns a scrolling panel with a tall track and a sticky stage. Every tile has two boxes, one in a loose row and one in the chosen final layout, and the script blends position, size and tilt between them as the scroll progress goes from 0 to 1, with a small per-tile delay from the centre outwards. Each tile is drawn at its larger size and scaled with a transform, while its art is counter-scaled so it crops instead of stretching. Scroll progress is smoothed with a lerp in one requestAnimationFrame loop that only runs while the value is still moving.\nAccessibility: The panel is a keyboard-focusable scroll region, so arrow keys, Page Up and Page Down and touch all work and the focus ring is visible. The tiles are decorative and hidden from assistive technology, and the caption states the layout in text. With reduced motion the smoothing and the art zoom are off and the layout follows the scroll position exactly, still driven by the user.\n\nTunable settings:\n- Final layout: select (Grid / Feature / Fanned stack), default grid\n- Scroll length (screens): range 1 to 6, step 0.5, default 2.5\n- Smoothing: range 0 to 1, step 0.05, default 0.6\n- Tiles: range 5 to 9, step 1, default 7\n- Accent 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/scroll-layout-flip.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 \"Scroll layout flip\" 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 \"Scroll layout flip\" element from the Enrichr Library: A pinned row of tiles that re-flows into a grid, a feature view or a fanned stack as you scroll inside the panel, with the art cropped rather than stretched.\nPage: https://enrichr.dev/elements/scroll-layout-flip.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-layout-flip.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 ScrollLayoutFlip.\n2. Paste the JavaScript below into a separate code file named scroll-layout-flip.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 \"./scroll-layout-flip\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function ScrollLayoutFlip(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(ScrollLayoutFlip, {\n  layout: { type: ControlType.Enum, title: \"Final layout\", options: [\"grid\",\"feature\",\"stack\"], optionTitles: [\"Grid\",\"Feature\",\"Fanned stack\"], defaultValue: \"grid\" },\n  length: { type: ControlType.Number, title: \"Scroll length\", min: 1, max: 6, step: 0.5, defaultValue: 2.5 },\n  smooth: { type: ControlType.Number, title: \"Smoothing\", min: 0, max: 1, step: 0.05, defaultValue: 0.6 },\n  count: { type: ControlType.Number, title: \"Tiles\", min: 5, max: 9, step: 1, defaultValue: 7 },\n  accent: { type: ControlType.Color, title: \"Accent 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 \"Scroll layout flip\" 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 \"Scroll layout flip\" element from the Enrichr Library: A pinned row of tiles that re-flows into a grid, a feature view or a fanned stack as you scroll inside the panel, with the art cropped rather than stretched.\nPage: https://enrichr.dev/elements/scroll-layout-flip.html\nMachine-readable spec: https://enrichr.dev/elements/scroll-layout-flip.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-scroll-layout-flip\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-scroll-layout-flip\"), { ...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 panel is a keyboard-focusable scroll region, so arrow keys, Page Up and Page Down and touch all work and the focus ring is visible. The tiles are decorative and hidden from assistive technology, and the caption states the layout in text. With reduced motion the smoothing and the art zoom are off and the layout follows the scroll position exactly, still driven by the user.",
  "performance": "Only transforms on a handful of tiles change per frame, plus the radius on the same tiles. Geometry is measured once on resize through a ResizeObserver, not on every scroll event, and the rAF loop stops when the smoothed value reaches the target.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-slf\">\n  <div class=\"ef-slf__wrap\">\n    <div class=\"ef-slf__scroller\" tabindex=\"0\" role=\"region\" aria-label=\"Scroll inside this panel to rearrange the tiles from a row into a new layout\">\n      <div class=\"ef-slf__track\">\n        <div class=\"ef-slf__stage\">\n          <div class=\"ef-slf__items\" aria-hidden=\"true\"></div>\n          <p class=\"ef-slf__cap\"><b class=\"ef-slf__capt\"></b><span class=\"ef-slf__caps\"></span></p>\n          <div class=\"ef-slf__bar\" aria-hidden=\"true\"><i></i></div>\n          <div class=\"ef-slf__hint\" aria-hidden=\"true\">Scroll</div>\n        </div>\n      </div>\n    </div>\n  </div>\n</div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n/* Adapted from https://github.com/codrops/ScrollBasedLayoutAnimations (MIT) — Copyright (c) 2009 - 2022 [Codrops](https://tympanus.net/codrops) */\n.ef-slf { width: 100%; height: 100%; min-height: 26rem; font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; }\n.ef-slf__wrap { --ef-acc: #e6ff55; position: relative; box-sizing: border-box; width: 100%; height: 100%; min-height: 26rem; border-radius: 1rem; overflow: hidden; background: #0c1e18; color: #fbf8f1; }\n.ef-slf__scroller { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(251, 248, 241, 0.35) transparent; outline: none; }\n.ef-slf__scroller:focus-visible { box-shadow: inset 0 0 0 2px var(--ef-acc); }\n.ef-slf__track { position: relative; width: 100%; height: 300%; }\n.ef-slf__stage { position: sticky; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; }\n.ef-slf__items { position: absolute; inset: 0; }\n.ef-slf__tile { position: absolute; left: 0; top: 0; overflow: hidden; transform-origin: 0 0; will-change: transform; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.7); }\n.ef-slf__inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; }\n.ef-slf__art { position: absolute; inset: 0; will-change: transform; }\n.ef-slf__art svg { position: absolute; inset: 0; margin: auto; width: 58%; height: 58%; display: block; }\n.ef-slf__n { position: absolute; left: 0.7rem; bottom: 0.55rem; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.14em; opacity: 0.85; }\n.ef-slf__cap { z-index: 20; position: absolute; left: 0.9rem; bottom: 1.5rem; margin: 0; max-width: 70%; padding: 0.6rem 0.8rem; border-radius: 0.7rem; background: rgba(12, 30, 24, 0.94); display: flex; flex-direction: column; gap: 0.15rem; opacity: 0; transform: translateY(8px); pointer-events: none; }\n.ef-slf__capt { font-size: 0.95rem; font-weight: 800; letter-spacing: -0.01em; }\n.ef-slf__caps { font-size: 0.72rem; opacity: 0.8; line-height: 1.35; }\n.ef-slf__bar { z-index: 20; position: absolute; left: 0.9rem; right: 0.9rem; bottom: 0.7rem; height: 3px; border-radius: 3px; background: rgba(251, 248, 241, 0.2); }\n.ef-slf__bar i { display: block; height: 100%; border-radius: inherit; background: var(--ef-acc); transform-origin: 0 50%; transform: scaleX(0); }\n.ef-slf__hint { z-index: 20; position: absolute; top: 0.8rem; right: 0.9rem; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ef-acc); }\n.ef-slf__hint::after { content: \"\"; display: inline-block; width: 0.45rem; height: 0.45rem; margin-left: 0.4rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); animation: ef-slf-nudge 1.4s ease-in-out infinite; }\n@keyframes ef-slf-nudge { 0%, 100% { translate: 0 -2px; } 50% { translate: 0 3px; } }\n@media (prefers-reduced-motion: reduce) { .ef-slf__hint::after { animation: none; } .ef-slf__cap { transform: none; } }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Adapted from https://github.com/codrops/ScrollBasedLayoutAnimations (MIT) — Copyright (c) 2009 - 2022 [Codrops](https://tympanus.net/codrops)\n// Scroll layout flip: a row of tiles pinned in a panel of its own re-flows into a grid, a feature view or a fanned stack as you scroll.\n// A hand-made FLIP: every tile has a \"row\" box and a \"final\" box, and the scroll progress blends position, size and tilt between them.\n// The tile art is counter-scaled so it is cropped, never stretched. No GSAP, no ScrollTrigger: the panel scrolls itself (wheel, touch,\n// keys), so it works inside an overflow:hidden container. Scrolling is smoothed with a lerp; reduced motion follows the scroll 1:1.\n// mount(root, { background, accent, layout (\"grid\"|\"feature\"|\"stack\"), length (screens of scroll), smooth (0-1), count (5-9) })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var wrap = root.querySelector(\".ef-slf__wrap\");\n  var sc = root.querySelector(\".ef-slf__scroller\");\n  var track = root.querySelector(\".ef-slf__track\");\n  var stage = root.querySelector(\".ef-slf__stage\");\n  var itemsEl = root.querySelector(\".ef-slf__items\");\n  var cap = root.querySelector(\".ef-slf__cap\");\n  var capT = root.querySelector(\".ef-slf__capt\");\n  var capS = root.querySelector(\".ef-slf__caps\");\n  var bar = root.querySelector(\".ef-slf__bar i\");\n  var hint = root.querySelector(\".ef-slf__hint\");\n  var PIECES = [\n    { vb: \"1513.7 1453.9 322.3 322.3\", d: \"M1821 1761.2h-292.3v-111.6c0-8 6.5-14.5 14.5-14.5 4.2 0 8.2 1.9 11 5.1 7.8 8.6 19.7 13.6 32.7 11.9 16.8-2.3 30.1-16 32-32.7 2.5-22.6-15.1-41.6-37.1-41.6-11 0-20.9 4.7-27.7 12.3-2.8 3.1-6.7 4.9-10.9 4.9-8 0-14.5-6.4-14.5-14.4v-111.7h292.3v111.7c0 8-6.4 14.4-14.5 14.4-4.2 0-8.1-1.8-10.9-5-7.9-8.6-19.7-13.6-32.7-11.9-16.8 2.2-30.1 15.9-32 32.7-2.5 22.6 15.1 41.6 37.1 41.6 11 0 20.8-4.8 27.7-12.3 2.8-3.1 6.7-5 10.8-5 8.1 0 14.5 6.5 14.5 14.5z\" },\n    { vb: \"1423.36 860.8 503.07 322.3\", d: \"M1821 875.8v111.6c0 8 6.5 14.5 14.5 14.5 4.2 0 8.1-1.9 10.9-5 6.8-7.5 16.7-12.3 27.7-12.3 22 0 39.6 19 37.1 41.6-1.9 16.7-15.2 30.5-32 32.7-13 1.7-24.8-3.3-32.7-11.9-2.8-3.2-6.8-5-11-5-8 0-14.5 6.4-14.5 14.4v111.7h-111.6c-8 0-14.5-6.5-14.5-14.5 0-4.2 1.9-8.2 5-11 8.7-7.9 13.7-19.7 12-32.7-2.3-16.8-16-30.1-32.8-32-22.5-2.5-41.5 15.1-41.5 37.1 0 11 4.7 20.9 12.3 27.7 3.1 2.8 4.9 6.7 4.9 10.8v0.1c0 8-6.4 14.5-14.5 14.5h-111.6v-111.7c0-8-6.4-14.4-14.5-14.4-4.1 0-8 1.8-10.8 4.9-6.9 7.6-16.7 12.3-27.7 12.3-22 0-39.6-19-37.1-41.6 1.9-16.7 15.2-30.4 32-32.7 13-1.7 24.8 3.3 32.7 11.9 2.8 3.2 6.7 5.1 10.9 5.1 8.1 0 14.5-6.5 14.5-14.5v-111.6z\" },\n    { vb: \"1513.7 166.86 322.3 503.06\", d: \"M1528.7 564.5v-111.6c0-8 6.5-14.5 14.5-14.5 4.2 0 8.2 1.9 11 5 7.8 8.7 19.7 13.7 32.7 11.9 16.8-2.2 30.1-15.9 32-32.7 2.5-22.5-15.1-41.5-37.1-41.5-11 0-20.9 4.7-27.7 12.3-2.8 3.1-6.7 4.9-10.9 4.9-8 0-14.5-6.5-14.5-14.5v-111.6h111.6c8.1 0 14.5-6.5 14.5-14.5 0-4.1-1.8-8.1-4.9-10.9-7.6-6.8-12.3-16.6-12.3-27.6 0-22 19-39.6 41.5-37.1 16.8 1.8 30.5 15.2 32.8 32 1.7 12.9-3.3 24.8-12 32.7-3.1 2.8-5 6.7-5 10.9 0 8 6.5 14.5 14.5 14.5h111.6v111.6c0 8-6.4 14.5-14.5 14.5-4.2 0-8.1-1.9-10.9-5-7.9-8.7-19.7-13.6-32.7-11.9-16.8 2.2-30.1 15.9-32 32.7-2.5 22.5 15.1 41.6 37.1 41.6 11 0 20.8-4.8 27.7-12.3 2.8-3.1 6.7-5 10.8-5 8.1 0 14.5 6.5 14.5 14.5v111.6h-111.6c-8 0-14.5 6.5-14.5 14.5 0 4.2 1.9 8.1 5 10.9 7.5 6.8 12.3 16.7 12.3 27.7 0 22-19 39.5-41.6 37.1-16.8-1.9-30.5-15.3-32.7-32-1.7-13 3.3-24.9 11.9-32.7 3.1-2.9 5-6.8 5-11 0-8-6.4-14.5-14.5-14.5z\" }\n  ];\n  // [background, piece colour]; dark tiles take cream or the accent, light tiles take deep green\n  var ART = [\n    [\"linear-gradient(150deg, #005236, #0c1e18)\", \"A\", \"#fbf8f1\"],\n    [\"linear-gradient(160deg, #c6f26b, #2f7d5b)\", \"#005236\", \"#0c1e18\"],\n    [\"linear-gradient(145deg, #2f7d5b, #0a6b46)\", \"#fbf8f1\", \"#fbf8f1\"],\n    [\"linear-gradient(155deg, #fbf8f1, #c6f26b)\", \"#0a6b46\", \"#0c1e18\"],\n    [\"radial-gradient(circle at 70% 25%, #0a6b46, #0c1e18 70%)\", \"#c6f26b\", \"#fbf8f1\"],\n    [\"linear-gradient(160deg, #e6ff55, #c6f26b)\", \"#005236\", \"#0c1e18\"]\n  ];\n  var CAPS = {\n    grid: [\"A tidy grid\", \"The row settles into even tiles that fill the panel.\"],\n    feature: [\"A feature view\", \"One tile steps forward and the rest line up beside it.\"],\n    stack: [\"A fanned stack\", \"The row gathers into a loose pile, centre tile on top.\"]\n  };\n  var RADIUS = 9;\n  var opts = {}, tiles = [], geo = [], W = 0, H = 0, target = 0, cur = 0, raf = 0, last = 0, ro = null, built = \"\";\n\n  function lerp(a, b, t) { return a + (b - a) * t; }\n  function clamp(v, a, b) { return Math.max(a, Math.min(b, v)); }\n\n  // The \"row\" boxes: tiles in one line, the middle one biggest, a little wider than the panel\n  function rowBoxes() {\n    var n = opts.count, g = Math.max(5, Math.round(Math.min(W, H) * 0.018)), c = (n - 1) / 2, wt = [], sum = 0, i, out = [];\n    for (i = 0; i < n; i++) { wt[i] = 0.55 + 0.9 * (1 - Math.abs(i - c) / (c || 1)); sum += wt[i]; }\n    var avail = W * 1.06 - g * (n - 1), x = (W - (avail + g * (n - 1))) / 2;\n    for (i = 0; i < n; i++) {\n      var w = wt[i] / sum * avail, h = Math.min(H * 0.8, w * 1.4);\n      out.push({ cx: x + w / 2, cy: H / 2, w: w, h: h, r: 0 });\n      x += w + g;\n    }\n    return out;\n  }\n  // The \"final\" boxes for the chosen layout\n  function finalBoxes() {\n    var n = opts.count, pad = Math.round(Math.min(W, H) * 0.04) + 6, g = Math.max(6, Math.round(Math.min(W, H) * 0.02));\n    var aw = W - 2 * pad, ah = H - 2 * pad, c = (n - 1) / 2, ci = Math.round(c), out = [], i;\n    if (opts.layout === \"feature\") {\n      var bw = aw * 0.6;\n      out[ci] = { cx: pad + bw / 2, cy: H / 2, w: bw, h: ah, r: 0 };\n      var rest = [], rows, cw = aw * 0.4 - g, k = 0;\n      for (i = 0; i < n; i++) if (i !== ci) rest.push(i);\n      rows = Math.ceil(rest.length / 2);\n      var th = (ah - g * (rows - 1)) / rows, tw = (cw - g) / 2;\n      rest.forEach(function (idx) {\n        var col = k % 2, row = Math.floor(k / 2);\n        out[idx] = { cx: pad + bw + g + col * (tw + g) + tw / 2, cy: pad + row * (th + g) + th / 2, w: tw, h: th, r: 0 };\n        k++;\n      });\n    } else if (opts.layout === \"stack\") {\n      var sw = Math.min(aw * 0.56, ah * 0.52), sh = Math.min(ah * 0.78, sw * 1.35);\n      for (i = 0; i < n; i++) out.push({ cx: W / 2 + (i - c) * aw * 0.065, cy: H / 2 + (i - c) * ah * 0.012, w: sw, h: sh, r: (i - c) * 0.06 });\n    } else {\n      var cols = n <= 4 ? 2 : 3, nr = Math.ceil(n / cols), ch = (ah - g * (nr - 1)) / nr;\n      for (i = 0; i < n; i++) {\n        var r = Math.floor(i / cols), inRow = Math.min(cols, n - r * cols), cwid = (aw - g * (inRow - 1)) / inRow, col = i - r * cols;\n        out.push({ cx: pad + col * (cwid + g) + cwid / 2, cy: pad + r * (ch + g) + ch / 2, w: cwid, h: ch, r: 0 });\n      }\n    }\n    return out;\n  }\n  function layoutGeo() {\n    W = sc.clientWidth; H = sc.clientHeight;\n    if (!W || !H) return false;\n    stage.style.height = H + \"px\";\n    track.style.height = (H * (1 + opts.length)) + \"px\";\n    var a = rowBoxes(), b = finalBoxes(), n = opts.count, c = (n - 1) / 2;\n    geo = [];\n    for (var i = 0; i < n; i++) {\n      var mw = Math.max(a[i].w, b[i].w), mh = Math.max(a[i].h, b[i].h);\n      geo.push({ a: a[i], b: b[i], mw: mw, mh: mh, d: 0.28 * Math.abs(i - c) / (c || 1) });\n      var t = tiles[i];\n      t.el.style.width = mw + \"px\"; t.el.style.height = mh + \"px\";\n      t.inner.style.width = mw + \"px\"; t.inner.style.height = mh + \"px\";\n      t.el.style.zIndex = String(opts.layout === \"stack\" ? n - Math.round(Math.abs(i - c)) : (i === Math.round(c) ? n : 1));\n    }\n    return true;\n  }\n\n  function build() {\n    itemsEl.textContent = \"\";\n    tiles = [];\n    for (var i = 0; i < opts.count; i++) {\n      var art = ART[i % ART.length], pc = PIECES[[0, 1, 2][i % 3]];\n      var col = art[1] === \"A\" ? opts.accent : art[1];\n      var el = document.createElement(\"div\"); el.className = \"ef-slf__tile\";\n      var inner = document.createElement(\"div\"); inner.className = \"ef-slf__inner\";\n      var a = document.createElement(\"div\"); a.className = \"ef-slf__art\"; a.style.background = art[0]; a.style.color = col;\n      a.innerHTML = '<svg viewBox=\"' + pc.vb + '\" focusable=\"false\"><path fill=\"currentColor\" d=\"' + pc.d + '\"/></svg>';\n      var n = document.createElement(\"span\"); n.className = \"ef-slf__n\"; n.style.color = art[2]; n.textContent = String(i + 1).padStart(2, \"0\");\n      a.appendChild(n); inner.appendChild(a); el.appendChild(inner); itemsEl.appendChild(el);\n      tiles.push({ el: el, inner: inner, art: a });\n    }\n    built = opts.count + \"|\" + opts.accent;\n  }\n\n  function render(p) {\n    if (!geo.length) return;\n    var e = p * p * (3 - 2 * p), n = geo.length;\n    for (var i = 0; i < n; i++) {\n      var g = geo[i], t = tiles[i];\n      var lp = clamp((e - g.d) / (1 - 0.28), 0, 1);\n      lp = lp * lp * (3 - 2 * lp);\n      var w = lerp(g.a.w, g.b.w, lp), h = lerp(g.a.h, g.b.h, lp), cx = lerp(g.a.cx, g.b.cx, lp), cy = lerp(g.a.cy, g.b.cy, lp), r = lerp(g.a.r, g.b.r, lp);\n      var sx = w / g.mw, sy = h / g.mh;\n      var tx = cx - (Math.cos(r) * w / 2 - Math.sin(r) * h / 2), ty = cy - (Math.sin(r) * w / 2 + Math.cos(r) * h / 2);\n      t.el.style.transform = \"translate(\" + tx.toFixed(2) + \"px,\" + ty.toFixed(2) + \"px) rotate(\" + r.toFixed(4) + \"rad) scale(\" + sx.toFixed(4) + \",\" + sy.toFixed(4) + \")\";\n      t.el.style.borderRadius = (RADIUS / sx).toFixed(2) + \"px / \" + (RADIUS / sy).toFixed(2) + \"px\";\n      t.inner.style.transform = \"translate(\" + ((w - g.mw) / (2 * sx)).toFixed(2) + \"px,\" + ((h - g.mh) / (2 * sy)).toFixed(2) + \"px) scale(\" + (1 / sx).toFixed(4) + \",\" + (1 / sy).toFixed(4) + \")\";\n      t.art.style.transform = reduce ? \"\" : \"scale(\" + (1 + 0.3 * (1 - lp)).toFixed(3) + \")\";\n    }\n    var ca = clamp((p - 0.55) / 0.3, 0, 1);\n    cap.style.opacity = ca.toFixed(3);\n    cap.style.transform = \"translateY(\" + ((1 - ca) * 8).toFixed(1) + \"px)\";\n    bar.style.transform = \"scaleX(\" + p.toFixed(4) + \")\";\n    hint.style.opacity = (1 - clamp(p / 0.12, 0, 1)).toFixed(3);\n  }\n\n  function frame(ts) {\n    raf = 0;\n    var dt = Math.min(0.05, (ts - last) / 1000 || 0.016);\n    last = ts;\n    var k = opts.smooth > 0 ? 24 - 20 * opts.smooth : 0;\n    if (reduce || k <= 0) cur = target; else cur += (target - cur) * (1 - Math.exp(-dt * k));\n    if (Math.abs(target - cur) < 0.0004) cur = target;\n    render(cur);\n    if (cur !== target) raf = requestAnimationFrame(frame);\n  }\n  function kick() { if (!raf) { last = performance.now(); raf = requestAnimationFrame(frame); } }\n  function onScroll() {\n    var max = sc.scrollHeight - sc.clientHeight;\n    target = max > 0 ? clamp(sc.scrollTop / max, 0, 1) : 0;\n    kick();\n  }\n  function onResize() { if (layoutGeo()) { onScroll(); render(cur); } }\n\n  function update(next) {\n    var prev = opts;\n    opts = Object.assign({ background: \"#0c1e18\", accent: \"#e6ff55\", layout: \"grid\", length: 2.5, smooth: 0.6, count: 7 }, opts, next || {});\n    opts.count = Math.max(5, Math.min(9, Math.round(opts.count)));\n    opts.length = clamp(Number(opts.length) || 2.5, 1, 6);\n    opts.smooth = clamp(Number(opts.smooth) || 0, 0, 1);\n    if (!CAPS[opts.layout]) opts.layout = \"grid\";\n    wrap.style.background = opts.background;\n    wrap.style.setProperty(\"--ef-acc\", opts.accent);\n    capT.textContent = CAPS[opts.layout][0];\n    capS.textContent = CAPS[opts.layout][1];\n    if (built !== opts.count + \"|\" + opts.accent) build();\n    var ratio = sc.scrollHeight - sc.clientHeight > 0 ? sc.scrollTop / (sc.scrollHeight - sc.clientHeight) : 0;\n    if (layoutGeo()) {\n      var max = sc.scrollHeight - sc.clientHeight;\n      if (prev.length !== undefined && prev.length !== opts.length) sc.scrollTop = ratio * max;\n      onScroll();\n      cur = target;\n      render(cur);\n    }\n  }\n\n  sc.addEventListener(\"scroll\", onScroll, { passive: true });\n  if (window.ResizeObserver) { ro = new ResizeObserver(onResize); ro.observe(sc); }\n  else window.addEventListener(\"resize\", onResize);\n  update(o);\n  return {\n    update: update,\n    destroy: function () {\n      sc.removeEventListener(\"scroll\", onScroll);\n      if (ro) ro.disconnect(); else window.removeEventListener(\"resize\", onResize);\n      if (raf) cancelAnimationFrame(raf);\n      raf = 0;\n      itemsEl.textContent = \"\";\n      tiles = []; geo = [];\n    }\n  };\n}"
  }
}