{
  "id": "folding-layout-3d",
  "kind": "element",
  "title": "Folding layout 3D",
  "summary": "A stack of panels hinged like a concertina that folds and unfolds in CSS 3D with scroll or a slider.",
  "url": "https://enrichr.dev/elements/folding-layout-3d.html",
  "section": "band",
  "techniques": [
    "3d-css",
    "scroll-driven"
  ],
  "stack": [
    "Vanilla JS",
    "CSS 3D"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "bold",
    "tactile",
    "playful"
  ],
  "intents": [
    "concertina fold animation",
    "accordion folding panels 3d",
    "paper fold scroll effect",
    "css 3d fold layout",
    "panels that fold on scroll"
  ],
  "status": "tested",
  "params": [
    {
      "key": "panels",
      "label": "Panels",
      "type": "range",
      "min": 2,
      "max": 8,
      "step": 1,
      "value": 4
    },
    {
      "key": "foldAngle",
      "label": "Fold angle (degrees)",
      "type": "range",
      "min": 20,
      "max": 85,
      "step": 5,
      "value": 70
    },
    {
      "key": "height",
      "label": "Flat height (px)",
      "type": "range",
      "min": 160,
      "max": 520,
      "step": 10,
      "value": 320
    },
    {
      "key": "word",
      "label": "Words across the panels",
      "type": "text",
      "value": "Fold out"
    },
    {
      "key": "manual",
      "label": "Fixed fold % (0 follows scroll)",
      "type": "range",
      "min": 0,
      "max": 100,
      "step": 5,
      "value": 0
    },
    {
      "key": "colorA",
      "label": "Panel colour",
      "type": "color",
      "value": "#005236"
    },
    {
      "key": "colorB",
      "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 \"Folding layout 3D\" element to this project.\n\nThis is the \"Folding layout 3D\" element from the Enrichr Library: A stack of panels hinged like a concertina that folds and unfolds in CSS 3D with scroll or a slider.\nPage: https://enrichr.dev/elements/folding-layout-3d.html\nMachine-readable spec: https://enrichr.dev/elements/folding-layout-3d.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/folding-layout-3d.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 \"Folding layout 3D\" 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 \"Folding layout 3D\" element from the Enrichr Library: A stack of panels hinged like a concertina that folds and unfolds in CSS 3D with scroll or a slider.\nPage: https://enrichr.dev/elements/folding-layout-3d.html\nMachine-readable spec: https://enrichr.dev/elements/folding-layout-3d.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 \"Folding layout 3D\" element to this codebase.\n\nThis is the \"Folding layout 3D\" element from the Enrichr Library: A stack of panels hinged like a concertina that folds and unfolds in CSS 3D with scroll or a slider.\nPage: https://enrichr.dev/elements/folding-layout-3d.html\nMachine-readable spec: https://enrichr.dev/elements/folding-layout-3d.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-folding-layout-3d.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Folding layout 3D 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 \"Folding layout 3D\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Folding layout 3D\" element from the Enrichr Library: A stack of panels hinged like a concertina that folds and unfolds in CSS 3D with scroll or a slider.\nPage: https://enrichr.dev/elements/folding-layout-3d.html\nMachine-readable spec: https://enrichr.dev/elements/folding-layout-3d.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- folding-layout-3d.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 \"./folding-layout-3d\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function FoldingLayout3d(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 \"Folding layout 3D\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Folding layout 3D\" element from the Enrichr Library: A stack of panels hinged like a concertina that folds and unfolds in CSS 3D with scroll or a slider.\nPage: https://enrichr.dev/elements/folding-layout-3d.html\nMachine-readable spec: https://enrichr.dev/elements/folding-layout-3d.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- folding-layout-3d.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/FoldingLayout3d.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./folding-layout-3d\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function FoldingLayout3d(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 \"Folding layout 3D\" element.\n\nThis is the \"Folding layout 3D\" element from the Enrichr Library: A stack of panels hinged like a concertina that folds and unfolds in CSS 3D with scroll or a slider.\nPage: https://enrichr.dev/elements/folding-layout-3d.html\nMachine-readable spec: https://enrichr.dev/elements/folding-layout-3d.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), folding-layout-3d.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 \"Folding layout 3D\" element. No packages, no server code.\n\nThis is the \"Folding layout 3D\" element from the Enrichr Library: A stack of panels hinged like a concertina that folds and unfolds in CSS 3D with scroll or a slider.\nPage: https://enrichr.dev/elements/folding-layout-3d.html\nMachine-readable spec: https://enrichr.dev/elements/folding-layout-3d.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 folding-layout-3d.js and then main.js), style.css (the CSS below), folding-layout-3d.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 \"Folding layout 3D\" 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 \"Folding layout 3D\" element from the Enrichr Library: A stack of panels hinged like a concertina that folds and unfolds in CSS 3D with scroll or a slider.\nPage: https://enrichr.dev/elements/folding-layout-3d.html\nMachine-readable spec: https://enrichr.dev/elements/folding-layout-3d.json\n\nWhat it does: Each panel is nested inside the one above it, positioned at the top of the parent's bottom edge, with its transform origin on that edge. That makes every bottom edge a hinge. Rotating the first panel by the fold angle and each child by double the angle in alternating directions gives a zigzag, so the whole chain folds like a concertina. Every panel shows a slice of one shared picture, so the art stays continuous when flat. A shade layer darkens panels that face down and lightens those that face up, and the stack is nudged so it stays centred as it shortens. Scroll position sets the fold amount, flat in the middle of the screen and folded at the edges, and the slider overrides it until the page is scrolled again.\nAccessibility: The art is decorative, and the text is also present once as hidden text so it is read a single time. The slider is a native range input with a label and a spoken value, so it works with the keyboard and screen readers. With prefers-reduced-motion the stack stays flat and does not animate on scroll, while the slider still folds it on request.\n\nTunable settings:\n- Panels: range 2 to 8, step 1, default 4\n- Fold angle (degrees): range 20 to 85, step 5, default 70\n- Flat height (px): range 160 to 520, step 10, default 320\n- Words across the panels: text, default Fold out\n- Fixed fold % (0 follows scroll): range 0 to 100, step 5, default 0\n- Panel colour: color, default #005236\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/folding-layout-3d.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 \"Folding layout 3D\" 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 \"Folding layout 3D\" element from the Enrichr Library: A stack of panels hinged like a concertina that folds and unfolds in CSS 3D with scroll or a slider.\nPage: https://enrichr.dev/elements/folding-layout-3d.html\nMachine-readable spec: https://enrichr.dev/elements/folding-layout-3d.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 FoldingLayout3d.\n2. Paste the JavaScript below into a separate code file named folding-layout-3d.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 \"./folding-layout-3d\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function FoldingLayout3d(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(FoldingLayout3d, {\n  panels: { type: ControlType.Number, title: \"Panels\", min: 2, max: 8, step: 1, defaultValue: 4 },\n  foldAngle: { type: ControlType.Number, title: \"Fold angle\", min: 20, max: 85, step: 5, defaultValue: 70 },\n  height: { type: ControlType.Number, title: \"Flat height\", min: 160, max: 520, step: 10, defaultValue: 320 },\n  word: { type: ControlType.String, title: \"Words across the panels\", defaultValue: \"Fold out\" },\n  manual: { type: ControlType.Number, title: \"Fixed fold %\", min: 0, max: 100, step: 5, defaultValue: 0 },\n  colorA: { type: ControlType.Color, title: \"Panel colour\", defaultValue: \"#005236\" },\n  colorB: { 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 \"Folding layout 3D\" 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 \"Folding layout 3D\" element from the Enrichr Library: A stack of panels hinged like a concertina that folds and unfolds in CSS 3D with scroll or a slider.\nPage: https://enrichr.dev/elements/folding-layout-3d.html\nMachine-readable spec: https://enrichr.dev/elements/folding-layout-3d.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-folding-layout-3d\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-folding-layout-3d\"), { ...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 art is decorative, and the text is also present once as hidden text so it is read a single time. The slider is a native range input with a label and a spoken value, so it works with the keyboard and screen readers. With prefers-reduced-motion the stack stays flat and does not animate on scroll, while the slider still folds it on request.",
  "performance": "Only transform and opacity change, so the work stays on the compositor. Cost grows with panel count because each panel holds its own copy of the art, so keep it to about eight. One scroll read per frame while on screen, paused when off screen.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-fold\">\n  <div class=\"ef-fold__view\"><div class=\"ef-fold__stack\"></div></div>\n  <label class=\"ef-fold__ctl\"><span class=\"ef-fold__lab\">Fold</span><input class=\"ef-fold__rng\" type=\"range\" min=\"0\" max=\"100\" step=\"1\" value=\"0\" aria-label=\"Fold amount\"></label>\n</div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-fold { overflow: hidden; container-type: inline-size; width: 100%; padding: 1.2rem 1rem 1rem; box-sizing: border-box; font-family: \"Helvetica Neue\", Arial, \"Segoe UI\", system-ui, sans-serif; background: var(--ef-fold-bg, #0c1e18); color: #fbf8f1; }\n.ef-fold__view { position: relative; height: var(--ef-fh, 20rem); perspective: 1100px; perspective-origin: 50% 40%; }\n.ef-fold__stack { position: relative; width: 100%; height: var(--ef-ph, 5rem); transform-style: preserve-3d; will-change: transform; }\n.ef-fold__p { position: relative; width: 100%; height: var(--ef-ph, 5rem); transform-origin: 50% 0; transform-style: preserve-3d; will-change: transform; }\n.ef-fold__p > .ef-fold__p { position: absolute; left: 0; top: 100%; }\n.ef-fold__face { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; background: var(--ef-fold-a, #005236); }\n.ef-fold__art { position: absolute; left: 0; width: 100%; height: calc(var(--ef-ph, 5rem) * var(--ef-n, 4)); background: radial-gradient(circle at 78% 30%, var(--ef-fold-b, #e6ff55) 0 14%, transparent 14.5%), radial-gradient(circle at 20% 90%, rgba(255, 255, 255, 0.18) 0 28%, transparent 28.5%), linear-gradient(160deg, var(--ef-fold-a, #005236), #0c1e18 95%); }\n.ef-fold__word { position: absolute; left: 6%; bottom: 8%; right: 6%; font-size: clamp(2rem, 17cqw, 7rem); font-weight: 900; line-height: 0.9; letter-spacing: -0.04em; text-transform: uppercase; color: #fbf8f1; }\n.ef-fold__word em { font-style: normal; color: var(--ef-fold-b, #e6ff55); }\n.ef-fold__shade { position: absolute; inset: 0; pointer-events: none; background: #000; opacity: 0; }\n.ef-fold__p[data-up] .ef-fold__shade { background: #fff; }\n.ef-fold__ctl { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.9rem; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }\n.ef-fold__rng { flex: 1; min-width: 0; accent-color: var(--ef-fold-b, #e6ff55); height: 1.6rem; }\n.ef-fold__rng:focus-visible { outline: 2px solid var(--ef-fold-b, #e6ff55); outline-offset: 3px; }\n.ef-fold__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@media (prefers-reduced-motion: reduce) { .ef-fold__stack, .ef-fold__p { transition: none !important; } }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Folding layout 3D: a stack of panels hinged to each other like a concertina. Each panel is nested inside the one above\n// (transform-origin at the hinge), so rotateX on the whole chain folds the stack in CSS 3D. Fold amount follows scroll\n// (flat in the middle of the screen, folded as it enters and leaves) or the slider under the stack.\n// mount(root, { panels (2-8), foldAngle (max degrees per hinge), height (flat stack height px), word (text across the panels),\n//               manual (0 = follow scroll, 1-100 = fixed fold %), colorA, colorB })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var box = root.querySelector(\".ef-fold\");\n  var view = root.querySelector(\".ef-fold__view\");\n  var stack = root.querySelector(\".ef-fold__stack\");\n  var rng = root.querySelector(\".ef-fold__rng\");\n  var opts = {}, panels = [], raf = 0, visible = true, io = null;\n  var fold = 0, target = 0, lastP = -1, held = false, lastDrawn = -1;\n\n  function render() {\n    stack.textContent = \"\";\n    var n = Math.max(2, Math.min(8, Math.round(opts.panels)));\n    box.style.setProperty(\"--ef-n\", n);\n    box.style.setProperty(\"--ef-fh\", opts.height + \"px\");\n    box.style.setProperty(\"--ef-ph\", (opts.height / n).toFixed(2) + \"px\");\n    box.style.setProperty(\"--ef-fold-a\", opts.colorA);\n    box.style.setProperty(\"--ef-fold-b\", opts.colorB);\n    var parent = stack;\n    panels = [];\n    for (var i = 0; i < n; i++) {\n      var p = document.createElement(\"div\");\n      p.className = \"ef-fold__p\";\n      if (i % 2) p.setAttribute(\"data-up\", \"\");\n      var face = document.createElement(\"div\"); face.className = \"ef-fold__face\"; face.setAttribute(\"aria-hidden\", \"true\");\n      var art = document.createElement(\"div\"); art.className = \"ef-fold__art\"; art.style.top = \"calc(var(--ef-ph) * \" + (-i) + \")\";\n      var w = document.createElement(\"div\"); w.className = \"ef-fold__word\";\n      var words = String(opts.word).split(/\\s+/);\n      w.textContent = \"\";\n      words.forEach(function (t, k) {\n        if (k) w.appendChild(document.createElement(\"br\"));\n        var s = document.createElement(k === words.length - 1 && words.length > 1 ? \"em\" : \"span\"); s.textContent = t; w.appendChild(s);\n      });\n      art.appendChild(w);\n      var sh = document.createElement(\"div\"); sh.className = \"ef-fold__shade\";\n      face.appendChild(art); face.appendChild(sh); p.appendChild(face);\n      parent.appendChild(p);\n      panels.push({ el: p, shade: sh });\n      parent = p;\n    }\n    var sr = document.createElement(\"span\"); sr.className = \"ef-fold__sr\"; sr.textContent = opts.word;\n    stack.appendChild(sr);\n    lastDrawn = -1;\n    apply(fold);\n  }\n  function apply(f) {\n    if (Math.abs(f - lastDrawn) < 0.0005) return;\n    lastDrawn = f;\n    var n = panels.length, th = f * Math.min(85, opts.foldAngle) * Math.PI / 180, deg = th * 180 / Math.PI;\n    panels.forEach(function (p, i) {\n      var rel = i === 0 ? deg : (i % 2 ? -2 * deg : 2 * deg);\n      p.el.style.transform = \"rotateX(\" + rel.toFixed(2) + \"deg)\";\n      var s = Math.sin(th);\n      p.shade.style.opacity = (i % 2 ? 0.16 * s : 0.5 * s).toFixed(3);\n    });\n    var flat = opts.height, proj = flat * Math.cos(th);\n    stack.style.transform = \"translateY(\" + ((flat - proj) / 2).toFixed(1) + \"px)\";\n    rng.value = String(Math.round(f * 100));\n    rng.setAttribute(\"aria-valuetext\", Math.round(f * 100) + \"% folded\");\n  }\n  function scrollFold() {\n    if (opts.manual > 0) return opts.manual / 100;\n    var r = box.getBoundingClientRect(), vh = window.innerHeight || 800;\n    var c = (r.top + r.height / 2) / vh;\n    var d = Math.abs(c - 0.5) - 0.1;\n    var t = Math.min(1, Math.max(0, d / 0.42));\n    return t * t * (3 - 2 * t);\n  }\n  function tick() {\n    raf = requestAnimationFrame(tick);\n    if (!visible) return;\n    var s = window.scrollY;\n    if (Math.abs(s - lastP) > 0.5) { if (lastP >= 0) held = false; lastP = s; }\n    if (!held && !reduce) target = scrollFold();\n    fold += (target - fold) * (reduce ? 1 : 0.14);\n    if (Math.abs(target - fold) < 0.001) fold = target;\n    apply(fold);\n  }\n  function onInput() { held = true; target = Number(rng.value) / 100; fold = target; apply(fold); }\n  function update(next) {\n    opts = Object.assign({ panels: 4, foldAngle: 70, height: 320, word: \"Fold out\", manual: 0, colorA: \"#005236\", colorB: \"#e6ff55\" }, opts, next || {});\n    [\"panels\", \"foldAngle\", \"height\", \"manual\"].forEach(function (k) { opts[k] = Number(opts[k]); });\n    held = false;\n    target = reduce ? (opts.manual > 0 ? opts.manual / 100 : 0) : scrollFold();\n    fold = target;\n    render();\n  }\n  rng.addEventListener(\"input\", onInput);\n  update(o);\n  if (!reduce && \"IntersectionObserver\" in window) { io = new IntersectionObserver(function (e) { visible = e[0].isIntersecting; }); io.observe(box); }\n  raf = requestAnimationFrame(tick);\n  return { update: update, destroy: function () { cancelAnimationFrame(raf); if (io) io.disconnect(); rng.removeEventListener(\"input\", onInput); } };\n}"
  }
}