{
  "schemaVersion": 1,
  "count": 69,
  "byLayer": {
    "motion": 27,
    "3d": 13,
    "fun": 7,
    "mobile": 10,
    "glass": 3,
    "webgl": 9
  },
  "byNature": {
    "连续": 10,
    "节奏": 14,
    "方向": 11,
    "材质": 14,
    "权重": 9,
    "反馈": 11
  },
  "effects": [
    {
      "id": "accordion",
      "name": "平滑折叠展开",
      "name_en": "Smooth Grid Accordion",
      "layer": "motion",
      "nature": "连续",
      "platform": "both",
      "status": "shipped",
      "entry": "accordion(root, { single, collapsible }) / .mk-acc__panel",
      "source": "CSS Grid 0fr → 1fr 双向平滑折叠 + inert 键盘焦点隔离（全引擎一致，零 scrollHeight 测量）",
      "source_en": "CSS Grid 0fr -> 1fr bidirectional disclosure + inert focus isolation (all engines, zero scrollHeight)",
      "file": "effects/accordion.md",
      "summary": "用纯 CSS Grid 的 `grid-template-rows: 0fr → 1fr` 让手风琴、FAQ 和可折叠配置面板双向平滑伸缩，全程零 `scrollHeight` 测量、零 `max-height` 缓动失真，并在收起态自动用 `inert` 隔离键盘焦点。",
      "summary_en": "Zero-measurement bidirectional disclosure using CSS Grid 0fr -> 1fr tracks, subtle inner fade/translate, chevron rotation, and automatic inert focus isolation when collapsed.",
      "problem": "绝大多数前端折叠面板会掉进两个老坑：\n1. 用 `max-height: 0 → 999px`：展开前 200ms 正常，收起时前 70% 时间都在空等 `999px` 降到真实高度，手感像卡顿了一拍；\n2. 用 JS 测 `scrollHeight` 再写死 `height`：动态增删子内容或窗口缩放时立刻被裁切，且在 WebKit 里 `interpolate-size` 收起路径仍有硬切差异。\n\n`grid-template-rows: 0fr → 1fr` 在 Chrome、Safari、Firefox 全引擎天然支持双向过渡，且面板展开后依然是自适应高度。",
      "origin": "来自现代 Web 平台 CSS Grid 轨道动画最佳实践与 Radix Accordion / Apple 设置面板的焦点隔离语义：\n- 取：Grid 轨道 `0fr ↔ 1fr` 双向过渡 + 内部内容轻淡入上浮（避免收起像铡刀硬切文字）+ 箭头 `180°` 同步旋转 + 收起态 `inert`；\n- 丢：依赖 `max-height` 猜测上限、依赖 `scrollHeight` 强制同步布局、或仅在 Chromium 双向生效的 `::details-content` 试验路径。",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 轨道过渡时长 | `260ms` | 落在日常容器切换的 200–300ms 黄金区：比 160ms 从容，又不会在连续点开 3 条 FAQ 时显得拖沓 |\n| 缓动曲线 | `cubic-bezier(0.22, 1, 0.36, 1)` | 快起慢停，点击瞬间立刻响应展开，末段柔和停稳 |\n| 内容淡出 / 淡入时长 | 收起 `140ms` / 展开 `200ms` | 收起时内容先于容器完全闭合前淡走，避免文字被边框“轧断”；展开时略慢让位给空间撑开 |\n| 内容微位移 | `-4px → 0` | 仅 4px 的轻柔落位，提供方向线索而不让整段文字乱晃 |\n| 箭头旋转 | `180deg` / `220ms` | 与展开主节奏错开 40ms 略早到位，视觉重心收束利落 |",
      "implementation": "- 纯函数状态机：`nextAccordionState(openIds, targetId, { single, collapsible })`（支持单开、多开、禁止全关三种产品语义，可单测）；\n- 交互控制器：`accordion(root, opts)` 同步 `is-open`、`aria-expanded` 与 `panel.inert`；\n- CSS 原语：`.mk-acc__panel`（Grid 轨道）+ `.mk-acc__inner`（**必带 `min-height: 0; overflow: hidden`**）+ `.mk-acc__chev`。",
      "degradation": "**走 `motion` 档：减。** `prefers-reduced-motion: reduce` 下 `grid-template-rows`、内容透明度与箭头旋转时长全部压到 `1ms`，去掉 `-4px` 位移，保留完整的开关状态与 `inert` 无障碍行为。",
      "pitfalls": "1. **忘了给内层包裹块写 `min-height: 0`**：Grid 子项默认 `min-height: auto`，即使外层设了 `grid-template-rows: 0fr`，面板也会被内容撑死、完全合不上。\n2. **直接把 `padding` 写在 `.mk-acc__panel` 或 `.mk-acc__inner` 上**：`0fr` 时外层 padding 不会缩为 0，收起后仍会留下一条尴尬的空白缝。正确做法是把内边距写在 `.mk-acc__inner` 内部的子内容节点上。\n3. **收起态没加 `inert`**：面板高度为 0 但 DOM 仍在树里，键盘用户按 `Tab` 会掉进看不见的链接或输入框里迷路。",
      "ai_assets": {
        "prompt": "实现一个平滑折叠展开的手风琴/折叠面板组件，零动画库依赖，全浏览器双向丝滑且键盘无障碍。\n\n原理一句话：外层面板使用 CSS Grid 的 `grid-template-rows: 0fr -> 1fr` 驱动双向高度过渡，内层唯一子块设 `min-height: 0; overflow: hidden` 配合轻微透明度与 4px 位移，收起态通过 `inert` 隔离键盘焦点。\n\n做法：\n1. 纯函数状态机 `nextAccordionState(openIds, targetId, { single = true, collapsible = true })`：\n   - 若 targetId 已展开：当 `collapsible` 为 false 且仅剩 1 项展开时保持不变，否则移除；\n   - 若 targetId 未展开：单开模式返回 `[targetId]`，多开模式追加到集合。\n2. DOM 与 CSS 结构（两层嵌套不可省）：\n   - 外层面板：`display: grid; grid-template-rows: 0fr; transition: grid-template-rows 260ms cubic-bezier(0.22, 1, 0.36, 1);`\n   - 展开态：`grid-template-rows: 1fr;`\n   - 内层直接子元素：`min-height: 0; overflow: hidden; opacity: 0; transform: translate3d(0, -4px, 0); transition: opacity 140ms cubic-bezier(0.22, 1, 0.36, 1), transform 220ms cubic-bezier(0.22, 1, 0.36, 1);`\n   - 展开态内层：`opacity: 1; transform: none; transition-duration: 200ms, 260ms;`\n   - 内边距 `padding` 写在更内侧的内容块上，绝不写在 `0fr` 外壳或内层裁剪容器上。\n   - 指示箭头：`transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1)`，展开时 `rotate(180deg)`。\n3. 无障碍与键盘焦点：\n   - 触发按钮必须是原生 `<button type=\"button\">` 并维护 `aria-expanded=\"true|false\"` 与 `aria-controls`；\n   - 收起态面板必须设置 `inert`（以及 `aria-hidden=\"true\"`），展开时移除 `inert`。\n\n硬要求：\n- 严禁使用 `max-height: 0 -> 999px`（收起延迟失真）或 JS 测量 `scrollHeight` 动画 `height`。\n- 内层包裹节点必须同时写 `min-height: 0` 与 `overflow: hidden`。\n- `prefers-reduced-motion: reduce` 下所有过渡压到 `1ms` 且清除 `translate3d` 位移。\n\n验收：\n- 展开与收起双向均为实时跟手曲线，无收起前空等现象；\n- 展开后动态追加两行文字，面板自然撑高无裁切；\n- 收起态按 Tab 键不会聚焦到面板内部任何链接或按钮；\n- 连续快速点击触发按钮，动画可中途自然反向打断。",
        "dont_do": "- 别把 `padding` 直接写在 `grid-template-rows: 0fr` 的容器上，会导致收起后残留两条缝隙。\n- 别用 `display: none` 立即隐藏收起态，那会直接砍断收起过渡。\n- 别漏掉 `min-height: 0`，漏了在所有浏览器里都无法合拢到 0px。",
        "skill_rule": "# 平滑折叠展开 (accordion) · 跨平台动效规范\n性质：连续 ｜ 平台：both\n\n【核心原理】外层面板使用 CSS Grid 的 `grid-template-rows: 0fr -> 1fr` 驱动双向高度过渡，内层唯一子块设 `min-height: 0; overflow: hidden` 配合轻微透明度与 4px 位移，收起态通过 `inert` 隔离键盘焦点。\n\n【硬要求】\n- 严禁使用 `max-height: 0 -> 999px`（收起延迟失真）或 JS 测量 `scrollHeight` 动画 `height`。\n- 内层包裹节点必须同时写 `min-height: 0` 与 `overflow: hidden`。\n- `prefers-reduced-motion: reduce` 下所有过渡压到 `1ms` 且清除 `translate3d` 位移。\n\n【验收标准】\n- 展开与收起双向均为实时跟手曲线，无收起前空等现象；\n- 展开后动态追加两行文字，面板自然撑高无裁切；\n- 收起态按 Tab 键不会聚焦到面板内部任何链接或按钮；\n- 连续快速点击触发按钮，动画可中途自然反向打断。\n\n【禁止做法】\n- 别把 `padding` 直接写在 `grid-template-rows: 0fr` 的容器上，会导致收起后残留两条缝隙。\n- 别用 `display: none` 立即隐藏收起态，那会直接砍断收起过渡。\n- 别漏掉 `min-height: 0`，漏了在所有浏览器里都无法合拢到 0px。",
        "prompt_en": "Implement a smooth, zero-dependency bidirectional accordion / collapsible disclosure panel that works consistently across Chrome, Safari, and Firefox with proper keyboard focus isolation.\n\nCore Principle: Drive bidirectional height expansion purely with CSS Grid `grid-template-rows: 0fr -> 1fr`, pair it with a single inner wrapper carrying `min-height: 0; overflow: hidden` plus subtle opacity and 4px Y-translation, and apply `inert` to collapsed panels so keyboard focus never traps inside hidden controls.\n\nImplementation:\n1. Pure state machine `nextAccordionState(openIds, targetId, { single = true, collapsible = true })`:\n   - If `targetId` is already open: keep it unchanged when `collapsible === false` and it is the only open item; otherwise remove it.\n   - If `targetId` is closed: return `[targetId]` in single-open mode, or append it in multi-open mode.\n2. Two-layer DOM & CSS structure (both wrappers are mandatory):\n   - Outer panel: `display: grid; grid-template-rows: 0fr; transition: grid-template-rows 260ms cubic-bezier(0.22, 1, 0.36, 1);`\n   - Open state: `grid-template-rows: 1fr;`\n   - Direct inner child: `min-height: 0; overflow: hidden; opacity: 0; transform: translate3d(0, -4px, 0); transition: opacity 140ms cubic-bezier(0.22, 1, 0.36, 1), transform 220ms cubic-bezier(0.22, 1, 0.36, 1);`\n   - Open inner child: `opacity: 1; transform: none; transition-duration: 200ms, 260ms;` (fades out slightly faster on close so text does not look clipped).\n   - Place inner `padding` on a child *inside* the inner clipping wrapper, never on the `0fr` shell itself.\n   - Chevron indicator: `transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1)`, rotating `180deg` when open.\n3. Accessibility & keyboard focus:\n   - Triggers must be native `<button type=\"button\">` elements keeping `aria-expanded=\"true|false\"` and `aria-controls` synced.\n   - Collapsed panels must set `inert` and `aria-hidden=\"true\"`; remove `inert` when expanded.\n\nHard Constraints:\n- Never use `max-height: 0 -> 999px` (causes dead closing lag) or JS `scrollHeight` measurement to animate `height`.\n- The direct inner wrapper must specify both `min-height: 0` and `overflow: hidden`.\n- Under `prefers-reduced-motion: reduce`, compress all transitions to `1ms` and remove the `translate3d` offset.\n\nAcceptance Criteria:\n- Both opening and closing track immediately with zero dead delay and interrupt cleanly on rapid clicks.\n- Dynamically appending lines to an open panel grows naturally without clipping.\n- Pressing Tab when collapsed never focuses links or buttons hidden inside the closed panel.",
        "dont_do_en": "- Do NOT put `padding` directly on the `grid-template-rows: 0fr` container — collapsed items will leave awkward leftover padding gaps.\n- Do NOT toggle `display: none` immediately on close — it kills the closing transition.\n- Do NOT omit `min-height: 0` on the inner grid child — without it, CSS Grid's `auto` min-size refuses to collapse to 0px.",
        "skill_rule_en": "# Smooth Grid Accordion (accordion) · Cross-Platform Motion Spec\nNature: Continuity | Layer: motion | Platform: both\n\nCore Principle: Drive bidirectional height expansion purely with CSS Grid `grid-template-rows: 0fr -> 1fr`, pair it with a single inner wrapper carrying `min-height: 0; overflow: hidden` plus subtle opacity and 4px Y-translation, and apply `inert` to collapsed panels so keyboard focus never traps inside hidden controls.\n\nHard Constraints:\n- Never use `max-height: 0 -> 999px` (causes dead closing lag) or JS `scrollHeight` measurement to animate `height`.\n- The direct inner wrapper must specify both `min-height: 0` and `overflow: hidden`.\n- Under `prefers-reduced-motion: reduce`, compress all transitions to `1ms` and remove the `translate3d` offset.\n\nAcceptance Criteria:\n- Both opening and closing track immediately with zero dead delay and interrupt cleanly on rapid clicks.\n- Dynamically appending lines to an open panel grows naturally without clipping.\n- Pressing Tab when collapsed never focuses links or buttons hidden inside the closed panel.\n\nDo NOT Do:\n- Do NOT put `padding` directly on the `grid-template-rows: 0fr` container — collapsed items will leave awkward leftover padding gaps.\n- Do NOT toggle `display: none` immediately on close — it kills the closing transition.\n- Do NOT omit `min-height: 0` on the inner grid child — without it, CSS Grid's `auto` min-size refuses to collapse to 0px."
      }
    },
    {
      "id": "ai-stream",
      "name": "AI 流式输出柔显与智能锁底",
      "name_en": "AI Token Stream & Smart Auto-Scroll",
      "layer": "motion",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.aiStream(el, { threshold, onLockChange }) + .mk-stream",
      "source": "ChatGPT / Claude / Antigravity 对话流（Token 分块 220ms 柔显 + 用户上翻立即脱锁 + 回到底部自动重锁）",
      "source_en": "ChatGPT / Claude / Antigravity streaming conversations (220ms chunk reveal + 36px smart lock-to-bottom)",
      "file": "effects/ai-stream.md",
      "summary": "AI 流式输出的新增文本片段以 `220ms` 轻微去模糊淡入（告别硬蹦字），同时维护“智能锁底”状态：用户没动滚动条时自动跟随最新一行，用户一往上翻看历史记录立刻让出控制权，滚回距底 `36px` 内自动重新锁底。",
      "summary_en": "Soft 220ms blur-to-crisp reveal for incoming AI chunks without breaking text selection, paired with smart scroll-lock that yields the instant a user scrolls up and re-locks near the bottom.",
      "problem": "**市面上 80% 的自建 AI 聊天界面都会踩这两个最让用户抓狂的体验坑：① 流式回复期间每次新 Token 到达都强行 `scrollTop = scrollHeight`，用户想往上翻看前文时屏幕拼命跟手指抢滚动条；② Token 一坨坨硬刷出来像老式终端闪屏。** 一个纯函数 `isNearBottom` 管住锁底状态机 + 每个追加片段自带 220ms 柔显关键帧，一次性解决阅读舒适度与滚动尊重。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 纯函数 `isNearBottom(scrollTop, scrollHeight, clientHeight, 36)` 判断是否贴底，脱锁/重锁零歧义 | 每次 `append` 不分青红皂白强拉到底部和用户抢滚轮 |\n| 新增片段包成独立行内 `<span>` 自播 `220ms` `opacity 0→1 + blur(2px → 0)`，已渲染文字纹丝不动 | 每次来 Token 重写整段 `innerHTML` 导致整篇文章重绘、选中文字丢失 |\n| 暴露 `.isLocked()` 与 `onLockChange(locked)`，方便业务侧在脱锁时浮出“↓ 回到底部”小按钮 | 用户脱锁后不知道还有新内容在下面生成 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 贴底判定阈值 `threshold` | `36px`（约 1.5 行文字高度） | 触控板惯性滚到底部常差 2–12px 未严丝合缝贴齐，36px 容差让用户自然滑到底即可轻松重锁，往上轻滑两行又能灵敏脱锁 |\n| 片段柔显时长 | `220ms cubic-bezier(0.22, 1, 0.36, 1)` + `blur(2px → 0)` | 刚好抹平 30–80ms 不均匀网络流式抖动，看起来像墨水丝滑浮现，又不拖慢快速扫读 |\n| DOM 追加策略 | `appendChild(<span class=\"chunk\">)` 只增不改旧节点 | 绝不破坏用户正在拖选复制的历史文字，且零整段重排 |\n| 监听模式 | `{ passive: true }` | 滚动事件绝不阻塞主线程与手势惯性 |",
      "implementation": "```\nsrc/core/ui-motion.js:285   isNearBottom(top, height, view, th)   纯函数，贴底判定（可单测）\nsrc/core/ui-motion.js:292   aiStream(el, { threshold })           分块柔显 + 智能锁底状态机 + scrollToBottom()\nstyles/motion.css:1530      .mk-stream / .mk-stream__chunk        220ms 去模糊柔显与减弱动效降级\n```",
      "degradation": "**走 `motion` 层契约：关闭分块淡入与模糊动画，完整保留智能锁底与不抢滚动条行为。**\n\n`prefers-reduced-motion: reduce` 下新到达的 Token 直接清晰呈现（`animation: none`），智能锁底与脱锁机制照常工作。",
      "pitfalls": "**① 流式期间无条件 `el.scrollTop = el.scrollHeight`，和用户抢滚动条。**\n这是 AI 产品最致命的交互灾难；只要用户上翻离开底部超过 36px，必须立即停止自动滚底，直到用户手动滑回底部或点击“回到底部”。\n\n**② 每次收到新 Chunk 时用 `el.textContent += chunk` 覆写整块文本。**\n覆写整块文本不仅无法让最新片段单独柔显，还会瞬间清空用户的文本划词选区；必须以只增不改的方式追加轻量行内 `<span>`。\n\n**③ `threshold` 写成 `0`（严格相等 `scrollTop + clientHeight === scrollHeight`）。**\n高分屏小数像素或弹性回弹下经常差 `1px`，写 `0` 会导致用户明明滚到底了却死活重锁不上；必须留 `24–40px` 容差。\n\n---",
      "ai_assets": {
        "prompt": "实现零依赖的 AI 流式输出柔显与智能锁底（AI Token Stream & Smart Auto-Scroll）。\n\n原理一句话：新增文本以独立行内 <span> 只增不改地追加并自播 220ms 去模糊淡入动画；用纯函数 isNearBottom(threshold = 36px) 维护锁底状态，用户上翻立刻脱锁绝不抢滚轮，滚回底部自动重锁。\n\n做法：\n1. 纯函数 isNearBottom(scrollTop, scrollHeight, clientHeight, threshold = 36)：\n   - 若 scrollHeight <= clientHeight 返回 true；\n   - 返回 (scrollHeight - (scrollTop + clientHeight)) <= threshold。\n2. 片段柔显 CSS：\n   - 追加的每个行内片段 span：display: inline; animation: stream-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;\n   - 关键帧：from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; }。\n3. 智能锁底控制器：\n   - 内部状态 locked 默认 true；监听容器 scroll（passive: true），每次更新 next = isNearBottom(...)；若状态变化同步切换脱锁类并回调 onLockChange(locked)（供业务显隐「回到底部」按钮）。\n   - append(chunk)：创建行内 span 追加到容器末尾（绝不覆写旧内容、不破坏用户划词选区）；仅当 locked === true 时执行 el.scrollTop = el.scrollHeight。\n   - 暴露 scrollToBottom()（手动回底并重锁）、clear()（清空并重锁）、isLocked() 与 destroy()。\n4. 降级：\n   - prefers-reduced-motion: reduce 关闭片段淡入动画（animation: none），完整保留智能锁底逻辑。\n\n硬要求：\n- 严禁在用户向上滚动查看历史时强制把容器拉回底部。\n- 严禁每次来新 Token 覆写整段 innerHTML/textContent，必须只增追加保持已有文本与选区稳定。\n- 贴底阈值必须留足 24–40px 容差（推荐 36px），禁止写死 0px 相等判断。\n\n验收：\n- 连续流式输出时，新字如墨水柔和浮现，容器自动平滑跟随到底部，可随时选中复制上方已输出文字不被打断。\n- 输出中途向上滚动超过 36px，界面立刻停止抢滚轮并通知脱锁状态；滑回底部或点击「回到底部」后立即无缝恢复跟随。\n- 开启减弱动效后新字直接清晰出现无模糊闪烁；卸载后正确移除滚动监听。",
        "dont_do": "- 别在流式回调里无条件 `el.scrollTop = el.scrollHeight` —— 用户上翻看代码时被反复拽回底部会直接暴走。\n- 别用 `el.innerHTML += chunk` —— 不仅每帧重解析整段 DOM、闪瞎眼，还会让用户永远选不中文字复制。\n- 别把贴底判定写成 `scrollTop + clientHeight === scrollHeight` —— 差 0.5px 亚像素就会锁不上。",
        "skill_rule": "# AI 流式输出柔显与智能锁底 (ai-stream) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】新增文本以独立行内 <span> 只增不改地追加并自播 220ms 去模糊淡入动画；用纯函数 isNearBottom(threshold = 36px) 维护锁底状态，用户上翻立刻脱锁绝不抢滚轮，滚回底部自动重锁。\n\n【硬要求】\n- 严禁在用户向上滚动查看历史时强制把容器拉回底部。\n- 严禁每次来新 Token 覆写整段 innerHTML/textContent，必须只增追加保持已有文本与选区稳定。\n- 贴底阈值必须留足 24–40px 容差（推荐 36px），禁止写死 0px 相等判断。\n\n【验收标准】\n- 连续流式输出时，新字如墨水柔和浮现，容器自动平滑跟随到底部，可随时选中复制上方已输出文字不被打断。\n- 输出中途向上滚动超过 36px，界面立刻停止抢滚轮并通知脱锁状态；滑回底部或点击「回到底部」后立即无缝恢复跟随。\n- 开启减弱动效后新字直接清晰出现无模糊闪烁；卸载后正确移除滚动监听。\n\n【禁止做法】\n- 别在流式回调里无条件 `el.scrollTop = el.scrollHeight` —— 用户上翻看代码时被反复拽回底部会直接暴走。\n- 别用 `el.innerHTML += chunk` —— 不仅每帧重解析整段 DOM、闪瞎眼，还会让用户永远选不中文字复制。\n- 别把贴底判定写成 `scrollTop + clientHeight === scrollHeight` —— 差 0.5px 亚像素就会锁不上。",
        "prompt_en": "Implement a zero-dependency AI token streaming soft-reveal and smart bottom-lock auto-scroll (AI Token Stream & Smart Auto-Scroll).\n\nCore Principle: Append incoming text as independent inline <span> elements (append-only, never mutating existing content) that play a 220ms de-blur fade-in animation; maintain bottom-lock state via pure function isNearBottom(threshold = 36px) so scrolling up immediately unlocks without fighting the user's wheel, and scrolling back to the bottom automatically re-locks.\n\nImplementation:\n1. Pure function isNearBottom(scrollTop, scrollHeight, clientHeight, threshold = 36):\n   - Return true if scrollHeight <= clientHeight;\n   - Otherwise return (scrollHeight - (scrollTop + clientHeight)) <= threshold.\n2. Fragment soft-reveal CSS:\n   - Each appended inline fragment span: display: inline; animation: stream-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;\n   - Keyframes: from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; }.\n3. Smart bottom-lock controller:\n   - Internal state locked defaults to true; listen to container scroll (passive: true), computing next = isNearBottom(...) on each event; when state changes, toggle the unlocked class and invoke onLockChange(locked) (for the caller to show/hide a \"Scroll to bottom\" button).\n   - append(chunk): create an inline span and append it to the end of the container (never overwrite existing content or break user text selection); only execute el.scrollTop = el.scrollHeight when locked === true.\n   - Expose scrollToBottom() (manually scroll to bottom and re-lock), clear() (empty container and re-lock), isLocked(), and destroy().\n4. Reduced motion:\n   - Under prefers-reduced-motion: reduce, disable the fragment fade-in animation (animation: none) while fully preserving smart bottom-lock behavior.\n\nHard Constraints:\n- Never force-scroll the container back to the bottom while the user is scrolling up to inspect history.\n- Never overwrite the entire innerHTML / textContent on each new token; must be append-only to keep existing text and selection stable.\n- The near-bottom threshold must leave 24–40px of tolerance (36px recommended); never hardcode a 0px equality check.\n\nAcceptance Criteria:\n- During continuous streaming, new characters softly emerge like ink and the container smoothly follows to the bottom while users can select and copy earlier text uninterrupted.\n- Scrolling up more than 36px mid-stream immediately stops hijacking scroll and notifies the unlocked state; scrolling back to the bottom or clicking \"Scroll to bottom\" seamlessly resumes following.\n- With reduced motion enabled, new text appears crisp immediately without blur flicker; after teardown, the scroll listener is properly removed.",
        "dont_do_en": "- Do NOT unconditionally set `el.scrollTop = el.scrollHeight` inside the streaming callback — repeatedly yanking users back to the bottom while they scroll up to read code is infuriating.\n- Do NOT use `el.innerHTML += chunk` — it re-parses the entire DOM every frame, causes severe flicker, and prevents users from ever selecting text to copy.\n- Do NOT write the bottom-lock check as `scrollTop + clientHeight === scrollHeight` — even a 0.5px subpixel discrepancy will prevent locking.",
        "skill_rule_en": "# AI Token Stream & Smart Auto-Scroll (ai-stream) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: motion | Platform: both\n\nCore Principle: Append incoming text as independent inline <span> elements (append-only, never mutating existing content) that play a 220ms de-blur fade-in animation; maintain bottom-lock state via pure function isNearBottom(threshold = 36px) so scrolling up immediately unlocks without fighting the user's wheel, and scrolling back to the bottom automatically re-locks.\n\nHard Constraints:\n- Never force-scroll the container back to the bottom while the user is scrolling up to inspect history.\n- Never overwrite the entire innerHTML / textContent on each new token; must be append-only to keep existing text and selection stable.\n- The near-bottom threshold must leave 24–40px of tolerance (36px recommended); never hardcode a 0px equality check.\n\nAcceptance Criteria:\n- During continuous streaming, new characters softly emerge like ink and the container smoothly follows to the bottom while users can select and copy earlier text uninterrupted.\n- Scrolling up more than 36px mid-stream immediately stops hijacking scroll and notifies the unlocked state; scrolling back to the bottom or clicking \"Scroll to bottom\" seamlessly resumes following.\n- With reduced motion enabled, new text appears crisp immediately without blur flicker; after teardown, the scroll listener is properly removed.\n\nDo NOT Do:\n- Do NOT unconditionally set `el.scrollTop = el.scrollHeight` inside the streaming callback — repeatedly yanking users back to the bottom while they scroll up to read code is infuriating.\n- Do NOT use `el.innerHTML += chunk` — it re-parses the entire DOM every frame, causes severe flicker, and prevents users from ever selecting text to copy.\n- Do NOT write the bottom-lock check as `scrollTop + clientHeight === scrollHeight` — even a 0.5px subpixel discrepancy will prevent locking."
      }
    },
    {
      "id": "anchor-popover",
      "name": "原生锚点浮层",
      "name_en": "Anchored Popover & Viewport Flip",
      "layer": "motion",
      "nature": "方向",
      "platform": "both",
      "status": "shipped",
      "entry": "anchorPopover(trigger, popover, { placement, gap }) / placeAnchored()",
      "source": "CSS Anchor Positioning（position-area + flip-block）与纯函数视口翻转/触发对齐缩放降级",
      "source_en": "CSS Anchor Positioning (position-area + flip-block) + pure-function viewport flip & trigger-origin fallback",
      "file": "effects/anchor-popover.md",
      "summary": "让气泡面板、下拉菜单或操作浮层牢牢贴住触发按钮：优先走原生 CSS Anchor Positioning，并在不支持或受限于定位容器时自动切到纯函数视口翻转与触发器对齐的 `scale(0.95)` 弹出，零 Floating UI 运行时依赖。",
      "summary_en": "Zero-Floating-UI anchored popover using native CSS Anchor Positioning with pure-function viewport flip/clamp fallback and trigger-aligned scale(0.95) entrance.",
      "problem": "业务里几乎每个工具栏和表格行都有“点按钮弹一个小面板”的需求：\n- 自己写 `top: 100%; left: 0` 一到屏幕底部或右侧边缘立刻被裁切出界；\n- 引整套定位库（Floating UI / Popper）为了一个轻量气泡增加依赖体积；\n- 哪怕位置算对了，如果 `transform-origin` 没对齐触发按钮、或者从 `scale(0)` 弹出来，观感依然廉价僵硬。",
      "origin": "来自 W3C CSS Anchor Positioning 实测规范（Chrome / WebKit 双引擎验证）与 Emil Kowalski 的触发锚点缩放原则：\n- 取：原生 `position-area` + `position-try-fallbacks: flip-block` 零 JS 定位模型、纯函数视口自动翻转/夹取降级、`transform-origin` 动态对准触发器中心、`scale(0.95) -> 1` 克制弹出；\n- 丢：每帧无条件重排监听、把物理方位和逻辑 `span-*` 混写（静默失效）、从 `scale(0)` 暴弹。",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 间距 `gap` | `8px` | 既清晰断开按钮与浮层的视觉粘连，又保持一眼可辨的归属关系 |\n| 视口安全边距 `padding` | `8px` | 避免浮层紧贴屏幕边线产生压迫或被圆角屏幕裁掉 |\n| 初始缩放 | `scale(0.95)` | 严禁 `scale(0)`：从 0.95 结合 `opacity: 0` 轻抬，既有“从按钮里长出来”的方向感又克制稳重 |\n| 进出场时长 | `180ms`（位置/缩放）/ `140ms`（透明度） | 浮层属于高频工具操作，压在 200ms 内响应利落 |\n| `transform-origin` 水平钳制 | `8% .. 92%` | 即使浮层被视口夹住偏离按钮正中，缩放锚点仍精准指回触发按钮中心 |",
      "implementation": "- 纯函数定位器：`placeAnchored(anchorRect, popRect, viewport, { placement, gap, padding })` → 返回 `{ x, y, side, flipped, origin }`，覆盖底部溢出自动翻顶、左右边界夹取与触发器对齐原点；\n- 交互控制器：`anchorPopover(trigger, popover, opts)` 管理打开/关闭、点击外部收起、`Escape` 收起并把焦点还给触发按钮、`aria-expanded` 同步；\n- CSS 原语：`.mk-apop`（仅通过 `--mk-apop-x/y/origin` 与 `transform` 定位，不触碰动画期布局重排）。",
      "degradation": "**走 `motion` 档：减。** `prefers-reduced-motion: reduce` 下时长压到 `1ms`、取消 `scale(0.95)` 缩放形变，保留精确落点与开关显隐。",
      "pitfalls": "使用原生 CSS Anchor Positioning 时，双引擎实测踩过 **5 条反直觉陷阱**：\n1. **写了 `left: 0` 或 `top: 0` 会让那一轴的 `position-area` 静默失效**：`position-area` 只填充仍为 `auto` 的 inset 属性，必须留空或显式 `inset: auto`。\n2. **物理方向与逻辑 `span-*` 混写整条声明无效**：`bottom span-inline-start` 会直接算成 `none` 掉到 `(0, 0)`；必须全逻辑（`block-end span-inline-end`）或全物理（`bottom span-right`）。\n3. **`span-*` 表达的是“生长方向”而非“对齐边”**：`span-left` 表示右缘贴齐锚点右缘并向左生长（即右对齐）；`block-end inline-start` 是整块放到锚点左边**外面**，想要下方左对齐应写 `block-end span-inline-end`。\n4. **按 `Escape` 关掉浮层后忘了把焦点还给触发按钮**：键盘用户焦点会直接掉回 `document.body`。\n5. **从 `scale(0)` 或居中 `50% 50%` 弹出**：会彻底失去浮层与触发按钮的因果连接。",
      "ai_assets": {
        "prompt": "实现一个零定位库依赖的锚点浮层（Popover / 下拉面板），支持视口边缘自动翻转与触发对齐的克制弹出。\n\n原理一句话：支持原生 CSS Anchor Positioning 时优先用 `position-area` + `position-try-fallbacks: flip-block`；通用降级使用纯函数按锚点矩形、浮层尺寸与视口计算落点、自动上下翻转、水平安全夹取以及对齐触发器中心的 `transform-origin`，再以 `scale(0.95) -> 1` 弹出。\n\n做法：\n1. 纯函数 `placeAnchored(anchorRect, popRect, viewport, { placement = 'bottom-start', gap = 8, padding = 8 })`：\n   - 优先放在目标侧（`belowY = anchor.top + anchor.height + gap` 或 `aboveY = anchor.top - pop.height - gap`）；若目标侧溢出视口且对侧放得下，自动翻转 `side` 并标记 `flipped = true`；\n   - 水平坐标按 `start / center / end` 对齐后钳制在 `[padding, viewport.width - pop.width - padding]`；\n   - 计算 `originX = clamp(((anchorCenterX - x) / pop.width) * 100, 8, 92)`、`originY = side === 'top' ? 100 : 0`，输出 `origin = \"${originX}% ${originY}%\"`。\n2. 原生 CSS Anchor Positioning 路径（渐进增强）：\n   - 触发器写 `anchor-name: --trigger-a`；浮层写 `position-anchor: --trigger-a; inset: auto; position-area: block-end span-inline-end; position-try-fallbacks: flip-block, flip-inline;`\n   - 严禁在该浮层上写 `left: 0` / `top: 0`，严禁混写物理与逻辑词（如 `bottom span-inline-start`）。\n3. 克制进出场动画：\n   - 关闭态：`opacity: 0; pointer-events: none; transform-origin: var(--origin); transform: translate3d(var(--x), var(--y), 0) scale(0.95);`\n   - 打开态：`opacity: 1; pointer-events: auto; transform: translate3d(var(--x), var(--y), 0) scale(1);`\n   - 过渡：`opacity 140ms cubic-bezier(0.22, 1, 0.36, 1), transform 180ms cubic-bezier(0.22, 1, 0.36, 1)`。\n4. 交互与无障碍：\n   - 触发按钮同步 `aria-expanded=\"true|false\"`；\n   - 点击外部自动收起；按 `Escape` 收起并立即调用 `trigger.focus()` 归还焦点。\n\n硬要求：\n- 严禁从 `scale(0)` 弹出，严禁入场使用 `ease-in`。\n- 浮层在屏幕底边放不下时必须自动翻到触发器上方，且 `transform-origin` 随之切到 `100%`（底边）。\n- `prefers-reduced-motion: reduce` 下过渡压到 `1ms` 且取消缩放位移。\n\n验收：\n- 触发器贴近视口底边打开时，浮层自动翻到上方且不溢出视口；\n- 触发器贴近右边缘打开时，浮层自动向左夹回视口内，且缩放原点仍指向按钮中心；\n- 按 Escape 收起后，键盘焦点准确回到触发按钮上。",
        "dont_do": "- 别在原生 CSS Anchor 浮层上写 `left: 0; top: 0`——会静默废掉 `position-area`。\n- 别混写 `bottom span-inline-start`（物理 + 逻辑），浏览器会把整条声明判为 `none`。\n- 别为单个轻量气泡强行引入庞大的定位第三方库或每帧轮询 `getBoundingClientRect()`。",
        "skill_rule": "# 原生锚点浮层 (anchor-popover) · 跨平台动效规范\n性质：方向 ｜ 平台：both\n\n【核心原理】支持原生 CSS Anchor Positioning 时优先用 `position-area` + `position-try-fallbacks: flip-block`；通用降级使用纯函数按锚点矩形、浮层尺寸与视口计算落点、自动上下翻转、水平安全夹取以及对齐触发器中心的 `transform-origin`，再以 `scale(0.95) -> 1` 弹出。\n\n【硬要求】\n- 严禁从 `scale(0)` 弹出，严禁入场使用 `ease-in`。\n- 浮层在屏幕底边放不下时必须自动翻到触发器上方，且 `transform-origin` 随之切到 `100%`（底边）。\n- `prefers-reduced-motion: reduce` 下过渡压到 `1ms` 且取消缩放位移。\n\n【验收标准】\n- 触发器贴近视口底边打开时，浮层自动翻到上方且不溢出视口；\n- 触发器贴近右边缘打开时，浮层自动向左夹回视口内，且缩放原点仍指向按钮中心；\n- 按 Escape 收起后，键盘焦点准确回到触发按钮上。\n\n【禁止做法】\n- 别在原生 CSS Anchor 浮层上写 `left: 0; top: 0`——会静默废掉 `position-area`。\n- 别混写 `bottom span-inline-start`（物理 + 逻辑），浏览器会把整条声明判为 `none`。\n- 别为单个轻量气泡强行引入庞大的定位第三方库或每帧轮询 `getBoundingClientRect()`。",
        "prompt_en": "Implement a zero-dependency anchored popover / dropdown panel with automatic viewport edge flipping and trigger-aligned restrained scale entrance (no Floating UI runtime required).\n\nCore Principle: Use native CSS Anchor Positioning (`position-area` + `position-try-fallbacks: flip-block`) where supported, and fall back to a pure-function geometric solver that computes viewport-safe `(x, y)` coordinates, flips sides on vertical overflow, clamps horizontally, and sets `transform-origin` directly onto the trigger center so `scale(0.95) -> 1` blooms straight from the button.\n\nImplementation:\n1. Pure function `placeAnchored(anchorRect, popRect, viewport, { placement = 'bottom-start', gap = 8, padding = 8 })`:\n   - Try preferred side (`belowY = anchor.top + anchor.height + gap` or `aboveY = anchor.top - pop.height - gap`); flip `side` and set `flipped = true` if the preferred side overflows and the opposite side fits.\n   - Align horizontally (`start` / `center` / `end`) and clamp within `[padding, viewport.width - pop.width - padding]`.\n   - Compute `originX = clamp(((anchorCenterX - x) / pop.width) * 100, 8, 92)` and `originY = side === 'top' ? 100 : 0` to output `origin = \"${originX}% ${originY}%\"`.\n2. Native CSS Anchor Positioning path (progressive enhancement):\n   - Anchor sets `anchor-name: --trigger-a`; popover sets `position-anchor: --trigger-a; inset: auto; position-area: block-end span-inline-end; position-try-fallbacks: flip-block, flip-inline;`.\n   - Never set `left: 0` or `top: 0` on a `position-area` popover (silently breaks that axis), and never mix physical + logical tokens like `bottom span-inline-start` (evaluates to `none`).\n3. Restrained entrance/exit CSS:\n   - Closed: `opacity: 0; pointer-events: none; transform-origin: var(--origin); transform: translate3d(var(--x), var(--y), 0) scale(0.95);`\n   - Open: `opacity: 1; pointer-events: auto; transform: translate3d(var(--x), var(--y), 0) scale(1);`\n   - Transition: `opacity 140ms cubic-bezier(0.22, 1, 0.36, 1), transform 180ms cubic-bezier(0.22, 1, 0.36, 1)`.\n4. Interaction & accessibility:\n   - Sync `aria-expanded=\"true|false\"` on the trigger; close on outside click; close on `Escape` and immediately return focus to `trigger.focus()`.\n\nHard Constraints:\n- Never start popovers from `scale(0)` and never use `ease-in` for entrances.\n- Automatically flip above the trigger when overflowing the bottom edge, switching `transform-origin` Y to `100%`.\n- Under `prefers-reduced-motion: reduce`, compress transition duration to `1ms` and remove scale animation.\n\nAcceptance Criteria:\n- Triggering near the viewport bottom flips the popover above without clipping.\n- Triggering near the right edge clamps the popover cleanly inside the viewport while `transform-origin` still points at the trigger center.\n- Pressing Escape closes the popover and restores keyboard focus to the trigger button.",
        "dont_do_en": "- Do NOT set `left: 0; top: 0` on a native CSS Anchor `position-area` popover — it silently disables `position-area` along those axes.\n- Do NOT mix physical and logical keywords (e.g. `bottom span-inline-start`) — browsers invalidate the entire declaration to `none`.\n- Do NOT pull in a heavy positioning runtime or poll `getBoundingClientRect()` every animation frame for a lightweight popover.",
        "skill_rule_en": "# Anchored Popover & Viewport Flip (anchor-popover) · Cross-Platform Motion Spec\nNature: Direction | Layer: motion | Platform: both\n\nCore Principle: Use native CSS Anchor Positioning (`position-area` + `position-try-fallbacks: flip-block`) where supported, and fall back to a pure-function geometric solver that computes viewport-safe `(x, y)` coordinates, flips sides on vertical overflow, clamps horizontally, and sets `transform-origin` directly onto the trigger center so `scale(0.95) -> 1` blooms straight from the button.\n\nHard Constraints:\n- Never start popovers from `scale(0)` and never use `ease-in` for entrances.\n- Automatically flip above the trigger when overflowing the bottom edge, switching `transform-origin` Y to `100%`.\n- Under `prefers-reduced-motion: reduce`, compress transition duration to `1ms` and remove scale animation.\n\nAcceptance Criteria:\n- Triggering near the viewport bottom flips the popover above without clipping.\n- Triggering near the right edge clamps the popover cleanly inside the viewport while `transform-origin` still points at the trigger center.\n- Pressing Escape closes the popover and restores keyboard focus to the trigger button.\n\nDo NOT Do:\n- Do NOT set `left: 0; top: 0` on a native CSS Anchor `position-area` popover — it silently disables `position-area` along those axes.\n- Do NOT mix physical and logical keywords (e.g. `bottom span-inline-start`) — browsers invalidate the entire declaration to `none`.\n- Do NOT pull in a heavy positioning runtime or poll `getBoundingClientRect()` every animation frame for a lightweight popover."
      }
    },
    {
      "id": "bar-3d",
      "name": "3D 等轴立体数据柱图",
      "name_en": "3D Isometric Data Bars",
      "layer": "3d",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.bar3d(el, { values, max }) + .mk-bar3d",
      "source": "真三维等轴柱状图（前/右/顶三面 preserve-3d 拼合 + 320ms 封顶级联入场 + 单变量高度平滑更新）",
      "source_en": "True 3D isometric bar chart (3-face preserve-3d prism + single height variable)",
      "file": "effects/bar-3d.md",
      "summary": "每根数据柱用前、右、顶三个真实 `preserve-3d` 平面在等轴视角下拼成实心立方体，首屏按 320ms 封顶级联拔地而起，数据刷新时只需改一个高度变量即可原地平滑升降。",
      "summary_en": "True 3-face preserve-3d solid isometric bars with stepped lighting across top/front/side faces, 280ms-capped stagger entry, and zero-delay smooth height updates.",
      "problem": "**普通 2D 柱状图在总览大屏或展示卡片里缺乏质感，但用伪阴影贴图画“假立体柱子”一旦改变高度或更新数据就会露馅（顶面脱节、侧面渐变不随高变）。** 用 `transform-style: preserve-3d` 把顶面锚定在 `top: 0`、侧面锚定在 `right: 0`，高度变动时三个面自然作为一个刚体同步拉伸，永不裂开。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 等轴倾斜舞台（`rotateX(-24deg) rotateY(-28deg)`）+ 三面不同受光色阶（顶最亮、前次之、侧最暗） | 三面用同一种纯色导致糊成一团看不出立体棱线 |\n| 顶面 `transform-origin: top center` + 侧面 `right center`，三面共读同一个高度变量 | 用 JS 每帧分别算三个面的 `translateY` 与 `scaleY` |\n| 顶部数值标签反向旋转（`rotateY(28deg) rotateX(24deg)`）保持正面朝向读者，配 `tabular-nums` | 跟着柱子一起歪斜导致数字锯齿难读 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 等轴舞台视角 | `rotateX(-24deg) rotateY(-28deg)` | 同时露出正面、右侧面与顶面三个受光面，既立体又不让顶面遮住后排柱子 |\n| 柱体三面拼合 | 前 `translateZ(w/2)`、右 `translateZ(w/2) rotateY(90deg)`、顶 `translateZ(w/2) rotateX(90deg)` | 前面推前、右侧绕右边缘向后折 90°、顶面绕上边缘向后折 90°，严丝合缝闭合无白缝 |\n| 级联延迟上限 | `Math.min(280, i * 55)ms`（单柱时长 `560ms`） | 5–6 根柱子如波浪依次升起，数据多时总入场仍封顶不拖沓；后续 `update()` 延迟归 `0ms` 即时响应 |\n| 数值高度纯函数 | `Math.round(clamp(value / max, 0, 1) * maxPx)` | 防负值、溢出或 `max <= 0` 产出非法 `NaN` 高度把柱子撑爆容器 |",
      "implementation": "```\nsrc/core/scene3d.js:382   bar3dHeight(value, max, maxPx)   纯函数，安全归一化像素高度（可单测）\nsrc/core/scene3d.js:392   bar3d(el, { values, max, maxPx }) 生成三面立体柱并暴露 .update(nextVals)\nstyles/3d.css:558         .mk-bar3d / __col / __front / __side / __top / __val\n```",
      "degradation": "**走 `3d` 层专属契约：归零塌回清晰 2D 柱状图。**\n\n`prefers-reduced-motion: reduce` 下舞台 `transform: none`、隐藏侧面与顶面（`display: none`）、正面归平，过渡时长压至 `1ms` 且取消级联延迟，保留清晰准确的 2D 数值柱对比，不丢任何信息。",
      "pitfalls": "**① 侧面或顶面折叠方向写反，折到前面挡住正面或留下 1px 裂缝。**\n正面推出 `+w/2` 后，右侧面必须以 `transform-origin: right center` 先 `translateZ(w/2)` 再 `rotateY(90deg)` 往后折，顶面以 `transform-origin: top center` 先 `translateZ(w/2)` 再 `rotateX(90deg)` 往后折，三面才能共用前棱边严丝合缝。\n\n**② 数据二次更新 `update()` 时仍然带着首屏的 `i * 55ms` 级联延迟。**\n首屏入场需要节奏感，但用户点“切换月份 / 随机刷新”时如果还等 280ms 才开始动，会显得卡顿迟钝；二次更新必须将每根柱子的延迟清零为 `0ms`。\n\n**③ 忘了反向旋转数值标签或忘了 `font-variant-numeric: tabular-nums`。**\n标签不反向抵消舞台倾角会斜着糊掉；不加等宽数字会导致刷新数值时标签左右抖动。\n\n---",
      "ai_assets": {
        "prompt": "实现零图表库依赖的真 3D 等轴立体数据柱图（CSS Preserve-3D Isometric Bar Chart）。\n\n原理一句话：舞台设等轴视角 rotateX(-24deg) rotateY(-28deg)，每根柱子由前/右/顶三个 preserve-3d 平面以同一高度变量无缝拼合成刚体立方柱，首屏带 280ms 封顶级联升起，数据更新时清零延迟原地平滑升降。\n\n做法：\n1. 纯函数 bar3dHeight(value, max = 100, maxPx = 110)：\n   - 若 value / max 非有限数或 max <= 0 或 maxPx <= 0 返回 0；\n   - 否则钳制 ratio = clamp(value / max, 0, 1)，返回 Math.round(ratio * maxPx)。\n2. CSS 真 3D 三面刚体拼合（柱宽变量 --col-w: 22px，高度变量 --col-h）：\n   - 舞台容器：display: flex; align-items: flex-end; justify-content: center; gap: 16px; transform-style: preserve-3d; transform: rotateX(-24deg) rotateY(-28deg);\n   - 单根柱子：position: relative; width: var(--col-w); height: var(--col-h, 8px); transform-style: preserve-3d; transition: height 560ms cubic-bezier(0.22, 1, 0.36, 1); transition-delay: var(--col-d, 0ms);\n   - 正面（主亮渐变）：position: absolute; inset: 0; transform: translateZ(calc(var(--col-w) / 2));\n   - 右侧面（暗一级营造立体受光）：position: absolute; top: 0; bottom: 0; right: 0; width: var(--col-w); transform-origin: right center; transform: translateZ(calc(var(--col-w) / 2)) rotateY(90deg);\n   - 顶面（最亮高光面）：position: absolute; left: 0; right: 0; top: 0; height: var(--col-w); transform-origin: top center; transform: translateZ(calc(var(--col-w) / 2)) rotateX(90deg);\n   - 数值标签：position: absolute; left: 50%; top: -20px; transform: translateX(-50%) rotateY(28deg) rotateX(24deg); font-variant-numeric: tabular-nums;\n3. 节奏与更新控制：\n   - 首屏初始化将每根柱子延迟设为 Math.min(280, i * 55)ms，在下一 rAF 写入目标 --col-h 触发级联升起。\n   - 提供 update(nextValues, nextMax) 方法：将 --col-d 重置为 0ms 后直接更新 --col-h 与数值文字，实现无延迟原地升降。\n4. 降级：\n   - prefers-reduced-motion: reduce 下舞台 transform: none，隐藏右侧面与顶面，正面 transform: none，数值标签取消反旋，过渡压至 1ms / 0ms 延迟，完整呈现清晰 2D 柱图。\n\n硬要求：\n- 必须用顶/前/右三个明度递减的受光面建立立体感，禁止三面同色。\n- 数据二次更新必须清零级联延迟，且所有数值标签必须启用 tabular-nums 与反旋归正。\n- 严禁引入 ECharts / Three.js 等外部图表或 3D 库。\n\n验收：\n- 多根 3D 立方柱在等轴视角下三面无缝闭合，首屏如波浪依次升起，顶部数值清晰正对观众。\n- 调用 update() 切换数据后柱子立即原地平滑升降，三面不脱节、数值不左右晃动。\n- 开启减弱动效后退化为规整的 2D 柱状图，数据比例与数值完整可读。",
        "dont_do": "- 别把顶面、正面、右侧面涂成同一个纯色 —— 失去受光阶差后 3D 立体感会瞬间消失。\n- 别在二次更新数据时保留首屏的级联 `transition-delay` —— 用户点了数据刷新还要傻等几百毫秒。\n- 别在 `prefers-reduced-motion` 下把整个柱图藏掉 —— 只需拆平 3D 退回清晰 2D 柱图即可。",
        "skill_rule": "# 3D 等轴立体数据柱图 (bar-3d) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】舞台设等轴视角 rotateX(-24deg) rotateY(-28deg)，每根柱子由前/右/顶三个 preserve-3d 平面以同一高度变量无缝拼合成刚体立方柱，首屏带 280ms 封顶级联升起，数据更新时清零延迟原地平滑升降。\n\n【硬要求】\n- 必须用顶/前/右三个明度递减的受光面建立立体感，禁止三面同色。\n- 数据二次更新必须清零级联延迟，且所有数值标签必须启用 tabular-nums 与反旋归正。\n- 严禁引入 ECharts / Three.js 等外部图表或 3D 库。\n\n【验收标准】\n- 多根 3D 立方柱在等轴视角下三面无缝闭合，首屏如波浪依次升起，顶部数值清晰正对观众。\n- 调用 update() 切换数据后柱子立即原地平滑升降，三面不脱节、数值不左右晃动。\n- 开启减弱动效后退化为规整的 2D 柱状图，数据比例与数值完整可读。\n\n【禁止做法】\n- 别把顶面、正面、右侧面涂成同一个纯色 —— 失去受光阶差后 3D 立体感会瞬间消失。\n- 别在二次更新数据时保留首屏的级联 `transition-delay` —— 用户点了数据刷新还要傻等几百毫秒。\n- 别在 `prefers-reduced-motion` 下把整个柱图藏掉 —— 只需拆平 3D 退回清晰 2D 柱图即可。",
        "prompt_en": "Implement a zero-chart-library true 3D isometric data bar chart (CSS Preserve-3D Isometric Bar Chart).\n\nCore Principle: Set the stage to an isometric angle rotateX(-24deg) rotateY(-28deg), assemble each bar from three preserve-3d planes (front, right, top) sharing a single height variable into a rigid 3D column, raise bars on initial load with a staggered entrance capped at 280ms, and clear delays on data updates for immediate in-place transitions.\n\nImplementation:\n1. Pure function bar3dHeight(value, max = 100, maxPx = 110):\n   - Return 0 if value or max is non-finite, or max <= 0, or maxPx <= 0;\n   - Otherwise clamp ratio = clamp(value / max, 0, 1) and return Math.round(ratio * maxPx).\n2. True 3D three-face rigid assembly in CSS (width variable --col-w: 22px, height variable --col-h):\n   - Stage container: display: flex; align-items: flex-end; justify-content: center; gap: 16px; transform-style: preserve-3d; transform: rotateX(-24deg) rotateY(-28deg);\n   - Individual bar: position: relative; width: var(--col-w); height: var(--col-h, 8px); transform-style: preserve-3d; transition: height 560ms cubic-bezier(0.22, 1, 0.36, 1); transition-delay: var(--col-d, 0ms);\n   - Front face (primary bright gradient): position: absolute; inset: 0; transform: translateZ(calc(var(--col-w) / 2));\n   - Right face (one shade darker for 3D lighting): position: absolute; top: 0; bottom: 0; right: 0; width: var(--col-w); transform-origin: right center; transform: translateZ(calc(var(--col-w) / 2)) rotateY(90deg);\n   - Top face (brightest highlight): position: absolute; left: 0; right: 0; top: 0; height: var(--col-w); transform-origin: top center; transform: translateZ(calc(var(--col-w) / 2)) rotateX(90deg);\n   - Value label: position: absolute; left: 50%; top: -20px; transform: translateX(-50%) rotateY(28deg) rotateX(24deg); font-variant-numeric: tabular-nums;\n3. Pacing and update control:\n   - On initial mount, set each bar's delay to Math.min(280, i * 55)ms and write target --col-h on the next rAF to trigger the staggered rise.\n   - Expose update(nextValues, nextMax): reset --col-d to 0ms and immediately update --col-h and label text for zero-delay in-place height changes.\n4. Reduced motion:\n   - Under prefers-reduced-motion: reduce, set stage transform: none, hide right and top faces, set front face transform: none, remove counter-rotation on value labels, and compress transition to 1ms / 0ms delay to present a crisp 2D bar chart.\n\nHard Constraints:\n- Must establish 3D volume with three faces of descending brightness (top > front > right); painting all three faces the same color is forbidden.\n- Subsequent data updates must reset stagger delay to 0ms, and all value labels must use tabular-nums and counter-rotation to stay upright.\n- Never import external charting or 3D libraries such as ECharts or Three.js.\n\nAcceptance Criteria:\n- Multiple 3D cubic bars close seamlessly across all three faces under the isometric view, rise sequentially like a wave on initial load, and display crisp upright numeric labels at the top.\n- Calling update() immediately transitions bars smoothly in place without face separation or horizontal label jitter.\n- Enabling reduced motion degrades cleanly to a neat 2D bar chart with all proportions and values fully legible.",
        "dont_do_en": "- Do NOT paint the top, front, and right faces the exact same solid color — without tonal lighting steps, 3D depth vanishes instantly.\n- Do NOT keep the initial-load stagger `transition-delay` during subsequent data updates — users shouldn't wait hundreds of milliseconds after clicking refresh.\n- Do NOT hide the entire chart under `prefers-reduced-motion` — simply flatten the 3D geometry back into a clean 2D bar chart.",
        "skill_rule_en": "# 3D Isometric Data Bars (bar-3d) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: 3d | Platform: both\n\nCore Principle: Set the stage to an isometric angle rotateX(-24deg) rotateY(-28deg), assemble each bar from three preserve-3d planes (front, right, top) sharing a single height variable into a rigid 3D column, raise bars on initial load with a staggered entrance capped at 280ms, and clear delays on data updates for immediate in-place transitions.\n\nHard Constraints:\n- Must establish 3D volume with three faces of descending brightness (top > front > right); painting all three faces the same color is forbidden.\n- Subsequent data updates must reset stagger delay to 0ms, and all value labels must use tabular-nums and counter-rotation to stay upright.\n- Never import external charting or 3D libraries such as ECharts or Three.js.\n\nAcceptance Criteria:\n- Multiple 3D cubic bars close seamlessly across all three faces under the isometric view, rise sequentially like a wave on initial load, and display crisp upright numeric labels at the top.\n- Calling update() immediately transitions bars smoothly in place without face separation or horizontal label jitter.\n- Enabling reduced motion degrades cleanly to a neat 2D bar chart with all proportions and values fully legible.\n\nDo NOT Do:\n- Do NOT paint the top, front, and right faces the exact same solid color — without tonal lighting steps, 3D depth vanishes instantly.\n- Do NOT keep the initial-load stagger `transition-delay` during subsequent data updates — users shouldn't wait hundreds of milliseconds after clicking refresh.\n- Do NOT hide the entire chart under `prefers-reduced-motion` — simply flatten the 3D geometry back into a clean 2D bar chart."
      }
    },
    {
      "id": "bar-grow",
      "name": "条形数据生长",
      "name_en": "Data Bar Scale Growth",
      "layer": "motion",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-bar + .mk-bar / .mk-bar__fill / barRatio() / barStagger()",
      "source": "Stripe / Vercel Analytics 表格占比条与柱状图生长（scaleX 合成器 + 封顶级联）",
      "source_en": "Linear / Stripe analytics dashboards (compositor scaleX/scaleY + 320ms capped stagger)",
      "file": "effects/bar-grow.md",
      "summary": "表格占比条和柱状图进入视口时从起点按比例平滑生长，全程用 `scaleX`/`scaleY` 走合成器不触排，级联延迟严格封顶 320ms，数据刷新时原地伸缩不归零。",
      "summary_en": "Compositor-only scaleX/scaleY bar growth on viewport entry with 320ms capped stagger; live data updates morph in-place without resetting to zero.",
      "problem": "**数据表里的占比条瞬间拍在脸上缺少量级比较感，而动画 `width` 会把整张表拖进每帧重排。** 更糟的是如果给 30 行表格每行加 `40ms` 延迟，最后一行要等 1.2 秒才开始动——数据界面的第一优先级是扫读速度，动效绝不能拖慢人看数。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| Stripe / Linear 看板条形图入场时的轻快生长节奏与原地更新伸缩 | 图表库运行时与整段 SVG/Canvas 重绘 |\n| `scaleX(var(--p))` + `transform-origin: 0 50%` 全程合成器层运动 | 动画 `width` / `height` 触发每帧 Layout |\n| `barStagger` 320ms 封顶 + 入场后清零延迟 | 超过 10 行的无上限延迟级联 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 归一化比例 `p` | `clamp(value / max, 0, 1)` | 异常负值、超上限或 `max <= 0` 统一安全钳制，绝不撑破轨道 |\n| 生长时长 | `--mk-dur-5` = 560ms | 数据量级需要稍微多一点时间让眼睛比较长短，但超过 700ms 显得拖沓 |\n| 行级联步长 / 封顶 | `36ms` / `320ms` | 前 8–9 行形成利落斜波，第 10 行起全部封顶在 320ms 同步到达，不拖慢长表扫读 |\n| 入场后延迟归零 | `0ms` | 后续实时筛选或切换周期时，条形必须立刻原地伸缩，不能再等 stagger 延迟 |",
      "implementation": "```\nsrc/core/data.js:12   barRatio(value, max)          纯函数，归一化并钳制 0..1\nsrc/core/data.js:19   barStagger(index, step, cap)  纯函数，封顶级联延迟\nsrc/core/data.js:28   barGrow(el, opts)             只写 --mk-bar-p / --mk-bar-d，IO 触发 .is-in\nstyles/motion.css     .mk-bar / .mk-bar__fill / .mk-bar--vertical\n```",
      "degradation": "**走 `motion` 档：减，不关。**\n\n`prefers-reduced-motion: reduce` 下将 `transition-duration` 压到 `1ms`、`transition-delay` 清零，条形直接以精确比例呈现，数据可视化信息 100% 完整保留。",
      "pitfalls": "**① 直接动画 `width: 0% → 72%`。**\n表格里 20 行同时改 `width` 会连续触发 20 次重排；必须让填充层固定 `width: 100%`，通过 `transform: scaleX(var(--p))` 与 `transform-origin: 0 50%` 缩放。\n\n**② 数据刷新时先归零再重新长一遍。**\n筛选日期或实时更新数值时如果把 `.is-in` 摘掉重播，整张表会闪烁跳动；正确做法是只更新 `--p`，让条形从旧长度原地滑到新长度。\n\n**③ 忘了在入场后把 `transition-delay` 清零。**\n如果不清零，第 8 行在后续点击“切换周期”时每次都要慢 288ms 才动，看着像数据卡顿。\n\n**④ 圆角填充条在 `scaleX` 很小时显得被压扁。**\n给外层轨道 `.bar` 设 `overflow: hidden; border-radius: 999px` 负责裁切左右外圆角，比给内层做复杂 clip 更稳。\n\n---",
      "ai_assets": {
        "prompt": "实现零重排的表格条形 / 柱状图数据生长动效（零图表库依赖）。\n\n原理一句话：填充条固定 100% 宽度，用 transform: scaleX(var(--bar-p))（竖柱用 scaleY）在合成器层生长，入场级联严格封顶 320ms，数据更新时原地伸缩不归零。\n\n做法：\n1. 纯函数：\n   - barRatio(value, max = 100)：非有限数或 max <= 0 返回 0，否则 clamp(value / max, 0, 1)。\n   - barStagger(index, step = 36, cap = 320)：index <= 0 返回 0，否则 Math.min(cap, Math.round(index * step))。\n2. 结构与 CSS：\n   - 轨道 .bar：position: relative; overflow: hidden; border-radius: 999px; height: 8px;\n   - 填充 .bar-fill：display: block; width: 100%; height: 100%; transform-origin: 0 50%; transform: scaleX(0); transition: transform 560ms cubic-bezier(0.22, 1, 0.36, 1); transition-delay: var(--bar-d, 0ms);\n   - 激活态 .bar.is-in .bar-fill：transform: scaleX(var(--bar-p, 0));\n   - 竖向柱状图变体 .bar--vertical：transform-origin: 50% 100%，用 scaleY(0) → scaleY(var(--bar-p, 0))。\n3. 触发与更新：\n   - 挂载时写入 --bar-p 与 --bar-d，用 IntersectionObserver（once: true）在进入视口时加 .is-in。\n   - 入场完成后（约 stagger + 520ms）立刻将 --bar-d 置为 0ms。\n   - 后续数据更新时直接覆写 --bar-p（不移除 .is-in），让条形从旧比例原地平滑伸缩到新比例。\n\n硬要求：\n- 严禁动画 width 或 height —— 必须用 transform: scaleX / scaleY 走合成器。\n- 表格行级联延迟必须封顶 <= 320ms，且入场后清零延迟，避免二次更新拖沓。\n- 数值展示列必须配 font-variant-numeric: tabular-nums 防止数字与条形对齐抖动。\n- prefers-reduced-motion: reduce 下将过渡时长压到 1ms、延迟清零，直接显示最终比例。\n\n验收：\n- 20 行表格进入视口时前 9 行呈平滑斜波生长，第 10–20 行在 320ms 封顶同步到位，整表 0.9s 内全部静止。\n- 切换数据周期时，所有条形无延迟、不归零，原地平滑伸缩到新值。\n- 传入负数、NaN 或 max=0 时条形安全停在 0，不抛错不溢出。\n- 减弱动效模式下条形立即可见且比例准确。",
        "dont_do": "- 别动画 `width` 或 `flex-basis` —— 表格里几十行同时触发重排会直接掉帧。\n- 别给长表格每一行无限累加 stagger —— 第 30 行等 1.5 秒才长出来会毁掉后台可读性。\n- 别在数据更新时把条形重置为 0 再重新生长 —— 那是视觉噪音，原地差值过渡才传达“变化量”。",
        "skill_rule": "# 条形数据生长 (bar-grow) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】填充条固定 100% 宽度，用 transform: scaleX(var(--bar-p))（竖柱用 scaleY）在合成器层生长，入场级联严格封顶 320ms，数据更新时原地伸缩不归零。\n\n【硬要求】\n- 严禁动画 width 或 height —— 必须用 transform: scaleX / scaleY 走合成器。\n- 表格行级联延迟必须封顶 <= 320ms，且入场后清零延迟，避免二次更新拖沓。\n- 数值展示列必须配 font-variant-numeric: tabular-nums 防止数字与条形对齐抖动。\n- prefers-reduced-motion: reduce 下将过渡时长压到 1ms、延迟清零，直接显示最终比例。\n\n【验收标准】\n- 20 行表格进入视口时前 9 行呈平滑斜波生长，第 10–20 行在 320ms 封顶同步到位，整表 0.9s 内全部静止。\n- 切换数据周期时，所有条形无延迟、不归零，原地平滑伸缩到新值。\n- 传入负数、NaN 或 max=0 时条形安全停在 0，不抛错不溢出。\n- 减弱动效模式下条形立即可见且比例准确。\n\n【禁止做法】\n- 别动画 `width` 或 `flex-basis` —— 表格里几十行同时触发重排会直接掉帧。\n- 别给长表格每一行无限累加 stagger —— 第 30 行等 1.5 秒才长出来会毁掉后台可读性。\n- 别在数据更新时把条形重置为 0 再重新生长 —— 那是视觉噪音，原地差值过渡才传达“变化量”。",
        "prompt_en": "Implement a zero-reflow table bar / column chart data growth animation (zero charting library dependencies).\n\nCore Principle: Keep the fill bar at a fixed 100% width and grow it on the compositor layer using transform: scaleX(var(--bar-p)) (scaleY for vertical bars), strictly cap entrance stagger at 320ms, and transition in place on data updates without resetting to zero.\n\nImplementation:\n1. Pure functions:\n   - barRatio(value, max = 100): return 0 if value or max is non-finite or max <= 0, otherwise clamp(value / max, 0, 1).\n   - barStagger(index, step = 36, cap = 320): return 0 if index <= 0, otherwise Math.min(cap, Math.round(index * step)).\n2. Structure and CSS:\n   - Track .bar: position: relative; overflow: hidden; border-radius: 999px; height: 8px;\n   - Fill .bar-fill: display: block; width: 100%; height: 100%; transform-origin: 0 50%; transform: scaleX(0); transition: transform 560ms cubic-bezier(0.22, 1, 0.36, 1); transition-delay: var(--bar-d, 0ms);\n   - Active state .bar.is-in .bar-fill: transform: scaleX(var(--bar-p, 0));\n   - Vertical column variant .bar--vertical: transform-origin: 50% 100%, transitioning scaleY(0) -> scaleY(var(--bar-p, 0)).\n3. Triggering and updates:\n   - On mount, write --bar-p and --bar-d, and use IntersectionObserver (once: true) to add .is-in upon entering the viewport.\n   - Once entrance finishes (around stagger + 520ms), immediately reset --bar-d to 0ms.\n   - On subsequent data updates, overwrite --bar-p directly (without removing .is-in) so bars smoothly scale in place from the old ratio to the new ratio.\n\nHard Constraints:\n- Never animate width or height — must use transform: scaleX / scaleY on the compositor.\n- Table row stagger delay must be capped at <= 320ms and cleared after entrance to avoid sluggish subsequent updates.\n- Numeric value columns must set font-variant-numeric: tabular-nums to prevent number/bar alignment jitter.\n- Under prefers-reduced-motion: reduce, compress transition duration to 1ms, clear delay to 0ms, and display final ratios immediately.\n\nAcceptance Criteria:\n- When a 20-row table enters the viewport, rows 1–9 grow in a smooth diagonal wave while rows 10–20 finish together at the 320ms cap, with the entire table settled within 0.9s.\n- When switching data periods, all bars scale smoothly in place to new values with zero delay and without resetting to 0.\n- Passing negative numbers, NaN, or max = 0 safely clamps bars to 0 without throwing or overflowing.\n- Under reduced motion, bars appear immediately at accurate proportions.",
        "dont_do_en": "- Do NOT animate `width` or `flex-basis` — triggering layout reflow across dozens of table rows simultaneously will drop frames.\n- Do NOT accumulate stagger indefinitely across long tables — waiting 1.5s for row 30 to appear ruins dashboard readability.\n- Do NOT reset bars to 0 and regrow them on data updates — that creates visual noise; in-place delta transitions communicate the actual change.",
        "skill_rule_en": "# Data Bar Scale Growth (bar-grow) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: motion | Platform: both\n\nCore Principle: Keep the fill bar at a fixed 100% width and grow it on the compositor layer using transform: scaleX(var(--bar-p)) (scaleY for vertical bars), strictly cap entrance stagger at 320ms, and transition in place on data updates without resetting to zero.\n\nHard Constraints:\n- Never animate width or height — must use transform: scaleX / scaleY on the compositor.\n- Table row stagger delay must be capped at <= 320ms and cleared after entrance to avoid sluggish subsequent updates.\n- Numeric value columns must set font-variant-numeric: tabular-nums to prevent number/bar alignment jitter.\n- Under prefers-reduced-motion: reduce, compress transition duration to 1ms, clear delay to 0ms, and display final ratios immediately.\n\nAcceptance Criteria:\n- When a 20-row table enters the viewport, rows 1–9 grow in a smooth diagonal wave while rows 10–20 finish together at the 320ms cap, with the entire table settled within 0.9s.\n- When switching data periods, all bars scale smoothly in place to new values with zero delay and without resetting to 0.\n- Passing negative numbers, NaN, or max = 0 safely clamps bars to 0 without throwing or overflowing.\n- Under reduced motion, bars appear immediately at accurate proportions.\n\nDo NOT Do:\n- Do NOT animate `width` or `flex-basis` — triggering layout reflow across dozens of table rows simultaneously will drop frames.\n- Do NOT accumulate stagger indefinitely across long tables — waiting 1.5s for row 30 to appear ruins dashboard readability.\n- Do NOT reset bars to 0 and regrow them on data updates — that creates visual noise; in-place delta transitions communicate the actual change."
      }
    },
    {
      "id": "blob",
      "name": "液态有机变形体",
      "name_en": "Organic Morphing Blob",
      "layer": "fun",
      "nature": "材质",
      "platform": "both",
      "status": "shipped",
      "entry": ".mk-blob（纯 CSS 8 值 border-radius 呼吸插值）",
      "source": "有机流体形态（8 值斜杠圆角语法 a b c d / e f g h，纯 CSS 零 SVG 路径计算）",
      "source_en": "Pure CSS 8-radius organic droplet morphing (zero SVG, zero JS)",
      "file": "effects/blob.md",
      "summary": "纯 CSS 用 8 值 `border-radius`（四个角的横纵半径分别错开）配合 `8s ease-in-out` 往返插值，让一块色块或头像容器像水滴一样持续有机呼吸变形，零 SVG、零 JS。",
      "summary_en": "Pure CSS 8-value border-radius interpolation on an 8s breathing loop that turns any container or avatar into an organic liquid droplet — zero SVG, zero JS.",
      "problem": "**想给 AI 助手头像、品牌主视觉或加载态做一块有生命感的流体水滴，常见做法是引 SVG 贝塞尔路径变形库（GSAP MorphSVG / Flubber）——代码重且难调。** 浏览器原生支持的 8 值 `border-radius` 就能零依赖画出极其自然的有机水滴循环。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| CSS 8 值圆角 `x1 x2 x3 x4 / y1 y2 y3 y4` 错相插值 | 运行时逐帧重算 SVG `<path d=\"...\">` 字符串 |\n| `8s` 慢速往返呼吸（`alternate`），首尾连贯无跳帧 | 快速乱扭像果冻抽筋 |\n| 减弱动效下 `animation: none` 停在柔和有机静态轮廓 | 降级成生硬直角方块 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 圆角区间 | `32% ~ 68%` | 低于 25% 会露出尖角像多边形，高于 75% 几乎退化成正圆；32–68% 永远圆润有机 |\n| 互补配对 | 对角之和接近 `100%`（如 `62% 38%`） | 防止相邻两角半径之和超过 100% 触发浏览器强行压缩比例导致形变停顿 |\n| 呼吸周期 | `8s ease-in-out infinite alternate` | 像水面慢波一样柔和不抢正文注意力 |",
      "implementation": "```\nstyles/fun.css:231  .mk-blob / @keyframes mk-blob\n```",
      "degradation": "**走 `fun` 层专属契约：整层关掉（`animation: none`，停留在优雅静态有机形态）。**",
      "pitfalls": "**① 只写了 4 个值（`border-radius: 40% 60% 50% 50%`）。**\n4 值模式下每个角的横纵半径相等，变形像一个被捏的圆球，缺少流体拉扯感；必须用斜杠分隔的 8 值语法分别错开水平与垂直半径。\n\n**② 首帧 `0%` 和末帧 `100%` 值不一致又没加 `alternate`。**\n循环边界会瞬间“啪”地跳回原点；要么 `0%` 与 `100%` 写死同值，要么配合 `alternate` 往返平滑过渡。\n\n---",
      "ai_assets": {
        "prompt": "实现纯 CSS（零 JS / 零 SVG）的液态有机变形体（Organic Fluid Blob）。\n\n原理一句话：利用 CSS 原生 8 值 border-radius（四个角横纵半径独立取值在 32%–68% 之间互补配对），通过 8s ease-in-out 循环插值产生无缝流体呼吸变形。\n\n做法：\n1. 关键帧（0% 与 100% 相同保证无缝循环，每组横向与纵向相邻值之和贴近 100%）：\n   @keyframes blob-morph {\n     0%, 100% { border-radius: 62% 38% 54% 46% / 44% 58% 42% 56%; }\n     33%      { border-radius: 42% 58% 36% 64% / 58% 40% 60% 42%; }\n     66%      { border-radius: 54% 46% 66% 34% / 38% 62% 38% 62%; }\n   }\n2. 元素样式：\n   - .blob { animation: blob-morph 8s ease-in-out infinite; background: radial-gradient(circle at 30% 30%, #b8ff3d, #3b82f6); }\n3. 降级：\n   - @media (prefers-reduced-motion: reduce) { .blob { animation: none; border-radius: 58% 42% 54% 46% / 44% 56% 42% 58%; } }\n\n硬要求：\n- 必须使用 8 值斜杠语法 border-radius（x1 x2 x3 x4 / y1 y2 y3 y4），数值约束在 30%–70%。\n- 循环首尾必须连续无跳帧。\n- prefers-reduced-motion: reduce 下停止动画但保留静态有机轮廓。\n\n验收：\n- 元素像水滴一样平滑连续呼吸变形，无尖角、无循环边界跳帧。\n- 全程零 JS、零 SVG 路径重绘。\n- 开启减弱动效后停留在柔和静态水滴形状。",
        "dont_do": "- 别为了一个流体水滴引入 SVG Morph 动画库或 Canvas。\n- 别把周期设小于 3 秒 —— 变形太快会显得焦虑廉价。\n- 别只写 4 值 `border-radius` —— 缺少横向/纵向非对称张力就不像液体。",
        "skill_rule": "# 液态有机变形体 (blob) · 跨平台动效规范\n性质：材质 ｜ 平台：both\n\n【核心原理】利用 CSS 原生 8 值 border-radius（四个角横纵半径独立取值在 32%–68% 之间互补配对），通过 8s ease-in-out 循环插值产生无缝流体呼吸变形。\n\n【硬要求】\n- 必须使用 8 值斜杠语法 border-radius（x1 x2 x3 x4 / y1 y2 y3 y4），数值约束在 30%–70%。\n- 循环首尾必须连续无跳帧。\n- prefers-reduced-motion: reduce 下停止动画但保留静态有机轮廓。\n\n【验收标准】\n- 元素像水滴一样平滑连续呼吸变形，无尖角、无循环边界跳帧。\n- 全程零 JS、零 SVG 路径重绘。\n- 开启减弱动效后停留在柔和静态水滴形状。\n\n【禁止做法】\n- 别为了一个流体水滴引入 SVG Morph 动画库或 Canvas。\n- 别把周期设小于 3 秒 —— 变形太快会显得焦虑廉价。\n- 别只写 4 值 `border-radius` —— 缺少横向/纵向非对称张力就不像液体。",
        "prompt_en": "Implement a pure CSS (zero JS / zero SVG) organic fluid morphing blob (Organic Fluid Blob).\n\nCore Principle: Use native CSS 8-value border-radius (four corners with independent horizontal and vertical radii paired complementarily between 32%–68%) interpolated in an 8s ease-in-out infinite loop for seamless fluid breathing morphs.\n\nImplementation:\n1. Keyframes (0% and 100% identical for seamless looping; adjacent horizontal and vertical pairs sum close to 100%):\n   @keyframes blob-morph {\n     0%, 100% { border-radius: 62% 38% 54% 46% / 44% 58% 42% 56%; }\n     33%      { border-radius: 42% 58% 36% 64% / 58% 40% 60% 42%; }\n     66%      { border-radius: 54% 46% 66% 34% / 38% 62% 38% 62%; }\n   }\n2. Element styling:\n   - .blob { animation: blob-morph 8s ease-in-out infinite; background: radial-gradient(circle at 30% 30%, #b8ff3d, #3b82f6); }\n3. Reduced motion:\n   - @media (prefers-reduced-motion: reduce) { .blob { animation: none; border-radius: 58% 42% 54% 46% / 44% 56% 42% 58%; } }\n\nHard Constraints:\n- Must use 8-value slash syntax border-radius (x1 x2 x3 x4 / y1 y2 y3 y4) with values constrained between 30%–70%.\n- Loop start and end states must match continuously with zero frame jump.\n- Under prefers-reduced-motion: reduce, stop the animation while preserving a static organic silhouette.\n\nAcceptance Criteria:\n- The element breathes and morphs smoothly like a liquid droplet with no sharp corners and no loop-boundary frame jump.\n- Zero JS and zero SVG path redraws throughout.\n- With reduced motion enabled, it rests in a soft static droplet shape.",
        "dont_do_en": "- Do NOT pull in an SVG Morph animation library or Canvas just for a fluid droplet.\n- Do NOT set the cycle duration below 3 seconds — overly fast morphing looks anxious and cheap.\n- Do NOT use only 4-value `border-radius` — without asymmetric horizontal/vertical tension, it loses the liquid feel.",
        "skill_rule_en": "# Organic Morphing Blob (blob) · Cross-Platform Motion Spec\nNature: Material | Layer: fun | Platform: both\n\nCore Principle: Use native CSS 8-value border-radius (four corners with independent horizontal and vertical radii paired complementarily between 32%–68%) interpolated in an 8s ease-in-out infinite loop for seamless fluid breathing morphs.\n\nHard Constraints:\n- Must use 8-value slash syntax border-radius (x1 x2 x3 x4 / y1 y2 y3 y4) with values constrained between 30%–70%.\n- Loop start and end states must match continuously with zero frame jump.\n- Under prefers-reduced-motion: reduce, stop the animation while preserving a static organic silhouette.\n\nAcceptance Criteria:\n- The element breathes and morphs smoothly like a liquid droplet with no sharp corners and no loop-boundary frame jump.\n- Zero JS and zero SVG path redraws throughout.\n- With reduced motion enabled, it rests in a soft static droplet shape.\n\nDo NOT Do:\n- Do NOT pull in an SVG Morph animation library or Canvas just for a fluid droplet.\n- Do NOT set the cycle duration below 3 seconds — overly fast morphing looks anxious and cheap.\n- Do NOT use only 4-value `border-radius` — without asymmetric horizontal/vertical tension, it loses the liquid feel."
      }
    },
    {
      "id": "book-3d",
      "name": "3D 精装立书封面开合",
      "name_en": "3D Hardcover Book Showcase",
      "layer": "3d",
      "nature": "材质",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.book3d(el, { open }) + .mk-book-stage / .mk-book",
      "source": "真五面 preserve-3d 硬壳精装书（封面/书脊/封底/书口页纹/内页 + 悬停微启与点击 132° 展读）",
      "source_en": "5-face preserve-3d hardcover book (hover peek + click 132° hinge open)",
      "file": "effects/book-3d.md",
      "summary": "用前封面、立体书脊、封底、带纸页横纹的书口侧边与内页五层 `preserve-3d` 拼出一本厚实的 3D 硬壳精装书；悬停时封面微启 `24°` 露出一角内页，点击或按键盘即可绕左侧书脊平滑翻开 `132°` 展读。",
      "summary_en": "Five-face preserve-3d hardcover book with spine, striped page-edge, and inner spread: peeks open 24° on hover and swings open 132° around the left spine on click or keyboard.",
      "problem": "**电子书展示、设计系统手册、年度报告或付费专栏卡片只贴一张扁平长方形封面图显得单薄缺乏实物价值感；但渲染 3D 书本模型又太重。** 仅用 5 个 DOM 平面和 `transform-style: preserve-3d` 就能给出书脊厚度、书口纸张层纹与真实的铰链翻页手感，点击后原地展开内页简介。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 书脊厚 `22px`、书口重复渐变纸纹（`2px` 浅灰/白交替）、封面左边缘高光压槽 | 只有一张纸片前后翻转没有厚度 |\n| 两级交互反馈：桌面悬停微启 `-24°` 邀请点击，点击后整书右移回正并把封面翻开至 `-132°` | 悬停直接彻底翻开导致光标移走又啪地合上（鬼畜闪烁） |\n| 完整无障碍支持：`role=\"button\"`、`tabindex=\"0\"`、`aria-expanded` 与 Enter/Space 触发 | 只能鼠标点不能键盘操作 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 书体静置倾角 | `rotateY(-24deg) rotateX(8deg)` | 恰好同时露出正面封面、左侧立体书脊和一点顶部立体感，最有陈列柜质感 |\n| 悬停微启角 / 展读角 | `-24deg` / `-132deg`（由 `bookCoverAngle` 控角） | 微启够让人一眼看出“这书能翻开”；翻开 `132°` 而非 `180°` 保留立体书页弧度与纵深 |\n| 书脊厚度 `--book-t` | `22px`（前封面 `+11px`、封底 `-11px`） | 对 112×152px 精装书比例最协调，既有厚实精装感又不会显得像砖头 |\n| 展读整体补偿位移 | `translateX(24px) rotateY(-6deg)` | 封面往左翻开 132° 后重心左移，书体略向右移 24px 保持视觉居中不顶出容器左边界 |",
      "implementation": "```\nsrc/core/scene3d.js:500   bookCoverAngle(open, hover)   纯函数，返回封面目标角度 0 / -28 / -132（可单测）\nsrc/core/scene3d.js:509   book3d(el, { open, onChange }) 点击/键盘切换开合态并同步 aria-expanded\nstyles/3d.css:730         .mk-book-stage / .mk-book / __cover / __page / __back / __spine / __pages-edge\n```",
      "degradation": "**走 `3d` 层专属契约：拆平 3D 骨架，退回清晰的封面/内页 2D 切换卡。**\n\n`prefers-reduced-motion: reduce` 下取消透视与旋转，隐藏书脊、封底与书口侧边；点击后直接切换封面透明度以清晰展示内页文本，交互功能与信息可读性完全保留。",
      "pitfalls": "**① 封面 `transform-origin` 忘设在 `left center`，导致封面绕中心轴像旋转门一样穿模。**\n书本封面必须绕左侧书脊边缘（`transform-origin: left center`）旋转，且必须先 `translateZ(thickness / 2)` 再 `rotateY(angle)`，才能贴合书脊不脱臼。\n\n**② 只做“悬停翻开 140°”，结果鼠标移到翻开的封面上或稍微偏一点就反复抽搐开合。**\n悬停只做轻度微启（`-24deg`）作为交互暗示，彻底展读必须由点击/键盘触发锁定在 `.is-open` 状态。\n\n**③ 展开后忘了让整本书右移一点，导致左翻的封面裁切在卡片左侧边缘外。**\n`.is-open` 时配合 `translateX(24px)` 把打开后的双页重心重新拉回舞台中央。\n\n---",
      "ai_assets": {
        "prompt": "实现零依赖的 3D 精装立书封面开合展示（3D Hardcover Book Showcase）。\n\n原理一句话：用封面、内页、封底、书脊与纸纹书口五个 preserve-3d 平面拼出有真实厚度的 3D 精装书，悬停时封面微启暗示可交互，点击或按键盘绕左侧书脊翻开 132° 展读内页。\n\n做法：\n1. 纯函数 bookCoverAngle(open, hover = false)：\n   - open 为真返回 -132；否则 hover 为真返回 -28；默认返回 0。\n2. 五面真 3D 拼合（宽 W=112px，高 H=152px，厚 T=22px，舞台 perspective: 920px）：\n   - 书体容器：transform-style: preserve-3d; 默认静置 transform: rotateY(-24deg) rotateX(8deg); 展开态 transform: rotateY(-6deg) rotateX(3deg) translateX(24px); transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1)。\n   - 硬壳封面：transform-origin: left center; transform: translateZ(T/2) rotateY(var(--book-a, 0deg)); transition: transform 620ms cubic-bezier(0.22, 1, 0.36, 1)；左缘加内高光压槽模拟精装折痕。\n   - 内页：inset: 3px 3px 3px 2px; transform: translateZ(T/2 - 2px); 浅纸色微渐变底与可读排版。\n   - 封底：transform: translateZ(-T/2)。\n   - 左侧书脊：left: 0; width: T; transform-origin: left center; transform: translateZ(-T/2) rotateY(-90deg)。\n   - 右侧书口纸纹：right: 2px; top/bottom: 3px; width: T - 4px; repeating-linear-gradient(90deg, #d6dde8 0 2px, #f2f5fa 2px 4px); transform-origin: right center; transform: translateZ(-T/2 + 2px) rotateY(90deg)。\n3. 交互与无障碍：\n   - 仅在 @media (hover: hover) 且未展开时，悬停让书体轻抬并将封面微启至 -24deg（不彻底翻开，防光标抖动闪烁）。\n   - 点击或聚焦按 Enter / Space 切换展开态，同步写入 aria-expanded 与 --book-a。\n4. 降级：\n   - prefers-reduced-motion: reduce 下书体与封面取消 transform/transition，隐藏书脊/封底/书口，展开时将封面 opacity 置 0 清晰露出内页。\n\n硬要求：\n- 封面必须设 transform-origin: left center 并按 translateZ(T/2) rotateY(...) 顺序变换，确保绕书脊铰链开合不穿模。\n- 必须区分“悬停微启”与“点击锁定展读”，禁止纯 hover 翻开 130°+ 引发边界抽搐。\n- 必须支持键盘 Enter/Space 与 aria-expanded，严禁引入 Three.js。\n\n验收：\n- 静置时清晰可见立体书脊、封面压槽与右侧纸张纹路；鼠标移入封面微启露出一角内页。\n- 点击或按回车后封面丝滑翻开 132° 露出内页内容且整体居中不裁切；再点平滑合上。\n- 开启减弱动效后退化为清晰 2D 封面/内页切换卡片，内容完整可读。",
        "dont_do": "- 别把封面 `transform-origin` 留在默认 `center` —— 旋转时会像旋转门一样切穿整本书。\n- 别用纯 `:hover` 把封面直接翻到 `-140deg` —— 封面翻走后鼠标脱离命中区立刻合上，会陷入鬼畜死循环。\n- 别只画封面和内页两张纸片而省掉书脊和书口纸纹 —— 没厚度就没有精装书的材质说服力。",
        "skill_rule": "# 3D 精装立书封面开合 (book-3d) · 跨平台动效规范\n性质：材质 ｜ 平台：both\n\n【核心原理】用封面、内页、封底、书脊与纸纹书口五个 preserve-3d 平面拼出有真实厚度的 3D 精装书，悬停时封面微启暗示可交互，点击或按键盘绕左侧书脊翻开 132° 展读内页。\n\n【硬要求】\n- 封面必须设 transform-origin: left center 并按 translateZ(T/2) rotateY(...) 顺序变换，确保绕书脊铰链开合不穿模。\n- 必须区分“悬停微启”与“点击锁定展读”，禁止纯 hover 翻开 130°+ 引发边界抽搐。\n- 必须支持键盘 Enter/Space 与 aria-expanded，严禁引入 Three.js。\n\n【验收标准】\n- 静置时清晰可见立体书脊、封面压槽与右侧纸张纹路；鼠标移入封面微启露出一角内页。\n- 点击或按回车后封面丝滑翻开 132° 露出内页内容且整体居中不裁切；再点平滑合上。\n- 开启减弱动效后退化为清晰 2D 封面/内页切换卡片，内容完整可读。\n\n【禁止做法】\n- 别把封面 `transform-origin` 留在默认 `center` —— 旋转时会像旋转门一样切穿整本书。\n- 别用纯 `:hover` 把封面直接翻到 `-140deg` —— 封面翻走后鼠标脱离命中区立刻合上，会陷入鬼畜死循环。\n- 别只画封面和内页两张纸片而省掉书脊和书口纸纹 —— 没厚度就没有精装书的材质说服力。",
        "prompt_en": "Implement a zero-dependency 3D hardcover book showcase with cover opening and closing (3D Hardcover Book Showcase).\n\nCore Principle: Assemble a front cover, inner pages, back cover, spine, and textured page fore-edge from five preserve-3d planes to give genuine 3D book thickness; slightly crack the cover open on hover to signal interactivity, and swing it 132° around the left spine hinge on click or keyboard activation to display the inside pages.\n\nImplementation:\n1. Pure function bookCoverAngle(open, hover = false):\n   - Return -132 if open is truthy; otherwise return -28 if hover is truthy; default to 0.\n2. Five-plane true 3D assembly (W = 112px, H = 152px, thickness T = 22px, stage perspective: 920px):\n   - Book container: transform-style: preserve-3d; idle transform: rotateY(-24deg) rotateX(8deg); open transform: rotateY(-6deg) rotateX(3deg) translateX(24px); transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1).\n   - Hardcover front: transform-origin: left center; transform: translateZ(T/2) rotateY(var(--book-a, 0deg)); transition: transform 620ms cubic-bezier(0.22, 1, 0.36, 1); add an inner highlight crease along the left edge to simulate hardcover binding.\n   - Inner pages: inset: 3px 3px 3px 2px; transform: translateZ(T/2 - 2px); subtle light paper gradient background with legible typography.\n   - Back cover: transform: translateZ(-T/2).\n   - Left spine: left: 0; width: T; transform-origin: left center; transform: translateZ(-T/2) rotateY(-90deg).\n   - Right fore-edge paper grain: right: 2px; top/bottom: 3px; width: T - 4px; repeating-linear-gradient(90deg, #d6dde8 0 2px, #f2f5fa 2px 4px); transform-origin: right center; transform: translateZ(-T/2 + 2px) rotateY(90deg).\n3. Interaction and accessibility:\n   - Only under @media (hover: hover) and when closed, hover slightly lifts the book and cracks the cover open to -24deg (never opening fully on hover, preventing cursor jitter).\n   - Click or press Enter / Space while focused to toggle the open state, syncing aria-expanded and --book-a.\n4. Reduced motion:\n   - Under prefers-reduced-motion: reduce, remove transform/transition on book and cover, hide spine/back cover/fore-edge, and set cover opacity: 0 when open to cleanly reveal the inner pages.\n\nHard Constraints:\n- The cover must set transform-origin: left center and apply translateZ(T/2) rotateY(...) in that exact order so it pivots on the spine hinge without Z-clipping through the book.\n- Must separate \"hover peek\" from \"click-locked open\"; never open 130°+ on pure hover, which causes boundary oscillation.\n- Must support keyboard Enter/Space and aria-expanded; never import Three.js.\n\nAcceptance Criteria:\n- At rest, the 3D spine, cover binding crease, and right-edge paper grain are clearly visible; hovering cracks the cover open to reveal a corner of the inner pages.\n- Clicking or pressing Enter smoothly swings the cover open 132° to display the inner pages centered without clipping; clicking again smoothly closes it.\n- With reduced motion enabled, degrades to a crisp 2D cover/page toggle card with all content fully readable.",
        "dont_do_en": "- Do NOT leave the cover's `transform-origin` at the default `center` — rotating it will slice straight through the book like a revolving door.\n- Do NOT open the cover directly to `-140deg` on pure `:hover` — once the cover swings away, the cursor leaves the hit area, snapping it shut in an infinite jitter loop.\n- Do NOT draw only two flat sheets (cover and page) without the spine and fore-edge paper grain — without thickness, the hardcover material loses all credibility.",
        "skill_rule_en": "# 3D Hardcover Book Showcase (book-3d) · Cross-Platform Motion Spec\nNature: Material | Layer: 3d | Platform: both\n\nCore Principle: Assemble a front cover, inner pages, back cover, spine, and textured page fore-edge from five preserve-3d planes to give genuine 3D book thickness; slightly crack the cover open on hover to signal interactivity, and swing it 132° around the left spine hinge on click or keyboard activation to display the inside pages.\n\nHard Constraints:\n- The cover must set transform-origin: left center and apply translateZ(T/2) rotateY(...) in that exact order so it pivots on the spine hinge without Z-clipping through the book.\n- Must separate \"hover peek\" from \"click-locked open\"; never open 130°+ on pure hover, which causes boundary oscillation.\n- Must support keyboard Enter/Space and aria-expanded; never import Three.js.\n\nAcceptance Criteria:\n- At rest, the 3D spine, cover binding crease, and right-edge paper grain are clearly visible; hovering cracks the cover open to reveal a corner of the inner pages.\n- Clicking or pressing Enter smoothly swings the cover open 132° to display the inner pages centered without clipping; clicking again smoothly closes it.\n- With reduced motion enabled, degrades to a crisp 2D cover/page toggle card with all content fully readable.\n\nDo NOT Do:\n- Do NOT leave the cover's `transform-origin` at the default `center` — rotating it will slice straight through the book like a revolving door.\n- Do NOT open the cover directly to `-140deg` on pure `:hover` — once the cover swings away, the cursor leaves the hit area, snapping it shut in an infinite jitter loop.\n- Do NOT draw only two flat sheets (cover and page) without the spine and fore-edge paper grain — without thickness, the hardcover material loses all credibility."
      }
    },
    {
      "id": "border-run",
      "name": "流光跑动边框",
      "name_en": "Animated Conic Glow Border",
      "layer": "fun",
      "nature": "材质",
      "platform": "both",
      "status": "shipped",
      "entry": ".mk-border-run（纯 CSS @property --mk-angle + conic-gradient）",
      "source": "Linear / Magic UI / Vercel AI 卡片流光霓虹边框（零 JS、双 mask 掏空、@property 角度插值）",
      "source_en": "Linear / Vercel glowing border cards (CSS @property + conic-gradient mask)",
      "file": "effects/border-run.md",
      "summary": "纯 CSS 用 `@property` 登记角度变量驱动 `conic-gradient` 旋转，再用双 `mask` 掏空中间，让一道柔和流光沿着卡片圆角外圈匀速流动，零 JS、不重排。",
      "summary_en": "Pure CSS @property angle variable driving a rotating conic-gradient masked to a 1px rounded border — zero JS, zero layout thrash.",
      "problem": "**重点推荐卡片、AI 正在生成中的状态框或定价主卡需要一道高级的视觉聚焦边，但传统做法是塞一个旋转的巨大 `div` 再靠 `overflow: hidden` 遮罩——不仅多两层 DOM、还容易在圆角抗锯齿处露白边。** `@property <angle>` + `conic-gradient` + 双 mask 掏空，单伪元素零 JS 即可完美沿着任意圆角流动。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| `@property` 登记 `<angle>` 让 `conic-gradient` 角度原生可动画 | 用一个 `width: 200%` 的子元素做 `rotate(360deg)` 旋转裁切 |\n| 双 `mask` + `mask-composite: exclude`（Safari `xor`）只留 1.5px 边框环 | 整张卡片盖着不透明底色挡住底层玻璃透明感 |\n| 整层可关：减弱动效直接 `animation: none` 停在静态高光角度 | 闪烁刺眼的彩虹全谱色带（克制到 1–2 个品牌色 + 大段暗灰） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 旋转周期 | `4s linear infinite` | 低于 2s 显得焦躁抢视线，高于 8s 看不出在流；4s 是呼吸感最舒服的匀速节拍 |\n| 光带弧度 | 约 `25%–35%` 亮段 + 其余极低透明 | 整圈全亮就失去了“一道光在跑”的方向感，大段留暗才能凸显流光头尾 |\n| 边框厚度 | `1.5px`（`padding`） | 与液态玻璃亮棱一致，细到精致又不至于在高分屏断线 |\n| Safari 前缀 | `-webkit-mask-composite: xor` | 标准语法是 `exclude`，Safari 前缀版必须写 `xor`，否则整块卡片被锥形渐变糊死 |",
      "implementation": "```\nstyles/fun.css    @property --mk-angle（syntax: '<angle>'）\nstyles/fun.css    .mk-border-run / .mk-border-run::before / @keyframes mk-border-run\n```",
      "degradation": "**走 `fun` 层专属契约：整层关掉（停在静态光角，零动画）。**\n\n`prefers-reduced-motion: reduce` 与 `.mk-lite` 下 `animation: none`，流光停在一个静态高亮角度，保留边框轮廓但彻底静止。",
      "pitfalls": "**① 忘了用 `@property` 登记角度变量。**\n未登记的 CSS 自定义属性是字符串，浏览器无法在 `0deg` 和 `360deg` 之间插值，结果边框纹丝不动。\n\n**② 忘了写 `-webkit-mask-composite: xor`。**\n只写 `mask-composite: exclude` 在 Safari 上不会镂空中间，整个按钮或卡片会变成一块实心旋转色盘。\n\n**③ 伪元素漏写 `pointer-events: none` 或 `border-radius: inherit`。**\n漏掉 `pointer-events: none` 会吞掉卡片点击；漏掉 `border-radius: inherit` 会让光圈变成直角框。\n\n---",
      "ai_assets": {
        "prompt": "实现纯 CSS（零 JS）的圆角流光跑动边框（Animated Conic Border Beam）。\n\n原理一句话：用 @property 将自定义角度登记为 <angle>，驱动 ::before 的 conic-gradient 旋转，再通过双 mask + mask-composite 掏空中间，只留 1.5px 圆角流光环。\n\n做法：\n1. 注册可插值角度变量：\n   @property --beam-angle {\n     syntax: '<angle>';\n     initial-value: 0deg;\n     inherits: false;\n   }\n   @keyframes beam-spin { to { --beam-angle: 360deg; } }\n2. 容器与流光伪元素：\n   - .border-beam { position: relative; border-radius: 16px; }\n   - .border-beam::before {\n       content: ''; position: absolute; inset: 0; border-radius: inherit;\n       padding: 1.5px; pointer-events: none;\n       background: conic-gradient(from var(--beam-angle), transparent 0deg, transparent 230deg, rgba(184,255,61,0.9) 300deg, rgba(96,165,250,0.85) 340deg, transparent 360deg);\n       -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);\n       mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);\n       -webkit-mask-composite: xor;\n       mask-composite: exclude;\n       animation: beam-spin 4s linear infinite;\n     }\n3. 降级：\n   - @media (prefers-reduced-motion: reduce) { .border-beam::before { animation: none; } }\n\n硬要求：\n- 必须使用 @property 声明 syntax: '<angle>'，严禁用 JS rAF 每帧改角度。\n- 必须同时写 -webkit-mask-composite: xor 与 mask-composite: exclude 以兼容 Safari 与 Chrome。\n- ::before 必须带 pointer-events: none 与 border-radius: inherit。\n- prefers-reduced-motion: reduce 下必须 animation: none 停止旋转。\n\n验收：\n- 一道约 1/3 周长的柔和渐变流光沿卡片圆角外圈匀速流动，周期 4s，中间内容区完全透明无遮挡。\n- 在 Chrome 与 Safari 下均精准镂空，不出现实心色盘。\n- 卡片内按钮点击畅通；开启减弱动效后流光立刻静止。",
        "dont_do": "- 别用全彩虹 6 色渐变把整圈填满 —— 显得廉价刺眼，保持 65% 以上弧段为透明/极暗色。\n- 别在卡片里面套一个 `width: 200%; height: 200%` 的旋转 `div` 来裁切 —— 多余 DOM 且圆角处易露锯齿。\n- 别忘记 `@property` 声明 —— 否则角度无法做 CSS 插值，动画完全不动。",
        "skill_rule": "# 流光跑动边框 (border-run) · 跨平台动效规范\n性质：材质 ｜ 平台：both\n\n【核心原理】用 @property 将自定义角度登记为 <angle>，驱动 ::before 的 conic-gradient 旋转，再通过双 mask + mask-composite 掏空中间，只留 1.5px 圆角流光环。\n\n【硬要求】\n- 必须使用 @property 声明 syntax: '<angle>'，严禁用 JS rAF 每帧改角度。\n- 必须同时写 -webkit-mask-composite: xor 与 mask-composite: exclude 以兼容 Safari 与 Chrome。\n- ::before 必须带 pointer-events: none 与 border-radius: inherit。\n- prefers-reduced-motion: reduce 下必须 animation: none 停止旋转。\n\n【验收标准】\n- 一道约 1/3 周长的柔和渐变流光沿卡片圆角外圈匀速流动，周期 4s，中间内容区完全透明无遮挡。\n- 在 Chrome 与 Safari 下均精准镂空，不出现实心色盘。\n- 卡片内按钮点击畅通；开启减弱动效后流光立刻静止。\n\n【禁止做法】\n- 别用全彩虹 6 色渐变把整圈填满 —— 显得廉价刺眼，保持 65% 以上弧段为透明/极暗色。\n- 别在卡片里面套一个 `width: 200%; height: 200%` 的旋转 `div` 来裁切 —— 多余 DOM 且圆角处易露锯齿。\n- 别忘记 `@property` 声明 —— 否则角度无法做 CSS 插值，动画完全不动。",
        "prompt_en": "Implement a pure CSS (zero JS) animated rounded conic-gradient border beam (Animated Conic Border Beam).\n\nCore Principle: Register a custom angle variable as <angle> using @property, drive a rotating conic-gradient on ::before, and hollow out the interior with dual mask + mask-composite so only a 1.5px rounded luminous border beam remains.\n\nImplementation:\n1. Register interpolatable angle variable:\n   @property --beam-angle {\n     syntax: '<angle>';\n     initial-value: 0deg;\n     inherits: false;\n   }\n   @keyframes beam-spin { to { --beam-angle: 360deg; } }\n2. Container and beam pseudo-element:\n   - .border-beam { position: relative; border-radius: 16px; }\n   - .border-beam::before {\n       content: ''; position: absolute; inset: 0; border-radius: inherit;\n       padding: 1.5px; pointer-events: none;\n       background: conic-gradient(from var(--beam-angle), transparent 0deg, transparent 230deg, rgba(184,255,61,0.9) 300deg, rgba(96,165,250,0.85) 340deg, transparent 360deg);\n       -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);\n       mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);\n       -webkit-mask-composite: xor;\n       mask-composite: exclude;\n       animation: beam-spin 4s linear infinite;\n     }\n3. Reduced motion:\n   - @media (prefers-reduced-motion: reduce) { .border-beam::before { animation: none; } }\n\nHard Constraints:\n- Must use @property with syntax: '<angle>'; never update the angle every frame via JS rAF.\n- Must write both -webkit-mask-composite: xor and mask-composite: exclude for Safari and Chrome compatibility.\n- ::before must include pointer-events: none and border-radius: inherit.\n- Under prefers-reduced-motion: reduce, must set animation: none to stop rotation.\n\nAcceptance Criteria:\n- A soft gradient beam spanning roughly 1/3 of the perimeter travels steadily around the rounded card border on a 4s cycle while the interior stays completely transparent and unobstructed.\n- Punches out cleanly in both Chrome and Safari without rendering a solid color disc.\n- Buttons inside the card remain freely clickable; enabling reduced motion freezes the beam immediately.",
        "dont_do_en": "- Do NOT fill the entire ring with a full 6-color rainbow gradient — it looks cheap and harsh; keep over 65% of the arc transparent or very dim.\n- Do NOT nest a `width: 200%; height: 200%` rotating `div` inside the card to clip — it adds unnecessary DOM and exposes jagged edges at rounded corners.\n- Do NOT forget the `@property` declaration — without it, CSS cannot interpolate the angle and the animation will not move at all.",
        "skill_rule_en": "# Animated Conic Glow Border (border-run) · Cross-Platform Motion Spec\nNature: Material | Layer: fun | Platform: both\n\nCore Principle: Register a custom angle variable as <angle> using @property, drive a rotating conic-gradient on ::before, and hollow out the interior with dual mask + mask-composite so only a 1.5px rounded luminous border beam remains.\n\nHard Constraints:\n- Must use @property with syntax: '<angle>'; never update the angle every frame via JS rAF.\n- Must write both -webkit-mask-composite: xor and mask-composite: exclude for Safari and Chrome compatibility.\n- ::before must include pointer-events: none and border-radius: inherit.\n- Under prefers-reduced-motion: reduce, must set animation: none to stop rotation.\n\nAcceptance Criteria:\n- A soft gradient beam spanning roughly 1/3 of the perimeter travels steadily around the rounded card border on a 4s cycle while the interior stays completely transparent and unobstructed.\n- Punches out cleanly in both Chrome and Safari without rendering a solid color disc.\n- Buttons inside the card remain freely clickable; enabling reduced motion freezes the beam immediately.\n\nDo NOT Do:\n- Do NOT fill the entire ring with a full 6-color rainbow gradient — it looks cheap and harsh; keep over 65% of the arc transparent or very dim.\n- Do NOT nest a `width: 200%; height: 200%` rotating `div` inside the card to clip — it adds unnecessary DOM and exposes jagged edges at rounded corners.\n- Do NOT forget the `@property` declaration — without it, CSS cannot interpolate the angle and the animation will not move at all."
      }
    },
    {
      "id": "bottom-sheet",
      "name": "底部弹层",
      "name_en": "Draggable Bottom Sheet",
      "layer": "mobile",
      "nature": "连续",
      "platform": "touch",
      "status": "shipped",
      "entry": "v-mk-sheet + .mk-sheet / .mk-sheet-backdrop / .mk-sheet__grabber",
      "source": "iOS 13+ 原生 sheet（抓手拖拽）+ Vaul 的「拖到一半遮罩恰好透明一半」",
      "source_en": "iOS UISheetPresentationController / Vaul (28% threshold + flick velocity projection)",
      "file": "effects/bottom-sheet.md",
      "summary": "从屏幕底部升起的一块面板，抓手可拖；拖过 28% 高度或甩得够快就收起，否则回弹。",
      "summary_en": "Touch-first modal sheet rising from the bottom edge: dismisses when dragged past 28% height or flicked fast (>0.55px/ms), otherwise springs smoothly back.",
      "problem": "**「从哪儿冒出来」本身就是信息。** 一个从底部升起的面板告诉用户\"这是另一层临时内容，\n关掉就回原地\"，而一个淡入的居中弹窗什么也没说 —— 用户不知道它在层级上属于谁。\n\n第二个问题更要紧：**收起必须能用手势完成。** 只要面板上有抓手（或者手机上任何一块\n非滚动区），用户就会本能地往下拖。如果拖不动，那一下会读成\"卡了\"。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| iOS sheet 的抓手 + 跟手拖拽 | 多档位（30% / 60% / 全屏）—— 现在只有开/关两态，见缺口队列 P0 |\n| Vaul 的「遮罩跟手一起变淡」：`opacity = 1 - y / (h*1.5)` | Vaul 的滚动锁与嵌套滚动接管 |\n| 距离**或**速度，任一满足即判定收起 | 「拖到一半松手自动吸附到最近档位」 |\n| `@starting-style` 让入场不需要 JS 加类 | 手势期间的面板圆角随位移变化（iOS 有，这里没有） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 收起阈值 | `28%` 高度 | 低于 22% 太容易误收（用户想回弹却收起了）；高于 35% 会让人觉得\"拖了半天还不走\" |\n| 速度阈值 | `0.55 px/ms` | 快速轻甩（一帧移动 >33px @60fps）就该算\"我想关\"。取 0.5 会和正常拖拽的末速混淆 |\n| 遮罩淡出除数 | `h * 1.5` | 用 `h` 的话，拖到 100% 时遮罩刚好透明，但视觉上面板还有一半在屏幕里，读起来像\"遮罩先跑了\" |\n| 入场时长 | `--mk-dur-4` = 380ms | 区块级。比 240ms 慢，因为它是整层内容；比 560ms 快，否则会觉得\"等它升上来\" |\n| 遮罩模糊 | `blur(2px)` | 再高会让人以为真的失焦了；2px 只够\"按下去\"这一层 |",
      "implementation": "```\ngesture.js:16     shouldDismiss(dy, size, velocity, { threshold, velocityThreshold })  纯函数\ngesture.js:86     pointerDrag(...)      全库唯一一份速度计算\ngesture.js:187    sheet(el, { backdrop, handle, onClose, dismissThreshold, velocityThreshold })\nmobile.css:90     .mk-sheet-backdrop    + [data-mk-sheet-handle] 抓手\nmobile.css:110    .mk-sheet             位置与尺寸\nmobile.css:143    .mk-sheet__grabber    40×4 的条 + 96×32 的透明热区\n```\n\n拖拽期间**由 JS 写 inline `transform`**（`paint()`），松手后把 inline 清掉让 CSS 过渡接手。\n这和「JS 只写变量」的约定不冲突 —— 那条约定针对的是**离散状态与指针位置**\n（`--mk-tilt-x`、`--mk-glass-x`），目的是让多个效果能叠在同一个节点上。\n这里的位移是连续手势的直接产物，写进变量反而要在 CSS 里再拼一次同样的表达式，\n而且会在松手时多一次\"变量清零 → 过渡重算\"的抖动。\n\n代价是**同一个节点上不能再挂别的写 transform 的效果**（`v-mk-tap`、`mk-press`）。\n全库写 inline transform 的就三处：这里、`swipe()` 的 `translate3d(x)`、\n以及 `count-up` 的里程表列 —— 前两个都是拖拽。",
      "degradation": "**走 `mobile.css` 那档：减。**\n\n```css\n@media (prefers-reduced-motion: reduce) {\n  .mk-sheet, .mk-sheet-backdrop { transition-duration: 120ms; }\n  @starting-style { .mk-sheet { transform: none; opacity: 0; } }\n}\n```\n\n关键在 `@starting-style` 那条：减弱动效时**入场不能靠位移**（`translateY(100%)` 是运动），\n改成纯透明淡入。出场仍然是 `translateY(100%)`，但只有 120ms，读起来是\"瞬间消失\"而不是\"滑走\"。\n\n拖拽手势本身不摘 —— 它是操作方式，不是装饰；减弱动效的用户一样要能往下拖。",
      "pitfalls": "**① `close()` 里那个 `requestAnimationFrame` 不能省。**\n\n```js\nel.style.transition = '';                     // 恢复 CSS 过渡\nrequestAnimationFrame(() => {                 // ← 必须等一帧\n  el.classList.add('is-closing');\n  el.style.transform = '';\n});\n```\n\n同一帧内既清 inline `transform` 又加 `.is-closing`，浏览器会把两次样式变更合并成一次，\n**过渡的起点变成\"收起后的位置\"**，结果是面板直接消失、没有下滑。这是 `@starting-style`\n之前最容易踩的坑。\n\n**② 抓手是唯一的拖拽区，不是整个面板。**\n\n```css\n.mk-sheet__grabber { touch-action: none; }\n```\n\n面板内容区要能滚动。如果整个面板都接管 `pointerdown`，用户想滚内容时会拖起面板。\n`touch-action: none` 只给抓手，内容区保持默认 —— 这是\"竖滑归谁\"的分工。\n\n**③ `pointerDrag` 用的是 `e.timeStamp` 而不是 `performance.now()`。**\n两者在触摸事件上都会给到同一时间基准，但 `timeStamp` 在合成事件里保留原始时间，\n用 `performance.now()` 会把\"事件被延迟派发\"的那段时间算进速度里，甩出的速度偏小。\n`gesture.js:94` 有这行兜底：`e.timeStamp || performance.now()`。\n\n**④ 收起后 `onClose` 里要隐藏节点，而不是在这里移除节点。**\n`close()` 的 `done()` 会先调 `onClose()`（此时 `.is-closing` 还在），再让调用方\n置 `open = false`。反过来的话，清类那一瞬面板会闪回原位。\n\n**⑤ 兜底 `setTimeout(..., 560)` 不是冗余。**\n如果过渡被中断（切页面、浏览器优化掉不可见元素的过渡、减弱动效把时长压到 120ms\n导致 `transitionend` 早到但类还没清），`transitionend` 可能永远不来。\n560ms 是 `--mk-dur-4`(380) + 余量。\n\n**⑥ 面板放进设备框时要给祖先 `contain: paint`。**\n`.mk-sheet` 是 `position: fixed`，会跑到**视口**底部而不是演示框底部。\ndemo 的 `.device` 靠这个把 fixed 关进框里。\n\n**⑦ `pointercancel` 曾被当成\"松手\"判定。** 实测（Chrome 触摸模拟）：\n拖到 60% 高度后派发 `pointercancel`，旧实现直接收起（`closed: true`）——\n浏览器抢走手势（比如系统返回、外层滚动接管）时，用户**没有**松手，面板却关了。\n拖到 22% 时取消则正确回弹。**已修复**（2025-11）：`onEnd` 里判\n`e.type === 'pointercancel'` 直接走回弹分支，不做松手判定。\n同一修法同步进了 `edge-back` / `swipe` / `pull-refresh` ——\n**这是\"松手判定\"类效果共通的第四条硬约束**：cancel 不是 release。\n\n---",
      "ai_assets": {
        "prompt": "实现 iOS 风格的底部弹层（sheet）。结构固定三件套：\n\n原理一句话：一条位移过渡 + 一个纯函数判定（距离或末速，任一满足即收起）。没有物理引擎，判定只用到 dy 和 px/ms 两个数。\n\n  <div class=\"sheet-backdrop\"></div>\n  <div class=\"sheet\">\n    <div class=\"sheet-grabber\"></div>   <!-- 唯一的拖拽区 -->\n    ...内容...\n  </div>\n\n行为：\n- 入场：从 translateY(100%) 到 0，380ms，cubic-bezier(0.22, 1, 0.36, 1)。\n  用 @starting-style 让入场不需要 JS 加类：\n    .sheet { transform: translate3d(0, 0, 0); transition: transform 380ms var(--ease-out); }\n    @starting-style { .sheet { transform: translate3d(0, 100%, 0); } }\n- 拖拽只发生在抓手（grabber）上，抓手设 touch-action: none；\n  面板内容区保持默认，照样能滚。抓手视觉 40×4px，但热区至少 96×32px\n  （用 ::before 扩大，不要真把条画大）。\n- 拖动中：面板跟手 translate3d(0, y, 0)（y 钳在 0..height），\n  遮罩透明度 = clamp(1 - y / (height * 1.5), 0, 1)。\n  除数用 1.5：拖到 100% 时遮罩还剩 1/3，否则视觉上面板还有一半在屏里、\n  遮罩却全透明了，读起来像\"遮罩先跑了\"。\n- 松手判定（纯函数，方便单测）：\n    收起 = (dy > 0) && (dy > height * 0.28 || velocity > 0.55 /* px/ms */)\n  往上拖（dy <= 0）一律不算收起。\n- 收起动画：先清 inline transition 恢复 CSS 过渡，等一帧（requestAnimationFrame）\n  再加 .is-closing 类。同一帧内既清 transform 又加类，过渡会被浏览器合并掉，\n  面板会直接消失而不是滑下去。收起结束用 transitionend + 560ms 兜底\n  （过渡被中断时 transitionend 不会来）。\n- 速度计算用 PointerEvent.timeStamp（不要 performance.now()），单位 px/ms。\n\n硬要求：\n- 拖动期间 inline transform，松手后清掉 inline 让 CSS 接管 —— 两种状态不能混写。\n- prefers-reduced-motion：时长压到 120ms，且 @starting-style 改成\n  { transform: none; opacity: 0 }（入场变纯淡入，位移不算\"减弱\"）。\n- pointercancel 不能走\"松手判定\"——浏览器抢走手势时用户没有松手，\n  必须直接走回弹分支，否则面板会在用户没操作时自己关掉。\n- onClose 回调在收起过渡结束后触发，由调用方负责隐藏节点；\n  组件自己不要 remove() 节点。\n\n验收：\n- 拖到 30% 高度松手 → 收起；拖到 15% 慢慢松手 → 回弹到 0。\n- 拖到 15% 快速一甩（末速 > 0.55px/ms）→ 收起。\n- 拖到 60% 后触发 pointercancel → 回弹，不收起。\n- 抓手以外的区域拖动 → 面板不动，内容正常滚动。\n- 减弱动效 → 淡入淡出，无位移。",
        "dont_do": "- 别把整个面板设 `touch-action: none`，内容就滚不动了。\n- 别用 `bottom` / `top` 做跟手位移 —— 那是布局属性，每帧重排。只用 `transform`。\n- 别让遮罩和面板各用一条缓动 —— 拖到一半松手时两者会不同步地回去，接缝看得见。\n- 别给面板加 `will-change: transform` 常驻 —— 拖拽开始时加、结束 时摘，否则多一层合成。",
        "skill_rule": "# 底部弹层 (bottom-sheet) · 跨平台动效规范\n性质：连续 ｜ 平台：touch\n\n【核心原理】一条位移过渡 + 一个纯函数判定（距离或末速，任一满足即收起）。没有物理引擎，判定只用到 dy 和 px/ms 两个数。\n\n【硬要求】\n- 拖动期间 inline transform，松手后清掉 inline 让 CSS 接管 —— 两种状态不能混写。\n- prefers-reduced-motion：时长压到 120ms，且 @starting-style 改成\n  { transform: none; opacity: 0 }（入场变纯淡入，位移不算\"减弱\"）。\n- pointercancel 不能走\"松手判定\"——浏览器抢走手势时用户没有松手，\n  必须直接走回弹分支，否则面板会在用户没操作时自己关掉。\n- onClose 回调在收起过渡结束后触发，由调用方负责隐藏节点；\n  组件自己不要 remove() 节点。\n\n【验收标准】\n- 拖到 30% 高度松手 → 收起；拖到 15% 慢慢松手 → 回弹到 0。\n- 拖到 15% 快速一甩（末速 > 0.55px/ms）→ 收起。\n- 拖到 60% 后触发 pointercancel → 回弹，不收起。\n- 抓手以外的区域拖动 → 面板不动，内容正常滚动。\n- 减弱动效 → 淡入淡出，无位移。\n\n【禁止做法】\n- 别把整个面板设 `touch-action: none`，内容就滚不动了。\n- 别用 `bottom` / `top` 做跟手位移 —— 那是布局属性，每帧重排。只用 `transform`。\n- 别让遮罩和面板各用一条缓动 —— 拖到一半松手时两者会不同步地回去，接缝看得见。\n- 别给面板加 `will-change: transform` 常驻 —— 拖拽开始时加、结束 时摘，否则多一层合成。",
        "prompt_en": "Implement an iOS-style draggable bottom sheet with a fixed three-part DOM structure.\n\nCore Principle: One displacement transition plus one pure-function decision rule (distance or end velocity — meeting either dismisses). No physics engine; the decision uses only two numbers: dy and px/ms.\n\n  <div class=\"sheet-backdrop\"></div>\n  <div class=\"sheet\">\n    <div class=\"sheet-grabber\"></div>   <!-- the only drag handle -->\n    ...content...\n  </div>\n\nImplementation:\n- Entrance: from translateY(100%) to 0, 380ms, cubic-bezier(0.22, 1, 0.36, 1). Use @starting-style so entrance requires no JS class toggle:\n    .sheet { transform: translate3d(0, 0, 0); transition: transform 380ms var(--ease-out); }\n    @starting-style { .sheet { transform: translate3d(0, 100%, 0); } }\n- Dragging happens only on the grabber, which sets touch-action: none; the sheet content area keeps default touch behavior so it scrolls normally. The grabber is visually 40×4px, with a hit target of at least 96×32px (expanded via ::before without enlarging the visible bar).\n- While dragging: sheet tracks pointer via translate3d(0, y, 0) (y clamped to 0..height), backdrop opacity = clamp(1 - y / (height * 1.5), 0, 1). Using divisor 1.5 leaves 1/3 backdrop opacity at 100% drag; otherwise half the sheet remains on-screen while the backdrop is already fully transparent (looking as if the backdrop ran away first).\n- Release decision (pure function for easy unit testing):\n    dismiss = (dy > 0) && (dy > height * 0.28 || velocity > 0.55 /* px/ms */)\n  Dragging upward (dy <= 0) never triggers dismissal.\n- Closing animation: first clear inline transition to restore CSS transition, wait one frame (requestAnimationFrame), then add .is-closing. Clearing transform and adding the class in the same frame lets the browser coalesce them, causing the sheet to vanish instead of sliding down. Detect close completion via transitionend + 560ms fallback (transitionend does not fire when interrupted).\n- Compute velocity using PointerEvent.timeStamp (never performance.now()), in px/ms.\n\nHard Constraints:\n- Apply inline transform during drag, and clear inline styles on release so CSS transitions take over — never mix both states.\n- Under prefers-reduced-motion: compress duration to 120ms, and change @starting-style to { transform: none; opacity: 0 } (entrance becomes pure fade-in; translation is not \"reduced\" motion).\n- pointercancel must NOT run the release decision — when the browser reclaims the gesture, the user did not release, so it must unconditionally take the snap-back branch; otherwise the sheet closes by itself without user intent.\n- Fire onClose after the closing transition ends and let the caller hide/unmount the node; the component itself must never call remove().\n\nAcceptance Criteria:\n- Drag to 30% height and release -> dismisses; drag to 15% and release slowly -> snaps back to 0.\n- Drag to 15% and flick quickly (end velocity > 0.55px/ms) -> dismisses.\n- Drag to 60% and trigger pointercancel -> snaps back, does not dismiss.\n- Dragging outside the grabber -> sheet does not move, content scrolls normally.\n- Reduced motion -> fades in and out, zero translation.",
        "dont_do_en": "- Do NOT set `touch-action: none` on the entire sheet — inner content will become unscrollable.\n- Do NOT use `bottom` / `top` for pointer-tracking translation — those are layout properties causing per-frame reflow; use `transform` only.\n- Do NOT give the backdrop and the sheet different easing curves — releasing mid-drag will cause them to return out of sync, exposing a visible seam.\n- Do NOT leave `will-change: transform` permanently on the sheet — add it on drag start and remove it on drag end to avoid an extra persistent compositor layer.",
        "skill_rule_en": "# Draggable Bottom Sheet (bottom-sheet) · Cross-Platform Motion Spec\nNature: Continuity | Layer: mobile | Platform: touch\n\nCore Principle: One displacement transition plus one pure-function decision rule (distance or end velocity — meeting either dismisses). No physics engine; the decision uses only two numbers: dy and px/ms.\n\nHard Constraints:\n- Apply inline transform during drag, and clear inline styles on release so CSS transitions take over — never mix both states.\n- Under prefers-reduced-motion: compress duration to 120ms, and change @starting-style to { transform: none; opacity: 0 } (entrance becomes pure fade-in; translation is not \"reduced\" motion).\n- pointercancel must NOT run the release decision — when the browser reclaims the gesture, the user did not release, so it must unconditionally take the snap-back branch; otherwise the sheet closes by itself without user intent.\n- Fire onClose after the closing transition ends and let the caller hide/unmount the node; the component itself must never call remove().\n\nAcceptance Criteria:\n- Drag to 30% height and release -> dismisses; drag to 15% and release slowly -> snaps back to 0.\n- Drag to 15% and flick quickly (end velocity > 0.55px/ms) -> dismisses.\n- Drag to 60% and trigger pointercancel -> snaps back, does not dismiss.\n- Dragging outside the grabber -> sheet does not move, content scrolls normally.\n- Reduced motion -> fades in and out, zero translation.\n\nDo NOT Do:\n- Do NOT set `touch-action: none` on the entire sheet — inner content will become unscrollable.\n- Do NOT use `bottom` / `top` for pointer-tracking translation — those are layout properties causing per-frame reflow; use `transform` only.\n- Do NOT give the backdrop and the sheet different easing curves — releasing mid-drag will cause them to return out of sync, exposing a visible seam.\n- Do NOT leave `will-change: transform` permanently on the sheet — add it on drag start and remove it on drag end to avoid an extra persistent compositor layer."
      }
    },
    {
      "id": "bounce-text",
      "name": "逐字波浪弹跳",
      "name_en": "Wave Bounce Typography",
      "layer": "fun",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-bounce + .mk-bounce-text / .mk-bounce-text__u / bounceText(el)",
      "source": "逐字弹性起浪标题（中英混排拆字 + 32ms 级联延迟 + 空格保宽不坍塌）",
      "source_en": "Playful editorial kinetic typography (32ms per-unit staggered wave)",
      "file": "effects/bounce-text.md",
      "summary": "初始化把标题按中文单字、英文整词拆成行内块并写入序号变量，悬停或触发时各片段按 `32ms` 间隔依次轻快弹起形成一道文字波浪。",
      "summary_en": "Splits headlines into CJK characters and Latin words once on mount, rippling a crisp 32ms staggered wave bounce on hover or trigger.",
      "problem": "**互动彩蛋标题、空状态趣味提示或导航品牌字在悬停时如果整体上下动一下略显呆板，而逐字错开 32ms 形成波浪则立刻充满俏皮活力。** 关键在于中文按字切、英文按词切，且空格不能被吞掉。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 32ms 紧凑级联延迟 + `ease-snap` 弹性回落形成连续波浪 | 整句英文按单个字母狂跳（破坏阅读节奏） |\n| 空格用 `&nbsp;` 或保留 TextNode 保宽，绝不把英文词粘一起 | 用 JS `setInterval` 逐字改 `style.top` |\n| 支持 `sibling-index()` 兜底自动算序号 | 触屏残留 hover 弹起态 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 级联步长 | `32ms` / 片段 | 10 个字整道波浪 320ms 扫过，像琴键一样清脆连贯；超过 60ms 会断成一颗颗孤立跳动 |\n| 弹起高度 | `-6px ~ -8px` | 足够俏皮可见又不撞到上一行文字 |\n| 拆字正则 | `[\\u4e00-\\u9fa5]\\|[A-Za-z0-9]+\\|\\s+\\|.` | 中文逐字起浪、英文整词起浪、空格原样撑宽 |",
      "implementation": "```\nsrc/core/fun.js:127  bounceText(el)       一次性拆字写 --mk-i，返回 restore()\nstyles/fun.css:136   .mk-bounce-text / .mk-bounce-text__u\n```",
      "degradation": "**走 `fun` 层专属契约：整层关掉（`prefers-reduced-motion: reduce` 下取消所有弹跳位移与过渡）。**",
      "pitfalls": "**① 拆字后给 `<span>` 设为 `display: inline` 导致 `transform: translateY()` 完全不生效。**\nCSS 规范里 `transform` 对纯行内盒无效，必须给每个片段设 `display: inline-block`。\n\n**② 空白片段放进空 `<span> </span>` 被折叠成 0 宽度，英文词全部黏在一起。**\n空白片段必须转为 `\\u00A0`（`&nbsp;`）或保留为普通文本节点。\n\n**③ 裸写 `:hover` 不包在 `@media (hover: hover)` 里，手机点一下后整排字永远卡在半空。**\n\n---",
      "ai_assets": {
        "prompt": "实现支持中英混排的逐字波浪弹跳标题（Wave Bounce Text），零动画库依赖。\n\n原理一句话：挂载时一次性将文本按「中文单字 / 英文整词」拆成带递增索引 --i 的 inline-block <span>，悬停或触发时靠 transition-delay: calc(var(--i) * 32ms) 依次向上弹起形成琴键波浪。\n\n做法：\n1. 拆字函数 bounceText(el)：\n   - 正则 match(/[\\u4e00-\\u9fa5]|[A-Za-z0-9]+|\\s+|./gu) 切分片段。\n   - 每个片段建 <span class=\"bounce-u\" style=\"--i: idx\">，若为空白写 '\\u00A0' 撑住词间宽度。\n   - 外层容器保留 aria-label=\"<原文>\"，内部 span 标 aria-hidden=\"true\"，并返回 restore() 还原纯文本。\n2. CSS：\n   - .bounce-u { display: inline-block; transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1); transition-delay: calc(var(--i, 0) * 32ms); }\n   - @media (hover: hover) { .bounce-text:hover .bounce-u { transform: translate3d(0, -7px, 0); } }\n   - 同时支持 .bounce-text.is-wave .bounce-u { transform: translate3d(0, -7px, 0); } 便于点击触发。\n3. 降级：\n   - @media (prefers-reduced-motion: reduce) { .bounce-u { transform: none !important; transition: none; } }\n\n硬要求：\n- 每个片段必须是 display: inline-block，否则 translateY 静默失效。\n- 空白字符必须保留宽度，不得导致英文单词粘连。\n- hover 规则必须包在 @media (hover: hover) 内防止触屏卡态。\n- prefers-reduced-motion: reduce 下彻底关闭弹跳。\n\n验收：\n- 鼠标移入「Hello 动效世界」时，Hello、动、效、世、界按 32ms 间隔依次向上弹起 7px 形成丝滑波浪；词间空格完整保留。\n- 屏幕阅读器正常朗读完整标题。\n- 开启减弱动效后悬停无位移。",
        "dont_do": "- 别把拆出的 `<span>` 留成 `display: inline` —— `transform` 会完全不生效。\n- 别在 `mouseenter` 里每次重新拆 DOM —— 只在初始化拆一次。\n- 别把步长设超过 `80ms` —— 会断成一卡一卡的单独跳动，失去波浪感。",
        "skill_rule": "# 逐字波浪弹跳 (bounce-text) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】挂载时一次性将文本按「中文单字 / 英文整词」拆成带递增索引 --i 的 inline-block <span>，悬停或触发时靠 transition-delay: calc(var(--i) * 32ms) 依次向上弹起形成琴键波浪。\n\n【硬要求】\n- 每个片段必须是 display: inline-block，否则 translateY 静默失效。\n- 空白字符必须保留宽度，不得导致英文单词粘连。\n- hover 规则必须包在 @media (hover: hover) 内防止触屏卡态。\n- prefers-reduced-motion: reduce 下彻底关闭弹跳。\n\n【验收标准】\n- 鼠标移入「Hello 动效世界」时，Hello、动、效、世、界按 32ms 间隔依次向上弹起 7px 形成丝滑波浪；词间空格完整保留。\n- 屏幕阅读器正常朗读完整标题。\n- 开启减弱动效后悬停无位移。\n\n【禁止做法】\n- 别把拆出的 `<span>` 留成 `display: inline` —— `transform` 会完全不生效。\n- 别在 `mouseenter` 里每次重新拆 DOM —— 只在初始化拆一次。\n- 别把步长设超过 `80ms` —— 会断成一卡一卡的单独跳动，失去波浪感。",
        "prompt_en": "Implement a zero-library wave bounce typography effect supporting mixed CJK and Latin text (Wave Bounce Text).\n\nCore Principle: On mount, split text once into inline-block <span> tokens (individual CJK characters / whole English words) each carrying an incrementing index --i, so hovering or toggling triggers a piano-key upward bounce staggered via transition-delay: calc(var(--i) * 32ms).\n\nImplementation:\n1. Splitting function bounceText(el):\n   - Split tokens with regex match(/[\\u4e00-\\u9fa5]|[A-Za-z0-9]+|\\s+|./gu).\n   - Create <span class=\"bounce-u\" style=\"--i: idx\"> for each token, writing '\\u00A0' for whitespace to preserve inter-word width.\n   - Preserve aria-label=\"<original text>\" on the outer container, set aria-hidden=\"true\" on inner spans, and return restore() to revert to plain text.\n2. CSS:\n   - .bounce-u { display: inline-block; transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1); transition-delay: calc(var(--i, 0) * 32ms); }\n   - @media (hover: hover) { .bounce-text:hover .bounce-u { transform: translate3d(0, -7px, 0); } }\n   - Also support .bounce-text.is-wave .bounce-u { transform: translate3d(0, -7px, 0); } for click/programmatic triggers.\n3. Reduced motion:\n   - @media (prefers-reduced-motion: reduce) { .bounce-u { transform: none !important; transition: none; } }\n\nHard Constraints:\n- Every token must be display: inline-block, otherwise translateY silently fails.\n- Whitespace characters must preserve their width so English words never collapse together.\n- Hover rules must be wrapped inside @media (hover: hover) to prevent sticky hover states on touchscreens.\n- Under prefers-reduced-motion: reduce, completely disable bouncing.\n\nAcceptance Criteria:\n- Hovering over mixed text (e.g., \"Hello Motion World\" or mixed Latin/CJK text) bounces each word or CJK character upward by 7px at 32ms intervals forming a smooth wave while preserving inter-word spaces.\n- Screen readers read the complete title normally.\n- Hovering produces zero displacement with reduced motion enabled.",
        "dont_do_en": "- Do NOT leave the split `<span>` elements as `display: inline` — `transform` will have zero effect.\n- Do NOT re-split the DOM on every `mouseenter` — split once during initialization only.\n- Do NOT set the stagger step above `80ms` — it breaks into choppy isolated hops and loses the wave feel.",
        "skill_rule_en": "# Wave Bounce Typography (bounce-text) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: fun | Platform: both\n\nCore Principle: On mount, split text once into inline-block <span> tokens (individual CJK characters / whole English words) each carrying an incrementing index --i, so hovering or toggling triggers a piano-key upward bounce staggered via transition-delay: calc(var(--i) * 32ms).\n\nHard Constraints:\n- Every token must be display: inline-block, otherwise translateY silently fails.\n- Whitespace characters must preserve their width so English words never collapse together.\n- Hover rules must be wrapped inside @media (hover: hover) to prevent sticky hover states on touchscreens.\n- Under prefers-reduced-motion: reduce, completely disable bouncing.\n\nAcceptance Criteria:\n- Hovering over mixed text (e.g., \"Hello Motion World\" or mixed Latin/CJK text) bounces each word or CJK character upward by 7px at 32ms intervals forming a smooth wave while preserving inter-word spaces.\n- Screen readers read the complete title normally.\n- Hovering produces zero displacement with reduced motion enabled.\n\nDo NOT Do:\n- Do NOT leave the split `<span>` elements as `display: inline` — `transform` will have zero effect.\n- Do NOT re-split the DOM on every `mouseenter` — split once during initialization only.\n- Do NOT set the stagger step above `80ms` — it breaks into choppy isolated hops and loses the wave feel."
      }
    },
    {
      "id": "card-deck",
      "name": "3D 物理甩牌堆叠卡组",
      "name_en": "3D Draggable Card Stack",
      "layer": "3d",
      "nature": "权重",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.cardDeck(el, { threshold, onChange }) + .mk-deck / .mk-deck__card",
      "source": "实体扑克 / Tinder 3D 卡叠（纯函数算纵深层级 + 跟手 3D 偏航甩出 + pointercancel 回弹防卡死 + 自动循环回底）",
      "source_en": "Tinder / physical deck physics (Z-depth stack + coupled 3D fling + pointercancel guard)",
      "file": "effects/card-deck.md",
      "summary": "多张卡片沿 Z 轴层层叠放并逐级微缩露出底边；抓住顶牌左右拖拽时卡片随位移产生真实 3D 偏航与倾角，拉过阈值松手即干脆飞出并自动循环回卡堆底部，下一张无缝顶上。",
      "summary_en": "Layered Z-axis card stack with 1:1 pointer-capture drag, coupled 3D yaw/tilt, crisp fling-to-back cycling past 82px, and pointercancel safety bounce-back.",
      "problem": "**引导步骤、灵感卡片或推荐流用普通轮播翻页太机械，而自己手写堆叠甩牌最容易踩三个坑：拖拽中被系统手势 `pointercancel` 打断后卡片僵死在半空、甩飞后顺序错乱闪烁、以及用 `left/top` 拖拽导致移动端掉帧。** 用纯函数 `deckPose(slot, total)` 统一管理堆叠纵深、用 Pointer Capture 严密兜底 `pointercancel` 回弹、全部变换只写合成层 CSS 变量，手感立刻像真手洗牌。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 拖拽时同时耦合水平位移 `dx`、微弱竖向跟随 `dy * 0.35`、平面倾角 `dx * 0.08°` 与 3D 偏航 `-dx * 0.14°` | 只平移 X 轴像在推一张生硬纸片 |\n| 拖拽中关闭过渡（`.is-dragging { transition: none }`）实现 1:1 零延迟跟手；松手立刻恢复 `360ms` 缓动弹回或飞出 | 拖拽中还带着 CSS transition 导致卡片滞后拖尾 |\n| 显式处理 `pointercancel`：任何系统中断强制安全弹回原位，绝不误判为甩走也不卡死半空 | 漏写 `pointercancel` 导致顶牌卡在屏幕边上动不了 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 堆叠纵深步进 `deckPose` | 每深一层 `z: -28px` / `y: +10px` / `scale: -0.06` / `opacity: -0.22` | 底部露边清晰呈现“一叠厚卡片”的体量感，同时把视觉焦点稳稳锁在顶牌 |\n| 甩牌判定阈值 `threshold` | 默认 `82px`（水平位移 `|dx|`） | 轻碰微滑会弹回原位防误触，明确一拉立刻干脆飞走 |\n| 拖拽 3D 姿态耦合系数 | `rz = dx * 0.08deg` / `ry = -dx * 0.14deg` | 向右拉时卡面向左轻转带出透视纵深，幅度克制不翻背穿帮 |\n| 飞出切牌时序 | 飞出 `±220px` + `opacity: 0`，`220ms` 后队列循环 `push(shift())` 重绘 | 等顶牌飞出视野再无缝切到堆底，后排卡片同时前移补位毫无闪烁 |",
      "implementation": "```\nsrc/core/scene3d.js:612   deckPose(index, total)           纯函数，计算卡叠各层纵深/露边/缩放/zIndex（可单测）\nsrc/core/scene3d.js:627   cardDeck(el, { threshold })      Pointer Capture 3D 拖拽甩牌 + pointercancel 保护 + 键盘切换\nstyles/3d.css:912         .mk-deck / .mk-deck__card / .is-top / .is-dragging\n```",
      "degradation": "**走 `3d` 层专属契约：取消透视与 3D 甩飞过渡，保留清晰切牌与键盘翻阅。**\n\n`prefers-reduced-motion: reduce` 下取消舞台 `perspective` 与卡片过渡动画，点击切牌按钮或按方向键/空格可直接干净切换到下一张卡片，核心浏览能力完整保留。",
      "pitfalls": "**① 漏接 `pointercancel`，手机边缘返回手势或系统弹窗抢走焦点后顶牌永久悬停半空。**\n`pointercancel` 必须强制重置 `dragging = false` 并执行回位重绘，绝不触发甩走。\n\n**② 给堆叠容器设 `touch-action: none` 把手机页面上下滚动锁死。**\n甩牌主要是横向手势，容器应设 `touch-action: pan-y` 保留页面纵向滚动。\n\n**③ 拖拽期间没有去掉 `transition`，手指拖得快一点卡片就在后面慢半拍追赶。**\n`pointerdown` 立即加 `.is-dragging { transition: none }`，松手或取消时再移除恢复弹性过渡。\n\n---",
      "ai_assets": {
        "prompt": "实现零依赖的 3D 物理甩牌堆叠卡组（3D Draggable Card Stack）。\n\n原理一句话：用纯函数按堆叠槽位算每张卡的 Z 纵深、下露边、缩放与 zIndex 写入 CSS 变量；顶牌通过 Pointer Capture 支持 1:1 跟手 3D 偏航拖拽，超过 82px 松手即飞出并循环回卡堆底部，任何 pointercancel 强制安全弹回。\n\n做法：\n1. 纯函数 deckPose(index, total)：\n   - 顶牌 index === 0：{ z: 0, y: 0, scale: 1, opacity: 1, zIndex: total }；\n   - 第 i 层：{ z: -i * 28, y: i * 10, scale: Math.max(0.76, 1 - i * 0.06), opacity: Math.max(0.25, 1 - i * 0.22), zIndex: Math.max(1, total - i) }。\n2. CSS 3D 结构与合成层运动：\n   - 舞台容器：position: relative; perspective: 820px; transform-style: preserve-3d; touch-action: pan-y; user-select: none;\n   - 每张卡：position: absolute; inset: 0; transform: translate3d(var(--dk-dx), calc(var(--dk-y) + var(--dk-dy)), var(--dk-z)) rotateY(var(--dk-ry)) rotateZ(var(--dk-rz)) scale(var(--dk-s)); opacity: var(--dk-o);\n   - 默认 transition: transform 360ms cubic-bezier(0.22, 1, 0.36, 1), opacity 260ms ease；拖拽态 .is-dragging 必须 transition: none。\n3. 拖拽、甩飞与无障碍：\n   - 仅当 pointerdown 落在顶牌时启动，setPointerCapture(pointerId) 并加 .is-dragging；\n   - pointermove 写入 --dk-dx = dx、--dk-dy = dy * 0.35、--dk-rz = dx * 0.08deg、--dk-ry = -dx * 0.14deg；\n   - pointerup：若 |dx| >= threshold（默认 82px），按方向飞出 ±220px、rz ±18deg、ry ∓26deg、opacity 0，220ms 后执行 order.push(order.shift()) 重绘全堆并触发 onChange；未过阈值直接重绘平滑弹回；\n   - pointercancel：一律视为取消，不甩牌直接平滑弹回原位；\n   - 容器设 tabindex=\"0\"，支持 ArrowRight / Space 向右甩牌、ArrowLeft 向左甩牌，并暴露 .next() 方法。\n4. 降级：\n   - prefers-reduced-motion: reduce 取消 perspective 与 transition，支持无晕眩干净切牌。\n\n硬要求：\n- 必须处理 pointercancel 且取消时强制回弹，严禁留下悬空卡死状态。\n- 拖拽中必须禁用 transition 实现零延迟跟手；必须设 touch-action: pan-y 不锁页面纵滑。\n- 所有位置与姿态动画必须只走 transform 与 opacity。\n\n验收：\n- 4 张卡片呈明显 3D 纵深叠放与底部露边；拖拽顶牌时跟手倾斜并带 3D 偏航，小拖松手弹回、大拖松手干脆飞出并由下一张无缝顶上。\n- 触发系统手势打断（pointercancel）时顶牌立刻安全弹回，不会误切牌或卡死。\n- 点击切牌按钮或按空格/方向键流畅循环；开启减弱动效后干净切换无晕眩。",
        "dont_do": "- 别漏写 `pointercancel` 处理 —— 移动端系统手势一抢事件顶牌就会永远卡在半空。\n- 别在拖拽过程中留着 CSS `transition` —— 卡片会像粘了胶水一样追在手指后面。\n- 别给容器写 `touch-action: none` —— 用户在卡组上方滑不动页面。",
        "skill_rule": "# 3D 物理甩牌堆叠卡组 (card-deck) · 跨平台动效规范\n性质：权重 ｜ 平台：both\n\n【核心原理】用纯函数按堆叠槽位算每张卡的 Z 纵深、下露边、缩放与 zIndex 写入 CSS 变量；顶牌通过 Pointer Capture 支持 1:1 跟手 3D 偏航拖拽，超过 82px 松手即飞出并循环回卡堆底部，任何 pointercancel 强制安全弹回。\n\n【硬要求】\n- 必须处理 pointercancel 且取消时强制回弹，严禁留下悬空卡死状态。\n- 拖拽中必须禁用 transition 实现零延迟跟手；必须设 touch-action: pan-y 不锁页面纵滑。\n- 所有位置与姿态动画必须只走 transform 与 opacity。\n\n【验收标准】\n- 4 张卡片呈明显 3D 纵深叠放与底部露边；拖拽顶牌时跟手倾斜并带 3D 偏航，小拖松手弹回、大拖松手干脆飞出并由下一张无缝顶上。\n- 触发系统手势打断（pointercancel）时顶牌立刻安全弹回，不会误切牌或卡死。\n- 点击切牌按钮或按空格/方向键流畅循环；开启减弱动效后干净切换无晕眩。\n\n【禁止做法】\n- 别漏写 `pointercancel` 处理 —— 移动端系统手势一抢事件顶牌就会永远卡在半空。\n- 别在拖拽过程中留着 CSS `transition` —— 卡片会像粘了胶水一样追在手指后面。\n- 别给容器写 `touch-action: none` —— 用户在卡组上方滑不动页面。",
        "prompt_en": "Implement a zero-dependency 3D physics-fling stacked card deck (3D Draggable Card Stack).\n\nCore Principle: Use a pure function to compute each card's Z depth, bottom peek offset, scale, and zIndex by stack slot into CSS variables; the top card supports 1:1 pointer-captured 3D yaw dragging, flings out past 82px on release to cycle to the bottom of the deck, and unconditionally snaps back safely on any pointercancel.\n\nImplementation:\n1. Pure function deckPose(index, total):\n   - Top card index === 0: { z: 0, y: 0, scale: 1, opacity: 1, zIndex: total };\n   - Layer i: { z: -i * 28, y: i * 10, scale: Math.max(0.76, 1 - i * 0.06), opacity: Math.max(0.25, 1 - i * 0.22), zIndex: Math.max(1, total - i) }.\n2. CSS 3D structure and compositor-layer motion:\n   - Stage container: position: relative; perspective: 820px; transform-style: preserve-3d; touch-action: pan-y; user-select: none;\n   - Each card: position: absolute; inset: 0; transform: translate3d(var(--dk-dx), calc(var(--dk-y) + var(--dk-dy)), var(--dk-z)) rotateY(var(--dk-ry)) rotateZ(var(--dk-rz)) scale(var(--dk-s)); opacity: var(--dk-o);\n   - Default transition: transform 360ms cubic-bezier(0.22, 1, 0.36, 1), opacity 260ms ease; dragging state .is-dragging must set transition: none.\n3. Dragging, flinging, and accessibility:\n   - Start only when pointerdown lands on the top card; call setPointerCapture(pointerId) and add .is-dragging.\n   - On pointermove, write --dk-dx = dx, --dk-dy = dy * 0.35, --dk-rz = dx * 0.08deg, --dk-ry = -dx * 0.14deg.\n   - On pointerup: if |dx| >= threshold (default 82px), fling along the drag direction (±220px, rz ±18deg, ry ∓26deg, opacity 0), then after 220ms execute order.push(order.shift()), re-render the stack, and fire onChange; below threshold, re-render to smoothly snap back.\n   - On pointercancel: unconditionally treat as cancelled — never fling, immediately snap back to rest.\n   - Set tabindex=\"0\" on the container, support ArrowRight / Space to fling right and ArrowLeft to fling left, and expose .next().\n4. Reduced motion:\n   - Under prefers-reduced-motion: reduce, remove perspective and transition for clean, vertigo-free card switching.\n\nHard Constraints:\n- Must handle pointercancel by forcing a snap-back; never leave a card stuck suspended mid-air.\n- Must disable transition while dragging for zero-lag tracking, and set touch-action: pan-y so vertical page scrolling is not blocked.\n- All position and pose animations must use transform and opacity only.\n\nAcceptance Criteria:\n- Four cards stack with clear 3D depth and bottom peek edges; dragging the top card tilts and yaws smoothly in 3D, snapping back on small drags and cleanly flinging out on large drags while the next card promotes seamlessly.\n- Triggering a system gesture interruption (pointercancel) immediately snaps the top card back safely without accidental cycling or getting stuck.\n- Clicking the next button or pressing Space/Arrow keys cycles smoothly; reduced motion switches cleanly without motion sickness.",
        "dont_do_en": "- Do NOT omit `pointercancel` handling — if mobile OS gestures hijack the pointer, the top card will stay stuck mid-air forever.\n- Do NOT leave CSS `transition` active during dragging — the card will lag behind the finger as if stuck in glue.\n- Do NOT set `touch-action: none` on the container — users won't be able to scroll the page over the card deck.",
        "skill_rule_en": "# 3D Draggable Card Stack (card-deck) · Cross-Platform Motion Spec\nNature: Weight | Layer: 3d | Platform: both\n\nCore Principle: Use a pure function to compute each card's Z depth, bottom peek offset, scale, and zIndex by stack slot into CSS variables; the top card supports 1:1 pointer-captured 3D yaw dragging, flings out past 82px on release to cycle to the bottom of the deck, and unconditionally snaps back safely on any pointercancel.\n\nHard Constraints:\n- Must handle pointercancel by forcing a snap-back; never leave a card stuck suspended mid-air.\n- Must disable transition while dragging for zero-lag tracking, and set touch-action: pan-y so vertical page scrolling is not blocked.\n- All position and pose animations must use transform and opacity only.\n\nAcceptance Criteria:\n- Four cards stack with clear 3D depth and bottom peek edges; dragging the top card tilts and yaws smoothly in 3D, snapping back on small drags and cleanly flinging out on large drags while the next card promotes seamlessly.\n- Triggering a system gesture interruption (pointercancel) immediately snaps the top card back safely without accidental cycling or getting stuck.\n- Clicking the next button or pressing Space/Arrow keys cycles smoothly; reduced motion switches cleanly without motion sickness.\n\nDo NOT Do:\n- Do NOT omit `pointercancel` handling — if mobile OS gestures hijack the pointer, the top card will stay stuck mid-air forever.\n- Do NOT leave CSS `transition` active during dragging — the card will lag behind the finger as if stuck in glue.\n- Do NOT set `touch-action: none` on the container — users won't be able to scroll the page over the card deck."
      }
    },
    {
      "id": "cell-flash",
      "name": "单元格涨跌脉冲",
      "name_en": "Live Table Cell Flash",
      "layer": "motion",
      "nature": "反馈",
      "platform": "both",
      "status": "shipped",
      "entry": "flashCell(el, dir) / valueDelta(prev, next) + .mk-cell",
      "source": "Bloomberg / Stripe / Linear 实时表格数值变动脉冲（80ms 亮起 → 650ms 缓退 + tabular-nums）",
      "source_en": "Bloomberg / TradingView live quotes (80ms flash + 650ms decay + tabular-nums)",
      "file": "effects/cell-flash.md",
      "summary": "实时表格里某个数字变动时，按涨/跌方向在单元格背景打出一记「80ms 瞬时亮起 → 650ms 缓慢退去」的绿/红脉冲，并锁定等宽数字防止整列左右抖动。",
      "summary_en": "Directional green/red 80ms attack + 650ms decay pulse on live metric ticks, locked with tabular-nums so table columns never jitter horizontally.",
      "problem": "**在 30–100 格的实时监控或行情表里，数字静默刷新等于没刷新。** 人眼无法同时扫描几十个单元格去比对刚才哪一格变了；反过来如果给变动格加缩放或弹跳，整张表格的对齐线会瞬间崩掉。只动背景色、快亮慢退，是信息密度最高且零干扰的反馈语言。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 金融终端与现代监控面板的「快起慢落」非对称色彩脉冲（12% 峰值、88% 衰减） | 改变字号、加粗或 `scale` 弹跳（破坏表格对齐） |\n| `font-variant-numeric: tabular-nums` 强制等宽数字 | 每次更新都重播入场动画或全行闪烁 |\n| 纯函数 `valueDelta(prev, next, eps)` 判定方向与死区过滤 | 浮点微小噪声导致单元格不停乱闪 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 总时长 | `730ms`（12% ≈ 88ms 亮起，642ms 退去） | 亮起必须像电脉冲一样干脆（≤100ms 抓眼），退去要慢到余光能扫到、又不至于把表格染花 |\n| 峰值透明度 | `rgba(..., 0.28)` | 足够在深色或浅色底上被余光捕捉，同时保证前景数字对比度全程清晰可读 |\n| 等宽数字 | `tabular-nums` | `1` 和 `8` 等宽，数字刷新时小数点与右对齐列纹丝不动 |\n| 死区阈值 `eps` | 默认 `0`，可配置 | 对带浮点抖动的传感器/延迟指标，可设 `eps` 屏蔽无意义微变 |",
      "implementation": "```\nsrc/core/data.js:65   valueDelta(prev, next, eps)   纯函数，返回 'up' | 'down' | 'same'\nsrc/core/data.js:75   flashCell(el, dir)            摘类 + reflow + 加 .is-up / .is-down\nstyles/motion.css     .mk-cell / @keyframes mk-cell-up / @keyframes mk-cell-down\n```",
      "degradation": "**走 `motion` 档：减，不关。**\n\n`prefers-reduced-motion: reduce` 下将脉冲动画压短到 `120ms`，去掉长时间缓变余辉，避免对前庭/视觉敏感用户造成大片闪烁干扰，同时保留变动提示。",
      "pitfalls": "**① 表格数字列忘了加 `font-variant-numeric: tabular-nums`。**\n数字从 `11.11` 变成 `88.88` 时整列宽度左右跳动，看几秒钟就会头晕；这是实时表格的第一铁律。\n\n**② 高频连续刷新时直接 `classList.add('is-up')` 导致第二次不闪。**\n如果上一次 730ms 还没播完，同帧重复加同一个类浏览器不会重播关键帧；必须先 `remove('is-up', 'is-down')` 再触发一次 `void el.offsetWidth` 重排后再加类。\n\n**③ 初始渲染（挂载第 1 帧）就把所有单元格全闪一遍。**\n初始加载不是“涨跌变化”，只有前后两个有效数值都存在且 `valueDelta(prev, next) !== 'same'` 时才允许触发脉冲。\n\n**④ 只靠红/绿色区分涨跌，忽略色盲用户。**\n脉冲只负责「吸引注意力到变动格」，单元格文案本身应配 `+` / `-` 或 `↑` / `↓` 符号，不把颜色当唯一信息通道。\n\n---",
      "ai_assets": {
        "prompt": "实现实时数据表格的单元格涨跌脉冲动效（零依赖，仅背景色脉冲 + 等宽数字）。\n\n原理一句话：纯函数对比新旧值判定 up/down/same，仅对变动单元格触发「80ms 快亮 → 650ms 慢退」的背景色关键帧，配合 tabular-nums 保证数字列零抖动。\n\n做法：\n1. 纯函数 valueDelta(prev, next, eps = 0)：\n   - 若 prev 或 next 非有限数字，返回 'same'。\n   - 若 Math.abs(next - prev) <= eps，返回 'same'。\n   - 否则返回 next > prev ? 'up' : 'down'。\n2. CSS 样式：\n   - 单元格 .data-cell：font-variant-numeric: tabular-nums; border-radius: 6px;\n   - 关键帧（快起慢落非对称曲线，总长 730ms）：\n     @keyframes cell-up   { 0% { background-color: transparent; } 12% { background-color: rgba(74, 222, 128, 0.28); } 100% { background-color: transparent; } }\n     @keyframes cell-down { 0% { background-color: transparent; } 12% { background-color: rgba(248, 113, 113, 0.28); } 100% { background-color: transparent; } }\n   - .data-cell.is-up { animation: cell-up 730ms cubic-bezier(0.22, 1, 0.36, 1); }\n   - .data-cell.is-down { animation: cell-down 730ms cubic-bezier(0.22, 1, 0.36, 1); }\n3. 触发逻辑 flashCell(el, dir)：\n   - 仅在已有旧值且 dir 为 'up' 或 'down' 时触发（首屏初次渲染不闪）。\n   - 先 el.classList.remove('is-up', 'is-down')，再 void el.offsetWidth 强制重排，再加对应类，确保连续两次上涨也能可靠重播。\n\n硬要求：\n- 所有变动数字单元格必须设 font-variant-numeric: tabular-nums，禁止列宽跳动。\n- 严禁在脉冲中修改 transform / scale / font-weight / padding（会破坏表格对齐或触排）。\n- 颜色不可作为涨跌唯一信号，需与 +/- 或 ↑/↓ 文案配合。\n- prefers-reduced-motion: reduce 下将动画时长压缩至 120ms，避免大面积长时间闪烁。\n\n验收：\n- 数值从 120 变为 135 时，单元格在 90ms 内闪绿并在 ~730ms 内平滑退回透明；表格其他未变动格完全静止。\n- 500ms 内连续两次上涨，第二次脉冲正常重播不丢失。\n- 数值未变或传入 NaN 时不闪；首屏初次加载不闪。\n- 数字从 111.11 变为 888.88 时，小数点与右边界位置 0px 偏移。",
        "dont_do": "- 别给变动单元格加 `scale(1.06)` 弹跳 —— 表格里同时跳三格会显得非常廉价且破坏对齐。\n- 别忘记 `tabular-nums` —— 比例字体下数字刷新会让整列像地震一样左右晃。\n- 别在首次渲染数据加载完时把全表闪成一片绿 —— 只有增量变化才配脉冲。",
        "skill_rule": "# 单元格涨跌脉冲 (cell-flash) · 跨平台动效规范\n性质：反馈 ｜ 平台：both\n\n【核心原理】纯函数对比新旧值判定 up/down/same，仅对变动单元格触发「80ms 快亮 → 650ms 慢退」的背景色关键帧，配合 tabular-nums 保证数字列零抖动。\n\n【硬要求】\n- 所有变动数字单元格必须设 font-variant-numeric: tabular-nums，禁止列宽跳动。\n- 严禁在脉冲中修改 transform / scale / font-weight / padding（会破坏表格对齐或触排）。\n- 颜色不可作为涨跌唯一信号，需与 +/- 或 ↑/↓ 文案配合。\n- prefers-reduced-motion: reduce 下将动画时长压缩至 120ms，避免大面积长时间闪烁。\n\n【验收标准】\n- 数值从 120 变为 135 时，单元格在 90ms 内闪绿并在 ~730ms 内平滑退回透明；表格其他未变动格完全静止。\n- 500ms 内连续两次上涨，第二次脉冲正常重播不丢失。\n- 数值未变或传入 NaN 时不闪；首屏初次加载不闪。\n- 数字从 111.11 变为 888.88 时，小数点与右边界位置 0px 偏移。\n\n【禁止做法】\n- 别给变动单元格加 `scale(1.06)` 弹跳 —— 表格里同时跳三格会显得非常廉价且破坏对齐。\n- 别忘记 `tabular-nums` —— 比例字体下数字刷新会让整列像地震一样左右晃。\n- 别在首次渲染数据加载完时把全表闪成一片绿 —— 只有增量变化才配脉冲。",
        "prompt_en": "Implement a real-time data table cell delta flash animation (zero dependencies, background-color pulse + tabular numerals only).\n\nCore Principle: Compare old and new values in a pure function to classify up/down/same, triggering a \"80ms fast-flash -> 650ms slow-fade\" background-color keyframe only on changed cells, paired with tabular-nums to guarantee zero column jitter.\n\nImplementation:\n1. Pure function valueDelta(prev, next, eps = 0):\n   - Return 'same' if prev or next is non-finite.\n   - Return 'same' if Math.abs(next - prev) <= eps.\n   - Otherwise return next > prev ? 'up' : 'down'.\n2. CSS styling:\n   - Cell .data-cell: font-variant-numeric: tabular-nums; border-radius: 6px;\n   - Keyframes (asymmetric fast-rise, slow-fade curve, 730ms total):\n     @keyframes cell-up   { 0% { background-color: transparent; } 12% { background-color: rgba(74, 222, 128, 0.28); } 100% { background-color: transparent; } }\n     @keyframes cell-down { 0% { background-color: transparent; } 12% { background-color: rgba(248, 113, 113, 0.28); } 100% { background-color: transparent; } }\n   - .data-cell.is-up { animation: cell-up 730ms cubic-bezier(0.22, 1, 0.36, 1); }\n   - .data-cell.is-down { animation: cell-down 730ms cubic-bezier(0.22, 1, 0.36, 1); }\n3. Trigger logic flashCell(el, dir):\n   - Trigger only when a prior value exists and dir is 'up' or 'down' (never flash on initial render).\n   - First call el.classList.remove('is-up', 'is-down'), force reflow with void el.offsetWidth, then add the corresponding class so consecutive increases reliably replay.\n\nHard Constraints:\n- All updating numeric cells must set font-variant-numeric: tabular-nums to prevent column width jumping.\n- Never modify transform, scale, font-weight, or padding during the pulse (breaks table alignment or triggers reflow).\n- Color must not be the sole indicator of up/down; pair with +/- or ↑/↓ text markers.\n- Under prefers-reduced-motion: reduce, compress animation duration to 120ms to avoid large-area prolonged flashing.\n\nAcceptance Criteria:\n- When a value changes from 120 to 135, the cell flashes green within 90ms and fades smoothly back to transparent over ~730ms; unchanged cells remain completely still.\n- Two consecutive increases within 500ms both replay the pulse reliably without dropping the second flash.\n- Unchanged values, NaN, and initial page load produce no flash.\n- Changing a value from 111.11 to 888.88 results in 0px shift of the decimal point and right edge.",
        "dont_do_en": "- Do NOT add a `scale(1.06)` bounce to updating cells — three cells popping simultaneously in a table looks cheap and breaks alignment.\n- Do NOT forget `tabular-nums` — proportional digits make the entire column shake horizontally on every update.\n- Do NOT flash the entire table green on initial data load — only incremental deltas deserve a pulse.",
        "skill_rule_en": "# Live Table Cell Flash (cell-flash) · Cross-Platform Motion Spec\nNature: Feedback | Layer: motion | Platform: both\n\nCore Principle: Compare old and new values in a pure function to classify up/down/same, triggering a \"80ms fast-flash -> 650ms slow-fade\" background-color keyframe only on changed cells, paired with tabular-nums to guarantee zero column jitter.\n\nHard Constraints:\n- All updating numeric cells must set font-variant-numeric: tabular-nums to prevent column width jumping.\n- Never modify transform, scale, font-weight, or padding during the pulse (breaks table alignment or triggers reflow).\n- Color must not be the sole indicator of up/down; pair with +/- or ↑/↓ text markers.\n- Under prefers-reduced-motion: reduce, compress animation duration to 120ms to avoid large-area prolonged flashing.\n\nAcceptance Criteria:\n- When a value changes from 120 to 135, the cell flashes green within 90ms and fades smoothly back to transparent over ~730ms; unchanged cells remain completely still.\n- Two consecutive increases within 500ms both replay the pulse reliably without dropping the second flash.\n- Unchanged values, NaN, and initial page load produce no flash.\n- Changing a value from 111.11 to 888.88 results in 0px shift of the decimal point and right edge.\n\nDo NOT Do:\n- Do NOT add a `scale(1.06)` bounce to updating cells — three cells popping simultaneously in a table looks cheap and breaks alignment.\n- Do NOT forget `tabular-nums` — proportional digits make the entire column shake horizontally on every update.\n- Do NOT flash the entire table green on initial data load — only incremental deltas deserve a pulse."
      }
    },
    {
      "id": "confetti",
      "name": "物理撒花礼炮",
      "name_en": "Physics Confetti Cannon",
      "layer": "fun",
      "nature": "反馈",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.confetti({ origin, count, colors, spread }) + .mk-confetti",
      "source": "物理抛射礼炮（WAAPI 零依赖批量起播 + 抛物线重力坠落 + 播完自毁 DOM）",
      "source_en": "Celebration micro-interaction (native WAAPI ballistic burst + auto-cleanup)",
      "file": "effects/confetti.md",
      "summary": "在按钮或视口中心瞬间炸出一蓬彩色纸屑，按圆周抖动角向上抛射再受重力旋转飘落，全部走原生 WAAPI 并在播完后自动销毁节点不留残留。",
      "summary_en": "Zero-dependency WAAPI confetti burst launching colored particles from a button or viewport center with upward arc, gravity spin, and automatic DOM cleanup.",
      "problem": "**完成关键里程碑（首次发布、支付成功、通关打卡）时，一个冷冰冰的「成功」弹窗缺少情绪峰值；但为此引入 30KB 的 canvas-confetti 库又显得过重。** 用 60 行原生 Web Animations API 批量起播 + 播完自摘容器，零依赖就能给出极爽的庆祝瞬间。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 礼炮先向上抛（`dy - 90`）再受重力下坠（`+320px`）的两段抛物线感 | 整页常驻 `<canvas>` 粒子引擎 |\n| 角度按 `2π * i / count` 均匀铺开再加随机抖动，避免聚成一坨或排成车轮 | 纯 `Math.random() * 2π` 导致某些方向空一大块 |\n| 建完所有关键帧后统一 `animate()`，避免肉眼可见的先后起飞差 | 播完不清理 DOM 导致内存与节点泄漏 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 碎片数 `count` | 桌面 `90` / 触屏上限 `60` | 90 片足够热闹饱满；手机端自动压到 60 片省电防掉帧 |\n| 抛射峰值偏移 | `offset: 0.42`、`dy - 90` | 先在 42% 时长冲到最高点，后 58% 旋转下坠淡出，符合真实纸屑阻力感 |\n| 持续时长 `duration` | `1600ms`（× 0.7..1.2 随机） | 错开每片落地时间，不会像一块布同时消失 |\n| 清理兜底 | `Promise.all(finished)` + `setTimeout` | 切到后台标签页时 `finished` 可能挂起，兜底定时器保证容器必被摘除 |",
      "implementation": "```\nsrc/core/fun.js:36    confetti({ count, origin, colors, spread, duration, seed })\nstyles/fun.css        .mk-confetti / .mk-confetti__bit\n```",
      "degradation": "**走 `fun` 层专属契约：整层关掉。**\n\n`prefers-reduced-motion: reduce` 下 `confetti()` 第一行直接返回空清理函数，不创建任何节点、不启动任何动画——庆祝彩带是纯情绪装饰，在减弱动效下没有折中空间。",
      "pitfalls": "**① 纸屑容器忘了设 `pointer-events: none` 与 `position: fixed; inset: 0`。**\n如果挡住点击，用户庆祝完点“下一步”会点在透明撒花层上没反应。\n\n**② 只靠 `animation.finished` 清理容器，没加 `setTimeout` 兜底。**\n用户点了按钮立刻切标签页，浏览器暂停动画导致 `finished` 迟迟不触发，DOM 节点挂着不释放。\n\n**③ 节点原点没设到点击按钮中心，全从屏幕左上角 `(0,0)` 炸出来。**\n若传入 `origin` DOM 元素，应读取 `getBoundingClientRect()` 算出按钮正中心 `(x, y)` 作为爆炸起点。\n\n---",
      "ai_assets": {
        "prompt": "实现零依赖的物理撒花礼炮动效（Confetti Burst，原生 Web Animations API）。\n\n原理一句话：在触发点（按钮中心或视口中心）创建一个 pointer-events: none 的 fixed 容器，按均匀圆周+抖动角生成 60–90 片彩纸，统一用 WAAPI 播放「先上抛 → 旋转下坠淡出」三帧动画，播完后自动销毁容器。\n\n做法：\n1. 降级与节流：prefers-reduced-motion: reduce 直接返回不播；触屏粗指针将 count 上限压至 60。\n2. 起点计算：若传入 DOM 元素 origin，取其 getBoundingClientRect() 中心 (x, y)；否则取视口中心。\n3. 批量生成纸屑（默认 count = 90, duration = 1600ms）：\n   - 宿主容器：position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 9999; aria-hidden=\"true\"。\n   - 每片纸屑定位在 (x, y)，宽 8px 高 5px 圆角 2px，从高对比色板随机取色。\n   - 角度 angle = (i / count) * Math.PI * 2 + random * 0.8（均匀铺开再加抖动，既不聚团也不像车轮）；\n     力度 power = 70 + random * 150；\n     dx = cos(angle) * power；dy = sin(angle) * power * 0.75 - 90（先向上抛）；\n     rot = (random - 0.5) * 900deg；单寿命 life = duration * (0.7 + random * 0.5)。\n   - 三帧关键帧：\n     0%: transform: translate3d(0,0,0) rotate(0deg), opacity: 1\n     42%: transform: translate3d(dx, dy, 0) rotate(rot), opacity: 1\n     100%: transform: translate3d(dx*1.32, dy+320px, 0) rotate(rot*1.6), opacity: 0\n   - 所有节点挂完后再统一调用 bit.animate(keyframes, { duration: life, easing: 'cubic-bezier(0.16, 0.8, 0.3, 1)', fill: 'both' })。\n4. 自动清理：Promise.all(anims.map(a => a.finished.catch(() => {}))) 与 setTimeout(cleanup, duration * 1.6 + 600) 双保险取消动画并 remove() 容器。\n\n硬要求：\n- 容器必须设 pointer-events: none 与 aria-hidden=\"true\"，绝不挡住页面点击。\n- 必须带双保险清理，播完后 DOM 中 0 残留节点。\n- prefers-reduced-motion: reduce 下彻底不播（整层关闭）。\n\n验收：\n- 点击按钮后，彩纸从该按钮正中心向四周先上抛再旋转飘落，约 2 秒内全部消失。\n- 播完后检查 document.body，撒花容器已被完整移除，无残留节点。\n- 撒花过程中页面其他按钮点击畅通无阻。\n- 开启减弱动效后点击不产生任何动画与节点。",
        "dont_do": "- 别为了撒一次花引入几十 KB 的第三方粒子/Canvas 库。\n- 别用纯随机角度不均匀分布 —— 容易在一侧扎堆、另一侧留白。\n- 别在循环里边 appendChild 边 animate 读布局 —— 先批量建节点再统一起播。",
        "skill_rule": "# 物理撒花礼炮 (confetti) · 跨平台动效规范\n性质：反馈 ｜ 平台：both\n\n【核心原理】在触发点（按钮中心或视口中心）创建一个 pointer-events: none 的 fixed 容器，按均匀圆周+抖动角生成 60–90 片彩纸，统一用 WAAPI 播放「先上抛 → 旋转下坠淡出」三帧动画，播完后自动销毁容器。\n\n【硬要求】\n- 容器必须设 pointer-events: none 与 aria-hidden=\"true\"，绝不挡住页面点击。\n- 必须带双保险清理，播完后 DOM 中 0 残留节点。\n- prefers-reduced-motion: reduce 下彻底不播（整层关闭）。\n\n【验收标准】\n- 点击按钮后，彩纸从该按钮正中心向四周先上抛再旋转飘落，约 2 秒内全部消失。\n- 播完后检查 document.body，撒花容器已被完整移除，无残留节点。\n- 撒花过程中页面其他按钮点击畅通无阻。\n- 开启减弱动效后点击不产生任何动画与节点。\n\n【禁止做法】\n- 别为了撒一次花引入几十 KB 的第三方粒子/Canvas 库。\n- 别用纯随机角度不均匀分布 —— 容易在一侧扎堆、另一侧留白。\n- 别在循环里边 appendChild 边 animate 读布局 —— 先批量建节点再统一起播。",
        "prompt_en": "Implement a zero-dependency physics confetti cannon burst using the native Web Animations API.\n\nCore Principle: Create a pointer-events: none fixed container at the trigger origin (button center or viewport center), spawn 60–90 confetti pieces around a jittered uniform circle, animate them together via WAAPI using a three-keyframe \"launch upward -> spin and fall with fade-out\" trajectory, and automatically destroy the container on completion.\n\nImplementation:\n1. Reduced motion and throttling: return immediately without playing under prefers-reduced-motion: reduce; cap count at 60 on coarse-pointer touch devices.\n2. Origin calculation: if a DOM element origin is provided, take its getBoundingClientRect() center (x, y); otherwise use the viewport center.\n3. Batch confetti generation (default count = 90, duration = 1600ms):\n   - Host container: position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 9999; aria-hidden=\"true\".\n   - Position each piece at (x, y), 8px wide by 5px tall with 2px border-radius, picking a random color from a high-contrast palette.\n   - angle = (i / count) * Math.PI * 2 + random * 0.8 (uniform spread plus jitter to avoid clumping or spoke-wheel artifacts);\n     power = 70 + random * 150;\n     dx = cos(angle) * power; dy = sin(angle) * power * 0.75 - 90 (launch upward first);\n     rot = (random - 0.5) * 900deg; per-piece life = duration * (0.7 + random * 0.5).\n   - Three keyframes:\n     0%: transform: translate3d(0,0,0) rotate(0deg), opacity: 1\n     42%: transform: translate3d(dx, dy, 0) rotate(rot), opacity: 1\n     100%: transform: translate3d(dx*1.32, dy+320px, 0) rotate(rot*1.6), opacity: 0\n   - After appending all nodes, start animations together via bit.animate(keyframes, { duration: life, easing: 'cubic-bezier(0.16, 0.8, 0.3, 1)', fill: 'both' }).\n4. Automatic cleanup: dual safeguard with Promise.all(anims.map(a => a.finished.catch(() => {}))) and setTimeout(cleanup, duration * 1.6 + 600) to cancel animations and remove() the container.\n\nHard Constraints:\n- The container must set pointer-events: none and aria-hidden=\"true\" so it never blocks page clicks.\n- Must include dual-safeguard cleanup leaving 0 residual DOM nodes after playback.\n- Under prefers-reduced-motion: reduce, skip completely (disable the entire layer).\n\nAcceptance Criteria:\n- Clicking the button launches confetti upward from the button's exact center before spinning and drifting down in all directions, vanishing completely within ~2 seconds.\n- Inspecting document.body after completion confirms the confetti container is completely removed with zero leftover nodes.\n- Other buttons on the page remain freely clickable during the burst.\n- Under reduced motion, clicking produces zero animations and zero DOM nodes.",
        "dont_do_en": "- Do NOT import a tens-of-KB third-party particle or Canvas library just for a confetti burst.\n- Do NOT use purely random angles without uniform spacing — confetti tends to clump on one side and leave empty gaps on the other.\n- Do NOT interleave `appendChild` and `animate` inside the loop — create and append all nodes first, then start animations together.",
        "skill_rule_en": "# Physics Confetti Cannon (confetti) · Cross-Platform Motion Spec\nNature: Feedback | Layer: fun | Platform: both\n\nCore Principle: Create a pointer-events: none fixed container at the trigger origin (button center or viewport center), spawn 60–90 confetti pieces around a jittered uniform circle, animate them together via WAAPI using a three-keyframe \"launch upward -> spin and fall with fade-out\" trajectory, and automatically destroy the container on completion.\n\nHard Constraints:\n- The container must set pointer-events: none and aria-hidden=\"true\" so it never blocks page clicks.\n- Must include dual-safeguard cleanup leaving 0 residual DOM nodes after playback.\n- Under prefers-reduced-motion: reduce, skip completely (disable the entire layer).\n\nAcceptance Criteria:\n- Clicking the button launches confetti upward from the button's exact center before spinning and drifting down in all directions, vanishing completely within ~2 seconds.\n- Inspecting document.body after completion confirms the confetti container is completely removed with zero leftover nodes.\n- Other buttons on the page remain freely clickable during the burst.\n- Under reduced motion, clicking produces zero animations and zero DOM nodes.\n\nDo NOT Do:\n- Do NOT import a tens-of-KB third-party particle or Canvas library just for a confetti burst.\n- Do NOT use purely random angles without uniform spacing — confetti tends to clump on one side and leave empty gaps on the other.\n- Do NOT interleave `appendChild` and `animate` inside the loop — create and append all nodes first, then start animations together."
      }
    },
    {
      "id": "context-menu",
      "name": "长按上下文菜单",
      "name_en": "Long-Press Context Menu",
      "layer": "mobile",
      "nature": "反馈",
      "platform": "touch",
      "status": "shipped",
      "entry": "v-mk-ctxmenu / contextMenu(el, { items, onSelect, stage, bounds }) / placeMenu()",
      "source": "iOS 14+ 长按上下文菜单（整页下沉 + 背景模糊 + 菜单从指尖长出）",
      "source_en": "iOS 14+ UIContextMenu / Radix ContextMenu (fingertip origin + auto-flip bounds)",
      "file": "effects/context-menu.md",
      "summary": "按住 480ms：整页缩一点、背景糊掉、菜单从指尖那个点撑开；点外部或按 Esc 收起。",
      "summary_en": "Hold 480ms to gently scale down the background stage, blur backdrop, and expand a bounds-clamped menu directly from the fingertip with three-way edge flipping.",
      "problem": "**长按的反馈不能只是\"元素变小\"。** 只有元素自己动，用户读不出\"系统进入了另一种模式\"——\n他会以为那只是一次普通的按下。iOS 的做法是**把整个界面推远**：页面缩 4%、变暗一点、\n背景糊掉，菜单浮在最近的一层。这个\"推远\"才是\"我现在可以对你做更多事\"的信号。\n\n第二个问题是**菜单必须从指尖长出来**。从屏幕中央、或从元素中心弹出的菜单，\n用户要重新找自己的手指在哪儿。从指尖撑开的菜单不需要看就知道\"这是关于我刚按的那一项\"。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 整页 `scale(0.96)` + `brightness(0.92)` | iOS 的原生\"抬起预览\"（长按中的那一层浮起卡片） |\n| 菜单 `transform-origin` 落在指尖 | 原生的触觉波形（Core Haptics 连续微震） |\n| 放不下就**整个翻到另一侧**，不硬塞 | 原生的\"菜单跟着手指微移\"（跟随会让人以为菜单是拖出来的） |\n| 点外部 / Esc / 滚动 关闭 | 原生的\"菜单项可再次长按展开子菜单\" |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 长按阈值 | `480ms` | 和 `long-press` 共用同一个数，见那张卡 |\n| 整页缩放 | `0.96` | iOS 的量级。`0.9` 会读成\"换了一页\"，`0.98` 看不出来 |\n| 整页亮度 | `brightness(0.92)` | 缩放只改变几何，亮度才是\"退到后面一层\"的观感来源。两者要一起 |\n| `transform-origin` | `50% 42%` | 略高于几何中心 —— 菜单通常在手指上方长出来，支点抬高一点缩放才不像\"整体平移\" |\n| 菜单起点 | `scale(0.86)` | 比 1 小 14%。再小会像\"从远处飞入\"，再大看不出\"撑开\" |\n| 指尖与菜单间距 | `6px` | 手指是圆的，贴着会盖住菜单第一行 |\n| 边界留白 | `8px` | 和设备圆角 / 安全区留一点呼吸 |\n| 菜单模糊 | `blur(24px) saturate(180%)` | 比 sheet 的 `blur(2px)` 重得多：sheet 是盖住内容，菜单是浮在内容之上、需要读清自己的字 |\n| 关闭时长 | `--mk-dur-2` = 160ms | 收起要比展开快。展开 160ms 撑开，收起也 160ms 但用 `scale(0.94)` 而不是 0.86 |",
      "implementation": "```\ncontext-menu.js:40    placeMenu(ax, ay, w, h, { pad, gap, bounds })   纯函数：位置 + origin\ncontext-menu.js:83    openMenu({ x, y, items, onSelect, stage, bounds })\ncontext-menu.js:224   contextMenu(el, { items, onSelect, stage })\ntap.js:168            origin = { x: e.clientX, y: e.clientY }   ← 长按回调拿到起手坐标\nmobile.css:574        .mk-ctx-stage    整页缩 + 变暗\nmobile.css:586        .mk-ctx          遮罩（只盖 bounds 那块）\nmobile.css:607        .mk-ctx-menu     菜单本体 + transform-origin 吃两个变量\n```\n\n三件事的分工很干净：\n\n- **坐标**由 `longPress` 在 `pointerdown` 那一刻记下来（回调里读不到事件）；\n- **几何**由 `placeMenu` 纯函数算（可单测，8 条测试）；\n- **形变**全在 CSS，JS 只写 `left/top` 和两个 origin 变量。",
      "degradation": "**走 `mobile.css` 那档：减。**\n\n```css\n@media (prefers-reduced-motion: reduce) {\n  .mk-ctx-stage, .mk-ctx-stage.is-ctx-open {\n    transition-duration: 120ms; transform: none; filter: none;\n  }\n  .mk-ctx-menu { transition-duration: 120ms; }\n  @starting-style { .mk-ctx-menu { transform: none; opacity: 0; } }\n  .mk-ctx.is-closing .mk-ctx-menu { transform: none; }\n}\n```\n\n注意 `filter: none` 也要写：**亮度变化本身也是动效**，只掐 `transform` 会漏掉它。\n\n菜单本体不摘 —— 它是功能（用户要用它执行操作），只是从\"撑开\"变成\"淡入\"。",
      "pitfalls": "**① 菜单的 `left/top` 是相对遮罩的，不是相对视口。**\n\n遮罩已经定位到 `bounds` 左上角（`position: fixed; left: bounds.left; top: bounds.top`），\n所以菜单作为它的子元素，`left` 必须**减掉 `bounds.left`**：\n\n```js\nmenu.style.left = `${at.x - bb.left}px`;   // at 是视口坐标\n```\n\n实测过：直接写 `at.x` 会让菜单整整偏出 `bounds.left` 那么远（设备框在页面里居中时偏了 155px）。\n\n**② 量菜单尺寸必须用 `offsetWidth`，不能用 `getBoundingClientRect()`。**\n\n菜单此刻处在 `@starting-style` 的 `scale(0.86)` 起点上，`rect` 返回的是**缩小后**的尺寸\n（196px 量成 168px）。\"放不下就翻边\"的判定会永远不成立 —— 实测菜单溢出容器右侧 12px，\n翻边从不触发。`offsetWidth/offsetHeight` 读布局尺寸，不受 `transform` 影响。\n\n**③ 遮罩只盖 `bounds`，不是整个视口。**\n\n演示框（`.device`）里打开菜单时，整屏遮罩会把框外面的桌面一起糊掉。传 `bounds` 进来，\n遮罩定位到那块区域，菜单仍然用 `position: fixed` + 视口坐标计算 —— 两者不冲突，\n因为**只借 `bounds` 夹取，不借它定位**。\n\n**④ 菜单打开后，页面一滚就会\"飞\"。**\n\n菜单是按某个视口坐标钉住的。滚动之后指针那一项已经移走，菜单却还在原地。\n在 `document` 捕获阶段挂 `scroll`，任何嵌套滚动容器都能被听见，一滚就关。\n\n**⑤ 长按之后的 click 拦截和\"点菜单项\"是同一个 `document` 捕获监听的两端。**\n\n`longPress` 武装拦截器只拦**下一个** click。用户点菜单项时，那个 click 已经隔了几百毫秒，\n拦截窗口早过期了 —— 所以菜单项能被正常点到。如果拦截窗口做成\"永久武装\"，菜单就点不动了。\n350ms 这个值的另一半意义在这里。\n\n**⑥ 焦点管理不是加分项，是可访问性的下限。**\n\n打开时把焦点放到第一项、Esc 关闭、关闭后焦点回到打开前的元素、`role=\"menu\"` / `role=\"menuitem\"`。\n少这些的话键盘用户完全进不来 —— 而长按本身在键盘上就无法触发，所以更需要一个有替代入口的设计。",
      "ai_assets": {
        "prompt": "实现移动端的「长按上下文菜单」。原生 Pointer Events + CSS，不引依赖。\n\n原理一句话：三件事同时发生 —— 整页缩一点、背景糊掉、菜单从指尖那个点撑开。\n缺任何一件，这个手势就读不出\"进入了另一种模式\"。\n\n结构：\n  <!-- 被推远的那一层 -->\n  <div class=\"stage\"> ...整页内容... </div>\n\n  <!-- 菜单由 JS 动态插入 body -->\n  <div class=\"ctx\" style=\"left/top/width/height = bounds\">\n    <div class=\"ctx-menu\" role=\"menu\" style=\"left;top;--ox;--oy\">\n      <button role=\"menuitem\">分享</button>\n      ...\n    </div>\n  </div>\n\n行为：\n- 在目标元素上按住 480ms 触发（和普通长按同一个阈值）。\n  必须在 pointerdown 那一刻记下 clientX / clientY —— 回调里读不到任何事件。\n- 触发时：\n    1. stage 加 .is-open → transform: scale(0.96); filter: brightness(0.92)，\n       transition 160ms cubic-bezier(0.22, 1, 0.36, 1)，transform-origin: 50% 42%。\n    2. 插入遮罩 + 菜单。遮罩 position: fixed，定位到 bounds（默认整个视口），\n       背景 rgba(0,0,0,0.22)。\n    3. 菜单 position: absolute，背景 rgba(30,36,48,0.92) + backdrop-filter:\n       blur(24px) saturate(180%)，圆角 14px，min-width 196px。\n- 定位算法（纯函数，单独测）：\n    x = 指尖x + 6;  若 x + 菜单宽 > 右边界 → x = 指尖x - 6 - 菜单宽\n    y = 指尖y + 6;  若 y + 菜单高 > 下边界 → y = 指尖y - 6 - 菜单高\n    两者都要 clamp 到 [边界+8, 边界-8-自身尺寸]\n    ox = clamp((指尖x - x) / 菜单宽, 0, 1)   // 0 表示指尖在左边\n    oy = clamp((指尖y - y) / 菜单高, 0, 1)\n    ── 这两个值直接当 transform-origin: calc(ox*100%) calc(oy*100%)\n- 入场：菜单 @starting-style { transform: scale(0.86); opacity: 0 } → scale(1)。\n  只用缩放，不用位移 —— 位移会读成\"从别处飞过来\"，而这里要的是\"从手指底下长出来\"。\n- 关闭：点击菜单外 / 按 Escape / 页面滚动 / 窗口 resize。收起 scale(0.94) + opacity 0，\n  160ms，结束后摘节点。\n- 可访问性：role=\"menu\" / role=\"menuitem\"；打开时焦点到第一项；\n  上下箭头在项间移动；关闭后焦点回到打开前的元素。\n\n硬要求：\n- 遮罩是菜单的定位父级，菜单的 left/top 必须减掉遮罩的偏移（bounds.left / bounds.top）。\n  不减的话菜单会整整偏出一个 bounds 的距离。\n- 量菜单尺寸必须用 offsetWidth / offsetHeight，**不要**用 getBoundingClientRect() ——\n  此刻菜单还在 scale(0.86) 的起点上，rect 返回缩小后的尺寸，翻边判定会全部失效。\n- 滚动监听要挂在 document 的捕获阶段，才能听见任意嵌套滚动容器。\n- 长按触发后要拦掉紧随其后的那一个 click（否则\"长按菜单\"会同时触发详情页），\n  但拦截必须在几百毫秒后自动失效 —— 否则菜单项自己就点不动了。\n\n验收：\n- 在屏幕中部按住 480ms → 整页缩到 0.96、变暗，菜单出现在指尖右下方，间距 6px。\n- 靠右边缘按住 → 菜单翻到指尖左侧，且完全在容器内（不溢出）。\n- 靠近底部按住 → 菜单翻到指尖上方。\n- 右下角同时按住 → 两个方向都翻。\n- 菜单比可用空间还大 → 贴左上边，仍然不出界。\n- 点菜单项 → 回调收到该项并关闭；点外部 / 按 Esc / 滚动 → 关闭。\n- 关闭后 stage 的 transform 恢复 none，焦点回到打开前的元素。\n- 长按后松手不会额外触发目标元素的 click。",
        "dont_do": "- 别用 getBoundingClientRect 量一个正在做 scale 入场的元素。\n- 别在菜单里用 position: absolute 相对 body 定位却按视口坐标算 ——\n  fixed 和 absolute 的参考系不同，混用必偏。\n- 别让遮罩覆盖整个视口后又在里头夹取一个更小的 bounds —— 直接让遮罩就是 bounds。\n- 别给菜单常驻 will-change: transform。\n- 别把长按的 click 拦截设成永久 —— 它会吃掉菜单项的点击。",
        "skill_rule": "# 长按上下文菜单 (context-menu) · 跨平台动效规范\n性质：反馈 ｜ 平台：touch\n\n【核心原理】三件事同时发生 —— 整页缩一点、背景糊掉、菜单从指尖那个点撑开。\n\n【硬要求】\n- 遮罩是菜单的定位父级，菜单的 left/top 必须减掉遮罩的偏移（bounds.left / bounds.top）。\n  不减的话菜单会整整偏出一个 bounds 的距离。\n- 量菜单尺寸必须用 offsetWidth / offsetHeight，**不要**用 getBoundingClientRect() ——\n  此刻菜单还在 scale(0.86) 的起点上，rect 返回缩小后的尺寸，翻边判定会全部失效。\n- 滚动监听要挂在 document 的捕获阶段，才能听见任意嵌套滚动容器。\n- 长按触发后要拦掉紧随其后的那一个 click（否则\"长按菜单\"会同时触发详情页），\n  但拦截必须在几百毫秒后自动失效 —— 否则菜单项自己就点不动了。\n\n【验收标准】\n- 在屏幕中部按住 480ms → 整页缩到 0.96、变暗，菜单出现在指尖右下方，间距 6px。\n- 靠右边缘按住 → 菜单翻到指尖左侧，且完全在容器内（不溢出）。\n- 靠近底部按住 → 菜单翻到指尖上方。\n- 右下角同时按住 → 两个方向都翻。\n- 菜单比可用空间还大 → 贴左上边，仍然不出界。\n- 点菜单项 → 回调收到该项并关闭；点外部 / 按 Esc / 滚动 → 关闭。\n- 关闭后 stage 的 transform 恢复 none，焦点回到打开前的元素。\n- 长按后松手不会额外触发目标元素的 click。\n\n【禁止做法】\n- 别用 getBoundingClientRect 量一个正在做 scale 入场的元素。\n- 别在菜单里用 position: absolute 相对 body 定位却按视口坐标算 ——\n  fixed 和 absolute 的参考系不同，混用必偏。\n- 别让遮罩覆盖整个视口后又在里头夹取一个更小的 bounds —— 直接让遮罩就是 bounds。\n- 别给菜单常驻 will-change: transform。\n- 别把长按的 click 拦截设成永久 —— 它会吃掉菜单项的点击。",
        "prompt_en": "Implement a mobile long-press context menu using native Pointer Events + CSS, zero dependencies.\n\nCore Principle: Three things happen simultaneously — the entire page scales down slightly, the background blurs/dims, and the menu expands from the exact fingertip point. Missing any one prevents the gesture from reading as \"entered another mode.\"\n\n  <!-- Background stage pushed away -->\n  <div class=\"stage\"> ...page content... </div>\n\n  <!-- Menu dynamically inserted into body by JS -->\n  <div class=\"ctx\" style=\"left/top/width/height = bounds\">\n    <div class=\"ctx-menu\" role=\"menu\" style=\"left;top;--ox;--oy\">\n      <button role=\"menuitem\">Share</button>\n      ...\n    </div>\n  </div>\n\nImplementation:\n- Trigger after holding on the target element for 480ms (same threshold as standard long-press). Must record clientX / clientY at the moment of pointerdown — no event is available inside the timer callback.\n- On trigger:\n    1. Add .is-open to stage -> transform: scale(0.96); filter: brightness(0.92), transition 160ms cubic-bezier(0.22, 1, 0.36, 1), transform-origin: 50% 42%.\n    2. Insert backdrop + menu. Backdrop is position: fixed, sized/positioned to bounds (defaults to full viewport), background rgba(0,0,0,0.22).\n    3. Menu is position: absolute, background rgba(30,36,48,0.92) + backdrop-filter: blur(24px) saturate(180%), border-radius 14px, min-width 196px.\n- Positioning algorithm (pure function, tested independently):\n    x = fingerX + 6; if x + menuWidth > rightBound -> x = fingerX - 6 - menuWidth\n    y = fingerY + 6; if y + menuHeight > bottomBound -> y = fingerY - 6 - menuHeight\n    Clamp both to [bound + 8, bound - 8 - ownSize]\n    ox = clamp((fingerX - x) / menuWidth, 0, 1)   // 0 means fingertip is on the left\n    oy = clamp((fingerY - y) / menuHeight, 0, 1)\n    -- Apply both directly as transform-origin: calc(ox*100%) calc(oy*100%)\n- Entrance: menu @starting-style { transform: scale(0.86); opacity: 0 } -> scale(1). Use scale only, never translation — translation reads as \"flying in from elsewhere,\" whereas this must feel like \"growing out from under the finger.\"\n- Dismissal: click outside menu / press Escape / page scroll / window resize. Close with scale(0.94) + opacity 0 over 160ms, then remove nodes when done.\n- Accessibility: role=\"menu\" / role=\"menuitem\"; move focus to the first item on open; Up/Down arrows navigate items; restore focus to the trigger element on close.\n\nHard Constraints:\n- The backdrop is the menu's positioning parent, so the menu's left/top must subtract the backdrop's offset (bounds.left / bounds.top); otherwise the menu shifts by an entire bounds offset.\n- Measure menu dimensions with offsetWidth / offsetHeight, NEVER getBoundingClientRect() — at that moment the menu is at its scale(0.86) starting state, so rect returns scaled-down dimensions and breaks edge-flipping math.\n- Attach the scroll listener to document in the capture phase so any nested scroll container is heard.\n- After long-press triggers, suppress the immediately following click (otherwise opening the context menu also activates the detail view), but auto-expire the suppression after a few hundred milliseconds — otherwise menu items themselves cannot be clicked.\n\nAcceptance Criteria:\n- Hold 480ms in the center of the screen -> page scales to 0.96 and dims; menu appears to the bottom-right of the fingertip with a 6px gap.\n- Hold near the right edge -> menu flips to the left of the fingertip and stays completely inside the container (no overflow).\n- Hold near the bottom edge -> menu flips above the fingertip.\n- Hold in the bottom-right corner -> flips on both axes.\n- Menu larger than available space -> pins to top-left bound and still never overflows.\n- Click a menu item -> callback receives that item and closes; click outside / press Esc / scroll -> closes.\n- After closing, stage transform resets to none and focus returns to the pre-open element.\n- Releasing after long-press triggers no extra click on the target element.",
        "dont_do_en": "- Do NOT use `getBoundingClientRect()` to measure an element currently running a `scale` entrance animation.\n- Do NOT position the menu with `position: absolute` relative to `body` while computing coordinates in viewport space — `fixed` and `absolute` use different coordinate frames and will always misalign.\n- Do NOT make the backdrop cover the entire viewport while clamping to a smaller inner `bounds` — size the backdrop directly to `bounds`.\n- Do NOT leave `will-change: transform` permanently on the menu.\n- Do NOT make the long-press `click` suppression permanent — it will swallow clicks on the menu items themselves.",
        "skill_rule_en": "# Long-Press Context Menu (context-menu) · Cross-Platform Motion Spec\nNature: Feedback | Layer: mobile | Platform: touch\n\nCore Principle: Three things happen simultaneously — the entire page scales down slightly, the background blurs/dims, and the menu expands from the exact fingertip point. Missing any one prevents the gesture from reading as \"entered another mode.\"\n\nHard Constraints:\n- The backdrop is the menu's positioning parent, so the menu's left/top must subtract the backdrop's offset (bounds.left / bounds.top); otherwise the menu shifts by an entire bounds offset.\n- Measure menu dimensions with offsetWidth / offsetHeight, NEVER getBoundingClientRect() — at that moment the menu is at its scale(0.86) starting state, so rect returns scaled-down dimensions and breaks edge-flipping math.\n- Attach the scroll listener to document in the capture phase so any nested scroll container is heard.\n- After long-press triggers, suppress the immediately following click (otherwise opening the context menu also activates the detail view), but auto-expire the suppression after a few hundred milliseconds — otherwise menu items themselves cannot be clicked.\n\nAcceptance Criteria:\n- Hold 480ms in the center of the screen -> page scales to 0.96 and dims; menu appears to the bottom-right of the fingertip with a 6px gap.\n- Hold near the right edge -> menu flips to the left of the fingertip and stays completely inside the container (no overflow).\n- Hold near the bottom edge -> menu flips above the fingertip.\n- Hold in the bottom-right corner -> flips on both axes.\n- Menu larger than available space -> pins to top-left bound and still never overflows.\n- Click a menu item -> callback receives that item and closes; click outside / press Esc / scroll -> closes.\n- After closing, stage transform resets to none and focus returns to the pre-open element.\n- Releasing after long-press triggers no extra click on the target element.\n\nDo NOT Do:\n- Do NOT use `getBoundingClientRect()` to measure an element currently running a `scale` entrance animation.\n- Do NOT position the menu with `position: absolute` relative to `body` while computing coordinates in viewport space — `fixed` and `absolute` use different coordinate frames and will always misalign.\n- Do NOT make the backdrop cover the entire viewport while clamping to a smaller inner `bounds` — size the backdrop directly to `bounds`.\n- Do NOT leave `will-change: transform` permanently on the menu.\n- Do NOT make the long-press `click` suppression permanent — it will swallow clicks on the menu items themselves."
      }
    },
    {
      "id": "count-up",
      "name": "数字滚动 / 里程表",
      "name_en": "Number Count-Up & Odometer",
      "layer": "motion",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-count（`{ to, odometer }`）/ countUp({ from, to, duration, format }) / odometer(el, value)",
      "source": "大屏看板与营销页的数字登场（count-up.js）+ 机场翻牌/里程表的\"每位一列\"",
      "source_en": "Stripe / Apple metrics (rAF count-up + CSS 0–9 column odometer)",
      "file": "effects/count-up.md",
      "summary": "两条路：`countUp` 用 rAF 逐帧算值（通用、可格式化）；`odometer` 给每位数\n建一列 0–9，只写一次 transform、由 CSS 过渡滑到位（几十个数字同屏也不掉帧）。",
      "summary_en": "Two zero-dep modes: smooth rAF formatted count-up for single hero KPIs, and CSS translateY digit-column odometer for dozens of simultaneous live metrics.",
      "problem": "**数字的变化幅度本身就是信息。** 余额从 0 滚到 12,800，用户读到的不是\n\"一个数字\"，而是\"这个数不小\"；金额更新时只换末两位，读出来的是\"变化很小\"。\n硬切让变化被抹平——用户的眼睛跟不上一次 5 位数→6 位数的瞬间替换。\n\n第二个问题：**数字跳动的布局必须稳定。** 数字变宽会把右边的排版推来推去，\n`tabular-nums`（等宽数字）是这条效果能成立的前提，不是美化。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| `easeOutCubic`：先快后慢，像\"停下来\"而不是\"匀速跑完\" | 数字过大时的物理滚轮感（那种要 2 秒以上）——超过 900ms 用户已经在等它了 |\n| 末帧直接落**精确值**，不许浮点误差留下 99.9987 | countUp 的中间格式化精细控制（只有 format 回调一个口子） |\n| 里程表每位一列 0–9，`translateY(-N em)` 只写一次 | 数字增减的方向感（金额 +100 和 -100 转向相同）——需要方向时在 format 里自己加符号动画 |\n| 9→0 的回绕：每列建 11 格（0–9 + 一个 0） | 负数滚动的方向处理（按字符串处理，负号是静态占位） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| countUp 时长 | 900ms | 数字是从 0 滚到目标的\"陈述\"，比微交互长、比整页进场短。大额（亿级）可到 1.4s，再长就是拖延 |\n| easeOutCubic | `1 - (1-t)³` | 前三分之一走完约 63% 的行程——数字大部分的\"变化感\"集中在前段，尾段是\"确认\" |\n| 里程表过渡 | `--mk-dur-5` = 560ms ease-out | 每列滑动的节奏必须**慢于 countUp 的平均速度**，否则翻牌快过读数 |\n| 列高 | 1em（`line-height: 1`） | `translateY(-N em)` 的单位是 em——行高不是 1em 的话每位会错位半个像素，滚得越久错得越明显 |\n| 小程序节流 | 60ms（≈16fps） | 肉眼无差，`setData` 次数少一个数量级（README 第 8 条） |",
      "implementation": "```\ncount-up.js:24  countUp({ from, to, duration, format, reduced }, onUpdate)\n                 → { cancel, promise }   promise 用于串后续动作\ncount-up.js:67  formatNumber(v, { decimals, thousands, prefix, suffix })\ncount-up.js:82  odometer(el, value, { decimals, reduced })  → { update(next) }\nmotion.css:233  .mk-num         tabular-nums（防止跳动）\nmotion.css:766  .mk-odometer 系列\n```\n\n两条路怎么选：\n\n- **值会连续变化**（实时数据、倒计时）→ `countUp`，每帧拿到格式化后的字符串。\n- **值是离散跳变**（报表刷新、里程表）→ `odometer`，`update(next)` 就地滑动，\n  **不逐帧重绘**——一屏几十个数字时它是唯一不卡的选择。\n\n里程表的列结构：\n\n```\n每个数字位 → 一列 span（0,1,…,9,0），共 11 格\ntransform: translateY(-digit em) —— \"0 那格回绕在末尾\"是 9→0 往下滑的关键\n非数字字符（小数点/逗号/负号）→ 静态占位，不参与滚动\n```",
      "degradation": "**走 `motion` 那档：减，且减法做得最彻底——直接落终值。**\n\n`resolveReduced()` 为真时 `countUp` 不启动 rAF，第一帧就 `onUpdate(to)`；\n`odometer` 的 `run()` 把每列的 transition 置 `none`，数字直接出现在目标位。\n理由：数字的价值是**数值本身**，滚动是表达；而且倒计时/余额这类场景里\n\"慢慢滚出来\"对读屏用户和认知障碍用户是**纯噪声**。\n`promise` 在 reduced 下立即 resolve——使用方的后续逻辑不会卡住。",
      "pitfalls": "**① 末帧必须落精确值。**\n`from + (to-from) * easeOutCubic(p)` 在 p=0.9999 时是 99.9987——\n如果 format 里四舍五入，显示是 100，但如果 `format` 不取整（金额两位小数），\n最后一帧就是 99.9987。所以代码里 `p === 1 ? format(to) : format(v)` 分了叉。\n少这一行，十次里有一次尾部闪一个错值。\n\n**② 里程表重建会让新列从 0 滑到目标位——看起来像\"倒转\"。**\n列的 transform 过渡是 CSS 类驱动的：新插入的节点初始 transform 是 0\n（第 0 格），写入 `-3em` 后 CSS 会**滑过去**。所以重建期间必须先加\n`.is-static`（transition: none），挂载后下一帧再摘——README 第 9 条的\n\"重建瞬间加 `.is-static`\" 就是这个。**挂载后那个 `requestAnimationFrame`\n也不能省**：同一帧写入 transform 又摘掉静态类，过渡又会生效。\n\n**③ 位数变了就整列重建，没有平滑路径。**\n`update(next)` 只处理**等长**变化；位数变了直接递归重建。\n使用方要先给一个等长占位（比如 `\"0000.00\"`）起步，让首次滚动有动画，\n后续增量更新才走得通。这是刻意的取舍：逐位插入/删除的 FLIP 复杂度\n对这条效果的价值不成比例。\n\n**④ `formatNumber` 的千分位正则只处理整数部分。**\n`int.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')` 在小数拆分之后才跑，\n所以 `\"1,234.56\"` 是对的；但**负号**在 `int` 里，`-1234` 会被格式化成\n`-1,234`——没错。真正会错的是传入已经是字符串的数字\n（`\"1234567\"` 会被重新分割），**这条函数只接受 number**。\n\n**⑤ 里程表的 `em` 依赖元素自身的 font-size。**\n`translateY(-3em)` 的 em 是**列元素**的字号。如果某一位被包在更小的\n`<small>` 里（金额的小数部分常见），那一列的高度就不是 1em，滚动会错位。\n**整条 odometer 内字号必须统一**，小数位变小是排版的活，别做进列里。\n\n**⑥ 小程序端的节流在适配层，不在核心。**\n`countUp` 每帧回调一次 `onUpdate`——Web 上这是对的；\nTaro 的 `setData` 每次都是序列化+通信，60fps 会把通信线程打满。\n所以小程序适配层把回调节流到 60ms。**这不是核心能感知的事**——\n如果有人把节流搬进核心，Web 端的流畅反而会被砍。\n\n---",
      "ai_assets": {
        "prompt": "实现两条数字动画，同一文件里二选一。\n\n原理一句话：数值插值。两种做法二选一 —— 每帧算一个数并重绘文字，或只写一次 transform 让合成器补齐。前者通用，后者能扛几十个同时跳。\n\nA. countUp（逐帧计算，通用）：\n- easeOutCubic：v = from + (to-from) * (1 - Math.pow(1-t, 3))，t = 已过时长/总时长。\n- 时长 900ms，rAF 驱动。\n- 每帧回调 onUpdate(格式化后的字符串)；格式化交给调用方传 format。\n- 最后一帧必须直接写 format(to)（精确值），不许让浮点误差显示成 99.9987。\n- 返回 { cancel, promise }：cancel 停帧并 resolve；promise 在完成后 resolve，\n  调用方用来串后续动作。\n- prefers-reduced-motion：不启动 rAF，第一帧直接 onUpdate(最终值)，\n  promise 立即 resolve。\n\nB. odometer（翻牌列，高性能）：\n- 把值转成字符串，每个字符一列；数字位建一列 0-9 再补一个回绕的 0（共 11 格），\n  transform: translateY(-digit em)；小数点/逗号/负号是静态占位不滚动。\n- 只写一次 transform，滑动交给 CSS transition（560ms ease-out）。\n- 容器 height: 1em、line-height: 1、每个格子 flex-basis: 1em ——\n  em 单位要求整条内 font-size 统一。\n- 重建/挂载时先加 .static（transition: none），下一帧再摘 ——\n  否则新列会从 0 滑到目标位，看起来像在倒转。\n- update(next)：字符串长度不变 → 就地改各列 transform；\n  长度变了 → 整体重建（调用方应先用等长占位起步）。\n- prefers-reduced-motion：transition 恒为 none。\n\n格式化（两路共用）：\n- 千分位 + 小数位 + 前后缀；只接受 number 入参。\n- 所有数字展示必须 tabular-nums（font-variant-numeric），\n  否则变宽会把右边排版推来推去。\n\n硬要求：\n- 两条路都不做增减方向动画（+绿/-红）；那是调用方的展示层。\n- Web 端每帧回调；小程序/Taro 端的节流放在适配层，核心不感知平台。\n- reduced 下两条路都要立即呈现终值。\n\n验收：\n- countUp 到 100：最后一帧显示值恰好是 format(to)，无 99.9987。\n- odometer 从 9 滚到 0：该位向下顺滑回绕，不向上倒转。\n- 同屏 40 个 odometer 同时 update：无掉帧（rAF 期间无额外 DOM 写入）。\n- reduced：数字直接出现，无任何动画帧。\n- 金额 1234567.891，decimals 2 → \"1,234,567.89\"。",
        "dont_do": "- 别在 format 里做副作用（写 DOM、发请求）——它每帧被调，副作用会被放大 60 倍。\n- 别给 countUp 用弹簧/过冲——数字\"超过目标再回来\"读起来是显示错误，\n  过冲留给 `detent` 那类物理控件。\n- 别把 odometer 的列数做成响应式重建——位数变化才重建，\n  每次 update 都重建等于放弃了它\"只写一次 transform\"的全部优势。",
        "skill_rule": "# 数字滚动 / 里程表 (count-up) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】数值插值。两种做法二选一 —— 每帧算一个数并重绘文字，或只写一次 transform 让合成器补齐。前者通用，后者能扛几十个同时跳。\n\n【硬要求】\n- 两条路都不做增减方向动画（+绿/-红）；那是调用方的展示层。\n- Web 端每帧回调；小程序/Taro 端的节流放在适配层，核心不感知平台。\n- reduced 下两条路都要立即呈现终值。\n\n【验收标准】\n- countUp 到 100：最后一帧显示值恰好是 format(to)，无 99.9987。\n- odometer 从 9 滚到 0：该位向下顺滑回绕，不向上倒转。\n- 同屏 40 个 odometer 同时 update：无掉帧（rAF 期间无额外 DOM 写入）。\n- reduced：数字直接出现，无任何动画帧。\n- 金额 1234567.891，decimals 2 → \"1,234,567.89\"。\n\n【禁止做法】\n- 别在 format 里做副作用（写 DOM、发请求）——它每帧被调，副作用会被放大 60 倍。\n- 别给 countUp 用弹簧/过冲——数字\"超过目标再回来\"读起来是显示错误，\n  过冲留给 `detent` 那类物理控件。\n- 别把 odometer 的列数做成响应式重建——位数变化才重建，\n  每次 update 都重建等于放弃了它\"只写一次 transform\"的全部优势。",
        "prompt_en": "Implement two numeric animation strategies in the same module (pick one per use case).\n\nCore Principle: Numeric interpolation via two selectable approaches — computing a value and updating text every frame, or writing transform once and letting the compositor finish the glide. The former is general-purpose; the latter handles dozens of simultaneous counters.\n\nImplementation:\nA. countUp (per-frame calculation, general-purpose):\n- easeOutCubic: v = from + (to - from) * (1 - Math.pow(1 - t, 3)), where t = elapsed / duration.\n- Duration 900ms, driven by rAF.\n- Invoke onUpdate(formattedString) every frame; formatting is supplied by the caller via format.\n- The final frame must write format(to) directly (exact value); floating-point drift must never display 99.9987.\n- Return { cancel, promise }: cancel stops frames and resolves; promise resolves upon completion so callers can chain subsequent actions.\n- prefers-reduced-motion: do not start rAF; invoke onUpdate(finalValue) immediately on frame 1 and resolve promise right away.\n\nB. odometer (rolling digit columns, high performance):\n- Convert value to string, one column per character; each digit slot builds a column of 0-9 plus a wrapping 0 (11 cells total), positioned with transform: translateY(-digit em); decimal points, commas, and minus signs are static non-scrolling slots.\n- Write transform once and let CSS transition (560ms ease-out) handle the slide.\n- Container height: 1em, line-height: 1, each cell flex-basis: 1em — em units require a uniform font-size across the entire strip.\n- On rebuild/mount, apply .static (transition: none) first and remove it on the next frame — otherwise new columns slide from 0 to target and look like they are spinning backward.\n- update(next): if string length is unchanged -> update column transforms in place; if length changed -> rebuild the whole strip (callers should initialize with equal-length placeholders).\n- prefers-reduced-motion: transition is always none.\n\nFormatting (shared by both):\n- Thousands separators + decimal places + prefix/suffix; accept number input only.\n- All numeric displays must use font-variant-numeric: tabular-nums, otherwise variable digit widths jostle layout to the right.\n\nHard Constraints:\n- Neither mode animates increase/decrease color direction (+green/-red); that belongs to the caller's presentation layer.\n- Web invokes the callback every frame; throttling for mini-programs/Taro belongs in the adapter layer, keeping the core platform-agnostic.\n- Under prefers-reduced-motion: reduce, both modes must render the final value immediately.\n\nAcceptance Criteria:\n- countUp to 100: final frame displays exact format(to), never 99.9987.\n- odometer rolling from 9 to 0: that digit wraps smoothly downward rather than reversing upward.\n- 40 simultaneous odometer updates on screen: zero dropped frames (no extra DOM writes during rAF).\n- Reduced motion: numbers appear immediately with zero animation frames.\n- Amount 1234567.891 with decimals 2 -> \"1,234,567.89\".",
        "dont_do_en": "- Do NOT perform side effects (DOM writes, network requests) inside `format` — it runs every frame, amplifying side effects 60×.\n- Do NOT use spring/overshoot easing on `countUp` — numbers overshooting past the target and bouncing back read as a display bug; save overshoot for physical controls like `detent`.\n- Do NOT rebuild `odometer` columns on every update — rebuild only when digit count changes; rebuilding on every `update` throws away the entire benefit of writing `transform` once.",
        "skill_rule_en": "# Number Count-Up & Odometer (count-up) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: motion | Platform: both\n\nCore Principle: Numeric interpolation via two selectable approaches — computing a value and updating text every frame, or writing transform once and letting the compositor finish the glide. The former is general-purpose; the latter handles dozens of simultaneous counters.\n\nHard Constraints:\n- Neither mode animates increase/decrease color direction (+green/-red); that belongs to the caller's presentation layer.\n- Web invokes the callback every frame; throttling for mini-programs/Taro belongs in the adapter layer, keeping the core platform-agnostic.\n- Under prefers-reduced-motion: reduce, both modes must render the final value immediately.\n\nAcceptance Criteria:\n- countUp to 100: final frame displays exact format(to), never 99.9987.\n- odometer rolling from 9 to 0: that digit wraps smoothly downward rather than reversing upward.\n- 40 simultaneous odometer updates on screen: zero dropped frames (no extra DOM writes during rAF).\n- Reduced motion: numbers appear immediately with zero animation frames.\n- Amount 1234567.891 with decimals 2 -> \"1,234,567.89\".\n\nDo NOT Do:\n- Do NOT perform side effects (DOM writes, network requests) inside `format` — it runs every frame, amplifying side effects 60×.\n- Do NOT use spring/overshoot easing on `countUp` — numbers overshooting past the target and bouncing back read as a display bug; save overshoot for physical controls like `detent`.\n- Do NOT rebuild `odometer` columns on every update — rebuild only when digit count changes; rebuilding on every `update` throws away the entire benefit of writing `transform` once."
      }
    },
    {
      "id": "coverflow",
      "name": "3D 封面流画廊",
      "name_en": "3D Cover Flow Gallery",
      "layer": "3d",
      "nature": "方向",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.coverflow(el, { active }) + .mk-coverflow / .mk-coverflow__item",
      "source": "Apple iTunes / macOS Cover Flow（纯函数相对下标偏移算 3D 姿态 + 点击/拖拽/键盘三端统一驱动）",
      "source_en": "Apple iTunes / macOS Cover Flow (pure offset pose + click/drag/keyboard)",
      "file": "effects/coverflow.md",
      "summary": "居中封面正对观众且沿 Z 轴微向前凸出，左右两侧封面以对称 `±42°` 斜切退后叠排；点任意侧卡、左右滑或按方向键，整排封面丝滑滑切并自动更新层次。",
      "summary_en": "Classic Apple Cover Flow computed from a single relative-offset pure function: centered focal card forward in Z, side cards symmetrically angled ±42° with click, drag, and arrow keys.",
      "problem": "**普通横向轮播（Carousel）只平推 X 轴，缺少焦点主次与纵深层次；但手写 3D 封面流常把每张卡的像素位移硬编码在多套 CSS class 里，一增减卡片数量就错位，或 `z-index` 叠错导致侧卡盖住中心卡。** 把任意下标相对中心焦点的偏移量 `offset = i - active` 放进一个纯函数算出 `(x, z, ry, scale, opacity, zIndex)`，任意张数卡片都能严丝合缝地自动排布。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 中心卡正向凸出（`z: +54px, ry: 0°`），左右侧卡对称斜切退入纵深（`ry: ∓42°`） | 所有卡站在同一 Z 平面只靠缩放假装景深 |\n| 点击侧卡、横向轻拖（`> 36px`）与 `ArrowLeft / ArrowRight` 三种入口走同一个 `select(idx)` | 只支持点按钮不支持直接点侧卡或手滑 |\n| `grid-area: 1 / 1` 同格叠放 + 仅动画 `transform` 与 `opacity` | 靠改 `left` / `margin` 排版触发布局重排 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 舞台透视 `perspective` | `820px` | 既让两侧 `±42°` 卡片呈现明显梯形近大远小，又不会像 `300px` 那样边缘严重畸变 |\n| 中心卡与首张侧卡间距 | `x = ±76px`，后续每级 `+44px` | 首张侧卡留出清晰呼吸缝不压住中心焦点，更远的卡片渐密叠加成书架纵深 |\n| 侧卡偏转角 `ry` | 左侧 `+42deg`，右侧 `-42deg` | 正好朝向中心焦点内扣，建立“左右包裹中央”的舞台聚焦感 |\n| 拖拽翻页阈值 | `Math.abs(dx) > 36px` | 轻扫一指即可切页，同时避免点击侧卡时手指微小抖动误触发翻页 |",
      "implementation": "```\nsrc/core/scene3d.js:292   coverflowPose(offset)            纯函数，根据相对偏移算 x/z/ry/scale/opacity/zIndex\nsrc/core/scene3d.js:312   coverflow(el, { active, onChange }) 统一处理点击、拖拽与键盘方向键，仅写 CSS 变量\nstyles/3d.css:515         .mk-coverflow / .mk-coverflow__item 透视舞台、合成层过渡与减弱动效横排降级\n```",
      "degradation": "**走 `3d` 层专属契约：归零塌回平面横向滚动列表。**\n\n`prefers-reduced-motion: reduce` 下取消 `perspective` 与全部 3D `transform`（`transform: none; opacity: 1; transition: none`），容器切换为 `display: flex; overflow-x: auto`，确保所有卡片完整可读且依然可点选，绝不叠成一摞。",
      "pitfalls": "**① 两侧卡片旋转符号写反，变成背向观众外翻。**\n`offset < 0`（在中心左边）的卡片应当绕 Y 轴正向旋转 `+42deg` 面向中心，`offset > 0`（在中心右边）旋转 `-42deg`，即 `ry = -Math.sign(offset) * 42`。\n\n**② 忘了按距离递减 `zIndex` 导致靠后的 DOM 节点盖住中心焦点卡。**\n即使中心卡 `translateZ(+54px)` 在前，部分浏览器在混合层叠上下文下仍以 DOM 顺序优先命中点击与渲染；必须同步写入 `zIndex = 100 - abs(offset) * 10`。\n\n**③ 给容器写了 `touch-action: none` 锁死手机页面上下滚动。**\n封面流只需要横向轻扫，容器必须设 `touch-action: pan-y` 把纵向滚动留给页面。\n\n---",
      "ai_assets": {
        "prompt": "实现零依赖的 3D 封面流画廊（Cover Flow 3D Gallery）。\n\n原理一句话：所有卡片同格叠放在带 perspective: 820px 的舞台中，用纯函数按相对中心下标的偏移量 offset = i - active 算出 (x, z, ry, scale, opacity, zIndex) 写入 CSS 变量，点击侧卡、横向轻拖或按左右方向键共用同一切换入口。\n\n做法：\n1. 纯函数 coverflowPose(offset)：\n   - offset === 0（中心焦点）：{ x: 0, z: 54, ry: 0, scale: 1, opacity: 1, zIndex: 100 }。\n   - offset !== 0：s = offset < 0 ? -1 : 1，a = Math.abs(offset)；\n     x = s * (76 + (a - 1) * 44)；\n     z = -(38 + a * 34)；\n     ry = -s * 42（左卡 +42deg、右卡 -42deg，向中心内扣）；\n     scale = Math.max(0.68, 0.86 - (a - 1) * 0.08)；\n     opacity = Math.max(0, 1 - a * 0.24)；\n     zIndex = Math.max(1, 100 - Math.round(a * 10))。\n2. CSS 结构与合成层过渡：\n   - 舞台容器：perspective: 820px; display: grid; place-items: center; touch-action: pan-y; user-select: none;\n   - 每张卡片：grid-area: 1 / 1; transform: translate3d(var(--cf-x), 0, var(--cf-z)) rotateY(var(--cf-ry)) scale(var(--cf-s)); opacity: var(--cf-o);\n   - 过渡仅放 transform（420ms cubic-bezier(0.22, 1, 0.36, 1)）与 opacity（360ms ease-out），中心态加亮边框与投影。\n3. 三端交互统一入口 select(idx)：\n   - 点击任意卡片直接 select(i)；\n   - pointerdown 记录 startX，pointerup 若 |dx| > 36 则向左/右切换一格；pointercancel 重置拖拽态；\n   - 容器设 tabindex=\"0\"，监听 ArrowLeft / ArrowRight 切换。\n4. 降级：\n   - prefers-reduced-motion: reduce 下舞台改为 display: flex; gap: 8px; overflow-x: auto; perspective: none; 所有卡片 transform: none; opacity: 1; transition: none; 完整横排可读。\n\n硬要求：\n- 必须同时写入 zIndex 与 translateZ，确保中心卡在渲染与点击命中上永远压在最上方。\n- 严禁动画 left / top / width / margin，所有位移动画必须走 transform 与 opacity。\n- 必须保留 touch-action: pan-y，不能阻止移动页面纵向滚动。\n\n验收：\n- 初始中心卡正对突出，左右侧卡对称内扣 42° 依次隐入纵深，无遮挡错层。\n- 点击任意侧卡、横向拖拽 >36px 或聚焦后按左右方向键，均平滑切换焦点并触发 onChange。\n- 开启减弱动效后自动退化为无动画横排列表，卡片不重叠。",
        "dont_do": "- 别把左右侧卡的 `rotateY` 符号写反 —— 外翻的卡片会彻底破坏焦点包裹感。\n- 别只靠 `translateZ` 不设 `z-index` —— 后面的 DOM 卡片在 Safari/部分 GPU 合成下会抢走中心卡的点击事件。\n- 别在 `prefers-reduced-motion` 下只关 `transform` 而不把 `grid-area: 1/1` 改为 `flex` 横排 —— 所有封面会糊成一摞。",
        "skill_rule": "# 3D 封面流画廊 (coverflow) · 跨平台动效规范\n性质：方向 ｜ 平台：both\n\n【核心原理】所有卡片同格叠放在带 perspective: 820px 的舞台中，用纯函数按相对中心下标的偏移量 offset = i - active 算出 (x, z, ry, scale, opacity, zIndex) 写入 CSS 变量，点击侧卡、横向轻拖或按左右方向键共用同一切换入口。\n\n【硬要求】\n- 必须同时写入 zIndex 与 translateZ，确保中心卡在渲染与点击命中上永远压在最上方。\n- 严禁动画 left / top / width / margin，所有位移动画必须走 transform 与 opacity。\n- 必须保留 touch-action: pan-y，不能阻止移动页面纵向滚动。\n\n【验收标准】\n- 初始中心卡正对突出，左右侧卡对称内扣 42° 依次隐入纵深，无遮挡错层。\n- 点击任意侧卡、横向拖拽 >36px 或聚焦后按左右方向键，均平滑切换焦点并触发 onChange。\n- 开启减弱动效后自动退化为无动画横排列表，卡片不重叠。\n\n【禁止做法】\n- 别把左右侧卡的 `rotateY` 符号写反 —— 外翻的卡片会彻底破坏焦点包裹感。\n- 别只靠 `translateZ` 不设 `z-index` —— 后面的 DOM 卡片在 Safari/部分 GPU 合成下会抢走中心卡的点击事件。\n- 别在 `prefers-reduced-motion` 下只关 `transform` 而不把 `grid-area: 1/1` 改为 `flex` 横排 —— 所有封面会糊成一摞。",
        "prompt_en": "Implement a zero-dependency 3D Cover Flow gallery (Cover Flow 3D Gallery).\n\nCore Principle: Stack all cards in the same grid cell inside a stage with perspective: 820px, compute (x, z, ry, scale, opacity, zIndex) from each card's signed center-relative offset = i - active via a pure function into CSS variables, and route side-card clicks, horizontal drags, and left/right arrow keys through one unified entry point.\n\nImplementation:\n1. Pure function coverflowPose(offset):\n   - offset === 0 (center focus): { x: 0, z: 54, ry: 0, scale: 1, opacity: 1, zIndex: 100 }.\n   - offset !== 0: s = offset < 0 ? -1 : 1, a = Math.abs(offset);\n     x = s * (76 + (a - 1) * 44);\n     z = -(38 + a * 34);\n     ry = -s * 42 (left cards +42deg, right cards -42deg, angled inward toward center);\n     scale = Math.max(0.68, 0.86 - (a - 1) * 0.08);\n     opacity = Math.max(0, 1 - a * 0.24);\n     zIndex = Math.max(1, 100 - Math.round(a * 10)).\n2. CSS structure and compositor transitions:\n   - Stage container: perspective: 820px; display: grid; place-items: center; touch-action: pan-y; user-select: none;\n   - Each card: grid-area: 1 / 1; transform: translate3d(var(--cf-x), 0, var(--cf-z)) rotateY(var(--cf-ry)) scale(var(--cf-s)); opacity: var(--cf-o);\n   - Transition only transform (420ms cubic-bezier(0.22, 1, 0.36, 1)) and opacity (360ms ease-out), highlighting the center card with an accented border and shadow.\n3. Unified interaction entry select(idx):\n   - Clicking any card calls select(i) directly;\n   - pointerdown records startX; pointerup steps left/right by one if |dx| > 36; pointercancel resets drag state;\n   - Set tabindex=\"0\" on the container and listen for ArrowLeft / ArrowRight.\n4. Reduced motion:\n   - Under prefers-reduced-motion: reduce, switch stage to display: flex; gap: 8px; overflow-x: auto; perspective: none; and set all cards to transform: none; opacity: 1; transition: none; for a fully readable horizontal row.\n\nHard Constraints:\n- Must write both zIndex and translateZ so the center card always stays on top for both rendering and click hit-testing.\n- Never animate left / top / width / margin; all positional transitions must use transform and opacity.\n- Must preserve touch-action: pan-y so vertical scrolling on mobile pages is not blocked.\n\nAcceptance Criteria:\n- The initial center card faces forward prominently while left and right cards tilt inward symmetrically at 42° receding into depth without clipping or Z-fighting.\n- Clicking any side card, dragging horizontally >36px, or pressing Left/Right arrow keys while focused smoothly shifts focus and fires onChange.\n- Enabling reduced motion automatically degrades to an un-animated horizontal row with non-overlapping cards.",
        "dont_do_en": "- Do NOT invert the sign of `rotateY` on the left and right cards — outward-flaring cards completely destroy the focal wrap-around feel.\n- Do NOT rely solely on `translateZ` without setting `z-index` — under Safari and certain GPU compositors, later DOM cards will intercept clicks meant for the center card.\n- Do NOT disable only `transform` under `prefers-reduced-motion` without changing `grid-area: 1/1` to a `flex` row — otherwise all covers stack into an unreadable pile.",
        "skill_rule_en": "# 3D Cover Flow Gallery (coverflow) · Cross-Platform Motion Spec\nNature: Direction | Layer: 3d | Platform: both\n\nCore Principle: Stack all cards in the same grid cell inside a stage with perspective: 820px, compute (x, z, ry, scale, opacity, zIndex) from each card's signed center-relative offset = i - active via a pure function into CSS variables, and route side-card clicks, horizontal drags, and left/right arrow keys through one unified entry point.\n\nHard Constraints:\n- Must write both zIndex and translateZ so the center card always stays on top for both rendering and click hit-testing.\n- Never animate left / top / width / margin; all positional transitions must use transform and opacity.\n- Must preserve touch-action: pan-y so vertical scrolling on mobile pages is not blocked.\n\nAcceptance Criteria:\n- The initial center card faces forward prominently while left and right cards tilt inward symmetrically at 42° receding into depth without clipping or Z-fighting.\n- Clicking any side card, dragging horizontally >36px, or pressing Left/Right arrow keys while focused smoothly shifts focus and fires onChange.\n- Enabling reduced motion automatically degrades to an un-animated horizontal row with non-overlapping cards.\n\nDo NOT Do:\n- Do NOT invert the sign of `rotateY` on the left and right cards — outward-flaring cards completely destroy the focal wrap-around feel.\n- Do NOT rely solely on `translateZ` without setting `z-index` — under Safari and certain GPU compositors, later DOM cards will intercept clicks meant for the center card.\n- Do NOT disable only `transform` under `prefers-reduced-motion` without changing `grid-area: 1/1` to a `flex` row — otherwise all covers stack into an unreadable pile."
      }
    },
    {
      "id": "cube",
      "name": "纯 CSS 3D 旋转魔方",
      "name_en": "Pure CSS 3D Rotating Cube",
      "layer": "fun",
      "nature": "材质",
      "platform": "both",
      "status": "shipped",
      "entry": ".mk-cube-stage / .mk-cube / .mk-cube__face（六面 translateZ 半边长，零 JS）",
      "source": "纯 CSS 几何六面体（preserve-3d + 半边长变量 --h 控制全局尺寸，零 WebGL）",
      "source_en": "Pure CSS preserve-3d 6-face geometric cube (zero JS)",
      "file": "effects/cube.md",
      "summary": "纯 CSS 用六个面分别旋转并沿法线推出 `translateZ(半边长)` 拼合出真三维半透明魔方，单条 `@keyframes` 匀速空间自转，零 JS、零 WebGL。",
      "summary_en": "Six translucent faces positioned via rotate + translateZ(half-size) into a true 3D cube spinning smoothly on a single CSS @keyframes loop — zero JS, zero WebGL.",
      "problem": "**想在 404 页、加载徽章或三维概念卡片里放一颗立体的旋转方块，常见做法直接拉 Three.js 建 `BoxGeometry`——只为一颗 64px 的小方块引入几百 KB 运行时完全不值。** 纯 CSS 六面体只需 20 行样式、单变量控制大小，锐利清晰且极度轻量。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 单尺寸变量 `--size` 自动派生半边长 `calc(var(--size) / 2)`，六面永不裂开 | 为每个面手写死 `translateZ(40px)` 导致一改尺寸魔方就散架 |\n| 半透明玻璃面 + 细亮边让背面轮廓隐约可见，立体感翻倍 | 不透明纯色面失去空间穿透感 |\n| 整层归零降级：减弱动效直接停止旋转 | 停在怪异斜角或遮挡文字 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 半边长 `--h` | `calc(var(--size) / 2)` | 六面严格贴合无缝的几何充要条件；改 `--size` 整颗魔方等比缩放 |\n| 透视距 `perspective` | `500px ~ 700px` | 对 48–96px 的小立方体透视最立体且不畸变 |\n| 自转周期 | `12s linear infinite` | 匀速斜轴自转（`rotateX + rotateY` 同步走完 360°），循环首尾丝滑衔接 |",
      "implementation": "```\nstyles/fun.css:339  .mk-cube-stage / .mk-cube / .mk-cube__face--front|back|right|left|top|bottom\n```",
      "degradation": "**走 `fun` 层专属契约：整层关掉（`animation: none`，停在静态等轴视角 `rotateX(-22deg) rotateY(32deg)`）。**",
      "pitfalls": "**① 六个面的 `translateZ` 与容器宽高不严格等于 1/2。**\n哪怕差 1px，旋转时就能看到明显的接缝或穿模；必须统一用 `calc(var(--size) / 2)` 派生。\n\n**② `rotateX` 和 `rotateY` 在 100% 关键帧没同时走完 `360deg` 的整数倍。**\n如果不成整数倍，每次循环结束都会“啪”地跳回 0°；必须两者均从基准角走满 `+360deg`。\n\n---",
      "ai_assets": {
        "prompt": "实现纯 CSS（零 JS / 零 WebGL）的 3D 自转半透明魔方（CSS 3D Cube）。\n\n原理一句话：用单变量 --cube-size 派生半边长 --h: calc(var(--cube-size) / 2)，将 6 个面分别旋转到 6 个方向后推出 translateZ(var(--h))，在 preserve-3d 容器上匀速双轴旋转 360deg。\n\n做法：\n1. HTML：.cube-stage > .cube > 6 个面（front / back / right / left / top / bottom）。\n2. CSS 几何：\n   - .cube-stage { perspective: 600px; display: grid; place-items: center; }\n   - .cube {\n       --cube-size: 64px; --h: calc(var(--cube-size) / 2);\n       width: var(--cube-size); height: var(--cube-size); position: relative;\n       transform-style: preserve-3d;\n       animation: cube-spin 12s linear infinite;\n     }\n   - .cube-face {\n       position: absolute; inset: 0; border-radius: 6px;\n       border: 1px solid rgba(184,255,61,0.45); background: rgba(184,255,61,0.08);\n       display: grid; place-items: center;\n     }\n   - 六面定位：\n     front: translateZ(var(--h));\n     back: rotateY(180deg) translateZ(var(--h));\n     right: rotateY(90deg) translateZ(var(--h));\n     left: rotateY(-90deg) translateZ(var(--h));\n     top: rotateX(90deg) translateZ(var(--h));\n     bottom: rotateX(-90deg) translateZ(var(--h));\n   - @keyframes cube-spin {\n       from { transform: rotateX(-20deg) rotateY(0deg); }\n       to   { transform: rotateX(340deg) rotateY(360deg); }\n     }\n3. 降级：@media (prefers-reduced-motion: reduce) { .cube { animation: none; transform: rotateX(-22deg) rotateY(32deg); } }\n\n硬要求：\n- 半边长必须由 --cube-size / 2 自动计算，严禁手写死像素导致缩放裂开。\n- 关键帧起止角度差必须严格为 360deg 整数倍，保证无缝循环。\n- prefers-reduced-motion: reduce 下停止自转并停在静态等轴视角。\n\n验收：\n- 六面无缝拼合，匀速双轴旋转 12 秒一圈无任何循环跳帧。\n- 修改 --cube-size 为任意值（如 48px / 96px）六面依然严丝合缝。\n- 开启减弱动效后停在清晰静态立体视角。",
        "dont_do": "- 别为了画一颗小魔方引入 Three.js。\n- 别手写死 `translateZ(32px)` —— 一旦改方块大小六面就会散架。\n- 别让 `0%` 到 `100%` 的旋转差不是 `360deg` 倍数 —— 每 12 秒会明显跳一下。",
        "skill_rule": "# 纯 CSS 3D 旋转魔方 (cube) · 跨平台动效规范\n性质：材质 ｜ 平台：both\n\n【核心原理】用单变量 --cube-size 派生半边长 --h: calc(var(--cube-size) / 2)，将 6 个面分别旋转到 6 个方向后推出 translateZ(var(--h))，在 preserve-3d 容器上匀速双轴旋转 360deg。\n\n【硬要求】\n- 半边长必须由 --cube-size / 2 自动计算，严禁手写死像素导致缩放裂开。\n- 关键帧起止角度差必须严格为 360deg 整数倍，保证无缝循环。\n- prefers-reduced-motion: reduce 下停止自转并停在静态等轴视角。\n\n【验收标准】\n- 六面无缝拼合，匀速双轴旋转 12 秒一圈无任何循环跳帧。\n- 修改 --cube-size 为任意值（如 48px / 96px）六面依然严丝合缝。\n- 开启减弱动效后停在清晰静态立体视角。\n\n【禁止做法】\n- 别为了画一颗小魔方引入 Three.js。\n- 别手写死 `translateZ(32px)` —— 一旦改方块大小六面就会散架。\n- 别让 `0%` 到 `100%` 的旋转差不是 `360deg` 倍数 —— 每 12 秒会明显跳一下。",
        "prompt_en": "Implement a pure CSS (zero JS / zero WebGL) 3D self-rotating translucent cube (CSS 3D Cube).\n\nCore Principle: Derive the half-edge length --h: calc(var(--cube-size) / 2) from a single variable --cube-size, rotate 6 faces toward 6 orientations and push each out by translateZ(var(--h)), then continuously spin the preserve-3d container 360deg on two axes.\n\nImplementation:\n1. HTML: .cube-stage > .cube > 6 faces (front / back / right / left / top / bottom).\n2. CSS geometry:\n   - .cube-stage { perspective: 600px; display: grid; place-items: center; }\n   - .cube {\n       --cube-size: 64px; --h: calc(var(--cube-size) / 2);\n       width: var(--cube-size); height: var(--cube-size); position: relative;\n       transform-style: preserve-3d;\n       animation: cube-spin 12s linear infinite;\n     }\n   - .cube-face {\n       position: absolute; inset: 0; border-radius: 6px;\n       border: 1px solid rgba(184,255,61,0.45); background: rgba(184,255,61,0.08);\n       display: grid; place-items: center;\n     }\n   - Six-face positioning:\n     front: translateZ(var(--h));\n     back: rotateY(180deg) translateZ(var(--h));\n     right: rotateY(90deg) translateZ(var(--h));\n     left: rotateY(-90deg) translateZ(var(--h));\n     top: rotateX(90deg) translateZ(var(--h));\n     bottom: rotateX(-90deg) translateZ(var(--h));\n   - @keyframes cube-spin {\n       from { transform: rotateX(-20deg) rotateY(0deg); }\n       to   { transform: rotateX(340deg) rotateY(360deg); }\n     }\n3. Reduced motion: @media (prefers-reduced-motion: reduce) { .cube { animation: none; transform: rotateX(-22deg) rotateY(32deg); } }\n\nHard Constraints:\n- Half-edge offset must be automatically computed from --cube-size / 2; never hardcode pixel values that split open when resized.\n- Keyframe start-to-end angle delta must be strictly an integer multiple of 360deg for seamless looping.\n- Under prefers-reduced-motion: reduce, stop spinning and rest at a static isometric angle.\n\nAcceptance Criteria:\n- All six faces join seamlessly and spin smoothly on two axes at 12 seconds per revolution with zero loop jump.\n- Changing --cube-size to any value (such as 48px / 96px) keeps all six faces tightly sealed.\n- Enabling reduced motion rests at a crisp static 3D angle.",
        "dont_do_en": "- Do NOT import Three.js just to render a small rotating cube.\n- Do NOT hardcode `translateZ(32px)` — changing the cube size will immediately break all six faces apart.\n- Do NOT let the rotation delta from `0%` to `100%` deviate from a multiple of `360deg` — it will visibly jump every 12 seconds.",
        "skill_rule_en": "# Pure CSS 3D Rotating Cube (cube) · Cross-Platform Motion Spec\nNature: Material | Layer: fun | Platform: both\n\nCore Principle: Derive the half-edge length --h: calc(var(--cube-size) / 2) from a single variable --cube-size, rotate 6 faces toward 6 orientations and push each out by translateZ(var(--h)), then continuously spin the preserve-3d container 360deg on two axes.\n\nHard Constraints:\n- Half-edge offset must be automatically computed from --cube-size / 2; never hardcode pixel values that split open when resized.\n- Keyframe start-to-end angle delta must be strictly an integer multiple of 360deg for seamless looping.\n- Under prefers-reduced-motion: reduce, stop spinning and rest at a static isometric angle.\n\nAcceptance Criteria:\n- All six faces join seamlessly and spin smoothly on two axes at 12 seconds per revolution with zero loop jump.\n- Changing --cube-size to any value (such as 48px / 96px) keeps all six faces tightly sealed.\n- Enabling reduced motion rests at a crisp static 3D angle.\n\nDo NOT Do:\n- Do NOT import Three.js just to render a small rotating cube.\n- Do NOT hardcode `translateZ(32px)` — changing the cube size will immediately break all six faces apart.\n- Do NOT let the rotation delta from `0%` to `100%` deviate from a multiple of `360deg` — it will visibly jump every 12 seconds."
      }
    },
    {
      "id": "depth",
      "name": "真 Z 轴景深悬浮卡",
      "name_en": "True Z-Axis Depth Card",
      "layer": "3d",
      "nature": "材质",
      "platform": "web",
      "status": "shipped",
      "entry": "v-mk-3d + .mk-3d-scene / .mk-3d-depth / .mk-3d-layer / trackTilt()",
      "source": "Apple TV / visionOS 真 Z 轴多层景深（translateZ 透视自然算视差，零手算偏移）",
      "source_en": "Apple TV parallax posters (real CSS preserve-3d perspective layers)",
      "file": "effects/depth.md",
      "summary": "把卡片里的背景、标题、徽章分别推到不同的 `translateZ` 高度上，指针一晃容器倾斜，各层由浏览器三维透视自然错开，不需要 JS 手算任何视差偏移。",
      "summary_en": "Places card layers at distinct translateZ elevations so real browser perspective creates natural parallax when tilted — zero manual JS offset math.",
      "problem": "**普通 2D 视差卡片要给每一层单独写 `dx * 0.1`、`dx * 0.3` 的 JS 偏移公式，层一多就难维护且缺少真实的立体厚重感。** 用 `transform-style: preserve-3d` 把层真正摆到 Z 轴上，JS 只需要写容器的 `--rx` / `--ry` 两个角度，调整卡片厚度只需改一个 `--z` 变量。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 真实三维透视投影：层站得越靠前（`--z` 越大），转同样角度自然错位越大 | JS 逐层手算 `translateX/Y` 伪视差 |\n| 两段手感：跟手时 `.is-tracking` 压到 60ms，松手回中放回 380ms 柔和过渡 | 跟手和回中用同一条 380ms 过渡（拖尾滞后） |\n| 触屏自动关闭 + 3D 归零降级 | 在手机上强行跟手歪斜遮挡视线 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 最大倾角 `max` | `14deg` | 比平面 `tilt` 的 10° 略大一档，才能让 Z 轴 20–46px 的分层错位一眼看清 |\n| 阻尼系数 `damp` | `0.12` / 帧 | 每帧逼近 12%，既跟手又有厚重景深感；误差 ≤0.01° 自动停帧 |\n| 分层高度 `--z` | `16px / 32px / 46px` | 超过 60px 在小卡片里边缘会明显飘出边框，16–46px 立体层次最克制 |\n| 停帧阈值 | `0.01deg` | 移开回中到位立刻停掉 rAF，静止零开销 |",
      "implementation": "```\nsrc/core/scene3d.js:22   trackTilt(el, { max, damp, disabled })  只写 --mk-3d-rx / --mk-3d-ry\nstyles/3d.css            .mk-3d-scene / .mk-3d-depth（.is-tracking）/ .mk-3d-layer（--mk-z）\n```",
      "degradation": "**走 `3d` 层专属契约：归零塌回平面。**\n\n`prefers-reduced-motion: reduce` 或触屏粗指针下不挂监听，所有层 `transform: none` 塌回纯平面卡片，文字与层级保持正常排布。",
      "pitfalls": "**① 在 `.depth` 容器上写了 `overflow: hidden`。**\n规范里 `overflow: hidden` 会强制把 `transform-style: preserve-3d` 拍扁成 `flat`！所有 `translateZ` 分层会瞬间失效变成纯平面。\n\n**② 忘了 `pointer-events: none` 或给卡片整体 `perspective` 设得太小（如 `200px`）。**\n透视距离太小会产生夸张鱼眼畸变；800–1000px 最接近人眼看实体卡片的透视比例。\n\n**③ `rotateX` 符号写反。**\n指针在卡片上方（`ny < 0`）时上沿下压，`rotateX` 应为正（`-ny * max`）；指针在右侧（`nx > 0`）时右沿下压，`rotateY` 为正（`nx * max`）。\n\n---",
      "ai_assets": {
        "prompt": "实现真 Z 轴多层景深悬浮卡片（True Z-Axis Depth Card），零 3D 引擎依赖。\n\n原理一句话：外层设 perspective，卡片本体设 transform-style: preserve-3d，子层各自设不同 translateZ(16px~46px)；JS 只用 rAF 阻尼（0.12/帧）写入容器 --rx / --ry 两个角度，多层视差由浏览器三维投影自动算出。\n\n做法：\n1. 结构与 CSS：\n   - .depth-scene：perspective: 900px;\n   - .depth-card：transform-style: preserve-3d; transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));\n     （注意：绝对不能给 .depth-card 设 overflow: hidden，否则会拍扁 preserve-3d！）\n   - 内部各层 .depth-layer：transform: translateZ(var(--z, 0px));（如底层 0px、主标题 28px、徽章 44px）。\n2. 指针与到位即停 rAF（max = 14deg, damp = 0.12）：\n   - 能力门禁：prefers-reduced-motion: reduce 或粗指针设备直接跳过。\n   - pointermove：归一化 nx, ny 到 [-1, 1]，目标 ty = nx * max, tx = -ny * max，启动 rAF。\n   - pointerleave：目标 tx = 0, ty = 0，启动 rAF。\n   - loop：cx += (tx - cx) * 0.12; cy += (ty - cy) * 0.12; 写 --rx = cx deg, --ry = cy deg；仅当 |tx - cx| > 0.01 || |ty - cy| > 0.01 时继续下一帧，否则停帧。\n\n硬要求：\n- 严禁在 transform-style: preserve-3d 容器上写 overflow: hidden（会静默拍扁所有 Z 轴分层）。\n- 严禁由 JS 逐层手算 translateX/Y 偏移，只写容器的 --rx / --ry。\n- 指针离开回中后 rAF 必须彻底停止。\n- prefers-reduced-motion: reduce 下所有层 transform: none 归零塌回平面。\n\n验收：\n- 鼠标在卡片四周移动时，标题与徽章相对底板产生真实三维悬空错位；只改某层的 --z 即可改变浮起高度。\n- 鼠标移开后平滑回中并停止 rAF。\n- 减弱动效与触屏下卡片保持平面静止，不残歪。",
        "dont_do": "- 别给 `preserve-3d` 容器加 `overflow: hidden` 或 `filter` —— 都会破坏 3D 渲染上下文把分层拍扁。\n- 别把 `perspective` 设到 `300px` 以下 —— 透视畸变会非常夸张失真。\n- 别用 JS 给 5 个子元素分别写 5 套视差偏移公式 —— 交给真 Z 轴透视最干净。",
        "skill_rule": "# 真 Z 轴景深悬浮卡 (depth) · 跨平台动效规范\n性质：材质 ｜ 平台：web\n\n【核心原理】外层设 perspective，卡片本体设 transform-style: preserve-3d，子层各自设不同 translateZ(16px~46px)；JS 只用 rAF 阻尼（0.12/帧）写入容器 --rx / --ry 两个角度，多层视差由浏览器三维投影自动算出。\n\n【硬要求】\n- 严禁在 transform-style: preserve-3d 容器上写 overflow: hidden（会静默拍扁所有 Z 轴分层）。\n- 严禁由 JS 逐层手算 translateX/Y 偏移，只写容器的 --rx / --ry。\n- 指针离开回中后 rAF 必须彻底停止。\n- prefers-reduced-motion: reduce 下所有层 transform: none 归零塌回平面。\n\n【验收标准】\n- 鼠标在卡片四周移动时，标题与徽章相对底板产生真实三维悬空错位；只改某层的 --z 即可改变浮起高度。\n- 鼠标移开后平滑回中并停止 rAF。\n- 减弱动效与触屏下卡片保持平面静止，不残歪。\n\n【禁止做法】\n- 别给 `preserve-3d` 容器加 `overflow: hidden` 或 `filter` —— 都会破坏 3D 渲染上下文把分层拍扁。\n- 别把 `perspective` 设到 `300px` 以下 —— 透视畸变会非常夸张失真。\n- 别用 JS 给 5 个子元素分别写 5 套视差偏移公式 —— 交给真 Z 轴透视最干净。",
        "prompt_en": "Implement a true Z-axis multi-layer parallax depth card (True Z-Axis Depth Card), zero 3D engine dependencies.\n\nCore Principle: Set perspective on the outer scene, transform-style: preserve-3d on the card body, and distinct translateZ(16px~46px) depths on child layers; JS only writes two damped (0.12/frame) angles --rx / --ry to the container via rAF, and the browser's 3D projection computes multi-layer parallax automatically.\n\nImplementation:\n1. Structure and CSS:\n   - .depth-scene: perspective: 900px;\n   - .depth-card: transform-style: preserve-3d; transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));\n     (Note: NEVER set overflow: hidden on .depth-card, or it will flatten preserve-3d!)\n   - Inner layers .depth-layer: transform: translateZ(var(--z, 0px)); (e.g., base 0px, headline 28px, badge 44px).\n2. Pointer tracking and settle-to-stop rAF (max = 14deg, damp = 0.12):\n   - Capability gate: skip completely under prefers-reduced-motion: reduce or coarse-pointer devices.\n   - pointermove: normalize nx, ny to [-1, 1], set target ty = nx * max, tx = -ny * max, start rAF.\n   - pointerleave: set target tx = 0, ty = 0, start rAF.\n   - loop: cx += (tx - cx) * 0.12; cy += (ty - cy) * 0.12; write --rx = cx deg, --ry = cy deg; continue next frame only while |tx - cx| > 0.01 || |ty - cy| > 0.01, otherwise stop.\n\nHard Constraints:\n- Never add overflow: hidden to the transform-style: preserve-3d container (silently flattens all Z-axis layers).\n- Never manually compute per-layer translateX/Y offsets in JS; write only --rx / --ry on the container.\n- rAF must stop completely after the pointer leaves and returns to center.\n- Under prefers-reduced-motion: reduce, set transform: none on all layers to flatten back to a plane.\n\nAcceptance Criteria:\n- Moving the mouse around the card produces genuine 3D floating parallax between the title, badge, and baseplate; changing a single layer's --z adjusts its floating height.\n- Moving the mouse away smoothly centers the card and stops rAF.\n- Under reduced motion or on touchscreens, the card stays flat and still with no residual tilt.",
        "dont_do_en": "- Do NOT add `overflow: hidden` or `filter` to a `preserve-3d` container — both break the 3D rendering context and flatten all depth layers.\n- Do NOT set `perspective` below `300px` — perspective distortion becomes severely exaggerated.\n- Do NOT write 5 separate JS parallax offset formulas for 5 child elements — let true Z-axis perspective handle it cleanly.",
        "skill_rule_en": "# True Z-Axis Depth Card (depth) · Cross-Platform Motion Spec\nNature: Material | Layer: 3d | Platform: web\n\nCore Principle: Set perspective on the outer scene, transform-style: preserve-3d on the card body, and distinct translateZ(16px~46px) depths on child layers; JS only writes two damped (0.12/frame) angles --rx / --ry to the container via rAF, and the browser's 3D projection computes multi-layer parallax automatically.\n\nHard Constraints:\n- Never add overflow: hidden to the transform-style: preserve-3d container (silently flattens all Z-axis layers).\n- Never manually compute per-layer translateX/Y offsets in JS; write only --rx / --ry on the container.\n- rAF must stop completely after the pointer leaves and returns to center.\n- Under prefers-reduced-motion: reduce, set transform: none on all layers to flatten back to a plane.\n\nAcceptance Criteria:\n- Moving the mouse around the card produces genuine 3D floating parallax between the title, badge, and baseplate; changing a single layer's --z adjusts its floating height.\n- Moving the mouse away smoothly centers the card and stops rAF.\n- Under reduced motion or on touchscreens, the card stays flat and still with no residual tilt.\n\nDo NOT Do:\n- Do NOT add `overflow: hidden` or `filter` to a `preserve-3d` container — both break the 3D rendering context and flatten all depth layers.\n- Do NOT set `perspective` below `300px` — perspective distortion becomes severely exaggerated.\n- Do NOT write 5 separate JS parallax offset formulas for 5 child elements — let true Z-axis perspective handle it cleanly."
      }
    },
    {
      "id": "detent",
      "name": "拖动刻度",
      "name_en": "Discrete Detent Slider",
      "layer": "mobile",
      "nature": "权重",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-detent + .mk-detent / detent(el, { n, onSnap })",
      "source": "iOS `UIDatePicker` / 相机曝光滑块的刻度感（拖动中每过一格给一次确认）",
      "source_en": "iOS / Apple Watch Crown discrete detents (immediate notch commit + haptic tick)",
      "file": "effects/detent.md",
      "summary": "一个离散的滑块：拖动时**每跨过一格**就立刻提交并震一下，松手吸回刻度。",
      "summary_en": "Stepped tactile slider that commits immediately on every notch crossing with optional haptic pulse and snaps crisply on release.",
      "problem": "**「连续的输入」和「离散的值」之间必须有一座桥。** 手指在屏幕上是连续的，\n但音量是 15 级、时长是 5 档、曝光是 9 格。如果拖动过程只是视觉跟手、\n松手才算值，用户全程不知道\"现在算是第几档\"——刻度感必须**在拖动中就有**。\n\n第二个问题：**提交的时机决定了回调的语义。** 松手才提交，使用方就要自己\n在拖动中做预览；每格都提交，使用方写一行 `onChange` 就够。这条库选后者——\n前提是提交必须只从一个出口发（见第 7 节②）。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 每跨一格 `buzz(6)`——6ms 是\"刻度\"不是\"确认\"（长按的 12ms 才是确认） | 原生的 Taptic Engine 连续微震；`navigator.vibrate` 只有整段震动，拼不出刻度感 |\n| 旋钮在松手时用 `ease-snap` 吸回刻度（160ms，轻微过冲） | 拖动中的粘滞阻尼——这里拖动是 1:1 跟手，阻尼留给 `pull-refresh` |\n| 跨格即刻提交，不等松手 | 「拖到一半预览、松手才生效」的模型——要那种模型就别用 `onSnap`，监听拖动自己算 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 格数 | `data-n`，默认 5 | 拖动件的格数应该少（5±2）。超过 9 格用户不会数刻度，直接用连续滑块 |\n| 震动 | `buzz(6)` | 比 tap 的 8ms 短——一格是\"路过\"不是\"落点\"。频繁触发时更长会更吵 |\n| 吸附过渡 | `--mk-dur-2` = 160ms + `ease-snap` | 只用于松手回吸。带一点过冲（1.56）是\"咔哒进槽\"的观感来源 |\n| 旋钮按下 | `scale(1.18)` | \"我抓住了\"的确认。发生在 `is-dragging`，和过渡关闭同帧 |",
      "implementation": "```\nseg.js:21    segIndexAt(x, width, n)   纯函数：指针位置 → 最近格\nseg.js:101   detent(el, { n, onSnap })\nseg.js:42    segmented(el, { onChange })  同源的点击版（分段控件）\nmobile.css:495 .mk-detent 系列\n```\n\n刻度线**不用 N 个节点**，一条渐变画完：\n\n```css\nbackground-image: repeating-linear-gradient(\n  to right, rgba(255,255,255,.22) 0 1px, transparent 1px calc(100% / (var(--mk-detent-n) - 1)));\nmask-image: linear-gradient(to right, #000 calc(100% - 2px), transparent);\n```\n\n最后一条线会贴在右边缘外，用 mask 裁掉。`--mk-detent-n` 一变，刻度自动重排——\n这也是\"视觉只消费进度\"的另一个好处。\n\n拖动逻辑（README 第 16 条的两半）：\n\n```js\nonMove(_dx, _v, e) {\n  // 绝对位置，不累加 dx —— 贴边时累加会攒误差\n  const t = clamp((e.clientX - r.left) / r.width, 0, 1);\n  set(Math.round(t * (count - 1)));     // 跨格即刻提交\n},\nonEnd() { set(cur); }                   // 松手补一次；拖动中已落格则为空操作\n```\n\n实测（Chrome，5 格拖满）：回调序列恰为 `[1,2,3,4]`，松手**零**额外回调，\n`set(同一格)` 也是零回调——单一出口闭环成立。",
      "degradation": "**走 `mobile` 那档：减。**\n\n`prefers-reduced-motion` 下旋钮的 `transition: none`（吸附变瞬移）+ `buzz()` 静默——\n**拖动、刻度、回调全保留**，因为这是控件本体不是装饰。\n`buzz` 内部还有一层能力探测：没有 `navigator.vibrate` 的设备全部静默，\n**视觉上的分段不依赖震动**（刻度线、进度填充、文字都在）。",
      "pitfalls": "**① 跨格提交必须走 `set()`，不能直接改 `cur`。**\n这是全库最容易被\"优化\"坏的一条。直接改 `cur` 的话，`cur` 和\"已经通知过外界\"的状态\n就脱节了：松手时 `set(cur)` 一看没变化直接 return，结果是**拖到底了外面一次回调\n都没收到**。`set()` 里的 `changed` 判断是唯一真相。\n\n**② 旋钮用的是 `left`，不是 `transform`——一次有记录的破例。**\n`left: calc(var(--mk-detent-p) * 100%)` 是布局属性，每帧改动都会触发 layout。\n破例的理由：旋钮要相对**轨道**定位（轨道本身是 flex 子项，宽度自适应），\ntransform 方案需要额外一层定位容器；而这个元素只有 26×26、不在滚动容器里、\n每帧一次小 layout 的代价可以接受。**破例要写下来，否则下次有人\"顺手优化\"**——\n或者反过来，在别的场景照抄这个破例（列表里每行的 transform 别这么写）。\n进度填充 `.mk-detent__fill` 的 `width` 同理。\n\n**③ 刻度数变多时 mask 会裁错。**\n`mask-image` 里那个 `calc(100% - 2px)` 假设最后一条线 1px 宽 + 1px 余量。\n如果有人把刻度线加粗到 2px，最后一条会切半条。改线宽时两个数字要一起改。\n\n**④ `onSnap` 在\"初始落格\"时不发。**\n`set(cur, false)` 挂载时静默设一次初始值——使用方不必在 mounted 里忽略一次回调。\n反过来讲，**想知道初始值就读 `data-value` / `index()`**，不要等回调。\n\n**⑤ 和 `segmented` 共用同一套换算，但别混用。**\n`segIndexAt` 是给点击版（分段控件）的；拖动版在 `onMove` 里内联了同一条\n`Math.round(t * (n-1))`。两处公式必须同步——改了舍入策略（比如改成 floor）\n要两边一起改，否则\"点出来的格\"和\"拖出来的格\"会差半格。\n\n**⑥ 桌面鼠标也能拖——这是有意的，和 `pull-refresh` 相反。**\n刻度滑块在桌面上是正常控件（`pointerDrag` 全 pointer 事件，无 coarse 判定）。\n不要照抄 `pull-refresh` 的\"仅触屏\"思路给它加判定。\n\n---",
      "ai_assets": {
        "prompt": "实现一个「拖动刻度」控件：离散 N 格、拖动跟手、每跨一格立刻提交并给一次轻触觉。\n\n原理一句话：把连续的指针位置量化成整数档位，松手吸附过去。没有惯性物理，只有\"位置→最近档\"的取整和一个很短的过渡。\n\n结构：\n  <div class=\"detent\" data-n=\"5\" data-value=\"2\">\n    <div class=\"detent__track\"><i class=\"detent__fill\"></i></div>\n    <i class=\"detent__knob\"></i>\n  </div>\n\n行为：\n- 进度只有一种表达：CSS 变量 --p ∈ [0,1]，JS 只写这个变量。\n  填充条 width: calc(var(--p) * 100%)，旋钮 left: calc(var(--p) * 100%)。\n- 拖动中：按指针相对轨道的绝对位置算当前格 Math.round(t * (n-1))，\n  不要累加 dx（贴边时会攒误差）。用 Pointer Events + setPointerCapture。\n- 跨格即刻调用 onSnap(i)：不等松手。拖满 5 格应依次收到 1,2,3,4（0 起手）。\n- 所有状态变更必须走同一个 set(i) 函数：里面做钳制、查 changed、写变量、\n  写 data-value、跨格时才 buzz(6) + onSnap。松手时再调 set(当前格) 收尾——\n  若拖动中已落格，这次调用必须是空操作。\n- 拖动中给容器加 .dragging：旋钮的吸附过渡（160ms，轻微过冲）此时必须关掉，\n  同时旋钮 scale(1.18) 表示\"抓住了\"；松手摘类恢复过渡。\n- 刻度线用一条 repeating-linear-gradient 画完 N-1 条，不要生成 N 个节点；\n  最后一条贴边的用 mask 裁掉。\n- 触觉是加分项：navigator.vibrate 存在才调（6ms），iOS 静默。\n  prefers-reduced-motion 下不震、吸附过渡改瞬移，其余全保留。\n\n硬要求：\n- 状态只有一个真相（set 内部的 cur），任何地方不得绕过 set 直接改值。\n- onSnap 在挂载设初始值时不触发；初始值读 data-value。\n- 桌面鼠标也能拖（这是控件，不是手势）。\n- teardown 摘掉全部监听。\n\n验收：\n- 5 格从 0 拖到末尾：onSnap 依次 [1,2,3,4]，松手无额外回调。\n- 拖到一半往回拖：已走过的格不重复回调，只在新跨格时回调。\n- 拖动中旋钮零滞后跟手；松手后 160ms 吸附到位。\n- 不支持 vibrate 的浏览器：无报错，刻度视觉完整。",
        "dont_do": "- 别用 CSS `input[type=range]` 冒充——它的事件粒度做不到\"跨格即刻\"，\n  而且样式化旋钮和刻度线的成本比自己写还高。\n- 别在 onSnap 里做重活（发请求、重排列表）——它可能一帧内连发多次，\n  使用方要自己 debounce；控件的职责是忠实报告，不是替使用方节流。\n- 别给拖动加阻尼/惯性——这里要的是\"一格是一格\"的确定性，\n  惯性会让\"我现在到底在第几格\"变得不可预判。",
        "skill_rule": "# 拖动刻度 (detent) · 跨平台动效规范\n性质：权重 ｜ 平台：both\n\n【核心原理】把连续的指针位置量化成整数档位，松手吸附过去。没有惯性物理，只有\"位置→最近档\"的取整和一个很短的过渡。\n\n【硬要求】\n- 状态只有一个真相（set 内部的 cur），任何地方不得绕过 set 直接改值。\n- onSnap 在挂载设初始值时不触发；初始值读 data-value。\n- 桌面鼠标也能拖（这是控件，不是手势）。\n- teardown 摘掉全部监听。\n\n【验收标准】\n- 5 格从 0 拖到末尾：onSnap 依次 [1,2,3,4]，松手无额外回调。\n- 拖到一半往回拖：已走过的格不重复回调，只在新跨格时回调。\n- 拖动中旋钮零滞后跟手；松手后 160ms 吸附到位。\n- 不支持 vibrate 的浏览器：无报错，刻度视觉完整。\n\n【禁止做法】\n- 别用 CSS `input[type=range]` 冒充——它的事件粒度做不到\"跨格即刻\"，\n  而且样式化旋钮和刻度线的成本比自己写还高。\n- 别在 onSnap 里做重活（发请求、重排列表）——它可能一帧内连发多次，\n  使用方要自己 debounce；控件的职责是忠实报告，不是替使用方节流。\n- 别给拖动加阻尼/惯性——这里要的是\"一格是一格\"的确定性，\n  惯性会让\"我现在到底在第几格\"变得不可预判。",
        "prompt_en": "Implement a discrete detent slider control: N discrete stops, direct pointer tracking, immediate commit on each step crossing, and a subtle haptic pulse.\n\nCore Principle: Quantize continuous pointer position into integer steps and snap on release. No inertia physics — only \"position -> nearest step\" rounding and a very short snap transition.\n\n  <div class=\"detent\" data-n=\"5\" data-value=\"2\">\n    <div class=\"detent__track\"><i class=\"detent__fill\"></i></div>\n    <i class=\"detent__knob\"></i>\n  </div>\n\nImplementation:\n- Progress has only one representation: CSS variable --p ∈ [0, 1], the only variable JS writes. Fill bar width: calc(var(--p) * 100%), knob left: calc(var(--p) * 100%).\n- While dragging: compute current step from pointer's absolute position relative to the track via Math.round(t * (n - 1)); never accumulate dx (accumulates error at track edges). Use Pointer Events + setPointerCapture.\n- Call onSnap(i) immediately upon crossing a step without waiting for release. Dragging across all 5 steps from 0 should fire 1, 2, 3, 4 sequentially.\n- All state changes must route through one set(i) function: clamp, check changed, write CSS variable, update data-value, and trigger buzz(6) + onSnap only when the step actually changes. Call set(currentStep) on release to finalize — if already settled on that step during drag, this call must be a no-op.\n- Add .dragging to the container while dragging: the knob's snap transition (160ms, slight overshoot) must be disabled during drag, while the knob applies scale(1.18) to show it is grabbed; remove the class on release to restore the transition.\n- Draw all N - 1 tick marks using a single repeating-linear-gradient rather than creating N DOM nodes; clip the final edge tick with a mask.\n- Haptics are a progressive enhancement: call navigator.vibrate(6) only when present (silent on iOS). Under prefers-reduced-motion, do not vibrate and make the snap transition instant while preserving everything else.\n\nHard Constraints:\n- Single source of truth for state (cur inside set); nowhere may value be mutated bypassing set.\n- onSnap must not fire when setting the initial value on mount; read initial value from data-value.\n- Must also support desktop mouse dragging (this is a UI control, not a touch-only gesture).\n- teardown must remove all listeners.\n\nAcceptance Criteria:\n- Dragging 5 steps from 0 to the end: onSnap fires [1, 2, 3, 4] in order, with no extra callback on release.\n- Dragging halfway and reversing: already-settled steps do not re-fire; fires only when crossing into a new step.\n- Zero-lag knob tracking while dragging; 160ms snap settle on release.\n- Browsers without vibrate support throw no errors and display complete tick marks.",
        "dont_do_en": "- Do NOT fake this with CSS `input[type=range]` — its event granularity cannot trigger immediate per-step commits, and styling custom knobs and ticks costs more than building it directly.\n- Do NOT run heavy work (network requests, list reflows) inside `onSnap` — it may fire multiple times within one frame; callers should debounce themselves while the control faithfully reports transitions.\n- Do NOT add damping or inertia to dragging — this control requires deterministic step-by-step precision; inertia makes \"which step am I on\" unpredictable.",
        "skill_rule_en": "# Discrete Detent Slider (detent) · Cross-Platform Motion Spec\nNature: Weight | Layer: mobile | Platform: both\n\nCore Principle: Quantize continuous pointer position into integer steps and snap on release. No inertia physics — only \"position -> nearest step\" rounding and a very short snap transition.\n\nHard Constraints:\n- Single source of truth for state (cur inside set); nowhere may value be mutated bypassing set.\n- onSnap must not fire when setting the initial value on mount; read initial value from data-value.\n- Must also support desktop mouse dragging (this is a UI control, not a touch-only gesture).\n- teardown must remove all listeners.\n\nAcceptance Criteria:\n- Dragging 5 steps from 0 to the end: onSnap fires [1, 2, 3, 4] in order, with no extra callback on release.\n- Dragging halfway and reversing: already-settled steps do not re-fire; fires only when crossing into a new step.\n- Zero-lag knob tracking while dragging; 160ms snap settle on release.\n- Browsers without vibrate support throw no errors and display complete tick marks.\n\nDo NOT Do:\n- Do NOT fake this with CSS `input[type=range]` — its event granularity cannot trigger immediate per-step commits, and styling custom knobs and ticks costs more than building it directly.\n- Do NOT run heavy work (network requests, list reflows) inside `onSnap` — it may fire multiple times within one frame; callers should debounce themselves while the control faithfully reports transitions.\n- Do NOT add damping or inertia to dragging — this control requires deterministic step-by-step precision; inertia makes \"which step am I on\" unpredictable."
      }
    },
    {
      "id": "dock",
      "name": "停靠栏放大",
      "name_en": "macOS Dock Magnification",
      "layer": "motion",
      "nature": "权重",
      "platform": "web",
      "status": "shipped",
      "entry": "v-mk-dock + .mk-dock / .mk-dock__item / dock(el, { radius, amp, lift })",
      "source": "macOS Dock 的图标放大（指针距离 → 邻近项梯度缩放）",
      "source_en": "macOS Dock (quadratic falloff curve + layout-stable offsetLeft math)",
      "file": "effects/dock.md",
      "summary": "一排图标里，指针指哪个哪个最大、左右邻居依次变小——放大曲线是一条平方衰减。",
      "summary_en": "Quadratic distance-falloff icon magnification driven by layout offsetLeft (never jittering getBoundingClientRect) so neighbors scale smoothly with zero boundary kink.",
      "problem": "**一排东西太多、又都一样大时，\"指向\"必须被放大成\"焦点\"。** 文件管理器的工具栏、\n底部标签栏、表情面板——用户要的是\"我知道我指到了哪个\"，而不是\"这一排都能点\"。\n\n为什么不用 CSS `:hover` + 相邻选择器：那只能让紧邻的一个变大，做不出三个梯度；\n而每帧算一次距离，一条公式就能得到连续曲线，还不用给每个元素写一条规则。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 平方衰减曲线 `amp * (1 - d/r)²` | macOS 的真 3D 透视（图标会绕 X 轴翻起来）—— 2D 里用\"上抬\"替代 |\n| 放大多少就上抬多少：底部对齐，像\"长高\"而不是\"变大\" | 原生的磁吸点击预览 |\n| rAF 合批：一帧最多重算一次，指针 move 只记位置 | 指针离开时的弹性回落（这里直接归零，靠 80ms 过渡收） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| `radius` | 110px | 影响半径。太小（<60px）只有被指的那个动，梯度消失；太大（>160px）整排都在动，焦点没了。110 ≈ 两个 44px 热区的宽度 |\n| `amp` | 0.55 | 最大放大到 1.55 倍。1.3 以上图标会互相叠住；低于 1.2 梯度看不出来 |\n| `lift` | 10px | 上抬量 = `(s / amp) * -lift`，和放大成正比。**底部对齐**是关键：transform-origin 在底部，看起来是\"长高\"而不是\"飘起来\" |\n\n`dockScale` 的五个性质全部有单测（README 第 17 条）：\n\n```\n中心最大 / 边缘归零 / 左右对称 / 单调递减 / 边界导数趋零\n```\n\n最后一条最容易被忽视：**平方衰减在边界处导数为 0，图标不会\"折一下\"**。\n换成线性衰减 `amp * (1 - d/r)`，指针扫过半径边界时邻近图标会突然一顿——\n那一下顿挫就是\"廉价感\"的来源。",
      "implementation": "```\ndock.js:26   dockScale(dx, radius, amp)   纯函数\ndock.js:40   dock(el, { radius, amp, lift })\n```\n\n三条容易踩的几何坑，全在这里：\n\n**① 中心点用 `offsetLeft`，不用 `getBoundingClientRect`。**\n后者把 transform 算进去——元素一边被放大一边位移，中心会自己漂，\n结果是**放大到一半开始抖**（算出的中心偏了 → 放大量变 → 中心又偏……）。\n`offsetLeft` 只反映布局，永远稳定。\n\n**② 指针坐标要减 `clientLeft`。**\n`offsetLeft` 相对的是 offsetParent 的 padding 边，`getBoundingClientRect().left`\n给的是边框边，中间差 1~2px。大图标上看不出来，44px 热区里就是\"偏了一格\"。\n\n**③ 中心点缓存 + resize 重算。**\n`measure()` 只在挂载和 window resize 时跑，move 里只做减法和赋值。\n代价：**条目增删 / 字体加载完成导致的宽度变化不会触发重算**——见第 7 节③。\n\n触屏直接不挂（`isCoarsePointer()` → noop）：触屏没有\"指针靠近\"，\n开了只会是点一下跳一下。这也是这条卡归在 `motion` 层（Web 面）的原因。",
      "degradation": "**走 `motion` 那档：减，且这里减得更狠——直接不挂。**\n\n`resolveReduced()` 或 `isCoarsePointer()` 任一为真，返回空 teardown。\n理由：dock 的全部价值在\"连续梯度\"这个动效上，梯度没了（只剩 hover 变色）\n它就退化成了一个普通工具栏，**挂不挂没有区别**。这和 `tap` 不同——\ntap 的价值是\"0ms 反馈\"这个功能，所以减弱时必须保留。\n判断标准：**降级后还剩下的部分，是否独立成立。** 独立成立就摘动画，不独立就整个不挂。",
      "pitfalls": "**① transform 既是输出又是输入，会自己绕成抖动。**\n`dockScale` 的输入是指针到**元素中心**的距离。如果中心用 `getBoundingClientRect` 取，\n而元素此刻正被 transform 缩放着，中心就是被缩放污染过的——放得越大中心偏得越远，\n下一帧又根据偏了的中心重新算，结果是图标在\"抖\"。**输入必须来自布局（offsetLeft），\n输出才允许是 transform。** 这条对所有\"根据元素位置驱动的效果\"都成立（tilt、磁吸同理）。\n\n**② `paint` 里 `inside = false` 的分支别忘了把所有项归零。**\n指针离开后，如果只停掉 rAF 不清变量，最后一个指针位置对应的放大状态会**冻在栏上**。\n`paint()` 的第一行 `raf = 0` 也很关键——`kick()` 靠它防止重复入队。\n\n**③ 字体加载会让中心点过期。**\n`measure()` 在挂载和 resize 时跑，但 webfont 加载完成、图标换成不同宽度的 SVG、\n或者使用方动态增删条目——这些都不触发 resize。过期后梯度会整体偏移，\n症状是\"指针指在 A 和 B 中间，B 却最大\"。使用方在内容变化后要自己触发\n一次 resize（`window.dispatchEvent(new Event('resize'))`），或者等这条卡\n的后续改进把 `ResizeObserver` 接上。\n\n**④ 项与项的间距会放大后互相叠。**\n`amp = 0.55` 时相邻 44px 图标峰值宽度差约 24px，间距小于 24px 就会叠。\n这不是 bug 是几何——排 dock 的时候间距要按**放大后的宽度**留，不是按原始宽度。\n\n**⑤ 别把它挂在会滚动的容器里。**\n`pointermove` 挂在 dock 元素上，滚动时指针相对位置变了但不会来 move 事件，\n梯度会冻在一个错的位置直到下一次 move。工具栏不该滚动；非要滚就用\n`scroll` 监听补 `kick()`（当前没做，记录在案）。\n\n---",
      "ai_assets": {
        "prompt": "实现 macOS Dock 式的图标放大。纯 JS + CSS 变量，不引依赖。\n\n原理一句话：每个图标到指针的水平距离决定它的缩放，距离→比例是一个衰减函数。每帧重算一遍距离，只写一个 CSS 变量。\n\n结构：\n  <nav class=\"dock\">\n    <button class=\"dock__item\">…</button> × N\n  </nav>\n\n行为：\n- 指针在栏内移动时，对每个图标算它中心到指针的水平距离 dx，\n  放大量 s = amp * (1 - |dx|/radius)²，其中 |dx| >= radius 时 s = 0。\n  必须用平方（不是线性）：平方的导数在半径边界为 0，\n  指针扫过边界时图标不会突然一顿。\n- 每个图标只写两个 CSS 变量：\n    --s（0~amp），CSS 拼 transform: scale(1 + var(--s))；\n    --y（= s/amp * -lift），transform 里同时 translate3d(0, var(--y), 0)。\n  transform-origin 用 bottom：放大的同时上抬，看起来是\"长高\"而不是\"飘起来\"。\n- 指针离开整条栏（pointerleave / pointercancel）→ 所有项归零。\n- 用 rAF 合批：pointermove 只记录指针位置并 requestAnimationFrame，\n  一帧最多重算一次；rAF 已在队列中时不得重复入队。\n- 中心点用 offsetLeft + offsetWidth/2 缓存（挂载和 window resize 时重算），\n  绝对不用 getBoundingClientRect —— 它把 transform 算进去，\n  元素边放大边量自己，中心会漂，表现为放大到一半开始抖。\n- 指针 x 要减掉容器的 borderLeftWidth（clientLeft），\n  否则 offsetLeft 的 padding 基准和 clientX 的 border 基准差 1~2px。\n\n硬要求：\n- 只在精确指针上生效：matchMedia('(hover: hover) and (pointer: fine)')。\n  触屏没有\"靠近\"，挂了只会点一下跳一下。\n- prefers-reduced-motion 下整个不挂，而不是只关动画 ——\n  它降级后就是普通工具栏，挂不挂没有区别。\n- 图标间距按放大后的宽度留（峰值 1+amp 倍），否则邻居会叠。\n\n验收：\n- 指针扫过整条栏，每个图标平滑起落、边界处无顿挫。\n- 指针停在两图标中间：两边放大程度相同（对称性）。\n- 指针停在某个图标正中：它最大，左右邻居更小（单调性）。\n- 快速划过后离开：所有图标回落到 1.0，无残留放大。\n- 放大过程中再快速移动：不抖动（中心来自布局，不被 transform 污染）。",
        "dont_do": "- 别用 CSS 相邻选择器 `:hover + *`——只能做一个邻居，梯度断档。\n- 别给每个图标单独监听 pointermove——N 个监听器不如一个容器级的。\n- 别把 `radius` 做成随容器宽度自适应却不同步 `measure()`——半径和中心点\n  必须同一次 measure 里算出来，否则梯度会歪。",
        "skill_rule": "# 停靠栏放大 (dock) · 跨平台动效规范\n性质：权重 ｜ 平台：web\n\n【核心原理】每个图标到指针的水平距离决定它的缩放，距离→比例是一个衰减函数。每帧重算一遍距离，只写一个 CSS 变量。\n\n【硬要求】\n- 只在精确指针上生效：matchMedia('(hover: hover) and (pointer: fine)')。\n  触屏没有\"靠近\"，挂了只会点一下跳一下。\n- prefers-reduced-motion 下整个不挂，而不是只关动画 ——\n  它降级后就是普通工具栏，挂不挂没有区别。\n- 图标间距按放大后的宽度留（峰值 1+amp 倍），否则邻居会叠。\n\n【验收标准】\n- 指针扫过整条栏，每个图标平滑起落、边界处无顿挫。\n- 指针停在两图标中间：两边放大程度相同（对称性）。\n- 指针停在某个图标正中：它最大，左右邻居更小（单调性）。\n- 快速划过后离开：所有图标回落到 1.0，无残留放大。\n- 放大过程中再快速移动：不抖动（中心来自布局，不被 transform 污染）。\n\n【禁止做法】\n- 别用 CSS 相邻选择器 `:hover + *`——只能做一个邻居，梯度断档。\n- 别给每个图标单独监听 pointermove——N 个监听器不如一个容器级的。\n- 别把 `radius` 做成随容器宽度自适应却不同步 `measure()`——半径和中心点\n  必须同一次 measure 里算出来，否则梯度会歪。",
        "prompt_en": "Implement macOS Dock-style icon magnification using pure JS + CSS variables, zero dependencies.\n\nCore Principle: Each icon's horizontal distance to the pointer determines its scale through a quadratic falloff function. Recompute distances once per frame and write only CSS variables.\n\n  <nav class=\"dock\">\n    <button class=\"dock__item\">…</button> × N\n  </nav>\n\nImplementation:\n- As the pointer moves across the dock, compute horizontal distance dx from each icon's center to the pointer: magnification s = amp * (1 - |dx|/radius)², with s = 0 when |dx| >= radius. Must use quadratic falloff (not linear): the quadratic derivative is 0 at the radius boundary so icons do not jerk abruptly when the pointer crosses the edge.\n- Write only two CSS variables per icon:\n    --s (0..amp), composed in CSS as transform: scale(1 + var(--s));\n    --y (= s/amp * -lift), applied in the same transform via translate3d(0, var(--y), 0).\n  Use transform-origin: bottom so icons grow upward as they scale rather than floating.\n- Pointer leaving the entire dock (pointerleave / pointercancel) -> reset all items to zero.\n- Batch via rAF: pointermove only stores pointer position and schedules requestAnimationFrame, recomputing at most once per frame; never enqueue another rAF if one is already pending.\n- Cache icon centers via offsetLeft + offsetWidth/2 (recomputed on mount and window resize); never use getBoundingClientRect — it includes transform, so measuring an icon while it scales causes its center to drift and jitter mid-magnification.\n- Subtract the container's borderLeftWidth (clientLeft) from pointer x, otherwise offsetLeft's padding-box reference and clientX's border-box reference differ by 1–2px.\n\nHard Constraints:\n- Activate only on precision pointers: matchMedia('(hover: hover) and (pointer: fine)'). Touchscreens have no hover proximity; attaching it causes icons to jump on tap.\n- Under prefers-reduced-motion, skip attaching completely rather than only disabling transitions — degraded, it is simply a normal toolbar.\n- Space icons for peak magnified width (1 + amp), otherwise neighbors overlap.\n\nAcceptance Criteria:\n- Sweeping the pointer across the dock smoothly raises and lowers each icon with zero abrupt jumps at boundaries.\n- Resting the pointer halfway between two icons magnifies both identically (symmetry).\n- Resting the pointer centered on an icon makes it tallest while left/right neighbors decrease monotonically.\n- Quickly swiping past and leaving resets all icons to 1.0 with zero residual magnification.\n- Rapid pointer movement mid-magnification shows zero jitter (centers come from layout, unpolluted by transform).",
        "dont_do_en": "- Do NOT use CSS adjacent sibling selectors `:hover + *` — that reaches only one neighbor and creates a broken step gradient.\n- Do NOT attach separate `pointermove` listeners to each icon — one container-level listener beats N per-item listeners.\n- Do NOT make `radius` adapt to container width without recomputing it inside the same `measure()` pass as icon centers — desynchronized radius and centers skew the magnification curve.",
        "skill_rule_en": "# macOS Dock Magnification (dock) · Cross-Platform Motion Spec\nNature: Weight | Layer: motion | Platform: web\n\nCore Principle: Each icon's horizontal distance to the pointer determines its scale through a quadratic falloff function. Recompute distances once per frame and write only CSS variables.\n\nHard Constraints:\n- Activate only on precision pointers: matchMedia('(hover: hover) and (pointer: fine)'). Touchscreens have no hover proximity; attaching it causes icons to jump on tap.\n- Under prefers-reduced-motion, skip attaching completely rather than only disabling transitions — degraded, it is simply a normal toolbar.\n- Space icons for peak magnified width (1 + amp), otherwise neighbors overlap.\n\nAcceptance Criteria:\n- Sweeping the pointer across the dock smoothly raises and lowers each icon with zero abrupt jumps at boundaries.\n- Resting the pointer halfway between two icons magnifies both identically (symmetry).\n- Resting the pointer centered on an icon makes it tallest while left/right neighbors decrease monotonically.\n- Quickly swiping past and leaving resets all icons to 1.0 with zero residual magnification.\n- Rapid pointer movement mid-magnification shows zero jitter (centers come from layout, unpolluted by transform).\n\nDo NOT Do:\n- Do NOT use CSS adjacent sibling selectors `:hover + *` — that reaches only one neighbor and creates a broken step gradient.\n- Do NOT attach separate `pointermove` listeners to each icon — one container-level listener beats N per-item listeners.\n- Do NOT make `radius` adapt to container width without recomputing it inside the same `measure()` pass as icon centers — desynchronized radius and centers skew the magnification curve."
      }
    },
    {
      "id": "dynamic-pill",
      "name": "灵动胶囊状态条",
      "name_en": "Dynamic Status Pill",
      "layer": "motion",
      "nature": "连续",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.dynamicPill(el, { state }) + .mk-pill",
      "source": "Apple Dynamic Island / Family App（紧凑药丸与展开状态卡片间的连续形态过渡 + 脉动状态点）",
      "source_en": "Apple Dynamic Island / Family App (continuous container state morphing)",
      "file": "effects/dynamic-pill.md",
      "summary": "同一个顶部状态容器在 `idle / thinking / done / error` 四种状态间连续变形：紧凑待机时是圆润药丸，进入思考或报错态时柔和舒展为圆角状态卡并点亮对应语义色与呼吸状态点。",
      "summary_en": "Single persistent container morphing smoothly across idle, thinking, done, and error states — transitioning pill radius, padding, semantic border, and breathing indicator dot.",
      "problem": "**AI Agent 执行任务、文件同步或后台处理时，用弹窗打断用户太重、用普通静态文字条又容易被忽略；若不同状态用 `v-if` 切换两套 DOM，视觉上会硬闪割裂。** 让同一个胶囊容器通过纯函数状态规格连续驱动圆角、内边距、边框语义色与状态点脉动，用户一眼看懂系统正在发生什么且全程保持同一物体的连续性。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 同一容器连续形变（`padding` / `border-radius` / `border-color` 同步 `280ms` 过渡），保持“同一个生命体”认知 | 不同状态用两个独立元素销毁重建硬切 |\n| 状态规格由纯函数 `pillStateSpec(state)` 集中映射 `{ state, expanded, accent }` | 业务代码到处散落 `if/else` 拼类名与颜色 |\n| `thinking` 态状态点 `1.1s` 柔和呼吸脉动，完成后转为稳定绿点 | 高频刺眼闪烁红灯或大面积霓虹发光 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 四态规格 `PILL_SPECS` | `idle`(紧凑中性) / `thinking`(展开强调) / `done`(紧凑成功) / `error`(展开警示) | 需要解释信息或正在执行时略微展开承载上下文，静置与完成时收拢不占屏 |\n| 形态过渡时长 | `280ms ease-out`（圆角 `999px ↔ 18px`） | 既有类似 Dynamic Island 的弹性舒展感，又在 300ms 内利落落位不拖泥带水 |\n| 呼吸灯周期 | `1.1s ease-in-out infinite`（缩放 `1 → 1.35` + 透明度 `0.35`） | 接近人类平静呼吸节奏，后台长任务盯着看也不焦虑 |\n| 未知状态兜底 | 回退 `idle` | 防止接口返回未知枚举把胶囊样式弄崩 |",
      "implementation": "```\nsrc/core/ui-motion.js:132   PILL_SPECS / pillStateSpec(state)   纯函数，四态归一化规格映射（可单测）\nsrc/core/ui-motion.js:144   dynamicPill(el, { state })          写 data-state / data-accent / .is-expanded\nstyles/motion.css:1432      .mk-pill / .is-expanded / __dot     圆角与内边距连续形变 + 呼吸灯与降级\n```",
      "degradation": "**走 `motion` 层契约：保留全部语义色与展开状态，关闭呼吸动画并将形变时长压至 `1ms`。**\n\n`prefers-reduced-motion: reduce` 下停止状态点脉动动画，保留边框色、状态点颜色与紧凑/展开信息层级。",
      "pitfalls": "**① 不同状态销毁重建整个容器节点，导致 CSS 过渡完全不触发。**\n必须保持外层胶囊 DOM 节点恒定，只切换 `data-state`、展开类与内部文案，浏览器才能在两态圆角与内边距之间插值。\n\n**② `border-radius` 写 `50%` 而不是 `999px`。**\n长方形药丸设 `50%` 会变成难看的椭圆，必须写 `999px` 才能保持两端严格半圆胶囊形状。\n\n**③ 忘了给状态点设 `flex: none`。**\n在窄屏或长文案挤压下，不加 `flex: none` 会把圆形状态点压扁成竖椭圆。\n\n---",
      "ai_assets": {
        "prompt": "实现零依赖的灵动胶囊状态条（Dynamic Pill / Status Island）。\n\n原理一句话：保持同一个容器 DOM 节点不变，用纯函数把 idle / thinking / done / error 映射为紧凑/展开形态与语义色，同步过渡圆角（999px <-> 18px）、内边距与呼吸状态点。\n\n做法：\n1. 纯函数 pillStateSpec(state)：\n   - 映射表：{ idle: { expanded: false, accent: 'neutral' }, thinking: { expanded: true, accent: 'accent' }, done: { expanded: false, accent: 'success' }, error: { expanded: true, accent: 'danger' } }；未知态安全回退 idle。\n2. 连续形变 CSS：\n   - 基础紧凑态：display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; transition: padding 280ms cubic-bezier(0.22,1,0.36,1), border-radius 280ms cubic-bezier(0.22,1,0.36,1), border-color 220ms ease;\n   - 展开态 .is-expanded：padding: 10px 18px; border-radius: 18px;\n   - 左侧 7px 圆形状态点（flex: none）：thinking 态 1.1s 呼吸缩放 1->1.35 且透明度 0.35；done 态常亮绿点；error 态常亮红点；容器边框按 accent 切换对应柔和语义色。\n3. 控制器与降级：\n   - 暴露 setState(next) 更新 data-state、data-accent、.is-expanded 并触发 onChange 回调。\n   - prefers-reduced-motion: reduce 停止状态点脉动，过渡时长压至 1ms，完整保留语义色与文案。\n\n硬要求：\n- 严禁在状态切换时销毁重建胶囊外层节点；胶囊圆角必须写 999px 禁止写 50%。\n- 状态点必须加 flex: none 防止被长文案压扁。\n\n验收：\n- 在 idle -> thinking -> done -> error 间切换时，胶囊原地平滑舒展与收拢，圆角和边框语义色同步过渡无闪烁。\n- thinking 态状态点平滑呼吸；开启减弱动效后脉动停止但状态色与文案一目了然。",
        "dont_do": "- 别把药丸圆角写成 `border-radius: 50%` —— 横向胶囊会被拉成难看的橄榄椭圆。\n- 别为每个状态拆出独立的 `v-if` 外框 —— 会彻底丢失“同一物体变形”的连续感。\n- 别给状态点漏掉 `flex: none` —— 文案稍长小圆点就会被压扁。",
        "skill_rule": "# 灵动胶囊状态条 (dynamic-pill) · 跨平台动效规范\n性质：连续 ｜ 平台：both\n\n【核心原理】保持同一个容器 DOM 节点不变，用纯函数把 idle / thinking / done / error 映射为紧凑/展开形态与语义色，同步过渡圆角（999px <-> 18px）、内边距与呼吸状态点。\n\n【硬要求】\n- 严禁在状态切换时销毁重建胶囊外层节点；胶囊圆角必须写 999px 禁止写 50%。\n- 状态点必须加 flex: none 防止被长文案压扁。\n\n【验收标准】\n- 在 idle -> thinking -> done -> error 间切换时，胶囊原地平滑舒展与收拢，圆角和边框语义色同步过渡无闪烁。\n- thinking 态状态点平滑呼吸；开启减弱动效后脉动停止但状态色与文案一目了然。\n\n【禁止做法】\n- 别把药丸圆角写成 `border-radius: 50%` —— 横向胶囊会被拉成难看的橄榄椭圆。\n- 别为每个状态拆出独立的 `v-if` 外框 —— 会彻底丢失“同一物体变形”的连续感。\n- 别给状态点漏掉 `flex: none` —— 文案稍长小圆点就会被压扁。",
        "prompt_en": "Implement a zero-dependency dynamic status pill (Dynamic Pill / Status Island).\n\nCore Principle: Keep the same single container DOM node intact across states, mapping idle / thinking / done / error via a pure function to compact/expanded shapes and semantic accents while synchronously transitioning border-radius (999px <-> 18px), padding, and a breathing status dot.\n\nImplementation:\n1. Pure function pillStateSpec(state):\n   - Mapping table: { idle: { expanded: false, accent: 'neutral' }, thinking: { expanded: true, accent: 'accent' }, done: { expanded: false, accent: 'success' }, error: { expanded: true, accent: 'danger' } }; unknown states safely fall back to idle.\n2. Continuous morphing CSS:\n   - Base compact state: display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; transition: padding 280ms cubic-bezier(0.22,1,0.36,1), border-radius 280ms cubic-bezier(0.22,1,0.36,1), border-color 220ms ease;\n   - Expanded state .is-expanded: padding: 10px 18px; border-radius: 18px;\n   - Left 7px circular status dot (flex: none): thinking state breathes on a 1.1s cycle (scale 1->1.35 and opacity 0.35); done shows a steady green dot; error shows a steady red dot; container border switches to matching subtle semantic accent colors.\n3. Controller and reduced motion:\n   - Expose setState(next) to update data-state, data-accent, .is-expanded, and invoke onChange.\n   - Under prefers-reduced-motion: reduce, stop status dot pulsing, compress transitions to 1ms, and preserve semantic colors and text.\n\nHard Constraints:\n- Never destroy and recreate the outer pill DOM node on state changes; pill border-radius must be 999px, never 50%.\n- Status dot must set flex: none so long text never squashes it.\n\nAcceptance Criteria:\n- Switching across idle -> thinking -> done -> error smoothly expands and contracts the pill in place with synchronized border-radius and semantic border color transitions and zero flicker.\n- The thinking status dot breathes smoothly; with reduced motion enabled, pulsing stops while status colors and text remain clear.",
        "dont_do_en": "- Do NOT write `border-radius: 50%` for a pill — horizontal capsules stretch into ugly olive ovals.\n- Do NOT render separate `v-if` wrapper elements per state — it completely loses the continuity of a single morphing object.\n- Do NOT omit `flex: none` on the status dot — slightly longer text will crush the dot flat.",
        "skill_rule_en": "# Dynamic Status Pill (dynamic-pill) · Cross-Platform Motion Spec\nNature: Continuity | Layer: motion | Platform: both\n\nCore Principle: Keep the same single container DOM node intact across states, mapping idle / thinking / done / error via a pure function to compact/expanded shapes and semantic accents while synchronously transitioning border-radius (999px <-> 18px), padding, and a breathing status dot.\n\nHard Constraints:\n- Never destroy and recreate the outer pill DOM node on state changes; pill border-radius must be 999px, never 50%.\n- Status dot must set flex: none so long text never squashes it.\n\nAcceptance Criteria:\n- Switching across idle -> thinking -> done -> error smoothly expands and contracts the pill in place with synchronized border-radius and semantic border color transitions and zero flicker.\n- The thinking status dot breathes smoothly; with reduced motion enabled, pulsing stops while status colors and text remain clear.\n\nDo NOT Do:\n- Do NOT write `border-radius: 50%` for a pill — horizontal capsules stretch into ugly olive ovals.\n- Do NOT render separate `v-if` wrapper elements per state — it completely loses the continuity of a single morphing object.\n- Do NOT omit `flex: none` on the status dot — slightly longer text will crush the dot flat."
      }
    },
    {
      "id": "edge-back",
      "name": "边缘返回",
      "name_en": "Left-Edge Swipe Back",
      "layer": "mobile",
      "nature": "方向",
      "platform": "touch",
      "status": "shipped",
      "entry": "v-mk-edgeback / edgeSwipeBack(el, { onBack, onProgress, edge, threshold })",
      "source": "iOS 7+ 的交互式返回（左边缘起手，页面跟手右移，过阈值松手才返回）",
      "source_en": "iOS UINavigationController interactive pop gesture (20px edge + 1/3 width / velocity)",
      "file": "effects/edge-back.md",
      "summary": "从左边缘 20px 内起手往右拖，页面跟着走；拖过 1/3 屏宽或向右甩，松手返回。",
      "summary_en": "Interactive drag-to-navigate starting within 20px of the left edge; commits back navigation past 1/3 viewport width or a crisp rightward flick.",
      "problem": "**返回必须和「去」互为镜像。** 进入详情是从右边推过来的，返回就该往右推回去。\n如果返回只靠左上角的箭头按钮，用户的手在屏幕下半部，得横跨整屏去够那个按钮 ——\n这是单手大屏时代最贵的操作成本之一。\n\n第二个问题：**必须先分方向。** 页面上还有竖向滚动。如果横拖和竖滚抢同一个手势，\n用户每次想往下滚都可能被\"拖出去一半又弹回来\"，那比没有这个手势更糟。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| iOS 的「边缘 20px 起手」—— 这个带宽足够窄，不会和内容区的横滑（轮播、左滑删除）打架 | 原生的「前一层视图同时淡入并略微左移」—— 需要路由层的双视图，这里只给 `onProgress` 让你自己驱动 |\n| 「拖到 1/3 或甩一下」双判定 | 原生的进度超过 50% 时松手即返回（不看速度）；这里 1/3 更早，容错更大 |\n| 「手指离开边缘带之后仍然跟手」（`pointerDrag` 里 `setPointerCapture`） | 原生的「拖到一半反向拖回会取消」—— 这里拖回 0 再松手同样不返回，效果接近 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| `edge` | `20px` | 40px 会吃掉轮播卡片的左边缘，12px 太窄、手指容易落空。20 是 iOS 的量级 |\n| 方向判定阈值 | `8px` | 低于 8px 时手指落下的抖动会误判成横滑；高于 12px 用户已经拖出去一段了才分方向，感觉迟钝 |\n| 返回阈值 | 屏宽 `× 0.33` | 1/2 太远（拖到一半屏幕才生效）；1/4 太近（想看看上一页又缩回的意图会被误判成返回） |\n| 速度阈值 | `0.5 px/ms` | 和弹层同一个量级。轻甩一帧 >30px 就该算数 |\n| `onProgress` 上限 | 1（在 `w * threshold` 处到顶） | 到顶就停，不要继续涨到 1.5 —— 进度条涨过头会让人以为\"已经过了还能更过\" |",
      "implementation": "```\ngesture.js:431  shouldGoBack(dx, width, velocity, { threshold, velocityThreshold })  纯函数\ngesture.js:450  edgeSwipeBack(el, { onBack, onProgress, edge, threshold })\nvue/index.js:545  _mkEdgeCleanup  ← 独立清理槽，理由见下\n```\n\n状态机只有四个字段：\n\n```\narmed     起手是否落在左边缘带内\nhorizontal null = 未判 / true = 横滑 / false = 竖滑（已放弃本次手势）\ndx        当前水平位移\nw         起手时的元素宽度（不是屏幕宽 —— 精确指针下整个窗口可能是 1200px）\n```\n\n**速度不自己算** —— `edgeSwipeBack` 把 `pointerDrag` 当成\"带速度的指针流\"用，\n`onMove` / `onEnd` 里的 `_d, v` 直接来自 `gesture.js:113` 那一行。\n全库只有这一份速度计算，别再造第二份（两份一定在一帧率抖动时出现分歧）。",
      "degradation": "**不降级。** 这是功能而不是动效 —— 减弱动效的用户一样需要返回手势。\n\n但它**依赖使用方自己处理 `onProgress` 的动画**：demo 里 `--mk-edge-p` 驱动一条\n进度条，`transition: width 220ms`；`prefers-reduced-motion` 下那条过渡该摘掉，\n否则\"跟手\"会变成\"追手\"。这是使用方的责任，库里没有替它兜底 ——\n因为 `onProgress` 只是给数字，怎么画由调用方决定。",
      "pitfalls": "**① 清理槽必须是独立的。** `v-mk-glass` 和 `v-mk-edgeback` 可能挂在同一个容器上，\n但 `_mkCleanup` 是单槽：谁后挂谁覆盖，先挂的监听器永远摘不掉。\n表现是\"路由切走了，手势还在\"，下次进这个页面会收到双份 `onBack`。\n所以 `vue/index.js:524` 用 `_mkEdgeCleanup`。\n\n**② 桌面鼠标上它照样会触发。** 实测（Chrome，`pointer: coarse` 为 false、`hover: none` 为 false）：\n\n```\n桌面鼠标从左边缘横拖的结果: {\"backs\":1,\"mediaCoarse\":false,\"mediaHoverNone\":false}\n```\n\n`edgeSwipeBack()` 里没有任何 `isTouchLike()` 判定 —— 和 `tap()` / `tilt()` 不一样。\n在桌面站点上引入它，用户从窗口左边往外拖想开侧栏，会把页面\"返回\"掉。\n需要的话由使用方包一层：\n\n```js\nif (matchMedia('(pointer: coarse)').matches) edgeSwipeBack(el, opts);\n```\n\n**③ 竖滑一旦判定就必须彻底放手。**\n\n```js\nif (horizontal === null) {\n  if (dx < 8 && dy < 8) return;\n  horizontal = dx >= dy;\n  if (!horizontal) { onProgress?.(0); return; }   // ← 之后本次手势永不复活\n}\nif (!armed || horizontal === false) return;\n```\n\n`horizontal = false` 是粘性的，不是每帧重算。否则用户先竖着滚一段、再斜着滑，\n手势会在中途\"觉醒\"，页面滚到一半突然开始右移。\n\n**④ `w` 取元素宽度，不取 `window.innerWidth`。**\n在桌面或平板分栏里，手势区可能只是右侧一半；用窗口宽算 1/3 会让阈值大出好几倍，\n用户拖到手酸也不返回。\n\n**⑤ `dx` 用 `Math.max(0, ...)` 夹死。**\n往左拖时 `dx` 保持 0 而不是负数。`shouldGoBack` 里也有 `if (!(dx > 0)) return false` 兜底 ——\n两层都留着，因为 `onProgress` 要拿去乘百分比，负数会在 `width: calc()` 里变成负宽度。\n\n**⑥ `pointercancel` 曾被当成\"松手\"。** 拖过阈值后浏览器抢走手势（系统返回、\n外层滚动接管），旧实现会照常判定并触发 `onBack` —— 用户没松手，页面却返回了。\n已修复：`pointercancel` 直接 `reset()` 归零，不进入判定。这条和\n`bottom-sheet` / `swipe` / `pull-refresh` 是同一修法，见 `bottom-sheet.md` 第 7 栏⑦。\n\n**⑦ 和 `v-mk-swipe`（左滑删除）会抢。**\n左滑删除也是横滑，也在列表行上。删掉的那一侧是往左、返回是往右，方向不冲突；\n但如果左侧滑删除的元素本身就贴着屏幕左边缘 20px，起手那一下两个都在等 ——\n`edgeSwipeBack` 会在 8px 时判成横滑并 `onProgress`，左滑删除也会拉起。\n唯一稳的分法是把左滑删除的行往右留出至少 20px 的边距，或者干脆别在同一屏用。\n\n---",
      "ai_assets": {
        "prompt": "实现 iOS 风格的左边缘返回手势。原生 Pointer Events，不引依赖。\n\n原理一句话：左边缘带内的 pointerdown 起手 → 判方向 → 看位移或末速决定是否返回。全部是指针数学，没有任何动画引擎。\n\n行为：\n- 只在触屏/粗指针上生效：matchMedia('(pointer: coarse)')。\n  桌面鼠标不要挂（不然用户从窗口左边缘往外拖想开侧栏，会把页面返回掉）。\n- 起手必须落在容器左边缘 20px 内（edge = 20）；\n  不在带内，这整次手势都不参与，连方向判定都不做。\n- 位移达到 8px 才判方向：水平位移 >= 垂直位移 → 横滑，接管；\n  否则这次手势永久交给页面滚动（标记是粘性的，不每帧重算）。\n- 横滑期间每帧回调 onProgress(clamp(dx / (容器宽 * 0.33), 0, 1))。\n  宽度用容器 getBoundingClientRect().width，不要用 window.innerWidth ——\n  在平板分栏或桌面上手势区可能只是半屏。\n- 松手判定（纯函数）：\n    返回 = (dx > 0) && (dx > 容器宽 * 0.33 || velocity > 0.5 /* px/ms，向右为正 */)\n- dx 用 Math.max(0, ...) 钳死为非负：负值会让使用方的 calc() 算出负宽度。\n- 速度复用同一个 pointer 拖拽器算出来的那份（px/ms，e.timeStamp 做分母），\n  不要另算一份 —— 两份速度在帧率抖动时一定会出现分歧。\n- 返回 teardown：摘掉全部监听 + 把进度归零。\n\n状态机只有四个字段：armed（起手在带内）/ horizontal（null=未判、true=横、false=已放弃）/\ndx / w。不要引入第五个状态。\n\n硬要求：\n- pointercancel 不走松手判定，直接归零（已实现；浏览器抢手势时用户没有松手）。\n- onProgress 是唯一出口 —— 组件不碰 DOM，怎么画（页面位移 / 侧边进度条）\n  由使用方用这个数字决定。\n- 挂载在会滚动的页面容器上时，容器必须允许竖向滚动穿透\n  （不要给整个容器设 touch-action: none）。\n\n验收：\n- 左边缘 5px 起手横拖到 40% 松手 → onBack 恰好一次。\n- 左边缘 50px 起手同样的拖动 → 不触发。\n- 竖向滚 30px 再斜着往右拖 → 不触发（这次手势已经交还给滚动）。\n- 拖到 50% 往左拖回 0 再松手 → 不触发。\n- 桌面鼠标同样的拖动 → 不触发。\n- 100 次挂载/卸载后不残留监听器（teardown 全摘）。",
        "dont_do": "- 别用 `touchstart/touchmove` —— 拿不到鼠标端的统一行为，也拿不到 `setPointerCapture`。\n- 别在 `pointermove` 里每帧 `preventDefault()`，那会让 passive 监听器优化失效、\n  滚动掉帧。方向判定用\"不接管\"而不是\"拦下来\"。\n- 别把\"返回\"直接绑成 `history.back()` 写死在组件里 —— 回调是使用方的，\n  组件只报告\"该返回了\"。",
        "skill_rule": "# 边缘返回 (edge-back) · 跨平台动效规范\n性质：方向 ｜ 平台：touch\n\n【核心原理】左边缘带内的 pointerdown 起手 → 判方向 → 看位移或末速决定是否返回。全部是指针数学，没有任何动画引擎。\n\n【硬要求】\n- pointercancel 不走松手判定，直接归零（已实现；浏览器抢手势时用户没有松手）。\n- onProgress 是唯一出口 —— 组件不碰 DOM，怎么画（页面位移 / 侧边进度条）\n  由使用方用这个数字决定。\n- 挂载在会滚动的页面容器上时，容器必须允许竖向滚动穿透\n  （不要给整个容器设 touch-action: none）。\n\n【验收标准】\n- 左边缘 5px 起手横拖到 40% 松手 → onBack 恰好一次。\n- 左边缘 50px 起手同样的拖动 → 不触发。\n- 竖向滚 30px 再斜着往右拖 → 不触发（这次手势已经交还给滚动）。\n- 拖到 50% 往左拖回 0 再松手 → 不触发。\n- 桌面鼠标同样的拖动 → 不触发。\n- 100 次挂载/卸载后不残留监听器（teardown 全摘）。\n\n【禁止做法】\n- 别用 `touchstart/touchmove` —— 拿不到鼠标端的统一行为，也拿不到 `setPointerCapture`。\n- 别在 `pointermove` 里每帧 `preventDefault()`，那会让 passive 监听器优化失效、\n  滚动掉帧。方向判定用\"不接管\"而不是\"拦下来\"。\n- 别把\"返回\"直接绑成 `history.back()` 写死在组件里 —— 回调是使用方的，\n  组件只报告\"该返回了\"。",
        "prompt_en": "Implement an iOS-style left-edge swipe-back gesture using native Pointer Events, zero dependencies.\n\nCore Principle: pointerdown inside the left-edge strip -> determine direction -> decide back navigation from displacement or end velocity. Pure pointer math with zero animation engine.\n\nImplementation:\n- Activate only on touch/coarse pointers: matchMedia('(pointer: coarse)'). Never attach on desktop mice (otherwise dragging out from the left window edge to open a sidebar would accidentally navigate back).\n- Gesture must start within 20px of the container's left edge (edge = 20); if outside this strip, the entire gesture does not participate—not even direction detection.\n- Determine direction only once displacement reaches 8px: horizontal displacement >= vertical displacement -> horizontal swipe, claim gesture; otherwise permanently yield this gesture to page scrolling (the flag is sticky and never recomputed per frame).\n- During horizontal swipe, call onProgress(clamp(dx / (containerWidth * 0.33), 0, 1)) every frame. Measure width from the container's getBoundingClientRect().width, never window.innerWidth — on split-screen tablets or desktop panes the gesture area may only be half-screen.\n- Release decision (pure function):\n    goBack = (dx > 0) && (dx > containerWidth * 0.33 || velocity > 0.5 /* px/ms, positive rightward */)\n- Clamp dx to non-negative via Math.max(0, ...): negative values would cause caller calc() expressions to evaluate negative widths.\n- Reuse the velocity computed by the shared pointer tracker (px/ms with e.timeStamp as denominator) rather than computing a second one — two velocity values inevitably diverge under frame-rate jitter.\n- Return teardown: removes all listeners and resets progress to 0.\n- State machine has strictly four fields: armed (started in edge strip) / horizontal (null = undecided, true = horizontal, false = yielded) / dx / w. Do not introduce a fifth state.\n\nHard Constraints:\n- pointercancel must not run the release decision; reset progress directly to 0 (when the browser steals the gesture, the user did not release).\n- onProgress is the sole output — the component never touches the DOM; how progress is rendered (page translation / edge progress bar) is decided by the caller using that number.\n- When mounted on a scrollable page container, the container must allow vertical scrolling to pass through (never set touch-action: none on the whole container).\n\nAcceptance Criteria:\n- Dragging horizontally from 5px inside the left edge to 40% and releasing -> onBack fires exactly once.\n- Same drag starting 50px from the left edge -> does not trigger.\n- Scrolling vertically 30px then dragging diagonally right -> does not trigger (gesture already yielded to scrolling).\n- Dragging to 50%, sliding back left to 0, then releasing -> does not trigger.\n- Same drag with a desktop mouse -> does not trigger.\n- After 100 mount/unmount cycles, zero dangling listeners remain (teardown removes all).\n",
        "dont_do_en": "- Do NOT use `touchstart/touchmove` — you lose unified mouse/pointer behavior and `setPointerCapture`.\n- Do NOT call `preventDefault()` every frame in `pointermove` — that breaks passive listener optimizations and drops scroll frames; handle direction by choosing not to claim the gesture instead of blocking it.\n- Do NOT hardcode `history.back()` inside the component — navigation is the caller's callback; the component only reports that it is time to go back.",
        "skill_rule_en": "# Left-Edge Swipe Back (edge-back) · Cross-Platform Motion Spec\nNature: Direction | Layer: mobile | Platform: touch\n\nCore Principle: pointerdown inside the left-edge strip -> determine direction -> decide back navigation from displacement or end velocity. Pure pointer math with zero animation engine.\n\nHard Constraints:\n- pointercancel must not run the release decision; reset progress directly to 0 (when the browser steals the gesture, the user did not release).\n- onProgress is the sole output — the component never touches the DOM; how progress is rendered (page translation / edge progress bar) is decided by the caller using that number.\n- When mounted on a scrollable page container, the container must allow vertical scrolling to pass through (never set touch-action: none on the whole container).\n\nAcceptance Criteria:\n- Dragging horizontally from 5px inside the left edge to 40% and releasing -> onBack fires exactly once.\n- Same drag starting 50px from the left edge -> does not trigger.\n- Scrolling vertically 30px then dragging diagonally right -> does not trigger (gesture already yielded to scrolling).\n- Dragging to 50%, sliding back left to 0, then releasing -> does not trigger.\n- Same drag with a desktop mouse -> does not trigger.\n- After 100 mount/unmount cycles, zero dangling listeners remain (teardown removes all).\n\nDo NOT Do:\n- Do NOT use `touchstart/touchmove` — you lose unified mouse/pointer behavior and `setPointerCapture`.\n- Do NOT call `preventDefault()` every frame in `pointermove` — that breaks passive listener optimizations and drops scroll frames; handle direction by choosing not to claim the gesture instead of blocking it.\n- Do NOT hardcode `history.back()` inside the component — navigation is the caller's callback; the component only reports that it is time to go back."
      }
    },
    {
      "id": "enter",
      "name": "进场",
      "name_en": "Viewport Staggered Reveal",
      "layer": "motion",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-enter（`--section` / `--scale` / `--fade` 变体）/ inView / staggerIn",
      "source": "Framer Motion whileInView 的语义 + IntersectionObserver 的标准做法",
      "source_en": "Framer Motion whileInView (IntersectionObserver + 70ms capped stagger)",
      "file": "effects/enter.md",
      "summary": "元素滚到视口内才入场：上移 16px + 淡入，一组元素按 70ms 级联，全程零滚动监听。",
      "summary_en": "IntersectionObserver-driven 16px rise + fade with 70ms stagger capped so long lists never feel sluggish; zero scroll listeners.",
      "problem": "**首屏之后的内容需要一个\"它来了\"的时刻。** 用户滚到一段新内容时，\n如果它早就躺在那儿，视线落点没有锚——入场动画就是那个锚，它告诉用户\n\"从这儿开始是新的一段\"。\n\n第二个问题更实际：**页面初次加载时必须区分\"还没滚到\"和\"加载失败\"。**\n进场效果全部由 IntersectionObserver 驱动、没有任何\"预隐藏\"的 JS——\nJS 挂不上时内容照常可见（见第 6 节）。这是所有滚动驱动效果的底线：\n**动画可以失败，内容不能消失。**",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| Framer `whileInView` 的\"进入视口触发一次\"语义 | 它的 `amount` / `margin` 全套配置——这里只留一个 threshold |\n| 级联 70ms 一档、封顶 600ms | 按视口内实际可见数量动态算 delay（固定级联更可预测） |\n| 四个变体（位移/区块/缩放/纯淡） | 模糊入场（`.mk-enter--blur` 曾有过，和 blur 系统耦合后拆掉了） |\n\n`rootMargin: '0px 0px -8% 0px'` 这个底部内缩是手感的关键：\n元素要**再往上滚 8% 才算\"到了\"**。不加的话，元素刚露出一条边就开始入场，\n用户看到的动画有一半发生在屏幕外。",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 位移 | `--mk-dist-enter` = 16px | 超过 24px 会像\"飞进来\"抢内容；低于 8px 淡入和位移分不开。16 是\"挪了一下\"的量级 |\n| 区块级变体 | 32px | 整段内容的入场要有分量，位移加倍才和卡片级区分得开 |\n| 时长 | `--mk-dur-4` = 380ms | 区块级。这是\"入场\"不是\"反馈\"，240ms 会显得急 |\n| 缩放变体 | `scale(0.96)` | 配卡片/弹层。0.92 以下像弹窗砸出来 |\n| 级联步长 | 70ms，封顶 600ms | 70ms 是\"同批\"的上限感知（超过 100ms 用户会把它们读成两次事件）。封顶保证第 10 个元素不用等 700ms |\n| `threshold` | 0.15 | 元素露出 15% 才触发。1.0 会让很高的元素永远不触发 |\n| `.is-done` | 清 `will-change` + 清内联 delay | 见第 7 节①②——这两行是整条效果最容易省略又最不能省的 |",
      "implementation": "```\nin-view.js:21   inView(targets, onEnter, { threshold, rootMargin, once })\nin-view.js:52   staggerIn(targets, { step, cap })\nvue/index.js:52 v-mk-enter（reduced 直接 is-in；transitionend 后 is-done）\nmotion.css:92   .mk-enter 系列四变体\n```\n\n两条结构性决定：\n\n**① 预隐藏写在 CSS，触发写在 JS——但 JS 挂不上时必须兜底。**\n`.mk-enter { opacity: 0; transform: … }` 是初始态；`inView()` 在**没有\nIntersectionObserver 的环境**（极老 webview）里直接对所有元素触发回调。\n顺序不能反：先加类再观察，还是先观察再加类，决定了\"JS 失败时内容可不可见\"。\n\n**② 同帧加类会被合并，必须先让\"未进入\"状态落一帧。**\n\n```js\nrequestAnimationFrame(() => {\n  el.style.transitionDelay = `${delay}ms`;\n  el.classList.add('is-in');\n});\n```\n\n如果元素刚插入 DOM 就在同一帧加 `is-in`，浏览器把两次样式变更合并，\n过渡从最终值直接开始——**看不到入场，只有终态**。`staggerIn` 里那个\n`requestAnimationFrame` 就是干这个的，删掉它批量入场会静默失效。",
      "degradation": "**走 `motion` 那档：减。**\n\n`prefers-reduced-motion` 下 `v-mk-enter` **直接加 `is-in`**，跳过观察器——\n不播动画，但\"内容可见\"这件事照常完成。`motion.css` 的全局减弱块把\n`--mk-dist-enter` 归零、时长压到 1ms，就算哪条路径漏了直接加类，\n视觉上也不会有位移。\n\n两层兜底指向同一件事：**这条效果的\"功能\"是内容可见，\"动效\"只是它的表达。**\n表达可以减，功能不能丢。",
      "pitfalls": "**① 入场结束后必须清内联 `transition-delay`。**\n级联给每个元素写了 `el.style.transitionDelay = '70ms'` 这类内联值。不清理的话，\n它作用于该元素**之后的所有过渡**——包括按压回弹、颜色切换，全部被拖慢 70ms。\n`v-mk-enter` 在 `transitionend` 后加 `.is-done`（清 `will-change`）并\n`el.style.transitionDelay = ''`（`vue/index.js:74`）。自己手写入场时，\n这是最常被省略的一行，症状是\"整个页面的交互都慢半拍\"。\n\n**② `transitionend` 不会总来，要给兜底。**\n过渡被中断（元素滚出视口、display 变化、减弱动效把时长压到 1ms）时\n`transitionend` 可能不触发，`is-done` 就永远加不上。\n`setTimeout(done, 900)` 兜底（380ms 过渡 + 级联上限 600ms 再留余量）。\n\n**③ `once: true` 之后元素不会再入场第二次。**\n列表复用、tab 切换后重新显示的元素，类还在 `is-in` 上，不会再有动画——\n这是默认语义。要每次出现都播，传 `once: false`，但注意 IO 会一直持有引用，\n**长列表上用它要记得 teardown**。\n\n**④ 级联的 delay 写在元素上，但\"第几个\"是挂载顺序。**\n`staggerIn` 按数组顺序编号。如果 DOM 顺序和业务顺序不一致（虚拟列表、\n排序后的渲染），级联会按 DOM 序播——看起来就是\"乱序入场\"。\n虚拟列表场景建议不用级联，每行独立入场。\n\n**⑤ `rootMargin` 的百分比是相对观察器 root 的，不是元素的。**\n`-8%` 在 `root: null`（视口）时是视口高的 8%。如果使用方传了自定义\n`root`（滚动容器），8% 就变成那个容器的高度的 8%——容器很矮时几乎等于 0，\n元素一露边就入场。用自定义 root 时建议改用像素。\n\n**⑥ 别把 `.mk-enter` 加在会 transform 定位的元素上。**\n初始态 `transform: translate3d(0, 16px, 0)` 会**覆盖**元素自己的 transform\n（tilt、磁吸、dock 都是 transform 驱动的）。要叠加就分两层：外层包一个\n`.mk-enter`，内层挂 tilt/dock。这条和 `glass` 的 `.is-press` 互斥是同一类问题。\n\n---",
      "ai_assets": {
        "prompt": "实现「滚动入场」：元素进入视口后位移 + 淡入一次。IntersectionObserver，不引依赖。\n\n原理一句话：用可见性观察器决定\"该入场了\"，用 CSS 过渡做位移。时机与动画解耦，不要用滚动事件自己算位置。\n\n结构：\n  CSS 预隐藏（没有 JS 时由兜底保证可见，见下）：\n    .enter { opacity: 0; transform: translate3d(0, 16px, 0);\n             transition: opacity 380ms cubic-bezier(0.22,1,0.36,1),\n                         transform 380ms cubic-bezier(0.22,1,0.36,1); }\n    .enter.is-in { opacity: 1; transform: translate3d(0, 0, 0); }\n    .enter.is-done { will-change: auto; }\n\n行为：\n- IntersectionObserver，threshold 0.15，rootMargin '0px 0px -8% 0px'\n  （元素要再进视口 8% 才触发，避免动画一半发生在屏幕外）。\n- 进入后 requestAnimationFrame 再加 .is-in —— 元素刚插入 DOM 就同帧加类\n  会被浏览器合并，过渡直接从终态开始，动画静默失效。\n- once 默认 true：触发后 unobserve。\n- 环境没有 IntersectionObserver：立即对所有元素触发回调，保证内容可见。\n  这是兜底的底线 —— 动画可以缺，内容不能消失。\n- prefers-reduced-motion：跳过观察器直接加 .is-in。\n\n级联（同批多个元素）：\n- 按数组顺序给每个元素写内联 transition-delay = i * 70ms，封顶 600ms。\n- 同样要在 rAF 后再加 is-in。\n- 过渡结束（transitionend）后：加 .is-done 清 will-change，\n  并把内联 transitionDelay 清成 '' —— 否则级联延迟会拖慢该元素\n  之后的所有过渡（包括按压反馈），表现为整个页面交互慢半拍。\n- transitionend 不总来（中断/时长被压到 1ms），用 setTimeout(900) 兜底。\n\n硬要求：\n- 初始隐藏只能写在 CSS 的 .enter 类上，JS 不做预隐藏 ——\n  JS 失败时元素必须是可见的。\n- will-change 只在动画期间存在，.is-done 必须释放。\n- 不要把这个类加在自身被 transform 驱动的元素（tilt/磁吸）上，\n  初始态的 translate3d 会覆盖它们的 transform。\n\n验收：\n- 刷新页面：首屏元素立即入场（不等滚动）；下方元素滚到 15% 露出才入场。\n- 级联：同批 5 个元素依次相差 70ms；第 10 个元素 delay 不超过 600ms。\n- 入场完成后 getComputedStyle(el).transitionDelay 为 '0s'，\n  will-change 为 auto。\n- 禁用 JS：内容全部可见（只有动画缺失）。\n- prefers-reduced-motion：无位移无淡入，内容直接可见。",
        "dont_do": "- 别用 `scroll` 事件 + `getBoundingClientRect` 逐帧判断——\n  IntersectionObserver 由合成器调度，不占主线程，这是入场效果唯一正确的入场券。\n- 别给首屏元素也配 delay——首屏的级联延迟是白等的，首屏只该有一个整体的错相。\n- 别把入场做成\"退场对称\"——离开视口再播一次退场动画是反模式，\n  用户往上回滚时会看到内容反复消失又出现。",
        "skill_rule": "# 进场 (enter) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】用可见性观察器决定\"该入场了\"，用 CSS 过渡做位移。时机与动画解耦，不要用滚动事件自己算位置。\n\n【硬要求】\n- 初始隐藏只能写在 CSS 的 .enter 类上，JS 不做预隐藏 ——\n  JS 失败时元素必须是可见的。\n- will-change 只在动画期间存在，.is-done 必须释放。\n- 不要把这个类加在自身被 transform 驱动的元素（tilt/磁吸）上，\n  初始态的 translate3d 会覆盖它们的 transform。\n\n【验收标准】\n- 刷新页面：首屏元素立即入场（不等滚动）；下方元素滚到 15% 露出才入场。\n- 级联：同批 5 个元素依次相差 70ms；第 10 个元素 delay 不超过 600ms。\n- 入场完成后 getComputedStyle(el).transitionDelay 为 '0s'，\n  will-change 为 auto。\n- 禁用 JS：内容全部可见（只有动画缺失）。\n- prefers-reduced-motion：无位移无淡入，内容直接可见。\n\n【禁止做法】\n- 别用 `scroll` 事件 + `getBoundingClientRect` 逐帧判断——\n  IntersectionObserver 由合成器调度，不占主线程，这是入场效果唯一正确的入场券。\n- 别给首屏元素也配 delay——首屏的级联延迟是白等的，首屏只该有一个整体的错相。\n- 别把入场做成\"退场对称\"——离开视口再播一次退场动画是反模式，\n  用户往上回滚时会看到内容反复消失又出现。",
        "prompt_en": "Implement viewport scroll-reveal: elements translate and fade in once upon entering the viewport using IntersectionObserver, zero dependencies.\n\nCore Principle: Use a visibility observer to decide \"time to enter\" and CSS transitions for the motion. Decouple timing from animation; never compute positions manually in scroll events.\n\n  CSS pre-hidden (with fallback ensuring visibility when JS is absent, see below):\n    .enter { opacity: 0; transform: translate3d(0, 16px, 0);\n             transition: opacity 380ms cubic-bezier(0.22,1,0.36,1),\n                         transform 380ms cubic-bezier(0.22,1,0.36,1); }\n    .enter.is-in { opacity: 1; transform: translate3d(0, 0, 0); }\n    .enter.is-done { will-change: auto; }\n\nImplementation:\n- IntersectionObserver with threshold 0.15 and rootMargin '0px 0px -8% 0px' (elements must enter 8% further into the viewport before triggering so half the animation doesn't happen off-screen).\n- Add .is-in on the next requestAnimationFrame after intersection — adding the class in the same frame an element is inserted into the DOM gets coalesced by the browser, starting directly at the end state so the transition silently fails.\n- once defaults to true: unobserve after triggering.\n- Fallback when IntersectionObserver is unavailable: immediately trigger callback on all elements to ensure content stays visible (animation may be missing, content must never disappear).\n- prefers-reduced-motion: skip the observer and add .is-in directly.\n- Stagger (batch of multiple elements):\n  - Write inline transition-delay = i * 70ms in array order, capped at 600ms.\n  - Still add .is-in after rAF.\n  - After transitionend: add .is-done to clear will-change, and reset inline transitionDelay to '' — otherwise the stagger delay slows down every subsequent transition on that element (including press feedback), making the whole page feel half a beat slow.\n  - Since transitionend does not always fire (interrupted or duration compressed to 1ms), add a setTimeout(900) fallback.\n\nHard Constraints:\n- Initial hiding must live only on the CSS .enter class, never pre-hidden by JS — if JS fails, elements must stay visible.\n- will-change exists only during the animation and must be released by .is-done.\n- Do not apply this class to elements already driven by transform (tilt/magnetic), as the initial translate3d will overwrite their transform.\n\nAcceptance Criteria:\n- On page refresh: above-the-fold elements reveal immediately (without waiting for scroll); below-the-fold elements reveal once 15% visible.\n- Stagger: 5 batched elements enter 70ms apart; the 10th element's delay never exceeds 600ms.\n- After entrance finishes, getComputedStyle(el).transitionDelay is '0s' and will-change is auto.\n- With JS disabled: all content is visible (only animation missing).\n- prefers-reduced-motion: zero translation, zero fade, content immediately visible.",
        "dont_do_en": "- Do NOT check `getBoundingClientRect` every frame inside a `scroll` event — `IntersectionObserver` is scheduled by the compositor off the main thread and is the only proper trigger for viewport reveals.\n- Do NOT give above-the-fold elements a stagger delay — staggering initial above-the-fold content is wasted wait time; initial load should have one cohesive phase.\n- Do NOT make reveals symmetric with exit animations — playing an exit animation when leaving the viewport is an anti-pattern that makes content repeatedly vanish and reappear as users scroll back up.",
        "skill_rule_en": "# Viewport Staggered Reveal (enter) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: motion | Platform: both\n\nCore Principle: Use a visibility observer to decide \"time to enter\" and CSS transitions for the motion. Decouple timing from animation; never compute positions manually in scroll events.\n\nHard Constraints:\n- Initial hiding must live only on the CSS .enter class, never pre-hidden by JS — if JS fails, elements must stay visible.\n- will-change exists only during the animation and must be released by .is-done.\n- Do not apply this class to elements already driven by transform (tilt/magnetic), as the initial translate3d will overwrite their transform.\n\nAcceptance Criteria:\n- On page refresh: above-the-fold elements reveal immediately (without waiting for scroll); below-the-fold elements reveal once 15% visible.\n- Stagger: 5 batched elements enter 70ms apart; the 10th element's delay never exceeds 600ms.\n- After entrance finishes, getComputedStyle(el).transitionDelay is '0s' and will-change is auto.\n- With JS disabled: all content is visible (only animation missing).\n- prefers-reduced-motion: zero translation, zero fade, content immediately visible.\n\nDo NOT Do:\n- Do NOT check `getBoundingClientRect` every frame inside a `scroll` event — `IntersectionObserver` is scheduled by the compositor off the main thread and is the only proper trigger for viewport reveals.\n- Do NOT give above-the-fold elements a stagger delay — staggering initial above-the-fold content is wasted wait time; initial load should have one cohesive phase.\n- Do NOT make reveals symmetric with exit animations — playing an exit animation when leaving the viewport is an anti-pattern that makes content repeatedly vanish and reappear as users scroll back up."
      }
    },
    {
      "id": "fan",
      "name": "扇形手牌展开",
      "name_en": "3D Card Fan Spread",
      "layer": "3d",
      "nature": "方向",
      "platform": "both",
      "status": "shipped",
      "entry": "fan(el) + .mk-fan / .mk-fan__card（单变量 --spread 控张开角，纯 CSS 悬停）",
      "source": "扑克手牌扇形展开（相对中心序号 (i - center) * spread + 底部圆心旋转 + 归零平铺降级）",
      "source_en": "Physical hand of cards (shared bottom pivot + single CSS spread factor)",
      "file": "effects/fan.md",
      "summary": "多张卡片绕底部中心点叠成一把闭合扇子，悬停或点击时只需改一个 `--spread` 角度变量，整副卡片同步对称张开成优雅扇面。",
      "summary_en": "Cards stacked around a shared bottom pivot fan open symmetrically on hover by multiplying a single CSS spread coefficient — keeping the center card upright.",
      "problem": "**多张相册封面、主题预览或会员权益卡并排摆着太占空间，叠在一起又看不出有几张。** 把每张卡的角度写成「相对中心序号 × 单位展开角」，闭合时像一叠精致卡片、一碰就丝滑张开，且完全由 CSS 过渡驱动。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 相对中心序号 `k = i - (n - 1) / 2`（5 张得 `-2, -1, 0, +1, +2`），天然左右对称 | 为 5 张卡分别硬编码 5 套 `:nth-child()` 旋转规则 |\n| 仅改变单变量 `--spread`（如 `4deg → 13deg`）同时联动外扩位移 | JS 逐张手算三角函数坐标 |\n| `prefers-reduced-motion` 下归零成横向 `flex` 排列 | 卡片永远叠死看不见后面的内容 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 闭合 / 展开单位角 | `3.5deg` → `13deg` | 闭合时微露 3.5° 暗示“下面还有牌”；展开 13°（5 张共 52°）优雅舒展又不倒挂 |\n| 旋转支点 | `transform-origin: 50% 130%` | 支点落在卡片底边下方 30%，展开弧线才像真手拿着一把扇子 |\n| 过渡曲线 | `380ms ease-snap` | 带轻微弹性过冲，像手指弹开扑克牌的脆感 |",
      "implementation": "```\nsrc/core/scene3d.js:280  fan(el)       仅写入相对中心序号 --mk-i，零监听\nstyles/3d.css:242        .mk-fan / .mk-fan__card（亦支持 CSS sibling-index() 零 JS 兜底）\n```",
      "degradation": "**走 `3d` 层专属契约：归零塌回平面并切为横向 Flex 列表。**",
      "pitfalls": "**① `transform-origin` 留在默认中心 `50% 50%`。**\n绕卡片正中心旋转只会让牌原地打转互相打架，完全没有扇形弧度；必须把支点下移到 `50% 125% ~ 140%`。\n\n**② 每张卡 `z-index` 不递增导致展开时前后压盖顺序混乱。**\n自然 DOM 顺序即可保证右压左，悬停某张卡时可额外轻微抬升 `translateY(-10px)` 突出当前牌。\n\n---",
      "ai_assets": {
        "prompt": "实现对称扇形手牌展开动效（Card Fan Spread），零动画库依赖。\n\n原理一句话：每张卡片只持有一个相对中心序号 --k（如 5 张为 -2, -1, 0, 1, 2），transform 统一写成 rotate(calc(var(--k) * var(--spread))) translateX(calc(var(--k) * var(--shift)))，悬停或点击只改 --spread 和 --shift 两个变量即可整副对称张开。\n\n做法：\n1. 相对中心序号：对 N 张卡片写入 --k = i - (N - 1) / 2（现代浏览器亦可纯 CSS 用 sibling-index() - (sibling-count() + 1) / 2 兜底）。\n2. CSS 扇形几何：\n   - .fan { --spread: 3.5deg; --shift: 6px; position: relative; display: grid; place-items: center; }\n   - .fan-card {\n       grid-area: 1 / 1; transform-origin: 50% 130%;\n       transform: rotate(calc(var(--k, 0) * var(--spread))) translateX(calc(var(--k, 0) * var(--shift)));\n       transition: transform 380ms cubic-bezier(0.34, 1.56, 0.64, 1);\n     }\n   - @media (hover: hover) { .fan:hover { --spread: 13deg; --shift: 22px; } }\n   - 触屏/点击支持：.fan.is-open { --spread: 13deg; --shift: 22px; }\n3. 降级：\n   - @media (prefers-reduced-motion: reduce) {\n       .fan { display: flex; gap: 10px; }\n       .fan-card { transform: none !important; transition: none; }\n     }\n\n硬要求：\n- 严禁为每张卡写死单独的 :nth-child() 角度 —— 必须由 --k * --spread 统一计算，增删卡片自动居中对称。\n- transform-origin 必须设在卡片底边下方（如 50% 130%），不可用默认中心。\n- prefers-reduced-motion: reduce 下必须切为 display: flex 展平，防止所有卡片叠死在同一格。\n\n验收：\n- 3 张、5 张、7 张卡片均自动左右完全对称；悬停或点击时平滑弹开成优雅扇面，松开/移出利落收拢。\n- 开启减弱动效后自动排成横向一行，每张卡片完整可见。",
        "dont_do": "- 别把 `transform-origin` 留在默认的 `50% 50%` —— 牌只会像风车一样叠着打转。\n- 别用 JS 监听 `mouseenter` 逐张算 `sin/cos` —— 改两个 CSS 变量就是全部逻辑。\n- 别忘了在减弱动效下把容器改成 `display: flex`，否则叠在一起的卡永远打不开。",
        "skill_rule": "# 扇形手牌展开 (fan) · 跨平台动效规范\n性质：方向 ｜ 平台：both\n\n【核心原理】每张卡片只持有一个相对中心序号 --k（如 5 张为 -2, -1, 0, 1, 2），transform 统一写成 rotate(calc(var(--k) * var(--spread))) translateX(calc(var(--k) * var(--shift)))，悬停或点击只改 --spread 和 --shift 两个变量即可整副对称张开。\n\n【硬要求】\n- 严禁为每张卡写死单独的 :nth-child() 角度 —— 必须由 --k * --spread 统一计算，增删卡片自动居中对称。\n- transform-origin 必须设在卡片底边下方（如 50% 130%），不可用默认中心。\n- prefers-reduced-motion: reduce 下必须切为 display: flex 展平，防止所有卡片叠死在同一格。\n\n【验收标准】\n- 3 张、5 张、7 张卡片均自动左右完全对称；悬停或点击时平滑弹开成优雅扇面，松开/移出利落收拢。\n- 开启减弱动效后自动排成横向一行，每张卡片完整可见。\n\n【禁止做法】\n- 别把 `transform-origin` 留在默认的 `50% 50%` —— 牌只会像风车一样叠着打转。\n- 别用 JS 监听 `mouseenter` 逐张算 `sin/cos` —— 改两个 CSS 变量就是全部逻辑。\n- 别忘了在减弱动效下把容器改成 `display: flex`，否则叠在一起的卡永远打不开。",
        "prompt_en": "Implement a symmetrical card fan spread animation (Card Fan Spread), zero animation library dependencies.\n\nCore Principle: Assign each card a single center-relative index --k (e.g., -2, -1, 0, 1, 2 for 5 cards), write transform uniformly as rotate(calc(var(--k) * var(--spread))) translateX(calc(var(--k) * var(--shift))), and update only --spread and --shift on hover or click to spread the entire hand symmetrically.\n\nImplementation:\n1. Center-relative index: write --k = i - (N - 1) / 2 for N cards (modern browsers can also fall back to pure CSS sibling-index() - (sibling-count() + 1) / 2).\n2. CSS fan geometry:\n   - .fan { --spread: 3.5deg; --shift: 6px; position: relative; display: grid; place-items: center; }\n   - .fan-card {\n       grid-area: 1 / 1; transform-origin: 50% 130%;\n       transform: rotate(calc(var(--k, 0) * var(--spread))) translateX(calc(var(--k, 0) * var(--shift)));\n       transition: transform 380ms cubic-bezier(0.34, 1.56, 0.64, 1);\n     }\n   - @media (hover: hover) { .fan:hover { --spread: 13deg; --shift: 22px; } }\n   - Touch / click support: .fan.is-open { --spread: 13deg; --shift: 22px; }\n3. Reduced motion:\n   - @media (prefers-reduced-motion: reduce) {\n       .fan { display: flex; gap: 10px; }\n       .fan-card { transform: none !important; transition: none; }\n     }\n\nHard Constraints:\n- Never hardcode separate :nth-child() angles per card — everything must be computed uniformly from --k * --spread so adding or removing cards stays automatically centered and symmetric.\n- transform-origin must be placed below the card's bottom edge (such as 50% 130%), never at the default center.\n- Under prefers-reduced-motion: reduce, must switch to display: flex to lay cards flat so all cards do not stack inseparably in one grid cell.\n\nAcceptance Criteria:\n- 3, 5, and 7 cards all maintain exact left-right symmetry; hovering or clicking smoothly fans out into an elegant arc, and leaving/clicking again closes briskly.\n- Enabling reduced motion automatically arranges cards into a horizontal row with every card fully visible.",
        "dont_do_en": "- Do NOT leave `transform-origin` at the default `50% 50%` — the cards will just spin stacked on top of each other like a pinwheel.\n- Do NOT compute `sin/cos` per card in a JS `mouseenter` handler — updating two CSS variables is the entire logic.\n- Do NOT forget to switch the container to `display: flex` under reduced motion, otherwise stacked cards can never be opened or read.",
        "skill_rule_en": "# 3D Card Fan Spread (fan) · Cross-Platform Motion Spec\nNature: Direction | Layer: 3d | Platform: both\n\nCore Principle: Assign each card a single center-relative index --k (e.g., -2, -1, 0, 1, 2 for 5 cards), write transform uniformly as rotate(calc(var(--k) * var(--spread))) translateX(calc(var(--k) * var(--shift))), and update only --spread and --shift on hover or click to spread the entire hand symmetrically.\n\nHard Constraints:\n- Never hardcode separate :nth-child() angles per card — everything must be computed uniformly from --k * --spread so adding or removing cards stays automatically centered and symmetric.\n- transform-origin must be placed below the card's bottom edge (such as 50% 130%), never at the default center.\n- Under prefers-reduced-motion: reduce, must switch to display: flex to lay cards flat so all cards do not stack inseparably in one grid cell.\n\nAcceptance Criteria:\n- 3, 5, and 7 cards all maintain exact left-right symmetry; hovering or clicking smoothly fans out into an elegant arc, and leaving/clicking again closes briskly.\n- Enabling reduced motion automatically arranges cards into a horizontal row with every card fully visible.\n\nDo NOT Do:\n- Do NOT leave `transform-origin` at the default `50% 50%` — the cards will just spin stacked on top of each other like a pinwheel.\n- Do NOT compute `sin/cos` per card in a JS `mouseenter` handler — updating two CSS variables is the entire logic.\n- Do NOT forget to switch the container to `display: flex` under reduced motion, otherwise stacked cards can never be opened or read."
      }
    },
    {
      "id": "flip-clock",
      "name": "3D 机械翻页时钟 / 翻牌器",
      "name_en": "3D Split-Flap Mechanical Clock",
      "layer": "3d",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.flipClock(el, { value, pad }) + .mk-flap",
      "source": "Braun / 机场出发屏机械翻牌（上下独立裁切静页 + 居中水平转轴两段接力翻折 + 折角亮度压暗）",
      "source_en": "Braun / Solari split-flap display (4-layer two-stage 90° hinge fold + shadow)",
      "file": "effects/flip-clock.md",
      "summary": "复刻经典机场出发屏与 Braun 机械翻页钟：每一位数由上下独立裁切静页与两片居中转轴翻页叶组成，数值变更时仅变化的那一位触发 3D 下翻接力并带真实的折角压暗阴影。",
      "summary_en": "Airport departure board / Braun split-flap digits: 4-layer hinged halves fold down in two 90° relays with mid-fold hinge darkening, animating only changed digits.",
      "problem": "**倒计时、实时在线人数或大屏 KPI 跳变时，直接替换文字缺少仪式感，普通上下滚动又太像老套老虎机；而手写翻牌动效最容易踩“翻到一半旧字新字穿帮”或“未变化的十位也跟着乱翻”的坑。** 把一次翻牌拆成严格的四层结构与两段 90° 接力（上半旧字 `0° → -90°` 加速落下，下半新字 `90° → 0°` 减速弹停），只在 `next[i] !== cur[i]` 的位上触发，机械质感立刻拉满。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 上半翻折加速下落（`cubic-bezier(0.55, 0.05, 0.9, 0.6)`）模拟重力，下半着陆减速收住（`cubic-bezier(0.16, 1, 0.3, 1)`） | 一条匀速 `linear` 动画到底（像软塑料片而不是金属翻牌） |\n| 翻到 90° 处叠加 `filter: brightness(0.45)` 压暗再回亮，模拟真实物理页片背光阴影 | 纯平面旋转无明暗变化显得扁平廉价 |\n| 只对发生变化的位触发翻页，高位未变保持纹丝不动 | 每次更新把所有位数一起重建重翻 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 两段接力时长 | 上半 `220ms` + 下半 `220ms`（延迟 `215ms`） | `5ms` 极微重叠防止中轴交接处出现 1 帧空闪；总计 `435ms` 赶得上 1 秒一跳的时钟节奏 |\n| 单格透视深度 | `perspective: 420px` | 让 76px 高的翻牌在折到 45° 时呈现利落的梯形透视张力，不至于过度畸变 |\n| 中缝分割线 | 居中 `1.5px` 深黑横缝（`z-index: 6`） | 还原机械翻页牌物理铰链间隙，天然掩护上下两半裁切接缝 |\n| 定长位规范化 | `splitFlapDigits(value, pad)` + `tabular-nums` | 无论传入负数、`NaN` 或短数字，永远产出稳定位数字符数组，卡片宽度零跳动 |",
      "implementation": "```\nsrc/core/scene3d.js:430   splitFlapDigits(value, pad)  纯函数，定长数字/字符位规范化（可单测）\nsrc/core/scene3d.js:443   flipClock(el, { value, pad }) 仅变更位触发四层两段 3D 翻折，暴露 .set(next)\nstyles/3d.css:635         .mk-flap / __unit / __half / __leaf + mk-flap-down / mk-flap-up\n```",
      "degradation": "**走 `3d` 层专属契约：取消 3D 翻折，直接原地干净换字。**\n\n`prefers-reduced-motion: reduce` 下关闭两段翻折关键帧动画，数据更新时数字直接干净切换，保留机械翻牌卡片外观与中缝结构，不丢失任何实时数值。",
      "pitfalls": "**① 上下四层内容赋值顺序搞错，导致翻到一半露出旧字或新字提前穿帮。**\n正确时序：开始翻页瞬间，**上静页**立刻显示新字（被上翻叶挡住），**下静页**保持旧字；**上翻叶**显示旧字从 `0° → -90°` 折下露出上静页新字；到中点后**下翻叶**显示新字从 `90° → 0°` 盖住下静页旧字；动画结束后把下静页同步为新字。\n\n**② 没设 `backface-visibility: hidden` 导致翻过 90° 后看到镜像反字。**\n两片翻页叶必须设置 `backface-visibility: hidden`（含 `-webkit-` 前缀），过垂直面自动隐藏。\n\n**③ 连续快速触发 `.set()` 忘记先清理旧 `setTimeout` 或强制 reflow 重置动画。**\n必须维护定时器集合并在 `destroy()` 里清理，避免卸载后残留回调改写已移除 DOM。\n\n---",
      "ai_assets": {
        "prompt": "实现零依赖的 3D 机械翻页时钟 / 翻牌器（Split-Flap 3D Mechanical Flip Card）。\n\n原理一句话：每位翻牌由上静页、下静页、上翻叶、下翻叶四层构成，内部文字高度 200% 各自裁切上下半；数值变化时仅变更位触发两段 90° 3D 接力翻折（重力加速下折 + 减速着陆 + 折角压暗阴影）。\n\n做法：\n1. 纯函数 splitFlapDigits(value, pad = 2)：\n   - pad 钳制在 [1, 8]；数字取 Math.max(0, Math.floor(value))（非有限数按 0）左侧补零截断为定长数组；字符串转大写去非字母数字后补零截断。\n2. 四层 DOM 与 CSS 3D 结构（单格 perspective: 420px，居中 1.5px 铰链黑缝）：\n   - 上静页 / 上翻叶：top: 0; height: 50%; overflow: hidden; 内层文字 height: 200%; top: 0;\n   - 下静页 / 下翻叶：bottom: 0; height: 50%; overflow: hidden; 内层文字 height: 200%; bottom: 0;\n   - 两片翻叶均设 backface-visibility: hidden；上翻叶 transform-origin: 50% 100%，下翻叶 transform-origin: 50% 0% 且默认 rotateX(90deg)。\n3. 严密四层赋值与两段接力动画（仅当 next[i] !== cur[i] 时触发）：\n   - 翻转起点：上静页 = 新字，下静页 = 旧字，上翻叶 = 旧字，下翻叶 = 新字；\n   - 上翻叶 220ms cubic-bezier(0.55, 0.05, 0.9, 0.6)：rotateX(0deg) brightness(1) -> rotateX(-90deg) brightness(0.45)；\n   - 下翻叶 220ms 延迟 215ms cubic-bezier(0.16, 1, 0.3, 1)：rotateX(90deg) brightness(0.55) -> rotateX(0deg) brightness(1)；\n   - 460ms 结束后将下静页与上翻叶同步为新字并移除翻转态类。\n4. 降级与清理：\n   - prefers-reduced-motion: reduce 禁用两段翻折关键帧，直接完成数值更新。\n   - destroy() 清理全部未完成 timer 防止内存泄漏。\n\n硬要求：\n- 必须严格按四层时序更新文字，确保翻折前后与中点瞬间绝不出现新旧字穿帮。\n- 仅发生变化的位触发翻页，未变位严禁重播动画；数字必须开启 tabular-nums。\n- 翻页叶必须设置 backface-visibility: hidden 与折角压暗阴影。\n\n验收：\n- 倒计时或点击 +1 / 随机切换时，只有变动的位数发生干脆利落的机械翻折，未变动位纹丝不动。\n- 翻折经过 90° 中缝时有真实阴影变暗与无缝接力，无白闪、无镜像反字。\n- 开启减弱动效后数值干净切换无晃动；卸载后无残留定时器报错。",
        "dont_do": "- 别用单个 `div` 直接 `rotateX(-180deg)` 假装翻牌 —— 真实翻牌是上下两半在水平中缝处翻折，整卡旋转会失去机械感且字会上下颠倒。\n- 别在只变个位时把十位、百位也一起翻一遍 —— 极其吵闹且违背物理机械结构。\n- 别忘了在上下翻页交界留 `5ms` 重叠（`220ms` 与 `215ms` 延迟）—— 严丝合缝设为 `220ms` 时部分浏览器帧对齐会漏出 1 帧黑缝。",
        "skill_rule": "# 3D 机械翻页时钟 / 翻牌器 (flip-clock) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】每位翻牌由上静页、下静页、上翻叶、下翻叶四层构成，内部文字高度 200% 各自裁切上下半；数值变化时仅变更位触发两段 90° 3D 接力翻折（重力加速下折 + 减速着陆 + 折角压暗阴影）。\n\n【硬要求】\n- 必须严格按四层时序更新文字，确保翻折前后与中点瞬间绝不出现新旧字穿帮。\n- 仅发生变化的位触发翻页，未变位严禁重播动画；数字必须开启 tabular-nums。\n- 翻页叶必须设置 backface-visibility: hidden 与折角压暗阴影。\n\n【验收标准】\n- 倒计时或点击 +1 / 随机切换时，只有变动的位数发生干脆利落的机械翻折，未变动位纹丝不动。\n- 翻折经过 90° 中缝时有真实阴影变暗与无缝接力，无白闪、无镜像反字。\n- 开启减弱动效后数值干净切换无晃动；卸载后无残留定时器报错。\n\n【禁止做法】\n- 别用单个 `div` 直接 `rotateX(-180deg)` 假装翻牌 —— 真实翻牌是上下两半在水平中缝处翻折，整卡旋转会失去机械感且字会上下颠倒。\n- 别在只变个位时把十位、百位也一起翻一遍 —— 极其吵闹且违背物理机械结构。\n- 别忘了在上下翻页交界留 `5ms` 重叠（`220ms` 与 `215ms` 延迟）—— 严丝合缝设为 `220ms` 时部分浏览器帧对齐会漏出 1 帧黑缝。",
        "prompt_en": "Core Principle:\nBuild a zero-dependency 3D Split-Flap Mechanical Clock / Flip Counter. Each digit cell consists of four layers—static top half, static bottom half, top flipping flap, and bottom flipping flap—with inner glyph text set to `height: 200%` and clipped to the upper or lower half. When the value changes, only the modified digit positions trigger a two-stage 90° 3D relay flip (gravity-accelerated fold down + decelerated landing + hinge-angle darkening shadow).\n\nImplementation:\n1. Pure function `splitFlapDigits(value, pad = 2)`:\n   - Clamp `pad` to `[1, 8]`; for numbers, compute `Math.max(0, Math.floor(value))` (treat non-finite values as `0`), left-pad with `'0'`, and slice to a fixed-length array; for strings, convert to uppercase, strip non-alphanumeric characters, then zero-pad and truncate.\n2. Four-layer DOM and CSS 3D structure (per cell `perspective: 420px`, centered `1.5px` dark hinge seam):\n   - Static top / top flap: `top: 0; height: 50%; overflow: hidden;`, inner text `height: 200%; top: 0;`.\n   - Static bottom / bottom flap: `bottom: 0; height: 50%; overflow: hidden;`, inner text `height: 200%; bottom: 0;`.\n   - Set `backface-visibility: hidden` on both flaps; set `transform-origin: 50% 100%` on the top flap and `transform-origin: 50% 0%` with resting `rotateX(90deg)` on the bottom flap.\n3. Strict 4-layer assignment and two-stage relay animation (triggered only when `next[i] !== cur[i]`):\n   - Flip start state: static top = new char, static bottom = old char, top flap = old char, bottom flap = new char.\n   - Top flap `220ms cubic-bezier(0.55, 0.05, 0.9, 0.6)`: `rotateX(0deg) brightness(1)` -> `rotateX(-90deg) brightness(0.45)`.\n   - Bottom flap `220ms` with `215ms` delay, `cubic-bezier(0.16, 1, 0.3, 1)`: `rotateX(90deg) brightness(0.55)` -> `rotateX(0deg) brightness(1)`.\n   - After `460ms`, sync static bottom and top flap to the new character and remove the flipping state class.\n4. Reduced-motion & cleanup:\n   - Under `prefers-reduced-motion: reduce`, disable the two-stage flip keyframes and apply the updated value directly.\n   - `destroy()` clears all pending timers to prevent memory leaks.\n\nHard Constraints:\n- Update the four layers strictly in sequence so old and new glyphs never clash before, during, or at the midpoint of the flip.\n- Only changed digit positions may animate; unchanged digits must never replay; digits must enable `font-variant-numeric: tabular-nums`.\n- Flipping flaps must set `backface-visibility: hidden` and hinge-angle darkening shadows (`brightness`).\n\nAcceptance Criteria:\n- During countdowns, `+1` clicks, or random updates, only changed digits perform a crisp mechanical flip while unchanged digits remain completely still.\n- Passing through the `90°` center seam shows realistic shadow darkening and a seamless handoff with no white flash or mirrored/inverted glyphs.\n- With reduced motion enabled, values update cleanly without wobble; after unmounting, no leftover timer errors occur.",
        "dont_do_en": "- Do NOT fake a flip card by rotating a single `div` with `rotateX(-180deg)` — a real split-flap folds upper and lower halves along a horizontal center seam; rotating the whole card loses mechanical realism and flips glyphs upside down.\n- Do NOT re-flip the tens or hundreds digits when only the ones digit changes — it is visually noisy and violates physical mechanics.\n- Do NOT omit the `5ms` overlap between upper and lower flaps (`220ms` duration with `215ms` delay) — an exact `220ms` boundary exposes a 1-frame dark gap due to browser frame alignment.",
        "skill_rule_en": "# 3D Split-Flap Mechanical Clock (flip-clock) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: 3d | Platform: both\n\nCore Principle: Build a zero-dependency 3D Split-Flap Mechanical Clock / Flip Counter. Each digit cell consists of four layers—static top half, static bottom half, top flipping flap, and bottom flipping flap—with inner glyph text set to `height: 200%` and clipped to the upper or lower half. When the value changes, only the modified digit positions trigger a two-stage 90° 3D relay flip (gravity-accelerated fold down + decelerated landing + hinge-angle darkening shadow).\n\nHard Constraints:\n- Update the four layers strictly in sequence so old and new glyphs never clash before, during, or at the midpoint of the flip.\n- Only changed digit positions may animate; unchanged digits must never replay; digits must enable `font-variant-numeric: tabular-nums`.\n- Flipping flaps must set `backface-visibility: hidden` and hinge-angle darkening shadows (`brightness`).\n\nAcceptance Criteria:\n- During countdowns, `+1` clicks, or random updates, only changed digits perform a crisp mechanical flip while unchanged digits remain completely still.\n- Passing through the `90°` center seam shows realistic shadow darkening and a seamless handoff with no white flash or mirrored/inverted glyphs.\n- With reduced motion enabled, values update cleanly without wobble; after unmounting, no leftover timer errors occur.\n\nDo NOT Do:\n- Do NOT fake a flip card by rotating a single `div` with `rotateX(-180deg)` — a real split-flap folds upper and lower halves along a horizontal center seam; rotating the whole card loses mechanical realism and flips glyphs upside down.\n- Do NOT re-flip the tens or hundreds digits when only the ones digit changes — it is visually noisy and violates physical mechanics.\n- Do NOT omit the `5ms` overlap between upper and lower flaps (`220ms` duration with `215ms` delay) — an exact `220ms` boundary exposes a 1-frame dark gap due to browser frame alignment."
      }
    },
    {
      "id": "fluid-height",
      "name": "流体高度容器",
      "name_en": "Fluid Height Container",
      "layer": "motion",
      "nature": "连续",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.fluidHeight(el, { min, max }) + .mk-fluid / .mk-fluid__inner",
      "source": "Family App 托盘与步骤弹窗（ResizeObserver 测内层真实高度写 CSS 变量 + 首帧零跳闪）",
      "source_en": "Family App drawers & step modals (ResizeObserver inner measurement + zero-jump mount)",
      "file": "effects/fluid-height.md",
      "summary": "弹窗切换步骤、手风琴展开或表单动态增减字段时，外层容器通过 `ResizeObserver` 监听内层包裹块真实高度并写入单个高度变量，让容器像呼吸一样丝滑伸缩，全浏览器一致且首帧零动画跳闪。",
      "summary_en": "ResizeObserver measures an unconstrained inner wrapper and writes a single subpixel CSS height variable so multi-step modals and accordions breathe smoothly across all browsers.",
      "problem": "**多步骤弹窗或 AI 折叠区在内容变高/变矮时如果直接硬切，整个对话框会猛地上下一跳打断视线；而传统的 `max-height: 999px` 技巧收起时有明显延迟空转，CSS 原生 `interpolate-size` 在 Safari 收起阶段又存在兼容差异。** 用 `ResizeObserver` 测量无裁切内层节点的精确高度，写入外层容器的单个 CSS 变量，就能 100% 跨浏览器丝滑过渡且永不估算错高度。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 内层不限制高度（自由撑开）、外层 `overflow: hidden` 读变量 `--fh` 过渡 `320ms ease-out` | `max-height: 1000px` 假动画（收起时前 300ms 啥也没动） |\n| 首次测量期间加 `.is-init { transition: none }`，下一帧再移除，避免首屏挂载时从 0px 傻傻撑开 | 刚进页面弹窗自己抽拉一下 |\n| 纯函数 `clampHeight(h, min, max)` 兜底 `NaN` 与极端值 | 内层异步卸载时写入非法负高度 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 高度过渡曲线 | `320ms cubic-bezier(0.22, 1, 0.36, 1)` | 迅速起步、柔和着陆；比 200ms 更有流体呼吸感，比 500ms 不拖慢用户下一步点击 |\n| 首帧静默保护 | 初始化挂 `.is-init { transition: none }`，首测后下一 rAF 摘除 | 保证 SSR / 首次打开弹窗即刻处于精确高度，只在**后续内容变更**时动画 |\n| 测量来源 | `inner.getBoundingClientRect().height`（1 位小数精度） | 比 `offsetHeight` 保留亚像素精度，防止含小数行高文本在最后 1px 被裁底边 |\n| 高度钳制上限 | 默认 `[0, 4000]` | 拦截异常 DOM 状态下的离谱数值同时满足常规弹窗/折叠面板需求 |",
      "implementation": "```\nsrc/core/ui-motion.js:97    clampHeight(h, min, max)   纯函数，亚像素精度安全钳制高度（可单测）\nsrc/core/ui-motion.js:104   fluidHeight(el, opts)      ResizeObserver 测量内层写 --mk-fh + 首帧静默保护\nstyles/motion.css:1423      .mk-fluid / .is-init       overflow: hidden + 320ms 高度过渡与减弱动效降级\n```",
      "degradation": "**走 `motion` 层契约：保留精确高度包裹，过渡时长压至 `1ms`。**\n\n`prefers-reduced-motion: reduce` 下容器依然准确跟随内层高度，只是去掉连续伸缩过程直接到位，绝不裁切内容。",
      "pitfalls": "**① 直接把 `ResizeObserver` 挂在外层自身而不是内层包裹块上。**\n观察外层自身会形成“外层高变了 → 触发 RO → 写自己高度”的死循环，容器永远卡死在初始高度不动；必须分成**外层裁切壳 + 内层自由撑开块**两层结构。\n\n**② 忘了做首帧静默保护，页面刚打开时容器从 `0px` 慢悠悠展开。**\n首测必须禁用 `transition`，等第一次高度落定后的下一帧再恢复过渡。\n\n**③ 卸载组件时忘了调用 `ro.disconnect()`。**\n残留的 `ResizeObserver` 会长期持有已移除 DOM 引用造成内存泄漏。\n\n---",
      "ai_assets": {
        "prompt": "实现零依赖的流体高度容器（Fluid Height Container）。\n\n原理一句话：采用「外层裁切壳 + 内层自由内容块」双层结构，用 ResizeObserver 监听内层精确亚像素高度并写入外层 CSS 变量 --fh，首帧静默落位、后续内容增减时 320ms 平滑呼吸伸缩。\n\n做法：\n1. 纯函数 clampHeight(h, min = 0, max = 4000)：\n   - 钳制到 [min, max]，保留 1 位小数，非有限数回退 min。\n2. 双层结构与 CSS：\n   - 外层容器：overflow: hidden; height: var(--fh, auto); transition: height 320ms cubic-bezier(0.22, 1, 0.36, 1);\n   - 首帧静默类 .is-init：transition: none;\n   - 内层容器：普通文档流不设固定高度，自由随内容撑开。\n3. ResizeObserver 控制器：\n   - 挂载时先给外层加 .is-init，监听内层节点（绝不监听外层自身）；\n   - 每次回调读取 inner.getBoundingClientRect().height，经 clampHeight 后写入外层 --fh: <h>px；\n   - 首帧测量完成后在下一 requestAnimationFrame 移除 .is-init，之后每次内容变化自动平滑过渡；\n   - destroy() 调用 ro.disconnect() 清理监听。\n4. 降级：\n   - prefers-reduced-motion: reduce 将过渡压至 1ms，高度依然准确无裁切。\n\n硬要求：\n- 必须区分外层裁切壳与内层被测节点，严禁把 ResizeObserver 挂在外层自身导致高度锁死。\n- 必须做首帧静默保护，首次渲染严禁出现从 0px 展开的抖动。\n- 严禁使用 max-height: 9999px 技巧替代真实高度测量。\n\n验收：\n- 容器首次渲染即刻贴合内容高度，无任何多余展开动画。\n- 切换不同长度的步骤/折叠内容时，外层高度以 320ms 平滑呼吸伸缩，不裁切文字底边、不出现收起空等延迟。\n- 开启减弱动效后瞬时贴合新高度；组件卸载后 ResizeObserver 正确断开。",
        "dont_do": "- 别用 `max-height: 0 ↔ 1000px` 假装高度动画 —— 实际内容只有 120px 时，收起的前 80% 时间页面毫无动静。\n- 别把 `ResizeObserver` 绑在设置了 `height: var(--fh)` 的外层上 —— 自己锁死自己永远展不开。\n- 别用 `offsetHeight` 丢掉小数像素 —— 高分屏下最后一行字底部常被裁掉 1px。",
        "skill_rule": "# 流体高度容器 (fluid-height) · 跨平台动效规范\n性质：连续 ｜ 平台：both\n\n【核心原理】采用「外层裁切壳 + 内层自由内容块」双层结构，用 ResizeObserver 监听内层精确亚像素高度并写入外层 CSS 变量 --fh，首帧静默落位、后续内容增减时 320ms 平滑呼吸伸缩。\n\n【硬要求】\n- 必须区分外层裁切壳与内层被测节点，严禁把 ResizeObserver 挂在外层自身导致高度锁死。\n- 必须做首帧静默保护，首次渲染严禁出现从 0px 展开的抖动。\n- 严禁使用 max-height: 9999px 技巧替代真实高度测量。\n\n【验收标准】\n- 容器首次渲染即刻贴合内容高度，无任何多余展开动画。\n- 切换不同长度的步骤/折叠内容时，外层高度以 320ms 平滑呼吸伸缩，不裁切文字底边、不出现收起空等延迟。\n- 开启减弱动效后瞬时贴合新高度；组件卸载后 ResizeObserver 正确断开。\n\n【禁止做法】\n- 别用 `max-height: 0 ↔ 1000px` 假装高度动画 —— 实际内容只有 120px 时，收起的前 80% 时间页面毫无动静。\n- 别把 `ResizeObserver` 绑在设置了 `height: var(--fh)` 的外层上 —— 自己锁死自己永远展不开。\n- 别用 `offsetHeight` 丢掉小数像素 —— 高分屏下最后一行字底部常被裁掉 1px。",
        "prompt_en": "Core Principle:\nBuild a zero-dependency Fluid Height Container using a two-layer architecture (outer clipping shell + inner unconstrained content block). A `ResizeObserver` tracks the inner block's exact subpixel height and writes it to the outer CSS variable `--fh`, settling silently on the first frame and smoothly breathing over `320ms` on subsequent content changes.\n\nImplementation:\n1. Pure function `clampHeight(h, min = 0, max = 4000)`:\n   - Clamp to `[min, max]`, round to 1 decimal place, and fall back to `min` for non-finite values.\n2. Two-layer structure & CSS:\n   - Outer container: `overflow: hidden; height: var(--fh, auto); transition: height 320ms cubic-bezier(0.22, 1, 0.36, 1);`.\n   - First-frame silent class `.is-init`: `transition: none;`.\n   - Inner container: normal document flow with no fixed height, expanding freely with its content.\n3. `ResizeObserver` controller:\n   - On mount, add `.is-init` to the outer shell first and observe only the inner node (never the outer shell itself).\n   - On each callback, read `inner.getBoundingClientRect().height`, clamp it via `clampHeight`, and write `--fh: <h>px` to the outer shell.\n   - After the first measurement completes, remove `.is-init` on the next `requestAnimationFrame` so subsequent content changes transition smoothly.\n   - `destroy()` calls `ro.disconnect()` to clean up observation.\n4. Reduced-motion:\n   - `prefers-reduced-motion: reduce` compresses the transition duration to `1ms` while keeping height accurate and unclipped.\n\nHard Constraints:\n- Must separate the outer clipping shell from the inner measured node; never attach `ResizeObserver` to the outer shell itself, which locks its height.\n- Must enforce first-frame silent protection so initial render never jitters or expands from `0px`.\n- Never use `max-height: 9999px` hacks instead of true height measurement.\n\nAcceptance Criteria:\n- On initial render, the container fits content height immediately with zero unwanted expand animation.\n- Switching between steps or collapsible content of varying lengths smoothly animates outer height over `320ms` without clipping bottom text descenders or leaving a dead collapse delay.\n- With reduced motion enabled, height snaps immediately to the new size; on unmount, `ResizeObserver` disconnects cleanly.",
        "dont_do_en": "- Do NOT fake height animation with `max-height: 0 <-> 1000px` — when actual content is only `120px` tall, the first 80% of the collapse duration shows nothing happening.\n- Do NOT bind `ResizeObserver` to the outer element that has `height: var(--fh)` — it locks itself and can never expand.\n- Do NOT use `offsetHeight` and drop fractional pixels — on high-DPI displays, the bottom `1px` of the last line of text is often clipped.",
        "skill_rule_en": "# Fluid Height Container (fluid-height) · Cross-Platform Motion Spec\nNature: Continuity | Layer: motion | Platform: both\n\nCore Principle: Build a zero-dependency Fluid Height Container using a two-layer architecture (outer clipping shell + inner unconstrained content block). A `ResizeObserver` tracks the inner block's exact subpixel height and writes it to the outer CSS variable `--fh`, settling silently on the first frame and smoothly breathing over `320ms` on subsequent content changes.\n\nHard Constraints:\n- Must separate the outer clipping shell from the inner measured node; never attach `ResizeObserver` to the outer shell itself, which locks its height.\n- Must enforce first-frame silent protection so initial render never jitters or expands from `0px`.\n- Never use `max-height: 9999px` hacks instead of true height measurement.\n\nAcceptance Criteria:\n- On initial render, the container fits content height immediately with zero unwanted expand animation.\n- Switching between steps or collapsible content of varying lengths smoothly animates outer height over `320ms` without clipping bottom text descenders or leaving a dead collapse delay.\n- With reduced motion enabled, height snaps immediately to the new size; on unmount, `ResizeObserver` disconnects cleanly.\n\nDo NOT Do:\n- Do NOT fake height animation with `max-height: 0 <-> 1000px` — when actual content is only `120px` tall, the first 80% of the collapse duration shows nothing happening.\n- Do NOT bind `ResizeObserver` to the outer element that has `height: var(--fh)` — it locks itself and can never expand.\n- Do NOT use `offsetHeight` and drop fractional pixels — on high-DPI displays, the bottom `1px` of the last line of text is often clipped."
      }
    },
    {
      "id": "fold",
      "name": "3D 折纸面板",
      "name_en": "3D Paper Fold Panel",
      "layer": "3d",
      "nature": "方向",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-fold + .mk-fold / .mk-fold__head / .mk-fold__panel / fold(el)",
      "source": "物理折纸铰链展开（transform-origin 顶边 + rotateX(-92deg) + inert 焦点隔离 + 归零降级）",
      "source_en": "Origami 3D disclosure (top-hinge rotateX + automatic inert focus management)",
      "file": "effects/fold.md",
      "summary": "面板像沿顶边铰链折起来的纸页一样通过 `rotateX(-92deg → 0deg)` 展开与收起，收起态自动加 `inert` 隔离键盘焦点与误触，减弱动效下彻底归零塌回平面。",
      "summary_en": "Hinged top-edge rotateX(-92deg → 0deg) origami disclosure that automatically toggles `inert` when collapsed so hidden controls never trap Tab focus.",
      "problem": "**普通折叠面板靠 `max-height` 抽拉既难算高度又显得死板，而 3D 折叠面板最常被忽略的其实是交互坑：面板折上去看不见时，里面的按钮仍然能被 Tab 键聚焦、被屏幕阅读器读出来。** 折纸动效必须把空间方向隐喻（从标题下沿翻下来）与焦点隔离（`inert` + `aria-expanded`）绑成一件事。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 真实纸页沿顶边 `transform-origin: 50% 0%` 铰链翻转的空间方向感 | 逐帧 JS 计算多段折痕顶点 |\n| `panel.inert = !open` + `aria-expanded` + 键盘 Enter/Space 完整无障碍 | 收起后仅 `opacity: 0` 却留着可点按钮 |\n| 3D 专属「归零降级」：`prefers-reduced-motion` 下直接 `transform: none` 塌回平面 | 把 3D 面板停在半空 45° 的尴尬半路状态 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 收起倾角 | `rotateX(-92deg)` | `-90deg` 在部分高分屏透视下仍会露出一道 1px 细缝，多给 2° 压到 `-92deg` 彻底藏平 |\n| 铰链轴心 | `transform-origin: 50% 0%` | 锚在面板最顶边，紧贴标题下沿翻开，方向隐喻才成立 |\n| 展开时长 | `380ms`（`ease-out`） | 区块级空间展开；低于 240ms 看不出折页立体感，高于 500ms 显得笨重 |\n| 焦点隔离 | `panel.inert = !open` | 一行原生属性同时拦截 Tab 聚焦、点击事件与辅助技术访问，比手动遍历子按钮靠谱得多 |",
      "implementation": "```\nsrc/core/scene3d.js:234  fold(el)         只管 .is-open、aria-expanded、aria-hidden、panel.inert 与键盘触发\nstyles/3d.css            .mk-fold / __head / __chev / __panel（rotateX 过渡与归零降级）\n```",
      "degradation": "**走 `3d` 层专属契约：归零，不是停住。**\n\n`prefers-reduced-motion: reduce` 与弱机模式下，所有 3D 变换一律 `transform: none` 塌回平面显隐，绝不让面板悬在半空中；展开/收起功能与 `inert` 焦点隔离完整保留。",
      "pitfalls": "**① 收起态忘了给面板设 `inert = true`。**\n用户按 Tab 键会把焦点移进一个“折起来看不见”的面板里，按回车还会误触里面的操作按钮。初始化时若默认收起，也必须立刻置 `panel.inert = true`。\n\n**② 忘了给父级设 `perspective` 导致 `rotateX` 看起来像被压扁的 2D 缩放。**\n必须在 `.fold` 容器上设 `perspective: 900px`，翻转才具有近大远小的真实折页透视。\n\n**③ 减弱动效时只写了 `transition: none` 却留着 `rotateX(-92deg)`。**\n3D 层的降级原则是「塌回平面」，减弱动效下收起态直接 `display: none` 或 `opacity: 0; transform: none`，打开态 `transform: none`。\n\n---",
      "ai_assets": {
        "prompt": "实现 3D 折纸展开/收起面板（零动画库依赖，带完整无障碍与平面归零降级）。\n\n原理一句话：父容器提供 perspective，面板以顶边 transform-origin: 50% 0% 做 rotateX(-92deg → 0deg) 铰链翻转，收起时用原生 inert 彻底隔离焦点与点击。\n\n做法：\n1. 结构：.fold（设 perspective: 900px）内含 .fold-head（标题触发器）与 .fold-panel（折叠内容）。\n2. CSS 3D 铰链：\n   - .fold-panel：transform-origin: 50% 0%; transform: rotateX(-92deg); opacity: 0;\n     transition: transform 380ms cubic-bezier(0.22, 1, 0.36, 1), opacity 260ms ease-out;\n     （用 -92deg 而非 -90deg 防止高分屏透视留出 1px 残缝）\n   - .fold.is-open .fold-panel：transform: rotateX(0deg); opacity: 1;\n   - 箭头图标 .fold-chev 在 .is-open 时平滑旋转 180deg。\n3. 交互与无障碍状态机：\n   - 标题设 role=\"button\"、tabindex=\"0\"、aria-expanded=\"false|true\"，支持 click 以及 Enter / Space 键盘切换（Space 需 preventDefault 防止页面滚动）。\n   - 初始收起以及每次收起时，必须设置 panel.inert = true 与 panel.setAttribute('aria-hidden', 'true')；展开时置 panel.inert = false 与 aria-hidden=\"false\"。\n\n硬要求：\n- 收起态面板必须设 panel.inert = true，确保不可被 Tab 聚焦或误触。\n- 父容器必须声明 perspective，面板必须设 transform-origin: 50% 0%。\n- prefers-reduced-motion: reduce 下走 3D 归零降级：取消所有 rotateX 透视与过渡（transform: none），改为直接平面显隐，不可悬停在半路角度。\n\n验收：\n- 点击标题或按 Enter/Space，面板沿标题下沿 380ms 立体翻开，无 1px 残缝。\n- 收起状态下连续按 Tab 键，焦点直接跳过面板内部所有按钮。\n- 减弱动效模式下，面板无 3D 翻转，直接干净切换显隐。",
        "dont_do": "- 别用 `max-height: 0 → 999px` 模拟折叠 —— 速度失真且收起前半段长时间空等。\n- 别在收起态只写 `opacity: 0` 却不加 `inert` —— 会把键盘焦点陷阱留在不可见面板里。\n- 别忘了给 `Space` 键 `preventDefault()` —— 否则按空格展开面板时整页会往下跳一屏。",
        "skill_rule": "# 3D 折纸面板 (fold) · 跨平台动效规范\n性质：方向 ｜ 平台：both\n\n【核心原理】父容器提供 perspective，面板以顶边 transform-origin: 50% 0% 做 rotateX(-92deg → 0deg) 铰链翻转，收起时用原生 inert 彻底隔离焦点与点击。\n\n【硬要求】\n- 收起态面板必须设 panel.inert = true，确保不可被 Tab 聚焦或误触。\n- 父容器必须声明 perspective，面板必须设 transform-origin: 50% 0%。\n- prefers-reduced-motion: reduce 下走 3D 归零降级：取消所有 rotateX 透视与过渡（transform: none），改为直接平面显隐，不可悬停在半路角度。\n\n【验收标准】\n- 点击标题或按 Enter/Space，面板沿标题下沿 380ms 立体翻开，无 1px 残缝。\n- 收起状态下连续按 Tab 键，焦点直接跳过面板内部所有按钮。\n- 减弱动效模式下，面板无 3D 翻转，直接干净切换显隐。\n\n【禁止做法】\n- 别用 `max-height: 0 → 999px` 模拟折叠 —— 速度失真且收起前半段长时间空等。\n- 别在收起态只写 `opacity: 0` 却不加 `inert` —— 会把键盘焦点陷阱留在不可见面板里。\n- 别忘了给 `Space` 键 `preventDefault()` —— 否则按空格展开面板时整页会往下跳一屏。",
        "prompt_en": "Core Principle:\nBuild a zero-library 3D Paper Fold expand/collapse panel with full accessibility and a flat reduced-motion fallback. The parent container provides `perspective`, while the panel hinges from its top edge (`transform-origin: 50% 0%`) via `rotateX(-92deg -> 0deg)` and uses native `inert` when collapsed to isolate focus and pointer hits completely.\n\nImplementation:\n1. Structure: `.fold` (`perspective: 900px`) containing `.fold-head` (trigger header) and `.fold-panel` (collapsible content).\n2. CSS 3D hinge:\n   - `.fold-panel`: `transform-origin: 50% 0%; transform: rotateX(-92deg); opacity: 0; transition: transform 380ms cubic-bezier(0.22, 1, 0.36, 1), opacity 260ms ease-out;` (use `-92deg` instead of `-90deg` to prevent a `1px` residual gap under high-DPI perspective).\n   - `.fold.is-open .fold-panel`: `transform: rotateX(0deg); opacity: 1;`.\n   - Chevron icon `.fold-chev` rotates smoothly by `180deg` when `.is-open` is active.\n3. Interaction & accessibility state machine:\n   - Header sets `role=\"button\"`, `tabindex=\"0\"`, `aria-expanded=\"false|true\"`, supporting `click` as well as `Enter` and `Space` keyboard toggles (`Space` must call `preventDefault()` to prevent page scrolling).\n   - On initial collapsed state and every collapse, set `panel.inert = true` and `panel.setAttribute('aria-hidden', 'true')`; on expand, set `panel.inert = false` and `aria-hidden=\"false\"`.\n\nHard Constraints:\n- The collapsed panel must set `panel.inert = true` so inner elements cannot receive `Tab` focus or accidental clicks.\n- The parent container must declare `perspective`, and the panel must set `transform-origin: 50% 0%`.\n- Under `prefers-reduced-motion: reduce`, apply a flat zeroed-out 3D fallback: remove all `rotateX` perspective and transitions (`transform: none`) and toggle visibility flatly without stalling at an intermediate angle.\n\nAcceptance Criteria:\n- Clicking the header or pressing `Enter`/`Space` unfolds the panel in 3D along the header's bottom edge over `380ms` with no `1px` seam.\n- When collapsed, pressing `Tab` skips directly past all buttons inside the panel.\n- In reduced-motion mode, the panel toggles cleanly and flatly with zero 3D rotation.",
        "dont_do_en": "- Do NOT simulate folding with `max-height: 0 -> 999px` — velocity is distorted and the first half of collapsing stalls with an empty wait.\n- Do NOT set only `opacity: 0` when collapsed without `inert` — it leaves a keyboard focus trap inside an invisible panel.\n- Do NOT forget `preventDefault()` on the `Space` key — otherwise pressing Space to toggle the panel scrolls the page down by a full viewport.",
        "skill_rule_en": "# 3D Paper Fold Panel (fold) · Cross-Platform Motion Spec\nNature: Direction | Layer: 3d | Platform: both\n\nCore Principle: Build a zero-library 3D Paper Fold expand/collapse panel with full accessibility and a flat reduced-motion fallback. The parent container provides `perspective`, while the panel hinges from its top edge (`transform-origin: 50% 0%`) via `rotateX(-92deg -> 0deg)` and uses native `inert` when collapsed to isolate focus and pointer hits completely.\n\nHard Constraints:\n- The collapsed panel must set `panel.inert = true` so inner elements cannot receive `Tab` focus or accidental clicks.\n- The parent container must declare `perspective`, and the panel must set `transform-origin: 50% 0%`.\n- Under `prefers-reduced-motion: reduce`, apply a flat zeroed-out 3D fallback: remove all `rotateX` perspective and transitions (`transform: none`) and toggle visibility flatly without stalling at an intermediate angle.\n\nAcceptance Criteria:\n- Clicking the header or pressing `Enter`/`Space` unfolds the panel in 3D along the header's bottom edge over `380ms` with no `1px` seam.\n- When collapsed, pressing `Tab` skips directly past all buttons inside the panel.\n- In reduced-motion mode, the panel toggles cleanly and flatly with zero 3D rotation.\n\nDo NOT Do:\n- Do NOT simulate folding with `max-height: 0 -> 999px` — velocity is distorted and the first half of collapsing stalls with an empty wait.\n- Do NOT set only `opacity: 0` when collapsed without `inert` — it leaves a keyboard focus trap inside an invisible panel.\n- Do NOT forget `preventDefault()` on the `Space` key — otherwise pressing Space to toggle the panel scrolls the page down by a full viewport."
      }
    },
    {
      "id": "glass-base",
      "name": "玻璃基底材质",
      "name_en": "Liquid Glass Material Base",
      "layer": "glass",
      "nature": "材质",
      "platform": "both",
      "status": "shipped",
      "entry": ".mk-glass（配 v-mk-glass / refract()）",
      "source": "Apple iOS 26 Liquid Glass 四要素分层（折射 + 低模糊高饱和 + 连续斜向亮棱 + 镜面高光）",
      "source_en": "Apple Liquid Glass (low-blur high-saturation backdrop + 1.5px rim highlight)",
      "file": "effects/glass-base.md",
      "summary": "把导航栏、操作条、浮层卡片做成有厚度的实心玻璃：低模糊高饱和底材 + 沿圆角连续的 1.5px 斜向亮棱 + 镜面高光，且不挂 JS 也能静态成立。",
      "summary_en": "Low-blur high-saturation translucent surface with continuous 1.5px diagonal specular rim and inner sheen — looks solid even without JS.",
      "problem": "**普通「毛玻璃卡片」只是半透明糊板子，没有层级边界。** 很多界面给弹窗加一个 `backdrop-filter: blur(20px)` + 1px 白边就叫玻璃，但在深色或复杂内容上滚动时，边界发灰、文字对比度不稳定，用户感受不到它是一层浮在内容之上的实体材质。\n\n更棘手的是降级：**玻璃承载版面（导航栏、操作条），不能像装饰层一样在减弱动效下直接关掉**；它必须有独立的「冻住」与弱机实底两档退路。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| Apple Liquid Glass 的四层叠加：低半径模糊 + 高饱和 + 斜向高光棱 + 镜面高光 | WebGL / Three.js 实时光线追踪（违反 0 运行时原则） |\n| 双 `mask` + `mask-composite: exclude` 掏空中间，让 152° 斜向高光穿过圆角连续 | 12px 宽渐变边框拟物「厚度圈」（读起来像塑料壳） |\n| `isolation: isolate` 锁定 `mix-blend-mode: screen` 混合范围 | 把所有动态特效写死在基底里（流动/按压/折射拆分到独立变体与状态类） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 背景模糊 | `6px` | 模糊和边缘折射抢同一件事：超过 12px 会把边缘被折弯的纹理磨平，只剩一块灰板子；低于 4px 背景文字干扰前景可读性 |\n| 饱和度 | `178%` | 玻璃滤镜会把底色拉灰，提饱和才能让背后的色块透出“透亮”而不是“脏灰” |\n| 基底着色 | `rgba(255, 255, 255, 0.068)` | 足够把玻璃面和纯黑背景拉开，又不至于把底层内容盖死 |\n| 边缘亮线 | `1.5px` + `152deg` 渐变 | 1px 在高分屏偏弱，超过 2px 像硬描边；152° 模拟左上主光源、右下微弱回光 |\n| 默认高光位 | `30%`, `-8%`, `opacity: 0.26` | 即使完全不挂 JS，静态页面也自带自然顶光；强度压在 0.26 防止与边缘折射亮带叠加发腻 |\n| 弱机实底 | `rgba(16, 21, 29, 0.94)` | 摘掉 `backdrop-filter` 后必须立刻补足不透明度，否则文字会直接糊在底层内容上 |",
      "implementation": "```\nstyles/glass.css:33   :root 变量定义（--mk-glass-blur / -sat / -tint / -r / -band / -x / -y / -o）\nstyles/glass.css:54   @property --mk-glass-x / --mk-glass-y（登记为 <percentage> 以支持 CSS 插值）\nstyles/glass.css:76   .mk-glass 基底（backdrop-filter + 四层 box-shadow）\nstyles/glass.css:96   .mk-glass.is-refract（叠加折射 filter 时重新补全 blur + contrast(1.12) + brightness(1.04)）\nstyles/glass.css:106  .mk-glass::before（双 mask 掏空形成连续斜向亮棱）\nstyles/glass.css:130  .mk-glass::after（screen 混合镜面高光）\n```",
      "degradation": "**走 `glass` 专属两档契约：冻，而不是关。**\n\n- `prefers-reduced-motion: reduce`：材质本身、边缘亮线、静态高光与边缘折射**全部保留**（它们静止时不动），只停掉流动、按压与高光位移动画。\n- 低端机 / 省电模式（`.mk-lite`）：摘掉 `backdrop-filter: none`（含折射滤镜），并立刻切为高不透明度实色底 `rgba(16, 21, 29, 0.94)` 保证文字可读。",
      "pitfalls": "**① 直接用 `border` 或 `border-image` 画斜向高光边。**\n`border` 无法在圆角处平滑连续过渡，会断成四条直线；必须用 `::before` 铺满 + `padding: 1.5px` + 双 `mask` 掏空中间。\n\n**② 忘了 Safari 的旧语法 `-webkit-mask-composite: xor`。**\n标准属性是 `mask-composite: exclude`，但 Safari 的前缀版本值叫 `xor`，写错成 `exclude` 会导致整块卡片被白色渐变糊死。\n\n**③ 叠加折射滤镜时漏重写 `blur()`。**\n`backdrop-filter` 是整条覆盖而不是追加。加上 `url(#refract)` 时如果没把 `blur(6px) contrast(1.12) brightness(1.04) saturate(178%)` 一起写回去，背景模糊会突然消失，且重采样后的像素会发软发雾。\n\n**④ 漏写 `isolation: isolate` 或 `pointer-events: none`。**\n高光伪元素 `::after` 用了 `mix-blend-mode: screen`，不加 `isolation: isolate` 会穿透容器去混合外层页面背景；不加 `pointer-events: none` 会挡住玻璃里的按钮点击。\n\n**⑤ 弱机摘掉 `backdrop-filter` 却不提高背景不透明度。**\n原本 `rgba(255,255,255,0.068)` 在没模糊时几乎全透明，文字会直接和底层图文撞在一起不可读。\n\n---",
      "ai_assets": {
        "prompt": "实现一套“液态玻璃”基底材质（纯 CSS 即可成立，无运行时依赖）。\n\n原理一句话：四层叠加——低半径高饱和背景模糊 + 双 mask 掏空连续斜向亮棱 + screen 混合镜面高光 + 四层立体投影，并配合“减弱动效冻住、弱机换实底”的两档降级契约。\n\n做法：\n1. 容器基底（.glass-surface）：\n   - position: relative; isolation: isolate; border-radius: 26px;\n   - background: rgba(255, 255, 255, 0.068);\n   - backdrop-filter: blur(6px) saturate(178%);（同时写 -webkit-backdrop-filter）\n   - box-shadow 四层：\n     inset 0 1px 0 rgba(255,255,255,0.34),\n     inset 0 -1px 0 rgba(255,255,255,0.05),\n     0 0 0 1px rgba(255,255,255,0.085),\n     0 18px 42px -18px rgba(0,0,0,0.62)\n2. 连续斜向亮棱（::before）：\n   - position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none;\n   - background: linear-gradient(152deg, rgba(255,255,255,0.62) 0%, rgba(255,255,255,0.18) 28%, rgba(255,255,255,0.02) 54%, rgba(255,255,255,0.12) 82%, rgba(255,255,255,0.38) 100%);\n   - 双掩膜掏空中间：\n     -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);\n     mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);\n     -webkit-mask-composite: xor;\n     mask-composite: exclude;\n3. 镜面高光（::after）：\n   - position: absolute; inset: 0; border-radius: inherit; pointer-events: none;\n   - 用 CSS 变量 --glass-x (默认 30%)、--glass-y (默认 -8%)、--glass-o (默认 0.26) 驱动径向渐变：\n     radial-gradient(118% 88% at var(--glass-x) var(--glass-y), rgba(255,255,255,0.42), rgba(255,255,255,0.10) 26%, rgba(255,255,255,0) 58%)\n   - mix-blend-mode: screen; opacity: var(--glass-o);\n   - 用 @property 将 --glass-x 和 --glass-y 登记为 <percentage>，以便后续高光坐标可做 CSS 过渡。\n\n硬要求：\n- 两档降级不可混为一谈：\n  1) prefers-reduced-motion: reduce：保留玻璃材质、亮棱与静态高光，只停止动态流动/高光动画。\n  2) 低端机/省电模式类（如 .is-lite）：关闭 backdrop-filter: none，并把背景切为高不透明度实色 rgba(16, 21, 29, 0.94)。\n- ::before 和 ::after 必须带 pointer-events: none，容器必须带 isolation: isolate。\n- 若后续叠加 SVG 边缘折射滤镜，必须在同一条 backdrop-filter 里重新写出 blur(6px) contrast(1.12) brightness(1.04) saturate(178%)。\n\n验收：\n- 静态无 JS 渲染下，玻璃边缘可见 1.5px 沿圆角连续的左上高光棱，中间完全透出底层色彩且无白色糊层。\n- 在 Safari 与 Chrome 下圆角亮棱均正常镂空（不整块变白）。\n- 玻璃内部按钮点击畅通，不被伪元素拦截。\n- 切换 prefers-reduced-motion 时玻璃不消失、不闪烁；切换弱机模式时背景变实色且前景文字清晰可读。",
        "dont_do": "- 别把 `blur` 开到 20px–30px —— 过度模糊会让玻璃退化成灰板子，且叠加折射时完全看不出边缘弯曲。\n- 别用 `border` 模拟高光边 —— 圆角处会断开，无法表现连续光源。\n- 别在 `prefers-reduced-motion` 下删掉 `backdrop-filter` —— 静止材质不是动画，删掉会破坏导航栏层级可读性。",
        "skill_rule": "# 玻璃基底材质 (glass-base) · 跨平台动效规范\n性质：材质 ｜ 平台：both\n\n【核心原理】四层叠加——低半径高饱和背景模糊 + 双 mask 掏空连续斜向亮棱 + screen 混合镜面高光 + 四层立体投影，并配合“减弱动效冻住、弱机换实底”的两档降级契约。\n\n【硬要求】\n- 两档降级不可混为一谈：\n  1) prefers-reduced-motion: reduce：保留玻璃材质、亮棱与静态高光，只停止动态流动/高光动画。\n  2) 低端机/省电模式类（如 .is-lite）：关闭 backdrop-filter: none，并把背景切为高不透明度实色 rgba(16, 21, 29, 0.94)。\n- ::before 和 ::after 必须带 pointer-events: none，容器必须带 isolation: isolate。\n- 若后续叠加 SVG 边缘折射滤镜，必须在同一条 backdrop-filter 里重新写出 blur(6px) contrast(1.12) brightness(1.04) saturate(178%)。\n\n【验收标准】\n- 静态无 JS 渲染下，玻璃边缘可见 1.5px 沿圆角连续的左上高光棱，中间完全透出底层色彩且无白色糊层。\n- 在 Safari 与 Chrome 下圆角亮棱均正常镂空（不整块变白）。\n- 玻璃内部按钮点击畅通，不被伪元素拦截。\n- 切换 prefers-reduced-motion 时玻璃不消失、不闪烁；切换弱机模式时背景变实色且前景文字清晰可读。\n\n【禁止做法】\n- 别把 `blur` 开到 20px–30px —— 过度模糊会让玻璃退化成灰板子，且叠加折射时完全看不出边缘弯曲。\n- 别用 `border` 模拟高光边 —— 圆角处会断开，无法表现连续光源。\n- 别在 `prefers-reduced-motion` 下删掉 `backdrop-filter` —— 静止材质不是动画，删掉会破坏导航栏层级可读性。",
        "prompt_en": "Core Principle:\nBuild a pure CSS Liquid Glass material base with zero runtime dependencies. It stacks four layers—low-radius high-saturation backdrop blur, a dual-mask hollowed continuous diagonal specular rim, a `screen`-blended specular highlight, and a four-layer depth shadow—paired with a two-tier degradation contract (freeze motion under reduced motion; switch to a solid opaque fill on low-end devices).\n\nImplementation:\n1. Surface base (`.glass-surface`):\n   - `position: relative; isolation: isolate; border-radius: 26px;`\n   - `background: rgba(255, 255, 255, 0.068);`\n   - `backdrop-filter: blur(6px) saturate(178%);` (also include `-webkit-backdrop-filter`)\n   - Four-layer `box-shadow`: `inset 0 1px 0 rgba(255,255,255,0.34)`, `inset 0 -1px 0 rgba(255,255,255,0.05)`, `0 0 0 1px rgba(255,255,255,0.085)`, `0 18px 42px -18px rgba(0,0,0,0.62)`.\n2. Continuous diagonal specular rim (`::before`):\n   - `position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none;`\n   - `background: linear-gradient(152deg, rgba(255,255,255,0.62) 0%, rgba(255,255,255,0.18) 28%, rgba(255,255,255,0.02) 54%, rgba(255,255,255,0.12) 82%, rgba(255,255,255,0.38) 100%);`\n   - Dual-mask center cutout:\n     `-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);`\n     `mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);`\n     `-webkit-mask-composite: xor;`\n     `mask-composite: exclude;`\n3. Specular highlight (`::after`):\n   - `position: absolute; inset: 0; border-radius: inherit; pointer-events: none;`\n   - Driven by CSS variables `--glass-x` (default `30%`), `--glass-y` (default `-8%`), and `--glass-o` (default `0.26`):\n     `radial-gradient(118% 88% at var(--glass-x) var(--glass-y), rgba(255,255,255,0.42), rgba(255,255,255,0.10) 26%, rgba(255,255,255,0) 58%)`\n   - `mix-blend-mode: screen; opacity: var(--glass-o);`\n   - Register `--glass-x` and `--glass-y` with `@property` as `<percentage>` so highlight coordinates can transition in CSS.\n\nHard Constraints:\n- Never conflate the two degradation tiers:\n  1) `prefers-reduced-motion: reduce`: preserve the glass material, specular rim, and static highlight; only freeze animated flow/highlight motion.\n  2) Low-end / power-saving mode class (e.g., `.is-lite`): set `backdrop-filter: none` and switch the background to high-opacity solid `rgba(16, 21, 29, 0.94)`.\n- `::before` and `::after` must set `pointer-events: none`, and the container must set `isolation: isolate`.\n- If an SVG edge-refraction filter is layered on later, re-declare the full chain in the same `backdrop-filter`: `blur(6px) contrast(1.12) brightness(1.04) saturate(178%)`.\n\nAcceptance Criteria:\n- Under static no-JS rendering, a continuous `1.5px` upper-left specular rim traces the rounded corners while the interior cleanly transmits underlying colors with no milky haze.\n- Rounded specular rim masking hollows cleanly (never turns solid white) in both Safari and Chrome.\n- Buttons inside the glass remain clickable without being blocked by pseudo-elements.\n- Toggling `prefers-reduced-motion` keeps the glass intact with no disappearing or flicker; toggling lite mode switches to a solid backdrop with crisp, readable foreground text.",
        "dont_do_en": "- Do NOT raise `blur` to `20px–30px` — excessive blur turns glass into a gray slab and hides edge bending when refraction is layered on.\n- Do NOT simulate the specular rim with `border` — it breaks at rounded corners and cannot express a continuous directional light source.\n- Do NOT strip `backdrop-filter` under `prefers-reduced-motion` — static surface material is not animation, and removing it breaks legibility and hierarchy.",
        "skill_rule_en": "# Liquid Glass Material Base (glass-base) · Cross-Platform Motion Spec\nNature: Material | Layer: glass | Platform: both\n\nCore Principle: Build a pure CSS Liquid Glass material base with zero runtime dependencies. It stacks four layers—low-radius high-saturation backdrop blur, a dual-mask hollowed continuous diagonal specular rim, a `screen`-blended specular highlight, and a four-layer depth shadow—paired with a two-tier degradation contract (freeze motion under reduced motion; switch to a solid opaque fill on low-end devices).\n\nHard Constraints:\n- Never conflate the two degradation tiers:\n  1) `prefers-reduced-motion: reduce`: preserve the glass material, specular rim, and static highlight; only freeze animated flow/highlight motion.\n  2) Low-end / power-saving mode class (e.g., `.is-lite`): set `backdrop-filter: none` and switch the background to high-opacity solid `rgba(16, 21, 29, 0.94)`.\n- `::before` and `::after` must set `pointer-events: none`, and the container must set `isolation: isolate`.\n- If an SVG edge-refraction filter is layered on later, re-declare the full chain in the same `backdrop-filter`: `blur(6px) contrast(1.12) brightness(1.04) saturate(178%)`.\n\nAcceptance Criteria:\n- Under static no-JS rendering, a continuous `1.5px` upper-left specular rim traces the rounded corners while the interior cleanly transmits underlying colors with no milky haze.\n- Rounded specular rim masking hollows cleanly (never turns solid white) in both Safari and Chrome.\n- Buttons inside the glass remain clickable without being blocked by pseudo-elements.\n- Toggling `prefers-reduced-motion` keeps the glass intact with no disappearing or flicker; toggling lite mode switches to a solid backdrop with crisp, readable foreground text.\n\nDo NOT Do:\n- Do NOT raise `blur` to `20px–30px` — excessive blur turns glass into a gray slab and hides edge bending when refraction is layered on.\n- Do NOT simulate the specular rim with `border` — it breaks at rounded corners and cannot express a continuous directional light source.\n- Do NOT strip `backdrop-filter` under `prefers-reduced-motion` — static surface material is not animation, and removing it breaks legibility and hierarchy."
      }
    },
    {
      "id": "glass-tap",
      "name": "点击高光",
      "name_en": "Liquid Glass Tap Specular",
      "layer": "glass",
      "nature": "反馈",
      "platform": "touch",
      "status": "shipped",
      "entry": "v-mk-glass / glass(el, { depth, linger, press })",
      "source": "iOS 26 Liquid Glass 的控件反馈（按下时形状与光同时变，松手自己收）",
      "source_en": "iOS 26 Liquid Glass interactive touch specular (contact bloom + minimum linger)",
      "file": "effects/glass-tap.md",
      "summary": "玻璃上的光不跟着手指走 —— 点一下，光聚到触点、形状压扁回弹、光晕炸开，然后自己散回去。",
      "summary_en": "Touch-focused specular bloom that concentrates light at the exact contact point, squishes with elastic rebound, and gracefully lingers before fading.",
      "problem": "**移动端没有 hover。** 少掉\"指针停在表面上的位置\"这个前提，\"高光追着指针\"就没有输入源。\n\n这条以前写反过：旧实现让触屏也走桌面那套 `pointermove` 跟随，理由是\n\"手指按住时光往指尖聚，才能让人相信这块东西是实心的\"。真机上不成立 ——\n**手指落下的那一刻就把要看的那一小块整个盖住了**，跟手的结果是光从指下钻出来、\n又从指下滑走，用户一次都没看见它在哪。它还是移动端最坏的一种反馈：**没有终点**。\n手指一停，动画就停在那儿；手指一松，它才回位。\n\n移动端的反馈词汇是离散的：按、给一段完整的动画、结束。所以这里不是\"把跟随调弱一点\"，\n是换一类交互。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 一次点击 = 一段有始有终的动画（聚 → 停 → 散） | 原生的连续触觉波形（Core Haptics） |\n| 光点由接触位置决定，而不是永远从中心 | iOS 26 的控件 morph（方形吸成胶囊） |\n| 形状压扁回弹与光晕共用同一个触发 | 长按拖拽时的高光跟随（那里\"拖\"本身就是输入） |\n| 光晕 `transform-origin` 落在光点上 | 原生在抬起瞬间就收（这里要多停一拍，见 §4） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 聚过来 | `200ms` | 手指落下那一瞬就该看到反应。超过 240ms 会读成\"系统在思考\" |\n| 散回去 | `420ms` | 散场比聚场慢是通用的：到达要准，离开可以有余晖。反过来会像被弹开 |\n| `linger` | `520ms` | **从按下起算**，不是从松手起算。按压关键帧本身 460ms，520 刚好让整段播完再加 60ms 余量 |\n| `depth` | `0.62` | 桌面遗留参数，触屏照用：把 0–100% 压到 19–81%，光永远落在玻璃内部 |\n| 按压形变 | `scale(1.055, 0.945)` → `(0.972, 1.035)` | 见 `glass-press`；这里只是复用它，不另起一套 |\n\n`linger` 的\"从按下起算\"是这一条里唯一有单测的语义（`lingerRemaining()`）。\n从松手起算的话，快速点击（按住 80ms）会把 `mk-glass-press` 的关键帧砍在半截 ——\n看起来像\"按下去弹不起来\"，而这恰好是最常见的点击方式。",
      "implementation": "```\nglass.js:197   lingerRemaining(held, linger)      纯函数：松手后还要等多久（5 条断言）\nglass.js:362   glass(el, { depth, linger, press }) 粗指针分支：只有 down / up / cancel\nglass.css:54   @property --mk-glass-x / -y        登记成 <percentage>，否则插值不成立\nglass.css:266  06 · 触屏                          两档过渡：聚 200ms / 散 420ms\nglass.css:302  .is-press::after                   光晕 origin 吃光点坐标\n```\n\n分工和库里其它手势一致：**JS 只写终值**（两个百分比 + 一个类），\n中间路径全交给 CSS 过渡。触屏分支里没有 rAF、没有 `pointermove`。",
      "degradation": "**走 `glass` 那档：冻。**\n\n```css\n@media (prefers-reduced-motion: reduce) {\n  .mk-glass--liquid, .mk-glass.is-press, .mk-glass.is-press::after { animation: none; }\n  .mk-glass { --mk-glass-o: 0.22; --mk-glass-x: 32%; --mk-glass-y: -10%; }\n  .mk-glass, .mk-glass.is-press, .mk-glass::after { transition: none; }\n}\n```\n\n注意这里要掐**两条**过渡：`::after` 的 `opacity`，以及触屏那档挂在 `.mk-glass`\n上的高光坐标位移。只掐一条会漏掉\"光自己滑过去\"——它同样是动效。\n另外 `glass()` 在 `resolveReduced()` 为真时**根本不注册监听**，所以连光点都不会被写。",
      "pitfalls": "**① 自定义属性默认不可插值，写 `transition` 是白写。**\n\n不登记 `@property` 的话 `--mk-glass-x: 30% → 71%` 只是字符串替换，\n下一帧直接到位，`transition` 一个中间帧都不产出。实测：登记后 60ms 采到\n`61.88%`、120ms 采到 `70.91%`；不登记则两个采样点都已经是终值。\n\n（浏览器不支持 `@property` 时不会报错，只是退回\"瞬间到位\"。\n这是可接受的退化 —— 布局和可读性都不受影响。）\n\n**② 量尺寸必须在加 `.is-press` 之前。**\n\n`.is-press` 挂着 `mk-glass-press`，28% 处是 `scale(1.055, 0.945)`。\n`getBoundingClientRect()` 返回的是**变换后**的框，按它算触点会偏。\n此刻量出来是原尺寸纯粹是因为动画刚走到 0% —— 这个前提不该被依赖。\n\n**③ 写坐标必须在加 `.is-press` 之后。**\n\n两档过渡的时长不同（聚 200ms / 散 420ms）。先写坐标、后加类，\n浏览器取的是**变更前**的计算样式，光会按 420ms 慢慢挪过去 ——\n看起来像\"按下没反应，过一会儿才亮\"。散场同理：先摘类再写坐标。\n\n一句话：**量的顺序和写的顺序方向相反，两边都别省。**\n\n**④ `pointercancel` 不是松手。**\n\n手势被系统抢走（来电、切后台、被父级滚动容器接管）时动画不该继续演。\n`cancel` 直接 `rest()`，不走 `linger` 那段等待 —— 和 sheet / edgeback 的\n\"cancel ≠ release\" 是同一条规矩。\n\n**⑤ 只在粗指针上挂过渡。**\n\n桌面端的光跟着鼠标一路走，每一帧换个目标。给它挂 `transition`，\n光就会永远落后指针一截，像拖着一根橡皮筋。所以 `glass.css` 那两档过渡\n必须包在 `@media (hover: none), (pointer: coarse)` 里，而桌面走 rAF + lerp。",
      "ai_assets": {
        "prompt": "实现移动端玻璃表面的点击反馈。原生 Pointer Events + CSS 自定义属性，不引依赖。\n\n原理一句话：触屏没有 hover，所以光不跟随 —— 一次点击就是一段有始有终的动画：\n按下把光点写进去（200ms 聚过来），松手停一拍，再散回静止位（420ms）。\nJS 只写终点，中间路径交给 CSS 过渡。\n\n结构：\n  <div class=\"glass\" role=\"button\">…</div>\n  /* 高光是一个伪元素，位置吃两个自定义属性 */\n\n样式：\n  @property --glass-x { syntax: '<percentage>'; inherits: true; initial-value: 30%; }\n  @property --glass-y { syntax: '<percentage>'; inherits: true; initial-value: -8%; }\n\n  .glass::after {\n    content: ''; position: absolute; inset: 0; border-radius: inherit;\n    pointer-events: none; mix-blend-mode: screen;\n    background: radial-gradient(118% 88% at var(--glass-x) var(--glass-y),\n      rgba(255,255,255,.42), rgba(255,255,255,.10) 26%, transparent 58%);\n    opacity: .26;\n    transition: opacity 360ms cubic-bezier(.22,1,.36,1);\n  }\n\n  @media (hover: none), (pointer: coarse) {\n    .glass { transition: --glass-x 420ms ease-out, --glass-y 420ms ease-out; }\n    .glass.is-press { transition: --glass-x 200ms ease-out, --glass-y 200ms ease-out; }\n    .glass.is-press::after { transform-origin: var(--glass-x) var(--glass-y); }\n  }\n\n行为：\n- pointerdown：\n    1. 先量 getBoundingClientRect()（此时还没有任何 transform）\n    2. 摘掉 .is-press、强制重排（void el.offsetWidth）、再加回来 —— 连续两次点击才能重播\n    3. 用第 1 步的框把 clientX/clientY 换算成百分比，写 --glass-x / --glass-y\n       （写法：50 + (px/w - 0.5) * 100 * 0.62，把行程压到 19–81%，光不会贴边穿帮）\n- pointerup：定时 linger - 已按住时长 后散场；散场 = 摘 .is-press + 写回 30% / -8%\n- pointercancel：立刻散场，不等\n- 不要监听 pointermove。按住期间手指挪动不改变光的位置。\n\n硬要求：\n- 两个自定义属性必须用 @property 登记成 <percentage>，否则 transition 完全不插值，\n  光会瞬间跳到终点。\n- 量尺寸必须在加 .is-press 之前（那一档带 scale，rect 是变换后的）；\n  写坐标必须在加 .is-press 之后（否则会沿用\"散场\"那档的长时长）。\n- 停留时长要从**按下**起算，不是从松手起算 —— 否则快速点击会把按压动画砍半截。\n- 这类过渡只能包在 (hover: none), (pointer: coarse) 里；桌面端要靠 rAF 跟随，\n  挂过渡会让光永远落后指针。\n\n验收：\n- 在卡片右上角按一下：60ms 内能看到光已经过半，200ms 到终点、停在触点附近。\n- 按住期间横向拖动：光**不动**（这是这条效果的全部意义）。\n- 松手后约半秒，光自己滑回左上角，按压形变同时播完。\n- 连按两次：第二次仍然重播完整动画（不是\"没反应\"）。\n- 按下之后立刻松手（80ms）：按压动画仍然播满，不被截断。\n- 系统开启\"减少动效\"：光固定在左上、不位移，也没有按压动画。",
        "dont_do": "- 别在触屏上监听 pointermove 去跟手 —— 手指盖住的那块正是要在看的地方。\n- 别用 JS 逐帧 rAF 去写一个本来就能 transition 的属性；抢不到合成器还更贵。\n- 别把光点归一化到 0–100% 全行程：高光跑到边界就穿帮，压到中间那一截。\n- 别用 @starting-style 做这件事 —— 它只管首次渲染，重播要靠摘类 + 强制重排。",
        "skill_rule": "# 点击高光 (glass-tap) · 跨平台动效规范\n性质：反馈 ｜ 平台：touch\n\n【核心原理】触屏没有 hover，所以光不跟随 —— 一次点击就是一段有始有终的动画：\n\n【硬要求】\n- 两个自定义属性必须用 @property 登记成 <percentage>，否则 transition 完全不插值，\n  光会瞬间跳到终点。\n- 量尺寸必须在加 .is-press 之前（那一档带 scale，rect 是变换后的）；\n  写坐标必须在加 .is-press 之后（否则会沿用\"散场\"那档的长时长）。\n- 停留时长要从**按下**起算，不是从松手起算 —— 否则快速点击会把按压动画砍半截。\n- 这类过渡只能包在 (hover: none), (pointer: coarse) 里；桌面端要靠 rAF 跟随，\n  挂过渡会让光永远落后指针。\n\n【验收标准】\n- 在卡片右上角按一下：60ms 内能看到光已经过半，200ms 到终点、停在触点附近。\n- 按住期间横向拖动：光**不动**（这是这条效果的全部意义）。\n- 松手后约半秒，光自己滑回左上角，按压形变同时播完。\n- 连按两次：第二次仍然重播完整动画（不是\"没反应\"）。\n- 按下之后立刻松手（80ms）：按压动画仍然播满，不被截断。\n- 系统开启\"减少动效\"：光固定在左上、不位移，也没有按压动画。\n\n【禁止做法】\n- 别在触屏上监听 pointermove 去跟手 —— 手指盖住的那块正是要在看的地方。\n- 别用 JS 逐帧 rAF 去写一个本来就能 transition 的属性；抢不到合成器还更贵。\n- 别把光点归一化到 0–100% 全行程：高光跑到边界就穿帮，压到中间那一截。\n- 别用 @starting-style 做这件事 —— 它只管首次渲染，重播要靠摘类 + 强制重排。",
        "prompt_en": "Core Principle:\nBuild mobile touch-surface glass tap feedback using native Pointer Events + CSS custom properties with zero dependencies. Touch devices have no hover, so light does not track continuously—a tap is a bounded animation: pressing writes the light position (`200ms` gather), releasing holds briefly (`linger`), then disperses back to the resting position (`420ms`). JS only writes endpoints; CSS transitions interpolate the path.\n\nImplementation:\n1. Structure & CSS:\n   - Markup: `<div class=\"glass\" role=\"button\">...</div>` with a pseudo-element highlight driven by two custom properties.\n   - Register `@property --glass-x { syntax: '<percentage>'; inherits: true; initial-value: 30%; }` and `@property --glass-y { syntax: '<percentage>'; inherits: true; initial-value: -8%; }`.\n   - `.glass::after`: `content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; mix-blend-mode: screen; background: radial-gradient(118% 88% at var(--glass-x) var(--glass-y), rgba(255,255,255,.42), rgba(255,255,255,.10) 26%, transparent 58%); opacity: .26; transition: opacity 360ms cubic-bezier(.22,1,.36,1);`.\n   - Scope coordinate transitions inside `@media (hover: none), (pointer: coarse)`:\n     `.glass { transition: --glass-x 420ms ease-out, --glass-y 420ms ease-out; }`\n     `.glass.is-press { transition: --glass-x 200ms ease-out, --glass-y 200ms ease-out; }`\n     `.glass.is-press::after { transform-origin: var(--glass-x) var(--glass-y); }`\n2. Pointer behavior:\n   - `pointerdown`:\n     1) Measure `getBoundingClientRect()` first (before any `transform` is applied).\n     2) Remove `.is-press`, force reflow (`void el.offsetWidth`), and re-add `.is-press` so consecutive taps replay cleanly.\n     3) Using step 1's rect, convert `clientX`/`clientY` into percentages and write `--glass-x` / `--glass-y` via `50 + (px/w - 0.5) * 100 * 0.62`, compressing travel to `19%–81%` so the highlight never clips at edges.\n   - `pointerup`: schedule dispersion after `linger - elapsedPressTime`; dispersion = remove `.is-press` and reset `--glass-x: 30%`, `--glass-y: -8%`.\n   - `pointercancel`: disperse immediately without waiting.\n   - Do not listen to `pointermove`; moving a finger while pressing must not move the light.\n\nHard Constraints:\n- Both custom properties must be registered with `@property` as `<percentage>`, otherwise `transition` will not interpolate and the highlight jumps instantly.\n- Measure `getBoundingClientRect()` BEFORE adding `.is-press` (which applies `scale`, altering the rect); write coordinates AFTER adding `.is-press` (otherwise it uses the longer `420ms` release duration).\n- Linger duration must be counted from `pointerdown`, not `pointerup`—otherwise quick taps chop the press animation in half.\n- These CSS transitions must be wrapped in `@media (hover: none), (pointer: coarse)`; desktop uses `rAF` tracking, where a transition causes the highlight to lag behind the pointer.\n\nAcceptance Criteria:\n- Tapping the upper-right corner moves the highlight past halfway within `60ms` and settles near the tap point by `200ms`.\n- Dragging horizontally while pressing keeps the highlight stationary (the core point of this interaction).\n- Roughly half a second after release, the highlight glides back to the upper-left corner as press deformation finishes.\n- Tapping twice in a row replays the full animation on the second tap rather than doing nothing.\n- Releasing immediately after pressing (`80ms` tap) still completes the full press animation without truncation.\n- With `prefers-reduced-motion: reduce`, the highlight stays fixed at upper-left with no displacement or press animation.",
        "dont_do_en": "- Do NOT listen to `pointermove` on touch devices to track the finger — the finger physically covers the exact area you are trying to illuminate.\n- Do NOT drive a CSS-transitionable property frame-by-frame with JS `rAF` — it cannot beat the compositor and costs more.\n- Do NOT normalize highlight coordinates across the full `0–100%` range — highlights hitting the border look broken; compress travel into the inner `19–81%` band.\n- Do NOT use `@starting-style` for this — it only applies on initial render, whereas replaying taps requires class removal plus forced reflow.",
        "skill_rule_en": "# Liquid Glass Tap Specular (glass-tap) · Cross-Platform Motion Spec\nNature: Feedback | Layer: glass | Platform: touch\n\nCore Principle: Build mobile touch-surface glass tap feedback using native Pointer Events + CSS custom properties with zero dependencies. Touch devices have no hover, so light does not track continuously—a tap is a bounded animation: pressing writes the light position (`200ms` gather), releasing holds briefly (`linger`), then disperses back to the resting position (`420ms`). JS only writes endpoints; CSS transitions interpolate the path.\n\nHard Constraints:\n- Both custom properties must be registered with `@property` as `<percentage>`, otherwise `transition` will not interpolate and the highlight jumps instantly.\n- Measure `getBoundingClientRect()` BEFORE adding `.is-press` (which applies `scale`, altering the rect); write coordinates AFTER adding `.is-press` (otherwise it uses the longer `420ms` release duration).\n- Linger duration must be counted from `pointerdown`, not `pointerup`—otherwise quick taps chop the press animation in half.\n- These CSS transitions must be wrapped in `@media (hover: none), (pointer: coarse)`; desktop uses `rAF` tracking, where a transition causes the highlight to lag behind the pointer.\n\nAcceptance Criteria:\n- Tapping the upper-right corner moves the highlight past halfway within `60ms` and settles near the tap point by `200ms`.\n- Dragging horizontally while pressing keeps the highlight stationary (the core point of this interaction).\n- Roughly half a second after release, the highlight glides back to the upper-left corner as press deformation finishes.\n- Tapping twice in a row replays the full animation on the second tap rather than doing nothing.\n- Releasing immediately after pressing (`80ms` tap) still completes the full press animation without truncation.\n- With `prefers-reduced-motion: reduce`, the highlight stays fixed at upper-left with no displacement or press animation.\n\nDo NOT Do:\n- Do NOT listen to `pointermove` on touch devices to track the finger — the finger physically covers the exact area you are trying to illuminate.\n- Do NOT drive a CSS-transitionable property frame-by-frame with JS `rAF` — it cannot beat the compositor and costs more.\n- Do NOT normalize highlight coordinates across the full `0–100%` range — highlights hitting the border look broken; compress travel into the inner `19–81%` band.\n- Do NOT use `@starting-style` for this — it only applies on initial render, whereas replaying taps requires class removal plus forced reflow."
      }
    },
    {
      "id": "glitch",
      "name": "赛博故障字",
      "name_en": "Cyber Glitch Typography",
      "layer": "fun",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": ".mk-glitch + data-text（纯 CSS 双伪元素 RGB 错位 + steps(1) 脉冲）",
      "source": "赛博朋克信号干扰字（85% 时间静止可读、仅在周期末尾用 steps(1) 瞬爆，零 JS）",
      "source_en": "Cyberpunk signal glitch (pure CSS dual-channel clip-path + steps(1) bursts)",
      "file": "effects/glitch.md",
      "summary": "纯 CSS 用 `::before`/`::after` 克隆文字叠加青/品红双色错位与切片裁切，绝大部分时间完全静止可读，只在每 3.4 秒周期末尾用 `steps(1)` 瞬爆一下故障感。",
      "summary_en": "Pure CSS ::before/::after cyan-magenta chromatic offset and clip-path slices that stay 100% readable most of the cycle and burst briefly via steps(1).",
      "problem": "**普通故障字一直疯狂抖动，看 3 秒眼睛就疼、字也读不清。** 真正高级的故障效果应该像信号偶发丢帧：85% 的时间稳如泰山，只在周期末尾抽搐 2–3 帧立刻恢复，既有记忆点又不伤害可读性。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| `steps(1)` 离散跳帧 + `clip-path: inset()` 水平切片错位 | 平滑缓动滑动（故障是数字信号丢包，绝不能“丝滑”） |\n| 周期前 85% 静默、后 15% 爆发的稀疏节奏 | 100% 全程持续狂抖让人头晕 |\n| 零 JS 纯 CSS，伪元素直接读 `attr(data-text)` | 为一个标题引入 Canvas / WebGL 故障着色器 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 周期时长 | `3.4s`（`steps(1)`） | 够读完两遍标题才偶尔闪一下，像真实信号微扰而不是坏屏 |\n| 双色通道 | 青色 `#00f0ff` / 品红 `#ff2e93` | 模拟 RGB 色差分离，深色底上对比度最锋利 |\n| 错位幅度 | `±2px ~ ±4px` | 超过 8px 字形撕裂过度无法辨认；2–4px 刚好出电信号质感 |\n| 切片裁切 | `clip-path: inset(top% 0 bottom% 0)` | 只切出 15%–35% 水平条带错开，主体文字骨架保持完整 |",
      "implementation": "```\nstyles/fun.css:27  .mk-glitch / ::before / ::after（读 attr(data-text)）\n```",
      "degradation": "**走 `fun` 层专属契约：整层关掉。**\n\n`prefers-reduced-motion: reduce` 与弱机模式下彻底隐藏两个伪元素并 `animation: none`，只保留干净清晰的原始文字。",
      "pitfalls": "**① 忘了在元素上写 `data-text=\"同款文案\"`。**\n伪元素依赖 `content: attr(data-text)`，漏写或文案不同步时故障层会完全空白或错字。\n\n**② 用了 `ease-in-out` 而不是 `steps(1)`。**\n平滑过渡会让青色和品红色像两块橡皮泥一样慢慢飘来飘去，完全失去电子故障的干脆感。\n\n**③ 没给伪元素加 `aria-hidden` 或造成屏幕阅读器读三遍。**\n确保伪元素只作纯装饰（`pointer-events: none`），不要在 DOM 里真的复制三份真实文字节点。\n\n---",
      "ai_assets": {
        "prompt": "实现纯 CSS（零 JS）的赛博故障字动效（Glitch Text）。\n\n原理一句话：主文字保持静止可读，::before / ::after 读取 attr(data-text) 叠加青/品红双色切片，用 steps(1) 在 3.4s 周期的前 86% 保持静默、仅在最后 14% 瞬爆 3 帧水平错位。\n\n做法：\n1. HTML：<span class=\"glitch\" data-text=\"MOTION KIT\">MOTION KIT</span>\n2. CSS 结构：\n   - .glitch { position: relative; display: inline-block; }\n   - .glitch::before, .glitch::after {\n       content: attr(data-text); position: absolute; inset: 0; pointer-events: none; opacity: 0;\n     }\n   - .glitch::before { color: #00f0ff; animation: glitch-a 3.4s steps(1) infinite; }\n   - .glitch::after  { color: #ff2e93; animation: glitch-b 3.4s steps(1) infinite; }\n3. 稀疏爆发关键帧（0%–86% 全程 opacity: 0，88%/92%/96% 各给不同 inset 切片与 ±3px translate3d 错位，100% 归零）。\n4. 降级：@media (prefers-reduced-motion: reduce) { .glitch::before, .glitch::after { display: none; animation: none; } }\n\n硬要求：\n- 必须使用 steps(1) 离散跳帧，严禁用 ease/linear 平滑移动。\n- 80% 以上周期必须完全静止可读，禁止全程持续狂抖。\n- 严禁在 DOM 里复制三份真实文本节点（会破坏屏幕阅读器与复制粘贴）。\n- prefers-reduced-motion: reduce 下必须彻底关闭并隐藏伪元素。\n\n验收：\n- 大部分时间标题清晰静止，每隔 ~3.4 秒末尾瞬间闪出 2–3 帧青/品红切片错位后立刻复原。\n- 选中复制标题文本只复制出一份原文。\n- 开启减弱动效后标题完全静止，无彩色重影。",
        "dont_do": "- 别用 `ease` 或 `linear` 做故障位移 —— 那叫重影飘移，不叫故障。\n- 别让故障 100% 全程不停抖动 —— 用户看 2 秒就会关掉页面。\n- 别为故障字引入 JS 定时器或 Canvas。",
        "skill_rule": "# 赛博故障字 (glitch) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】主文字保持静止可读，::before / ::after 读取 attr(data-text) 叠加青/品红双色切片，用 steps(1) 在 3.4s 周期的前 86% 保持静默、仅在最后 14% 瞬爆 3 帧水平错位。\n\n【硬要求】\n- 必须使用 steps(1) 离散跳帧，严禁用 ease/linear 平滑移动。\n- 80% 以上周期必须完全静止可读，禁止全程持续狂抖。\n- 严禁在 DOM 里复制三份真实文本节点（会破坏屏幕阅读器与复制粘贴）。\n- prefers-reduced-motion: reduce 下必须彻底关闭并隐藏伪元素。\n\n【验收标准】\n- 大部分时间标题清晰静止，每隔 ~3.4 秒末尾瞬间闪出 2–3 帧青/品红切片错位后立刻复原。\n- 选中复制标题文本只复制出一份原文。\n- 开启减弱动效后标题完全静止，无彩色重影。\n\n【禁止做法】\n- 别用 `ease` 或 `linear` 做故障位移 —— 那叫重影飘移，不叫故障。\n- 别让故障 100% 全程不停抖动 —— 用户看 2 秒就会关掉页面。\n- 别为故障字引入 JS 定时器或 Canvas。",
        "prompt_en": "Core Principle:\nBuild pure CSS (zero JS) Cyber Glitch Typography. The primary text remains static and legible while `::before` and `::after` read `attr(data-text)` to overlay cyan and magenta clipped slices, staying silent for the first `86%` of a `3.4s` cycle via `steps(1)` and bursting into 3 frames of horizontal offset only in the final `14%`.\n\nImplementation:\n1. HTML: `<span class=\"glitch\" data-text=\"CYBER GLITCH\">CYBER GLITCH</span>`\n2. CSS structure:\n   - `.glitch { position: relative; display: inline-block; }`\n   - `.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; pointer-events: none; opacity: 0; }`\n   - `.glitch::before { color: #00f0ff; animation: glitch-a 3.4s steps(1) infinite; }`\n   - `.glitch::after { color: #ff2e93; animation: glitch-b 3.4s steps(1) infinite; }`\n3. Sparse burst keyframes: keep `opacity: 0` across `0%–86%`; at `88%`, `92%`, and `96%` apply distinct `inset` clip slices and `±3px` `translate3d` offsets; reset to zero at `100%`.\n4. Reduced-motion fallback: `@media (prefers-reduced-motion: reduce) { .glitch::before, .glitch::after { display: none; animation: none; } }`.\n\nHard Constraints:\n- Must use discrete `steps(1)` frame stepping; never use smooth `ease` or `linear` sliding.\n- More than `80%` of each cycle must remain completely static and legible; continuous shaking is forbidden.\n- Never duplicate three real text nodes in the DOM (breaks screen readers and copy-paste).\n- Under `prefers-reduced-motion: reduce`, pseudo-elements must be completely disabled and hidden.\n\nAcceptance Criteria:\n- Most of the time the heading is sharp and still; every `~3.4s` near the end of the cycle it flashes 2–3 frames of cyan/magenta slice offsets and immediately snaps back.\n- Selecting and copying the heading text copies only a single clean string.\n- With reduced motion enabled, the heading is completely static with zero colored ghosting.",
        "dont_do_en": "- Do NOT use `ease` or `linear` for glitch offsets — that creates drifting ghost shadows rather than digital glitching.\n- Do NOT run the glitch 100% of the time without pauses — users will close the page within two seconds.\n- Do NOT introduce JS timers or Canvas for glitch typography.",
        "skill_rule_en": "# Cyber Glitch Typography (glitch) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: fun | Platform: both\n\nCore Principle: Build pure CSS (zero JS) Cyber Glitch Typography. The primary text remains static and legible while `::before` and `::after` read `attr(data-text)` to overlay cyan and magenta clipped slices, staying silent for the first `86%` of a `3.4s` cycle via `steps(1)` and bursting into 3 frames of horizontal offset only in the final `14%`.\n\nHard Constraints:\n- Must use discrete `steps(1)` frame stepping; never use smooth `ease` or `linear` sliding.\n- More than `80%` of each cycle must remain completely static and legible; continuous shaking is forbidden.\n- Never duplicate three real text nodes in the DOM (breaks screen readers and copy-paste).\n- Under `prefers-reduced-motion: reduce`, pseudo-elements must be completely disabled and hidden.\n\nAcceptance Criteria:\n- Most of the time the heading is sharp and still; every `~3.4s` near the end of the cycle it flashes 2–3 frames of cyan/magenta slice offsets and immediately snaps back.\n- Selecting and copying the heading text copies only a single clean string.\n- With reduced motion enabled, the heading is completely static with zero colored ghosting.\n\nDo NOT Do:\n- Do NOT use `ease` or `linear` for glitch offsets — that creates drifting ghost shadows rather than digital glitching.\n- Do NOT run the glitch 100% of the time without pauses — users will close the page within two seconds.\n- Do NOT introduce JS timers or Canvas for glitch typography."
      }
    },
    {
      "id": "holo-card",
      "name": "3D 全息折射炫彩卡",
      "name_en": "3D Holographic Foil Card",
      "layer": "3d",
      "nature": "材质",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.holoCard(el, { max }) + .mk-holo-stage / .mk-holo",
      "source": "实体收藏卡 / Apple Card 金属箔（3D 倾斜同步驱动彩虹衍射渐变角度 + color-dodge 混合 + 镜面点光斑 + 内嵌浮雕层）",
      "source_en": "Collectible holographic foil / Apple Card (coupled 3D tilt + diffraction grating)",
      "file": "effects/holo-card.md",
      "summary": "鼠标在卡片上滑动时，3D 倾斜角、彩虹衍射光栅的倾角与位移、镜面高光光斑三者由同一套物理光照坐标同步驱动，还原真实实体全息烫金收藏卡的晃动折射质感。",
      "summary_en": "Pointer-driven 3D tilt synchronized with a color-dodge rainbow diffraction grating, overlay specular glare, and translateZ(24px) embossed content.",
      "problem": "**普通 3D Tilt 卡片只会转个角度，视觉上仍是平淡塑料片；而强行叠一层死板的彩虹静态背景图又像廉价 PPT。** 当彩虹衍射层的角度（`--holo-ang`）、偏移（`--holo-bgx / -bgy`）与高光斑点（`--holo-gx / -gy`）严格跟 3D 倾斜角绑定，且使用 `mix-blend-mode: color-dodge` 与 `overlay` 叠加在暗底材质上时，一晃鼠标就会浮现出逼真的金属衍射光泽。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 指针坐标经纯函数 `holoLight(nx, ny, maxTilt)` 一次解算出 7 个光学量，倾斜与彩虹流光严丝合缝 | 倾斜一套 JS、光斑另一套监听导致两层各走各的 |\n| 彩虹衍射层 `mix-blend-mode: color-dodge`（静置淡隐 `0.24`，激活浮现 `0.72`）+ 镜面光斑 `overlay` | 直接盖半透明不混合彩虹把文字糊到看不清 |\n| 卡片内主元素 `translateZ(24px)` 轻微浮雕凸起，在 3D 倾斜时与底板产生真实视差错位 | 所有内容死贴在同一平面 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 最大倾斜角 `maxTilt` | 默认 `16deg`（`rx = -dy*2*max`, `ry = dx*2*max`） | 足够让彩虹光栅大角度扫过整张卡，又不会倾到边角字迹变形难读 |\n| 衍射角与背景偏移 | `angle = 115 + dx*90 - dy*45` / `bgPos = 50 ± 30%` | 指针横向扫过时彩虹条纹旋转并斜向滑过，最贴近真实光栅衍射箔的物理观感 |\n| 跟踪 / 回正过渡时长 | 激活跟踪 `70ms` / 移出回正 `320ms` | 跟手时不粘滞延迟，移出后柔和回正归平不僵硬弹跳 |\n| 舞台透视 `perspective` | `900px` | 对 210×132px 卡片给出自然纵深，且浮雕内层 `translateZ(24px)` 错位恰到好处 |",
      "implementation": "```\nsrc/core/scene3d.js:557   holoLight(nx, ny, maxTilt)   纯函数，解算倾斜角、光斑与衍射光栅参数（可单测）\nsrc/core/scene3d.js:576   holoCard(el, { max })        指针跟踪写入 CSS 变量，移出自动平滑归中\nstyles/3d.css:848         .mk-holo-stage / .mk-holo / ::before（彩虹箔）/ ::after（高光斑）/ __inner\n```",
      "degradation": "**走 `3d` 层专属契约：取消 3D 倾斜与动态高光，保留克制的静态金属质感边框与微弱箔光。**\n\n`prefers-reduced-motion: reduce` 下 JS 跳过指针倾斜计算，CSS 关闭 `transform` 与高光斑 `::after`，仅保留 `opacity: 0.25` 的静态虹彩光泽纹理，卡片信息与质感均不丢失。",
      "pitfalls": "**① 直接给彩虹层设高不透明度 `normal` 混合，把卡片文字盖得发灰发花。**\n彩虹衍射层必须用 `mix-blend-mode: color-dodge` 配合深色底面，并设 `pointer-events: none` 绝不拦截点击。\n\n**② `rx` 旋转方向符号写反（往上移指针反而顶部翘起迎面）。**\n按下角下沉的自然直觉是：指针在上方（`dy < 0`）时顶部向里压，绕 X 轴应为正向 `+rx`（即 `rx = -dy * 2 * max`）；指针在右侧（`dx > 0`）时右侧向里压，绕 Y 轴应为 `+ry`。\n\n**③ 移出卡片后忘记清掉 `.is-active` 和把角度复位到 `(0.5, 0.5)`。**\n必须监听 `pointerleave` 复位全部光学变量并切换回 `320ms` 缓动，让卡片优雅归平。\n\n---",
      "ai_assets": {
        "prompt": "实现零依赖的 3D 全息折射炫彩卡（Holographic Foil 3D Card）。\n\n原理一句话：用纯函数把归一化指针坐标 (nx, ny) 同步映射为卡片 3D 倾斜角 (rx, ry)、彩虹光栅衍射角与背景偏移、镜面高光斑点位置 7 个光学 CSS 变量，以 color-dodge 衍射箔层 + overlay 镜面光斑 + translateZ(24px) 浮雕内容还原实体全息收藏卡质感。\n\n做法：\n1. 纯函数 holoLight(nx, ny, maxTilt = 16)：\n   - 钳制 nx, ny ∈ [0, 1]（非法回退 0.5），dx = nx - 0.5，dy = ny - 0.5；\n   - 返回 { rx: -dy*2*maxTilt, ry: dx*2*maxTilt, gx: nx*100, gy: ny*100, bgX: 50 + dx*60, bgY: 50 + dy*60, angle: 115 + dx*90 - dy*45 }。\n2. CSS 三层光学与真 3D 结构（外层 perspective: 900px）：\n   - 卡片本体：transform-style: preserve-3d; transform: rotateX(var(--holo-rx, 0deg)) rotateY(var(--holo-ry, 0deg)); 默认 transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1)，激活态 transition-duration: 70ms。\n   - ::before 彩虹衍射箔层：repeating-linear-gradient(var(--holo-ang), 青绿/天蓝/紫罗兰/粉红循环)，background-size: 240% 240%，background-position: var(--holo-bgx) var(--holo-bgy)，mix-blend-mode: color-dodge，静置 opacity: 0.24，激活 opacity: 0.72，pointer-events: none。\n   - ::after 镜面光斑层：radial-gradient(circle at var(--holo-gx) var(--holo-gy), rgba(255,255,255,0.42), transparent 64%)，mix-blend-mode: overlay，激活 opacity: 1，pointer-events: none。\n   - 内部文字/徽章容器：transform: translateZ(24px) 形成浮雕视差。\n3. 指针同步与降级：\n   - pointermove 读取归一化坐标写入全部 CSS 变量并加 .is-active；pointerleave 复位 (0.5, 0.5) 并移除 .is-active。\n   - prefers-reduced-motion: reduce 下禁用倾斜与高光斑，仅保留静态微弱箔光（opacity: 0.25）。\n\n硬要求：\n- 倾斜角、衍射光栅角/位移与镜面光斑必须由同一份指针坐标同步计算，禁止拆成互不相关的动画。\n- 两层光学伪元素必须设 pointer-events: none，且分别使用 color-dodge 与 overlay 混合保住暗底文字对比度。\n- 严禁引入 Three.js 或外部图片遮罩。\n\n验收：\n- 鼠标移入并绕卡面滑动时，卡片 3D 倾斜跟手，彩虹光栅随角度扫过表面，白色高光点紧贴指针，内部文字呈微浮雕视差。\n- 移出卡片后 320ms 平滑归平，衍射光收回到克制静置态。\n- 开启减弱动效后卡片保持平面静止与静态微光，文字锐利清晰。",
        "dont_do": "- 别把彩虹层设成不透明普通图层盖在文字上面 —— 文字对比度会直接崩掉。\n- 别在 `pointermove` 上保留 `320ms` 慢过渡 —— 鼠标甩过去半秒后光斑才追上来，手感会极度发黏。\n- 别忘了 `pointerleave` 归位 —— 鼠标划走后卡片一直歪着非常难看。",
        "skill_rule": "# 3D 全息折射炫彩卡 (holo-card) · 跨平台动效规范\n性质：材质 ｜ 平台：both\n\n【核心原理】用纯函数把归一化指针坐标 (nx, ny) 同步映射为卡片 3D 倾斜角 (rx, ry)、彩虹光栅衍射角与背景偏移、镜面高光斑点位置 7 个光学 CSS 变量，以 color-dodge 衍射箔层 + overlay 镜面光斑 + translateZ(24px) 浮雕内容还原实体全息收藏卡质感。\n\n【硬要求】\n- 倾斜角、衍射光栅角/位移与镜面光斑必须由同一份指针坐标同步计算，禁止拆成互不相关的动画。\n- 两层光学伪元素必须设 pointer-events: none，且分别使用 color-dodge 与 overlay 混合保住暗底文字对比度。\n- 严禁引入 Three.js 或外部图片遮罩。\n\n【验收标准】\n- 鼠标移入并绕卡面滑动时，卡片 3D 倾斜跟手，彩虹光栅随角度扫过表面，白色高光点紧贴指针，内部文字呈微浮雕视差。\n- 移出卡片后 320ms 平滑归平，衍射光收回到克制静置态。\n- 开启减弱动效后卡片保持平面静止与静态微光，文字锐利清晰。\n\n【禁止做法】\n- 别把彩虹层设成不透明普通图层盖在文字上面 —— 文字对比度会直接崩掉。\n- 别在 `pointermove` 上保留 `320ms` 慢过渡 —— 鼠标甩过去半秒后光斑才追上来，手感会极度发黏。\n- 别忘了 `pointerleave` 归位 —— 鼠标划走后卡片一直歪着非常难看。",
        "prompt_en": "Core Principle:\nBuild a zero-dependency 3D Holographic Foil Card. A pure function synchronously maps normalized pointer coordinates `(nx, ny)` into 7 optical CSS variables—3D card tilt `(rx, ry)`, rainbow diffraction grating angle & background offset, and specular hotspot position—combining a `color-dodge` diffraction foil layer, an `overlay` specular spot, and `translateZ(24px)` embossed content to reproduce a physical holographic collectible card.\n\nImplementation:\n1. Pure function `holoLight(nx, ny, maxTilt = 16)`:\n   - Clamp `nx, ny` to `[0, 1]` (fallback `0.5` if invalid), `dx = nx - 0.5`, `dy = ny - 0.5`.\n   - Return `{ rx: -dy * 2 * maxTilt, ry: dx * 2 * maxTilt, gx: nx * 100, gy: ny * 100, bgX: 50 + dx * 60, bgY: 50 + dy * 60, angle: 115 + dx * 90 - dy * 45 }`.\n2. CSS 3-layer optical & true 3D structure (outer wrapper `perspective: 900px`):\n   - Card body: `transform-style: preserve-3d; transform: rotateX(var(--holo-rx, 0deg)) rotateY(var(--holo-ry, 0deg));`, default `transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1)`, active state `transition-duration: 70ms`.\n   - `::before` rainbow diffraction foil: `repeating-linear-gradient(var(--holo-ang), ...)` cycling cyan-green/sky-blue/violet/pink, `background-size: 240% 240%`, `background-position: var(--holo-bgx) var(--holo-bgy)`, `mix-blend-mode: color-dodge`, resting `opacity: 0.24`, active `opacity: 0.72`, `pointer-events: none`.\n   - `::after` specular hotspot: `radial-gradient(circle at var(--holo-gx) var(--holo-gy), rgba(255,255,255,0.42), transparent 64%)`, `mix-blend-mode: overlay`, active `opacity: 1`, `pointer-events: none`.\n   - Inner text/badge container: `transform: translateZ(24px)` for embossed parallax.\n3. Pointer synchronization & reduced-motion:\n   - `pointermove` reads normalized coordinates, writes all CSS variables, and adds `.is-active`; `pointerleave` resets to `(0.5, 0.5)` and removes `.is-active`.\n   - Under `prefers-reduced-motion: reduce`, disable tilt and specular hotspot while retaining a subtle static foil sheen (`opacity: 0.25`).\n\nHard Constraints:\n- Tilt angles, diffraction grating angle/offset, and specular hotspot must all be derived synchronously from the same pointer coordinates—never split into unrelated animations.\n- Both optical pseudo-elements must set `pointer-events: none` and use `color-dodge` and `overlay` blend modes respectively to preserve dark-background text contrast.\n- Never import Three.js or external image masks.\n\nAcceptance Criteria:\n- Hovering and gliding across the card makes 3D tilt track the pointer smoothly while rainbow grating sweeps across the surface, the white specular hotspot hugs the cursor, and inner text displays subtle embossed parallax.\n- Moving off the card settles smoothly back to flat over `320ms` as diffraction recedes to its restrained resting state.\n- With reduced motion enabled, the card remains flat and still with subtle static sheen and crisp, legible text.",
        "dont_do_en": "- Do NOT make the rainbow foil an opaque normal layer sitting over the text — text contrast will collapse immediately.\n- Do NOT keep the `320ms` slow transition active during `pointermove` — if the highlight trails half a second behind a fast sweep, the feel becomes sluggish and sticky.\n- Do NOT forget to reset on `pointerleave` — leaving the card permanently tilted after the cursor exits looks broken.",
        "skill_rule_en": "# 3D Holographic Foil Card (holo-card) · Cross-Platform Motion Spec\nNature: Material | Layer: 3d | Platform: both\n\nCore Principle: Build a zero-dependency 3D Holographic Foil Card. A pure function synchronously maps normalized pointer coordinates `(nx, ny)` into 7 optical CSS variables—3D card tilt `(rx, ry)`, rainbow diffraction grating angle & background offset, and specular hotspot position—combining a `color-dodge` diffraction foil layer, an `overlay` specular spot, and `translateZ(24px)` embossed content to reproduce a physical holographic collectible card.\n\nHard Constraints:\n- Tilt angles, diffraction grating angle/offset, and specular hotspot must all be derived synchronously from the same pointer coordinates—never split into unrelated animations.\n- Both optical pseudo-elements must set `pointer-events: none` and use `color-dodge` and `overlay` blend modes respectively to preserve dark-background text contrast.\n- Never import Three.js or external image masks.\n\nAcceptance Criteria:\n- Hovering and gliding across the card makes 3D tilt track the pointer smoothly while rainbow grating sweeps across the surface, the white specular hotspot hugs the cursor, and inner text displays subtle embossed parallax.\n- Moving off the card settles smoothly back to flat over `320ms` as diffraction recedes to its restrained resting state.\n- With reduced motion enabled, the card remains flat and still with subtle static sheen and crisp, legible text.\n\nDo NOT Do:\n- Do NOT make the rainbow foil an opaque normal layer sitting over the text — text contrast will collapse immediately.\n- Do NOT keep the `320ms` slow transition active during `pointermove` — if the highlight trails half a second behind a fast sweep, the feel becomes sluggish and sticky.\n- Do NOT forget to reset on `pointerleave` — leaving the card permanently tilted after the cursor exits looks broken."
      }
    },
    {
      "id": "long-press",
      "name": "长按",
      "name_en": "Long Press with Click Guard",
      "layer": "mobile",
      "nature": "反馈",
      "platform": "touch",
      "status": "shipped",
      "entry": "v-mk-longpress / longPress(el, onLong, { delay, haptic })",
      "source": "iOS 14+ 上下文菜单的前置动作（按住不动 → 系统进入\"可对这项做更多事\"的状态）",
      "source_en": "iOS / Android long-press recognizer (480ms timer + post-trigger click suppression)",
      "file": "effects/long-press.md",
      "summary": "按住不动 480ms，元素轻微下沉、震一下，并触发回调；提前松手或手指滑走即取消。",
      "summary_en": "480ms sustained press with subtle sink feedback, haptic buzz, movement cancellation, and a document-capture click suppressor so releasing never fires stray clicks.",
      "problem": "**「点一下」和「按住」必须是两个不同的意图。** 列表项点一下是进入详情，按住是进入多选 /\n呼出上下文菜单。如果只有 click，用户没有第二个通道表达「我要对这一项做更多事」——\n只能退回到某一级菜单里去找。\n\n这个效果同时解决第二个问题：**按住的那 480ms 里必须持续有反馈**，否则用户不知道\n\"系统有没有收到我在按着\"。这就是 `.is-longpress` 那 3% 下沉的全部意义。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 480ms 这个阈值（比 iOS 原生 500ms 略短，留出人类反应误差） | 系统的触觉波形（Core Haptics 的连续微震）—— 见 `haptic-pattern` 卡 |\n| 「按住期间有可见状态」 | 原生的背景模糊 + 整页缩放 + 菜单从指尖长出，那需要整套浮层，见缺口队列 P0 |\n| 「滑走即取消」 | 原生的\"按到一半浮起预览\"（peek） |\n\n480ms 不是拍脑袋的：UIKit 的 `UILongPressGestureRecognizer` 默认\n`minimumPressDuration` 是 500ms，取 480 只是把这段留给\"手指真正落下比\n`pointerdown` 早几毫秒\"的误差。低于约 400ms 开始出问题 —— **按得慢一点的普通点击**\n（手指按下去、想了一下、再抬起）会被误判成长按；高于 550ms 则会让\"按住\"\n读起来像\"卡住了\"，用户会松手再试一次。",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| `delay` | 480ms | 见上。这是唯一必须调对的数 |\n| `haptic` | `true` → `buzz(12)` | 比按压的 8ms 长，因为长按是一个\"承诺\"而非\"接触\"；iOS 上静默失败，不影响功能 |\n| 下沉幅度 | `scale(0.97)` | 和按压的 `0.955` 几乎一样大 —— 不用更大，因为时长本身已经在传达\"这不是一次点击\" |\n| 取消条件 | `pointerup` / `pointercancel` / `pointerleave` | 三个都要挂。少 `pointerleave` 就会出现\"手指滑出去、计时还在跑、480ms 后在别处触发了长按\" |",
      "implementation": "```\ntap.js:95      armedLongPresses + onDocClick  —— 全库共用一个 document 捕获监听\ntap.js:153     longPress(el, onLong, { delay = 480, haptic = true, suppressClickFor = 350 })\ntap.js:69      buzz(ms)            —— 能力探测，没有 navigator.vibrate 就返回 false\nmobile.css:80  .mk-tap.is-longpress —— 只写 transform，不写动画\n```\n\n三个职责分得很干净：\n- **计时与取消**在 JS（`longPress`），因为要读指针事件；\n- **视觉状态**在 CSS（`.is-longpress`），因为不挂 JS 时它不该存在；\n- **震动**是可选加分项（`buzz`），失败静默。\n\n`v-mk-longpress` 会顺手加 `mk-tap` 类 —— 没有它，`.is-longpress` 的 `scale` 起不来，\n因为那条规则是挂在 `.mk-tap` 上的。",
      "degradation": "**走 `mobile.css` 那档：减，不是关。**\n\n`.is-longpress` 只写 `transform: scale(0.97)`，没有 `transition`（下沉是瞬时的），\n所以 `prefers-reduced-motion` 下不需要特殊处理 —— 它不是动画，是一次性的状态切换。\n震动本来就不该在\"减少动效\"时保留，但 `buzz()` 只在触发时调用一次，没有常驻开销。\n\n`.mk-lite` 下同样不摘：长按是功能而不是装饰，摘掉就没有多选入口了。",
      "pitfalls": "**① 长按触发之后，`click` 还是会跟进来。** 这是实测确认过的（修复前）：\n\n```\n真实库 · 长按 700ms 后松手: [\"longpress\",\"click\"]\n真实库 · 短按 200ms 后松手: [\"click\"]\n```\n\n也就是说，如果同一个元素上挂 `v-mk-longpress` 又挂了 `@click`，用户长按想进多选，\n松手却把详情页也打开了。**已修复**（2025-11）：\n\n- 触发长按时\"武装\"一个拦截器，拦掉下一个 click；click 来了或 350ms 过后自动解除\n  （手指移出没产生 click 时，窗口不能永久占着，否则会误拦无关点击）。\n- **拦截器挂 `document` 捕获阶段，不是元素上** —— 这是这次修复真正学到的知识：\n  元素上的监听在**目标阶段**执行，而同一节点上的监听按**注册顺序**跑，业务的\n  `@click` 几乎总是先于指令挂上，元素上的拦截器永远排在它后面，\n  `stopImmediatePropagation` 也拦不住先注册的。**捕获祖先（document）天然早于\n  目标阶段**，是目前唯一能稳定跑在业务 handler 前面的位置。\n  唯一失效的情形：业务自己也挂了 `document` 捕获监听、且注册得更早 —— 那种页面\n  本来就该自己管事件顺序，不归这个指令负责。\n- 修复前卡片里给的\"元素上挂捕获期拦截\"的规避写法是**错的** —— 同一节点上\n  `capture: true` 不改变执行顺序（目标阶段 capture/bubble 按注册序合并），\n  那段代码只在业务 handler 挂在祖先节点时碰巧可用。\n- 拦截器在**挂载时**就和所有长按共用注册（`document` 上只有一个 click 监听），\n  不等到触发时再 add。捕获阶段的先后与注册时机无关，所以触发时再注册在浏览器里\n  也能跑；但那样\"监听器在不在\"就依赖时序，同步派发 click 的环境（比如 Node 桩\n  做单测）会测不出真实行为。早注册 + 靠 armed 集合判断，行为只取决于集合状态。\n\n**② 这条注释和代码不符。** `mobile.css:79` 写的是「轻微下沉 + 一圈扩散的进度环」，\n但下面只有 `transform: scale(0.97)` —— 进度环从来没有实现过。任何依赖\"按住时有进度感\"\n的设计，都得自己补：`--mk-longpress-p` 由 rAF 从 0 写到 1，CSS 拿去驱动 `conic-gradient`。\n补的时候别用 `transition` 从 0 到 1 —— 那和计时器不同步，用户松手时环还差一截。\n\n**③ 长按不能挂在会滚动的容器本身**，否则用户想滚动列表时，每一次滑动都先触发一次\n`pointerdown` 计时。要么挂在行上（行不滚，容器滚），要么在 `pointermove` 超过 8px 时取消\n—— 但那是另一套逻辑，`longPress()` 现在不判位移。\n\n**④ 和 `v-mk-tap` 别叠在同一个节点。** 两者都写 `transform`，虽然 `scale(0.955)` 和\n`scale(0.97)` 差不多，但一边 `pointerup` 撤类、一边移类，会出现\"按下下沉、松开弹回、\n再沉一次\"的抖动。要两者都要，就只留 `v-mk-tap`（它已经在粗指针上生效），\n把长按的视觉交给同一个 `.is-tap`。\n\n---",
      "ai_assets": {
        "prompt": "实现移动端的「长按」交互。原生 JS，不引依赖。\n\n原理一句话：一个计时器 + 一个\"已经触发\"的标记。难点不在计时，在于长按之后浏览器仍会补一个 click，必须按事件传播顺序把它吃掉。\n\n行为：\n- 指针按下后启动计时器，480ms 后触发一次 onLong 回调。\n- 提前 pointerup / pointercancel / pointerleave 任一发生，立即取消计时器。\n- 触发时给元素加 .is-longpress（CSS 里写 transform: scale(0.97)，不要 transition ——\n  它是状态切换不是动画），并尝试 navigator.vibrate(12)，\n  不支持就静默跳过（iOS Safari 没有 vibrate，绝不能抛错）。\n- 只在触屏/粗指针上生效：matchMedia('(hover: none), (pointer: coarse)')。\n  鼠标端不要挂 —— 鼠标有自己的右键菜单。\n\n硬要求（这一条最容易做错）：\n- 长按触发之后，同一次触摸在松手时仍会派发一个 click 事件。\n  必须拦掉它，否则\"长按进多选\"会同时把详情页也打开。\n  拦截器要挂在 document 的捕获阶段，触发时\"武装\"、拦掉第一个 click 或\n  350ms 后自动解除 —— 不要挂在元素上：元素上的监听在目标阶段执行，\n  同一节点按注册顺序跑，业务的 @click 多半先注册，永远排在它后面。\n- 监听器在挂载时就注册在 document 上（捕获），不要等触发时才 add ——\n  捕获阶段本来就早于目标阶段，早注册只是让行为不依赖时序，\n  同步派发 click 的测试环境才测得出真实行为。\n- 一页可能有几十行都用这个指令：document 上只留一个 click 监听，\n  用引用计数在最后一个实例卸载时摘掉，不要每行各挂一个。\n- 拦截用 stopImmediatePropagation + preventDefault。\n\n验收：\n- 按住 700ms 松手：onLong 恰好触发一次，click 不触发。\n- 按住 200ms 松手：只有 click，onLong 不触发。\n- 按住 300ms 后手指滑出元素：什么都不触发。\n- 触发后 350ms 内没有 click（手指移走）：窗口自动解除，\n  之后一次无关的合法点击不受影响。\n- 按 1000 次不泄漏监听器（返回 teardown 函数，移除全部监听）。",
        "dont_do": "- 别用 `setTimeout` 里读 `getBoundingClientRect` —— 长按不需要几何。\n- 别在 `pointerdown` 里 `preventDefault()`，那会顺手禁掉文本选择和链接预览。\n- 别把拦截器挂到元素上 —— 注册顺序保证不了，详见第 7 栏①。\n- 别在触发长按时才往 document 上加监听 —— 捕获虽然不分先后，但那样\n  监听器的存在与否就取决于时序，同步派发 click 的环境测不出真实行为。\n- 别把 `delay` 做成 CSS 变量或可配项却不同步改震动时长 —— 两个数是一对。",
        "skill_rule": "# 长按 (long-press) · 跨平台动效规范\n性质：反馈 ｜ 平台：touch\n\n【核心原理】一个计时器 + 一个\"已经触发\"的标记。难点不在计时，在于长按之后浏览器仍会补一个 click，必须按事件传播顺序把它吃掉。\n\n【验收标准】\n- 按住 700ms 松手：onLong 恰好触发一次，click 不触发。\n- 按住 200ms 松手：只有 click，onLong 不触发。\n- 按住 300ms 后手指滑出元素：什么都不触发。\n- 触发后 350ms 内没有 click（手指移走）：窗口自动解除，\n  之后一次无关的合法点击不受影响。\n- 按 1000 次不泄漏监听器（返回 teardown 函数，移除全部监听）。\n\n【禁止做法】\n- 别用 `setTimeout` 里读 `getBoundingClientRect` —— 长按不需要几何。\n- 别在 `pointerdown` 里 `preventDefault()`，那会顺手禁掉文本选择和链接预览。\n- 别把拦截器挂到元素上 —— 注册顺序保证不了，详见第 7 栏①。\n- 别在触发长按时才往 document 上加监听 —— 捕获虽然不分先后，但那样\n  监听器的存在与否就取决于时序，同步派发 click 的环境测不出真实行为。\n- 别把 `delay` 做成 CSS 变量或可配项却不同步改震动时长 —— 两个数是一对。",
        "prompt_en": "Core Principle:\nBuild a zero-dependency mobile Long Press interaction in native JS using one timer and one \"already triggered\" flag. The real challenge is not timing, but intercepting the trailing `click` event dispatched by the browser on release according to DOM event propagation order.\n\nImplementation:\n1. Timing & feedback:\n   - Start a timer on pointer down and fire `onLong` once after `480ms`.\n   - Cancel the timer immediately if `pointerup`, `pointercancel`, or `pointerleave` occurs early.\n   - On trigger, add `.is-longpress` to the element (CSS uses `transform: scale(0.97)` with NO `transition`—it is a state switch, not an animation) and attempt `navigator.vibrate(12)`, silently skipping if unsupported (iOS Safari lacks `vibrate` and must never throw).\n   - Activate only on touch/coarse-pointer devices: `matchMedia('(hover: none), (pointer: coarse)')`. Do not attach on mouse devices, which already have context menus.\n2. Click guard architecture:\n   - Attach a capture-phase `click` listener on `document` at mount time (arm on trigger, block the first `click`, or disarm automatically after `350ms`) using `stopImmediatePropagation()` + `preventDefault()`.\n   - Share a single `document` capture `click` listener across all instances via reference counting, removing it only when the last instance unmounts.\n\nHard Constraints:\n- When long press triggers, lifting the finger from that same touch still dispatches a `click` event; it MUST be blocked so \"long press to enter multi-select\" does not also open the detail page. Never attach the blocker directly to the element—target-phase listeners run in registration order, and business `@click` handlers are usually registered first.\n- Register the capture-phase listener on `document` at mount time rather than waiting until trigger time—capture already runs before target, and early registration avoids timing-dependent behavior when tests dispatch `click` synchronously.\n- Maintain only one shared `document` click listener with reference counting across dozens of rows, never one per row.\n- Block the trailing click using both `stopImmediatePropagation()` and `preventDefault()`.\n\nAcceptance Criteria:\n- Press `700ms` and release: `onLong` fires exactly once; `click` does not fire.\n- Press `200ms` and release: only `click` fires; `onLong` does not fire.\n- Press `300ms` and slide finger off the element: neither fires.\n- If no `click` arrives within `350ms` after trigger (finger moved away), the guard disarms automatically and a subsequent unrelated legitimate click works normally.\n- Pressing 1,000 times leaks zero listeners (returns a `teardown` function that removes all listeners).",
        "dont_do_en": "- Do NOT call `getBoundingClientRect()` inside `setTimeout` — long press requires no geometry.\n- Do NOT call `preventDefault()` inside `pointerdown` — that disables text selection and link previews.\n- Do NOT attach the click blocker directly to the element — listener registration order cannot be guaranteed (use a document-level capture listener as specified in Hard Constraints).\n- Do NOT wait until long press triggers to add the listener to `document` — making listener presence depend on timing breaks deterministic testing when `click` is dispatched synchronously.\n- Do NOT expose `delay` as a CSS variable or configurable option without keeping any paired feedback timing in sync — the two values belong together.",
        "skill_rule_en": "# Long Press with Click Guard (long-press) · Cross-Platform Motion Spec\nNature: Feedback | Layer: mobile | Platform: touch\n\nCore Principle: Build a zero-dependency mobile Long Press interaction in native JS using one timer and one \"already triggered\" flag. The real challenge is not timing, but intercepting the trailing `click` event dispatched by the browser on release according to DOM event propagation order.\n\nHard Constraints:\n- When long press triggers, lifting the finger from that same touch still dispatches a `click` event; it MUST be blocked so \"long press to enter multi-select\" does not also open the detail page. Never attach the blocker directly to the element—target-phase listeners run in registration order, and business `@click` handlers are usually registered first.\n- Register the capture-phase listener on `document` at mount time rather than waiting until trigger time—capture already runs before target, and early registration avoids timing-dependent behavior when tests dispatch `click` synchronously.\n- Maintain only one shared `document` click listener with reference counting across dozens of rows, never one per row.\n- Block the trailing click using both `stopImmediatePropagation()` and `preventDefault()`.\n\nAcceptance Criteria:\n- Press `700ms` and release: `onLong` fires exactly once; `click` does not fire.\n- Press `200ms` and release: only `click` fires; `onLong` does not fire.\n- Press `300ms` and slide finger off the element: neither fires.\n- If no `click` arrives within `350ms` after trigger (finger moved away), the guard disarms automatically and a subsequent unrelated legitimate click works normally.\n- Pressing 1,000 times leaks zero listeners (returns a `teardown` function that removes all listeners).\n\nDo NOT Do:\n- Do NOT call `getBoundingClientRect()` inside `setTimeout` — long press requires no geometry.\n- Do NOT call `preventDefault()` inside `pointerdown` — that disables text selection and link previews.\n- Do NOT attach the click blocker directly to the element — listener registration order cannot be guaranteed (use a document-level capture listener as specified in Hard Constraints).\n- Do NOT wait until long press triggers to add the listener to `document` — making listener presence depend on timing breaks deterministic testing when `click` is dispatched synchronously.\n- Do NOT expose `delay` as a CSS variable or configurable option without keeping any paired feedback timing in sync — the two values belong together."
      }
    },
    {
      "id": "magnetic",
      "name": "磁吸按钮",
      "name_en": "Magnetic Pull Button",
      "layer": "motion",
      "nature": "权重",
      "platform": "web",
      "status": "shipped",
      "entry": "v-mk-magnetic + .mk-magnetic / magnetic(el, { strength, radius, max })",
      "source": "Rauno / Vercel / 苹果磁吸控件（90px 判定半径 + 0.18 lerp 追随 + 14px 钳制上限）",
      "source_en": "Award-winning portfolio CTAs (90px proximity field + damped magnetic offset)",
      "file": "effects/magnetic.md",
      "summary": "指针靠近按钮周围 90px 判定区时，按钮被柔和拉向指针方向（最大偏移 14px），离开判定区后沿阻尼插值自然弹回原位。",
      "summary_en": "Gently pulls a CTA button toward the cursor within a 90px field (capped at 14px offset) and springs cleanly back to rest on pointer exit.",
      "problem": "**主 CTA 按钮如果只在 hover 时换个颜色，缺少“它正在等你点”的吸引力；但偏移太大又会让用户追着按钮点不到。** 用极克制的 0.35 跟随系数 + 14px 硬上限，既给出明显磁性吸附感，又保证指针永远轻松命中按钮。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 指针靠近判定区即启动吸引 + 0.18 lerp 顺滑回中 | 按钮跑出原位 40px 导致用户点空的过度磁吸 |\n| JS 只写 `--mk-mag-x` / `--mk-mag-y`，不覆写 inline `transform` | 在触屏设备上启用（无悬停，纯属误触发） |\n| 归位误差 ≤0.05px 自动停掉 rAF | 常驻 60fps 空转动画循环 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 判定半径 `radius` | `90px`（外扩） | 指针快到按钮前就能感受到微妙牵引；超过 160px 会干扰邻近元素 |\n| 跟随系数 `strength` | `0.35` | 手指/鼠标移动 10px 按钮跟 3.5px，有重量感又不抢跑 |\n| 最大偏移 `max` | `14px` | 保证按钮中心永远不跑出原本热区范围，绝不出现“追着点不到” |\n| lerp 系数 | `0.18` / 帧 | 比硬跟手更有磁性粘滞感，离开时平滑回弹，误差 ≤0.05px 停帧 |",
      "implementation": "```\nsrc/core/tilt.js:98   magnetic(el, { strength, radius, max, reduced })  写 --mk-mag-x / --mk-mag-y\nstyles/motion.css     .mk-magnetic（transform: translate3d(var(--mk-mag-x), var(--mk-mag-y), 0)）\n```",
      "degradation": "**走 `motion` 档：减，不关（减弱动效与触屏端直接不挂监听）。**\n\n`prefers-reduced-motion: reduce` 或 `(hover: none), (pointer: coarse)` 下直接返回空清理函数，按钮保持静止原位，点击功能不受任何影响。",
      "pitfalls": "**① 偏移不设 `max` 上限导致鼠标在边缘时按钮“躲开点击”。**\n必须对 `dx * strength` 和 `dy * strength` 分别钳制在 `[-14px, 14px]`。\n\n**② 一屏给 10 个按钮都挂磁吸。**\n磁吸是强调手段，整屏最多给 1–3 个主 CTA 或核心导航项；满屏都在吸会让页面显得像在晃动。\n\n**③ 忘了停帧或卸载时未移除 `window` 上的 `pointermove`。**\n收敛到 `< 0.05px` 必须把 `raf = 0`，且 `destroy()` 里务必 `cancelAnimationFrame` 并摘除全局监听。\n\n---",
      "ai_assets": {
        "prompt": "实现桌面端磁吸按钮（Magnetic Button），零动画库依赖。\n\n原理一句话：监听指针距离按钮中心是否进入 radius（半宽 + 90px），进入时目标偏移 = clamp(差值 * 0.35, -14, 14)px，通过 rAF lerp（0.18/帧）写入 CSS 变量 --mag-x / --mag-y，收敛到 0.05px 内停帧。\n\n做法：\n1. 能力门禁：若 prefers-reduced-motion: reduce 或 matchMedia('(hover: none), (pointer: coarse)') 命中，直接不注册监听。\n2. 判定与插值（strength = 0.35, radius = 90, max = 14）：\n   - window 监听 pointermove（passive: true）：\n     计算按钮中心 (cx, cy) 与指针差值 (dx, dy) 及欧氏距离 dist = Math.hypot(dx, dy)。\n     若 dist > rect.width / 2 + radius，目标置 { x: 0, y: 0 }；\n     否则目标置 { x: clamp(dx * 0.35, -14, 14), y: clamp(dy * 0.35, -14, 14) }。\n   - rAF loop：cur.x += (target.x - cur.x) * 0.18；cur.y 同理；写入 --mag-x / --mag-y（px）。\n     仅当 |target.x - cur.x| > 0.05 || |target.y - cur.y| > 0.05 时继续预约下一帧，否则停帧。\n3. CSS：\n   - 按钮 transform: translate3d(var(--mag-x, 0px), var(--mag-y, 0px), 0);\n\n硬要求：\n- 位移必须硬钳制在 ±14px 内，绝不让按钮跑出原本点击热区。\n- JS 只写 CSS 变量，不直接覆盖 transform；且归位后 rAF 必须彻底停止。\n- 触屏与减弱动效下直接关闭。\n\n验收：\n- 指针进入按钮外 90px 范围时按钮柔和偏向指针，最大偏移不超过 14px。\n- 指针移开后按钮平滑弹回 (0, 0) 并停止 rAF。\n- 组件卸载后 window pointermove 监听被完整移除。",
        "dont_do": "- 别把最大偏移设到 30px 以上 —— 会让用户追着按钮点不到。\n- 别给一整排普通列表按钮全部挂磁吸 —— 每屏克制在 1–3 个主操作即可。\n- 别让 rAF 在页面静止时持续空转。",
        "skill_rule": "# 磁吸按钮 (magnetic) · 跨平台动效规范\n性质：权重 ｜ 平台：web\n\n【核心原理】监听指针距离按钮中心是否进入 radius（半宽 + 90px），进入时目标偏移 = clamp(差值 * 0.35, -14, 14)px，通过 rAF lerp（0.18/帧）写入 CSS 变量 --mag-x / --mag-y，收敛到 0.05px 内停帧。\n\n【硬要求】\n- 位移必须硬钳制在 ±14px 内，绝不让按钮跑出原本点击热区。\n- JS 只写 CSS 变量，不直接覆盖 transform；且归位后 rAF 必须彻底停止。\n- 触屏与减弱动效下直接关闭。\n\n【验收标准】\n- 指针进入按钮外 90px 范围时按钮柔和偏向指针，最大偏移不超过 14px。\n- 指针移开后按钮平滑弹回 (0, 0) 并停止 rAF。\n- 组件卸载后 window pointermove 监听被完整移除。\n\n【禁止做法】\n- 别把最大偏移设到 30px 以上 —— 会让用户追着按钮点不到。\n- 别给一整排普通列表按钮全部挂磁吸 —— 每屏克制在 1–3 个主操作即可。\n- 别让 rAF 在页面静止时持续空转。",
        "prompt_en": "Core Principle:\nBuild a zero-library desktop Magnetic Pull Button. Monitors whether the pointer enters `radius` (`halfWidth + 90px`) from the button center; when inside, computes `target = clamp(delta * 0.35, -14, 14)px` and interpolates via a `rAF` lerp (`0.18` per frame) into `--mag-x` / `--mag-y`, stopping the loop once settled within `0.05px`.\n\nImplementation:\n1. Capability gate:\n   - If `prefers-reduced-motion: reduce` or `matchMedia('(hover: none), (pointer: coarse)')` matches, do not register listeners.\n2. Detection & interpolation (`strength = 0.35`, `radius = 90`, `max = 14`):\n   - Listen to `window` `pointermove` (`passive: true`): compute button center `(cx, cy)`, pointer delta `(dx, dy)`, and Euclidean distance `dist = Math.hypot(dx, dy)`. If `dist > rect.width / 2 + radius`, set `target = { x: 0, y: 0 }`; otherwise `target = { x: clamp(dx * 0.35, -14, 14), y: clamp(dy * 0.35, -14, 14) }`.\n   - `rAF` loop: `cur.x += (target.x - cur.x) * 0.18` (and same for `cur.y`); write `--mag-x` / `--mag-y` in `px`. Schedule the next frame only while `|target.x - cur.x| > 0.05 || |target.y - cur.y| > 0.05`; otherwise stop.\n3. CSS:\n   - Button applies `transform: translate3d(var(--mag-x, 0px), var(--mag-y, 0px), 0);`.\n\nHard Constraints:\n- Displacement must be hard-clamped within `±14px` so the button never escapes its original hit target.\n- JS must write only CSS variables without overwriting `transform` directly, and `rAF` must stop completely once settled back at rest.\n- Must be disabled on touch devices and under `prefers-reduced-motion: reduce`.\n\nAcceptance Criteria:\n- When the pointer enters within `90px` outside the button, the button gently pulls toward the pointer with a maximum offset of `14px`.\n- When the pointer leaves, the button smoothly springs back to `(0, 0)` and halts `rAF`.\n- On unmount, the `window` `pointermove` listener is completely removed.",
        "dont_do_en": "- Do NOT set max offset above `30px` — users end up chasing a button they cannot click.\n- Do NOT attach magnetic pull to an entire row of ordinary list buttons — restrict it to 1–3 primary actions per screen.\n- Do NOT leave `rAF` spinning idly when the page is stationary.",
        "skill_rule_en": "# Magnetic Pull Button (magnetic) · Cross-Platform Motion Spec\nNature: Weight | Layer: motion | Platform: web\n\nCore Principle: Build a zero-library desktop Magnetic Pull Button. Monitors whether the pointer enters `radius` (`halfWidth + 90px`) from the button center; when inside, computes `target = clamp(delta * 0.35, -14, 14)px` and interpolates via a `rAF` lerp (`0.18` per frame) into `--mag-x` / `--mag-y`, stopping the loop once settled within `0.05px`.\n\nHard Constraints:\n- Displacement must be hard-clamped within `±14px` so the button never escapes its original hit target.\n- JS must write only CSS variables without overwriting `transform` directly, and `rAF` must stop completely once settled back at rest.\n- Must be disabled on touch devices and under `prefers-reduced-motion: reduce`.\n\nAcceptance Criteria:\n- When the pointer enters within `90px` outside the button, the button gently pulls toward the pointer with a maximum offset of `14px`.\n- When the pointer leaves, the button smoothly springs back to `(0, 0)` and halts `rAF`.\n- On unmount, the `window` `pointermove` listener is completely removed.\n\nDo NOT Do:\n- Do NOT set max offset above `30px` — users end up chasing a button they cannot click.\n- Do NOT attach magnetic pull to an entire row of ordinary list buttons — restrict it to 1–3 primary actions per screen.\n- Do NOT leave `rAF` spinning idly when the page is stationary."
      }
    },
    {
      "id": "mgrid",
      "name": "磁性斥力点阵",
      "name_en": "Magnetic Repulsion Dot Grid",
      "layer": "fun",
      "nature": "权重",
      "platform": "web",
      "status": "shipped",
      "entry": "v-mk-mgrid + .mk-mgrid / magneticGrid(el, { radius, max }) / repelOffset()",
      "source": "物理斥力场点阵（二次衰减纯函数 repelOffset + 边缘连续归零 + 整层可关）",
      "source_en": "Interactive kinetic dot field (quadratic repulsion falloff + zero boundary snap)",
      "file": "effects/mgrid.md",
      "summary": "桌面指针划过点阵区域时，半径 90px 内的圆点按二次衰减公式背离指针平滑推开，越近推得越远、边缘处连续归零不突兀。",
      "summary_en": "Interactive dot matrix where points within 90px smoothly part away from the pointer along a quadratic falloff curve, seamlessly settling to zero at the edge.",
      "problem": "**科技感产品官网的背景或卡片装饰区如果只是静态点阵太乏味，但盲目加线性斥力会在指针扫过半径边界时看到点群“啪”地弹一下。** 用二次衰减 `(1 - d/radius)²` 让位移在边界处导数为 0，形成如水面涟漪般丝滑的交互场。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 物理斥力场二次衰减 `strength = (1 - d / radius)²`，边界导数归零 | 整页 WebGL 粒子着色器（违反 0 运行时原则） |\n| 抽离纯函数 `repelOffset(dx, dy, radius, max)` 并覆盖 5 项单测 | 触屏端强开（无持续悬停指针） |\n| 仅更新单容器内圆点位移，指针移出容器自动归零停算 | 全局全屏铺几千个 DOM 节点拖垮主线程 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 影响半径 `radius` | `90px` | 足够在鼠标周围形成清晰的一圈“空洞波纹”，又不会把整个小卡片的点全推乱 |\n| 最大推开位移 `max` | `16px` | 刚好让相邻圆点产生张力而不互相撞叠成一团 |\n| 衰减曲线 | `(1 - d / radius)²` | 距离越近推力陡增、在 `d = radius` 处值和斜率同时为 0，边界绝不折角 |\n| 零距离保护 | `d === 0` 返回 `{0, 0}` | 防止指针恰好落在圆心时 `dx / d` 除零算出 `NaN` |",
      "implementation": "```\nsrc/core/fun.js:231   repelOffset(dx, dy, radius, max)  纯函数，已覆盖 5 项单测\nsrc/core/fun.js:245   magneticGrid(el, { radius, max }) 自动铺点并驱动斥力位移\nstyles/fun.css        .mk-mgrid / .mk-mgrid__dot\n```",
      "degradation": "**走 `fun` 层专属契约：整层关掉（保留静态点阵，关闭所有斥力计算与监听）。**\n\n`prefers-reduced-motion: reduce` 或触屏粗指针下不注册 `pointermove`，点阵保持干净静止装饰，零 CPU 占用。",
      "pitfalls": "**① 忘了在 `d === 0` 时做除零防护。**\n指针正好压在某个圆点中心时 `Math.hypot(0, 0) === 0`，直接除以 `d` 会把该点坐标算成 `NaN` 消失。\n\n**② 在 `pointermove` 里每次都对 80 个点调用 `getBoundingClientRect()`。**\n每帧读 80 次布局会触发严重强制同步布局；应仅读一次容器的 `rect`，按网格行列坐标算出每个点的基准中心，或者在 resize 时缓存坐标。\n\n**③ 线性衰减 `1 - d / radius` 导致边界突兀。**\n线性公式在半径边缘斜率不为 0，圆点进入/离开影响圈时会明显“一顿”；平方衰减彻底消除折角。\n\n---",
      "ai_assets": {
        "prompt": "实现桌面端磁性斥力点阵（Magnetic Repel Dot Grid），零 WebGL/动画库依赖。\n\n原理一句话：用纯函数 repelOffset(dx, dy, radius=90, max=16) 按二次衰减 (1 - d/radius)² 计算每个圆点背离指针的推开位移，容器级单次测距驱动，边界连续归零。\n\n做法：\n1. 纯函数 repelOffset(dx, dy, radius = 90, max = 16)：\n   - d = Math.hypot(dx, dy)；若 d >= radius || d === 0 返回 { x: 0, y: 0 }（防除零）。\n   - strength = (1 - d / radius) ** 2；k = (strength * max) / d；\n   - 返回 { x: dx * k, y: dy * k }（方向严格背离指针，幅度 <= max）。\n2. 容器与铺点：\n   - 能力门禁：prefers-reduced-motion: reduce 或粗指针设备仅渲染静态点阵，不挂监听。\n   - 容器用 CSS Grid 均匀铺设 5×8 到 8×12 个圆点（每点 4–6px 圆，transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1)）。\n3. 指针交互：\n   - pointermove（用 rAF 合批，每帧最多算一次）：仅读容器 rect 或缓存各点基准中心 (bx, by)，对每个点算 dx = bx - pointerX, dy = by - pointerY，调 repelOffset 写入 transform: translate3d(x, y, 0)。\n   - pointerleave / pointercancel：所有圆点归零回到 translate3d(0, 0, 0)。\n\n硬要求：\n- 必须用二次衰减 (1 - d/radius)²，确保边界处位移与导数同时趋零。\n- d === 0 与 d >= radius 必须安全返回 { x: 0, y: 0 }，绝不产生 NaN。\n- 严禁在 pointermove 循环里对每个圆点逐个调用 getBoundingClientRect()。\n- prefers-reduced-motion: reduce 与触屏下保持静态点阵，不运行 JS 计算。\n\n验收：\n- 鼠标划过点阵，周围 90px 内的点平滑向四周让开形成圆形波纹，边缘过渡无折角；鼠标移开全部柔和归位。\n- repelOffset(0, 0) 返回 {0,0}；repelOffset(100, 0, 90, 16) 返回 {0,0}；推开幅度永远不超过 16px。\n- 减弱动效下点阵静止可读，控制台无报错。",
        "dont_do": "- 别为了一个小区域点阵引入 Three.js 或 Canvas 物理引擎。\n- 别一屏铺 1000 个 DOM 圆点 —— 单个交互区块控制在 40–100 个点以内最流畅。\n- 别用线性衰减 `1 - d/r` —— 半径边缘会出现生硬顿挫。",
        "skill_rule": "# 磁性斥力点阵 (mgrid) · 跨平台动效规范\n性质：权重 ｜ 平台：web\n\n【核心原理】用纯函数 repelOffset(dx, dy, radius=90, max=16) 按二次衰减 (1 - d/radius)² 计算每个圆点背离指针的推开位移，容器级单次测距驱动，边界连续归零。\n\n【硬要求】\n- 必须用二次衰减 (1 - d/radius)²，确保边界处位移与导数同时趋零。\n- d === 0 与 d >= radius 必须安全返回 { x: 0, y: 0 }，绝不产生 NaN。\n- 严禁在 pointermove 循环里对每个圆点逐个调用 getBoundingClientRect()。\n- prefers-reduced-motion: reduce 与触屏下保持静态点阵，不运行 JS 计算。\n\n【验收标准】\n- 鼠标划过点阵，周围 90px 内的点平滑向四周让开形成圆形波纹，边缘过渡无折角；鼠标移开全部柔和归位。\n- repelOffset(0, 0) 返回 {0,0}；repelOffset(100, 0, 90, 16) 返回 {0,0}；推开幅度永远不超过 16px。\n- 减弱动效下点阵静止可读，控制台无报错。\n\n【禁止做法】\n- 别为了一个小区域点阵引入 Three.js 或 Canvas 物理引擎。\n- 别一屏铺 1000 个 DOM 圆点 —— 单个交互区块控制在 40–100 个点以内最流畅。\n- 别用线性衰减 `1 - d/r` —— 半径边缘会出现生硬顿挫。",
        "prompt_en": "Core Principle:\nBuild a zero-WebGL, zero-library desktop Magnetic Repulsion Dot Grid. A pure function `repelOffset(dx, dy, radius = 90, max = 16)` computes each dot's push-away displacement via quadratic falloff `(1 - d/radius)²`, driven by container-level measurement so both displacement and slope reach zero smoothly at the radius edge.\n\nImplementation:\n1. Pure function `repelOffset(dx, dy, radius = 90, max = 16)`:\n   - `d = Math.hypot(dx, dy)`; if `d >= radius || d === 0`, return `{ x: 0, y: 0 }` (prevent division by zero).\n   - `strength = (1 - d / radius) ** 2`; `k = (strength * max) / d`;\n   - Return `{ x: dx * k, y: dy * k }` (strictly directed away from the pointer, magnitude `<= max`).\n2. Container & grid layout:\n   - Capability gate: render a static dot grid with no listeners under `prefers-reduced-motion: reduce` or coarse-pointer devices.\n   - Lay out `5x8` to `8x12` circular dots (`4–6px` diameter each) using CSS Grid with `transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1)`.\n3. Pointer interaction:\n   - Batch `pointermove` with `rAF` (at most once per frame): read only the container rect or cached dot resting centers `(bx, by)`, compute `dx = bx - pointerX, dy = by - pointerY`, invoke `repelOffset`, and write `transform: translate3d(x, y, 0)`.\n   - On `pointerleave` / `pointercancel`: reset all dots to `translate3d(0, 0, 0)`.\n\nHard Constraints:\n- Must use quadratic falloff `(1 - d/radius)²` so both displacement and its derivative converge to zero at the radius boundary.\n- `d === 0` and `d >= radius` must safely return `{ x: 0, y: 0 }` and never produce `NaN`.\n- Never call `getBoundingClientRect()` per dot inside the `pointermove` loop.\n- Keep a static dot grid with zero JS computation under `prefers-reduced-motion: reduce` and on touch devices.\n\nAcceptance Criteria:\n- Sweeping the cursor across the grid smoothly parts dots within `90px` into a circular ripple with no abrupt edge kink; leaving returns all dots gently to rest.\n- `repelOffset(0, 0)` returns `{0, 0}`; `repelOffset(100, 0, 90, 16)` returns `{0, 0}`; push magnitude never exceeds `16px`.\n- Under reduced motion, the grid remains static and legible with zero console errors.",
        "dont_do_en": "- Do NOT import Three.js or a Canvas physics engine just for a small localized dot grid.\n- Do NOT render 1,000 DOM dots across a screen — keep a single interactive region within 40–100 dots for smooth performance.\n- Do NOT use linear falloff `1 - d/r` — it creates a harsh discontinuity at the radius edge.",
        "skill_rule_en": "# Magnetic Repulsion Dot Grid (mgrid) · Cross-Platform Motion Spec\nNature: Weight | Layer: fun | Platform: web\n\nCore Principle: Build a zero-WebGL, zero-library desktop Magnetic Repulsion Dot Grid. A pure function `repelOffset(dx, dy, radius = 90, max = 16)` computes each dot's push-away displacement via quadratic falloff `(1 - d/radius)²`, driven by container-level measurement so both displacement and slope reach zero smoothly at the radius edge.\n\nHard Constraints:\n- Must use quadratic falloff `(1 - d/radius)²` so both displacement and its derivative converge to zero at the radius boundary.\n- `d === 0` and `d >= radius` must safely return `{ x: 0, y: 0 }` and never produce `NaN`.\n- Never call `getBoundingClientRect()` per dot inside the `pointermove` loop.\n- Keep a static dot grid with zero JS computation under `prefers-reduced-motion: reduce` and on touch devices.\n\nAcceptance Criteria:\n- Sweeping the cursor across the grid smoothly parts dots within `90px` into a circular ripple with no abrupt edge kink; leaving returns all dots gently to rest.\n- `repelOffset(0, 0)` returns `{0, 0}`; `repelOffset(100, 0, 90, 16)` returns `{0, 0}`; push magnitude never exceeds `16px`.\n- Under reduced motion, the grid remains static and legible with zero console errors.\n\nDo NOT Do:\n- Do NOT import Three.js or a Canvas physics engine just for a small localized dot grid.\n- Do NOT render 1,000 DOM dots across a screen — keep a single interactive region within 40–100 dots for smooth performance.\n- Do NOT use linear falloff `1 - d/r` — it creates a harsh discontinuity at the radius edge."
      }
    },
    {
      "id": "number-flow",
      "name": "动态数字流",
      "name_en": "Live Rolling Number Flow",
      "layer": "motion",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "numberFlow(el, value, { format }) / tokenizeNumber() / diffNumberFlow()",
      "source": "NumberFlow (@barvian) 的按位稳态滚动（仅滚变化位 + 个位对齐 + 读屏无障碍）",
      "source_en": "NumberFlow (@barvian) digit-diff rolling (ones-anchored keys + tabular-nums + aria-label isolation)",
      "file": "effects/number-flow.md",
      "summary": "金额、定价切换（月付 ↔ 年付）、实时余额或计数器变动时，按个位稳定编号拆槽——**只有发生变化的数位平滑滚动**，未变数位与货币/千分位符号稳如磐石，搭配 `tabular-nums` 零水平抖动且读屏软件正常播报完整数值。",
      "summary_en": "Right-aligned digit-keyed slot roller for live prices, balances, and counters — only changed digits roll smoothly with tabular-nums stability and full screen-reader isolation.",
      "problem": "传统数字动效有两大痛点：\n1. 一次性入场计数器（`countUp`）每次改值都用 rAF 逐帧重算并重写整段文本，导致未变的高位跟着闪烁、频繁变动时主线程压力大；\n2. 简单把字符串按从左到右索引拆列时，数字从 `$99` 涨到 `$100` 会让每一位都错位乱滚，且屏幕阅读器会把 0–9 滚筒全读成 `\"0123456789...\"`。",
      "origin": "来自 NumberFlow（`@barvian`）在定价页、金融看板与实时计费卡片中的数字流体验，去除 Web Component 运行时依赖：\n- 取：从个位向左稳定编 key（`int-0, int-1, ...`）实现增减位不错位、只滚变化位、等宽数字（`tabular-nums`）零抖动、`aria-label` 与滚筒 `aria-hidden=\"true\"` 分离读屏；\n- 丢：重型自定义元素运行时、逐帧 JS 改写文本、未做读屏隔离的裸 0–9 列表。",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 行高与视窗高度 | `1.15em` | 比 `1em` 多留 0.15em 上下余量，避免中文字体混排或带下沉基线的字体（如部分衬线体）顶底被裁切 |\n| 滚动时长 | `320ms` | 刚好让肉眼捕捉到数字“滑进新值”的因果感，又能在连续快速加减时随时中断跟上 |\n| 缓动曲线 | `cubic-bezier(0.22, 1, 0.36, 1)` | 快起慢落，高位/低位同时滚时末尾轻稳落定不回弹晃眼 |\n| 整数位 key 基准 | 从个位（`int-0`）向左编号 | `$99` → `$100` 时个位和十位原地保留槽位、仅左侧新增百位，绝不触发全列错位重绘 |",
      "implementation": "- 纯函数分词与差分：`tokenizeNumber(str)`（拆出前缀/负号/按个位编号的整数位/千分位/小数点/小数位/后缀）与 `diffNumberFlow(prevStr, nextStr, prevValue, nextValue)`（计算每位是否变化与整体涨跌趋势）；\n- 运行时控制器：`numberFlow(el, initialValue, { format, reduced })` 维护槽位节点复用、只改变化位的 `--mk-nf-d` 变量并同步 `aria-label`；\n- CSS 原语：`.mk-nflow`（强制 `font-variant-numeric: tabular-nums`）+ `.mk-nflow__digit`（`overflow: hidden; height: 1.15em`）+ `.mk-nflow__reel`（合成层 `translate3d` 滑动）。",
      "degradation": "**走 `motion` 档：减。** `prefers-reduced-motion: reduce` 下 `.mk-nflow__reel` 的 `transition-duration` 压到 `1ms`（首次挂载同样走 `.is-static` 无过渡），数值立刻直达目标，无滚动动画。",
      "pitfalls": "1. **按从左到右索引作为数位 key**：`99 → 100` 会把原本的 `9` 槽位复用到百位 `1`，导致所有数位集体错乱翻滚；整数区必须从**个位**向左计数。\n2. **没做读屏隔离**：把 `0 1 2 3 4 5 6 7 8 9` 塞进 DOM 却不加 `aria-hidden=\"true\"`，VoiceOver 会把 `$42` 朗读成 `\"美元 0123456789 0123456789\"`。必须在容器上写 `aria-label=\"$42\"` 并隐藏所有视觉滚筒。\n3. **漏写 `font-variant-numeric: tabular-nums`**：数字 `1` 与 `8` 宽度不等时，非等宽字体在切换瞬间会让前后文字和单位来回抖动。\n4. **首次挂载时没关过渡**：节点刚插入默认在 `0`，下一帧滑到目标值会看着像“所有数字每次进场都从 0 猛翻一遍”。首帧必须静默落位。",
      "ai_assets": {
        "prompt": "实现一个零依赖的「动态数字流（Number Flow）」组件，用于价格切换（月付/年付）、余额、实时看板和计数器变动。\n\n原理一句话：把格式化数字按「整数区从个位向左编号、小数区从十分位向右编号」拆成稳定槽位，每个数位维护一条 0–9 竖向 CSS 滚筒；数值更新时复用已有节点、仅修改变化位的单个位置变量，由合成层 `translate3d` 平滑滚到位，未变数位完全静止。\n\n做法：\n1. 纯函数 `tokenizeNumber(formattedStr)` 与 `diffNumberFlow(prevStr, nextStr, prevVal, nextVal)`：\n   - 拆分前缀（如 `$` / `¥`）、负号、整数位、千分位逗号、小数点、小数位、后缀（如 `/mo` / `%`）；\n   - 整数位 key 必须从个位向左递增（个位 `int-0`，十位 `int-1`，百位 `int-2`...），小数位向右递增（`frac-0`, `frac-1`...）；\n   - 仅当同 key 的新旧数字不同，该槽位才发生滚动。\n2. DOM 与 CSS（零 rAF 逐帧重绘）：\n   - 容器：`display: inline-flex; align-items: baseline; font-variant-numeric: tabular-nums; line-height: 1.15;`\n   - 单数位视窗：`display: inline-block; height: 1.15em; overflow: hidden; vertical-align: bottom;`\n   - 内部 0–9 滚筒：`display: flex; flex-direction: column; transform: translate3d(0, calc(var(--digit) * -1.15em), 0); transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);`\n   - 首次渲染给滚筒加 `.is-static`（`transition: none`）静默落位，之后移除。\n3. 无障碍读屏隔离：\n   - 每次更新将完整纯文本写入容器 `aria-label`（如 `aria-label=\"$1,280.00\"`）；\n   - 所有视觉槽位与 0–9 滚筒必须标 `aria-hidden=\"true\"`。\n\n硬要求：\n- 必须加 `font-variant-numeric: tabular-nums`，杜绝数字宽度抖动。\n- 整数位必须从个位向左编 key，保证 `99 -> 100` 新增高位时不打乱低位。\n- 必须用 `aria-label` + 子槽 `aria-hidden=\"true\"` 隔离读屏。\n- `prefers-reduced-motion: reduce` 下将滚筒过渡压到 `1ms`，直接跳到新值。\n\n验收：\n- 从 `$128` 切到 `$129` 时，仅个位 `8 -> 9` 滚动，`$`, `1`, `2` 像素级静止；\n- 从 `$99` 切到 `$100` 时，新增百位不触发整行错位闪动；\n- 快速连续切换 5 次数值，动画可随时平滑转向目标值无堆积卡顿；\n- 检查 DOM 无障碍名称，仅读出完整格式化数值，不读出 0–9 滚筒。",
        "dont_do": "- 别在数字变动时整块 `innerHTML` 重建所有滚筒——那会让未变数位失去过渡甚至从 0 重滚。\n- 别按从左到右索引给整数位编 key，位数增减时整串数字会错位乱滚。\n- 别把 `0123456789` 裸露给屏幕阅读器，必须加 `aria-hidden=\"true\"`。",
        "skill_rule": "# 动态数字流 (number-flow) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】把格式化数字按「整数区从个位向左编号、小数区从十分位向右编号」拆成稳定槽位，每个数位维护一条 0–9 竖向 CSS 滚筒；数值更新时复用已有节点、仅修改变化位的单个位置变量，由合成层 `translate3d` 平滑滚到位，未变数位完全静止。\n\n【硬要求】\n- 必须加 `font-variant-numeric: tabular-nums`，杜绝数字宽度抖动。\n- 整数位必须从个位向左编 key，保证 `99 -> 100` 新增高位时不打乱低位。\n- 必须用 `aria-label` + 子槽 `aria-hidden=\"true\"` 隔离读屏。\n- `prefers-reduced-motion: reduce` 下将滚筒过渡压到 `1ms`，直接跳到新值。\n\n【验收标准】\n- 从 `$128` 切到 `$129` 时，仅个位 `8 -> 9` 滚动，`$`, `1`, `2` 像素级静止；\n- 从 `$99` 切到 `$100` 时，新增百位不触发整行错位闪动；\n- 快速连续切换 5 次数值，动画可随时平滑转向目标值无堆积卡顿；\n- 检查 DOM 无障碍名称，仅读出完整格式化数值，不读出 0–9 滚筒。\n\n【禁止做法】\n- 别在数字变动时整块 `innerHTML` 重建所有滚筒——那会让未变数位失去过渡甚至从 0 重滚。\n- 别按从左到右索引给整数位编 key，位数增减时整串数字会错位乱滚。\n- 别把 `0123456789` 裸露给屏幕阅读器，必须加 `aria-hidden=\"true\"`。",
        "prompt_en": "Core Principle:\nBuild a zero-dependency Live Rolling Number Flow component for pricing toggles (monthly/yearly), live balances, KPIs, and counters. Tokenize formatted numeric strings into stable slots indexed leftward from the ones place (`int-0, int-1, ...`) and rightward for decimals (`frac-0, frac-1, ...`), attach a 0-9 vertical CSS digit reel per digit slot, and on updates reuse existing slot nodes while modifying only the CSS `--digit` variable of changed digits so unchanged digits stay completely motionless.\n\nImplementation:\n1. Pure functions `tokenizeNumber(formattedStr)` and `diffNumberFlow(prevStr, nextStr, prevVal, nextVal)`:\n   - Split prefix (`$` / `€`), minus sign, integer digits, thousands commas, decimal point, fractional digits, and suffix (`/mo` / `%`).\n   - Key integer digits leftward from the ones place (`int-0` = ones, `int-1` = tens, `int-2` = hundreds...) and fractional digits rightward (`frac-0`, `frac-1`...).\n   - Mark `changed = true` only when a digit slot's numeric value differs from the previous token at the same key.\n2. DOM & CSS (zero rAF frame-by-frame text rewriting):\n   - Container: `display: inline-flex; align-items: baseline; font-variant-numeric: tabular-nums; line-height: 1.15;`\n   - Single-digit viewport: `display: inline-block; height: 1.15em; overflow: hidden; vertical-align: bottom;`\n   - Inner 0-9 reel: `display: flex; flex-direction: column; transform: translate3d(0, calc(var(--digit) * -1.15em), 0); transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);`\n   - Apply `.is-static` (`transition: none`) on initial mount so digits land silently without rolling up from `0`.\n3. Screen-reader isolation:\n   - Write the full formatted string to the container's `aria-label` (e.g., `aria-label=\"$1,280.00\"`) on every update.\n   - Set `aria-hidden=\"true\"` on every visual slot and 0-9 digit reel.\n\nHard Constraints:\n- Must set `font-variant-numeric: tabular-nums` to prevent horizontal width jitter.\n- Must key integer digits from the ones place leftward so `$99 -> $100` adds a hundreds digit without scrambling existing lower digits.\n- Must isolate 0-9 digit reels with `aria-hidden=\"true\"` and expose the plain formatted string via `aria-label`.\n- Under `prefers-reduced-motion: reduce`, compress reel transitions to `1ms` so values snap cleanly without rolling.\n\nAcceptance Criteria:\n- Updating `$128` to `$129` rolls only the ones digit (`8 -> 9`) while `$`, `1`, and `2` stay pixel-still.\n- Updating `$99` to `$100` smoothly adds the hundreds slot without scrambling tens/ones digits.\n- Rapidly toggling values 5 times redirects reels smoothly mid-flight with zero lag accumulation.\n- Inspecting the accessibility tree announces only the clean formatted value, never `0123456789`.",
        "dont_do_en": "- Do NOT rebuild the entire `innerHTML` on each number update — recreating reels kills transitions on unchanged digits and causes reels to snap from 0.\n- Do NOT key integer digits from left to right — adding or removing a digit scrambles every column.\n- Do NOT leave the 0-9 reel spans exposed to screen readers without `aria-hidden=\"true\"`.",
        "skill_rule_en": "# Live Rolling Number Flow (number-flow) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: motion | Platform: both\n\nCore Principle: Build a zero-dependency Live Rolling Number Flow component for pricing toggles (monthly/yearly), live balances, KPIs, and counters. Tokenize formatted numeric strings into stable slots indexed leftward from the ones place (`int-0, int-1, ...`) and rightward for decimals (`frac-0, frac-1, ...`), attach a 0-9 vertical CSS digit reel per digit slot, and on updates reuse existing slot nodes while modifying only the CSS `--digit` variable of changed digits so unchanged digits stay completely motionless.\n\nHard Constraints:\n- Must set `font-variant-numeric: tabular-nums` to prevent horizontal width jitter.\n- Must key integer digits from the ones place leftward so `$99 -> $100` adds a hundreds digit without scrambling existing lower digits.\n- Must isolate 0-9 digit reels with `aria-hidden=\"true\"` and expose the plain formatted string via `aria-label`.\n- Under `prefers-reduced-motion: reduce`, compress reel transitions to `1ms` so values snap cleanly without rolling.\n\nAcceptance Criteria:\n- Updating `$128` to `$129` rolls only the ones digit (`8 -> 9`) while `$`, `1`, and `2` stay pixel-still.\n- Updating `$99` to `$100` smoothly adds the hundreds slot without scrambling tens/ones digits.\n- Rapidly toggling values 5 times redirects reels smoothly mid-flight with zero lag accumulation.\n- Inspecting the accessibility tree announces only the clean formatted value, never `0123456789`.\n\nDo NOT Do:\n- Do NOT rebuild the entire `innerHTML` on each number update — recreating reels kills transitions on unchanged digits and causes reels to snap from 0.\n- Do NOT key integer digits from left to right — adding or removing a digit scrambles every column.\n- Do NOT leave the 0-9 reel spans exposed to screen readers without `aria-hidden=\"true\"`."
      }
    },
    {
      "id": "orbit",
      "name": "3D 轨道卫星",
      "name_en": "3D Orbital Satellites",
      "layer": "3d",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": ".mk-orbit-stage / .mk-orbit / .mk-orbit__core / .mk-orbit__sat（纯 CSS 反向抵消自转，零 JS）",
      "source": "3D 空间公转与正面锁定（rotateY(a) → translateZ(r) → rotateY(-a) 抵消朝向，零 JS）",
      "source_en": "Pure CSS counter-rotated 3D orbit (zero JS)",
      "file": "effects/orbit.md",
      "summary": "多个图标或徽章沿倾斜三维轨道绕核心匀速公转，通过 `rotateY(a) → translateZ(r) → rotateY(-a)` 反向抵消自转，让卫星始终正面朝向观众，全程零 JS。",
      "summary_en": "Pure CSS counter-rotating 3D orbital badges (rotateY(a) → translateZ(r) → rotateY(-a)) so orbiting icons always stay upright facing the viewer.",
      "problem": "**生态集成图（核心产品居中、周围一圈技术栈/插件图标公转）如果只写单层 `rotateY`，卫星转到背面时图标会变成水平镜像甚至侧成一条 1px 细线。** 只要在推出轨道半径后再补一条等角反向旋转，卫星就会像摩天轮座舱一样永远正面朝人。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 纯 CSS 反向抵消旋转 `rotateY(θ) translateZ(r) rotateY(-θ)`，卫星永不倒转 | JS rAF 每帧用 `Math.cos` / `Math.sin` 手算每个图标的 2D 伪轨道 |\n| 负延迟等分圆周相位，第 0 帧即均匀分布 | 全部图标挤在起点逐个出发 |\n| 3D 归零降级：减弱动效下 `transform: none` + `display: flex` 排开展示 | 停在半路把图标挡在核心后面 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 轨道倾角 | `rotateX(68deg)` | 既有强烈的立体椭圆轨道感，又能让前景/背景卫星自然拉开上下层次 |\n| 公转周期 | `14s linear infinite` | 慢到能看清每个生态图标，又不至于静止无感 |\n| 相位错开 | `delay = -i * (14s / n)` | 负延迟保证第 0 帧卫星就等分整条轨道 |",
      "implementation": "```\nstyles/3d.css:285  .mk-orbit-stage / .mk-orbit / .mk-orbit__core / .mk-orbit__sat\n```",
      "degradation": "**走 `3d` 层专属契约：归零塌回平面并切为横向 Flex 列表，保证所有生态徽章清晰可读。**",
      "pitfalls": "**① 忘了在 `translateZ(r)` 之后补 `rotateY(-同角)`。**\n卫星会跟着轨道一起翻面，转到侧面缩成一条线、转到背面图标变成左右镜像。\n\n**② 轨道平面倾了 `rotateX(68deg)` 但卫星本身没反向立起来 `rotateX(-68deg)`。**\n如果不把卫星立回 `-68deg`，图标会像贴纸一样平躺在斜轨道面上被压扁。\n\n---",
      "ai_assets": {
        "prompt": "实现纯 CSS（零 JS）的 3D 轨道卫星生态图（3D Orbiting Satellites，图标始终正面朝向观众）。\n\n原理一句话：每个卫星在倾斜的 preserve-3d 轨道上执行 rotateY(a) → translateZ(r) → rotateY(-a) → rotateX(-tilt)，反向抵消公转与倾角，像摩天轮座舱一样永远正向面向观众。\n\n做法：\n1. 结构：.orbit-stage（perspective: 700px）> .orbit（transform-style: preserve-3d; transform: rotateX(68deg)）内含中心 .orbit-core 与 N 个 .orbit-sat（--i: 0..N-1）。\n2. CSS 反向抵消关键帧（周期 14s，负延迟均匀错相）：\n   @keyframes orbit-go {\n     from { transform: rotateY(0deg) translateZ(var(--r, 92px)) rotateY(0deg) rotateX(-68deg); }\n     to   { transform: rotateY(360deg) translateZ(var(--r, 92px)) rotateY(-360deg) rotateX(-68deg); }\n   }\n   .orbit-sat {\n     position: absolute;\n     animation: orbit-go 14s linear infinite;\n     animation-delay: calc(var(--i, 0) * (-14s / var(--n, 4)));\n   }\n   .orbit-core { transform: rotateX(-68deg); }\n3. 降级：\n   @media (prefers-reduced-motion: reduce) {\n     .orbit { display: flex; gap: 10px; transform: none; }\n     .orbit-sat, .orbit-core { position: static; animation: none; transform: none; }\n   }\n\n硬要求：\n- 必须包含反向 rotateY(-360deg) 与 rotateX(-68deg)，确保卫星与核心全程正向不镜像、不压扁。\n- 必须使用负 animation-delay 等分相位，首帧即均匀布满轨道。\n- prefers-reduced-motion: reduce 下必须展平为 flex 横排。\n\n验收：\n- 4 个图标绕中心核心沿立体椭圆轨道匀速公转，转到前、后、左、右任意位置均正面朝向观众无镜像。\n- 全程零 JS、零 rAF；开启减弱动效后展平为一排清晰图标。",
        "dont_do": "- 别用 JS 每帧算 `sin/cos` 拼 2D 伪轨道 —— 纯 CSS 3D 原生自带近大远小透视与层级遮挡。\n- 别漏写 `rotateY(-360deg)` —— 卫星转到背面会左右翻转。\n- 别在减弱动效下只停动画不改布局 —— 卫星会停在核心背后被挡住。",
        "skill_rule": "# 3D 轨道卫星 (orbit) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】每个卫星在倾斜的 preserve-3d 轨道上执行 rotateY(a) → translateZ(r) → rotateY(-a) → rotateX(-tilt)，反向抵消公转与倾角，像摩天轮座舱一样永远正向面向观众。\n\n【硬要求】\n- 必须包含反向 rotateY(-360deg) 与 rotateX(-68deg)，确保卫星与核心全程正向不镜像、不压扁。\n- 必须使用负 animation-delay 等分相位，首帧即均匀布满轨道。\n- prefers-reduced-motion: reduce 下必须展平为 flex 横排。\n\n【验收标准】\n- 4 个图标绕中心核心沿立体椭圆轨道匀速公转，转到前、后、左、右任意位置均正面朝向观众无镜像。\n- 全程零 JS、零 rAF；开启减弱动效后展平为一排清晰图标。\n\n【禁止做法】\n- 别用 JS 每帧算 `sin/cos` 拼 2D 伪轨道 —— 纯 CSS 3D 原生自带近大远小透视与层级遮挡。\n- 别漏写 `rotateY(-360deg)` —— 卫星转到背面会左右翻转。\n- 别在减弱动效下只停动画不改布局 —— 卫星会停在核心背后被挡住。",
        "prompt_en": "Core Principle:\nBuild a pure CSS (zero JS) 3D Orbital Satellites ecosystem where icons always face the viewer upright. Each satellite executes `rotateY(a) -> translateZ(r) -> rotateY(-a) -> rotateX(-tilt)` on a tilted `preserve-3d` plane, counter-rotating against both orbit angle and tilt angle so icons stay upright like Ferris wheel cabins.\n\nImplementation:\n1. Structure: `.orbit-stage` (`perspective: 700px`) > `.orbit` (`transform-style: preserve-3d; transform: rotateX(68deg)`) containing central `.orbit-core` and `N` `.orbit-sat` elements (`--i: 0..N-1`).\n2. CSS counter-rotation keyframes (`14s` period, staggered evenly via negative `animation-delay`):\n   - `@keyframes orbit-go`:\n     `from { transform: rotateY(0deg) translateZ(var(--r, 92px)) rotateY(0deg) rotateX(-68deg); }`\n     `to   { transform: rotateY(360deg) translateZ(var(--r, 92px)) rotateY(-360deg) rotateX(-68deg); }`\n   - `.orbit-sat`: `position: absolute; animation: orbit-go 14s linear infinite; animation-delay: calc(var(--i, 0) * (-14s / var(--n, 4)));`.\n   - `.orbit-core`: `transform: rotateX(-68deg);`.\n3. Reduced-motion fallback:\n   - `@media (prefers-reduced-motion: reduce)`: `.orbit { display: flex; gap: 10px; transform: none; }` and `.orbit-sat, .orbit-core { position: static; animation: none; transform: none; }`.\n\nHard Constraints:\n- Must include counter-rotations `rotateY(-360deg)` and `rotateX(-68deg)` so satellites and core remain forward-facing without mirroring or flattening.\n- Must use negative `animation-delay` to divide phase angles evenly so satellites populate the orbit on frame 1.\n- Under `prefers-reduced-motion: reduce`, must flatten into a horizontal `flex` row.\n\nAcceptance Criteria:\n- Four icons orbit smoothly around the center core along a 3D elliptical track, facing the viewer cleanly without mirroring at front, back, left, or right positions.\n- Zero JS and zero `rAF`; enabling reduced motion flattens items into a crisp row of icons.",
        "dont_do_en": "- Do NOT calculate `sin/cos` every frame in JS to fake a 2D orbit — pure CSS 3D natively handles perspective depth scaling and occlusion.\n- Do NOT omit `rotateY(-360deg)` — satellites will flip horizontally (mirror) when passing behind the orbit.\n- Do NOT only pause animation under `prefers-reduced-motion` without changing layout — satellites can stop hidden behind the center core.",
        "skill_rule_en": "# 3D Orbital Satellites (orbit) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: 3d | Platform: both\n\nCore Principle: Build a pure CSS (zero JS) 3D Orbital Satellites ecosystem where icons always face the viewer upright. Each satellite executes `rotateY(a) -> translateZ(r) -> rotateY(-a) -> rotateX(-tilt)` on a tilted `preserve-3d` plane, counter-rotating against both orbit angle and tilt angle so icons stay upright like Ferris wheel cabins.\n\nHard Constraints:\n- Must include counter-rotations `rotateY(-360deg)` and `rotateX(-68deg)` so satellites and core remain forward-facing without mirroring or flattening.\n- Must use negative `animation-delay` to divide phase angles evenly so satellites populate the orbit on frame 1.\n- Under `prefers-reduced-motion: reduce`, must flatten into a horizontal `flex` row.\n\nAcceptance Criteria:\n- Four icons orbit smoothly around the center core along a 3D elliptical track, facing the viewer cleanly without mirroring at front, back, left, or right positions.\n- Zero JS and zero `rAF`; enabling reduced motion flattens items into a crisp row of icons.\n\nDo NOT Do:\n- Do NOT calculate `sin/cos` every frame in JS to fake a 2D orbit — pure CSS 3D natively handles perspective depth scaling and occlusion.\n- Do NOT omit `rotateY(-360deg)` — satellites will flip horizontally (mirror) when passing behind the orbit.\n- Do NOT only pause animation under `prefers-reduced-motion` without changing layout — satellites can stop hidden behind the center core."
      }
    },
    {
      "id": "pop",
      "name": "弹层 / 轻提示",
      "name_en": "Pure CSS @starting-style Popover",
      "layer": "motion",
      "nature": "连续",
      "platform": "both",
      "status": "shipped",
      "entry": ".mk-pop / .mk-toast（纯 CSS，无 JS）",
      "source": "CSS `@starting-style` + `transition-behavior: allow-discrete`（Baseline 2024-08）",
      "source_en": "Modern CSS Popover API (@starting-style + transition-behavior: allow-discrete)",
      "file": "effects/pop.md",
      "summary": "纯 CSS 的进出场：入场靠 `@starting-style`，退场靠 `display` 参与过渡，一行 JS 都不用写。",
      "summary_en": "Zero-JS enter/exit popover transitions powered by native CSS @starting-style and allow-discrete display transitions.",
      "problem": "**浮层的出现必须顺着来源。** 从按钮底下冒出来的菜单、从底部升起的 toast、\n从触发点展开的 popover——方向感告诉用户\"这东西属于谁、关掉回哪儿\"。\n硬切（display 瞬间翻转）把这些信息全丢了。\n\n第二个问题更工程：**`display: none` 一直是过渡的天敌。**\n元素的显隐如果靠 `display` 翻转，任何 `opacity/transform` 过渡都来不及播——\n所以过去要做进出场，要么 JS 控制两段式（先摘类、等 transitionend、再隐藏），\n要么元素永远占布局。2024 年起浏览器让 `display` 自己参与过渡，这两条路都不用了。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| `@starting-style`：入场起始态写在 CSS 里，JS 只负责把元素渲染出来 | JS 双段式退场（`.is-closing` + transitionend）在 pop 上不需要了——但 `bottom-sheet` 那种跟手面板仍然要 |\n| `allow-discrete` 让 `display` 可过渡，退场自动等动画播完再消失 | 每个浮层定制方向——这里统一是\"下方 8px + 缩放 0.97\"，方向感由使用者摆放位置决定 |\n| toast 单独一条：`-50%` 居中 + `ease-snap` 回弹落位 | 堆叠排队（多个 toast 会叠在一起，没有队列）——见第 7 节④ |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 入场位移 | 8px + `scale(0.97)` | 浮层是从\"原地\"长出来的，不是从远处飞来的；8px 足够读出方向，32px 就成了另一个进场 |\n| opacity 时长 | `--mk-dur-2` = 160ms | 浮层出现是微交互，比内容进场（380ms）快一倍——用户正等着用它 |\n| transform 时长 | `--mk-dur-3` = 240ms | 位移比透明度长一点，\"落定\"的最后一段由位移完成 |\n| toast 位移 | 16px + `ease-snap` | toast 从底部升起，行程更长，且带一点回弹——它是\"来了个东西\"，允许比 pop 更戏剧化 |\n| display 时长 | 与 transform 同参数 | `display` 是离散属性，时长只决定\"什么时候翻到 none\"，跟 transform 对齐才不会中途消失 |",
      "implementation": "```\nmotion.css:203  .mk-pop          正常态 + display 参与过渡\nmotion.css:214  @starting-style  入场起始态（无需 JS 加类）\nmotion.css:222  [hidden] / .is-closing  退场终态\nmotion.css:712  .mk-toast        底部轻提示（同结构，snap 落位）\n```\n\n整个效果的核心就这三段：\n\n```css\n.mk-pop {\n  transition: opacity 160ms, transform 240ms, display 240ms allow-discrete;\n}\n@starting-style {\n  .mk-pop { opacity: 0; transform: translate3d(0, 8px, 0) scale(0.97); }\n}\n.mk-pop[hidden] { opacity: 0; transform: …; display: none; }\n```\n\n**`@starting-style` 只在\"元素第一次被渲染\"时生效**——它是\"display 从 none\n变成别的\"那一刻的起始态。Vue 里用 `v-show`（切 display）触发它；\n用 `v-if`（整个节点卸载/重建）也能触发入场，但**退场没有任何动画**——\n节点直接没了，`display` 过渡根本没有机会播。要用纯 CSS 退场就必须 `v-show`。",
      "degradation": "**走 `motion` 那档：减。**\n\n全局减弱块把 `--mk-dur-2/3` 压到 1ms/120ms，浮层变成近瞬间的出现/消失。\n不支持 `@starting-style` 或 `allow-discrete` 的浏览器（2023 年以前）：\n声明整条不解析，浮层**直接出现、直接消失**——没有动画，没有报错，\n内容完全可用。这是这条效果最理想的降级形态：**退化到零也不坏**。",
      "pitfalls": "**① 入场不触发，十有八九是没切 `display`。**\n`@starting-style` 只在元素从\"未渲染\"变\"渲染\"时生效。只切 `opacity`（比如\n从 `visibility: hidden` 换成可见、或者一直 display:block 只加减类）\n**不会**触发起始态。所以 `.mk-pop` 的显隐必须走 `[hidden]` / `display`。\n调试时先确认：改变前后 `getComputedStyle(el).display` 是否翻转了。\n\n**② 退场用 `v-if` 就没有动画。**\n`v-if` 卸载节点，`display: none` 的过渡来不及播。`v-show` 切的是 display，\n`allow-discrete` 会把\"翻到 none\"推迟到过渡结束——这正是这个特性的意义。\nReact 里同理：`conditional render` 换成 `hidden` 属性。\n\n**③ `display` 必须显式列在 `transition` 里。**\n只写 `transition: opacity, transform` 再切 `display`，过渡不会发生——\n`display` 默认不可动画，也**不在 transition 属性表里**，翻转就是瞬间的。\n`allow-discrete` 只是把\"可动画\"的口子打开，列出来这一步还是必须的。\n\n**④ toast 没有队列。**\n连发三条 toast 会叠在同一个位置。要队列就得有组件层的状态\n（当前条、等待条、位移让位），那是 JS 的活——这条效果刻意停在\"词汇\"层\n（关卡 5：提供类名，不规定 DOM 结构）。\n\n**⑤ `@starting-style` 里的规则会被更高优先级覆盖。**\n如果使用方给浮层写了内联 `opacity: 1`，起始态的 `opacity: 0` 赢不了\n——内联优先级高于任何选择器，包括 `@starting-style`。浮层的状态\n一律走类和变量，不走内联（和 `tokens.js` 把默认值放 `<style>` 的决定同源）。\n\n**⑥ 退场终态里 `[hidden]` 和 `.is-closing` 都写了。**\n`[hidden]` 给纯 HTML 用（`el.hidden = true`），`.is-closing` 给需要\n\"先播完再隐藏\"的 JS 两段式用。两条都要——少了 `[hidden]`，纯 HTML 页面\n的浮层退场会把 `display` 过渡走完却停在不透明（因为没终态可去）。\n\n---",
      "ai_assets": {
        "prompt": "实现纯 CSS 的浮层进出场，不用任何 JS 动画代码。\n\n原理一句话：纯 CSS 的状态机 —— 让 display 也参与过渡（离散动画），再用首帧样式块声明\"还没显示时\"的起点。零 JS。\n\nCSS：\n  .pop {\n    opacity: 1;\n    transform: translate3d(0, 0, 0) scale(1);\n    transition:\n      opacity 160ms cubic-bezier(0.22, 1, 0.36, 1),\n      transform 240ms cubic-bezier(0.22, 1, 0.36, 1),\n      display 240ms allow-discrete;      /* display 必须列进来，否则翻转是瞬间的 */\n    display: block;\n  }\n  @starting-style {\n    .pop { opacity: 0; transform: translate3d(0, 8px, 0) scale(0.97); }\n  }\n  .pop[hidden] {\n    opacity: 0;\n    transform: translate3d(0, 8px, 0) scale(0.97);\n    display: none;\n  }\n\n行为：\n- 显隐只切 display（hidden 属性 / style.display / v-show），不卸载节点。\n  入场动画由 @starting-style 自动触发；退场由 allow-discrete 把\n  \"翻到 none\"推迟到过渡结束。\n- 不要用条件渲染（v-if / && 卸载节点）——退场动画会完全没有机会播放。\n- 浮层状态一律走类和 CSS 变量，不走内联样式 ——\n  内联的 opacity/transform 优先级高于 @starting-style，会把入场起始态压死。\n\n硬要求：\n- 显式声明 transition 里包含 display 且带 allow-discrete。\n- 退场终态要同时提供 [hidden] 和 .is-closing 两条（纯 HTML 和 JS 两段式各用一条）。\n- 不支持 @starting-style 的浏览器直接出现/消失，不要 polyfill。\n\n验收：\n- el.hidden = false → 浮层从下方 8px + scale(0.97) 淡入升起，160-240ms。\n- el.hidden = true → 浮层播完淡出后从布局中消失\n  （transitionrun 期间 el.getBoundingClientRect() 不为空，结束后为空）。\n- 切换前后 getComputedStyle(el).display 确实翻转（'none' ↔ 'block'）。\n- 不支持新特性的浏览器：浮层瞬间出现/消失，功能不受影响。",
        "dont_do": "- 别给 `@starting-style` 配 JS 加类——那是 `bottom-sheet` 的两段式做法，\n  两者混用会出现\"起始态和 JS 类互相覆盖\"。\n- 别把 `@starting-style` 用在页面首屏内容上——它是给\"用户操作后出现的东西\"的，\n  首屏入场请走 `enter`（IntersectionObserver 那条）。\n- 别用 `visibility` 或 `opacity: 0` 代替 `display: none` 做退场——\n  那样元素仍占布局、仍能挡住下面的点击，浮层语义就没了。",
        "skill_rule": "# 弹层 / 轻提示 (pop) · 跨平台动效规范\n性质：连续 ｜ 平台：both\n\n【核心原理】纯 CSS 的状态机 —— 让 display 也参与过渡（离散动画），再用首帧样式块声明\"还没显示时\"的起点。零 JS。\n\n【硬要求】\n- 显式声明 transition 里包含 display 且带 allow-discrete。\n- 退场终态要同时提供 [hidden] 和 .is-closing 两条（纯 HTML 和 JS 两段式各用一条）。\n- 不支持 @starting-style 的浏览器直接出现/消失，不要 polyfill。\n\n【验收标准】\n- el.hidden = false → 浮层从下方 8px + scale(0.97) 淡入升起，160-240ms。\n- el.hidden = true → 浮层播完淡出后从布局中消失\n  （transitionrun 期间 el.getBoundingClientRect() 不为空，结束后为空）。\n- 切换前后 getComputedStyle(el).display 确实翻转（'none' ↔ 'block'）。\n- 不支持新特性的浏览器：浮层瞬间出现/消失，功能不受影响。\n\n【禁止做法】\n- 别给 `@starting-style` 配 JS 加类——那是 `bottom-sheet` 的两段式做法，\n  两者混用会出现\"起始态和 JS 类互相覆盖\"。\n- 别把 `@starting-style` 用在页面首屏内容上——它是给\"用户操作后出现的东西\"的，\n  首屏入场请走 `enter`（IntersectionObserver 那条）。\n- 别用 `visibility` 或 `opacity: 0` 代替 `display: none` 做退场——\n  那样元素仍占布局、仍能挡住下面的点击，浮层语义就没了。",
        "prompt_en": "Core Principle:\nBuild pure CSS popover enter/exit transitions using zero JS animation code. A pure CSS state machine allows `display` to participate in transitions (`allow-discrete`) while `@starting-style` declares the initial \"before shown\" origin state.\n\nImplementation:\n1. CSS:\n   - `.pop`: `opacity: 1; transform: translate3d(0, 0, 0) scale(1); transition: opacity 160ms cubic-bezier(0.22, 1, 0.36, 1), transform 240ms cubic-bezier(0.22, 1, 0.36, 1), display 240ms allow-discrete; display: block;` (`display` must be listed in `transition`, otherwise toggling is instantaneous).\n   - `@starting-style { .pop { opacity: 0; transform: translate3d(0, 8px, 0) scale(0.97); } }`\n   - `.pop[hidden], .pop.is-closing { opacity: 0; transform: translate3d(0, 8px, 0) scale(0.97); display: none; }`\n2. Behavior:\n   - Toggle visibility solely through `display` (`hidden` attribute / `style.display` / `v-show`) without unmounting the node. Entry plays automatically via `@starting-style`; exit uses `allow-discrete` to defer flipping `display` to `none` until the transition finishes.\n   - Do not use conditional unmounting (`v-if` / `&&`), which destroys the node before exit transitions can play.\n   - Drive popover state solely with classes and CSS variables, never inline styles—inline `opacity`/`transform` overrides `@starting-style` and suppresses the entry start state.\n\nHard Constraints:\n- Explicitly declare `display` with `allow-discrete` in the `transition` list.\n- Provide both `[hidden]` and `.is-closing` selectors for the exit end state (covering both pure-HTML `[hidden]` and two-stage JS class flows).\n- Browsers without `@starting-style` support simply show/hide immediately—do not polyfill.\n\nAcceptance Criteria:\n- `el.hidden = false` -> popover fades and rises from `8px` below at `scale(0.97)` over `160–240ms`.\n- `el.hidden = true` -> popover finishes fading out before leaving layout (`el.getBoundingClientRect()` remains non-empty during `transitionrun` and becomes empty after completion).\n- `getComputedStyle(el).display` visibly flips between `'none'` and `'block'` before and after toggling.\n- In unsupported browsers, the popover appears/disappears instantly with intact functionality.",
        "dont_do_en": "- Do NOT combine `@starting-style` with JS entry class toggling (the two-stage bottom-sheet pattern) — mixing them causes initial states and JS classes to overwrite each other.\n- Do NOT use `@starting-style` for initial above-the-fold page load reveals — it is meant for user-triggered reveals; use an `IntersectionObserver` entrance pattern for initial page reveals.\n- Do NOT replace `display: none` on exit with `visibility` or `opacity: 0` — the element remains in layout and intercepts clicks underneath, breaking popover semantics.",
        "skill_rule_en": "# Pure CSS @starting-style Popover (pop) · Cross-Platform Motion Spec\nNature: Continuity | Layer: motion | Platform: both\n\nCore Principle: Build pure CSS popover enter/exit transitions using zero JS animation code. A pure CSS state machine allows `display` to participate in transitions (`allow-discrete`) while `@starting-style` declares the initial \"before shown\" origin state.\n\nHard Constraints:\n- Explicitly declare `display` with `allow-discrete` in the `transition` list.\n- Provide both `[hidden]` and `.is-closing` selectors for the exit end state (covering both pure-HTML `[hidden]` and two-stage JS class flows).\n- Browsers without `@starting-style` support simply show/hide immediately—do not polyfill.\n\nAcceptance Criteria:\n- `el.hidden = false` -> popover fades and rises from `8px` below at `scale(0.97)` over `160–240ms`.\n- `el.hidden = true` -> popover finishes fading out before leaving layout (`el.getBoundingClientRect()` remains non-empty during `transitionrun` and becomes empty after completion).\n- `getComputedStyle(el).display` visibly flips between `'none'` and `'block'` before and after toggling.\n- In unsupported browsers, the popover appears/disappears instantly with intact functionality.\n\nDo NOT Do:\n- Do NOT combine `@starting-style` with JS entry class toggling (the two-stage bottom-sheet pattern) — mixing them causes initial states and JS classes to overwrite each other.\n- Do NOT use `@starting-style` for initial above-the-fold page load reveals — it is meant for user-triggered reveals; use an `IntersectionObserver` entrance pattern for initial page reveals.\n- Do NOT replace `display: none` on exit with `visibility` or `opacity: 0` — the element remains in layout and intercepts clicks underneath, breaking popover semantics."
      }
    },
    {
      "id": "pull-refresh",
      "name": "下拉刷新",
      "name_en": "Pull-to-Refresh with Damping",
      "layer": "mobile",
      "nature": "权重",
      "platform": "touch",
      "status": "shipped",
      "entry": "v-mk-pull + .mk-ptr-list / pullToRefresh(el, onRefresh, { max, trigger })",
      "source": "iOS 原生下拉刷新（内容跟手下移 + 越拉越沉）+ Chrome 的阻尼过滚曲线",
      "source_en": "iOS UIRefreshControl (progressive drag resistance + async promise hold)",
      "file": "effects/pull-refresh.md",
      "summary": "列表滚到顶后继续往下拉，指示器跟着长出来（带阻尼），拉过阈值松手就刷新。",
      "summary_en": "Over-scroll drag gesture at list top with progressive resistance, threshold commit feedback, async loading hold, and smooth release snap-back.",
      "problem": "**「数据会不会自己更新」是列表类产品的信任问题。** 用户不知道新内容有没有来，\n就得退出再进来——下拉刷新给了他们一个*主动确认*的通道：拉一下，看见在转，放心了。\n\n第二个问题是**越界必须有阻力**。触摸屏上任何列表都能拉过头（物理上没有\"边界\"），\n拉过顶之后屏幕怎么响应，决定了这块内容读起来是\"有质量的\"还是\"一张会滑的纸\"。\n完全不动 = 死板；等量跟手 = 拉出半个屏幕；阻尼递减 = 有重量。这是\"权重\"性质的教科书场景。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 指数阻尼：`damped = max * (1 - exp(-d / max))` —— 永远到不了 max，越拉越沉 | iOS 的弹性回弹曲线（橡皮筋会过冲再回来）；这里是饱和，不是过冲 |\n| 「拉过阈值才触发」+ 阈值处**文字先变**（下拉刷新 → 松手刷新） | 原生的 haptic 告知（过阈值那一下震一下）—— 和 `detent` 的过格震动是同一类，还没接 |\n| 刷新中停在固定高度（44px）转圈，长度不随手指 | 原生的\"完成后指示器淡出、列表从后面接上\"—— 这里是瞬间塌回去 |\n| 触发后 `busy` 锁死，刷新没完成前拉不动 | 失败态的重试文案（onRefresh 抛错时只会静默结束） |\n\n阻尼公式为什么选指数：线性阻尼（`d * 0.5`）永远成正比，拉多远缩多少，\n手指拉 400px 指示器还有 200px——拦不住。指数饱和把输出**钳在 max 以内**，\n拉 720px 也只有 71px，而且前期跟手、后期变沉，一条曲线两件事都做了。",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| `max` | 72px | 指示器永远到不了的高度上限（渐近线）。72 是\"看得清字、又不把首行推出屏幕\"的量级 |\n| `trigger` | 56px | **注意：这是阻尼后的距离，不是手指位移。** 阻尼后到 56px，手指实际要拉 **约 108px**（解 `72(1-e^(-d/72))=56`）。低于 44px（手指约 80px）太容易误触发 |\n| 刷新态高度 | 44px | 转圈圈的稳态。比 trigger 略小——进入刷新后不再跟手指，收成一个固定尺寸 |\n| 旋转周期 | 640ms linear | 一圈 640ms 是\"忙但没卡死\"的量级；必须 `linear`，转圈用缓动会一眼假 |\n| 文字 | 下拉刷新 / 松手刷新 / 刷新中… | 三态文案在 `damped >= trigger` 处切换。文字比图标便宜，而且能把\"还差多少\"说清楚 |",
      "implementation": "```\ntap.js:212    pullToRefresh(el, onRefresh, { max = 72, trigger = 56 })\ntap.js:223    paint(d)      阻尼 + 写 --mk-ptr-y + 切文字 —— 唯一的输出出口\ntap.js:269    cancel()      touchcancel 只收回，不做刷新判定\nmobile.css:225 .mk-ptr       height 直接吃变量\nmobile.css:232 .mk-ptr-list  overscroll-behavior-y: contain\nmobile.css:236 .is-refreshing 44px 稳态 + 转圈\n```\n\n三处职责：\n\n- **指示器是 JS 建的**（`el.prepend(indicator)`），不是使用方写的——\n  这样 `.mk-ptr` 的结构和状态机就永远不会被业务 DOM 拼错。\n- **输出只有一个出口 `paint()`**：写变量 + 切文字。松手判定、busy 锁都不碰 DOM。\n- **位移不是 transform**：指示器用 `height` 长出来，列表内容被自然推下去。\n  这里写 `transform` 反而错——指示器必须**占布局**，下面的内容才会让位。\n\nCSS 一条关键决定：**transition 只挂在 `.is-refreshing`**。\n\n```css\n.mk-ptr  { height: var(--mk-ptr-y, 0px); }              /* 拖拽：逐帧长，无过渡 */\n.mk-ptr-list.is-refreshing .mk-ptr { height: 44px; transition: height 240ms; }\n```\n\n拖拽是直接操纵，过渡会让指示器追不上手指（240ms 的滞后肉眼可见）；\n松手后的 0 → 44 是状态跳变，才需要过渡。**同一条属性在两种模式下要不同的过渡策略**，\n这是所有\"跟手 + 状态\"混合效果通用的规矩（`bottom-sheet` 的 `is-dragging` 是同一件事）。",
      "degradation": "**走 `mobile` 那档：减。**\n\n手势本身不摘（它是功能）；`--mk-dur-*` 被全局压到 1ms 后，刷新态的高度跳变变成瞬时的。\n有一处**已知取舍**：转圈动画（`mk-ptr-spin`，640ms linear infinite）在\n`prefers-reduced-motion` 下**还在转**——它没有被任何 reduce 块摘掉。\n理由：转圈是\"正在忙\"的状态指示，不是装饰，摘掉之后用户无法区分\"在刷新\"和\"死了\"。\n但无限旋转确实是持续动效，弱机上可以更省——记录在案，还没动。",
      "pitfalls": "**① 指示器曾经完全不可见——最该警惕的一类 bug。** 旧实现是：\n\n```css\n.mk-ptr { height: 0; overflow: hidden; margin-top: calc(-1 * var(--mk-ptr-y)); }\n```\n\n`height: 0` + `overflow: hidden` 把内容全裁掉，负 margin 又把它挪到滚动区顶**外面**\n（实测拖到 62px 时 `offsetTop = -62`，指示器在可视区上方）。结果：拉动全程用户什么\n都看不见，文字三态等于白做；直到松手进入刷新态（`height: 44px`）才突然出现。\n**教训：验证要看渲染结果（`offsetHeight` / `offsetTop`），不能只看变量有没有被写。**\n变量是对的、布局是错的，这种 bug 在控制台里全是绿的。\n\n**② `trigger` 是阻尼后的距离。** 想调\"松手刷新\"的触发点，改 `trigger` 之前先算：\n手指实际要拉的长度 = `-max * ln(1 - trigger/max)`。56 对应 108px；\n想要 iOS 那种 60px 就拉动的手感，`trigger` 得降到 30 左右——但那样很容易误触发，\n所以维持现状，把这个换算写在这里而不是让人猜。\n\n**③ 这条用的是 touch 事件，不是 pointer 事件——全库唯一的例外。**\n`gesture.js` 全家（sheet / swipe / edgeback）都是 `pointerDrag`，这里却是\n`touchstart/touchmove/touchend/touchcancel`。后果有三：桌面鼠标拉不动（没有 `force` 选项）；\n触摸事件在指针被 `setPointerCapture` 时行为不同；和库内其它手势的抽象不齐。\n留着它的理由：passive touch 监听最便宜、且这套本来只该在触屏上存在。\n**如果哪天要统一，注意 pointer 版必须在 `down` 里重新判定 `scrollTop`**——见 ④。\n\n**④ 起手判定只在 touchstart 做一次。** `down()` 看 `el.scrollTop > 0` 就不 arm，\n但这个检查**不会在 move 里重做**：用户一次触摸里先向上滚一段、再向下拉，\n`pulling` 还是 true，指示器会在滚动中途冒出来。这和 `edge-back` 的\n\"`horizontal = false` 是粘性的\"是同一类问题——**方向/状态的判定要粘住，\n否则手势会在中途觉醒**。根治要在首次上向位移超 8px 时解除 arm。\n\n**⑤ `overscroll-behavior-y: contain` 不是装饰，是必须的。**\n监听器全是 `passive: true`，不能 `preventDefault`——拦不住浏览器。\nChrome/Android 自己就有\"下拉刷新页面\"手势和过滚光晕，容器不声明 contain，\n浏览器会抢在 JS 前面刷新整个页面。这条写在 `.mk-ptr-list` 上，\n**使用方换了容器类名就会掉**，而且没有报错——表现只是\"偶尔整页被刷新\"。\n\n**⑥ 刷新结束要复位文字。** `finally` 里除了摘类、归零变量，还要把文字写回\n\"下拉刷新\"——否则它停在\"刷新中…\"，下一次拉动的前几帧显示的是上一次的状态\n（靠 `paint()` 在第一次 move 时兜回来，中间有窗口）。已修复。\n\n**⑦ `busy` 锁必须挡在 `down()` 而不是 `up()`。**\n刷新进行中用户又拉了一把：`down()` 里 `if (busy) return` 直接不 arm。\n如果只挡 `up()`，拉动的位移会照常 paint，指示器会和转圈圈打架。\n\n**⑧ `touchcancel` 曾会误触发刷新。** 拉过阈值后手势被浏览器抢走（touchcancel），\n旧实现走的是与 touchend 相同的判定路径，用户没松手却触发了刷新。\n已修复：cancel 直接收回指示器，不做判定。同 `bottom-sheet` 第 7 栏⑦。\n\n**⑨ `onRefresh` 忘了 await 会静默跳过整个刷新态。**\n回调返回的不是 Promise 时，`await` 直接过，`.is-refreshing` 挂上一帧就摘，\n用户只看到列表闪一下。使用方写 `v-mk-pull=\"() => { fetch(); }\"`（没 return）就是这种情况。\n文档里必须给对示例：要么传 async 函数，要么 return promise。",
      "ai_assets": {
        "prompt": "实现移动端的「下拉刷新」。Touch Events + 一个 CSS 变量，不引依赖。\n\n原理一句话：手指位移先做指数阻尼，把阻尼后的值写进一个 CSS 变量，指示器高度直接吃这个变量。判定看阻尼后的距离，不是手指走了多远。\n\n行为：\n- 指示器由 JS 创建并插为滚动容器的第一个子元素，不要求使用方写 DOM。\n- 只在容器 scrollTop <= 0 且不在刷新中时才武装（记 pulling = true）。\n- touchmove 时算手指位移 d = clientY - startY（d <= 0 时按 0 处理），\n  做指数阻尼：damped = max * (1 - exp(-d / max))，max = 72。\n  把 damped 写进 CSS 变量 --ptr-y，指示器 height 直接用这个变量。\n- 阻尼值 >= trigger(56) 时文字从「下拉刷新」切到「松手刷新」。\n  注意 trigger 是阻尼后的值：手指实际要拉约 108px 才到 56，这是有意的。\n- 松手：damped < trigger → 变量归零收回去；否则进入刷新态：\n  加 .is-refreshing（CSS 里 height 固定 44px、显示转圈、文字「刷新中…」），\n  await onRefresh()，完成后摘类、变量归零、**文字复位为「下拉刷新」**。\n- 刷新中 busy = true，此时新的下拉不武装。\n- touchcancel 与 touchend 同路径处理。\n\n硬要求：\n- 容器 CSS 必须有 overscroll-behavior-y: contain —— 监听全是 passive，\n  不能 preventDefault，不声明它 Chrome 会抢在 JS 前面刷新整个页面。\n- 指示器高度用变量直接驱动，拖拽路径上**不许有 transition**（直接操纵不能滞后）；\n  transition 只挂在刷新态那条 height 0→44 的跳变上。\n- 指示器必须占布局（用 height 长出来），不要用 transform ——\n  下面的列表内容要让位，这是 iOS 式下拉刷新的观感来源。\n- prefers-reduced-motion 下手势保留；转圈保留（它是状态指示不是装饰），\n  但要在文档里注明这是已知取舍。\n\n已知限制（写进注释，不要假装没有）：\n- 起手判定只在 touchstart 做一次：一次触摸里先上滚再下拉，指示器会中途冒出来。\n- 指数阻尼的 trigger 换算：手指位移 = -max * ln(1 - trigger/max)。\n\n验收：\n- 滚到顶后下拉，指示器逐帧长高、内容被推下去；文字在阻尼值过 56 时切换。\n- 拉 80px（阻尼约 52）松手 → 收回，不刷新；拉 120px 松手 → 刷新。\n- 刷新中再拉 → 不武装；刷新结束后文字回到「下拉刷新」。\n- 列表不在顶部时下拉 → 指示器不出动。\n- Chrome Android 上滚动到顶继续拉 → 页面级刷新手势不出现（contain 生效）。",
        "dont_do": "- 别给 `touchmove` 挂非 passive 监听去 `preventDefault`——那会让整个列表滚动掉帧，\n  `overscroll-behavior` 就是干这个的。\n- 别把指示器做成 `position: absolute` 浮在列表上 —— 内容让位才是\"拉\"的物理感，\n  浮层只有\"出现\"，没有\"被拉出来\"。\n- 别用弹簧曲线做过滚回弹 —— 这里的输出是阻尼**饱和**（永远到不了 max），\n  弹簧会过冲，两个模型混用会让\"拉到头\"的手感前后不一致。\n- 别在刷新态还让指示器跟手指 —— 进了 `busy` 就该收成固定高度，\n  高度晃动的转圈圈读起来像坏了。",
        "skill_rule": "# 下拉刷新 (pull-refresh) · 跨平台动效规范\n性质：权重 ｜ 平台：touch\n\n【核心原理】手指位移先做指数阻尼，把阻尼后的值写进一个 CSS 变量，指示器高度直接吃这个变量。判定看阻尼后的距离，不是手指走了多远。\n\n【硬要求】\n- 容器 CSS 必须有 overscroll-behavior-y: contain —— 监听全是 passive，\n  不能 preventDefault，不声明它 Chrome 会抢在 JS 前面刷新整个页面。\n- 指示器高度用变量直接驱动，拖拽路径上**不许有 transition**（直接操纵不能滞后）；\n  transition 只挂在刷新态那条 height 0→44 的跳变上。\n- 指示器必须占布局（用 height 长出来），不要用 transform ——\n  下面的列表内容要让位，这是 iOS 式下拉刷新的观感来源。\n- prefers-reduced-motion 下手势保留；转圈保留（它是状态指示不是装饰），\n  但要在文档里注明这是已知取舍。\n\n已知限制（写进注释，不要假装没有）：\n- 起手判定只在 touchstart 做一次：一次触摸里先上滚再下拉，指示器会中途冒出来。\n- 指数阻尼的 trigger 换算：手指位移 = -max * ln(1 - trigger/max)。\n\n【验收标准】\n- 滚到顶后下拉，指示器逐帧长高、内容被推下去；文字在阻尼值过 56 时切换。\n- 拉 80px（阻尼约 52）松手 → 收回，不刷新；拉 120px 松手 → 刷新。\n- 刷新中再拉 → 不武装；刷新结束后文字回到「下拉刷新」。\n- 列表不在顶部时下拉 → 指示器不出动。\n- Chrome Android 上滚动到顶继续拉 → 页面级刷新手势不出现（contain 生效）。\n\n【禁止做法】\n- 别给 `touchmove` 挂非 passive 监听去 `preventDefault`——那会让整个列表滚动掉帧，\n  `overscroll-behavior` 就是干这个的。\n- 别把指示器做成 `position: absolute` 浮在列表上 —— 内容让位才是\"拉\"的物理感，\n  浮层只有\"出现\"，没有\"被拉出来\"。\n- 别用弹簧曲线做过滚回弹 —— 这里的输出是阻尼**饱和**（永远到不了 max），\n  弹簧会过冲，两个模型混用会让\"拉到头\"的手感前后不一致。\n- 别在刷新态还让指示器跟手指 —— 进了 `busy` 就该收成固定高度，\n  高度晃动的转圈圈读起来像坏了。",
        "prompt_en": "Core Principle:\nBuild mobile Pull-to-Refresh using Touch Events + a single CSS custom property with zero dependencies. Finger travel is passed through exponential damping and written to `--ptr-y`, which directly drives indicator height—trigger detection evaluates the damped distance rather than raw finger travel.\n\nImplementation:\n1. Indicator setup & arming:\n   - Create the indicator element in JS and prepend it as the first child of the scroll container (no boilerplate DOM required from callers).\n   - Arm pulling (`pulling = true`) only when container `scrollTop <= 0` and not currently refreshing.\n2. Damping & threshold:\n   - On `touchmove`, compute finger displacement `d = clientY - startY` (treat `d <= 0` as `0`) and apply exponential damping: `damped = max * (1 - Math.exp(-d / max))` with `max = 72`. Write `damped` in `px` to `--ptr-y`, driving indicator `height` directly.\n   - When `damped >= trigger` (`56`), switch indicator text from `\"Pull to refresh\"` to `\"Release to refresh\"`. (Because `trigger` is evaluated after damping, actual finger travel is roughly `108px` to reach `56`; this is intentional.)\n3. Release & refresh lifecycle (handle `touchcancel` on the same path as `touchend`):\n   - If `damped < trigger`, reset `--ptr-y` to `0` to collapse.\n   - Otherwise enter refreshing state (`busy = true`), add `.is-refreshing` (CSS fixes `height: 44px`, shows spinner, sets label `\"Refreshing...\"`), `await onRefresh()`, then remove `.is-refreshing`, reset `--ptr-y` to `0`, clear `busy`, and reset the label back to `\"Pull to refresh\"`.\n   - While `busy = true`, new pulls must not arm.\n\nHard Constraints:\n- Container CSS must declare `overscroll-behavior-y: contain`—all touch listeners are `passive` and cannot call `preventDefault()`, so without `contain`, Chrome intercepts with browser-level page refresh.\n- Indicator height must be driven directly by `--ptr-y` with no `transition` along the drag path (direct manipulation must not lag); attach `transition` only to the `0 <-> 44px` state snaps.\n- The indicator must occupy layout space (growing via `height`), not `transform`—pushing list content down creates the authentic iOS pull-to-refresh feel.\n- Under `prefers-reduced-motion: reduce`, retain both the gesture and the spinner (as a status indicator rather than decoration), and document this intentional trade-off in comments.\n- Document known limitations in code comments: arming checks run once on `touchstart` (scrolling up then pulling down in one touch will not engage mid-gesture); exponential-damping trigger conversion is `fingerTravel = -max * ln(1 - trigger / max)`.\n\nAcceptance Criteria:\n- At scroll top, pulling down grows the indicator frame-by-frame while pushing list content downward; label switches once damped distance crosses `56`.\n- Pulling `80px` (damped `~52`) and releasing collapses without refreshing; pulling `120px` and releasing triggers refresh.\n- Pulling again while refreshing does not arm; after refresh finishes, label resets to `\"Pull to refresh\"`.\n- Pulling when the list is not at scroll top does not activate the indicator.\n- On Chrome Android, pulling past scroll top does not trigger the browser's native page-refresh gesture (`contain` holds).",
        "dont_do_en": "- Do NOT attach a non-passive `touchmove` listener just to call `preventDefault()` — it causes dropped scroll frames; `overscroll-behavior` handles this natively.\n- Do NOT position the indicator `position: absolute` floating over the list — pushing content down is what conveys physical pulling rather than an overlay popping in.\n- Do NOT use a spring curve for overscroll resistance — this model uses saturating exponential damping (never reaching `max`), and mixing it with spring overshoot makes pulling to the limit feel inconsistent.\n- Do NOT let the indicator keep tracking finger position during the refreshing state — once `busy` starts, lock to a fixed height (`44px`), as a wobbling spinner looks broken.",
        "skill_rule_en": "# Pull-to-Refresh with Damping (pull-refresh) · Cross-Platform Motion Spec\nNature: Weight | Layer: mobile | Platform: touch\n\nCore Principle: Build mobile Pull-to-Refresh using Touch Events + a single CSS custom property with zero dependencies. Finger travel is passed through exponential damping and written to `--ptr-y`, which directly drives indicator height—trigger detection evaluates the damped distance rather than raw finger travel.\n\nHard Constraints:\n- Container CSS must declare `overscroll-behavior-y: contain`—all touch listeners are `passive` and cannot call `preventDefault()`, so without `contain`, Chrome intercepts with browser-level page refresh.\n- Indicator height must be driven directly by `--ptr-y` with no `transition` along the drag path (direct manipulation must not lag); attach `transition` only to the `0 <-> 44px` state snaps.\n- The indicator must occupy layout space (growing via `height`), not `transform`—pushing list content down creates the authentic iOS pull-to-refresh feel.\n- Under `prefers-reduced-motion: reduce`, retain both the gesture and the spinner (as a status indicator rather than decoration), and document this intentional trade-off in comments.\n- Document known limitations in code comments: arming checks run once on `touchstart` (scrolling up then pulling down in one touch will not engage mid-gesture); exponential-damping trigger conversion is `fingerTravel = -max * ln(1 - trigger / max)`.\n\nAcceptance Criteria:\n- At scroll top, pulling down grows the indicator frame-by-frame while pushing list content downward; label switches once damped distance crosses `56`.\n- Pulling `80px` (damped `~52`) and releasing collapses without refreshing; pulling `120px` and releasing triggers refresh.\n- Pulling again while refreshing does not arm; after refresh finishes, label resets to `\"Pull to refresh\"`.\n- Pulling when the list is not at scroll top does not activate the indicator.\n- On Chrome Android, pulling past scroll top does not trigger the browser's native page-refresh gesture (`contain` holds).\n\nDo NOT Do:\n- Do NOT attach a non-passive `touchmove` listener just to call `preventDefault()` — it causes dropped scroll frames; `overscroll-behavior` handles this natively.\n- Do NOT position the indicator `position: absolute` floating over the list — pushing content down is what conveys physical pulling rather than an overlay popping in.\n- Do NOT use a spring curve for overscroll resistance — this model uses saturating exponential damping (never reaching `max`), and mixing it with spring overshoot makes pulling to the limit feel inconsistent.\n- Do NOT let the indicator keep tracking finger position during the refreshing state — once `busy` starts, lock to a fixed height (`44px`), as a wobbling spinner looks broken."
      }
    },
    {
      "id": "refraction",
      "name": "边缘折射",
      "name_en": "Liquid Glass Edge Refraction",
      "layer": "glass",
      "nature": "材质",
      "platform": "both",
      "status": "shipped",
      "entry": "refract(el, { strength, feather, ior }) / glass(el, { refract: 0.34 })",
      "source": "自研解析圆角倒角几何 + 斯涅尔光学折射（Snell's Law）+ SVG feDisplacementMap 共享池",
      "source_en": "Original analytical bevel geometry + Snell's Law optical refraction (IOR 1.52) + shared SVG filter pool",
      "file": "effects/refraction.md",
      "summary": "在玻璃边缘把背景**弯折**一下：生成一张 dx/dy 位移图，交给 `feDisplacementMap`，\n让 `backdrop-filter` 折出\"这块东西有厚度\"的那一圈。",
      "summary_en": "Real optical edge bending using analytical rounded-bevel normals and Snell's Law refraction (IOR 1.52) encoded into an SVG feDisplacementMap + backdrop-filter, with geometry-pooled shared filters.",
      "problem": "**「毛玻璃卡片」和「液态玻璃」的区别只有一件事：边缘有没有被折弯。**\n\n`backdrop-filter: blur()` 是把背景磨平——它让表面看起来是**半透明**的，\n但半透明不等于**实心**。一块真正有厚度的玻璃，靠近边缘时会把后面的东西\n压缩、错位，这是光学上唯一的\"厚度证据\"。没有它，再叠多少高光、亮边、投影，\n读起来都是一张贴纸。\n\n这个效果不给用户任何新信息，但它回答了一个问题：**\"这东西是块实体，还是一层膜？\"**",
      "origin": "基于经典几何光学（**斯涅尔折射定律 Snell's Law**）与 iOS 26 液态玻璃的边缘透镜厚度观感，自研无 WebGL 的纯 SVG 位移图折射方案：\n\n| 组成部分 | 设计取舍 |\n|---|---|\n| **解析圆角几何与法线（`bevelGeometry`）** | 直边区沿最近边取单位外法线（45° 对角折中），圆角扇区按圆心向量归一化，一次解析算出内距与单位外法线；零 4 点中心差分近似，尖角与极扁条无网格伪影 |\n| **凸面倒角斯涅尔折射（`snellRefraction`）** | 将带宽内倒角建模为与中心平面 C¹ 相切的凸面透镜（`sin(θi) = 0.92 · (1 - u)^1.5`），按 `sin(θt) = sin(θi) / IOR`（默认冕牌玻璃 `IOR = 1.52`）求真实光线偏转 `tan(θi - θt)` |\n| **动态尺寸 + 降采样保力道** | 读取元素实测 `getBoundingClientRect()` 与 `border-top-left-radius`，长边降采样到 168 格，但位移量始终按 CSS px 计算 |\n| **共享 `<svg><filter>` 池** | 以 `w×h r s f i` 为 key 复用位移图与 `feDisplacementMap`，避免每块玻璃各建一份 `<svg>` + `<canvas>` + dataURL |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| `ior` | 1.52（冕牌玻璃） | 真实光学玻璃折射率；`ior = 1` 时零折射，`ior` 越高（如蓝宝石 1.77）边缘透镜压缩越强 |\n| `curvature` | 0.92 | 倒角边缘最大入射正弦，既保留强边缘弯折又避免贴边 90° 掠射切线发散 |\n| `samples` | 168（长边格数） | 位移场是平滑的，降采样后双线性放大看不出来。168 格 = 340px 宽的卡片每格约 2px；再低圆角会出现阶梯。上限压到 172 是为了大卡片（1200px）不把主线程卡住 |\n| `feather` | 0.42 | 折弯带宽 = 短边 × feather。0.42 时 150px 高的卡片带宽约 31px —— 比圆角半径（26px）略大，弯折刚好裹住圆角外沿。低于 0.3 会只剩一条细线 |\n| `strength` | 0.34 | 位移峰值 = 带宽 × strength ≈ 10.7px。这是\"看得出被压扁、但认得出后面是什么\"的上限；0.5 以上背景会糊成一团 |\n| `--mk-glass-blur` | **6px**（原 24px） | **模糊和折射在抢同一件事。** 背景糊得越狠，边缘那圈被折弯的纹理越看不出来，最后只剩一块灰板子。24px 时折射基本白做 |\n| `contrast(1.12)` `brightness(1.04)` | 写死在 `.is-refract` 里 | 位移之后像素被重采样，整体会软一档，不提一点看起来像蒙了层雾 |\n| ResizeObserver 重算阈值 | 2px | 位移图按 px 算，尺寸一变就过期。但 grid 重排会连响好几次，所以小于 2px 不动、且攒到一帧里做 |\n| filter 池 key | `w×h r s f i` | 几何 + 参数完全相同才能共用。实测 6 块玻璃 / 3 种尺寸 → 3 条 filter，而不是 6 条 |\n\n**三个属性少一行就变灰图**（这是整套东西里最容易踩的坑，见第 7 节）：\n\n```\nfilterUnits=\"userSpaceOnUse\"\ncolorInterpolationFilters=\"sRGB\"\nx=\"0\" y=\"0\" width=W height=H      ← W/H 必须是元素尺寸\n```",
      "implementation": "```\nglass.js       bevelGeometry(px, py, halfW, halfH, radius)     纯函数：解析内距与单位外法线\nglass.js       snellRefraction(u, ior = 1.52, curvature = 0.92) 纯函数：斯涅尔凸面偏转量\nglass.js       lensField(w, h, { radius, feather, strength, ior, samples })\n                 → { data: Uint8ClampedArray, width, height, scale }\nglass.js       ensureFilter(w, h, radius, opt)  → 共享池，key = 几何+参数\nglass.js       refract(el, { strength, feather, ior }) → teardown\nglass.css      .mk-glass 的基底（纯 blur，没折射时唯一的一层）\nglass.css      .mk-glass.is-refract  覆盖成 url(#…) + blur + 提对比\n```\n\n职责切得很干净：\n\n- **数学全在 `lensField`**，纯函数、不碰 DOM，所以能单测（R/G 的方向、scale 与 strength 成正比、\n  降采样后力道不变、极扁的条也能出图 —— 都有断言盯着）。\n- **池子在 `ensureFilter`**，只负责\"这个几何算过没有\"。\n- **`refract()` 只管生命周期**：算几何、写 `--mk-glass-url`、加 `.is-refract`、挂 ResizeObserver。\n  它**不写 transform、也不碰高光** —— 那是 `glass()` 的事。\n\n`scale` 必须是**全图最大偏移**，因为 `feDisplacementMap` 只有一个 `scale` 属性。\n按每侧各自归一化的话，大的那一侧会被裁掉。",
      "degradation": "**走 `glass` 那档：冻。**\n\n折射是**贴图**不是动画 —— 静止画面里它就在那儿，`prefers-reduced-motion` 下不需要任何处理。\n这一条和 `motion.css` 的\"减\"、`fun/3d` 的\"关\"都不同，是第三套契约里的特例。\n\n两条真正的降级：\n\n```css\n/* 弱机 / 省电：feDisplacementMap 是逐像素重采样，\n   和 backdrop-filter 叠在一起正是最贵的那一段 */\n.mk-lite .mk-glass.is-refract {\n  -webkit-backdrop-filter: none;\n  backdrop-filter: none;\n  background-color: rgba(16, 21, 29, 0.94);\n}\n```\n\n以及能力门（在 `refract()` 里，不是 CSS）：\n\n```js\nif (!CSS.supports('backdrop-filter', 'url(#mk-glass-f0) blur(1px)')) return noop;\n```\n\n门失败时**安静退回纯模糊**：class 不加、变量不写、filter 不建。\n实测通过这道门的是 **Chrome / Edge / Safari 18.6**（三者都落到 `.is-refract`，\n`--mk-glass-url` 都写入、`#mk-glass-defs` 里都建出一条 filter）。\n旧版 Safari 与拿不到 `feDisplacementMap` 的引擎才走降级。",
      "pitfalls": "**① 三个 filter 属性少一个，Chrome 就给一张灰图。**\n\n```\nfilterUnits=\"userSpaceOnUse\"        ← 坐标锁到元素盒，而不是默认的 -10%..120% bbox\ncolorInterpolationFilters=\"sRGB\"    ← 编码是 sRGB 直存的 u8，线性色彩空间会算错\nx=\"0\" y=\"0\" width=W height=H        ← 显式给区域；缺省时位移图会被缩放到一个奇怪的范围\n```\n\n表现是玻璃变成一块均匀的灰色/空白，而不是\"折射弱一点\"。**没有渐变、没有提示，\n只是全灰** —— 所以这三行必须当成不可省略的字面量。\n\n**② `blur` 和折射抢同一件事。**\n`--mk-glass-blur` 从 24px 降到 6px 不是为了省性能，是为了让边缘那圈折弯**看得见**。\n如果哪天有人把它调回去\"让玻璃更磨砂\"，折射会立刻消失，而现象是\"折射坏了\"——\n实际是被模糊吃掉了。`.is-refract` 那条覆盖里必须把 `blur()` 再写一遍（它是覆盖不是追加），\n少写就是\"一开折射模糊就没了\"。\n\n**③ 位移图过期是静默的。**\n图是按 px 画的。元素从 340 变成 200 宽之后，如果没重算，折射会按旧比例拉伸，\n看起来像\"折射突然变淡\"。所以 `refract()` 挂 ResizeObserver；但 grid 重排时会连响多次，\n所以只在 ≥2px 时动、并且攒一帧。\n\n**④ `feImage` 的 href 必须走 xlink 命名空间。**\n\n```js\nfeImage.setAttributeNS('http://www.w3.org/1999/xlink', 'href', canvas.toDataURL())\n```\n\n只用 `setAttribute('href', ...)` 在部分引擎里不生效。\n\n**⑤ 位移图的采样分辨率**和**位移量**是两个独立的东西。**\n降采样把格数降到 168 之后，如果偏移按\"采样像素\"算，折射力道会跟着变弱 3 倍。\n所以 `lensField` 里 `dx/dy` 一律按 `cellW/cellH` 换算回 CSS px ——\n这条有单测（`samples: 24` 的 scale 必须不低于 `samples: 168` 的 85%）。\n\n**⑥ `rect.height` 的取整。**\n池子 key 用 `Math.round`，但 `rect.width` 是浮点。0.4px 的差异会造成两条 filter 白算一遍。\n现在用 round 挡住大部分，但 `<canvas>` 里仍是 `field.width × field.height` 的整数格 ——\n`preserveAspectRatio=\"none\"` 负责把非整数比例拉回去。\n\n**⑦ `.is-press` 和 `v-mk-tap` 抢 `transform`。**\n`glass()` 在触屏上接管按压（加 `.is-press` 播 `mk-glass-press` 关键帧），\n而 `v-mk-tap` 写的是 `scale(0.955)` —— 同一个节点只能二选一，\n否则两段关键帧互相抢，按压看起来像抽搐。\n\n**⑧ 文档里的默认值曾经是错的。** `refract()` 的 JSDoc 有一段时间写\n`[opt.strength=0.26]`，实际签名是 `0.34` —— 0.26 是更早一版的默认，\n调参之后注释没跟上。这类错比没有注释更糟：读代码的人会以为自己在看默认值。\n现在已改回 `0.34`，与 `glass({ refract: 0.34 })` 一致。\n\n---",
      "ai_assets": {
        "prompt": "实现「液态玻璃」的边缘折射材质。不要用 WebGL，只用 CSS + SVG filter。\n\n原理：\n用一张 PNG 位移图告诉浏览器「背景在这个像素要往哪个方向挪多少」。\n把它挂到 backdrop-filter 上，背景就会在边缘被弯折，出现\"玻璃有厚度\"的观感。\n\n第一步：画位移图（canvas，一次性，不进 rAF）\n1. 尺寸取元素的 getBoundingClientRect()，圆角取 computedStyle 的 border-top-left-radius。\n2. 逐点用解析几何计算到圆角矩形边界的内距 depth 与精确单位外法线 (nx, ny)（零中心差分）：\n   - 令 bx = halfW - r, by = halfH - r, ax = |px|, ay = |py|；\n   - 圆角扇区（ax > bx 且 ay > by）：cx = ax - bx, cy = ay - by, dist = hypot(cx, cy)，depth = r - dist，外法线 (sx*cx/dist, sy*cy/dist)；\n   - 直边区：dxWall = halfW - ax, dyWall = halfH - ay, depth = min(dxWall, dyWall)，沿较近边取单位外法线（等距处取 45° 对角单位向量）。\n3. 带宽 reach = min(halfW, halfH) * 0.42，归一内距 u = depth / reach（u >= 1 的平坦中心区偏移为 0）。\n4. 按斯涅尔定律（Snell's Law）计算凸面玻璃倒角折射偏转（默认冕牌玻璃 ior = 1.52，曲率 alpha = 0.92）：\n   - sinI = alpha * clamp(1 - max(0, u), 0, 1)^1.5，cosI = sqrt(1 - sinI^2)；\n   - sinT = sinI / ior，cosT = sqrt(1 - sinT^2)；\n   - 偏转角正切 delta = (sinI*cosT - cosI*sinT) / (cosI*cosT + sinI*sinT)；\n   - 以边缘标准峰值归一化到 amp = reach * 0.34，向内取样：dx = -nx * mag, dy = -ny * mag。\n5. 整图取最大偏移 max，编码成 RGBA：\n     R = (dx / max + 0.5) * 255\n     G = (dy / max + 0.5) * 255     ← 128 表示\"不位移\"\n     B = 0, A = 255\n6. 采样可以降密度：长边限制在 168 格左右。但 dx/dy 必须按 CSS px 算，\n   不能按采样格算，否则降采样会让折射变弱。\n7. canvas.toDataURL() 拿 dataURL。记得释放 canvas。\n\n第二步：建 filter（全站共用一个池）\n   <svg id=\"defs\" width=\"0\" height=\"0\" aria-hidden=\"true\"><defs/></svg>\n   <filter id=\"f0\" filterUnits=\"userSpaceOnUse\" colorInterpolationFilters=\"sRGB\"\n           x=\"0\" y=\"0\" width=\"{W}\" height=\"{H}\">\n     <feImage href=\"{dataURL}\" width=\"{W}\" height=\"{H}\" preserveAspectRatio=\"none\" result=\"map\"/>\n     <feDisplacementMap in=\"SourceGraphic\" in2=\"map\" scale=\"{max}\"\n                        xChannelSelector=\"R\" yChannelSelector=\"G\"/>\n   </filter>\n   池子的 key 用 `${round(W)}x${round(H)}r${round(r)}s${strength}f${feather}i${ior}`，\n   几何 + 参数完全一样才能共用。feImage 的 href 用 setAttributeNS(xlink 命名空间)。\n\n第三步：挂上去\n   el.style.setProperty('--glass-url', `url(#f0)`)\n   el.classList.add('is-refract')\n   配合的 CSS（注意是覆盖不是追加，blur 必须重写一遍）：\n     .is-refract {\n       backdrop-filter: var(--glass-url) blur(6px) contrast(1.12) brightness(1.04) saturate(1.78);\n     }\n\n第四步：能力门与降级\n   - 开门：CSS.supports('backdrop-filter', 'url(#f0) blur(1px)') 为真才做。\n     为假时安静返回，什么都不写（class 不加、变量不写），CSS 回落到纯 blur。\n   - 元素尺寸变化 ≥2px 时重算，用 ResizeObserver，并攒到一帧里做。\n   - 低端机 / 省电模式：backdrop-filter: none + 实色背景。feDisplacementMap 是逐像素重采样，\n     和 backdrop-filter 叠加时最贵。\n\n硬要求（少一条就会失败）：\n- 三个 filter 属性必须写全：filterUnits=\"userSpaceOnUse\"、colorInterpolationFilters=\"sRGB\"、\n  显式 x/y/width/height。缺一个 Chrome 会给一张全灰的图，没有报错。\n- blur 必须 ≤ 8px。模糊和折射抢同一件事：背景糊得越狠，边缘那圈弯折越看不出来。\n- 位移方向一律向内。向外是\"推挤\"不是\"折射\"。\n- prefers-reduced-motion 下不要摘掉它 —— 它是贴图不是动画，静止画面里也需要。\n\n验收：\n- 一块 340×150、圆角 26px 的玻璃，边缘 30px 内背景有明显压缩/错位，中心不变形。\n- 两块同尺寸玻璃只建 1 条 filter；不同尺寸建 2 条。\n- 元素从 340 缩到 200 宽后，折射依旧贴着新边缘（不是被拉伸的旧图）。\n- 不支持 backdrop-filter: url() 的浏览器：不报错、无灰块、退回纯模糊。",
        "dont_do": "**验收（人工）**：把玻璃放在一张有竖条纹或细文字的底图上，边缘应该看到条纹被压弯；\n放在纯色底上应该**看不出任何折射**（没有可弯的东西）—— 这是正常的，不是没生效。\n\n- 别加 `will-change: backdrop-filter`，对这条几乎无效，还可能反而掉帧。\n- 别把位移图放进 rAF 每帧重画 —— 它只跟几何有关，不跟时间有关。\n- 别用 `feGaussianBlur` 冒充边缘弯折：那是模糊，不是折射。\n- 别在 `prefers-reduced-motion` 下把它设成 `none`，那会让玻璃变薄一档。",
        "skill_rule": "# 边缘折射 (refraction) · 跨平台动效规范\n性质：材质 ｜ 平台：both\n\n【核心原理】在玻璃边缘把背景**弯折**一下：生成一张 dx/dy 位移图，交给 `feDisplacementMap`， 让 `backdrop-filter` 折出\"这块东西有厚度\"的那一圈。\n\n【验收标准】\n- 一块 340×150、圆角 26px 的玻璃，边缘 30px 内背景有明显压缩/错位，中心不变形。\n- 两块同尺寸玻璃只建 1 条 filter；不同尺寸建 2 条。\n- 元素从 340 缩到 200 宽后，折射依旧贴着新边缘（不是被拉伸的旧图）。\n- 不支持 backdrop-filter: url() 的浏览器：不报错、无灰块、退回纯模糊。\n\n【禁止做法】\n**验收（人工）**：把玻璃放在一张有竖条纹或细文字的底图上，边缘应该看到条纹被压弯；\n放在纯色底上应该**看不出任何折射**（没有可弯的东西）—— 这是正常的，不是没生效。\n\n- 别加 `will-change: backdrop-filter`，对这条几乎无效，还可能反而掉帧。\n- 别把位移图放进 rAF 每帧重画 —— 它只跟几何有关，不跟时间有关。\n- 别用 `feGaussianBlur` 冒充边缘弯折：那是模糊，不是折射。\n- 别在 `prefers-reduced-motion` 下把它设成 `none`，那会让玻璃变薄一档。",
        "prompt_en": "Core Principle:\nBuild Liquid Glass Edge Refraction without WebGL, using only CSS + an SVG filter driven by analytical rounded-bevel geometry and Snell's Law optical physics (crown glass IOR 1.52). A precomputed PNG displacement map instructs the browser how far and in which direction to shift background pixels along the glass rim; attached to `backdrop-filter`, it bends background details at the edge to create authentic optical glass thickness.\n\nImplementation:\n1. Generate displacement map (offscreen `canvas`, one-time, never inside `rAF`):\n   - Read dimensions via `getBoundingClientRect()` and corner radius from computed `border-top-left-radius`.\n   - For each sample point `(px, py)` relative to element center, compute exact analytical inward depth `depth` and unit outward normal `(nx, ny)` (zero finite differences):\n     - Let `bx = halfW - r`, `by = halfH - r`, `ax = |px|`, `ay = |py|`.\n     - Corner arc sector (`ax > bx && ay > by`): `cx = ax - bx`, `cy = ay - by`, `dist = hypot(cx, cy)`, `depth = r - dist`, `nx = sign(px) * cx / dist`, `ny = sign(py) * cy / dist`.\n     - Straight-edge sector: `dxWall = halfW - ax`, `dyWall = halfH - ay`, `depth = min(dxWall, dyWall)`, normal points along the closer wall (45-degree unit diagonal when equidistant).\n   - Band width `reach = min(halfW, halfH) * 0.42`, normalized inward distance `u = depth / reach` (`u >= 1` flat interior has zero shift).\n   - Compute Snell's Law deflection on a C1-smooth convex bevel (`ior = 1.52`, `curvature = 0.92`): `sinI = 0.92 * clamp(1 - max(0, u), 0, 1)^1.5`, `cosI = sqrt(1 - sinI^2)`, `sinT = sinI / ior`, `cosT = sqrt(1 - sinT^2)`, `deflection = (sinI*cosT - cosI*sinT) / (cosI*cosT + sinI*sinT)`. Normalize against the crown-glass rim peak to `amp = reach * 0.34`, then project inward: `dx = -nx * mag`, `dy = -ny * mag`.\n   - Find global max displacement `max` across the map and encode RGBA: `R = (dx / max + 0.5) * 255`, `G = (dy / max + 0.5) * 255` (`128` = zero shift), `B = 0`, `A = 255`.\n   - Downsampling is allowed (cap longest edge near `168` cells), but `dx`/`dy` must be computed in CSS `px`, not sample grid units, or downsampling weakens refraction.\n   - Export `canvas.toDataURL()` and release the canvas.\n2. Build SVG filter (shared global `<defs>` pool):\n   - `<svg id=\"defs\" width=\"0\" height=\"0\" aria-hidden=\"true\"><defs/></svg>`\n   - `<filter id=\"f0\" filterUnits=\"userSpaceOnUse\" colorInterpolationFilters=\"sRGB\" x=\"0\" y=\"0\" width=\"{W}\" height=\"{H}\">` containing `<feImage href=\"{dataURL}\" width=\"{W}\" height=\"{H}\" preserveAspectRatio=\"none\" result=\"map\"/>` and `<feDisplacementMap in=\"SourceGraphic\" in2=\"map\" scale=\"{max}\" xChannelSelector=\"R\" yChannelSelector=\"G\"/>`.\n   - Pool key: `` `${round(W)}x${round(H)}r${round(r)}s${strength}f${feather}i${ior}` ``—only identical geometry and parameters share a filter. Set `feImage` `href` using `setAttributeNS` (`xlink` namespace).\n3. Attach filter:\n   - `el.style.setProperty('--glass-url', 'url(#f0)')`; `el.classList.add('is-refract')`.\n   - CSS (overrides rather than appends, so re-declare blur): `.is-refract { backdrop-filter: var(--glass-url) blur(6px) contrast(1.12) brightness(1.04) saturate(1.78); }`.\n4. Capability gate & degradation:\n   - Gate on `CSS.supports('backdrop-filter', 'url(#f0) blur(1px)')`; if false, return silently without adding classes or variables so CSS falls back to plain blur.\n   - Recompute via `ResizeObserver` when dimensions change by `>= 2px`, batched into one animation frame.\n   - Low-end / power-saving mode: `backdrop-filter: none` + solid opaque fill (`feDisplacementMap` resamples per pixel and is expensive when stacked on `backdrop-filter`).\n\nHard Constraints:\n- All three `<filter>` attributes must be set explicitly: `filterUnits=\"userSpaceOnUse\"`, `colorInterpolationFilters=\"sRGB\"`, and explicit `x`/`y`/`width`/`height`—omitting any one causes Chrome to output a solid gray block with no error.\n- `blur` must be `<= 8px`; stronger blur washes out the edge bending produced by refraction.\n- Displacement direction must always point inward; outward displacement looks like bulging/pushing rather than refraction.\n- Do not remove refraction under `prefers-reduced-motion: reduce`—it is a static surface map, not an animation.\n\nAcceptance Criteria:\n- On a `340x150` panel with `26px` radius, background patterns within `30px` of the edge visibly compress/shift while the center stays undistorted.\n- Two panels of identical dimensions share `1` filter; different dimensions produce `2` filters.\n- Shrinking width from `340` to `200` regenerates the map so refraction hugs the new edge rather than stretching the old map.\n- Manual visual check: place the glass over vertical stripes or fine text to verify edge bending; over a solid-color background, seeing no refraction is normal because there is no detail to bend.\n- Browsers lacking `backdrop-filter: url()` support throw no errors, show no gray blocks, and fall back to plain blur.",
        "dont_do_en": "- Do NOT mistake the lack of visible refraction over a flat solid-color background for a broken filter — verify over vertical stripes or fine text, since uniform backgrounds have nothing to bend.\n- Do NOT add `will-change: backdrop-filter` — it has virtually no benefit here and can actually drop frames.\n- Do NOT redraw the displacement map inside `rAF` every frame — it depends purely on geometry, not time.\n- Do NOT fake edge bending with `feGaussianBlur` — that produces blur, not refraction.\n- Do NOT set refraction to `none` under `prefers-reduced-motion` — doing so makes the glass look noticeably flatter.",
        "skill_rule_en": "# Liquid Glass Edge Refraction (refraction) · Cross-Platform Motion Spec\nNature: Material | Layer: glass | Platform: both\n\nCore Principle: Build Liquid Glass Edge Refraction without WebGL, using only CSS + an SVG filter driven by analytical rounded-bevel geometry and Snell's Law optical physics (crown glass IOR 1.52). A precomputed PNG displacement map instructs the browser how far and in which direction to shift background pixels along the glass rim; attached to `backdrop-filter`, it bends background details at the edge to create authentic optical glass thickness.\n\nHard Constraints:\n- All three `<filter>` attributes must be set explicitly: `filterUnits=\"userSpaceOnUse\"`, `colorInterpolationFilters=\"sRGB\"`, and explicit `x`/`y`/`width`/`height`—omitting any one causes Chrome to output a solid gray block with no error.\n- `blur` must be `<= 8px`; stronger blur washes out the edge bending produced by refraction.\n- Displacement direction must always point inward; outward displacement looks like bulging/pushing rather than refraction.\n- Do not remove refraction under `prefers-reduced-motion: reduce`—it is a static surface map, not an animation.\n\nAcceptance Criteria:\n- On a `340x150` panel with `26px` radius, background patterns within `30px` of the edge visibly compress/shift while the center stays undistorted.\n- Two panels of identical dimensions share `1` filter; different dimensions produce `2` filters.\n- Shrinking width from `340` to `200` regenerates the map so refraction hugs the new edge rather than stretching the old map.\n- Manual visual check: place the glass over vertical stripes or fine text to verify edge bending; over a solid-color background, seeing no refraction is normal because there is no detail to bend.\n- Browsers lacking `backdrop-filter: url()` support throw no errors, show no gray blocks, and fall back to plain blur.\n\nDo NOT Do:\n- Do NOT mistake the lack of visible refraction over a flat solid-color background for a broken filter — verify over vertical stripes or fine text, since uniform backgrounds have nothing to bend.\n- Do NOT add `will-change: backdrop-filter` — it has virtually no benefit here and can actually drop frames.\n- Do NOT redraw the displacement map inside `rAF` every frame — it depends purely on geometry, not time.\n- Do NOT fake edge bending with `feGaussianBlur` — that produces blur, not refraction.\n- Do NOT set refraction to `none` under `prefers-reduced-motion` — doing so makes the glass look noticeably flatter."
      }
    },
    {
      "id": "ring",
      "name": "3D 环形画廊轮播",
      "name_en": "Draggable 3D Ring Carousel",
      "layer": "3d",
      "nature": "方向",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-ring + .mk-ring / ring(el, { count, radius, auto, drag })",
      "source": "真三维环形卡廊（单角度真源 + 惯性 0.96 衰减平滑交还自动旋转）",
      "source_en": "True 3D cylindrical carousel (single-source angle + 0.96 friction handoff)",
      "file": "effects/ring.md",
      "summary": "N 张卡片绕 Y 轴排成真三维圆环，自动缓慢公转；手指或鼠标可随时抓住拖拽甩动，松手后惯性滑行并无缝交还给自动旋转。",
      "summary_en": "Cards arranged in a true 3D Y-axis cylinder combining auto-orbit, pointer-capture dragging, and 0.96 inertia decay into a single unified angle variable with zero velocity jumps.",
      "problem": "**作品集、模型展示或主题精选卡片用普通横向轮播略显平庸，而手写 3D 环形轮播最容易出“松手瞬间猛地加速或回弹跳角”的断裂感。** 把自动旋转、手动拖拽和惯性滑行全部写进同一个累计角度变量 `--ring-a`，三段状态切换就完全丝滑无缝。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 单一角度真源 `--ring-a`：拖拽、惯性与自动旋转共用一个量 | 拆成“自动角 + 拖拽角”两个动画叠加（松手必然出现二次加速） |\n| 惯性每帧 `vel *= 0.96` 衰减，低于 `0.02` 才交还给自动匀速旋转 | 拖拽松手后生硬截停或跳回 0° |\n| 3D 归零降级：减弱动效下 `transform: none` + `display: flex` 排成横行 | 卡片叠在同一个坐标里互相遮死 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 卡片步进角 | `360deg / n` | 第 `i` 张卡 `rotateY(i * step) translateZ(radius)` 严格等分圆周 |\n| 拖拽灵敏度 `drag` | `0.55 deg/px` | 拖过 180px 大约转 100°，既不费力又不会轻轻一碰转三圈 |\n| 惯性摩擦 | `vel *= 0.96` / 帧 | 类似物理转盘的阻尼滑行，约 1–1.5 秒优雅收速 |\n| 交还阈值 | `Math.abs(vel) < 0.02` | 等惯性几乎停稳再把控制权交回 `auto` 匀速旋转，肉眼看不到接缝 |",
      "implementation": "```\nsrc/core/scene3d.js:83   ring(el, { count, radius, auto, drag })  单真源角度循环 + Pointer Capture 拖拽\nstyles/3d.css            .mk-ring-stage / .mk-ring / .mk-ring__item\n```",
      "degradation": "**走 `3d` 层专属契约：归零塌回平面并切为横向 Flex 列表。**\n\n`prefers-reduced-motion: reduce` 下 `ring()` 不启动 rAF，CSS 将圆环与卡片 `transform: none` 并切为 `display: flex; gap: 12px` 横排展示，防止所有卡片塌在同一中心叠成一摞。",
      "pitfalls": "**① 自动旋转用 CSS `@keyframes`、拖拽用 JS 写 `transform`，两者打架。**\n一旦拆成两套动画源，开始拖拽和松手恢复时必然出现跳帧或双重加速；必须由同一个 `angle` 变量统一驱动。\n\n**② 忘了给圆环设 `backface-visibility` 或恰当透视半径导致卡片互相穿插。**\n根据卡片宽度 `w` 和张数 `n`，半径应大于 `w / (2 * tan(π / n))` 才不会边缘穿模。\n\n**③ 减弱动效只写了 `transform: none` 却没把布局改成 `flex`。**\n绝对定位的 6 张卡片去掉 3D 变换后会全部叠在 `(0,0)` 互相遮住；必须配合改为 `display: flex` 排开。\n\n---",
      "ai_assets": {
        "prompt": "实现零 Three.js 依赖的 3D 环形画廊轮播（Draggable 3D Ring Carousel）。\n\n原理一句话：N 张卡片按 rotateY(i * 360/N) translateZ(radius) 排成真 3D 圆环，拖拽、惯性滑行（0.96/帧衰减）与自动公转全部写入同一个累计角度变量 --ring-a，三段切换零跳变。\n\n做法：\n1. CSS 3D 结构：\n   - 外层舞台 .ring-stage：perspective: 900px; display: grid; place-items: center; touch-action: pan-y; user-select: none;\n   - 圆环容器 .ring：position: relative; transform-style: preserve-3d; transform: rotateY(var(--ring-a, 0deg)); cursor: grab;\n   - 每张卡片 .ring-item：position: absolute; transform: rotateY(calc(var(--i) * var(--step))) translateZ(var(--r));\n2. 单真源角度循环（auto = 12, drag = 0.55）：\n   - pointerdown：dragging = true, vel = 0, lastX = e.clientX，setPointerCapture。\n   - pointermove：d = (e.clientX - lastX) * drag; angle += d; vel = d; lastX = e.clientX。\n   - pointerup / pointercancel：dragging = false，释放 pointerCapture。\n   - rAF tick(t)：若 !dragging，则 vel *= 0.96; angle += vel; 当 |vel| < 0.02 时置 vel = 0 并改为 angle += auto * (dt / 1000) * 8（dt 钳制 <= 48ms 防切后台跳角）；写入 --ring-a。\n\n硬要求：\n- 自动公转与拖拽必须共用同一个 --ring-a 变量，严禁混用 CSS keyframes 旋转与 JS 拖拽。\n- dt 必须钳制上限（如 <= 48ms），防止切换浏览器标签页回来后瞬间狂转。\n- prefers-reduced-motion: reduce 下不启动 rAF，所有元素 transform: none 且容器改为 display: flex 横排，避免卡片全部叠在同一位置。\n\n验收：\n- 6 张卡片均匀排成 3D 圆环缓慢自转；横向拖拽跟手转动，快速一甩松手后惯性滑行并平滑过渡回自动旋转，无任何跳角。\n- 切到后台标签页 10 秒再切回来，圆环不出现瞬间暴冲。\n- 开启减弱动效后卡片自动展平排成一行，内容完整可读。",
        "dont_do": "- 别把自动旋转写在 CSS `@keyframes` 里再叠加 JS 拖拽角度 —— 松手必跳。\n- 别在 `prefers-reduced-motion` 下只关 `transform` 不改 `display: flex` —— 所有卡片会叠死在一起。\n- 别给容器设 `touch-action: none` —— 留 `pan-y` 给页面竖向滚动。",
        "skill_rule": "# 3D 环形画廊轮播 (ring) · 跨平台动效规范\n性质：方向 ｜ 平台：both\n\n【核心原理】N 张卡片按 rotateY(i * 360/N) translateZ(radius) 排成真 3D 圆环，拖拽、惯性滑行（0.96/帧衰减）与自动公转全部写入同一个累计角度变量 --ring-a，三段切换零跳变。\n\n【硬要求】\n- 自动公转与拖拽必须共用同一个 --ring-a 变量，严禁混用 CSS keyframes 旋转与 JS 拖拽。\n- dt 必须钳制上限（如 <= 48ms），防止切换浏览器标签页回来后瞬间狂转。\n- prefers-reduced-motion: reduce 下不启动 rAF，所有元素 transform: none 且容器改为 display: flex 横排，避免卡片全部叠在同一位置。\n\n【验收标准】\n- 6 张卡片均匀排成 3D 圆环缓慢自转；横向拖拽跟手转动，快速一甩松手后惯性滑行并平滑过渡回自动旋转，无任何跳角。\n- 切到后台标签页 10 秒再切回来，圆环不出现瞬间暴冲。\n- 开启减弱动效后卡片自动展平排成一行，内容完整可读。\n\n【禁止做法】\n- 别把自动旋转写在 CSS `@keyframes` 里再叠加 JS 拖拽角度 —— 松手必跳。\n- 别在 `prefers-reduced-motion` 下只关 `transform` 不改 `display: flex` —— 所有卡片会叠死在一起。\n- 别给容器设 `touch-action: none` —— 留 `pan-y` 给页面竖向滚动。",
        "prompt_en": "Core Principle:\nBuild a zero-Three.js Draggable 3D Ring Carousel. `N` cards are arranged into a true 3D circle via `rotateY(i * 360/N) translateZ(radius)`, while dragging, inertial coasting (`0.96`/frame decay), and auto-rotation all write to the same cumulative angle variable `--ring-a` for seamless transitions with zero jumps.\n\nImplementation:\n1. CSS 3D structure:\n   - Outer stage `.ring-stage`: `perspective: 900px; display: grid; place-items: center; touch-action: pan-y; user-select: none;`.\n   - Ring container `.ring`: `position: relative; transform-style: preserve-3d; transform: rotateY(var(--ring-a, 0deg)); cursor: grab;`.\n   - Each card `.ring-item`: `position: absolute; transform: rotateY(calc(var(--i) * var(--step))) translateZ(var(--r));`.\n2. Single-source-of-truth angle loop (`auto = 12`, `drag = 0.55`):\n   - `pointerdown`: `dragging = true, vel = 0, lastX = e.clientX`, call `setPointerCapture`.\n   - `pointermove`: `d = (e.clientX - lastX) * drag; angle += d; vel = d; lastX = e.clientX;`.\n   - `pointerup` / `pointercancel`: `dragging = false`, release pointer capture.\n   - `rAF` `tick(t)`: if `!dragging`, update `vel *= 0.96; angle += vel;`; when `|vel| < 0.02`, set `vel = 0` and advance `angle += auto * (dt / 1000) * 8` (clamp `dt <= 48ms` to prevent jumps after backgrounding); write `--ring-a`.\n\nHard Constraints:\n- Auto-rotation and dragging must share the single `--ring-a` variable; never mix CSS `@keyframes` rotation with JS dragging.\n- `dt` must be clamped (e.g., `<= 48ms`) to prevent sudden spin bursts when returning from a background tab.\n- Under `prefers-reduced-motion: reduce`, do not start `rAF`; set all transforms to `none` and switch the container to `display: flex` horizontal layout so cards do not pile onto a single spot.\n\nAcceptance Criteria:\n- Six cards form an evenly spaced 3D ring rotating gently; horizontal dragging tracks the pointer, and a quick flick coasts with inertia before blending smoothly back into auto-rotation with zero angle jumps.\n- Switching to a background tab for 10 seconds and returning produces no sudden spin burst.\n- With reduced motion enabled, cards flatten automatically into a readable horizontal row.",
        "dont_do_en": "- Do NOT drive auto-rotation in CSS `@keyframes` and layer JS drag angles on top — releasing the drag will always jump.\n- Do NOT only disable `transform` under `prefers-reduced-motion` without switching to `display: flex` — all cards will pile on top of one another.\n- Do NOT set `touch-action: none` on the container — preserve `pan-y` for vertical page scrolling.",
        "skill_rule_en": "# Draggable 3D Ring Carousel (ring) · Cross-Platform Motion Spec\nNature: Direction | Layer: 3d | Platform: both\n\nCore Principle: Build a zero-Three.js Draggable 3D Ring Carousel. `N` cards are arranged into a true 3D circle via `rotateY(i * 360/N) translateZ(radius)`, while dragging, inertial coasting (`0.96`/frame decay), and auto-rotation all write to the same cumulative angle variable `--ring-a` for seamless transitions with zero jumps.\n\nHard Constraints:\n- Auto-rotation and dragging must share the single `--ring-a` variable; never mix CSS `@keyframes` rotation with JS dragging.\n- `dt` must be clamped (e.g., `<= 48ms`) to prevent sudden spin bursts when returning from a background tab.\n- Under `prefers-reduced-motion: reduce`, do not start `rAF`; set all transforms to `none` and switch the container to `display: flex` horizontal layout so cards do not pile onto a single spot.\n\nAcceptance Criteria:\n- Six cards form an evenly spaced 3D ring rotating gently; horizontal dragging tracks the pointer, and a quick flick coasts with inertia before blending smoothly back into auto-rotation with zero angle jumps.\n- Switching to a background tab for 10 seconds and returning produces no sudden spin burst.\n- With reduced motion enabled, cards flatten automatically into a readable horizontal row.\n\nDo NOT Do:\n- Do NOT drive auto-rotation in CSS `@keyframes` and layer JS drag angles on top — releasing the drag will always jump.\n- Do NOT only disable `transform` under `prefers-reduced-motion` without switching to `display: flex` — all cards will pile on top of one another.\n- Do NOT set `touch-action: none` on the container — preserve `pan-y` for vertical page scrolling."
      }
    },
    {
      "id": "ripple",
      "name": "点击涟漪",
      "name_en": "Origin-Aware Click Ripple",
      "layer": "motion",
      "nature": "反馈",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-ripple / ripple(el, { color, duration })，宿主类 .mk-ripple-host",
      "source": "Material Design 的涟漪（按压点扩散 + 淡出）的轻量版",
      "source_en": "Material Design Ripple (exact pointer origin + auto-cleanup)",
      "file": "effects/ripple.md",
      "summary": "在点击点插一个绝对定位的圆，从 0 放大到覆盖全元素同时淡出，动画结束自动摘节点。",
      "summary_en": "Expands a translucent circular wave from the exact pointer coordinates to the farthest element corner and self-removes cleanly on finish.",
      "problem": "**按压反馈必须回答\"在哪里\"。** `tap`（形变）告诉用户\"点到了这个元素\"，\n涟漪告诉用户\"点在了这个元素的**哪个位置**\"——这对大按钮、卡片、列表行\n这类热区比内容大的元素是必要信息。两者是不同的问题，不是同一效果的两种画法。\n\n第二个问题：**涟漪的生命周期必须自洽。** 每次点击插一个节点、动画结束摘掉——\n不常驻监听、不残留 DOM，是这个效果能\"到处加\"的前提。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| Material 的\"从按压点扩散\"，不是\"从中心扩散\" | Material 的按住不松时涟漪悬停、松手才继续淡出的两段式——那需要 pointerup 状态机 |\n| `currentColor` 默认——涟漪自动继承文字颜色，深浅底都不用调色 | 波纹的多层扩散（Material 有内外两圈） |\n| `animationend` 摘节点 + 兜底 setTimeout | 触觉联动（Material 的 Android 上涟漪与震动同帧）——`buzz()` 可以自己叠 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 圆的直径 | `max(w, h) * 2` | 从任意角点击都能盖住对角。1 倍只够盖住一半，2 倍是最小保险 |\n| 时长 | 620ms | 扩散 + 淡出两件事的总时长。低于 400ms 读不到\"扩散\"，高于 800ms 下一次点击时上一个还没走完 |\n| `ease-out` | 曲线末段缓 | 扩散是\"能量耗尽\"，前快后慢；线性会像雷达扫描 |\n| 起始 opacity | 0.28 | 深底浅底都可见的上限。0.4 以上会盖住按钮文字 |\n| 摘除兜底 | `duration + 400` | `animationend` 可能不来（元素中途 display:none、标签页切走），兜底必须比动画长 |",
      "implementation": "```\nripple.js:7    ripple(el, { color, duration })   pointerdown 监听 + teardown\nmotion.css:657  .mk-ripple-host   position: relative + overflow: hidden\nmotion.css:662  .mk-ripple        transform: scale(0) 起始，keyframes 到 scale(1) + opacity: 0\n```\n\n节点是 JS 建的，样式全在 CSS 类上——JS 只写几何（left/top/size）和两个\n每次都要变的值（颜色、时长）。**size 用 `max(w,h)*2`、定位用点击点减半径**，\n所以涟漪永远是从点击点长出来的正圆，不依赖宿主形状。\n\n`overflow: hidden` 是宿主类的一部分——涟漪在扩散中必然超出宿主，\n不裁剪会溢出到相邻元素上。**换宿主时这个类不能丢**。",
      "degradation": "**走 `motion` 那档：减，但不需要专门规则。**\n\n全局减弱块把时长压到 1ms 后，涟漪变成一帧的闪现——**仍然是一次点击反馈**，\n只是没有了扩散过程。`animationend` 照常触发、节点照常摘除，生命周期不受影响。\n没必要像 `fun.css` 那样整层关掉：涟漪是按压反馈的表达，reduced-motion 用户\n依然需要\"点到了\"的确认。真想完全关，使用方不挂这条指令即可。",
      "pitfalls": "**① 点击点的回退逻辑有一个已知的边界 bug。**\n\n```js\nconst x = (e.clientX || r.left + r.width / 2) - r.left - size / 2;\n```\n\n`e.clientX || 中心点`——**`clientX === 0` 是 falsy**。在元素恰好贴着视口\n左边缘（x=0）点击时，涟漪会从中心扩散而不是从点击点。概率低但逻辑错。\n正确写法是显式判空：\n\n```js\nconst hasPoint = e.clientX !== undefined && e.clientX !== 0;\n```\n\n当前代码保留旧写法是因为触发它的场景极窄（整元素贴左边 + 精确点到 0px），\n修复要动核心层——**记录在案，不改**。键盘激活（Enter）没有坐标，\n`clientX` 为 undefined，走中心点——这是对的。\n\n**② 宿主必须有 `position: relative` 和 `overflow: hidden`，缺一个就穿帮。**\n少 relative：涟漪相对最近的定位祖先定位，出现在别人的位置上；\n少 hidden：圆扩散出界，盖到旁边的按钮上。`.mk-ripple-host` 把两条打包，\n但使用方如果自己写了 `position: absolute` 之类会顶掉它——\n**宿主的定位属性要和涟漪一起规划**。\n\n**③ pointerdown 而不是 click。**\n涟漪是按压反馈，必须和指尖同帧（同 `tap` 的理由）。`click` 要等 300ms\n双击判定。副作用：**滚动起手也会插一个涟漪**——和 `tap` 的\"闪一帧\"是同一个\n取舍，`pointercancel` 不拦它（涟漪自己会淡出，视觉成本比形变更低）。\n\n**④ 深浅底用 `currentColor`，别写死颜色。**\n按钮文字是白的，涟漪就是白的；换成深底浅字自动跟着变。\n`opts.color` 是给特殊场景的口子（比如品牌色按钮），默认值必须继承。\n\n**⑤ 快速连点会叠多个涟漪——这是对的，别去重。**\nMaterial 自己就连点叠加，每个涟漪从各自点击点扩散。去重（只留最后一个）\n会让第二次点击看起来\"没反应\"。兜底 setTimeout 保证最坏情况下\n每个节点也在 `duration + 400` 后被清掉。\n\n**⑥ 和 `tap`（形变）的叠加是设计决策，不是技术冲突。**\n技术上两者可以共存（涟漪是子节点、形变改宿主 transform，互不打架）。\n但两种反馈语言同时出现，用户读到的是\"这个按钮很用力\"——**语义重复**。\nMaterial 的原教旨做法是涟漪**替代**形变。库的立场：列表行/卡片用涟漪，\n按钮用形变，一个节点选一种。\n\n---",
      "ai_assets": {
        "prompt": "实现点击涟漪。原生 Pointer Events + CSS keyframes，不引依赖。\n\n原理一句话：在点击坐标插一个绝对定位的圆，用 CSS keyframes 放大并淡出，动画结束移除节点。JS 只负责起一个元素。\n\nCSS：\n  .ripple-host { position: relative; overflow: hidden; }\n  .ripple {\n    position: absolute;\n    border-radius: 50%;\n    pointer-events: none;\n    transform: scale(0);\n    opacity: 0.28;\n    animation: ripple 620ms cubic-bezier(0.22, 1, 0.36, 1) forwards;\n  }\n  @keyframes ripple { to { transform: scale(1); opacity: 0; } }\n\nJS（pointerdown 监听，不常驻额外开销）：\n- 直径 = max(宿主宽, 宿主高) * 2 —— 从任意角点击都能盖住对角。\n- 位置 = 点击点 - 半径（left/top），宿主内相对坐标。\n- 点击点缺失（键盘 Enter 激活，clientX 为 undefined）→ 回退宿主中心。\n  注意判断要用显式比较，不要 e.clientX || 中心 —— clientX 为 0 时\n  元素贴着视口左边缘，回退到中心是错的。\n- 颜色默认 currentColor（继承文字色，深浅底自动适配），可传 opts.color 覆盖。\n- 插入 span.ripple，animationend 时 remove（once 监听）；\n  另设 duration + 400 的兜底 setTimeout —— 动画被中断时 animationend 不来。\n- teardown：摘监听 + 清掉所有残留的 .ripple 节点。\n\n硬要求：\n- 宿主必须有 position: relative 和 overflow: hidden（涟漪会超出宿主）。\n- 用 pointerdown 不要用 click —— 涟漪是按压反馈，必须同帧；\n  click 有 300ms 双击判定延迟。\n- 快速连点叠加多个涟漪，不去重。\n- prefers-reduced-motion 下时长压缩即可（全局 token 会自动处理），\n  反馈本身保留 —— 它是\"点到了\"的确认，不是装饰。\n\n验收：\n- 点击元素任意角：圆从点击点扩散覆盖全元素后淡出，节点被移除\n  （1 秒后 el.querySelectorAll('.ripple').length === 0）。\n- 键盘 Tab + Enter 激活：涟漪从中心扩散，不报错。\n- 快速连点 5 次：5 个涟漪同时扩散，各自独立淡出。\n- 深底白字按钮：涟漪是白色的；换成浅底黑字自动变黑。\n- 宿主是圆角元素：涟漪被裁在圆角内（overflow hidden 生效）。",
        "dont_do": "- 别在 pointerup 才开始播——Material 的两段式（按住悬停、松手继续）\n  需要状态机，轻量版从 pointerdown 播完即可。\n- 别用 box-shadow 或伪元素做扩散——多个涟漪叠加时伪元素只有两个名额，\n  且无法按点击点定位。\n- 别把涟漪和按压形变绑成同一个效果——两种反馈语言，列表行用涟漪、\n  按钮用形变，一个节点选一种。",
        "skill_rule": "# 点击涟漪 (ripple) · 跨平台动效规范\n性质：反馈 ｜ 平台：both\n\n【核心原理】在点击坐标插一个绝对定位的圆，用 CSS keyframes 放大并淡出，动画结束移除节点。JS 只负责起一个元素。\n\n【硬要求】\n- 宿主必须有 position: relative 和 overflow: hidden（涟漪会超出宿主）。\n- 用 pointerdown 不要用 click —— 涟漪是按压反馈，必须同帧；\n  click 有 300ms 双击判定延迟。\n- 快速连点叠加多个涟漪，不去重。\n- prefers-reduced-motion 下时长压缩即可（全局 token 会自动处理），\n  反馈本身保留 —— 它是\"点到了\"的确认，不是装饰。\n\n【验收标准】\n- 点击元素任意角：圆从点击点扩散覆盖全元素后淡出，节点被移除\n  （1 秒后 el.querySelectorAll('.ripple').length === 0）。\n- 键盘 Tab + Enter 激活：涟漪从中心扩散，不报错。\n- 快速连点 5 次：5 个涟漪同时扩散，各自独立淡出。\n- 深底白字按钮：涟漪是白色的；换成浅底黑字自动变黑。\n- 宿主是圆角元素：涟漪被裁在圆角内（overflow hidden 生效）。\n\n【禁止做法】\n- 别在 pointerup 才开始播——Material 的两段式（按住悬停、松手继续）\n  需要状态机，轻量版从 pointerdown 播完即可。\n- 别用 box-shadow 或伪元素做扩散——多个涟漪叠加时伪元素只有两个名额，\n  且无法按点击点定位。\n- 别把涟漪和按压形变绑成同一个效果——两种反馈语言，列表行用涟漪、\n  按钮用形变，一个节点选一种。",
        "prompt_en": "Core Principle:\nBuild an Origin-Aware Click Ripple using native Pointer Events + CSS keyframes with zero dependencies. Inserts an absolutely positioned circle at the tap/click coordinates, scales and fades it out via CSS `@keyframes`, and removes the node upon completion; JS only spawns and cleans up the element.\n\nImplementation:\n1. CSS:\n   - `.ripple-host { position: relative; overflow: hidden; }`\n   - `.ripple { position: absolute; border-radius: 50%; pointer-events: none; transform: scale(0); opacity: 0.28; animation: ripple 620ms cubic-bezier(0.22, 1, 0.36, 1) forwards; }`\n   - `@keyframes ripple { to { transform: scale(1); opacity: 0; } }`\n2. JS (`pointerdown` listener, zero idle overhead):\n   - `diameter = Math.max(hostWidth, hostHeight) * 2` so clicks from any corner reach the opposite corner.\n   - Position (`left`/`top`) = click point relative to host minus `radius`.\n   - When coordinates are absent (keyboard `Enter` activation where `clientX` is `undefined`), fall back to host center. Check explicitly for `undefined` rather than `e.clientX || center`—when an element touches the left viewport edge, `clientX === 0` is valid and falling back to center is wrong.\n   - Default color is `currentColor` (inherits text color for automatic light/dark adaptation), overridable via `opts.color`.\n   - Insert `span.ripple`, remove on `animationend` (`{ once: true }`), plus a fallback `setTimeout` at `duration + 400` in case the animation is interrupted and `animationend` never fires.\n   - `teardown()`: detach listener and clear all remaining `.ripple` nodes.\n\nHard Constraints:\n- Host must have `position: relative` and `overflow: hidden` (the ripple intentionally extends beyond host bounds).\n- Trigger on `pointerdown`, not `click`—ripples are press feedback that must start on the same frame without `300ms` double-tap delay.\n- Rapid consecutive clicks must layer multiple concurrent ripples without deduplication.\n- Under `prefers-reduced-motion: reduce`, compress duration (handled by global motion tokens) while preserving the feedback itself—it confirms the tap landed rather than being purely decorative.\n\nAcceptance Criteria:\n- Clicking any corner expands a circle from that click point across the entire element, fades out, and removes the node (`el.querySelectorAll('.ripple').length === 0` after 1 second).\n- Activating via keyboard `Tab` + `Enter` expands a ripple from the center with no errors.\n- Clicking rapidly 5 times spawns 5 simultaneous ripples that fade out independently.\n- White text on a dark button yields a white ripple; dark text on a light button automatically yields a dark ripple.\n- Rounded hosts clip the ripple cleanly inside their border radius (`overflow: hidden` takes effect).",
        "dont_do_en": "- Do NOT wait until `pointerup` to start the ripple — Material's two-stage hold-and-release ripple requires a state machine, whereas a lightweight ripple should play directly from `pointerdown`.\n- Do NOT use `box-shadow` or pseudo-elements for ripple expansion — pseudo-elements only provide two slots and cannot be positioned at arbitrary click points.\n- Do NOT combine ripple and press-scale deformation on the same element — they are two distinct feedback languages (list rows use ripple, buttons use scale); pick one per node.",
        "skill_rule_en": "# Origin-Aware Click Ripple (ripple) · Cross-Platform Motion Spec\nNature: Feedback | Layer: motion | Platform: both\n\nCore Principle: Build an Origin-Aware Click Ripple using native Pointer Events + CSS keyframes with zero dependencies. Inserts an absolutely positioned circle at the tap/click coordinates, scales and fades it out via CSS `@keyframes`, and removes the node upon completion; JS only spawns and cleans up the element.\n\nHard Constraints:\n- Host must have `position: relative` and `overflow: hidden` (the ripple intentionally extends beyond host bounds).\n- Trigger on `pointerdown`, not `click`—ripples are press feedback that must start on the same frame without `300ms` double-tap delay.\n- Rapid consecutive clicks must layer multiple concurrent ripples without deduplication.\n- Under `prefers-reduced-motion: reduce`, compress duration (handled by global motion tokens) while preserving the feedback itself—it confirms the tap landed rather than being purely decorative.\n\nAcceptance Criteria:\n- Clicking any corner expands a circle from that click point across the entire element, fades out, and removes the node (`el.querySelectorAll('.ripple').length === 0` after 1 second).\n- Activating via keyboard `Tab` + `Enter` expands a ripple from the center with no errors.\n- Clicking rapidly 5 times spawns 5 simultaneous ripples that fade out independently.\n- White text on a dark button yields a white ripple; dark text on a light button automatically yields a dark ripple.\n- Rounded hosts clip the ripple cleanly inside their border radius (`overflow: hidden` takes effect).\n\nDo NOT Do:\n- Do NOT wait until `pointerup` to start the ripple — Material's two-stage hold-and-release ripple requires a state machine, whereas a lightweight ripple should play directly from `pointerdown`.\n- Do NOT use `box-shadow` or pseudo-elements for ripple expansion — pseudo-elements only provide two slots and cannot be positioned at arbitrary click points.\n- Do NOT combine ripple and press-scale deformation on the same element — they are two distinct feedback languages (list rows use ripple, buttons use scale); pick one per node."
      }
    },
    {
      "id": "rubber-band",
      "name": "橡胶越界阻尼",
      "name_en": "iOS Rubber-Band Overscroll",
      "layer": "motion",
      "nature": "权重",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-rubber + .mk-rubber / rubberBand(x, dim, c) / rubberClamp(v, min, max, dim, c)",
      "source": "iOS UIScrollView 越界橡胶阻尼公式 b(x,d,c) = x·c·d / (d + c·x) + Vaul / M3 Expressive 弹性边界",
      "source_en": "iOS UIScrollView / Vaul (hyperbolic rubber-band constant c = 0.55)",
      "file": "effects/rubber-band.md",
      "summary": "拖到内容边界外时不硬停（clamp），而是用双曲阻尼让内容越拉越重、永远拉不到头，松手后带轻微过冲弹回界内。",
      "summary_en": "Authentic UIScrollView hyperbolic overscroll damping (c = 0.55) that grows asymptotically heavier past bounds and springs cleanly back on release.",
      "problem": "**硬停像撞墙，线性减半像假物理。** 当用户把横向卡片轨、抽屉或列表拖到头时，直接截断（`clamp`）会让手势突然失联，用户以为页面卡死了；简单乘 `0.5` 虽然动了，但拉出整个屏幕还能继续线性走，完全没有“快到极限了”的阻力递增感。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| iOS UIScrollView 通行逆向双曲阻尼 `b(x, d, c) = (x * c * d) / (d + c * x)` | 完整的弹簧速度积分器与惯性滑行（deceleration rate） |\n| 拖动中关过渡（跟手零延迟）、松手开回弹过渡的两段手感 | 双向二维自由拖拽（单轴更克制，另一轴还给页面滚动） |\n| 仅写单 CSS 变量，transform 由样式表拼装 | 手写 inline `transform` 覆盖同节点其他效果 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 阻尼系数 `c` | `0.55` | iOS 原生实测逆向值。起点斜率即 `c`（刚越界时手指走 1px 内容走 0.55px，立刻变重）；低于 0.35 几乎拉不动，高于 0.75 太轻像没撞边 |\n| 渐近上限 `dim` | 容器该轴尺寸 | $x \\to \\infty$ 时位移严格趋近 `dim`，无论拉多远都不会把内容甩出可视区 |\n| 回弹时长 | `--mk-dur-4` = 380ms | 区块级位移回弹，配合 `ease-snap` 轻微过冲读成“被弹回来”而非“被拽回来” |\n| 轴向分工 | `touch-action: pan-y`（横拖） | 横拖由控制器接管，竖滑原样留给页面滚动，避免锁死整页 |",
      "implementation": "```\nsrc/core/rubber.js:18   RUBBER_C = 0.55\nsrc/core/rubber.js:26   rubberBand(x, dim, c)       纯函数，奇函数映射\nsrc/core/rubber.js:36   rubberClamp(v, min, max, d) 纯函数，界内直通、界外阻尼\nsrc/core/rubber.js:53   rubber(el, { axis, bounds, onSettle })  写 --mk-rb（px）\nstyles/motion.css       .mk-rubber / .mk-rubber.is-dragging\n```",
      "degradation": "**走 `motion` 档：减，不关。**\n\n拖拽本身是操作方式不能关；`prefers-reduced-motion: reduce` 下全局时长压短，并将回弹曲线从 `ease-snap` 切换为无过冲的 `ease-out`，保留界内落位但去掉弹跳。",
      "pitfalls": "**① 直接用 `Math.sqrt(x)` 或 `x * 0.5` 冒充阻尼。**\n`x * 0.5` 没有上界，拉远了会把整块内容拖飞；`Math.sqrt(x)` 在 $x=0$ 处导数为无穷大，越界瞬间会猛地往前蹿一下。双曲公式在 $x=0$ 导数恒为 `c = 0.55`、无穷远处趋近 `dim`，两端都光滑。\n\n**② `pointercancel` 当成正常松手提交了位移。**\n浏览器抢走手势时用户没松手，必须回到拖动前的位置 `start`（再钳进界内），不能把中途位移提交给 `onSettle`。\n\n**③ 内容比容器短（`min > max`）时把界外算反。**\n必须先把上限归一化 `hi = Math.max(min, max)`，否则内容短于容器时左右拖会直接跳变。\n\n**④ 拖动期间忘了关 `transition`。**\n拖的时候挂着 `380ms` 过渡会让内容一直慢半拍黏在手指后面；必须按下加 `.is-dragging { transition: none }`，松手再撤掉。\n\n---",
      "ai_assets": {
        "prompt": "实现 iOS 风格的越界橡胶阻尼（Rubber-banding / Elastic Overscroll），零动画库依赖。\n\n原理一句话：界内 1:1 跟手，界外用双曲阻尼公式 b(x, d, c) = (|x| * c * d) / (d + c * |x|) 把越界位移压成\"越拉越重、永远不超过容器尺寸 d\"，拖动中关过渡、松手开弹性回弹。\n\n做法：\n1. 纯函数（方便单测）：\n   - rubberBand(x, dim, c = 0.55)：\n     若 dim <= 0 或 !Number.isFinite(x) 或 x === 0 返回 0；\n     r = (Math.abs(x) * c * dim) / (dim + c * Math.abs(x))；\n     返回 x < 0 ? -r : r（奇函数，保留方向）。\n   - rubberClamp(v, min, max, dim, c = 0.55)：\n     hi = Math.max(min, max)；\n     v < min 返回 min - rubberBand(min - v, dim, c)；\n     v > hi  返回 hi + rubberBand(v - hi, dim, c)；\n     否则原样返回 v。\n2. 指针控制（横拖为例，纵拖对称）：\n   - 容器设 touch-action: pan-y; user-select: none;（竖滑留给页面滚动）。\n   - pointerdown：测量容器宽度 dim 与可拖区间 [min, max]（默认 [Math.min(0, dim - scrollWidth), 0]），记录起点 start = pos，加 .is-dragging（transition: none）。\n   - pointermove：计算 rubberClamp(start + delta, min, max, dim)，写入 CSS 变量 --rb（px），样式层用 transform: translate3d(var(--rb, 0px), 0, 0) 消费。\n   - pointerup / pointercancel：撤掉 .is-dragging（恢复 transition: transform 380ms cubic-bezier(0.34, 1.56, 0.64, 1)），若为 pointercancel 则 raw = start 否则 raw = start + delta，将 pos 钳回 [min, Math.max(min, max)] 并写入 --rb 触发回弹。\n\n硬要求：\n- 阻尼常数 c 固定 0.55，渐近上限必须取容器该轴真实尺寸 dim。\n- 拖动中必须关掉 transition，松手瞬间再恢复 —— 不能用 rAF 逐帧补间回弹。\n- pointercancel 必须回退到拖动前的位置，绝不能提交中途位移。\n- prefers-reduced-motion: reduce 下保留拖拽能力，仅把回弹缓动改为无过冲 ease-out 且压缩时长。\n\n验收：\n- rubberBand(0, 300) === 0；rubberBand(-x, 300) === -rubberBand(x, 300)。\n- 越界拉动 10px 时实际位移约 5.4px（斜率趋近 0.55）；拉动 10000px 时位移严格小于容器宽度 dim。\n- 界内拖动 1:1 跟手零延迟；松手后越界部分在 380ms 内平滑弹回边界。\n- 触发 pointercancel 时回到拖动前位置。",
        "dont_do": "- 别用 `x * 0.5` 线性折半 —— 没有上限，继续拖会把内容拖出屏幕且缺少阻力递增感。\n- 别用 `Math.sqrt(x)` —— 零点导数无穷大，刚过边界时会突然猛蹿一下。\n- 别给横向拖拽容器设 `touch-action: none` —— 会把移动端页面的正常上下滚动锁死。",
        "skill_rule": "# 橡胶越界阻尼 (rubber-band) · 跨平台动效规范\n性质：权重 ｜ 平台：both\n\n【核心原理】界内 1:1 跟手，界外用双曲阻尼公式 b(x, d, c) = (|x| * c * d) / (d + c * |x|) 把越界位移压成\"越拉越重、永远不超过容器尺寸 d\"，拖动中关过渡、松手开弹性回弹。\n\n【硬要求】\n- 阻尼常数 c 固定 0.55，渐近上限必须取容器该轴真实尺寸 dim。\n- 拖动中必须关掉 transition，松手瞬间再恢复 —— 不能用 rAF 逐帧补间回弹。\n- pointercancel 必须回退到拖动前的位置，绝不能提交中途位移。\n- prefers-reduced-motion: reduce 下保留拖拽能力，仅把回弹缓动改为无过冲 ease-out 且压缩时长。\n\n【验收标准】\n- rubberBand(0, 300) === 0；rubberBand(-x, 300) === -rubberBand(x, 300)。\n- 越界拉动 10px 时实际位移约 5.4px（斜率趋近 0.55）；拉动 10000px 时位移严格小于容器宽度 dim。\n- 界内拖动 1:1 跟手零延迟；松手后越界部分在 380ms 内平滑弹回边界。\n- 触发 pointercancel 时回到拖动前位置。\n\n【禁止做法】\n- 别用 `x * 0.5` 线性折半 —— 没有上限，继续拖会把内容拖出屏幕且缺少阻力递增感。\n- 别用 `Math.sqrt(x)` —— 零点导数无穷大，刚过边界时会突然猛蹿一下。\n- 别给横向拖拽容器设 `touch-action: none` —— 会把移动端页面的正常上下滚动锁死。",
        "prompt_en": "Core Principle:\nBuild zero-library iOS-style Rubber-Band Elastic Overscroll. Tracks 1:1 inside bounds and applies the hyperbolic damping formula `b(x, d, c) = (|x| * c * d) / (d + c * |x|)` outside bounds so resistance increases progressively and displacement never exceeds container dimension `d`; CSS transitions are turned off during drag and re-enabled on release for elastic snap-back.\n\nImplementation:\n1. Pure functions (unit-testable):\n   - `rubberBand(x, dim, c = 0.55)`: if `dim <= 0` or `!Number.isFinite(x)` or `x === 0`, return `0`; `r = (Math.abs(x) * c * dim) / (dim + c * Math.abs(x))`; return `x < 0 ? -r : r` (odd function preserving sign).\n   - `rubberClamp(v, min, max, dim, c = 0.55)`: `hi = Math.max(min, max)`; if `v < min`, return `min - rubberBand(min - v, dim, c)`; if `v > hi`, return `hi + rubberBand(v - hi, dim, c)`; otherwise return `v`.\n2. Pointer controller (horizontal drag shown; vertical is symmetric):\n   - Container styles: `touch-action: pan-y; user-select: none;` (preserve vertical page scroll).\n   - `pointerdown`: measure container width `dim` and draggable range `[min, max]` (default `[Math.min(0, dim - scrollWidth), 0]`), record `start = pos`, and add `.is-dragging` (`transition: none`).\n   - `pointermove`: compute `rubberClamp(start + delta, min, max, dim)` and write `--rb` in `px`, consumed via `transform: translate3d(var(--rb, 0px), 0, 0)`.\n   - `pointerup` / `pointercancel`: remove `.is-dragging` (restoring `transition: transform 380ms cubic-bezier(0.34, 1.56, 0.64, 1)`), set `raw = start` on `pointercancel` or `raw = start + delta` on `pointerup`, clamp `pos` back to `[min, Math.max(min, max)]`, and write `--rb` to trigger snap-back.\n\nHard Constraints:\n- Damping constant `c` is fixed at `0.55`, and the asymptotic cap must be the container's true dimension `dim` along that axis.\n- Must disable `transition` while dragging and restore it immediately on release—never use frame-by-frame `rAF` tweening for snap-back.\n- `pointercancel` must revert to the pre-drag position and never commit mid-drag displacement.\n- Under `prefers-reduced-motion: reduce`, preserve drag capability, but switch snap-back easing to non-overshooting `ease-out` with compressed duration.\n\nAcceptance Criteria:\n- `rubberBand(0, 300) === 0`; `rubberBand(-x, 300) === -rubberBand(x, 300)`.\n- Pulling `10px` past the bound yields `~5.4px` displacement (slope approaching `0.55`); pulling `10000px` remains strictly less than container width `dim`.\n- In-bounds dragging tracks 1:1 with zero lag; releasing past bounds snaps smoothly back within `380ms`.\n- Triggering `pointercancel` restores the pre-drag position.",
        "dont_do_en": "- Do NOT use linear halving like `x * 0.5` — it has no upper limit, allows dragging content off-screen, and lacks progressive resistance.\n- Do NOT use `Math.sqrt(x)` — its derivative at zero is infinite, causing a sudden lurch right as you cross the boundary.\n- Do NOT set `touch-action: none` on a horizontally draggable container — it locks normal vertical page scrolling on mobile.",
        "skill_rule_en": "# iOS Rubber-Band Overscroll (rubber-band) · Cross-Platform Motion Spec\nNature: Weight | Layer: motion | Platform: both\n\nCore Principle: Build zero-library iOS-style Rubber-Band Elastic Overscroll. Tracks 1:1 inside bounds and applies the hyperbolic damping formula `b(x, d, c) = (|x| * c * d) / (d + c * |x|)` outside bounds so resistance increases progressively and displacement never exceeds container dimension `d`; CSS transitions are turned off during drag and re-enabled on release for elastic snap-back.\n\nHard Constraints:\n- Damping constant `c` is fixed at `0.55`, and the asymptotic cap must be the container's true dimension `dim` along that axis.\n- Must disable `transition` while dragging and restore it immediately on release—never use frame-by-frame `rAF` tweening for snap-back.\n- `pointercancel` must revert to the pre-drag position and never commit mid-drag displacement.\n- Under `prefers-reduced-motion: reduce`, preserve drag capability, but switch snap-back easing to non-overshooting `ease-out` with compressed duration.\n\nAcceptance Criteria:\n- `rubberBand(0, 300) === 0`; `rubberBand(-x, 300) === -rubberBand(x, 300)`.\n- Pulling `10px` past the bound yields `~5.4px` displacement (slope approaching `0.55`); pulling `10000px` remains strictly less than container width `dim`.\n- In-bounds dragging tracks 1:1 with zero lag; releasing past bounds snaps smoothly back within `380ms`.\n- Triggering `pointercancel` restores the pre-drag position.\n\nDo NOT Do:\n- Do NOT use linear halving like `x * 0.5` — it has no upper limit, allows dragging content off-screen, and lacks progressive resistance.\n- Do NOT use `Math.sqrt(x)` — its derivative at zero is infinite, causing a sudden lurch right as you cross the boundary.\n- Do NOT set `touch-action: none` on a horizontally draggable container — it locks normal vertical page scrolling on mobile."
      }
    },
    {
      "id": "scramble",
      "name": "赛博乱序解码",
      "name_en": "Cyber Text Scramble Decode",
      "layer": "motion",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-scramble / scrambleText(el, { duration, glyphs }) / scrambleFrame()",
      "source": "Aceternity / Vercel 赛博终端乱码解码（前 35% 全乱码 + 左到右定格 + 仅改 textContent 零重排）",
      "source_en": "Terminal / sci-fi decryption text (deterministic frame function + tabular-nums)",
      "file": "effects/scramble.md",
      "summary": "标题或数字从一串跳动的随机符号里自左向右逐字解码定格成正文，每帧只写 `textContent` 不碰 DOM 结构，搭配等宽字体零宽度抖动。",
      "summary_en": "Deterministic left-to-right glyph decoding from noise to final copy by updating textContent only — zero DOM thrash, CJK-safe, and width-stable.",
      "problem": "**科技/开发工具类的 Hero 标题、状态标签或版本号需要一眼抓住注意力的“解码感”，但如果拆成几十个 DOM 节点逐帧动画又重又容易把整行文字推来推去。** 纯文本节点逐帧替换字符 + 等宽字，兼顾极高视觉辨识度与极低性能开销。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 经典终端解密节奏：前 35% 全乱码、后 65% 从左到右依次定格 | 逐字符创建几十个 `<span>` 触发布局计算 |\n| 确定性纯函数 `scrambleFrame(text, p, seed)`，每个字符错开相位 | 整行字符同步跳动像一块砖 |\n| 按 Unicode 码点 `[...text]` 切分，不劈开中文或 emoji | `text.split('')` 破坏代理对字符 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 前置乱码期 | `0 ~ 0.35` | 开头留 35% 全乱码才真的像“正在破译”；直接从 0 开始定格会显得第一帧没坏彻底 |\n| 总时长 `duration` | `900ms` | 短于 500ms 看不清字符跳动，长于 1400ms 会拖慢用户读懂标题 |\n| 空白保留 | `' '` / `'\\n'` 原样保留 | 保留单词边界与换行结构，防止整句解码期间突然折行跳动 |\n| 末帧兜底 | `p >= 1` 强制写回原文 | 防止最后一帧精度误差残留一个乱码字符 |",
      "implementation": "```\nsrc/core/scramble.js:24  scrambleFrame(text, p, seed, glyphs)  纯函数，已覆盖 7 项单测\nsrc/core/scramble.js:70  scrambleText(el, { duration, glyphs }) rAF 驱动，原文存 WeakMap\n```",
      "degradation": "**走 `motion` 档：减，不关（减弱动效直接显示原文）。**\n\n`prefers-reduced-motion: reduce` 下跳过所有乱码帧，直接将 `el.textContent` 写为最终原文，零闪烁、立即可读。",
      "pitfalls": "**① 没用等宽字体（或没锁宽度）导致乱码跳动时整行左右狂抖。**\n`W` 和 `i` 在比例字体下宽度差一倍，每秒跳 24 次会把旁边元素推得像地震；必须配 `font-family: ui-monospace, ...` 或 `font-variant-numeric: tabular-nums`。\n\n**② 和框架模板双绑（如 Vue `{{ text }}`）抢写同一个节点的 `textContent`。**\nJS 每帧写 `textContent`、框架一更新又 patch 回去会互相覆盖；必须把文案管理权交由控制器 `setText()` 或独立指令。\n\n**③ 忘了按码点 `[...text]` 切分导致 emoji 裂成两个乱码。**\n必须用扩展运算符 `[...text]` 或 `Array.from(text)`，且空格与换行绝不替换成乱码。\n\n---",
      "ai_assets": {
        "prompt": "实现赛博终端风格的乱序解码文字动效（Scramble Text），零动画库依赖。\n\n原理一句话：纯函数按进度 p（0..1）将文本前 35% 保持全乱码、后 65% 从左到右依次定格，rAF 每帧仅改 textContent 不增删 DOM 节点，配合等宽字体零重排。\n\n做法：\n1. 纯函数 scrambleFrame(text, p, seed = 0, glyphs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#$%&@*+=<>/\\\\|')：\n   - 按码点切分 chars = [...text]（禁止 split('') 劈开 emoji）。\n   - 每个字符的定格时刻 settle(i) = 0.35 + (i / Math.max(1, n - 1)) * 0.65。\n   - 遍历 chars：空格与换行原样保留；p >= settle(i) 输出原字符；否则按错相索引 k = (seed * 31 + i * 17 + Math.floor(p * 24) * 7) % glyphs.length 取乱码字符。\n2. 控制器 scrambleText(el, { duration = 900 })：\n   - 用 WeakMap 保存原始文本（不污染 DOM 属性）。\n   - replay()：若 prefers-reduced-motion: reduce 直接写原文返回；否则启动 rAF 计算 p = Math.min(1, (now - t0) / duration)，调用 scrambleFrame 写入 el.textContent；p >= 1 时强制写回原始文本并停帧。\n   - 提供 setText(next) 与 stop()（卸载时 cancelAnimationFrame 并还原原文）。\n\n硬要求：\n- 目标文本容器必须使用等宽字体（monospace）或固定宽度，防止字符宽度变化引起整行左右抖动。\n- 空格与换行必须原样保留，不得替换为乱码字符。\n- 末帧必须强制写回精确原文，不允许残留乱码。\n- prefers-reduced-motion: reduce 下跳过解码直接呈现原文。\n\n验收：\n- p = 0 时除空格外全为乱码且字符总长度与原文完全一致；p = 0.6 时左侧已定格、右侧仍在跳动；p = 1 时 100% 还原原文。\n- 中英混排与含 emoji 文本解码不出现半个乱码字符。\n- 动画全程无布局宽度跳动，结束后 rAF 停止。",
        "dont_do": "- 别把每个字符拆成独立 `<span>` 用 CSS 动画替换 —— DOM 节点膨胀且没必要，单节点改 `textContent` 最轻。\n- 别让所有字符用同一个随机索引 —— 整行同步跳动看起来像一块闪烁的砖头。\n- 别在比例字体段落里直接套用而不锁宽 —— 会导致整行剧烈左右晃动。",
        "skill_rule": "# 赛博乱序解码 (scramble) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】纯函数按进度 p（0..1）将文本前 35% 保持全乱码、后 65% 从左到右依次定格，rAF 每帧仅改 textContent 不增删 DOM 节点，配合等宽字体零重排。\n\n【硬要求】\n- 目标文本容器必须使用等宽字体（monospace）或固定宽度，防止字符宽度变化引起整行左右抖动。\n- 空格与换行必须原样保留，不得替换为乱码字符。\n- 末帧必须强制写回精确原文，不允许残留乱码。\n- prefers-reduced-motion: reduce 下跳过解码直接呈现原文。\n\n【验收标准】\n- p = 0 时除空格外全为乱码且字符总长度与原文完全一致；p = 0.6 时左侧已定格、右侧仍在跳动；p = 1 时 100% 还原原文。\n- 中英混排与含 emoji 文本解码不出现半个乱码字符。\n- 动画全程无布局宽度跳动，结束后 rAF 停止。\n\n【禁止做法】\n- 别把每个字符拆成独立 `<span>` 用 CSS 动画替换 —— DOM 节点膨胀且没必要，单节点改 `textContent` 最轻。\n- 别让所有字符用同一个随机索引 —— 整行同步跳动看起来像一块闪烁的砖头。\n- 别在比例字体段落里直接套用而不锁宽 —— 会导致整行剧烈左右晃动。",
        "prompt_en": "Core Principle:\nBuild zero-library Cyber Terminal Text Scramble Decode. A pure function maps progress `p` (`0..1`) so text remains fully scrambled for the first `35%` and settles left-to-right over the remaining `65%`, updating `textContent` in `rAF` without adding/removing DOM nodes and paired with monospace typography for zero reflow.\n\nImplementation:\n1. Pure function `scrambleFrame(text, p, seed = 0, glyphs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#$%&@*+=<>/\\|')`:\n   - Split by code points with `chars = [...text]` (never `split('')`, which splits emojis).\n   - Per-character settle threshold: `settle(i) = 0.35 + (i / Math.max(1, n - 1)) * 0.65`.\n   - Iterate `chars`: preserve spaces and newlines verbatim; output original character if `p >= settle(i)`; otherwise select glyph at staggered index `k = (seed * 31 + i * 17 + Math.floor(p * 24) * 7) % glyphs.length`.\n2. Controller `scrambleText(el, { duration = 900 })`:\n   - Store the original text in a `WeakMap` (never pollute DOM attributes).\n   - `replay()`: if `prefers-reduced-motion: reduce`, write original text immediately and return; otherwise run `rAF` with `p = Math.min(1, (now - t0) / duration)`, write `scrambleFrame` to `el.textContent`, and at `p >= 1` force-write the exact original text and stop the loop.\n   - Expose `setText(next)` and `stop()` (which calls `cancelAnimationFrame` and restores original text on unmount).\n\nHard Constraints:\n- Target text container must use a `monospace` font or fixed width to prevent character-width changes from jittering the line horizontally.\n- Spaces and newlines must be preserved verbatim and never replaced with scramble glyphs.\n- The final frame must force-write the exact original text, leaving zero leftover glyphs.\n- Under `prefers-reduced-motion: reduce`, skip decoding and show the original text directly.\n\nAcceptance Criteria:\n- At `p = 0`, all non-whitespace characters are scrambled and total character count matches the original; at `p = 0.6`, the left portion is settled while the right is still cycling; at `p = 1`, 100% of the original text is restored.\n- Mixed CJK/Latin strings and emojis decode cleanly with zero half-corrupted characters.\n- Zero layout width jitter throughout the animation, and `rAF` stops on completion.",
        "dont_do_en": "- Do NOT split every character into its own `<span>` animated by CSS — it bloats the DOM unnecessarily when updating a single node's `textContent` is lightest.\n- Do NOT use the same random index for every character — having the whole line flash in unison looks like a blinking brick.\n- Do NOT apply this directly to proportional-font paragraphs without locking width — varying character widths will shake the entire line horizontally.",
        "skill_rule_en": "# Cyber Text Scramble Decode (scramble) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: motion | Platform: both\n\nCore Principle: Build zero-library Cyber Terminal Text Scramble Decode. A pure function maps progress `p` (`0..1`) so text remains fully scrambled for the first `35%` and settles left-to-right over the remaining `65%`, updating `textContent` in `rAF` without adding/removing DOM nodes and paired with monospace typography for zero reflow.\n\nHard Constraints:\n- Target text container must use a `monospace` font or fixed width to prevent character-width changes from jittering the line horizontally.\n- Spaces and newlines must be preserved verbatim and never replaced with scramble glyphs.\n- The final frame must force-write the exact original text, leaving zero leftover glyphs.\n- Under `prefers-reduced-motion: reduce`, skip decoding and show the original text directly.\n\nAcceptance Criteria:\n- At `p = 0`, all non-whitespace characters are scrambled and total character count matches the original; at `p = 0.6`, the left portion is settled while the right is still cycling; at `p = 1`, 100% of the original text is restored.\n- Mixed CJK/Latin strings and emojis decode cleanly with zero half-corrupted characters.\n- Zero layout width jitter throughout the animation, and `rAF` stops on completion.\n\nDo NOT Do:\n- Do NOT split every character into its own `<span>` animated by CSS — it bloats the DOM unnecessarily when updating a single node's `textContent` is lightest.\n- Do NOT use the same random index for every character — having the whole line flash in unison looks like a blinking brick.\n- Do NOT apply this directly to proportional-font paragraphs without locking width — varying character widths will shake the entire line horizontally."
      }
    },
    {
      "id": "scroll-fade",
      "name": "滚动边缘羽化",
      "name_en": "Scroll Edge Fade Mask",
      "layer": "motion",
      "nature": "方向",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.scrollFade(el, { axis, edge }) + .mk-scroll-fade",
      "source": "Linear / Vercel 横向标签栏与侧边栏（动态 mask-image 羽化，滚到头自动归零不挡字）",
      "source_en": "Linear / Vercel scrollable tabs (dynamic mask-image stops + ResizeObserver)",
      "file": "effects/scroll-fade.md",
      "summary": "横向标签栏、代码框或可滚动列表只在“还有隐藏内容未滚出”的那一侧自动显现柔和 `mask-image` 渐变羽化，滚到起点或终点时羽化宽度平滑归零，绝不遮挡首尾文字。",
      "summary_en": "Background-agnostic horizontal or vertical mask-image feathering that appears only where overflow remains and smoothly vanishes to 0px at either scroll boundary.",
      "problem": "**可滚动的横向导航条或卡片列表如果不加视觉提示，用户根本不知道右边还能划；但如果用伪元素写死一层纯色遮罩覆盖在两边，不仅换背景色就露馅，滚到最左/最右时还会把第一个或最后一个标签糊掉半截。** 用 `mask-image: linear-gradient(...)` 配合两个按滚动余量实时计算的像素变量，背景换什么颜色都完全透底融合，且滚到头立刻清晰锐利。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| `mask-image` 真实透明通道羽化：底色不管是渐变、网格还是玻璃都能完美融合 | 用实心色伪元素盖边（底色一变立刻露出补丁方块） |\n| 羽化宽度按距离两端余量 `min(edge, pos)` / `min(edge, maxScroll - pos)` 连续渐变归零 | 到头时突然整块 `display: none` 闪掉 |\n| 无溢出（`scrollSize <= clientSize + 1`）时双端自动为 `0px`，绝不误模糊短列表 | 内容本来装得下还给两边糊掉一块 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 羽化带宽 `edge` | 默认 `28px` | 足够柔和暗示“外面还有内容”，又不会像 `64px` 那样把倒数第二个词糊得看不清 |\n| 溢出容差 | `scrollSize - clientSize <= 1` 视为无溢出 | 规避高分屏亚像素舍入导致 `scrollWidth` 比 `clientWidth` 多 `0.5px` 误触发羽化 |\n| 双轴支持 `axis` | `'x'`（横向 `to right`）/ `'y'`（纵向 `to bottom`） | 同一套纯函数覆盖横向 Tab 栏与纵向聊天/目录列表 |\n| 滚动监听 | `{ passive: true }` + `ResizeObserver` | 零阻塞滚屏，窗口缩放时自动重算溢出态 |",
      "implementation": "```\nsrc/core/ui-motion.js:167   scrollFadeStops(pos, size, view, edge)  纯函数，计算首尾羽化像素（可单测）\nsrc/core/ui-motion.js:183   scrollFade(el, { axis, edge })          监听 scroll + ResizeObserver 写 --mk-sf-a / -b\nstyles/motion.css:1475      .mk-scroll-fade                         水平/垂直双轴 mask-image 渐变规则\n```",
      "degradation": "**走 `motion` 层契约：本身为纯静态光学遮罩，无运动晕眩风险，减弱动效下完整保留。**\n\n`scroll-fade` 是直接跟滚动位置绑定的方向视觉线索（非自动播放动画），`prefers-reduced-motion: reduce` 下无需关闭，始终帮助用户感知可滚动方向。",
      "pitfalls": "**① 用实心背景色伪元素叠加两边，结果放在渐变或暗色玻璃卡片上露出两条难看的色块边。**\n必须用 `mask-image` + `-webkit-mask-image` 直接削减内容自身透明度，彻底无视底层背景颜色。\n\n**② 忘了处理窗口缩放（`ResizeObserver`）。**\n宽屏时不溢出、缩窄窗口后突然溢出的列表，如果只在初始化和 `scroll` 时算一次，缩放后右边不会出现羽化提示；必须接 `ResizeObserver`。\n\n**③ 没给 `scrollSize - clientSize` 留 `1px` 亚像素容差。**\n部分浏览器缩放 125% 时明明装得下，但 `scrollWidth` 仍比 `clientWidth` 多 `0.4px`，不留容差会误加微弱虚边。\n\n---",
      "ai_assets": {
        "prompt": "实现零背景耦合的滚动边缘羽化遮罩（Scroll Edge Fade Mask）。\n\n原理一句话：纯函数按滚动位置与两端余量算出首尾羽化像素写入 --sf-a / --sf-b，驱动容器的 mask-image 线性透明渐变；滚到起点或终点时羽化连续归零，底层无论是什么背景色都无缝融合。\n\n做法：\n1. 纯函数 scrollFadeStops(scrollPos, scrollSize, clientSize, edge = 28)：\n   - 若 maxScroll = scrollSize - clientSize <= 1（无溢出或亚像素误差），返回 { start: 0, end: 0 }；\n   - pos = clamp(scrollPos, 0, maxScroll)，rem = maxScroll - pos；\n   - 返回 { start: Math.min(edge, pos), end: Math.min(edge, rem) }。\n2. CSS Mask 规则（同时写 mask-image 与 -webkit-mask-image）：\n   - 横向（默认）：linear-gradient(to right, transparent 0, #000 var(--sf-a, 0px), #000 calc(100% - var(--sf-b, 0px)), transparent 100%)；\n   - 纵向（axis=\"y\"）：方向改为 to bottom；\n   - 隐藏原生滚动条（scrollbar-width: none + ::-webkit-scrollbar { display: none }）保持界面干净。\n3. 控制器：\n   - 绑定 passive scroll 监听与 ResizeObserver，实时调用 scrollFadeStops 并写入 --sf-a / --sf-b；\n   - 初始化立即计算一次，destroy() 解绑监听与断开 ResizeObserver。\n\n硬要求：\n- 必须使用 mask-image 透明遮罩，严禁用写死背景色的伪元素遮盖边缘。\n- 必须同时监听 scroll 与 ResizeObserver，且对 scrollSize - clientSize <= 1 返回双端 0。\n\n验收：\n- 处于最左侧时左缘清晰无羽化、右缘柔和淡出 28px；滚至中间时双侧均有 28px 羽化；滚到最右侧时右缘羽化连续归零不挡尾项文字。\n- 容器置于任意渐变或玻璃背景上边缘均完美透底，无色块补丁；窗口拉宽至无溢出时双侧羽化自动消失。",
        "dont_do": "- 别用 `linear-gradient(to right, #07090d, transparent)` 盖在容器上 —— 换个浅色或渐变底色立刻穿帮。\n- 别在滚到头时用 `if (pos > 0)` 硬切 `0px ↔ 28px` —— 边缘会突然闪一下，按 `Math.min(edge, pos)` 线性过渡才丝滑。\n- 别忘记同时写 `-webkit-mask-image` —— Safari 上只写无前缀在某些版本会失效。",
        "skill_rule": "# 滚动边缘羽化 (scroll-fade) · 跨平台动效规范\n性质：方向 ｜ 平台：both\n\n【核心原理】纯函数按滚动位置与两端余量算出首尾羽化像素写入 --sf-a / --sf-b，驱动容器的 mask-image 线性透明渐变；滚到起点或终点时羽化连续归零，底层无论是什么背景色都无缝融合。\n\n【硬要求】\n- 必须使用 mask-image 透明遮罩，严禁用写死背景色的伪元素遮盖边缘。\n- 必须同时监听 scroll 与 ResizeObserver，且对 scrollSize - clientSize <= 1 返回双端 0。\n\n【验收标准】\n- 处于最左侧时左缘清晰无羽化、右缘柔和淡出 28px；滚至中间时双侧均有 28px 羽化；滚到最右侧时右缘羽化连续归零不挡尾项文字。\n- 容器置于任意渐变或玻璃背景上边缘均完美透底，无色块补丁；窗口拉宽至无溢出时双侧羽化自动消失。\n\n【禁止做法】\n- 别用 `linear-gradient(to right, #07090d, transparent)` 盖在容器上 —— 换个浅色或渐变底色立刻穿帮。\n- 别在滚到头时用 `if (pos > 0)` 硬切 `0px ↔ 28px` —— 边缘会突然闪一下，按 `Math.min(edge, pos)` 线性过渡才丝滑。\n- 别忘记同时写 `-webkit-mask-image` —— Safari 上只写无前缀在某些版本会失效。",
        "prompt_en": "Core Principle:\nBuild a zero-background-coupling Scroll Edge Fade Mask. A pure function computes start/end feathering pixels from scroll position and remaining overflow and writes them to `--sf-a` / `--sf-b`, driving a linear transparent CSS `mask-image` gradient; at the start or end edge, feathering shrinks continuously to `0`, blending seamlessly over any backdrop.\n\nImplementation:\n1. Pure function `scrollFadeStops(scrollPos, scrollSize, clientSize, edge = 28)`:\n   - If `maxScroll = scrollSize - clientSize <= 1` (no overflow or subpixel rounding tolerance), return `{ start: 0, end: 0 }`.\n   - `pos = clamp(scrollPos, 0, maxScroll)`, `rem = maxScroll - pos`.\n   - Return `{ start: Math.min(edge, pos), end: Math.min(edge, rem) }`.\n2. CSS Mask rules (include both `mask-image` and `-webkit-mask-image`):\n   - Horizontal (default): `linear-gradient(to right, transparent 0, #000 var(--sf-a, 0px), #000 calc(100% - var(--sf-b, 0px)), transparent 100%)`.\n   - Vertical (`axis=\"y\"`): change gradient direction to `to bottom`.\n   - Hide native scrollbars (`scrollbar-width: none` + `::-webkit-scrollbar { display: none }`) to keep the edge clean.\n3. Controller:\n   - Attach a `passive` `scroll` listener and a `ResizeObserver`, calling `scrollFadeStops` and writing `--sf-a` / `--sf-b`.\n   - Compute once immediately on init; `destroy()` unbinds listeners and disconnects the `ResizeObserver`.\n\nHard Constraints:\n- Must use transparent `mask-image`; never cover edges with pseudo-elements using hardcoded background colors.\n- Must observe both `scroll` and `ResizeObserver`, returning `0` for both stops when `scrollSize - clientSize <= 1`.\n\nAcceptance Criteria:\n- At the far left, the left edge is crisp (`0px` fade) while the right edge softens over `28px`; in the middle, both edges fade `28px`; at the far right, the right edge fades continuously down to `0` without obscuring the last item's text.\n- Over any gradient or glass backdrop, edges remain cleanly transparent with no solid color patches; widening the window until overflow disappears removes both fades automatically.",
        "dont_do_en": "- Do NOT overlay `linear-gradient(to right, #07090d, transparent)` on top of the container — it breaks immediately on any light or gradient background.\n- Do NOT hard-switch `0px <-> 28px` with `if (pos > 0)` at scroll endpoints — the edge flashes abruptly instead of gliding smoothly via `Math.min(edge, pos)`.\n- Do NOT forget `-webkit-mask-image` — unprefixed `mask-image` alone fails on some Safari versions.",
        "skill_rule_en": "# Scroll Edge Fade Mask (scroll-fade) · Cross-Platform Motion Spec\nNature: Direction | Layer: motion | Platform: both\n\nCore Principle: Build a zero-background-coupling Scroll Edge Fade Mask. A pure function computes start/end feathering pixels from scroll position and remaining overflow and writes them to `--sf-a` / `--sf-b`, driving a linear transparent CSS `mask-image` gradient; at the start or end edge, feathering shrinks continuously to `0`, blending seamlessly over any backdrop.\n\nHard Constraints:\n- Must use transparent `mask-image`; never cover edges with pseudo-elements using hardcoded background colors.\n- Must observe both `scroll` and `ResizeObserver`, returning `0` for both stops when `scrollSize - clientSize <= 1`.\n\nAcceptance Criteria:\n- At the far left, the left edge is crisp (`0px` fade) while the right edge softens over `28px`; in the middle, both edges fade `28px`; at the far right, the right edge fades continuously down to `0` without obscuring the last item's text.\n- Over any gradient or glass backdrop, edges remain cleanly transparent with no solid color patches; widening the window until overflow disappears removes both fades automatically.\n\nDo NOT Do:\n- Do NOT overlay `linear-gradient(to right, #07090d, transparent)` on top of the container — it breaks immediately on any light or gradient background.\n- Do NOT hard-switch `0px <-> 28px` with `if (pos > 0)` at scroll endpoints — the edge flashes abruptly instead of gliding smoothly via `Math.min(edge, pos)`.\n- Do NOT forget `-webkit-mask-image` — unprefixed `mask-image` alone fails on some Safari versions."
      }
    },
    {
      "id": "seg",
      "name": "分段控件滑动",
      "name_en": "Sliding Segmented Control",
      "layer": "motion",
      "nature": "连续",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-seg + .mk-seg / .mk-seg__pill / .mk-seg__opt",
      "source": "iOS UISegmentedControl 的胶囊滑块（离散选项 + 连续位移，单真源驱动）",
      "source_en": "iOS UISegmentedControl (single CSS index variable + overshoot curve)",
      "file": "effects/seg.md",
      "summary": "多个等宽互斥选项共用一块背景胶囊，切换时胶囊通过单个 CSS 索引变量连续滑到目标格，不重排、不量像素。",
      "summary_en": "Shared background pill gliding smoothly across equal-width options via a single CSS index variable with subtle overshoot — zero pixel measurement.",
      "problem": "**互斥 Tab 切换如果只是瞬间换底色，用户的视线会断。** 尤其在 3–5 格并排切换（日/周/月、列表/网格）时，一块实体胶囊从旧选项滑到新选项，能让用户一眼确认「还是同一组开关，只是状态换了位置」，同时天然传达“多选一”的互斥关系。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| iOS UISegmentedControl 的实体滑块在槽内连续平移 | 按住滑块跨格拖拽与轻微挤压形变（那属于 `detent` 权重类） |\n| 索引单真源：`--mk-seg-i` / `--mk-seg-n` 驱动 `translateX(calc(i * 100%))` | 用 JS 读取 `offsetLeft` / `getBoundingClientRect` 动态改 `width` 和 `left`（等宽场景下完全多余，且窗口缩放易错位） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 滑块宽度 | `calc((100% - 2 * padding) / n)` | 由格数 `n` 直接算出，响应式缩放零 JS 监听 |\n| 位移公式 | `translate3d(calc(i * 100%), 0, 0)` | 百分比相对滑块自身宽度，第 `i` 格精准对齐第 `i` 栏，纯合成器层运动 |\n| 过渡时长 | `--mk-dur-2` = 160ms–240ms | 高频切换控件必须干脆，超过 280ms 连续点击会显得拖沓 |\n| 状态真源 | `dataset.value` + `cur` 闭环 | 只在 `next !== cur` 时重绘并触发 `onChange`，杜绝重复点击触发无意义回调 |",
      "implementation": "```\nsrc/core/seg.js:21    segIndexAt(x, width, n)   纯函数（与 detent 共用刻度数学）\nsrc/core/seg.js:42    segmented(el, { onChange })  绑定点击、写 --mk-seg-n / --mk-seg-i、同步 .is-on 与 dataset.value\nstyles/motion.css     .mk-seg / .mk-seg__pill / .mk-seg__opt\n```\n\n所有选项自动补齐 `type=\"button\"` 和 `role=\"tab\"`，确保表单内点击不会误触 submit 且键盘可达。",
      "degradation": "**走 `motion` 档：减，不关。**\n\n`prefers-reduced-motion: reduce` 下胶囊位移时长压到 `1ms`，切换变成瞬时高亮到位——状态指示依然清晰，只是去掉滑动过程。",
      "pitfalls": "**① 用 `left` 而不是 `transform: translateX` 移动滑块。**\n改 `left` 每帧触发重排；在等宽槽里，滑块自身宽就是 1 格宽，直接 `translate3d(calc(var(--seg-i) * 100%), 0, 0)` 既精准又全程走合成器。\n\n**② 按钮没写 `type=\"button\"` 导致放在 `<form>` 里一点就提交表单。**\n初始化时必须检查并补上 `type=\"button\"`。\n\n**③ 外部程序调用 `select(i)` 时意外再次触发 `onChange` 造成死循环。**\n双向绑定场景下需要 `select(i, silent = true)` 通道：同步视觉与 `dataset.value`，但不向外派发变更事件。\n\n**④ 滑块 `z-index` 压住文字或拦截点击。**\n滑块 `.pill` 必须设 `pointer-events: none` 且位于选项文字下方（选项设 `position: relative; z-index: 1`）。\n\n---",
      "ai_assets": {
        "prompt": "实现一个 iOS 风格的分段控件（Segmented Control），支持任意数量等宽选项的连续胶囊滑动切换。\n\n原理一句话：位置是离散的索引（0..n-1），视觉是连续的合成器位移——容器写入格数 --seg-n 与当前索引 --seg-i，滑块纯靠 CSS 算出宽度并 translate3d(calc(var(--seg-i) * 100%), 0, 0) 平移，零像素测量。\n\n做法：\n1. 结构：一个相对定位容器，内含 1 个绝对定位滑块元素 + N 个等宽按钮选项（CSS Grid: grid-template-columns: repeat(var(--seg-n), 1fr)）。\n2. 滑块样式：\n   - position: absolute; top: 4px; bottom: 4px; left: 4px; pointer-events: none;\n   - width: calc((100% - 8px) / var(--seg-n));\n   - transform: translate3d(calc(var(--seg-i, 0) * 100%), 0, 0);\n   - transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);\n3. 选项按钮：\n   - 必须有 type=\"button\" 和 role=\"tab\"（以及 aria-selected），position: relative; z-index: 1;\n   - 选中态切换文字高亮色，与滑块同步。\n4. 状态管理：\n   - 索引钳制在 0..n-1；仅当目标索引 !== 当前索引时更新 --seg-i、选中类与 onChange 回调。\n   - 提供编程式更新入口 select(index, silent)，silent=true 时只同步视图不触发 onChange。\n\n硬要求：\n- 严禁用 JS 测量 offsetLeft/getBoundingClientRect 来定位等宽滑块（窗口缩放会错位）。\n- 严禁动画 left 属性，位移必须走 transform: translate3d。\n- prefers-reduced-motion: reduce 下将滑块 transition-duration 压到 1ms（瞬时切位，不可隐藏滑块）。\n\n验收：\n- 点击任意选项，胶囊在 200ms 内平滑滑到该选项正下方，无跳动或像素偏差。\n- 缩放浏览器窗口宽度时，滑块自动贴合当前选中格，无需 resize 监听。\n- 重复点击当前已选中项不重复触发 onChange。\n- 放在 <form> 中点击切换不会触发表单提交。",
        "dont_do": "- 别为了这个控件引入 Framer Motion `layoutId` —— 等宽槽里一行 `translate3d(calc(i * 100%), 0, 0)` 比运行时 FLIP 更稳、更轻、零抖动。\n- 别让滑块接收指针事件（漏 `pointer-events: none` 会吞掉点击）。\n- 别在非等宽、字数差异极大的标签栏强行套用等宽公式 —— 非等宽场景应改用测量或 View Transitions。",
        "skill_rule": "# 分段控件滑动 (seg) · 跨平台动效规范\n性质：连续 ｜ 平台：both\n\n【核心原理】位置是离散的索引（0..n-1），视觉是连续的合成器位移——容器写入格数 --seg-n 与当前索引 --seg-i，滑块纯靠 CSS 算出宽度并 translate3d(calc(var(--seg-i) * 100%), 0, 0) 平移，零像素测量。\n\n【硬要求】\n- 严禁用 JS 测量 offsetLeft/getBoundingClientRect 来定位等宽滑块（窗口缩放会错位）。\n- 严禁动画 left 属性，位移必须走 transform: translate3d。\n- prefers-reduced-motion: reduce 下将滑块 transition-duration 压到 1ms（瞬时切位，不可隐藏滑块）。\n\n【验收标准】\n- 点击任意选项，胶囊在 200ms 内平滑滑到该选项正下方，无跳动或像素偏差。\n- 缩放浏览器窗口宽度时，滑块自动贴合当前选中格，无需 resize 监听。\n- 重复点击当前已选中项不重复触发 onChange。\n- 放在 <form> 中点击切换不会触发表单提交。\n\n【禁止做法】\n- 别为了这个控件引入 Framer Motion `layoutId` —— 等宽槽里一行 `translate3d(calc(i * 100%), 0, 0)` 比运行时 FLIP 更稳、更轻、零抖动。\n- 别让滑块接收指针事件（漏 `pointer-events: none` 会吞掉点击）。\n- 别在非等宽、字数差异极大的标签栏强行套用等宽公式 —— 非等宽场景应改用测量或 View Transitions。",
        "prompt_en": "Core Principle:\nBuild an iOS-style Sliding Segmented Control supporting smooth capsule sliding across any number of equal-width options. Position is a discrete index (`0..n-1`) while visuals use continuous compositor translation: the container writes item count `--seg-n` and active index `--seg-i`, and the slider computes its own width in pure CSS and moves via `translate3d(calc(var(--seg-i) * 100%), 0, 0)` with zero pixel measurement.\n\nImplementation:\n1. Structure: a relatively positioned container holding 1 absolutely positioned slider element + `N` equal-width option buttons (`display: grid; grid-template-columns: repeat(var(--seg-n), 1fr)`).\n2. Slider styles:\n   - `position: absolute; top: 4px; bottom: 4px; left: 4px; pointer-events: none;`\n   - `width: calc((100% - 8px) / var(--seg-n));`\n   - `transform: translate3d(calc(var(--seg-i, 0) * 100%), 0, 0);`\n   - `transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);`\n3. Option buttons:\n   - Must include `type=\"button\"`, `role=\"tab\"`, and `aria-selected`, with `position: relative; z-index: 1;`.\n   - Highlight active text color in sync with the slider.\n4. State management:\n   - Clamp index to `0..n-1`; update `--seg-i`, active class, and `onChange` callback only when `targetIndex !== currentIndex`.\n   - Provide programmatic `select(index, silent)` where `silent = true` syncs the view without firing `onChange`.\n\nHard Constraints:\n- Never measure `offsetLeft` or `getBoundingClientRect()` in JS to position equal-width sliders (breaks on window resize).\n- Never animate `left`; movement must use `transform: translate3d`.\n- Under `prefers-reduced-motion: reduce`, compress slider `transition-duration` to `1ms` (instant snap; never hide the slider).\n\nAcceptance Criteria:\n- Clicking any option smoothly slides the pill underneath it within `200ms` with zero jump or pixel drift.\n- Resizing browser width keeps the pill aligned with the active slot automatically without a `resize` listener.\n- Re-clicking the currently selected option does not re-trigger `onChange`.\n- Clicking inside a `<form>` does not trigger form submission.",
        "dont_do_en": "- Do NOT import Framer Motion `layoutId` just for this control — a single line of `translate3d(calc(i * 100%), 0, 0)` across equal-width slots is lighter, steadier, and jitter-free.\n- Do NOT allow the slider to receive pointer events (omitting `pointer-events: none` swallows clicks).\n- Do NOT force this equal-width formula onto uneven tab bars with vastly different label lengths — variable-width tabs should use measurement or View Transitions instead.",
        "skill_rule_en": "# Sliding Segmented Control (seg) · Cross-Platform Motion Spec\nNature: Continuity | Layer: motion | Platform: both\n\nCore Principle: Build an iOS-style Sliding Segmented Control supporting smooth capsule sliding across any number of equal-width options. Position is a discrete index (`0..n-1`) while visuals use continuous compositor translation: the container writes item count `--seg-n` and active index `--seg-i`, and the slider computes its own width in pure CSS and moves via `translate3d(calc(var(--seg-i) * 100%), 0, 0)` with zero pixel measurement.\n\nHard Constraints:\n- Never measure `offsetLeft` or `getBoundingClientRect()` in JS to position equal-width sliders (breaks on window resize).\n- Never animate `left`; movement must use `transform: translate3d`.\n- Under `prefers-reduced-motion: reduce`, compress slider `transition-duration` to `1ms` (instant snap; never hide the slider).\n\nAcceptance Criteria:\n- Clicking any option smoothly slides the pill underneath it within `200ms` with zero jump or pixel drift.\n- Resizing browser width keeps the pill aligned with the active slot automatically without a `resize` listener.\n- Re-clicking the currently selected option does not re-trigger `onChange`.\n- Clicking inside a `<form>` does not trigger form submission.\n\nDo NOT Do:\n- Do NOT import Framer Motion `layoutId` just for this control — a single line of `translate3d(calc(i * 100%), 0, 0)` across equal-width slots is lighter, steadier, and jitter-free.\n- Do NOT allow the slider to receive pointer events (omitting `pointer-events: none` swallows clicks).\n- Do NOT force this equal-width formula onto uneven tab bars with vastly different label lengths — variable-width tabs should use measurement or View Transitions instead."
      }
    },
    {
      "id": "shader-aurora",
      "name": "WebGL 流体丝绸极光",
      "name_en": "WebGL Liquid Silk Aurora",
      "layer": "webgl",
      "nature": "材质",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.shaderAurora(host, opts) + .mk-shader.mk-shader--aurora",
      "source": "Stripe Mesh Gradient 域扭曲 FBM 极光（原生 WebGL 零 Three.js + DPR 1.5 封顶 + 双停帧 + CSS 渐变兜底）",
      "source_en": "Inigo Quilez domain-warping FBM (native WebGL, 0KB Three.js)",
      "file": "effects/shader-aurora.md",
      "summary": "原生 WebGL 全屏三角形 + 2D Simplex Noise 域扭曲（Domain Warping FBM）渲染多色丝绸极光，指针划过产生柔和流体扰动；零 Three.js 依赖，不支持或切后台时自动停帧或退回 CSS 渐变。",
      "summary_en": "Native WebGL fullscreen-triangle 2D Simplex Noise domain-warping FBM aurora with subtle pointer fluid ripples, DPR 1.5 cap, offscreen halt, and CSS gradient fallback.",
      "problem": "**纯 CSS 极光只能让几个圆形径向渐变来回平移，怎么调都像“几团雾在飘”，做不出 Stripe 官网那种丝绸般的流体褶皱。** 但为了一个背景引入 600KB 的 Three.js 又完全背离零依赖原则。一段 40 行的 GLSL Fragment Shader + 80 行原生 WebGL 封装就能 60fps 跑出电影级流体质感。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 域扭曲 FBM（`q = fbm(p)` 再用 `q` 扭曲第二次 `fbm(p + 1.7*q)`）形成的丝绸流体褶皱 | Three.js / R3F / PixiJS 庞大运行时依赖 |\n| 一个覆盖裁剪空间的大三角形 `(-1,-1), (3,-1), (-1,3)` 单次 draw call | 双三角形矩形（多一道对角线接缝）与 3D 顶点网格 |\n| 四条工程红线：DPR ≤1.5、像素上限 120 万、离屏/后台双停帧、CSS 渐变无缝兜底 | 3× Retina 屏跑满分辨率把笔记本风扇吹起飞 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| DPR 封顶 `dprCap` | `1.5` | 流畅柔和的背景噪声在 1.5× 和 3× 下肉眼几乎无差别，但 GPU 像素着色负载直接下降 75% |\n| 总像素上限 `maxPixels` | `1,200,000` | 防止 4K/5K 超宽屏全屏画布突破显卡填充率造成掉帧，超限时自动等比缩放 |\n| FBM 层数 | `5` octaves | 3 层显得太粗像大色块，7 层以上细节被噪点淹没且移动端片元耗时翻倍 |\n| 指针平滑系数 | `0.08` / 帧 | 流体应比按钮更慢、更有粘滞感，0.08 让光标扰动像手指划过绸缎 |\n| 减弱动效静止帧 | `u_time = 12.0` | 只画 1 帧后彻底停掉循环；取 12s 而非 0s 是因为此时噪声形态更舒展成形 |",
      "implementation": "```\nsrc/core/shader.js:18    cappedDpr(dpr, cap) / canvasSize(w, h, dpr, cap, maxPx)  纯函数\nsrc/core/shader.js:104   AURORA_FRAG                                               域扭曲 FBM GLSL\nsrc/core/shader.js:194   shaderCanvas(host, opts)                                  全屏三角形 + IO/后台停帧 + 资源销毁\nsrc/core/shader.js:322   shaderAurora(host, opts)                                  极光入口\nstyles/webgl.css:29      .mk-shader--aurora                                        首帧未就绪与降级时的 CSS 径向渐变兜底\n```",
      "degradation": "**走 `webgl` 层专属契约：退回渐变 + 静止单帧。**\n\n- `prefers-reduced-motion: reduce`：仅绘制 1 帧静态极光（`u_time = 12`），不启动 `requestAnimationFrame` 循环、不挂指针监听。\n- 浏览器不支持 WebGL / Shader 编译失败 / `webglcontextlost`：隐藏 `<canvas>`，容器自带的 CSS 多层径向渐变立刻顶上，画面不黑屏、版面不塌。",
      "pitfalls": "**① 直接拿 `window.devicePixelRatio` 乘宽高不封顶。**\n在 3× 屏或 5K 显示器上每帧要跑上千万个 FBM 片元，风扇狂转且掉到 20fps；必须同时做 `min(dpr, 1.5)` 与 `maxPixels <= 1.2M` 双封顶。\n\n**② 页面滚过 Hero 后或切后台标签页后 rAF 仍在 60fps 烧 GPU。**\n必须挂 `IntersectionObserver`（滚出视口停帧）与 `visibilitychange`（切后台停帧），做到画面看不见时 0% GPU 占用。\n\n**③ 组件卸载时不调用 `deleteBuffer` / `deleteProgram` / `loseContext()`。**\n浏览器对单页活跃 WebGL 上下文有硬上限（通常 8–16 个），路由切换几次不释放就会把整页后续 WebGL 画布全部干黑。\n\n**④ 画布未画完第 1 帧前露出纯黑块闪一下。**\n容器底色必须先铺好近似配色的 CSS 径向渐变，`<canvas>` 初始 `opacity: 0`，首帧绘制完成后加 `.is-ready` 600ms 柔和淡入。\n\n---",
      "ai_assets": {
        "prompt": "实现零 Three.js 依赖的原生 WebGL 流体丝绸极光背景（Domain-Warped FBM Aurora Shader）。\n\n原理一句话：一个全屏大三角形 + 2D Simplex Noise 域扭曲 5 层 FBM 片元着色器渲染丝绸流体极光，配合 DPR≤1.5 封顶、离屏/后台双停帧、卸载释放上下文与 CSS 渐变兜底。\n\n做法：\n1. 画布尺寸纯函数 canvasSize(cssW, cssH, dpr, cap = 1.5, maxPixels = 1200000)：\n   - s = Math.min(dpr > 0 ? dpr : 1, cap)；若 cssW*s * cssH*s > maxPixels，按 sqrt(maxPixels / px) 等比缩小 s；返回整数宽高（至少 1×1）。\n2. 原生 WebGL 1 管线（powerPreference: 'low-power', depth: false, stencil: false, antialias: false）：\n   - 顶点着色器直接渲染覆盖全屏的单个大三角形 [-1,-1, 3,-1, -1,3]（单次 drawArrays(TRIANGLES, 0, 3)）。\n   - 片元着色器（带 highp/mediump 精度宏保护）：\n     实现 2D simplex noise 与 5 层 fbm(p)；\n     计算指针平滑 uv 距离扰动 md = exp(-dot(m, m) * 7.0)；\n     域扭曲：q = vec2(fbm(p + vec2(0.0, t)), fbm(p + vec2(5.2, 1.3) - t))；\n     n = fbm(p + 1.7 * q + md * 0.55 + vec2(t * 0.6, -t * 0.3))；\n     用 smoothstep 在蓝 / 紫 / 亮绿与深暗底色之间柔和混合输出。\n3. 工程守护与降级：\n   - 容器先铺近似配色的 CSS 多层径向渐变作为首帧与降级底色；<canvas> 初始 opacity: 0，首帧绘制后淡入。\n   - IntersectionObserver 监测离开视口立刻 cancelAnimationFrame，重新进入再续跑；visibilitychange 切后台同步停帧。\n   - 监听 webglcontextlost（preventDefault 并切回 CSS 渐变兜底）。\n   - prefers-reduced-motion: reduce 下仅绘制 u_time = 12.0 的单帧静态画面，不启动 rAF。\n   - destroy() 时断开全部观察者，调用 gl.deleteBuffer / gl.deleteProgram / gl.getExtension('WEBGL_lose_context')?.loseContext() 并移除 canvas。\n\n硬要求：\n- 严禁引入 Three.js / PixiJS / 任何第三方 WebGL 框架。\n- 必须对 DPR（<=1.5）与总像素（<=1.2M）做双封顶。\n- 必须同时具备 IntersectionObserver 离屏停帧、visibilitychange 后台停帧与销毁释放 context。\n- 必须提供 CSS 静态渐变兜底，WebGL 不可用或上下文丢失时绝不黑屏。\n\n验收：\n- 画面呈现丝绸般连续流动的多色极光，鼠标划过产生柔和流体扰动（0.08 粘滞平滑）。\n- 页面滚出该区块或切到其他标签页时，rAF 立即停止。\n- 屏蔽 WebGL 或触发 webglcontextlost 时无缝呈现 CSS 渐变底色，无报错无黑屏。\n- 开启减弱动效后仅绘制静态成形极光帧，CPU/GPU 占用归零。",
        "dont_do": "- 别引入 Three.js 来画一个全屏 2D 片元着色器 —— 99% 的代码都是多余开销。\n- 别在 3× 高分屏上直接 `canvas.width = w * devicePixelRatio` 不封顶 —— 极易发烫掉帧。\n- 别忘记在卸载时释放 WebGL context —— SPA 切页几次就会撞到浏览器上下文上限变黑屏。",
        "skill_rule": "# WebGL 流体丝绸极光 (shader-aurora) · 跨平台动效规范\n性质：材质 ｜ 平台：both\n\n【核心原理】一个全屏大三角形 + 2D Simplex Noise 域扭曲 5 层 FBM 片元着色器渲染丝绸流体极光，配合 DPR≤1.5 封顶、离屏/后台双停帧、卸载释放上下文与 CSS 渐变兜底。\n\n【硬要求】\n- 严禁引入 Three.js / PixiJS / 任何第三方 WebGL 框架。\n- 必须对 DPR（<=1.5）与总像素（<=1.2M）做双封顶。\n- 必须同时具备 IntersectionObserver 离屏停帧、visibilitychange 后台停帧与销毁释放 context。\n- 必须提供 CSS 静态渐变兜底，WebGL 不可用或上下文丢失时绝不黑屏。\n\n【验收标准】\n- 画面呈现丝绸般连续流动的多色极光，鼠标划过产生柔和流体扰动（0.08 粘滞平滑）。\n- 页面滚出该区块或切到其他标签页时，rAF 立即停止。\n- 屏蔽 WebGL 或触发 webglcontextlost 时无缝呈现 CSS 渐变底色，无报错无黑屏。\n- 开启减弱动效后仅绘制静态成形极光帧，CPU/GPU 占用归零。\n\n【禁止做法】\n- 别引入 Three.js 来画一个全屏 2D 片元着色器 —— 99% 的代码都是多余开销。\n- 别在 3× 高分屏上直接 `canvas.width = w * devicePixelRatio` 不封顶 —— 极易发烫掉帧。\n- 别忘记在卸载时释放 WebGL context —— SPA 切页几次就会撞到浏览器上下文上限变黑屏。",
        "prompt_en": "Core Principle:\nBuild a zero-Three.js native WebGL Liquid Silk Aurora background. A single fullscreen triangle and a 2D Simplex Noise domain-warped 5-octave FBM fragment shader render flowing silk aurora, paired with `DPR <= 1.5` capping, dual offscreen/background frame pausing, full context disposal on unmount, and a CSS gradient fallback.\n\nImplementation:\n1. Pure canvas sizing function `canvasSize(cssW, cssH, dpr, cap = 1.5, maxPixels = 1200000)`:\n   - `s = Math.min(dpr > 0 ? dpr : 1, cap)`; if `cssW * s * cssH * s > maxPixels`, scale `s` down proportionally by `Math.sqrt(maxPixels / px)`; return integer width and height (minimum `1x1`).\n2. Native WebGL 1 pipeline (`powerPreference: 'low-power', depth: false, stencil: false, antialias: false`):\n   - Vertex shader draws one fullscreen triangle `[-1,-1, 3,-1, -1,3]` via a single `drawArrays(TRIANGLES, 0, 3)`.\n   - Fragment shader (guarded with `highp`/`mediump` precision macros): implement 2D simplex noise and 5-octave `fbm(p)`; compute smoothed pointer UV perturbation `md = exp(-dot(m, m) * 7.0)`; domain warp `q = vec2(fbm(p + vec2(0.0, t)), fbm(p + vec2(5.2, 1.3) - t))`; `n = fbm(p + 1.7 * q + md * 0.55 + vec2(t * 0.6, -t * 0.3))`; blend smoothly via `smoothstep` across blue, purple, bright green, and deep dark base tones.\n3. Engineering guards & degradation:\n   - Pre-paint the container with a matching multi-layer CSS radial gradient as first-frame and fallback surface; `<canvas>` starts at `opacity: 0` and fades in after its first rendered frame.\n   - `IntersectionObserver` cancels `rAF` immediately when offscreen and resumes on re-entry; `visibilitychange` pauses when backgrounded.\n   - Listen to `webglcontextlost` (`preventDefault()` and fall back cleanly to the CSS gradient).\n   - Under `prefers-reduced-motion: reduce`, render a single static frame at `u_time = 12.0` without starting `rAF`.\n   - `destroy()` disconnects all observers, calls `gl.deleteBuffer` / `gl.deleteProgram` / `gl.getExtension('WEBGL_lose_context')?.loseContext()`, and removes `<canvas>`.\n\nHard Constraints:\n- Never import Three.js, PixiJS, or any third-party WebGL framework.\n- Must apply dual capping on `DPR <= 1.5` and total pixel count `<= 1,200,000`.\n- Must implement `IntersectionObserver` offscreen pause, `visibilitychange` background pause, and WebGL context disposal.\n- Must provide a static CSS gradient fallback so unavailable WebGL or lost contexts never show a black screen.\n\nAcceptance Criteria:\n- Renders continuous silk-like multicolored aurora waves with smooth pointer fluid disturbance (`0.08` viscous damping).\n- Scrolling the section out of view or switching browser tabs immediately halts `rAF`.\n- Blocking WebGL or triggering `webglcontextlost` seamlessly displays the CSS gradient backdrop with zero errors or black screens.\n- Under reduced motion, renders a single formed static aurora frame with zero ongoing CPU/GPU load.",
        "dont_do_en": "- Do NOT import Three.js just to render a fullscreen 2D fragment shader — 99% of its code is unnecessary overhead.\n- Do NOT set `canvas.width = w * devicePixelRatio` uncapped on 3x high-DPI screens — it quickly causes thermal throttling and frame drops.\n- Do NOT forget to release the WebGL context on unmount — a few SPA page transitions will exhaust the browser's context limit and turn canvases black.",
        "skill_rule_en": "# WebGL Liquid Silk Aurora (shader-aurora) · Cross-Platform Motion Spec\nNature: Material | Layer: webgl | Platform: both\n\nCore Principle: Build a zero-Three.js native WebGL Liquid Silk Aurora background. A single fullscreen triangle and a 2D Simplex Noise domain-warped 5-octave FBM fragment shader render flowing silk aurora, paired with `DPR <= 1.5` capping, dual offscreen/background frame pausing, full context disposal on unmount, and a CSS gradient fallback.\n\nHard Constraints:\n- Never import Three.js, PixiJS, or any third-party WebGL framework.\n- Must apply dual capping on `DPR <= 1.5` and total pixel count `<= 1,200,000`.\n- Must implement `IntersectionObserver` offscreen pause, `visibilitychange` background pause, and WebGL context disposal.\n- Must provide a static CSS gradient fallback so unavailable WebGL or lost contexts never show a black screen.\n\nAcceptance Criteria:\n- Renders continuous silk-like multicolored aurora waves with smooth pointer fluid disturbance (`0.08` viscous damping).\n- Scrolling the section out of view or switching browser tabs immediately halts `rAF`.\n- Blocking WebGL or triggering `webglcontextlost` seamlessly displays the CSS gradient backdrop with zero errors or black screens.\n- Under reduced motion, renders a single formed static aurora frame with zero ongoing CPU/GPU load.\n\nDo NOT Do:\n- Do NOT import Three.js just to render a fullscreen 2D fragment shader — 99% of its code is unnecessary overhead.\n- Do NOT set `canvas.width = w * devicePixelRatio` uncapped on 3x high-DPI screens — it quickly causes thermal throttling and frame drops.\n- Do NOT forget to release the WebGL context on unmount — a few SPA page transitions will exhaust the browser's context limit and turn canvases black."
      }
    },
    {
      "id": "shader-dna",
      "name": "WebGL 3D DNA 双螺旋粒子链",
      "name_en": "WebGL 3D DNA Double Helix",
      "layer": "webgl",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.shaderDna(host, { pairs, rungsPerPair }) + .mk-shader.mk-shader--dna",
      "source": "原生 WebGL gl.POINTS 双螺旋分子链（静态 VBO 一次上传双主链与碱基横桥 + 顶点 3D 旋转与近大远小散景）",
      "source_en": "Native WebGL gl.POINTS 3D double helix (static VBO + depth bokeh)",
      "file": "effects/shader-dna.md",
      "summary": "一次性把双螺旋主链与碱基对横桥的 700+ 颗 3D 粒子上传至 GPU 静态 VBO，每帧在顶点着色器里匀速自转并随指针微倾视角，以加法混合与景深散景呈现出呼吸感十足的 3D DNA 螺旋结构。",
      "summary_en": "Single gl.POINTS draw call rendering 700+ static-VBO double-helix strand and base-pair particles with GPU 3D rotation, pointer tilt, additive glow, and depth bokeh.",
      "problem": "**生物科技、AI 大模型参数空间或生命科学数据页面常需要 3D 双螺旋主视觉，但用 SVG 2D 正弦波模拟极易穿帮（前后遮挡与近大远小全假），引 Three.js 又太重。** 把双螺旋几何一次性编码成带类型标记 `(x, y, z, type)` 的静态粒子 VBO，单次 `gl.POINTS` 绘制就能拥有真实的 3D 透视旋转与前后景深层次。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 两条主链各用 3 颗微偏粒子束增强主干体量（青绿链 A + 蔚蓝链 B），碱基横桥用紫罗兰细粒子连接 | 主链与横桥一样细导致远看糊成一根直棒 |\n| 整条螺旋自带 `-0.42 rad`（~24°）优雅斜倾角，构图比垂直立柱更有动势 | 死板垂直居中占满高度显得僵硬 |\n| 透视点径 `gl_PointSize` + 景深亮度 `v_depth` 同步变化，转到背后的粒子自然变小变暗 | 背面粒子跟正面一样大一样亮导致失去立体前后关系 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 螺旋对数与圈数 | `pairs = 44` / `turns = 2.6` / `rungsPerPair = 11` | 共 `748` 颗粒子，2.6 圈螺旋在方形或宽屏容器内节奏最舒展，横桥疏密清晰可读 |\n| 主链 / 横桥点径基准 | 主链 `12.5 * dpr / z` / 横桥 `7.5 * dpr / z` | 主副层次一目了然，一眼识别双螺旋拓扑而不是杂乱点云 |\n| 相机距离与景深 | `z = p.z + 2.95` / `v_depth ∈ [0.18, 1.0]` | 保证后侧螺旋依然隐约可见（`0.18` 下限不彻底消失），同时与前景形成鲜明对比 |\n| 混合模式 | 预乘加法 `gl.blendFunc(gl.ONE, gl.ONE)` | 螺旋交叉节点自动叠加微光，且免去透明粒子 Z 排序开销 |",
      "implementation": "```\nsrc/core/shader.js:152   helixPositions(pairs, rungs)  确定性 DNA 双螺旋 + 横桥粒子生成器（可单测）\nsrc/core/shader.js:953   DNA_VERT / DNA_FRAG           GPU 3D 旋转斜倾 + 分类型着色柔焦圆点 GLSL\nsrc/core/shader.js:1004  shaderDna(host, opts)         gl.POINTS 渲染器（DPR 1.5 + 双停帧 + 释放 context）\nstyles/webgl.css:96      .mk-shader--dna               WebGL 不可用时的深空径向渐变兜底\n```",
      "degradation": "**走 `webgl` 层专属契约：退回 CSS 渐变 + 减弱动效单帧冻结。**\n\n- `prefers-reduced-motion: reduce`：仅绘制 `t = 2.4s` 一帧静态 3D 双螺旋，不启动 rAF 循环，不响应指针摆动。\n- WebGL 不可用或上下文丢失时隐藏 `<canvas>`，展示容器渐变兜底。",
      "pitfalls": "**① 没给前后粒子区分 `v_depth` 亮度与点径，导致视觉上出现“双稳态错觉”分不清哪条链在前。**\n深度线索必须同时作用在 `gl_PointSize` 与片元透明度/亮度 `v_depth` 上，前景链大而亮、后景链细而柔。\n\n**② 在 `gl.POINTS` 片元里漏写圆形裁剪 `if (dot(c, c) > 0.25) discard;`，满屏变成锯齿小方块。**\n必须基于 `gl_PointCoord - 0.5` 做径向 `smoothstep` 柔焦圆点。\n\n**③ 每帧在 JS 里循环算 `Math.sin / Math.cos` 更新 VBO。**\n螺旋是刚体旋转，静态坐标只需初始化时 `gl.STATIC_DRAW` 上传一次，旋转全交给顶点着色器的 `rot2`。\n\n---",
      "ai_assets": {
        "prompt": "实现零 Three.js 依赖的原生 WebGL 3D DNA 双螺旋粒子链（gl.POINTS 3D Double-Helix）。\n\n原理一句话：初始化时用纯函数生成双螺旋主链与碱基横桥的 3D 粒子数组 (x, y, z, type) 一次性写入 GPU 静态 VBO，每帧在顶点着色器里完成匀速自转、斜倾与指针视角微调，并按近大远小透视与加法混合呈现清晰前后景深。\n\n做法：\n1. 纯函数 helixPositions(pairs = 44, rungsPerPair = 11)：\n   - 钳制 pairs ∈ [4, 120]、rungsPerPair ∈ [1, 20]，共 count = pairs * (6 + rungsPerPair) 颗粒子，返回 { vertices: Float32Array(count * 4), count }。\n   - 沿 y ∈ [-1.275, +1.275] 旋转 turns = 2.6 圈、半径 radius = 0.62：\n     每对在角度 ang 与 ang + π 各生成 3 颗微偏主链粒子（type = 0.0 / 1.0），并在两链之间等距插值 rungsPerPair 颗碱基横桥粒子（type = 0.5）。\n2. 原生 WebGL 管线与工程约束：\n   - 一次性 gl.STATIC_DRAW 上传 VBO；开启 gl.BLEND 与 gl.blendFunc(gl.ONE, gl.ONE)；单次 gl.drawArrays(gl.POINTS, 0, count)。\n   - DPR <= 1.5 且画布总像素 <= 1,200,000；接 ResizeObserver、IntersectionObserver（离屏停帧）与 visibilitychange（后台停帧）；destroy() 释放 buffer/program 并主动 loseContext。\n3. 顶点与片元着色器：\n   - 顶点着色器：先绕 XZ 旋 u_time*0.85 + (u_mouse.x - 0.5)*2.2，再绕 XY 斜倾 -0.42 + (u_mouse.y - 0.5)*0.65；\n     透视投影 z = p.z + 2.95，proj = vec2(p.x / asp, p.y) * (1.72 / max(z, 0.3))；\n     主链点径基准 12.5、横桥基准 7.5，gl_PointSize = clamp(base * u_dpr / max(z, 0.4), 1.6, 8.5)；\n     输出景深权重 v_depth = clamp(1.0 - (z - 1.6) / 2.6, 0.18, 1.0)。\n   - 片元着色器：裁剪圆形柔焦点（dot(c, c) > 0.25 丢弃），按 v_type 分别着荧光绿（链 A）、蔚蓝（链 B）与淡紫（横桥，亮度系数 0.68），同乘 v_depth 确立前后纵深。\n4. 降级：\n   - prefers-reduced-motion: reduce 仅画 t = 2.4s 一帧静态螺旋，不起 rAF；不支持或 context lost 隐藏 canvas 展示 CSS 渐变兜底。\n\n硬要求：\n- 粒子几何必须一次性 STATIC_DRAW 上传、单次 gl.POINTS 绘制，严禁 JS 每帧重算坐标。\n- 必须用点径与亮度双重深度线索区分前后螺旋链，禁止无景深平面点阵。\n- 严禁引入 Three.js，必须落齐 DPR 封顶、双停帧与 context 销毁。\n\n验收：\n- 两条异色主链与中间碱基横桥清晰可辨，以 ~24° 斜角流畅 3D 自转，前景饱满高亮、后景细腻柔和。\n- 移动鼠标按 0.08 阻尼平滑摆动螺旋视角，宽屏容器内不变形。\n- 滚出视口、切后台或开启减弱动效时 rAF 自动停止；卸载无 WebGL context 泄漏。",
        "dont_do": "- 别把主链和横桥设成一样大小和亮度 —— 整体会糊成一根分不清结构的噪点柱子。\n- 别忘了在片元着色器里裁掉正方形点精灵四角 —— 发光方块会毁掉分子链的柔和散景感。\n- 别在 JS 里每帧重新生成坐标并调用 `bufferData` —— 白白浪费 CPU 和显存带宽。",
        "skill_rule": "# WebGL 3D DNA 双螺旋粒子链 (shader-dna) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】初始化时用纯函数生成双螺旋主链与碱基横桥的 3D 粒子数组 (x, y, z, type) 一次性写入 GPU 静态 VBO，每帧在顶点着色器里完成匀速自转、斜倾与指针视角微调，并按近大远小透视与加法混合呈现清晰前后景深。\n\n【硬要求】\n- 粒子几何必须一次性 STATIC_DRAW 上传、单次 gl.POINTS 绘制，严禁 JS 每帧重算坐标。\n- 必须用点径与亮度双重深度线索区分前后螺旋链，禁止无景深平面点阵。\n- 严禁引入 Three.js，必须落齐 DPR 封顶、双停帧与 context 销毁。\n\n【验收标准】\n- 两条异色主链与中间碱基横桥清晰可辨，以 ~24° 斜角流畅 3D 自转，前景饱满高亮、后景细腻柔和。\n- 移动鼠标按 0.08 阻尼平滑摆动螺旋视角，宽屏容器内不变形。\n- 滚出视口、切后台或开启减弱动效时 rAF 自动停止；卸载无 WebGL context 泄漏。\n\n【禁止做法】\n- 别把主链和横桥设成一样大小和亮度 —— 整体会糊成一根分不清结构的噪点柱子。\n- 别忘了在片元着色器里裁掉正方形点精灵四角 —— 发光方块会毁掉分子链的柔和散景感。\n- 别在 JS 里每帧重新生成坐标并调用 `bufferData` —— 白白浪费 CPU 和显存带宽。",
        "prompt_en": "Core Principle:\nBuild a zero-Three.js native WebGL 3D DNA Double Helix particle chain (`gl.POINTS`). At initialization, a pure function generates 3D `(x, y, z, type)` particles for both backbone strands and base-pair rungs and uploads them once to a static GPU VBO; each frame, the vertex shader handles steady rotation, tilt, and pointer parallax while perspective point sizing and additive blending establish crisp front-to-back depth.\n\nImplementation:\n1. Pure function `helixPositions(pairs = 44, rungsPerPair = 11)`:\n   - Clamp `pairs` to `[4, 120]` and `rungsPerPair` to `[1, 20]`; total `count = pairs * (6 + rungsPerPair)`; return `{ vertices: Float32Array(count * 4), count }`.\n   - Along `y` in `[-1.275, +1.275]` over `turns = 2.6` turns and `radius = 0.62`: for each pair, generate 3 slightly offset backbone particles at angle `ang` (`type = 0.0`) and 3 at `ang + Math.PI` (`type = 1.0`), plus `rungsPerPair` evenly interpolated base-pair rung particles between the two strands (`type = 0.5`).\n2. Native WebGL pipeline & engineering constraints:\n   - Upload VBO once with `gl.STATIC_DRAW`; enable `gl.BLEND` with `gl.blendFunc(gl.ONE, gl.ONE)`; draw in one call via `gl.drawArrays(gl.POINTS, 0, count)`.\n   - Cap `DPR <= 1.5` and total pixels `<= 1,200,000`; wire `ResizeObserver`, `IntersectionObserver` (offscreen pause), and `visibilitychange` (background pause); `destroy()` deletes buffers/programs and actively calls `loseContext()`.\n3. Vertex & fragment shaders:\n   - Vertex shader: rotate in XZ by `u_time * 0.85 + (u_mouse.x - 0.5) * 2.2`, then tilt in XY by `-0.42 + (u_mouse.y - 0.5) * 0.65`; perspective projection `z = p.z + 2.95`, `proj = vec2(p.x / asp, p.y) * (1.72 / max(z, 0.3))`; base point size `12.5` for backbones and `7.5` for rungs, `gl_PointSize = clamp(base * u_dpr / max(z, 0.4), 1.6, 8.5)`; output depth weight `v_depth = clamp(1.0 - (z - 1.6) / 2.6, 0.18, 1.0)`.\n   - Fragment shader: clip to a soft circular point sprite (`discard` when `dot(c, c) > 0.25`), color by `v_type` into fluorescent green (strand A), azure blue (strand B), and pale violet (rungs, brightness factor `0.68`), all multiplied by `v_depth` for front-to-back depth clarity.\n4. Reduced-motion & fallback:\n   - Under `prefers-reduced-motion: reduce`, render a single static frame at `t = 2.4s` without starting `rAF`; when WebGL is unsupported or context is lost, hide `<canvas>` and show the CSS gradient fallback.\n\nHard Constraints:\n- Particle geometry must be uploaded once via `gl.STATIC_DRAW` and drawn in a single `gl.POINTS` call; never recompute coordinates in JS every frame.\n- Must encode front/back depth using both point size and brightness—never render a flat, depthless point cloud.\n- Never import Three.js; must implement DPR/pixel caps, dual offscreen/background pausing, and context disposal.\n\nAcceptance Criteria:\n- Two distinct colored backbone strands and base-pair rungs are clearly legible, rotating smoothly in 3D at a `~24°` tilt with bright foreground points and softer background points.\n- Moving the mouse smoothly swings the helix view with `0.08` damping, remaining undistorted in widescreen containers.\n- Scrolling out of view, backgrounding the tab, or enabling reduced motion halts `rAF`; unmounting leaks zero WebGL contexts.",
        "dont_do_en": "- Do NOT give backbone strands and base-pair rungs the same size and brightness — the structure blurs into an unreadable column of noise.\n- Do NOT forget to clip the square corners of `gl_PointCoord` in the fragment shader — glowing squares ruin the soft molecular bokeh feel.\n- Do NOT regenerate coordinates in JS every frame and call `bufferData` — it wastes CPU and GPU memory bandwidth.",
        "skill_rule_en": "# WebGL 3D DNA Double Helix (shader-dna) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: webgl | Platform: both\n\nCore Principle: Build a zero-Three.js native WebGL 3D DNA Double Helix particle chain (`gl.POINTS`). At initialization, a pure function generates 3D `(x, y, z, type)` particles for both backbone strands and base-pair rungs and uploads them once to a static GPU VBO; each frame, the vertex shader handles steady rotation, tilt, and pointer parallax while perspective point sizing and additive blending establish crisp front-to-back depth.\n\nHard Constraints:\n- Particle geometry must be uploaded once via `gl.STATIC_DRAW` and drawn in a single `gl.POINTS` call; never recompute coordinates in JS every frame.\n- Must encode front/back depth using both point size and brightness—never render a flat, depthless point cloud.\n- Never import Three.js; must implement DPR/pixel caps, dual offscreen/background pausing, and context disposal.\n\nAcceptance Criteria:\n- Two distinct colored backbone strands and base-pair rungs are clearly legible, rotating smoothly in 3D at a `~24°` tilt with bright foreground points and softer background points.\n- Moving the mouse smoothly swings the helix view with `0.08` damping, remaining undistorted in widescreen containers.\n- Scrolling out of view, backgrounding the tab, or enabling reduced motion halts `rAF`; unmounting leaks zero WebGL contexts.\n\nDo NOT Do:\n- Do NOT give backbone strands and base-pair rungs the same size and brightness — the structure blurs into an unreadable column of noise.\n- Do NOT forget to clip the square corners of `gl_PointCoord` in the fragment shader — glowing squares ruin the soft molecular bokeh feel.\n- Do NOT regenerate coordinates in JS every frame and call `bufferData` — it wastes CPU and GPU memory bandwidth."
      }
    },
    {
      "id": "shader-globe",
      "name": "WebGL 3D 交互全息地球",
      "name_en": "WebGL 3D Holographic Globe",
      "layer": "webgl",
      "nature": "方向",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.shaderGlobe(host) + .mk-shader.mk-shader--globe",
      "source": "解析射线求交全息地球（零网格顶点 + 经纬线余弦校正网格 + 程序化发光大陆与脉动信标 + 大气 Fresnel 辉光）",
      "source_en": "Analytical ray-sphere holographic globe (0KB Three.js, 0 textures)",
      "file": "effects/shader-globe.md",
      "summary": "不用 Three.js 也不用球体贴图，直接在 GLSL 里对单位球做解析射线求交（`z = sqrt(R² - r²)`），单帧画出带经纬线网格、点阵发光大陆、城市脉动信标与大气边缘辉光的 3D 全息地球。",
      "summary_en": "Analytical ray-sphere intersection (zero mesh, zero texture) rendering cosine-corrected lat/lon grid, dotted FBM continents, pulsing city beacons, and Fresnel atmosphere.",
      "problem": "**全球化 SaaS、边缘节点监控或开发者主页最爱放一颗可互动的 3D 地球（类似 Stripe / GitHub Globe），但一引入 Three.js + 地球纹理 + 球体网格细分，首屏包体和显存瞬间飙升，移动端风扇狂转。** 球面解析求交只需一次平方根就能拿到完美光滑的球面法线与经纬度，包体近乎为零且任何放大倍数下边缘都没有多边形折角。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 解析求交 `z = sqrt(R² - r²)` + 球体外大气指数辉光 `exp(-(r - R) * 14)` | 几千个三角形的球体网格 + 2MB 高清地图贴图 |\n| 经线宽度按 `1 / max(cos(lat), 0.25)` 补偿，高纬度与两极网格不糊成一团 | 直接对经度做固定像素线宽导致南北极糊死发白 |\n| 球面自动匀速自转叠平滑阻尼（`0.08`）的指针偏航/俯仰转向 | 拖拽松手后生硬卡停或鼠标离开瞬间弹回 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 球半径与外大气 | `R = 0.37` / `halo = exp(-(r - R) * 14.0) * 0.55` | 球体占短边 74% 直径，四周留足 13% 空间让蓝色/青绿大气辉光自然消散不被画布裁切 |\n| 经线极点校正 | `smoothstep(0.035 / max(cos(lat), 0.25), 0.0, lonGrid)` | 球面经线间距随 `cos(lat)` 收缩，除以 `cos(lat)` 后全纬度视觉线宽一致且在极点封顶 |\n| 大气边缘 Fresnel | `pow(1.0 - max(n.z, 0.0), 2.8)` | 球心通透便于读大陆与信标，球体轮廓自然泛起一层厚重科技感边缘光 |\n| 透明背景与抗锯齿 | `edgeAA = smoothstep(R, R - 0.004, r)` | 边缘亚像素羽化，透明画布直接叠在任意深色面板上无锯齿白边 |",
      "implementation": "```\nsrc/core/shader.js:96    globeCoords(latDeg, lonDeg)   经纬度转单位球面 3D 坐标纯函数（可单测）\nsrc/core/shader.js:750   GLOBE_FRAG                    解析球面求交 + 经纬网格 + 大陆点阵 + 信标 GLSL\nsrc/core/shader.js:823   shaderGlobe(host, opts)       复用 shaderCanvas（DPR 1.5 + 双停帧 + 释放 context）\nstyles/webgl.css:77      .mk-shader--globe             WebGL 未就绪或降级时的双环径向地球兜底\n```",
      "degradation": "**走 `webgl` 层专属契约：退回 CSS 渐变 + 减弱动效单帧冻结。**\n\n- `prefers-reduced-motion: reduce`：仅渲染静态一帧全息地球，不启动 rAF 循环，不绑定指针旋转。\n- 不支持 WebGL 或上下文丢失时隐藏 `<canvas>`，由容器双色径向渐变兜底呈现球体轮廓。",
      "pitfalls": "**① 没对经线做 `cos(lat)` 补偿，南北极变成一整块发白光斑。**\n球面经线向两极汇聚，固定经度阈值会让两极全部被判成“在线上”；必须按 `0.035 / max(cos(lat), 0.25)` 自适应收缩。\n\n**② 未按 `min(u_res.x, u_res.y)` 归一化导致宽屏容器里地球变成橄榄球。**\n必须用短边归一化坐标，确保任意比例容器内都是严格正圆球。\n\n**③ 球半径设太大（如 `0.48`）把外大气辉光硬切在画布边界。**\n把 `R` 控在 `0.36–0.38`，给大气辉光留足平滑衰减距离。\n\n---",
      "ai_assets": {
        "prompt": "实现零 Three.js、零贴图依赖的原生 WebGL 3D 交互全息地球（Analytical Ray-Sphere Holographic Globe）。\n\n原理一句话：在透明全屏三角形片元着色器里用解析方程 z = sqrt(R² - r²) 直接求得球面法线与经纬度，叠加余弦校正的经纬网格、程序化 FBM 点阵大陆、脉动数据信标与大气 Fresnel 辉光，由平滑阻尼指针驱动 3D 旋转。\n\n做法：\n1. 纯函数 globeCoords(latDeg, lonDeg)：\n   - 经纬度（度）转单位球面坐标 { x: cos(lat)*sin(lon), y: sin(lat), z: cos(lat)*cos(lon) }，纬度钳制 [-90, 90]，非法值返回 { x: 0, y: 0, z: 1 }。\n2. 原生 WebGL 工程约束：\n   - 单全屏三角形 + alpha: true + powerPreference: 'low-power'；DPR 封顶 1.5 且画布总像素 <= 1,200,000。\n   - 接 ResizeObserver、IntersectionObserver（滚出视口停帧）与 visibilitychange（切后台停帧）；destroy() 删除 buffer/program 并主动 loseContext。\n3. GLSL 解析球面核心：\n   - 短边归一化坐标：uv = (gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y)；r = length(uv)；球半径 R = 0.37。\n   - 球外（r > R）：渲染指数衰减外大气辉光 halo = exp(-(r - R) * 14.0) * 0.55 后返回。\n   - 球内：z = sqrt(max(0.0, R*R - r*r))；法线 n = normalize(vec3(uv, z))；先绕 YZ 旋俯仰角 -0.22 + (u_mouse.y - 0.5)*1.4，再绕 XZ 旋偏航角 u_time*0.28 + (u_mouse.x - 0.5)*3.0 得到球面本地点 p。\n   - 球面映射：lat = asin(clamp(p.y, -1.0, 1.0))；lon = atan(p.x, p.z)。\n   - 视觉四层叠加：\n     a) 经纬网格：经线按 0.035 / max(cos(lat), 0.25) 补偿极点收敛；\n     b) 程序化大陆：FBM(lon*1.45, lat*2.1) 区分海洋、点阵大陆与海岸亮边；\n     c) 脉动节点信标：在 4 个固定单位球面坐标上用 exp(-distance(p, b) * 18.0) 叠加交替呼吸高亮；\n     d) 方向漫反射 + pow(1.0 - max(n.z, 0.0), 2.8) 大气边缘 Fresnel，边缘做 smoothstep(R, R - 0.004, r) 抗锯齿。\n4. 降级：\n   - prefers-reduced-motion: reduce 仅画一帧静态地球，不起 rAF。\n   - 不支持 WebGL 或 webglcontextlost 时隐藏 canvas 展示同色系 CSS 径向渐变球兜底。\n\n硬要求：\n- 严禁引入 Three.js 或外部地球图片纹理。\n- 必须做短边归一化与极点经线 cos(lat) 宽度校正，且球半径 <= 0.38 保证大气辉光不被方框裁切。\n- 必须落齐 DPR 封顶、离屏/后台双停帧与 context 清理。\n\n验收：\n- 地球在透明画布上呈现锐利正圆与柔和外大气辉光，自转流畅且两极经纬线清晰不糊团。\n- 鼠标移动时地球按 0.08 阻尼平滑转向，移出后柔和回正。\n- 滚出视口、切后台或开启减弱动效时 rAF 自动停止；卸载无 context 泄漏。",
        "dont_do": "- 别为了做个展示地球把几百 KB 的 Three.js 和 4K 地球贴图塞进首屏包体。\n- 别忘记对经线做 `cos(lat)` 补偿 —— 两极一定会糊成一坨刺眼白块。\n- 别把球半径画满到 `0.48` —— 外层大气辉光撞到画布四条边会切出硬方框。",
        "skill_rule": "# WebGL 3D 交互全息地球 (shader-globe) · 跨平台动效规范\n性质：方向 ｜ 平台：both\n\n【核心原理】在透明全屏三角形片元着色器里用解析方程 z = sqrt(R² - r²) 直接求得球面法线与经纬度，叠加余弦校正的经纬网格、程序化 FBM 点阵大陆、脉动数据信标与大气 Fresnel 辉光，由平滑阻尼指针驱动 3D 旋转。\n\n【硬要求】\n- 严禁引入 Three.js 或外部地球图片纹理。\n- 必须做短边归一化与极点经线 cos(lat) 宽度校正，且球半径 <= 0.38 保证大气辉光不被方框裁切。\n- 必须落齐 DPR 封顶、离屏/后台双停帧与 context 清理。\n\n【验收标准】\n- 地球在透明画布上呈现锐利正圆与柔和外大气辉光，自转流畅且两极经纬线清晰不糊团。\n- 鼠标移动时地球按 0.08 阻尼平滑转向，移出后柔和回正。\n- 滚出视口、切后台或开启减弱动效时 rAF 自动停止；卸载无 context 泄漏。\n\n【禁止做法】\n- 别为了做个展示地球把几百 KB 的 Three.js 和 4K 地球贴图塞进首屏包体。\n- 别忘记对经线做 `cos(lat)` 补偿 —— 两极一定会糊成一坨刺眼白块。\n- 别把球半径画满到 `0.48` —— 外层大气辉光撞到画布四条边会切出硬方框。",
        "prompt_en": "Core Principle:\nZero-Three.js, zero-texture native WebGL 3D interactive holographic globe (Analytical Ray-Sphere Holographic Globe). In a transparent fullscreen-triangle fragment shader, solve the analytical sphere equation `z = sqrt(R² - r²)` directly to derive surface normals and lat/lon coordinates, layering cosine-compensated graticule gridlines, procedural FBM dot-matrix continents, pulsing data beacons, and atmospheric Fresnel glow, driven by pointer-damped 3D rotation.\n\nImplementation:\n1. Pure function `globeCoords(latDeg, lonDeg)`:\n   - Convert latitude/longitude (degrees) to unit-sphere coordinates `{ x: cos(lat)*sin(lon), y: sin(lat), z: cos(lat)*cos(lon) }`, clamping latitude to `[-90, 90]` and returning `{ x: 0, y: 0, z: 1 }` for invalid inputs.\n2. Native WebGL engineering constraints:\n   - Single fullscreen triangle with `alpha: true` and `powerPreference: 'low-power'`; cap DPR at `1.5` and total canvas pixels `<= 1,200,000`.\n   - Attach `ResizeObserver`, `IntersectionObserver` (pause loop offscreen), and `visibilitychange` (pause loop in background); in `destroy()`, delete buffers/programs and actively invoke `loseContext()`.\n3. GLSL analytical sphere core:\n   - Short-edge normalized coordinates: `uv = (gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y)`; `r = length(uv)`; sphere radius `R = 0.37`.\n   - Outside sphere (`r > R`): render exponentially decaying outer atmospheric halo `halo = exp(-(r - R) * 14.0) * 0.55` and return.\n   - Inside sphere: `z = sqrt(max(0.0, R*R - r*r))`; normal `n = normalize(vec3(uv, z))`; rotate around YZ by pitch `-0.22 + (u_mouse.y - 0.5)*1.4`, then around XZ by yaw `u_time*0.28 + (u_mouse.x - 0.5)*3.0` to obtain local sphere point `p`.\n   - Spherical mapping: `lat = asin(clamp(p.y, -1.0, 1.0))`; `lon = atan(p.x, p.z)`.\n   - Four visual layers:\n     a) Graticule grid: compensate longitude line width by `0.035 / max(cos(lat), 0.25)` to prevent polar convergence;\n     b) Procedural continents: `FBM(lon*1.45, lat*2.1)` separating ocean, dot-matrix landmasses, and bright coastlines;\n     c) Pulsing node beacons: alternate breathing highlights across 4 fixed unit-sphere coordinates using `exp(-distance(p, b) * 18.0)`;\n     d) Directional diffuse shading + `pow(1.0 - max(n.z, 0.0), 2.8)` atmospheric rim Fresnel, with `smoothstep(R, R - 0.004, r)` edge anti-aliasing.\n4. Fallbacks:\n   - Under `prefers-reduced-motion: reduce`, render only a single static globe frame with no `rAF` loop.\n   - When WebGL is unsupported or on `webglcontextlost`, hide the canvas and show a matching CSS radial-gradient sphere fallback.\n\nHard Constraints:\n- Strictly forbid Three.js or external Earth image textures.\n- Must apply short-edge normalization and polar longitude `cos(lat)` width compensation, with sphere radius `<= 0.38` so the atmospheric halo is never clipped by the canvas bounding box.\n- Must implement DPR capping, offscreen/background dual loop pausing, and explicit context cleanup.\n\nAcceptance Criteria:\n- The globe renders as a crisp true circle on a transparent canvas with a soft outer atmospheric halo, smooth auto-rotation, and sharp graticule lines at both poles without clumping.\n- Moving the pointer smoothly steers the globe with `0.08` damping and eases back to center on exit.\n- `rAF` stops automatically when scrolled offscreen, backgrounded, or when reduced motion is enabled; zero context leaks on unmount.",
        "dont_do_en": "- Do NOT bundle hundreds of KB of Three.js and 4K Earth textures into the initial load just to display a globe.\n- Do NOT forget `cos(lat)` compensation on meridians — the poles will inevitably merge into a glaring white blob.\n- Do NOT size the sphere radius up to `0.48` — the outer atmospheric halo will hit the four canvas edges and get clipped into a hard square box.",
        "skill_rule_en": "# WebGL 3D Holographic Globe (shader-globe) · Cross-Platform Motion Spec\nNature: Direction | Layer: webgl | Platform: both\n\nCore Principle: Zero-Three.js, zero-texture native WebGL 3D interactive holographic globe (Analytical Ray-Sphere Holographic Globe). In a transparent fullscreen-triangle fragment shader, solve the analytical sphere equation `z = sqrt(R² - r²)` directly to derive surface normals and lat/lon coordinates, layering cosine-compensated graticule gridlines, procedural FBM dot-matrix continents, pulsing data beacons, and atmospheric Fresnel glow, driven by pointer-damped 3D rotation.\n\nHard Constraints:\n- Strictly forbid Three.js or external Earth image textures.\n- Must apply short-edge normalization and polar longitude `cos(lat)` width compensation, with sphere radius `<= 0.38` so the atmospheric halo is never clipped by the canvas bounding box.\n- Must implement DPR capping, offscreen/background dual loop pausing, and explicit context cleanup.\n\nAcceptance Criteria:\n- The globe renders as a crisp true circle on a transparent canvas with a soft outer atmospheric halo, smooth auto-rotation, and sharp graticule lines at both poles without clumping.\n- Moving the pointer smoothly steers the globe with `0.08` damping and eases back to center on exit.\n- `rAF` stops automatically when scrolled offscreen, backgrounded, or when reduced motion is enabled; zero context leaks on unmount.\n\nDo NOT Do:\n- Do NOT bundle hundreds of KB of Three.js and 4K Earth textures into the initial load just to display a globe.\n- Do NOT forget `cos(lat)` compensation on meridians — the poles will inevitably merge into a glaring white blob.\n- Do NOT size the sphere radius up to `0.48` — the outer atmospheric halo will hit the four canvas edges and get clipped into a hard square box."
      }
    },
    {
      "id": "shader-metaballs",
      "name": "WebGL 3D 液态水银融合球",
      "name_en": "WebGL 3D Liquid Mercury Metaballs",
      "layer": "webgl",
      "nature": "连续",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.shaderMetaballs(host) + .mk-shader.mk-shader--metaballs",
      "source": "Inigo Quilez 多项式 Smooth-Min 3D Metaballs（5 颗公转液滴 + 1 颗指针引力液滴 + 42 步 SDF 射线步进与镜面虹彩反射）",
      "source_en": "Inigo Quilez polynomial smooth-min 3D raymarched metaballs (0KB Three.js)",
      "file": "effects/shader-metaballs.md",
      "summary": "零 Three.js、零网格重构，用多项式平滑最小函数 `smin(d1, d2, k)` 把 5 颗公转 3D 球体与 1 颗随鼠标游走的引力液滴在片元着色器里实时融合成一团拉丝粘连的液态水银。",
      "summary_en": "Polynomial smooth-min blending 5 orbiting 3D chrome droplets plus 1 pointer-attracted droplet via 42-step SDF raymarching and iridescent specular reflections.",
      "problem": "**想做会“靠拢融合、拉开拉丝”的 3D 液态球（Metaballs），如果走传统 3D 引擎需要每帧在 CPU 上跑 Marching Cubes 重建上万个三角形网格，手机直接发烫掉帧。** 在 SDF 射线步进里，融合两颗球体只需一行多项式 `smin`，计算量几乎等于免费，且融合颈部自带无穷光滑的液态镜面过渡。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 多项式平滑最小 `smin(a, b, k)`（`k = 0.36–0.42`），C1 连续且绝不出现生硬接缝折痕 | CPU 端 Marching Cubes 网格重建与低面数多边形棱角 |\n| 6 颗液滴中的第 6 颗跟随阻尼指针游走（`k = 0.42` 略大粘连半径），手一靠近就能“粘起”拉丝 | 纯观赏背景不响应用户交互 |\n| 基于反射向量 `reflect(-v, n)` 采样紫/蓝/荧光绿三色环境反射 + 48 次方锐利高光 | 单一漫反射显得像橡皮泥而不是水银 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 平滑融合半径 `k` | 轨道球 `0.36` / 指针球 `0.42` | 略大于球半径（`0.23–0.30`），两球靠近至 0.6 倍直径时自然起粘连液桥，分开时干净拉断 |\n| 射线步进预算 | `42` 步 / `d < 0.002` / `dist > 5.0` | 球体组 SDF 梯度平缓，42 步即可稳定收敛至清晰轮廓并保持移动端 60fps |\n| 高光幂次与 Fresnel | `spec pow 48` / `fres pow 3.0` | 锐利高光点确立“液态水银”质感，边缘虹彩 Fresnel 让球体在暗底中清晰浮现 |\n| 透明背景与微光 | 未命中输出中心淡紫蓝径向光晕 | 可无框悬浮在任意卡片、登录区或 AI 助手顶栏上 |",
      "implementation": "```\nsrc/core/shader.js:140   smoothMin(a, b, k)        多项式 Smooth-Min 纯函数（可单测）\nsrc/core/shader.js:882   METABALLS_FRAG            6 球 SDF 融合 + 42 步射线步进 + 水银反射 GLSL\nsrc/core/shader.js:949   shaderMetaballs(host)     复用 shaderCanvas（DPR 1.5 + 双停帧 + 释放 context）\nstyles/webgl.css:89      .mk-shader--metaballs     WebGL 不可用时的双球交融 CSS 径向渐变兜底\n```",
      "degradation": "**走 `webgl` 层专属契约：退回 CSS 渐变 + 减弱动效单帧冻结。**\n\n- `prefers-reduced-motion: reduce`：仅绘制一帧静态液态水银雕塑，不启动 rAF 循环，不响应鼠标拖拽液滴。\n- WebGL 不可用或上下文丢失时隐藏 `<canvas>`，展示容器双色交融径向渐变兜底。",
      "pitfalls": "**① 直接用 `min(d1, d2)` 拼接球体而没用 `smin`，球与球相交处出现生硬折线。**\n硬 `min` 是刚体并集，没有液态张力；必须使用二次多项式 `h = max(k - abs(a - b), 0) / k; min(a, b) - h*h*k*0.25` 才能产出饱满的液态粘连颈部。\n\n**② 指针引力球直接硬跟 `e.clientX/Y`，鼠标一划液滴像瞬移传送。**\n指针 UV 必须经过 `mouse += (target - mouse) * 0.08` 指数阻尼，才能产生“把水银拖过来又慢慢拉断”的流体重量感。\n\n**③ 没做 DPR 封顶与总像素上限，在 3× 屏跑满像素拖垮帧率。**\n射线步进对像素数极度敏感，必须将 DPR 压在 `1.5` 且总像素 `<= 1,200,000`。\n\n---",
      "ai_assets": {
        "prompt": "实现零 Three.js 依赖的原生 WebGL 3D 液态水银融合球（3D Raymarched Metaballs）。\n\n原理一句话：在透明全屏三角形片元着色器里，用多项式平滑最小 smin(a, b, k) 将 5 颗 3D 轨道球与 1 颗阻尼跟随指针的引力球融合成连续液态曲面，以 42 步射线步进 + 中心差分法线 + 反射向量环境光渲染出水银镜面拉丝质感。\n\n做法：\n1. 纯函数 smoothMin(a, b, k = 0.35)：\n   - 若 k <= 0 返回 Math.min(a, b)；否则 h = Math.max(k - Math.abs(a - b), 0) / k，返回 Math.min(a, b) - h * h * k * 0.25（C1 连续且严格 <= min(a, b)）。\n2. 原生 WebGL 工程约束：\n   - 单全屏三角形 + alpha: true + powerPreference: 'low-power'；DPR <= 1.5 且画布总像素 <= 1,200,000。\n   - 接 ResizeObserver、IntersectionObserver（离屏停帧）与 visibilitychange（后台停帧）；destroy() 删除 buffer/program 并主动 loseContext。\n3. GLSL 核心：\n   - 短边归一化坐标：uv = (gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y)；相机 ro = vec3(0, 0, 2.45)，射线 rd = normalize(vec3(uv, -1.7))。\n   - 场景 SDF mapBalls(p, t)：5 颗沿不同相位三角函数轨迹公转的 3D 球（半径 0.23–0.30）加第 6 颗指针球 cm = vec3((u_mouse.x - 0.5)*1.45, (u_mouse.y - 0.5)*1.1, 0.28)，依次用 smin(d, ..., 0.36..0.42) 融合。\n   - 最多 42 步射线步进，d < 0.002 判命中，dist > 5.0 退出；未命中返回中心柔和微光。\n   - 命中后用 e = 0.0028 的 6 点中心差分求法线 n，计算反射向量 rdir = reflect(-v, n) 混合紫/蓝/荧光绿环境色，叠加 48 次方镜面高光与 3.0 次方 Fresnel 轮廓亮边。\n4. 指针阻尼与降级：\n   - 指针坐标每帧 mouse += (target - mouse) * 0.08 平滑逼近，移出容器自动回中。\n   - prefers-reduced-motion: reduce 仅渲染一帧静态雕塑，不起 rAF；context lost 或不支持时隐藏 canvas 展示 CSS 径向渐变兜底。\n\n硬要求：\n- 严禁引入 Three.js 或使用 CPU Marching Cubes 网格重建。\n- 必须使用多项式 smin 实现平滑拉丝融合，禁止硬 min 刚体拼接。\n- 必须落齐 DPR 封顶、离屏/后台双停帧与 destroy 释放 context。\n\n验收：\n- 多颗液态金属球在 3D 空间自由穿梭、靠拢时自然粘连起液桥、远离时顺滑拉断，表面有清晰水银镜面高光。\n- 鼠标移入时引力液滴以阻尼黏附拉扯主球团，移出后柔和回落中央。\n- 滚出视口、切后台或开启减弱动效时 rAF 自动停止；卸载无 WebGL context 泄漏。",
        "dont_do": "- 别用 `min(d1, d2)` 代替 `smin` —— 球体相交只会留下一圈硬棱线，完全没有液态融合感。\n- 别在 JS 里每帧运行 Marching Cubes 生成三角形 —— 体积大且移动端必掉帧。\n- 别让指针球零阻尼硬跟鼠标 —— 失去流体惯性与拉丝重量感。",
        "skill_rule": "# WebGL 3D 液态水银融合球 (shader-metaballs) · 跨平台动效规范\n性质：连续 ｜ 平台：both\n\n【核心原理】在透明全屏三角形片元着色器里，用多项式平滑最小 smin(a, b, k) 将 5 颗 3D 轨道球与 1 颗阻尼跟随指针的引力球融合成连续液态曲面，以 42 步射线步进 + 中心差分法线 + 反射向量环境光渲染出水银镜面拉丝质感。\n\n【硬要求】\n- 严禁引入 Three.js 或使用 CPU Marching Cubes 网格重建。\n- 必须使用多项式 smin 实现平滑拉丝融合，禁止硬 min 刚体拼接。\n- 必须落齐 DPR 封顶、离屏/后台双停帧与 destroy 释放 context。\n\n【验收标准】\n- 多颗液态金属球在 3D 空间自由穿梭、靠拢时自然粘连起液桥、远离时顺滑拉断，表面有清晰水银镜面高光。\n- 鼠标移入时引力液滴以阻尼黏附拉扯主球团，移出后柔和回落中央。\n- 滚出视口、切后台或开启减弱动效时 rAF 自动停止；卸载无 WebGL context 泄漏。\n\n【禁止做法】\n- 别用 `min(d1, d2)` 代替 `smin` —— 球体相交只会留下一圈硬棱线，完全没有液态融合感。\n- 别在 JS 里每帧运行 Marching Cubes 生成三角形 —— 体积大且移动端必掉帧。\n- 别让指针球零阻尼硬跟鼠标 —— 失去流体惯性与拉丝重量感。",
        "prompt_en": "Core Principle:\nZero-Three.js native WebGL 3D liquid mercury metaballs (3D Raymarched Metaballs). In a transparent fullscreen-triangle fragment shader, blend 5 orbital 3D spheres and 1 pointer-damped attractor sphere into a continuous liquid surface via polynomial smooth minimum `smin(a, b, k)`, rendering brushed-mercury specular reflections with 42-step raymarching, central-difference normals, and reflection-vector environment shading.\n\nImplementation:\n1. Pure function `smoothMin(a, b, k = 0.35)`:\n   - Return `Math.min(a, b)` if `k <= 0`; otherwise compute `h = Math.max(k - Math.abs(a - b), 0) / k` and return `Math.min(a, b) - h * h * k * 0.25` (C1-continuous and strictly `<= min(a, b)`).\n2. Native WebGL engineering constraints:\n   - Single fullscreen triangle with `alpha: true` and `powerPreference: 'low-power'`; `DPR <= 1.5` and total canvas pixels `<= 1,200,000`.\n   - Attach `ResizeObserver`, `IntersectionObserver` (pause offscreen), and `visibilitychange` (pause in background); in `destroy()`, delete buffers/programs and actively invoke `loseContext()`.\n3. GLSL core:\n   - Short-edge normalized coordinates: `uv = (gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y)`; camera `ro = vec3(0, 0, 2.45)`, ray `rd = normalize(vec3(uv, -1.7))`.\n   - Scene SDF `mapBalls(p, t)`: 5 orbiting 3D spheres (radii `0.23–0.30`) following phase-offset trigonometric trajectories plus a 6th pointer sphere `cm = vec3((u_mouse.x - 0.5)*1.45, (u_mouse.y - 0.5)*1.1, 0.28)`, blended sequentially with `smin(d, ..., 0.36..0.42)`.\n   - Raymarch up to 42 steps: hit when `d < 0.002`, exit when `dist > 5.0`; on miss, return a soft centered ambient glow.\n   - On hit, compute normal `n` via 6-point central differences with `e = 0.0028`, compute reflection vector `rdir = reflect(-v, n)` mixing purple/blue/neon-green environment colors, and add power-`48` specular highlights plus power-`3.0` Fresnel rim lighting.\n4. Pointer damping & fallbacks:\n   - Approach target smoothly each frame with `mouse += (target - mouse) * 0.08`, easing back to center when the pointer leaves the container.\n   - Under `prefers-reduced-motion: reduce`, render a single static sculpture frame with no `rAF`; on `webglcontextlost` or lack of support, hide the canvas and display a CSS radial-gradient fallback.\n\nHard Constraints:\n- Strictly forbid Three.js or CPU Marching Cubes mesh reconstruction.\n- Must use polynomial `smin` for smooth stretching fusion; hard `min` rigid intersections are forbidden.\n- Must implement DPR capping, offscreen/background dual loop pausing, and context release in `destroy()`.\n\nAcceptance Criteria:\n- Multiple liquid metal spheres weave freely in 3D space, forming natural liquid bridges as they approach and snapping apart cleanly as they separate, with crisp mercury specular highlights.\n- Moving the pointer inside attracts and stretches the main cluster with damped inertia, gently settling back to center on exit.\n- `rAF` stops automatically when scrolled offscreen, backgrounded, or under reduced motion; zero WebGL context leaks on unmount.",
        "dont_do_en": "- Do NOT replace `smin` with `min(d1, d2)` — intersecting spheres will only show hard creases with zero liquid-fusion feel.\n- Do NOT run Marching Cubes in JS every frame to generate triangles — bundle size balloons and mobile framerates will drop.\n- Do NOT make the pointer sphere track the cursor with zero damping — it destroys the fluid inertia and viscous weight.",
        "skill_rule_en": "# WebGL 3D Liquid Mercury Metaballs (shader-metaballs) · Cross-Platform Motion Spec\nNature: Continuity | Layer: webgl | Platform: both\n\nCore Principle: Zero-Three.js native WebGL 3D liquid mercury metaballs (3D Raymarched Metaballs). In a transparent fullscreen-triangle fragment shader, blend 5 orbital 3D spheres and 1 pointer-damped attractor sphere into a continuous liquid surface via polynomial smooth minimum `smin(a, b, k)`, rendering brushed-mercury specular reflections with 42-step raymarching, central-difference normals, and reflection-vector environment shading.\n\nHard Constraints:\n- Strictly forbid Three.js or CPU Marching Cubes mesh reconstruction.\n- Must use polynomial `smin` for smooth stretching fusion; hard `min` rigid intersections are forbidden.\n- Must implement DPR capping, offscreen/background dual loop pausing, and context release in `destroy()`.\n\nAcceptance Criteria:\n- Multiple liquid metal spheres weave freely in 3D space, forming natural liquid bridges as they approach and snapping apart cleanly as they separate, with crisp mercury specular highlights.\n- Moving the pointer inside attracts and stretches the main cluster with damped inertia, gently settling back to center on exit.\n- `rAF` stops automatically when scrolled offscreen, backgrounded, or under reduced motion; zero WebGL context leaks on unmount.\n\nDo NOT Do:\n- Do NOT replace `smin` with `min(d1, d2)` — intersecting spheres will only show hard creases with zero liquid-fusion feel.\n- Do NOT run Marching Cubes in JS every frame to generate triangles — bundle size balloons and mobile framerates will drop.\n- Do NOT make the pointer sphere track the cursor with zero damping — it destroys the fluid inertia and viscous weight."
      }
    },
    {
      "id": "shader-orb",
      "name": "WebGL AI 液态能量光球",
      "name_en": "WebGL AI Energy Orb",
      "layer": "webgl",
      "nature": "材质",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.shaderOrb(host, { state }) + .mk-shader.mk-shader--orb",
      "source": "Apple Siri / AI 语音能量光球（噪声扰动 SDF + Fresnel 边缘发光 + idle/listening/thinking 三态平滑能量过渡）",
      "source_en": "Apple Siri / AI voice orb (SDF + cubic Fresnel + smoothed energy states)",
      "file": "effects/shader-orb.md",
      "summary": "原生 WebGL 用噪声扰动的圆 SDF + Fresnel 边缘亮环 + 外辉光渲染一颗漂浮的 AI 能量光球，支持 `idle` / `listening` / `thinking` 三态指数平滑切换呼吸速度与光晕强度。",
      "summary_en": "Noise-perturbed SDF sphere with cubic Fresnel rim and soft outer glow supporting exponentially smoothed idle / listening / thinking energy states on transparent canvas.",
      "problem": "**AI 助手、语音输入、思考加载态如果只放一个普通旋转圆圈，显得冰冷又没有生命感；但套 GIF/Lottie 视频既糊又无法根据对话状态实时改变能量节奏。** 一段 30 行的 SDF + Fresnel 着色器能以 60fps 无限清晰地表现从安静待机到高速思考的连续呼吸变化。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 球体径向 Fresnel（`pow(edge, 3.0)`）+ 指数衰减边缘亮环 `exp(-|d|*46)` + 柔和外辉光 | 昂贵的 3D 网格细分球体与光照贴图 |\n| 状态切换走指数逼近（每帧 `0.06`），光球“慢慢兴奋起来”而非瞬间切档 | 三套割裂的 Lottie 文件硬切 |\n| 透明背景 `alpha: true` + CSS 静态径向光球伪元素无缝兜底 | 盖死黑底导致无法叠在任意卡片上 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 三态能量 `ORB_STATES` | `idle: 0.25` / `listening: 0.6` / `thinking: 1.0` | 待机保持微妙生命感（非完全死静）、聆听明显活跃、思考达到满功率高频流动 |\n| 状态过渡阻尼 | `cur += (target - cur) * 0.06` | 约 0.8s 内平滑升档/降档，像生物呼吸加速而不是机械开关 |\n| 边缘 Fresnel 指数 | `pow(edge, 3.0)` | 中心透亮柔和、球面轮廓边缘陡然提亮，立刻建立立体玻璃球感 |\n| 透明背景 | `alpha: true` + `a = clamp(body + glow + rim, 0, 1)` | 光球可直接悬浮在任意暗色卡片、弹窗或顶栏上，外辉光自然融入底层 |",
      "implementation": "```\nsrc/core/shader.js:35    ORB_STATES / orbEnergy(state)    纯函数，支持命名态或 0..1 连续值（可接麦克风音量）\nsrc/core/shader.js:121   ORB_FRAG                         SDF + Fresnel + 外辉光 GLSL\nsrc/core/shader.js:326   shaderOrb(host, { state })       返回 { setState(next), destroy() }\nstyles/webgl.css:36      .mk-shader--orb::before          WebGL 未就绪或降级时的 CSS 静态光球兜底\n```",
      "degradation": "**走 `webgl` 层专属契约：退回 CSS 静态光球 + 减弱动效单帧冻结。**\n\n- `prefers-reduced-motion: reduce`：只画 1 帧静态光球，`setState()` 时仅重绘 1 帧反映状态亮度变化，不跑连续循环。\n- WebGL 不可用或上下文丢失时，容器 `::before` 伪元素呈现高质感 CSS 径向渐变光球，绝不留空白。",
      "pitfalls": "**① 球体半径未按 `min(u_res.x, u_res.y)` 归一化导致在宽屏卡片里被压成椭圆。**\n必须用 `(gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y)` 保持严格 1:1 正圆坐标，且基准半径 `0.29` 给外辉光留足空间不被画布边界硬裁。\n\n**② 外辉光触碰到 `<canvas>` 边缘被切成一条硬直线。**\n基准半径超过 `0.42` 时辉光必然撞到画布四边露出方框感；压在 `0.29` 并让 `exp(-max(d,0)*8.5)` 在边缘前衰减归零。\n\n**③ 切 `state` 时直接把 `u_energy` 硬跳变。**\n直接硬改 `u_energy` 会让表面噪声相位瞬间撕裂跳闪；必须用每帧 `0.06` 的插值平滑过渡能量值。\n\n---",
      "ai_assets": {
        "prompt": "实现零 Three.js 依赖的原生 WebGL AI 液态能量光球（Fresnel Noise Energy Orb）。\n\n原理一句话：在透明画布上用按短边归一化的 2D 圆 SDF 叠加 Simplex Noise 边界形变、立方 Fresnel 边缘亮环与指数外辉光，通过指数平滑的 u_energy 统一驱动 idle / listening / thinking 三态呼吸。\n\n做法：\n1. 纯函数 orbEnergy(state)：映射 { idle: 0.25, listening: 0.6, thinking: 1.0 }；若传入 0..1 有限数字则钳制后直接返回（方便接入实时音量）。\n2. 原生 WebGL 透明画布（alpha: true, premultipliedAlpha: true，DPR <= 1.5，离屏/后台双停帧，卸载释放 context）。\n3. 片元着色器核心：\n   - 正圆归一化坐标：uv = (gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y)；r = length(uv)。\n   - 动态半径：speed = 0.25 + u_energy * 1.1；n = snoise(normalize(uv) * 1.3 + vec2(t * speed, -t * speed * 0.7))；\n     radius = 0.29 + n * 0.03 * (0.55 + u_energy)；d = r - radius。\n   - 三层叠加：\n     body = smoothstep(0.006, -0.006, d)（抗锯齿实心球体）；\n     fres = pow(clamp(r / radius, 0.0, 1.0), 3.0)（边缘提亮）；\n     rim = exp(-abs(d) * 46.0) * (0.55 + u_energy * 0.9)（高能亮环）；\n     glow = exp(-max(d, 0.0) * 8.5) * (0.22 + u_energy * 0.38) * (1.0 - body)（柔和外辉光）；\n     叠加左上角镜面高光点，最终 alpha = clamp(body + glow + rim, 0.0, 1.0)。\n4. 状态平滑与降级：\n   - setState(next) 更新目标能量 target，每帧 cur += (target - cur) * 0.06 平滑逼近（绝不硬跳）。\n   - 容器 ::before 提供同色系 CSS 静态光球兜底，WebGL 首帧画好后隐藏伪元素；context lost 时自动恢复显示。\n   - prefers-reduced-motion: reduce 下仅画静态单帧，切换状态时仅单次重绘。\n\n硬要求：\n- 必须用 min(u_res.x, u_res.y) 归一化坐标，且基准半径 <= 0.31 确保外辉光不被画布方框裁切。\n- 必须平滑插值 u_energy，禁止状态切换时噪声画面跳闪。\n- 必须支持透明背景叠加与 CSS 静态兜底，严禁引入 Three.js。\n\n验收：\n- 在任意宽/高比例容器内光球均保持严格正圆且外辉光自然消散无硬边。\n- 从 idle 切到 thinking 时，光球在 ~0.8s 内平滑加速扰动并增强边缘亮环，无跳帧。\n- 滚出视口、切后台或开启减弱动效时 rAF 自动停止；卸载后 WebGL context 被正确释放。",
        "dont_do": "- 别把球体半径写到 `0.45` 以上 —— 外辉光会被 canvas 四条边硬切出难看的方框。\n- 别用 `gl_FragCoord.xy / u_res` 直接算圆 —— 非正方形容器里光球会被压成鸡蛋。\n- 别给三个状态分别准备三段 MP4/GIF —— 体积大、不清晰且状态切换必定生硬断开。",
        "skill_rule": "# WebGL AI 液态能量光球 (shader-orb) · 跨平台动效规范\n性质：材质 ｜ 平台：both\n\n【核心原理】在透明画布上用按短边归一化的 2D 圆 SDF 叠加 Simplex Noise 边界形变、立方 Fresnel 边缘亮环与指数外辉光，通过指数平滑的 u_energy 统一驱动 idle / listening / thinking 三态呼吸。\n\n【硬要求】\n- 必须用 min(u_res.x, u_res.y) 归一化坐标，且基准半径 <= 0.31 确保外辉光不被画布方框裁切。\n- 必须平滑插值 u_energy，禁止状态切换时噪声画面跳闪。\n- 必须支持透明背景叠加与 CSS 静态兜底，严禁引入 Three.js。\n\n【验收标准】\n- 在任意宽/高比例容器内光球均保持严格正圆且外辉光自然消散无硬边。\n- 从 idle 切到 thinking 时，光球在 ~0.8s 内平滑加速扰动并增强边缘亮环，无跳帧。\n- 滚出视口、切后台或开启减弱动效时 rAF 自动停止；卸载后 WebGL context 被正确释放。\n\n【禁止做法】\n- 别把球体半径写到 `0.45` 以上 —— 外辉光会被 canvas 四条边硬切出难看的方框。\n- 别用 `gl_FragCoord.xy / u_res` 直接算圆 —— 非正方形容器里光球会被压成鸡蛋。\n- 别给三个状态分别准备三段 MP4/GIF —— 体积大、不清晰且状态切换必定生硬断开。",
        "prompt_en": "Core Principle:\nZero-Three.js native WebGL AI liquid energy orb (Fresnel Noise Energy Orb). On a transparent canvas, combine a short-edge-normalized 2D circle SDF with Simplex Noise boundary displacement, cubic Fresnel edge brightening, and exponential outer glow, unifying `idle` / `listening` / `thinking` breathing states via exponentially smoothed `u_energy`.\n\nImplementation:\n1. Pure function `orbEnergy(state)`: maps `{ idle: 0.25, listening: 0.6, thinking: 1.0 }`; if passed a finite number in `0..1`, clamp and return it directly (for live audio-level binding).\n2. Native WebGL transparent canvas (`alpha: true`, `premultipliedAlpha: true`, `DPR <= 1.5`, offscreen/background dual pausing, context release on unmount).\n3. Fragment shader core:\n   - True-circle normalized coordinates: `uv = (gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y)`; `r = length(uv)`.\n   - Dynamic radius: `speed = 0.25 + u_energy * 1.1`; `n = snoise(normalize(uv) * 1.3 + vec2(t * speed, -t * speed * 0.7))`;\n     `radius = 0.29 + n * 0.03 * (0.55 + u_energy)`; `d = r - radius`.\n   - Three-layer composition:\n     `body = smoothstep(0.006, -0.006, d)` (anti-aliased solid core);\n     `fres = pow(clamp(r / radius, 0.0, 1.0), 3.0)` (edge brightening);\n     `rim = exp(-abs(d) * 46.0) * (0.55 + u_energy * 0.9)` (high-energy bright ring);\n     `glow = exp(-max(d, 0.0) * 8.5) * (0.22 + u_energy * 0.38) * (1.0 - body)` (soft outer halo);\n     add a top-left specular highlight and set final `alpha = clamp(body + glow + rim, 0.0, 1.0)`.\n4. State smoothing & fallbacks:\n   - `setState(next)` updates `target` energy, and each frame interpolates `cur += (target - cur) * 0.06` (never hard-jumping).\n   - Container `::before` provides a color-matched CSS static orb fallback, hidden once WebGL draws its first frame and restored automatically on `webglcontextlost`.\n   - Under `prefers-reduced-motion: reduce`, draw only a single static frame and redraw once on state changes.\n\nHard Constraints:\n- Must normalize coordinates by `min(u_res.x, u_res.y)` with base radius `<= 0.31` so the outer glow is never clipped by the canvas edges.\n- Must smoothly interpolate `u_energy`; sudden noise jumps on state transitions are forbidden.\n- Must support transparent background compositing and CSS static fallback; Three.js is strictly forbidden.\n\nAcceptance Criteria:\n- The orb remains a strict true circle in containers of any aspect ratio, with its outer glow fading out naturally without hard edges.\n- Switching from `idle` to `thinking` smoothly accelerates turbulence and intensifies the rim ring within `~0.8s` with zero frame jumps.\n- `rAF` stops automatically when scrolled offscreen, backgrounded, or under reduced motion; WebGL context is properly released on unmount.",
        "dont_do_en": "- Do NOT set the sphere radius above `0.45` — the outer glow will be hard-clipped into an ugly box by the four canvas edges.\n- Do NOT compute the circle directly from `gl_FragCoord.xy / u_res` — the orb will stretch into an oval in non-square containers.\n- Do NOT prepare three separate MP4/GIF clips for the three states — file sizes are huge, resolution suffers, and state transitions will cut abruptly.",
        "skill_rule_en": "# WebGL AI Energy Orb (shader-orb) · Cross-Platform Motion Spec\nNature: Material | Layer: webgl | Platform: both\n\nCore Principle: Zero-Three.js native WebGL AI liquid energy orb (Fresnel Noise Energy Orb). On a transparent canvas, combine a short-edge-normalized 2D circle SDF with Simplex Noise boundary displacement, cubic Fresnel edge brightening, and exponential outer glow, unifying `idle` / `listening` / `thinking` breathing states via exponentially smoothed `u_energy`.\n\nHard Constraints:\n- Must normalize coordinates by `min(u_res.x, u_res.y)` with base radius `<= 0.31` so the outer glow is never clipped by the canvas edges.\n- Must smoothly interpolate `u_energy`; sudden noise jumps on state transitions are forbidden.\n- Must support transparent background compositing and CSS static fallback; Three.js is strictly forbidden.\n\nAcceptance Criteria:\n- The orb remains a strict true circle in containers of any aspect ratio, with its outer glow fading out naturally without hard edges.\n- Switching from `idle` to `thinking` smoothly accelerates turbulence and intensifies the rim ring within `~0.8s` with zero frame jumps.\n- `rAF` stops automatically when scrolled offscreen, backgrounded, or under reduced motion; WebGL context is properly released on unmount.\n\nDo NOT Do:\n- Do NOT set the sphere radius above `0.45` — the outer glow will be hard-clipped into an ugly box by the four canvas edges.\n- Do NOT compute the circle directly from `gl_FragCoord.xy / u_res` — the orb will stretch into an oval in non-square containers.\n- Do NOT prepare three separate MP4/GIF clips for the three states — file sizes are huge, resolution suffers, and state transitions will cut abruptly."
      }
    },
    {
      "id": "shader-particles",
      "name": "WebGL 3D GPU 星尘粒子星云",
      "name_en": "WebGL 3D Spiral Nebula Particles",
      "layer": "webgl",
      "nature": "权重",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.shaderParticles(host, { count, seed }) + .mk-shader.mk-shader--particles",
      "source": "真 3D 螺旋星系粒子场（单次 gl.POINTS 绘制 1500 颗粒子 + 近大远小透视 + 指针 3D 视角旋转 + 加法混合）",
      "source_en": "Native WebGL gl.POINTS 3D spiral galaxy (static VBO + additive bloom)",
      "file": "effects/shader-particles.md",
      "summary": "单次 `gl.drawArrays(gl.POINTS, 0, 1500)` 在 GPU 上同时投影并渲染 1,500 颗三旋臂 3D 螺旋星云粒子，近大远小带景深光晕，随指针平滑转动整个星系视角。",
      "summary_en": "Single gl.POINTS draw call projecting 1,500 three-arm 3D spiral galaxy particles with pointer yaw/pitch rotation, perspective sizing, and additive core bloom.",
      "problem": "**想在深色数据大屏、AI 入口或 3D 展厅里做满天星尘的立体纵深感，但用 DOM 节点放几百个 `<div>` 会瞬间压垮合成层，用 Canvas 2D 每帧在 JS 里循环算 1,500 次三角函数投影又会把主线程卡死。** 把所有 3D 坐标一次性写入 GPU 静态 VBO，每帧在顶点着色器里并行旋转与透视投影，主线程几乎零开销。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 三旋臂螺旋分布（`pow(rnd, 0.72)` 中心略密、边缘散开）+ 确定性伪随机种子 | 均匀填满立方体的杂乱噪点（像雪花屏而不是星系） |\n| 顶点着色器并行计算 `rot2` 旋转、透视缩放 `gl_PointSize` 与景深透明度 `v_depth` | 主线程 JS 每帧 `for` 循环手算 1,500 个粒子矩阵 |\n| `gl.blendFunc(gl.ONE, gl.ONE)` 加法混合 + 片元圆形柔焦散景 | 方块硬边缘粒子或昂贵的深度排序 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 粒子数 `count` | 默认 `1500`（三旋臂） | 视觉上足够绵密成星云，单次 draw call 在移动端集成显卡上仍轻松 60fps |\n| 粒子径向分布 | `r = 0.14 + pow(rnd, 0.72) * 1.45` | 避开绝对中心奇点且内密外疏，形成有核心重量的旋涡星系层次 |\n| 相机距离与点径 | `z = p.z + 3.2` / `gl_PointSize = clamp(13 * dpr / z, 1.4, 9.0)` | 近处粒子饱满通透、远处自然缩成细星，且上限 9px 防止贴脸爆大糊块 |\n| 混合模式 | 预乘加法 `gl.blendFunc(gl.ONE, gl.ONE)` | 重叠的星尘自动叠加出星核辉光，且加法混合与绘制顺序无关，省去 Z 排序 |",
      "implementation": "```\nsrc/core/shader.js:63    nebulaPositions(count, seed)   确定性三旋臂 3D 星云粒子生成器（可单测）\nsrc/core/shader.js:521   PARTICLE_VERT / PARTICLE_FRAG  GPU 3D 旋转投影 + 圆形柔焦星尘片元着色器\nsrc/core/shader.js:569   shaderParticles(host, opts)    gl.POINTS 渲染器（DPR 1.5 + 双停帧 + 释放 context）\nstyles/webgl.css:72      .mk-shader--particles          WebGL 未就绪或降级时的星云径向渐变兜底\n```",
      "degradation": "**走 `webgl` 层专属契约：退回 CSS 渐变 + 减弱动效单帧冻结。**\n\n- `prefers-reduced-motion: reduce`：仅渲染 `t = 4s` 一帧静态 3D 星云，不启动 rAF 循环，不响应指针晃动。\n- 不支持 WebGL 或触发 `webglcontextlost` 时隐藏 `<canvas>`，显示容器上的深空星云渐变底色。",
      "pitfalls": "**① 在片元着色器里忘了裁掉 `gl_PointCoord` 四角导致满屏都是发光小方块。**\nWebGL 的 `gl.POINTS` 默认画的是正方形点精灵；必须在片元里算 `r = dot(c, c)`，大于 `0.25` 直接 `discard` 并用 `smoothstep(0.25, 0.0, r)` 画出柔焦圆点。\n\n**② 粒子坐标在 JS 每帧重新 `bufferData` 上传到 GPU。**\n星云的静态拓扑只需在初始化时用 `gl.STATIC_DRAW` 上传一次；旋转、起伏波动和透视全放进顶点着色器，每帧只传 `u_time` 和 `u_mouse` 两个 uniform。\n\n**③ 忘了按画布宽高比 `asp = u_res.x / u_res.y` 修正 X 轴投影。**\n宽屏容器里不把 `p.x` 除以 `asp`，整片星系会被横向拉成一根扁椭圆。\n\n---",
      "ai_assets": {
        "prompt": "实现零 Three.js 依赖的原生 WebGL 3D GPU 星尘粒子星云（gl.POINTS 3D Spiral Nebula）。\n\n原理一句话：初始化时用确定性伪随机生成 1,500 颗三旋臂 3D 坐标 (x, y, z, phase) 一次性写入 GPU 静态 VBO，每帧在顶点着色器里完成指针 3D 旋转与近大远小透视投影，片元裁剪柔焦圆点并用加法混合叠出星核辉光。\n\n做法：\n1. 纯函数 nebulaPositions(count = 1500, seed = 1337)：\n   - 返回 Float32Array(count * 4)，每颗粒子占 4 个 float：(x, y, z, phase)。\n   - 使用确定性 Xorshift32 伪随机（保证同种子同输出），均分 3 条旋臂（arms = 3）：\n     t = pow(rnd(), 0.72)；r = 0.14 + t * 1.45；angle = (arm / 3) * 2π + r * 2.35 + (rnd() - 0.5) * 0.65；\n     spread = 0.12 + t * 0.28；x = cos(angle)*r + jitter；z = sin(angle)*r + jitter；\n     y = (rnd() - 0.5) * (0.45 * (1 - t * 0.55))；phase = rnd()。\n2. WebGL 管线与工程约束：\n   - 仅初始化一次 gl.STATIC_DRAW VBO；开启 gl.enable(gl.BLEND) 与 gl.blendFunc(gl.ONE, gl.ONE) 加法混合。\n   - DPR 封顶 1.5 且总像素 <= 1,200,000；接 ResizeObserver、IntersectionObserver（离屏停帧）与 visibilitychange（后台停帧）；destroy() 释放 buffer、program 并调用 WEBGL_lose_context.loseContext()。\n3. 顶点与片元着色器：\n   - 顶点着色器：将 a_pos.xyz 绕 XZ 旋 t*0.22 + (u_mouse.x - 0.5)*1.4，绕 YZ 旋 0.42 + (u_mouse.y - 0.5)*0.9，并叠加 sin(t*2.0 + phase*2π) * 0.05 的轻微纵波起伏。\n   - 透视投影：z = p.z + 3.2；asp = u_res.x / max(u_res.y, 1.0)；proj = vec2(p.x / asp, p.y) * (1.75 / max(z, 0.2))；\n     gl_PointSize = clamp((13.0 * u_dpr) / max(z, 0.4), 1.4, 9.0)；v_depth = clamp(1.0 - (z - 1.5) / 3.4, 0.15, 1.0)。\n   - 片元着色器：c = gl_PointCoord - 0.5；r = dot(c, c)；if (r > 0.25) discard；\n     a = smoothstep(0.25, 0.0, r) * v_depth；按 v_phase 混合蓝/紫/青绿星色，输出 vec4(col * a, a * 0.92)。\n4. 降级：\n   - prefers-reduced-motion: reduce 仅画 t = 4s 一帧静态星云，不起 rAF。\n   - 不支持 WebGL 或 webglcontextlost 时隐藏 canvas 展示 CSS 径向渐变兜底。\n\n硬要求：\n- 所有粒子必须一次 STATIC_DRAW 上传、单次 gl.drawArrays(gl.POINTS, 0, count) 绘制，严禁每帧在 JS 循环更新顶点缓冲。\n- 必须在片元中丢弃四角并做径向柔焦，禁止渲染正方形硬边点。\n- 严禁引入 Three.js，必须包含 DPR 封顶、离屏/后台双停帧与 context 清理。\n\n验收：\n- 1,500 颗星尘形成清晰的三旋臂 3D 星系，近处大而亮、远处细而柔，星核因加法混合自然泛光。\n- 移动鼠标时整个星系随 0.08 阻尼平滑倾斜转向，宽屏与窄屏容器内星系比例均不拉伸变形。\n- 滚出视口、切后台或开启减弱动效时 rAF 归零；卸载后无 WebGL context 泄漏。",
        "dont_do": "- 别用 1,500 个 DOM 节点或每帧 JS 重算粒子坐标上传 VBO —— CPU 立刻跑满掉帧。\n- 别忘了在片元着色器里把 `dot(c, c) > 0.25` 裁掉 —— 满屏发光方块毫无质感。\n- 别在 `gl.POINTS` 上开启深度写入后再做半透明混合 —— 粒子之间会出现难看的方形黑框遮挡，直接用加法混合 `ONE, ONE` 即可。",
        "skill_rule": "# WebGL 3D GPU 星尘粒子星云 (shader-particles) · 跨平台动效规范\n性质：权重 ｜ 平台：both\n\n【核心原理】初始化时用确定性伪随机生成 1,500 颗三旋臂 3D 坐标 (x, y, z, phase) 一次性写入 GPU 静态 VBO，每帧在顶点着色器里完成指针 3D 旋转与近大远小透视投影，片元裁剪柔焦圆点并用加法混合叠出星核辉光。\n\n【硬要求】\n- 所有粒子必须一次 STATIC_DRAW 上传、单次 gl.drawArrays(gl.POINTS, 0, count) 绘制，严禁每帧在 JS 循环更新顶点缓冲。\n- 必须在片元中丢弃四角并做径向柔焦，禁止渲染正方形硬边点。\n- 严禁引入 Three.js，必须包含 DPR 封顶、离屏/后台双停帧与 context 清理。\n\n【验收标准】\n- 1,500 颗星尘形成清晰的三旋臂 3D 星系，近处大而亮、远处细而柔，星核因加法混合自然泛光。\n- 移动鼠标时整个星系随 0.08 阻尼平滑倾斜转向，宽屏与窄屏容器内星系比例均不拉伸变形。\n- 滚出视口、切后台或开启减弱动效时 rAF 归零；卸载后无 WebGL context 泄漏。\n\n【禁止做法】\n- 别用 1,500 个 DOM 节点或每帧 JS 重算粒子坐标上传 VBO —— CPU 立刻跑满掉帧。\n- 别忘了在片元着色器里把 `dot(c, c) > 0.25` 裁掉 —— 满屏发光方块毫无质感。\n- 别在 `gl.POINTS` 上开启深度写入后再做半透明混合 —— 粒子之间会出现难看的方形黑框遮挡，直接用加法混合 `ONE, ONE` 即可。",
        "prompt_en": "Core Principle:\nZero-Three.js native WebGL 3D GPU stardust spiral nebula (`gl.POINTS` 3D Spiral Nebula). At initialization, deterministically generate 1,500 three-arm 3D coordinates `(x, y, z, phase)` and upload them once to a static GPU VBO; each frame, perform pointer-driven 3D rotation and perspective projection in the vertex shader, then discard corners in the fragment shader for soft radial discs with additive blending to build a glowing galactic core.\n\nImplementation:\n1. Pure function `nebulaPositions(count = 1500, seed = 1337)`:\n   - Returns `Float32Array(count * 4)` where each particle stores 4 floats `(x, y, z, phase)`.\n   - Uses deterministic Xorshift32 PRNG (identical output for identical seed) distributed evenly across 3 spiral arms (`arms = 3`):\n     `t = pow(rnd(), 0.72)`; `r = 0.14 + t * 1.45`; `angle = (arm / 3) * 2π + r * 2.35 + (rnd() - 0.5) * 0.65`;\n     `spread = 0.12 + t * 0.28`; `x = cos(angle)*r + jitter`; `z = sin(angle)*r + jitter`;\n     `y = (rnd() - 0.5) * (0.45 * (1 - t * 0.55))`; `phase = rnd()`.\n2. WebGL pipeline & engineering constraints:\n   - Upload once into a `gl.STATIC_DRAW` VBO; enable `gl.enable(gl.BLEND)` with `gl.blendFunc(gl.ONE, gl.ONE)` additive blending.\n   - Cap DPR at `1.5` and total pixels `<= 1,200,000`; attach `ResizeObserver`, `IntersectionObserver` (pause offscreen), and `visibilitychange` (pause in background); in `destroy()`, delete buffers/programs and call `WEBGL_lose_context.loseContext()`.\n3. Vertex & fragment shaders:\n   - Vertex shader: rotate `a_pos.xyz` around XZ by `t*0.22 + (u_mouse.x - 0.5)*1.4` and around YZ by `0.42 + (u_mouse.y - 0.5)*0.9`, adding a subtle vertical wave `sin(t*2.0 + phase*2π) * 0.05`.\n   - Perspective projection: `z = p.z + 3.2`; `asp = u_res.x / max(u_res.y, 1.0)`; `proj = vec2(p.x / asp, p.y) * (1.75 / max(z, 0.2))`;\n     `gl_PointSize = clamp((13.0 * u_dpr) / max(z, 0.4), 1.4, 9.0)`; `v_depth = clamp(1.0 - (z - 1.5) / 3.4, 0.15, 1.0)`.\n   - Fragment shader: `c = gl_PointCoord - 0.5`; `r = dot(c, c)`; `if (r > 0.25) discard`;\n     `a = smoothstep(0.25, 0.0, r) * v_depth`; mix blue/purple/cyan-green star colors by `v_phase` and output `vec4(col * a, a * 0.92)`.\n4. Fallbacks:\n   - Under `prefers-reduced-motion: reduce`, render a single static nebula frame at `t = 4s` with no `rAF`.\n   - When WebGL is unsupported or on `webglcontextlost`, hide the canvas and display a CSS radial-gradient fallback.\n\nHard Constraints:\n- All particles must be uploaded once with `STATIC_DRAW` and drawn in a single `gl.drawArrays(gl.POINTS, 0, count)` call; never update vertex buffers in a JS loop each frame.\n- Must discard corners and apply radial soft falloff in the fragment shader; rendering hard-edged square points is forbidden.\n- Strictly forbid Three.js; must include DPR capping, offscreen/background dual pausing, and context cleanup.\n\nAcceptance Criteria:\n- 1,500 stardust particles form a distinct three-arm 3D spiral galaxy—larger and brighter up close, finer and softer at distance—with natural core bloom from additive blending.\n- Moving the pointer tilts and steers the entire galaxy smoothly with `0.08` damping, maintaining undistorted proportions in both wide and narrow containers.\n- `rAF` drops to zero when scrolled offscreen, backgrounded, or under reduced motion; zero WebGL context leaks after unmount.",
        "dont_do_en": "- Do NOT use 1,500 DOM nodes or recompute and re-upload particle coordinates in JS every frame — the CPU will max out and drop frames immediately.\n- Do NOT forget to discard `dot(c, c) > 0.25` in the fragment shader — a screen full of glowing squares looks cheap.\n- Do NOT enable depth writes alongside translucent blending on `gl.POINTS` — particles will occlude each other with ugly dark square boxes; use additive blending `ONE, ONE` instead.",
        "skill_rule_en": "# WebGL 3D Spiral Nebula Particles (shader-particles) · Cross-Platform Motion Spec\nNature: Weight | Layer: webgl | Platform: both\n\nCore Principle: Zero-Three.js native WebGL 3D GPU stardust spiral nebula (`gl.POINTS` 3D Spiral Nebula). At initialization, deterministically generate 1,500 three-arm 3D coordinates `(x, y, z, phase)` and upload them once to a static GPU VBO; each frame, perform pointer-driven 3D rotation and perspective projection in the vertex shader, then discard corners in the fragment shader for soft radial discs with additive blending to build a glowing galactic core.\n\nHard Constraints:\n- All particles must be uploaded once with `STATIC_DRAW` and drawn in a single `gl.drawArrays(gl.POINTS, 0, count)` call; never update vertex buffers in a JS loop each frame.\n- Must discard corners and apply radial soft falloff in the fragment shader; rendering hard-edged square points is forbidden.\n- Strictly forbid Three.js; must include DPR capping, offscreen/background dual pausing, and context cleanup.\n\nAcceptance Criteria:\n- 1,500 stardust particles form a distinct three-arm 3D spiral galaxy—larger and brighter up close, finer and softer at distance—with natural core bloom from additive blending.\n- Moving the pointer tilts and steers the entire galaxy smoothly with `0.08` damping, maintaining undistorted proportions in both wide and narrow containers.\n- `rAF` drops to zero when scrolled offscreen, backgrounded, or under reduced motion; zero WebGL context leaks after unmount.\n\nDo NOT Do:\n- Do NOT use 1,500 DOM nodes or recompute and re-upload particle coordinates in JS every frame — the CPU will max out and drop frames immediately.\n- Do NOT forget to discard `dot(c, c) > 0.25` in the fragment shader — a screen full of glowing squares looks cheap.\n- Do NOT enable depth writes alongside translucent blending on `gl.POINTS` — particles will occlude each other with ugly dark square boxes; use additive blending `ONE, ONE` instead."
      }
    },
    {
      "id": "shader-ripple",
      "name": "WebGL 光学水波纹折射",
      "name_en": "WebGL Optical Water Ripples",
      "layer": "webgl",
      "nature": "反馈",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.shaderRipple(host, opts) + .mk-shader.mk-shader--ripple",
      "source": "光学水面涟漪折射（6 槽环形池 + 正弦高斯波包位移 + 波峰高光与轻微色散，零 Three.js）",
      "source_en": "Native WebGL optical water refraction (6 concurrent wave slots + dispersion)",
      "file": "effects/shader-ripple.md",
      "summary": "点击或触碰表面时，片元着色器从触点向外扩散一圈带高斯包络的物理水波，实时折弯底层纹理并叠加波峰高光与轻微色散；支持 6 道波纹并发叠加与自动过期复用。",
      "summary_en": "Pointer-triggered Gaussian sine-wave refraction rings with subtle chromatic aberration and specular crests, supporting 6 concurrent auto-recycled ripple slots.",
      "problem": "**普通 CSS 点击涟漪只是一个半透明白圆放大淡出，缺少“液体表面真的被按出波纹并折弯光线”的沉浸感。** 在互动封面、创意卡片或音视频表面，用 6 槽 uniform 数组在 GPU 上实时叠加多道水波位移，点击哪里就从哪里荡开一圈真实光学涟漪。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 高斯包络调制正弦波 `exp(-k²*120) * sin(k*70) * fade²`，既有波峰波谷又自然消散 | 昂贵的双缓冲 FBO 流体纳维-斯托克斯求解器 |\n| 6 槽固定 `uniform vec3 u_rip[6]`（`x, y, startTime`），纯函数 `rippleSlot()` 优先复用过期槽 | 无限增长的波纹数组导致 shader 循环失控 |\n| 按位移幅度叠一点色散 + 波峰高光，水面折射感立竿见影 | 过度扭曲把底层画面拉扯成马赛克 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 并发槽数 | `6` | 连续快点 6 下均可完整同屏叠加干涉；超出后自动覆盖最老的一道波，片元开销恒定可控 |\n| 波纹寿命 `LIFE` | `2.2s` | 刚好够一圈水波优雅扩散过整个卡片并自然消隐，不显得戛然而止 |\n| 波速 | `0.42` 归一化单位/秒 | 类似平静水面的扩散速度，快于 0.8 像冲击波、慢于 0.2 像粘稠糖浆 |\n| 折射强度 | `0.02` UV 位移 | 足够明显折弯背后条纹又保持清晰优雅，超过 0.06 会撕裂变形 |",
      "implementation": "```\nsrc/core/shader.js:43    rippleEnvelope(age, life)       纯函数，平方衰减包络（可单测）\nsrc/core/shader.js:50    rippleSlot(starts, now, life)   纯函数，槽位分配与最老覆盖（可单测）\nsrc/core/shader.js:146   RIPPLE_FRAG                     6 槽并发光学水波 + 高光 + 色散 GLSL\nsrc/core/shader.js:349   shaderRipple(host, opts)        pointerdown 触发 + 闲置偶发环境滴落\nstyles/webgl.css:54      .mk-shader--ripple              静态条纹渐变兜底\n```",
      "degradation": "**走 `webgl` 层专属契约：退回静态条纹渐变 + 减弱动效单帧冻结。**\n\n- `prefers-reduced-motion: reduce`：不触发水波动画、不跑环境滴落，保持安静静态画面。\n- 不支持 WebGL 或 `webglcontextlost` 时显示容器静态 CSS 条纹渐变底图。",
      "pitfalls": "**① 忘记把点击的屏幕 Y 坐标翻转成 WebGL 坐标系（Y 轴向上）。**\nDOM `clientY` 从顶向下递增，而 GLSL `gl_FragCoord.y` 从底向上递增；必须计算 `uvY = 1 - (clientY - rect.top) / rect.height`，否则点上面波纹从下面冒出来。\n\n**② 没按宽高比 `aspect = u_res.x / u_res.y` 修正距离向量。**\n宽卡片里直接算 `length(uv - center)` 会把圆形水波拉成扁椭圆；必须先把 X 差值乘以 `aspect` 再求长度。\n\n**③ 没对 `length(d)` 做 `max(dist, 1e-4)` 保护。**\n波心处 `d = (0, 0)`，直接做 `d / dist` 会在波纹中心产生 `NaN` 黑点。\n\n---",
      "ai_assets": {
        "prompt": "实现零 Three.js 依赖的原生 WebGL 光学水波纹折射效果（Optical Water Ripple Shader）。\n\n原理一句话：维护 6 槽固定 uniform vec3 u_rip[6]（x, y, startTime），片元着色器将每道活跃水波的高斯正弦波包合成径向 UV 位移来折弯底层纹理，并叠加波峰高光与轻微色散。\n\n做法：\n1. 纯函数槽位管理（寿命 LIFE = 2.2s）：\n   - rippleSlot(starts, now, life = 2.2)：优先返回空槽（< 0）或已过期槽（now - s >= life），若全忙则覆盖最早的槽。\n   - rippleEnvelope(age, life = 2.2)：age 在 [0, life) 内返回 (1 - age / life)²，否则 0。\n2. 指针坐标换算（关键：Y 轴翻转）：\n   - pointerdown 时算 x = (e.clientX - rect.left) / rect.width，y = 1 - (e.clientY - rect.top) / rect.height，写入选中槽位 (x, y, currentTimeSec)。\n3. 片元着色器（DPR <= 1.5，离屏/后台双停帧，卸载释放 context）：\n   - asp = u_res.x / u_res.y；遍历 6 槽跳过无效或超时项。\n   - d = (uv - rp.xy) * vec2(asp, 1.0)；dist = length(d)；k = dist - age * 0.42；\n   - fade = 1.0 - age / 2.2；env = exp(-k * k * 120.0) * fade * fade；w = sin(k * 70.0) * env；\n   - disp += (d / max(dist, 1e-4)) * w * 0.02；hi += env * max(w, 0.0)；\n   - 用 suv = uv + disp 采样底层纹理/程序化条纹，叠加轻微色散与 hi * 0.55 高光。\n\n硬要求：\n- 必须翻转 Y 坐标（1 - clientY_norm）并按宽高比修正距离向量，保证触点精准且波纹为正圆。\n- 波心除法必须用 max(dist, 1e-4) 防止 NaN 黑点。\n- 并发槽数固定上限（6 槽），严禁动态无限增长循环。\n- 必须含 DPR<=1.5、离屏/后台停帧、卸载 loseContext 与 CSS 静态兜底；prefers-reduced-motion 下停止动画。\n\n验收：\n- 点击画布任意位置，严格正圆水波精准从点击点向外扩散 2.2s，肉眼可见底层纹理被波峰折弯并带柔和光泽。\n- 连续快点 6 次以上，多道波纹自然叠加干涉、不卡顿不溢出，最老槽平滑复用。\n- 滚出视口或切后台 rAF 停止；不支持 WebGL 时平滑回退 CSS 静态底纹。",
        "dont_do": "- 别忘了翻转 Y 坐标 —— 否则点上半区水波从下半区炸出来。\n- 别在非正方形画布里省掉 `aspect` 修正 —— 水波会被拉扁成椭圆。\n- 别在波心直接写 `normalize(d)` 或 `d / length(d)` —— 中心点 `0/0` 会冒出一个永久黑像素。",
        "skill_rule": "# WebGL 光学水波纹折射 (shader-ripple) · 跨平台动效规范\n性质：反馈 ｜ 平台：both\n\n【核心原理】维护 6 槽固定 uniform vec3 u_rip[6]（x, y, startTime），片元着色器将每道活跃水波的高斯正弦波包合成径向 UV 位移来折弯底层纹理，并叠加波峰高光与轻微色散。\n\n【硬要求】\n- 必须翻转 Y 坐标（1 - clientY_norm）并按宽高比修正距离向量，保证触点精准且波纹为正圆。\n- 波心除法必须用 max(dist, 1e-4) 防止 NaN 黑点。\n- 并发槽数固定上限（6 槽），严禁动态无限增长循环。\n- 必须含 DPR<=1.5、离屏/后台停帧、卸载 loseContext 与 CSS 静态兜底；prefers-reduced-motion 下停止动画。\n\n【验收标准】\n- 点击画布任意位置，严格正圆水波精准从点击点向外扩散 2.2s，肉眼可见底层纹理被波峰折弯并带柔和光泽。\n- 连续快点 6 次以上，多道波纹自然叠加干涉、不卡顿不溢出，最老槽平滑复用。\n- 滚出视口或切后台 rAF 停止；不支持 WebGL 时平滑回退 CSS 静态底纹。\n\n【禁止做法】\n- 别忘了翻转 Y 坐标 —— 否则点上半区水波从下半区炸出来。\n- 别在非正方形画布里省掉 `aspect` 修正 —— 水波会被拉扁成椭圆。\n- 别在波心直接写 `normalize(d)` 或 `d / length(d)` —— 中心点 `0/0` 会冒出一个永久黑像素。",
        "prompt_en": "Core Principle:\nZero-Three.js native WebGL optical water ripple refraction (Optical Water Ripple Shader). Maintain a fixed 6-slot uniform array `vec3 u_rip[6]` (`x, y, startTime`); in the fragment shader, sum the Gaussian-windowed sine wave packets of each active ripple into a radial UV displacement that refracts the underlying texture, layered with crest highlights and subtle chromatic dispersion.\n\nImplementation:\n1. Pure slot-management functions (lifetime `LIFE = 2.2s`):\n   - `rippleSlot(starts, now, life = 2.2)`: prefer an empty slot (`< 0`) or expired slot (`now - s >= life`); if all slots are busy, overwrite the oldest slot.\n   - `rippleEnvelope(age, life = 2.2)`: return `(1 - age / life)²` when `age` is in `[0, life)`, otherwise `0`.\n2. Pointer coordinate conversion (critical: Y-axis flip):\n   - On `pointerdown`, compute `x = (e.clientX - rect.left) / rect.width`, `y = 1 - (e.clientY - rect.top) / rect.height`, and write `(x, y, currentTimeSec)` into the selected slot.\n3. Fragment shader (`DPR <= 1.5`, offscreen/background dual pausing, context release on unmount):\n   - `asp = u_res.x / u_res.y`; iterate the 6 slots, skipping inactive or expired entries.\n   - `d = (uv - rp.xy) * vec2(asp, 1.0)`; `dist = length(d)`; `k = dist - age * 0.42`;\n   - `fade = 1.0 - age / 2.2`; `env = exp(-k * k * 120.0) * fade * fade`; `w = sin(k * 70.0) * env`;\n   - `disp += (d / max(dist, 1e-4)) * w * 0.02`; `hi += env * max(w, 0.0)`;\n   - Sample the underlying texture/procedural stripes at `suv = uv + disp`, adding subtle chromatic dispersion and `hi * 0.55` crest specular.\n\nHard Constraints:\n- Must flip the Y coordinate (`1 - clientY_norm`) and aspect-correct the distance vector so hit points align accurately and ripples remain true circles.\n- Division at the ripple center must use `max(dist, 1e-4)` to prevent `NaN` black pixels.\n- Concurrent slots must have a fixed cap (6 slots); dynamically growing unbounded loops are forbidden.\n- Must include `DPR <= 1.5`, offscreen/background pausing, `loseContext()` on unmount, CSS static fallback, and animation stop under `prefers-reduced-motion`.\n\nAcceptance Criteria:\n- Clicking anywhere on the canvas spawns a strictly circular ripple expanding outward from the exact click point for `2.2s`, visibly bending the underlying texture at wave crests with a soft sheen.\n- Clicking rapidly more than 6 times blends multiple interfering ripples smoothly with no stutter or overflow, recycling the oldest slot seamlessly.\n- `rAF` stops when scrolled offscreen or backgrounded; falls back cleanly to CSS static styling when WebGL is unsupported.",
        "dont_do_en": "- Do NOT forget to flip the Y coordinate — otherwise clicking the upper half makes ripples erupt from the lower half.\n- Do NOT omit the `aspect` correction on non-square canvases — ripples will be squashed into ellipses.\n- Do NOT write `normalize(d)` or `d / length(d)` at the ripple origin — `0/0` produces a permanent black pixel at the center.",
        "skill_rule_en": "# WebGL Optical Water Ripples (shader-ripple) · Cross-Platform Motion Spec\nNature: Feedback | Layer: webgl | Platform: both\n\nCore Principle: Zero-Three.js native WebGL optical water ripple refraction (Optical Water Ripple Shader). Maintain a fixed 6-slot uniform array `vec3 u_rip[6]` (`x, y, startTime`); in the fragment shader, sum the Gaussian-windowed sine wave packets of each active ripple into a radial UV displacement that refracts the underlying texture, layered with crest highlights and subtle chromatic dispersion.\n\nHard Constraints:\n- Must flip the Y coordinate (`1 - clientY_norm`) and aspect-correct the distance vector so hit points align accurately and ripples remain true circles.\n- Division at the ripple center must use `max(dist, 1e-4)` to prevent `NaN` black pixels.\n- Concurrent slots must have a fixed cap (6 slots); dynamically growing unbounded loops are forbidden.\n- Must include `DPR <= 1.5`, offscreen/background pausing, `loseContext()` on unmount, CSS static fallback, and animation stop under `prefers-reduced-motion`.\n\nAcceptance Criteria:\n- Clicking anywhere on the canvas spawns a strictly circular ripple expanding outward from the exact click point for `2.2s`, visibly bending the underlying texture at wave crests with a soft sheen.\n- Clicking rapidly more than 6 times blends multiple interfering ripples smoothly with no stutter or overflow, recycling the oldest slot seamlessly.\n- `rAF` stops when scrolled offscreen or backgrounded; falls back cleanly to CSS static styling when WebGL is unsupported.\n\nDo NOT Do:\n- Do NOT forget to flip the Y coordinate — otherwise clicking the upper half makes ripples erupt from the lower half.\n- Do NOT omit the `aspect` correction on non-square canvases — ripples will be squashed into ellipses.\n- Do NOT write `normalize(d)` or `d / length(d)` at the ripple origin — `0/0` produces a permanent black pixel at the center."
      }
    },
    {
      "id": "shader-terrain",
      "name": "WebGL 3D 赛博地形波浪线框",
      "name_en": "WebGL 3D Wireframe Terrain",
      "layer": "webgl",
      "nature": "连续",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.shaderTerrain(host, { cols, rows }) + .mk-shader.mk-shader--terrain",
      "source": "原生 WebGL gl.LINES 3D 线框山脉（静态 VBO 一次上传 + 顶点多频行波起伏 + 海拔渐变着色与远景雾化）",
      "source_en": "Synthwave / cyber 3D wireframe terrain (native WebGL gl.LINES + elevation fog)",
      "file": "effects/shader-terrain.md",
      "summary": "一次性把 28×28 线框网格上传至 GPU 静态 VBO，每帧在顶点着色器里用多频行波实时掀起起伏山脉与中央峡谷，按海拔从深海蓝渐变到荧光绿山脊并带远景透视淡出。",
      "summary_en": "Single gl.LINES draw call rendering a 28×28 static-VBO terrain mesh displaced in the vertex shader with traveling valley ridges, elevation coloring, and horizon fog.",
      "problem": "**复古未来风（Synthwave / 赛博数据大屏 / 技术发布会背景）常需要起伏流动的 3D 线框山脉，但用 SVG 折线或 Canvas 2D 每帧重算几百条线段投影会吃光主线程；引入 Three.js 又太重。** 原生 WebGL 的 `gl.LINES` 单次 Draw Call 绘制 1,500+ 条 3D 线段，顶点着色器并行算波高与透视，CPU 占用近乎为零。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 中央低平峡谷 + 两侧高耸山脊（`smoothstep(0.15, 1.5, abs(x))`），天生自带视觉走廊焦点 | 整张纸均匀正弦波上下乱抖（像一块床单而不是地形） |\n| 海拔驱动三段配色（山谷深蓝 → 山腰紫罗兰 → 山峰荧光绿）+ 远景深度雾化 `v_depth` | 单一纯色线框远近不分导致远处网格糊成亮团 |\n| 静态网格 `gl.STATIC_DRAW` 一次上传，每帧仅传 `u_time` 与阻尼 `u_mouse` | 每帧 JS 重建顶点数组上传 GPU |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 网格密度 `cols × rows` | 默认 `28 × 28`（1,512 条线段） | 既能清晰勾勒连续山脊曲面，又避免过密导致远处线条莫尔纹闪烁 |\n| 峡谷包络 `ridge` | `0.35 + smoothstep(0.15, 1.5, abs(x)) * 0.95` | 屏幕中央压低留出前景呼吸感（适合叠加标题文字），左右两侧抬高出立体群山 |\n| 俯角与相机距离 | 俯角 `0.46 rad`（~26°）/ `zz = p.z + 3.45` | 经典低空掠过地形视角，纵深透视强烈且前排山峰不会穿出镜头近裁剪面 |\n| 远景雾化 `v_depth` | `clamp(1.0 - (zz - 1.2) / 4.4, 0.08, 1.0)` | 越远的网格越柔和淡入背景，自然消除远端密线锯齿 |",
      "implementation": "```\nsrc/core/shader.js:111   terrainGrid(cols, rows)       确定性 3D 线框网格顶点生成器（可单测）\nsrc/core/shader.js:827   TERRAIN_VERT / TERRAIN_FRAG   多频行波顶点位移 + 海拔渐变与深度雾化 GLSL\nsrc/core/shader.js:874   shaderTerrain(host, opts)     gl.LINES 渲染器（DPR 1.5 + 双停帧 + 释放 context）\nstyles/webgl.css:83      .mk-shader--terrain           WebGL 不可用时的赛博地形渐变兜底\n```",
      "degradation": "**走 `webgl` 层专属契约：退回 CSS 渐变 + 减弱动效单帧冻结。**\n\n- `prefers-reduced-motion: reduce`：仅绘制 `t = 3.5s` 一帧静态 3D 线框山脉，不起 rAF 循环，不响应指针晃动。\n- WebGL 不可用或上下文丢失时隐藏 `<canvas>`，展示容器深空渐变兜底。",
      "pitfalls": "**① 用每帧 JS 循环改写顶点 Y 坐标再 `bufferSubData` 上传。**\n地形起伏完全是 `(x, z, t)` 的解析函数，直接写在顶点着色器里能让 VBO 保持 `gl.STATIC_DRAW`，零 CPU 拷贝。\n\n**② 没做远景深度衰减，远处密集线框全挤在一起发亮刺眼。**\n必须把深度因子 `v_depth` 乘进片元颜色与透明度，让地平线处的网格柔顺融进背景。\n\n**③ 网格行数/列数传非法值（如 `0`、`1`、`NaN`）导致除零产出 `NaN` 顶点。**\n纯函数 `terrainGrid(cols, rows)` 必须把 `cols / rows` 钳制在 `[2, 80]` 区间内。\n\n---",
      "ai_assets": {
        "prompt": "实现零 Three.js 依赖的原生 WebGL 3D 赛博地形波浪线框（gl.LINES 3D Wireframe Terrain）。\n\n原理一句话：初始化时生成 cols × rows 网格线段（横线 + 纵线）一次性写入 GPU 静态 VBO，每帧在顶点着色器里叠加多频行波与中央峡谷包络计算 3D 起伏和透视投影，片元着色器按海拔着色并随距离雾化淡出。\n\n做法：\n1. 纯函数 terrainGrid(cols = 28, rows = 28)：\n   - 将 cols / rows 钳制到 [2, 80] 整数；\n   - 生成全部横向与纵向相邻网格点的线段端点对 vec2(u, v)（u, v ∈ [0, 1]），共 segs = rows*(cols-1) + cols*(rows-1) 条线段，返回 { vertices: Float32Array(segs * 4), count: segs * 2 }。\n2. 原生 WebGL 管线与工程约束：\n   - 一次性 gl.bufferData(..., gl.STATIC_DRAW) 上传 vertices；开启透明混合 gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)；每帧单次 gl.drawArrays(gl.LINES, 0, count)。\n   - DPR 封顶 1.5 且总像素 <= 1,200,000；接 ResizeObserver、IntersectionObserver（离屏停帧）与 visibilitychange（后台停帧）；destroy() 删除 buffer/program 并主动 loseContext。\n3. 顶点与片元着色器：\n   - 顶点着色器：x = (a_uv.x - 0.5)*4.4；z = (a_uv.y - 0.5)*4.4；\n     峡谷包络 ridge = smoothstep(0.15, 1.5, abs(x))；\n     多频行波 h = (sin(x*2.1 + t*0.4)*cos(z*1.8 - t)*0.34 + sin(x*1.4 - z*2.3 + t*1.2)*0.18 + cos(length(vec2(x, z*0.7))*2.4 - t*1.3)*0.14) * (0.35 + ridge*0.95)；\n     点 p = vec3(x, h - 0.48, z) 按阻尼指针偏转 XZ/YZ，透视投影 zz = p.z + 3.45，proj = vec2(p.x / asp, p.y) * (1.85 / max(zz, 0.25))；\n     输出归一化海拔 v_h 与远景深度因子 v_depth = clamp(1.0 - (zz - 1.2) / 4.4, 0.08, 1.0)。\n   - 片元着色器：按 v_h 从深蓝 → 紫罗兰 → 荧光绿插值，颜色与透明度同乘 v_depth 实现自然远景雾化。\n4. 降级：\n   - prefers-reduced-motion: reduce 仅画 t = 3.5s 一帧静态山脉，不启动 rAF。\n   - 不支持 WebGL 或 context lost 时隐藏 canvas，保留容器 CSS 渐变兜底。\n\n硬要求：\n- 顶点缓冲必须一次 STATIC_DRAW 上传，严禁每帧在 JS 循环重算高度再上传 GPU。\n- 必须同时包含中央峡谷包络、海拔分层着色与远景深度雾化。\n- 严禁引入 Three.js，必须落齐 DPR 封顶、离屏/后台双停帧与 context 销毁。\n\n验收：\n- 3D 线框山脉沿 Z 轴连续向镜头涌来，两侧高耸、中间低平，山峰泛青绿、山谷呈深蓝、远处柔顺融入暗底。\n- 移动鼠标可按 0.08 阻尼轻微晃动飞行视角，无卡顿与莫尔纹刺眼感。\n- 滚出视口、切后台或开启减弱动效时 rAF 立即停止；卸载无 WebGL context 泄漏。",
        "dont_do": "- 别用 Canvas 2D 或 SVG 每帧在 JS 里遍历几千个点做 3D 投影 —— 主线程立刻掉帧。\n- 别把网格密度设到 `120 × 120` —— 远处线条挤成噪点莫尔纹反而失去清晰科技感。\n- 别忘了按 `v_depth` 给远景线框做雾化衰减 —— 地平线处会糊成一片发白杂线。",
        "skill_rule": "# WebGL 3D 赛博地形波浪线框 (shader-terrain) · 跨平台动效规范\n性质：连续 ｜ 平台：both\n\n【核心原理】初始化时生成 cols × rows 网格线段（横线 + 纵线）一次性写入 GPU 静态 VBO，每帧在顶点着色器里叠加多频行波与中央峡谷包络计算 3D 起伏和透视投影，片元着色器按海拔着色并随距离雾化淡出。\n\n【硬要求】\n- 顶点缓冲必须一次 STATIC_DRAW 上传，严禁每帧在 JS 循环重算高度再上传 GPU。\n- 必须同时包含中央峡谷包络、海拔分层着色与远景深度雾化。\n- 严禁引入 Three.js，必须落齐 DPR 封顶、离屏/后台双停帧与 context 销毁。\n\n【验收标准】\n- 3D 线框山脉沿 Z 轴连续向镜头涌来，两侧高耸、中间低平，山峰泛青绿、山谷呈深蓝、远处柔顺融入暗底。\n- 移动鼠标可按 0.08 阻尼轻微晃动飞行视角，无卡顿与莫尔纹刺眼感。\n- 滚出视口、切后台或开启减弱动效时 rAF 立即停止；卸载无 WebGL context 泄漏。\n\n【禁止做法】\n- 别用 Canvas 2D 或 SVG 每帧在 JS 里遍历几千个点做 3D 投影 —— 主线程立刻掉帧。\n- 别把网格密度设到 `120 × 120` —— 远处线条挤成噪点莫尔纹反而失去清晰科技感。\n- 别忘了按 `v_depth` 给远景线框做雾化衰减 —— 地平线处会糊成一片发白杂线。",
        "prompt_en": "Core Principle:\nZero-Three.js native WebGL 3D wireframe cyber terrain (`gl.LINES` 3D Wireframe Terrain). At initialization, generate a `cols × rows` grid of horizontal and vertical line segments and upload them once to a static GPU VBO; each frame, compute 3D wave elevation with a central canyon envelope and perspective projection in the vertex shader, while the fragment shader colors by elevation and fades into distance fog.\n\nImplementation:\n1. Pure function `terrainGrid(cols = 28, rows = 28)`:\n   - Clamp `cols` / `rows` to integers in `[2, 80]`.\n   - Generate endpoint pairs `vec2(u, v)` (`u, v ∈ [0, 1]`) for all adjacent horizontal and vertical grid edges, totaling `segs = rows*(cols-1) + cols*(rows-1)` segments, and return `{ vertices: Float32Array(segs * 4), count: segs * 2 }`.\n2. Native WebGL pipeline & engineering constraints:\n   - Upload `vertices` once via `gl.bufferData(..., gl.STATIC_DRAW)`; enable alpha blending `gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)`; draw once per frame with `gl.drawArrays(gl.LINES, 0, count)`.\n   - Cap DPR at `1.5` and total pixels `<= 1,200,000`; attach `ResizeObserver`, `IntersectionObserver` (pause offscreen), and `visibilitychange` (pause in background); in `destroy()`, delete buffers/programs and actively invoke `loseContext()`.\n3. Vertex & fragment shaders:\n   - Vertex shader: `x = (a_uv.x - 0.5)*4.4`; `z = (a_uv.y - 0.5)*4.4`;\n     central canyon envelope `ridge = smoothstep(0.15, 1.5, abs(x))`;\n     multi-frequency traveling waves `h = (sin(x*2.1 + t*0.4)*cos(z*1.8 - t)*0.34 + sin(x*1.4 - z*2.3 + t*1.2)*0.18 + cos(length(vec2(x, z*0.7))*2.4 - t*1.3)*0.14) * (0.35 + ridge*0.95)`;\n     tilt `p = vec3(x, h - 0.48, z)` by damped pointer XZ/YZ offsets, project with `zz = p.z + 3.45`, `proj = vec2(p.x / asp, p.y) * (1.85 / max(zz, 0.25))`;\n     output normalized elevation `v_h` and far depth factor `v_depth = clamp(1.0 - (zz - 1.2) / 4.4, 0.08, 1.0)`.\n   - Fragment shader: interpolate across `v_h` from deep blue → violet → neon green, multiplying both color and alpha by `v_depth` for natural distance fog.\n4. Fallbacks:\n   - Under `prefers-reduced-motion: reduce`, draw a single static mountain frame at `t = 3.5s` without starting `rAF`.\n   - When WebGL is unsupported or on `webglcontextlost`, hide the canvas and keep the container's CSS gradient fallback.\n\nHard Constraints:\n- Vertex buffer must be uploaded once with `STATIC_DRAW`; never recompute elevations in a JS loop and re-upload to GPU every frame.\n- Must include all three: central canyon envelope, elevation-banded coloring, and far-distance depth fog.\n- Strictly forbid Three.js; must implement DPR capping, offscreen/background dual pausing, and context destruction.\n\nAcceptance Criteria:\n- 3D wireframe ridges roll continuously toward the camera along the Z axis—towering on the flanks and flat down the central canyon—with neon-green peaks, deep-blue valleys, and distant lines melting smoothly into the dark background.\n- Moving the pointer tilts the flight camera smoothly with `0.08` damping, free of stutter or harsh moire aliasing.\n- `rAF` stops immediately when scrolled offscreen, backgrounded, or under reduced motion; zero WebGL context leaks on unmount.",
        "dont_do_en": "- Do NOT project thousands of vertices every frame on the CPU using Canvas 2D or SVG — the main thread will immediately drop frames.\n- Do NOT crank grid density up to `120 × 120` — distant lines crush into noisy moire patterns and lose crisp sci-fi clarity.\n- Do NOT forget distance fog attenuation via `v_depth` — the horizon will turn into a bright, cluttered smear of overlapping lines.",
        "skill_rule_en": "# WebGL 3D Wireframe Terrain (shader-terrain) · Cross-Platform Motion Spec\nNature: Continuity | Layer: webgl | Platform: both\n\nCore Principle: Zero-Three.js native WebGL 3D wireframe cyber terrain (`gl.LINES` 3D Wireframe Terrain). At initialization, generate a `cols × rows` grid of horizontal and vertical line segments and upload them once to a static GPU VBO; each frame, compute 3D wave elevation with a central canyon envelope and perspective projection in the vertex shader, while the fragment shader colors by elevation and fades into distance fog.\n\nHard Constraints:\n- Vertex buffer must be uploaded once with `STATIC_DRAW`; never recompute elevations in a JS loop and re-upload to GPU every frame.\n- Must include all three: central canyon envelope, elevation-banded coloring, and far-distance depth fog.\n- Strictly forbid Three.js; must implement DPR capping, offscreen/background dual pausing, and context destruction.\n\nAcceptance Criteria:\n- 3D wireframe ridges roll continuously toward the camera along the Z axis—towering on the flanks and flat down the central canyon—with neon-green peaks, deep-blue valleys, and distant lines melting smoothly into the dark background.\n- Moving the pointer tilts the flight camera smoothly with `0.08` damping, free of stutter or harsh moire aliasing.\n- `rAF` stops immediately when scrolled offscreen, backgrounded, or under reduced motion; zero WebGL context leaks on unmount.\n\nDo NOT Do:\n- Do NOT project thousands of vertices every frame on the CPU using Canvas 2D or SVG — the main thread will immediately drop frames.\n- Do NOT crank grid density up to `120 × 120` — distant lines crush into noisy moire patterns and lose crisp sci-fi clarity.\n- Do NOT forget distance fog attenuation via `v_depth` — the horizon will turn into a bright, cluttered smear of overlapping lines."
      }
    },
    {
      "id": "shader-torus",
      "name": "WebGL 3D 液态扭环射线步进",
      "name_en": "WebGL 3D Raymarched Chrome Torus",
      "layer": "webgl",
      "nature": "材质",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.shaderTorus(host) + .mk-shader.mk-shader--torus",
      "source": "真 3D SDF 射线步进雕塑（44 步 Torus SDF + 中心差分法线 + 虹彩 Fresnel 液态金属高光 + 指针 3D 旋转）",
      "source_en": "Native WebGL 44-step SDF raymarched twisted torus (0KB Three.js)",
      "file": "effects/shader-torus.md",
      "summary": "零 Three.js、零网格顶点，只用一个全屏三角形在片元着色器里跑 44 步 3D 射线步进（Raymarching），实时雕塑出一枚随指针旋转、表面流动虹彩金属高光的 3D 液态扭环。",
      "summary_en": "Zero-mesh 44-step SDF raymarching sculpting a twisted liquid-chrome torus with central-difference normals, iridescent Fresnel sheen, and damped pointer 3D rotation.",
      "problem": "**官网 Hero、AI 产品主视觉或深色专题页想放一个会动的 3D 液态金属雕塑，但引入 Three.js + GLTF 模型 + 环境贴图动辄几百 KB 到数 MB，首屏白屏还容易把低端机显卡拉满。** 用 50 行 GLSL 解析圆环 SDF 叠加 3 瓣螺旋扭转与 Fresnel 虹彩反射，既零网格包体、无限分辨率锐利，又能顺手响应鼠标 3D 转动。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 44 步解析 SDF 射线步进 + 6 次采样中心差分法线，任意缩放永无多边形锯齿 | 加载数百 KB 的 `.glb` 模型与 Three.js 场景图运行时 |\n| 指针 X/Y 经 `0.08` 阻尼平滑后直接旋入相机/物体坐标系，转动有重量感 | 指针硬绑旋转角导致手一抖雕塑狂颤 |\n| 透明画布 + 柔和径向背光 + 工程四件套（DPR 1.5、总像素封顶、离屏/后台双停帧） | 不封顶分辨率在 3× Retina 屏上每帧算千万像素烧电 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 步进上限与命中阈值 | `44` 步 / `d < 0.0018` / `dist > 5.0` | 圆环拓扑平滑，44 步即可收束到亚像素级边缘，远低于 100+ 步的移动端掉帧线 |\n| 环主半径 / 管半径 | `R = 0.68` / `r = 0.24 + 0.032 * sin(6a - 1.8t)` | 管径留出中心通孔，3 瓣螺旋扭转叠加 6 频行波让轮廓像流动水银而非死板甜甜圈 |\n| Fresnel 与高光幂次 | `pow(1 - dot(n,v), 3.2)` / `spec pow 36` | 掠射边缘陡然泛起青绿虹彩，主光点形成锐利液态金属反光 |\n| 指针平滑阻尼 | `mouse += (target - mouse) * 0.08` | 鼠标移入或移出后雕塑以丝滑惯性回中，不出现瞬移折返 |",
      "implementation": "```\nsrc/core/shader.js:215   TORUS_FRAG              44 步 SDF 射线步进 + 中心差分法线 + 虹彩 Fresnel GLSL\nsrc/core/shader.js:517   shaderTorus(host, opts) 复用通用 shaderCanvas 控制器（DPR 1.5 + 双停帧 + 释放 context）\nstyles/webgl.css:65      .mk-shader--torus       WebGL 未就绪或降级时的双色径向渐变兜底\n```",
      "degradation": "**走 `webgl` 层专属契约：退回 CSS 渐变 + 减弱动效单帧冻结。**\n\n- `prefers-reduced-motion: reduce`：仅绘制 `t = 12s` 一帧静态 3D 雕塑，不启动 rAF 循环，不绑定指针旋转。\n- 浏览器不支持 WebGL、Shader 编译失败或触发 `webglcontextlost` 时，隐藏 `<canvas>` 并展示容器上的双色径向渐变兜底，版面不塌不黑屏。",
      "pitfalls": "**① 在 3× 屏或 4K 大图上直接按 `devicePixelRatio` 跑 Raymarching。**\n每个像素要跑最多 44 次 SDF + 6 次法线采样，不封顶 DPR 和总像素数会瞬间把核显和手机发烫拖到 15fps；必须把 DPR 封顶 `1.5` 且总像素压在 `1,200,000` 以内。\n\n**② 坐标未按 `min(u_res.x, u_res.y)` 归一化导致宽屏容器里圆环被拉扁。**\n射线方向 `uv` 必须用 `(gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y)`，才能在任意宽高比卡片里保持严格 3D 正圆环。\n\n**③ 滚动离开视口或卸载组件时忘记停帧和释放 WebGL context。**\n单页里如果挂载多个 3D Shader，不接 `IntersectionObserver` 离屏停帧和 `WEBGL_lose_context` 销毁，很快会撞上浏览器 8–16 个活跃 WebGL context 上限导致前面的画布黑屏。\n\n---",
      "ai_assets": {
        "prompt": "实现零 Three.js 依赖的原生 WebGL 3D 液态扭环射线步进雕塑（Raymarching Twisted Chrome Torus）。\n\n原理一句话：用一个全屏三角形在 GLSL 片元着色器里执行 44 步 3D 扭转圆环 SDF 射线步进，用中心差分求法线并叠加双光源 + 3.2 次方 Fresnel 虹彩液态金属高光，由平滑阻尼的指针坐标驱动 3D 旋转。\n\n做法：\n1. 画布与工程约束：\n   - 仅用原生 WebGL 绘制一个覆盖全屏的超大三角形（顶点 [-1,-1], [3,-1], [-1,3]），alpha: true, powerPreference: 'low-power'。\n   - DPR 封顶 1.5 且画布总像素数 <= 1,200,000；通过 ResizeObserver 同步尺寸。\n   - 接 IntersectionObserver（滚出视口停 rAF）与 visibilitychange（切后台停 rAF）；destroy() 时 deleteBuffer、deleteProgram 并调用 WEBGL_lose_context.loseContext()。\n2. GLSL 3D 射线步进核心：\n   - 正比例坐标：uv = (gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y)；相机 ro = vec3(0.0, 0.0, 2.35)，射线 rd = normalize(vec3(uv, -1.65))。\n   - 扭转圆环 SDF mapTorus(p, t)：\n     先绕 Y 轴旋 t*0.45 + (u_mouse.x - 0.5)*2.4，绕 Z 轴旋 0.45 + (u_mouse.y - 0.5)*1.6；\n     取环角 a = atan(p.z, p.x)，截面 q = vec2(length(p.xz) - 0.68, p.y) 乘以 rot2(a * 1.5 + t * 0.9)；\n     返回 length(q) - (0.24 + 0.032 * sin(a * 6.0 - t * 1.8))。\n   - 最多 44 步步进，d < 0.0018 判命中，dist > 5.0 退出；未命中返回中心柔和微光透明像素。\n   - 命中后用 e = 0.0025 的 6 点中心差分计算解析法线 n，叠加主副双漫反射、36 次方镜面高光与 pow(1.0 - max(dot(n, v), 0.0), 3.2) 的蓝/紫/荧光绿虹彩 Fresnel 反射。\n3. 指针阻尼与降级：\n   - pointermove 更新目标 UV，每帧 mouse += (target - mouse) * 0.08 平滑逼近；pointerleave 平滑回中心 (0.5, 0.5)。\n   - prefers-reduced-motion: reduce 只渲染 t = 12s 一帧静态雕塑并停止 rAF。\n   - 容器自带同色系 CSS 径向渐变，WebGL 首帧完成后淡入 canvas；不支持或 webglcontextlost 时隐藏 canvas 保留 CSS 渐变。\n\n硬要求：\n- 严禁引入 Three.js 或加载外部 3D 模型文件。\n- 必须同时落齐 DPR 封顶 1.5、总像素 <= 1.2M、离屏/后台双停帧、webglcontextlost 兜底与 destroy 释放 context。\n- 必须按 min(u_res.x, u_res.y) 归一化坐标，保证任意比例容器内圆环不变形。\n\n验收：\n- 液态扭环在暗色透明画布上 60fps 旋转，边缘清晰无锯齿，呈现流动金属虹彩与镜面高光。\n- 鼠标滑过时扭环顺滑 3D 转向，移出后缓慢回中；滚出视口或切后台时 rAF 立即归零。\n- 开启减弱动效后仅呈现单帧静态 3D 雕塑；组件销毁后无 WebGL context 泄漏。",
        "dont_do": "- 别为了做单个 3D 雕塑引入几百 KB 的 Three.js —— 50 行原生 GLSL 射线步进就能搞定且零包体。\n- 别把步进上限拉到 128 步还不限制 DPR —— 移动端 GPU 会立刻掉帧发烫。\n- 别在 `destroy()` 时只把 `<canvas>` 从 DOM 移除而不主动释放 buffer/program/context —— 页面切几次就会触发浏览器 WebGL context 上限黑屏。",
        "skill_rule": "# WebGL 3D 液态扭环射线步进 (shader-torus) · 跨平台动效规范\n性质：材质 ｜ 平台：both\n\n【核心原理】用一个全屏三角形在 GLSL 片元着色器里执行 44 步 3D 扭转圆环 SDF 射线步进，用中心差分求法线并叠加双光源 + 3.2 次方 Fresnel 虹彩液态金属高光，由平滑阻尼的指针坐标驱动 3D 旋转。\n\n【硬要求】\n- 严禁引入 Three.js 或加载外部 3D 模型文件。\n- 必须同时落齐 DPR 封顶 1.5、总像素 <= 1.2M、离屏/后台双停帧、webglcontextlost 兜底与 destroy 释放 context。\n- 必须按 min(u_res.x, u_res.y) 归一化坐标，保证任意比例容器内圆环不变形。\n\n【验收标准】\n- 液态扭环在暗色透明画布上 60fps 旋转，边缘清晰无锯齿，呈现流动金属虹彩与镜面高光。\n- 鼠标滑过时扭环顺滑 3D 转向，移出后缓慢回中；滚出视口或切后台时 rAF 立即归零。\n- 开启减弱动效后仅呈现单帧静态 3D 雕塑；组件销毁后无 WebGL context 泄漏。\n\n【禁止做法】\n- 别为了做单个 3D 雕塑引入几百 KB 的 Three.js —— 50 行原生 GLSL 射线步进就能搞定且零包体。\n- 别把步进上限拉到 128 步还不限制 DPR —— 移动端 GPU 会立刻掉帧发烫。\n- 别在 `destroy()` 时只把 `<canvas>` 从 DOM 移除而不主动释放 buffer/program/context —— 页面切几次就会触发浏览器 WebGL context 上限黑屏。",
        "prompt_en": "Core Principle:\nZero-Three.js native WebGL 3D raymarched liquid twisted torus sculpture (Raymarching Twisted Chrome Torus). Execute a 44-step 3D twisted-torus SDF raymarch inside a GLSL fragment shader over a single fullscreen triangle, computing normals via central differences and layering dual light sources plus power-`3.2` Fresnel iridescent liquid-metal speculars, rotated in 3D by smoothly damped pointer coordinates.\n\nImplementation:\n1. Canvas & engineering constraints:\n   - Use native WebGL only to draw a single oversized fullscreen triangle (`[-1,-1]`, `[3,-1]`, `[-1,3]`) with `alpha: true` and `powerPreference: 'low-power'`.\n   - Cap DPR at `1.5` and total canvas pixels `<= 1,200,000`; sync size via `ResizeObserver`.\n   - Attach `IntersectionObserver` (pause `rAF` offscreen) and `visibilitychange` (pause `rAF` in background); in `destroy()`, call `deleteBuffer`, `deleteProgram`, and `WEBGL_lose_context.loseContext()`.\n2. GLSL 3D raymarching core:\n   - Aspect-true coordinates: `uv = (gl_FragCoord.xy - 0.5 * u_res) / min(u_res.x, u_res.y)`; camera `ro = vec3(0.0, 0.0, 2.35)`, ray `rd = normalize(vec3(uv, -1.65))`.\n   - Twisted torus SDF `mapTorus(p, t)`: rotate around Y by `t*0.45 + (u_mouse.x - 0.5)*2.4` and around Z by `0.45 + (u_mouse.y - 0.5)*1.6`; compute ring angle `a = atan(p.z, p.x)`, transform cross-section `q = vec2(length(p.xz) - 0.68, p.y)` by `rot2(a * 1.5 + t * 0.9)`, and return `length(q) - (0.24 + 0.032 * sin(a * 6.0 - t * 1.8))`.\n   - Raymarch up to 44 steps: hit when `d < 0.0018`, exit when `dist > 5.0`; on miss, return a transparent pixel with soft centered glow.\n   - On hit, compute normal `n` using 6-point central differences with `e = 0.0025`, layering dual primary/secondary diffuse lights, power-`36` specular highlight, and `pow(1.0 - max(dot(n, v), 0.0), 3.2)` blue/purple/neon-green iridescent Fresnel reflection.\n3. Pointer damping & fallbacks:\n   - `pointermove` updates target UV and each frame interpolates `mouse += (target - mouse) * 0.08`; `pointerleave` eases back to center `(0.5, 0.5)`.\n   - Under `prefers-reduced-motion: reduce`, render a single static sculpture frame at `t = 12s` and stop `rAF`.\n   - Container ships a color-matched CSS radial gradient; fade in the canvas after the first WebGL frame completes, and hide the canvas to keep the CSS gradient when unsupported or on `webglcontextlost`.\n\nHard Constraints:\n- Strictly forbid Three.js or loading external 3D model files.\n- Must implement all of: DPR cap `1.5`, total pixels `<= 1.2M`, offscreen/background dual pausing, `webglcontextlost` fallback, and context release in `destroy()`.\n- Must normalize coordinates by `min(u_res.x, u_res.y)` so the torus never distorts in any container aspect ratio.\n\nAcceptance Criteria:\n- The twisted liquid torus rotates at 60fps on a dark transparent canvas with crisp anti-aliased silhouettes, flowing metallic iridescence, and specular highlights.\n- Moving the cursor smoothly steers the torus in 3D and slowly returns it to center on exit; `rAF` drops to zero immediately when scrolled offscreen or backgrounded.\n- Under reduced motion, only a single static 3D sculpture frame renders; zero WebGL context leaks after component unmount.",
        "dont_do_en": "- Do NOT pull in hundreds of KB of Three.js for a single 3D sculpture — 50 lines of raw GLSL raymarching handles it with zero bundle weight.\n- Do NOT push the step cap to 128 steps without a DPR cap — mobile GPUs will immediately drop frames and overheat.\n- Do NOT just remove the `<canvas>` from the DOM in `destroy()` without releasing buffers/programs/context — switching pages a few times will hit the browser's WebGL context limit and black out.",
        "skill_rule_en": "# WebGL 3D Raymarched Chrome Torus (shader-torus) · Cross-Platform Motion Spec\nNature: Material | Layer: webgl | Platform: both\n\nCore Principle: Zero-Three.js native WebGL 3D raymarched liquid twisted torus sculpture (Raymarching Twisted Chrome Torus). Execute a 44-step 3D twisted-torus SDF raymarch inside a GLSL fragment shader over a single fullscreen triangle, computing normals via central differences and layering dual light sources plus power-`3.2` Fresnel iridescent liquid-metal speculars, rotated in 3D by smoothly damped pointer coordinates.\n\nHard Constraints:\n- Strictly forbid Three.js or loading external 3D model files.\n- Must implement all of: DPR cap `1.5`, total pixels `<= 1.2M`, offscreen/background dual pausing, `webglcontextlost` fallback, and context release in `destroy()`.\n- Must normalize coordinates by `min(u_res.x, u_res.y)` so the torus never distorts in any container aspect ratio.\n\nAcceptance Criteria:\n- The twisted liquid torus rotates at 60fps on a dark transparent canvas with crisp anti-aliased silhouettes, flowing metallic iridescence, and specular highlights.\n- Moving the cursor smoothly steers the torus in 3D and slowly returns it to center on exit; `rAF` drops to zero immediately when scrolled offscreen or backgrounded.\n- Under reduced motion, only a single static 3D sculpture frame renders; zero WebGL context leaks after component unmount.\n\nDo NOT Do:\n- Do NOT pull in hundreds of KB of Three.js for a single 3D sculpture — 50 lines of raw GLSL raymarching handles it with zero bundle weight.\n- Do NOT push the step cap to 128 steps without a DPR cap — mobile GPUs will immediately drop frames and overheat.\n- Do NOT just remove the `<canvas>` from the DOM in `destroy()` without releasing buffers/programs/context — switching pages a few times will hit the browser's WebGL context limit and black out."
      }
    },
    {
      "id": "shared-element",
      "name": "共享元素转场",
      "name_en": "Shared Element View Transition",
      "layer": "motion",
      "nature": "连续",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-share=\"seed\" / startShare(update, { duration, reduced })",
      "source": "Framer Motion 的 `layoutId`、View Transitions API（Chrome 157 / WebKit 27.2 实测）",
      "source_en": "iOS App Store card expansion / View Transitions API (zero FLIP math)",
      "file": "effects/shared-element.md",
      "summary": "点列表里的一张卡，**那张卡自己长大成详情页**，不是淡入一个新页面；返回时是同一段的逆向。",
      "summary_en": "Card-to-detail morph powered purely by browser-native View Transitions API (`view-transition-name`) with deterministic safe-ID generation and zero JS FLIP measurement.",
      "problem": "用户点了「第 3 个」，详情打开后他得重新找「这是刚才那个吗」。硬切或整页淡入把这条线索删了 ——\n他得多花一眼确认自己没点错。\n\n这条以前是打算用 Framer 那套 FLIP 手写的：量旧矩形、量新矩形、写 `transform`、下一帧归零。\n**库里面现在一行测量代码都没有。** 浏览器自己会给每个 `view-transition-name` 建一个\n`::view-transition-group(name)` 伪元素，尺寸和位置都在两个快照之间插值。手写 FLIP 是**多做一遍\n浏览器已经在做的事**，而且会在滚动容器、`border-radius`、`overflow: hidden` 这三处各赔一次精度。\n\n所以这里的工作量从「测量 + 补间」变成了**只回答三个浏览器不管的问题**：能不能用、减弱要不要跳过、\n时长写哪儿。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| iOS App Store：卡片展开成详情页，位置和尺寸一起变 | Framer 的 `layoutId` 运行时测量（浏览器接管了） |\n| 元素身份（\"还是它\"）由**同名**表达，而不是由一段动画代码表达 | 两快照之间的内容差异（旧内容淡出、新内容淡入仍走默认交叉淡入淡出） |\n| 时长/缓动走 token，和库里其它原语同一套 | 跨文档转场（那是 `@view-transition`，另一个话题） |\n| `prefers-reduced-motion` 整段跳过 | 部分减速（见 §4：这段没有\"半程\"这个档） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| `duration` | `380ms` | 卡片 348×84 → 388×842（约 10 倍面积）。300ms 以内读成\"跳了一下\"；480ms 以上手指已经抬完了还在长，像卡住。两端卡片尺寸差得更大时按面积比例微调，一档之内 |\n| 缓动 | `var(--mk-ease-out)` | 到达要准。这里**不用弹簧**：`startViewTransition` 给的是伪元素上的 `transform`/`width` 关键帧，弹簧要靠 `@keyframes` 手算一串采样点，而这段的观感已经被浏览器自己的插值定型了，外加弹簧只会打架 |\n| 根层过渡 | `animation: none` | **必须掐掉**。根层的交叉淡入淡出会和元素长大叠在一起，变成\"整页糊一下再飞\" |\n| reduced 档 | `1ms !important` | 不是 `0s`：`0s` 在部分引擎里会让 `finished` 立刻 resolve，清理逻辑抢在伪元素建立之前跑 |\n\n面积比例是个**起点不是规矩**：388/348 的宽度变化来自 `.share-detail` 盖满 `.screen`（`.device` 有 20px 内边距），\n如果容器算出不同的宽度，观感会跟着变 —— 这不是 bug，是\"两个真实元素之间的关系\"。",
      "implementation": "```\nflip.js:34    canShare()                            能力探测\nflip.js:58    shareName(seed, prefix)               种子 → 合法 name（16 条单测）\nflip.js:96    startShare(update, opts)              挂类 / 写时长 / 跑回调 / 收拾干净\nflip.js:128   skipShare()                           能力探测（真正的 skip 交给调用方持有的 tx）\nvue/index.js:500  vMkShare                          写 --mk-share，null 时摘掉\nvue/index.js:697  install()                         app.directive('mk-share') + $mkShare\nmotion.css:1046   .mk-share                         元素侧：name 走 var、class 走字面量\nmotion.css:1056   ::view-transition-old/new(root)   掐掉整页淡入淡出\nmotion.css:1063   ::view-transition-group(*.mk-share) 只给这一族改时长\n```\n\n分工：**JS 只做三件事** —— 判断能不能用、在回调里换 DOM、挂 `:root` 上的之类与时长变量。\n中间那一段插值完全不在库里。\n\n`shareName()` 是纯函数，值得单独钉死，因为**名字合法与否是\"过渡到底跑不跑\"的唯一开关**。\n它做的事：剥掉非标识符字符 → 空的话用 FNV-1a 散列保后缀 → 以数字开头的补前缀字母。",
      "degradation": "**走 motion 那档，但这段的降级是\"没有过渡\"，不是\"换成更弱的动画\"。**\n\n```css\n.mk-share {\n  view-transition-name: var(--mk-share, none);\n  view-transition-class: mk-share;\n}\n\n@media (prefers-reduced-motion: reduce) {\n  :root.mk-vt-share::view-transition-group(*),\n  :root.mk-vt-share::view-transition-old(*),\n  :root.mk-vt-share::view-transition-new(*) {\n    animation-duration: 1ms !important;\n  }\n}\n```\n\n两层降级，缺一不可：\n\n1. **不支持 View Transitions 的引擎**：`view-transition-name` 被静默忽略（实测 `0` / `*` 都 compute 成 `none`）。\n   `startShare()` 先探 `canShare()`，不支持就直接跑回调 —— 页面功能全在，只是硬切。\n   **这里不写降级动画**：按下反馈归 `v-mk-tap`，再叠一层位移会让\"点了但没动画\"变成\"点了但动得很怪\"。\n2. **`prefers-reduced-motion: reduce`**：`startViewTransition` **自己不认 reduce** ——\n   实测两个引擎里，reduce 下时长仍是 250ms。所以必须由 `startShare()` 里的 `resolveReduced()` 提前跳过，\n   CSS 那条 `1ms` 是第二道保险（万一有人绕过 `startShare` 直接调 API）。",
      "pitfalls": "**这一栏最值钱，五条全踩过。**\n\n### ① 名字交接必须在同一帧，否则 `InvalidStateError` 静默失败\n\n`view-transition-name` **在任意时刻只能有一个元素持有**。两侧同时挂会被判\n`InvalidStateError: Multiple elements found with view-transition-name: mk-share-card-pulse`\n（WebKit 报得比 Chrome 更早）。表现是**过渡完全不启动，但回调整照跑** —— 页面不会卡死，\n只是没动画。第一版就是这么写的：列表和详情都挂 `'card-' + id`，结果打出来只剩 pageerror。\n\n正确写法：列表在详情打开时把名字**交出去**。\n\n```html\n<div class=\"share-card\" v-mk-share=\"shareOpen ? null : 'card-' + c.id\">\n```\n\n`v-mk-share` 收到 `null` 时 `applyShareName()` 会 `removeProperty('--mk-share')`，\n`var(--mk-share, none)` 回落成 `none`。详情层接过同名 —— 交接和 DOM 变化在同一帧完成，\n浏览器才看得见\"同一个元素从这儿长到那儿\"。\n\n### ② `::view-transition-*` 规则必须随样式表预加载\n\n在 `startViewTransition()` 前一刻 `appendChild` 一个 `<style>`，**两个引擎都不认** ——\n时长仍是浏览器默认的 `0.25s`。这不是时序问题也不是加载问题，是规范里过渡伪元素的\n样式在过渡启动那一刻就从**已存在的样式表**里解析完毕了。\n\n所以规则在 `motion.css` 里，不在 `flip.js` 里。\n\n### ③ 作用域必须挂类，裸写会波及别人家的转场\n\n```css\n/* ✗ 同页所有 view transition 都被改成 380ms */\n::view-transition-group(*) { animation-duration: 380ms; }\n```\n\n挂 `:root.mk-vt-share` 之后，只有本次带类的转场生效，摘类立刻回默认。\n实测：同页别人家的 `::view-transition-group(root)` 仍是 `0.25s`。\n\n`view-transition-class` + `*.mk-share` 是这条的另一半：一组卡片各自带不同的 `--mk-share`，\n规则只写一条，不用给每张卡单独写伪元素选择器。\n\n### ④ 名字必须是合法标识符，且**不同种子不能撞名**\n\n实测 `0` / `1hero` / `mk s0` / `*` 全部 compute 成 `none`；`mk-s0` / `mk_s0` 可以。\n所以 `shareName()` 永远带前缀，不直接用索引。\n\n第一版这里是错的：把非法字符剥光之后，`*` / `中文` / 空串统统退回同一个占位符 `mk-share-s0` ——\n和种子 `0` 撞名。撞名就是 ① 那个 `InvalidStateError`。改法是剥光之后用**种子本身的散列**：\n\n```js\nif (!slug) return `${prefix}-h${hash32(raw)}`;   // FNV-1a 32 位 → base36\n```\n\n实测 `*` → `mk-share-hd1yn99`、`''` → `mk-share-hztntfp`、`'中文'` → `mk-share-hmj2ca5`、\n`'拍立得'` → `mk-share-hpukyhm`，互不相同。\n\n残留（已写进 JSDoc）：`null` / `undefined` / `''` 三者同名。这没关系 —— 指令层已经拦了\n`name != null`，缺种子时根本不挂名字。\n\n### ⑤ Vue 里必须 `await nextTick()`，而且 DOM 变化只能在回调里发生\n\n```js\n// ✗ 先改 state 再调 API：浏览器拍到的\"新快照\"还是老 DOM\nshareOpen.value = card;\nMK.startShare(() => {});\n\n// ✓ 改 DOM 的那一段必须包在回调里，且等 Vue 刷完\nMK.startShare(async () => {\n  shareOpen.value = card;\n  await Vue.nextTick();      // ← 少了这行，快照仍是老的，看起来\"没生效\"\n});\n```\n\n`update` 返回 Promise 时浏览器会等它 resolve 才拍\"新状态\"快照。少了 `nextTick`，\n赋值是同步的但 Vue 的 flush 是微任务 —— 浏览器拍快照的时机在 flush 之前，等于什么都没变。\n现象是**名字和 CSS 全对，但一点动画都没有**，很容易误判成\"API 没生效\"。\n\n### 另外两条不值得开小标题的\n\n- **不要在共享元素外面再套 `<transition>`**：淡入会和尺寸插值叠在一起，变成\"糊一下再飞\"。\n  页首那块渐变之所以看起来是\"卡片在长大\"，正是因为这里只做了尺寸/位置的插值。\n- **容器不需要特殊处理**：`.device` 那种 `transform` + `overflow: hidden` + `border-radius`\n  的手机框，两个引擎都不裁过渡伪元素。不用给容器加 `isolation` 之类的东西。",
      "ai_assets": {
        "prompt": "给一个列表页和它的详情页做共享元素转场：点列表里的一张卡，那张卡自己长大成详情页的页首区块，\n返回时是同一段的逆向。**不要手写 FLIP 测量** —— 尺寸和位置的插值交给浏览器的 View Transitions。\n\n**原理**：`document.startViewTransition(cb)` 会拍两个快照（回调前 = 旧状态，回调 resolve 后 = 新状态）。\n任何在两个快照里都带**同一个** `view-transition-name` 的元素，浏览器自动建一个\n`::view-transition-group(name)` 伪元素，在两者之间插值 `width`/`height`/`transform`。\n你不需要量任何矩形。\n\n**步骤**：\n\n1. 写一个模板类，给需要共享的元素挂 `view-transition-class: xf`，\n   `view-transition-name` 走自定义属性：\n   ```css\n   .xf { view-transition-name: var(--xf, none); view-transition-class: xf; }\n   ```\n2. 写一个纯函数把任意种子变成**合法标识符**（CSS 自定义属性里的名字会被当作 ident 解析，\n   非法就静默变 `none`）：\n   - 把 `[^A-Za-z0-9_-]` 全部替换成 `-`，再去掉首尾的 `-`；\n   - 如果剥完是空串（种子是 `*`、中文、汉字组合等），**不能用固定占位符** ——\n     用种子自身的 FNV-1a 32 位散列转 base36，返回 `xf-h<hash>`；\n   - 如果首字符是数字，前面补一个 `s`；\n   - 最终形如 `xf-<id>`。\n3. 过渡时长和缓动**必须写在样式表里**（预先加载），用自定义属性做 token：\n   ```css\n   :root { --xf-dur: 380ms; }\n   :root.xf-on::view-transition-group(*.xf) {\n     animation-duration: var(--xf-dur, 380ms);\n     animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);\n   }\n   /* 整页不做交叉淡入淡出，否则会和元素长大叠在一起 */\n   :root.xf-on::view-transition-old(root),\n   :root.xf-on::view-transition-new(root) { animation: none; }\n   ```\n4. 写一个启动函数：\n   - 探测 `typeof document.startViewTransition === 'function'`，没有就直接执行回调并返回；\n   - 探测 `matchMedia('(prefers-reduced-motion: reduce)').matches`，为真也直接执行回调\n     —— **API 自己不认这个媒体查询**，实测 reduce 下时长仍是 250ms；\n   - 给 `document.documentElement` 加 `xf-on` 类、写 `--xf-dur`，调 `startViewTransition(cb)`，\n     在 `transition.finished` 的 resolve **和** reject 里都摘类、删变量。\n5. 在应用层：打开详情时**把列表项的名字交出去**（设为 `none`），详情层接过同名；\n   关闭时反过来。两侧绝不能同时持有同一个名字。\n\n**硬要求**（少一条就失败）：\n\n- 同一时刻只能有一个元素持有某个 `view-transition-name`。两个 → `InvalidStateError`，\n  **过渡不启动但回调整照跑**，现象是硬切、控制台报错。\n- `::view-transition-*` 规则必须**随样式表预先存在**。过渡前一瞬注入 `<style>` 会被两个引擎忽略，\n  时长退回 250ms。\n- 改 DOM 的代码必须在回调**内部**执行，且框架异步刷新（React/Vue/Svelte）时要 `await` 到刷新完成。\n  否则浏览器拍到的\"新快照\"还是旧 DOM，一点动画都没有。\n- `view-transition-name` 的取值必须是合法 CSS 标识符。`0`、`*`、含空格的字符串都变 `none`。\n\n**验收标准**（都要可观测，不许\"看起来对\"）：\n\n- 过渡期间用 `getComputedStyle(document.documentElement, '::view-transition-group(<name>)')`\n  采样，`width` 应该从列表卡的宽度**单调**增长到详情区块的宽度，中间取到至少 4 个不同值；\n- 该伪元素的 `animationDuration` 等于你设的 token，不是 `0.25s`；\n- 同页若有其它 View Transition，它们的 group 时长仍是 `0.25s`（证明作用域没漏）；\n- `matchMedia('(prefers-reduced-motion: reduce)')` 为真时，点击后**没有任何**\n  `::view-transition-*` 动画被创建，DOM 仍然正确切换；\n- 连续开关三次后，`document.documentElement` 上没有残留的开关类或 token 变量。",
        "dont_do": "- 不要手写 `getBoundingClientRect` + `transform` 的 FLIP，也不要装 Framer Motion / GSAP 来做这件事\n  —— 浏览器已经在做同一件事，而且做得更准（滚动容器、圆角、`overflow: hidden` 都不用你处理）。\n- 不要在共享元素外面套淡入/淡出动画。\n- 不要用固定的 `view-transition-name` 字面量给一组列表项（比如都写 `hero`），会立刻撞名。\n- 不要把时长写成 `0s` 来表示\"关掉\"——用 `1ms`，`0s` 会让 `finished` 抢在伪元素建立之前 resolve。\n- 不支持 View Transitions 的引擎上**不要**补一段降级动画，直接硬切；按下反馈是另一层的事。",
        "skill_rule": "# 共享元素转场 (shared-element) · 跨平台动效规范\n性质：连续 ｜ 平台：both\n\n【核心原理】点列表里的一张卡，**那张卡自己长大成详情页**，不是淡入一个新页面；返回时是同一段的逆向。\n\n【禁止做法】\n- 不要手写 `getBoundingClientRect` + `transform` 的 FLIP，也不要装 Framer Motion / GSAP 来做这件事\n  —— 浏览器已经在做同一件事，而且做得更准（滚动容器、圆角、`overflow: hidden` 都不用你处理）。\n- 不要在共享元素外面套淡入/淡出动画。\n- 不要用固定的 `view-transition-name` 字面量给一组列表项（比如都写 `hero`），会立刻撞名。\n- 不要把时长写成 `0s` 来表示\"关掉\"——用 `1ms`，`0s` 会让 `finished` 抢在伪元素建立之前 resolve。\n- 不支持 View Transitions 的引擎上**不要**补一段降级动画，直接硬切；按下反馈是另一层的事。",
        "prompt_en": "Core Principle:\nImplement a shared-element transition between a list view and a detail view: clicking a list card morphs that card smoothly into the detail page hero block, and navigating back reverses the same path. Do not write manual FLIP measurements—let the browser's View Transitions API interpolate size and position. `document.startViewTransition(cb)` captures two snapshots (old state before the callback, new state after the callback resolves); for any element sharing the same `view-transition-name` in both snapshots, the browser automatically creates a `::view-transition-group(name)` pseudo-element and interpolates `width`/`height`/`transform` between them with zero rectangle measurements.\n\nImplementation:\n1. Define a template class assigning `view-transition-class: xf` and reading `view-transition-name` from a CSS custom property:\n   ```css\n   .xf { view-transition-name: var(--xf, none); view-transition-class: xf; }\n   ```\n2. Write a pure sanitizer turning any seed into a valid CSS identifier (invalid names inside custom properties silently collapse to `none`):\n   - Replace all `[^A-Za-z0-9_-]` with `-` and strip leading/trailing `-`;\n   - If the stripped string is empty (e.g., `*` or non-ASCII characters), do not use a fixed placeholder—compute an FNV-1a 32-bit hash of the seed in base36 and return `xf-h<hash>`;\n   - If the leading character is a digit, prepend `s`;\n   - Final format is `xf-<id>`.\n3. Transition duration and easing must live in a preloaded stylesheet, parameterized by a custom property:\n   ```css\n   :root { --xf-dur: 380ms; }\n   :root.xf-on::view-transition-group(*.xf) {\n     animation-duration: var(--xf-dur, 380ms);\n     animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);\n   }\n   /* Disable root cross-fade so it does not layer over the growing element */\n   :root.xf-on::view-transition-old(root),\n   :root.xf-on::view-transition-new(root) { animation: none; }\n   ```\n4. Write a launcher function:\n   - Feature-detect `typeof document.startViewTransition === 'function'` and run the callback directly if missing;\n   - Check `matchMedia('(prefers-reduced-motion: reduce)').matches` and also run the callback directly when true (the API itself ignores this media query—measured duration stays `250ms` under reduce);\n   - Add `xf-on` and set `--xf-dur` on `document.documentElement`, call `startViewTransition(cb)`, and remove the class and variable in both the resolve and reject handlers of `transition.finished`.\n5. At the application layer, hand off the list item's name when opening detail (set list item to `none` and assign the same name to the detail hero), and reverse on close. Both elements must never hold the same name simultaneously.\n\nHard Constraints:\n- Only one element at a time may hold a given `view-transition-name`; two simultaneous holders throw `InvalidStateError` (the transition aborts while the callback still runs, resulting in a hard cut and a console error).\n- `::view-transition-*` rules must already exist in the stylesheet before starting; injecting a `<style>` right before the transition is ignored by browsers and falls back to `250ms`.\n- DOM mutations must happen inside the callback, and asynchronous framework updates (React/Vue/Svelte) must be awaited to completion inside it; otherwise the \"new snapshot\" captures stale DOM with zero animation.\n- `view-transition-name` must evaluate to a valid CSS `<custom-ident>`; `0`, `*`, or strings with spaces collapse to `none`.\n\nAcceptance Criteria:\n- Sampling `getComputedStyle(document.documentElement, '::view-transition-group(<name>)').width` during the transition yields monotonically increasing values from the list card width to the detail block width, with at least 4 distinct intermediate values.\n- That pseudo-element's `animationDuration` equals your configured token rather than `0.25s`.\n- Any other View Transition on the same page retains `0.25s` group duration (proving scope isolation).\n- When `matchMedia('(prefers-reduced-motion: reduce)')` is true, clicking creates zero `::view-transition-*` animations while still switching the DOM accurately.\n- After three consecutive open/close cycles, no stray toggle class or token variable remains on `document.documentElement`.",
        "dont_do_en": "- Do NOT hand-roll `getBoundingClientRect` + `transform` FLIP or install Framer Motion / GSAP for this — the browser already performs the exact interpolation more accurately (handling scroll containers, border-radius, and `overflow: hidden` automatically).\n- Do NOT wrap the shared element in an extra fade-in/fade-out animation.\n- Do NOT assign a hardcoded literal `view-transition-name` (such as `hero`) to a list of items — names will collide immediately.\n- Do NOT set duration to `0s` to \"disable\" it — use `1ms`, because `0s` causes `finished` to resolve before pseudo-elements are constructed.\n- Do NOT bolt on a fallback animation for engines without View Transitions — hard-cut directly; press feedback belongs to a separate layer.",
        "skill_rule_en": "# Shared Element View Transition (shared-element) · Cross-Platform Motion Spec\nNature: Continuity | Layer: motion | Platform: both\n\nCore Principle: Implement a shared-element transition between a list view and a detail view: clicking a list card morphs that card smoothly into the detail page hero block, and navigating back reverses the same path. Do not write manual FLIP measurements—let the browser's View Transitions API interpolate size and position. `document.startViewTransition(cb)` captures two snapshots (old state before the callback, new state after the callback resolves); for any element sharing the same `view-transition-name` in both snapshots, the browser automatically creates a `::view-transition-group(name)` pseudo-element and interpolates `width`/`height`/`transform` between them with zero rectangle measurements.\n\nHard Constraints:\n- Only one element at a time may hold a given `view-transition-name`; two simultaneous holders throw `InvalidStateError` (the transition aborts while the callback still runs, resulting in a hard cut and a console error).\n- `::view-transition-*` rules must already exist in the stylesheet before starting; injecting a `<style>` right before the transition is ignored by browsers and falls back to `250ms`.\n- DOM mutations must happen inside the callback, and asynchronous framework updates (React/Vue/Svelte) must be awaited to completion inside it; otherwise the \"new snapshot\" captures stale DOM with zero animation.\n- `view-transition-name` must evaluate to a valid CSS `<custom-ident>`; `0`, `*`, or strings with spaces collapse to `none`.\n\nAcceptance Criteria:\n- Sampling `getComputedStyle(document.documentElement, '::view-transition-group(<name>)').width` during the transition yields monotonically increasing values from the list card width to the detail block width, with at least 4 distinct intermediate values.\n- That pseudo-element's `animationDuration` equals your configured token rather than `0.25s`.\n- Any other View Transition on the same page retains `0.25s` group duration (proving scope isolation).\n- When `matchMedia('(prefers-reduced-motion: reduce)')` is true, clicking creates zero `::view-transition-*` animations while still switching the DOM accurately.\n- After three consecutive open/close cycles, no stray toggle class or token variable remains on `document.documentElement`.\n\nDo NOT Do:\n- Do NOT hand-roll `getBoundingClientRect` + `transform` FLIP or install Framer Motion / GSAP for this — the browser already performs the exact interpolation more accurately (handling scroll containers, border-radius, and `overflow: hidden` automatically).\n- Do NOT wrap the shared element in an extra fade-in/fade-out animation.\n- Do NOT assign a hardcoded literal `view-transition-name` (such as `hero`) to a list of items — names will collide immediately.\n- Do NOT set duration to `0s` to \"disable\" it — use `1ms`, because `0s` causes `finished` to resolve before pseudo-elements are constructed.\n- Do NOT bolt on a fallback animation for engines without View Transitions — hard-cut directly; press feedback belongs to a separate layer."
      }
    },
    {
      "id": "snap-sheet",
      "name": "多档位弹层",
      "name_en": "Multi-Snap Bottom Sheet",
      "layer": "mobile",
      "nature": "权重",
      "platform": "touch",
      "status": "shipped",
      "entry": "sheet(el, { snapPoints, snap, onSnap, dismissible }) / snapIndexAt() / snapShouldClose()",
      "source": "Vaul 的 snapPoints + Apple Maps 的三档面板",
      "source_en": "Apple Maps / Vaul snapPoints (velocity-projected detent selection)",
      "file": "effects/snap-sheet.md",
      "summary": "同一个底部面板停在三档高度上（35% / 62% / 全开），拖动时按「位移 + 速度」一起决定落到哪一档。",
      "summary_en": "Three-detent bottom sheet (35% / 62% / 100%) using velocity-projected landing calculation and dedicated lowest-detent quick-dismiss ergonomics.",
      "problem": "**两态面板会逼用户做一次它不该做的决定。** 「开」和「关」之间其实常常有中间态：看地图时\n想知道附近有什么（35%），想看清列表（62%），想看全（全开）。只有两态的话，用户只能在\n\"挡住半屏\"和\"什么都没有\"之间跳。\n\n第二个问题更细：**档位不是\"拖到哪个高度就停在哪\"**，而是\"松手时判断你想去哪\"。\n慢慢拖到 50% 高度松手，落点是 62% 还是 35%，取决于最近的那个——但轻轻一甩，\n即使只拖了 15%，也应该跨到下一档。这就是为什么速度不参与\"距离阈值\"，而是改变**落点本身**。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| Vaul 的 snapPoints：档位是「可见高度比例」，不是绝对像素 | Vaul 的滚动容器接管与内部滚动联动（面板滚到底再拖收起） |\n| 速度把落点**往前投影**再取最近档 —— 一套数学覆盖\"慢慢拖\"和\"轻甩\" | 「甩得够快直接关掉」当作独立阈值（那种写法在两档之间会误判） |\n| 在最低档往下轻甩就关（单独一条判定） | 面板圆角/阴影随档位渐变（iOS 有） |\n| 档位间迁移只写 `transform`，遮罩不跟手 | 遮罩随档位微调透明度（会让最低档读起来像\"快关了\"） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 档位单位 | 面板自身高度的比例 | 面板高度是内容驱动的（`max-height: 82dvh` 只是上限）。用视口比例会在内容少的面板上算出不一致的档 |\n| 默认档位 | `[0.35, 0.62, 1]` | 35% 够看到三行（\"附近有什么\"）；62% 是\"正在读列表\"；1 = 遮罩消失、内容全见 |\n| 速度投影窗口 `carry` | `160ms` | 0.55 px/ms 的甩速 × 160ms ≈ 88px，相当于\"再往前多拖半个拇指\"。低于 100ms 甩不动，高于 250ms 会跨两档 |\n| 最低档甩出阈值 | 复用 `velocityThreshold` 0.55 px/ms | 和收起判定同一个数。用户感受到的\"甩一下\"只有一个强度，不该有第二套标尺 |\n| 档位迁移时长 | `--mk-dur-4` = 380ms | 跨档是一次\"层面切换\"，不是微调。240ms 会显得被拽过去，560ms 像在等 |\n| 最低档可见比例 | 0.35 | 低于 30% 抓手会和底部安全区打架；高于 40% 就挡掉太多内容，失去\"半开\"的意义 |",
      "implementation": "```\ngesture.js:32    offsetForSnap(visible, height)     纯函数：可见比例 → 位移\ngesture.js:55    snapIndexAt(offset, h, snaps, v)   纯函数：落点 + 速度投影 → 档位下标\ngesture.js:150   snapShouldClose(...)               纯函数：这一下该不该关（含\"最低档甩一把\"）\ngesture.js:187   sheet(el, { snapPoints, snap, onSnap, dismissible })\nmobile.css:110   .mk-sheet                          基础位置；有档位时由 demo 覆盖 transform\n```\n\n**三个纯函数 + 一个接线层。** 所有判断都能单测（8 条测试覆盖），`sheet()` 只做\n\"把指针位移喂进去、把结果写回 DOM\"。这条分工和 `shouldDismiss` / `shouldGoBack` 一致。\n\n有档位时 `sheet()` 多两个状态：\n\n```\nidx    当前档位下标\nrest() 当前档位对应的位移 —— 每次现算，不缓存\n```\n\n`rest()` 现算不缓存是必需的：Vue 指令 `mounted` 时节点可能还没布局，`offsetHeight` 是 0，\n缓存下来的位移会永远停在 0，面板一打开就在最顶上。",
      "degradation": "**走 `mobile.css` 那档：减。**\n\n```css\n@media (prefers-reduced-motion: reduce) {\n  .mk-sheet { transition-duration: 120ms; }\n  @starting-style { .mk-sheet { transform: none; opacity: 0; } }\n}\n```\n\n档位逻辑不摘 —— 它是**功能**（用户要能选择看多少内容），和\"动效\"不是一回事。\n减弱动效时只把跨档的 380ms 压到 120ms：档位还是那三档，只是过去得更快。\n\n拖拽手势本身也保留：减弱动效的用户一样要把面板拖起来看全。",
      "pitfalls": "**① 别在构造时缓存档位位移。**\n\n```js\n// 错：mounted 时 offsetHeight 可能是 0\nlet rest = offsetForSnap(snaps[idx], el.offsetHeight);\n\n// 对：用到时再算\nconst rest = () => (snaps ? offsetForSnap(snaps[idx], height()) : 0);\n```\n\n实测过这个坑：`v-show` 控制的节点在 `mounted` 那一刻 `display: none`，`offsetHeight` 返回 0，\n`rest` 被算成 0，面板一打开就直接贴在最顶上（全开档），和声明的初始档无关。\n\n**② 速度不能替换距离判定，要参与\"落点计算\"。**\n\n错误直觉是\"拖得够远 → 下一档；甩得够快 → 下一档\"，两个条件并列。这样在两档之间\n会同时命中或都不命中。正确做法是把落点往前投影：\n\n```js\nconst projected = clamp(offset + velocity * carry, 0, height);\n// 然后在 projected 上取最近档\n```\n\n一套最近邻数学同时覆盖\"慢慢拖\"和\"轻甩\"，不需要 if 分叉。\n\n**③ 最低档到关闭档之间要单独判一次速度。**\n\n最低档 0.35、关闭是 1.0，两者位移差 0.65 × 高度 = 约 390px。只靠投影要甩到\n**0.66 px/ms** 才能跨过中点 —— 而 iOS 上\"在最低档往下轻轻一甩就关\"是肌肉记忆，\n那个动作在投影里永远差一点，结果就是\"甩了没反应\"。所以：\n\n```js\nvelocity > velocityThreshold && offset >= lowest - 1   // 宽容 1px 的浮点误差\n```\n\n这条是实测发现的：初版只有投影，从最低档 0.5 px/ms 甩下去只回到 35%，不关。\n\n**④ 有档位时遮罩不能跟手变淡。**\n\n无档位的 `sheet()` 里 `opacity = 1 - y / (h * 1.5)` 是对的：拖到一半遮罩半透明，\n用户从遮罩就知道\"我快把它关掉了\"。但有档位时，从 62% 拖到 35% 也是往下拖 ——\n遮罩跟着变淡会让**最低档看起来像\"快关了\"，而它其实是个稳态**。\n\n正确做法：有档位时遮罩只在真正关闭时变（`.is-closing` 那条 CSS）。\n\n**⑤ `dismissible: false` 时不能让\"关闭档\"参与最近邻。**\n\n如果调用方明确说\"这面板不能关\"，虚拟关闭档就必须从候选里去掉，否则\n\"拖得很远\"会落到一个不存在的档上。`snapIndexAt` 的 `dismissible` 参数就是干这个的；\n`sheet()` 里先判 `snapShouldClose`（它会尊重 `dismissible`），再用\n`dismissible: false` 取档位——顺序反了会得到\"该关但关了没关\"的矛盾状态。\n\n**⑥ 档位顺序由调用方给，但必须自己再排一次。**\n\n`[1, 0.35, 0.62]` 和 `[0.35, 0.62, 1]` 是同一组档位，但下标语义完全不同\n（`snap: 1` 指的是第二档）。`sheet()` 里做一次 `sort()` 并约定\"下标从低到高\"，\n调用方就不用记规则。代价是**调用方传 `snap` 时必须按排序后的顺序数**——\n这一条写进 JSDoc，否则第一次用必踩。",
      "ai_assets": {
        "prompt": "实现一个多档位底部面板（snap points）。原生 Pointer Events + CSS 过渡，不引依赖。\n\n原理一句话：档位是一组固定的位移落点，松手时把\"当前位移 + 速度×一小段时间\"投影成一个落点，\n再取最近的档 —— 一套最近邻数学同时覆盖\"慢慢拖\"和\"轻甩\"。\n\n结构：\n  <div class=\"backdrop\"></div>\n  <div class=\"sheet\" style=\"max-height: 82dvh\">\n    <div class=\"grabber\" data-handle></div>\n    ...内容...\n  </div>\n\n档位用「面板自身可见高度的比例」表示，升序，例如 [0.35, 0.62, 1]。\n位移 = 高度 × (1 − 比例)：全开 0，完全收起 = 高度。\n\n单指针拖动（只接主键 e.button === 0），pointerdown 时调 setPointerCapture，\n这样手指移出元素也继续收到 move。\n\n拖动中：transform = translate3d(0, clamp(当前档位移 + dy, 0, 高度), 0)，\n并且该元素 transition: none。\n\n松手：\n1. 若是 pointercancel → 不做任何判定，直接滑回当前档（浏览器抢走手势不是用户松手）。\n2. 若 velocity > 0.55 px/ms 且当前位移已到最低档（容差 1px）→ 关闭。\n3. 否则取档：\n     projected = clamp(offset + velocity * 160, 0, 高度)   // 160ms 投影窗口\n     在 [各档位移..., 高度] 里找距离 projected 最近的；若最近的正好是最后那个\n     (= 高度) → 关闭；否则吸附到该档位移。\n4. 恢复过渡（transition: ''）后再写新的 transform，让过渡从当前跟手位置接管。\n\n硬要求：\n- 档位位移必须**用到时现算**（高度 × (1 − 比例)），不要在初始化时缓存 ——\n  节点在 display:none 状态下 offsetHeight 是 0，缓存会让面板永远停在全开档。\n- 位移一律走 transform，不要动 top / bottom / height。\n- 投影结果必须 clamp 到 0..高度。不钳的话往上狂甩会算出负落点。\n- 有档位时遮罩**不要**跟手变淡。档位之间是稳态，跟手淡出会让最低档看起来像快关了。\n  遮罩只在真正关闭时过渡到 0。\n- 关闭 = 滑到 translateY(100%)，然后通知调用方隐藏节点；组件自己不要 remove 节点。\n- 调用方传初始档位时，下标按\"排序后的档位数组\"数；实现内部必须自己 sort 一次。\n\n验收：\n- 从最低档慢慢往上拖 27% 高度（正好到中档）→ 停在 62%，位移 = 高度 × 0.38。\n- 再慢慢往上拖 38% 高度 → 停在 0（全开）。\n- 从全开慢慢往下拖 20% 高度 → 回到 62%（不是直接关）。\n- 在最低档往下轻甩（约 0.5px/ms，只拖 70px）→ 面板关闭。\n- 慢慢往下拖 25% 高度（从 62% 出发）→ 停在最低档，不关。\n- 拖到任意位置派发 pointercancel → 滑回拖动前那一档，不关闭。\n- 关闭后重新打开 → 回到调用方指定的初始档，且没有\"先闪一下全开\"。",
        "dont_do": "- 别用 height / max-height 做档位切换 —— 每帧重排，而且会打断内容滚动。\n- 别把\"拖得够远\"和\"甩得够快\"写成两个并列的 if —— 它们要合成一个投影落点。\n- 别在最低档只靠投影判断关闭 —— 最低档到关闭档隔着一整段高度，\n  必须单独给\"在最低档甩一把\"开一条判定。\n- 别给面板常驻 will-change: transform —— 拖动开始加、结束摘。",
        "skill_rule": "# 多档位弹层 (snap-sheet) · 跨平台动效规范\n性质：权重 ｜ 平台：touch\n\n【核心原理】档位是一组固定的位移落点，松手时把\"当前位移 + 速度×一小段时间\"投影成一个落点，\n\n【硬要求】\n- 档位位移必须**用到时现算**（高度 × (1 − 比例)），不要在初始化时缓存 ——\n  节点在 display:none 状态下 offsetHeight 是 0，缓存会让面板永远停在全开档。\n- 位移一律走 transform，不要动 top / bottom / height。\n- 投影结果必须 clamp 到 0..高度。不钳的话往上狂甩会算出负落点。\n- 有档位时遮罩**不要**跟手变淡。档位之间是稳态，跟手淡出会让最低档看起来像快关了。\n  遮罩只在真正关闭时过渡到 0。\n- 关闭 = 滑到 translateY(100%)，然后通知调用方隐藏节点；组件自己不要 remove 节点。\n- 调用方传初始档位时，下标按\"排序后的档位数组\"数；实现内部必须自己 sort 一次。\n\n【验收标准】\n- 从最低档慢慢往上拖 27% 高度（正好到中档）→ 停在 62%，位移 = 高度 × 0.38。\n- 再慢慢往上拖 38% 高度 → 停在 0（全开）。\n- 从全开慢慢往下拖 20% 高度 → 回到 62%（不是直接关）。\n- 在最低档往下轻甩（约 0.5px/ms，只拖 70px）→ 面板关闭。\n- 慢慢往下拖 25% 高度（从 62% 出发）→ 停在最低档，不关。\n- 拖到任意位置派发 pointercancel → 滑回拖动前那一档，不关闭。\n- 关闭后重新打开 → 回到调用方指定的初始档，且没有\"先闪一下全开\"。\n\n【禁止做法】\n- 别用 height / max-height 做档位切换 —— 每帧重排，而且会打断内容滚动。\n- 别把\"拖得够远\"和\"甩得够快\"写成两个并列的 if —— 它们要合成一个投影落点。\n- 别在最低档只靠投影判断关闭 —— 最低档到关闭档隔着一整段高度，\n  必须单独给\"在最低档甩一把\"开一条判定。\n- 别给面板常驻 will-change: transform —— 拖动开始加、结束摘。",
        "prompt_en": "Core Principle:\nImplement a multi-snap-point bottom sheet using native Pointer Events and CSS transitions with zero dependencies. Snap points are fixed offset targets; on release, project `currentOffset + velocity * 160ms` into a landing point and pick the nearest snap target—one nearest-neighbor formula handles both slow drags and quick flicks uniformly.\n\nImplementation:\n1. Structure:\n   `<div class=\"backdrop\"></div>`\n   `<div class=\"sheet\" style=\"max-height: 82dvh\"><div class=\"grabber\" data-handle></div>...content...</div>`\n   Express snap points as ascending fractions of the sheet's own visible height, e.g., `[0.35, 0.62, 1]`. Offset = `height * (1 - ratio)` (`0` = fully open, `height` = fully closed).\n2. Single-pointer drag (`e.button === 0` primary button only): call `setPointerCapture` on `pointerdown` so moves keep firing even when the finger leaves the element.\n3. While dragging: set `transform = translate3d(0, clamp(currentSnapOffset + dy, 0, height), 0)` with `transition: none` on the sheet.\n4. On release:\n   - If `pointercancel`, skip all snap logic and slide back to the current snap point (OS gesture takeover is not a user release).\n   - If `velocity > 0.55` px/ms and current offset is already at the lowest snap point (`1px` tolerance), close the sheet.\n   - Otherwise compute `projected = clamp(offset + velocity * 160, 0, height)` (160ms projection window), find the nearest candidate in `[...snapOffsets, height]`; if the nearest is the final `height` entry, close; otherwise snap to that offset.\n   - Restore `transition: ''` before writing the new `transform` so the transition picks up smoothly from the live dragged position.\n\nHard Constraints:\n- Snap offsets must be computed on demand (`height * (1 - ratio)`), never cached at init—`offsetHeight` is `0` while `display: none`, which would lock the sheet permanently at fully open.\n- Move strictly via `transform`; never animate `top`, `bottom`, or `height`.\n- Projection result must be clamped to `0..height`; without clamping, an aggressive upward flick produces a negative target.\n- When multiple snap points exist, do not fade the backdrop continuously during drag—snap points are resting states and fading makes the lowest snap look half-dismissed; transition the backdrop to `0` only on actual close.\n- Closing means sliding to `translateY(100%)` and notifying the caller to hide the node; the component must never remove the DOM node itself.\n- Caller-supplied initial snap index must reference the sorted snap array; sort the array internally.\n\nAcceptance Criteria:\n- Dragging slowly up by 27% height from the lowest snap (reaching mid snap) settles at 62%, offset = `height * 0.38`.\n- Dragging slowly up another 38% height settles at `0` (fully open).\n- Dragging slowly down 20% height from fully open returns to 62% (does not close).\n- Flicking downward at the lowest snap (`~0.5px/ms` over only `70px`) closes the sheet.\n- Dragging slowly down 25% height from 62% settles at the lowest snap without closing.\n- Dispatching `pointercancel` mid-drag slides back to the pre-drag snap without closing.\n- Reopening after close lands on the caller's specified initial snap with zero flash of the fully-open state.",
        "dont_do_en": "- Do NOT switch snap points using `height` or `max-height` — it forces per-frame layout reflow and interrupts inner scrolling.\n- Do NOT write separate `if` branches for \"dragged far enough\" vs \"flicked fast enough\" — unify them into a single projected landing offset.\n- Do NOT rely solely on projection to close from the lowest snap — a full height span separates the lowest snap from closed, so add a dedicated downward-flick check at the lowest snap.\n- Do NOT leave `will-change: transform` permanently on the sheet — add it on drag start and remove it on drag end.",
        "skill_rule_en": "# Multi-Snap Bottom Sheet (snap-sheet) · Cross-Platform Motion Spec\nNature: Weight | Layer: mobile | Platform: touch\n\nCore Principle: Implement a multi-snap-point bottom sheet using native Pointer Events and CSS transitions with zero dependencies. Snap points are fixed offset targets; on release, project `currentOffset + velocity * 160ms` into a landing point and pick the nearest snap target—one nearest-neighbor formula handles both slow drags and quick flicks uniformly.\n\nHard Constraints:\n- Snap offsets must be computed on demand (`height * (1 - ratio)`), never cached at init—`offsetHeight` is `0` while `display: none`, which would lock the sheet permanently at fully open.\n- Move strictly via `transform`; never animate `top`, `bottom`, or `height`.\n- Projection result must be clamped to `0..height`; without clamping, an aggressive upward flick produces a negative target.\n- When multiple snap points exist, do not fade the backdrop continuously during drag—snap points are resting states and fading makes the lowest snap look half-dismissed; transition the backdrop to `0` only on actual close.\n- Closing means sliding to `translateY(100%)` and notifying the caller to hide the node; the component must never remove the DOM node itself.\n- Caller-supplied initial snap index must reference the sorted snap array; sort the array internally.\n\nAcceptance Criteria:\n- Dragging slowly up by 27% height from the lowest snap (reaching mid snap) settles at 62%, offset = `height * 0.38`.\n- Dragging slowly up another 38% height settles at `0` (fully open).\n- Dragging slowly down 20% height from fully open returns to 62% (does not close).\n- Flicking downward at the lowest snap (`~0.5px/ms` over only `70px`) closes the sheet.\n- Dragging slowly down 25% height from 62% settles at the lowest snap without closing.\n- Dispatching `pointercancel` mid-drag slides back to the pre-drag snap without closing.\n- Reopening after close lands on the caller's specified initial snap with zero flash of the fully-open state.\n\nDo NOT Do:\n- Do NOT switch snap points using `height` or `max-height` — it forces per-frame layout reflow and interrupts inner scrolling.\n- Do NOT write separate `if` branches for \"dragged far enough\" vs \"flicked fast enough\" — unify them into a single projected landing offset.\n- Do NOT rely solely on projection to close from the lowest snap — a full height span separates the lowest snap from closed, so add a dedicated downward-flick check at the lowest snap.\n- Do NOT leave `will-change: transform` permanently on the sheet — add it on drag start and remove it on drag end."
      }
    },
    {
      "id": "sparkline-draw",
      "name": "迷你走势线生长",
      "name_en": "SVG Sparkline Draw-In",
      "layer": "motion",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-spark + .mk-spark / sparklineGeometry() / sparkline()",
      "source": "Stripe / Vercel / Apple Stocks 表格内嵌迷你折线（零图表库 SVG stroke-dashoffset 描绘）",
      "source_en": "Stripe / Vercel KPI sparklines (zero chart library + 520ms stroke reveal)",
      "file": "effects/sparkline-draw.md",
      "summary": "纯函数把一串数字映射成轻量 SVG 迷你折线与渐变面积，进入视口时线条从左向右 520ms 平滑描绘，面积晚 120ms 淡入，末端数据点最后轻弹落位。",
      "summary_en": "Pure geometry generator producing a minimal SVG trendline and gradient fill that strokes left-to-right over 520ms with staggered area fade and terminal dot pop.",
      "problem": "**表格里嵌一条 7 日趋势线能瞬间传达“正在涨还是正在跌”，但为此引入几百 KB 的图表库完全杀鸡用牛刀。** 静态折线又缺少时间从左向右流淌的方向感；用 50 行纯数学 + 原生 SVG `stroke-dashoffset` 就能拿到媲美 Stripe 表格的手感。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| Stripe / Apple Stocks 表格折线的三拍层次（描线 → 面积淡入 → 末点落位） | ECharts / Chart.js / D3 运行时依赖 |\n| 纯函数 `sparklineGeometry()` 处理全平数据（`min === max` 居中画线不除零） | 复杂的坐标轴、网格线与图例（迷你走势线只传达趋势形状） |\n| 按首尾趋势自动标 `data-trend=\"up|down\"` 切换涨跌主题色 | 手写死 `stroke-dasharray: 999` 导致短线前半段空等 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 描线时长 | `520ms`（`ease-out`） | 足够看清曲线从左到右走完的趋势方向，又不至于超过 600ms 拖慢页面 |\n| 面积淡入延迟 | `120ms`（时长 `380ms`） | 等折线先画出开头再垫上渐变底色，视觉层次更干净，不抢线条风头 |\n| 末点落位延迟 | `380ms`（`scale 0.4 → 1`） | 恰好在笔尖快走到最右端时轻弹亮起，像给趋势打上句号 |\n| 线宽 / 内边距 | `1.75px` / `4px` | 1px 在高分屏偏细、2.5px 在 36px 高单元格里太粗；4px pad 保证极值点和末点圆点不被 viewBox 裁切 |",
      "implementation": "```\nsrc/core/data.js:90    sparklineGeometry(values, opts)  纯函数，输出 linePath / areaPath / points / trend\nsrc/core/data.js:121   sparkline(el, values, opts)      生成 SVG，量 getTotalLength() 写 --mk-spark-len\nstyles/motion.css      .mk-spark / __line / __area / __dot\n```",
      "degradation": "**走 `motion` 档：减，不关。**\n\n`prefers-reduced-motion: reduce` 下所有描绘、淡入与圆点缩放的时长压到 `1ms`、延迟归零，完整走势线、渐变面积与末点直接呈现。",
      "pitfalls": "**① 所有数据点相等（全平直线 `max === min`）时直接除以 `max - min` 算出 `NaN`。**\n必须显式判断 `span === 0`，把所有点放在垂直中线 `y = height / 2`，正常画出水平线。\n\n**② `stroke-dasharray` 随便写死成 `1000`。**\n当真实路径只有 140px 时，写死 1000 会让动画前 85% 的时间线条都藏在负偏移里根本看不见，最后 80ms 突然闪完。必须调用 `line.getTotalLength()` 写入真实长度。\n\n**③ 没留 `pad` 内边距导致波峰、波谷或末端圆点被 SVG 边缘削掉一半。**\n圆点半径 `2.6px` + 线宽一半，至少留 `4px` 内边距。\n\n**④ 同一页面多条走势线共用了相同的 `<linearGradient id=\"spark-grad\">`。**\n如果多行表格共用同一个 gradient id，某一行被筛选卸载时，其余所有行的渐变填充会瞬间消失。每条实例必须生成唯一 gradient id。\n\n---",
      "ai_assets": {
        "prompt": "实现零图表库依赖的迷你走势线生长动效（SVG Sparkline Draw）。\n\n原理一句话：纯函数将数字数组归一化为 SVG 折线与封闭面积路径，读取真实 path.getTotalLength() 写入 CSS 变量，通过 stroke-dashoffset 按「描线 → 面积淡入 → 末点落位」三拍完成生长。\n\n做法：\n1. 纯函数 sparklineGeometry(values, { width = 120, height = 36, pad = 4 })：\n   - 过滤非有限数；若为空返回空路径。\n   - 计算 min / max / span = max - min；innerW = width - pad * 2，innerH = height - pad * 2。\n   - 每个点：x = n === 1 ? width / 2 : pad + (i / (n - 1)) * innerW；y = span === 0 ? height / 2 : pad + (1 - (v - min) / span) * innerH（全平数据居中画线，绝不除零）。\n   - linePath = \"M x0 y0 L x1 y1 ...\"；areaPath = linePath + \" L xLast (height-pad) L x0 (height-pad) Z\"；trend = 末值与首值比较得 'up' | 'down' | 'same'。\n2. SVG 渲染（每条实例必须用唯一 linearGradient id）：\n   - 渐变填充从 currentColor 26% 透明到 0%；\n   - 折线：fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"；\n   - 末点：<circle cx={last.x} cy={last.y} r=\"2.6\" fill=\"currentColor\" />；\n   - 挂载后立刻测量 len = Math.ceil(line.getTotalLength()) 写入容器变量 --spark-len。\n3. 三拍 CSS 过渡（进入视口加 .is-in 触发）：\n   - 折线：stroke-dasharray: var(--spark-len); stroke-dashoffset: var(--spark-len) → 0（520ms cubic-bezier(0.22,1,0.36,1)）；\n   - 面积：opacity: 0 → 1（380ms ease-out，delay 120ms）；\n   - 末点：opacity: 0, scale(0.4) → opacity: 1, scale(1)（240ms cubic-bezier(0.34,1.56,0.64,1)，delay 380ms，注意 transform-box: fill-box; transform-origin: center）。\n\n硬要求：\n- 必须用 path.getTotalLength() 写精确路径长度，严禁写死 500 或 1000。\n- 全平数据（如 [5, 5, 5, 5]）与单点数据不得出现 NaN。\n- 每条走势线的 SVG linearGradient id 必须全局唯一，防止多行表格删行时连带销毁渐变。\n- prefers-reduced-motion: reduce 下将三拍时长压到 1ms、延迟清零，直接显示完整图形。\n\n验收：\n- 折线在 520ms 内从最左平滑描到最右，中途无停顿或末段加速；渐变面积随后浮现，末点在笔尖到达时轻弹亮起。\n- 传入 [10, 10, 10, 10] 输出水平中线且无 NaN；传入上涨/下跌数组自动切换对应趋势色。\n- 同一表格渲染 10 行走势线并删除第 1 行，其余 9 行渐变填充保持正常。",
        "dont_do": "- 别为了表格里一条 120×36 的走势线引入 ECharts / Chart.js / Recharts。\n- 别把 `stroke-dasharray` 写死成一个大数 —— 会导致曲线开头空等、结尾瞬闪。\n- 别忘了 `transform-box: fill-box` —— SVG `<circle>` 默认以整个 SVG `(0,0)` 为缩放原点，不写这行圆点会从左上角飞进来。",
        "skill_rule": "# 迷你走势线生长 (sparkline-draw) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】纯函数将数字数组归一化为 SVG 折线与封闭面积路径，读取真实 path.getTotalLength() 写入 CSS 变量，通过 stroke-dashoffset 按「描线 → 面积淡入 → 末点落位」三拍完成生长。\n\n【硬要求】\n- 必须用 path.getTotalLength() 写精确路径长度，严禁写死 500 或 1000。\n- 全平数据（如 [5, 5, 5, 5]）与单点数据不得出现 NaN。\n- 每条走势线的 SVG linearGradient id 必须全局唯一，防止多行表格删行时连带销毁渐变。\n- prefers-reduced-motion: reduce 下将三拍时长压到 1ms、延迟清零，直接显示完整图形。\n\n【验收标准】\n- 折线在 520ms 内从最左平滑描到最右，中途无停顿或末段加速；渐变面积随后浮现，末点在笔尖到达时轻弹亮起。\n- 传入 [10, 10, 10, 10] 输出水平中线且无 NaN；传入上涨/下跌数组自动切换对应趋势色。\n- 同一表格渲染 10 行走势线并删除第 1 行，其余 9 行渐变填充保持正常。\n\n【禁止做法】\n- 别为了表格里一条 120×36 的走势线引入 ECharts / Chart.js / Recharts。\n- 别把 `stroke-dasharray` 写死成一个大数 —— 会导致曲线开头空等、结尾瞬闪。\n- 别忘了 `transform-box: fill-box` —— SVG `<circle>` 默认以整个 SVG `(0,0)` 为缩放原点，不写这行圆点会从左上角飞进来。",
        "prompt_en": "Core Principle:\nZero-charting-library SVG sparkline draw-in animation (SVG Sparkline Draw). A pure function normalizes a numeric array into SVG polyline and closed area paths, reads the real `path.getTotalLength()` into a CSS variable, and animates growth across three beats (`stroke-dashoffset` line draw → area fade-in → endpoint pop).\n\nImplementation:\n1. Pure function `sparklineGeometry(values, { width = 120, height = 36, pad = 4 })`:\n   - Filter out non-finite numbers; return empty paths if empty.\n   - Compute `min` / `max` / `span = max - min`; `innerW = width - pad * 2`, `innerH = height - pad * 2`.\n   - Per point: `x = n === 1 ? width / 2 : pad + (i / (n - 1)) * innerW`; `y = span === 0 ? height / 2 : pad + (1 - (v - min) / span) * innerH` (flat data draws a centered horizontal line with zero division-by-zero).\n   - `linePath = \"M x0 y0 L x1 y1 ...\"`; `areaPath = linePath + \" L xLast (height-pad) L x0 (height-pad) Z\"`; `trend` compares last vs first value (`'up' | 'down' | 'same'`).\n2. SVG rendering (each instance must use a unique `linearGradient` `id`):\n   - Gradient fill from `currentColor` at 26% opacity to 0%;\n   - Polyline: `fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"`;\n   - Endpoint: `<circle cx={last.x} cy={last.y} r=\"2.6\" fill=\"currentColor\" />`;\n   - Immediately after mount, measure `len = Math.ceil(line.getTotalLength())` and write `--spark-len` on the container.\n3. Three-beat CSS transitions (triggered by adding `.is-in` on viewport entry):\n   - Line: `stroke-dasharray: var(--spark-len); stroke-dashoffset: var(--spark-len) → 0` (`520ms cubic-bezier(0.22,1,0.36,1)`).\n   - Area: `opacity: 0 → 1` (`380ms ease-out`, `120ms` delay).\n   - Endpoint: `opacity: 0, scale(0.4) → opacity: 1, scale(1)` (`240ms cubic-bezier(0.34,1.56,0.64,1)`, `380ms` delay, with `transform-box: fill-box; transform-origin: center`).\n\nHard Constraints:\n- Must write exact path length via `path.getTotalLength()`; never hardcode `500` or `1000`.\n- Flat data (e.g., `[5, 5, 5, 5]`) and single-point arrays must never produce `NaN`.\n- Every sparkline's SVG `linearGradient` `id` must be globally unique so deleting a row in a multi-row table never destroys gradients used by remaining rows.\n- Under `prefers-reduced-motion: reduce`, compress all three beat durations to `1ms` with `0ms` delay to display the complete chart immediately.\n\nAcceptance Criteria:\n- The line draws smoothly from far left to far right within `520ms` with no mid-path stalls or end-bursts; the gradient area fades in smoothly and the endpoint dot pops into place right as the stroke tip arrives.\n- Passing `[10, 10, 10, 10]` renders a centered horizontal line with no `NaN`; rising/falling arrays automatically switch trend colors.\n- Rendering 10 sparkline rows in a table and deleting row 1 leaves the gradient fills on all remaining 9 rows intact.",
        "dont_do_en": "- Do NOT pull in ECharts / Chart.js / Recharts just for a 120×36 table sparkline.\n- Do NOT hardcode `stroke-dasharray` to an arbitrary large number — it causes an empty pause at the start and an instant snap at the end.\n- Do NOT forget `transform-box: fill-box` — an SVG `<circle>` defaults its transform origin to the entire SVG's `(0,0)`, causing the dot to fly in from the top-left corner.",
        "skill_rule_en": "# SVG Sparkline Draw-In (sparkline-draw) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: motion | Platform: both\n\nCore Principle: Zero-charting-library SVG sparkline draw-in animation (SVG Sparkline Draw). A pure function normalizes a numeric array into SVG polyline and closed area paths, reads the real `path.getTotalLength()` into a CSS variable, and animates growth across three beats (`stroke-dashoffset` line draw → area fade-in → endpoint pop).\n\nHard Constraints:\n- Must write exact path length via `path.getTotalLength()`; never hardcode `500` or `1000`.\n- Flat data (e.g., `[5, 5, 5, 5]`) and single-point arrays must never produce `NaN`.\n- Every sparkline's SVG `linearGradient` `id` must be globally unique so deleting a row in a multi-row table never destroys gradients used by remaining rows.\n- Under `prefers-reduced-motion: reduce`, compress all three beat durations to `1ms` with `0ms` delay to display the complete chart immediately.\n\nAcceptance Criteria:\n- The line draws smoothly from far left to far right within `520ms` with no mid-path stalls or end-bursts; the gradient area fades in smoothly and the endpoint dot pops into place right as the stroke tip arrives.\n- Passing `[10, 10, 10, 10]` renders a centered horizontal line with no `NaN`; rising/falling arrays automatically switch trend colors.\n- Rendering 10 sparkline rows in a table and deleting row 1 leaves the gradient fills on all remaining 9 rows intact.\n\nDo NOT Do:\n- Do NOT pull in ECharts / Chart.js / Recharts just for a 120×36 table sparkline.\n- Do NOT hardcode `stroke-dasharray` to an arbitrary large number — it causes an empty pause at the start and an instant snap at the end.\n- Do NOT forget `transform-box: fill-box` — an SVG `<circle>` defaults its transform origin to the entire SVG's `(0,0)`, causing the dot to fly in from the top-left corner."
      }
    },
    {
      "id": "sphere",
      "name": "3D 斐波那契点阵球",
      "name_en": "3D Fibonacci Dot Sphere",
      "layer": "3d",
      "nature": "材质",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-sphere + .mk-sphere / sphere(el, { count, radius }) / spherePoint(i, count)",
      "source": "斐波那契球面等面积布点（高度等分 + 黄金角 137.5° + 纯 CSS 3D 零 WebGL）",
      "source_en": "Fibonacci golden-angle equal-area sphere lattice (pure CSS preserve-3d)",
      "file": "effects/sphere.md",
      "summary": "用 10 行斐波那契等面积数学公式把 120–150 个圆点均匀铺在真三维球面上，纯 CSS `preserve-3d` 缓慢自转，零 Three.js / WebGL 依赖。",
      "summary_en": "Distributes 120–150 CSS dots evenly across a true 3D sphere using golden-angle Fibonacci lattice math (zero polar clumping) on a smooth preserve-3d spin.",
      "problem": "**全球节点、AI 神经网络或抽象品牌视觉经常需要一颗旋转的 3D 点阵地球，但为此引入 600KB 的 Three.js 实在太重。** 而手写经纬度双层循环会把点全挤在南北两极、赤道空出一圈；用斐波那契高度等分 + 黄金角就能用纯 CSS 3D 渲染出几何完美的等面积光球。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 斐波那契格点：`y = 1 - 2i/(n-1)`（按高度等分即球面等面积）+ 黄金角 `π(3 - √5)` | Three.js / WebGL Canvas 运行时 |\n| 严格 CSS 变换顺序 `rotateY(lon) rotateX(lat) translateZ(r)`，并有单位球模长单测守护 | 按纬度角度等分导致两极堆成一团 |\n| 3D 归零降级：减弱动效下直接 `transform: none` 塌回平面 flex 排布 | 停在半路像一团歪斜乱点 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 黄金角 `golden` | `π * (3 - √5) ≈ 2.39996 rad (137.5°)` | 无理数步进确保相邻点永不排成竖直经线，视觉极其均匀 |\n| 高度等分 `y` | `1 - (i / (n - 1)) * 2` | 球带面积与高度差成正比（阿基米德帽箱定理），按 `y` 等分即全局等面积 |\n| 变换顺序 | `rotateY(lon) → rotateX(lat) → translateZ(r)` | 顺序一旦颠倒点就会偏离单位球面；该顺序有单测验证还原 xyz 后模长恒为 1 |\n| 点数 `count` | `80–150` | 低于 50 看不出球体感，高于 220 在低端移动浏览器里 CSS 3D 合成层压力陡增 |",
      "implementation": "```\nsrc/core/scene3d.js:180  spherePoint(i, count)            纯函数，已覆盖 6 项几何单测\nsrc/core/scene3d.js:190  sphere(el, { count, radius })    生成圆点并写入经纬度变量\nstyles/3d.css            .mk-sphere-stage / .mk-sphere / .mk-sphere__dot\n```",
      "degradation": "**走 `3d` 层专属契约：归零塌回平面。**\n\n`prefers-reduced-motion: reduce` 下停止旋转并将所有圆点 `transform: none` 塌回平面排列，不留半空散点。",
      "pitfalls": "**① 写错 CSS `rotateY` / `rotateX` / `translateZ` 的顺序。**\n必须是 `rotateY(lon) rotateX(lat) translateZ(radius)`；如果把 `translateZ` 放最前面，所有点会先推出去再原地自转，球体直接崩掉。\n\n**② `count === 1` 时 `i / (count - 1)` 除零算出 `NaN`。**\n必须用 `Math.max(count - 1, 1)` 做分母兜底。\n\n**③ 忘了在容器上设 `transform-style: preserve-3d` 与外层 `perspective`。**\n漏掉 `preserve-3d` 会把所有点压扁成一个 2D 圆盘。\n\n---",
      "ai_assets": {
        "prompt": "实现零 WebGL / Three.js 依赖的纯 CSS 3D 斐波那契点阵球体（Fibonacci Dot Sphere）。\n\n原理一句话：纯函数按阿基米德高度等分 y = 1 - 2i/(n-1) 与黄金角 π(3-√5) 算出每个点的经纬度，用严格顺序 rotateY(lon) rotateX(lat) translateZ(r) 铺在 preserve-3d 容器上匀速自转。\n\n做法：\n1. 纯函数 spherePoint(i, count)：\n   - golden = Math.PI * (3 - Math.sqrt(5))；n = Math.max(count - 1, 1)。\n   - y = 1 - (i / n) * 2；r = Math.sqrt(Math.max(0, 1 - y * y))；theta = i * golden。\n   - x = Math.cos(theta) * r；z = Math.sin(theta) * r。\n   - 返回纬度 lat = Math.asin(y) * 180 / Math.PI（度），经度 lon = Math.atan2(x, z) * 180 / Math.PI（度）。\n2. DOM 与 CSS 3D：\n   - 外层舞台 .sphere-stage：perspective: 680px; display: grid; place-items: center;\n   - 球体容器 .sphere：position: relative; width: 0; height: 0; transform-style: preserve-3d; animation: sphere-spin 18s linear infinite;\n   - 生成 count（建议 80–140）个点 .sphere-dot：position: absolute; width: 4px; height: 4px; border-radius: 50%; margin: -2px;\n     transform: rotateY(var(--lon)) rotateX(var(--lat)) translateZ(var(--r));\n   - @keyframes sphere-spin { from { transform: rotateX(-14deg) rotateY(0deg); } to { transform: rotateX(-14deg) rotateY(360deg); } }\n\n硬要求：\n- 必须用高度等分 + 黄金角，严禁双层经纬度循环（两极会堆成一团）。\n- CSS 变换顺序必须是 rotateY(lon) rotateX(lat) translateZ(r)，不可调换。\n- count === 1 时不得出现 NaN。\n- prefers-reduced-motion: reduce 下停止旋转并归零塌回平面。\n\n验收：\n- 球面各区域（南北极与赤道）圆点视觉密度完全均匀，无明显经线扎堆。\n- 还原任意点的 (lat, lon) 到三维笛卡尔坐标后模长均为 1（误差 < 1e-6）。\n- 全程零 Canvas / WebGL 上下文创建；开启减弱动效后彻底静止归零。",
        "dont_do": "- 别引入 Three.js / WebGL 来画一颗 100 个点的装饰球。\n- 别按 `lat` 角度均匀循环 —— 会导致南北极挤成两团白点、赤道空荡荡。\n- 别在一颗球里塞 500 个以上 DOM 节点 —— 保持 80–150 个即可兼顾美观与 60fps。",
        "skill_rule": "# 3D 斐波那契点阵球 (sphere) · 跨平台动效规范\n性质：材质 ｜ 平台：both\n\n【核心原理】纯函数按阿基米德高度等分 y = 1 - 2i/(n-1) 与黄金角 π(3-√5) 算出每个点的经纬度，用严格顺序 rotateY(lon) rotateX(lat) translateZ(r) 铺在 preserve-3d 容器上匀速自转。\n\n【硬要求】\n- 必须用高度等分 + 黄金角，严禁双层经纬度循环（两极会堆成一团）。\n- CSS 变换顺序必须是 rotateY(lon) rotateX(lat) translateZ(r)，不可调换。\n- count === 1 时不得出现 NaN。\n- prefers-reduced-motion: reduce 下停止旋转并归零塌回平面。\n\n【验收标准】\n- 球面各区域（南北极与赤道）圆点视觉密度完全均匀，无明显经线扎堆。\n- 还原任意点的 (lat, lon) 到三维笛卡尔坐标后模长均为 1（误差 < 1e-6）。\n- 全程零 Canvas / WebGL 上下文创建；开启减弱动效后彻底静止归零。\n\n【禁止做法】\n- 别引入 Three.js / WebGL 来画一颗 100 个点的装饰球。\n- 别按 `lat` 角度均匀循环 —— 会导致南北极挤成两团白点、赤道空荡荡。\n- 别在一颗球里塞 500 个以上 DOM 节点 —— 保持 80–150 个即可兼顾美观与 60fps。",
        "prompt_en": "Core Principle:\nZero-WebGL / zero-Three.js pure CSS 3D Fibonacci Dot Sphere. A pure function computes spherical coordinates via Archimedes equal-height slicing `y = 1 - 2i/(n-1)` and the golden angle `π(3 - √5)`, placing dots in a `preserve-3d` container using the strict transform order `rotateY(lon) rotateX(lat) translateZ(r)` under uniform rotation.\n\nImplementation:\n1. Pure function `spherePoint(i, count)`:\n   - `golden = Math.PI * (3 - Math.sqrt(5))`; `n = Math.max(count - 1, 1)`.\n   - `y = 1 - (i / n) * 2`; `r = Math.sqrt(Math.max(0, 1 - y * y))`; `theta = i * golden`.\n   - `x = Math.cos(theta) * r`; `z = Math.sin(theta) * r`.\n   - Return `lat = Math.asin(y) * 180 / Math.PI` (degrees) and `lon = Math.atan2(x, z) * 180 / Math.PI` (degrees).\n2. DOM & CSS 3D:\n   - Outer stage `.sphere-stage`: `perspective: 680px; display: grid; place-items: center;`.\n   - Sphere container `.sphere`: `position: relative; width: 0; height: 0; transform-style: preserve-3d; animation: sphere-spin 18s linear infinite;`.\n   - Generate `count` (`80–140` recommended) `.sphere-dot` elements: `position: absolute; width: 4px; height: 4px; border-radius: 50%; margin: -2px; transform: rotateY(var(--lon)) rotateX(var(--lat)) translateZ(var(--r));`.\n   - `@keyframes sphere-spin { from { transform: rotateX(-14deg) rotateY(0deg); } to { transform: rotateX(-14deg) rotateY(360deg); } }`.\n\nHard Constraints:\n- Must use equal-height slicing + golden angle; double lat/lon loops are strictly forbidden (they cluster heavily at the poles).\n- CSS transform order must strictly be `rotateY(lon) rotateX(lat) translateZ(r)` and must not be reordered.\n- `count === 1` must never produce `NaN`.\n- Under `prefers-reduced-motion: reduce`, stop rotation and collapse flat to resting origin.\n\nAcceptance Criteria:\n- Visual dot density is completely uniform across poles and equator with no meridian bunching.\n- Converting any point's `(lat, lon)` back to 3D Cartesian coordinates yields unit length `1` (error `< 1e-6`).\n- Zero Canvas/WebGL contexts created; completely static and reset under reduced motion.",
        "dont_do_en": "- Do NOT pull in Three.js or WebGL just to draw a 100-dot decorative sphere.\n- Do NOT loop uniformly over `lat` angles — dots will pile into dense white clumps at both poles while leaving the equator sparse.\n- Do NOT stuff more than 500 DOM nodes into one sphere — 80–150 dots keeps both aesthetics and 60fps.",
        "skill_rule_en": "# 3D Fibonacci Dot Sphere (sphere) · Cross-Platform Motion Spec\nNature: Material | Layer: 3d | Platform: both\n\nCore Principle: Zero-WebGL / zero-Three.js pure CSS 3D Fibonacci Dot Sphere. A pure function computes spherical coordinates via Archimedes equal-height slicing `y = 1 - 2i/(n-1)` and the golden angle `π(3 - √5)`, placing dots in a `preserve-3d` container using the strict transform order `rotateY(lon) rotateX(lat) translateZ(r)` under uniform rotation.\n\nHard Constraints:\n- Must use equal-height slicing + golden angle; double lat/lon loops are strictly forbidden (they cluster heavily at the poles).\n- CSS transform order must strictly be `rotateY(lon) rotateX(lat) translateZ(r)` and must not be reordered.\n- `count === 1` must never produce `NaN`.\n- Under `prefers-reduced-motion: reduce`, stop rotation and collapse flat to resting origin.\n\nAcceptance Criteria:\n- Visual dot density is completely uniform across poles and equator with no meridian bunching.\n- Converting any point's `(lat, lon)` back to 3D Cartesian coordinates yields unit length `1` (error `< 1e-6`).\n- Zero Canvas/WebGL contexts created; completely static and reset under reduced motion.\n\nDo NOT Do:\n- Do NOT pull in Three.js or WebGL just to draw a 100-dot decorative sphere.\n- Do NOT loop uniformly over `lat` angles — dots will pile into dense white clumps at both poles while leaving the equator sparse.\n- Do NOT stuff more than 500 DOM nodes into one sphere — 80–150 dots keeps both aesthetics and 60fps."
      }
    },
    {
      "id": "split",
      "name": "逐词逐字入场",
      "name_en": "Split Word / Char Reveal",
      "layer": "motion",
      "nature": "节奏",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-split（word / char / line）/ split(el, { by })",
      "source": "GSAP SplitText 的标题级联入场，内置 CJK/拉丁混排分词器且零运行时依赖",
      "source_en": "Editorial SplitText reveal (CJK-aware tokenizer + CSS stagger)",
      "file": "effects/split.md",
      "summary": "初始化时一次性把标题拆成词/字片段并写入递增索引，入场时纯靠 CSS `transition-delay` 按节奏逐个浮现，滚动与缩放零计算。",
      "summary_en": "Splits headings into words or CJK characters once on mount and cascades their entrance purely via CSS transition-delay — zero per-frame JS work.",
      "problem": "**整块大标题一起淡入显得笨重，而纯按空格拆词在中文界面会直接失效。** 英文句天然有空格，中文没有——如果按 `\\s+` 拆，整句中文会变成一个巨大片段，完全失去节奏感；反之如果把英文也按字母拆，单词会被撕碎影响阅读。需要一个懂中英混排和全角标点的轻量分词器。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| GSAP SplitText 的逐词/逐字入场节奏与 `overflow: hidden` 裁切升起手感 | 运行时 DOM 测量自动换行（强制同步布局 + 窗口 resize 需重建） |\n| 中英混排语义分词：CJK 按字、拉丁/数字按词、全角标点并入前一片段 | 逐帧 JS timeline 控制每个 span 的 transform |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 级联步长 | `28ms` / 片段 | 比列表项的 70ms 密得多：标题通常 8–18 个片段，28ms 让整句在 300–500ms 内完成扫过，既有波浪感又不拖慢阅读 |\n| 中文标点归并 | 并入前一片段 | `，`、`。`、`：` 单独作为一拍冒出来非常碎且怪异，跟前一个字一起出现才符合阅读直觉 |\n| 空白处理 | 保留为纯文本节点 | 不包裹空白 span，既不占用递增索引 `--i`（避免英文词间多出一拍空等），又不让英文词黏在一起 |\n| `line` 模式 | 仅按 `\\n` 切分 | 不做 DOM 几何测量来算软换行——测量会触发强制同步布局，且字号/宽度一变就错位 |",
      "implementation": "```\nsrc/core/text-reveal.js:26  CJK / PUNCT_RE / TOKEN_RE  中英混排与标点归并正则\nsrc/core/text-reveal.js:31  splitTokens(text, by)      纯函数，已覆盖 5 项单测\nsrc/core/text-reveal.js:53  split(el, { by, cls })     一次性拆节点、写 --mk-i、返回 { reveal, restore }\nstyles/motion.css           .mk-split / .mk-split__unit（transition-delay 消费 --mk-i）\n```\n\n注意：`line` 模式下每行内只有一个子元素，CSS `sibling-index()` 恒为 1，因此 JS 仍显式写入全局递增索引，不能完全删掉 JS 索引逻辑（见 `sources.md` §4.1）。",
      "degradation": "**走 `motion` 档：减，不关。**\n\n`prefers-reduced-motion: reduce` 下片段位移归零、时长压到 1ms、级联延迟清零，整句标题瞬间显现——文字是核心信息，绝不能因减弱动效而不可见。",
      "pitfalls": "**① 直接用 `text.split(' ')` 处理中文或中英混排。**\n中文句子里没有空格，会整句作为一个片段同时弹出来；必须区分 CJK 码点区间与拉丁词。\n\n**② `char` 模式用 `text.split('')` 拆分。**\n遇到 emoji 或代理对（surrogate pair）会把一个字符劈成两个乱码；必须用 `Array.from(text)` 按码点切分。\n\n**③ 丢掉空白字符或把空白字符也计入索引。**\n丢掉空白会让英文单词黏成一团；把空白计入延迟索引会让每个英文词之间凭空多出 28ms 停顿。\n\n**④ 屏幕阅读器逐个 span 断续朗读，或销毁时无法还原原文。**\n外层应保留 `aria-label`（原文）并给拆分后的视觉 span 标 `aria-hidden=\"true\"`；`restore()` 需能一键还原 `el.textContent = original`。\n\n---",
      "ai_assets": {
        "prompt": "实现一个支持中英混排的文字逐词/逐字入场动效（零依赖，替代 SplitText）。\n\n原理一句话：初始化时用中英混排分词器一次性把文本拆成带索引 --i 的 <span>，纯靠 CSS transition-delay: calc(var(--i) * 28ms) 级联升起，不碰运行时动画循环。\n\n做法：\n1. 纯函数分词器 splitTokens(text, by = 'word')：\n   - by === 'char'：使用 Array.from(text) 按 Unicode 码点切分（禁止用 split('')，会劈开 emoji）。\n   - by === 'word'：用正则将 CJK 字符（[\\u3400-\\u4dbf\\u4e00-\\u9fff\\u3040-\\u30ff\\uac00-\\ud7af\\uf900-\\ufaff]）逐字切出、连续非空白非 CJK 作为一个英文/数字词、空白单独保留。\n   - 标点归并：全角/中文标点（[\\u3000-\\u303f\\ufe10-\\ufe1f\\uff01-\\uff0f\\uff1a-\\uff20\\uff3b-\\uff40\\uff5b-\\uff65]+）不单独成片，直接拼接到前一个非空白片段末尾。\n2. DOM 拆分（挂载时只执行一次）：\n   - 空白片段保留为普通 TextNode，不递增索引。\n   - 非空白片段包裹为 <span class=\"split-unit\" style=\"--i: <index>\" aria-hidden=\"true\">。\n   - 给原容器设置 aria-label=\"<原始文本>\" 保证无障碍朗读连贯，并提供 restore() 还原原始文本。\n3. CSS 动画：\n   - 初始态：display: inline-block; opacity: 0; transform: translate3d(0, 14px, 0);\n   - 过渡：transition: opacity 380ms cubic-bezier(0.22,1,0.36,1), transform 380ms cubic-bezier(0.22,1,0.36,1); transition-delay: calc(var(--i, 0) * 28ms);\n   - 触发态（.is-in，由 IntersectionObserver 加一次即 unobserve）：opacity: 1; transform: none;\n\n硬要求：\n- 仅在初始化拆一次 DOM，滚动与 resize 期间零计算、零重建。\n- line 模式仅按显式换行符 \\n 切分，严禁读取 offsetTop/getBoundingClientRect 测量软换行。\n- prefers-reduced-motion: reduce 下将位移归零、时长与延迟清零，确保标题立即可读。\n\n验收：\n- 输入「Hello 世界，2026！」在 word 模式下输出 [\"Hello\", \" \", \"世\", \"界，\", \"2026！\"]（5 片，其中 4 个有效索引，空格不占索引）。\n- 中文逐字依次升起、英文整词升起、逗号紧随「界」一起升起。\n- 屏幕阅读器朗读完整句子而非逐字停顿。\n- 减弱动效模式下文字无位移、立即可见。",
        "dont_do": "- 别用 `split(' ')` 当分词器 —— 中文会彻底失效。\n- 别用 `split('')` 拆字 —— emoji 和生僻字会裂成乱码。\n- 别在 `scroll` 或 `resize` 事件里重新拆 DOM —— 会引起剧烈重排与闪烁。",
        "skill_rule": "# 逐词逐字入场 (split) · 跨平台动效规范\n性质：节奏 ｜ 平台：both\n\n【核心原理】初始化时用中英混排分词器一次性把文本拆成带索引 --i 的 <span>，纯靠 CSS transition-delay: calc(var(--i) * 28ms) 级联升起，不碰运行时动画循环。\n\n【硬要求】\n- 仅在初始化拆一次 DOM，滚动与 resize 期间零计算、零重建。\n- line 模式仅按显式换行符 \\n 切分，严禁读取 offsetTop/getBoundingClientRect 测量软换行。\n- prefers-reduced-motion: reduce 下将位移归零、时长与延迟清零，确保标题立即可读。\n\n【验收标准】\n- 输入「Hello 世界，2026！」在 word 模式下输出 [\"Hello\", \" \", \"世\", \"界，\", \"2026！\"]（5 片，其中 4 个有效索引，空格不占索引）。\n- 中文逐字依次升起、英文整词升起、逗号紧随「界」一起升起。\n- 屏幕阅读器朗读完整句子而非逐字停顿。\n- 减弱动效模式下文字无位移、立即可见。\n\n【禁止做法】\n- 别用 `split(' ')` 当分词器 —— 中文会彻底失效。\n- 别用 `split('')` 拆字 —— emoji 和生僻字会裂成乱码。\n- 别在 `scroll` 或 `resize` 事件里重新拆 DOM —— 会引起剧烈重排与闪烁。",
        "prompt_en": "Core Principle:\nZero-dependency mixed-script (CJK + Latin) word/character split text reveal (a lightweight SplitText replacement). At initialization, a mixed-script tokenizer splits text once into `<span>` elements carrying index `--i`, cascading upward via pure CSS `transition-delay: calc(var(--i) * 28ms)` with no runtime animation loop.\n\nImplementation:\n1. Pure tokenizer `splitTokens(text, by = 'word')`:\n   - When `by === 'char'`, split by Unicode code points using `Array.from(text)` (never `split('')`, which breaks emoji).\n   - When `by === 'word'`, use regex to emit each CJK character (`[\\u3400-\\u4dbf\\u4e00-\\u9fff\\u3040-\\u30ff\\uac00-\\ud7af\\uf900-\\ufaff]`) individually, keep contiguous non-whitespace non-CJK runs as whole words/numbers, and preserve whitespace runs separately.\n   - Punctuation attachment: full-width/CJK punctuation (`[\\u3000-\\u303f\\ufe10-\\ufe1f\\uff01-\\uff0f\\uff1a-\\uff20\\uff3b-\\uff40\\uff5b-\\uff65]+`) must not form standalone tokens; append it directly to the end of the preceding non-whitespace token.\n2. One-time DOM split on mount:\n   - Keep whitespace tokens as plain `TextNode`s without incrementing `--i`.\n   - Wrap non-whitespace tokens in `<span class=\"split-unit\" style=\"--i: <index>\" aria-hidden=\"true\">`.\n   - Set `aria-label=\"<original text>\"` on the container for coherent screen-reader narration, and provide `restore()` to revert to plain text.\n3. CSS animation:\n   - Initial state: `display: inline-block; opacity: 0; transform: translate3d(0, 14px, 0);`.\n   - Transition: `transition: opacity 380ms cubic-bezier(0.22,1,0.36,1), transform 380ms cubic-bezier(0.22,1,0.36,1); transition-delay: calc(var(--i, 0) * 28ms);`.\n   - Triggered state (`.is-in`, added once by `IntersectionObserver` then `unobserve`): `opacity: 1; transform: none;`.\n\nHard Constraints:\n- Split the DOM only once at initialization; zero measurement or DOM rebuilding during scroll or resize.\n- Line mode splits only on explicit `\\n` newlines; never read `offsetTop` or `getBoundingClientRect` to measure soft line wraps.\n- Under `prefers-reduced-motion: reduce`, zero out displacement, duration, and delay so headings are immediately readable.\n\nAcceptance Criteria:\n- Input `\"Hello <CJK1><CJK2>，2026！\"` (two CJK ideographs with full-width comma and exclamation mark) in `word` mode outputs `[\"Hello\", \" \", \"<CJK1>\", \"<CJK2>，\", \"2026！\"]` (5 tokens, 4 indexed spans; the space gets no index).\n- CJK characters rise one by one, English words rise as whole words, and the trailing full-width comma rises attached to `<CJK2>`.\n- Screen readers read the full sentence continuously rather than pausing per token.\n- Under reduced motion, text is immediately visible with zero displacement.",
        "dont_do_en": "- Do NOT use `split(' ')` as a tokenizer — CJK text without spaces will fail completely.\n- Do NOT use `split('')` to split characters — emoji and surrogate-pair glyphs will shatter into mojibake.\n- Do NOT re-split the DOM inside `scroll` or `resize` handlers — it triggers severe layout thrashing and flicker.",
        "skill_rule_en": "# Split Word / Char Reveal (split) · Cross-Platform Motion Spec\nNature: Rhythm | Layer: motion | Platform: both\n\nCore Principle: Zero-dependency mixed-script (CJK + Latin) word/character split text reveal (a lightweight SplitText replacement). At initialization, a mixed-script tokenizer splits text once into `<span>` elements carrying index `--i`, cascading upward via pure CSS `transition-delay: calc(var(--i) * 28ms)` with no runtime animation loop.\n\nHard Constraints:\n- Split the DOM only once at initialization; zero measurement or DOM rebuilding during scroll or resize.\n- Line mode splits only on explicit `\\n` newlines; never read `offsetTop` or `getBoundingClientRect` to measure soft line wraps.\n- Under `prefers-reduced-motion: reduce`, zero out displacement, duration, and delay so headings are immediately readable.\n\nAcceptance Criteria:\n- Input `\"Hello <CJK1><CJK2>，2026！\"` (two CJK ideographs with full-width comma and exclamation mark) in `word` mode outputs `[\"Hello\", \" \", \"<CJK1>\", \"<CJK2>，\", \"2026！\"]` (5 tokens, 4 indexed spans; the space gets no index).\n- CJK characters rise one by one, English words rise as whole words, and the trailing full-width comma rises attached to `<CJK2>`.\n- Screen readers read the full sentence continuously rather than pausing per token.\n- Under reduced motion, text is immediately visible with zero displacement.\n\nDo NOT Do:\n- Do NOT use `split(' ')` as a tokenizer — CJK text without spaces will fail completely.\n- Do NOT use `split('')` to split characters — emoji and surrogate-pair glyphs will shatter into mojibake.\n- Do NOT re-split the DOM inside `scroll` or `resize` handlers — it triggers severe layout thrashing and flicker."
      }
    },
    {
      "id": "spotlight",
      "name": "指针光斑与描边聚光",
      "name_en": "Pointer Spotlight & Border Glow",
      "layer": "motion",
      "nature": "材质",
      "platform": "web",
      "status": "shipped",
      "entry": "v-mk-spotlight + .mk-spotlight（--border 变体）/ spotlight(el, { intensity })",
      "source": "Magic UI / Linear 卡片指针柔光斑（纯 2D 零形变，可与任意 transform 叠加）",
      "source_en": "Linear / Stripe spotlight cards (transform-free radial glow + border light)",
      "file": "effects/spotlight.md",
      "summary": "桌面指针移过暗色卡片时，一团柔和径向光斑（或仅照亮 1px 描边）用 lerp 丝滑跟随指针；完全不碰 `transform`，可与任意位移/缩放效果无冲突叠加。",
      "summary_en": "Smooth lerp-tracked radial spotlight and 1px border illumination on dark cards without touching transform, composing conflict-free with tilt or scale.",
      "problem": "**暗色栅格里的多张卡片容易显得平淡死板，但并不是每张卡片都适合 3D 倾斜。** 纯 2D 的指针光斑在完全不晃动文字的前提下，给用户清晰的“光标正落在这块区域”的材质反馈，特别适合特性网格、定价卡和代码工具栏。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| Linear / Magic UI 暗色卡片的「径向柔光 + 1px 描边聚光」 | 需要整页 WebGL / Canvas 渲染的光照系统 |\n| 位置（0.18）与透明度（0.16）双 lerp 收敛、归零即停帧 | CSS `background-position` 硬跟鼠标导致边缘跳闪 |\n| 与 `transform` 彻底解耦，零几何形变 | 触屏端点一下亮一块的残留光斑 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 位置插值 | `0.18` / 帧 | 比硬跟手稍带一点“光在磨砂面上滑行”的阻尼质感，又不会落后鼠标太远 |\n| 透明度插值 | `0.16` / 帧 | 移入移出柔和渐显渐隐，不需要额外写 CSS transition 与 JS 抢状态 |\n| 默认强度 `intensity` | `0.85` | 配合径向渐变内部低不透明度白/强调色，刚好点亮质感而不盖掉文字对比度 |\n| 停帧阈值 | `o <= 0.002` 且 `!hovering` | 光斑完全淡出后立刻停掉 rAF，静止页面零开销 |",
      "implementation": "```\nsrc/core/spotlight.js:12  spotlight(el, { intensity, reduced })  写 --mk-spot-x/y/o\nstyles/motion.css         .mk-spotlight / .mk-spotlight--border\n```",
      "degradation": "**走 `motion` 档：减，不关（本效果在减少动效与触屏下静默退回无光斑）。**\n\n`prefers-reduced-motion: reduce` 或粗指针设备（`pointer: coarse`）下直接将 `--mk-spot-o` 置 `0` 且不注册任何事件与 rAF，卡片保持干净静态暗色表面。",
      "pitfalls": "**① 光斑伪元素忘了设 `pointer-events: none` 或 `z-index` 盖住文字。**\n光斑层必须设 `pointer-events: none`，且通过低不透明度径向渐变叠加，绝不能挡住卡片里的按钮或把文字洗白。\n\n**② 忘了做停帧判断导致页面上 12 张卡片挂着 12 条常驻 rAF。**\n只有 `hovering || o > 0.002` 时才继续预约下一帧；淡出到 `<= 0.002` 时强制写 `0` 并清零 `raf`。\n\n**③ 卡片尺寸变化或隐藏时没防 `rect.width === 0` 除零。**\n`onMove` 中必须先判 `if (!r.width || !r.height) return`。\n\n---",
      "ai_assets": {
        "prompt": "实现 Linear / Magic UI 风格的指针柔光斑卡片（支持整面柔光与 1px 描边聚光变体，零动画库依赖）。\n\n原理一句话：不碰 transform，仅用 rAF 双 lerp（位置 0.18、透明度 0.16）写入 --spot-x / --spot-y / --spot-o 驱动 ::before 径向渐变，淡出归零即停帧。\n\n做法：\n1. 能力门禁：若 prefers-reduced-motion: reduce 或 matchMedia('(hover: none), (pointer: coarse)') 命中，写 --spot-o: 0 后直接返回，不挂监听。\n2. 指针与双 lerp 循环：\n   - pointermove：读取 getBoundingClientRect()（宽高为 0 直接返回），计算百分比目标 tx / ty，置 to = 0.85, hovering = true，唤醒 rAF。\n   - pointerleave / pointercancel：hovering = false, to = 0，唤醒 rAF。\n   - loop：cx += (tx - cx) * 0.18; cy += (ty - cy) * 0.18; o += (to - o) * 0.16; 写入 --spot-x/y/o；仅当 hovering || o > 0.002 时继续下一帧，否则写 --spot-o: 0 并停帧。\n3. CSS 渲染：\n   - 卡片 position: relative; overflow: hidden;\n   - ::before：content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;\n     opacity: var(--spot-o, 0);\n     background: radial-gradient(320px circle at var(--spot-x, 50%) var(--spot-y, 50%), rgba(184,255,61,0.16), transparent 70%);\n   - 描边聚光变体（仅亮 1px 边框）：padding: 1px + 双 mask（content-box, border-box）+ -webkit-mask-composite: xor; mask-composite: exclude;\n\n硬要求：\n- 严禁修改 transform —— 保证能与按压、入场、3D 倾斜自由叠加。\n- 光斑淡出归零后必须彻底停止 rAF，不能常驻空转。\n- 伪元素必须带 pointer-events: none。\n- 触屏与减弱动效下直接关闭光斑。\n\n验收：\n- 鼠标滑过卡片，柔光斑平滑追随；移开后柔和淡出并停止 rAF。\n- 描边变体在 Chrome 与 Safari 下均只照亮 1px 外圈，中间不发白。\n- 卡片内部链接与按钮点击畅通，无遮挡。",
        "dont_do": "- 别在 `pointermove` 里直接改 `background` 字符串 —— 触发样式重解析且无插值阻尼，只写 3 个 CSS 变量。\n- 别在触屏设备上开启 —— 会留下点按后的静态亮斑。\n- 别忘了 Safari 的 `-webkit-mask-composite: xor`（描边变体漏写会整块糊白）。",
        "skill_rule": "# 指针光斑与描边聚光 (spotlight) · 跨平台动效规范\n性质：材质 ｜ 平台：web\n\n【核心原理】不碰 transform，仅用 rAF 双 lerp（位置 0.18、透明度 0.16）写入 --spot-x / --spot-y / --spot-o 驱动 ::before 径向渐变，淡出归零即停帧。\n\n【硬要求】\n- 严禁修改 transform —— 保证能与按压、入场、3D 倾斜自由叠加。\n- 光斑淡出归零后必须彻底停止 rAF，不能常驻空转。\n- 伪元素必须带 pointer-events: none。\n- 触屏与减弱动效下直接关闭光斑。\n\n【验收标准】\n- 鼠标滑过卡片，柔光斑平滑追随；移开后柔和淡出并停止 rAF。\n- 描边变体在 Chrome 与 Safari 下均只照亮 1px 外圈，中间不发白。\n- 卡片内部链接与按钮点击畅通，无遮挡。\n\n【禁止做法】\n- 别在 `pointermove` 里直接改 `background` 字符串 —— 触发样式重解析且无插值阻尼，只写 3 个 CSS 变量。\n- 别在触屏设备上开启 —— 会留下点按后的静态亮斑。\n- 别忘了 Safari 的 `-webkit-mask-composite: xor`（描边变体漏写会整块糊白）。",
        "prompt_en": "Core Principle:\nZero-animation-library pointer-tracking spotlight card in Linear / Magic UI style (supporting both full-surface glow and 1px border-glow variants). Without touching `transform`, drive a `::before` radial gradient by writing `--spot-x`, `--spot-y`, and `--spot-o` via dual `rAF` lerps (position `0.18`, opacity `0.16`), stopping the loop as soon as opacity fades back to zero.\n\nImplementation:\n1. Capability gate: if `prefers-reduced-motion: reduce` or `matchMedia('(hover: none), (pointer: coarse)')` matches, set `--spot-o: 0` and return immediately without attaching listeners.\n2. Pointer tracking & dual lerp loop:\n   - `pointermove`: read `getBoundingClientRect()` (return early if width or height is `0`), compute percentage targets `tx` / `ty`, set `to = 0.85`, `hovering = true`, and wake `rAF`.\n   - `pointerleave` / `pointercancel`: set `hovering = false`, `to = 0`, and wake `rAF`.\n   - Loop: `cx += (tx - cx) * 0.18`; `cy += (ty - cy) * 0.18`; `o += (to - o) * 0.16`; write `--spot-x/y/o`; continue requesting frames only while `hovering || o > 0.002`, otherwise write `--spot-o: 0` and stop.\n3. CSS rendering:\n   - Card: `position: relative; overflow: hidden;`.\n   - `::before`: `content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: var(--spot-o, 0); background: radial-gradient(320px circle at var(--spot-x, 50%) var(--spot-y, 50%), rgba(184,255,61,0.16), transparent 70%);`.\n   - Border-glow variant (illuminates only the 1px rim): `padding: 1px` + dual masks (`content-box, border-box`) + `-webkit-mask-composite: xor; mask-composite: exclude;`.\n\nHard Constraints:\n- Never modify `transform`—guaranteeing clean composition with press, entrance, and 3D tilt effects.\n- Must stop `rAF` completely once the glow fades to zero; never leave `rAF` spinning idle.\n- Pseudo-element must set `pointer-events: none`.\n- Automatically disable the spotlight on touch devices and under reduced motion.\n\nAcceptance Criteria:\n- Moving the cursor across the card yields a smoothly trailing soft glow that fades out gracefully on exit and halts `rAF`.\n- The border-glow variant illuminates only the 1px outer ring in both Chrome and Safari without washing out the card interior.\n- Links and buttons inside the card remain fully clickable with zero interception.",
        "dont_do_en": "- Do NOT mutate the `background` string directly inside `pointermove` — it triggers style re-parsing with zero damping; only write the 3 CSS custom properties.\n- Do NOT enable this on touch devices — it leaves a stale bright spot stuck at the last tap point.\n- Do NOT forget Safari's `-webkit-mask-composite: xor` (omitting it on the border-glow variant turns the entire card white).",
        "skill_rule_en": "# Pointer Spotlight & Border Glow (spotlight) · Cross-Platform Motion Spec\nNature: Material | Layer: motion | Platform: web\n\nCore Principle: Zero-animation-library pointer-tracking spotlight card in Linear / Magic UI style (supporting both full-surface glow and 1px border-glow variants). Without touching `transform`, drive a `::before` radial gradient by writing `--spot-x`, `--spot-y`, and `--spot-o` via dual `rAF` lerps (position `0.18`, opacity `0.16`), stopping the loop as soon as opacity fades back to zero.\n\nHard Constraints:\n- Never modify `transform`—guaranteeing clean composition with press, entrance, and 3D tilt effects.\n- Must stop `rAF` completely once the glow fades to zero; never leave `rAF` spinning idle.\n- Pseudo-element must set `pointer-events: none`.\n- Automatically disable the spotlight on touch devices and under reduced motion.\n\nAcceptance Criteria:\n- Moving the cursor across the card yields a smoothly trailing soft glow that fades out gracefully on exit and halts `rAF`.\n- The border-glow variant illuminates only the 1px outer ring in both Chrome and Safari without washing out the card interior.\n- Links and buttons inside the card remain fully clickable with zero interception.\n\nDo NOT Do:\n- Do NOT mutate the `background` string directly inside `pointermove` — it triggers style re-parsing with zero damping; only write the 3 CSS custom properties.\n- Do NOT enable this on touch devices — it leaves a stale bright spot stuck at the last tap point.\n- Do NOT forget Safari's `-webkit-mask-composite: xor` (omitting it on the border-glow variant turns the entire card white)."
      }
    },
    {
      "id": "state-button",
      "name": "态变按钮",
      "name_en": "Zero-Jitter Multi-State Button",
      "layer": "motion",
      "nature": "反馈",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-state-btn + .mk-state-btn / nextButtonState() / loadingRemaining()",
      "source": "Family App / Linear / Emil Kowalski 的四态提交按钮（零宽跳 + 400ms 防闪 + 防连点）",
      "source_en": "Family App / Linear submit button (grid-area 1/1 + 400ms min loading)",
      "file": "effects/state-button.md",
      "summary": "把提交按钮的 `idle → loading → success / error → idle` 压进同一个不跳宽的网格格子里，旧文案上移微糊退场、新文案下移弹入，且自带 400ms 最低加载时长与防连点锁。",
      "summary_en": "Stacks idle / loading / success / error labels in a single grid cell so width never jumps, with 400ms anti-flash minimum loading duration and double-submit lock.",
      "problem": "**异步提交按钮最常见的三个廉价感：宽度乱跳、转圈一闪而过、重复点击发两次请求。** 文案从「保存」变成「保存中…」再变成「已保存」时，按钮宽一变就把旁边整排元素推歪；接口 60ms 返回时转圈闪一帧像页面抽风；禁用按钮用原生 `disabled` 又会把键盘焦点踢飞。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| Family / Linear 的纵向错位换字（`±0.7em` + `blur(2px)`）与 `≤240ms` 干脆节奏 | JS 测量文字宽度并用 Framer Motion `layout` 动画 `width`（容易推挤邻近按钮） |\n| CSS Grid `grid-area: 1 / 1` 四态叠放，天然撑出最宽态的固定宽度 | 给按钮写死 `min-width: 120px`（换文案或多语言立刻撑爆或留白失衡） |\n| `aria-disabled=\"true\"` 拦点击而不丢焦点 | 原生 `disabled` 属性踢掉焦点 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 最低加载时长 `minLoading` | `400ms` | 低于 300ms 的 spinner 读起来像闪屏/报错；400ms 刚好让眼睛确认“系统在干活”又不拖慢操作 |\n| 成功态停留 `hold.success` | `1600ms` | 够读一眼确认打勾并自动复位，不长到妨碍下一轮操作 |\n| 失败态停留 `hold.error` | `2400ms` | 失败比成功需要多 0.8s 读清原因；且失败态下随时点一下可直接重试 |\n| 退场 / 入场时长 | `160ms` / `240ms` | 退场比入场快一档，避免新旧两行字在中间叠成一团 |\n| 错位距离 + 模糊 | `±0.7em` + `blur(2px)` | 相对字号缩放，大按钮小按钮比例一致；2px 轻糊掩盖字形切换硬边 |\n| 失败抖动 | `360ms`、`±4px` 阻尼衰减 | 用独立 CSS `translate` 属性而不碰 `transform`，方便与按压反馈叠加不打架 |",
      "implementation": "```\nsrc/core/state-button.js:14   STATE_BUTTON                  常量表\nsrc/core/state-button.js:24   nextButtonState(state, event) 纯函数状态机\nsrc/core/state-button.js:41   loadingRemaining(t0, now, min)纯函数，防闪剩余时长\nsrc/core/state-button.js:54   stateButton(el, getOpts)      绑定点击与 Promise，只写 data-state / aria-*\nstyles/motion.css             .mk-state-btn / [data-for] / .mk-state-btn__spin / @keyframes mk-state-shake\n```",
      "degradation": "**走 `motion` 档：减，不关。**\n\n`prefers-reduced-motion: reduce` 下取消文案上下位移、模糊与失败抖动，仅保留透明度切换；加载圈停止旋转，改为缓慢透明度呼吸（`1.2s`）以继续传达“进行中”状态。",
      "pitfalls": "**① 用原生 `disabled` 属性锁定加载态，导致键盘用户焦点瞬间丢失。**\n应使用 `aria-disabled=\"true\"` + `aria-busy=\"true\"` 并在点击处理器里由状态机吃掉重复提交，焦点始终留在按钮上。\n\n**② 连续两次失败不触发抖动。**\n同一个 `.is-shaking` 类还在或同帧移除再加会被浏览器合并；必须在加类前移除并触发一次 `void el.offsetWidth`，且在 `animationend` 清掉类。\n\n**③ 抖动动画写 `transform: translateX(...)` 覆盖了按压的 `scale()`。**\n使用现代 CSS 独立变换属性 `translate: -4px` 做抖动，与按压的 `transform: scale(...)` 完全正交，同一按钮可同时挂按压反馈。\n\n**④ 异步请求在组件卸载后才 resolve，继续操作已销毁节点的定时器。**\n控制器必须维护 `alive` 标志，在 `destroy()` 中清掉全部定时器并拦截延迟回来的状态迁移。\n\n---",
      "ai_assets": {
        "prompt": "实现一个四态提交按钮（idle → loading → success / error → idle），零动画库依赖。\n\n原理一句话：四态文案全部叠在同一个 CSS Grid 格子里（grid-area: 1 / 1）天然锁定最宽宽度，状态机纯函数防重复提交并保证 loading 至少停留 400ms 防闪屏。\n\n做法：\n1. 纯函数状态机 nextButtonState(state, event)：\n   - submit：仅 idle / error → loading（loading 和 success 态下点击一律吃掉，防重复提交；error 态点一下即重试）。\n   - resolve：仅 loading → success；reject：仅 loading → error；reset：仅 success / error → idle。\n   - loadingRemaining(startedAt, now, min = 400) = Math.max(0, min - (now - startedAt))。\n2. 布局与零宽跳 CSS：\n   - 按钮容器：display: inline-grid; place-items: center; overflow: hidden;\n   - 四个状态文案节点 [data-for=\"idle|loading|success|error\"] 全部 grid-area: 1 / 1; white-space: nowrap; pointer-events: none;\n   - 非当前态：opacity: 0; transform: translate3d(0, 0.7em, 0); filter: blur(2px); transition: 240ms cubic-bezier(0.22,1,0.36,1);\n   - 当前态（容器 data-state 匹配）：opacity: 1; transform: none; filter: none;\n   - 刚离开的旧态加 .is-leaving：transform: translate3d(0, -0.7em, 0); transition-duration: 160ms（退得比进快，避免两行字叠糊）。\n   - 失败态加 .is-shaking：360ms 阻尼横抖（0/100%: 0, 20%: -4px, 40%: 4px, 60%: -3px, 80%: 2px），用独立 CSS 属性 translate 而非 transform。\n3. 交互与无障碍：\n   - 点击时驱动状态机切到 loading，记录 t0 = performance.now()，await 业务 action()；返回后等待 loadingRemaining(t0, performance.now(), 400) 再切入 success / error。\n   - success 停留 1600ms、error 停留 2400ms 后自动 reset 回 idle；loading / success 期间设 aria-disabled=\"true\"（不用原生 disabled 防止丢键盘焦点），loading 设 aria-busy=\"true\"，非当前态文案设 aria-hidden=\"true\"。\n\n硬要求：\n- 严禁在状态切换时动画 width 或用 JS 测量文字宽度 —— 四态同格 grid 天然零宽跳。\n- 严禁使用原生 disabled 属性锁加载态（会踢掉键盘焦点）；必须用 aria-disabled + 状态机拦截。\n- 连续失败重播抖动前必须先摘 .is-shaking 并触发一次 reflow。\n- prefers-reduced-motion: reduce 下去掉位移、模糊与抖动，加载圈由旋转改为 1.2s 透明度呼吸。\n\n验收：\n- 四个状态切换全程按钮宽度像素级不变（前后 getBoundingClientRect().width 差为 0）。\n- 接口 30ms 内返回时，loading 态仍稳定停留满 400ms 后再切到 success，无一帧闪烁。\n- loading 或 success 期间狂点按钮，action 仅执行 1 次；error 态点击立即进入新一轮 loading 重试。\n- 键盘 Tab 聚焦后按 Enter 提交，全程焦点不丢失。",
        "dont_do": "- 别用 `v-if` / 条件渲染把旧文案直接卸掉 —— 节点没了就失去退场过渡，且按钮宽度会随着当前文案长度来回跳动。\n- 别让抖动动画写 `transform: translateX()` —— 会和按钮按压的 `scale()` 互相覆盖。\n- 别在接口秒回时跳过 loading 直接闪一帧转圈 —— 要么不进 loading，进了就撑满 400ms。",
        "skill_rule": "# 态变按钮 (state-button) · 跨平台动效规范\n性质：反馈 ｜ 平台：both\n\n【核心原理】四态文案全部叠在同一个 CSS Grid 格子里（grid-area: 1 / 1）天然锁定最宽宽度，状态机纯函数防重复提交并保证 loading 至少停留 400ms 防闪屏。\n\n【硬要求】\n- 严禁在状态切换时动画 width 或用 JS 测量文字宽度 —— 四态同格 grid 天然零宽跳。\n- 严禁使用原生 disabled 属性锁加载态（会踢掉键盘焦点）；必须用 aria-disabled + 状态机拦截。\n- 连续失败重播抖动前必须先摘 .is-shaking 并触发一次 reflow。\n- prefers-reduced-motion: reduce 下去掉位移、模糊与抖动，加载圈由旋转改为 1.2s 透明度呼吸。\n\n【验收标准】\n- 四个状态切换全程按钮宽度像素级不变（前后 getBoundingClientRect().width 差为 0）。\n- 接口 30ms 内返回时，loading 态仍稳定停留满 400ms 后再切到 success，无一帧闪烁。\n- loading 或 success 期间狂点按钮，action 仅执行 1 次；error 态点击立即进入新一轮 loading 重试。\n- 键盘 Tab 聚焦后按 Enter 提交，全程焦点不丢失。\n\n【禁止做法】\n- 别用 `v-if` / 条件渲染把旧文案直接卸掉 —— 节点没了就失去退场过渡，且按钮宽度会随着当前文案长度来回跳动。\n- 别让抖动动画写 `transform: translateX()` —— 会和按钮按压的 `scale()` 互相覆盖。\n- 别在接口秒回时跳过 loading 直接闪一帧转圈 —— 要么不进 loading，进了就撑满 400ms。",
        "prompt_en": "Core Principle:\nZero-animation-library four-state submit button (`idle → loading → success / error → idle`). Stack all four state labels inside the same CSS Grid cell (`grid-area: 1 / 1`) to naturally lock the widest width, while a pure state machine prevents duplicate submissions and guarantees at least `400ms` in `loading` to prevent flicker.\n\nImplementation:\n1. Pure state machine `nextButtonState(state, event)`:\n   - `submit`: transitions only `idle / error → loading` (clicks during `loading` or `success` are ignored to prevent double submit; clicking in `error` immediately retries).\n   - `resolve`: only `loading → success`; `reject`: only `loading → error`; `reset`: only `success / error → idle`.\n   - `loadingRemaining(startedAt, now, min = 400) = Math.max(0, min - (now - startedAt))`.\n2. Zero-jitter layout CSS:\n   - Button container: `display: inline-grid; place-items: center; overflow: hidden;`.\n   - All four state nodes `[data-for=\"idle|loading|success|error\"]`: `grid-area: 1 / 1; white-space: nowrap; pointer-events: none;`.\n   - Inactive states: `opacity: 0; transform: translate3d(0, 0.7em, 0); filter: blur(2px); transition: 240ms cubic-bezier(0.22,1,0.36,1);`.\n   - Active state (matching container `data-state`): `opacity: 1; transform: none; filter: none;`.\n   - Exiting previous state gets `.is-leaving`: `transform: translate3d(0, -0.7em, 0); transition-duration: 160ms` (exits faster than entrance so two labels never smear together).\n   - Error state gets `.is-shaking`: `360ms` damped horizontal shake (`0/100%: 0, 20%: -4px, 40%: 4px, 60%: -3px, 80%: 2px`) using the standalone CSS `translate` property rather than `transform`.\n3. Interaction & accessibility:\n   - On click, drive state to `loading`, record `t0 = performance.now()`, `await` async `action()`, then wait `loadingRemaining(t0, performance.now(), 400)` before entering `success` or `error`.\n   - Auto-reset to `idle` after `1600ms` on `success` or `2400ms` on `error`. Set `aria-disabled=\"true\"` during `loading` / `success` (avoid native `disabled` so keyboard focus is preserved), set `aria-busy=\"true\"` during `loading`, and set `aria-hidden=\"true\"` on non-active state labels.\n\nHard Constraints:\n- Never animate `width` or measure text widths in JS during state switches—sharing one Grid cell eliminates width jitter naturally.\n- Never lock loading state with the native `disabled` attribute (it drops keyboard focus); use `aria-disabled` plus state-machine gating.\n- Before replaying `.is-shaking` on consecutive errors, remove `.is-shaking` and force a reflow first.\n- Under `prefers-reduced-motion: reduce`, remove translation, blur, and shake, and change the spinner rotation into a `1.2s` opacity pulse.\n\nAcceptance Criteria:\n- Across all four state transitions, button width stays pixel-identical (`getBoundingClientRect().width` delta equals `0`).\n- When the API resolves in under `30ms`, `loading` still holds cleanly for the full `400ms` before transitioning to `success` with zero single-frame flash.\n- Spam-clicking during `loading` or `success` executes `action` only once; clicking in `error` immediately triggers a fresh `loading` retry.\n- Focusing via `Tab` and submitting with `Enter` preserves focus throughout the entire lifecycle.",
        "dont_do_en": "- Do NOT use `v-if` or conditional rendering to unmount old labels — removing the node kills the exit transition and causes button width to jump between label lengths.\n- Do NOT write `transform: translateX()` for the shake animation — it overwrites press `scale()`.\n- Do NOT skip loading or flash a single-frame spinner when the API returns instantly — either stay out of loading or hold it for the full `400ms`.",
        "skill_rule_en": "# Zero-Jitter Multi-State Button (state-button) · Cross-Platform Motion Spec\nNature: Feedback | Layer: motion | Platform: both\n\nCore Principle: Zero-animation-library four-state submit button (`idle → loading → success / error → idle`). Stack all four state labels inside the same CSS Grid cell (`grid-area: 1 / 1`) to naturally lock the widest width, while a pure state machine prevents duplicate submissions and guarantees at least `400ms` in `loading` to prevent flicker.\n\nHard Constraints:\n- Never animate `width` or measure text widths in JS during state switches—sharing one Grid cell eliminates width jitter naturally.\n- Never lock loading state with the native `disabled` attribute (it drops keyboard focus); use `aria-disabled` plus state-machine gating.\n- Before replaying `.is-shaking` on consecutive errors, remove `.is-shaking` and force a reflow first.\n- Under `prefers-reduced-motion: reduce`, remove translation, blur, and shake, and change the spinner rotation into a `1.2s` opacity pulse.\n\nAcceptance Criteria:\n- Across all four state transitions, button width stays pixel-identical (`getBoundingClientRect().width` delta equals `0`).\n- When the API resolves in under `30ms`, `loading` still holds cleanly for the full `400ms` before transitioning to `success` with zero single-frame flash.\n- Spam-clicking during `loading` or `success` executes `action` only once; clicking in `error` immediately triggers a fresh `loading` retry.\n- Focusing via `Tab` and submitting with `Enter` preserves focus throughout the entire lifecycle.\n\nDo NOT Do:\n- Do NOT use `v-if` or conditional rendering to unmount old labels — removing the node kills the exit transition and causes button width to jump between label lengths.\n- Do NOT write `transform: translateX()` for the shake animation — it overwrites press `scale()`.\n- Do NOT skip loading or flash a single-frame spinner when the API returns instantly — either stay out of loading or hold it for the full `400ms`."
      }
    },
    {
      "id": "sticky-title",
      "name": "吸顶与滚动阴影",
      "name_en": "Scroll-Driven Sticky Hairline",
      "layer": "mobile",
      "nature": "方向",
      "platform": "both",
      "status": "shipped",
      "entry": ".mk-sticky / .mk-glass--sticky（玻璃版）/ 一段 @keyframes + scroll() 时间轴，零 JS",
      "source": "iOS 导航栏的滚动阴影（发丝线在滚过顶部后淡入）+ 原生 CSS scroll-driven animations",
      "source_en": "iOS navigation bar scroll edge (CSS animation-timeline: scroll(), zero JS)",
      "file": "effects/sticky-title.md",
      "summary": "吸顶条滚过顶部后，底部那条发丝线自动淡入（0 → 48px 行程）——\n`animation-timeline: scroll()` 驱动，零 JS、零监听。",
      "summary_en": "Automatically fades in a crisp bottom hairline border as a sticky header scrolls past 0–48px via CSS `animation-timeline: scroll()` — zero JS, zero listeners.",
      "problem": "**吸顶条一旦吸住，内容就从它底下\"钻\"过去了——这条边界必须被画出来。**\n不画线，吸顶条和列表行之间没有层级关系，用户分不清\"哪一行是当前的\"。\n阴影/发丝线就是那条边界，而它**只在滚动后才有意义**：在顶部时它是多余的，\n滚起来才该出现。\n\n第二个问题：**这个\"只跟滚动位置有关\"的动画，不该用 scroll 事件来做。**\n滚动位置 → 视觉状态的映射是纯函数，浏览器自己就能算——\n`scroll()` 时间轴让映射跑在合成器上，主线程零参与，快滚也不掉帧。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 发丝线 0 → 48px 行程淡入（iOS 导航栏的量级） | iOS 的\"标题随滚动缩小\"—— 库里有一组 `.mk-sticky__title` keyframes（22→17px），但 demo 不用它（字号体系会打架），见第 7 节⑤ |\n| 吸顶底色 `rgba(7,9,13,.82)` + `blur(14px)`——常驻，不参与动画 | 玻璃版的\"底色固化\"（`glass-sticky`）：底色 10% → 78% 随滚动变实，那是另一条卡的事 |\n| `animation-range: 0px 48px` 把动画**钉在滚动距离上** | 倒滚时线条淡出的对称处理——时间轴天然双向，反向滚动自动淡出 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| `animation-range` | `0px 48px` | 48px ≈ 吸顶条自身的高度。滚过自身高度才亮完，太快（<24px）会闪一下 |\n| 发丝线 | 1px、`rgba(255,255,255,.12)` | 阴影太重会像\"掉下来一块板子\"；1px 发丝线是\"有分界\"的最小表达 |\n| 吸顶底色 | 常驻 `.82` + blur(14px) | 底色**不参与动画**——它必须从第一帧就足够实，否则吸住瞬间文字和下方内容会串 |\n| 时间轴 | `scroll(nearest block)` | 见第 7 节①——root/nearest 之差是**实测抓出来的 bug**，同一错误犯过两次（①和⑤） |\n| z-index | 40 | 吸顶条在普通内容之上、弹层（90/91）之下 |",
      "implementation": "```\nmobile.css:277  .mk-sticky        sticky 定位 + 常驻底色\nmobile.css:286  .mk-sticky::after 发丝线（opacity: 0 起始）\nmobile.css:297  @supports 块      scroll() 时间轴（不支持的浏览器没有线，也不出错）\nglass.css:229   .mk-glass--sticky 玻璃版：底色固化 10% → 78%\n```\n\n结构上的关键决定：**动画只动发丝线的 opacity，底色和 blur 常驻。**\n\n为什么不连底色一起淡入：吸顶条吸住的瞬间，正文第一行正好从它底下钻过去——\n如果那时底色还是透明的，文字会**叠在正文上**。所以底色必须从第一帧就够实。\n要\"更实\"的渐进感，那是玻璃版的事（`glass-sticky` 的底色 10% → 78%），\n而且它动的是 `background-color` 不是 blur——见第 7 节②。\n\n时间轴是声明式的，没有 JS 状态可测：\n\n```css\n@supports (animation-timeline: scroll()) {\n  .mk-sticky::after {\n    animation: mk-sticky-line linear both;\n    animation-timeline: scroll(nearest block);\n    animation-range: 0px 48px;\n  }\n}\n```\n\n`both` 是双向填充——时间轴的值跟着滚动位置走，倒滚自动回退。",
      "degradation": "**走 `mobile` 那档：减，但这里减的是\"有没有线\"。**\n\n`@supports` 括住了整个时间轴声明：不支持 scroll-driven animations 的浏览器\n（2023 年前的 Safari）**只是没有那条线**——吸顶、底色、模糊全部照常。\n这是三条降级契约之外少有的第四种形态：**特性整体缺失时，装饰降级为零、功能不动。**\n发丝线是纯装饰（拿掉无感），所以它可以整条消失；底色不是（拿掉内容会串），\n所以底色不在动画里。",
      "pitfalls": "**① 时间轴用 `root` 在滚动容器里是死的——实测抓出来的。**\n`scroll(root block)` 指文档滚动器。吸顶条几乎总是挂在 `overflow: auto` 的\n容器里（页面主体区、弹层内部、设备框），**容器自己滚，root 纹丝不动**。\n实测（Chrome，430×900，设备框内挂 `.mk-sticky`、容器滚 200px）：\n\n```\nscroll(root block)   → 发丝线 opacity 恒为 0\nscroll(nearest block) → opacity = 1\n```\n\n没有报错、没有警告，就是永远不亮。和 `.mk-glass--sticky` 是同一条规矩\n（README「已知边界」那条），这条卡之前用的却是 root——**同一库内两条同类规则\n用了不同时间轴，说明这条规矩没有成为 reflex**。已改为 nearest。\n调试这类问题的唯一办法是读 `getComputedStyle(el, '::after').opacity`——\n时间轴驱动的动画在 DevTools 动画面板里也看不见。\n\n**② \"固化底色而不是模糊半径\"是被推翻重来的决策。**\n直觉做法是 blur 从 0 → 14px 随滚动插值。做不了：blur 是 backdrop-filter 的\n参数，让它随滚动插值需要 `@property` 注册自定义属性 + 时间轴双条件，\n缺一个就变成在区间中点\"啪\"地跳一档。而\"变得更实\"（background-color）本身\n就是导航栏的观感来源——**降级方案反而是零代价、任何浏览器都不跳的方案**。\n这条的完整论述在 `glass.css:229` 的注释里，属于\"被推翻重来\"的知识，\n比\"正解是什么\"更值钱。\n\n**③ `animation-range` 的单位是滚动距离，不是百分比。**\n`0px 48px` 意思是\"容器滚过 0 到 48px 之间这段\"。写成百分比（`0% 100%`）\n分母是**整个可滚动高度**——列表越长线亮得越慢，列表短到不足一屏时\n（`scrollHeight == clientHeight`）百分比区间塌缩，线永远不亮。\n吸顶条的 range 永远该用 px。\n\n**④ sticky 生效的前提是祖先不裁剪、不设 overflow。**\n`position: sticky` 对任意祖先的 `overflow: hidden` 敏感——\n只要某个祖先裁剪了，sticky 就失效变成普通定位。demo 的设备框能跑是因为\n`.screen` 本身就是滚动容器；把 `.mk-sticky` 挂进一个 `overflow: hidden`\n的卡片里它会钉在卡片顶部而不是视口。**sticky 的时间和空间归属要一起想。**\n\n**⑤ 标题缩小的规则一直在库里，但用的是 `root` 时间轴 —— 所以从来没生效过。**\n\n`mobile.css` 里有一组 `.mk-sticky__title` + `@keyframes mk-sticky-title`\n（22px → 17px，range `0px 120px`），demo 里一度删掉了对应文案，理由是\"没实现\"。\n实际上规则在，只是和①犯了同一个错：`scroll(root block)`（后改为 `nearest`）。\n实测（Chrome，设备框内挂 `.mk-sticky__title`、容器滚 200px）：\n\n```\nscroll(root block)    → font-size 22px → 22px（纹丝不动）\nscroll(nearest block) → font-size 22px → 17px\n```\n\n**这是①的第二次发作**，说明\"时间轴一律用 nearest\"当时没有真正成为 reflex ——\n只改了出事的那一处。同类规则要一次搜干净：`grep -n 'animation-timeline' styles/*.css`。\n\ndemo 里仍然没有用它：演示框的标题为了排版压到了 14px，套上这组 keyframes\n会和 demo 自己的字号规则打架。想用就把 keyframes 的起止值按自己的字号改掉，\n不要以为它是\"通用的\"。\n\n---",
      "ai_assets": {
        "prompt": "实现吸顶条的滚动阴影（发丝线随滚动淡入）。纯 CSS scroll-driven animation，零 JS。\n\n原理一句话：滚动驱动动画 —— 滚动位置直接驱动时间轴，不需要滚动监听、不需要 rAF。零 JS。\n\nCSS：\n  .sticky {\n    position: sticky;\n    top: 0;\n    z-index: 40;\n    /* 底色和模糊必须常驻、从第一帧就够实 ——\n       吸住瞬间正文会从它底下钻过去，透明底色会让文字叠在正文上 */\n    background: rgba(7, 9, 13, 0.82);\n    backdrop-filter: blur(14px) saturate(140%);\n  }\n  .sticky::after {\n    content: '';\n    position: absolute;\n    left: 0; right: 0; bottom: 0;\n    height: 1px;\n    background: rgba(255, 255, 255, 0.12);\n    opacity: 0;\n  }\n  @supports (animation-timeline: scroll()) {\n    .sticky::after {\n      animation: line linear both;\n      animation-timeline: scroll(nearest block);   /* 必须 nearest，见下 */\n      animation-range: 0px 48px;                    /* px，不是百分比 */\n    }\n    @keyframes line { from { opacity: 0 } to { opacity: 1 } }\n  }\n\n硬要求：\n- 时间轴必须 scroll(nearest block)。scroll(root) 指文档滚动器，\n  吸顶条几乎总挂在 overflow 容器里 —— 容器自己滚、root 不动，\n  发丝线永远不亮，且没有任何报错。\n- animation-range 用 px 不用百分比：分母是整个可滚动高度，\n  列表越长线亮得越慢，不足一屏时区间塌缩、线永远不亮。\n- 底色不参与动画（理由见上）；只动画发丝线的 opacity。\n- @supports 括住整个时间轴块：不支持的浏览器没有线，其余照常。\n\n验收：\n- 容器滚 0px：线透明；滚 48px 以上：线全亮；中间呈线性过渡。\n- 反向滚回顶部：线自动淡出（both 双向填充，无需额外规则）。\n- 吸顶条吸住的瞬间：正文从它底下钻过去时不透字（底色第一帧就是实的）。\n- 不支持 scroll() 的浏览器：无报错、无残留样式，吸顶和底色照常。\n- 验证方法：getComputedStyle(bar, '::after').opacity ——\n  时间轴动画不出现在 DevTools 动画面板，只能读计算值。",
        "dont_do": "- 别用 scroll 事件 + `classList.toggle('is-scrolled')`——\n  阈值附近来回滚动会抖（加类撤类打架），且多一条主线程监听；\n  时间轴是连续值，天生不抖。\n- 别动画 blur 半径——需要 `@property` + 时间轴双条件，缺一个就在中点跳档；\n  要\"变实\"就动 `background-color`（glass-sticky 那条已验证的路）。\n- 别把发丝线做进 `box-shadow`——shadow 不参与 opacity 过渡的起点，\n  从 0 长出来的那一帧会全宽闪现；单独一个 1px 伪元素是可控的最小表达。",
        "skill_rule": "# 吸顶与滚动阴影 (sticky-title) · 跨平台动效规范\n性质：方向 ｜ 平台：both\n\n【核心原理】滚动驱动动画 —— 滚动位置直接驱动时间轴，不需要滚动监听、不需要 rAF。零 JS。\n\n【硬要求】\n- 时间轴必须 scroll(nearest block)。scroll(root) 指文档滚动器，\n  吸顶条几乎总挂在 overflow 容器里 —— 容器自己滚、root 不动，\n  发丝线永远不亮，且没有任何报错。\n- animation-range 用 px 不用百分比：分母是整个可滚动高度，\n  列表越长线亮得越慢，不足一屏时区间塌缩、线永远不亮。\n- 底色不参与动画（理由见上）；只动画发丝线的 opacity。\n- @supports 括住整个时间轴块：不支持的浏览器没有线，其余照常。\n\n【验收标准】\n- 容器滚 0px：线透明；滚 48px 以上：线全亮；中间呈线性过渡。\n- 反向滚回顶部：线自动淡出（both 双向填充，无需额外规则）。\n- 吸顶条吸住的瞬间：正文从它底下钻过去时不透字（底色第一帧就是实的）。\n- 不支持 scroll() 的浏览器：无报错、无残留样式，吸顶和底色照常。\n- 验证方法：getComputedStyle(bar, '::after').opacity ——\n  时间轴动画不出现在 DevTools 动画面板，只能读计算值。\n\n【禁止做法】\n- 别用 scroll 事件 + `classList.toggle('is-scrolled')`——\n  阈值附近来回滚动会抖（加类撤类打架），且多一条主线程监听；\n  时间轴是连续值，天生不抖。\n- 别动画 blur 半径——需要 `@property` + 时间轴双条件，缺一个就在中点跳档；\n  要\"变实\"就动 `background-color`（glass-sticky 那条已验证的路）。\n- 别把发丝线做进 `box-shadow`——shadow 不参与 opacity 过渡的起点，\n  从 0 长出来的那一帧会全宽闪现；单独一个 1px 伪元素是可控的最小表达。",
        "prompt_en": "Core Principle:\nImplement a scroll-driven sticky header shadow/hairline (hairline fades in with scroll) using pure CSS scroll-driven animation with zero JS. Scroll position directly drives the animation timeline—no scroll listeners, no `rAF`, zero JS.\n\nImplementation:\n```css\n.sticky {\n  position: sticky;\n  top: 0;\n  z-index: 40;\n  /* Background and blur must be present and opaque enough from frame 0 —\n     body text passes underneath the moment it sticks, and a transparent fill causes overlapping text */\n  background: rgba(7, 9, 13, 0.82);\n  backdrop-filter: blur(14px) saturate(140%);\n}\n.sticky::after {\n  content: '';\n  position: absolute;\n  left: 0; right: 0; bottom: 0;\n  height: 1px;\n  background: rgba(255, 255, 255, 0.12);\n  opacity: 0;\n}\n@supports (animation-timeline: scroll()) {\n  .sticky::after {\n    animation: line linear both;\n    animation-timeline: scroll(nearest block);   /* must be nearest, see below */\n    animation-range: 0px 48px;                    /* px, not percentage */\n  }\n  @keyframes line { from { opacity: 0 } to { opacity: 1 } }\n}\n```\n\nHard Constraints:\n- Timeline must use `scroll(nearest block)`. `scroll(root)` targets the document scroller, whereas sticky headers almost always live inside an `overflow` container—the container scrolls while `root` stays at `0`, leaving the hairline permanently invisible with zero errors.\n- `animation-range` must use `px`, not percentages: percentage denominators span the full scrollable height, making longer lists fade slower and collapsing the range when content is shorter than one viewport.\n- Do not animate the background color (for the reason above); animate only the hairline's `opacity`.\n- Wrap the entire timeline block in `@supports (animation-timeline: scroll())`: unsupported browsers simply omit the hairline while everything else works normally.\n\nAcceptance Criteria:\n- At `0px` scroll, the hairline is transparent; past `48px` scroll, it is at full opacity; in between, it transitions linearly.\n- Scrolling back to the top automatically fades the hairline out (`both` fill mode requires no extra rules).\n- The moment the header sticks, body text passing underneath does not bleed through (the background is solid from frame 0).\n- Browsers without `scroll()` support show zero errors and no broken leftover styles, with sticky positioning and background working normally.\n- Verification method: read `getComputedStyle(bar, '::after').opacity`—timeline animations do not appear in the DevTools Animations panel, so inspect computed styles directly.",
        "dont_do_en": "- Do NOT use a `scroll` listener + `classList.toggle('is-scrolled')` — scrolling back and forth near the threshold causes flicker (class-add/remove thrashing) and adds a main-thread listener; a scroll timeline is continuous and flicker-free.\n- Do NOT animate `blur` radius — it requires both `@property` and timeline support, and missing either causes a sudden step jump at the midpoint; to \"solidify\", animate `background-color` instead (as proven in the glass-sticky pattern).\n- Do NOT put the hairline inside `box-shadow` — shadow does not interpolate cleanly from `0` opacity and flashes full-width on frame 1; a standalone 1px pseudo-element is the smallest controllable primitive.",
        "skill_rule_en": "# Scroll-Driven Sticky Hairline (sticky-title) · Cross-Platform Motion Spec\nNature: Direction | Layer: mobile | Platform: both\n\nCore Principle: Implement a scroll-driven sticky header shadow/hairline (hairline fades in with scroll) using pure CSS scroll-driven animation with zero JS. Scroll position directly drives the animation timeline—no scroll listeners, no `rAF`, zero JS.\n\nHard Constraints:\n- Timeline must use `scroll(nearest block)`. `scroll(root)` targets the document scroller, whereas sticky headers almost always live inside an `overflow` container—the container scrolls while `root` stays at `0`, leaving the hairline permanently invisible with zero errors.\n- `animation-range` must use `px`, not percentages: percentage denominators span the full scrollable height, making longer lists fade slower and collapsing the range when content is shorter than one viewport.\n- Do not animate the background color (for the reason above); animate only the hairline's `opacity`.\n- Wrap the entire timeline block in `@supports (animation-timeline: scroll())`: unsupported browsers simply omit the hairline while everything else works normally.\n\nAcceptance Criteria:\n- At `0px` scroll, the hairline is transparent; past `48px` scroll, it is at full opacity; in between, it transitions linearly.\n- Scrolling back to the top automatically fades the hairline out (`both` fill mode requires no extra rules).\n- The moment the header sticks, body text passing underneath does not bleed through (the background is solid from frame 0).\n- Browsers without `scroll()` support show zero errors and no broken leftover styles, with sticky positioning and background working normally.\n- Verification method: read `getComputedStyle(bar, '::after').opacity`—timeline animations do not appear in the DevTools Animations panel, so inspect computed styles directly.\n\nDo NOT Do:\n- Do NOT use a `scroll` listener + `classList.toggle('is-scrolled')` — scrolling back and forth near the threshold causes flicker (class-add/remove thrashing) and adds a main-thread listener; a scroll timeline is continuous and flicker-free.\n- Do NOT animate `blur` radius — it requires both `@property` and timeline support, and missing either causes a sudden step jump at the midpoint; to \"solidify\", animate `background-color` instead (as proven in the glass-sticky pattern).\n- Do NOT put the hairline inside `box-shadow` — shadow does not interpolate cleanly from `0` opacity and flashes full-width on frame 1; a standalone 1px pseudo-element is the smallest controllable primitive."
      }
    },
    {
      "id": "swipe",
      "name": "左滑操作",
      "name_en": "Swipe-to-Reveal List Action",
      "layer": "mobile",
      "nature": "方向",
      "platform": "touch",
      "status": "shipped",
      "entry": "v-mk-swipe + .mk-swipe / .mk-swipe__body / .mk-swipe__action / swipe(el, { threshold, onDismiss })",
      "source": "iOS 列表的左滑删除（body 滑开露出底下固定宽度的操作区）",
      "source_en": "iOS Mail / WeChat swipe actions (40% threshold + pan-y scroll preservation)",
      "file": "effects/swipe.md",
      "summary": "列表行往左拖，露出底下固定宽度的操作按钮；拖过 40% 或往左甩就停在打开位。",
      "summary_en": "Horizontal drag on mobile list rows revealing fixed-width actions behind; latches open past 40% travel or a quick leftward flick while preserving vertical scroll.",
      "problem": "**次要操作不能占可见空间，但也不能藏到找不到。** 删除、归档、置顶——这些操作\n一天用不了几次，给每个都放一个按钮会把列表变成工具栏；收进\"更多\"菜单又要多两步。\n左滑是两者的折中：操作一直在那儿，只是被行盖住。\n\n第二个问题是**滚动和横滑必须不打架**。列表行的主任务是被竖向滚动，\n横滑是叠加在它上面的次要手势——两者抢同一个手指，谁赢了都难受。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| `touch-action: pan-y` 的分工：竖滚归浏览器，横滑才归 JS——**触屏上唯一不打架的分法** | iOS 的\"连续露出多个操作\"（慢滑全露出、快滑只露第一个）—— 这里只有一个操作区 |\n| 距离或速度双判定，和 `bottom-sheet` / `edge-back` 同一套语义 | 松手后的吸附动画（当前直接落位，靠 body 的 240ms 过渡收） |\n| 拖动中 `is-dragging` 关过渡、松手恢复 | 操作区宽度随手指拉伸（iOS 有轻微的阻尼伸出） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 操作区宽度 | 88px（CSS 定，JS 读 `offsetWidth`） | 一个 44px 热区 + 文字。**JS 不写死宽度**，读布局——操作区改成两个按钮时 JS 不用动 |\n| 打开阈值 | 40% 操作区宽 | 低于 30% 误开（想滚列表路过一下就开了）；高于 50% 要拖很远 |\n| 甩速阈值 | `-0.4 px/ms`（向左为负） | 和 `bottom-sheet` 的 0.55、`edge-back` 的 0.5 同一量级。轻甩一下就该开，不用拖满 |\n| body 过渡 | `--mk-dur-3` = 240ms | 松手落位。拖动中必须关掉（见第 5 节） |",
      "implementation": "```\ngesture.js:357  swipe(el, { threshold = 0.4, onDismiss })\ngesture.js:86   pointerDrag(body, { axis: 'x' })   速度来自全库唯一的那份\nmobile.css:192  .mk-swipe / __action / __body\n```\n\n**结构是三层，不是两层**：\n\n```html\n<div class=\"mk-swipe\">              <!-- 裁剪容器，overflow: hidden -->\n  <div class=\"mk-swipe__action\">删除</div>   <!-- 铺底，永远在原位 -->\n  <div class=\"mk-swipe__body\">…行内容…</div> <!-- 唯一被位移的东西 -->\n</div>\n```\n\n操作区**不动**，动的是盖在它上面的 body。这样松手回弹时操作区不会有任何\n\"跟着缩回去\"的错觉，也天然支持多个操作区并排。\n\n**`touch-action: pan-y` 挂在 body 上**——浏览器接管所有竖向手势（滚动照常、\n连惯性都原生），只有横向位移会到 JS 手里。这是触屏上唯一不需要\n`preventDefault`、不破坏滚动惯性的分法；用 `touchmove` + 方向判断自己拦的\n方案全部会在快速滚动时掉帧。\n\n拖动中 `.is-dragging` 把 body 的过渡关掉（和 `bottom-sheet` 的\n`is-dragging`、`detent` 的旋钮是同一条规矩：**跟手零延迟，落位才过渡**）。",
      "degradation": "**走 `mobile` 那档：减。**\n\n手势和落位全部保留（它是功能）；松手那 240ms 的过渡在全局减弱下被压到 1ms，\n变成瞬时落位。注意 `swipe()` **没有** `isCoarsePointer()` 判定——桌面鼠标\n也能拖着打开，这和 `edge-back` 一样是未设防的，但左滑删除在桌面上是可用操作\n而不是误触源，所以**不设防在这里是对的**。两条卡对照着读：\n判定要不要加，看的是\"这个手势在鼠标下是功能还是事故\"。",
      "pitfalls": "**① 打开状态下再拖，起点要带 `-width` 偏移。**\n\n```js\nonStart() { start = open ? -width() : 0; },\nonMove(dx) { setX(clamp(start + dx, -width(), 0)); },\n```\n\n`pointerDrag` 给的 `dx` 是**本次手势**的位移。打开状态漏掉 `-width()` 基准的话，\n手指一动行就跳回 0。`clamp(..., -width(), 0)` 同时保证向右拖不超出关闭位、\n向左拖不超出操作区宽——**左滑没有橡皮筋**，因为右边不是边界是内容。\n\n**② 甩的判定用速度符号，不只是大小。**\n`velocity < -0.4` 里的负号：`pointerDrag` 的速度带方向，向左是负。\n写成 `Math.abs(velocity) > 0.4` 的话，向右快甩也会打开操作区——用户明明在关它。\n\n**③ 操作区按钮的点击要接在 `action` 上，不是靠 body 滑开后\"露出可点\"。**\n`onActionClick` 直接调 `onDismiss`。**使用方千万别在行内容上绑 click 再指望\n滑开后的点击**——body 滑开后仍然盖着下面的东西吗？不，body 是滑走的，\n露出的是 action；但 body 自己还在原坐标系里，点击目标判定以视觉为准。\n所以 action 的按钮必须是 `action` 的子元素，语义才对。\n\n**④ 行高变化时 `overflow: hidden` 会裁掉阴影。**\n`.mk-swipe` 是裁剪容器，body 的投影、focus 环都会被裁。列表里的行通常没有\n外阴影所以没暴露；要加阴影就加在 `.mk-swipe` 上，不是 body 上。\n\n**⑤ `pointercancel` 曾会误开行。** 拖过 40% 后手势被浏览器抢走，旧实现照常\n判定\"要打开\"——用户没松手，操作区却弹开了。已修复：cancel 时回到拖动前的\n状态（开着就还原开着，关着就还原关着），不做判定。同 `bottom-sheet` 第 7 栏⑦。\n\n**⑥ 兄弟行不会自动关。**\niOS 的行为是打开一行时自动关掉上一行。这里没有——每行是独立的 `swipe()`\n实例，互相不知道。多开几行的话操作区叠着都开着，视觉上像漏了。\n当前要使用方自己在 `onDismiss`/外部状态里遍历关闭（`close()` 已导出）。\n**这是已知缺口**，做\"行管理器\"属于组件层的事，不该塞进手势核心。\n\n**⑦ 打开状态下滑动列表，行会保持开着跟着滚。**\n和⑤同源：没有\"滚动即关闭\"的逻辑。iOS 上滚动列表时所有打开的行会收回。\n当前版本记录为已知边界；补法是给列表容器挂一次 scroll 监听（阈值 1px）\n遍历 `close()`，但那又是组件层的事。\n\n**⑧ 别把 `touch-action` 挂到容器上。**\n`.mk-swipe` 容器如果也设 `pan-y`，竖向滚动没问题，但**行内横向的原生行为**\n（比如行里有横向滑动的子组件）会被一起接管。`pan-y` 只属于 body——\n它是\"这块区域的横滑归 JS\"的声明，作用域必须最小。\n\n---",
      "ai_assets": {
        "prompt": "实现 iOS 式的左滑操作行。Pointer Events + touch-action，不引依赖。\n\n原理一句话：横向指针位移写进 translate3d，松手按阈值吸附到开/关两态。没有物理，只有位移钳制 + 一个过渡。\n\n结构（三层）：\n  <div class=\"swipe\">                    /* overflow: hidden 的裁剪容器 */\n    <div class=\"swipe__action\">删除</div>  /* 铺底，绝对定位 right:0，不动 */\n    <div class=\"swipe__body\">…</div>       /* 唯一被位移的行内容 */\n  </div>\n\n行为：\n- 只给 body 挂 pointer 拖拽（axis: x），并在 body 上设 touch-action: pan-y ——\n  竖向滚动完全交给浏览器（惯性、回弹都是原生的），\n  只有横向位移会到 JS。不要在容器上设 touch-action，不要 preventDefault。\n- 拖动中加 .dragging：body 的 transform 过渡此时必须关掉（跟手零延迟），\n  松手摘类恢复 240ms 过渡落位。\n- 位移 = clamp(基准 + dx, -actionWidth, 0)。基准在拖拽开始时确定：\n  已打开是 -actionWidth，否则 0。actionWidth 读 offsetWidth，不写死。\n- 松手判定：x < -actionWidth * 0.4（拖过 40%）或 velocity < -0.4 px/ms\n  （向左快甩，注意负号是方向）→ 打开；否则关闭。\n- 速度必须复用同一个拖拽器算出的那份（px/ms，e.timeStamp 做分母）。\n- 操作区按钮的 click 直接调 onDismiss 回调。\n\n硬要求：\n- transform 用 translate3d(x, 0, 0)，只有 body 动，操作区不动。\n- 已打开时往右拖，要能拖回关闭位；向右快甩不允许触发打开（速度方向判定）。\n- 左滑无橡皮筋：clamp 的下界就是 -actionWidth，不要做过滚。\n- teardown 摘监听、归位。\n\n已知限制（写进注释）：不做\"打开 A 行自动关 B 行\"和\"滚动列表自动收起\"——\n那是列表组件层的事，手势核心只负责一行。\n\n验收：\n- 慢拖过 50% 松手 → 停在打开位；慢拖到 30% 松手 → 弹回关闭。\n- 轻快向左一甩（不足 40%）→ 打开。\n- 打开后向右拖回 0 → 关闭；向右快甩 → 仍关闭（不会误开）。\n- 行内上下滚动列表：行不动、页面正常滚，无掉帧。\n- 打开状态下再按住拖动：从 -width 基准开始，不跳变。",
        "dont_do": "- 别用 `overflow-x: scroll` + scroll-snap 模拟——snap 停靠位置没法和\n  \"40% 或甩速\"的双判定对齐，而且拿不到松手速度。\n- 别把删除直接做进手势（拖过阈值就删）——**打开位先确认再点**是安全设计，\n  拖过即删的操作不可撤销，iOS 自己都不这么做。\n- 别让 body 和 action 各自动画——只有 body 有 transform，\n  action 是背景，动了就露馅。",
        "skill_rule": "# 左滑操作 (swipe) · 跨平台动效规范\n性质：方向 ｜ 平台：touch\n\n【核心原理】横向指针位移写进 translate3d，松手按阈值吸附到开/关两态。没有物理，只有位移钳制 + 一个过渡。\n\n【硬要求】\n- transform 用 translate3d(x, 0, 0)，只有 body 动，操作区不动。\n- 已打开时往右拖，要能拖回关闭位；向右快甩不允许触发打开（速度方向判定）。\n- 左滑无橡皮筋：clamp 的下界就是 -actionWidth，不要做过滚。\n- teardown 摘监听、归位。\n\n已知限制（写进注释）：不做\"打开 A 行自动关 B 行\"和\"滚动列表自动收起\"——\n那是列表组件层的事，手势核心只负责一行。\n\n【验收标准】\n- 慢拖过 50% 松手 → 停在打开位；慢拖到 30% 松手 → 弹回关闭。\n- 轻快向左一甩（不足 40%）→ 打开。\n- 打开后向右拖回 0 → 关闭；向右快甩 → 仍关闭（不会误开）。\n- 行内上下滚动列表：行不动、页面正常滚，无掉帧。\n- 打开状态下再按住拖动：从 -width 基准开始，不跳变。\n\n【禁止做法】\n- 别用 `overflow-x: scroll` + scroll-snap 模拟——snap 停靠位置没法和\n  \"40% 或甩速\"的双判定对齐，而且拿不到松手速度。\n- 别把删除直接做进手势（拖过阈值就删）——**打开位先确认再点**是安全设计，\n  拖过即删的操作不可撤销，iOS 自己都不这么做。\n- 别让 body 和 action 各自动画——只有 body 有 transform，\n  action 是背景，动了就露馅。",
        "prompt_en": "Core Principle:\nImplement an iOS-style swipe-to-reveal row action using Pointer Events + `touch-action` with zero dependencies. Write horizontal pointer displacement into `translate3d` and snap on release to open or closed by threshold—no physics engine, just clamped displacement plus one CSS transition.\n\nImplementation:\n1. Three-layer structure:\n   ```html\n   <div class=\"swipe\">                      <!-- overflow: hidden clip container -->\n     <div class=\"swipe__action\">Delete</div> <!-- stationary backdrop, position: absolute; right: 0 -->\n     <div class=\"swipe__body\">…</div>       <!-- the only translated row content -->\n   </div>\n   ```\n2. Attach horizontal pointer drag (`axis: x`) exclusively to `body` with `touch-action: pan-y` on `body`—vertical scrolling stays completely native (with native inertia and bounce), and only horizontal gestures reach JS. Do not set `touch-action` on the outer container and do not call `preventDefault`.\n3. Add `.dragging` during drag with `transition: none` on `body` for zero-latency tracking; remove `.dragging` on release to restore the `240ms` settling transition.\n4. Offset = `clamp(base + dx, -actionWidth, 0)`. Capture `base` on drag start (`-actionWidth` if already open, else `0`). Read `actionWidth` from `offsetWidth` rather than hardcoding.\n5. Release rule: open if `x < -actionWidth * 0.4` (past 40%) or `velocity < -0.4` px/ms (fast leftward flick; negative sign encodes direction); otherwise close.\n6. Reuse the exact same velocity computed by the drag tracker (`px/ms` using `e.timeStamp` as denominator). Clicking the action button invokes the `onDismiss` callback directly.\n\nHard Constraints:\n- Use `translate3d(x, 0, 0)` on `body` only; the action layer stays stationary.\n- Dragging right when already open must drag smoothly back to closed; a fast rightward flick must never trigger open (directional velocity check).\n- No leftward rubber-banding: clamp lower bound strictly at `-actionWidth` with zero overscroll.\n- Teardown removes listeners and resets position. Known limitation (document in comments): single-row gesture core does not auto-close sibling rows or auto-collapse on list scroll—that belongs to the list wrapper.\n\nAcceptance Criteria:\n- Slow drag past 50% and release → locks open; slow drag to 30% and release → snaps closed.\n- Brisk leftward flick (under 40% distance) → opens.\n- Dragging right back to `0` from open → closes; fast rightward flick → stays closed (never misfires open).\n- Scrolling the list vertically from inside a row moves the page smoothly without moving the row or dropping frames.\n- Pressing and dragging while already open starts from `-width` with zero jump.",
        "dont_do_en": "- Do NOT emulate this with `overflow-x: scroll` + scroll-snap — snap points cannot match the dual \"40% or flick velocity\" rule and give you no release velocity.\n- Do NOT bind deletion directly to the swipe gesture (deleting on threshold pass) — reveal first, tap to confirm is a safety contract; swipe-to-delete without undo is destructive and even iOS avoids making it irreversible.\n- Do NOT animate both `body` and `action` — only `body` moves with `transform`; `action` is a stationary backdrop and moving it gives the trick away.",
        "skill_rule_en": "# Swipe-to-Reveal List Action (swipe) · Cross-Platform Motion Spec\nNature: Direction | Layer: mobile | Platform: touch\n\nCore Principle: Implement an iOS-style swipe-to-reveal row action using Pointer Events + `touch-action` with zero dependencies. Write horizontal pointer displacement into `translate3d` and snap on release to open or closed by threshold—no physics engine, just clamped displacement plus one CSS transition.\n\nHard Constraints:\n- Use `translate3d(x, 0, 0)` on `body` only; the action layer stays stationary.\n- Dragging right when already open must drag smoothly back to closed; a fast rightward flick must never trigger open (directional velocity check).\n- No leftward rubber-banding: clamp lower bound strictly at `-actionWidth` with zero overscroll.\n- Teardown removes listeners and resets position. Known limitation (document in comments): single-row gesture core does not auto-close sibling rows or auto-collapse on list scroll—that belongs to the list wrapper.\n\nAcceptance Criteria:\n- Slow drag past 50% and release → locks open; slow drag to 30% and release → snaps closed.\n- Brisk leftward flick (under 40% distance) → opens.\n- Dragging right back to `0` from open → closes; fast rightward flick → stays closed (never misfires open).\n- Scrolling the list vertically from inside a row moves the page smoothly without moving the row or dropping frames.\n- Pressing and dragging while already open starts from `-width` with zero jump.\n\nDo NOT Do:\n- Do NOT emulate this with `overflow-x: scroll` + scroll-snap — snap points cannot match the dual \"40% or flick velocity\" rule and give you no release velocity.\n- Do NOT bind deletion directly to the swipe gesture (deleting on threshold pass) — reveal first, tap to confirm is a safety contract; swipe-to-delete without undo is destructive and even iOS avoids making it irreversible.\n- Do NOT animate both `body` and `action` — only `body` moves with `transform`; `action` is a stationary backdrop and moving it gives the trick away."
      }
    },
    {
      "id": "tap",
      "name": "按下即反馈",
      "name_en": "Zero-Latency Touch Press",
      "layer": "mobile",
      "nature": "反馈",
      "platform": "touch",
      "status": "shipped",
      "entry": "v-mk-tap（`--deep` 修饰符）/ tap(el, { haptic, force })",
      "source": "iOS 原生按钮的按压形变（scale + 提亮）+「反馈必须和指尖同一帧」的原则",
      "source_en": "Native iOS touch press (0ms pointerdown response + scroll-cancel guard)",
      "file": "effects/tap.md",
      "summary": "`pointerdown` 那一帧就按下（`scale(0.955)` + 提亮），松手/滑走撤掉 ——\n把\"按了\"的确认从 `:active` 的 100ms 之后拉回第 0ms。",
      "summary_en": "Applies crisp scale(0.955) + highlight on the exact pointerdown frame (0ms instead of CSS :active's 100ms mobile delay) and cancels cleanly if the finger scrolls away.",
      "problem": "**触摸屏上，按下和没按下在一开始是看不见的。** iOS 上 `:active` 要等约 100ms 才亮\n（系统在等这是不是滚动/双击的一部分），这段时间用户手里捏着按钮，屏幕没有任何表示\n—— 这就是\"卡\"感的最大单一来源。桌面没有这个问题，所以 `:active`/`:hover` 够用。\n\n第二个问题藏在 CSS 里：移动浏览器默认要等 **300ms** 才能确认这不是双击缩放。\n`touch-action: manipulation` 把这段等待砍掉，但它必须写在元素上，不是全局的。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| iOS 按钮的\"按下去变浅 + 轻微缩小\"两件套 | Material 的涟漪 —— 那是另一个效果（`ripple`），两者别叠在同一节点 |\n| 「反馈和指尖同一帧」：不用 `:active`，用 `pointerdown` 直接加类 | 长按的持续下沉 —— 那是 `long-press` 的事 |\n| 主操作更深一档（`--deep`） | 按压时的音效 / 连续微震（Core Haptics 那套） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 下沉幅度 | `scale(0.955)` | 可感知但不抢内容：低于 0.94 用户会以为按钮坏了，高于 0.97 看不出来。这是\"皮肤被按下去\"而不是\"按钮被放大\" |\n| 深按压 | `scale(0.92)` + `brightness(0.94)` | 给主 CTA 用。变暗而不是变亮 —— 主操作按下去应该\"沉\"，次操作按下去应该\"亮\" |\n| 回弹时长 | `--mk-dur-1` = 80ms | 反馈类的上限。超过 120ms 按压会读成\"一个动画\"而不是\"一个状态\" |\n| 震动 | `buzz(8)` | 8ms 是\"接触\"不是\"确认\"（长按的 12ms 才是确认）。iOS 没有 vibrate，静默失败 —— 视觉反馈才是必需项 |\n| 生效条件 | `(hover: none), (pointer: coarse)` | 精确指针上 `:active`/`:hover` 已经足够精细，再叠一层 JS 只会让点击变钝 |",
      "implementation": "```\ntap.js:24     tap(el, { haptic = true, force = false })    → teardown\ntap.js:59     isTouchLike()   (hover: none), (pointer: coarse)\ntap.js:69     buzz(ms)        navigator.vibrate 不存在就返回 false\nmobile.css:59 .mk-tap         tap-highlight + touch-action + 80ms 过渡\nmobile.css:68 .mk-tap.is-tap\nmobile.css:74 .mk-tap--deep.is-tap\n```\n\n四个事件一个都不能少：\n\n```js\nel.addEventListener('pointerdown',  on);      // 加类\nel.addEventListener('pointerup',    off);     // 松手\nel.addEventListener('pointercancel', cancel); // 滚动/系统手势接管\nel.addEventListener('pointerleave', cancel);  // 手指滑出（部分浏览器不发 cancel）\n```\n\n`pointercancel` 和 `pointerleave` **都要挂**。实测（Chrome 触摸模拟）：手指按下后\n滑出元素，浏览器会先发 `pointercancel` 再补 `pointerleave`；桌面鼠标拖出只有\n`pointerleave`。只挂一个，另一个路径上按压态就永远摘不掉。\n\n`v-mk-tap` 挂载时顺手加 `mk-tap` 类 —— 视觉规则全挂在 `.mk-tap` 上，\nJS 只负责\"什么时候加 `.is-tap`\"。",
      "degradation": "**走 `motion` 那档：减，不是关。**\n\n`motion.css` 的全局减弱块把 `--mk-dur-1` 压到 `1ms`，所以按压回弹变成瞬时切换 ——\n**状态还在，动画没了**。这是对的：按压反馈是功能（告诉用户\"点到了\"），不是装饰。\n震动在减弱动效下没有专门处理，因为它本来就是一次性的、不连续的。\n\n`.mk-lite` 下同样保留 —— 理由同上。",
      "pitfalls": "**① 和 `v-mk-glass` 的 `.is-press` 互斥。**\n`glass()` 在触屏上接管按压，加 `.is-press` 播 `mk-glass-press` 关键帧，\n和 `.is-tap` 都写 `transform`。同一个节点只能二选一，否则两段关键帧互相抢，\n按压看起来像抽搐（README 第 607 行）。\n\n**② 和 `v-mk-longpress` 叠加会\"按下去又弹起来一次\"。**\n`pointerdown` 那一帧 `is-tap`（`scale 0.955`）和计时器同时启动；480ms 后\n`is-longpress`（`scale 0.97`）压不住 `is-tap`——两条规则特异性相同，\n`.mk-tap.is-longpress` 在文件里更靠后所以赢了，元素会**向上弹一下**。\n用户读到的是\"按到一半松了一下\"。要长按就不要 tap，或者给长按单独一套视觉。\n\n**③ `v-mk-enter` 的内联 `transition-delay` 会拖慢按压。**\n入场动画给每个元素写了 `transition-delay: calc(var(--mk-i) * 70ms)`。\n如果不清理，这个 delay 会作用到该元素**之后的所有过渡**上 —— 包括按压回弹，\n结果就是\"按下要等 70ms 才亮\"，和没做这个效果一样。\n所以 `v-mk-enter` 在 `transitionend` 后必须把 `el.style.transitionDelay = ''`\n并加 `.is-done`（`vue/index.js:74`）。自己写入场动画时容易忘这一步。\n\n**④ 滚动起手会闪一帧按压态。**\n手指按在列表行上开始滚动时，`pointerdown` 先到、浏览器判定\"这是滚动\"再发\n`pointercancel` —— 中间那一两帧 `.is-tap` 已经挂上了。实测在合成事件里\n（没有真实滚动容器接管），这个状态会一直挂着直到手动 cancel（跑满 30 帧 / 488ms）。\n真实设备上通常只闪 1-2 帧。要消灭它得把加类推迟一帧并监听滚动意图，\n但那样\"同一帧反馈\"就没了 —— **这是个取舍，不是 bug**，目前的取向是宁可闪。\n\n**⑤ `isTouchLike()` 只在挂载时求值一次。**\n之后用户插上鼠标、或从外接屏切到触屏，判定不会重算。反过来，\n触屏笔记本（`pointer: coarse` 为 false，主指针是鼠标）上这个效果**默认不挂**——\n那块屏幕上的触摸走的是 `:active`，有 100ms 延迟。要全都要就 `force: true`，\n但鼠标端会变钝，这是参数名里那个 `force` 的真实含义。\n\n**⑥ iOS 的 `.mk-lift:active` 需要页面上有 touch 监听才会亮。**\niOS Safari 的规则：`:active` 伪类只在元素（或文档）有 touch 事件监听时才生效。\n`mobile.css` 里 `.mk-lift:active` 那条，在**一个 `tap()` 都没挂的页面**上是不工作的。\n只要页面上任何一个元素挂了 `tap()`，这条就顺带活了 —— 但如果你只用了\n`mk-lift` 而没用 `tap`，要么加一个空的 `document.body.addEventListener('touchstart', () => {})`，\n要么接受它只在 Android 上生效。\n\n**⑦ 嵌套的 `.mk-tap` 会双重按压。**\n按钮套在列表行里、两个都挂 `v-mk-tap`：按下时两层同时缩小，视觉上是\"整行和按钮\n一起陷下去\"。事件不冲突（都会触发 click，冒泡而已），纯视觉问题。\n解法是内层加、外层不加，或者外层用 `mk-group` 那种\"其余变暗\"的表达。\n\n---",
      "ai_assets": {
        "prompt": "实现移动端的「按下即反馈」。原生 Pointer Events，不引依赖。\n\n原理一句话：把\"指针按下\"这一瞬间映射成一个类名，形变交给 CSS。要的是零延迟的状态切换，不是补间动画 —— 所以不需要动画库，只需要挂对事件。\n\n行为：\n- pointerdown 那一帧给元素加 .is-pressing（不要等 :active ——\n  iOS 上 :active 有约 100ms 延迟，那 100ms 就是\"卡\"的来源）。\n- pointerup / pointercancel / pointerleave 任一发生就撤掉类。\n  三个都必须挂：触屏上滚动接管走 pointercancel，鼠标拖出走 pointerleave。\n- 元素样式：\n    .pressable { touch-action: manipulation; -webkit-tap-highlight-color: transparent;\n                 transition: transform 80ms ease-out; }\n    .pressable.is-pressing { transform: scale(0.955); }\n  主操作按钮用 .pressable--deep：scale(0.92) + brightness(0.94)（变暗表示\"沉\"）。\n- 可选触觉：pointerdown 时 navigator.vibrate(8)，不支持就静默跳过。\n- 只在粗指针上挂：matchMedia('(hover: none), (pointer: coarse)')。\n  鼠标端用 :active/:hover 就够；要强制启用用 force 参数。\n\n硬要求：\n- 如果元素上还有入场动画，入场结束后必须清掉 transition-delay ——\n  否则按压回弹会被入场时的级联延迟拖慢，等于白做。\n- 同一个元素上不要再叠别的写 transform 的按压效果（两种关键帧会互相抢）。\n- prefers-reduced-motion 下按压态保留，只把时长压到 1ms ——\n  这是功能（确认输入），不是装饰，不能关。\n\n验收：\n- 按下后 16ms 内 is-pressing 已挂上（人手能感知的差异就在这 100ms 里）。\n- 手指按住不放 → 保持按下态；滑出元素 → 撤掉；滚动接管 → 撤掉。\n- 松手后 80ms 内回到原状，且不残留 transform（teardown 时清干净）。\n- 桌面鼠标点击不触发 JS 按压（:active 接管），控制台无报错。",
        "dont_do": "- 别用 `click` 事件加按压类 —— 那比 `:active` 还晚。\n- 别把 `scale` 做成 CSS 变量然后每个组件调一个值 —— 两种档位（普通/深）是设计决策，\n  不是自由参数，散开之后整个界面就没有一致的\"按压深度\"了。\n- 别同时挂涟漪。涟漪（`ripple`）和形变是两种反馈语言，叠在一个节点上会打架；\n  要用涟漪就替换掉形变，不要叠加。",
        "skill_rule": "# 按下即反馈 (tap) · 跨平台动效规范\n性质：反馈 ｜ 平台：touch\n\n【核心原理】把\"指针按下\"这一瞬间映射成一个类名，形变交给 CSS。要的是零延迟的状态切换，不是补间动画 —— 所以不需要动画库，只需要挂对事件。\n\n【硬要求】\n- 如果元素上还有入场动画，入场结束后必须清掉 transition-delay ——\n  否则按压回弹会被入场时的级联延迟拖慢，等于白做。\n- 同一个元素上不要再叠别的写 transform 的按压效果（两种关键帧会互相抢）。\n- prefers-reduced-motion 下按压态保留，只把时长压到 1ms ——\n  这是功能（确认输入），不是装饰，不能关。\n\n【验收标准】\n- 按下后 16ms 内 is-pressing 已挂上（人手能感知的差异就在这 100ms 里）。\n- 手指按住不放 → 保持按下态；滑出元素 → 撤掉；滚动接管 → 撤掉。\n- 松手后 80ms 内回到原状，且不残留 transform（teardown 时清干净）。\n- 桌面鼠标点击不触发 JS 按压（:active 接管），控制台无报错。\n\n【禁止做法】\n- 别用 `click` 事件加按压类 —— 那比 `:active` 还晚。\n- 别把 `scale` 做成 CSS 变量然后每个组件调一个值 —— 两种档位（普通/深）是设计决策，\n  不是自由参数，散开之后整个界面就没有一致的\"按压深度\"了。\n- 别同时挂涟漪。涟漪（`ripple`）和形变是两种反馈语言，叠在一个节点上会打架；\n  要用涟漪就替换掉形变，不要叠加。",
        "prompt_en": "Core Principle:\nImplement mobile zero-latency touch press feedback using native Pointer Events with zero dependencies. Map the exact frame of pointer down to a CSS class and leave deformation to CSS—you want zero-latency state switching rather than tweening, so no animation library is needed, only the right event bindings.\n\nImplementation:\n1. Add `.is-pressing` on the `pointerdown` frame itself (do not wait for `:active`—on iOS `:active` incurs an `~100ms` delay, which is where sluggishness comes from).\n2. Remove `.is-pressing` on any of `pointerup` / `pointercancel` / `pointerleave` (all three are mandatory: scroll takeover fires `pointercancel` on touch, dragging out fires `pointerleave` on mouse).\n3. Element CSS:\n   `.pressable { touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: transform 80ms ease-out; }`\n   `.pressable.is-pressing { transform: scale(0.955); }`\n   Primary CTAs use `.pressable--deep`: `scale(0.92)` + `brightness(0.94)` (dimming conveys depth).\n4. Optional haptics: call `navigator.vibrate(8)` on `pointerdown`, silently skipping if unsupported.\n5. Attach only on coarse pointers (`matchMedia('(hover: none), (pointer: coarse)')`), letting `:active`/`:hover` handle desktop mice unless `force` is explicitly set.\n\nHard Constraints:\n- If the element also has an entrance animation, clear `transition-delay` once entrance finishes—otherwise press rebound inherits the entrance stagger delay and feels sluggish.\n- Never stack another `transform`-writing press effect on the same element (competing keyframes fight each other).\n- Keep the press state active under `prefers-reduced-motion` and only compress duration to `1ms`—press confirmation is functional input feedback, not decoration, and must not be disabled.\n\nAcceptance Criteria:\n- `.is-pressing` is applied within `16ms` of press (human perception notices that `100ms` difference).\n- Holding finger stays pressed; sliding off removes it; scroll takeover removes it.\n- Releasing restores resting state within `80ms` with no leftover `transform` (cleaned up on teardown).\n- Desktop mouse clicks do not trigger JS press logic (`:active` handles them) with zero console errors.",
        "dont_do_en": "- Do NOT apply the press class on `click` — that fires even later than `:active`.\n- Do NOT turn `scale` into a free-for-all CSS variable tweaked per component — the two tiers (normal / deep) are a deliberate design decision to keep press depth consistent across the entire UI.\n- Do NOT stack a `ripple` on the same element — ripple and scale deformation are two distinct feedback languages that fight on one node; swap one for the other instead of combining them.",
        "skill_rule_en": "# Zero-Latency Touch Press (tap) · Cross-Platform Motion Spec\nNature: Feedback | Layer: mobile | Platform: touch\n\nCore Principle: Implement mobile zero-latency touch press feedback using native Pointer Events with zero dependencies. Map the exact frame of pointer down to a CSS class and leave deformation to CSS—you want zero-latency state switching rather than tweening, so no animation library is needed, only the right event bindings.\n\nHard Constraints:\n- If the element also has an entrance animation, clear `transition-delay` once entrance finishes—otherwise press rebound inherits the entrance stagger delay and feels sluggish.\n- Never stack another `transform`-writing press effect on the same element (competing keyframes fight each other).\n- Keep the press state active under `prefers-reduced-motion` and only compress duration to `1ms`—press confirmation is functional input feedback, not decoration, and must not be disabled.\n\nAcceptance Criteria:\n- `.is-pressing` is applied within `16ms` of press (human perception notices that `100ms` difference).\n- Holding finger stays pressed; sliding off removes it; scroll takeover removes it.\n- Releasing restores resting state within `80ms` with no leftover `transform` (cleaned up on teardown).\n- Desktop mouse clicks do not trigger JS press logic (`:active` handles them) with zero console errors.\n\nDo NOT Do:\n- Do NOT apply the press class on `click` — that fires even later than `:active`.\n- Do NOT turn `scale` into a free-for-all CSS variable tweaked per component — the two tiers (normal / deep) are a deliberate design decision to keep press depth consistent across the entire UI.\n- Do NOT stack a `ripple` on the same element — ripple and scale deformation are two distinct feedback languages that fight on one node; swap one for the other instead of combining them."
      }
    },
    {
      "id": "tilt",
      "name": "3D 倾斜与光泽",
      "name_en": "3D Card Tilt & Glare",
      "layer": "motion",
      "nature": "材质",
      "platform": "web",
      "status": "shipped",
      "entry": "v-mk-tilt + .mk-tilt / tilt(el, { max, scale, glare })",
      "source": "Aceternity 全息卡 + Apple TV 卡片视角倾斜（rAF lerp 到位即停 + 触屏自动关闭）",
      "source_en": "Apple TV / Stripe interactive tilt (auto-settling rAF + touch guard)",
      "file": "effects/tilt.md",
      "summary": "桌面指针划过卡片时，卡片沿指针反方向 3D 微微倾斜并联动一层径向光泽；rAF 线性插值收敛到位即自动停帧，触屏端默认关闭避免残留歪斜。",
      "summary_en": "Damped desktop pointer tilt coupled with directional specular glare that halts its rAF loop immediately once settled and disables cleanly on coarse touch screens.",
      "problem": "**普通卡片 hover 只加一个 `translateY(-2px)` 缺少实体的重量与光面感；而直接把鼠标坐标硬塞进 `rotateX/Y` 会抖得像抽筋。** 用低幅倾角（≤10°）+ 每帧 22% 追随插值 + 同步反光点，能让平面卡片在桌面端立刻像一块拿在手里的实体卡。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| Apple TV / Aceternity 全息卡的「低倾角 + 镜面光泽联动」 | 超过 20° 的夸张透视翻转（像游戏卡牌，喧宾夺主） |\n| rAF lerp（0.22）平滑追随 + 误差 ≤0.001 自动停帧 | 常驻不停止的全局 `requestAnimationFrame` 循环 |\n| JS 只写 CSS 变量，由样式表拼 `perspective() rotateX/Y() scale()` | JS 覆写 inline `transform` 导致与视差/按压冲突 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 最大倾角 `max` | `10deg` | 8–10° 刚好能看出立体反光而不扭曲卡片里的文字；超过 15° 阅读体验明显变差 |\n| 插值系数 | `0.22` / 帧 | 比 0.12 跟手、比 0.45 柔和；离开卡片时自然平滑回中，不需要单独写松手曲线 |\n| 停帧阈值 | `0.001` | 指针离开回中到 0.001 内立刻停掉 rAF，静止页面零 CPU 占用 |\n| 悬停缩放 `scale` | `1.02` | 极克制的抬起感，不会撞到相邻栅格卡片 |\n| 触屏策略 | `isCoarsePointer()` 直接不挂 | 触屏没有 hover，松手后卡片会歪着卡住，比不动更难看 |",
      "implementation": "```\nsrc/core/tilt.js:21   tilt(el, { max, scale, glare, reduced })  写入 --mk-tilt-x/y/scale 与 --mk-glare-x/y/o\nstyles/motion.css     .mk-tilt / .mk-tilt::after（径向高光层）\n```",
      "degradation": "**走 `motion` 档：减，不关。**\n\n`prefers-reduced-motion: reduce` 与粗指针设备（`pointer: coarse`）下均不注册 `pointermove` 监听、不启动 rAF，只保留静态轻微抬起或完全平面，绝不残留歪斜。",
      "pitfalls": "**① 忘了在 `pointercancel` 复位，或者常驻 rAF 不停。**\n必须同时监听 `pointerleave` 和 `pointercancel` 归零目标值，并在收敛阈值 `< 0.001` 时把 `raf = 0` 彻底停掉。\n\n**② `rotateX` 和 `rotateY` 符号写反。**\n鼠标移到卡片上方（`ty < 0`）时，卡片上沿应向屏幕里压下去，即 `rotateX` 为正（`-ty * max`）；鼠标移到右侧（`tx > 0`）时右沿压下去，即 `rotateY` 为正（`tx * max`）。写反了读起来像卡片在“躲着鼠标”。\n\n**③ 触屏端强行启用倾斜。**\n手机上没有持续指针位置，点一下卡片歪了就回不去；必须用 `(hover: none), (pointer: coarse)` 门禁直接跳过。\n\n---",
      "ai_assets": {
        "prompt": "实现桌面端 3D 倾斜 + 镜面光泽跟随卡片（零动画库依赖）。\n\n原理一句话：指针归一化到 [-1, 1] 后用 rAF lerp（0.22/帧）写入 CSS 变量 --tilt-x / --tilt-y / --glare-x / --glare-y，由 CSS 拼装 perspective + rotateX/Y + scale，收敛到位即停帧。\n\n做法：\n1. 能力门禁：若 prefers-reduced-motion: reduce 或 matchMedia('(hover: none), (pointer: coarse)') 命中，直接不注册指针监听与 rAF。\n2. 指针映射（max = 10deg, scale = 1.02）：\n   - pointermove：px = clamp((clientX - rect.left) / rect.width, 0, 1)，py 同理；\n     目标 tx = px * 2 - 1，ty = py * 2 - 1；\n     光泽坐标 --glare-x = px * 100%，--glare-y = py * 100%，--glare-o = 1。\n   - pointerleave / pointercancel：active = false，tx = 0，ty = 0，--tilt-scale = 1，--glare-o = 0。\n3. 到位即停的 rAF 循环：\n   - 每帧 cx += (tx - cx) * 0.22，cy += (ty - cy) * 0.22；\n   - 写入 --tilt-x = (-cy * max)deg，--tilt-y = (cx * max)deg（注意 rotateX 取 -cy 才符合按压物理方向）；\n   - 仅当 active || |tx - cx| > 0.001 || |ty - cy| > 0.001 时继续预约下一帧，否则清零 raf 停止循环。\n4. CSS 拼装：\n   - 容器 transform: perspective(900px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) scale(var(--tilt-scale, 1));\n   - 光泽层 ::after：pointer-events: none; background: radial-gradient(circle at var(--glare-x, 50%) var(--glare-y, 50%), rgba(255,255,255,0.22), transparent 60%); opacity: var(--glare-o, 0);\n\n硬要求：\n- JS 严禁直接覆盖 el.style.transform，必须只写 CSS 变量。\n- 必须做到「到位即停」，鼠标移开回正后 rAF 回调数归零。\n- 触屏与减弱动效下必须自动跳过，不留歪斜态。\n\n验收：\n- 鼠标移向卡片左上角时，左上角向内微倾、高光落在左上；移开后在 ~300ms 内平滑回正并停止 rAF。\n- 卡片内文字与按钮点击正常，不被光泽伪元素拦截。\n- 在触屏模拟环境下点击卡片不产生歪斜残留。",
        "dont_do": "- 别把最大倾角设超过 `15deg` —— 卡片文字会明显畸变发糊。\n- 别在 `pointermove` 里直接赋值角度不加插值 —— 鼠标微抖或离开瞬间会生硬跳回。\n- 别让 rAF 在静止页面上 60fps 空转。",
        "skill_rule": "# 3D 倾斜与光泽 (tilt) · 跨平台动效规范\n性质：材质 ｜ 平台：web\n\n【核心原理】指针归一化到 [-1, 1] 后用 rAF lerp（0.22/帧）写入 CSS 变量 --tilt-x / --tilt-y / --glare-x / --glare-y，由 CSS 拼装 perspective + rotateX/Y + scale，收敛到位即停帧。\n\n【硬要求】\n- JS 严禁直接覆盖 el.style.transform，必须只写 CSS 变量。\n- 必须做到「到位即停」，鼠标移开回正后 rAF 回调数归零。\n- 触屏与减弱动效下必须自动跳过，不留歪斜态。\n\n【验收标准】\n- 鼠标移向卡片左上角时，左上角向内微倾、高光落在左上；移开后在 ~300ms 内平滑回正并停止 rAF。\n- 卡片内文字与按钮点击正常，不被光泽伪元素拦截。\n- 在触屏模拟环境下点击卡片不产生歪斜残留。\n\n【禁止做法】\n- 别把最大倾角设超过 `15deg` —— 卡片文字会明显畸变发糊。\n- 别在 `pointermove` 里直接赋值角度不加插值 —— 鼠标微抖或离开瞬间会生硬跳回。\n- 别让 rAF 在静止页面上 60fps 空转。",
        "prompt_en": "Core Principle:\nZero-animation-library desktop 3D tilt and specular glare card. Normalize pointer coordinates to `[-1, 1]`, interpolate via `rAF` lerp (`0.22`/frame) into CSS variables `--tilt-x`, `--tilt-y`, `--glare-x`, and `--glare-y`, let CSS compose `perspective` + `rotateX/Y` + `scale`, and halt the loop once settled.\n\nImplementation:\n1. Capability gate: if `prefers-reduced-motion: reduce` or `matchMedia('(hover: none), (pointer: coarse)')` matches, register neither pointer listeners nor `rAF`.\n2. Pointer mapping (`max = 10deg`, `scale = 1.02`):\n   - `pointermove`: `px = clamp((clientX - rect.left) / rect.width, 0, 1)`, same for `py`; targets `tx = px * 2 - 1`, `ty = py * 2 - 1`; glare coordinates `--glare-x = px * 100%`, `--glare-y = py * 100%`, `--glare-o = 1`.\n   - `pointerleave` / `pointercancel`: `active = false`, `tx = 0`, `ty = 0`, `--tilt-scale = 1`, `--glare-o = 0`.\n3. Settle-and-stop `rAF` loop:\n   - Each frame: `cx += (tx - cx) * 0.22`, `cy += (ty - cy) * 0.22`;\n   - Write `--tilt-x = (-cy * max)deg`, `--tilt-y = (cx * max)deg` (note `rotateX` uses `-cy` to match physical press-in direction);\n   - Schedule next frame only while `active || |tx - cx| > 0.001 || |ty - cy| > 0.001`; otherwise clear `raf` and stop.\n4. CSS composition:\n   - Container: `transform: perspective(900px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) scale(var(--tilt-scale, 1));`.\n   - Glare layer `::after`: `pointer-events: none; background: radial-gradient(circle at var(--glare-x, 50%) var(--glare-y, 50%), rgba(255,255,255,0.22), transparent 60%); opacity: var(--glare-o, 0);`.\n\nHard Constraints:\n- JS must never overwrite `el.style.transform` directly; write CSS custom properties only.\n- Must implement settle-and-stop so `rAF` callbacks drop to zero after the pointer leaves and the card returns to rest.\n- Must skip automatically on touch devices and under reduced motion without leaving a tilted state.\n\nAcceptance Criteria:\n- Moving the pointer toward the top-left corner dips that corner inward and places the specular glare there; on exit, the card settles smoothly back flat within `~300ms` and stops `rAF`.\n- Text and buttons inside the card remain clickable without being blocked by the glare pseudo-element.\n- Tapping the card under touch emulation leaves zero residual tilt.",
        "dont_do_en": "- Do NOT set the max tilt angle above `15deg` — card typography will visibly distort and blur.\n- Do NOT assign angles directly inside `pointermove` without interpolation — tiny cursor jitters or exits will snap abruptly.\n- Do NOT leave `rAF` spinning at 60fps on an idle page.",
        "skill_rule_en": "# 3D Card Tilt & Glare (tilt) · Cross-Platform Motion Spec\nNature: Material | Layer: motion | Platform: web\n\nCore Principle: Zero-animation-library desktop 3D tilt and specular glare card. Normalize pointer coordinates to `[-1, 1]`, interpolate via `rAF` lerp (`0.22`/frame) into CSS variables `--tilt-x`, `--tilt-y`, `--glare-x`, and `--glare-y`, let CSS compose `perspective` + `rotateX/Y` + `scale`, and halt the loop once settled.\n\nHard Constraints:\n- JS must never overwrite `el.style.transform` directly; write CSS custom properties only.\n- Must implement settle-and-stop so `rAF` callbacks drop to zero after the pointer leaves and the card returns to rest.\n- Must skip automatically on touch devices and under reduced motion without leaving a tilted state.\n\nAcceptance Criteria:\n- Moving the pointer toward the top-left corner dips that corner inward and places the specular glare there; on exit, the card settles smoothly back flat within `~300ms` and stops `rAF`.\n- Text and buttons inside the card remain clickable without being blocked by the glare pseudo-element.\n- Tapping the card under touch emulation leaves zero residual tilt.\n\nDo NOT Do:\n- Do NOT set the max tilt angle above `15deg` — card typography will visibly distort and blur.\n- Do NOT assign angles directly inside `pointermove` without interpolation — tiny cursor jitters or exits will snap abruptly.\n- Do NOT leave `rAF` spinning at 60fps on an idle page."
      }
    },
    {
      "id": "toast-stack",
      "name": "堆叠轻提示",
      "name_en": "Sonner Stacked Toasts",
      "layer": "motion",
      "nature": "连续",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-toast-stack + .mk-toast-stack / stackLayout() / shouldSwipeToast()",
      "source": "Sonner (Emil Kowalski) 的微缩层叠队列 + hover/点击展开 + 均速横甩消除",
      "source_en": "Sonner by Emil Kowalski (3-layer peek stack + hover expand + swipe dismiss)",
      "file": "effects/toast-stack.md",
      "summary": "多条轻提示默认叠成一摞（最前完整、后两条各露 14px 边并逐级缩 5%），悬停或点击时展开成列表并暂停倒计时，横向一甩即走、剩余条目同步补位。",
      "summary_en": "Stacks notifications cleanly with 14px peeking edges and 5% scale cascade, expands on hover with timer pause, and supports velocity-based horizontal swipe dismiss.",
      "problem": "**多条通知同时弹出时，竖排列表会瞬间遮死半个屏幕。** 但如果只显示最新一条又会把旧消息直接顶没，用户来不及看清上一条报错。层叠队列把“最新一条可读”与“后面还有几条待看”压缩进不到 100px 的高度里，需要时再一键展开细看。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| Sonner 的三层露出（14px 边、5% 缩放步进）+ 悬停展开暂停计时 | 绑定 React 树与全局 Store 的完整通知组件（本库只管容器词汇，DOM 归调用方） |\n| 后排 `clip-path: inset(clip 0 0 0)` 顶部裁切防高卡片冒头 | 每条动态改 `height` 触发布局重排 |\n| 横向甩走用「总位移 / 总时长」平均速度判定 | 仅看最后一帧瞬时速度（手指松前常停顿导致误判） |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 可见层数 `visible` | `3` | 第 4 条起透明度归 0 并标 `inert`；再多就变成一面墙，用户不会同时读超过 3 条 toast |\n| 露边 / 间距 `gap` | `14px` | 收起时每级露出的边宽 = 展开时的条间距，两态共用同一个数，展开时视觉位移最自然 |\n| 缩放步进 `scaleStep` | `0.05` | 3 级后为 `0.90`，一眼看得出景深层次又不会小到变形 |\n| 停留时长 `lifetime` | `4000ms` | 读完一句短通知需要 2.5–4s；悬停、键盘聚焦或切后台自动暂停并按剩余时间续计 |\n| 横甩阈值 | `45px` 或 `> 0.11 px/ms` | 短轻甩（如 25px / 120ms ≈ 0.21 px/ms）立刻走，慢拖不到 45px 回弹 |\n| 退场时长 `exit` | `200ms` | 退场开始瞬间其余条目立刻重排补位，200ms 后再通知调用方移除节点 |",
      "implementation": "```\nsrc/core/toast-stack.js:26   stackLayout(heights, opts)    纯函数，计算 y / scale / opacity / clip\nsrc/core/toast-stack.js:50   stackHeight(heights, opts)    纯函数，计算容器命中区高度\nsrc/core/toast-stack.js:61   shouldSwipeToast(dx, durMs)   纯函数，平均速度 + 距离双判定\nsrc/core/toast-stack.js:76   toastStack(el, opts)          MutationObserver 接管子节点，只写 --mk-ts-* 变量\nstyles/motion.css            .mk-toast-stack / .mk-toast-stack__item / @starting-style\n```",
      "degradation": "**走 `motion` 档：减，不关。**\n\n通知是核心状态反馈，不能关掉。`prefers-reduced-motion: reduce` 下入场 `@starting-style` 与退场 `.is-leaving` 均去掉位移（`transform: none`），只保留短促透明度淡入淡出。",
      "pitfalls": "**① 展开后鼠标从第 1 条移到第 2 条，穿过 14px 空隙触发 `pointerleave` 导致整摞突然收起。**\n必须在每条卡片上用 `::after` 向上铺一条高度等于 `gap`（14px）的透明命中桥，让整个展开列表的命中区连续不断。\n\n**② 后排卡片比最前卡片更高，收起时从最前卡片顶上露出一截文字。**\n纯靠 `translateY(-i * 14px)` 拦不住更高的后排卡片；必须算出 `clip = Math.max(0, h - frontHeight)` 并用 `clip-path: inset(clip 0 0 0)` 裁掉多出的顶部，同时把后排内部文字设为 `opacity: 0`。\n\n**③ 横甩判定用“最后一帧瞬时速度”导致轻甩经常失灵。**\n真实触屏松手前手指往往有 1 帧微停，瞬时速度掉到 0；改用平均速度 `Math.abs(dx) / durationMs > 0.11` 稳定性高得多。\n\n**④ 切到后台标签页时定时器照跑，切回来所有通知全没了。**\n必须监听 `visibilitychange`，页面不可见时暂停计时并记录剩余毫秒数 `left`，切回前台再按剩余时间续计。\n\n**⑤ 退场时直接把节点 `remove()`，看不到滑出动画，或者没先标 `is-leaving` 导致剩余条目等 200ms 才补位。**\n应该立刻给退场项加 `.is-leaving` + `inert` 并**马上重算其余条目的布局**，让补位与退场同步发生，200ms 过渡结束后再真正移除节点。\n\n---",
      "ai_assets": {
        "prompt": "实现 Sonner 风格的堆叠轻提示队列（Stacked Toast Stack），零动画库依赖。\n\n原理一句话：所有提示绝对定位贴在容器底边，纯函数按各条真实高度算出每条的纵向偏移 y、缩放 scale、透明度与顶部裁切 clip，写入 CSS 变量驱动平滑层叠与展开。\n\n做法：\n1. 纯函数布局 stackLayout(heights, { expanded = false, visible = 3, gap = 14, scaleStep = 0.05 })（heights[0] 为最新最前）：\n   - 收起态（expanded = false）：\n     y = -i * gap；scale = Math.max(0, 1 - i * scaleStep)；\n     opacity = i < visible ? 1 : 0；\n     clip = i === 0 ? 0 : Math.max(0, heights[i] - heights[0])（防止更高的后排从顶上冒头）。\n   - 展开态（expanded = true）：\n     y = -(前 i 条高度之和 + i * gap)；scale = 1；opacity = i < visible ? 1 : 0；clip = 0。\n   - 容器命中区高度 stackHeight：收起态 = heights[0] + (min(len, visible) - 1) * gap；展开态 = 前 visible 条高度和 + 间距和。\n2. CSS 样式：\n   - 容器 position: relative; height: var(--ts-h); transition: height 380ms cubic-bezier(0.22,1,0.36,1);\n   - 每条卡片 position: absolute; left: 0; right: 0; bottom: 0; transform-origin: 50% 100%;\n     transform: translate3d(var(--ts-dx, 0px), var(--ts-y, 0px), 0) scale(var(--ts-s, 1));\n     opacity: var(--ts-o, 1); clip-path: inset(var(--ts-clip, 0px) 0 0 0 round 14px);\n   - 命中桥：每条卡片加 ::after { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 14px; } 防止鼠标穿过展开缝隙触发收起。\n   - 收起态后排内部子元素 opacity: 0，防止多行字叠在一起变糊；不可见项（opacity === 0）加 inert 属性。\n   - 新条入场用 @starting-style { opacity: 0; transform: translate3d(0, 100%, 0); }。\n3. 交互与计时：\n   - 桌面 mouse pointerenter / focusin 展开，pointerleave / focusout 收起；触屏轻点展开、点容器外收起。\n   - 每条默认停留 4000ms；展开中或 document.visibilityState === 'hidden' 时暂停计时并保留剩余毫秒数，恢复后继续。\n   - 横向滑动消除：滑动期间关 transition 写 --ts-dx；松手时用平均速度判定（Math.abs(dx) >= 45 || Math.abs(dx) / durationMs > 0.11，且 pointercancel 不触发消除）。判定消除后将 --ts-dx 推至符号方向整宽外并加 .is-leaving，立即重算其余条布局同步补位，200ms 后移除节点。\n\n硬要求：\n- 容器须有 role=\"region\" 与 aria-live=\"polite\"。\n- 退场必须先加 .is-leaving 并立即触发其余条补位，200ms 后再删 DOM。\n- 必须带 ::after 透明命中桥，否则展开态鼠标在条目间隙移动会反复抖动收起。\n- prefers-reduced-motion: reduce 下去掉入场和退场位移，仅保留淡入淡出。\n\n验收：\n- 连续弹出 4 条提示：前 3 条层叠露出 14px 边且缩放为 1 / 0.95 / 0.90，第 4 条透明且 inert。\n- 后排卡片高度大于前排时，收起态顶部被整齐裁切，无文字冒出。\n- 鼠标移入整摞平滑展开、倒计时暂停；鼠标在两条缝隙间滑动不收起；移出后收起并续计剩余时间。\n- 横向快速轻甩（>45px 或均速 >0.11px/ms）卡片沿甩出方向飞出，后排同步补位；触发 pointercancel 则回弹归位。",
        "dont_do": "- 别用每条卡片动态改 `height` 做收起 —— 每帧重排且字会挤压换行，用 `clip-path: inset()` 裁切。\n- 别用最后一帧瞬时速度判断横甩 —— 松手前微停会让瞬时速度归零导致甩不走，用平均速度。\n- 别在 `visibilitychange` 后台期间继续跑倒计时 —— 用户切回标签页时会错过所有通知。",
        "skill_rule": "# 堆叠轻提示 (toast-stack) · 跨平台动效规范\n性质：连续 ｜ 平台：both\n\n【核心原理】所有提示绝对定位贴在容器底边，纯函数按各条真实高度算出每条的纵向偏移 y、缩放 scale、透明度与顶部裁切 clip，写入 CSS 变量驱动平滑层叠与展开。\n\n【硬要求】\n- 容器须有 role=\"region\" 与 aria-live=\"polite\"。\n- 退场必须先加 .is-leaving 并立即触发其余条补位，200ms 后再删 DOM。\n- 必须带 ::after 透明命中桥，否则展开态鼠标在条目间隙移动会反复抖动收起。\n- prefers-reduced-motion: reduce 下去掉入场和退场位移，仅保留淡入淡出。\n\n【验收标准】\n- 连续弹出 4 条提示：前 3 条层叠露出 14px 边且缩放为 1 / 0.95 / 0.90，第 4 条透明且 inert。\n- 后排卡片高度大于前排时，收起态顶部被整齐裁切，无文字冒出。\n- 鼠标移入整摞平滑展开、倒计时暂停；鼠标在两条缝隙间滑动不收起；移出后收起并续计剩余时间。\n- 横向快速轻甩（>45px 或均速 >0.11px/ms）卡片沿甩出方向飞出，后排同步补位；触发 pointercancel 则回弹归位。\n\n【禁止做法】\n- 别用每条卡片动态改 `height` 做收起 —— 每帧重排且字会挤压换行，用 `clip-path: inset()` 裁切。\n- 别用最后一帧瞬时速度判断横甩 —— 松手前微停会让瞬时速度归零导致甩不走，用平均速度。\n- 别在 `visibilitychange` 后台期间继续跑倒计时 —— 用户切回标签页时会错过所有通知。",
        "prompt_en": "Core Principle:\nZero-animation-library Sonner-style stacked toast notification queue (Stacked Toast Stack). Position all toasts absolutely along the container bottom edge, and use a pure layout function over actual item heights to compute each item's vertical offset `y`, scale, opacity, and top `clip-path`, writing CSS variables for smooth stacking and expansion.\n\nImplementation:\n1. Pure layout function `stackLayout(heights, { expanded = false, visible = 3, gap = 14, scaleStep = 0.05 })` (`heights[0]` is newest/frontmost):\n   - Collapsed (`expanded = false`): `y = -i * gap`; `scale = Math.max(0, 1 - i * scaleStep)`; `opacity = i < visible ? 1 : 0`; `clip = i === 0 ? 0 : Math.max(0, heights[i] - heights[0])` (prevents taller rear toasts from peeking out at the top).\n   - Expanded (`expanded = true`): `y = -(sum of previous i heights + i * gap)`; `scale = 1`; `opacity = i < visible ? 1 : 0`; `clip = 0`.\n   - Container hit-area height `stackHeight`: collapsed = `heights[0] + (min(len, visible) - 1) * gap`; expanded = sum of first `visible` heights + gaps.\n2. CSS styling:\n   - Container: `position: relative; height: var(--ts-h); transition: height 380ms cubic-bezier(0.22,1,0.36,1);`.\n   - Each toast: `position: absolute; left: 0; right: 0; bottom: 0; transform-origin: 50% 100%; transform: translate3d(var(--ts-dx, 0px), var(--ts-y, 0px), 0) scale(var(--ts-s, 1)); opacity: var(--ts-o, 1); clip-path: inset(var(--ts-clip, 0px) 0 0 0 round 14px);`.\n   - Hover bridge: add `::after { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 14px; }` to prevent collapsing when the cursor crosses gaps between expanded items.\n   - Set `opacity: 0` on inner children of rear collapsed items so multi-line text does not bleed together; set `inert` on invisible items (`opacity === 0`).\n   - Enter new items via `@starting-style { opacity: 0; transform: translate3d(0, 100%, 0); }`.\n3. Interaction & timers:\n   - Desktop expands on `pointerenter` / `focusin` and collapses on `pointerleave` / `focusout`; touch expands on tap and collapses on outside tap.\n   - Default lifetime `4000ms` per toast; pause timers while expanded or `document.visibilityState === 'hidden'`, preserving remaining milliseconds and resuming afterward.\n   - Horizontal swipe-to-dismiss: disable transition while dragging and write `--ts-dx`; on release, evaluate average velocity (`Math.abs(dx) >= 45 || Math.abs(dx) / durationMs > 0.11`, never dismissing on `pointercancel`). On dismiss, push `--ts-dx` beyond full width in the swipe direction, add `.is-leaving`, immediately recompute remaining layout slots to backfill smoothly, and remove the node after `200ms`.\n\nHard Constraints:\n- Container must have `role=\"region\"` and `aria-live=\"polite\"`.\n- Exit must add `.is-leaving` first and immediately trigger sibling backfill before removing the DOM node `200ms` later.\n- Must include the transparent `::after` hover bridge; otherwise moving the pointer across gaps while expanded causes flicker/collapse.\n- Under `prefers-reduced-motion: reduce`, remove enter/exit translation and keep fade only.\n\nAcceptance Criteria:\n- Pushing 4 toasts in succession stacks the front 3 with `14px` exposed edges and scales `1` / `0.95` / `0.90`, while the 4th is transparent and `inert`.\n- When a rear toast is taller than the front toast, its top edge is cleanly clipped in collapsed state with zero text peeking out.\n- Hovering expands the whole stack smoothly and pauses timers; moving across gaps between toasts does not collapse the stack; leaving collapses it and resumes remaining durations.\n- A quick horizontal flick (`>45px` or average speed `>0.11px/ms`) flings the toast offscreen in the flick direction while rear items backfill simultaneously; `pointercancel` springs it back into place.",
        "dont_do_en": "- Do NOT collapse cards by dynamically changing each item's `height` — it forces per-frame reflow and squeezes text into re-wrapping; clip with `clip-path: inset()` instead.\n- Do NOT judge horizontal flicks by last-frame instantaneous velocity — a micro-pause right before release zeroes instantaneous velocity and breaks flick dismissal; use average velocity.\n- Do NOT keep countdown timers running while `visibilitychange` is hidden — users will miss all their notifications by the time they switch back to the tab.",
        "skill_rule_en": "# Sonner Stacked Toasts (toast-stack) · Cross-Platform Motion Spec\nNature: Continuity | Layer: motion | Platform: both\n\nCore Principle: Zero-animation-library Sonner-style stacked toast notification queue (Stacked Toast Stack). Position all toasts absolutely along the container bottom edge, and use a pure layout function over actual item heights to compute each item's vertical offset `y`, scale, opacity, and top `clip-path`, writing CSS variables for smooth stacking and expansion.\n\nHard Constraints:\n- Container must have `role=\"region\"` and `aria-live=\"polite\"`.\n- Exit must add `.is-leaving` first and immediately trigger sibling backfill before removing the DOM node `200ms` later.\n- Must include the transparent `::after` hover bridge; otherwise moving the pointer across gaps while expanded causes flicker/collapse.\n- Under `prefers-reduced-motion: reduce`, remove enter/exit translation and keep fade only.\n\nAcceptance Criteria:\n- Pushing 4 toasts in succession stacks the front 3 with `14px` exposed edges and scales `1` / `0.95` / `0.90`, while the 4th is transparent and `inert`.\n- When a rear toast is taller than the front toast, its top edge is cleanly clipped in collapsed state with zero text peeking out.\n- Hovering expands the whole stack smoothly and pauses timers; moving across gaps between toasts does not collapse the stack; leaving collapses it and resumes remaining durations.\n- A quick horizontal flick (`>45px` or average speed `>0.11px/ms`) flings the toast offscreen in the flick direction while rear items backfill simultaneously; `pointercancel` springs it back into place.\n\nDo NOT Do:\n- Do NOT collapse cards by dynamically changing each item's `height` — it forces per-frame reflow and squeezes text into re-wrapping; clip with `clip-path: inset()` instead.\n- Do NOT judge horizontal flicks by last-frame instantaneous velocity — a micro-pause right before release zeroes instantaneous velocity and breaks flick dismissal; use average velocity.\n- Do NOT keep countdown timers running while `visibilitychange` is hidden — users will miss all their notifications by the time they switch back to the tab."
      }
    },
    {
      "id": "tooltip-group",
      "name": "热身提示组",
      "name_en": "Warmup Tooltip Group",
      "layer": "motion",
      "nature": "反馈",
      "platform": "web",
      "status": "shipped",
      "entry": "MK.tooltipGroup(root, { openDelay, warmup }) + .mk-tip-group",
      "source": "Radix Tooltip / Base UI / Rauno Freiberg（首次延迟 400ms 防误触 + 300ms 热身窗内相邻按钮 0ms 瞬切）",
      "source_en": "Radix Tooltip / Base UI / Rauno (400ms cold delay + 300ms instant warmup)",
      "file": "effects/tooltip-group.md",
      "summary": "工具栏里一组图标按钮共用同一个状态机：首次悬停等 `400ms` 防止鼠标路过误闪；一旦弹出并进入 `300ms` 热身窗，滑到相邻按钮时提示以 `0ms` 瞬切跟随并自动钳制在容器边界内。",
      "summary_en": "Shared toolbar tooltip state machine: waits 400ms on cold hover to prevent accidental flicker, then switches at 0ms instantly across neighbors within a 300ms warmup window.",
      "problem": "**普通 Tooltip 要么不设延迟（鼠标一划过顶栏满屏黑框乱闪），要么每个按钮各自孤立等 400ms（用户想扫读一排 6 个图标说明时要干等 2.4 秒，极其磨人）。** 共享热身窗把“防误触”和“连续扫读效率”这对矛盾彻底解开：冷启动克制、热切换零等待。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 纯函数 `tooltipDelay(lastCloseAt, now)` 判定冷启动 `400ms` vs 热身期 `0ms` | 每个按钮挂独立 `setTimeout` 互不知道对方状态 |\n| 整组共用一个悬浮节点，切到相邻按钮时只移动坐标变量不销毁重建 | 每次切换删旧建新导致闪烁与重排 |\n| 同时接 `focus / blur` 与 `Escape` 立即关闭，键鼠体验完全一致 | 仅支持 `mouseenter` 导致键盘用户看不到任何提示 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 冷启动延迟 `openDelay` | `400ms` | 足够过滤掉“鼠标经过工具栏去点别处”的 150–250ms 无意停留，又不至于让真想看提示的人以为坏了 |\n| 热身窗时长 `warmup` | `300ms` | 鼠标从一个图标移到相邻图标通常耗时 80–220ms，300ms 刚好覆盖连续扫读而不至于几秒后回来还乱弹 |\n| 出入场动画 | `opacity 150ms` + `scale(0.95 → 1) + 4px 轻抬 180ms` | 轻巧克制不抢视觉中心，绝不把提示做成夸张弹跳气泡 |\n| 边界钳制 | `clamp(cx - tw/2, 4, rootWidth - tw - 4)` | 最左和最右的图标弹出长文案提示时绝不被容器裁掉半截 |",
      "implementation": "```\nsrc/core/ui-motion.js:15   tooltipDelay(lastCloseAt, now, opts)  纯函数，计算冷/热延迟（可单测）\nsrc/core/ui-motion.js:23   tooltipGroup(root, opts)              共享浮层定位、热身窗、焦点与 Esc 清理\nstyles/motion.css:1391     .mk-tip-group / .mk-tip               单变量位移 + 轻缩放淡入与减弱动效降级\n```",
      "degradation": "**走 `motion` 层契约：保留热身延迟与全部信息，过渡压至 `1ms`。**\n\n`prefers-reduced-motion: reduce` 下取消位移与缩放过渡（`transition-duration: 1ms`），保留 `400ms` 防误触与 `0ms` 热身切换逻辑。",
      "pitfalls": "**① 鼠标离开按钮 A 到按钮 B 中间经过 6px 间隙，如果立刻把提示关掉且不记 `lastCloseAt`，到 B 时又要重等 400ms。**\n离开时必须记录 `lastCloseAt = performance.now()`，进入相邻按钮时只要 `now - lastCloseAt <= 300ms` 就走 `0ms` 瞬切。\n\n**② 忘了在 `pointerleave` 时 `clearTimeout(timer)`。**\n如果不清掉待触发定时器，鼠标快速扫过按钮后移开，400ms 后提示会在空无一人的地方幽灵般弹出来。\n\n**③ 提示气泡没设 `pointer-events: none`。**\n提示盖住鼠标触发点会引发 `leave → hide → enter → show` 鬼畜闪烁。\n\n---",
      "ai_assets": {
        "prompt": "实现零依赖的热身提示组（Warmup Tooltip Group）。\n\n原理一句话：同组触发按钮共享一个悬浮提示气泡与上次关闭时间戳；冷启动悬停等待 400ms 防误触，300ms 热身窗内滑到同组任意相邻按钮时 0ms 瞬切定位并自动钳制在容器边界内。\n\n做法：\n1. 纯函数 tooltipDelay(lastCloseAt, now, { openDelay = 400, warmup = 300 })：\n   - 若 lastCloseAt 无效或 < 0，返回 openDelay；\n   - 计算 elapsed = now - lastCloseAt，若 0 <= elapsed <= warmup 返回 0，否则返回 openDelay。\n2. 共享气泡控制器：\n   - 在组容器内创建一个共享 role=\"tooltip\" 浮层（pointer-events: none），定位只写 --tip-x / --tip-y 两个 CSS 变量，transform: translate3d(var(--tip-x), var(--tip-y), 0)。\n   - 坐标计算：水平居中于触发按钮，同时钳制在 [4, containerWidth - tipWidth - 4] 内防左右裁切；垂直位于按钮上方 gap = 8px。\n   - 绑定 pointerenter / focus 触发 show(btn)：先 clearTimeout；若当前已打开或 tooltipDelay(...) === 0 则立刻更新文案与坐标；否则延迟 400ms 显示。\n   - 绑定 pointerleave / blur / keydown(Escape) 触发 hide()：立刻 clearTimeout；若当前打开则记录 lastCloseAt = performance.now() 并隐藏。\n3. CSS 过渡与降级：\n   - 未打开时 opacity: 0，垂直下偏 4px 且 scale(0.95)；打开态 opacity: 1、scale(1) 归位（150–180ms ease-out）。\n   - prefers-reduced-motion: reduce 将过渡压至 1ms，保留热身逻辑与完整提示内容。\n\n硬要求：\n- 离开按钮时必须立即 clearTimeout，防止鼠标划走后延迟幽灵弹出。\n- 提示浮层必须设 pointer-events: none，且必须支持键盘 focus/blur 与 Escape 关闭。\n- 严禁为每个按钮各自维护互不通信的独立延迟。\n\n验收：\n- 首次悬停任一按钮 400ms 后平滑浮现提示；快速扫过按钮不闪现任何幽灵提示。\n- 提示打开后移向同组相邻按钮，0ms 无延迟瞬切文案与位置，边缘按钮提示不被容器裁切。\n- 按 Tab 聚焦按钮可触发提示，按 Escape 立即关闭；组件卸载后清理定时器与事件监听。",
        "dont_do": "- 别把所有提示延迟都设成 `0ms` —— 鼠标路过工具栏时满屏黑框闪现极度吵闹。\n- 别给每个按钮做孤立的 400ms 延迟 —— 连续扫读一排图标时会卡得让人崩溃。\n- 别忘了 `pointer-events: none` —— 浮层一旦挡住指针会反复触发闪烁。",
        "skill_rule": "# 热身提示组 (tooltip-group) · 跨平台动效规范\n性质：反馈 ｜ 平台：web\n\n【核心原理】同组触发按钮共享一个悬浮提示气泡与上次关闭时间戳；冷启动悬停等待 400ms 防误触，300ms 热身窗内滑到同组任意相邻按钮时 0ms 瞬切定位并自动钳制在容器边界内。\n\n【硬要求】\n- 离开按钮时必须立即 clearTimeout，防止鼠标划走后延迟幽灵弹出。\n- 提示浮层必须设 pointer-events: none，且必须支持键盘 focus/blur 与 Escape 关闭。\n- 严禁为每个按钮各自维护互不通信的独立延迟。\n\n【验收标准】\n- 首次悬停任一按钮 400ms 后平滑浮现提示；快速扫过按钮不闪现任何幽灵提示。\n- 提示打开后移向同组相邻按钮，0ms 无延迟瞬切文案与位置，边缘按钮提示不被容器裁切。\n- 按 Tab 聚焦按钮可触发提示，按 Escape 立即关闭；组件卸载后清理定时器与事件监听。\n\n【禁止做法】\n- 别把所有提示延迟都设成 `0ms` —— 鼠标路过工具栏时满屏黑框闪现极度吵闹。\n- 别给每个按钮做孤立的 400ms 延迟 —— 连续扫读一排图标时会卡得让人崩溃。\n- 别忘了 `pointer-events: none` —— 浮层一旦挡住指针会反复触发闪烁。",
        "prompt_en": "Core Principle:\nZero-dependency warmup tooltip group (Warmup Tooltip Group). Trigger buttons in the same group share a single floating tooltip bubble and a `lastCloseAt` timestamp: a cold hover waits `400ms` to prevent accidental flashes, while sliding onto any sibling button within the `300ms` warmup window switches text and position in `0ms` and automatically clamps inside container bounds.\n\nImplementation:\n1. Pure function `tooltipDelay(lastCloseAt, now, { openDelay = 400, warmup = 300 })`:\n   - Return `openDelay` if `lastCloseAt` is invalid or `< 0`;\n   - Compute `elapsed = now - lastCloseAt` and return `0` if `0 <= elapsed <= warmup`, otherwise `openDelay`.\n2. Shared bubble controller:\n   - Create one shared `role=\"tooltip\"` overlay (`pointer-events: none`) inside the group container, positioning strictly via CSS variables `--tip-x` and `--tip-y` with `transform: translate3d(var(--tip-x), var(--tip-y), 0)`.\n   - Coordinate math: center horizontally over the trigger button while clamping within `[4, containerWidth - tipWidth - 4]` to avoid left/right clipping; place vertically above the button with `gap = 8px`.\n   - Bind `pointerenter` / `focus` to `show(btn)`: call `clearTimeout` first; if already open or `tooltipDelay(...) === 0`, update content and coordinates immediately; otherwise delay `400ms`.\n   - Bind `pointerleave` / `blur` / `keydown(Escape)` to `hide()`: call `clearTimeout` immediately; if currently open, record `lastCloseAt = performance.now()` and hide.\n3. CSS transition & fallback:\n   - Closed state: `opacity: 0`, shifted `4px` downward with `scale(0.95)`; open state: `opacity: 1`, `scale(1)` (`150–180ms ease-out`).\n   - Under `prefers-reduced-motion: reduce`, compress transition duration to `1ms` while keeping warmup timing and full tooltip content intact.\n\nHard Constraints:\n- Must call `clearTimeout` immediately on pointer leave to prevent delayed ghost tooltips after the cursor sweeps away.\n- Tooltip overlay must set `pointer-events: none`, and must support keyboard `focus`/`blur` plus `Escape` dismissal.\n- Never maintain isolated, non-communicating delay timers per button.\n\nAcceptance Criteria:\n- First hover on any button reveals the tooltip smoothly after `400ms`; sweeping quickly across buttons triggers zero ghost flashes.\n- Moving from an open tooltip to a sibling button switches text and position instantly in `0ms`, and edge buttons stay unclipped inside the container.\n- `Tab`-focusing a button shows the tooltip, pressing `Escape` dismisses it immediately, and unmounting cleans up all timers and event listeners.",
        "dont_do_en": "- Do NOT set all tooltip delays to `0ms` — sweeping a pointer past a toolbar floods the screen with noisy flashing boxes.\n- Do NOT give each button an isolated `400ms` delay — scanning across a row of icons feels maddeningly sluggish.\n- Do NOT forget `pointer-events: none` — if the tooltip intercepts the pointer, it will trigger endless hover flicker.",
        "skill_rule_en": "# Warmup Tooltip Group (tooltip-group) · Cross-Platform Motion Spec\nNature: Feedback | Layer: motion | Platform: web\n\nCore Principle: Zero-dependency warmup tooltip group (Warmup Tooltip Group). Trigger buttons in the same group share a single floating tooltip bubble and a `lastCloseAt` timestamp: a cold hover waits `400ms` to prevent accidental flashes, while sliding onto any sibling button within the `300ms` warmup window switches text and position in `0ms` and automatically clamps inside container bounds.\n\nHard Constraints:\n- Must call `clearTimeout` immediately on pointer leave to prevent delayed ghost tooltips after the cursor sweeps away.\n- Tooltip overlay must set `pointer-events: none`, and must support keyboard `focus`/`blur` plus `Escape` dismissal.\n- Never maintain isolated, non-communicating delay timers per button.\n\nAcceptance Criteria:\n- First hover on any button reveals the tooltip smoothly after `400ms`; sweeping quickly across buttons triggers zero ghost flashes.\n- Moving from an open tooltip to a sibling button switches text and position instantly in `0ms`, and edge buttons stay unclipped inside the container.\n- `Tab`-focusing a button shows the tooltip, pressing `Escape` dismisses it immediately, and unmounting cleans up all timers and event listeners.\n\nDo NOT Do:\n- Do NOT set all tooltip delays to `0ms` — sweeping a pointer past a toolbar floods the screen with noisy flashing boxes.\n- Do NOT give each button an isolated `400ms` delay — scanning across a row of icons feels maddeningly sluggish.\n- Do NOT forget `pointer-events: none` — if the tooltip intercepts the pointer, it will trigger endless hover flicker."
      }
    },
    {
      "id": "tunnel",
      "name": "无限深渊隧道",
      "name_en": "Infinite 3D Depth Tunnel",
      "layer": "3d",
      "nature": "方向",
      "platform": "both",
      "status": "shipped",
      "entry": "v-mk-tunnel + .mk-tunnel-stage / .mk-tunnel / .mk-tunnel__ring / tunnel(el, { count })",
      "source": "负 animation-delay 错相无限穿越隧道（同周期错相，第 0 帧即满环零冷启动，零 JS 循环）",
      "source_en": "Pure CSS negative-delay Z-axis tunnel (zero JS animation loop)",
      "file": "effects/tunnel.md",
      "summary": "10 道光环共用同一条从远端 `-900px` 冲向镜头 `+200px` 的 CSS 关键帧，靠**负 `animation-delay`** 在第 0 帧就把整条无限深渊隧道铺满，零 JS 动画循环。",
      "summary_en": "Ten concentric frames flying along Z from -900px to +200px sharing one CSS @keyframes rule staggered via negative animation-delay so frame 0 is already full.",
      "problem": "**想做星际穿越/空间入口的无限隧道感，如果给每道环写正延迟（`+0.36s`），前 3 秒页面是空荡荡的一道道往外冒；如果用不同周期又会很快乱成一团。** 统一周期 + 负延迟错相，页面打开第 1 帧整条隧道就已经处于完美流动状态。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 全部环共用同一条 `3.6s linear infinite` 关键帧，仅用负 `delay = -i * (3.6s / count)` 均匀错相 | JS rAF 每帧更新 10 个环的 `translateZ` |\n| 两端淡入淡出（远端 `0%` 透明、近端冲过镜头 `100%` 透明），避免眼前突兀闪现 | 环突然在眼前硬裁切消失 |\n| 3D 归零降级：减弱动效直接 `animation: none; transform: none` | 停成一团错乱叠框 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 环数 `count` | `8 ~ 10` | 少于 6 环显得稀疏断层，多于 14 环重叠过密发白 |\n| 单环周期 | `3.6s linear infinite` | 与 10 环配合每环错相 `-0.36s`，穿越速度既有纵深感又不晃眼 |\n| 深度区间 | `translateZ(-900px → 180px)` | 配合 `perspective: 420px`，远端收敛到一点、近端刚好掠过镜框外沿 |",
      "implementation": "```\nsrc/core/scene3d.js:217  tunnel(el, { count })     自动生成 count 个环，零 rAF\nstyles/3d.css:154        .mk-tunnel-stage / .mk-tunnel / .mk-tunnel__ring\n```",
      "degradation": "**走 `3d` 层专属契约：归零塌回平面（停止穿越动画，仅留静态同心环或收起）。**",
      "pitfalls": "**① 延迟写成正数 `calc(var(--i) * 0.36s)`。**\n正延迟会让页面刚加载时前 3 秒隧道半空，必须写成**负延迟** `calc(var(--i) * -0.36s)` 让所有环第 0 帧就在轨道上就位。\n\n**② 忘了在 `100%` 处将 `opacity` 压回 `0`。**\n光环冲过 `translateZ` 接近 `perspective` 时会瞬间铺满整屏闪烁；最后 12% 必须平滑淡出到 `0`。\n\n---",
      "ai_assets": {
        "prompt": "实现纯 CSS 负延迟错相的无限 3D 深渊隧道（Infinite 3D Tunnel），零 WebGL / 零 JS 动画循环。\n\n原理一句话：N 道光环共用同一条 3.6s 从 translateZ(-900px) 冲向 translateZ(180px) 的关键帧，用负 animation-delay: calc(var(--i) * -0.36s) 在第 0 帧即均匀铺满整条隧道。\n\n做法：\n1. 结构：.tunnel-stage（perspective: 420px; overflow: hidden; display: grid; place-items: center）> .tunnel（transform-style: preserve-3d）> 10 个 .tunnel-ring（--i: 0..9）。\n2. CSS 关键帧：\n   @keyframes tunnel-fly {\n     0%   { transform: translateZ(-900px) scale(0.75); opacity: 0; }\n     18%  { opacity: 0.75; }\n     85%  { opacity: 0.85; }\n     100% { transform: translateZ(180px) scale(1.1); opacity: 0; }\n   }\n   .tunnel-ring {\n     position: absolute; width: 140px; height: 140px; border-radius: 24px;\n     border: 1.5px solid rgba(184,255,61,0.55);\n     animation: tunnel-fly 3.6s linear infinite;\n     animation-delay: calc(var(--i, 0) * -0.36s);\n   }\n3. 降级：@media (prefers-reduced-motion: reduce) { .tunnel-ring { animation: none; transform: none; opacity: 0.2; } }\n\n硬要求：\n- 必须使用负 animation-delay（-周期/环数），确保首帧即满环无冷启动空洞。\n- 0% 与 100% 两端必须淡出到 opacity: 0，防止冲过镜头时全屏闪白。\n- 严禁用 JS rAF 每帧更新环坐标。\n- prefers-reduced-motion: reduce 下停止动画并归零塌回平面。\n\n验收：\n- 页面打开第 1 帧即可看到 10 道光环等距均匀铺满隧道并匀速向前涌动，无接缝无闪白。\n- 全程零 JS 帧循环，纯合成器运行。\n- 开启减弱动效后彻底静止。",
        "dont_do": "- 别写正的 `animation-delay` —— 开局前几秒会看到隧道是空的。\n- 别给每道环写不同的 `animation-duration` —— 几秒后环距会彻底乱掉撞在一起。\n- 别让 `100%` 关键帧保持 `opacity: 1` —— 环贴到镜头上会爆闪。",
        "skill_rule": "# 无限深渊隧道 (tunnel) · 跨平台动效规范\n性质：方向 ｜ 平台：both\n\n【核心原理】N 道光环共用同一条 3.6s 从 translateZ(-900px) 冲向 translateZ(180px) 的关键帧，用负 animation-delay: calc(var(--i) * -0.36s) 在第 0 帧即均匀铺满整条隧道。\n\n【硬要求】\n- 必须使用负 animation-delay（-周期/环数），确保首帧即满环无冷启动空洞。\n- 0% 与 100% 两端必须淡出到 opacity: 0，防止冲过镜头时全屏闪白。\n- 严禁用 JS rAF 每帧更新环坐标。\n- prefers-reduced-motion: reduce 下停止动画并归零塌回平面。\n\n【验收标准】\n- 页面打开第 1 帧即可看到 10 道光环等距均匀铺满隧道并匀速向前涌动，无接缝无闪白。\n- 全程零 JS 帧循环，纯合成器运行。\n- 开启减弱动效后彻底静止。\n\n【禁止做法】\n- 别写正的 `animation-delay` —— 开局前几秒会看到隧道是空的。\n- 别给每道环写不同的 `animation-duration` —— 几秒后环距会彻底乱掉撞在一起。\n- 别让 `100%` 关键帧保持 `opacity: 1` —— 环贴到镜头上会爆闪。",
        "prompt_en": "Core Principle:\nZero-WebGL / zero-JS-loop pure CSS negative-delay phase-staggered Infinite 3D Tunnel. N rings share a single `3.6s` keyframe flying from `translateZ(-900px)` to `translateZ(180px)`, using negative `animation-delay: calc(var(--i) * -0.36s)` so the entire tunnel is evenly populated from frame 0.\n\nImplementation:\n1. Structure: `.tunnel-stage` (`perspective: 420px; overflow: hidden; display: grid; place-items: center`) > `.tunnel` (`transform-style: preserve-3d`) > 10 `.tunnel-ring` elements (`--i: 0..9`).\n2. CSS keyframes:\n   ```css\n   @keyframes tunnel-fly {\n     0%   { transform: translateZ(-900px) scale(0.75); opacity: 0; }\n     18%  { opacity: 0.75; }\n     85%  { opacity: 0.85; }\n     100% { transform: translateZ(180px) scale(1.1); opacity: 0; }\n   }\n   .tunnel-ring {\n     position: absolute; width: 140px; height: 140px; border-radius: 24px;\n     border: 1.5px solid rgba(184,255,61,0.55);\n     animation: tunnel-fly 3.6s linear infinite;\n     animation-delay: calc(var(--i, 0) * -0.36s);\n   }\n   ```\n3. Fallback: `@media (prefers-reduced-motion: reduce) { .tunnel-ring { animation: none; transform: none; opacity: 0.2; } }`.\n\nHard Constraints:\n- Must use negative `animation-delay` (`-period / ringCount`) so the tunnel is fully populated on frame 0 with no cold-start gap.\n- Both `0%` and `100%` endpoints must fade to `opacity: 0` so rings do not flash brightly as they pass the camera.\n- Never update ring positions in a JS `rAF` loop.\n- Under `prefers-reduced-motion: reduce`, stop animation and collapse flat.\n\nAcceptance Criteria:\n- On frame 1 after page load, all 10 rings are evenly spaced down the tunnel and flow continuously forward without seams or bright flashes.\n- Zero JS frame loop; runs purely on the compositor thread.\n- Completely static when reduced motion is enabled.",
        "dont_do_en": "- Do NOT use positive `animation-delay` values — the tunnel will look empty for the first several seconds.\n- Do NOT give each ring a different `animation-duration` — spacing will drift and rings will collide after a few seconds.\n- Do NOT leave `opacity: 1` on the `100%` keyframe — rings hitting the camera plane will cause a harsh flash.",
        "skill_rule_en": "# Infinite 3D Depth Tunnel (tunnel) · Cross-Platform Motion Spec\nNature: Direction | Layer: 3d | Platform: both\n\nCore Principle: Zero-WebGL / zero-JS-loop pure CSS negative-delay phase-staggered Infinite 3D Tunnel. N rings share a single `3.6s` keyframe flying from `translateZ(-900px)` to `translateZ(180px)`, using negative `animation-delay: calc(var(--i) * -0.36s)` so the entire tunnel is evenly populated from frame 0.\n\nHard Constraints:\n- Must use negative `animation-delay` (`-period / ringCount`) so the tunnel is fully populated on frame 0 with no cold-start gap.\n- Both `0%` and `100%` endpoints must fade to `opacity: 0` so rings do not flash brightly as they pass the camera.\n- Never update ring positions in a JS `rAF` loop.\n- Under `prefers-reduced-motion: reduce`, stop animation and collapse flat.\n\nAcceptance Criteria:\n- On frame 1 after page load, all 10 rings are evenly spaced down the tunnel and flow continuously forward without seams or bright flashes.\n- Zero JS frame loop; runs purely on the compositor thread.\n- Completely static when reduced motion is enabled.\n\nDo NOT Do:\n- Do NOT use positive `animation-delay` values — the tunnel will look empty for the first several seconds.\n- Do NOT give each ring a different `animation-duration` — spacing will drift and rings will collide after a few seconds.\n- Do NOT leave `opacity: 1` on the `100%` keyframe — rings hitting the camera plane will cause a harsh flash."
      }
    },
    {
      "id": "voice-wave",
      "name": "AI 语音对称频谱波",
      "name_en": "AI Symmetric Voice Waveform",
      "layer": "motion",
      "nature": "反馈",
      "platform": "both",
      "status": "shipped",
      "entry": "MK.voiceWave(el, { bars, state }) + .mk-vw",
      "source": "ChatGPT Voice / Siri 语音输入条（中心正弦包络加权双谐波 + 零音频依赖三态平滑能量过渡 + 仅动画 scaleY）",
      "source_en": "ChatGPT Voice / Siri waveform (center Hann envelope + dual harmonics + scaleY)",
      "file": "effects/voice-wave.md",
      "summary": "一排 9 根细圆角频谱柱通过中心加权正弦包络与双谐波叠加，仅以合成层 `scaleY` 实时律动；支持 `idle / listening / speaking` 三态（或实时麦克风音量 `0..1`）平滑升档，且滚出视口或切后台自动停帧。",
      "summary_en": "Nine center-weighted sine-envelope bars animated strictly via compositor scaleY across idle, listening, speaking, or live mic energy with offscreen/tab-hide halt.",
      "problem": "**AI 语音对话、实时转写或录音按钮如果只放一个静止麦克风图标，用户根本不知道麦克风有没有在收音；而每帧改柱子 `height` 会触发布局重排，用随机数乱跳又像坏掉的杂音条。** 用确定性中心包络函数驱动 `transform: scaleY()`，中间强、两边柔和收束，既优雅有机又全程零重排。",
      "origin": "| 取什么 | 丢什么 |\n|---|---|\n| 中心加权包络 `sin(π * (i + 0.5) / n)` + 反向传播双谐波，中央律动饱满、两侧自然收尖 | 每帧 `Math.random()` 乱抖（像白噪音而不是人声韵律） |\n| 只写单变量驱动 `transform: scaleY()`（`transform-origin: center`），全程 GPU 合成零重排 | 每帧改 `style.height` 导致 60fps 全行重排 |\n| 三态能量 `idle(0.18) / listening(0.58) / speaking(1.0)` 按 `0.1` 阻尼平滑逼近，且接受实时麦克风音量数字 | 状态切换时柱子瞬间猛跳抽风 |",
      "params": "| 参数 | 值 | 为什么是这个值 |\n|---|---|---|\n| 柱数与柱宽 | 默认 `9` 根 / 宽 `3.5px` / 间距 `4px` | 奇数根存在严格中轴峰值，整体宽度约 `64px`，正好嵌进语音胶囊按钮或聊天输入框 |\n| 最小高度下限 | `0.16`（约 `5–6px`） | 哪怕在最安静的 `idle` 态仍保留一排整齐的小胶囊点，不会彻底消失不见 |\n| 双谐波频率 | `sin(5.2t + 0.85i)` + `sin(3.1t - 1.15i)` | 两个互质频率反向行进，永不出现呆板的齐步上下或短周期机械重复 |\n| 节能与停帧 | `IntersectionObserver` + `visibilitychange` 双停帧 | 聊天气泡滚出屏幕或切到别的标签页时 CPU 归零 |",
      "implementation": "```\nsrc/core/ui-motion.js:211   VOICE_STATES / voiceBarHeight(...)  纯函数，对称包络双谐波高度（可单测）\nsrc/core/ui-motion.js:228   voiceWave(el, { bars, state })      rAF 驱动 --mk-vw-h + 离屏/后台双停帧\nstyles/motion.css:1508      .mk-vw / .mk-vw__bar                仅 transform: scaleY 合成层渲染\n```",
      "degradation": "**走 `motion` 层契约：减弱动效下冻结为单帧静态对称波形，切态时单次更新高度反映状态强弱。**\n\n`prefers-reduced-motion: reduce` 下不启动 rAF 循环，渲染静态一帧对称波形；调用 `.setState()` 时仅单次重绘以清晰区分待机/聆听/播报态。",
      "pitfalls": "**① 直接动画 `height` 而不是 `transform: scaleY()`。**\n一屏里哪怕只放 9 根柱子，每帧改 `height` 也会让父容器 60 次/秒重算布局；固定柱子 `height: 100%` 只缩放 `scaleY` 才是零成本合成层动画。\n\n**② `transform-origin` 忘设在 `center`（或只从底部长）。**\nAI 语音波形通常是居中对称双向伸缩（`transform-origin: center`），从底边单向长会更像普通柱状图。\n\n**③ 忘记在离屏和切后台时停 rAF。**\n聊天窗口滚走后如果后台语音条还在 60fps 狂跑，会持续消耗电量。\n\n---",
      "ai_assets": {
        "prompt": "实现零依赖的 AI 语音对称频谱波（AI Voice Waveform）。\n\n原理一句话：用中心正弦包络乘以双反向谐波的纯函数计算每根柱子 0.16..1.0 的比例高度，仅写入 CSS 变量驱动 transform: scaleY()，支持三态与实时音量平滑过渡，并自带离屏与切后台双停帧。\n\n做法：\n1. 纯函数 voiceBarHeight(index, count, time, energy = 0.5)：\n   - 中心包络 env = Math.sin(Math.PI * (index + 0.5) / count)；\n   - 双反向谐波 w = 0.5 + 0.32 * Math.sin(time * 5.2 + index * 0.85) + 0.18 * Math.sin(time * 3.1 - index * 1.15)；\n   - 返回 clamp(0.16 + env * clamp(energy, 0, 1) * clamp(w, 0, 1) * 0.84, 0.16, 1.0)。\n2. 零重排 CSS：\n   - 容器：display: inline-flex; align-items: center; gap: 4px; height: 36px;\n   - 每根柱子：width: 3.5px; height: 100%; border-radius: 999px; transform-origin: center; transform: scaleY(var(--vw-h, 0.2)); will-change: transform;\n3. 控制器与节能约束：\n   - 映射状态 { idle: 0.18, listening: 0.58, speaking: 1.0 }，也支持直接传入 0..1 实时麦克风音量；每帧 cur += (target - cur) * 0.1 平滑过渡能量值。\n   - 接 IntersectionObserver（离屏停 rAF）与 visibilitychange（切后台停 rAF）；prefers-reduced-motion: reduce 仅画单帧静态对称波形，切态时单次重绘；destroy() 取消 rAF 并解绑监听。\n\n硬要求：\n- 必须仅通过 transform: scaleY() 驱动柱高，严禁动画 height 或 margin。\n- 必须使用中心对称包络 + 双谐波，禁止 Math.random() 随机乱跳。\n- 必须包含离屏/后台双停帧与减弱动效静态单帧降级。\n\n验收：\n- 9 根圆角频谱柱以居中对称律动，中央振幅高、两端自然收束，无机械重复感。\n- 从 idle 切到 speaking 时振幅在约 0.4s 内平滑拉高，切回 idle 时轻柔落回点阵态。\n- 滚出视口、切后台或开启减弱动效时 rAF 自动停止；卸载后无内存泄漏。",
        "dont_do": "- 别每帧用 `Math.random()` 生成柱高 —— 画面像接触不良的杂音闪烁，毫无语音韵律感。\n- 别每帧修改 `el.style.height` —— 触发 60fps 持续回流重排。\n- 别让所有柱子等高齐步上下 —— 缺少中心正弦包络就失去了语音波形标志性的纺锤轮廓。",
        "skill_rule": "# AI 语音对称频谱波 (voice-wave) · 跨平台动效规范\n性质：反馈 ｜ 平台：both\n\n【核心原理】用中心正弦包络乘以双反向谐波的纯函数计算每根柱子 0.16..1.0 的比例高度，仅写入 CSS 变量驱动 transform: scaleY()，支持三态与实时音量平滑过渡，并自带离屏与切后台双停帧。\n\n【硬要求】\n- 必须仅通过 transform: scaleY() 驱动柱高，严禁动画 height 或 margin。\n- 必须使用中心对称包络 + 双谐波，禁止 Math.random() 随机乱跳。\n- 必须包含离屏/后台双停帧与减弱动效静态单帧降级。\n\n【验收标准】\n- 9 根圆角频谱柱以居中对称律动，中央振幅高、两端自然收束，无机械重复感。\n- 从 idle 切到 speaking 时振幅在约 0.4s 内平滑拉高，切回 idle 时轻柔落回点阵态。\n- 滚出视口、切后台或开启减弱动效时 rAF 自动停止；卸载后无内存泄漏。\n\n【禁止做法】\n- 别每帧用 `Math.random()` 生成柱高 —— 画面像接触不良的杂音闪烁，毫无语音韵律感。\n- 别每帧修改 `el.style.height` —— 触发 60fps 持续回流重排。\n- 别让所有柱子等高齐步上下 —— 缺少中心正弦包络就失去了语音波形标志性的纺锤轮廓。",
        "prompt_en": "Core Principle:\nZero-dependency AI symmetric voice spectrum waveform (AI Voice Waveform). A pure function multiplies a centered sine envelope by dual counter-propagating harmonics to compute each bar's normalized height in `0.16..1.0`, driving `transform: scaleY()` strictly via CSS custom properties, supporting smooth transitions across three states or live volume with automatic offscreen and background pausing.\n\nImplementation:\n1. Pure function `voiceBarHeight(index, count, time, energy = 0.5)`:\n   - Centered envelope: `env = Math.sin(Math.PI * (index + 0.5) / count)`;\n   - Dual counter-propagating harmonics: `w = 0.5 + 0.32 * Math.sin(time * 5.2 + index * 0.85) + 0.18 * Math.sin(time * 3.1 - index * 1.15)`;\n   - Return `clamp(0.16 + env * clamp(energy, 0, 1) * clamp(w, 0, 1) * 0.84, 0.16, 1.0)`.\n2. Zero-reflow CSS:\n   - Container: `display: inline-flex; align-items: center; gap: 4px; height: 36px;`.\n   - Each bar: `width: 3.5px; height: 100%; border-radius: 999px; transform-origin: center; transform: scaleY(var(--vw-h, 0.2)); will-change: transform;`.\n3. Controller & power-saving constraints:\n   - Map states `{ idle: 0.18, listening: 0.58, speaking: 1.0 }`, also accepting live `0..1` microphone volume directly; smooth energy each frame with `cur += (target - cur) * 0.1`.\n   - Attach `IntersectionObserver` (pause `rAF` offscreen) and `visibilitychange` (pause `rAF` in background); under `prefers-reduced-motion: reduce`, draw only a single static symmetric frame and redraw once on state change; `destroy()` cancels `rAF` and unbinds listeners.\n\nHard Constraints:\n- Must drive bar height strictly via `transform: scaleY()`; never animate `height` or `margin`.\n- Must use the centered symmetric envelope plus dual harmonics; `Math.random()` jitter is forbidden.\n- Must include offscreen/background dual pausing and single-frame static fallback under reduced motion.\n\nAcceptance Criteria:\n- 9 rounded spectrum bars pulse with centered symmetry—tall amplitude in the middle tapering naturally at both ends without mechanical repetition.\n- Switching from `idle` to `speaking` smoothly ramps amplitude up within `~0.4s`, and switching back to `idle` settles gently down to a dotted resting line.\n- `rAF` stops automatically when scrolled offscreen, backgrounded, or under reduced motion; zero memory leaks on unmount.",
        "dont_do_en": "- Do NOT generate bar heights with `Math.random()` every frame — it looks like loose-wire static noise with zero vocal rhythm.\n- Do NOT mutate `el.style.height` every frame — it forces continuous 60fps layout reflow.\n- Do NOT move all bars to equal heights in lockstep — without the centered sine envelope, the waveform loses its signature spindle silhouette.",
        "skill_rule_en": "# AI Symmetric Voice Waveform (voice-wave) · Cross-Platform Motion Spec\nNature: Feedback | Layer: motion | Platform: both\n\nCore Principle: Zero-dependency AI symmetric voice spectrum waveform (AI Voice Waveform). A pure function multiplies a centered sine envelope by dual counter-propagating harmonics to compute each bar's normalized height in `0.16..1.0`, driving `transform: scaleY()` strictly via CSS custom properties, supporting smooth transitions across three states or live volume with automatic offscreen and background pausing.\n\nHard Constraints:\n- Must drive bar height strictly via `transform: scaleY()`; never animate `height` or `margin`.\n- Must use the centered symmetric envelope plus dual harmonics; `Math.random()` jitter is forbidden.\n- Must include offscreen/background dual pausing and single-frame static fallback under reduced motion.\n\nAcceptance Criteria:\n- 9 rounded spectrum bars pulse with centered symmetry—tall amplitude in the middle tapering naturally at both ends without mechanical repetition.\n- Switching from `idle` to `speaking` smoothly ramps amplitude up within `~0.4s`, and switching back to `idle` settles gently down to a dotted resting line.\n- `rAF` stops automatically when scrolled offscreen, backgrounded, or under reduced motion; zero memory leaks on unmount.\n\nDo NOT Do:\n- Do NOT generate bar heights with `Math.random()` every frame — it looks like loose-wire static noise with zero vocal rhythm.\n- Do NOT mutate `el.style.height` every frame — it forces continuous 60fps layout reflow.\n- Do NOT move all bars to equal heights in lockstep — without the centered sine envelope, the waveform loses its signature spindle silhouette."
      }
    }
  ]
}
