{
  "id": "layered-parallax-scene",
  "kind": "element",
  "title": "Layered parallax scene",
  "summary": "A seeded landscape of hill ridges, a sun and a headline tucked behind the front hill, each moving at its own rate as you scroll.",
  "url": "https://enrichr.dev/elements/layered-parallax-scene.html",
  "section": "hero",
  "techniques": [
    "parallax",
    "scroll-driven"
  ],
  "stack": [
    "Vanilla JS",
    "CSS"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "cinematic",
    "calm"
  ],
  "intents": [
    "parallax landscape hero",
    "layered mountains scroll effect",
    "hills parallax on scroll",
    "depth layers hero section",
    "illustrated parallax scene without images"
  ],
  "status": "tested",
  "params": [
    {
      "key": "title",
      "label": "Headline",
      "type": "text",
      "value": "Other worlds"
    },
    {
      "key": "layers",
      "label": "Hill layers",
      "type": "range",
      "min": 3,
      "max": 5,
      "step": 1,
      "value": 4
    },
    {
      "key": "depth",
      "label": "Depth",
      "type": "range",
      "min": 0,
      "max": 100,
      "step": 5,
      "value": 60
    },
    {
      "key": "height",
      "label": "Height (px)",
      "type": "range",
      "min": 260,
      "max": 720,
      "step": 20,
      "value": 440
    },
    {
      "key": "seed",
      "label": "Landscape seed",
      "type": "range",
      "min": 1,
      "max": 30,
      "step": 1,
      "value": 7
    },
    {
      "key": "sky",
      "label": "Sky",
      "type": "color",
      "value": "#143b2b"
    },
    {
      "key": "sun",
      "label": "Sun",
      "type": "color",
      "value": "#e6ff55"
    },
    {
      "key": "haze",
      "label": "Far hills",
      "type": "color",
      "value": "#5f9a62"
    },
    {
      "key": "land",
      "label": "Near hills",
      "type": "color",
      "value": "#071e17"
    }
  ],
  "license": "Free to use in personal and client projects during the preview. Final licence terms will be published here before any paid tier starts; ask before reselling the code as a collection.",
  "contract": "function mount(root, opts) -> { update(partialOpts), destroy() }; root must contain the element markup",
  "exports": {
    "claude": "Add the \"Layered parallax scene\" element to this project.\n\nThis is the \"Layered parallax scene\" element from the Enrichr Library: A seeded landscape of hill ridges, a sun and a headline tucked behind the front hill, each moving at its own rate as you scroll.\nPage: https://enrichr.dev/elements/layered-parallax-scene.html\nMachine-readable spec: https://enrichr.dev/elements/layered-parallax-scene.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nSteps:\n1. Look at the project first to see its framework and where components, styles and static files live. Follow its conventions.\n2. Fetch https://enrichr.dev/elements/layered-parallax-scene.json if you can read URLs (fields: source.markup, source.css, source.js, params); otherwise use the source at the end of this message.\n3. Add the files, mount it where I tell you (default: the top of the home page), and pass the settings below as the opts.\n4. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n5. Run the dev server and check it. with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "chatgpt": "I want the \"Layered parallax scene\" element on my website. Below is its complete source. Please:\n1. Build one self-contained index.html that I can open locally to see it working (put the CSS in a <style> tag and the JavaScript in a <script> tag, with the markup in the body).\n2. Then explain, step by step, which parts go where in my own site, and how to mount it. My stack is: [tell me yours, or say \"plain HTML\"].\n3. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nThis is the \"Layered parallax scene\" element from the Enrichr Library: A seeded landscape of hill ridges, a sun and a headline tucked behind the front hill, each moving at its own rate as you scroll.\nPage: https://enrichr.dev/elements/layered-parallax-scene.html\nMachine-readable spec: https://enrichr.dev/elements/layered-parallax-scene.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.",
    "cursor": "Add the \"Layered parallax scene\" element to this codebase.\n\nThis is the \"Layered parallax scene\" element from the Enrichr Library: A seeded landscape of hill ridges, a sun and a headline tucked behind the front hill, each moving at its own rate as you scroll.\nPage: https://enrichr.dev/elements/layered-parallax-scene.html\nMachine-readable spec: https://enrichr.dev/elements/layered-parallax-scene.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nUse Composer / agent mode. First search the repo for how components, styles and scripts are organised, then add the files in the matching places, mount it on the page I name, and run the app to confirm it works. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.\n\nOptional: save this as .cursor/rules/enrichr-layered-parallax-scene.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Layered parallax scene element\nalwaysApply: false\n---\nmount(root, opts) expects the element markup inside root and returns { update, destroy }. Always call destroy() on unmount and never edit the ef- class names.",
    "v0": "Create a Next.js (App Router) client component for the \"Layered parallax scene\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Layered parallax scene\" element from the Enrichr Library: A seeded landscape of hill ridges, a sun and a headline tucked behind the front hill, each moving at its own rate as you scroll.\nPage: https://enrichr.dev/elements/layered-parallax-scene.html\nMachine-readable spec: https://enrichr.dev/elements/layered-parallax-scene.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles to create:\n- layered-parallax-scene.js : the JavaScript below, with one line appended at the end: export { mount };  (and the markup exported as: export const markup = \"<the markup string>\";). If the project uses TypeScript and does not allow JS imports, put // @ts-nocheck on the first line.\n- the CSS below goes in your global stylesheet (or a plain .css file imported once at the app root). The class names are global and start with ef-.\n\nUse this component as the wrapper (adjust the import paths):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./layered-parallax-scene\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function LayeredParallaxScene(props: Record<string, unknown>) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n```\n\nRender it on the home page so I can see it. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "lovable": "Add the \"Layered parallax scene\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Layered parallax scene\" element from the Enrichr Library: A seeded landscape of hill ridges, a sun and a headline tucked behind the front hill, each moving at its own rate as you scroll.\nPage: https://enrichr.dev/elements/layered-parallax-scene.html\nMachine-readable spec: https://enrichr.dev/elements/layered-parallax-scene.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles to create:\n- layered-parallax-scene.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/LayeredParallaxScene.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./layered-parallax-scene\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function LayeredParallaxScene(props: Record<string, unknown>) {\n  const ref = useRef<HTMLDivElement>(null);\n  const fx = useRef<{ update: (o: object) => void; destroy: () => void } | null>(null);\n  useEffect(() => {\n    const root = ref.current;\n    if (!root) return;\n    root.innerHTML = markup;\n    fx.current = mount(root, props);\n    return () => { fx.current?.destroy(); fx.current = null; root.innerHTML = \"\"; };\n  }, []);\n  useEffect(() => { fx.current?.update(props); }, [JSON.stringify(props)]);\n  return <div ref={ref} />;\n}\n```\n\nRemove the \"use client\" line if it is not needed. Show it on the home page. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "bolt": "Create a small Vite project (vanilla JavaScript, no framework unless I already have one) that shows the \"Layered parallax scene\" element.\n\nThis is the \"Layered parallax scene\" element from the Enrichr Library: A seeded landscape of hill ridges, a sun and a headline tucked behind the front hill, each moving at its own rate as you scroll.\nPage: https://enrichr.dev/elements/layered-parallax-scene.html\nMachine-readable spec: https://enrichr.dev/elements/layered-parallax-scene.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles: index.html (a container element, then a script tag), style.css (the CSS below), layered-parallax-scene.js (the JavaScript below) and main.js that sets the container's innerHTML to the markup and calls mount(container, opts) with the settings below. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}\n\nVerify: with reduced motion on, nothing moves; it works at 375px wide and with touch only; there are no console errors; scrolling stays smooth; destroy() is called when it unmounts.",
    "replit": "Create a new HTML, CSS and JavaScript Repl that shows the \"Layered parallax scene\" element. No packages, no server code.\n\nThis is the \"Layered parallax scene\" element from the Enrichr Library: A seeded landscape of hill ridges, a sun and a headline tucked behind the front hill, each moving at its own rate as you scroll.\nPage: https://enrichr.dev/elements/layered-parallax-scene.html\nMachine-readable spec: https://enrichr.dev/elements/layered-parallax-scene.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nFiles: index.html (a container element, link style.css, load layered-parallax-scene.js and then main.js), style.css (the CSS below), layered-parallax-scene.js (the JavaScript below), main.js (sets the container's innerHTML to the markup, then calls mount(container, opts) with the settings below). Press Run to preview. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "figma": "Designer handoff notes for the \"Layered parallax scene\" element (Enrichr Library). Figma cannot run this JavaScript inside a design file, so use it as a motion reference and hand the code to a developer.\n\nThis is the \"Layered parallax scene\" element from the Enrichr Library: A seeded landscape of hill ridges, a sun and a headline tucked behind the front hill, each moving at its own rate as you scroll.\nPage: https://enrichr.dev/elements/layered-parallax-scene.html\nMachine-readable spec: https://enrichr.dev/elements/layered-parallax-scene.json\n\nWhat it does: Each hill is an SVG path built from three sine waves whose phases come from a seeded random generator, so a seed always gives the same landscape. Layers are stacked from back to front and coloured from the far-hill colour to the near-hill colour for aerial perspective, and each extends below the scene. As the scene travels through the viewport, one frame per scroll works out its progress from 0 to 1 and moves every layer by its share of the depth: the nearest hills rise fastest, the headline, placed just behind the front hill, a little slower, and the sun sinks. Different speeds at different distances is what reads as depth.\nAccessibility: The headline is a real heading; the hills and sun are decorative and hidden from assistive technology. The default headline is a light colour on a dark sky for contrast. With prefers-reduced-motion everything stays still.\n\nTunable settings:\n- Headline: text, default Other worlds\n- Hill layers: range 3 to 5, step 1, default 4\n- Depth: range 0 to 100, step 5, default 60\n- Height (px): range 260 to 720, step 20, default 440\n- Landscape seed: range 1 to 30, step 1, default 7\n- Sky: color, default #143b2b\n- Sun: color, default #e6ff55\n- Far hills: color, default #5f9a62\n- Near hills: color, default #071e17\n\nCurrent settings:\n{{SETTINGS}}\n\nFor the developer: Element contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\nIn Figma:\n- Draw the resting state as a frame and the end state as a second frame; link them with Smart Animate to show the motion in a prototype.\n- Put the settings above in the frame's notes or Dev Mode annotations so the developer matches them.\n- Link https://enrichr.dev/elements/layered-parallax-scene.html in the handoff: the live demo and the copy-ready code are there. Developers can paste the prompts for Claude, Cursor or v0 from the Export menu.\nNothing is copied from another designer's file; this is original code from Enrichr.",
    "framer": "Add the \"Layered parallax scene\" element to Framer as a code component. Framer code components are React, so wrap the vanilla code like this. Check it in the Framer editor, as Framer's component API can change.\n\nThis is the \"Layered parallax scene\" element from the Enrichr Library: A seeded landscape of hill ridges, a sun and a headline tucked behind the front hill, each moving at its own rate as you scroll.\nPage: https://enrichr.dev/elements/layered-parallax-scene.html\nMachine-readable spec: https://enrichr.dev/elements/layered-parallax-scene.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 LayeredParallaxScene.\n2. Paste the JavaScript below into a separate code file named layered-parallax-scene.js in the same project, with  export { mount };  and  export const markup = \"<the markup string>\";  added. Put the CSS into the component as a <style> tag.\n3. Component:\n```tsx\nimport { addPropertyControls, ControlType } from \"framer\"\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./layered-parallax-scene\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function LayeredParallaxScene(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(LayeredParallaxScene, {\n  title: { type: ControlType.String, title: \"Headline\", defaultValue: \"Other worlds\" },\n  layers: { type: ControlType.Number, title: \"Hill layers\", min: 3, max: 5, step: 1, defaultValue: 4 },\n  depth: { type: ControlType.Number, title: \"Depth\", min: 0, max: 100, step: 5, defaultValue: 60 },\n  height: { type: ControlType.Number, title: \"Height\", min: 260, max: 720, step: 20, defaultValue: 440 },\n  seed: { type: ControlType.Number, title: \"Landscape seed\", min: 1, max: 30, step: 1, defaultValue: 7 },\n  sky: { type: ControlType.Color, title: \"Sky\", defaultValue: \"#143b2b\" },\n  sun: { type: ControlType.Color, title: \"Sun\", defaultValue: \"#e6ff55\" },\n  haze: { type: ControlType.Color, title: \"Far hills\", defaultValue: \"#5f9a62\" },\n  land: { type: ControlType.Color, title: \"Near hills\", defaultValue: \"#071e17\" },\n})\n```\n4. Keep the behaviour of the source unchanged. Do not add dependencies. Respect prefers-reduced-motion. Keep text as real HTML.\n\nSettings:\n{{SETTINGS}}\n\nSource:\n{{CODE}}",
    "webflow": "Add the \"Layered parallax scene\" element to a Webflow site with an Embed element. Test it on the published or preview site: scripts in embeds may not run inside the Designer canvas.\n\nThis is the \"Layered parallax scene\" element from the Enrichr Library: A seeded landscape of hill ridges, a sun and a headline tucked behind the front hill, each moving at its own rate as you scroll.\nPage: https://enrichr.dev/elements/layered-parallax-scene.html\nMachine-readable spec: https://enrichr.dev/elements/layered-parallax-scene.json\n\nElement contract (vanilla JavaScript, no dependencies):\n- The JavaScript defines a function mount(root, opts).\n- root is an empty container element. Set root.innerHTML to the markup first, then call mount(root, opts).\n- It returns an object with update(partialOpts) and destroy(). Call destroy() when the element is removed. Some elements also return replay().\n- The CSS classes all start with \"ef-\" so they will not collide with your styles.\n\n1. Add an Embed element where it should appear. Paste a <style> block with the CSS, one container <div id=\"enrichr-layered-parallax-scene\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-layered-parallax-scene\"), { ...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 a real heading; the hills and sun are decorative and hidden from assistive technology. The default headline is a light colour on a dark sky for contrast. With prefers-reduced-motion everything stays still.",
  "performance": "Scroll events only schedule a frame, and work stops off screen. Each frame reads one bounding box and writes a few transforms, composited without layout or paint. The ridges are drawn once.",
  "dependencies": [],
  "source": {
    "markup": "<div class=\"ef-lps\">\n  <div class=\"ef-lps__scene\">\n    <div class=\"ef-lps__sun\" aria-hidden=\"true\"></div>\n    <div class=\"ef-lps__layers\"></div>\n  </div>\n</div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-lps { --ef-lps-sky: #143b2b; --ef-lps-sun: #e6ff55; --ef-lps-haze: #5f9a62; --ef-lps-land: #071e17; --ef-lps-ink: #fbf8f1; width: 100%; font-family: \"Helvetica Neue\", Arial, \"Segoe UI\", system-ui, sans-serif; }\n.ef-lps__scene { position: relative; height: var(--ef-lps-h, 440px); overflow: hidden; border-radius: 1rem; background: linear-gradient(180deg, color-mix(in srgb, var(--ef-lps-sky) 80%, #000) 0%, var(--ef-lps-sky) 55%, color-mix(in srgb, var(--ef-lps-sky) 70%, var(--ef-lps-sun)) 100%); container-type: size; isolation: isolate; }\n.ef-lps__sun { position: absolute; left: 62%; top: 12%; width: clamp(4rem, 34cqh, 14rem); aspect-ratio: 1; border-radius: 50%; background: var(--ef-lps-sun); box-shadow: 0 0 6rem color-mix(in srgb, var(--ef-lps-sun) 35%, transparent); will-change: transform; }\n.ef-lps__layers { position: absolute; inset: 0; }\n.ef-lps__layer { position: absolute; left: -2%; right: -2%; bottom: -40%; will-change: transform; }\n.ef-lps__layer svg { display: block; width: 100%; height: 100%; }\n.ef-lps__title { position: absolute; left: 6%; top: 24%; margin: 0; max-width: 88%; font-size: clamp(2.6rem, min(15cqi, 30cqh), 10rem); font-weight: 900; line-height: 0.82; letter-spacing: -0.06em; text-transform: uppercase; color: var(--ef-lps-ink); will-change: transform; }\n@media (prefers-reduced-motion: reduce) { .ef-lps__sun, .ef-lps__layer, .ef-lps__title { transform: none !important; } }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Layered parallax scene: a landscape of hill ridges drawn as SVG paths from a seed, a sun and a headline tucked behind the\n// front hill. As the scene passes through the viewport each layer moves at its own rate (near hills rise fastest, the sun\n// sinks), which reads as depth. Scroll events from the page or any scrolling parent schedule one frame; nothing runs while\n// the page is still. Layers extend below the scene so moving them never shows a gap. No images are used.\n// mount(root, { title, layers (3-5), depth (0-100), height (px), seed (1-30), sky, sun, haze (far hills), land (near hills), ink })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var box = root.querySelector(\".ef-lps\");\n  var scene = root.querySelector(\".ef-lps__scene\");\n  var sun = root.querySelector(\".ef-lps__sun\");\n  var holder = root.querySelector(\".ef-lps__layers\");\n  var NS = \"http://www.w3.org/2000/svg\";\n  var opts = {}, parts = [], raf = 0, visible = true, io = null, last = -1;\n\n  function rng(seed) { var s = seed >>> 0 || 1; return function () { s = (s * 1664525 + 1013904223) >>> 0; return s / 4294967296; }; }\n  // A ridge is a sum of three sine waves with seeded phases, sampled into a path that is closed along the bottom.\n  function ridge(rand, rough) {\n    var w = [[1 + rand() * 1.5, rand() * 6.28, 1], [3 + rand() * 3, rand() * 6.28, 0.45], [9 + rand() * 6, rand() * 6.28, 0.12 * rough]];\n    var d = \"M0 1000L0 \";\n    for (var x = 0; x <= 1000; x += 20) {\n      var t = x / 1000, y = 0;\n      w.forEach(function (k) { y += Math.sin(t * k[0] * Math.PI + k[1]) * k[2]; });\n      d += (x ? \"L\" + x + \" \" : \"\") + (150 + y * 70).toFixed(1);\n    }\n    return d + \"L1000 1000Z\";\n  }\n  function build() {\n    holder.textContent = \"\";\n    parts = [];\n    var n = opts.layers, rand = rng(opts.seed * 7919);\n    var tops = { 3: [36, 52, 68], 4: [32, 45, 58, 71], 5: [30, 41, 52, 63, 74] }[n];\n    for (var i = 0; i < n; i++) {\n      var t = n === 1 ? 1 : i / (n - 1);\n      var layer = document.createElement(\"div\"); layer.className = \"ef-lps__layer\"; layer.setAttribute(\"aria-hidden\", \"true\");\n      layer.style.top = tops[i] + \"%\";\n      layer.style.zIndex = String(i + 1);\n      var svg = document.createElementNS(NS, \"svg\"); svg.setAttribute(\"viewBox\", \"0 0 1000 1000\"); svg.setAttribute(\"preserveAspectRatio\", \"none\"); svg.setAttribute(\"focusable\", \"false\");\n      var path = document.createElementNS(NS, \"path\"); path.setAttribute(\"d\", ridge(rand, 1 + t));\n      path.style.fill = \"color-mix(in srgb, var(--ef-lps-land) \" + Math.round(t * 100) + \"%, var(--ef-lps-haze))\";\n      svg.appendChild(path); layer.appendChild(svg);\n      holder.appendChild(layer);\n      parts.push({ el: layer, f: 0.25 + 0.75 * t });\n      if (i === n - 2) {\n        var h = document.createElement(\"h3\"); h.className = \"ef-lps__title\"; h.textContent = opts.title;\n        h.style.zIndex = String(i + 1);\n        holder.appendChild(h);\n        parts.push({ el: h, f: 0.15 + 0.75 * t });\n      }\n    }\n    parts.push({ el: sun, f: -0.6 });\n    last = -1;\n  }\n  function draw() {\n    raf = 0;\n    if (!visible || reduce) return;\n    var vh = window.innerHeight || document.documentElement.clientHeight || 800;\n    var r = scene.getBoundingClientRect();\n    var p = Math.min(1, Math.max(0, (vh - r.top) / (vh + r.height)));\n    if (Math.abs(p - last) < 0.0005) return;\n    last = p;\n    var range = r.height * opts.depth / 100 * 0.8;\n    parts.forEach(function (q) { q.el.style.transform = \"translate3d(0,\" + (-(p - 0.5) * range * q.f).toFixed(1) + \"px,0)\"; });\n  }\n  function kick() { if (!raf) raf = requestAnimationFrame(draw); }\n  function update(next) {\n    opts = Object.assign({ title: \"Other worlds\", layers: 4, depth: 60, height: 440, seed: 7, sky: \"#143b2b\", sun: \"#e6ff55\", haze: \"#5f9a62\", land: \"#071e17\", ink: \"#fbf8f1\" }, opts, next || {});\n    opts.layers = Math.min(5, Math.max(3, Math.round(Number(opts.layers) || 4)));\n    opts.depth = Math.min(100, Math.max(0, Number(opts.depth) || 0));\n    opts.seed = Math.max(1, Math.round(Number(opts.seed) || 1));\n    box.style.setProperty(\"--ef-lps-h\", Math.max(220, Number(opts.height) || 440) + \"px\");\n    [\"sky\", \"sun\", \"haze\", \"land\", \"ink\"].forEach(function (k) { box.style.setProperty(\"--ef-lps-\" + k, opts[k]); });\n    build();\n    kick();\n  }\n  update(o);\n  if (!reduce) {\n    window.addEventListener(\"scroll\", kick, { passive: true, capture: true });\n    window.addEventListener(\"resize\", kick);\n    if (\"IntersectionObserver\" in window) { io = new IntersectionObserver(function (e) { visible = e[0].isIntersecting; if (visible) kick(); }, { rootMargin: \"120px 0px\" }); io.observe(scene); }\n  }\n  return {\n    update: update,\n    destroy: function () {\n      if (raf) cancelAnimationFrame(raf); raf = 0;\n      if (io) io.disconnect();\n      window.removeEventListener(\"scroll\", kick, { capture: true });\n      window.removeEventListener(\"resize\", kick);\n    }\n  };\n}"
  }
}