An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
feat(engine): an upright 900 x 1600 stage for phone films
yzr31ea28188196
diff --git a/.claude/skills/papermorph/references/engine.md b/.claude/skills/papermorph/references/engine.mdindex f536e58..cbeffa3 100644--- a/.claude/skills/papermorph/references/engine.md+++ b/.claude/skills/papermorph/references/engine.md@@ -9,6 +9,7 @@ The maths helpers (number lines, tiles, fraction rows, planes, chance objects, t## Stage and state- The stage is SVG, `viewBox 0 0 1600 900`; animated things live in `#scene`. HTML cards go in `#ui`, in the same coordinates.+- **Upright stage** *(portrait)*. `<html data-stage="portrait">` turns the stage to 900 × 1600 for a phone feed ([shorts.md](shorts.md)). `SW` and `SH` hold the stage size (1600 and 900 otherwise), CSS has `--sw` and `--sh`, and the camera, the bottom band card, the captions, the window fit and `export.py` follow them. The side and top-right question cards and `header()` are still placed for the wide stage, so an upright chapter is a film without questions.- Every animated element carries a state object written to the DOM by `render()`: `x y` (translate), `s` (scale), `r` (rotate, degrees), `o` (opacity), `d` (stroke drawn, 0–1), `a_<attr>` (numeric attribute, e.g. `'a_stroke-width'`), `c_<attr>` (hex colour). Give a key a starting value before tweening it; an `a_`/`c_` key without one starts from the element's attribute.- Scale and rotation are about the element's own origin: draw around (0,0) and place with `x/y`.- `S` holds objects shared across beats (`S.panel`, `S.line`, …). `reset()` clears it, so anything a later beat needs must be stored on `S`.diff --git a/engine/engine.css b/engine/engine.cssindex 3e6079a..436bdb6 100644--- a/engine/engine.css+++ b/engine/engine.css@@ -24,18 +24,18 @@ button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--task);button[hidden] { display: none; }/* One fixed 1600×960 frame (900 stage + 60 controls), scaled to fit the window. */-#frame { position: absolute; left: 50%; top: 50%; width: 1600px; height: 960px; transform: translate(-50%, -50%) scale(var(--k, .5));+#frame { position: absolute; left: 50%; top: 50%; width: var(--sw, 1600px); height: calc(var(--sh, 900px) + 60px); transform: translate(-50%, -50%) scale(var(--k, .5));border-radius: 20px; overflow: hidden; background: var(--board); box-shadow: 0 0 0 1px var(--edge), 0 30px 80px rgba(0, 0, 0, .45); }-#stage { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: block;+#stage { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: block;background: radial-gradient(75% 75% at 50% 45%, rgba(0,0,0,0) 60%, var(--vignette)), var(--grain, none), var(--board); }-#ui { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; pointer-events: none; }+#ui { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); pointer-events: none; }#ui > * { pointer-events: auto; }-.cover { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }+.cover { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }.cover[hidden] { display: none; }.cover > div { display: flex; flex-direction: column; align-items: center; }.cover-k { margin: 0 0 10px; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }-.cover-t { margin: 0 0 44px; max-width: 1200px; text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }+.cover-t { margin: 0 0 44px; max-width: min(1200px, calc(var(--sw, 1600px) - 100px)); text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }.cover > div > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }.cover-t { animation-delay: .08s; }.cover .go { animation-delay: .18s; }@@ -43,7 +43,7 @@ button[hidden] { display: none; }@keyframes rise { from { opacity: 0; transform: translateY(14px); } }.cover .go { display: inline-flex; align-items: center; gap: 16px; padding: 20px 40px; border-radius: 999px; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 32px; }.cover small { display: block; margin-top: 22px; font-size: 22px; text-align: center; color: var(--dim); }-.paused-mark { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: none; place-items: center; pointer-events: none; }+.paused-mark { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: none; place-items: center; pointer-events: none; }.paused .paused-mark { display: grid; }.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }@@ -105,7 +105,7 @@ button[hidden] { display: none; }.tok { cursor: grab; touch-action: none; } /* a finger drags the chip instead of scrolling the page *//* Controls strip, part of the frame. */-#bar { position: absolute; left: 0; top: 900px; width: 1600px; height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }+#bar { position: absolute; left: 0; top: var(--sh, 900px); width: var(--sw, 1600px); height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }.icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); display: grid; place-items: center; flex: none; padding: 0; }.icon svg { width: 18px; height: 18px; fill: var(--chalk); }.icon .i-pause { display: none; }@@ -121,7 +121,7 @@ button[hidden] { display: none; }/* Keep the control strip usable without scaling down its touch targets. */@media (max-width: 700px) {#frame { top: calc(50% - 50px); overflow: visible; }- #bar { width: calc(1600px * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;+ #bar { width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }#bar .icon { width: 36px; height: 40px; }.step { display: none; }@@ -150,9 +150,9 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }.keys kbd { margin: 0 .15em; }.grid .row.cur { background: color-mix(in srgb, var(--chalk) 5%, transparent); box-shadow: inset 4px 0 var(--quiz); }-.help { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }+.help { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }.help[hidden] { display: none; }-.help-box { width: 1120px; padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }+.help-box { width: min(1120px, calc(var(--sw, 1600px) - 80px)); padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }.help h2 { margin: 0 0 22px; font-size: 32px; font-weight: 600; }.help h3 { margin: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--quiz); }.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }@@ -164,7 +164,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }.icon.txt { font-size: 20px; font-weight: 700; color: var(--dim); }/* 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: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }+.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: min(1180px, calc(var(--sw, 1600px) - 80px)); padding: 10px 24px; border-radius: 14px; background: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }.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); }@@ -186,7 +186,7 @@ svg.m { display: inline-block; overflow: visible; }.screen .body { margin-top: 30px; }.card.screen { display: flex; flex-direction: column; }.screen .head { order: 1; } .screen .body { order: 2; }-.screen .fb { order: 3; max-width: 1080px; margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers */+.screen .fb { order: 3; max-width: min(1080px, calc(var(--sw, 1600px) - 140px)); margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers *//* Practice screens: the bottom 130 px hold the buttons. Long answers scroll inside the body, so the feedback underthem stays in view after a wrong answer adds a 'why' line to each row. */.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }@@ -240,7 +240,7 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }#ui a.cite:hover { color: var(--quiz); }-.fin .srcs { margin: 26px 0 0; max-width: 1100px; font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }@@ -259,3 +259,5 @@ a.btn { text-decoration: none; display: inline-block; }.fin .kicker { font-size: 20px; letter-spacing: .14em; text-transform: uppercase; }.fin .prompt { margin: 6px 0 14px; font: 500 56px/1.15 "Iowan Old Style", Palatino, Georgia, serif; }.icon.speed { width: auto; min-width: 44px; padding: 0 10px; border-radius: 22px; font-size: 16px; }+/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */+:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }diff --git a/engine/engine.js b/engine/engine.jsindex 4d3817c..0082c18 100644--- a/engine/engine.js+++ b/engine/engine.js@@ -151,6 +151,11 @@ const TRANSLATIONS = {watchAgain: 'もう一度見る', nextChapter: '次の章へ',},};+// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.+const PORTRAIT = document.documentElement.dataset.stage === 'portrait';+const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;+document.documentElement.style.setProperty('--sw', SW + 'px');+document.documentElement.style.setProperty('--sh', SH + 'px');const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];const pluralRules = {};// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.@@ -173,7 +178,7 @@ const isShortcut = (event, letter) => event.key.toLowerCase() === letter.toLowerconst isShortcutCode = (event, code) => /^\p{L}$/u.test(event.key) && !isLatinLetter(event.key) && event.code === code;document.body.insertAdjacentHTML('afterbegin', `<div id="frame">- <svg id="stage" viewBox="0 0 1600 900" role="img" aria-label="${translate('stageLabel')}">+ <svg id="stage" viewBox="0 0 ${SW} ${SH}" role="img" aria-label="${translate('stageLabel')}"><g id="scene"></g></svg><div id="ui"></div>@@ -265,12 +270,13 @@ const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8',}const MATH = bookSetting('--math-font') || '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';const NAME = { nat: translate('natural'), whole: translate('whole'), int: translate('integers'), rat: translate('rational'), irr: translate('irrational'), real: translate('real') };-// Card positions inside the 1600×900 picture.-const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // bottom band (moves up when taller than the space left)+// Card positions inside the picture. BAND and the screens follow the stage; RIGHT and TOPR are placed for the wide+// stage's number line and map and have no upright layout yet.+const BAND = { x: 96 * SW / 1600, y: SH - 214, w: SW - 192 * SW / 1600, 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 mapconst 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' };-const SORT_SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen sort' };+const SCREEN = { x: 0, y: 0, w: SW, cls: 'screen' };+const SORT_SCREEN = { x: 0, y: 0, w: SW, cls: 'screen sort' };const $m = (...parts) => ({ m: parts });function mk(tag, attrs = {}, parent) {@@ -623,8 +629,8 @@ const clockRun = (f, D, { tail = false } = {}) => { f(0); const w = { t0: 0, dur// Moves are keyed on the beat clock: to(view, t0, dur, ease) blends each given key from its value at t0; a key may be a// function of t (follow). Unspecified keys keep following the earlier moves. dur 0 is a hard cut.let camN = 0;-function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {}) {- const [bx, by, bw, bh] = box || [0, 0, 1600, 900];+function camera(p, D, { box, x = SW / 2, y = SH / 2, z, r = 0, bg = COL.board } = {}) {+ const [bx, by, bw, bh] = box || [0, 0, SW, SH];const el = G(p, { x: bx + bw / 2, y: by + bh / 2 });let hold = el;if (box) {@@ -635,7 +641,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})}const view = mk('g', {}, hold), world = G(view);if (box) mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18, fill: 'none', stroke: COL.faint, 'stroke-width': 2 }, el);- const v0 = { x, y, z: z ?? (box ? Math.min(bw / 1600, bh / 900) : 1), r };+ const v0 = { x, y, z: z ?? (box ? Math.min(bw / SW, bh / SH) : 1), r };const ops = [], shakes = [], layers = [];const val = (v, t) => typeof v === 'function' ? v(t) : v;// The view at time t after the first n moves; each move remembers the view it starts from.@@ -693,7 +699,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})/* ---------- scene ---------- */const scene = document.getElementById('scene');const S = {};-const AXIS = { o: 800, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change it+const AXIS = { o: SW / 2, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change itconst X = v => AXIS.o + AXIS.u * v, Y0 = 610;const num = v => (v < 0 ? '−' : '') + String(Math.abs(v)).replace('.', DECIMAL_SIGN);function reset() {@@ -813,7 +819,7 @@ function card(pos, cls) {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 fit = () => { c.style.top = Math.max(16, Math.min(pos.y, SH - 16 - c.offsetHeight)) + 'px'; };const ro = new ResizeObserver(fit);ro.observe(c); fit();P.cleanup.push(() => ro.disconnect());@@ -1514,7 +1520,7 @@ 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}||`;+ if (c?.classList.contains('band')) at = `${SH + 60 - 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;@@ -1614,7 +1620,7 @@ document.addEventListener('keydown', e => {// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });$('bHelp').onclick = toggleHelp;-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / 1640, (innerHeight - (innerWidth <= 700 ? 120 : 0)) / 1000));+const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));addEventListener('resize', fit);fit();diff --git a/site/elementary-algebra/lib/engine.css b/site/elementary-algebra/lib/engine.cssindex 3e6079a..436bdb6 100644--- a/site/elementary-algebra/lib/engine.css+++ b/site/elementary-algebra/lib/engine.css@@ -24,18 +24,18 @@ button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--task);button[hidden] { display: none; }/* One fixed 1600×960 frame (900 stage + 60 controls), scaled to fit the window. */-#frame { position: absolute; left: 50%; top: 50%; width: 1600px; height: 960px; transform: translate(-50%, -50%) scale(var(--k, .5));+#frame { position: absolute; left: 50%; top: 50%; width: var(--sw, 1600px); height: calc(var(--sh, 900px) + 60px); transform: translate(-50%, -50%) scale(var(--k, .5));border-radius: 20px; overflow: hidden; background: var(--board); box-shadow: 0 0 0 1px var(--edge), 0 30px 80px rgba(0, 0, 0, .45); }-#stage { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: block;+#stage { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: block;background: radial-gradient(75% 75% at 50% 45%, rgba(0,0,0,0) 60%, var(--vignette)), var(--grain, none), var(--board); }-#ui { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; pointer-events: none; }+#ui { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); pointer-events: none; }#ui > * { pointer-events: auto; }-.cover { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }+.cover { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }.cover[hidden] { display: none; }.cover > div { display: flex; flex-direction: column; align-items: center; }.cover-k { margin: 0 0 10px; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }-.cover-t { margin: 0 0 44px; max-width: 1200px; text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }+.cover-t { margin: 0 0 44px; max-width: min(1200px, calc(var(--sw, 1600px) - 100px)); text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }.cover > div > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }.cover-t { animation-delay: .08s; }.cover .go { animation-delay: .18s; }@@ -43,7 +43,7 @@ button[hidden] { display: none; }@keyframes rise { from { opacity: 0; transform: translateY(14px); } }.cover .go { display: inline-flex; align-items: center; gap: 16px; padding: 20px 40px; border-radius: 999px; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 32px; }.cover small { display: block; margin-top: 22px; font-size: 22px; text-align: center; color: var(--dim); }-.paused-mark { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: none; place-items: center; pointer-events: none; }+.paused-mark { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: none; place-items: center; pointer-events: none; }.paused .paused-mark { display: grid; }.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }@@ -105,7 +105,7 @@ button[hidden] { display: none; }.tok { cursor: grab; touch-action: none; } /* a finger drags the chip instead of scrolling the page *//* Controls strip, part of the frame. */-#bar { position: absolute; left: 0; top: 900px; width: 1600px; height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }+#bar { position: absolute; left: 0; top: var(--sh, 900px); width: var(--sw, 1600px); height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }.icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); display: grid; place-items: center; flex: none; padding: 0; }.icon svg { width: 18px; height: 18px; fill: var(--chalk); }.icon .i-pause { display: none; }@@ -121,7 +121,7 @@ button[hidden] { display: none; }/* Keep the control strip usable without scaling down its touch targets. */@media (max-width: 700px) {#frame { top: calc(50% - 50px); overflow: visible; }- #bar { width: calc(1600px * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;+ #bar { width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }#bar .icon { width: 36px; height: 40px; }.step { display: none; }@@ -150,9 +150,9 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }.keys kbd { margin: 0 .15em; }.grid .row.cur { background: color-mix(in srgb, var(--chalk) 5%, transparent); box-shadow: inset 4px 0 var(--quiz); }-.help { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }+.help { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }.help[hidden] { display: none; }-.help-box { width: 1120px; padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }+.help-box { width: min(1120px, calc(var(--sw, 1600px) - 80px)); padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }.help h2 { margin: 0 0 22px; font-size: 32px; font-weight: 600; }.help h3 { margin: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--quiz); }.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }@@ -164,7 +164,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }.icon.txt { font-size: 20px; font-weight: 700; color: var(--dim); }/* 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: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }+.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: min(1180px, calc(var(--sw, 1600px) - 80px)); padding: 10px 24px; border-radius: 14px; background: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }.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); }@@ -186,7 +186,7 @@ svg.m { display: inline-block; overflow: visible; }.screen .body { margin-top: 30px; }.card.screen { display: flex; flex-direction: column; }.screen .head { order: 1; } .screen .body { order: 2; }-.screen .fb { order: 3; max-width: 1080px; margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers */+.screen .fb { order: 3; max-width: min(1080px, calc(var(--sw, 1600px) - 140px)); margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers *//* Practice screens: the bottom 130 px hold the buttons. Long answers scroll inside the body, so the feedback underthem stays in view after a wrong answer adds a 'why' line to each row. */.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }@@ -240,7 +240,7 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }#ui a.cite:hover { color: var(--quiz); }-.fin .srcs { margin: 26px 0 0; max-width: 1100px; font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }@@ -259,3 +259,5 @@ a.btn { text-decoration: none; display: inline-block; }.fin .kicker { font-size: 20px; letter-spacing: .14em; text-transform: uppercase; }.fin .prompt { margin: 6px 0 14px; font: 500 56px/1.15 "Iowan Old Style", Palatino, Georgia, serif; }.icon.speed { width: auto; min-width: 44px; padding: 0 10px; border-radius: 22px; font-size: 16px; }+/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */+:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }diff --git a/site/elementary-algebra/lib/engine.js b/site/elementary-algebra/lib/engine.jsindex 4d3817c..0082c18 100644--- a/site/elementary-algebra/lib/engine.js+++ b/site/elementary-algebra/lib/engine.js@@ -151,6 +151,11 @@ const TRANSLATIONS = {watchAgain: 'もう一度見る', nextChapter: '次の章へ',},};+// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.+const PORTRAIT = document.documentElement.dataset.stage === 'portrait';+const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;+document.documentElement.style.setProperty('--sw', SW + 'px');+document.documentElement.style.setProperty('--sh', SH + 'px');const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];const pluralRules = {};// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.@@ -173,7 +178,7 @@ const isShortcut = (event, letter) => event.key.toLowerCase() === letter.toLowerconst isShortcutCode = (event, code) => /^\p{L}$/u.test(event.key) && !isLatinLetter(event.key) && event.code === code;document.body.insertAdjacentHTML('afterbegin', `<div id="frame">- <svg id="stage" viewBox="0 0 1600 900" role="img" aria-label="${translate('stageLabel')}">+ <svg id="stage" viewBox="0 0 ${SW} ${SH}" role="img" aria-label="${translate('stageLabel')}"><g id="scene"></g></svg><div id="ui"></div>@@ -265,12 +270,13 @@ const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8',}const MATH = bookSetting('--math-font') || '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';const NAME = { nat: translate('natural'), whole: translate('whole'), int: translate('integers'), rat: translate('rational'), irr: translate('irrational'), real: translate('real') };-// Card positions inside the 1600×900 picture.-const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // bottom band (moves up when taller than the space left)+// Card positions inside the picture. BAND and the screens follow the stage; RIGHT and TOPR are placed for the wide+// stage's number line and map and have no upright layout yet.+const BAND = { x: 96 * SW / 1600, y: SH - 214, w: SW - 192 * SW / 1600, 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 mapconst 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' };-const SORT_SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen sort' };+const SCREEN = { x: 0, y: 0, w: SW, cls: 'screen' };+const SORT_SCREEN = { x: 0, y: 0, w: SW, cls: 'screen sort' };const $m = (...parts) => ({ m: parts });function mk(tag, attrs = {}, parent) {@@ -623,8 +629,8 @@ const clockRun = (f, D, { tail = false } = {}) => { f(0); const w = { t0: 0, dur// Moves are keyed on the beat clock: to(view, t0, dur, ease) blends each given key from its value at t0; a key may be a// function of t (follow). Unspecified keys keep following the earlier moves. dur 0 is a hard cut.let camN = 0;-function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {}) {- const [bx, by, bw, bh] = box || [0, 0, 1600, 900];+function camera(p, D, { box, x = SW / 2, y = SH / 2, z, r = 0, bg = COL.board } = {}) {+ const [bx, by, bw, bh] = box || [0, 0, SW, SH];const el = G(p, { x: bx + bw / 2, y: by + bh / 2 });let hold = el;if (box) {@@ -635,7 +641,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})}const view = mk('g', {}, hold), world = G(view);if (box) mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18, fill: 'none', stroke: COL.faint, 'stroke-width': 2 }, el);- const v0 = { x, y, z: z ?? (box ? Math.min(bw / 1600, bh / 900) : 1), r };+ const v0 = { x, y, z: z ?? (box ? Math.min(bw / SW, bh / SH) : 1), r };const ops = [], shakes = [], layers = [];const val = (v, t) => typeof v === 'function' ? v(t) : v;// The view at time t after the first n moves; each move remembers the view it starts from.@@ -693,7 +699,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})/* ---------- scene ---------- */const scene = document.getElementById('scene');const S = {};-const AXIS = { o: 800, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change it+const AXIS = { o: SW / 2, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change itconst X = v => AXIS.o + AXIS.u * v, Y0 = 610;const num = v => (v < 0 ? '−' : '') + String(Math.abs(v)).replace('.', DECIMAL_SIGN);function reset() {@@ -813,7 +819,7 @@ function card(pos, cls) {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 fit = () => { c.style.top = Math.max(16, Math.min(pos.y, SH - 16 - c.offsetHeight)) + 'px'; };const ro = new ResizeObserver(fit);ro.observe(c); fit();P.cleanup.push(() => ro.disconnect());@@ -1514,7 +1520,7 @@ 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}||`;+ if (c?.classList.contains('band')) at = `${SH + 60 - 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;@@ -1614,7 +1620,7 @@ document.addEventListener('keydown', e => {// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });$('bHelp').onclick = toggleHelp;-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / 1640, (innerHeight - (innerWidth <= 700 ? 120 : 0)) / 1000));+const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));addEventListener('resize', fit);fit();diff --git a/site/joke-collection/lib/engine.css b/site/joke-collection/lib/engine.cssindex 3e6079a..436bdb6 100644--- a/site/joke-collection/lib/engine.css+++ b/site/joke-collection/lib/engine.css@@ -24,18 +24,18 @@ button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--task);button[hidden] { display: none; }/* One fixed 1600×960 frame (900 stage + 60 controls), scaled to fit the window. */-#frame { position: absolute; left: 50%; top: 50%; width: 1600px; height: 960px; transform: translate(-50%, -50%) scale(var(--k, .5));+#frame { position: absolute; left: 50%; top: 50%; width: var(--sw, 1600px); height: calc(var(--sh, 900px) + 60px); transform: translate(-50%, -50%) scale(var(--k, .5));border-radius: 20px; overflow: hidden; background: var(--board); box-shadow: 0 0 0 1px var(--edge), 0 30px 80px rgba(0, 0, 0, .45); }-#stage { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: block;+#stage { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: block;background: radial-gradient(75% 75% at 50% 45%, rgba(0,0,0,0) 60%, var(--vignette)), var(--grain, none), var(--board); }-#ui { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; pointer-events: none; }+#ui { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); pointer-events: none; }#ui > * { pointer-events: auto; }-.cover { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }+.cover { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }.cover[hidden] { display: none; }.cover > div { display: flex; flex-direction: column; align-items: center; }.cover-k { margin: 0 0 10px; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }-.cover-t { margin: 0 0 44px; max-width: 1200px; text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }+.cover-t { margin: 0 0 44px; max-width: min(1200px, calc(var(--sw, 1600px) - 100px)); text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }.cover > div > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }.cover-t { animation-delay: .08s; }.cover .go { animation-delay: .18s; }@@ -43,7 +43,7 @@ button[hidden] { display: none; }@keyframes rise { from { opacity: 0; transform: translateY(14px); } }.cover .go { display: inline-flex; align-items: center; gap: 16px; padding: 20px 40px; border-radius: 999px; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 32px; }.cover small { display: block; margin-top: 22px; font-size: 22px; text-align: center; color: var(--dim); }-.paused-mark { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: none; place-items: center; pointer-events: none; }+.paused-mark { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: none; place-items: center; pointer-events: none; }.paused .paused-mark { display: grid; }.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }@@ -105,7 +105,7 @@ button[hidden] { display: none; }.tok { cursor: grab; touch-action: none; } /* a finger drags the chip instead of scrolling the page *//* Controls strip, part of the frame. */-#bar { position: absolute; left: 0; top: 900px; width: 1600px; height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }+#bar { position: absolute; left: 0; top: var(--sh, 900px); width: var(--sw, 1600px); height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }.icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); display: grid; place-items: center; flex: none; padding: 0; }.icon svg { width: 18px; height: 18px; fill: var(--chalk); }.icon .i-pause { display: none; }@@ -121,7 +121,7 @@ button[hidden] { display: none; }/* Keep the control strip usable without scaling down its touch targets. */@media (max-width: 700px) {#frame { top: calc(50% - 50px); overflow: visible; }- #bar { width: calc(1600px * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;+ #bar { width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }#bar .icon { width: 36px; height: 40px; }.step { display: none; }@@ -150,9 +150,9 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }.keys kbd { margin: 0 .15em; }.grid .row.cur { background: color-mix(in srgb, var(--chalk) 5%, transparent); box-shadow: inset 4px 0 var(--quiz); }-.help { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }+.help { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }.help[hidden] { display: none; }-.help-box { width: 1120px; padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }+.help-box { width: min(1120px, calc(var(--sw, 1600px) - 80px)); padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }.help h2 { margin: 0 0 22px; font-size: 32px; font-weight: 600; }.help h3 { margin: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--quiz); }.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }@@ -164,7 +164,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }.icon.txt { font-size: 20px; font-weight: 700; color: var(--dim); }/* 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: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }+.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: min(1180px, calc(var(--sw, 1600px) - 80px)); padding: 10px 24px; border-radius: 14px; background: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }.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); }@@ -186,7 +186,7 @@ svg.m { display: inline-block; overflow: visible; }.screen .body { margin-top: 30px; }.card.screen { display: flex; flex-direction: column; }.screen .head { order: 1; } .screen .body { order: 2; }-.screen .fb { order: 3; max-width: 1080px; margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers */+.screen .fb { order: 3; max-width: min(1080px, calc(var(--sw, 1600px) - 140px)); margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers *//* Practice screens: the bottom 130 px hold the buttons. Long answers scroll inside the body, so the feedback underthem stays in view after a wrong answer adds a 'why' line to each row. */.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }@@ -240,7 +240,7 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }#ui a.cite:hover { color: var(--quiz); }-.fin .srcs { margin: 26px 0 0; max-width: 1100px; font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }@@ -259,3 +259,5 @@ a.btn { text-decoration: none; display: inline-block; }.fin .kicker { font-size: 20px; letter-spacing: .14em; text-transform: uppercase; }.fin .prompt { margin: 6px 0 14px; font: 500 56px/1.15 "Iowan Old Style", Palatino, Georgia, serif; }.icon.speed { width: auto; min-width: 44px; padding: 0 10px; border-radius: 22px; font-size: 16px; }+/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */+:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }diff --git a/site/joke-collection/lib/engine.js b/site/joke-collection/lib/engine.jsindex 4d3817c..0082c18 100644--- a/site/joke-collection/lib/engine.js+++ b/site/joke-collection/lib/engine.js@@ -151,6 +151,11 @@ const TRANSLATIONS = {watchAgain: 'もう一度見る', nextChapter: '次の章へ',},};+// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.+const PORTRAIT = document.documentElement.dataset.stage === 'portrait';+const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;+document.documentElement.style.setProperty('--sw', SW + 'px');+document.documentElement.style.setProperty('--sh', SH + 'px');const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];const pluralRules = {};// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.@@ -173,7 +178,7 @@ const isShortcut = (event, letter) => event.key.toLowerCase() === letter.toLowerconst isShortcutCode = (event, code) => /^\p{L}$/u.test(event.key) && !isLatinLetter(event.key) && event.code === code;document.body.insertAdjacentHTML('afterbegin', `<div id="frame">- <svg id="stage" viewBox="0 0 1600 900" role="img" aria-label="${translate('stageLabel')}">+ <svg id="stage" viewBox="0 0 ${SW} ${SH}" role="img" aria-label="${translate('stageLabel')}"><g id="scene"></g></svg><div id="ui"></div>@@ -265,12 +270,13 @@ const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8',}const MATH = bookSetting('--math-font') || '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';const NAME = { nat: translate('natural'), whole: translate('whole'), int: translate('integers'), rat: translate('rational'), irr: translate('irrational'), real: translate('real') };-// Card positions inside the 1600×900 picture.-const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // bottom band (moves up when taller than the space left)+// Card positions inside the picture. BAND and the screens follow the stage; RIGHT and TOPR are placed for the wide+// stage's number line and map and have no upright layout yet.+const BAND = { x: 96 * SW / 1600, y: SH - 214, w: SW - 192 * SW / 1600, 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 mapconst 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' };-const SORT_SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen sort' };+const SCREEN = { x: 0, y: 0, w: SW, cls: 'screen' };+const SORT_SCREEN = { x: 0, y: 0, w: SW, cls: 'screen sort' };const $m = (...parts) => ({ m: parts });function mk(tag, attrs = {}, parent) {@@ -623,8 +629,8 @@ const clockRun = (f, D, { tail = false } = {}) => { f(0); const w = { t0: 0, dur// Moves are keyed on the beat clock: to(view, t0, dur, ease) blends each given key from its value at t0; a key may be a// function of t (follow). Unspecified keys keep following the earlier moves. dur 0 is a hard cut.let camN = 0;-function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {}) {- const [bx, by, bw, bh] = box || [0, 0, 1600, 900];+function camera(p, D, { box, x = SW / 2, y = SH / 2, z, r = 0, bg = COL.board } = {}) {+ const [bx, by, bw, bh] = box || [0, 0, SW, SH];const el = G(p, { x: bx + bw / 2, y: by + bh / 2 });let hold = el;if (box) {@@ -635,7 +641,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})}const view = mk('g', {}, hold), world = G(view);if (box) mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18, fill: 'none', stroke: COL.faint, 'stroke-width': 2 }, el);- const v0 = { x, y, z: z ?? (box ? Math.min(bw / 1600, bh / 900) : 1), r };+ const v0 = { x, y, z: z ?? (box ? Math.min(bw / SW, bh / SH) : 1), r };const ops = [], shakes = [], layers = [];const val = (v, t) => typeof v === 'function' ? v(t) : v;// The view at time t after the first n moves; each move remembers the view it starts from.@@ -693,7 +699,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})/* ---------- scene ---------- */const scene = document.getElementById('scene');const S = {};-const AXIS = { o: 800, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change it+const AXIS = { o: SW / 2, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change itconst X = v => AXIS.o + AXIS.u * v, Y0 = 610;const num = v => (v < 0 ? '−' : '') + String(Math.abs(v)).replace('.', DECIMAL_SIGN);function reset() {@@ -813,7 +819,7 @@ function card(pos, cls) {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 fit = () => { c.style.top = Math.max(16, Math.min(pos.y, SH - 16 - c.offsetHeight)) + 'px'; };const ro = new ResizeObserver(fit);ro.observe(c); fit();P.cleanup.push(() => ro.disconnect());@@ -1514,7 +1520,7 @@ 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}||`;+ if (c?.classList.contains('band')) at = `${SH + 60 - 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;@@ -1614,7 +1620,7 @@ document.addEventListener('keydown', e => {// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });$('bHelp').onclick = toggleHelp;-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / 1640, (innerHeight - (innerWidth <= 700 ? 120 : 0)) / 1000));+const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));addEventListener('resize', fit);fit();diff --git a/site/little-red-riding-hood/lib/engine.css b/site/little-red-riding-hood/lib/engine.cssindex 3e6079a..436bdb6 100644--- a/site/little-red-riding-hood/lib/engine.css+++ b/site/little-red-riding-hood/lib/engine.css@@ -24,18 +24,18 @@ button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--task);button[hidden] { display: none; }/* One fixed 1600×960 frame (900 stage + 60 controls), scaled to fit the window. */-#frame { position: absolute; left: 50%; top: 50%; width: 1600px; height: 960px; transform: translate(-50%, -50%) scale(var(--k, .5));+#frame { position: absolute; left: 50%; top: 50%; width: var(--sw, 1600px); height: calc(var(--sh, 900px) + 60px); transform: translate(-50%, -50%) scale(var(--k, .5));border-radius: 20px; overflow: hidden; background: var(--board); box-shadow: 0 0 0 1px var(--edge), 0 30px 80px rgba(0, 0, 0, .45); }-#stage { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: block;+#stage { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: block;background: radial-gradient(75% 75% at 50% 45%, rgba(0,0,0,0) 60%, var(--vignette)), var(--grain, none), var(--board); }-#ui { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; pointer-events: none; }+#ui { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); pointer-events: none; }#ui > * { pointer-events: auto; }-.cover { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }+.cover { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }.cover[hidden] { display: none; }.cover > div { display: flex; flex-direction: column; align-items: center; }.cover-k { margin: 0 0 10px; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }-.cover-t { margin: 0 0 44px; max-width: 1200px; text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }+.cover-t { margin: 0 0 44px; max-width: min(1200px, calc(var(--sw, 1600px) - 100px)); text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }.cover > div > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }.cover-t { animation-delay: .08s; }.cover .go { animation-delay: .18s; }@@ -43,7 +43,7 @@ button[hidden] { display: none; }@keyframes rise { from { opacity: 0; transform: translateY(14px); } }.cover .go { display: inline-flex; align-items: center; gap: 16px; padding: 20px 40px; border-radius: 999px; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 32px; }.cover small { display: block; margin-top: 22px; font-size: 22px; text-align: center; color: var(--dim); }-.paused-mark { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: none; place-items: center; pointer-events: none; }+.paused-mark { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: none; place-items: center; pointer-events: none; }.paused .paused-mark { display: grid; }.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }@@ -105,7 +105,7 @@ button[hidden] { display: none; }.tok { cursor: grab; touch-action: none; } /* a finger drags the chip instead of scrolling the page *//* Controls strip, part of the frame. */-#bar { position: absolute; left: 0; top: 900px; width: 1600px; height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }+#bar { position: absolute; left: 0; top: var(--sh, 900px); width: var(--sw, 1600px); height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }.icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); display: grid; place-items: center; flex: none; padding: 0; }.icon svg { width: 18px; height: 18px; fill: var(--chalk); }.icon .i-pause { display: none; }@@ -121,7 +121,7 @@ button[hidden] { display: none; }/* Keep the control strip usable without scaling down its touch targets. */@media (max-width: 700px) {#frame { top: calc(50% - 50px); overflow: visible; }- #bar { width: calc(1600px * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;+ #bar { width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }#bar .icon { width: 36px; height: 40px; }.step { display: none; }@@ -150,9 +150,9 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }.keys kbd { margin: 0 .15em; }.grid .row.cur { background: color-mix(in srgb, var(--chalk) 5%, transparent); box-shadow: inset 4px 0 var(--quiz); }-.help { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }+.help { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }.help[hidden] { display: none; }-.help-box { width: 1120px; padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }+.help-box { width: min(1120px, calc(var(--sw, 1600px) - 80px)); padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }.help h2 { margin: 0 0 22px; font-size: 32px; font-weight: 600; }.help h3 { margin: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--quiz); }.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }@@ -164,7 +164,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }.icon.txt { font-size: 20px; font-weight: 700; color: var(--dim); }/* 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: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }+.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: min(1180px, calc(var(--sw, 1600px) - 80px)); padding: 10px 24px; border-radius: 14px; background: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }.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); }@@ -186,7 +186,7 @@ svg.m { display: inline-block; overflow: visible; }.screen .body { margin-top: 30px; }.card.screen { display: flex; flex-direction: column; }.screen .head { order: 1; } .screen .body { order: 2; }-.screen .fb { order: 3; max-width: 1080px; margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers */+.screen .fb { order: 3; max-width: min(1080px, calc(var(--sw, 1600px) - 140px)); margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers *//* Practice screens: the bottom 130 px hold the buttons. Long answers scroll inside the body, so the feedback underthem stays in view after a wrong answer adds a 'why' line to each row. */.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }@@ -240,7 +240,7 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }#ui a.cite:hover { color: var(--quiz); }-.fin .srcs { margin: 26px 0 0; max-width: 1100px; font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }@@ -259,3 +259,5 @@ a.btn { text-decoration: none; display: inline-block; }.fin .kicker { font-size: 20px; letter-spacing: .14em; text-transform: uppercase; }.fin .prompt { margin: 6px 0 14px; font: 500 56px/1.15 "Iowan Old Style", Palatino, Georgia, serif; }.icon.speed { width: auto; min-width: 44px; padding: 0 10px; border-radius: 22px; font-size: 16px; }+/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */+:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }diff --git a/site/little-red-riding-hood/lib/engine.js b/site/little-red-riding-hood/lib/engine.jsindex 4d3817c..0082c18 100644--- a/site/little-red-riding-hood/lib/engine.js+++ b/site/little-red-riding-hood/lib/engine.js@@ -151,6 +151,11 @@ const TRANSLATIONS = {watchAgain: 'もう一度見る', nextChapter: '次の章へ',},};+// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.+const PORTRAIT = document.documentElement.dataset.stage === 'portrait';+const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;+document.documentElement.style.setProperty('--sw', SW + 'px');+document.documentElement.style.setProperty('--sh', SH + 'px');const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];const pluralRules = {};// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.@@ -173,7 +178,7 @@ const isShortcut = (event, letter) => event.key.toLowerCase() === letter.toLowerconst isShortcutCode = (event, code) => /^\p{L}$/u.test(event.key) && !isLatinLetter(event.key) && event.code === code;document.body.insertAdjacentHTML('afterbegin', `<div id="frame">- <svg id="stage" viewBox="0 0 1600 900" role="img" aria-label="${translate('stageLabel')}">+ <svg id="stage" viewBox="0 0 ${SW} ${SH}" role="img" aria-label="${translate('stageLabel')}"><g id="scene"></g></svg><div id="ui"></div>@@ -265,12 +270,13 @@ const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8',}const MATH = bookSetting('--math-font') || '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';const NAME = { nat: translate('natural'), whole: translate('whole'), int: translate('integers'), rat: translate('rational'), irr: translate('irrational'), real: translate('real') };-// Card positions inside the 1600×900 picture.-const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // bottom band (moves up when taller than the space left)+// Card positions inside the picture. BAND and the screens follow the stage; RIGHT and TOPR are placed for the wide+// stage's number line and map and have no upright layout yet.+const BAND = { x: 96 * SW / 1600, y: SH - 214, w: SW - 192 * SW / 1600, 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 mapconst 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' };-const SORT_SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen sort' };+const SCREEN = { x: 0, y: 0, w: SW, cls: 'screen' };+const SORT_SCREEN = { x: 0, y: 0, w: SW, cls: 'screen sort' };const $m = (...parts) => ({ m: parts });function mk(tag, attrs = {}, parent) {@@ -623,8 +629,8 @@ const clockRun = (f, D, { tail = false } = {}) => { f(0); const w = { t0: 0, dur// Moves are keyed on the beat clock: to(view, t0, dur, ease) blends each given key from its value at t0; a key may be a// function of t (follow). Unspecified keys keep following the earlier moves. dur 0 is a hard cut.let camN = 0;-function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {}) {- const [bx, by, bw, bh] = box || [0, 0, 1600, 900];+function camera(p, D, { box, x = SW / 2, y = SH / 2, z, r = 0, bg = COL.board } = {}) {+ const [bx, by, bw, bh] = box || [0, 0, SW, SH];const el = G(p, { x: bx + bw / 2, y: by + bh / 2 });let hold = el;if (box) {@@ -635,7 +641,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})}const view = mk('g', {}, hold), world = G(view);if (box) mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18, fill: 'none', stroke: COL.faint, 'stroke-width': 2 }, el);- const v0 = { x, y, z: z ?? (box ? Math.min(bw / 1600, bh / 900) : 1), r };+ const v0 = { x, y, z: z ?? (box ? Math.min(bw / SW, bh / SH) : 1), r };const ops = [], shakes = [], layers = [];const val = (v, t) => typeof v === 'function' ? v(t) : v;// The view at time t after the first n moves; each move remembers the view it starts from.@@ -693,7 +699,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})/* ---------- scene ---------- */const scene = document.getElementById('scene');const S = {};-const AXIS = { o: 800, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change it+const AXIS = { o: SW / 2, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change itconst X = v => AXIS.o + AXIS.u * v, Y0 = 610;const num = v => (v < 0 ? '−' : '') + String(Math.abs(v)).replace('.', DECIMAL_SIGN);function reset() {@@ -813,7 +819,7 @@ function card(pos, cls) {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 fit = () => { c.style.top = Math.max(16, Math.min(pos.y, SH - 16 - c.offsetHeight)) + 'px'; };const ro = new ResizeObserver(fit);ro.observe(c); fit();P.cleanup.push(() => ro.disconnect());@@ -1514,7 +1520,7 @@ 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}||`;+ if (c?.classList.contains('band')) at = `${SH + 60 - 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;@@ -1614,7 +1620,7 @@ document.addEventListener('keydown', e => {// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });$('bHelp').onclick = toggleHelp;-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / 1640, (innerHeight - (innerWidth <= 700 ? 120 : 0)) / 1000));+const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));addEventListener('resize', fit);fit();diff --git a/site/madness/lib/engine.css b/site/madness/lib/engine.cssindex 3e6079a..436bdb6 100644--- a/site/madness/lib/engine.css+++ b/site/madness/lib/engine.css@@ -24,18 +24,18 @@ button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--task);button[hidden] { display: none; }/* One fixed 1600×960 frame (900 stage + 60 controls), scaled to fit the window. */-#frame { position: absolute; left: 50%; top: 50%; width: 1600px; height: 960px; transform: translate(-50%, -50%) scale(var(--k, .5));+#frame { position: absolute; left: 50%; top: 50%; width: var(--sw, 1600px); height: calc(var(--sh, 900px) + 60px); transform: translate(-50%, -50%) scale(var(--k, .5));border-radius: 20px; overflow: hidden; background: var(--board); box-shadow: 0 0 0 1px var(--edge), 0 30px 80px rgba(0, 0, 0, .45); }-#stage { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: block;+#stage { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: block;background: radial-gradient(75% 75% at 50% 45%, rgba(0,0,0,0) 60%, var(--vignette)), var(--grain, none), var(--board); }-#ui { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; pointer-events: none; }+#ui { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); pointer-events: none; }#ui > * { pointer-events: auto; }-.cover { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }+.cover { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }.cover[hidden] { display: none; }.cover > div { display: flex; flex-direction: column; align-items: center; }.cover-k { margin: 0 0 10px; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }-.cover-t { margin: 0 0 44px; max-width: 1200px; text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }+.cover-t { margin: 0 0 44px; max-width: min(1200px, calc(var(--sw, 1600px) - 100px)); text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }.cover > div > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }.cover-t { animation-delay: .08s; }.cover .go { animation-delay: .18s; }@@ -43,7 +43,7 @@ button[hidden] { display: none; }@keyframes rise { from { opacity: 0; transform: translateY(14px); } }.cover .go { display: inline-flex; align-items: center; gap: 16px; padding: 20px 40px; border-radius: 999px; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 32px; }.cover small { display: block; margin-top: 22px; font-size: 22px; text-align: center; color: var(--dim); }-.paused-mark { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: none; place-items: center; pointer-events: none; }+.paused-mark { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: none; place-items: center; pointer-events: none; }.paused .paused-mark { display: grid; }.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }@@ -105,7 +105,7 @@ button[hidden] { display: none; }.tok { cursor: grab; touch-action: none; } /* a finger drags the chip instead of scrolling the page *//* Controls strip, part of the frame. */-#bar { position: absolute; left: 0; top: 900px; width: 1600px; height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }+#bar { position: absolute; left: 0; top: var(--sh, 900px); width: var(--sw, 1600px); height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }.icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); display: grid; place-items: center; flex: none; padding: 0; }.icon svg { width: 18px; height: 18px; fill: var(--chalk); }.icon .i-pause { display: none; }@@ -121,7 +121,7 @@ button[hidden] { display: none; }/* Keep the control strip usable without scaling down its touch targets. */@media (max-width: 700px) {#frame { top: calc(50% - 50px); overflow: visible; }- #bar { width: calc(1600px * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;+ #bar { width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }#bar .icon { width: 36px; height: 40px; }.step { display: none; }@@ -150,9 +150,9 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }.keys kbd { margin: 0 .15em; }.grid .row.cur { background: color-mix(in srgb, var(--chalk) 5%, transparent); box-shadow: inset 4px 0 var(--quiz); }-.help { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }+.help { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }.help[hidden] { display: none; }-.help-box { width: 1120px; padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }+.help-box { width: min(1120px, calc(var(--sw, 1600px) - 80px)); padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }.help h2 { margin: 0 0 22px; font-size: 32px; font-weight: 600; }.help h3 { margin: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--quiz); }.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }@@ -164,7 +164,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }.icon.txt { font-size: 20px; font-weight: 700; color: var(--dim); }/* 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: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }+.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: min(1180px, calc(var(--sw, 1600px) - 80px)); padding: 10px 24px; border-radius: 14px; background: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }.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); }@@ -186,7 +186,7 @@ svg.m { display: inline-block; overflow: visible; }.screen .body { margin-top: 30px; }.card.screen { display: flex; flex-direction: column; }.screen .head { order: 1; } .screen .body { order: 2; }-.screen .fb { order: 3; max-width: 1080px; margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers */+.screen .fb { order: 3; max-width: min(1080px, calc(var(--sw, 1600px) - 140px)); margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers *//* Practice screens: the bottom 130 px hold the buttons. Long answers scroll inside the body, so the feedback underthem stays in view after a wrong answer adds a 'why' line to each row. */.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }@@ -240,7 +240,7 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }#ui a.cite:hover { color: var(--quiz); }-.fin .srcs { margin: 26px 0 0; max-width: 1100px; font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }@@ -259,3 +259,5 @@ a.btn { text-decoration: none; display: inline-block; }.fin .kicker { font-size: 20px; letter-spacing: .14em; text-transform: uppercase; }.fin .prompt { margin: 6px 0 14px; font: 500 56px/1.15 "Iowan Old Style", Palatino, Georgia, serif; }.icon.speed { width: auto; min-width: 44px; padding: 0 10px; border-radius: 22px; font-size: 16px; }+/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */+:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }diff --git a/site/madness/lib/engine.js b/site/madness/lib/engine.jsindex 4d3817c..0082c18 100644--- a/site/madness/lib/engine.js+++ b/site/madness/lib/engine.js@@ -151,6 +151,11 @@ const TRANSLATIONS = {watchAgain: 'もう一度見る', nextChapter: '次の章へ',},};+// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.+const PORTRAIT = document.documentElement.dataset.stage === 'portrait';+const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;+document.documentElement.style.setProperty('--sw', SW + 'px');+document.documentElement.style.setProperty('--sh', SH + 'px');const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];const pluralRules = {};// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.@@ -173,7 +178,7 @@ const isShortcut = (event, letter) => event.key.toLowerCase() === letter.toLowerconst isShortcutCode = (event, code) => /^\p{L}$/u.test(event.key) && !isLatinLetter(event.key) && event.code === code;document.body.insertAdjacentHTML('afterbegin', `<div id="frame">- <svg id="stage" viewBox="0 0 1600 900" role="img" aria-label="${translate('stageLabel')}">+ <svg id="stage" viewBox="0 0 ${SW} ${SH}" role="img" aria-label="${translate('stageLabel')}"><g id="scene"></g></svg><div id="ui"></div>@@ -265,12 +270,13 @@ const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8',}const MATH = bookSetting('--math-font') || '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';const NAME = { nat: translate('natural'), whole: translate('whole'), int: translate('integers'), rat: translate('rational'), irr: translate('irrational'), real: translate('real') };-// Card positions inside the 1600×900 picture.-const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // bottom band (moves up when taller than the space left)+// Card positions inside the picture. BAND and the screens follow the stage; RIGHT and TOPR are placed for the wide+// stage's number line and map and have no upright layout yet.+const BAND = { x: 96 * SW / 1600, y: SH - 214, w: SW - 192 * SW / 1600, 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 mapconst 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' };-const SORT_SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen sort' };+const SCREEN = { x: 0, y: 0, w: SW, cls: 'screen' };+const SORT_SCREEN = { x: 0, y: 0, w: SW, cls: 'screen sort' };const $m = (...parts) => ({ m: parts });function mk(tag, attrs = {}, parent) {@@ -623,8 +629,8 @@ const clockRun = (f, D, { tail = false } = {}) => { f(0); const w = { t0: 0, dur// Moves are keyed on the beat clock: to(view, t0, dur, ease) blends each given key from its value at t0; a key may be a// function of t (follow). Unspecified keys keep following the earlier moves. dur 0 is a hard cut.let camN = 0;-function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {}) {- const [bx, by, bw, bh] = box || [0, 0, 1600, 900];+function camera(p, D, { box, x = SW / 2, y = SH / 2, z, r = 0, bg = COL.board } = {}) {+ const [bx, by, bw, bh] = box || [0, 0, SW, SH];const el = G(p, { x: bx + bw / 2, y: by + bh / 2 });let hold = el;if (box) {@@ -635,7 +641,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})}const view = mk('g', {}, hold), world = G(view);if (box) mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18, fill: 'none', stroke: COL.faint, 'stroke-width': 2 }, el);- const v0 = { x, y, z: z ?? (box ? Math.min(bw / 1600, bh / 900) : 1), r };+ const v0 = { x, y, z: z ?? (box ? Math.min(bw / SW, bh / SH) : 1), r };const ops = [], shakes = [], layers = [];const val = (v, t) => typeof v === 'function' ? v(t) : v;// The view at time t after the first n moves; each move remembers the view it starts from.@@ -693,7 +699,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})/* ---------- scene ---------- */const scene = document.getElementById('scene');const S = {};-const AXIS = { o: 800, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change it+const AXIS = { o: SW / 2, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change itconst X = v => AXIS.o + AXIS.u * v, Y0 = 610;const num = v => (v < 0 ? '−' : '') + String(Math.abs(v)).replace('.', DECIMAL_SIGN);function reset() {@@ -813,7 +819,7 @@ function card(pos, cls) {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 fit = () => { c.style.top = Math.max(16, Math.min(pos.y, SH - 16 - c.offsetHeight)) + 'px'; };const ro = new ResizeObserver(fit);ro.observe(c); fit();P.cleanup.push(() => ro.disconnect());@@ -1514,7 +1520,7 @@ 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}||`;+ if (c?.classList.contains('band')) at = `${SH + 60 - 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;@@ -1614,7 +1620,7 @@ document.addEventListener('keydown', e => {// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });$('bHelp').onclick = toggleHelp;-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / 1640, (innerHeight - (innerWidth <= 700 ? 120 : 0)) / 1000));+const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));addEventListener('resize', fit);fit();diff --git a/site/math-notebook/lib/engine.css b/site/math-notebook/lib/engine.cssindex 3e6079a..436bdb6 100644--- a/site/math-notebook/lib/engine.css+++ b/site/math-notebook/lib/engine.css@@ -24,18 +24,18 @@ button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--task);button[hidden] { display: none; }/* One fixed 1600×960 frame (900 stage + 60 controls), scaled to fit the window. */-#frame { position: absolute; left: 50%; top: 50%; width: 1600px; height: 960px; transform: translate(-50%, -50%) scale(var(--k, .5));+#frame { position: absolute; left: 50%; top: 50%; width: var(--sw, 1600px); height: calc(var(--sh, 900px) + 60px); transform: translate(-50%, -50%) scale(var(--k, .5));border-radius: 20px; overflow: hidden; background: var(--board); box-shadow: 0 0 0 1px var(--edge), 0 30px 80px rgba(0, 0, 0, .45); }-#stage { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: block;+#stage { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: block;background: radial-gradient(75% 75% at 50% 45%, rgba(0,0,0,0) 60%, var(--vignette)), var(--grain, none), var(--board); }-#ui { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; pointer-events: none; }+#ui { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); pointer-events: none; }#ui > * { pointer-events: auto; }-.cover { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }+.cover { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }.cover[hidden] { display: none; }.cover > div { display: flex; flex-direction: column; align-items: center; }.cover-k { margin: 0 0 10px; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }-.cover-t { margin: 0 0 44px; max-width: 1200px; text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }+.cover-t { margin: 0 0 44px; max-width: min(1200px, calc(var(--sw, 1600px) - 100px)); text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }.cover > div > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }.cover-t { animation-delay: .08s; }.cover .go { animation-delay: .18s; }@@ -43,7 +43,7 @@ button[hidden] { display: none; }@keyframes rise { from { opacity: 0; transform: translateY(14px); } }.cover .go { display: inline-flex; align-items: center; gap: 16px; padding: 20px 40px; border-radius: 999px; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 32px; }.cover small { display: block; margin-top: 22px; font-size: 22px; text-align: center; color: var(--dim); }-.paused-mark { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: none; place-items: center; pointer-events: none; }+.paused-mark { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: none; place-items: center; pointer-events: none; }.paused .paused-mark { display: grid; }.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }@@ -105,7 +105,7 @@ button[hidden] { display: none; }.tok { cursor: grab; touch-action: none; } /* a finger drags the chip instead of scrolling the page *//* Controls strip, part of the frame. */-#bar { position: absolute; left: 0; top: 900px; width: 1600px; height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }+#bar { position: absolute; left: 0; top: var(--sh, 900px); width: var(--sw, 1600px); height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }.icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); display: grid; place-items: center; flex: none; padding: 0; }.icon svg { width: 18px; height: 18px; fill: var(--chalk); }.icon .i-pause { display: none; }@@ -121,7 +121,7 @@ button[hidden] { display: none; }/* Keep the control strip usable without scaling down its touch targets. */@media (max-width: 700px) {#frame { top: calc(50% - 50px); overflow: visible; }- #bar { width: calc(1600px * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;+ #bar { width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }#bar .icon { width: 36px; height: 40px; }.step { display: none; }@@ -150,9 +150,9 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }.keys kbd { margin: 0 .15em; }.grid .row.cur { background: color-mix(in srgb, var(--chalk) 5%, transparent); box-shadow: inset 4px 0 var(--quiz); }-.help { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }+.help { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }.help[hidden] { display: none; }-.help-box { width: 1120px; padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }+.help-box { width: min(1120px, calc(var(--sw, 1600px) - 80px)); padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }.help h2 { margin: 0 0 22px; font-size: 32px; font-weight: 600; }.help h3 { margin: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--quiz); }.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }@@ -164,7 +164,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }.icon.txt { font-size: 20px; font-weight: 700; color: var(--dim); }/* 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: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }+.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: min(1180px, calc(var(--sw, 1600px) - 80px)); padding: 10px 24px; border-radius: 14px; background: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }.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); }@@ -186,7 +186,7 @@ svg.m { display: inline-block; overflow: visible; }.screen .body { margin-top: 30px; }.card.screen { display: flex; flex-direction: column; }.screen .head { order: 1; } .screen .body { order: 2; }-.screen .fb { order: 3; max-width: 1080px; margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers */+.screen .fb { order: 3; max-width: min(1080px, calc(var(--sw, 1600px) - 140px)); margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers *//* Practice screens: the bottom 130 px hold the buttons. Long answers scroll inside the body, so the feedback underthem stays in view after a wrong answer adds a 'why' line to each row. */.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }@@ -240,7 +240,7 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }#ui a.cite:hover { color: var(--quiz); }-.fin .srcs { margin: 26px 0 0; max-width: 1100px; font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }@@ -259,3 +259,5 @@ a.btn { text-decoration: none; display: inline-block; }.fin .kicker { font-size: 20px; letter-spacing: .14em; text-transform: uppercase; }.fin .prompt { margin: 6px 0 14px; font: 500 56px/1.15 "Iowan Old Style", Palatino, Georgia, serif; }.icon.speed { width: auto; min-width: 44px; padding: 0 10px; border-radius: 22px; font-size: 16px; }+/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */+:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }diff --git a/site/math-notebook/lib/engine.js b/site/math-notebook/lib/engine.jsindex 4d3817c..0082c18 100644--- a/site/math-notebook/lib/engine.js+++ b/site/math-notebook/lib/engine.js@@ -151,6 +151,11 @@ const TRANSLATIONS = {watchAgain: 'もう一度見る', nextChapter: '次の章へ',},};+// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.+const PORTRAIT = document.documentElement.dataset.stage === 'portrait';+const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;+document.documentElement.style.setProperty('--sw', SW + 'px');+document.documentElement.style.setProperty('--sh', SH + 'px');const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];const pluralRules = {};// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.@@ -173,7 +178,7 @@ const isShortcut = (event, letter) => event.key.toLowerCase() === letter.toLowerconst isShortcutCode = (event, code) => /^\p{L}$/u.test(event.key) && !isLatinLetter(event.key) && event.code === code;document.body.insertAdjacentHTML('afterbegin', `<div id="frame">- <svg id="stage" viewBox="0 0 1600 900" role="img" aria-label="${translate('stageLabel')}">+ <svg id="stage" viewBox="0 0 ${SW} ${SH}" role="img" aria-label="${translate('stageLabel')}"><g id="scene"></g></svg><div id="ui"></div>@@ -265,12 +270,13 @@ const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8',}const MATH = bookSetting('--math-font') || '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';const NAME = { nat: translate('natural'), whole: translate('whole'), int: translate('integers'), rat: translate('rational'), irr: translate('irrational'), real: translate('real') };-// Card positions inside the 1600×900 picture.-const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // bottom band (moves up when taller than the space left)+// Card positions inside the picture. BAND and the screens follow the stage; RIGHT and TOPR are placed for the wide+// stage's number line and map and have no upright layout yet.+const BAND = { x: 96 * SW / 1600, y: SH - 214, w: SW - 192 * SW / 1600, 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 mapconst 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' };-const SORT_SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen sort' };+const SCREEN = { x: 0, y: 0, w: SW, cls: 'screen' };+const SORT_SCREEN = { x: 0, y: 0, w: SW, cls: 'screen sort' };const $m = (...parts) => ({ m: parts });function mk(tag, attrs = {}, parent) {@@ -623,8 +629,8 @@ const clockRun = (f, D, { tail = false } = {}) => { f(0); const w = { t0: 0, dur// Moves are keyed on the beat clock: to(view, t0, dur, ease) blends each given key from its value at t0; a key may be a// function of t (follow). Unspecified keys keep following the earlier moves. dur 0 is a hard cut.let camN = 0;-function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {}) {- const [bx, by, bw, bh] = box || [0, 0, 1600, 900];+function camera(p, D, { box, x = SW / 2, y = SH / 2, z, r = 0, bg = COL.board } = {}) {+ const [bx, by, bw, bh] = box || [0, 0, SW, SH];const el = G(p, { x: bx + bw / 2, y: by + bh / 2 });let hold = el;if (box) {@@ -635,7 +641,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})}const view = mk('g', {}, hold), world = G(view);if (box) mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18, fill: 'none', stroke: COL.faint, 'stroke-width': 2 }, el);- const v0 = { x, y, z: z ?? (box ? Math.min(bw / 1600, bh / 900) : 1), r };+ const v0 = { x, y, z: z ?? (box ? Math.min(bw / SW, bh / SH) : 1), r };const ops = [], shakes = [], layers = [];const val = (v, t) => typeof v === 'function' ? v(t) : v;// The view at time t after the first n moves; each move remembers the view it starts from.@@ -693,7 +699,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})/* ---------- scene ---------- */const scene = document.getElementById('scene');const S = {};-const AXIS = { o: 800, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change it+const AXIS = { o: SW / 2, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change itconst X = v => AXIS.o + AXIS.u * v, Y0 = 610;const num = v => (v < 0 ? '−' : '') + String(Math.abs(v)).replace('.', DECIMAL_SIGN);function reset() {@@ -813,7 +819,7 @@ function card(pos, cls) {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 fit = () => { c.style.top = Math.max(16, Math.min(pos.y, SH - 16 - c.offsetHeight)) + 'px'; };const ro = new ResizeObserver(fit);ro.observe(c); fit();P.cleanup.push(() => ro.disconnect());@@ -1514,7 +1520,7 @@ 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}||`;+ if (c?.classList.contains('band')) at = `${SH + 60 - 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;@@ -1614,7 +1620,7 @@ document.addEventListener('keydown', e => {// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });$('bHelp').onclick = toggleHelp;-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / 1640, (innerHeight - (innerWidth <= 700 ? 120 : 0)) / 1000));+const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));addEventListener('resize', fit);fit();diff --git a/site/physics-notebook/lib/engine.css b/site/physics-notebook/lib/engine.cssindex 3e6079a..436bdb6 100644--- a/site/physics-notebook/lib/engine.css+++ b/site/physics-notebook/lib/engine.css@@ -24,18 +24,18 @@ button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--task);button[hidden] { display: none; }/* One fixed 1600×960 frame (900 stage + 60 controls), scaled to fit the window. */-#frame { position: absolute; left: 50%; top: 50%; width: 1600px; height: 960px; transform: translate(-50%, -50%) scale(var(--k, .5));+#frame { position: absolute; left: 50%; top: 50%; width: var(--sw, 1600px); height: calc(var(--sh, 900px) + 60px); transform: translate(-50%, -50%) scale(var(--k, .5));border-radius: 20px; overflow: hidden; background: var(--board); box-shadow: 0 0 0 1px var(--edge), 0 30px 80px rgba(0, 0, 0, .45); }-#stage { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: block;+#stage { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: block;background: radial-gradient(75% 75% at 50% 45%, rgba(0,0,0,0) 60%, var(--vignette)), var(--grain, none), var(--board); }-#ui { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; pointer-events: none; }+#ui { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); pointer-events: none; }#ui > * { pointer-events: auto; }-.cover { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }+.cover { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }.cover[hidden] { display: none; }.cover > div { display: flex; flex-direction: column; align-items: center; }.cover-k { margin: 0 0 10px; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }-.cover-t { margin: 0 0 44px; max-width: 1200px; text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }+.cover-t { margin: 0 0 44px; max-width: min(1200px, calc(var(--sw, 1600px) - 100px)); text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }.cover > div > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }.cover-t { animation-delay: .08s; }.cover .go { animation-delay: .18s; }@@ -43,7 +43,7 @@ button[hidden] { display: none; }@keyframes rise { from { opacity: 0; transform: translateY(14px); } }.cover .go { display: inline-flex; align-items: center; gap: 16px; padding: 20px 40px; border-radius: 999px; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 32px; }.cover small { display: block; margin-top: 22px; font-size: 22px; text-align: center; color: var(--dim); }-.paused-mark { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: none; place-items: center; pointer-events: none; }+.paused-mark { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: none; place-items: center; pointer-events: none; }.paused .paused-mark { display: grid; }.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }@@ -105,7 +105,7 @@ button[hidden] { display: none; }.tok { cursor: grab; touch-action: none; } /* a finger drags the chip instead of scrolling the page *//* Controls strip, part of the frame. */-#bar { position: absolute; left: 0; top: 900px; width: 1600px; height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }+#bar { position: absolute; left: 0; top: var(--sh, 900px); width: var(--sw, 1600px); height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }.icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); display: grid; place-items: center; flex: none; padding: 0; }.icon svg { width: 18px; height: 18px; fill: var(--chalk); }.icon .i-pause { display: none; }@@ -121,7 +121,7 @@ button[hidden] { display: none; }/* Keep the control strip usable without scaling down its touch targets. */@media (max-width: 700px) {#frame { top: calc(50% - 50px); overflow: visible; }- #bar { width: calc(1600px * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;+ #bar { width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }#bar .icon { width: 36px; height: 40px; }.step { display: none; }@@ -150,9 +150,9 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }.keys kbd { margin: 0 .15em; }.grid .row.cur { background: color-mix(in srgb, var(--chalk) 5%, transparent); box-shadow: inset 4px 0 var(--quiz); }-.help { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }+.help { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }.help[hidden] { display: none; }-.help-box { width: 1120px; padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }+.help-box { width: min(1120px, calc(var(--sw, 1600px) - 80px)); padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }.help h2 { margin: 0 0 22px; font-size: 32px; font-weight: 600; }.help h3 { margin: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--quiz); }.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }@@ -164,7 +164,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }.icon.txt { font-size: 20px; font-weight: 700; color: var(--dim); }/* 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: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }+.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: min(1180px, calc(var(--sw, 1600px) - 80px)); padding: 10px 24px; border-radius: 14px; background: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }.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); }@@ -186,7 +186,7 @@ svg.m { display: inline-block; overflow: visible; }.screen .body { margin-top: 30px; }.card.screen { display: flex; flex-direction: column; }.screen .head { order: 1; } .screen .body { order: 2; }-.screen .fb { order: 3; max-width: 1080px; margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers */+.screen .fb { order: 3; max-width: min(1080px, calc(var(--sw, 1600px) - 140px)); margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers *//* Practice screens: the bottom 130 px hold the buttons. Long answers scroll inside the body, so the feedback underthem stays in view after a wrong answer adds a 'why' line to each row. */.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }@@ -240,7 +240,7 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }#ui a.cite:hover { color: var(--quiz); }-.fin .srcs { margin: 26px 0 0; max-width: 1100px; font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }@@ -259,3 +259,5 @@ a.btn { text-decoration: none; display: inline-block; }.fin .kicker { font-size: 20px; letter-spacing: .14em; text-transform: uppercase; }.fin .prompt { margin: 6px 0 14px; font: 500 56px/1.15 "Iowan Old Style", Palatino, Georgia, serif; }.icon.speed { width: auto; min-width: 44px; padding: 0 10px; border-radius: 22px; font-size: 16px; }+/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */+:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }diff --git a/site/physics-notebook/lib/engine.js b/site/physics-notebook/lib/engine.jsindex 4d3817c..0082c18 100644--- a/site/physics-notebook/lib/engine.js+++ b/site/physics-notebook/lib/engine.js@@ -151,6 +151,11 @@ const TRANSLATIONS = {watchAgain: 'もう一度見る', nextChapter: '次の章へ',},};+// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.+const PORTRAIT = document.documentElement.dataset.stage === 'portrait';+const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;+document.documentElement.style.setProperty('--sw', SW + 'px');+document.documentElement.style.setProperty('--sh', SH + 'px');const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];const pluralRules = {};// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.@@ -173,7 +178,7 @@ const isShortcut = (event, letter) => event.key.toLowerCase() === letter.toLowerconst isShortcutCode = (event, code) => /^\p{L}$/u.test(event.key) && !isLatinLetter(event.key) && event.code === code;document.body.insertAdjacentHTML('afterbegin', `<div id="frame">- <svg id="stage" viewBox="0 0 1600 900" role="img" aria-label="${translate('stageLabel')}">+ <svg id="stage" viewBox="0 0 ${SW} ${SH}" role="img" aria-label="${translate('stageLabel')}"><g id="scene"></g></svg><div id="ui"></div>@@ -265,12 +270,13 @@ const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8',}const MATH = bookSetting('--math-font') || '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';const NAME = { nat: translate('natural'), whole: translate('whole'), int: translate('integers'), rat: translate('rational'), irr: translate('irrational'), real: translate('real') };-// Card positions inside the 1600×900 picture.-const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // bottom band (moves up when taller than the space left)+// Card positions inside the picture. BAND and the screens follow the stage; RIGHT and TOPR are placed for the wide+// stage's number line and map and have no upright layout yet.+const BAND = { x: 96 * SW / 1600, y: SH - 214, w: SW - 192 * SW / 1600, 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 mapconst 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' };-const SORT_SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen sort' };+const SCREEN = { x: 0, y: 0, w: SW, cls: 'screen' };+const SORT_SCREEN = { x: 0, y: 0, w: SW, cls: 'screen sort' };const $m = (...parts) => ({ m: parts });function mk(tag, attrs = {}, parent) {@@ -623,8 +629,8 @@ const clockRun = (f, D, { tail = false } = {}) => { f(0); const w = { t0: 0, dur// Moves are keyed on the beat clock: to(view, t0, dur, ease) blends each given key from its value at t0; a key may be a// function of t (follow). Unspecified keys keep following the earlier moves. dur 0 is a hard cut.let camN = 0;-function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {}) {- const [bx, by, bw, bh] = box || [0, 0, 1600, 900];+function camera(p, D, { box, x = SW / 2, y = SH / 2, z, r = 0, bg = COL.board } = {}) {+ const [bx, by, bw, bh] = box || [0, 0, SW, SH];const el = G(p, { x: bx + bw / 2, y: by + bh / 2 });let hold = el;if (box) {@@ -635,7 +641,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})}const view = mk('g', {}, hold), world = G(view);if (box) mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18, fill: 'none', stroke: COL.faint, 'stroke-width': 2 }, el);- const v0 = { x, y, z: z ?? (box ? Math.min(bw / 1600, bh / 900) : 1), r };+ const v0 = { x, y, z: z ?? (box ? Math.min(bw / SW, bh / SH) : 1), r };const ops = [], shakes = [], layers = [];const val = (v, t) => typeof v === 'function' ? v(t) : v;// The view at time t after the first n moves; each move remembers the view it starts from.@@ -693,7 +699,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})/* ---------- scene ---------- */const scene = document.getElementById('scene');const S = {};-const AXIS = { o: 800, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change it+const AXIS = { o: SW / 2, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change itconst X = v => AXIS.o + AXIS.u * v, Y0 = 610;const num = v => (v < 0 ? '−' : '') + String(Math.abs(v)).replace('.', DECIMAL_SIGN);function reset() {@@ -813,7 +819,7 @@ function card(pos, cls) {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 fit = () => { c.style.top = Math.max(16, Math.min(pos.y, SH - 16 - c.offsetHeight)) + 'px'; };const ro = new ResizeObserver(fit);ro.observe(c); fit();P.cleanup.push(() => ro.disconnect());@@ -1514,7 +1520,7 @@ 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}||`;+ if (c?.classList.contains('band')) at = `${SH + 60 - 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;@@ -1614,7 +1620,7 @@ document.addEventListener('keydown', e => {// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });$('bHelp').onclick = toggleHelp;-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / 1640, (innerHeight - (innerWidth <= 700 ? 120 : 0)) / 1000));+const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));addEventListener('resize', fit);fit();diff --git a/site/science/lib/engine.css b/site/science/lib/engine.cssindex 3e6079a..436bdb6 100644--- a/site/science/lib/engine.css+++ b/site/science/lib/engine.css@@ -24,18 +24,18 @@ button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--task);button[hidden] { display: none; }/* One fixed 1600×960 frame (900 stage + 60 controls), scaled to fit the window. */-#frame { position: absolute; left: 50%; top: 50%; width: 1600px; height: 960px; transform: translate(-50%, -50%) scale(var(--k, .5));+#frame { position: absolute; left: 50%; top: 50%; width: var(--sw, 1600px); height: calc(var(--sh, 900px) + 60px); transform: translate(-50%, -50%) scale(var(--k, .5));border-radius: 20px; overflow: hidden; background: var(--board); box-shadow: 0 0 0 1px var(--edge), 0 30px 80px rgba(0, 0, 0, .45); }-#stage { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: block;+#stage { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: block;background: radial-gradient(75% 75% at 50% 45%, rgba(0,0,0,0) 60%, var(--vignette)), var(--grain, none), var(--board); }-#ui { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; pointer-events: none; }+#ui { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); pointer-events: none; }#ui > * { pointer-events: auto; }-.cover { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }+.cover { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }.cover[hidden] { display: none; }.cover > div { display: flex; flex-direction: column; align-items: center; }.cover-k { margin: 0 0 10px; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }-.cover-t { margin: 0 0 44px; max-width: 1200px; text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }+.cover-t { margin: 0 0 44px; max-width: min(1200px, calc(var(--sw, 1600px) - 100px)); text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }.cover > div > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }.cover-t { animation-delay: .08s; }.cover .go { animation-delay: .18s; }@@ -43,7 +43,7 @@ button[hidden] { display: none; }@keyframes rise { from { opacity: 0; transform: translateY(14px); } }.cover .go { display: inline-flex; align-items: center; gap: 16px; padding: 20px 40px; border-radius: 999px; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 32px; }.cover small { display: block; margin-top: 22px; font-size: 22px; text-align: center; color: var(--dim); }-.paused-mark { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: none; place-items: center; pointer-events: none; }+.paused-mark { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: none; place-items: center; pointer-events: none; }.paused .paused-mark { display: grid; }.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }@@ -105,7 +105,7 @@ button[hidden] { display: none; }.tok { cursor: grab; touch-action: none; } /* a finger drags the chip instead of scrolling the page *//* Controls strip, part of the frame. */-#bar { position: absolute; left: 0; top: 900px; width: 1600px; height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }+#bar { position: absolute; left: 0; top: var(--sh, 900px); width: var(--sw, 1600px); height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }.icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); display: grid; place-items: center; flex: none; padding: 0; }.icon svg { width: 18px; height: 18px; fill: var(--chalk); }.icon .i-pause { display: none; }@@ -121,7 +121,7 @@ button[hidden] { display: none; }/* Keep the control strip usable without scaling down its touch targets. */@media (max-width: 700px) {#frame { top: calc(50% - 50px); overflow: visible; }- #bar { width: calc(1600px * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;+ #bar { width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }#bar .icon { width: 36px; height: 40px; }.step { display: none; }@@ -150,9 +150,9 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }.keys kbd { margin: 0 .15em; }.grid .row.cur { background: color-mix(in srgb, var(--chalk) 5%, transparent); box-shadow: inset 4px 0 var(--quiz); }-.help { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }+.help { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }.help[hidden] { display: none; }-.help-box { width: 1120px; padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }+.help-box { width: min(1120px, calc(var(--sw, 1600px) - 80px)); padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }.help h2 { margin: 0 0 22px; font-size: 32px; font-weight: 600; }.help h3 { margin: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--quiz); }.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }@@ -164,7 +164,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }.icon.txt { font-size: 20px; font-weight: 700; color: var(--dim); }/* 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: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }+.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: min(1180px, calc(var(--sw, 1600px) - 80px)); padding: 10px 24px; border-radius: 14px; background: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }.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); }@@ -186,7 +186,7 @@ svg.m { display: inline-block; overflow: visible; }.screen .body { margin-top: 30px; }.card.screen { display: flex; flex-direction: column; }.screen .head { order: 1; } .screen .body { order: 2; }-.screen .fb { order: 3; max-width: 1080px; margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers */+.screen .fb { order: 3; max-width: min(1080px, calc(var(--sw, 1600px) - 140px)); margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers *//* Practice screens: the bottom 130 px hold the buttons. Long answers scroll inside the body, so the feedback underthem stays in view after a wrong answer adds a 'why' line to each row. */.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }@@ -240,7 +240,7 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }#ui a.cite:hover { color: var(--quiz); }-.fin .srcs { margin: 26px 0 0; max-width: 1100px; font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }@@ -259,3 +259,5 @@ a.btn { text-decoration: none; display: inline-block; }.fin .kicker { font-size: 20px; letter-spacing: .14em; text-transform: uppercase; }.fin .prompt { margin: 6px 0 14px; font: 500 56px/1.15 "Iowan Old Style", Palatino, Georgia, serif; }.icon.speed { width: auto; min-width: 44px; padding: 0 10px; border-radius: 22px; font-size: 16px; }+/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */+:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }diff --git a/site/science/lib/engine.js b/site/science/lib/engine.jsindex 4d3817c..0082c18 100644--- a/site/science/lib/engine.js+++ b/site/science/lib/engine.js@@ -151,6 +151,11 @@ const TRANSLATIONS = {watchAgain: 'もう一度見る', nextChapter: '次の章へ',},};+// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.+const PORTRAIT = document.documentElement.dataset.stage === 'portrait';+const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;+document.documentElement.style.setProperty('--sw', SW + 'px');+document.documentElement.style.setProperty('--sh', SH + 'px');const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];const pluralRules = {};// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.@@ -173,7 +178,7 @@ const isShortcut = (event, letter) => event.key.toLowerCase() === letter.toLowerconst isShortcutCode = (event, code) => /^\p{L}$/u.test(event.key) && !isLatinLetter(event.key) && event.code === code;document.body.insertAdjacentHTML('afterbegin', `<div id="frame">- <svg id="stage" viewBox="0 0 1600 900" role="img" aria-label="${translate('stageLabel')}">+ <svg id="stage" viewBox="0 0 ${SW} ${SH}" role="img" aria-label="${translate('stageLabel')}"><g id="scene"></g></svg><div id="ui"></div>@@ -265,12 +270,13 @@ const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8',}const MATH = bookSetting('--math-font') || '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';const NAME = { nat: translate('natural'), whole: translate('whole'), int: translate('integers'), rat: translate('rational'), irr: translate('irrational'), real: translate('real') };-// Card positions inside the 1600×900 picture.-const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // bottom band (moves up when taller than the space left)+// Card positions inside the picture. BAND and the screens follow the stage; RIGHT and TOPR are placed for the wide+// stage's number line and map and have no upright layout yet.+const BAND = { x: 96 * SW / 1600, y: SH - 214, w: SW - 192 * SW / 1600, 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 mapconst 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' };-const SORT_SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen sort' };+const SCREEN = { x: 0, y: 0, w: SW, cls: 'screen' };+const SORT_SCREEN = { x: 0, y: 0, w: SW, cls: 'screen sort' };const $m = (...parts) => ({ m: parts });function mk(tag, attrs = {}, parent) {@@ -623,8 +629,8 @@ const clockRun = (f, D, { tail = false } = {}) => { f(0); const w = { t0: 0, dur// Moves are keyed on the beat clock: to(view, t0, dur, ease) blends each given key from its value at t0; a key may be a// function of t (follow). Unspecified keys keep following the earlier moves. dur 0 is a hard cut.let camN = 0;-function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {}) {- const [bx, by, bw, bh] = box || [0, 0, 1600, 900];+function camera(p, D, { box, x = SW / 2, y = SH / 2, z, r = 0, bg = COL.board } = {}) {+ const [bx, by, bw, bh] = box || [0, 0, SW, SH];const el = G(p, { x: bx + bw / 2, y: by + bh / 2 });let hold = el;if (box) {@@ -635,7 +641,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})}const view = mk('g', {}, hold), world = G(view);if (box) mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18, fill: 'none', stroke: COL.faint, 'stroke-width': 2 }, el);- const v0 = { x, y, z: z ?? (box ? Math.min(bw / 1600, bh / 900) : 1), r };+ const v0 = { x, y, z: z ?? (box ? Math.min(bw / SW, bh / SH) : 1), r };const ops = [], shakes = [], layers = [];const val = (v, t) => typeof v === 'function' ? v(t) : v;// The view at time t after the first n moves; each move remembers the view it starts from.@@ -693,7 +699,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})/* ---------- scene ---------- */const scene = document.getElementById('scene');const S = {};-const AXIS = { o: 800, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change it+const AXIS = { o: SW / 2, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change itconst X = v => AXIS.o + AXIS.u * v, Y0 = 610;const num = v => (v < 0 ? '−' : '') + String(Math.abs(v)).replace('.', DECIMAL_SIGN);function reset() {@@ -813,7 +819,7 @@ function card(pos, cls) {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 fit = () => { c.style.top = Math.max(16, Math.min(pos.y, SH - 16 - c.offsetHeight)) + 'px'; };const ro = new ResizeObserver(fit);ro.observe(c); fit();P.cleanup.push(() => ro.disconnect());@@ -1514,7 +1520,7 @@ 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}||`;+ if (c?.classList.contains('band')) at = `${SH + 60 - 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;@@ -1614,7 +1620,7 @@ document.addEventListener('keydown', e => {// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });$('bHelp').onclick = toggleHelp;-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / 1640, (innerHeight - (innerWidth <= 700 ? 120 : 0)) / 1000));+const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));addEventListener('resize', fit);fit();diff --git a/site/three-little-pigs/lib/engine.css b/site/three-little-pigs/lib/engine.cssindex 3e6079a..436bdb6 100644--- a/site/three-little-pigs/lib/engine.css+++ b/site/three-little-pigs/lib/engine.css@@ -24,18 +24,18 @@ button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--task);button[hidden] { display: none; }/* One fixed 1600×960 frame (900 stage + 60 controls), scaled to fit the window. */-#frame { position: absolute; left: 50%; top: 50%; width: 1600px; height: 960px; transform: translate(-50%, -50%) scale(var(--k, .5));+#frame { position: absolute; left: 50%; top: 50%; width: var(--sw, 1600px); height: calc(var(--sh, 900px) + 60px); transform: translate(-50%, -50%) scale(var(--k, .5));border-radius: 20px; overflow: hidden; background: var(--board); box-shadow: 0 0 0 1px var(--edge), 0 30px 80px rgba(0, 0, 0, .45); }-#stage { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: block;+#stage { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: block;background: radial-gradient(75% 75% at 50% 45%, rgba(0,0,0,0) 60%, var(--vignette)), var(--grain, none), var(--board); }-#ui { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; pointer-events: none; }+#ui { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); pointer-events: none; }#ui > * { pointer-events: auto; }-.cover { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }+.cover { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--page) 50%, transparent); border: 0; }.cover[hidden] { display: none; }.cover > div { display: flex; flex-direction: column; align-items: center; }.cover-k { margin: 0 0 10px; text-align: center; font-size: 22px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }-.cover-t { margin: 0 0 44px; max-width: 1200px; text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }+.cover-t { margin: 0 0 44px; max-width: min(1200px, calc(var(--sw, 1600px) - 100px)); text-align: center; font: 500 64px/1.15 "Iowan Old Style", Palatino, Georgia, serif; color: var(--chalk); text-wrap: balance; }.cover > div > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }.cover-t { animation-delay: .08s; }.cover .go { animation-delay: .18s; }@@ -43,7 +43,7 @@ button[hidden] { display: none; }@keyframes rise { from { opacity: 0; transform: translateY(14px); } }.cover .go { display: inline-flex; align-items: center; gap: 16px; padding: 20px 40px; border-radius: 999px; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 32px; }.cover small { display: block; margin-top: 22px; font-size: 22px; text-align: center; color: var(--dim); }-.paused-mark { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: none; place-items: center; pointer-events: none; }+.paused-mark { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: none; place-items: center; pointer-events: none; }.paused .paused-mark { display: grid; }.paused-mark div { padding: 14px 30px; border-radius: 999px; background: color-mix(in srgb, var(--page) 85%, transparent); color: var(--dim); font-size: 22px; }@@ -105,7 +105,7 @@ button[hidden] { display: none; }.tok { cursor: grab; touch-action: none; } /* a finger drags the chip instead of scrolling the page *//* Controls strip, part of the frame. */-#bar { position: absolute; left: 0; top: 900px; width: 1600px; height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }+#bar { position: absolute; left: 0; top: var(--sh, 900px); width: var(--sw, 1600px); height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: color-mix(in srgb, var(--page) 50%, var(--board)); border-top: 1px solid var(--bar-edge); }.icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); display: grid; place-items: center; flex: none; padding: 0; }.icon svg { width: 18px; height: 18px; fill: var(--chalk); }.icon .i-pause { display: none; }@@ -121,7 +121,7 @@ button[hidden] { display: none; }/* Keep the control strip usable without scaling down its touch targets. */@media (max-width: 700px) {#frame { top: calc(50% - 50px); overflow: visible; }- #bar { width: calc(1600px * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;+ #bar { width: calc(var(--sw, 1600px) * var(--k)); height: auto; flex-wrap: wrap; gap: 6px; padding: 8px;transform: scale(calc(1 / var(--k))); transform-origin: left top; border-radius: 0 0 12px 12px; }#bar .icon { width: 36px; height: 40px; }.step { display: none; }@@ -150,9 +150,9 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }.keys kbd { margin: 0 .15em; }.grid .row.cur { background: color-mix(in srgb, var(--chalk) 5%, transparent); box-shadow: inset 4px 0 var(--quiz); }-.help { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }+.help { position: absolute; left: 0; top: 0; width: var(--sw, 1600px); height: var(--sh, 900px); display: grid; place-items: center; background: color-mix(in srgb, var(--veil) 72%, transparent); }.help[hidden] { display: none; }-.help-box { width: 1120px; padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }+.help-box { width: min(1120px, calc(var(--sw, 1600px) - 80px)); padding: 40px 50px; border-radius: 22px; background: var(--panel); border: 1.5px solid var(--edge); }.help h2 { margin: 0 0 22px; font-size: 32px; font-weight: 600; }.help h3 { margin: 0 0 12px; font-size: 20px; font-weight: 600; color: var(--quiz); }.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }@@ -164,7 +164,7 @@ kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5e.help-close { margin: 26px 0 0; font-size: 18px; color: var(--dim); }.icon.txt { font-size: 20px; font-weight: 700; color: var(--dim); }/* 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: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }+.caption { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); width: max-content; max-width: min(1180px, calc(var(--sw, 1600px) - 80px)); padding: 10px 24px; border-radius: 14px; background: color-mix(in srgb, var(--veil) 82%, transparent); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }.caption[hidden] { display: none; }.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); }@@ -186,7 +186,7 @@ svg.m { display: inline-block; overflow: visible; }.screen .body { margin-top: 30px; }.card.screen { display: flex; flex-direction: column; }.screen .head { order: 1; } .screen .body { order: 2; }-.screen .fb { order: 3; max-width: 1080px; margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers */+.screen .fb { order: 3; max-width: min(1080px, calc(var(--sw, 1600px) - 140px)); margin: 26px 0 0; font-size: 24px; } /* feedback right under the answers *//* Practice screens: the bottom 130 px hold the buttons. Long answers scroll inside the body, so the feedback underthem stays in view after a wrong answer adds a 'why' line to each row. */.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }@@ -240,7 +240,7 @@ a.cite:focus-visible text, a.cite:focus-visible tspan { fill: var(--task); }a.cite:focus-visible { outline: 3px solid var(--task); outline-offset: 6px; border-radius: 4px; }#ui a.cite { color: inherit; text-decoration: underline; text-underline-offset: 3px; }#ui a.cite:hover { color: var(--quiz); }-.fin .srcs { margin: 26px 0 0; max-width: 1100px; font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }+.fin .srcs { margin: 26px 0 0; max-width: min(1100px, calc(var(--sw, 1600px) - 100px)); font-size: 19px; line-height: 1.45; color: var(--dim); text-align: left; }.fin .srcs h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--quiz); }.fin .srcs ol { margin: 0; padding-left: 0; list-style: none; max-height: 190px; overflow: auto; }.fin .srcs li { padding-left: 2em; text-indent: -2em; margin: 0 0 6px; }@@ -259,3 +259,5 @@ a.btn { text-decoration: none; display: inline-block; }.fin .kicker { font-size: 20px; letter-spacing: .14em; text-transform: uppercase; }.fin .prompt { margin: 6px 0 14px; font: 500 56px/1.15 "Iowan Old Style", Palatino, Georgia, serif; }.icon.speed { width: auto; min-width: 44px; padding: 0 10px; border-radius: 22px; font-size: 16px; }+/* An upright stage is seen at about half the scale of a wide one on the same screen: bigger caption text. */+:root[data-stage="portrait"] .caption { font-size: 38px; bottom: 60px; }diff --git a/site/three-little-pigs/lib/engine.js b/site/three-little-pigs/lib/engine.jsindex 4d3817c..0082c18 100644--- a/site/three-little-pigs/lib/engine.js+++ b/site/three-little-pigs/lib/engine.js@@ -151,6 +151,11 @@ const TRANSLATIONS = {watchAgain: 'もう一度見る', nextChapter: '次の章へ',},};+// <html data-stage="portrait"> turns the stage upright: 900 wide, 1600 tall. Landscape (1600×900) otherwise.+const PORTRAIT = document.documentElement.dataset.stage === 'portrait';+const SW = PORTRAIT ? 900 : 1600, SH = PORTRAIT ? 1600 : 900;+document.documentElement.style.setProperty('--sw', SW + 'px');+document.documentElement.style.setProperty('--sh', SH + 'px');const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];const pluralRules = {};// Interface text in LANGUAGE: translate('chapterNumber', { n: 3 }) → 'Chapter 3'. Chapters may use it too, e.g. for practice labels.@@ -173,7 +178,7 @@ const isShortcut = (event, letter) => event.key.toLowerCase() === letter.toLowerconst isShortcutCode = (event, code) => /^\p{L}$/u.test(event.key) && !isLatinLetter(event.key) && event.code === code;document.body.insertAdjacentHTML('afterbegin', `<div id="frame">- <svg id="stage" viewBox="0 0 1600 900" role="img" aria-label="${translate('stageLabel')}">+ <svg id="stage" viewBox="0 0 ${SW} ${SH}" role="img" aria-label="${translate('stageLabel')}"><g id="scene"></g></svg><div id="ui"></div>@@ -265,12 +270,13 @@ const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8',}const MATH = bookSetting('--math-font') || '"STIX Two Text","Cambria Math","Iowan Old Style",Palatino,Georgia,serif';const NAME = { nat: translate('natural'), whole: translate('whole'), int: translate('integers'), rat: translate('rational'), irr: translate('irrational'), real: translate('real') };-// Card positions inside the 1600×900 picture.-const BAND = { x: 96, y: 686, w: 1408, cls: 'band' }; // bottom band (moves up when taller than the space left)+// Card positions inside the picture. BAND and the screens follow the stage; RIGHT and TOPR are placed for the wide+// stage's number line and map and have no upright layout yet.+const BAND = { x: 96 * SW / 1600, y: SH - 214, w: SW - 192 * SW / 1600, 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 mapconst 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' };-const SORT_SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen sort' };+const SCREEN = { x: 0, y: 0, w: SW, cls: 'screen' };+const SORT_SCREEN = { x: 0, y: 0, w: SW, cls: 'screen sort' };const $m = (...parts) => ({ m: parts });function mk(tag, attrs = {}, parent) {@@ -623,8 +629,8 @@ const clockRun = (f, D, { tail = false } = {}) => { f(0); const w = { t0: 0, dur// Moves are keyed on the beat clock: to(view, t0, dur, ease) blends each given key from its value at t0; a key may be a// function of t (follow). Unspecified keys keep following the earlier moves. dur 0 is a hard cut.let camN = 0;-function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {}) {- const [bx, by, bw, bh] = box || [0, 0, 1600, 900];+function camera(p, D, { box, x = SW / 2, y = SH / 2, z, r = 0, bg = COL.board } = {}) {+ const [bx, by, bw, bh] = box || [0, 0, SW, SH];const el = G(p, { x: bx + bw / 2, y: by + bh / 2 });let hold = el;if (box) {@@ -635,7 +641,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})}const view = mk('g', {}, hold), world = G(view);if (box) mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18, fill: 'none', stroke: COL.faint, 'stroke-width': 2 }, el);- const v0 = { x, y, z: z ?? (box ? Math.min(bw / 1600, bh / 900) : 1), r };+ const v0 = { x, y, z: z ?? (box ? Math.min(bw / SW, bh / SH) : 1), r };const ops = [], shakes = [], layers = [];const val = (v, t) => typeof v === 'function' ? v(t) : v;// The view at time t after the first n moves; each move remembers the view it starts from.@@ -693,7 +699,7 @@ function camera(p, D, { box, x = 800, y = 450, z, r = 0, bg = COL.board } = {})/* ---------- scene ---------- */const scene = document.getElementById('scene');const S = {};-const AXIS = { o: 800, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change it+const AXIS = { o: SW / 2, u: 120 }; // number line: x of 0, pixels per unit; a chapter may change itconst X = v => AXIS.o + AXIS.u * v, Y0 = 610;const num = v => (v < 0 ? '−' : '') + String(Math.abs(v)).replace('.', DECIMAL_SIGN);function reset() {@@ -813,7 +819,7 @@ function card(pos, cls) {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 fit = () => { c.style.top = Math.max(16, Math.min(pos.y, SH - 16 - c.offsetHeight)) + 'px'; };const ro = new ResizeObserver(fit);ro.observe(c); fit();P.cleanup.push(() => ro.disconnect());@@ -1514,7 +1520,7 @@ 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}||`;+ if (c?.classList.contains('band')) at = `${SH + 60 - 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;@@ -1614,7 +1620,7 @@ document.addEventListener('keydown', e => {// Mouse clicks should not leave focus on a control, so Enter and Space keep meaning "check" and "play".$('frame').addEventListener('mousedown', e => { if (e.target.closest('button, [tabindex]')) e.preventDefault(); });$('bHelp').onclick = toggleHelp;-const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / 1640, (innerHeight - (innerWidth <= 700 ? 120 : 0)) / 1000));+const fit = () => document.documentElement.style.setProperty('--k', Math.min(innerWidth / (SW + 40), (innerHeight - (innerWidth <= 700 ? 120 : 0)) / (SH + 100)));addEventListener('resize', fit);fit();