{
  "$schema": "../../schema.json",
  "id": "end-card",
  "type": "recipe",
  "title": "End card",
  "summary": "The last 6 s of any piece: the wordmark arrives, one plain line, the action typed in, a hold.",
  "tags": [
    "recipe",
    "end-card",
    "sting",
    "cta"
  ],
  "version": "1.0.0",
  "license": "MIT",
  "params": [
    {
      "name": "line",
      "type": "string",
      "default": "",
      "description": "what the brand is; empty reads IDENTITY.md",
      "group": "main",
      "control": "text"
    },
    {
      "name": "action",
      "type": "string",
      "default": "npx skills add your/brand",
      "description": "URL, handle, date or command",
      "group": "main",
      "control": "text"
    },
    {
      "name": "background",
      "type": "string",
      "default": "",
      "description": "a background id from the registry; empty uses the brand's first",
      "group": "main",
      "control": "select"
    },
    {
      "name": "format",
      "type": "enum",
      "default": "1920x1080",
      "options": [
        "1920x1080",
        "1080x1920",
        "1080x1080"
      ],
      "description": "output size",
      "group": "main",
      "control": "segmented"
    }
  ],
  "install": {
    "kind": "scene"
  },
  "files": [
    {
      "path": "pieces/end-card/scene.html",
      "content": "<!doctype html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<title>end card</title>\n<!--\n  Recipe · end card (6 s). The last seconds of any piece, or a sting on its own.\n  Reveal 0–2 s (the wordmark arrives) · Line 2–3 s (what the brand is) · Action 3–5 s (typed) · Hold to the end.\n  Look, fonts, pace and sound come from /brand (serve from the project root). Edit CONFIG first.\n-->\n<style>\n  #stage { overflow: hidden; }\n  .abs { position: absolute; box-sizing: border-box; }\n  #mark { white-space: nowrap; }\n  #cur { display: inline-block; width: 0.55em; height: 1em; vertical-align: -0.15em; margin-left: 3px; }\n</style>\n</head>\n<body>\n<main id=\"stage\">\n  <div id=\"bg\" class=\"abs\" style=\"inset:0\"></div>\n  <div id=\"vig\" class=\"abs\" style=\"inset:0\"></div>\n  <div id=\"group\" class=\"abs\" style=\"inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center\">\n    <div id=\"mark\"></div><div id=\"line\"></div><div id=\"cmdrow\"><span id=\"cmd\"></span><span id=\"cur\"></span></div>\n  </div>\n</main>\n<script type=\"module\">\nimport { scene, progress, ease } from 'paper-motion';\nimport { wordRise, blurIn, typeOn, typingTimes, keySounds } from 'paper-motion/moves';\nimport { loadBrand } from 'paper-motion/brand';\n\nconst CONFIG = {\n  background: null,                 // a shader-set id (pamo add mesh-sage), or null for the brand's first entry\n  backgroundOpacity: 0.6,                 // the shader behind the type; 1 for a field with no words over it\n  line: null,                       // what the brand is, in plain words; null reads IDENTITY.md \"In one line\"\n  action: 'npx skills add your/brand', // a URL, a handle, a date or a command\n  format: [1920, 1080],             // 1920×1080, 1080×1920 or 1080×1080\n};\n\nconst B = await loadBrand();\nconst [W, H] = CONFIG.format, SHORT = Math.min(W, H);\nconst s = scene({ width: W, height: H, fps: 30, duration: 6, background: B.color('ground') });\nconst bgId = CONFIG.background ?? B.set.entries.find((e) => e.shader && !e.image)?.id;\nif (bgId) B.shader(s, '#bg', bgId);\ndocument.querySelector('#bg').style.opacity = CONFIG.backgroundOpacity;   // the material sits behind the type, never over it\ndocument.querySelector('#vig').style.background = 'radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 35%, rgba(0,0,0,0.55) 100%)';\n\nconst mark = B.style(document.querySelector('#mark'), 'display', { short: SHORT });\nconst line = B.style(document.querySelector('#line'), 'body', { short: SHORT, color: 'muted' });\nline.style.fontSize = `${SHORT * 0.03}px`;   // readable on a phone\nconst cmd = document.querySelector('#cmd'), cur = document.querySelector('#cur');\nObject.assign(document.querySelector('#cmdrow').style, { fontFamily: B.font('mono'), fontSize: `${SHORT * 0.024}px`, color: B.color('figure'), marginTop: `${SHORT * 0.05}px` });\nObject.assign(line.style, { marginTop: `${SHORT * 0.025}px` });\ncur.style.background = B.color('figure');\nmark.textContent = B.name;\nline.textContent = CONFIG.line ?? ((B.identity['In one line'] ?? '').split('\\n')[0] || '');\nawait document.fonts.ready;\nconst fit = (W * 0.84) / mark.scrollWidth;\nif (fit < 1) mark.style.fontSize = `${parseFloat(mark.style.fontSize) * fit}px`;\n\nconst times = typingTimes(CONFIG.action, { start: 3.0, cps: 18, seed: 3 });\ns.update((t) => {\n  wordRise(mark, t, { start: 0.3, each: B.pace.stagger, duration: 0.9 });\n  blurIn(line, t, { start: 2.0, duration: 0.8 });\n  typeOn(cmd, CONFIG.action, t, { times, cursor: cur });\n  document.querySelector('#cmdrow').style.opacity = t >= 2.9 ? 1 : 0;\n});\nB.cue(s, 'land', 0.3); B.cue(s, 'text', 2.0); keySounds(s, CONFIG.action, times, B.keys); B.sound(s);\nawait s.start();\n</script>\n</body>\n</html>\n"
    },
    {
      "path": "pieces/end-card/brief.md",
      "content": "# End card\n\nRecipe: end card (6 s), from paper-motion.app. The look, fonts, pace and sound come from `brand/`.\n\n## Before building\n- Agree the brief with the user: what the brand is in plain words, the one action at the end, the format.\n- Edit `CONFIG` at the top of scene.html: the copy, the background id, the format.\n- Swap the moves for the ones the user picked (`npx paper-motion add <id>`) and put real material where there is some.\n\n## Check and render\n- `npx paper-motion still pieces/end-card/scene.html --count 8` and look at the contact sheet.\n- `npx paper-motion render pieces/end-card/scene.html --motion-blur 5`\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.0"
  },
  "usage": "npx paper-motion add end-card --name my-piece\n# edit CONFIG in pieces/my-piece/scene.html, then:\nnpx paper-motion render pieces/my-piece/scene.html --motion-blur 5",
  "notes": [
    "Wired to the brand folder: needs brand/tokens.json (a palette and a font pair work: pamo add sage-night instrument) and, for the background, a shader-set entry (pamo add mesh-sage).",
    "Structure and timing only; the look always comes from the brand.",
    "Uses these moves from the engine: word-rise, blur-in, type-on."
  ],
  "related": [
    "word-rise",
    "blur-in",
    "type-on"
  ],
  "preview": {
    "video": "previews/end-card.webm",
    "poster": "previews/end-card.jpg",
    "values": {
      "line": "Brand videos, made by your coding agent.",
      "action": "npx skills add solanodz/paper-motion"
    }
  },
  "mood": [
    "minimal",
    "editorial"
  ],
  "duration": 6,
  "formats": [
    "16:9",
    "9:16",
    "1:1"
  ],
  "when": [
    "closing any piece",
    "a sting with the name and the action"
  ],
  "beats": [
    {
      "name": "Reveal",
      "from": 0,
      "to": 2,
      "what": "the wordmark arrives"
    },
    {
      "name": "Line",
      "from": 2,
      "to": 3,
      "what": "what the brand is, small"
    },
    {
      "name": "Action",
      "from": 3,
      "to": 5,
      "what": "a URL, a handle, a date, typed"
    },
    {
      "name": "Hold",
      "from": 5,
      "to": 6,
      "what": "everything still"
    }
  ]
}