{
  "$schema": "../../schema.json",
  "id": "product-demo",
  "type": "recipe",
  "title": "Product demo",
  "summary": "The real product, seen: three screenshots in one window under one camera (drift, punch, snap-scroll, whip), a caption each, in 22 s.",
  "tags": [
    "recipe",
    "product",
    "demo",
    "ui",
    "screenshots",
    "16:9"
  ],
  "version": "1.0.0",
  "license": "MIT",
  "params": [
    {
      "name": "what",
      "type": "string",
      "default": "",
      "description": "what the brand is, in plain words; empty reads IDENTITY.md",
      "group": "main",
      "control": "text"
    },
    {
      "name": "action",
      "type": "string",
      "default": "your.site",
      "description": "the one action at the end",
      "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": "chrome",
      "type": "enum",
      "default": "browser",
      "options": [
        "browser",
        "none"
      ],
      "description": "the window's frame",
      "group": "main",
      "control": "segmented"
    },
    {
      "name": "format",
      "type": "enum",
      "default": "1920x1080",
      "options": [
        "1920x1080",
        "1080x1920",
        "1080x1080"
      ],
      "description": "output size",
      "group": "main",
      "control": "segmented"
    },
    {
      "name": "shot1Image",
      "type": "string",
      "default": "",
      "description": "screenshot 1 (path); empty draws a placeholder UI",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "shot1Caption",
      "type": "string",
      "default": "The overview: everything in one place.",
      "description": "what screen 1 proves",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "shot2Image",
      "type": "string",
      "default": "",
      "description": "screenshot 2 (path)",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "shot2Caption",
      "type": "string",
      "default": "One click to the detail that matters.",
      "description": "what screen 2 proves",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "shot3Image",
      "type": "string",
      "default": "",
      "description": "screenshot 3 (path)",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "shot3Caption",
      "type": "string",
      "default": "Numbers you can act on, as they change.",
      "description": "what screen 3 proves",
      "group": "advanced",
      "control": "text"
    }
  ],
  "install": {
    "kind": "scene"
  },
  "files": [
    {
      "path": "pieces/product-demo/scene.html",
      "content": "<!doctype html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<title>product-demo</title>\n<!--\n  Recipe · product demo (22 s). The real product, seen: three screens of its UI under one camera.\n  One idea: the window is an object in space and the camera is a real camera. It arrives from the name, at an angle\n  (the screen tilted in perspective), straightens as the first screen settles, PUNCHES IN to the detail each caption\n  points at (`focus`), pulls back and swings a few degrees for each new screen, and leaves toward the close. Inside\n  the window the screens still snap-scroll and whip from one to the next.\n  What 0–3 s · Shots 3–19 s · Close 19–22 s.\n  Look, fonts, pace and sound come from /brand (serve from the project root). Edit CONFIG first: put the real\n  screenshots in (paths relative to this file, or under brand/assets/); with no image a shot draws a placeholder UI in\n  the brand's colors, so the structure can be judged before the material exists.\n-->\n<style>\n  #stage { overflow: hidden; }\n  .abs { position: absolute; box-sizing: border-box; }\n  .place { display: flex; flex-direction: column; align-items: center; text-align: center; box-sizing: border-box; }\n  .shot { position: absolute; inset: 0; overflow: hidden; box-sizing: border-box; }\n  .shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top left; display: block; }\n  .mock { position: absolute; inset: 0; display: grid; grid-template-columns: 22% 1fr; }\n  .mock .side { display: flex; flex-direction: column; gap: 6%; padding: 7% 14%; }\n  .mock .side i, .mock .row i { display: block; height: 0.55em; border-radius: 999px; opacity: 0.45; }\n  .mock .main { display: flex; flex-direction: column; gap: 4%; padding: 5%; }\n  .mock .row { display: grid; gap: 3%; }\n  .mock .box { border-radius: 0.6em; }\n  .chrome { position: absolute; left: 0; right: 0; top: 0; display: flex; gap: 0.6em; align-items: center; padding: 0 1.2em; }\n  .chrome b { width: 0.9em; height: 0.9em; border-radius: 50%; opacity: 0.35; }\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=\"world\">\n    <div id=\"p-what\" class=\"place\"><div id=\"name\"></div><div id=\"what\"></div></div>\n    <div id=\"window\"><div id=\"chrome\" class=\"chrome\"></div><div id=\"screen\" class=\"abs\"></div></div>\n    <div id=\"p-close\" class=\"place\"><div id=\"mark\"></div><div id=\"action\"></div></div>\n  </div>\n  <div id=\"caption\" class=\"abs\"></div>\n</main>\n<script type=\"module\">\nimport { scene, progress, ease, noise } from 'paper-motion';\nimport { wordRise, blurIn, snapScroll, whipPan } from 'paper-motion/moves';\nimport { camera } from 'paper-motion/kit';\nimport { loadBrand } from 'paper-motion/brand';\n\nconst CONFIG = {\n  background: null,                      // a calm shader-set id, or null for the brand's first entry\n  backgroundOpacity: 0.5,                // the shader behind the window; the product is the picture\n  what: '',                              // what the brand is, in plain words; empty reads IDENTITY.md's \"In one line\"\n  shots: [\n    { image: '', caption: 'The overview: everything in one place.', focus: [0.3, 0.35] },\n    { image: '', caption: 'One click to the detail that matters.', focus: [0.6, 0.5] },\n    { image: '', caption: 'Numbers you can act on, as they change.', focus: [0.5, 0.6] },\n  ],\n  chrome: 'browser',                     // 'browser' (three dots), 'none'\n  action: 'your.site',\n  format: [1920, 1080],\n};\n\nconst B = await loadBrand();\nconst [W, H] = CONFIG.format, SHORT = Math.min(W, H), D = 22;\nconst s = scene({ width: W, height: H, fps: 30, duration: D, 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);\nconst bg = document.querySelector('#bg'); bg.style.opacity = CONFIG.backgroundOpacity;\ndocument.querySelector('#vig').style.background = 'radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 30%, rgba(0,0,0,0.6) 100%)';\nconst $ = (id) => document.getElementById(id);\n\n// the stage in space: the words to the left, the window in the middle, the close to the right\nconst STEP = W * 1.15, DIST = SHORT * 0.6, K = 1 + DIST / (SHORT * 1.7);   // STEP: past the edge of the frame at this distance\nconst cam = camera($('stage'), $('world'), { perspective: SHORT * 1.7 });\nconst name = B.style($('name'), 'display', { short: SHORT * K }), what = B.style($('what'), 'title', { short: SHORT * K, color: 'muted' });\nconst mark = B.style($('mark'), 'display', { short: SHORT * K }), action = B.style($('action'), 'body', { short: SHORT * K, color: 'figure' });\nObject.assign(action.style, { fontFamily: B.font('mono'), fontSize: `${SHORT * K * 0.028}px`, letterSpacing: '0em' });\nwhat.style.marginTop = action.style.marginTop = `${SHORT * 0.03}px`;\nname.textContent = mark.textContent = B.name;\nwhat.textContent = CONFIG.what || ((B.identity['In one line'] ?? '').split('\\n')[0] || '');\naction.textContent = CONFIG.action;\nfor (const id of ['p-what', 'p-close']) $(id).style.width = `${W * 0.9}px`;\ncam.place($('p-what'), { x: -STEP, yaw: 10 });\ncam.place($('p-close'), { x: STEP, yaw: -10 });\n\n// the window: one object, three screens inside it\nconst R = (B.tokens?.shape?.radius ?? 12) * (SHORT / 1080) * K;\nconst win = $('window'), ww = W * 0.72 * K, chromeH = CONFIG.chrome === 'none' ? 0 : SHORT * 0.036 * K, wh = ww * 0.58 + chromeH;\nObject.assign(win.style, { width: `${ww}px`, height: `${wh}px`, borderRadius: `${R}px`, overflow: 'hidden', background: B.surface(), border: `1.5px solid ${B.color('muted')}55`, boxShadow: `0 ${SHORT * 0.04}px ${SHORT * 0.12}px rgba(0,0,0,0.5)` });\ncam.place(win, { x: 0, y: -SHORT * 0.02 * K });\nconst chrome = $('chrome');\nObject.assign(chrome.style, { height: `${chromeH}px`, fontSize: `${chromeH * 0.42}px`, background: B.color('ground') });\nif (chromeH) chrome.innerHTML = `<b style=\"background:${B.color('muted')}\"></b><b style=\"background:${B.color('muted')}\"></b><b style=\"background:${B.color('muted')}\"></b>`;\nObject.assign($('screen').style, { left: 0, right: 0, top: `${chromeH}px`, bottom: 0 });\n\nfunction mock(i, host) {\n  // a placeholder UI in the brand's colors, one layout per shot: a list, a detail, a chart\n  const m = document.createElement('div');\n  m.className = 'mock';\n  m.style.fontSize = `${ww * 0.012}px`;\n  const line = (w, c = B.color('muted')) => `<i style=\"width:${w}%;background:${c}\"></i>`;\n  const box = (h, c = B.color('ground')) => `<div class=\"box\" style=\"height:${h}px;background:${c};border:1px solid ${B.color('muted')}33\"></div>`;\n  const side = `<div class=\"side\" style=\"background:${B.color('ground')}\">${line(60, B.color('figure'))}${line(80)}${line(55)}${line(70)}${line(40)}</div>`;\n  const bodyH = (wh - chromeH) * 0.9;\n  const layouts = [\n    `<div class=\"main\">${line(28, B.color('figure'))}<div class=\"row\" style=\"grid-template-columns:1fr 1fr 1fr\">${box(bodyH * 0.22)}${box(bodyH * 0.22)}${box(bodyH * 0.22, B.color('accent'))}</div>${box(bodyH * 0.42)}</div>`,\n    `<div class=\"main\">${line(40, B.color('figure'))}<div class=\"row\" style=\"grid-template-columns:1.4fr 1fr\">${box(bodyH * 0.66)}<div class=\"row\" style=\"grid-template-rows:1fr 1fr\">${box(bodyH * 0.3, B.color('accent'))}${box(bodyH * 0.3)}</div></div></div>`,\n    `<div class=\"main\">${line(34, B.color('figure'))}<div class=\"row\" style=\"grid-template-columns:repeat(12,1fr);align-items:end;height:${bodyH * 0.6}px\">${Array.from({ length: 12 }, (_, k) => `<div class=\"box\" data-bar=\"${k}\" style=\"height:${30 + 60 * noise(k * 0.7, i)}%;background:${k === 8 ? B.color('accent') : B.color('muted')}\"></div>`).join('')}</div>${line(50)}</div>`,\n  ];\n  m.innerHTML = side + layouts[i % layouts.length];\n  host.append(m);\n  return m;\n}\nconst shots = CONFIG.shots.map((sh, i) => {\n  const el = document.createElement('div');\n  el.className = 'shot';\n  el.style.background = B.surface();\n  if (sh.image) { const img = document.createElement('img'); img.src = sh.image; el.append(img); } else mock(i, el);\n  $('screen').append(el);\n  return el;\n});\nconst caption = B.style($('caption'), 'body', { short: SHORT, color: 'figure' });\nObject.assign(caption.style, { left: `${W * 0.1}px`, right: `${W * 0.1}px`, bottom: `${H * 0.07}px`, textAlign: 'center', fontSize: `${SHORT * 0.036}px`, lineHeight: 1.3, textShadow: '0 2px 18px rgba(0,0,0,0.8)' });\nawait document.fonts.ready;\nfor (const el of [name, mark]) { el.style.whiteSpace = 'nowrap'; const k = (W * 0.84) / el.scrollWidth; if (k < 1) el.style.fontSize = `${parseFloat(el.style.fontSize) * k}px`; }\n\n// the camera: arrives at an angle, straightens, punches into each focus, swings for each new screen, leaves right\nconst T = { win: 2.4, punch1: 5.4, swap1: [8.6, 9.8], punch2: 11.6, swap2: [14.4, 15.3], punch3: 17.0, close: 18.8 };\nconst focusAt = (i, depth) => { const [fx, fy] = CONFIG.shots[i].focus ?? [0.5, 0.5]; return { x: (fx - 0.5) * ww * 0.7, y: (fy - 0.5) * (wh - chromeH) * 0.7 + chromeH / 2 - SHORT * 0.02 * K, z: DIST * depth }; };\nconst front = { x: 0, y: -SHORT * 0.02 * K, z: DIST };\nconst path = [\n  [0, { x: -STEP, y: 0, z: DIST, yaw: 6, pitch: 0 }],\n  [T.win - 0.6, { x: -STEP, yaw: 8 }],\n  [T.win + 1.1, { ...front, x: -SHORT * 0.06, z: DIST * 1.25, yaw: 22, pitch: 5 }, ease.inOutCubic],   // the screen, tilted\n  [T.win + 2.3, { ...front, yaw: 0, pitch: 0 }, ease.outCubic],                                        // it straightens\n  [T.punch1 + 0.9, focusAt(0, 0.55), ease.inOutQuart],                                               // punch in\n  [T.swap1[0], focusAt(0, 0.55)],\n  [T.swap1[1], { ...front, z: DIST * 1.1, yaw: -9, pitch: -2 }, ease.inOutCubic],                      // back and a swing\n  [T.swap1[1] + 0.8, { ...front, yaw: 0, pitch: 0 }, ease.outCubic],\n  [T.punch2 + 0.9, focusAt(1, 0.5), ease.inOutQuart],\n  [T.swap2[0], focusAt(1, 0.5)],\n  [T.swap2[1], { ...front, z: DIST * 1.1, yaw: 9, pitch: 2 }, ease.inOutCubic],\n  [T.swap2[1] + 0.8, { ...front, yaw: 0, pitch: 0 }, ease.outCubic],\n  [T.punch3 + 0.9, focusAt(2, 0.55), ease.inOutQuart],\n  [T.close - 0.2, focusAt(2, 0.55)],\n  [T.close + 1.2, { x: STEP, y: 0, z: DIST, yaw: -4, pitch: 0 }, ease.inOutQuart],                  // leave toward the close\n  [D, { x: STEP, z: DIST * 0.92, yaw: 0 }, ease.inOutSine],\n];\nconst RESET = ['transform', 'opacity', 'filter', 'clipPath', 'zIndex'];\nconst clean = (els) => els.forEach((e) => RESET.forEach((k) => { e.style[k] = ''; }));\nconst captionAt = (t) => (t < T.swap1[0] + 0.5 ? 0 : t < T.swap2[0] + 0.4 ? 1 : 2);\nlet shown = -1;\ns.update((t) => {\n  cam.travel(t, path);\n  cam.focus(cam.pos.z, SHORT * 1.2, 8, { fade: SHORT * 1.6 });   // wide presence: the words and the window overlap while the camera travels          // the window stays sharp wherever the camera is; the far words soften\n  bg.style.transform = `scale(${1.1 + 0.06 * progress(t, 0, D)}) translateX(${-SHORT * 0.06 * progress(t, 0, D)}px)`;\n  // inside the screen: the screens change under the camera\n  if (t >= T.swap1[1]) snapScroll(shots[0], shots[1], 1, { duration: 1.2 });\n  if (t >= T.swap2[1]) whipPan(shots[1], shots[2], 1, { duration: 0.9 });\n  clean(shots);\n  shots.forEach((c, i) => { c.style.opacity = 0; c.style.zIndex = i + 1; });\n  if (t < T.swap1[0]) shots[0].style.opacity = 1;\n  else if (t < T.swap1[1]) snapScroll(shots[0], shots[1], progress(t, ...T.swap1), { duration: 1.2 });\n  else if (t < T.swap2[0]) shots[1].style.opacity = 1;\n  else if (t < T.swap2[1]) whipPan(shots[1], shots[2], progress(t, ...T.swap2), { duration: 0.9 });\n  else shots[2].style.opacity = 1;\n  // the words\n  wordRise(name, t, { start: 0.2, each: B.pace.stagger, duration: 0.9 });\n  blurIn(what, t, { start: 0.9, duration: 0.9 });\n  const c = captionAt(t);\n  if (c !== shown) { caption.textContent = CONFIG.shots[c]?.caption ?? ''; shown = c; }\n  const starts = [T.win + 1.6, T.swap1[1] + 0.3, T.swap2[1] + 0.3], outAt = [T.swap1[0], T.swap2[0], T.close][c];\n  blurIn(caption, t, { start: starts[c], duration: 0.7 });\n  const out = progress(t, outAt - 0.35, outAt);\n  if (out > 0) caption.style.opacity = String((1 - out) * Number(caption.style.opacity || 1));\n  wordRise(mark, t, { start: T.close + 0.1, each: B.pace.stagger, duration: 0.9 });\n  blurIn(action, t, { start: T.close + 0.8, duration: 0.8 });\n});\nB.cue(s, 'land', 0.2); B.cue(s, 'transition', T.win); B.cue(s, 'land', T.win + 2.3);\nfor (const h of [T.punch1, T.punch2, T.punch3]) B.cue(s, 'text', h + 0.9);\nB.cue(s, 'transition', T.swap1[0]); B.cue(s, 'transition', T.swap2[0]); B.cue(s, 'transition', T.close); B.cue(s, 'land', T.close + 1.2);\nB.sound(s);\nawait s.start();\n</script>\n</body>\n</html>\n"
    },
    {
      "path": "pieces/product-demo/brief.md",
      "content": "# Product demo\n\nRecipe: product-demo (22 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 three screens worth showing and what each\n  proves, the one action at the end, the format.\n- Get the real screenshots (PNG or JPG, the window's aspect is 1.72:1; wider or taller crops are covered from the top\n  left). Put them next to this file or under `brand/assets/`, and write their paths into `CONFIG.shots[].image`.\n  Set each shot's `focus` to the detail the camera should punch into (0–1 across, 0–1 down).\n- Edit the rest of `CONFIG`: the captions, the background id, the chrome, the action.\n\n## Check and render\n- `npx paper-motion still pieces/product-demo/scene.html --count 8` and look at the contact sheet: is every caption\n  readable, does each punch land on something worth seeing?\n- `npx paper-motion render pieces/product-demo/scene.html --motion-blur 5`\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.1"
  },
  "usage": "npx paper-motion add product-demo --name my-piece\n# put the screenshots in, 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).",
    "Made for real screenshots: without them each shot draws a placeholder UI in the brand's colors, so the structure can be judged first.",
    "Uses these moves from the engine: mask-reveal, drift, punch, snap-scroll, whip-pan, flash, word-rise, blur-in."
  ],
  "related": [
    "snap-scroll",
    "whip-pan",
    "punch",
    "launch"
  ],
  "preview": {
    "video": "previews/product-demo.webm",
    "poster": "previews/product-demo.jpg",
    "at": 5,
    "values": {
      "what": "Brand videos, made by your coding agent.",
      "shot1Caption": "The library: every resource has a name.",
      "shot2Caption": "A board: your agent proposes, you choose.",
      "shot3Caption": "The kit: every choice adds up.",
      "action": "paper-motion.app"
    }
  },
  "mood": [
    "technical",
    "minimal",
    "editorial"
  ],
  "duration": 22,
  "formats": [
    "16:9",
    "9:16",
    "1:1"
  ],
  "when": [
    "you have real UI to show",
    "a feature tour, a changelog video, an app store preview"
  ],
  "beats": [
    {
      "name": "What",
      "from": 0,
      "to": 2.6,
      "what": "the name and what it is"
    },
    {
      "name": "Shots",
      "from": 3.4,
      "to": 18.8,
      "what": "three screenshots in one window: drift, punch, snap-scroll, whip"
    },
    {
      "name": "Close",
      "from": 19.3,
      "to": 22,
      "what": "the wordmark and the action"
    }
  ]
}