Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

fix(engine): keep quiz card prompts readable and on stage

yzr9cba3969b2b0
diff --git a/.claude/skills/papermorph/assets/engine/engine.css b/.claude/skills/papermorph/assets/engine/engine.css
index 17c8684..902eea8 100644
--- a/.claude/skills/papermorph/assets/engine/engine.css
+++ b/.claude/skills/papermorph/assets/engine/engine.css
@@ -38,11 +38,13 @@ button[hidden] { display: none; }
/* Question cards inside the picture. */
.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: rgba(34, 50, 45, .97); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
-.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
+/* Band card: prompt and buttons on top, answers below at full width, feedback last. A prompt beside the answers
+ lost the width race to long choices or answer rows (it was squeezed to a word per line, worst in Firefox). */
+.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "pic head acts" "pic body body" "pic fb fb"; column-gap: 28px; row-gap: 12px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
-.band .head { grid-area: head; align-self: end; }
-.band .fb { grid-area: fb; align-self: start; }
-.band .body { grid-area: body; }
+.band .head { grid-area: head; }
+.band .fb { grid-area: fb; margin-top: 0; }
+.band .body { grid-area: body; min-width: 0; }
.band .acts { grid-area: acts; }
.side .mascot { float: right; margin: -2px -4px 6px 10px; }
.kicker { margin: 0 0 4px; font-size: 20px; font-weight: 600; color: var(--quiz); }
diff --git a/.claude/skills/papermorph/assets/engine/engine.js b/.claude/skills/papermorph/assets/engine/engine.js
index fb64425..5328dc6 100644
--- a/.claude/skills/papermorph/assets/engine/engine.js
+++ b/.claude/skills/papermorph/assets/engine/engine.js
@@ -85,7 +85,7 @@ const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
const MATH = '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';
const NAME = { nat: 'Natural', whole: 'Whole', int: 'Integers', rat: 'Rational', irr: 'Irrational', real: 'Real' };
// Card positions inside the 1600×900 picture.
-const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // below the number line
+const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // bottom band (moves up when taller than the space left)
const RIGHT = { x: 1258, y: 546, w: 330, cls: 'side', maxH: 346 }; // right of the number map
const TOPR = { x: 960, y: 70, w: 624, cls: 'side', maxH: 470 }; // top right, above the number line
const SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen' };
@@ -1011,11 +1011,19 @@ function rich(parts, size = 28) {
for (const p of [].concat(parts)) s.append(typeof p === 'string' || p instanceof Node ? p : mathEl(p.m, size));
return s;
}
+// A card at pos; a band card keeps its bottom on the stage: when its content grows (a long question, feedback),
+// it moves up rather than running under the player bar.
function card(pos, cls) {
const c = h('div', `card ${pos.cls} ${cls}`);
Object.assign(c.style, { left: pos.x + 'px', top: pos.y + 'px', width: pos.w + 'px' });
if (pos.maxH) c.style.maxHeight = pos.maxH + 'px';
$('ui').append(c);
+ if (pos.cls === 'band') {
+ const fit = () => { c.style.top = Math.max(16, Math.min(pos.y, 900 - 16 - c.offsetHeight)) + 'px'; };
+ const ro = new ResizeObserver(fit);
+ ro.observe(c); fit();
+ P.cleanup.push(() => ro.disconnect());
+ }
return c;
}
// The guide: an infinity sign whose two loops are its eyes. Drawn in SVG so it can blink, hop and wobble.
diff --git a/site/science/ch09/index.html b/site/science/ch09/index.html
index 0469abc..c368ccc 100644
--- a/site/science/ch09/index.html
+++ b/site/science/ch09/index.html
@@ -20,8 +20,7 @@ const CHAPTER = { number: 9, title: 'Motion · Parts 1–3: Relative Motion, Spe
const V = 150; // 30 mph on screen, in world px per second (same scale in every road beat)
const MPH = v => Math.round(Math.abs(v) / V * 30);
const speedStr = rel => { const n = MPH(rel); return n === 0 ? '0 mph' : rel > 0 ? `${n} mph →` : `← ${n} mph`; };
-const Q_CARD = { x: 96, y: 586, w: 1408, cls: 'band' }; // band card lifted above the usual BAND, for longer feedback
-const Q2_CARD = { x: 96, y: 446, w: 1408, cls: 'band' }; // higher still: the speed check has two rows of boxes
+const Q_CARD = { x: 96, y: 586, w: 1408, cls: 'band' }; // a band card under the scenes; it moves up by itself when taller
const txt = (p, s, x, y, t0, { size = 32, fill = COL.chalk, anchor = 'middle', weight = 600 } = {}) => { const e = T(p, s, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };
// One line with coloured runs: [[text, colour?], …].
function runs(p, parts, { x, y, size = 40, anchor = 'middle', weight = 600, o = 0 }) {
@@ -510,7 +509,7 @@ const BEATS = [
put(dol, { x: dx }); put(wal, { x: wx });
put(dl, { x: dx, o: s >= 8 ? 1 : 0 }); put(wl, { x: wx, o: s >= 6 ? 1 : 0 });
}, D);
-}, { ask: done => quiz(Q2_CARD, [
+}, { ask: done => quiz(Q_CARD, [
{ id: 'c-dw-speed', prompt: ['Speed = ', h('b', '', 'distance ÷ time'), '. Find each speed.'],
build: blanks([
{ parts: ['dolphin: 56 meters ÷ 8 seconds = ', { box: '7' }, ' meters per second'], why: '56 ÷ 8 = 7.', hint: 'Divide the dolphin’s distance by its time: 56 ÷ 8.' },
@@ -663,7 +662,7 @@ const BEATS = [
const pose = d => { d = ((d % per) + per) % per; const w = X1 - X0, h = Y1 - Y0;
return d < w ? [X0 + d, Y0, 0] : d < w + h ? [X1, Y0 + d - w, 90] : d < 2 * w + h ? [X1 - (d - w - h), Y1, 180] : [X0, Y1 - (d - 2 * w - h), -90]; };
clockRun(t => { const [x, y, a] = pose(220 * t); put(walker, { x, y, r: a }); arrowAt(arr, x + 34 * Math.cos(a * Math.PI / 180), y + 34 * Math.sin(a * Math.PI / 180), 70, a, 14); }, D);
-}, { ask: done => quiz(Q2_CARD, [
+}, { ask: done => quiz(Q_CARD, [
{ id: 'c-vel-need', prompt: ['What do you need to know to describe an object’s ', h('b', '', 'velocity'), '?'],
build: choice([['its speed only'], ['its direction only'], ['its speed and its direction']], 2,
'Velocity is speed in a certain direction, so it needs both.',
diff --git a/site/science/lib/engine.css b/site/science/lib/engine.css
index 17c8684..902eea8 100644
--- a/site/science/lib/engine.css
+++ b/site/science/lib/engine.css
@@ -38,11 +38,13 @@ button[hidden] { display: none; }
/* Question cards inside the picture. */
.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: rgba(34, 50, 45, .97); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
-.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
+/* Band card: prompt and buttons on top, answers below at full width, feedback last. A prompt beside the answers
+ lost the width race to long choices or answer rows (it was squeezed to a word per line, worst in Firefox). */
+.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "pic head acts" "pic body body" "pic fb fb"; column-gap: 28px; row-gap: 12px; align-items: center; align-content: center; min-height: 150px; }
.band .mascot { grid-area: pic; }
-.band .head { grid-area: head; align-self: end; }
-.band .fb { grid-area: fb; align-self: start; }
-.band .body { grid-area: body; }
+.band .head { grid-area: head; }
+.band .fb { grid-area: fb; margin-top: 0; }
+.band .body { grid-area: body; min-width: 0; }
.band .acts { grid-area: acts; }
.side .mascot { float: right; margin: -2px -4px 6px 10px; }
.kicker { margin: 0 0 4px; font-size: 20px; font-weight: 600; color: var(--quiz); }
diff --git a/site/science/lib/engine.js b/site/science/lib/engine.js
index fb64425..5328dc6 100644
--- a/site/science/lib/engine.js
+++ b/site/science/lib/engine.js
@@ -85,7 +85,7 @@ const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
const MATH = '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';
const NAME = { nat: 'Natural', whole: 'Whole', int: 'Integers', rat: 'Rational', irr: 'Irrational', real: 'Real' };
// Card positions inside the 1600×900 picture.
-const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // below the number line
+const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // bottom band (moves up when taller than the space left)
const RIGHT = { x: 1258, y: 546, w: 330, cls: 'side', maxH: 346 }; // right of the number map
const TOPR = { x: 960, y: 70, w: 624, cls: 'side', maxH: 470 }; // top right, above the number line
const SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen' };
@@ -1011,11 +1011,19 @@ function rich(parts, size = 28) {
for (const p of [].concat(parts)) s.append(typeof p === 'string' || p instanceof Node ? p : mathEl(p.m, size));
return s;
}
+// A card at pos; a band card keeps its bottom on the stage: when its content grows (a long question, feedback),
+// it moves up rather than running under the player bar.
function card(pos, cls) {
const c = h('div', `card ${pos.cls} ${cls}`);
Object.assign(c.style, { left: pos.x + 'px', top: pos.y + 'px', width: pos.w + 'px' });
if (pos.maxH) c.style.maxHeight = pos.maxH + 'px';
$('ui').append(c);
+ if (pos.cls === 'band') {
+ const fit = () => { c.style.top = Math.max(16, Math.min(pos.y, 900 - 16 - c.offsetHeight)) + 'px'; };
+ const ro = new ResizeObserver(fit);
+ ro.observe(c); fit();
+ P.cleanup.push(() => ro.disconnect());
+ }
return c;
}
// The guide: an infinity sign whose two loops are its eyes. Drawn in SVG so it can blink, hop and wobble.