{
  "$schema": "../../schema.json",
  "version": "1.0.0",
  "license": "MIT",
  "id": "light-sweep",
  "type": "block",
  "title": "Light sweep",
  "summary": "A card turns in the light and a diagonal glint crosses its face in step with the turn, its edge catching a thin line.",
  "tags": [
    "block",
    "effect",
    "glint",
    "shine",
    "card",
    "reflection"
  ],
  "params": [
    {
      "name": "background",
      "type": "string",
      "default": "",
      "description": "a background id from the registry; empty uses the brand's first",
      "group": "advanced",
      "control": "select"
    },
    {
      "name": "title",
      "type": "string",
      "default": "",
      "description": "empty takes the brand's name",
      "group": "main",
      "control": "text"
    },
    {
      "name": "line",
      "type": "string",
      "default": "Release 0.2.6",
      "description": "line",
      "group": "main",
      "control": "text"
    },
    {
      "name": "corner",
      "type": "string",
      "default": "paper-motion.app",
      "description": "corner",
      "group": "main",
      "control": "text"
    },
    {
      "name": "format",
      "type": "enum",
      "default": "1920x1080",
      "options": [
        "1920x1080",
        "1080x1920",
        "1080x1080"
      ],
      "description": "output size; the layout recomposes for each",
      "group": "main",
      "control": "segmented"
    }
  ],
  "install": {
    "kind": "scene"
  },
  "files": [
    {
      "path": "pieces/light-sweep/scene.html",
      "content": "<!doctype html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<title>light-sweep</title>\n<!--\n  Effect · light sweep (4.6 s). A card turns in the light: as it rotates, a diagonal glint crosses its face in step with\n  the turn, its edge catches a thin line of light, and the shadow under it slides the other way. A second, fainter glint\n  follows. Works on any surface: a card, a logo, a product shot.\n  Turn 0.2–3.2 s · Glint 0.9–2.3 s · Second glint 2.2–3.2 s · Hold to 4.6 s.\n  Square: a narrower, taller card. Vertical: a portrait card, the title set big (wraps if it must), the bottom line stacked.\n-->\n<style>\n  #stage { overflow: hidden; }\n  .abs { position: absolute; box-sizing: border-box; }\n  #card { position: absolute; overflow: hidden; box-sizing: border-box; display: flex; flex-direction: column; justify-content: space-between; }\n  .glint { position: absolute; inset: -50%; pointer-events: none; mix-blend-mode: screen; }\n  #rim { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; }\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\"><div id=\"shadow\"></div><div id=\"card\"><div id=\"top\"></div><div id=\"bot\"></div><div id=\"g1\" class=\"glint\"></div><div id=\"g2\" class=\"glint\"></div><div id=\"rim\"></div></div></div>\n</main>\n<script type=\"module\">\nimport { scene, progress, ease } from 'paper-motion';\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  title: '',                             // empty takes the brand's name\n  line: 'Release 0.2.6',\n  corner: 'paper-motion.app',\n  format: [1920, 1080],\n};\n\nconst B = await loadBrand();\nconst [W, H] = CONFIG.format, SHORT = Math.min(W, H), D = 4.6;\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 $ = (id) => document.getElementById(id);\n$('bg').style.opacity = 0.35;\n$('vig').style.background = 'radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 30%, rgba(0,0,0,0.7) 100%)';\n\nconst DIST = SHORT * 0.62, K = 1 + DIST / (SHORT * 1.7);\nconst cam = camera($('stage'), $('world'), { perspective: SHORT * 1.7 });\nconst muted = B.color('muted'), figure = '#F2EFE8';   // the card is always dark metal, so its type is always light, whatever the brand's mode\n// 16:9 a wide card; square a narrower, taller one; vertical a portrait card whose title is set big and may wrap\nconst tall = H > W, square = W === H;\nconst card = $('card'), cw = (tall ? W * 0.72 : square ? W * 0.72 : SHORT * 1.05) * K, ch = cw * (tall ? 1.45 : square ? 0.75 : 0.62), R = cw * 0.05;\nObject.assign(card.style, { width: `${cw}px`, height: `${ch}px`, borderRadius: `${R}px`, padding: `${cw * 0.06}px`, background: 'linear-gradient(140deg, #232323 0%, #0c0c0c 55%, #1a1a1a 100%)', border: '1px solid #ffffff22' });\nconst top = B.style($('top'), 'display', { short: SHORT * K, color: 'figure' }); top.style.color = figure; top.textContent = CONFIG.title || B.name; top.style.fontSize = `${tall ? cw * 0.2 : square ? cw * 0.13 : ch * 0.17}px`; if (tall) Object.assign(top.style, { overflowWrap: 'break-word', lineHeight: 1 });\n$('bot').innerHTML = `<div style=\"display:flex;justify-content:space-between;${tall ? 'flex-direction:column;gap:0.5em' : 'align-items:flex-end'};font:400 ${tall ? cw * 0.058 : square ? cw * 0.042 : ch * 0.055}px ${B.font('mono')};color:${muted}\"><span style=\"color:${figure}\">${CONFIG.line}</span><span>${CONFIG.corner}</span></div>`;\nconst shadow = $('shadow');\nObject.assign(shadow.style, { position: 'absolute', width: `${cw * 0.9}px`, height: `${ch * 0.25}px`, borderRadius: '50%', background: 'radial-gradient(ellipse, rgba(0,0,0,0.75), transparent 70%)', filter: `blur(${SHORT * 0.02}px)` });\nconst g1 = $('g1'), g2 = $('g2');\ng1.style.background = 'linear-gradient(115deg, transparent 42%, rgba(255,255,255,0.05) 46%, rgba(255,255,255,0.32) 50%, rgba(255,255,255,0.05) 54%, transparent 58%)';\ng2.style.background = 'linear-gradient(115deg, transparent 46%, rgba(255,255,255,0.12) 50%, transparent 54%)';\ncam.place(card, { x: 0, y: 0, z: 0 });\ncam.place(shadow, { x: 0, y: ch * 0.62, z: -SHORT * 0.05, pitch: 80 });\nawait document.fonts.ready;\n// a title too long for the card shrinks until it fits\nfor (let i = 0; i < 40 && (top.scrollWidth > cw * 0.88 + 1 || top.scrollHeight > ch * 0.6); i++) top.style.fontSize = `${parseFloat(top.style.fontSize) * 0.95}px`;\n\nconst T = { turn: [0.2, 3.2], g1: [0.9, 2.3], g2: [2.2, 3.2] };\ns.update((t) => {\n  const p = progress(t, ...T.turn, ease.inOutCubic);\n  const yaw = -30 + 42 * p, pitch = 8 - 10 * p;                     // the card turns through the light\n  cam.place(card, { x: 0, y: -ch * 0.04, z: 0, yaw, pitch, roll: -2 + 3 * p });\n  cam.place(shadow, { x: -yaw * cw * 0.004, y: ch * 0.6, z: -SHORT * 0.05, pitch: 80 });\n  // the glints cross the face in step with the turn\n  const a = progress(t, ...T.g1, ease.inOutSine), b = progress(t, ...T.g2, ease.inOutSine);\n  g1.style.transform = `translateX(${(-0.6 + 1.2 * a) * cw}px)`; g1.style.opacity = String(Math.sin(a * Math.PI));\n  g2.style.transform = `translateX(${(-0.6 + 1.2 * b) * cw}px)`; g2.style.opacity = String(Math.sin(b * Math.PI) * 0.8);\n  // the rim catches a line of light on the edge facing it\n  const rim = Math.max(0, Math.sin(a * Math.PI)) * 0.9;\n  $('rim').style.boxShadow = `inset ${yaw > 0 ? -2 : 2}px 1px 0 rgba(255,255,255,${0.15 + 0.5 * rim})`;\n  // the camera: an easy push\n  const arrive = progress(t, 0, 0.9, ease.outCubic);\n  cam.at({ x: 0, y: 0, z: DIST + SHORT * 0.35 * (1 - arrive) - SHORT * 0.32 * progress(t, 0.9, D, ease.inOutSine), yaw: 0, pitch: 0 });\n  card.style.opacity = String(progress(t, 0, 0.3));\n});\nB.cue(s, 'transition', 0.2); B.cue(s, 'text', T.g1[0]); B.cue(s, 'land', T.turn[1]);\nB.sound(s);\nawait s.start();\n</script>\n</body>\n</html>\n"
    },
    {
      "path": "pieces/light-sweep/brief.md",
      "content": "# Light sweep\n\nBlock: light-sweep (4.6 s), from paper-motion.app. The look, fonts and sound come from `brand/`.\n\nA card turns in the light and a diagonal glint crosses its face in step with the turn, its edge catching a thin line.\n\nA block is one ready-made moment. Edit `CONFIG` (its words, numbers and format: 16:9, 9:16 or 1:1, the layout recomposes for each); check `npx paper-motion still` at 3.2 and 2.3 s; render.\n"
    }
  ],
  "requires": {
    "engine": ">=0.2.6"
  },
  "usage": "npx paper-motion add light-sweep --name my-light-sweep\n# edit CONFIG in pieces/my-light-sweep/scene.html, then:\nnpx paper-motion render pieces/my-light-sweep/scene.html --motion-blur 5",
  "notes": [
    "Wired to the brand folder: needs brand/tokens.json (a palette and a font pair work) and, for the field, a shader-set entry.",
    "Recomposes for 16:9, 9:16 and 1:1: set `format` and the layout and camera follow."
  ],
  "related": [
    "parallax-stack",
    "release"
  ],
  "preview": {
    "video": "previews/light-sweep.webm",
    "poster": "previews/light-sweep.jpg",
    "at": 1.8,
    "values": {}
  },
  "mood": [
    "luxury",
    "calm"
  ],
  "duration": 4.6,
  "formats": [
    "16:9",
    "9:16",
    "1:1"
  ],
  "beats": [
    {
      "name": "Turn",
      "from": 0.2,
      "to": 3.2,
      "what": "turn"
    },
    {
      "name": "Glint",
      "from": 0.9,
      "to": 2.3,
      "what": "glint"
    },
    {
      "name": "Second glint",
      "from": 2.2,
      "to": 3.2,
      "what": "second glint"
    },
    {
      "name": "Hold",
      "from": 3.2,
      "to": 4.6,
      "what": "hold"
    }
  ],
  "when": [
    "a release or a product card",
    "anything that should feel like an object"
  ],
  "needs": [
    {
      "kind": "name",
      "fill": {
        "corner": "$brief.action"
      }
    },
    {
      "kind": "line",
      "optional": true,
      "fill": {
        "line": "$text"
      }
    }
  ]
}