{
  "id": "lightning-bolts",
  "kind": "element",
  "title": "Lightning bolts",
  "summary": "Branching lightning bolts drawn by midpoint displacement strike from the top towards the pointer on click or on a timer, with a calm mode and a restrained flash.",
  "url": "https://enrichr.dev/elements/lightning-bolts.html",
  "section": "background",
  "techniques": [
    "pointer-interaction"
  ],
  "stack": [
    "Vanilla JS",
    "Canvas 2D",
    "CSS"
  ],
  "frameworks": [
    "React",
    "Next.js",
    "Vanilla"
  ],
  "mood": [
    "cinematic",
    "immersive",
    "calm"
  ],
  "intents": [
    "lightning strike canvas",
    "procedural lightning background",
    "click to strike lightning",
    "branching electric bolts",
    "storm effect hero"
  ],
  "status": "tested",
  "params": [
    {
      "key": "accent",
      "label": "Glow colour",
      "type": "color",
      "value": "#e6ff55"
    },
    {
      "key": "background",
      "label": "Background",
      "type": "color",
      "value": "#0c1e18"
    },
    {
      "key": "mode",
      "label": "Mode",
      "type": "select",
      "options": [
        "calm",
        "lively"
      ],
      "value": "calm"
    },
    {
      "key": "interval",
      "label": "Auto strike every (s)",
      "type": "range",
      "min": 1.2,
      "max": 8,
      "step": 0.1,
      "value": 2.5
    },
    {
      "key": "branches",
      "label": "Branches",
      "type": "range",
      "min": 0,
      "max": 6,
      "step": 1,
      "value": 3
    }
  ],
  "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 \"Lightning bolts\" element to this project.\n\nThis is the \"Lightning bolts\" element from the Enrichr Library: Branching lightning bolts drawn by midpoint displacement strike from the top towards the pointer on click or on a timer, with a calm mode and a restrained flash.\nPage: https://enrichr.dev/elements/lightning-bolts.html\nMachine-readable spec: https://enrichr.dev/elements/lightning-bolts.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/lightning-bolts.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 \"Lightning bolts\" 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 \"Lightning bolts\" element from the Enrichr Library: Branching lightning bolts drawn by midpoint displacement strike from the top towards the pointer on click or on a timer, with a calm mode and a restrained flash.\nPage: https://enrichr.dev/elements/lightning-bolts.html\nMachine-readable spec: https://enrichr.dev/elements/lightning-bolts.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 \"Lightning bolts\" element to this codebase.\n\nThis is the \"Lightning bolts\" element from the Enrichr Library: Branching lightning bolts drawn by midpoint displacement strike from the top towards the pointer on click or on a timer, with a calm mode and a restrained flash.\nPage: https://enrichr.dev/elements/lightning-bolts.html\nMachine-readable spec: https://enrichr.dev/elements/lightning-bolts.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-lightning-bolts.mdc so the rule stays with the project:\n---\ndescription: How to use the Enrichr Lightning bolts 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 \"Lightning bolts\" element. Tailwind is available but this component needs no utility classes.\n\nThis is the \"Lightning bolts\" element from the Enrichr Library: Branching lightning bolts drawn by midpoint displacement strike from the top towards the pointer on click or on a timer, with a calm mode and a restrained flash.\nPage: https://enrichr.dev/elements/lightning-bolts.html\nMachine-readable spec: https://enrichr.dev/elements/lightning-bolts.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- lightning-bolts.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 \"./lightning-bolts\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function LightningBolts(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 \"Lightning bolts\" element to this React + Vite + TypeScript + Tailwind project. Do not install any packages.\n\nThis is the \"Lightning bolts\" element from the Enrichr Library: Branching lightning bolts drawn by midpoint displacement strike from the top towards the pointer on click or on a timer, with a calm mode and a restrained flash.\nPage: https://enrichr.dev/elements/lightning-bolts.html\nMachine-readable spec: https://enrichr.dev/elements/lightning-bolts.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- lightning-bolts.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/LightningBolts.tsx):\n```tsx\n\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport { markup, mount } from \"./lightning-bolts\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function LightningBolts(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 \"Lightning bolts\" element.\n\nThis is the \"Lightning bolts\" element from the Enrichr Library: Branching lightning bolts drawn by midpoint displacement strike from the top towards the pointer on click or on a timer, with a calm mode and a restrained flash.\nPage: https://enrichr.dev/elements/lightning-bolts.html\nMachine-readable spec: https://enrichr.dev/elements/lightning-bolts.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), lightning-bolts.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 \"Lightning bolts\" element. No packages, no server code.\n\nThis is the \"Lightning bolts\" element from the Enrichr Library: Branching lightning bolts drawn by midpoint displacement strike from the top towards the pointer on click or on a timer, with a calm mode and a restrained flash.\nPage: https://enrichr.dev/elements/lightning-bolts.html\nMachine-readable spec: https://enrichr.dev/elements/lightning-bolts.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 lightning-bolts.js and then main.js), style.css (the CSS below), lightning-bolts.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 \"Lightning bolts\" 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 \"Lightning bolts\" element from the Enrichr Library: Branching lightning bolts drawn by midpoint displacement strike from the top towards the pointer on click or on a timer, with a calm mode and a restrained flash.\nPage: https://enrichr.dev/elements/lightning-bolts.html\nMachine-readable spec: https://enrichr.dev/elements/lightning-bolts.json\n\nWhat it does: A bolt starts as a straight line from just above the top edge to the target. Midpoint displacement then splits every segment in two and nudges the new midpoint sideways by a random amount that halves each pass, giving a jagged natural path. Side branches start from random points on the main path, head off at an angle and are built the same way with less detail. Each bolt is drawn twice, a wide soft glow in the accent colour using canvas shadow blur, then a thin cream core, and fades out with a fast rise and a power-curve decay plus a slow shimmer. Strikes come from a timer, aimed near the pointer, or from a click or tap at that point. This is an original build from the general idea, not a copy of any library.\nAccessibility: Designed for photosensitivity. Strikes are limited to one every 380 ms at most (under 3 a second), the flash is a faint accent wash at 10 percent opacity or less, and shimmer is a slow sine, not a strobe. Calm mode, the default, removes the flash and the shimmer and slows everything. With prefers-reduced-motion the loop stops and one still bolt is drawn; a click redraws a still bolt. The canvas is aria-hidden and decorative.\n\nTunable settings:\n- Glow colour: color, default #e6ff55\n- Background: color, default #0c1e18\n- Mode: select (a / i), default calm\n- Auto strike every (s): range 1.2 to 8, step 0.1, default 2.5\n- Branches: range 0 to 6, step 1, default 3\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/lightning-bolts.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 \"Lightning bolts\" 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 \"Lightning bolts\" element from the Enrichr Library: Branching lightning bolts drawn by midpoint displacement strike from the top towards the pointer on click or on a timer, with a calm mode and a restrained flash.\nPage: https://enrichr.dev/elements/lightning-bolts.html\nMachine-readable spec: https://enrichr.dev/elements/lightning-bolts.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 LightningBolts.\n2. Paste the JavaScript below into a separate code file named lightning-bolts.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 \"./lightning-bolts\"; // markup is the HTML string; mount is the JavaScript's mount function\n\nexport default function LightningBolts(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(LightningBolts, {\n  accent: { type: ControlType.Color, title: \"Glow colour\", defaultValue: \"#e6ff55\" },\n  background: { type: ControlType.Color, title: \"Background\", defaultValue: \"#0c1e18\" },\n  mode: { type: ControlType.Enum, title: \"Mode\", options: [\"c\",\"l\"], optionTitles: [\"a\",\"i\"], defaultValue: \"calm\" },\n  interval: { type: ControlType.Number, title: \"Auto strike every\", min: 1.2, max: 8, step: 0.1, defaultValue: 2.5 },\n  branches: { type: ControlType.Number, title: \"Branches\", min: 0, max: 6, step: 1, defaultValue: 3 },\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 \"Lightning bolts\" 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 \"Lightning bolts\" element from the Enrichr Library: Branching lightning bolts drawn by midpoint displacement strike from the top towards the pointer on click or on a timer, with a calm mode and a restrained flash.\nPage: https://enrichr.dev/elements/lightning-bolts.html\nMachine-readable spec: https://enrichr.dev/elements/lightning-bolts.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-lightning-bolts\"></div>, and a <script> block with the JavaScript followed by:\n   mount(document.getElementById(\"enrichr-lightning-bolts\"), { ...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": "Designed for photosensitivity. Strikes are limited to one every 380 ms at most (under 3 a second), the flash is a faint accent wash at 10 percent opacity or less, and shimmer is a slow sine, not a strobe. Calm mode, the default, removes the flash and the shimmer and slows everything. With prefers-reduced-motion the loop stops and one still bolt is drawn; a click redraws a still bolt. The canvas is aria-hidden and decorative.",
  "performance": "One canvas and one rAF loop that pauses off-screen. At most three bolts are alive at once, each a few hundred line segments; shadow blur is applied to the glow pass only. Device pixel ratio is capped at 2.",
  "dependencies": [],
  "codepen": "https://codepen.io/Enrichr-Dev/pen/xbqmJvX",
  "source": {
    "markup": "<div class=\"ef-lbt\">\n  <div class=\"ef-lbt__wrap\">\n    <canvas class=\"ef-lbt__cv\" aria-hidden=\"true\"></canvas>\n    <svg class=\"ef-lbt__piece ef-lbt__piece--a\" aria-hidden=\"true\" focusable=\"false\"><symbol id=\"ef-lbt-p4\" viewBox=\"1423.36 860.8 503.07 322.3\"><path fill=\"currentColor\" 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\"/></symbol><use href=\"#ef-lbt-p4\" width=\"100%\" height=\"100%\"/></svg>\n    <svg class=\"ef-lbt__piece ef-lbt__piece--b\" aria-hidden=\"true\" focusable=\"false\"><symbol id=\"ef-lbt-p8\" viewBox=\"1513.7 166.86 322.3 503.06\"><path fill=\"currentColor\" 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\"/></symbol><use href=\"#ef-lbt-p8\" width=\"100%\" height=\"100%\"/></svg>\n    <svg class=\"ef-lbt__piece ef-lbt__piece--c\" aria-hidden=\"true\" focusable=\"false\"><symbol id=\"ef-lbt-p1\" viewBox=\"1513.7 1453.9 322.3 322.3\"><path fill=\"currentColor\" 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\"/></symbol><use href=\"#ef-lbt-p1\" width=\"100%\" height=\"100%\"/></svg>\n  </div>\n</div>",
    "css": "/* Enrichr Library · https://enrichr.dev */\n.ef-lbt { width: 100%; }\n.ef-lbt__wrap { position: relative; box-sizing: border-box; width: 100%; min-height: 18rem; height: 100%; overflow: hidden; border-radius: 1rem; background: #0c1e18; touch-action: pan-y; }\n.ef-lbt__cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }\n.ef-lbt__piece { position: absolute; pointer-events: none; color: var(--ef-acc, #e6ff55); filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45)); animation: ef-lbt-float 7s ease-in-out infinite; }\n.ef-lbt__piece--a { width: 7.5rem; height: 4.8rem; top: 7%; right: 6%; transform: rotate(8deg); }\n.ef-lbt__piece--b { width: 3.6rem; height: 5.6rem; bottom: 8%; left: 6%; color: #c6f26b; opacity: 0.92; animation-delay: -2.4s; }\n.ef-lbt__piece--c { width: 3rem; height: 3rem; bottom: 14%; right: 22%; color: #fbf8f1; opacity: 0.85; animation-delay: -4.6s; }\n@keyframes ef-lbt-float { 0%, 100% { translate: 0 0; rotate: 0deg; } 50% { translate: 0 -10px; rotate: 5deg; } }\n@media (prefers-reduced-motion: reduce) { .ef-lbt__piece { animation: none; } }",
    "js": "// Enrichr Library · https://enrichr.dev\n// Lightning bolts: procedural bolts built by midpoint displacement with side branches, drawn as a soft glow plus a bright core.\n// Strikes fall from the top towards the pointer on click and on a timer. Photosensitivity: strikes are rate-limited to under 3 a second,\n// the flash is a faint wash, and \"calm\" mode removes the flash and flicker entirely. Reduced motion draws one still bolt.\n// mount(root, { background, accent, mode (\"calm\"|\"lively\"), interval (s), branches (0-6) })\nfunction mount(root, o) {\n  var reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n  var wrap = root.querySelector(\".ef-lbt__wrap\");\n  var cv = root.querySelector(\".ef-lbt__cv\");\n  var ctx = cv.getContext(\"2d\");\n  var opts = {}, offs = [], bolts = [];\n  var w = 0, h = 0, dpr = 1, px = 0, py = 0, hasPtr = false;\n  var raf = 0, vis = true, dead = false, nextAuto = 0, lastStrike = -1e9, flashAt = -1e9;\n  var MIN_GAP = 380; // ms between strikes: under 3 per second\n\n  function rnd(a, b) { return a + Math.random() * (b - a); }\n  function path(x1, y1, x2, y2, disp, iters) {\n    var pts = [[x1, y1], [x2, y2]];\n    for (var it = 0; it < iters; it++) {\n      var out = [pts[0]];\n      for (var i = 1; i < pts.length; i++) {\n        var a = pts[i - 1], b = pts[i];\n        var dx = b[0] - a[0], dy = b[1] - a[1], len = Math.sqrt(dx * dx + dy * dy) || 1;\n        var off = rnd(-1, 1) * disp;\n        out.push([(a[0] + b[0]) / 2 - dy / len * off, (a[1] + b[1]) / 2 + dx / len * off]);\n        out.push(b);\n      }\n      pts = out; disp *= 0.55;\n    }\n    return pts;\n  }\n  function makeBolt(tx, ty, auto) {\n    var sx = Math.max(10, Math.min(w - 10, tx + rnd(-0.22, 0.22) * w)), sy = -6;\n    var main = path(sx, sy, tx, ty, Math.hypot(tx - sx, ty - sy) * 0.22, 7);\n    var lines = [{ pts: main, wd: 2.2, al: 1 }];\n    var nb = Math.round(opts.branches);\n    for (var b = 0; b < nb; b++) {\n      var k = Math.floor(rnd(0.12, 0.85) * main.length), p = main[k];\n      var ang = Math.atan2(ty - sy, tx - sx) + rnd(0.35, 0.9) * (Math.random() < 0.5 ? -1 : 1);\n      var L = rnd(0.12, 0.3) * Math.hypot(tx - sx, ty - sy);\n      var ex = p[0] + Math.cos(ang) * L, ey = p[1] + Math.sin(ang) * L;\n      var br = path(p[0], p[1], ex, ey, L * 0.2, 5);\n      lines.push({ pts: br, wd: 1.2, al: 0.7 });\n      if (Math.random() < 0.4) {\n        var q = br[Math.floor(br.length * 0.5)], a2 = ang + rnd(-0.6, 0.6), L2 = L * 0.5;\n        lines.push({ pts: path(q[0], q[1], q[0] + Math.cos(a2) * L2, q[1] + Math.sin(a2) * L2, L2 * 0.2, 4), wd: 0.8, al: 0.45 });\n      }\n    }\n    return { lines: lines, t0: performance.now(), dur: opts.mode === \"calm\" ? 1300 : 800, seed: Math.random() * 6 };\n  }\n  function strike(tx, ty, now) {\n    if (now - lastStrike < MIN_GAP) return;\n    lastStrike = now; flashAt = now;\n    bolts.push(makeBolt(tx, ty, false));\n    if (bolts.length > 3) bolts.shift();\n    kick();\n  }\n  function stroke(b, env, calm) {\n    var i, j, L, p;\n    ctx.lineCap = \"round\"; ctx.lineJoin = \"round\";\n    for (i = 0; i < 2; i++) {\n      ctx.save();\n      if (i === 0) { ctx.shadowColor = opts.accent; ctx.shadowBlur = calm ? 14 : 22; ctx.strokeStyle = opts.accent; }\n      else ctx.strokeStyle = \"#fbf8f1\";\n      for (j = 0; j < b.lines.length; j++) {\n        L = b.lines[j]; p = L.pts;\n        ctx.globalAlpha = Math.min(1, env * L.al * (i === 0 ? (calm ? 0.45 : 0.6) : 1));\n        ctx.lineWidth = L.wd * (i === 0 ? 3.2 : 1) * (calm ? 0.85 : 1);\n        ctx.beginPath(); ctx.moveTo(p[0][0], p[0][1]);\n        for (var k = 1; k < p.length; k++) ctx.lineTo(p[k][0], p[k][1]);\n        ctx.stroke();\n      }\n      ctx.restore();\n    }\n  }\n  function draw(now) {\n    ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n    ctx.clearRect(0, 0, w, h);\n    var calm = opts.mode === \"calm\";\n    if (!calm) {\n      var f = Math.exp(-(now - flashAt) / 140) * 0.1;\n      if (f > 0.004) { ctx.globalAlpha = f; ctx.fillStyle = opts.accent; ctx.fillRect(0, 0, w, h); ctx.globalAlpha = 1; }\n    }\n    for (var i = bolts.length - 1; i >= 0; i--) {\n      var b = bolts[i], u = (now - b.t0) / b.dur;\n      if (u >= 1) { bolts.splice(i, 1); continue; }\n      var env = Math.min(1, u / 0.06) * Math.pow(1 - u, 1.6);\n      if (!calm) env *= 1 - 0.22 * (0.5 + 0.5 * Math.sin(u * 16 + b.seed)); // slow shimmer, never a strobe\n      stroke(b, env, calm);\n    }\n  }\n  function frame(now) {\n    raf = 0;\n    if (dead || !vis) return;\n    if (now >= nextAuto) {\n      var tx = hasPtr ? px : rnd(0.2, 0.8) * w, ty = hasPtr ? py : rnd(0.55, 0.95) * h;\n      strike(tx + rnd(-30, 30), ty, now);\n      var iv = Math.max(1.2, opts.interval) * (opts.mode === \"calm\" ? 1.7 : 1) * 1000;\n      nextAuto = now + iv * rnd(0.7, 1.3);\n    }\n    draw(now);\n    raf = requestAnimationFrame(frame);\n  }\n  function kick() { if (!reduce && !raf && vis && !dead) raf = requestAnimationFrame(frame); }\n  function still() {\n    bolts = [makeBolt(w * 0.58, h * 0.78, false)];\n    ctx.setTransform(dpr, 0, 0, dpr, 0, 0); ctx.clearRect(0, 0, w, h);\n    stroke(bolts[0], 0.8, true);\n  }\n  function build() {\n    var r = wrap.getBoundingClientRect();\n    w = Math.max(40, r.width); h = Math.max(40, r.height);\n    dpr = Math.min(2, window.devicePixelRatio || 1);\n    cv.width = Math.round(w * dpr); cv.height = Math.round(h * dpr);\n  }\n  function on(el, ev, fn) { el.addEventListener(ev, fn); offs.push(function () { el.removeEventListener(ev, fn); }); }\n  on(wrap, \"pointermove\", function (e) { var r = wrap.getBoundingClientRect(); px = e.clientX - r.left; py = e.clientY - r.top; hasPtr = true; });\n  on(wrap, \"pointerleave\", function () { hasPtr = false; });\n  on(wrap, \"pointerdown\", function (e) {\n    var r = wrap.getBoundingClientRect();\n    px = e.clientX - r.left; py = e.clientY - r.top;\n    if (reduce) { still(); return; }\n    strike(px, py, performance.now());\n  });\n  var ro = new ResizeObserver(function () { if (dead) return; build(); if (reduce) still(); });\n  ro.observe(wrap);\n  offs.push(function () { ro.disconnect(); });\n  var io = new IntersectionObserver(function (es) { vis = es[0].isIntersecting; if (vis) kick(); else if (raf) { cancelAnimationFrame(raf); raf = 0; } });\n  io.observe(wrap);\n  offs.push(function () { io.disconnect(); });\n\n  function update(next) {\n    opts = Object.assign({ background: \"#0c1e18\", accent: \"#e6ff55\", mode: \"calm\", interval: 2.5, branches: 3 }, opts, next || {});\n    wrap.style.background = \"radial-gradient(ellipse 80% 55% at 50% 0%, #005236 0%, transparent 70%), \" + opts.background;\n    wrap.style.setProperty(\"--ef-acc\", opts.accent);\n    if (!w) build();\n    if (reduce) still(); else { if (!nextAuto) nextAuto = performance.now() + 500; kick(); }\n  }\n  update(o);\n  function destroy() {\n    dead = true;\n    if (raf) cancelAnimationFrame(raf);\n    raf = 0; bolts = [];\n    offs.forEach(function (f) { f(); }); offs = [];\n  }\n  return { update: update, destroy: destroy };\n}"
  }
}