{
  "$schema": "../../schema.json",
  "type": "recipe",
  "version": "1.0.0",
  "license": "MIT",
  "id": "three-things",
  "title": "Three things",
  "summary": "Three traits, features or reasons, each with its own mechanic: one rises, two pushes, three flips; a card with words and the brand's material (or a picture), then the close, in 22 s.",
  "tags": [
    "recipe",
    "three",
    "features",
    "reasons",
    "cards",
    "16:9",
    "9:16"
  ],
  "params": [
    {
      "name": "intro",
      "type": "string",
      "default": "Three things to know.",
      "description": "the line under the name",
      "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": "format",
      "type": "enum",
      "default": "1920x1080",
      "options": [
        "1920x1080",
        "1080x1920",
        "1080x1080"
      ],
      "description": "output size",
      "group": "main",
      "control": "segmented"
    },
    {
      "name": "thing1Label",
      "type": "string",
      "default": "01",
      "description": "the small label of thing 1",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "thing1Title",
      "type": "string",
      "default": "Fast",
      "description": "thing one",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "thing1Body",
      "type": "string",
      "default": "A real number, a real result.",
      "description": "what it means, in one line",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "thing1Image",
      "type": "string",
      "default": "",
      "description": "a picture for it (path); empty uses the brand's material",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "thing2Label",
      "type": "string",
      "default": "02",
      "description": "the small label of thing 2",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "thing2Title",
      "type": "string",
      "default": "Simple",
      "description": "thing two",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "thing2Body",
      "type": "string",
      "default": "What it replaces, in one line.",
      "description": "what it means",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "thing2Image",
      "type": "string",
      "default": "",
      "description": "a picture (path)",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "thing3Label",
      "type": "string",
      "default": "03",
      "description": "the small label of thing 3",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "thing3Title",
      "type": "string",
      "default": "Yours",
      "description": "thing three",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "thing3Body",
      "type": "string",
      "default": "Who it is for, and why now.",
      "description": "what it means",
      "group": "advanced",
      "control": "text"
    },
    {
      "name": "thing3Image",
      "type": "string",
      "default": "",
      "description": "a picture (path)",
      "group": "advanced",
      "control": "text"
    }
  ],
  "install": {
    "kind": "scene"
  },
  "files": [
    {
      "path": "pieces/three-things/scene.html",
      "content": "<!doctype html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<title>three-things</title>\n<!--\n  Recipe · three things (22 s). Three traits, features or reasons.\n  One idea: the three cards hang in a column in space, one under the other, each turned a little the other way.\n  The camera starts on the name above them, then DESCENDS the column, orbiting as it goes (yaw swings left, right,\n  left), so every card is met from its own angle and the previous one leaves above, out of focus. The close is the\n  camera coming to rest under the last card, straight.\n  Intro 0–2.5 s · One 2.5–8 s · Two 8–13.5 s · Three 13.5–19 s · Close 19–22 s.\n  Look, fonts, pace and sound come from /brand (serve from the project root). Edit CONFIG first; put real material\n  (a screenshot, a photo) in a card's `image` when there is some.\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  .card { box-sizing: border-box; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }\n  .card .words { display: flex; flex-direction: column; justify-content: center; text-align: left; }\n  .card .pic { position: relative; overflow: hidden; }\n  .card .pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }\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-intro\" class=\"place\"><div id=\"name\"></div><div id=\"intro\"></div></div>\n    <div id=\"p-close\" class=\"place\"><div id=\"mark\"></div><div id=\"action\"></div></div>\n  </div>\n</main>\n<script type=\"module\">\nimport { scene, progress, ease } from 'paper-motion';\nimport { wordRise, blurIn, popIn } from 'paper-motion/moves';\nimport { camera } from 'paper-motion/kit';\nimport { loadBrand } from 'paper-motion/brand';\n\nconst CONFIG = {\n  background: null,                      // a shader-set id, or null for the brand's first entry\n  backgroundOpacity: 0.5,\n  intro: 'Three things to know.',        // the line under the name; name what the brand is when the brand is new\n  things: [\n    { label: '01', title: 'Fast', body: 'A real number, a real result.', image: '' },\n    { label: '02', title: 'Simple', body: 'What it replaces, in one line.', image: '' },\n    { label: '03', title: 'Yours', body: 'Who it is for, and why now.', image: '' },\n  ],\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, tall = H > W;\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 column: one place per beat, a step of STEP down; the camera reads each from DIST in front\nconst STEP = SHORT * 1.15, DIST = SHORT * 0.7, K = 1 + DIST / (SHORT * 1.7);\nconst cam = camera($('stage'), $('world'), { perspective: SHORT * 1.7 });\nconst name = B.style($('name'), 'display', { short: SHORT * K }), intro = B.style($('intro'), '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' });\nintro.style.marginTop = action.style.marginTop = `${SHORT * 0.03}px`;\nname.textContent = mark.textContent = B.name; intro.textContent = CONFIG.intro; action.textContent = CONFIG.action;\nfor (const id of ['p-intro', 'p-close']) $(id).style.width = `${W * 0.9}px`;\nconst Y = (i) => i * STEP;\ncam.place($('p-intro'), { y: Y(0) });\nconst R = (B.tokens?.shape?.radius ?? 12) * (SHORT / 1080) * K;\nconst cw = (tall ? W * 0.84 : SHORT * 1.1) * K, ch = (tall ? H * 0.5 : cw * 0.52);\nconst cards = CONFIG.things.map((p, i) => {\n  const c = document.createElement('div');\n  c.className = 'card';\n  Object.assign(c.style, { width: `${cw}px`, height: `${ch}px`, borderRadius: `${R}px`, background: B.surface(), border: `1.5px solid ${B.color('muted')}55`, boxShadow: `0 ${SHORT * 0.03}px ${SHORT * 0.1}px rgba(0,0,0,0.5)`, gridTemplateColumns: tall ? '1fr' : '1fr 1fr', direction: i % 2 ? 'rtl' : 'ltr' });\n  c.innerHTML = `<div class=\"words\" style=\"direction:ltr;padding:${cw * 0.06}px\"><div data-part=\"label\"></div><div data-part=\"title\"></div><div data-part=\"body\"></div></div><div class=\"pic\" data-part=\"pic\"></div>`;\n  const [label, title, body] = [...c.querySelector('.words').children];\n  B.style(label, 'caption', { short: SHORT * K, color: 'muted' }).textContent = p.label;\n  B.style(title, 'display', { short: SHORT * K * 0.7, color: 'figure' }).textContent = p.title;\n  B.style(body, 'body', { short: SHORT * K, color: 'muted' }).textContent = p.body;\n  title.style.marginTop = `${SHORT * 0.02}px`; body.style.marginTop = `${SHORT * 0.02}px`;\n  Object.assign(body.style, { fontSize: `${SHORT * K * 0.03}px`, lineHeight: 1.35, maxWidth: '24ch' });\n  const pic = c.querySelector('.pic');\n  if (p.image) { const img = document.createElement('img'); img.src = p.image; pic.append(img); }\n  else { pic.style.background = i === 1 ? B.color('accent', '#E9E4D8') : B.color('ground'); if (bgId && i !== 1) B.shader(s, pic, bgId); }\n  if (tall) pic.style.display = 'none';\n  $('world').append(c);\n  // one under the other, each turned the other way and a touch nearer or farther\n  cam.place(c, { y: Y(1 + i), x: [-1, 1, -1][i] * SHORT * 0.05, z: [0, -SHORT * 0.08, SHORT * 0.04][i], yaw: [12, -14, 10][i], pitch: [-3, 2, -2][i] });\n  return c;\n});\ncam.place($('p-close'), { y: Y(4) });\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 descent: the camera swings around the column as it drops from card to card\nconst T = { one: 2.5, two: 8, three: 13.5, close: 19 };\nconst at = (i, extra = {}) => ({ y: Y(i), z: DIST, ...extra });\nconst path = [\n  [0, at(0, { x: 0, yaw: 0, pitch: 0 })],\n  [T.one - 0.5, at(0, { pitch: 3 })],\n  [T.one + 1.0, at(1, { x: -SHORT * 0.04, yaw: 14, pitch: -2 }), ease.inOutCubic],\n  [T.two - 0.6, at(1, { yaw: 17 })],\n  [T.two + 1.0, at(2, { x: SHORT * 0.05, z: DIST - SHORT * 0.08, yaw: -16, pitch: 2 }), ease.inOutCubic],\n  [T.three - 0.6, at(2, { z: DIST - SHORT * 0.08, yaw: -19 })],\n  [T.three + 1.0, at(3, { x: -SHORT * 0.04, z: DIST + SHORT * 0.04, yaw: 12, pitch: -2 }), ease.inOutCubic],\n  [T.close - 0.6, at(3, { z: DIST + SHORT * 0.04, yaw: 15 })],\n  [T.close + 1.1, at(4, { x: 0, yaw: 0, pitch: 0 }), ease.inOutQuart],\n  [D, at(4, { z: DIST * 0.92 }), ease.inOutSine],\n];\nconst words = cards.map((c) => [...c.querySelector('.words').children]);\ns.update((t) => {\n  cam.travel(t, path);\n  cam.focus(DIST, SHORT * 0.9, 10, { fade: SHORT * 0.62 });   // a column: places leave through the top and bottom edges, so they fade sooner\n  bg.style.transform = `scale(${1.08 + 0.08 * progress(t, 0, D)}) translateY(${-SHORT * 0.05 * progress(t, 0, D)}px)`;\n  wordRise(name, t, { start: 0.2, each: B.pace.stagger, duration: 0.9 });\n  blurIn(intro, t, { start: 0.9, duration: 0.9 });\n  // three ways in for three things: words rise, pop, rise again with a longer stagger\n  const starts = [T.one, T.two, T.three];\n  wordRise(words[0][1], t, { start: starts[0], each: B.pace.stagger, duration: 0.8 }); blurIn(words[0][2], t, { start: starts[0] + 0.5, duration: 0.7 });\n  popIn(words[1][1], t, { start: starts[1] }); blurIn(words[1][2], t, { start: starts[1] + 0.5, duration: 0.7 });\n  wordRise(words[2][1], t, { start: starts[2], each: B.pace.stagger * 2, duration: 1.0 }); blurIn(words[2][2], t, { start: starts[2] + 0.6, duration: 0.7 });\n  wordRise(mark, t, { start: T.close - 0.1, each: B.pace.stagger, duration: 0.9 });\n  blurIn(action, t, { start: T.close + 0.7, duration: 0.8 });\n});\nB.cue(s, 'land', 0.2); B.cue(s, 'transition', T.one); B.cue(s, 'land', T.one + 0.6); B.cue(s, 'transition', T.two); B.cue(s, 'land', T.two + 0.6);\nB.cue(s, 'transition', T.three); B.cue(s, 'land', T.three + 0.6); B.cue(s, 'transition', T.close); B.cue(s, 'land', T.close + 0.8);\nB.sound(s);\nawait s.start();\n</script>\n</body>\n</html>\n"
    },
    {
      "path": "pieces/three-things/brief.md",
      "content": "# Three things\n\nRecipe: three-things (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: the three things (traits, features, reasons), one line each, and what is real to\n  show beside them (a screenshot, a photo). What the brand is goes in the intro line when the brand is new.\n- Edit `CONFIG`: `intro`, the three `things` (title, body, image), `action`, the background id, the format.\n- Three mechanics for three things: swap rise / push / flip for the moves the user picked (`npx paper-motion add <id>`).\n\n## Check and render\n- `npx paper-motion still pieces/three-things/scene.html --count 8` and look at the contact sheet.\n- `npx paper-motion render pieces/three-things/scene.html --motion-blur 5`\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.1"
  },
  "usage": "npx paper-motion add three-things --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).",
    "Three mechanics for three things (rise, push, flip): swap any of them for the moves the user chose.",
    "Uses these moves from the engine: word-rise, pop-in, blur-in, push, flip-3d, crossfade."
  ],
  "related": [
    "push",
    "flip-3d",
    "launch"
  ],
  "preview": {
    "video": "previews/three-things.webm",
    "poster": "previews/three-things.jpg",
    "at": 6,
    "values": {
      "intro": "Three things to know.",
      "thing1Title": "Named",
      "thing1Body": "Resources your agent picks by name.",
      "thing2Title": "Yours",
      "thing2Body": "Installed as code you own.",
      "thing3Title": "Exact",
      "thing3Body": "Every frame rendered. Same pixels every time.",
      "action": "paper-motion.app"
    }
  },
  "mood": [
    "technical",
    "editorial",
    "calm"
  ],
  "duration": 22,
  "formats": [
    "16:9",
    "9:16",
    "1:1"
  ],
  "beats": [
    {
      "name": "Intro",
      "from": 0,
      "to": 2.5,
      "what": "the name and the line"
    },
    {
      "name": "One",
      "from": 2.5,
      "to": 8,
      "what": "the card rises in, its words follow"
    },
    {
      "name": "Two",
      "from": 8,
      "to": 13.5,
      "what": "pushes the first up"
    },
    {
      "name": "Three",
      "from": 13.5,
      "to": 19,
      "what": "flips in"
    },
    {
      "name": "Close",
      "from": 19,
      "to": 22,
      "what": "the wordmark and the action"
    }
  ],
  "when": [
    "three reasons, features or values",
    "a product page in motion"
  ]
}