An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
fix(engine): a question's caption sits clear of its card
yzr3f70aba31995
diff --git a/.claude/skills/papermorph/references/engine.md b/.claude/skills/papermorph/references/engine.mdindex 887d536..d3aa5b2 100644--- a/.claude/skills/papermorph/references/engine.md+++ b/.claude/skills/papermorph/references/engine.md@@ -105,7 +105,7 @@ quiz(position, [{ id: 'c-mean', prompt: ['Find the mean of ', $m('7, 3, 9'), '.'## Player-Space play/pause, ←/→ previous/next beat (Shift+←/→ during a question), Home restart, C captions (a question's narration is captioned too, at the top left, until the narration ends), `<`/`>` speed (0.75–1.5×, remembered), volume (remembered, except muted), F full screen, ? help. Clicking a step segment jumps to that point of the beat (`seekInto(i, frac)`); the next beat's clip preloads while one plays. `seek(i, play)` rebuilds and jumps; `start(i, play)` begins a beat from the current picture. While audio plays, the beat clock follows `audio.currentTime`. `?beat=N&t=S` in the URL opens a frozen frame for review, without captions (N is kept within the chapter's steps). With `?review` in the URL, N pauses and asks for a note on the current moment and Shift+N copies the chapter's notes, one line each with the `?beat=N&t=S` that reopens it, so a reviewer can collect notes while watching and hand them over at once. The finish card's Enter opens `CHAPTER.next`, R replays.+Space play/pause, ←/→ previous/next beat (Shift+←/→ during a question), Home restart, C captions (a question's narration is captioned too, above its band or beside its corner card, until the narration ends), `<`/`>` speed (0.75–1.5×, remembered), volume (remembered, except muted), F full screen, ? help. Clicking a step segment jumps to that point of the beat (`seekInto(i, frac)`); the next beat's clip preloads while one plays. `seek(i, play)` rebuilds and jumps; `start(i, play)` begins a beat from the current picture. While audio plays, the beat clock follows `audio.currentTime`. `?beat=N&t=S` in the URL opens a frozen frame for review, without captions (N is kept within the chapter's steps). With `?review` in the URL, N pauses and asks for a note on the current moment and Shift+N copies the chapter's notes, one line each with the `?beat=N&t=S` that reopens it, so a reviewer can collect notes while watching and hand them over at once. The finish card's Enter opens `CHAPTER.next`, R replays.Progress is saved under `animebook:progress:<book-path>`; the cover and a picture book's series page read the same key. A book can set another key with `--progress-key` in `lib/book.css`; its cover must then read that key. Books served in different folders have separate saved places and completion lists.diff --git a/engine/engine.css b/engine/engine.cssindex eecc385..b65752d 100644--- a/engine/engine.css+++ b/engine/engine.css@@ -157,7 +157,6 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e/* Optional captions of the narration, one sentence at a time. Off by default: teaching text lives in the picture. */.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: 1180px; padding: 10px 24px; border-radius: 14px; background: rgba(10, 16, 14, .82); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }-.caption.ask { left: 40px; top: 24px; bottom: auto; transform: none; max-width: 880px; text-align: left; }.icon.cc { font-size: 15px; font-weight: 700; color: var(--dim); }.icon.cc[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--board); }.card.side { overflow: auto; }diff --git a/engine/engine.js b/engine/engine.jsindex 6c07a1d..257515a 100644--- a/engine/engine.js+++ b/engine/engine.js@@ -1338,8 +1338,8 @@ function ui() {if (step !== stepText) { stepText = step; $('stepName').textContent = step; }const b = BEATS[P.i];let text = '';- // a question's caption shows while its narration plays, at the top left, clear of the cards; a full-screen card- // already shows the question, so it has none+ // a question's caption shows while its narration plays, clear of the cards; a full-screen card already shows the+ // question, so it has noneconst asking = !!b.ask;if (P.started && !P.done && !(asking && (P.waiting || $('ui').querySelector('.card.screen')))) {// a cue is [start, line], [start, line, end] or [start, line, end, 1]: with an end, the caption clears once its@@ -1350,7 +1350,19 @@ function ui() {}}if (text !== capText) { capText = text; $('caption').textContent = text; $('caption').hidden = !text; }- if (text) $('caption').classList.toggle('ask', asking);+ if (text) placeCaption(asking);+}+// Above a bottom band, or centred left of a card in the bottom right; elsewhere the caption keeps its place.+let capAt = '';+function placeCaption(asking) {+ const c = asking ? $('ui').querySelector('.card.band, .card.side') : null;+ let at = '';+ if (c?.classList.contains('band')) at = `${960 - c.offsetTop + 12}||`;+ else if (c && c.offsetLeft > 800 && c.offsetTop + c.offsetHeight > 700) at = `|${c.offsetLeft / 2}|${c.offsetLeft - 60}`;+ if (at === capAt) return;+ capAt = at;+ const [bottom, left, width] = at.split('|'), s = $('caption').style;+ Object.assign(s, { bottom: bottom && bottom + 'px', left: left && left + 'px', maxWidth: width && width + 'px' });}let captions = false, capText = '';try { captions = localStorage.getItem('captions') === '1'; } catch {}diff --git a/site/elementary-algebra/lib/engine.css b/site/elementary-algebra/lib/engine.cssindex eecc385..b65752d 100644--- a/site/elementary-algebra/lib/engine.css+++ b/site/elementary-algebra/lib/engine.css@@ -157,7 +157,6 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e/* Optional captions of the narration, one sentence at a time. Off by default: teaching text lives in the picture. */.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: 1180px; padding: 10px 24px; border-radius: 14px; background: rgba(10, 16, 14, .82); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }-.caption.ask { left: 40px; top: 24px; bottom: auto; transform: none; max-width: 880px; text-align: left; }.icon.cc { font-size: 15px; font-weight: 700; color: var(--dim); }.icon.cc[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--board); }.card.side { overflow: auto; }diff --git a/site/elementary-algebra/lib/engine.js b/site/elementary-algebra/lib/engine.jsindex 6c07a1d..257515a 100644--- a/site/elementary-algebra/lib/engine.js+++ b/site/elementary-algebra/lib/engine.js@@ -1338,8 +1338,8 @@ function ui() {if (step !== stepText) { stepText = step; $('stepName').textContent = step; }const b = BEATS[P.i];let text = '';- // a question's caption shows while its narration plays, at the top left, clear of the cards; a full-screen card- // already shows the question, so it has none+ // a question's caption shows while its narration plays, clear of the cards; a full-screen card already shows the+ // question, so it has noneconst asking = !!b.ask;if (P.started && !P.done && !(asking && (P.waiting || $('ui').querySelector('.card.screen')))) {// a cue is [start, line], [start, line, end] or [start, line, end, 1]: with an end, the caption clears once its@@ -1350,7 +1350,19 @@ function ui() {}}if (text !== capText) { capText = text; $('caption').textContent = text; $('caption').hidden = !text; }- if (text) $('caption').classList.toggle('ask', asking);+ if (text) placeCaption(asking);+}+// Above a bottom band, or centred left of a card in the bottom right; elsewhere the caption keeps its place.+let capAt = '';+function placeCaption(asking) {+ const c = asking ? $('ui').querySelector('.card.band, .card.side') : null;+ let at = '';+ if (c?.classList.contains('band')) at = `${960 - c.offsetTop + 12}||`;+ else if (c && c.offsetLeft > 800 && c.offsetTop + c.offsetHeight > 700) at = `|${c.offsetLeft / 2}|${c.offsetLeft - 60}`;+ if (at === capAt) return;+ capAt = at;+ const [bottom, left, width] = at.split('|'), s = $('caption').style;+ Object.assign(s, { bottom: bottom && bottom + 'px', left: left && left + 'px', maxWidth: width && width + 'px' });}let captions = false, capText = '';try { captions = localStorage.getItem('captions') === '1'; } catch {}diff --git a/site/joke-collection/lib/engine.css b/site/joke-collection/lib/engine.cssindex eecc385..b65752d 100644--- a/site/joke-collection/lib/engine.css+++ b/site/joke-collection/lib/engine.css@@ -157,7 +157,6 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e/* Optional captions of the narration, one sentence at a time. Off by default: teaching text lives in the picture. */.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: 1180px; padding: 10px 24px; border-radius: 14px; background: rgba(10, 16, 14, .82); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }-.caption.ask { left: 40px; top: 24px; bottom: auto; transform: none; max-width: 880px; text-align: left; }.icon.cc { font-size: 15px; font-weight: 700; color: var(--dim); }.icon.cc[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--board); }.card.side { overflow: auto; }diff --git a/site/joke-collection/lib/engine.js b/site/joke-collection/lib/engine.jsindex 6c07a1d..257515a 100644--- a/site/joke-collection/lib/engine.js+++ b/site/joke-collection/lib/engine.js@@ -1338,8 +1338,8 @@ function ui() {if (step !== stepText) { stepText = step; $('stepName').textContent = step; }const b = BEATS[P.i];let text = '';- // a question's caption shows while its narration plays, at the top left, clear of the cards; a full-screen card- // already shows the question, so it has none+ // a question's caption shows while its narration plays, clear of the cards; a full-screen card already shows the+ // question, so it has noneconst asking = !!b.ask;if (P.started && !P.done && !(asking && (P.waiting || $('ui').querySelector('.card.screen')))) {// a cue is [start, line], [start, line, end] or [start, line, end, 1]: with an end, the caption clears once its@@ -1350,7 +1350,19 @@ function ui() {}}if (text !== capText) { capText = text; $('caption').textContent = text; $('caption').hidden = !text; }- if (text) $('caption').classList.toggle('ask', asking);+ if (text) placeCaption(asking);+}+// Above a bottom band, or centred left of a card in the bottom right; elsewhere the caption keeps its place.+let capAt = '';+function placeCaption(asking) {+ const c = asking ? $('ui').querySelector('.card.band, .card.side') : null;+ let at = '';+ if (c?.classList.contains('band')) at = `${960 - c.offsetTop + 12}||`;+ else if (c && c.offsetLeft > 800 && c.offsetTop + c.offsetHeight > 700) at = `|${c.offsetLeft / 2}|${c.offsetLeft - 60}`;+ if (at === capAt) return;+ capAt = at;+ const [bottom, left, width] = at.split('|'), s = $('caption').style;+ Object.assign(s, { bottom: bottom && bottom + 'px', left: left && left + 'px', maxWidth: width && width + 'px' });}let captions = false, capText = '';try { captions = localStorage.getItem('captions') === '1'; } catch {}diff --git a/site/little-red-riding-hood/lib/engine.css b/site/little-red-riding-hood/lib/engine.cssindex eecc385..b65752d 100644--- a/site/little-red-riding-hood/lib/engine.css+++ b/site/little-red-riding-hood/lib/engine.css@@ -157,7 +157,6 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e/* Optional captions of the narration, one sentence at a time. Off by default: teaching text lives in the picture. */.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: 1180px; padding: 10px 24px; border-radius: 14px; background: rgba(10, 16, 14, .82); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }-.caption.ask { left: 40px; top: 24px; bottom: auto; transform: none; max-width: 880px; text-align: left; }.icon.cc { font-size: 15px; font-weight: 700; color: var(--dim); }.icon.cc[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--board); }.card.side { overflow: auto; }diff --git a/site/little-red-riding-hood/lib/engine.js b/site/little-red-riding-hood/lib/engine.jsindex 6c07a1d..257515a 100644--- a/site/little-red-riding-hood/lib/engine.js+++ b/site/little-red-riding-hood/lib/engine.js@@ -1338,8 +1338,8 @@ function ui() {if (step !== stepText) { stepText = step; $('stepName').textContent = step; }const b = BEATS[P.i];let text = '';- // a question's caption shows while its narration plays, at the top left, clear of the cards; a full-screen card- // already shows the question, so it has none+ // a question's caption shows while its narration plays, clear of the cards; a full-screen card already shows the+ // question, so it has noneconst asking = !!b.ask;if (P.started && !P.done && !(asking && (P.waiting || $('ui').querySelector('.card.screen')))) {// a cue is [start, line], [start, line, end] or [start, line, end, 1]: with an end, the caption clears once its@@ -1350,7 +1350,19 @@ function ui() {}}if (text !== capText) { capText = text; $('caption').textContent = text; $('caption').hidden = !text; }- if (text) $('caption').classList.toggle('ask', asking);+ if (text) placeCaption(asking);+}+// Above a bottom band, or centred left of a card in the bottom right; elsewhere the caption keeps its place.+let capAt = '';+function placeCaption(asking) {+ const c = asking ? $('ui').querySelector('.card.band, .card.side') : null;+ let at = '';+ if (c?.classList.contains('band')) at = `${960 - c.offsetTop + 12}||`;+ else if (c && c.offsetLeft > 800 && c.offsetTop + c.offsetHeight > 700) at = `|${c.offsetLeft / 2}|${c.offsetLeft - 60}`;+ if (at === capAt) return;+ capAt = at;+ const [bottom, left, width] = at.split('|'), s = $('caption').style;+ Object.assign(s, { bottom: bottom && bottom + 'px', left: left && left + 'px', maxWidth: width && width + 'px' });}let captions = false, capText = '';try { captions = localStorage.getItem('captions') === '1'; } catch {}diff --git a/site/math-notebook/lib/engine.css b/site/math-notebook/lib/engine.cssindex eecc385..b65752d 100644--- a/site/math-notebook/lib/engine.css+++ b/site/math-notebook/lib/engine.css@@ -157,7 +157,6 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e/* Optional captions of the narration, one sentence at a time. Off by default: teaching text lives in the picture. */.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: 1180px; padding: 10px 24px; border-radius: 14px; background: rgba(10, 16, 14, .82); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }-.caption.ask { left: 40px; top: 24px; bottom: auto; transform: none; max-width: 880px; text-align: left; }.icon.cc { font-size: 15px; font-weight: 700; color: var(--dim); }.icon.cc[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--board); }.card.side { overflow: auto; }diff --git a/site/math-notebook/lib/engine.js b/site/math-notebook/lib/engine.jsindex 6c07a1d..257515a 100644--- a/site/math-notebook/lib/engine.js+++ b/site/math-notebook/lib/engine.js@@ -1338,8 +1338,8 @@ function ui() {if (step !== stepText) { stepText = step; $('stepName').textContent = step; }const b = BEATS[P.i];let text = '';- // a question's caption shows while its narration plays, at the top left, clear of the cards; a full-screen card- // already shows the question, so it has none+ // a question's caption shows while its narration plays, clear of the cards; a full-screen card already shows the+ // question, so it has noneconst asking = !!b.ask;if (P.started && !P.done && !(asking && (P.waiting || $('ui').querySelector('.card.screen')))) {// a cue is [start, line], [start, line, end] or [start, line, end, 1]: with an end, the caption clears once its@@ -1350,7 +1350,19 @@ function ui() {}}if (text !== capText) { capText = text; $('caption').textContent = text; $('caption').hidden = !text; }- if (text) $('caption').classList.toggle('ask', asking);+ if (text) placeCaption(asking);+}+// Above a bottom band, or centred left of a card in the bottom right; elsewhere the caption keeps its place.+let capAt = '';+function placeCaption(asking) {+ const c = asking ? $('ui').querySelector('.card.band, .card.side') : null;+ let at = '';+ if (c?.classList.contains('band')) at = `${960 - c.offsetTop + 12}||`;+ else if (c && c.offsetLeft > 800 && c.offsetTop + c.offsetHeight > 700) at = `|${c.offsetLeft / 2}|${c.offsetLeft - 60}`;+ if (at === capAt) return;+ capAt = at;+ const [bottom, left, width] = at.split('|'), s = $('caption').style;+ Object.assign(s, { bottom: bottom && bottom + 'px', left: left && left + 'px', maxWidth: width && width + 'px' });}let captions = false, capText = '';try { captions = localStorage.getItem('captions') === '1'; } catch {}diff --git a/site/physics-notebook/lib/engine.css b/site/physics-notebook/lib/engine.cssindex eecc385..b65752d 100644--- a/site/physics-notebook/lib/engine.css+++ b/site/physics-notebook/lib/engine.css@@ -157,7 +157,6 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e/* Optional captions of the narration, one sentence at a time. Off by default: teaching text lives in the picture. */.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: 1180px; padding: 10px 24px; border-radius: 14px; background: rgba(10, 16, 14, .82); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }-.caption.ask { left: 40px; top: 24px; bottom: auto; transform: none; max-width: 880px; text-align: left; }.icon.cc { font-size: 15px; font-weight: 700; color: var(--dim); }.icon.cc[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--board); }.card.side { overflow: auto; }diff --git a/site/physics-notebook/lib/engine.js b/site/physics-notebook/lib/engine.jsindex 6c07a1d..257515a 100644--- a/site/physics-notebook/lib/engine.js+++ b/site/physics-notebook/lib/engine.js@@ -1338,8 +1338,8 @@ function ui() {if (step !== stepText) { stepText = step; $('stepName').textContent = step; }const b = BEATS[P.i];let text = '';- // a question's caption shows while its narration plays, at the top left, clear of the cards; a full-screen card- // already shows the question, so it has none+ // a question's caption shows while its narration plays, clear of the cards; a full-screen card already shows the+ // question, so it has noneconst asking = !!b.ask;if (P.started && !P.done && !(asking && (P.waiting || $('ui').querySelector('.card.screen')))) {// a cue is [start, line], [start, line, end] or [start, line, end, 1]: with an end, the caption clears once its@@ -1350,7 +1350,19 @@ function ui() {}}if (text !== capText) { capText = text; $('caption').textContent = text; $('caption').hidden = !text; }- if (text) $('caption').classList.toggle('ask', asking);+ if (text) placeCaption(asking);+}+// Above a bottom band, or centred left of a card in the bottom right; elsewhere the caption keeps its place.+let capAt = '';+function placeCaption(asking) {+ const c = asking ? $('ui').querySelector('.card.band, .card.side') : null;+ let at = '';+ if (c?.classList.contains('band')) at = `${960 - c.offsetTop + 12}||`;+ else if (c && c.offsetLeft > 800 && c.offsetTop + c.offsetHeight > 700) at = `|${c.offsetLeft / 2}|${c.offsetLeft - 60}`;+ if (at === capAt) return;+ capAt = at;+ const [bottom, left, width] = at.split('|'), s = $('caption').style;+ Object.assign(s, { bottom: bottom && bottom + 'px', left: left && left + 'px', maxWidth: width && width + 'px' });}let captions = false, capText = '';try { captions = localStorage.getItem('captions') === '1'; } catch {}diff --git a/site/science/lib/engine.css b/site/science/lib/engine.cssindex eecc385..b65752d 100644--- a/site/science/lib/engine.css+++ b/site/science/lib/engine.css@@ -157,7 +157,6 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e/* Optional captions of the narration, one sentence at a time. Off by default: teaching text lives in the picture. */.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: 1180px; padding: 10px 24px; border-radius: 14px; background: rgba(10, 16, 14, .82); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }-.caption.ask { left: 40px; top: 24px; bottom: auto; transform: none; max-width: 880px; text-align: left; }.icon.cc { font-size: 15px; font-weight: 700; color: var(--dim); }.icon.cc[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--board); }.card.side { overflow: auto; }diff --git a/site/science/lib/engine.js b/site/science/lib/engine.jsindex 6c07a1d..257515a 100644--- a/site/science/lib/engine.js+++ b/site/science/lib/engine.js@@ -1338,8 +1338,8 @@ function ui() {if (step !== stepText) { stepText = step; $('stepName').textContent = step; }const b = BEATS[P.i];let text = '';- // a question's caption shows while its narration plays, at the top left, clear of the cards; a full-screen card- // already shows the question, so it has none+ // a question's caption shows while its narration plays, clear of the cards; a full-screen card already shows the+ // question, so it has noneconst asking = !!b.ask;if (P.started && !P.done && !(asking && (P.waiting || $('ui').querySelector('.card.screen')))) {// a cue is [start, line], [start, line, end] or [start, line, end, 1]: with an end, the caption clears once its@@ -1350,7 +1350,19 @@ function ui() {}}if (text !== capText) { capText = text; $('caption').textContent = text; $('caption').hidden = !text; }- if (text) $('caption').classList.toggle('ask', asking);+ if (text) placeCaption(asking);+}+// Above a bottom band, or centred left of a card in the bottom right; elsewhere the caption keeps its place.+let capAt = '';+function placeCaption(asking) {+ const c = asking ? $('ui').querySelector('.card.band, .card.side') : null;+ let at = '';+ if (c?.classList.contains('band')) at = `${960 - c.offsetTop + 12}||`;+ else if (c && c.offsetLeft > 800 && c.offsetTop + c.offsetHeight > 700) at = `|${c.offsetLeft / 2}|${c.offsetLeft - 60}`;+ if (at === capAt) return;+ capAt = at;+ const [bottom, left, width] = at.split('|'), s = $('caption').style;+ Object.assign(s, { bottom: bottom && bottom + 'px', left: left && left + 'px', maxWidth: width && width + 'px' });}let captions = false, capText = '';try { captions = localStorage.getItem('captions') === '1'; } catch {}diff --git a/site/three-little-pigs/lib/engine.css b/site/three-little-pigs/lib/engine.cssindex eecc385..b65752d 100644--- a/site/three-little-pigs/lib/engine.css+++ b/site/three-little-pigs/lib/engine.css@@ -157,7 +157,6 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e/* Optional captions of the narration, one sentence at a time. Off by default: teaching text lives in the picture. */.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: 1180px; padding: 10px 24px; border-radius: 14px; background: rgba(10, 16, 14, .82); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }-.caption.ask { left: 40px; top: 24px; bottom: auto; transform: none; max-width: 880px; text-align: left; }.icon.cc { font-size: 15px; font-weight: 700; color: var(--dim); }.icon.cc[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--board); }.card.side { overflow: auto; }diff --git a/site/three-little-pigs/lib/engine.js b/site/three-little-pigs/lib/engine.jsindex 6c07a1d..257515a 100644--- a/site/three-little-pigs/lib/engine.js+++ b/site/three-little-pigs/lib/engine.js@@ -1338,8 +1338,8 @@ function ui() {if (step !== stepText) { stepText = step; $('stepName').textContent = step; }const b = BEATS[P.i];let text = '';- // a question's caption shows while its narration plays, at the top left, clear of the cards; a full-screen card- // already shows the question, so it has none+ // a question's caption shows while its narration plays, clear of the cards; a full-screen card already shows the+ // question, so it has noneconst asking = !!b.ask;if (P.started && !P.done && !(asking && (P.waiting || $('ui').querySelector('.card.screen')))) {// a cue is [start, line], [start, line, end] or [start, line, end, 1]: with an end, the caption clears once its@@ -1350,7 +1350,19 @@ function ui() {}}if (text !== capText) { capText = text; $('caption').textContent = text; $('caption').hidden = !text; }- if (text) $('caption').classList.toggle('ask', asking);+ if (text) placeCaption(asking);+}+// Above a bottom band, or centred left of a card in the bottom right; elsewhere the caption keeps its place.+let capAt = '';+function placeCaption(asking) {+ const c = asking ? $('ui').querySelector('.card.band, .card.side') : null;+ let at = '';+ if (c?.classList.contains('band')) at = `${960 - c.offsetTop + 12}||`;+ else if (c && c.offsetLeft > 800 && c.offsetTop + c.offsetHeight > 700) at = `|${c.offsetLeft / 2}|${c.offsetLeft - 60}`;+ if (at === capAt) return;+ capAt = at;+ const [bottom, left, width] = at.split('|'), s = $('caption').style;+ Object.assign(s, { bottom: bottom && bottom + 'px', left: left && left + 'px', maxWidth: width && width + 'px' });}let captions = false, capText = '';try { captions = localStorage.getItem('captions') === '1'; } catch {}