Skip to content

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

feat(site): add Little Red Riding Hood, a paper-cutout stop-motion picture book

yzr9f96f8766f53
diff --git a/site/assets/bookshelf.png b/site/assets/bookshelf.png
index 5ebcc5b..b43ce50 100644
Binary files a/site/assets/bookshelf.png and b/site/assets/bookshelf.png differ
diff --git a/site/index.html b/site/index.html
index d8c87ea..6338a8f 100644
--- a/site/index.html
+++ b/site/index.html
@@ -16,7 +16,7 @@
<p>Animated books · A growing collection</p>
</header>
<figure class="photo-shelf" aria-label="Three shelves: STEM, picture books for children, and curious books">
- <img class="shelf-photo" src="assets/bookshelf.png" width="1086" height="1448" alt="A wooden bookshelf. Algebra, mathematics and physics books on the top shelf marked STEM; picture books on the middle shelf, starting with The Three Little Pigs; philosophy and history books on the bottom shelf; a GitHub emblem on the drawer." fetchpriority="high">
+ <img class="shelf-photo" src="assets/bookshelf.png" width="1086" height="1448" alt="A wooden bookshelf. Algebra, mathematics and physics books on the top shelf marked STEM; picture books on the middle shelf: The Three Little Pigs, Little Red Riding Hood and Why Is It So Fun?; philosophy and history books on the bottom shelf; a GitHub emblem on the drawer." fetchpriority="high">
<div id="shelf-books">
<section class="shelf-tier" aria-labelledby="stem-title">
<h2 class="visually-hidden" id="stem-title">STEM · Mathematics</h2>
@@ -31,10 +31,13 @@
</a>
</section>
<section class="shelf-tier" aria-labelledby="picture-title">
- <h2 class="visually-hidden" id="picture-title">Picture books for children · One experiment, more coming soon</h2>
+ <h2 class="visually-hidden" id="picture-title">Picture books for children · Two films, more coming soon</h2>
<a class="book-hotspot pigs-book" data-book="three-little-pigs" href="three-little-pigs/" aria-label="Open The Three Little Pigs, an animated picture book experiment and how it was made">
<span class="book-caption"><strong>The Three Little Pigs <span aria-hidden="true">↗</span></strong><small>An experiment · how it was made</small></span>
</a>
+ <a class="book-hotspot red-book" data-book="little-red-riding-hood" href="little-red-riding-hood/ch01/" aria-label="Open Little Red Riding Hood, a paper-cutout stop-motion picture book">
+ <span class="book-caption"><strong>Little Red Riding Hood <span aria-hidden="true">↗</span></strong><small>Paper-cutout stop motion</small></span>
+ </a>
</section>
<section class="shelf-tier" aria-labelledby="curious-title">
<h2 class="visually-hidden" id="curious-title">Curious books · Coming soon</h2>
diff --git a/site/lib/bookshelf.css b/site/lib/bookshelf.css
index 8e68d80..1c90ebc 100644
--- a/site/lib/bookshelf.css
+++ b/site/lib/bookshelf.css
@@ -24,9 +24,11 @@ a { color: inherit; }
.algebra-book { left: 10.1%; width: 26.1%; }
.math-book { left: 39.9%; width: 24.5%; }
.physics-book { left: 66.8%; width: 25.3%; }
-/* The middle shelf: the photographed cover of our picture book. */
+/* The middle shelf: the photographed covers of our picture books. */
.pigs-book { left: 8.1%; width: 25.8%; top: 34.5%; height: 19.6%; }
+.red-book { left: 37.2%; width: 26%; top: 34.4%; height: 19.6%; }
.pigs-book .book-caption { background: linear-gradient(110deg, #7a4a1ef5, #5a3414f0); }
+.red-book .book-caption { background: linear-gradient(110deg, #8a2a22f5, #5e1a16f0); }
.book-hotspot:hover { box-shadow: 0 0 0 2px #f7d998b3, 0 0 28px #edc97833; }
#shelf a:focus-visible { outline: 3px solid #f4d786; outline-offset: 5px; }
.book-caption { position: absolute; bottom: 0; left: 0; right: 0; display: flex; flex-direction: column; justify-content: center; gap: .35cqw; min-height: 6.45cqw; padding: 1.1cqw 1.2cqw .9cqw; color: #faf7e9; background: linear-gradient(110deg, #263d32f5, #182a23f0); box-shadow: 0 -2px 8px #0003; font: 1.4cqw/1.25 var(--ui); transition: background .2s; }
diff --git a/site/little-red-riding-hood/ch01/audio/bgm/m1-home.mp3 b/site/little-red-riding-hood/ch01/audio/bgm/m1-home.mp3
new file mode 100644
index 0000000..acdbe77
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/bgm/m1-home.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/bgm/m2-wolf.mp3 b/site/little-red-riding-hood/ch01/audio/bgm/m2-wolf.mp3
new file mode 100644
index 0000000..eca9045
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/bgm/m2-wolf.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/bgm/m3-chimney.mp3 b/site/little-red-riding-hood/ch01/audio/bgm/m3-chimney.mp3
new file mode 100644
index 0000000..073bb94
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/bgm/m3-chimney.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/bgm/m4-ending.mp3 b/site/little-red-riding-hood/ch01/audio/bgm/m4-ending.mp3
new file mode 100644
index 0000000..d50bf6a
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/bgm/m4-ending.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/mouths.js b/site/little-red-riding-hood/ch01/audio/en/mouths.js
new file mode 100644
index 0000000..e212525
--- /dev/null
+++ b/site/little-red-riding-hood/ch01/audio/en/mouths.js
@@ -0,0 +1 @@
+window.MOUTHS = {"s01":[[0.138,"E"],[0.242,"B"],[0.346,"C"],[0.45,"F"],[0.512,"A"],[0.575,"E"],[0.637,"B"],[0.7,"D"],[0.775,"B"],[0.913,"C"],[1.05,"A"],[1.188,"C"],[1.325,"X"],[1.5,"B"],[1.528,"C"],[1.556,"B"],[1.584,"C"],[1.613,"F"],[1.663,"D"],[1.712,"B"],[1.762,"D"],[1.825,"H"],[1.887,"C"],[1.95,"B"],[2.013,"H"],[2.075,"C"],[2.138,"B"],[2.231,"C"],[2.325,"B"],[2.419,"H"],[2.513,"F"],[2.558,"B"],[2.604,"E"],[2.65,"H"],[2.712,"E"],[2.775,"G"],[2.837,"C"],[2.9,"B"],[2.962,"B"],[3.017,"C"],[3.071,"B"],[3.125,"B"],[3.2,"C"],[3.275,"B"],[3.35,"B"],[3.417,"F"],[3.485,"B"],[3.553,"C"],[3.62,"B"],[3.688,"B"],[3.766,"D"],[3.844,"A"],[3.922,"C"],[4.0,"B"],[4.125,"E"],[4.25,"A"],[4.35,"F"],[4.45,"B"],[4.55,"B"],[4.612,"D"],[4.675,"B"],[4.737,"C"],[4.787,"G"],[4.838,"C"],[4.888,"B"],[4.938,"C"],[4.987,"E"],[5.037,"B"],[5.088,"C"],[5.138,"B"],[5.195,"D"],[5.253,"H"],[5.31,"C"],[5.367,"B"],[5.425,"B"],[5.467,"C"],[5.508,"B"],[5.55,"H"],[5.61,"C"],[5.67,"B"],[5.73,"H"],[5.79,"C"],[5.85,"B"],[5.912,"C"],[5.975,"B"],[6.037,"B"],[6.115,"C"],[6.192,"B"],[6.27,"C"],[6.348,"B"],[6.425,"B"],[6.608,"F"],[6.792,"B"],[6.975,"X"]],"s01b":[[0.102,"B"],[0.167,"D"],[0.232,"B"],[0.297,"C"],[0.362,"B"],[0.432,"C"],[0.501,"B"],[0.571,"B"],[0.646,"D"],[0.721,"B"],[0.795,"C"],[0.87,"D"],[0.948,"B"],[1.027,"D"],[1.098,"A"],[1.17,"H"],[1.241,"C"],[1.313,"B"],[1.37,"F"],[1.428,"C"],[1.485,"B"],[1.542,"C"],[1.599,"B"],[1.658,"E"],[1.717,"B"],[1.827,"D"],[1.937,"B"],[2.047,"A"],[2.157,"D"],[2.267,"X"],[3.177,"B"],[3.294,"C"],[3.411,"C"],[3.555,"B"],[3.698,"G"],[3.773,"C"],[3.849,"H"],[3.924,"C"],[4.0,"B"],[4.076,"F"],[4.259,"C"],[4.442,"H"],[4.626,"X"],[5.378,"B"],[5.54,"C"],[5.703,"E"],[5.768,"B"],[5.833,"B"],[5.879,"C"],[5.925,"A"],[6.108,"D"],[6.291,"B"],[6.474,"X"],[6.628,"D"],[6.699,"B"],[6.771,"B"],[6.849,"E"],[6.927,"B"],[7.005,"B"],[7.064,"D"],[7.122,"H"],[7.181,"B"],[7.24,"B"],[7.292,"E"],[7.344,"B"],[7.454,"D"],[7.564,"B"],[7.674,"C"],[7.784,"B"],[7.894,"X"]],"s01c":[[0.1,"C"],[0.263,"A"],[0.341,"B"],[0.42,"E"],[0.498,"A"],[0.577,"C"],[0.655,"B"],[0.734,"C"],[0.812,"X"]],"s02":[[0.113,"B"],[0.21,"D"],[0.307,"B"],[0.405,"A"],[0.503,"D"],[0.6,"H"],[0.657,"C"],[0.715,"G"],[0.772,"C"],[0.83,"B"],[0.887,"E"],[0.944,"B"],[1.0,"B"],[1.062,"C"],[1.125,"E"],[1.184,"B"],[1.244,"C"],[1.303,"B"],[1.363,"B"],[1.431,"C"],[1.5,"B"],[1.569,"C"],[1.637,"E"],[1.681,"G"],[1.725,"B"],[1.775,"C"],[1.825,"F"],[2.1,"B"],[2.375,"X"],[2.525,"F"],[2.587,"B"],[2.65,"C"],[2.712,"B"],[2.775,"B"],[2.931,"C"],[3.087,"A"],[3.158,"C"],[3.229,"B"],[3.3,"E"],[3.379,"D"],[3.458,"B"],[3.538,"B"],[3.721,"C"],[3.904,"B"],[4.088,"X"],[4.45,"A"],[4.525,"F"],[4.6,"B"],[4.675,"B"],[4.741,"E"],[4.807,"A"],[4.873,"C"],[4.939,"E"],[5.005,"B"],[5.071,"C"],[5.138,"F"],[5.196,"D"],[5.254,"B"],[5.312,"F"],[5.423,"D"],[5.532,"B"],[5.643,"C"],[5.752,"B"],[5.862,"X"]],"s03":[[0.1,"B"],[0.174,"F"],[0.248,"B"],[0.321,"A"],[0.431,"E"],[0.541,"B"],[0.651,"C"],[0.761,"B"],[0.871,"X"],[1.011,"H"],[1.082,"C"],[1.152,"B"],[1.222,"H"],[1.293,"C"],[1.363,"B"],[1.437,"C"],[1.511,"B"],[1.584,"B"],[1.673,"C"],[1.761,"B"],[1.85,"C"],[1.939,"B"],[2.027,"B"],[2.21,"F"],[2.394,"B"],[2.577,"X"],[3.396,"F"],[3.441,"B"],[3.485,"C"],[3.529,"B"],[3.573,"C"],[3.618,"D"],[3.644,"B"],[3.67,"C"],[3.696,"C"],[3.807,"F"],[3.917,"E"],[4.021,"G"],[4.126,"B"],[4.401,"E"],[4.676,"X"]],"s03b":[[0.1,"B"],[0.188,"E"],[0.275,"B"],[0.367,"D"],[0.458,"B"],[0.55,"A"],[0.642,"D"],[0.733,"B"],[0.925,"B"],[1.062,"F"],[1.2,"B"],[1.338,"C"],[1.475,"X"],[2.288,"C"],[2.4,"B"],[2.513,"F"],[2.594,"B"],[2.675,"C"],[2.756,"B"],[2.837,"B"],[2.9,"C"],[2.962,"B"],[3.144,"C"],[3.325,"A"],[3.421,"C"],[3.517,"B"],[3.612,"E"],[3.796,"D"],[3.979,"B"],[4.162,"X"]],"s03c":[[0.1,"B"],[0.238,"D"],[0.375,"B"],[0.513,"C"],[0.65,"X"],[0.79,"D"],[0.855,"B"],[0.92,"D"],[0.998,"B"],[1.108,"D"],[1.218,"B"],[1.328,"A"],[1.438,"D"],[1.548,"X"],[2.511,"F"],[2.573,"B"],[2.635,"D"],[2.696,"B"],[2.758,"D"],[2.849,"H"],[2.95,"F"],[3.051,"B"],[3.152,"C"],[3.253,"B"],[3.528,"C"],[3.803,"X"]],"s04":[[0.1,"F"],[0.195,"B"],[0.291,"C"],[0.386,"B"],[0.524,"F"],[0.661,"B"],[0.799,"C"],[0.936,"X"],[1.704,"H"],[1.795,"F"],[1.886,"B"],[1.977,"D"],[2.042,"B"],[2.107,"D"],[2.185,"H"],[2.264,"B"],[2.332,"C"],[2.4,"B"],[2.469,"C"],[2.537,"H"],[2.615,"E"],[2.693,"G"],[2.771,"C"],[2.849,"H"],[2.928,"C"],[3.006,"G"],[3.116,"H"],[3.226,"F"],[3.336,"C"],[3.446,"B"],[3.556,"X"]],"s04b":[[0.138,"B"],[0.244,"E"],[0.35,"H"],[0.427,"C"],[0.505,"B"],[0.583,"H"],[0.66,"C"],[0.738,"B"],[0.808,"C"],[0.879,"B"],[0.95,"B"],[1.05,"C"],[1.15,"B"],[1.25,"C"],[1.35,"B"],[1.45,"B"],[1.512,"F"],[1.575,"B"],[1.637,"H"],[1.709,"C"],[1.781,"G"],[1.853,"B"],[1.925,"B"],[1.975,"C"],[2.025,"A"],[2.175,"D"],[2.325,"B"],[2.475,"B"],[2.531,"E"],[2.587,"A"],[2.654,"C"],[2.721,"B"],[2.788,"D"],[2.875,"A"],[2.979,"F"],[3.083,"B"],[3.188,"G"],[3.229,"E"],[3.271,"B"],[3.312,"B"],[3.422,"D"],[3.532,"B"],[3.643,"A"],[3.752,"D"],[3.862,"X"],[4.263,"D"],[4.325,"B"],[4.388,"B"],[4.438,"C"],[4.487,"F"],[4.578,"E"],[4.669,"H"],[4.759,"G"],[4.85,"B"],[4.95,"D"],[5.05,"B"],[5.15,"B"],[5.296,"C"],[5.442,"B"],[5.588,"B"],[5.638,"E"],[5.688,"B"],[5.773,"D"],[5.858,"B"],[5.944,"A"],[6.029,"D"],[6.115,"B"],[6.2,"B"],[6.338,"F"],[6.475,"B"],[6.612,"C"],[6.75,"X"]],"s05":[[0.1,"B"],[0.21,"D"],[0.32,"B"],[0.43,"A"],[0.54,"D"],[0.65,"X"],[1.704,"C"],[1.84,"B"],[1.977,"A"],[2.231,"C"],[2.485,"H"],[2.558,"C"],[2.631,"B"],[2.704,"H"],[2.777,"C"],[2.849,"B"],[2.928,"C"],[3.006,"B"],[3.084,"B"],[3.178,"C"],[3.271,"B"],[3.365,"C"],[3.459,"B"],[3.553,"B"],[3.736,"F"],[3.919,"B"],[4.103,"X"]],"s05b":[[0.106,"B"],[0.217,"F"],[0.328,"B"],[0.439,"H"],[0.508,"C"],[0.578,"G"],[0.647,"B"],[0.717,"B"],[0.779,"C"],[0.842,"H"],[1.025,"D"],[1.208,"B"],[1.397,"B"],[1.581,"C"],[1.764,"B"],[2.008,"D"],[2.14,"B"],[2.272,"B"],[2.345,"E"],[2.418,"A"],[2.491,"C"],[2.564,"C"],[2.839,"B"],[3.114,"X"]],"s06":[[0.138,"B"],[0.233,"D"],[0.328,"B"],[0.423,"A"],[0.518,"D"],[0.613,"A"],[0.713,"C"],[0.812,"B"],[0.859,"D"],[0.906,"G"],[0.953,"C"],[1.0,"A"],[1.067,"C"],[1.133,"B"],[1.2,"A"],[1.31,"F"],[1.42,"B"],[1.53,"H"],[1.64,"C"],[1.75,"X"],[1.95,"A"],[2.008,"F"],[2.067,"B"],[2.125,"B"],[2.219,"C"],[2.312,"F"],[2.375,"D"],[2.438,"B"],[2.5,"B"],[2.638,"F"],[2.775,"C"],[2.912,"B"],[3.05,"X"],[3.325,"B"],[3.425,"C"],[3.525,"B"],[3.587,"E"],[3.65,"A"],[3.712,"C"],[3.775,"B"],[3.837,"C"],[3.917,"B"],[3.996,"E"],[4.075,"B"],[4.131,"C"],[4.188,"F"],[4.279,"D"],[4.371,"B"],[4.463,"E"],[4.554,"A"],[4.646,"C"],[4.825,"D"],[4.894,"B"],[4.963,"B"],[5.034,"C"],[5.106,"H"],[5.178,"B"],[5.25,"B"],[5.306,"C"],[5.362,"B"],[5.433,"F"],[5.504,"B"],[5.575,"B"],[5.758,"F"],[5.942,"B"],[6.125,"X"],[6.513,"B"],[6.562,"C"],[6.612,"F"],[6.697,"E"],[6.781,"H"],[6.866,"G"],[6.95,"A"],[7.021,"F"],[7.092,"B"],[7.162,"E"],[7.231,"B"],[7.3,"B"],[7.342,"C"],[7.383,"B"],[7.425,"B"],[7.532,"C"],[7.64,"B"],[7.748,"D"],[7.855,"A"],[7.963,"D"],[8.019,"B"],[8.075,"B"],[8.167,"H"],[8.258,"D"],[8.35,"B"],[8.442,"C"],[8.533,"B"],[8.625,"X"],[8.988,"B"],[9.048,"H"],[9.108,"C"],[9.169,"A"],[9.229,"C"],[9.29,"B"],[9.35,"C"],[9.429,"B"],[9.508,"E"],[9.588,"A"],[9.767,"C"],[9.946,"B"],[10.125,"D"],[10.188,"B"],[10.25,"F"],[10.36,"C"],[10.47,"B"],[10.58,"C"],[10.69,"B"],[10.8,"X"]],"s07w":[[0.1,"B"],[0.175,"F"],[0.25,"B"],[0.325,"A"],[0.435,"E"],[0.545,"B"],[0.655,"C"],[0.765,"B"],[0.875,"X"],[1.113,"A"],[1.306,"B"],[1.5,"F"],[1.592,"B"],[1.683,"F"],[1.775,"B"],[1.867,"C"],[1.958,"B"],[2.05,"X"]],"s07x":[[0.101,"A"],[0.211,"E"],[0.321,"B"],[0.431,"C"],[0.541,"B"],[0.651,"X"],[0.803,"H"],[0.859,"C"],[0.915,"B"],[0.971,"H"],[1.027,"C"],[1.083,"B"],[1.266,"C"],[1.45,"B"],[1.633,"X"],[2.321,"B"],[2.494,"C"],[2.666,"B"],[2.758,"C"],[2.851,"H"],[2.943,"E"],[3.036,"B"],[3.093,"E"],[3.151,"C"],[3.21,"F"],[3.27,"B"],[3.329,"B"],[3.416,"D"],[3.503,"B"],[3.589,"A"],[3.676,"D"],[3.763,"G"],[3.831,"E"],[3.899,"B"],[3.967,"A"],[4.242,"C"],[4.517,"X"]],"s07":[[0.113,"H"],[0.193,"C"],[0.272,"B"],[0.352,"H"],[0.432,"C"],[0.512,"B"],[0.583,"C"],[0.654,"B"],[0.725,"B"],[0.835,"C"],[0.945,"B"],[1.055,"C"],[1.165,"B"],[1.275,"B"],[1.333,"F"],[1.392,"B"],[1.45,"D"],[1.535,"B"],[1.621,"C"],[1.706,"G"],[1.792,"C"],[1.877,"B"],[1.962,"F"],[2.008,"C"],[2.054,"B"],[2.1,"B"],[2.142,"C"],[2.183,"B"],[2.225,"G"],[2.335,"H"],[2.445,"F"],[2.555,"C"],[2.665,"B"],[2.775,"X"],[3.275,"B"],[3.375,"F"],[3.475,"B"],[3.613,"D"],[3.75,"B"],[3.888,"C"],[4.025,"X"],[4.625,"B"],[4.694,"C"],[4.763,"B"],[4.854,"F"],[4.946,"B"],[5.037,"F"],[5.117,"D"],[5.196,"B"],[5.275,"F"],[5.35,"C"],[5.425,"B"],[5.5,"C"],[5.575,"E"],[5.713,"A"],[5.85,"C"],[5.987,"B"],[6.125,"X"]],"s07b":[[0.1,"B"],[0.21,"D"],[0.32,"B"],[0.43,"A"],[0.54,"D"],[0.65,"X"]],"s08":[[0.1,"B"],[0.21,"D"],[0.32,"B"],[0.43,"A"],[0.54,"D"],[0.65,"X"],[0.912,"F"],[0.975,"B"],[1.038,"D"],[1.1,"B"],[1.163,"A"],[1.25,"C"],[1.338,"B"],[1.425,"C"],[1.575,"B"],[1.725,"C"],[1.794,"F"],[1.863,"B"],[2.0,"D"],[2.138,"G"],[2.275,"C"],[2.413,"X"]],"s08b":[[0.1,"D"],[0.23,"H"],[0.36,"B"],[0.406,"C"],[0.452,"A"],[0.504,"C"],[0.556,"B"],[0.608,"C"],[0.66,"B"],[0.712,"B"],[0.758,"E"],[0.803,"B"],[0.89,"C"],[0.977,"B"],[1.064,"C"],[1.148,"F"],[1.233,"F"],[1.367,"C"],[1.502,"B"],[1.636,"A"],[1.747,"C"],[1.858,"B"],[2.041,"C"],[2.224,"B"],[2.408,"X"]],"s08c":[[0.1,"B"],[0.21,"D"],[0.32,"B"],[0.43,"A"],[0.54,"D"],[0.65,"X"],[0.925,"F"],[0.988,"B"],[1.05,"D"],[1.113,"B"],[1.175,"A"],[1.262,"C"],[1.35,"B"],[1.438,"C"],[1.6,"B"],[1.762,"C"],[1.837,"F"],[1.913,"B"],[2.05,"D"],[2.188,"G"],[2.325,"C"],[2.463,"X"]],"s08d":[[0.1,"D"],[0.237,"H"],[0.373,"B"],[0.419,"C"],[0.465,"A"],[0.517,"C"],[0.569,"B"],[0.621,"C"],[0.673,"B"],[0.725,"B"],[0.777,"E"],[0.829,"B"],[0.953,"C"],[1.077,"C"],[1.155,"F"],[1.233,"F"],[1.416,"C"],[1.599,"B"],[1.783,"X"]],"s08e":[[0.1,"D"],[0.2,"B"],[0.3,"B"],[0.41,"D"],[0.52,"B"],[0.63,"A"],[0.74,"D"],[0.85,"X"],[1.15,"F"],[1.2,"B"],[1.25,"D"],[1.3,"B"],[1.35,"D"],[1.438,"A"],[1.538,"C"],[1.637,"B"],[1.738,"A"],[1.854,"F"],[1.971,"B"],[2.087,"C"],[2.175,"F"],[2.263,"B"],[2.4,"D"],[2.538,"G"],[2.675,"C"],[2.812,"X"]],"s08f":[[0.1,"D"],[0.237,"H"],[0.373,"B"],[0.432,"C"],[0.491,"A"],[0.545,"C"],[0.6,"B"],[0.655,"C"],[0.709,"B"],[0.764,"B"],[0.823,"E"],[0.881,"C"],[1.018,"B"],[1.155,"C"],[1.226,"F"],[1.298,"F"],[1.481,"C"],[1.665,"B"],[1.848,"X"]],"s09a":[[0.1,"B"],[0.238,"C"],[0.375,"H"],[0.513,"A"],[0.65,"X"]],"s09":[[0.106,"F"],[0.203,"B"],[0.3,"E"],[0.362,"G"],[0.425,"A"],[0.536,"C"],[0.647,"B"],[0.785,"F"],[0.922,"B"],[1.06,"C"],[1.231,"C"],[1.335,"F"],[1.439,"B"],[1.549,"D"],[1.659,"B"],[1.769,"D"],[1.879,"H"],[1.989,"X"]],"s09b":[[0.101,"B"],[0.267,"E"],[0.433,"E"],[0.708,"B"],[0.983,"X"],[1.696,"B"],[1.971,"F"],[2.246,"X"]],"s09c":[[0.138,"F"],[0.196,"C"],[0.254,"B"],[0.312,"B"],[0.412,"D"],[0.512,"B"],[0.613,"A"],[0.713,"D"],[0.812,"E"],[0.912,"B"],[1.012,"E"],[1.096,"B"],[1.179,"C"],[1.262,"B"],[1.363,"C"],[1.462,"B"],[1.562,"C"],[1.663,"D"],[1.731,"B"],[1.8,"B"],[1.837,"C"],[1.875,"F"],[1.962,"B"],[2.05,"F"],[2.138,"B"],[2.225,"C"],[2.312,"B"],[2.4,"D"],[2.462,"B"],[2.525,"B"],[2.581,"C"],[2.638,"B"],[2.821,"F"],[3.004,"B"],[3.288,"B"],[3.338,"C"],[3.388,"F"],[3.463,"E"],[3.538,"H"],[3.612,"G"],[3.688,"B"],[3.742,"D"],[3.796,"B"],[3.85,"E"],[3.903,"B"],[3.956,"H"],[4.009,"C"],[4.062,"E"],[4.15,"B"],[4.237,"C"],[4.325,"F"],[4.431,"C"],[4.537,"F"],[4.812,"B"],[5.087,"X"]],"s10":[[0.101,"D"],[0.19,"B"],[0.28,"B"],[0.365,"E"],[0.45,"B"],[0.535,"B"],[0.586,"E"],[0.637,"A"],[0.688,"C"],[0.739,"A"],[0.828,"D"],[0.917,"B"],[1.007,"B"],[1.064,"E"],[1.121,"B"],[1.179,"C"],[1.236,"B"],[1.294,"C"],[1.351,"F"],[1.626,"B"],[1.901,"X"]],"s10b":[[0.138,"B"],[0.188,"C"],[0.237,"F"],[0.325,"E"],[0.412,"H"],[0.5,"G"],[0.588,"B"],[0.696,"D"],[0.804,"B"],[0.912,"B"],[1.038,"E"],[1.163,"G"],[1.346,"D"],[1.529,"B"],[1.713,"X"],[2.013,"B"],[2.056,"C"],[2.1,"B"],[2.158,"C"],[2.215,"G"],[2.272,"C"],[2.33,"B"],[2.388,"C"],[2.45,"G"],[2.513,"C"],[2.575,"B"],[2.638,"B"],[2.708,"F"],[2.779,"B"],[2.85,"E"],[2.938,"G"],[3.025,"B"],[3.075,"C"],[3.125,"B"],[3.235,"C"],[3.345,"B"],[3.455,"D"],[3.565,"A"],[3.675,"X"]],"s11":[[0.113,"B"],[0.203,"D"],[0.292,"B"],[0.383,"A"],[0.472,"D"],[0.562,"D"],[0.65,"B"],[0.737,"C"],[0.825,"B"],[0.875,"C"],[0.925,"B"],[1.062,"D"],[1.2,"B"],[1.338,"C"],[1.475,"X"],[1.6,"B"],[1.704,"D"],[1.808,"B"],[1.913,"B"],[1.969,"C"],[2.025,"D"],[2.097,"A"],[2.169,"H"],[2.241,"C"],[2.312,"B"],[2.422,"F"],[2.532,"C"],[2.643,"B"],[2.752,"C"],[2.938,"D"],[3.0,"B"],[3.062,"B"],[3.171,"F"],[3.279,"B"],[3.388,"G"],[3.466,"C"],[3.544,"H"],[3.622,"B"],[3.7,"A"],[3.783,"F"],[3.867,"B"],[3.95,"A"],[4.06,"C"],[4.17,"B"],[4.28,"C"],[4.39,"B"],[4.5,"X"]],"s11b":[[0.1,"G"],[0.178,"B"],[0.256,"E"],[0.334,"A"],[0.412,"B"],[0.562,"F"],[0.713,"E"],[0.988,"B"],[1.262,"C"],[1.344,"H"],[1.425,"B"],[1.594,"C"],[1.762,"E"],[1.844,"B"],[1.925,"B"],[1.969,"C"],[2.013,"A"],[2.196,"D"],[2.379,"B"],[2.562,"X"],[3.362,"D"],[3.487,"B"],[3.612,"C"],[3.712,"H"],[3.812,"B"],[3.893,"C"],[3.973,"G"],[4.053,"C"],[4.133,"B"],[4.213,"B"],[4.346,"D"],[4.479,"B"],[4.612,"F"],[4.679,"C"],[4.746,"B"],[4.812,"F"],[4.904,"E"],[4.996,"H"],[5.088,"G"],[5.179,"C"],[5.271,"B"],[5.362,"X"]],"s11c":[[0.113,"B"],[0.225,"C"],[0.338,"C"],[0.613,"B"],[0.888,"X"]]};
diff --git a/site/little-red-riding-hood/ch01/audio/en/s01.mp3 b/site/little-red-riding-hood/ch01/audio/en/s01.mp3
new file mode 100644
index 0000000..470424b
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s01.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s01b.mp3 b/site/little-red-riding-hood/ch01/audio/en/s01b.mp3
new file mode 100644
index 0000000..98d4bf3
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s01b.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s01c.mp3 b/site/little-red-riding-hood/ch01/audio/en/s01c.mp3
new file mode 100644
index 0000000..4f78433
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s01c.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s02.mp3 b/site/little-red-riding-hood/ch01/audio/en/s02.mp3
new file mode 100644
index 0000000..3c5d85b
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s02.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s03.mp3 b/site/little-red-riding-hood/ch01/audio/en/s03.mp3
new file mode 100644
index 0000000..8e58f06
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s03.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s03b.mp3 b/site/little-red-riding-hood/ch01/audio/en/s03b.mp3
new file mode 100644
index 0000000..5adf5fa
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s03b.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s03c.mp3 b/site/little-red-riding-hood/ch01/audio/en/s03c.mp3
new file mode 100644
index 0000000..3fb930b
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s03c.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s04.mp3 b/site/little-red-riding-hood/ch01/audio/en/s04.mp3
new file mode 100644
index 0000000..71a493d
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s04.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s04b.mp3 b/site/little-red-riding-hood/ch01/audio/en/s04b.mp3
new file mode 100644
index 0000000..a8a6419
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s04b.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s05.mp3 b/site/little-red-riding-hood/ch01/audio/en/s05.mp3
new file mode 100644
index 0000000..ddabbd2
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s05.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s05b.mp3 b/site/little-red-riding-hood/ch01/audio/en/s05b.mp3
new file mode 100644
index 0000000..55ee55f
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s05b.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s06.mp3 b/site/little-red-riding-hood/ch01/audio/en/s06.mp3
new file mode 100644
index 0000000..437dff5
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s06.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s07.mp3 b/site/little-red-riding-hood/ch01/audio/en/s07.mp3
new file mode 100644
index 0000000..8a11767
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s07.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s07b.mp3 b/site/little-red-riding-hood/ch01/audio/en/s07b.mp3
new file mode 100644
index 0000000..5b72fd7
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s07b.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s07w.mp3 b/site/little-red-riding-hood/ch01/audio/en/s07w.mp3
new file mode 100644
index 0000000..7cf0240
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s07w.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s07x.mp3 b/site/little-red-riding-hood/ch01/audio/en/s07x.mp3
new file mode 100644
index 0000000..a3d5d15
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s07x.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s08.mp3 b/site/little-red-riding-hood/ch01/audio/en/s08.mp3
new file mode 100644
index 0000000..2b254b7
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s08.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s08b.mp3 b/site/little-red-riding-hood/ch01/audio/en/s08b.mp3
new file mode 100644
index 0000000..dc0da01
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s08b.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s08c.mp3 b/site/little-red-riding-hood/ch01/audio/en/s08c.mp3
new file mode 100644
index 0000000..588d903
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s08c.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s08d.mp3 b/site/little-red-riding-hood/ch01/audio/en/s08d.mp3
new file mode 100644
index 0000000..6faca20
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s08d.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s08e.mp3 b/site/little-red-riding-hood/ch01/audio/en/s08e.mp3
new file mode 100644
index 0000000..c539ce9
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s08e.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s08f.mp3 b/site/little-red-riding-hood/ch01/audio/en/s08f.mp3
new file mode 100644
index 0000000..0131fa8
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s08f.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s09.mp3 b/site/little-red-riding-hood/ch01/audio/en/s09.mp3
new file mode 100644
index 0000000..862fa4d
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s09.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s09a.mp3 b/site/little-red-riding-hood/ch01/audio/en/s09a.mp3
new file mode 100644
index 0000000..72b290b
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s09a.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s09b.mp3 b/site/little-red-riding-hood/ch01/audio/en/s09b.mp3
new file mode 100644
index 0000000..c8a890d
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s09b.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s09c.mp3 b/site/little-red-riding-hood/ch01/audio/en/s09c.mp3
new file mode 100644
index 0000000..9539edf
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s09c.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s10.mp3 b/site/little-red-riding-hood/ch01/audio/en/s10.mp3
new file mode 100644
index 0000000..88a37d8
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s10.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s10b.mp3 b/site/little-red-riding-hood/ch01/audio/en/s10b.mp3
new file mode 100644
index 0000000..599c806
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s10b.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s11.mp3 b/site/little-red-riding-hood/ch01/audio/en/s11.mp3
new file mode 100644
index 0000000..7cf14dc
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s11.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s11b.mp3 b/site/little-red-riding-hood/ch01/audio/en/s11b.mp3
new file mode 100644
index 0000000..a85e090
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s11b.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/s11c.mp3 b/site/little-red-riding-hood/ch01/audio/en/s11c.mp3
new file mode 100644
index 0000000..ef79c8d
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/s11c.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/scene1.mp3 b/site/little-red-riding-hood/ch01/audio/en/scene1.mp3
new file mode 100644
index 0000000..aae47c2
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/scene1.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/scene10.mp3 b/site/little-red-riding-hood/ch01/audio/en/scene10.mp3
new file mode 100644
index 0000000..a385e38
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/scene10.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/scene11.mp3 b/site/little-red-riding-hood/ch01/audio/en/scene11.mp3
new file mode 100644
index 0000000..7278d54
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/scene11.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/scene2.mp3 b/site/little-red-riding-hood/ch01/audio/en/scene2.mp3
new file mode 100644
index 0000000..46a885c
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/scene2.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/scene3.mp3 b/site/little-red-riding-hood/ch01/audio/en/scene3.mp3
new file mode 100644
index 0000000..d3e05a9
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/scene3.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/scene4.mp3 b/site/little-red-riding-hood/ch01/audio/en/scene4.mp3
new file mode 100644
index 0000000..542ddfe
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/scene4.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/scene5.mp3 b/site/little-red-riding-hood/ch01/audio/en/scene5.mp3
new file mode 100644
index 0000000..32f421b
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/scene5.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/scene6.mp3 b/site/little-red-riding-hood/ch01/audio/en/scene6.mp3
new file mode 100644
index 0000000..da1dfad
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/scene6.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/scene7.mp3 b/site/little-red-riding-hood/ch01/audio/en/scene7.mp3
new file mode 100644
index 0000000..c9616b6
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/scene7.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/scene8.mp3 b/site/little-red-riding-hood/ch01/audio/en/scene8.mp3
new file mode 100644
index 0000000..f54103d
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/scene8.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/scene9.mp3 b/site/little-red-riding-hood/ch01/audio/en/scene9.mp3
new file mode 100644
index 0000000..555906b
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/en/scene9.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/en/shots.js b/site/little-red-riding-hood/ch01/audio/en/shots.js
new file mode 100644
index 0000000..b1965a8
--- /dev/null
+++ b/site/little-red-riding-hood/ch01/audio/en/shots.js
@@ -0,0 +1,24 @@
+TIMINGS.scene1 = {"dur": 22.996, "marks": {}, "cues": [[0.138, "Once upon a time, there was a little girl who loved her red hooded cape so much that everyone called her Little Red Riding Hood."], [7.58, "Take this cake and apple juice to Grandma."], [10.655, "She isn't feeling well."], [12.856, "Stay on the path, and don't talk to strangers!"], [16.952, "I promise!"]], "parts": {"s01": 0, "s01b": 7.478, "s01c": 16.852}};
+TIMINGS.scene2 = {"dur": 8.688, "marks": {"s02.eyes": 4.45}, "cues": [[0.113, "Grandma lived on the other side of the woods, under three big oak trees."], [4.45, "But someone was watching."]], "parts": {"s02": 0}};
+TIMINGS.scene3 = {"dur": 16.276, "marks": {}, "cues": [[0.1, "Good morning, Little Red Riding Hood!"], [3.396, "Where are you off to?"], [5.826, "To Grandma's house."], [8.014, "It's under the three big oaks."], [11.144, "Cake\u2026 and a grandma."], [13.555, "What a lucky day!"]], "parts": {"s03": 0, "s03b": 5.726, "s03c": 11.044}};
+TIMINGS.scene4 = {"dur": 14.338, "marks": {"s04b.pick": 5.048, "s04b.run": 10.073}, "cues": [[0.1, "Why hurry?"], [1.704, "Look at all these lovely flowers!"], [5.048, "So Little Red Riding Hood left the path to pick a bunch for Grandma."], [10.073, "And the wolf ran straight to Grandma's house."]], "parts": {"s04": 0, "s04b": 4.91}};
+TIMINGS.scene5 = {"dur": 10.91, "marks": {}, "cues": [[0.1, "Grandma!"], [1.704, "It's me, Little Red Riding Hood!"], [5.376, "Just lift the latch, dear, and come in."]], "parts": {"s05": 0, "s05b": 5.27}};
+TIMINGS.scene6 = {"dur": 12.208, "marks": {"s06.hide": 3.325, "s06.cap": 6.513}, "cues": [[0.138, "Grandma may have been poorly, but she was quick!"], [3.325, "She hopped into the wardrobe and held the door shut."], [6.513, "The wolf put on her nightcap and glasses, climbed into bed, and waited."]], "parts": {"s06": 0}};
+TIMINGS.scene7 = {"dur": 18.41, "marks": {}, "cues": [[0.1, "Good morning, Mr."], [1.5, "Woodcutter!"], [3.499, "Morning, Little Red!"], [5.719, "Say hello to your grandma for me!"], [9.045, "Little Red Riding Hood arrived with her flowers."], [12.207, "How strange."], [13.557, "The door was wide open."], [15.838, "Grandma?"]], "parts": {"s07w": 0, "s07x": 3.398, "s07": 8.932, "s07b": 15.738}};
+TIMINGS.scene8 = {"dur": 21.414, "marks": {}, "cues": [[0.1, "Grandma, what big ears you have!"], [3.642, "All the better to hear you with, my dear."], [7.28, "Grandma, what big eyes you have!"], [10.87, "All the better to see you with."], [13.692, "And Grandma\u2026 what a big mouth you have!"], [18.118, "All the better to EAT you with!"]], "parts": {"s08": 0, "s08b": 3.542, "s08c": 7.18, "s08d": 10.77, "s08e": 13.592, "s08f": 18.018}};
+TIMINGS.scene9 = {"dur": 18.394, "marks": {"s09c.gran": 11.05, "s09c.wood": 12.538, "s09c.way": 14.8}, "cues": [[0.1, "Help!"], [2.928, "Out of my house, you rascal!"], [7.369, "Go on!"], [8.964, "Shoo!"], [10.876, "With Grandma on one side and the woodcutter at the door, the wolf had only one way out!"]], "parts": {"s09a": 0, "s09": 2.222, "s09b": 7.268, "s09c": 10.738}};
+TIMINGS.scene10 = {"dur": 8.262, "marks": {}, "cues": [[0.101, "And don't come back to these woods!"], [3.224, "The wolf ran so fast, he never even took off the nightcap."]], "parts": {"s10": 0, "s10b": 3.086}};
+TIMINGS.scene11 = {"dur": 16.26, "marks": {}, "cues": [[0.113, "Grandma ate the cake, drank the apple juice, and soon felt much better."], [5.202, "From now on, I'll stay on the path."], [8.464, "And I'll never chat with wolves!"], [11.901, "The end."]], "parts": {"s11": 0, "s11b": 5.102, "s11c": 11.788}};
+MOUTHS.s01c = [[0.1, "C"], [0.263, "A"], [0.341, "B"], [0.42, "E"], [0.498, "A"], [0.577, "C"], [0.655, "B"], [0.734, "C"], [0.812, "X"], [1.899, "X"]];
+MOUTHS.s02 = [[0.113, "B"], [0.21, "D"], [0.307, "B"], [0.405, "A"], [0.503, "D"], [0.6, "H"], [0.657, "C"], [0.715, "G"], [0.772, "C"], [0.83, "B"], [0.887, "E"], [0.944, "B"], [1.0, "B"], [1.062, "C"], [1.125, "E"], [1.184, "B"], [1.244, "C"], [1.303, "B"], [1.363, "B"], [1.431, "C"], [1.5, "B"], [1.569, "C"], [1.637, "E"], [1.681, "G"], [1.725, "B"], [1.775, "C"], [1.825, "F"], [2.1, "B"], [2.375, "X"], [2.525, "F"], [2.587, "B"], [2.65, "C"], [2.712, "B"], [2.775, "B"], [2.931, "C"], [3.087, "A"], [3.158, "C"], [3.229, "B"], [3.3, "E"], [3.379, "D"], [3.458, "B"], [3.538, "B"], [3.721, "C"], [3.904, "B"], [4.088, "X"], [4.45, "A"], [4.525, "F"], [4.6, "B"], [4.675, "B"], [4.741, "E"], [4.807, "A"], [4.873, "C"], [4.939, "E"], [5.005, "B"], [5.071, "C"], [5.138, "F"], [5.196, "D"], [5.254, "B"], [5.312, "F"], [5.423, "D"], [5.532, "B"], [5.643, "C"], [5.752, "B"], [5.862, "X"], [6.199, "X"]];
+MOUTHS.s03c = [[0.1, "B"], [0.238, "D"], [0.375, "B"], [0.513, "C"], [0.65, "X"], [0.79, "D"], [0.855, "B"], [0.92, "D"], [0.998, "B"], [1.108, "D"], [1.218, "B"], [1.328, "A"], [1.438, "D"], [1.548, "X"], [2.511, "F"], [2.573, "B"], [2.635, "D"], [2.696, "B"], [2.758, "D"], [2.849, "H"], [2.95, "F"], [3.051, "B"], [3.152, "C"], [3.253, "B"], [3.528, "C"], [3.803, "X"], [4.599, "X"]];
+MOUTHS.s04b = [[0.138, "B"], [0.244, "E"], [0.35, "H"], [0.427, "C"], [0.505, "B"], [0.583, "H"], [0.66, "C"], [0.738, "B"], [0.808, "C"], [0.879, "B"], [0.95, "B"], [1.05, "C"], [1.15, "B"], [1.25, "C"], [1.35, "B"], [1.45, "B"], [1.512, "F"], [1.575, "B"], [1.637, "H"], [1.709, "C"], [1.781, "G"], [1.853, "B"], [1.925, "B"], [1.975, "C"], [2.025, "A"], [2.175, "D"], [2.325, "B"], [2.475, "B"], [2.531, "E"], [2.587, "A"], [2.654, "C"], [2.721, "B"], [2.788, "D"], [2.875, "A"], [2.979, "F"], [3.083, "B"], [3.188, "G"], [3.229, "E"], [3.271, "B"], [3.312, "B"], [3.422, "D"], [3.532, "B"], [3.643, "A"], [3.752, "D"], [3.862, "X"], [4.199, "X"], [5.163, "D"], [5.225, "B"], [5.288, "B"], [5.338, "C"], [5.387, "F"], [5.478, "E"], [5.569, "H"], [5.659, "G"], [5.75, "B"], [5.85, "D"], [5.95, "B"], [6.05, "B"], [6.196, "C"], [6.342, "B"], [6.488, "B"], [6.538, "E"], [6.588, "B"], [6.673, "D"], [6.758, "B"], [6.844, "A"], [6.929, "D"], [7.015, "B"], [7.1, "B"], [7.238, "F"], [7.375, "B"], [7.512, "C"], [7.65, "X"], [7.999, "X"]];
+MOUTHS.s05b = [[0.106, "B"], [0.217, "F"], [0.328, "B"], [0.439, "H"], [0.508, "C"], [0.578, "G"], [0.647, "B"], [0.717, "B"], [0.779, "C"], [0.842, "H"], [1.025, "D"], [1.208, "B"], [1.397, "B"], [1.581, "C"], [1.764, "B"], [2.008, "D"], [2.14, "B"], [2.272, "B"], [2.345, "E"], [2.418, "A"], [2.491, "C"], [2.564, "C"], [2.839, "B"], [3.114, "X"], [3.799, "X"]];
+MOUTHS.s06 = [[0.138, "B"], [0.233, "D"], [0.328, "B"], [0.423, "A"], [0.518, "D"], [0.613, "A"], [0.713, "C"], [0.812, "B"], [0.859, "D"], [0.906, "G"], [0.953, "C"], [1.0, "A"], [1.067, "C"], [1.133, "B"], [1.2, "A"], [1.31, "F"], [1.42, "B"], [1.53, "H"], [1.64, "C"], [1.75, "X"], [1.95, "A"], [2.008, "F"], [2.067, "B"], [2.125, "B"], [2.219, "C"], [2.312, "F"], [2.375, "D"], [2.438, "B"], [2.5, "B"], [2.638, "F"], [2.775, "C"], [2.912, "B"], [3.05, "X"], [3.325, "B"], [3.425, "C"], [3.525, "B"], [3.587, "E"], [3.65, "A"], [3.712, "C"], [3.775, "B"], [3.837, "C"], [3.917, "B"], [3.996, "E"], [4.075, "B"], [4.131, "C"], [4.188, "F"], [4.279, "D"], [4.371, "B"], [4.463, "E"], [4.554, "A"], [4.646, "C"], [4.825, "D"], [4.894, "B"], [4.963, "B"], [5.034, "C"], [5.106, "H"], [5.178, "B"], [5.25, "B"], [5.306, "C"], [5.362, "B"], [5.433, "F"], [5.504, "B"], [5.575, "B"], [5.758, "F"], [5.942, "B"], [6.125, "X"], [6.513, "B"], [6.562, "C"], [6.612, "F"], [6.697, "E"], [6.781, "H"], [6.866, "G"], [6.95, "A"], [7.021, "F"], [7.092, "B"], [7.162, "E"], [7.231, "B"], [7.3, "B"], [7.342, "C"], [7.383, "B"], [7.425, "B"], [7.532, "C"], [7.64, "B"], [7.748, "D"], [7.855, "A"], [7.963, "D"], [8.019, "B"], [8.075, "B"], [8.167, "H"], [8.258, "D"], [8.35, "B"], [8.442, "C"], [8.533, "B"], [8.625, "X"], [8.988, "B"], [9.048, "H"], [9.108, "C"], [9.169, "A"], [9.229, "C"], [9.29, "B"], [9.35, "C"], [9.429, "B"], [9.508, "E"], [9.588, "A"], [9.767, "C"], [9.946, "B"], [10.125, "D"], [10.188, "B"], [10.25, "F"], [10.36, "C"], [10.47, "B"], [10.58, "C"], [10.69, "B"], [10.8, "X"], [11.149, "X"]];
+MOUTHS.s07b = [[0.1, "B"], [0.21, "D"], [0.32, "B"], [0.43, "A"], [0.54, "D"], [0.65, "X"], [1.849, "X"]];
+MOUTHS.s08e = [[0.1, "D"], [0.2, "B"], [0.3, "B"], [0.41, "D"], [0.52, "B"], [0.63, "A"], [0.74, "D"], [0.85, "X"], [0.999, "X"], [1.65, "F"], [1.7, "B"], [1.75, "D"], [1.8, "B"], [1.85, "D"], [1.938, "A"], [2.038, "C"], [2.137, "B"], [2.238, "A"], [2.354, "F"], [2.471, "B"], [2.587, "C"], [2.675, "F"], [2.763, "B"], [2.9, "D"], [3.038, "G"], [3.175, "C"], [3.312, "X"]];
+MOUTHS.s08f = [[0.1, "D"], [0.237, "H"], [0.373, "B"], [0.432, "C"], [0.491, "A"], [0.545, "C"], [0.6, "B"], [0.655, "C"], [0.709, "B"], [0.764, "B"], [0.823, "E"], [0.881, "C"], [1.018, "B"], [1.155, "C"], [1.226, "F"], [1.298, "F"], [1.481, "C"], [1.665, "B"], [1.848, "X"], [2.449, "X"]];
+MOUTHS.s09 = [[0.049, "X"], [0.706, "F"], [0.803, "B"], [0.9, "E"], [0.962, "G"], [1.025, "A"], [1.136, "C"], [1.247, "B"], [1.385, "F"], [1.522, "B"], [1.66, "C"], [1.831, "C"], [1.935, "F"], [2.039, "B"], [2.149, "D"], [2.259, "B"], [2.369, "D"], [2.479, "H"], [2.589, "X"], [3.599, "X"]];
+MOUTHS.s09c = [[0.138, "F"], [0.196, "C"], [0.254, "B"], [0.312, "B"], [0.412, "D"], [0.512, "B"], [0.613, "A"], [0.713, "D"], [0.812, "E"], [0.912, "B"], [1.012, "E"], [1.096, "B"], [1.179, "C"], [1.262, "B"], [1.363, "C"], [1.462, "B"], [1.562, "C"], [1.663, "D"], [1.731, "B"], [1.8, "B"], [1.837, "C"], [1.875, "F"], [1.962, "B"], [2.05, "F"], [2.138, "B"], [2.225, "C"], [2.312, "B"], [2.4, "D"], [2.462, "B"], [2.525, "B"], [2.581, "C"], [2.638, "B"], [2.821, "F"], [3.004, "B"], [3.288, "B"], [3.338, "C"], [3.388, "F"], [3.463, "E"], [3.538, "H"], [3.612, "G"], [3.688, "B"], [3.742, "D"], [3.796, "B"], [3.85, "E"], [3.903, "B"], [3.956, "H"], [4.009, "C"], [4.062, "E"], [4.15, "B"], [4.237, "C"], [4.325, "F"], [4.431, "C"], [4.537, "F"], [4.812, "B"], [5.087, "X"], [5.149, "X"]];
+MOUTHS.s10b = [[0.138, "B"], [0.188, "C"], [0.237, "F"], [0.325, "E"], [0.412, "H"], [0.5, "G"], [0.588, "B"], [0.696, "D"], [0.804, "B"], [0.912, "B"], [1.038, "E"], [1.163, "G"], [1.346, "D"], [1.529, "B"], [1.713, "X"], [2.013, "B"], [2.056, "C"], [2.1, "B"], [2.158, "C"], [2.215, "G"], [2.272, "C"], [2.33, "B"], [2.388, "C"], [2.45, "G"], [2.513, "C"], [2.575, "B"], [2.638, "B"], [2.708, "F"], [2.779, "B"], [2.85, "E"], [2.938, "G"], [3.025, "B"], [3.075, "C"], [3.125, "B"], [3.235, "C"], [3.345, "B"], [3.455, "D"], [3.565, "A"], [3.675, "X"], [4.149, "X"]];
+MOUTHS.s11c = [[0.113, "B"], [0.225, "C"], [0.338, "C"], [0.613, "B"], [0.888, "X"], [1.849, "X"]];
diff --git a/site/little-red-riding-hood/ch01/audio/en/timings.js b/site/little-red-riding-hood/ch01/audio/en/timings.js
new file mode 100644
index 0000000..2f4f804
--- /dev/null
+++ b/site/little-red-riding-hood/ch01/audio/en/timings.js
@@ -0,0 +1,392 @@
+window.TIMINGS = {
+ "s01": {
+ "dur": 7.128,
+ "marks": {},
+ "cues": [
+ [
+ 0.138,
+ "Once upon a time, there was a little girl who loved her red hooded cape so much that everyone called her Little Red Riding Hood."
+ ]
+ ]
+ },
+ "s01b": {
+ "dur": 9.024,
+ "marks": {},
+ "cues": [
+ [
+ 0.102,
+ "Take this cake and apple juice to Grandma."
+ ],
+ [
+ 3.177,
+ "She isn't feeling well."
+ ],
+ [
+ 5.378,
+ "Stay on the path, and don't talk to strangers!"
+ ]
+ ]
+ },
+ "s01c": {
+ "dur": 1.944,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "I promise!"
+ ]
+ ]
+ },
+ "s02": {
+ "dur": 6.288,
+ "marks": {
+ "eyes": 4.45
+ },
+ "cues": [
+ [
+ 0.113,
+ "Grandma lived on the other side of the woods, under three big oak trees."
+ ],
+ [
+ 4.45,
+ "But someone was watching."
+ ]
+ ]
+ },
+ "s03": {
+ "dur": 5.376,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "Good morning, Little Red Riding Hood!"
+ ],
+ [
+ 3.396,
+ "Where are you off to?"
+ ]
+ ]
+ },
+ "s03b": {
+ "dur": 4.968,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "To Grandma's house."
+ ],
+ [
+ 2.288,
+ "It's under the three big oaks."
+ ]
+ ]
+ },
+ "s03c": {
+ "dur": 4.632,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "Cake\u2026 and a grandma."
+ ],
+ [
+ 2.511,
+ "What a lucky day!"
+ ]
+ ]
+ },
+ "s04": {
+ "dur": 4.56,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "Why hurry?"
+ ],
+ [
+ 1.704,
+ "Look at all these lovely flowers!"
+ ]
+ ]
+ },
+ "s04b": {
+ "dur": 7.128,
+ "marks": {
+ "pick": 0.138,
+ "run": 4.263
+ },
+ "cues": [
+ [
+ 0.138,
+ "So Little Red Riding Hood left the path to pick a bunch for Grandma."
+ ],
+ [
+ 4.263,
+ "And the wolf ran straight to Grandma's house."
+ ]
+ ]
+ },
+ "s05": {
+ "dur": 4.92,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "Grandma!"
+ ],
+ [
+ 1.704,
+ "It's me, Little Red Riding Hood!"
+ ]
+ ]
+ },
+ "s05b": {
+ "dur": 3.84,
+ "marks": {},
+ "cues": [
+ [
+ 0.106,
+ "Just lift the latch, dear, and come in."
+ ]
+ ]
+ },
+ "s06": {
+ "dur": 11.208,
+ "marks": {
+ "hide": 3.325,
+ "cap": 6.513
+ },
+ "cues": [
+ [
+ 0.138,
+ "Grandma may have been poorly, but she was quick!"
+ ],
+ [
+ 3.325,
+ "She hopped into the wardrobe and held the door shut."
+ ],
+ [
+ 6.513,
+ "The wolf put on her nightcap and glasses, climbed into bed, and waited."
+ ]
+ ]
+ },
+ "s07w": {
+ "dur": 3.048,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "Good morning, Mr."
+ ],
+ [
+ 1.5,
+ "Woodcutter!"
+ ]
+ ]
+ },
+ "s07x": {
+ "dur": 5.184,
+ "marks": {},
+ "cues": [
+ [
+ 0.101,
+ "Morning, Little Red!"
+ ],
+ [
+ 2.321,
+ "Say hello to your grandma for me!"
+ ]
+ ]
+ },
+ "s07": {
+ "dur": 6.456,
+ "marks": {},
+ "cues": [
+ [
+ 0.113,
+ "Little Red Riding Hood arrived with her flowers."
+ ],
+ [
+ 3.275,
+ "How strange."
+ ],
+ [
+ 4.625,
+ "The door was wide open."
+ ]
+ ]
+ },
+ "s07b": {
+ "dur": 1.872,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "Grandma?"
+ ]
+ ]
+ },
+ "s08": {
+ "dur": 3.192,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "Grandma, what big ears you have!"
+ ]
+ ]
+ },
+ "s08b": {
+ "dur": 3.288,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "All the better to hear you with, my dear."
+ ]
+ ]
+ },
+ "s08c": {
+ "dur": 3.24,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "Grandma, what big eyes you have!"
+ ]
+ ]
+ },
+ "s08d": {
+ "dur": 2.472,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "All the better to see you with."
+ ]
+ ]
+ },
+ "s08e": {
+ "dur": 3.576,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "And Grandma\u2026 what a big mouth you have!"
+ ]
+ ]
+ },
+ "s08f": {
+ "dur": 2.496,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "All the better to EAT you with!"
+ ]
+ ]
+ },
+ "s09a": {
+ "dur": 1.872,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "Help!"
+ ]
+ ]
+ },
+ "s09": {
+ "dur": 3.096,
+ "marks": {},
+ "cues": [
+ [
+ 0.106,
+ "Out of my house, you rascal!"
+ ]
+ ]
+ },
+ "s09b": {
+ "dur": 3.12,
+ "marks": {},
+ "cues": [
+ [
+ 0.101,
+ "Go on!"
+ ],
+ [
+ 1.696,
+ "Shoo!"
+ ]
+ ]
+ },
+ "s09c": {
+ "dur": 5.256,
+ "marks": {
+ "gran": 0.312,
+ "wood": 1.8,
+ "way": 4.062
+ },
+ "cues": [
+ [
+ 0.138,
+ "With Grandma on one side and the woodcutter at the door, the wolf had only one way out!"
+ ]
+ ]
+ },
+ "s10": {
+ "dur": 2.736,
+ "marks": {},
+ "cues": [
+ [
+ 0.101,
+ "And don't come back to these woods!"
+ ]
+ ]
+ },
+ "s10b": {
+ "dur": 4.176,
+ "marks": {},
+ "cues": [
+ [
+ 0.138,
+ "The wolf ran so fast, he never even took off the nightcap."
+ ]
+ ]
+ },
+ "s11": {
+ "dur": 4.752,
+ "marks": {},
+ "cues": [
+ [
+ 0.113,
+ "Grandma ate the cake, drank the apple juice, and soon felt much better."
+ ]
+ ]
+ },
+ "s11b": {
+ "dur": 6.336,
+ "marks": {},
+ "cues": [
+ [
+ 0.1,
+ "From now on, I'll stay on the path."
+ ],
+ [
+ 3.362,
+ "And I'll never chat with wolves!"
+ ]
+ ]
+ },
+ "s11c": {
+ "dur": 1.872,
+ "marks": {},
+ "cues": [
+ [
+ 0.113,
+ "The end."
+ ]
+ ]
+ }
+};
diff --git a/site/little-red-riding-hood/ch01/audio/sfx/bang.mp3 b/site/little-red-riding-hood/ch01/audio/sfx/bang.mp3
new file mode 100644
index 0000000..2c8abd0
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/sfx/bang.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/sfx/bonk.mp3 b/site/little-red-riding-hood/ch01/audio/sfx/bonk.mp3
new file mode 100644
index 0000000..af4dbd5
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/sfx/bonk.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/sfx/chop.mp3 b/site/little-red-riding-hood/ch01/audio/sfx/chop.mp3
new file mode 100644
index 0000000..088a42a
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/sfx/chop.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/sfx/crash.mp3 b/site/little-red-riding-hood/ch01/audio/sfx/crash.mp3
new file mode 100644
index 0000000..c0fb521
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/sfx/crash.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/sfx/knock.mp3 b/site/little-red-riding-hood/ch01/audio/sfx/knock.mp3
new file mode 100644
index 0000000..7228cbf
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/sfx/knock.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/audio/sfx/thud.mp3 b/site/little-red-riding-hood/ch01/audio/sfx/thud.mp3
new file mode 100644
index 0000000..47f676f
Binary files /dev/null and b/site/little-red-riding-hood/ch01/audio/sfx/thud.mp3 differ
diff --git a/site/little-red-riding-hood/ch01/index.html b/site/little-red-riding-hood/ch01/index.html
new file mode 100644
index 0000000..2f8e4c0
--- /dev/null
+++ b/site/little-red-riding-hood/ch01/index.html
@@ -0,0 +1,648 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Little Red Riding Hood</title>
+<link rel="stylesheet" href="../lib/engine.css">
+<link rel="expect" href="#bar" blocking="render">
+</head>
+<body>
+<script src="../lib/engine.js"></script>
+<script src="../img/sets/sets.js"></script>
+<script src="../img/puppets/baked.js" onerror="0"></script>
+<script src="../lib/paper.js"></script>
+<script src="../lib/cast.js"></script>
+<script src="audio/en/timings.js"></script>
+<script src="audio/en/mouths.js"></script>
+<script src="audio/en/shots.js"></script>
+<script>
+'use strict';
+const CHAPTER = { number: 1, title: 'Little Red Riding Hood', minutes: 4, language: 'en' };
+// A picture book: captions are on unless the reader turned them off.
+try { if (localStorage.getItem('captions') === null) setCaptions(true); } catch {}
+
+// The time (beat clock) of a word: part `b` of a joined scene, `w` seconds into its clip.
+const word = (scene, pre, b, w) => pre + TIMINGS[scene].parts[b] + w;
+
+/* ---------- scene 1: home ---------- */
+// The ground at the cottage door is y 790; puppets here are at scale .6 (Red about 245 px tall).
+const PRE1 = 1.5, DOOR = 6.75, OUT = 7.05, LAND = 8.25;
+const SC1 = t => PRE1 + TIMINGS.scene1.parts.s01b + t; // a moment in Mother's line
+const T13 = 8.9, GIVE = 9.15, REACH = 9.85, TAKE = 10.35;
+const T14 = SC1(5.25), T15 = PRE1 + TIMINGS.scene1.parts.s01c - .15, SC1c = t => PRE1 + TIMINGS.scene1.parts.s01c + t;
+// 1.6: Red turns round and walks off along the garden path toward the woods; the path climbs and narrows into the
+// distance, so she grows smaller as she goes. Mother waves from the door. A near tree trunk wipes to scene 2.
+const T16 = T15 + 1.5, TURN = T16 + .25, WALK = TURN + .4, WIPE = 23.55;
+const pathY = x => 806 - .05 * (x - 560), depth = x => .62 * (1 - .32 * Math.min(1, Math.max(0, (x - 830) / 970)));
+// A raised finger that wags on twos while she says the words between a and b.
+const wag = (q, a, b) => q > a && q < b ? 9 * (Math.floor(q * FPS / 2) % 2 ? 1 : -1) : 0;
+const tween = (q, t0, d, a, b) => a + (b - a) * span(q, t0, t0 + d);
+const footY = (gy, s) => gy - 170 * s; // hip height for feet on the ground line gy
+function door(parent) {
+ const g = mk('g', {}, parent);
+ g.innerHTML = `<g filter="url(#paper)"><path d="M606,790 L606,476 Q675,424 744,476 L744,790 Z" fill="#8a5a32"/>
+ <path d="M640,450 V790 M675,436 V790 M710,450 V790" stroke="#6e4426" stroke-width="3"/>
+ <path d="M606,530 h70 M606,720 h70" stroke="#3b2a1e" stroke-width="9"/><circle cx="726" cy="630" r="7" fill="#caa24c"/></g>`;
+ bakeAll(g);
+ const open = [1, .7, .3, -.1, -.4, -.55];
+ return q => { const k = Math.floor((q - DOOR) * FPS); tf(g, `translate(606,0) scale(${k < 0 ? 1 : open[Math.min(k, open.length - 1)]},1) translate(-606,0)`); };
+}
+function scene1(p, D) {
+ // 1.1 from the treetops down to the cottage, then a slow push toward the door
+ const cam = paperCam(p, 'home', { x: 800, y: -260, z: 1 });
+ cam.to({ y: 450 }, .4, 3.2).to({ x: 690, y: 560, z: 1.45 }, 3.8, 2.8);
+ // 1.2 medium on the door: it swings open and Red spins out into the garden, ending turned back toward the house
+ cam.cut({ x: 745, y: 640, z: 2 }, 6.6);
+ // 1.3 two-shot: Mother steps into the doorway and hands Red the basket
+ cam.cut({ x: 760, y: 600, z: 1.7 }, T13);
+ // 1.4 Mother close, facing us, finger raised; 1.5 Red close, nodding hard. Each is alone in her close-up.
+ cam.cut({ x: 708, y: 552, z: 4.4 }, T14).soft(T14, true);
+ // The reverse angle for Red's close-up: from the doorway out over the garden, so a second camera on its own set,
+ // with Red drawn large in it instead of zooming.
+ const out = paperCam(p, 'homeOut').soft(0, 'all'), redOut = redPuppet(out.stage);
+ cam.cut({ x: 1000, y: 470, z: 1 }, T16).soft(T16, false).to({ x: 1140 }, WALK + .3, 3);
+ const wipe = trunkWipe(p, WIPE, D - WIPE - .05);
+ const puffs = smoke(cam.stage, 932, 84), theDoor = door(cam.stage), mom = motherPuppet(cam.stage), red = redPuppet(cam.stage);
+ stopClock(D, (q, f) => {
+ const reverse = q >= T15 && q < T15 + 1.5;
+ vis(cam.root, !reverse); vis(out.root, reverse);
+ if (reverse) {
+ out.apply(q, f);
+ redOut.pose({ x: 800, y: 430 + 194 * 2.88, s: 2.88, head: 'F', mouth: mouthAt('s01c', q - SC1c(0)), shut: blinking(q, [19.4]),
+ nod: [.1, .45].some(t => q >= SC1c(t) && q < SC1c(t) + 2 / FPS) ? 22 : 0, rua: 4, rfa: -2 }, f);
+ return;
+ }
+ cam.apply(q, f); puffs(q); theDoor(q); wipe(q);
+
+ vis(mom.g, q >= T13);
+ const held = q < TAKE, sm = .6;
+ mom.pose({
+ x: 690, y: 790 - 212 * sm, s: sm,
+ ua: q < TAKE ? tween(q, GIVE, .45, 6, -45) : tween(q, TAKE + .15, .5, -45, 6),
+ fa: q < TAKE ? tween(q, GIVE, .45, -6, -15) : tween(q, TAKE + .15, .5, -15, -6),
+ finger: q >= T14 && q < T15, head: q >= T14 && q < T15 ? 'F' : 'P',
+ rua: -28, rfa: -146 + wag(q, SC1(5.4), SC1(6.1)) + wag(q, SC1(6.7), SC1(7.9)), lua: 40, lfa: -58,
+ basket: held, swing: held ? 6 * Math.exp(-(q - GIVE) * 2.5) * Math.sin((q - GIVE) * 9) * (q > GIVE) : 0,
+ brow: q < T14 ? span(q, SC1(3.0), SC1(3.3)) : -.7 * span(q, SC1(6.6), SC1(6.8)), headR: q < T14 ? 4 * span(q, SC1(3.0), SC1(3.3)) : -3 * span(q, SC1(6.6), SC1(6.8)),
+ mouth: mouthAt('s01b', q - SC1(0)), shut: blinking(q, [11.4, 15.6, 22.4]),
+ ...(q >= TURN + .2 ? { ua: -118, fa: -30 + (Math.floor(q * FPS / 2) % 2 ? 22 : -22) } : {}), // waving on twos
+ }, f);
+
+ vis(red.g, q >= DOOR + .25 && !(q >= T14 && q < T15));
+ const u = Math.min(1, Math.max(0, (q - OUT) / (LAND - OUT))), after = Math.max(0, q - LAND), s = .6 + .02 * u;
+ const settle = Math.exp(-after * 3) * Math.sin(after * 10), spinning = u > 0 && u < 1;
+ const sinceTake = Math.max(0, q - TAKE), sway = 7 * Math.exp(-sinceTake * 2.2) * Math.sin(sinceTake * 8);
+ if (q >= T16) { // 1.6
+ const w = walk(q - WALK, { period: .85, A: 26 }), xs = 830 + w.d * .5, sr = depth(xs), x = 830 + w.d * sr;
+ const tw = Math.min(1, Math.max(0, (q - TURN) / .35)), walking = q > WALK;
+ red.pose({ x, y: pathY(x) - (170 - w.drop) * sr, s: sr, turn: -Math.cos(Math.PI * tw),
+ near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, cape: walking ? 3 + 3 * Math.sin(2 * w.ph + .6) : 3,
+ ua: walking ? -8 + 6 * Math.sin(w.ph) : -8, fa: -78, swing: walking ? 9 * Math.sin(w.ph - 1) : 0,
+ headR: walking ? 2 * Math.sin(2 * w.ph) : 0, shut: blinking(q, [21.6]) }, f);
+ return;
+ }
+ red.pose({
+ x: 675 + 155 * ease(u), y: footY(790 + 10 * u, s) - 16 * Math.abs(Math.sin(Math.PI * 3 * u)), s,
+ turn: Math.cos(Math.PI * 3 * ease(u)), // one and a half turns: she ends facing the door
+ near: 12 * Math.sin(6 * Math.PI * u), far: -12 * Math.sin(6 * Math.PI * u),
+ kNear: 22 * Math.abs(Math.sin(3 * Math.PI * u)), kFar: 14 * Math.abs(Math.sin(3 * Math.PI * u + 1)),
+ cape: 3 + 30 * Math.sin(Math.PI * u) + 6 * settle,
+ ua: spinning ? -8 - 62 * Math.sin(Math.PI * u) : q < TAKE ? tween(q, REACH, .4, 4 + 4 * settle, -70) : tween(q, TAKE + .05, .5, -70, -8),
+ fa: spinning ? -24 : q < TAKE ? tween(q, REACH, .4, -10, -20) : tween(q, TAKE + .05, .5, -20, -78),
+ basket: !held, swing: sway,
+ headR: spinning ? 0 : -2 * settle - 3 * span(q, SC1(3.2), SC1(3.5)) + 3 * span(q, T15, T15 + .2), shut: blinking(q, [9.6, 13.9, 19.4]),
+
+ }, f);
+ });
+}
+
+/* ---------- sound effects ----------
+ sfx(beat, at, name, vol): play audio/sfx/<name>.mp3 when the clock of beat `beat` passes `at` in normal playback
+ (seeking past it does not fire it). Pausing stops them. Made by tools/little-red-riding-hood/sfx.py. */
+const SFX = [], sfxOn = [];
+const sfx = (beat, at, name, vol = 1) => SFX.push({ beat, at, name, vol });
+let sfxLast = { i: -1, t: 0 };
+function sfxTick() {
+ const id = BEATS[P.i]?.id, on = P.started && P.playing && !P.waiting && !P.done;
+ if (on && sfxLast.i === P.i && P.t > sfxLast.t && P.t - sfxLast.t < .5)
+ for (const e of SFX) if (e.beat === id && e.at > sfxLast.t && e.at <= P.t) {
+ const a = new Audio(`audio/sfx/${e.name}.mp3`); a.volume = e.vol * +(document.getElementById('volume')?.value ?? 1); a.playbackRate = P.rate || 1;
+ a.play().catch(() => {}); sfxOn.push(a); a.onended = () => sfxOn.splice(sfxOn.indexOf(a), 1);
+ }
+ if (!on) while (sfxOn.length) sfxOn.pop().pause();
+ sfxLast = { i: P.i, t: P.t };
+ requestAnimationFrame(sfxTick);
+}
+requestAnimationFrame(sfxTick);
+
+/* ---------- shared for scenes 2–11 ---------- */
+// Beat-clock time of `t` seconds into clip `clip` of a joined scene that starts its narration `pre` s in.
+const clipAt = (scene, pre, clip, t = 0) => pre + TIMINGS[scene].parts[clip] + t;
+const onTwos = q => Math.floor(q * FPS / 2) % 2 ? 1 : -1;
+const between = (q, a, b) => q >= a && q < b;
+// Who is speaking: [clip, scene, pre] → the mouth for this frame, or 'X'.
+const lips = (q, scene, pre, ...clips) => { for (const c of clips) { const m = mouthAt(c, q - clipAt(scene, pre, c)); if (m !== 'X') return m; } return 'X'; };
+// The ground the path runs on in the woods, and where a puppet's hip sits for feet on it.
+const WOODS = 785, hipOn = (gy, s, feet = 170) => gy - feet * s;
+// A walk of a puppet from x0 to the right (dir -1: to the left), stopping cleanly after `steps` steps.
+function walker(x0, s, opts = {}, dir = 1, steps = Infinity) {
+ const half = (opts.period || 1) / 2;
+ return tau => { const w = walk(Math.min(tau, steps * half), opts); return { ...w, x: x0 + dir * w.d * s }; };
+}
+const bushBackSVG = (x, y) => `<g filter="url(#paper)" transform="translate(${x},${y}) scale(.9)"><circle cx="-80" cy="-40" r="58" fill="#2f5638"/><circle cx="80" cy="-46" r="62" fill="#2f5638"/>
+ <rect x="-110" y="-70" width="220" height="90" rx="30" fill="#26482f"/><circle cx="0" cy="-122" r="50" fill="#3a6844"/></g>`;
+const bushFrontSVG = (x, y) => `<g filter="url(#paper)" transform="translate(${x},${y}) scale(.9)"><circle cx="-30" cy="-6" r="40" fill="#3a6844"/><circle cx="40" cy="-4" r="42" fill="#3a6844"/></g>`;
+// Round eyes in the dark of a bush: open (0 … 1) and look (-1 … 1).
+function bushEyes(parent, x, y) {
+ const g = mk('g', {}, parent);
+ const e = [-23, 23].map(dx => { const w = mk('g', { transform: `translate(${x + dx},${y})` }, g); mk('ellipse', { rx: 13.5, ry: 11.5, fill: '#fbf4e2' }, w); return [w, mk('circle', { r: 6, fill: '#22150e' }, w)]; });
+ return (open, look) => { vis(g, open > 0); e.forEach(([w, p], i) => { tf(w, `translate(${x + [-23, 23][i]},${y}) scale(1,${Math.max(.05, open).toFixed(2)})`); p.setAttribute('cx', (6 * look).toFixed(1)); }); };
+}
+const doorLeaf = (parent, d, fill, hinge, extra = '') => { const g = prop(parent, `<g filter="url(#paper)"><path d="${d}" fill="${fill}"/>${extra}</g>`); return k => tf(g, `translate(${hinge},0) scale(${k.toFixed(2)},1) translate(${-hinge},0)`); };
+// Door positions over its frames from shut (1) to open; returns the door's scale at time q for an opening at t0.
+const OPENING = [1, .75, .45, .15, -.15, -.35];
+const opening = (q, t0, steps = OPENING) => q < t0 ? steps[0] : steps[Math.min(steps.length - 1, Math.floor((q - t0) * FPS))];
+const quiltSVG = `<g filter="url(#paper)"><path d="M736,646 C800,630 900,640 1000,628 C1100,620 1200,632 1344,640 L1350,764 L730,764 Z" fill="#b5523b"/>
+ ${[0, 1, 2, 3, 4].map(i => `<rect x="${770 + i * 112}" y="${660 + (i % 2) * 34}" width="70" height="44" fill="${i % 2 ? '#e8c4a0' : '#c8704a'}"/>`).join('')}</g>`;
+function roomProps(cam, order) {
+ // order: puppet slots between the room's pieces, back to front. Returns the pieces' controls.
+ const st = cam.stage, slot = n => mk('g', {}, st), r = {};
+ r.daylight = prop(st, `<g filter="url(#paper)"><rect x="176" y="436" width="188" height="364" fill="#f6e7b8"/><rect x="176" y="690" width="188" height="110" fill="#8db35b"/></g>`);
+ r.atDoor = slot();
+ r.door = doorLeaf(st, 'M176,436 H364 V800 H176 Z', '#8a5a32', 176, '<path d="M220,436 V800 M270,436 V800 M320,436 V800" stroke="#6e4426" stroke-width="3"/><rect x="330" y="600" width="22" height="8" fill="#3b2a1e"/>');
+ r.inWardrobe = slot();
+ r.wardrobe = doorLeaf(st, 'M1790,410 H1932 V790 H1790 Z', '#8a5a32', 1790, '<circle cx="1918" cy="600" r="6" fill="#caa24c"/><path d="M1810,430 h102 v160 h-102 Z" fill="none" stroke="#6e4426" stroke-width="4"/>');
+ r.inBed = slot();
+ r.quilt = prop(st, quiltSVG);
+ r.front = slot();
+ return r;
+}
+
+/* ---------- scene 2: the woods ---------- */
+const PRE2 = .9;
+function scene2(p, D) {
+ const EYES = PRE2 + TIMINGS.scene2.marks['s02.eyes'], BX = 1180, BY = 742;
+ const cam = paperCam(p, 'forest', { x: 460, y: 470, z: 1 });
+ prop(cam.stage, bushBackSVG(BX, BY)); const eyes = bushEyes(cam.stage, BX, BY - 50); prop(cam.stage, bushFrontSVG(BX, BY));
+ const red = redPuppet(cam.stage), wipe = trunkWipe(p, 0, .8, 'out');
+ const go = walker(300, .6, { period: .95, A: 24 });
+ // 2.1 follow her along the path; 2.2 at "But someone was watching" the camera stops and pushes in on the bush
+ // she has just passed; 2.3 the eyes, close, watching her go.
+ cam.to({ x: t => go(t).x + 160 }, 0, .01).to({ x: BX, y: 650, z: 2.3 }, EYES, 1.3).cut({ x: BX, y: BY - 50, z: 5.5 }, EYES + 2.1);
+ stopClock(D, (q, f) => {
+ cam.apply(q, f); wipe(q);
+ const w = go(q), s = .6;
+ red.pose({ x: w.x, y: hipOn(WOODS, s) + w.drop * s, s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar,
+ cape: 3 + 3 * Math.sin(2 * w.ph + .6), ua: -8 + 6 * Math.sin(w.ph), fa: -78, swing: 9 * Math.sin(w.ph - 1), headR: 2 * Math.sin(2 * w.ph), shut: blinking(q, [2.6]) }, f);
+ const o = q < EYES + .8 ? 0 : q < EYES + .9 ? .3 : between(q, EYES + 3.4, EYES + 3.57) ? .1 : 1;
+ eyes(o, q < EYES + 2.3 ? .4 : Math.min(1, .4 + (q - EYES - 2.3) * .5));
+ });
+}
+
+/* ---------- scene 3: the wolf ---------- */
+const PRE3 = 2.2;
+function scene3(p, D) {
+ const C = (c, t) => clipAt('scene3', PRE3, c, t), TX = 2250, POP = 1.5, STOP = 1.425;
+ const cam = paperCam(p, 'forest', { x: 2060, y: 560, z: 1.45 });
+ const wolf = wolfPuppet(cam.stage), red = redPuppet(cam.stage);
+ prop(cam.stage, `<g filter="url(#paper)"><path d="M${TX - 64},800 C${TX - 50},500 ${TX - 56},200 ${TX - 40},-200 L${TX + 44},-200 C${TX + 56},200 ${TX + 50},500 ${TX + 66},800 Z" fill="#6e4a30"/>
+ <path d="M${TX - 20},700 C${TX - 10},500 ${TX - 24},300 ${TX - 12},0 M${TX + 22},760 C${TX + 30},520 ${TX + 18},300 ${TX + 26},40" stroke="#5a3b24" stroke-width="6" fill="none"/></g>`);
+ // 3.2 the wolf's view of her: the woods behind her, his ear and shoulder dark and close at the edge
+ const rev = paperCam(p, 'forestRev').soft(0, 'all'), redRev = redPuppet(rev.stage);
+ prop(rev.root, `<g filter="url(#paper)"><path d="M1290,900 C1300,700 1380,560 1480,520 L1520,380 L1560,500 C1620,520 1660,560 1680,600 L1680,900 Z" fill="#3e3a36"/></g>`);
+ const go = walker(1640, .6, { period: .95, A: 24 }, 1, 3);
+ cam.cut({ x: 2120, y: 520, z: 2.6 }, C('s03c', -.05)).soft(C('s03c', -.05), true);
+ stopClock(D, (q, f) => {
+ const reverse = between(q, C('s03b', -.05), C('s03c', -.05));
+ vis(cam.root, !reverse); vis(rev.root, reverse);
+ if (reverse) {
+ rev.apply(q, f);
+ redRev.pose({ x: 760, y: 430 + 194 * 2, s: 2, head: 'F', mouth: mouthAt('s03b', q - C('s03b')), shut: blinking(q, [C('s03b', 1.6)]),
+ rua: q > C('s03b', 2.2) ? -96 : 6, rfa: q > C('s03b', 2.2) ? -10 : -4 }, f);
+ return;
+ }
+ cam.apply(q, f);
+ const w = go(q), s = .6, startle = between(q, POP + .1, POP + .1 + 2 / FPS);
+ red.pose({ x: w.x - (q > POP + .1 ? 12 : 0), y: hipOn(WOODS, s) + w.drop * s - (startle ? 12 : 0), s,
+ near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, cape: 3, ua: -8, fa: -78,
+ headR: q > POP + .1 ? -4 : 0, shut: blinking(q, [6.2, 12.0]), mouth: 'X' }, f);
+ // the wolf hops out from behind the trunk, bows with his cap in his paw, then asks
+ const hop = Math.min(1, Math.max(0, (q - POP) / .4)), land = between(q, POP + .4, POP + .4 + 2 / FPS);
+ const bow = q < C('s03', 3) ? span(q, C('s03', .2), C('s03', .6)) : 1 - span(q, C('s03', 3), C('s03', 3.4));
+ const aside = q >= C('s03c', -.05);
+ wolf.pose({ x: TX + 10 - 150 * hop, y: hipOn(WOODS, s, 200) - 50 * Math.sin(Math.PI * hop) + (land ? 6 : 0), s, turn: -1,
+ lean: 26 * bow, cap: bow > .05 ? 'hand' : 'on', ua: bow > .05 ? -20 * bow : q > C('s03', 3.4) && q < C('s03b') ? -46 : 6, fa: bow > .05 ? -125 * bow : -20,
+ tail: 8 * Math.sin(q * 5), head: aside ? 'F' : 'P', mouth: lips(q, 'scene3', PRE3, 's03', 's03c'),
+ rua: 40, rfa: -104 + 8 * onTwos(q), lua: -40, lfa: 104 - 8 * onTwos(q),
+ brow: aside && q > C('s03c', 2.5) ? onTwos(q) : 0, look: aside && q < C('s03c', 2.3) ? -1 : 0, shut: blinking(q, [4.0, 14.8]) }, f);
+ });
+}
+
+/* ---------- scene 4: flowers ---------- */
+const PRE4 = .3;
+function scene4(p, D) {
+ const C = (c, t) => clipAt('scene4', PRE4, c, t), PICK = PRE4 + TIMINGS.scene4.marks['s04b.pick'], RUN = PRE4 + TIMINGS.scene4.marks['s04b.run'];
+ const cam = paperCam(p, 'forest', { x: 2000, y: 560, z: 1.5 });
+ const red = redPuppet(cam.stage), wolf = wolfPuppet(cam.stage);
+ // 4.1 he sweeps a paw at the meadow and the camera follows it; 4.2 she skips into the flowers and picks;
+ // 4.3 low, running with him along the path (she is a blur behind, still picking)
+ cam.to({ x: 3250, y: 500, z: 1.05 }, C('s04', 2.1), 2.6);
+ const RX = 2950, runner = walker(2600, .6, { L: 196, A: 26, period: .5, knee: 60 });
+ cam.cut({ x: 2700, y: 620, z: 1.7 }, RUN).to({ x: t => Math.min(3600, runner(t - RUN).x + 100) }, RUN, .01);
+ stopClock(D, (q, f) => {
+ cam.apply(q, f);
+ const s = .6, run = q >= RUN;
+ if (!run) {
+ const sweep = span(q, C('s04', 1.7), C('s04', 2.1));
+ wolf.pose({ x: 2120, y: hipOn(WOODS, s, 200), s, turn: q < C('s04', 1.6) ? -1 : q < C('s04', 1.9) ? .2 : 1,
+ lean: q < C('s04', 1.5) ? 8 * span(q, C('s04', 0), C('s04', .3)) : 0, ua: q < C('s04', 1.5) ? -50 : -60 - 50 * sweep, fa: -20,
+ mouth: lips(q, 'scene4', PRE4, 's04'), tail: 8 * Math.sin(q * 5), shut: blinking(q, [1.1]) }, f);
+ } else {
+ const w = runner(q - RUN);
+ wolf.pose({ x: w.x, y: hipOn(WOODS, s, 200) + w.drop * s - 6, s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar,
+ lean: 28, ua: -30 + 45 * Math.sin(w.ph), fa: -40, tail: -25 + 6 * Math.sin(2 * w.ph), mouth: 'D', jaw: .5 }, f);
+ }
+ // Red: before the pan she stands at the bend; off-screen she runs on; in the meadow she skips in and picks
+ if (q < PICK) {
+ red.pose({ x: 1883, y: hipOn(WOODS, s), s, ua: -8, fa: -78, headR: -3, shut: blinking(q, [2.4]) }, f);
+ } else {
+ const sm = .44, gy = 722, w = walk(Math.min(q - PICK, 1.9), { period: .7, A: 24 }), x = 2440 + w.d * sm; // out in the meadow, beyond the path
+ const picks = [7.3, 8.0, 8.7, 9.4, 10.6, 11.4, 12.2].map(t => t + PRE4), done = picks.filter(t => q >= t + .35).length;
+ const bend = picks.some(t => between(q, t, t + .35));
+ red.pose({ x: x + 40 * done, y: hipOn(gy, sm) + w.drop * sm - (q - PICK < 1.9 ? 8 * Math.abs(Math.sin(w.ph)) : 0) + (bend ? 10 : 0), s: sm,
+ near: w.near, far: w.far, kNear: bend ? 30 : w.kNear, kFar: bend ? 20 : w.kFar, ua: bend ? 40 : -8, fa: bend ? 30 : -78,
+ headR: bend ? 14 : -2, bouquet: done, shut: blinking(q, [9.0]) }, f);
+ }
+ });
+}
+
+/* ---------- scene 5: Grandma's door ---------- */
+const PRE5 = 4.0;
+[3.45, 3.62, 3.79].forEach(t => sfx('scene5', t, 'knock'));
+function scene5(p, D) {
+ const C = (c, t) => clipAt('scene5', PRE5, c, t);
+ const cam = paperCam(p, 'grandmaOut', { x: 900, y: 470, z: 1 }, { stages: ['inside'] });
+ const door = doorLeaf(cam.stage, 'M1010,800 L1010,560 Q1070,510 1130,560 L1130,800 Z', '#3f5f8a', 1010, '<path d="M1040,530 V800 M1070,520 V800 M1100,530 V800" stroke="#2f4a6e" stroke-width="3"/><circle cx="1116" cy="680" r="6" fill="#caa24c"/>');
+ const wolf = wolfPuppet(cam.stage);
+ // inside: 5.3 Grandma in bed answers; 5.4 from inside, the latch lifts and the door opens on the wolf
+ const inn = paperCam(p, 'room', { x: 1200, y: 560, z: 2.3 }), R = roomProps(inn, []), gran = grandmaPuppet(R.inBed), wolfIn = wolfPuppet(R.atDoor);
+ inn.cut({ x: 330, y: 600, z: 1.8 }, C('s05b', 3.75));
+ const RUN = 1.8, SKID = 2.1, TIP = 2.2, KNOCK = 3.45, INSIDE = C('s05b', -.05);
+ const runner = walker(-150, .6, { L: 196, A: 26, period: .5, knee: 60 }), tip = walker(650, .6, { period: 1.2, A: 28, knee: 50 });
+ cam.cut({ x: 1010, y: 610, z: 2.4 }, 3.3);
+ stopClock(D, (q, f) => {
+ const inside = q >= INSIDE;
+ vis(cam.root, !inside); vis(inn.root, inside);
+ const s = .6;
+ if (inside) {
+ inn.apply(q, f); R.door(opening(q, C('s05b', 4.3)));
+ gran.pose({ x: 1250, y: 630, s: .55, turn: -1, mouth: lips(q, 'scene5', PRE5, 's05b'), nod: between(q, C('s05b', .05), C('s05b', .05) + 2 / FPS) ? 4 : 0, shut: blinking(q, [C('s05b', 2.2)]) }, f);
+ vis(wolfIn.g, q >= C('s05b', 4.3));
+ wolfIn.pose({ x: 262, y: hipOn(800, s, 200), s, lean: 6, ua: -20, fa: -30, brow: 1 }, f);
+ return;
+ }
+ cam.apply(q, f); door(1);
+ let o;
+ if (q < SKID) { const w = runner(Math.min(q, RUN)); o = { x: Math.min(w.x, 600) + (q > RUN ? 50 * span(q, RUN, SKID) : 0), y: hipOn(800, s, 200) + w.drop * s, near: q > RUN ? 28 : w.near, far: q > RUN ? -20 : w.far, kNear: q > RUN ? 0 : w.kNear, kFar: q > RUN ? 0 : w.kFar, lean: q > RUN ? -14 : 28, ua: -30 + 40 * Math.sin(w.ph), fa: -40, tail: -20 }; }
+ else { const w = tip(Math.min(q - TIP, 2.4)), x = Math.min(935, w.x); o = { x, y: hipOn(800, s, 200) + w.drop * s - 10, near: x < 935 ? w.near : 0, far: x < 935 ? w.far : 0, kNear: x < 935 ? w.kNear : 0, kFar: x < 935 ? w.kFar : 0, lean: 10, ua: -100, fa: -60, tail: 10 }; }
+ if (q >= 3.3) { // 5.2 at the door: three knocks, then a paw at his throat for the high voice
+ const knock = [KNOCK, KNOCK + .17, KNOCK + .34].some(t => between(q, t, t + 1 / FPS));
+ o = { ...o, x: 935, near: 0, far: 0, kNear: 0, kFar: 0, lean: 6, ua: q < C('s05', 1.5) ? -75 : -10, fa: q < C('s05', 1.5) ? -35 + (knock ? 25 : 0) : -155,
+ brow: q > C('s05', 1.5) ? 1 : 0, shut: q > C('s05', 2) && q < C('s05', 2.6) && onTwos(q) > 0, mouth: lips(q, 'scene5', PRE5, 's05') };
+ }
+ wolf.pose({ s, ...o }, f);
+ });
+}
+
+/* ---------- scene 6: the wardrobe ---------- */
+const PRE6 = .6;
+sfx('scene6', PRE6 + TIMINGS.scene6.marks['s06.hide'] + .8, 'bang', .8); // the wardrobe slammed shut
+function scene6(p, D) {
+ const HIDE = PRE6 + TIMINGS.scene6.marks['s06.hide'], CAP = PRE6 + TIMINGS.scene6.marks['s06.cap'], W = t => PRE6 + t;
+ const cam = paperCam(p, 'room', { x: 1120, y: 480, z: .9 }), R = roomProps(cam, []);
+ const granIn = grandmaPuppet(R.inWardrobe), gran = grandmaPuppet(R.inBed), wolfBed = wolfPuppet(R.inBed), wolf = wolfPuppet(R.front);
+ const things = prop(R.front, `<g filter="url(#paper)"><path d="M-40,8 C-40,-30 46,-34 54,6 Q8,-10 -40,8 Z" fill="#f6efe0"/></g>`), specs = mk('g', {}, R.front);
+ specs.innerHTML = '<circle cx="-12" r="10" fill="none" stroke="#7a5a2a" stroke-width="2.6"/><circle cx="12" r="10" fill="none" stroke="#7a5a2a" stroke-width="2.6"/>';
+ const wipe = trunkWipe(p, D - .7, .65);
+ // 6.1 the wolf leans in; her eyes go wide; 6.2 she hops into the wardrobe and slams it; 6.3 close on the bed:
+ // nightcap, glasses, into bed; then wide again — a crack in the wardrobe door, one eye.
+ cam.shake(HIDE + .8, 2 / FPS, 8).cut({ x: 1120, y: 620, z: 1.9 }, CAP).to({ z: 2.15 }, CAP + .1, 4).cut({ x: 1120, y: 480, z: .9 }, W(11));
+ const sneak = walker(262, .6, { period: 1.1, A: 26, knee: 50 }, 1, 8);
+ stopClock(D, (q, f) => {
+ cam.apply(q, f); wipe(q); R.door(-.35);
+ const hop = Math.min(1, Math.max(0, (q - HIDE) / .7)), inWard = q >= HIDE + .8;
+ R.wardrobe(q < HIDE + .45 ? 1 : q < HIDE + .8 ? -.3 : q < W(11.2) ? 1 + (q < HIDE + 1.2 ? .03 * onTwos(q) : 0) : .82);
+ vis(gran.g, !inWard);
+ const sg = .55, startled = q >= W(1.0);
+ gran.pose({ x: 1250 + 605 * ease(hop), y: 630 + (692 - 630) * hop - 130 * Math.sin(Math.PI * hop), s: sg, turn: hop > 0 ? 1 : -1,
+ head: startled && hop === 0 ? 'F' : 'P', brow: startled ? 1 : 0, hop: between(q, W(1.0), W(1.0) + 2 / FPS) ? -8 : 0,
+ ua: between(q, W(.4), W(1.0)) ? -150 : 6, fa: between(q, W(.4), W(1.0)) ? -30 : -6, rua: -30, rfa: -10, lua: 30, lfa: 10,
+ cap: q < HIDE + .1, glasses: q < HIDE + .1 }, f);
+ vis(granIn.g, q >= W(11.2));
+ granIn.pose({ x: 1830, y: 692, s: sg, head: 'F', cap: false, glasses: false, shut: blinking(q, [W(11.9)]) }, f);
+ // her nightcap and glasses fly onto the bed, and wait there for the wolf
+ const fly = Math.min(1, Math.max(0, (q - HIDE - .1) / .4)), worn = q >= W(7.4), specsOn = q >= W(8.2);
+ vis(things, q >= HIDE + .1 && !worn); tf(things, `translate(${1300 - 120 * fly},${560 + 80 * fly - 90 * Math.sin(Math.PI * fly)}) scale(.55)`);
+ vis(specs, q >= HIDE + .1 && !specsOn); tf(specs, `translate(${1280 - 70 * fly},${560 + 84 * fly - 60 * Math.sin(Math.PI * fly)}) scale(.55)`);
+ const s = .6, w = sneak(Math.max(0, q - HIDE - 1.2)), bed = Math.min(1, Math.max(0, (q - W(9.0)) / .4));
+ const x = q < W(9.0) ? Math.min(1000, w.x) : 1000 + 250 * ease(bed);
+ // over the quilt while he climbs, under it once he is in: two of him, one on each side of the quilt
+ const tucked = bed >= 1; vis(wolf.g, !tucked); vis(wolfBed.g, tucked);
+ (tucked ? wolfBed : wolf).pose({ x, y: q < W(9.0) ? hipOn(800, s, 200) + w.drop * s : hipOn(800, s, 200) + (630 - hipOn(800, s, 200)) * bed - 80 * Math.sin(Math.PI * bed), s,
+ turn: q < W(9.0) ? 1 : bed < .5 ? 1 - 2 * bed * 2 : -1, near: q < W(9.0) && x < 1000 ? w.near : 0, far: q < W(9.0) && x < 1000 ? w.far : 0,
+ kNear: x < 1000 ? w.kNear : 0, kFar: x < 1000 ? w.kFar : 0, lean: q < W(1.2) ? 22 * span(q, W(.1), W(.5)) : q < HIDE + 1.2 ? 22 : 8,
+ ua: between(q, W(7.0), W(7.4)) ? -60 : between(q, W(7.4), W(8.6)) ? -150 : 6, fa: between(q, W(7.0), W(7.4)) ? -30 : between(q, W(7.4), W(8.6)) ? -30 : -6,
+ cap: worn ? 'off' : 'on', night: worn, glasses: specsOn, head: q >= W(10.2) ? 'F' : 'P', brow: q >= W(10.2) ? onTwos(q) * .6 : 0,
+ tail: 6 * Math.sin(q * 4), shut: blinking(q, [W(2.6), W(9.4)]) }, f);
+ });
+}
+
+/* ---------- scene 7: Red at the door ---------- */
+const PRE7 = 1.6;
+const C7 = (c, t) => clipAt('scene7', PRE7, c, t);
+// The woodcutter chops by the oak while nobody talks to him: a swing every CHOP s, the blade landing at .85 of it.
+const CHOP = .9, CHOPPING = [[0, C7('s07w', .1)], [C7('s07', .9), 99]];
+const chopAt = q => { for (const [a, b] of CHOPPING) if (q >= a && q < b) return ((q - a) / CHOP) % 1; return -1; };
+for (const [a, b] of CHOPPING) for (let t = a + .85 * CHOP; t < Math.min(b, PRE7 + TIMINGS.scene7.dur); t += CHOP) sfx('scene7', t, 'chop', a ? .45 : .8);
+function scene7(p, D) {
+ const C = C7;
+ const cam = paperCam(p, 'grandmaOut', { x: 820, y: 470, z: 1 }, { stages: ['inside'] });
+ const door = doorLeaf(cam.stage, 'M1010,800 L1010,560 Q1070,510 1130,560 L1130,800 Z', '#3f5f8a', 1010, '<path d="M1040,530 V800 M1070,520 V800 M1100,530 V800" stroke="#2f4a6e" stroke-width="3"/><circle cx="1116" cy="680" r="6" fill="#caa24c"/>');
+ // the woodcutter by the oak, a chopping block in front of him and a few split logs
+ const WX = 400, WY = 772;
+ const wood = woodcutterPuppet(cam.stage);
+ prop(cam.stage, `<g filter="url(#paper)"><path d="M${WX + 56},${WY} L${WX + 60},${WY - 78} L${WX + 116},${WY - 78} L${WX + 120},${WY} Z" fill="#7a5034"/><ellipse cx="${WX + 88}" cy="${WY - 78}" rx="28" ry="7" fill="#c9a074"/>
+ <rect x="${WX + 74}" y="${WY - 118}" width="28" height="40" fill="#a37a52"/><ellipse cx="${WX + 88}" cy="${WY - 118}" rx="14" ry="4.5" fill="#d8b88a"/>
+ <path d="M${WX - 120},${WY} l60,0 l-6,-22 l-56,4 Z M${WX - 110},${WY - 20} l56,-4 l-4,-20 l-54,6 Z" fill="#a37a52"/></g>`);
+ const red = redPuppet(cam.stage), wipe = trunkWipe(p, 0, .8, 'out');
+ const inn = paperCam(p, 'room', { x: 330, y: 600, z: 1.8 }), R = roomProps(inn, []), redIn = redPuppet(R.atDoor);
+ // 7.1 she comes along the path, stops to greet him, then on to the open door
+ const opts = { period: .95, A: 24 }, go1 = walker(-60, .6, opts, 1, 3), STOP = go1(99).x, go2 = walker(STOP, .6, opts, 1, 6), ON = C('s07', .2);
+ cam.cut({ x: WX - 20, y: 600, z: 2.1 }, C('s07w', -.05)).cut({ x: 820, y: 470, z: 1 }, ON); // the greeting, close
+ stopClock(D, (q, f) => {
+ const inside = q >= C('s07b', -.05);
+ vis(cam.root, !inside); vis(inn.root, inside);
+ const s = .6;
+ if (inside) {
+ inn.apply(q, f); R.door(-.35);
+ const w = walk(Math.max(0, Math.min(q - C('s07b', 1.1), .95)), { period: .95, A: 24 });
+ redIn.pose({ x: 270 + w.d * s, y: hipOn(800, s) + w.drop * s, s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, bouquet: 7,
+ mouth: lips(q, 'scene7', PRE7, 's07b'), headR: 3 }, f);
+ return;
+ }
+ cam.apply(q, f); wipe(q); door(.45 + .06 * Math.sin(q * 2.2));
+ // the axe: raised over his head, a pause, down onto the log
+ const u = chopAt(q), ua = u < 0 ? 6 : u < .6 ? -42 - 133 * ease(u / .6) : u < .75 ? -175 : u < .85 ? -175 + 133 * (u - .75) / .1 : -42;
+ const talk = between(q, C('s07w', .1), ON + .3), turnBack = span(q, C('s07w', .1), C('s07w', .4)) - span(q, ON, ON + .3);
+ wood.pose({ x: WX, y: WY - 200 * .62, s: .62, turn: 1 - 2 * turnBack, ua, fa: u < 0 ? -6 : 0, hop: u >= .85 && u < .9 ? 2 : 0,
+ mouth: lips(q, 'scene7', PRE7, 's07x'), brow: talk ? .6 : 0, shut: blinking(q, [C('s07x', 1.6), C('s07', 3.0)]) }, f);
+ const w = q < ON ? go1(q) : go2(q - ON);
+ red.pose({ x: w.x, y: hipOn(800, s) + w.drop * s, s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, cape: 3 + 3 * Math.sin(2 * w.ph + .6),
+ ua: -8 + 4 * Math.sin(w.ph), fa: -78, swing: 6 * Math.sin(w.ph - 1), bouquet: 7, mouth: lips(q, 'scene7', PRE7, 's07w'),
+ headR: q > C('s07', 3.2) ? -6 : 0, shut: blinking(q, [C('s07w', 2.2), C('s07', 2.4)]) }, f);
+ });
+}
+
+/* ---------- scene 8: what big ears ---------- */
+const PRE8 = .4;
+function scene8(p, D) {
+ const C = (c, t) => clipAt('scene8', PRE8, c, t), mid = c => C(c, -.05);
+ const cam = paperCam(p, 'room', { x: 1140, y: 560, z: 1.9 }), R = roomProps(cam, []);
+ const wolf = wolfPuppet(R.inBed), red = redPuppet(R.front);
+ // Grandma inside the wardrobe, seen only through the crack of its door (open to .6: 1875–1932)
+ mk('rect', { x: 1875, y: 424, width: 57, height: 366 }, mk('clipPath', { id: 'crack8' }, R.inWardrobe));
+ const crack = mk('g', { 'clip-path': 'url(#crack8)' }, R.inWardrobe);
+ mk('rect', { x: 1868, y: 410, width: 72, height: 390, fill: '#2a1a10' }, crack);
+ const granIn = grandmaPuppet(crack);
+ // the close-ups face each other across the bed: his, with the wall and window behind him (her view); hers, with
+ // the open door behind her (his view). Each line comes closer than the one before.
+ const A = paperCam(p, 'roomA').soft(0, 'all'), wolfA = wolfPuppet(A.stage);
+ const B = paperCam(p, 'roomB').soft(0, 'all'), redB = redPuppet(B.stage);
+ const shots = [['s08', 'two'], ['s08b', 'A', 1.9], ['s08c', 'B', 2], ['s08d', 'A', 2.7], ['s08e', 'B', 2.8], ['s08f', 'A', 3.4]];
+ const EAT = C('s08f', .88);
+ // while he says "see you with", a look at the wardrobe: through the crack, Grandma's eye narrows and the umbrella comes up
+ const WARD = [C('s08d', 1.0), mid('s08e')];
+ cam.cut({ x: 1870, y: 560, z: 2.6 }, WARD[0]);
+ stopClock(D, (q, f) => {
+ let k = 0; for (let i = 0; i < shots.length; i++) if (q >= mid(shots[i][0])) k = i;
+ const ward = between(q, ...WARD), [, which, big] = ward ? [, 'two'] : shots[k], s = .6;
+ vis(cam.root, which === 'two'); vis(A.root, which === 'A'); vis(B.root, which === 'B');
+ const wolfMouth = lips(q, 'scene8', PRE8, 's08b', 's08d', 's08f');
+ // s08e has half a second of silence after "And Grandma…": her mouth waits through it
+ const tE = q - C('s08e'), redMouth = lips(q, 'scene8', PRE8, 's08', 's08c') !== 'X' ? lips(q, 'scene8', PRE8, 's08', 's08c') : mouthAt('s08e', tE < 1 ? tE : tE < 1.5 ? -1 : tE - .5);
+ if (ward) {
+ cam.apply(q, f); R.wardrobe(.6);
+ const up = span(q, WARD[0] + .4, WARD[0] + 1.1);
+ granIn.pose({ x: 1906, y: 692, s: .55, head: 'F', cap: false, glasses: false, umbrella: true, brow: -1.8 * span(q, WARD[0] + .1, WARD[0] + .3), mouth: 'A',
+ rua: 30 - 150 * up, rfa: -10 - 70 * up, shut: blinking(q, [WARD[0] + .7]) }, f);
+ } else if (which === 'two') {
+ cam.apply(q, f); R.wardrobe(.6);
+ wolf.pose({ x: 1250, y: 630, s, turn: -1, cap: 'off', night: true, glasses: true, ear: between(q, C('s08', 1.3), C('s08', 2.6)) ? onTwos(q) : 0 }, f);
+ red.pose({ x: 1030, y: hipOn(800, s), s, bouquet: 7, mouth: redMouth, ua: -8, fa: -78, shut: blinking(q, [C('s08', 2.8)]) }, f);
+ } else if (which === 'A') {
+ A.apply(q, f);
+ const eat = q >= EAT, lunge = span(q, EAT + .6, D);
+ if (k === 5) A.shake(EAT, .3, 12);
+ wolfA.pose({ x: 800, y: 430 + 212 * big * (1 + .3 * lunge) - 300 * lunge, s: big * (1 + .3 * lunge), head: 'F', cap: 'off', night: true, glasses: !eat,
+ mouth: wolfMouth, jaw: eat && q < EAT + .9 ? 1 : null, brow: eat ? -1 : .6, rua: 30, rfa: -60, lua: -30, lfa: 60, shut: blinking(q, [C('s08b', 1.3), C('s08d', 1.5)]) }, f);
+ } else {
+ B.apply(q, f);
+ redB.pose({ x: 800, y: 430 + 194 * big, s: big, head: 'F', mouth: redMouth, headR: k === 2 ? -6 : 0, bouquet: 0, basket: false,
+ nod: k === 4 && between(tE, 1.0, 1.5) ? 3 : 0, shut: blinking(q, [C('s08c', 2.6), C('s08e', 1.1)]) }, f);
+ }
+ });
+}
+
+/* ---------- scene 9: out! ---------- */
+const PRE9 = 1.0;
+const C9 = (c, t) => clipAt('scene9', PRE9, c, t), M9 = k => PRE9 + TIMINGS.scene9.marks['s09c.' + k];
+// BANG: the wardrobe bursts open; WHACK: the umbrella comes down on his head; RUN: he bolts for the front door;
+// LEAP: the only way left, over everyone; CRASH: through the window.
+const LAND9 = 1.2, BANG = C9('s09', 0), WHACK = C9('s09', 2.04), RUN = C9('s09b', -.85), LEAP = C9('s09c', 5.3), CRASH = LEAP + .9;
+sfx('scene9', LAND9, 'thud'); sfx('scene9', BANG, 'bang'); sfx('scene9', WHACK + .12, 'bonk'); sfx('scene9', CRASH, 'crash');
+// The bedroom window (in the room set, 1420–1660 × 300–530): glass until `at`; then broken — the woods redrawn over
+// the set's cross bars, jagged glass left in the frame — and shards that burst out and fall to the floor.
+function brokenWindow(back, front, at) {
+ const glass = prop(back, `<g><rect x="1420" y="300" width="240" height="230" fill="#e8f4f6" opacity=".25"/>
+ <path d="M1440,340 l40,-26 M1450,362 l64,-42 M1562,340 l40,-26 M1572,470 l52,-34" stroke="#ffffff" stroke-width="6" stroke-linecap="round" opacity=".6"/></g>`);
+ const broken = prop(back, `<g filter="url(#paper)"><rect x="1418" y="298" width="244" height="234" fill="#cfe0d0"/><path d="M1418,430 C1480,400 1560,420 1662,396 L1662,532 L1418,532 Z" fill="#7fa54f"/>
+ <path d="M1440,430 l20,-60 l20,60 Z M1500,420 l24,-80 l24,80 Z M1590,410 l20,-64 l20,64 Z" fill="#4d7d55"/></g>
+ <path d="M1418,298 L1478,298 L1436,346 L1418,330 Z M1662,298 L1600,298 L1640,320 L1662,372 Z M1418,532 L1418,468 L1440,500 L1466,532 Z M1662,532 L1612,532 L1636,506 L1662,476 Z"
+ fill="#e8f4f6" stroke="#ffffff" stroke-width="2" opacity=".85"/>
+ <g filter="url(#paper)" fill="#7a5034"><path d="M1535,298 h10 v30 l-6,9 l-4,-7 Z M1535,532 h10 v-34 l-5,-9 l-5,11 Z M1418,410 v10 h28 l8,-4 l-10,-6 Z M1662,410 v10 h-24 l-6,-6 l8,-4 Z"/></g>`);
+ const G = 1800, shards = [...Array(18)].map((_, i) => {
+ const a = i * 2.4, r = .6 + (i % 5) * .25, y0 = 320 + (i * 53) % 190, vy = -150 - 140 * Math.abs(Math.sin(a)) * r;
+ return { el: mk('path', { d: `M0,${-7 - (i % 4) * 3} L${5 + (i % 3) * 3},6 L-6,4 Z`, fill: '#e8f4f6', stroke: '#ffffff', 'stroke-width': 1.5 }, front),
+ x0: 1440 + (i * 37) % 200, y0, vx: 240 * Math.cos(a) * r, vy, spin: (i % 2 ? 1 : -1) * (300 + i * 40), land: (-vy + Math.sqrt(vy * vy + 2 * G * (796 - y0))) / G };
+ });
+ return q => {
+ const t = q - at; vis(glass, t < 0); vis(broken, t >= 0);
+ for (const sh of shards) {
+ vis(sh.el, t >= 0); if (t < 0) continue;
+ const u = Math.min(t, sh.land);
+ tf(sh.el, `translate(${(sh.x0 + sh.vx * u).toFixed(1)},${(sh.y0 + sh.vy * u + G * u * u / 2).toFixed(1)}) rotate(${(sh.spin * u).toFixed(0)}) scale(1.6)`);
+ }
+ };
+}
+function scene9(p, D) {
+ const C = C9;
+ const cam = paperCam(p, 'room', { x: 1050, y: 500, z: 1.1 }), R = roomProps(cam, []);
+ const win = brokenWindow(R.atDoor, R.front, CRASH);
+ const wood = woodcutterPuppet(R.atDoor), gran = grandmaPuppet(R.front), red = redPuppet(R.front), wolf = wolfPuppet(R.front);
+ const spill = prop(R.front, `<g filter="url(#paper)">${[[-60, 4, '#d6493f'], [-30, -6, '#f6efe0'], [0, 6, '#efae48'], [30, -4, '#e88ab0'], [60, 6, '#d6493f'], [-90, 8, '#f6efe0']].map(([x, y, c]) =>
+ `<rect x="${x - 14}" y="${y - 2}" width="28" height="3" fill="#4f7a34"/><circle cx="${x + 14}" cy="${y}" r="9" fill="${c}"/>`).join('')}</g>`, { transform: 'translate(720,796) scale(.7)' });
+ // 9.1 he crouches on the bed and leaps; she ducks and cries for help; he sails over her, snaps the bouquet out of her
+ // hands and lands face first in it; 9.2 the wardrobe rattles and
+ // bursts open: Grandma and her umbrella; 9.3 wide: she runs at him and brings it down on his head; he bolts for the
+ // door — 9.4 where the woodcutter steps in; 9.5 wide: Grandma one side, the woodcutter the other, the window; the leap.
+ const DOOR = C('s09b', -.05), WIDE = C('s09c', -.05);
+ cam.cut({ x: 1800, y: 560, z: 1.8 }, C('s09', -.7)).cut({ x: 1150, y: 500, z: 1.1 }, C('s09', .9))
+ .cut({ x: 290, y: 560, z: 1.8 }, DOOR).cut({ x: 1000, y: 470, z: .95 }, WIDE).shake(CRASH, 3 / FPS, 10);
+ const runner = walker(780, .6, { L: 196, A: 26, period: .5, knee: 60 }, -1, 3);
+ stopClock(D, (q, f) => {
+ cam.apply(q, f); R.door(-.35); win(q);
+ R.wardrobe(q < C('s09', -.7) ? 1 : q < BANG ? 1 + .04 * onTwos(q) : opening(q, BANG, [1, .4, -.2, -.45, -.4]));
+ const s = .6, sw = q >= WIDE;
+ vis(spill, q >= LAND9);
+ // the wolf
+ let o;
+ const leap = Math.min(1, Math.max(0, (q - .3) / .9)), crouch = span(q, 0, .25) * (1 - leap), UP = C('s09', 1.2);
+ if (q < LAND9) o = { x: 1250 - 470 * ease(leap), y: 630 + 12 * crouch + 122 * leap - 80 * Math.sin(Math.PI * leap), turn: -1, lean: 20 * crouch + 40 * leap, ua: -120, fa: -30, near: -40 * Math.sin(Math.PI * leap), far: 40 * Math.sin(Math.PI * leap), tail: -30 * leap,
+ mouth: leap > .3 && leap < .7 ? 'D' : 'X', jaw: leap > .3 && leap < .55 ? 1 : null };
+ else if (q < UP) o = { x: 780, y: 752, turn: -1, lean: 78, shut: true, ua: -120, fa: -30 };
+ else if (q < RUN) {
+ const r = span(q, UP, UP + .5), hit = between(q, WHACK + .1, WHACK + .45);
+ o = { x: 780, y: 752 - 72 * r - (hit ? 40 * Math.sin(Math.PI * (q - WHACK - .1) / .35) : 0), turn: -1, lean: 78 * (1 - r),
+ ua: q > WHACK + .1 ? -160 : -20, fa: q > WHACK + .1 ? -30 : -10, brow: q > WHACK + .1 ? 1 : 0, ear: hit ? onTwos(q) : 0,
+ shut: between(q, WHACK + .1, WHACK + .9), mouth: hit ? 'D' : 'X' };
+ } else if (q < DOOR) { const w = runner(q - RUN); o = { x: w.x, y: 680 + w.drop * s, turn: -1, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, lean: 28, ua: -30 + 40 * Math.sin(w.ph), fa: -40, brow: 1, tail: -20 }; }
+ else if (q < WIDE) { // skids to a stop in front of the woodcutter
+ const k = span(q, DOOR, DOOR + .3);
+ o = { x: 470 - 40 * k + (q > DOOR + .5 ? 1.5 * onTwos(q) : 0), y: 680, turn: -1, lean: -14, near: 28 * (1 - k), far: -20 * (1 - k), ua: -100, fa: -60, brow: 1, tail: 10 };
+ } else if (q < LEAP) { // looks at Grandma, at the woodcutter, at the window; crouches
+ const look = q < M9('gran') ? -1 : q < M9('wood') ? 1 - 2 * span(q, M9('wood'), M9('wood') + .12) : -1 + 2 * span(q, M9('way'), M9('way') + .12);
+ const cr = span(q, LEAP - .35, LEAP - .05);
+ o = { x: 430, y: 680 + 14 * cr, turn: q < M9('wood') ? -1 + 2 * span(q, M9('gran'), M9('gran') + .12) : look, lean: 22 * cr, headR: q > M9('way') + .2 ? -12 * (1 - cr) : 0,
+ ua: -100 + 60 * cr, fa: -60, brow: 1, near: 20 * cr, far: 20 * cr, kNear: 40 * cr, kFar: 40 * cr, tail: 10 };
+ } else { const u = Math.min(1, (q - LEAP) / .9); o = { x: 430 + 1110 * u, y: 694 - 224 * u - 300 * Math.sin(Math.PI * u), s: s * (1 - .3 * u * u), turn: 1, lean: 30, near: -30, far: 30, ua: -150, fa: -20, tail: -30, brow: 1 }; }
+ vis(wolf.g, q < CRASH);
+ wolf.pose({ s, cap: 'off', night: true, glasses: false, ...o }, f);
+ // Red: ducks, then watches the wolf; at the crash, the window
+ const duck = between(q, .45, 1.9);
+ red.pose({ x: 1030, y: hipOn(800, s) + (duck ? 62 * s : 0), s, turn: q < 1.9 || q > CRASH - .3 ? 1 : -1, near: duck ? -62 : 0, far: duck ? -50 : 0, kNear: duck ? 104 : 0, kFar: duck ? 100 : 0, // a squat
+ ua: duck ? -150 : -8, fa: duck ? -40 : -78, headR: duck ? 10 : sw && q > LEAP ? -8 : 0, bouquet: q < .75 ? 7 : 0, shut: duck,
+ mouth: lips(q, 'scene9', PRE9, 's09a') }, f);
+ // Grandma: out of the wardrobe in a hop, across the room, the umbrella down on his head; then she shakes it at him
+ vis(gran.g, q >= BANG + 1 / FPS);
+ const hop = span(q, BANG, BANG + .5), run = span(q, C('s09', .9), C('s09', 1.9)), whack = span(q, WHACK, WHACK + .16);
+ gran.pose({ x: 1860 - 160 * hop - 810 * run, y: 692 - 110 * Math.sin(Math.PI * hop) - (run > 0 && run < 1 ? 8 * Math.abs(Math.sin(q * 14)) : 0), s: .55,
+ turn: q > CRASH - .4 ? 1 : -1, cap: false, glasses: false, umbrella: true, mouth: lips(q, 'scene9', PRE9, 's09'),
+ ua: q < WHACK ? -175 : -175 + 47 * whack + (between(q, WHACK + .5, RUN) || between(q, WIDE, LEAP) ? 30 * onTwos(q) : 0), fa: -10, brow: -1 }, f);
+ // the woodcutter steps into the doorway
+ vis(wood.g, q >= DOOR);
+ const stamp = between(q, C('s09b', 1.7), C('s09b', 1.7) + 2 / FPS);
+ wood.pose({ x: 200 + 68 * span(q, DOOR, DOOR + .35), y: hipOn(800, .62, 200), s: .62, ua: -20, fa: -150, lean: q > C('s09b', 1.6) ? 8 : 0, hop: stamp ? -10 : 0, brow: -1,
+ mouth: lips(q, 'scene9', PRE9, 's09b'), shut: blinking(q, [C('s09b', 2.4)]) }, f);
+ });
+}
+
+/* ---------- scene 10: away into the woods ---------- */
+const PRE10 = .3;
+function scene10(p, D) {
+ const C = (c, t) => clipAt('scene10', PRE10, c, t);
+ const cam = paperCam(p, 'grandmaOut', { x: 1750, y: 470, z: 1 }, { stages: ['inside'] });
+ // the window he went through: the room redrawn over the set's cross bars, the woodcutter seen only through the hole,
+ // jagged glass left in the frame and a few shards on the grass below
+ mk('rect', { x: 1300, y: 520, width: 160, height: 120 }, mk('clipPath', { id: 'pane10' }, cam.stage));
+ const pane = mk('g', { 'clip-path': 'url(#pane10)' }, cam.stage);
+ prop(pane, '<g filter="url(#paper)"><rect x="1296" y="516" width="168" height="44" fill="#6e4a30"/><rect x="1296" y="560" width="168" height="84" fill="#5a3a24"/></g>');
+ const wood = woodcutterPuppet(pane);
+ prop(cam.stage, `<path d="M1300,520 L1346,520 L1312,556 L1300,546 Z M1460,520 L1412,520 L1442,538 L1460,572 Z M1300,640 L1300,598 L1318,620 L1338,640 Z M1460,640 L1420,640 L1440,620 L1460,600 Z"
+ fill="#e8f4f6" stroke="#ffffff" stroke-width="2" opacity=".85"/>
+ <g filter="url(#paper)" fill="#6e4a30"><path d="M1376,520 h8 v22 l-5,7 l-3,-6 Z M1376,640 h8 v-24 l-4,-7 l-4,9 Z M1300,577 v7 h20 l6,-3 l-8,-4 Z M1460,577 v7 h-18 l-5,-4 l6,-3 Z"/></g>
+ ${[[1312, 812, 30], [1340, 820, -20], [1371, 808, 60], [1398, 818, 10], [1430, 811, -45], [1452, 822, 80]].map(([x, y, r]) =>
+ `<path d="M0,-8 L6,6 L-6,4 Z" fill="#e8f4f6" stroke="#ffffff" stroke-width="1.5" transform="translate(${x},${y}) rotate(${r}) scale(1.4)"/>`).join('')}`);
+ const wolf = wolfPuppet(cam.stage), wipe = trunkWipe(p, D - .7, .65); // time passes: to the table
+ cam.to({ x: 2560, y: 640, z: 2.4 }, C('s10b', 0), 3.4);
+ const backPath = x => 808 - (x - 1380) * 116 / 1620, far = x => .6 * (1 - .78 * Math.min(1, (x - 1380) / 1620));
+ stopClock(D, (q, f) => {
+ cam.apply(q, f); wipe(q);
+ const w = walk(Math.max(0, q - .25), { L: 196, A: 28, period: .48, knee: 60 }), xs = 1420 + w.d * .3, s = far(xs), x = 1420 + w.d * s;
+ wolf.pose({ x, y: backPath(x) - (200 - w.drop) * s - (q < .25 ? 20 * (1 - q / .25) : 0), s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar,
+ lean: 26, ua: -30 + 45 * Math.sin(w.ph), fa: -40, tail: -25 + 6 * Math.sin(2 * w.ph), cap: 'off', night: true, jaw: .4 }, f);
+ wood.pose({ x: 1372, y: 560 + 224 * .62, s: .62, axe: false, ua: -150, fa: -20 + 14 * onTwos(q), brow: -1, mouth: lips(q, 'scene10', PRE10, 's10'), shut: blinking(q, [C('s10b', .8)]) }, f);
+ });
+}
+
+/* ---------- scene 11: cake ---------- */
+const PRE11 = .8;
+function scene11(p, D) {
+ const C = (c, t) => clipAt('scene11', PRE11, c, t);
+ const cam = paperCam(p, 'room', { x: 2475, y: 590, z: 1.75 }), st = cam.stage;
+ const gran = grandmaPuppet(st), red = redPuppet(st), wood = woodcutterPuppet(st);
+ prop(st, `<g filter="url(#paper)"><path d="M2262,636 L2698,636 L2712,800 L2248,800 Z" fill="#f6efe0"/><path d="M2256,700 L2704,700" stroke="#c8322f" stroke-width="10" stroke-dasharray="14 10"/></g>
+ <g filter="url(#paper)"><ellipse cx="2405" cy="630" rx="42" ry="11" fill="#b5853c"/><rect x="2363" y="610" width="84" height="20" fill="#d9a85a"/><ellipse cx="2405" cy="610" rx="42" ry="11" fill="#f6efe0"/>
+ <path d="M2405,610 L2447,610 L2442,620 Z" fill="#c8322f"/></g>
+ <g filter="url(#paper)"><path d="M2556,632 L2560,580 Q2576,566 2592,580 L2596,632 Z" fill="#3f5f8a"/><path d="M2594,590 q16,4 6,24" stroke="#3f5f8a" stroke-width="6" fill="none"/></g>
+ <g filter="url(#paper)"><rect x="2348" y="616" width="18" height="20" fill="#f6e7b8"/><rect x="2606" y="616" width="18" height="20" fill="#f6e7b8"/><rect x="2516" y="616" width="16" height="20" fill="#f6e7b8"/></g>`);
+ const warm = mk('rect', { width: 1600, height: 900, fill: '#ffb050', opacity: .1 }, p), wipe = trunkWipe(p, 0, .8, 'out');
+ const shut = iris(p, C('s11c', 1.0), 1.2, 805, 445), card = endCard(p, C('s11c', 2.3));
+ // 11.1 the three at the table; 11.2 Red close, to us; 11.3 back out, and the iris closes on her
+ cam.cut({ x: 2480, y: 535, z: 3.4 }, C('s11b', -.05)).soft(C('s11b', -.05), true).cut({ x: 2475, y: 560, z: 1.5 }, C('s11c', -.05)).soft(C('s11c', -.05), false).to({ x: 2480, y: 520, z: 1.9 }, C('s11c', .1), 2.4);
+ stopClock(D, (q, f) => {
+ cam.apply(q, f); wipe(q); shut(q); card(q);
+ const eat = between(q, C('s11', .5), C('s11', 1.2)) || between(q, C('s11', 1.6), C('s11', 2.4));
+ gran.pose({ x: 2330, y: 655, s: .55, cap: true, glasses: true, ua: eat ? -60 : 6, fa: eat ? -110 : -6, blush: span(q, C('s11', 3), C('s11', 4.2)), shut: blinking(q, [C('s11', 1.0), C('s11b', 3)]) }, f);
+ red.pose({ x: 2482, y: 660, s: .6, head: 'F', basket: false, mouth: lips(q, 'scene11', PRE11, 's11b'), shut: blinking(q, [C('s11', 2.6), C('s11b', 5.6)]) || between(q, C('s11b', 5.0), C('s11b', 5.0) + 3 / FPS) }, f);
+ wood.pose({ x: 2640, y: 668, s: .62, turn: -1, axe: false, mouth: between(q, C('s11', 3.0), C('s11', 4.6)) ? (onTwos(q) > 0 ? 'D' : 'C') : 'X', shut: blinking(q, [C('s11', 1.8), C('s11b', 4)]) }, f);
+ });
+}
+
+/* ---------- beats: [id, title, run(m, D), extra] ---------- */
+const BEATS = [
+ ['scene1', 'Home', (m, D) => scene1(panel(0), D), { lead: false, pre: PRE1 }],
+ ['scene2', 'Into the woods', (m, D) => scene2(panel(0), D), { lead: false, pre: PRE2 }],
+ ['scene3', 'Good morning', (m, D) => scene3(panel(0), D), { lead: false, pre: PRE3 }],
+ ['scene4', 'Flowers', (m, D) => scene4(panel(0), D), { lead: false, pre: PRE4 }],
+ ['scene5', 'Knock, knock', (m, D) => scene5(panel(0), D), { lead: false, pre: PRE5 }],
+ ['scene6', 'The wardrobe', (m, D) => scene6(panel(0), D), { lead: false, pre: PRE6 }],
+ ['scene7', 'The open door', (m, D) => scene7(panel(0), D), { lead: false, pre: PRE7 }],
+ ['scene8', 'What big ears', (m, D) => scene8(panel(0), D), { lead: false, pre: PRE8 }],
+ ['scene9', 'Out!', (m, D) => scene9(panel(0), D), { lead: false, pre: PRE9 }],
+ ['scene10', 'Away', (m, D) => scene10(panel(0), D), { lead: false, pre: PRE10 }],
+ ['scene11', 'Cake', (m, D) => scene11(panel(0), D), { lead: false, pre: PRE11 }],
+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));
+// The music is the Three Little Pigs' score (Lyria), reused.
+/* ---------- background music ---------- */
+// One track per part of the story, following the picture: its position is the time since the part began, so
+// pausing, seeking and changing beats keep it in step. Tracks crossfade at part changes; the music sits lower while
+// someone is speaking, and follows the player's volume.
+const BGM = [['m1-home', ['scene1', 'scene2']], ['m2-wolf', ['scene3', 'scene4', 'scene5']], ['m3-chimney', ['scene6', 'scene7', 'scene8', 'scene9']], ['m4-ending', ['scene10', 'scene11']]]
+ .map(([n, beats]) => ({ n, beats, a: Object.assign(new Audio(`audio/bgm/${n}.mp3`), { preload: 'auto', loop: true, volume: 0 }), v: 0 }));
+const beatLen = id => { const b = BEATS.find(x => x.id === id); return (b.pre || 0) + TIMINGS[id].dur + .6; };
+let lastTick = performance.now();
+function bgmTick(now) {
+ const dt = Math.min(.1, (now - lastTick) / 1000); lastTick = now;
+ const id = BEATS[P.i]?.id, on = P.started && P.playing && !P.waiting && !P.done;
+ const speaking = P.audio && !P.audio.paused && !P.audio.ended;
+ const master = +(document.getElementById('volume')?.value ?? 1) * (speaking ? .16 : .3);
+ for (const m of BGM) {
+ const k = m.beats.indexOf(id), current = on && k >= 0;
+ m.v = Math.max(0, Math.min(1, m.v + (current ? 1 : -1) * dt / .8)); // 0.8 s fades
+ m.a.volume = m.v * master;
+ if (current) {
+ const want = (m.beats.slice(0, k).reduce((s, b) => s + beatLen(b), 0) + P.t) % (m.a.duration || 1e9);
+ if (Math.abs(m.a.currentTime - want) > .5) m.a.currentTime = want;
+ if (m.a.paused) m.a.play().catch(() => {});
+ } else if (m.v === 0 && !m.a.paused) m.a.pause();
+ }
+ if (!on && !P.done) for (const m of BGM) m.a.pause(); // paused: silence at once (at the end it fades out)
+ requestAnimationFrame(bgmTick);
+}
+requestAnimationFrame(bgmTick);
+paperWarm(g => { redPuppet(g); motherPuppet(g); wolfPuppet(g); grandmaPuppet(g); woodcutterPuppet(g); door(g); smoke(g, 0, 0); });
+boot();
+</script>
+</body>
+</html>
diff --git a/site/little-red-riding-hood/img/puppets/00691678.webp b/site/little-red-riding-hood/img/puppets/00691678.webp
new file mode 100644
index 0000000..0d29705
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/00691678.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/00b9c591.webp b/site/little-red-riding-hood/img/puppets/00b9c591.webp
new file mode 100644
index 0000000..e95b1cb
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/00b9c591.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/00ed75c0.webp b/site/little-red-riding-hood/img/puppets/00ed75c0.webp
new file mode 100644
index 0000000..c17c939
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/00ed75c0.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/019a6eb5.webp b/site/little-red-riding-hood/img/puppets/019a6eb5.webp
new file mode 100644
index 0000000..7e4741a
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/019a6eb5.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/01ece229.webp b/site/little-red-riding-hood/img/puppets/01ece229.webp
new file mode 100644
index 0000000..1b45fc6
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/01ece229.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/02233c08.webp b/site/little-red-riding-hood/img/puppets/02233c08.webp
new file mode 100644
index 0000000..df85392
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/02233c08.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/04825ab7.webp b/site/little-red-riding-hood/img/puppets/04825ab7.webp
new file mode 100644
index 0000000..131c703
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/04825ab7.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/048622bd.webp b/site/little-red-riding-hood/img/puppets/048622bd.webp
new file mode 100644
index 0000000..2992e6e
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/048622bd.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/052d3885.webp b/site/little-red-riding-hood/img/puppets/052d3885.webp
new file mode 100644
index 0000000..8ae91d0
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/052d3885.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/07e43fe2.webp b/site/little-red-riding-hood/img/puppets/07e43fe2.webp
new file mode 100644
index 0000000..06b5741
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/07e43fe2.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/08d278c9.webp b/site/little-red-riding-hood/img/puppets/08d278c9.webp
new file mode 100644
index 0000000..c94af6a
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/08d278c9.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/08df1e8a.webp b/site/little-red-riding-hood/img/puppets/08df1e8a.webp
new file mode 100644
index 0000000..800d55b
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/08df1e8a.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/0995fa4a.webp b/site/little-red-riding-hood/img/puppets/0995fa4a.webp
new file mode 100644
index 0000000..6dddd97
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/0995fa4a.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/0ade0161.webp b/site/little-red-riding-hood/img/puppets/0ade0161.webp
new file mode 100644
index 0000000..a26b6d3
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/0ade0161.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/0b6d5850.webp b/site/little-red-riding-hood/img/puppets/0b6d5850.webp
new file mode 100644
index 0000000..368984f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/0b6d5850.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/0e0bbf87.webp b/site/little-red-riding-hood/img/puppets/0e0bbf87.webp
new file mode 100644
index 0000000..cf4d13b
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/0e0bbf87.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/15348a3e.webp b/site/little-red-riding-hood/img/puppets/15348a3e.webp
new file mode 100644
index 0000000..8f02ca7
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/15348a3e.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/17cb9a67.webp b/site/little-red-riding-hood/img/puppets/17cb9a67.webp
new file mode 100644
index 0000000..0dd8f04
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/17cb9a67.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/1818c0b0.webp b/site/little-red-riding-hood/img/puppets/1818c0b0.webp
new file mode 100644
index 0000000..af23aed
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/1818c0b0.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/1927ca5f.webp b/site/little-red-riding-hood/img/puppets/1927ca5f.webp
new file mode 100644
index 0000000..1bf3e18
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/1927ca5f.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/1df26c50.webp b/site/little-red-riding-hood/img/puppets/1df26c50.webp
new file mode 100644
index 0000000..3566cb5
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/1df26c50.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/1fb78fa0.webp b/site/little-red-riding-hood/img/puppets/1fb78fa0.webp
new file mode 100644
index 0000000..c102732
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/1fb78fa0.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/21871651.webp b/site/little-red-riding-hood/img/puppets/21871651.webp
new file mode 100644
index 0000000..f09f987
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/21871651.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/22b330d8.webp b/site/little-red-riding-hood/img/puppets/22b330d8.webp
new file mode 100644
index 0000000..752c39a
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/22b330d8.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/2386ed1e.webp b/site/little-red-riding-hood/img/puppets/2386ed1e.webp
new file mode 100644
index 0000000..e445c5d
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/2386ed1e.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/249d4211.webp b/site/little-red-riding-hood/img/puppets/249d4211.webp
new file mode 100644
index 0000000..26f5aa1
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/249d4211.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/268183d8.webp b/site/little-red-riding-hood/img/puppets/268183d8.webp
new file mode 100644
index 0000000..d2c0050
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/268183d8.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/26ce673f.webp b/site/little-red-riding-hood/img/puppets/26ce673f.webp
new file mode 100644
index 0000000..d0f3383
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/26ce673f.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/285d009c.webp b/site/little-red-riding-hood/img/puppets/285d009c.webp
new file mode 100644
index 0000000..3c82ca7
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/285d009c.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/2b4def45.webp b/site/little-red-riding-hood/img/puppets/2b4def45.webp
new file mode 100644
index 0000000..a746098
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/2b4def45.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/2f3361cb.webp b/site/little-red-riding-hood/img/puppets/2f3361cb.webp
new file mode 100644
index 0000000..7e5b167
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/2f3361cb.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/2fccaa46.webp b/site/little-red-riding-hood/img/puppets/2fccaa46.webp
new file mode 100644
index 0000000..f4a67c3
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/2fccaa46.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/317f0998.webp b/site/little-red-riding-hood/img/puppets/317f0998.webp
new file mode 100644
index 0000000..325c382
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/317f0998.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/325e0ec0.webp b/site/little-red-riding-hood/img/puppets/325e0ec0.webp
new file mode 100644
index 0000000..c27dc58
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/325e0ec0.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/38a61d82.webp b/site/little-red-riding-hood/img/puppets/38a61d82.webp
new file mode 100644
index 0000000..910d361
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/38a61d82.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/38efed4a.webp b/site/little-red-riding-hood/img/puppets/38efed4a.webp
new file mode 100644
index 0000000..f579b3f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/38efed4a.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/3d022f6e.webp b/site/little-red-riding-hood/img/puppets/3d022f6e.webp
new file mode 100644
index 0000000..de7cc7f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/3d022f6e.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/430e8217.webp b/site/little-red-riding-hood/img/puppets/430e8217.webp
new file mode 100644
index 0000000..ad055cc
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/430e8217.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/448070af.webp b/site/little-red-riding-hood/img/puppets/448070af.webp
new file mode 100644
index 0000000..cdc7292
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/448070af.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/45adb00b.webp b/site/little-red-riding-hood/img/puppets/45adb00b.webp
new file mode 100644
index 0000000..eaf03c1
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/45adb00b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/47303142.webp b/site/little-red-riding-hood/img/puppets/47303142.webp
new file mode 100644
index 0000000..86d9020
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/47303142.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/49216877.webp b/site/little-red-riding-hood/img/puppets/49216877.webp
new file mode 100644
index 0000000..32a5d8b
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/49216877.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/49d81387.webp b/site/little-red-riding-hood/img/puppets/49d81387.webp
new file mode 100644
index 0000000..797ff85
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/49d81387.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/4fe02087.webp b/site/little-red-riding-hood/img/puppets/4fe02087.webp
new file mode 100644
index 0000000..9f23c71
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/4fe02087.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/5002f3c2.webp b/site/little-red-riding-hood/img/puppets/5002f3c2.webp
new file mode 100644
index 0000000..52bbc7f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/5002f3c2.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/50555d75.webp b/site/little-red-riding-hood/img/puppets/50555d75.webp
new file mode 100644
index 0000000..05709bd
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/50555d75.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/54724fde.webp b/site/little-red-riding-hood/img/puppets/54724fde.webp
new file mode 100644
index 0000000..ad582eb
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/54724fde.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/5591793f.webp b/site/little-red-riding-hood/img/puppets/5591793f.webp
new file mode 100644
index 0000000..6a8637f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/5591793f.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/5ce62f06.webp b/site/little-red-riding-hood/img/puppets/5ce62f06.webp
new file mode 100644
index 0000000..1b1c17b
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/5ce62f06.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/5e199298.webp b/site/little-red-riding-hood/img/puppets/5e199298.webp
new file mode 100644
index 0000000..cf00f64
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/5e199298.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/61c35daa.webp b/site/little-red-riding-hood/img/puppets/61c35daa.webp
new file mode 100644
index 0000000..aa5be0d
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/61c35daa.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/61e4b434.webp b/site/little-red-riding-hood/img/puppets/61e4b434.webp
new file mode 100644
index 0000000..791b1b3
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/61e4b434.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/626efa6b.webp b/site/little-red-riding-hood/img/puppets/626efa6b.webp
new file mode 100644
index 0000000..a4f8a78
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/626efa6b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/637b3242.webp b/site/little-red-riding-hood/img/puppets/637b3242.webp
new file mode 100644
index 0000000..37e6e03
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/637b3242.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/63f9861f.webp b/site/little-red-riding-hood/img/puppets/63f9861f.webp
new file mode 100644
index 0000000..c6ddd98
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/63f9861f.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/6560b54b.webp b/site/little-red-riding-hood/img/puppets/6560b54b.webp
new file mode 100644
index 0000000..1024e88
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/6560b54b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/65b40bba.webp b/site/little-red-riding-hood/img/puppets/65b40bba.webp
new file mode 100644
index 0000000..e60dbd7
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/65b40bba.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/66522ec1.webp b/site/little-red-riding-hood/img/puppets/66522ec1.webp
new file mode 100644
index 0000000..1982e3a
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/66522ec1.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/6718ece9.webp b/site/little-red-riding-hood/img/puppets/6718ece9.webp
new file mode 100644
index 0000000..d0b9116
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/6718ece9.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/67b96c62.webp b/site/little-red-riding-hood/img/puppets/67b96c62.webp
new file mode 100644
index 0000000..abf0ccf
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/67b96c62.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/68aacc3b.webp b/site/little-red-riding-hood/img/puppets/68aacc3b.webp
new file mode 100644
index 0000000..3ebad16
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/68aacc3b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/6bb05552.webp b/site/little-red-riding-hood/img/puppets/6bb05552.webp
new file mode 100644
index 0000000..f6d5afe
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/6bb05552.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/6e064772.webp b/site/little-red-riding-hood/img/puppets/6e064772.webp
new file mode 100644
index 0000000..6e8fe57
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/6e064772.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/7053431d.webp b/site/little-red-riding-hood/img/puppets/7053431d.webp
new file mode 100644
index 0000000..effa3fa
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/7053431d.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/710d33cc.webp b/site/little-red-riding-hood/img/puppets/710d33cc.webp
new file mode 100644
index 0000000..d537e0a
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/710d33cc.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/737fcf0d.webp b/site/little-red-riding-hood/img/puppets/737fcf0d.webp
new file mode 100644
index 0000000..18cd352
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/737fcf0d.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/73eea61d.webp b/site/little-red-riding-hood/img/puppets/73eea61d.webp
new file mode 100644
index 0000000..e5c0d10
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/73eea61d.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/76af3a6a.webp b/site/little-red-riding-hood/img/puppets/76af3a6a.webp
new file mode 100644
index 0000000..a2404e8
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/76af3a6a.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/7db58c86.webp b/site/little-red-riding-hood/img/puppets/7db58c86.webp
new file mode 100644
index 0000000..c79ed4f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/7db58c86.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/7f6aeb8e.webp b/site/little-red-riding-hood/img/puppets/7f6aeb8e.webp
new file mode 100644
index 0000000..bc946ff
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/7f6aeb8e.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/7f72bf1e.webp b/site/little-red-riding-hood/img/puppets/7f72bf1e.webp
new file mode 100644
index 0000000..2b47159
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/7f72bf1e.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/8084dbe5.webp b/site/little-red-riding-hood/img/puppets/8084dbe5.webp
new file mode 100644
index 0000000..9ed6903
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/8084dbe5.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/84ee8e9d.webp b/site/little-red-riding-hood/img/puppets/84ee8e9d.webp
new file mode 100644
index 0000000..168b956
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/84ee8e9d.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/87b38e88.webp b/site/little-red-riding-hood/img/puppets/87b38e88.webp
new file mode 100644
index 0000000..e8e5168
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/87b38e88.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/890768cc.webp b/site/little-red-riding-hood/img/puppets/890768cc.webp
new file mode 100644
index 0000000..8912ab5
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/890768cc.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/893c17b4.webp b/site/little-red-riding-hood/img/puppets/893c17b4.webp
new file mode 100644
index 0000000..4c6bc31
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/893c17b4.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/89dd7be0.webp b/site/little-red-riding-hood/img/puppets/89dd7be0.webp
new file mode 100644
index 0000000..b08b4b6
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/89dd7be0.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/8b92daf9.webp b/site/little-red-riding-hood/img/puppets/8b92daf9.webp
new file mode 100644
index 0000000..66b260a
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/8b92daf9.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/8c773887.webp b/site/little-red-riding-hood/img/puppets/8c773887.webp
new file mode 100644
index 0000000..9b388c1
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/8c773887.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/8fa5a67a.webp b/site/little-red-riding-hood/img/puppets/8fa5a67a.webp
new file mode 100644
index 0000000..30fa14d
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/8fa5a67a.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/8fb85b5f.webp b/site/little-red-riding-hood/img/puppets/8fb85b5f.webp
new file mode 100644
index 0000000..e200cd5
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/8fb85b5f.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/90c16dfc.webp b/site/little-red-riding-hood/img/puppets/90c16dfc.webp
new file mode 100644
index 0000000..95d7f49
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/90c16dfc.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/91989f79.webp b/site/little-red-riding-hood/img/puppets/91989f79.webp
new file mode 100644
index 0000000..f346520
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/91989f79.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/96ed815a.webp b/site/little-red-riding-hood/img/puppets/96ed815a.webp
new file mode 100644
index 0000000..d2bddce
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/96ed815a.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/972a2990.webp b/site/little-red-riding-hood/img/puppets/972a2990.webp
new file mode 100644
index 0000000..f3ce3fc
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/972a2990.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/9867d25c.webp b/site/little-red-riding-hood/img/puppets/9867d25c.webp
new file mode 100644
index 0000000..10d6613
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/9867d25c.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/9a8e7995.webp b/site/little-red-riding-hood/img/puppets/9a8e7995.webp
new file mode 100644
index 0000000..0876fe3
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/9a8e7995.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/9a93ee7b.webp b/site/little-red-riding-hood/img/puppets/9a93ee7b.webp
new file mode 100644
index 0000000..913044e
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/9a93ee7b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/9bcf915c.webp b/site/little-red-riding-hood/img/puppets/9bcf915c.webp
new file mode 100644
index 0000000..1c75f6e
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/9bcf915c.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/9c2a38c7.webp b/site/little-red-riding-hood/img/puppets/9c2a38c7.webp
new file mode 100644
index 0000000..193342f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/9c2a38c7.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/9e03257b.webp b/site/little-red-riding-hood/img/puppets/9e03257b.webp
new file mode 100644
index 0000000..025e869
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/9e03257b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/9e818400.webp b/site/little-red-riding-hood/img/puppets/9e818400.webp
new file mode 100644
index 0000000..6df3881
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/9e818400.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/9f11fb36.webp b/site/little-red-riding-hood/img/puppets/9f11fb36.webp
new file mode 100644
index 0000000..144fb6c
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/9f11fb36.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/a1accb5b.webp b/site/little-red-riding-hood/img/puppets/a1accb5b.webp
new file mode 100644
index 0000000..ddbdda2
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/a1accb5b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/a1f9044e.webp b/site/little-red-riding-hood/img/puppets/a1f9044e.webp
new file mode 100644
index 0000000..ab359fc
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/a1f9044e.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/a49022ab.webp b/site/little-red-riding-hood/img/puppets/a49022ab.webp
new file mode 100644
index 0000000..8d89f7f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/a49022ab.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/a4c7fe84.webp b/site/little-red-riding-hood/img/puppets/a4c7fe84.webp
new file mode 100644
index 0000000..f252291
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/a4c7fe84.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/a55d2d0b.webp b/site/little-red-riding-hood/img/puppets/a55d2d0b.webp
new file mode 100644
index 0000000..b21f511
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/a55d2d0b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/a82cdd39.webp b/site/little-red-riding-hood/img/puppets/a82cdd39.webp
new file mode 100644
index 0000000..f7435a3
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/a82cdd39.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/aa69cfd0.webp b/site/little-red-riding-hood/img/puppets/aa69cfd0.webp
new file mode 100644
index 0000000..fdbb61e
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/aa69cfd0.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/aae7782d.webp b/site/little-red-riding-hood/img/puppets/aae7782d.webp
new file mode 100644
index 0000000..8cbc06f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/aae7782d.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/abc36243.webp b/site/little-red-riding-hood/img/puppets/abc36243.webp
new file mode 100644
index 0000000..f4ed00a
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/abc36243.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/ad50f310.webp b/site/little-red-riding-hood/img/puppets/ad50f310.webp
new file mode 100644
index 0000000..3d62ab2
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/ad50f310.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/ad77d9d1.webp b/site/little-red-riding-hood/img/puppets/ad77d9d1.webp
new file mode 100644
index 0000000..0ea7402
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/ad77d9d1.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/ae02425a.webp b/site/little-red-riding-hood/img/puppets/ae02425a.webp
new file mode 100644
index 0000000..b71668f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/ae02425a.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/afce0caf.webp b/site/little-red-riding-hood/img/puppets/afce0caf.webp
new file mode 100644
index 0000000..b18efab
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/afce0caf.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/b10b1ba3.webp b/site/little-red-riding-hood/img/puppets/b10b1ba3.webp
new file mode 100644
index 0000000..d652d69
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/b10b1ba3.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/b18f7823.webp b/site/little-red-riding-hood/img/puppets/b18f7823.webp
new file mode 100644
index 0000000..e249f30
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/b18f7823.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/b1b68679.webp b/site/little-red-riding-hood/img/puppets/b1b68679.webp
new file mode 100644
index 0000000..04e6566
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/b1b68679.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/b244328f.webp b/site/little-red-riding-hood/img/puppets/b244328f.webp
new file mode 100644
index 0000000..0636525
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/b244328f.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/b260c6d9.webp b/site/little-red-riding-hood/img/puppets/b260c6d9.webp
new file mode 100644
index 0000000..c035f48
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/b260c6d9.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/b31a1c3e.webp b/site/little-red-riding-hood/img/puppets/b31a1c3e.webp
new file mode 100644
index 0000000..0fe87d7
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/b31a1c3e.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/b47df80a.webp b/site/little-red-riding-hood/img/puppets/b47df80a.webp
new file mode 100644
index 0000000..1dabcc5
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/b47df80a.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/b4b2a03f.webp b/site/little-red-riding-hood/img/puppets/b4b2a03f.webp
new file mode 100644
index 0000000..cd62e44
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/b4b2a03f.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/b4cfc9e6.webp b/site/little-red-riding-hood/img/puppets/b4cfc9e6.webp
new file mode 100644
index 0000000..7dd1d62
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/b4cfc9e6.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/b60600e6.webp b/site/little-red-riding-hood/img/puppets/b60600e6.webp
new file mode 100644
index 0000000..bafd360
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/b60600e6.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/b624a6da.webp b/site/little-red-riding-hood/img/puppets/b624a6da.webp
new file mode 100644
index 0000000..9511bdf
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/b624a6da.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/baked.js b/site/little-red-riding-hood/img/puppets/baked.js
new file mode 100644
index 0000000..35b0ca2
--- /dev/null
+++ b/site/little-red-riding-hood/img/puppets/baked.js
@@ -0,0 +1 @@
+window.BAKED = {"a1f9044e": "a1f9044e.webp", "a82cdd39": "a82cdd39.webp", "1fb78fa0": "1fb78fa0.webp", "2fccaa46": "2fccaa46.webp", "2b4def45": "2b4def45.webp", "61e4b434": "61e4b434.webp", "2f3361cb": "2f3361cb.webp", "38a61d82": "38a61d82.webp", "0b6d5850": "0b6d5850.webp", "972a2990": "972a2990.webp", "8fb85b5f": "8fb85b5f.webp", "47303142": "47303142.webp", "e8abb9cc": "e8abb9cc.webp", "6560b54b": "6560b54b.webp", "dfd0994b": "dfd0994b.webp", "637b3242": "637b3242.webp", "9a8e7995": "9a8e7995.webp", "d558d360": "d558d360.webp", "b60600e6": "b60600e6.webp", "67b96c62": "67b96c62.webp", "e07c2616": "e07c2616.webp", "68aacc3b": "68aacc3b.webp", "26ce673f": "26ce673f.webp", "1927ca5f": "1927ca5f.webp", "00b9c591": "00b9c591.webp", "38efed4a": "38efed4a.webp", "4fe02087": "4fe02087.webp", "91989f79": "91989f79.webp", "50555d75": "50555d75.webp", "00691678": "00691678.webp", "7db58c86": "7db58c86.webp", "430e8217": "430e8217.webp", "325e0ec0": "325e0ec0.webp", "b18f7823": "b18f7823.webp", "dd67ea8f": "dd67ea8f.webp", "052d3885": "052d3885.webp", "b31a1c3e": "b31a1c3e.webp", "0e0bbf87": "0e0bbf87.webp", "aa69cfd0": "aa69cfd0.webp", "a55d2d0b": "a55d2d0b.webp", "b260c6d9": "b260c6d9.webp", "8fa5a67a": "8fa5a67a.webp", "df4c9f52": "df4c9f52.webp", "15348a3e": "15348a3e.webp", "66522ec1": "66522ec1.webp", "8c773887": "8c773887.webp", "01ece229": "01ece229.webp", "afce0caf": "afce0caf.webp", "249d4211": "249d4211.webp", "268183d8": "268183d8.webp", "89dd7be0": "89dd7be0.webp", "3d022f6e": "3d022f6e.webp", "ad77d9d1": "ad77d9d1.webp", "17cb9a67": "17cb9a67.webp", "f44de40f": "f44de40f.webp", "49d81387": "49d81387.webp", "7f6aeb8e": "7f6aeb8e.webp", "90c16dfc": "90c16dfc.webp", "c8022302": "c8022302.webp", "c3ae56b8": "c3ae56b8.webp", "0995fa4a": "0995fa4a.webp", "65b40bba": "65b40bba.webp", "890768cc": "890768cc.webp", "45adb00b": "45adb00b.webp", "bd410b97": "bd410b97.webp", "07e43fe2": "07e43fe2.webp", "893c17b4": "893c17b4.webp", "96ed815a": "96ed815a.webp", "d88870bd": "d88870bd.webp", "aae7782d": "aae7782d.webp", "9c2a38c7": "9c2a38c7.webp", "317f0998": "317f0998.webp", "e0aa53c1": "e0aa53c1.webp", "bd496b6b": "bd496b6b.webp", "b1b68679": "b1b68679.webp", "6bb05552": "6bb05552.webp", "a4c7fe84": "a4c7fe84.webp", "49216877": "49216877.webp", "87b38e88": "87b38e88.webp", "fb74c845": "fb74c845.webp", "21871651": "21871651.webp", "048622bd": "048622bd.webp", "b10b1ba3": "b10b1ba3.webp", "76af3a6a": "76af3a6a.webp", "5e199298": "5e199298.webp", "02233c08": "02233c08.webp", "bbcfa223": "bbcfa223.webp", "ae02425a": "ae02425a.webp", "22b330d8": "22b330d8.webp", "b244328f": "b244328f.webp", "448070af": "448070af.webp", "f00e0a82": "f00e0a82.webp", "5591793f": "5591793f.webp", "a49022ab": "a49022ab.webp", "abc36243": "abc36243.webp", "c549a7dc": "c549a7dc.webp", "c72a7a0e": "c72a7a0e.webp", "ee7be279": "ee7be279.webp", "9a93ee7b": "9a93ee7b.webp", "b4cfc9e6": "b4cfc9e6.webp", "8084dbe5": "8084dbe5.webp", "9e818400": "9e818400.webp", "b47df80a": "b47df80a.webp", "cda48047": "cda48047.webp", "c831602c": "c831602c.webp", "de04d2a6": "de04d2a6.webp", "b624a6da": "b624a6da.webp", "b4b2a03f": "b4b2a03f.webp", "f4f12b0b": "f4f12b0b.webp", "cb722cbc": "cb722cbc.webp", "019a6eb5": "019a6eb5.webp", "5ce62f06": "5ce62f06.webp", "cfeeae59": "cfeeae59.webp", "08d278c9": "08d278c9.webp", "cc5293e9": "cc5293e9.webp", "00ed75c0": "00ed75c0.webp", "737fcf0d": "737fcf0d.webp", "d1098e28": "d1098e28.webp", "fccaed6b": "fccaed6b.webp", "04825ab7": "04825ab7.webp", "9f11fb36": "9f11fb36.webp", "1818c0b0": "1818c0b0.webp", "fd80fc06": "fd80fc06.webp", "fe24cdc6": "fe24cdc6.webp", "5002f3c2": "5002f3c2.webp", "a1accb5b": "a1accb5b.webp", "d1475779": "d1475779.webp", "8b92daf9": "8b92daf9.webp", "9e03257b": "9e03257b.webp", "84ee8e9d": "84ee8e9d.webp", "73eea61d": "73eea61d.webp", "710d33cc": "710d33cc.webp", "2386ed1e": "2386ed1e.webp", "63f9861f": "63f9861f.webp", "ad50f310": "ad50f310.webp", "e499397a": "e499397a.webp", "61c35daa": "61c35daa.webp", "7f72bf1e": "7f72bf1e.webp", "6e064772": "6e064772.webp", "d80c5e29": "d80c5e29.webp", "6718ece9": "6718ece9.webp", "54724fde": "54724fde.webp", "d03b1c7d": "d03b1c7d.webp", "1df26c50": "1df26c50.webp", "9bcf915c": "9bcf915c.webp", "0ade0161": "0ade0161.webp", "c354be41": "c354be41.webp", "9867d25c": "9867d25c.webp", "626efa6b": "626efa6b.webp", "285d009c": "285d009c.webp", "7053431d": "7053431d.webp", "f3801f21": "f3801f21.webp", "de2885ae": "de2885ae.webp", "08df1e8a": "08df1e8a.webp"};
diff --git a/site/little-red-riding-hood/img/puppets/bbcfa223.webp b/site/little-red-riding-hood/img/puppets/bbcfa223.webp
new file mode 100644
index 0000000..0f2f567
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/bbcfa223.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/bd410b97.webp b/site/little-red-riding-hood/img/puppets/bd410b97.webp
new file mode 100644
index 0000000..4b8642b
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/bd410b97.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/bd496b6b.webp b/site/little-red-riding-hood/img/puppets/bd496b6b.webp
new file mode 100644
index 0000000..9569d56
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/bd496b6b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/c354be41.webp b/site/little-red-riding-hood/img/puppets/c354be41.webp
new file mode 100644
index 0000000..6c568ef
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/c354be41.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/c3ae56b8.webp b/site/little-red-riding-hood/img/puppets/c3ae56b8.webp
new file mode 100644
index 0000000..874645f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/c3ae56b8.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/c549a7dc.webp b/site/little-red-riding-hood/img/puppets/c549a7dc.webp
new file mode 100644
index 0000000..5554c25
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/c549a7dc.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/c72a7a0e.webp b/site/little-red-riding-hood/img/puppets/c72a7a0e.webp
new file mode 100644
index 0000000..2d665b1
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/c72a7a0e.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/c8022302.webp b/site/little-red-riding-hood/img/puppets/c8022302.webp
new file mode 100644
index 0000000..8c3e15f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/c8022302.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/c831602c.webp b/site/little-red-riding-hood/img/puppets/c831602c.webp
new file mode 100644
index 0000000..42d515f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/c831602c.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/cb722cbc.webp b/site/little-red-riding-hood/img/puppets/cb722cbc.webp
new file mode 100644
index 0000000..8ecdccf
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/cb722cbc.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/cc5293e9.webp b/site/little-red-riding-hood/img/puppets/cc5293e9.webp
new file mode 100644
index 0000000..22638c2
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/cc5293e9.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/cda48047.webp b/site/little-red-riding-hood/img/puppets/cda48047.webp
new file mode 100644
index 0000000..35044bf
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/cda48047.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/cfeeae59.webp b/site/little-red-riding-hood/img/puppets/cfeeae59.webp
new file mode 100644
index 0000000..60c01d5
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/cfeeae59.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/d03b1c7d.webp b/site/little-red-riding-hood/img/puppets/d03b1c7d.webp
new file mode 100644
index 0000000..f8004ea
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/d03b1c7d.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/d1098e28.webp b/site/little-red-riding-hood/img/puppets/d1098e28.webp
new file mode 100644
index 0000000..ef5c498
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/d1098e28.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/d1475779.webp b/site/little-red-riding-hood/img/puppets/d1475779.webp
new file mode 100644
index 0000000..b8f09d6
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/d1475779.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/d558d360.webp b/site/little-red-riding-hood/img/puppets/d558d360.webp
new file mode 100644
index 0000000..c63c2d7
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/d558d360.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/d80c5e29.webp b/site/little-red-riding-hood/img/puppets/d80c5e29.webp
new file mode 100644
index 0000000..cd586c3
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/d80c5e29.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/d88870bd.webp b/site/little-red-riding-hood/img/puppets/d88870bd.webp
new file mode 100644
index 0000000..c8b518a
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/d88870bd.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/dd67ea8f.webp b/site/little-red-riding-hood/img/puppets/dd67ea8f.webp
new file mode 100644
index 0000000..49d9201
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/dd67ea8f.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/de04d2a6.webp b/site/little-red-riding-hood/img/puppets/de04d2a6.webp
new file mode 100644
index 0000000..6956087
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/de04d2a6.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/de2885ae.webp b/site/little-red-riding-hood/img/puppets/de2885ae.webp
new file mode 100644
index 0000000..0cb8cc9
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/de2885ae.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/df4c9f52.webp b/site/little-red-riding-hood/img/puppets/df4c9f52.webp
new file mode 100644
index 0000000..a0fb6b2
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/df4c9f52.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/dfd0994b.webp b/site/little-red-riding-hood/img/puppets/dfd0994b.webp
new file mode 100644
index 0000000..da356ae
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/dfd0994b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/e07c2616.webp b/site/little-red-riding-hood/img/puppets/e07c2616.webp
new file mode 100644
index 0000000..8a1aa19
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/e07c2616.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/e0aa53c1.webp b/site/little-red-riding-hood/img/puppets/e0aa53c1.webp
new file mode 100644
index 0000000..3d589f4
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/e0aa53c1.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/e499397a.webp b/site/little-red-riding-hood/img/puppets/e499397a.webp
new file mode 100644
index 0000000..a143641
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/e499397a.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/e8abb9cc.webp b/site/little-red-riding-hood/img/puppets/e8abb9cc.webp
new file mode 100644
index 0000000..392d4e2
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/e8abb9cc.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/ee7be279.webp b/site/little-red-riding-hood/img/puppets/ee7be279.webp
new file mode 100644
index 0000000..e9d2f25
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/ee7be279.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/f00e0a82.webp b/site/little-red-riding-hood/img/puppets/f00e0a82.webp
new file mode 100644
index 0000000..eae87fb
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/f00e0a82.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/f3801f21.webp b/site/little-red-riding-hood/img/puppets/f3801f21.webp
new file mode 100644
index 0000000..c629a5f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/f3801f21.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/f44de40f.webp b/site/little-red-riding-hood/img/puppets/f44de40f.webp
new file mode 100644
index 0000000..4b4c01f
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/f44de40f.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/f4f12b0b.webp b/site/little-red-riding-hood/img/puppets/f4f12b0b.webp
new file mode 100644
index 0000000..5b66c98
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/f4f12b0b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/fb74c845.webp b/site/little-red-riding-hood/img/puppets/fb74c845.webp
new file mode 100644
index 0000000..14061f3
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/fb74c845.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/fccaed6b.webp b/site/little-red-riding-hood/img/puppets/fccaed6b.webp
new file mode 100644
index 0000000..4b438ca
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/fccaed6b.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/fd80fc06.webp b/site/little-red-riding-hood/img/puppets/fd80fc06.webp
new file mode 100644
index 0000000..09831e8
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/fd80fc06.webp differ
diff --git a/site/little-red-riding-hood/img/puppets/fe24cdc6.webp b/site/little-red-riding-hood/img/puppets/fe24cdc6.webp
new file mode 100644
index 0000000..e4f6c17
Binary files /dev/null and b/site/little-red-riding-hood/img/puppets/fe24cdc6.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forest/far-soft.webp b/site/little-red-riding-hood/img/sets/forest/far-soft.webp
new file mode 100644
index 0000000..f9effd1
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forest/far-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forest/far.webp b/site/little-red-riding-hood/img/sets/forest/far.webp
new file mode 100644
index 0000000..4e37f13
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forest/far.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forest/fore-soft.webp b/site/little-red-riding-hood/img/sets/forest/fore-soft.webp
new file mode 100644
index 0000000..7d7a1c5
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forest/fore-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forest/fore.webp b/site/little-red-riding-hood/img/sets/forest/fore.webp
new file mode 100644
index 0000000..0d6f7c2
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forest/fore.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forest/house-soft.webp b/site/little-red-riding-hood/img/sets/forest/house-soft.webp
new file mode 100644
index 0000000..7dd833f
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forest/house-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forest/house.webp b/site/little-red-riding-hood/img/sets/forest/house.webp
new file mode 100644
index 0000000..a27e014
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forest/house.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forest/mid-soft.webp b/site/little-red-riding-hood/img/sets/forest/mid-soft.webp
new file mode 100644
index 0000000..563a5c1
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forest/mid-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forest/mid.webp b/site/little-red-riding-hood/img/sets/forest/mid.webp
new file mode 100644
index 0000000..9cdc486
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forest/mid.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forest/sky-soft.webp b/site/little-red-riding-hood/img/sets/forest/sky-soft.webp
new file mode 100644
index 0000000..a83566d
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forest/sky-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forest/sky.webp b/site/little-red-riding-hood/img/sets/forest/sky.webp
new file mode 100644
index 0000000..c32cd35
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forest/sky.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forestRev/far-soft.webp b/site/little-red-riding-hood/img/sets/forestRev/far-soft.webp
new file mode 100644
index 0000000..41e810e
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forestRev/far-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forestRev/far.webp b/site/little-red-riding-hood/img/sets/forestRev/far.webp
new file mode 100644
index 0000000..cafe05f
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forestRev/far.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forestRev/house-soft.webp b/site/little-red-riding-hood/img/sets/forestRev/house-soft.webp
new file mode 100644
index 0000000..b83125d
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forestRev/house-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/forestRev/house.webp b/site/little-red-riding-hood/img/sets/forestRev/house.webp
new file mode 100644
index 0000000..7a8f291
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/forestRev/house.webp differ
diff --git a/site/little-red-riding-hood/img/sets/grandmaOut/far-soft.webp b/site/little-red-riding-hood/img/sets/grandmaOut/far-soft.webp
new file mode 100644
index 0000000..903f3a7
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/grandmaOut/far-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/grandmaOut/far.webp b/site/little-red-riding-hood/img/sets/grandmaOut/far.webp
new file mode 100644
index 0000000..4ef04de
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/grandmaOut/far.webp differ
diff --git a/site/little-red-riding-hood/img/sets/grandmaOut/fore-soft.webp b/site/little-red-riding-hood/img/sets/grandmaOut/fore-soft.webp
new file mode 100644
index 0000000..d2202eb
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/grandmaOut/fore-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/grandmaOut/fore.webp b/site/little-red-riding-hood/img/sets/grandmaOut/fore.webp
new file mode 100644
index 0000000..bf84295
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/grandmaOut/fore.webp differ
diff --git a/site/little-red-riding-hood/img/sets/grandmaOut/house-soft.webp b/site/little-red-riding-hood/img/sets/grandmaOut/house-soft.webp
new file mode 100644
index 0000000..12837e3
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/grandmaOut/house-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/grandmaOut/house.webp b/site/little-red-riding-hood/img/sets/grandmaOut/house.webp
new file mode 100644
index 0000000..eb8dd08
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/grandmaOut/house.webp differ
diff --git a/site/little-red-riding-hood/img/sets/grandmaOut/inside.webp b/site/little-red-riding-hood/img/sets/grandmaOut/inside.webp
new file mode 100644
index 0000000..1456742
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/grandmaOut/inside.webp differ
diff --git a/site/little-red-riding-hood/img/sets/grandmaOut/mid-soft.webp b/site/little-red-riding-hood/img/sets/grandmaOut/mid-soft.webp
new file mode 100644
index 0000000..66a1bb3
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/grandmaOut/mid-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/grandmaOut/mid.webp b/site/little-red-riding-hood/img/sets/grandmaOut/mid.webp
new file mode 100644
index 0000000..3fb496d
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/grandmaOut/mid.webp differ
diff --git a/site/little-red-riding-hood/img/sets/grandmaOut/sky-soft.webp b/site/little-red-riding-hood/img/sets/grandmaOut/sky-soft.webp
new file mode 100644
index 0000000..1214f63
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/grandmaOut/sky-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/grandmaOut/sky.webp b/site/little-red-riding-hood/img/sets/grandmaOut/sky.webp
new file mode 100644
index 0000000..718e794
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/grandmaOut/sky.webp differ
diff --git a/site/little-red-riding-hood/img/sets/home/far-soft.webp b/site/little-red-riding-hood/img/sets/home/far-soft.webp
new file mode 100644
index 0000000..15c122d
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/home/far-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/home/far.webp b/site/little-red-riding-hood/img/sets/home/far.webp
new file mode 100644
index 0000000..069a623
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/home/far.webp differ
diff --git a/site/little-red-riding-hood/img/sets/home/fore-soft.webp b/site/little-red-riding-hood/img/sets/home/fore-soft.webp
new file mode 100644
index 0000000..df50e10
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/home/fore-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/home/fore.webp b/site/little-red-riding-hood/img/sets/home/fore.webp
new file mode 100644
index 0000000..4fbe2a7
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/home/fore.webp differ
diff --git a/site/little-red-riding-hood/img/sets/home/house-soft.webp b/site/little-red-riding-hood/img/sets/home/house-soft.webp
new file mode 100644
index 0000000..8179c25
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/home/house-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/home/house.webp b/site/little-red-riding-hood/img/sets/home/house.webp
new file mode 100644
index 0000000..8075636
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/home/house.webp differ
diff --git a/site/little-red-riding-hood/img/sets/home/mid-soft.webp b/site/little-red-riding-hood/img/sets/home/mid-soft.webp
new file mode 100644
index 0000000..42d9b35
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/home/mid-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/home/mid.webp b/site/little-red-riding-hood/img/sets/home/mid.webp
new file mode 100644
index 0000000..57f59de
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/home/mid.webp differ
diff --git a/site/little-red-riding-hood/img/sets/home/sky-soft.webp b/site/little-red-riding-hood/img/sets/home/sky-soft.webp
new file mode 100644
index 0000000..1cf2a4b
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/home/sky-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/home/sky.webp b/site/little-red-riding-hood/img/sets/home/sky.webp
new file mode 100644
index 0000000..b9a99a3
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/home/sky.webp differ
diff --git a/site/little-red-riding-hood/img/sets/homeOut/far-soft.webp b/site/little-red-riding-hood/img/sets/homeOut/far-soft.webp
new file mode 100644
index 0000000..4ce9c46
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/homeOut/far-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/homeOut/far.webp b/site/little-red-riding-hood/img/sets/homeOut/far.webp
new file mode 100644
index 0000000..abb87dd
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/homeOut/far.webp differ
diff --git a/site/little-red-riding-hood/img/sets/homeOut/ground-soft.webp b/site/little-red-riding-hood/img/sets/homeOut/ground-soft.webp
new file mode 100644
index 0000000..2e2faba
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/homeOut/ground-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/homeOut/ground.webp b/site/little-red-riding-hood/img/sets/homeOut/ground.webp
new file mode 100644
index 0000000..2241a8d
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/homeOut/ground.webp differ
diff --git a/site/little-red-riding-hood/img/sets/homeOut/mid-soft.webp b/site/little-red-riding-hood/img/sets/homeOut/mid-soft.webp
new file mode 100644
index 0000000..c283937
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/homeOut/mid-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/homeOut/mid.webp b/site/little-red-riding-hood/img/sets/homeOut/mid.webp
new file mode 100644
index 0000000..d704a58
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/homeOut/mid.webp differ
diff --git a/site/little-red-riding-hood/img/sets/homeOut/sky-soft.webp b/site/little-red-riding-hood/img/sets/homeOut/sky-soft.webp
new file mode 100644
index 0000000..e057e48
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/homeOut/sky-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/homeOut/sky.webp b/site/little-red-riding-hood/img/sets/homeOut/sky.webp
new file mode 100644
index 0000000..8c1b739
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/homeOut/sky.webp differ
diff --git a/site/little-red-riding-hood/img/sets/room/house-soft.webp b/site/little-red-riding-hood/img/sets/room/house-soft.webp
new file mode 100644
index 0000000..60bc533
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/room/house-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/room/house.webp b/site/little-red-riding-hood/img/sets/room/house.webp
new file mode 100644
index 0000000..0fba217
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/room/house.webp differ
diff --git a/site/little-red-riding-hood/img/sets/room/wall-soft.webp b/site/little-red-riding-hood/img/sets/room/wall-soft.webp
new file mode 100644
index 0000000..1866a89
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/room/wall-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/room/wall.webp b/site/little-red-riding-hood/img/sets/room/wall.webp
new file mode 100644
index 0000000..9bf9fd1
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/room/wall.webp differ
diff --git a/site/little-red-riding-hood/img/sets/roomA/house-soft.webp b/site/little-red-riding-hood/img/sets/roomA/house-soft.webp
new file mode 100644
index 0000000..ec85fa3
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/roomA/house-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/roomA/house.webp b/site/little-red-riding-hood/img/sets/roomA/house.webp
new file mode 100644
index 0000000..92d01c1
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/roomA/house.webp differ
diff --git a/site/little-red-riding-hood/img/sets/roomB/house-soft.webp b/site/little-red-riding-hood/img/sets/roomB/house-soft.webp
new file mode 100644
index 0000000..43b25cb
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/roomB/house-soft.webp differ
diff --git a/site/little-red-riding-hood/img/sets/roomB/house.webp b/site/little-red-riding-hood/img/sets/roomB/house.webp
new file mode 100644
index 0000000..53edb0f
Binary files /dev/null and b/site/little-red-riding-hood/img/sets/roomB/house.webp differ
diff --git a/site/little-red-riding-hood/img/sets/sets.js b/site/little-red-riding-hood/img/sets/sets.js
new file mode 100644
index 0000000..9a0d413
--- /dev/null
+++ b/site/little-red-riding-hood/img/sets/sets.js
@@ -0,0 +1 @@
+window.SETS = {"home": [{"name": "sky", "k": 0.15, "box": [-400, -300, 3000, 1300], "soft": true}, {"name": "far", "k": 0.35, "box": [-400, 300, 3000, 700], "soft": true}, {"name": "mid", "k": 0.65, "box": [-400, 280, 3000, 720], "soft": true}, {"name": "house", "k": 1, "box": [-300, -620, 2900, 1620], "soft": true}, {"name": "fore", "k": 1.3, "box": [-400, 860, 3100, 140], "soft": true}], "homeOut": [{"name": "sky", "k": 0.2, "box": [-200, -100, 2000, 1100], "soft": true}, {"name": "far", "k": 0.4, "box": [-200, 280, 2000, 720], "soft": true}, {"name": "mid", "k": 0.7, "box": [-200, 320, 2000, 680], "soft": true}, {"name": "ground", "k": 1, "box": [-200, 640, 2000, 360], "soft": true}], "forest": [{"name": "sky", "k": 0.15, "box": [-200, -200, 2600, 1200], "soft": true}, {"name": "far", "k": 0.35, "box": [-200, 280, 3300, 720], "soft": true}, {"name": "mid", "k": 0.65, "box": [-200, 300, 4100, 700], "soft": true}, {"name": "house", "k": 1, "box": [-200, 690, 5000, 310], "soft": true}, {"name": "fore", "k": 1.3, "box": [-200, 860, 6200, 140], "soft": true}], "forestRev": [{"name": "far", "k": 0.4, "box": [-200, -100, 2000, 1100], "soft": true}, {"name": "house", "k": 1, "box": [-200, 300, 2000, 700], "soft": true}], "grandmaOut": [{"name": "sky", "k": 0.15, "box": [-300, -200, 2800, 1200], "soft": true}, {"name": "far", "k": 0.35, "box": [-300, 280, 2900, 720], "soft": true}, {"name": "mid", "k": 0.65, "box": [-300, 300, 3300, 700], "soft": true}, {"name": "inside", "k": 1, "box": [970, 430, 580, 380], "soft": false}, {"name": "house", "k": 1, "box": [-300, -560, 3300, 1560], "soft": true}, {"name": "fore", "k": 1.3, "box": [-300, 860, 3800, 140], "soft": true}], "room": [{"name": "wall", "k": 0.9, "box": [-200, -100, 3400, 940], "soft": true}, {"name": "house", "k": 1, "box": [-200, 360, 3400, 640], "soft": true}], "roomA": [{"name": "house", "k": 1, "box": [-200, -100, 2000, 1100], "soft": true}], "roomB": [{"name": "house", "k": 1, "box": [-200, -100, 2000, 1100], "soft": true}]};
diff --git a/site/little-red-riding-hood/index.html b/site/little-red-riding-hood/index.html
new file mode 100644
index 0000000..8683d61
--- /dev/null
+++ b/site/little-red-riding-hood/index.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>Little Red Riding Hood</title>
+<meta http-equiv="refresh" content="0; url=../">
+<p>Back to the <a href="../">bookshelf</a>.</p>
diff --git a/site/little-red-riding-hood/lib/book.css b/site/little-red-riding-hood/lib/book.css
new file mode 100644
index 0000000..5d49bfb
--- /dev/null
+++ b/site/little-red-riding-hood/lib/book.css
@@ -0,0 +1,9 @@
+/* This book's own settings, imported by engine.css. The engine files next to this one are the same in every book
+ and are replaced when the engine is updated; this file is not.
+ Settings (uncomment to use):
+:root {
+ --math-font: "Avenir Next", Arial, sans-serif; face for numbers and formulas (default: a serif, see engine.js)
+ --progress-key: "progress"; localStorage key shared with the cover (default: one per book folder)
+}
+ Style overrides go here too. They come before the engine's rules, so make each selector more specific than the
+ engine's, e.g. ':root .card.band' for '.card.band'. */
diff --git a/site/little-red-riding-hood/lib/cast.js b/site/little-red-riding-hood/lib/cast.js
new file mode 100644
index 0000000..e05444e
--- /dev/null
+++ b/site/little-red-riding-hood/lib/cast.js
@@ -0,0 +1,233 @@
+/* cast.js — the wolf, Grandma and the woodcutter, on paper.js. Each is drawn at its hip (0, 0) facing right, with a
+ profile set and a front set of pieces; the front set shows whenever head is 'F' or the turn is past its middle,
+ so a puppet always faces us as a whole. */
+'use strict';
+document.querySelector('svg defs').insertAdjacentHTML('beforeend', `
+ <pattern id="plaid" width="24" height="24" patternUnits="userSpaceOnUse">
+ <rect width="24" height="24" fill="#b03a2e"/><rect y="9" width="24" height="6" fill="#2a1a14" opacity=".5"/><rect x="9" width="6" height="24" fill="#2a1a14" opacity=".5"/>
+ </pattern>`);
+const CAST_DEFS = `<pattern id="plaid" width="24" height="24" patternUnits="userSpaceOnUse">
+ <rect width="24" height="24" fill="#b03a2e"/><rect y="9" width="24" height="6" fill="#2a1a14" opacity=".5"/><rect x="9" width="6" height="24" fill="#2a1a14" opacity=".5"/>
+ </pattern>`;
+// The baker renders pieces in their own documents: give it the cast's patterns too.
+PAPER_EXTRA.push(CAST_DEFS);
+
+// How far a jaw opens for each mouth shape of the cues.
+const JAW = { X: 0, A: 0, B: .25, C: .45, D: .85, E: .6, F: .3, G: .2, H: .35 };
+
+function puppet(parent, svg, rest, pose) {
+ const g = mk('g', {}, parent);
+ g.innerHTML = svg;
+ bakeAll(g);
+ const P = pieces(g);
+ return { g, pose(o, f) { o = { ...rest, ...o }; pose(P, o, k => jit(f, k), g); } };
+}
+// What every puppet does with its pose: place, jitter, turn, legs, arms, head; returns whether it faces us.
+function common(P, o, j, g, { neck, sh, el, hand, fsh, fup, knee }) {
+ const front = o.head === 'F' || Math.abs(o.turn) < .55;
+ tf(g, `translate(${(o.x + j(1) * .8).toFixed(1)},${(o.y + o.hop + j(2) * .6).toFixed(1)}) scale(${o.s}) rotate(${(j(3) * .5).toFixed(2)})`);
+ tf(P.body, `scale(${o.turn.toFixed(3)},1)`); vis(P.body, !front); vis(P.bodyF, front);
+ if (P.upper) tf(P.upper, `rotate(${o.lean.toFixed(2)})`);
+ if (P.legN) {
+ tf(P.legN, `rotate(${(o.near + j(4) * .6).toFixed(2)})`); tf(P.legNk, `rotate(${o.kNear.toFixed(2)},0,${knee})`);
+ tf(P.legF, `rotate(${(o.far + j(5) * .6).toFixed(2)})`); tf(P.legFk, `rotate(${o.kFar.toFixed(2)},0,${knee})`);
+ }
+ const ua = o.ua + j(7) * .6, fa = o.fa + j(8) * .6;
+ tf(P.arm, `rotate(${ua.toFixed(2)},${sh[0]},${sh[1]})`); tf(P.fore, `rotate(${fa.toFixed(2)},${el[0]},${el[1]})`);
+ armsF(P, o, j, fsh[0], fsh[1], fup);
+ const hr = `translate(0,${o.nod.toFixed(1)}) rotate(${(o.headR + j(9) * .7).toFixed(2)},${neck[0]},${neck[1]})`;
+ tf(P.headP, hr); tf(P.headF, hr);
+ vis(P.headP, !front); vis(P.headF, front);
+ face(front ? P.headF : P.headP, o);
+ return { front, ua, fa };
+}
+const both = (P, k, on) => { if (P[k + 'P']) vis(P[k + 'P'], on); if (P[k + 'F']) vis(P[k + 'F'], on); };
+const REST = { x: 0, y: 0, s: 1, turn: 1, near: 0, far: 0, kNear: 0, kFar: 0, lean: 0, ua: 6, fa: -6, rua: 6, rfa: -4, lua: -6, lfa: 4,
+ head: 'P', headR: 0, nod: 0, mouth: 'X', shut: false, hop: 0, brow: 0 };
+
+/* ---------- the wolf: grey, a flat cap and a red bow tie, more polite than he should be ----------
+ Feet at y 200. jaw follows the mouth cue unless given; cap 'on' | 'hand' | 'off'; night (Grandma's nightcap),
+ glasses; ears twitch with `ear`; look moves the pupils. */
+const FUR = '#8a8178', FUR2 = '#6b635b', ARM = '#787067', BELLY = '#d3cabc', NOSE = '#2a2420';
+const wolfHeadP = `<g data-p="headP">
+ <g filter="url(#paper)">
+ <ellipse cx="10" cy="-206" rx="46" ry="40" fill="${FUR}"/>
+ <path d="M28,-226 C70,-228 104,-216 108,-202 C108,-192 92,-186 62,-186 L28,-184 Z" fill="${FUR}"/>
+ <path d="M30,-186 L86,-187 L86,-176 L30,-172 Z" fill="#5a1f1f"/>
+ <path d="M52,-188 l4,7 l4,-7 Z M76,-188 l4,7 l4,-7 Z" fill="#f6efe0"/>
+ <path d="M-30,-196 C-44,-186 -40,-170 -24,-172 C-18,-180 -22,-190 -30,-196 Z" fill="${BELLY}"/>
+ <ellipse cx="42" cy="-216" rx="10" ry="9" fill="#f6efe0"/></g>
+ <g data-p="jawP" filter="url(#paper)"><path d="M28,-186 L90,-186 C96,-180 88,-170 70,-170 L30,-168 Z" fill="${FUR2}"/></g>
+ <g filter="url(#paper)"><ellipse cx="106" cy="-205" rx="9" ry="7" fill="${NOSE}"/></g>
+ <g class="eyeO"><circle data-p="pupilP" cx="44" cy="-216" r="4.6" fill="${NOSE}"/></g>
+ <g class="eyeC"><ellipse cx="42" cy="-218" rx="11" ry="9" fill="${FUR}"/><path d="M32,-215 Q42,-210 52,-215" stroke="${NOSE}" stroke-width="2.6" fill="none"/></g>
+ <path data-p="browP" d="M30,-233 L54,-229" stroke="${FUR2}" stroke-width="5" stroke-linecap="round"/>
+ <g data-p="nightP" filter="url(#paper)"><path d="M-36,-228 C-32,-278 34,-288 54,-236 Z" fill="#f6efe0"/><path d="M-30,-258 C-70,-268 -92,-238 -96,-212" stroke="#f6efe0" stroke-width="16" fill="none" stroke-linecap="round"/>
+ <circle cx="-98" cy="-206" r="9" fill="#e8b4a6"/><path d="M-38,-230 Q8,-222 56,-236" stroke="#e8b4a6" stroke-width="6" fill="none"/></g>
+ <g data-p="earP" filter="url(#paper)"><path d="M-16,-236 L-8,-294 L24,-240 Z" fill="${FUR}"/><path d="M-8,-244 L-3,-280 L14,-246 Z" fill="#e8b4a6"/></g>
+ <g data-p="capP" filter="url(#paper)"><path d="M-34,-238 C-22,-264 42,-266 54,-238 L80,-234 C76,-226 54,-226 42,-228 L-34,-228 Z" fill="#6e4a30"/><path d="M-30,-236 h76" stroke="#5a3b24" stroke-width="3"/></g>
+ <g data-p="glassesP"><circle cx="44" cy="-216" r="13" fill="#ffffff" fill-opacity=".18" stroke="#3a2a1a" stroke-width="3"/><path d="M31,-218 L-4,-224" stroke="#3a2a1a" stroke-width="3"/></g>
+ ${pinAt(8, -160)}</g>`;
+const wolfHeadF = `<g data-p="headF">
+ <g filter="url(#paper)">
+ <circle cx="0" cy="-212" r="52" fill="${FUR}"/><path d="M-52,-200 L-70,-184 L-46,-180 Z M52,-200 L70,-184 L46,-180 Z" fill="${FUR}"/>
+ <ellipse cx="0" cy="-174" rx="20" ry="18" fill="#5a1f1f"/>
+ <circle cx="-19" cy="-222" r="11" fill="#f6efe0"/><circle cx="19" cy="-222" r="11" fill="#f6efe0"/></g>
+ <g data-p="jawF" filter="url(#paper)"><ellipse cx="0" cy="-176" rx="22" ry="13" fill="${BELLY}"/></g>
+ <g filter="url(#paper)"><ellipse cx="0" cy="-196" rx="32" ry="19" fill="${BELLY}"/><path d="M-14,-180 l4,8 l4,-8 Z M6,-180 l4,8 l4,-8 Z" fill="#f6efe0"/>
+ <ellipse cx="0" cy="-204" rx="12" ry="8.5" fill="${NOSE}"/></g>
+ <g class="eyeO"><circle data-p="pupilL" cx="-19" cy="-222" r="5" fill="${NOSE}"/><circle data-p="pupilR" cx="19" cy="-222" r="5" fill="${NOSE}"/></g>
+ <g class="eyeC"><path d="M-30,-222 a11,9 0 0 1 22,0 Z M8,-222 a11,9 0 0 1 22,0 Z" fill="${FUR}"/><path d="M-29,-221 Q-19,-216 -9,-221 M9,-221 Q19,-216 29,-221" stroke="${NOSE}" stroke-width="2.6" fill="none"/></g>
+ <path data-p="browL" d="M-32,-240 L-8,-236" stroke="${FUR2}" stroke-width="5" stroke-linecap="round"/>
+ <path data-p="browR" d="M8,-236 L32,-240" stroke="${FUR2}" stroke-width="5" stroke-linecap="round"/>
+ <g data-p="nightF" filter="url(#paper)"><path d="M-50,-236 C-48,-300 48,-300 50,-236 Q0,-252 -50,-236 Z" fill="#f6efe0"/><path d="M30,-284 C70,-300 90,-270 92,-240" stroke="#f6efe0" stroke-width="16" fill="none" stroke-linecap="round"/>
+ <circle cx="93" cy="-234" r="9" fill="#e8b4a6"/><path d="M-50,-238 Q0,-254 50,-238" stroke="#e8b4a6" stroke-width="6" fill="none"/></g>
+ <g data-p="earsF" filter="url(#paper)"><path d="M-46,-238 L-36,-302 L-8,-252 Z M46,-238 L36,-302 L8,-252 Z" fill="${FUR}"/><path d="M-38,-246 L-34,-288 L-18,-254 Z M38,-246 L34,-288 L18,-254 Z" fill="#e8b4a6"/></g>
+ <g data-p="capF" filter="url(#paper)"><path d="M-46,-248 C-44,-288 44,-288 46,-248 Q0,-238 -46,-248 Z" fill="#6e4a30"/><path d="M-40,-246 Q0,-232 40,-246 L44,-240 Q0,-226 -44,-240 Z" fill="#5a3b24"/></g>
+ <g data-p="glassesF"><circle cx="-19" cy="-222" r="14" fill="#ffffff" fill-opacity=".18" stroke="#3a2a1a" stroke-width="3"/><circle cx="19" cy="-222" r="14" fill="#ffffff" fill-opacity=".18" stroke="#3a2a1a" stroke-width="3"/><path d="M-5,-222 h10" stroke="#3a2a1a" stroke-width="3"/></g>
+ </g>`;
+const bowTie = (x, y) => `<g filter="url(#paper)"><path d="M${x},${y} l-14,-9 v18 Z M${x},${y} l14,-9 v18 Z" fill="#c8322f"/><circle cx="${x}" cy="${y}" r="4.5" fill="#a82626"/></g>`;
+const capInHand = (x, y, id) => `<g data-p="${id}" filter="url(#paper)"><path d="M${x - 30},${y + 10} C${x - 22},${y - 14} ${x + 22},${y - 14} ${x + 30},${y + 10} Z" fill="#6e4a30"/></g>`;
+const REST_WOLF = { ...REST, tail: 0, jaw: null, cap: 'on', night: false, glasses: false, ear: 0, look: 0 };
+function wolfPuppet(parent) {
+ return puppet(parent, `<g data-p="body">
+ <g data-p="tail" filter="url(#paper)"><path d="M-30,-30 C-80,-40 -130,-30 -150,-70 C-120,-60 -96,-80 -110,-110 C-70,-80 -40,-70 -24,-50 Z" fill="${FUR}"/><path d="M-150,-70 C-140,-80 -126,-96 -110,-110 C-118,-90 -134,-76 -150,-70 Z" fill="${BELLY}"/></g>
+ ${legPiece('legF', FUR2, NOSE, 104, 100, 28)}${legPiece('legN', FUR, NOSE, 104, 100, 28)}
+ <g data-p="upper">
+ <g filter="url(#paper)"><path d="M-28,-140 L-26,-198 L32,-198 L30,-140 Z" fill="${FUR}"/></g>
+ <g filter="url(#paper)"><path d="M-40,-152 C-62,-80 -60,0 -38,20 L38,20 C58,-10 52,-100 32,-152 Z" fill="${FUR}"/><path d="M8,-124 C32,-84 36,-22 28,14 L2,16 C12,-30 10,-82 0,-124 Z" fill="${BELLY}"/></g>
+ ${bowTie(22, -150)}
+ ${wolfHeadP}
+ <g data-p="arm"><g filter="url(#paper)"><rect x="6" y="-146" width="19" height="66" rx="9" fill="${ARM}"/></g>
+ <g data-p="fore"><g filter="url(#paper)"><rect x="8.5" y="-86" width="15" height="58" rx="7" fill="${ARM}"/><circle cx="15.5" cy="-28" r="12" fill="${FUR2}"/></g>
+ ${capInHand(15.5, -12, 'capHand')}${pinAt(15.5, -82)}</g>${pinAt(15.5, -140)}</g>
+ </g></g>
+ <g data-p="bodyF">
+ <g filter="url(#paper)"><path d="M30,-40 C80,-60 110,-90 100,-130 C90,-100 70,-80 30,-70 Z" fill="${FUR}"/></g>
+ <g filter="url(#paper)"><rect x="-30" y="10" width="24" height="186" rx="10" fill="${FUR}"/><rect x="6" y="10" width="24" height="186" rx="10" fill="${FUR}"/>
+ <ellipse cx="-16" cy="198" rx="16" ry="8" fill="${NOSE}"/><ellipse cx="16" cy="198" rx="16" ry="8" fill="${NOSE}"/></g>
+ <g filter="url(#paper)"><rect x="-28" y="-198" width="56" height="58" fill="${FUR}"/></g>
+ <g filter="url(#paper)"><path d="M-40,-152 C-62,-80 -58,0 -40,22 L40,22 C58,0 62,-80 40,-152 Z" fill="${FUR}"/><path d="M-20,-124 C-30,-60 -26,0 -18,16 L18,16 C26,0 30,-60 20,-124 Z" fill="${BELLY}"/></g>
+ ${bowTie(0, -148)}
+ ${frontArm('lArm', -38, -140, ARM, ARM, 60, 58)}
+ ${frontArm('rArm', 38, -140, ARM, ARM, 60, 58, capInHand(38, -26, 'capHandF'))}
+ </g>
+ ${wolfHeadF}`, REST_WOLF, (P, o, j, g) => {
+ const { front } = common(P, o, j, g, { neck: [8, -160], sh: [15.5, -140], el: [15.5, -82], fsh: [38, -140], fup: 60, knee: 96 });
+ tf(P.tail, `rotate(${(o.tail + j(6) * 1.2).toFixed(2)},-30,-40)`);
+ const jaw = o.jaw ?? JAW[o.mouth || 'X'] ?? 0;
+ tf(P.jawP, `rotate(${(jaw * 30).toFixed(1)},30,-184)`); tf(P.jawF, `translate(0,${(jaw * 22).toFixed(1)})`);
+ tf(P.earP, `rotate(${(o.ear * 14).toFixed(1)},4,-238)`); tf(P.earsF, `translate(0,${(-6 * Math.abs(o.ear)).toFixed(1)})`);
+ tf(P.browP, `rotate(${(-10 * o.brow).toFixed(1)},42,-231)`);
+ tf(P.browL, `translate(0,${(-5 * Math.max(0, o.brow)).toFixed(1)}) rotate(${(14 * o.brow).toFixed(1)},-8,-236)`);
+ tf(P.browR, `translate(0,${(-5 * Math.max(0, o.brow)).toFixed(1)}) rotate(${(-14 * o.brow).toFixed(1)},8,-236)`);
+ P.pupilP.setAttribute('cx', 44 + 3 * o.look); P.pupilL.setAttribute('cx', -19 + 4 * o.look); P.pupilR.setAttribute('cx', 19 + 4 * o.look);
+ both(P, 'cap', o.cap === 'on'); vis(P.capHand, o.cap === 'hand'); vis(P.capHandF, o.cap === 'hand');
+ both(P, 'night', o.night); both(P, 'glasses', o.glasses);
+ });
+}
+
+/* ---------- Grandma: small and round, nightcap, glasses and a lilac shawl ----------
+ Feet at y 196. umbrella: held in her near hand (pointing along the forearm). */
+const SKIN_G = '#f2cfb4', GOWN = '#f1ece0', SHAWL = '#8a6a9a', HAIR_G = '#cfc8be';
+const umbrellaSVG = (x, y, id) => `<g data-p="${id}" filter="url(#paper)"><rect x="${x - 2.5}" y="${y - 6}" width="5" height="118" fill="#5a3b24"/>
+ <path d="M${x},${y + 24} L${x + 15},${y + 92} L${x},${y + 112} L${x - 15},${y + 92} Z" fill="#3f5f8a"/><path d="M${x},${y - 6} q-14,-4 -14,10" stroke="#5a3b24" stroke-width="5" fill="none"/></g>`;
+const REST_GRAN = { ...REST, cap: true, glasses: true, umbrella: false, blush: 0 };
+function grandmaPuppet(parent) {
+ const ink = '#22150e';
+ return puppet(parent, `<g data-p="body">
+ <g filter="url(#paper)"><path d="M14,184 h28 q12,0 12,8 v5 h-40 z M-16,184 h24 q10,0 10,8 v5 h-34 z" fill="#8a6a9a"/></g>
+ <g filter="url(#paper)"><path d="M-42,-14 L40,-14 C52,60 62,140 70,190 Q0,202 -70,190 C-62,140 -54,60 -42,-14 Z" fill="${GOWN}"/><path d="M-68,184 Q0,198 68,184" stroke="#d8cfbf" stroke-width="5" fill="none"/></g>
+ <g filter="url(#paper)"><path d="M-32,-140 L28,-140 L40,-10 L-42,-10 Z" fill="${GOWN}"/><rect x="-8" y="-166" width="16" height="30" fill="${SKIN_G}"/></g>
+ <g filter="url(#paper)"><path d="M-42,-152 Q0,-166 34,-146 L46,-88 Q0,-74 -54,-82 Q-52,-120 -42,-152 Z" fill="${SHAWL}"/></g>
+ <g data-p="headP">
+ <g filter="url(#paper)"><circle cx="-30" cy="-226" r="18" fill="${HAIR_G}"/><circle cx="12" cy="-200" r="40" fill="${SKIN_G}"/><circle cx="52" cy="-198" r="8.5" fill="${SKIN_G}"/>
+ <path d="M-34,-200 C-36,-242 30,-252 52,-216 Q26,-232 2,-222 Q-12,-210 -14,-190 Q-18,-172 -8,-164 L-30,-168 C-38,-180 -36,-192 -34,-200 Z" fill="${HAIR_G}"/>
+ <path d="M22,-186 q6,4 12,0" stroke="#d9a98e" stroke-width="2" fill="none"/></g>
+ <circle data-p="blushP" cx="32" cy="-184" r="9" fill="#ef8a7a"/>
+ <g class="eyeO"><ellipse cx="36" cy="-206" rx="4" ry="5.5" fill="${ink}"/></g>
+ <g class="eyeC"><path d="M31,-205 Q36,-201 41,-205" fill="none" stroke="${ink}" stroke-width="2.4" stroke-linecap="round"/></g>
+ <path data-p="browP" d="M28,-220 L44,-218" stroke="#a9a196" stroke-width="3.5" stroke-linecap="round"/>
+ <use class="mouth" href="#mX" transform="translate(42,-180) scale(.8)"/>
+ <g data-p="glassesP"><circle cx="37" cy="-205" r="11" fill="#ffffff" fill-opacity=".15" stroke="#7a5a2a" stroke-width="2.6"/><path d="M26,-207 L-4,-212" stroke="#7a5a2a" stroke-width="2.6"/></g>
+ <g data-p="capP" filter="url(#paper)"><path d="M-42,-212 C-42,-264 52,-268 60,-216 Q10,-234 -42,-212 Z" fill="#f6efe0"/>
+ <path d="M-42,-212 Q10,-234 60,-216" stroke="#e8c4d0" stroke-width="7" fill="none" stroke-dasharray="7 5"/></g>
+ ${pinAt(0, -162)}</g>
+ <g data-p="arm"><g filter="url(#paper)"><rect x="7" y="-140" width="17" height="58" rx="8" fill="${GOWN}"/></g>
+ <g data-p="fore"><g filter="url(#paper)"><rect x="9.5" y="-88" width="13" height="56" rx="6" fill="${SKIN_G}"/><circle cx="16" cy="-30" r="9.5" fill="${SKIN_G}"/></g>
+ ${umbrellaSVG(16, -30, 'umbP')}${pinAt(16, -84)}</g>${pinAt(16, -134)}</g></g>
+ <g data-p="bodyF">
+ <g filter="url(#paper)"><ellipse cx="-16" cy="194" rx="13" ry="7" fill="#8a6a9a"/><ellipse cx="16" cy="194" rx="13" ry="7" fill="#8a6a9a"/></g>
+ <g filter="url(#paper)"><path d="M-44,-14 L44,-14 C56,60 66,140 74,190 Q0,202 -74,190 C-66,140 -56,60 -44,-14 Z" fill="${GOWN}"/></g>
+ <g filter="url(#paper)"><path d="M-36,-140 L36,-140 L44,-10 L-44,-10 Z" fill="${GOWN}"/><rect x="-8" y="-166" width="16" height="30" fill="${SKIN_G}"/></g>
+ ${frontArm('lArm', -34, -136, GOWN, SKIN_G, 52, 54)}
+ ${frontArm('rArm', 34, -136, GOWN, SKIN_G, 52, 54, umbrellaSVG(34, -34, 'umbF'))}
+ <g filter="url(#paper)"><path d="M-48,-152 Q0,-170 48,-152 L58,-92 Q0,-74 -58,-92 Z" fill="${SHAWL}"/></g>
+ </g>
+ <g data-p="headF">
+ <g filter="url(#paper)"><circle cx="-38" cy="-206" r="16" fill="${HAIR_G}"/><circle cx="38" cy="-206" r="16" fill="${HAIR_G}"/><circle cx="0" cy="-200" r="42" fill="${SKIN_G}"/>
+ <path d="M-40,-206 Q0,-246 40,-206 Q20,-222 0,-218 Q-20,-222 -40,-206 Z" fill="${HAIR_G}"/></g>
+ <circle data-p="blushF1" cx="-24" cy="-184" r="8.5" fill="#ef8a7a"/><circle data-p="blushF2" cx="24" cy="-184" r="8.5" fill="#ef8a7a"/>
+ <g class="eyeO"><ellipse cx="-14" cy="-204" rx="4" ry="5.5" fill="${ink}"/><ellipse cx="14" cy="-204" rx="4" ry="5.5" fill="${ink}"/></g>
+ <g class="eyeC"><path d="M-19,-203 Q-14,-199 -9,-203 M9,-203 Q14,-199 19,-203" fill="none" stroke="${ink}" stroke-width="2.4" stroke-linecap="round"/></g>
+ <path data-p="browL" d="M-22,-218 L-8,-217" stroke="#a9a196" stroke-width="3.5" stroke-linecap="round"/>
+ <path data-p="browR" d="M8,-217 L22,-218" stroke="#a9a196" stroke-width="3.5" stroke-linecap="round"/>
+ <use class="mouth" href="#mX" transform="translate(0,-178)"/>
+ <g data-p="glassesF"><circle cx="-14" cy="-204" r="12" fill="#ffffff" fill-opacity=".15" stroke="#7a5a2a" stroke-width="2.6"/><circle cx="14" cy="-204" r="12" fill="#ffffff" fill-opacity=".15" stroke="#7a5a2a" stroke-width="2.6"/><path d="M-2,-204 h4" stroke="#7a5a2a" stroke-width="2.6"/></g>
+ <g data-p="capF" filter="url(#paper)"><path d="M-54,-206 C-54,-276 54,-276 54,-206 Q0,-232 -54,-206 Z" fill="#f6efe0"/><path d="M-54,-206 Q0,-232 54,-206" stroke="#e8c4d0" stroke-width="7" fill="none" stroke-dasharray="7 5"/></g>
+ </g>`, REST_GRAN, (P, o, j, g) => {
+ common(P, o, j, g, { neck: [0, -162], sh: [16, -134], el: [16, -84], fsh: [34, -136], fup: 52, knee: 0 });
+ tf(P.browP, `rotate(${(-12 * o.brow).toFixed(1)},28,-220)`);
+ tf(P.browL, `translate(0,${(-4 * Math.max(0, o.brow)).toFixed(1)}) rotate(${(-12 * o.brow).toFixed(1)},-8,-217)`);
+ tf(P.browR, `translate(0,${(-4 * Math.max(0, o.brow)).toFixed(1)}) rotate(${(12 * o.brow).toFixed(1)},8,-217)`);
+ for (const k of ['blushP', 'blushF1', 'blushF2']) P[k].setAttribute('opacity', (.35 + .5 * o.blush).toFixed(2));
+ both(P, 'cap', o.cap); both(P, 'glasses', o.glasses); vis(P.umbP, o.umbrella); vis(P.umbF, o.umbrella);
+ });
+}
+
+/* ---------- the woodcutter: tall, a red check shirt, a beard and a green knit hat; axe on his shoulder ----------
+ Feet at y 200. */
+const SKIN_W = '#e9b892', BEARD = '#6b4a2e';
+const axeSVG = (x, y, id) => `<g data-p="${id}" filter="url(#paper)"><rect x="${x - 3.5}" y="${y - 10}" width="7" height="140" rx="3" fill="#8a5a32"/>
+ <path d="M${x - 3},${y + 100} L${x - 34},${y + 92} L${x - 40},${y + 132} L${x - 3},${y + 126} Z" fill="#9aa0a6"/><path d="M${x - 34},${y + 92} L${x - 40},${y + 132}" stroke="#d6dade" stroke-width="4"/></g>`;
+const REST_WOOD = { ...REST, axe: true };
+function woodcutterPuppet(parent) {
+ const ink = '#22150e';
+ return puppet(parent, `<g data-p="body">
+ ${legPiece('legF', '#4e3a2a', '#2a1a10', 104, 96, 22)}${legPiece('legN', '#5e4632', '#3a2418', 104, 96, 22)}
+ <g filter="url(#paper)"><path d="M-40,-172 L36,-172 L46,-4 L-46,-4 Z" fill="url(#plaid)"/><rect x="-46" y="-20" width="92" height="14" fill="#3a2418"/><rect x="-9" y="-196" width="18" height="30" fill="${SKIN_W}"/></g>
+ <g data-p="headP">
+ <g filter="url(#paper)"><circle cx="12" cy="-224" r="40" fill="${SKIN_W}"/><circle cx="52" cy="-224" r="8.5" fill="${SKIN_W}"/>
+ <path d="M-18,-216 C-22,-170 34,-158 56,-200 L52,-208 Q30,-196 12,-202 Q-4,-206 -18,-216 Z" fill="${BEARD}"/>
+ <path d="M-32,-234 C-30,-280 52,-282 56,-234 Z" fill="#3f6d3a"/><path d="M-34,-238 h92 v12 h-92 Z" fill="#2f5a2c"/></g>
+ <g class="eyeO"><ellipse cx="36" cy="-220" rx="4.5" ry="5.5" fill="${ink}"/></g>
+ <g class="eyeC"><path d="M31,-219 Q36,-215 41,-219" fill="none" stroke="${ink}" stroke-width="2.4" stroke-linecap="round"/></g>
+ <path data-p="browP" d="M27,-233 L46,-231" stroke="${BEARD}" stroke-width="5" stroke-linecap="round"/>
+ <use class="mouth" href="#mX" transform="translate(42,-204) scale(.85)"/>
+ ${pinAt(0, -194)}</g>
+ <g data-p="arm"><g filter="url(#paper)"><rect x="6" y="-168" width="20" height="68" rx="9" fill="url(#plaid)"/></g>
+ <g data-p="fore"><g filter="url(#paper)"><rect x="9" y="-106" width="15" height="60" rx="7" fill="${SKIN_W}"/><circle cx="16.5" cy="-46" r="12" fill="${SKIN_W}"/></g>
+ ${axeSVG(16.5, -46, 'axeP')}${pinAt(16.5, -102)}</g>${pinAt(16.5, -162)}</g></g>
+ <g data-p="bodyF">
+ <g filter="url(#paper)"><rect x="-28" y="-6" width="22" height="196" rx="9" fill="#5e4632"/><rect x="6" y="-6" width="22" height="196" rx="9" fill="#5e4632"/>
+ <ellipse cx="-17" cy="196" rx="17" ry="9" fill="#3a2418"/><ellipse cx="17" cy="196" rx="17" ry="9" fill="#3a2418"/></g>
+ <g filter="url(#paper)"><path d="M-44,-172 L44,-172 L50,-4 L-50,-4 Z" fill="url(#plaid)"/><rect x="-50" y="-20" width="100" height="14" fill="#3a2418"/><rect x="-9" y="-196" width="18" height="30" fill="${SKIN_W}"/></g>
+ ${frontArm('lArm', -42, -164, 'url(#plaid)', SKIN_W, 62, 60)}
+ ${frontArm('rArm', 42, -164, 'url(#plaid)', SKIN_W, 62, 60, axeSVG(42, -46, 'axeF'))}
+ </g>
+ <g data-p="headF">
+ <g filter="url(#paper)"><circle cx="0" cy="-224" r="42" fill="${SKIN_W}"/>
+ <path d="M-40,-222 C-44,-170 44,-170 40,-222 Q22,-200 0,-204 Q-22,-200 -40,-222 Z" fill="${BEARD}"/>
+ <path d="M-44,-236 C-44,-290 44,-290 44,-236 Z" fill="#3f6d3a"/><path d="M-46,-240 h92 v12 h-92 Z" fill="#2f5a2c"/></g>
+ <g class="eyeO"><ellipse cx="-15" cy="-218" rx="4.5" ry="5.5" fill="${ink}"/><ellipse cx="15" cy="-218" rx="4.5" ry="5.5" fill="${ink}"/></g>
+ <g class="eyeC"><path d="M-20,-217 Q-15,-213 -10,-217 M10,-217 Q15,-213 20,-217" fill="none" stroke="${ink}" stroke-width="2.4" stroke-linecap="round"/></g>
+ <path data-p="browL" d="M-24,-230 L-8,-229" stroke="${BEARD}" stroke-width="5" stroke-linecap="round"/>
+ <path data-p="browR" d="M8,-229 L24,-230" stroke="${BEARD}" stroke-width="5" stroke-linecap="round"/>
+ <use class="mouth" href="#mX" transform="translate(0,-200)"/>
+ </g>`, REST_WOOD, (P, o, j, g) => {
+ common(P, o, j, g, { neck: [0, -194], sh: [16.5, -162], el: [16.5, -102], fsh: [42, -164], fup: 62, knee: 96 });
+ tf(P.browP, `rotate(${(-12 * o.brow).toFixed(1)},27,-233)`);
+ tf(P.browL, `rotate(${(-14 * o.brow).toFixed(1)},-8,-229)`); tf(P.browR, `rotate(${(14 * o.brow).toFixed(1)},8,-229)`);
+ vis(P.axeP, o.axe); vis(P.axeF, o.axe);
+ });
+}
diff --git a/site/little-red-riding-hood/lib/contents.css b/site/little-red-riding-hood/lib/contents.css
new file mode 100644
index 0000000..3f59f10
--- /dev/null
+++ b/site/little-red-riding-hood/lib/contents.css
@@ -0,0 +1,115 @@
+/* The book's cover and contents (index.html): the chalkboard look, the cover, the guide, the chapter grid and the
+ page-to-page motion. A book's own <style> after this file sets its theme: the colour and font tokens below, and the
+ few rules a theme redraws (e.g. body::before for the paper). */
+:root {
+ --page: #0f1613; --board: #1d2b27; --panel: #22322d; --edge: #3a5047;
+ --chalk: #ece8dc; --dim: #9aaba3; --faint: #5d7068; --task: #f0b45a; --quiz: #86c9e8; --good: #8fd6b0;
+ --ui: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
+ --book: "Iowan Old Style", Palatino, Georgia, serif;
+ --ease: cubic-bezier(.2, .8, .2, 1);
+ --top-bg: rgba(22, 33, 29, .86); --top-line: #2a3b35; /* the sticky contents header */
+ --lift: rgba(0, 0, 0, .3); /* a card's shadow on hover */
+ color-scheme: dark;
+}
+* { box-sizing: border-box; }
+html { scroll-padding-top: 90px; }
+body { margin: 0; min-height: 100svh; background: var(--board); color: var(--chalk); font: 18px/1.5 var(--ui); }
+/* Chalkboard: the same grain and vignette as the lesson stage. */
+body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
+ background: radial-gradient(ellipse at 50% 42%, transparent 55%, rgba(0, 0, 0, .38)),
+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .92 0 0 0 0 .95 0 0 0 0 .9 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E"); }
+a { color: inherit; }
+a:focus-visible { outline: 3px solid var(--task); outline-offset: 3px; }
+.kicker { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--quiz); }
+
+/* ---------- cover ---------- */
+#cover { position: relative; min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center;
+ padding: 48px 16px 64px; text-align: center; overflow: hidden; }
+.open #cover, body:not(.open) #contents { display: none; }
+#cover > * { animation: rise .8s var(--ease) backwards; }
+#cover .mascot { animation: none; margin-bottom: 26px; view-transition-name: guide; }
+#cover .kicker { animation-delay: .9s; }
+#cover h1 { animation-delay: 1s; }
+#cover .lede { animation-delay: 1.12s; }
+#cover .acts { animation-delay: 1.24s; }
+#cover .meta { animation-delay: 1.36s; }
+h1 { margin: 14px 0 18px; font: 500 clamp(44px, 8.4vw, 92px)/1.02 var(--book); letter-spacing: -.01em; view-transition-name: book; }
+h1 i { color: var(--task); font-style: italic; }
+.lede { max-width: 34em; margin: 0 0 34px; color: var(--dim); font-size: clamp(17px, 2.2vw, 20px); text-wrap: balance; }
+.acts { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
+.btn { display: inline-flex; align-items: center; gap: 12px; padding: 14px 30px; border-radius: 999px; font-weight: 600; font-size: 19px; text-decoration: none;
+ transition: transform .25s var(--ease), background-color .25s, border-color .25s; }
+.btn[hidden] { display: none; }
+.btn:hover { transform: translateY(-2px); }
+.btn.go { background: var(--chalk); color: var(--board); }
+.btn.quiet { border: 1.5px solid var(--edge); color: var(--chalk); }
+.btn.quiet:hover { border-color: var(--dim); }
+.btn svg { width: 15px; height: 15px; fill: currentColor; }
+.meta { margin: 30px 0 0; color: var(--faint); font-size: 15px; letter-spacing: .04em; }
+/* Faint chalk notes around the edges of the board. */
+.chalk { position: absolute; inset: 0; z-index: -1; pointer-events: none; animation: none !important; }
+.chalk span { position: absolute; font: italic 400 clamp(22px, 3vw, 38px) var(--book); color: var(--chalk); opacity: 0; white-space: nowrap;
+ animation: chalk 1.6s ease-out forwards, drift 14s ease-in-out infinite alternate; animation-delay: calc(var(--d) * 1s), calc(var(--d) * 1s); }
+@keyframes chalk { to { opacity: .075; } }
+@keyframes drift { to { translate: 0 -10px; } }
+@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
+
+/* ---------- the guide: an infinity sign whose loops are its eyes ---------- */
+.mascot { display: block; overflow: visible; }
+.mascot .mbody { transform-box: view-box; transform-origin: 60px 46px; animation: bob 3.4s ease-in-out infinite; }
+.mascot .pupil { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
+.mascot .joy { display: none; }
+#cover:has(.go:hover, .go:focus-visible) .pupil { display: none; }
+#cover:has(.go:hover, .go:focus-visible) .joy { display: inline; }
+.draw .loop { stroke-dasharray: 1 1; animation: draw 1.3s cubic-bezier(.6, 0, .3, 1) .15s backwards; }
+.draw .face { animation: pop .45s var(--ease) 1.25s backwards; }
+@keyframes draw { from { stroke-dashoffset: 1; } }
+@keyframes pop { from { opacity: 0; transform: scale(.6); } }
+.draw .face { transform-box: view-box; transform-origin: 60px 44px; }
+@keyframes bob { 50% { transform: translateY(-3px) rotate(-2deg); } }
+@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
+
+/* ---------- contents ---------- */
+.top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 14px; padding: 12px max(16px, calc(50% - 590px));
+ background: var(--top-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--top-line); }
+.home { display: flex; align-items: center; gap: 12px; text-decoration: none; border-radius: 10px; }
+.home .mascot { view-transition-name: guide; }
+.home strong { font: 500 22px/1.1 var(--book); view-transition-name: book; }
+.home strong i { color: var(--task); }
+.prog { margin-left: auto; color: var(--dim); font-size: 15px; white-space: nowrap; }
+.prog b { color: var(--good); font-weight: 600; }
+main#contents { padding-bottom: 80px; }
+.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
+.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 16px; row-gap: 8px; min-height: 112px;
+ padding: 16px 18px 14px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--edge); border-left: 6px solid var(--c);
+ text-decoration: none; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
+.ch:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 14px 34px var(--lift); }
+.ch b { grid-row: span 2; min-width: 1.15em; font: 500 42px/1 var(--book); color: var(--c); font-variant-numeric: lining-nums tabular-nums; }
+.ch span { font-size: 18px; line-height: 1.3; }
+.ch small { color: var(--dim); font-size: 14px; }
+.ch.done small::before { content: var(--done, "✓ Finished · "); color: var(--good); font-weight: 600; }
+.ch.last small::after { content: var(--last, " · Last opened"); color: var(--quiz); }
+.ch.here:focus-visible { outline-color: var(--c); }
+.ch.here { animation: here 1.8s ease-out .3s; }
+@keyframes here { 0% { box-shadow: 0 0 0 0 var(--c); } 25% { box-shadow: 0 0 0 5px var(--c); } 100% { box-shadow: 0 0 0 14px transparent; } }
+.stagger .top { animation: rise .6s var(--ease) backwards; }
+.stagger .unit h2, .stagger .ch { animation: rise .6s var(--ease) backwards; animation-delay: calc(min(var(--i), 14) * 32ms + 80ms); }
+
+/* ---------- page-to-page motion ---------- */
+@view-transition { navigation: auto; }
+/* Firefox flickers through view transitions (the header blinks for several frames): it switches without one, and the
+ contents still rise in. -moz-orient exists only in Firefox. */
+@supports (-moz-orient: inline) { @view-transition { navigation: none; } }
+::view-transition-group(*) { animation-duration: .5s; animation-timing-function: var(--ease); }
+::view-transition-old(lesson), ::view-transition-new(lesson) { height: 100%; object-fit: cover; }
+::view-transition-old(lesson) { animation-duration: .18s; }
+@media (max-width: 560px) {
+ .home strong { font-size: 18px; }
+ #contents .top { flex-wrap: wrap; gap: 8px 12px; }
+ .ch { min-height: 0; }
+ .chalk span:not(:nth-child(3), :nth-child(4), :nth-child(7)) { display: none; }
+}
+@media (prefers-reduced-motion: reduce) {
+ *, *::before, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
+ .chalk span { opacity: .075; }
+}
diff --git a/site/little-red-riding-hood/lib/contents.js b/site/little-red-riding-hood/lib/contents.js
new file mode 100644
index 0000000..6b3272b
--- /dev/null
+++ b/site/little-red-riding-hood/lib/contents.js
@@ -0,0 +1,192 @@
+/* The book's cover and contents (index.html): interface text, the chapter list with reading progress, the guide,
+ and the cover ↔ contents ↔ lesson motion. Load it in <head>; after the markup, the page calls
+ Contents.book({ units, start, hues }) with its chapter list. */
+'use strict';
+// Observe aborted incoming transitions before the first rendering opportunity.
+addEventListener('pagereveal', e => e.viewTransition?.ready.catch(() => {}));
+
+const Contents = (() => {
+ // Interface text in the page's <html lang>, as in the lessons; missing keys fall back to English.
+ // A value is a string or plural forms { one, few, many, other } chosen by vars.n.
+ const TRANSLATIONS = {
+ en: {
+ open: 'Open the book', toCover: 'Back to the cover', resume: 'Continue · Chapter {n}', unit: 'Unit {n}', minutes: '{n} min',
+ meta: '{chapters}{samples} · {units} · with sound', metaChapters: { one: '{n} chapter', other: '{n} chapters' },
+ metaUnits: { one: '{n} unit', other: '{n} units' }, metaSamples: { one: ' + {n} sample', other: ' + {n} samples' }, samples: 'Sample chapters, another look',
+ chapterCount: { one: '{n} chapter', other: '{n} chapters' }, finished: '{done} of {n} finished',
+ doneMark: '✓ Finished · ', lastMark: ' · Last opened',
+ },
+ ru: {
+ open: 'Открыть книгу', toCover: 'К обложке', resume: 'Продолжить · Глава {n}', unit: 'Раздел {n}', minutes: '{n} мин',
+ meta: '{chapters}{samples} · {units} · со звуком',
+ metaChapters: { one: '{n} глава', few: '{n} главы', many: '{n} глав', other: '{n} главы' },
+ metaUnits: { one: '{n} раздел', few: '{n} раздела', many: '{n} разделов', other: '{n} раздела' },
+ metaSamples: { one: ' + {n} пробная', few: ' + {n} пробные', many: ' + {n} пробных', other: ' + {n} пробной' },
+ samples: 'Пробные главы в другом стиле',
+ chapterCount: { one: '{n} глава', few: '{n} главы', many: '{n} глав', other: '{n} главы' }, finished: 'Пройдено {done} из {n}',
+ doneMark: '✓ Пройдено · ', lastMark: ' · Открыта последней',
+ },
+ zh: {
+ open: '打开这本书', toCover: '返回封面', resume: '继续 · 第 {n} 章', unit: '第 {n} 单元', minutes: '{n} 分钟',
+ meta: '{chapters}{samples} · {units} · 有配音', metaChapters: '{n} 章', metaUnits: '{n} 个单元',
+ metaSamples: ' + {n} 个示例章', samples: '示例章,另一种风格',
+ chapterCount: '{n} 章', finished: '已完成 {done} / {n}',
+ doneMark: '✓ 已完成 · ', lastMark: ' · 上次打开',
+ },
+ ja: {
+ open: '本を開く', toCover: '表紙に戻る', resume: '続きから · 第{n}章', unit: '単元 {n}', minutes: '{n}分',
+ meta: '{chapters}{samples} · {units} · 音声つき', metaChapters: '{n}章', metaUnits: '{n}単元',
+ metaSamples: ' + サンプル{n}章', samples: 'サンプル章(別のスタイル)',
+ chapterCount: '{n}章', finished: '{n}章中 {done}章 完了',
+ doneMark: '✓ 完了 · ', lastMark: ' · 最後に開いた章',
+ },
+ };
+ const LANGUAGE = (document.documentElement.lang || 'en').toLowerCase().split('-')[0];
+ function translate(key, vars = {}) {
+ const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
+ let text = TRANSLATIONS[language][key] ?? key;
+ if (typeof text === 'object') {
+ let rules;
+ try { rules = new Intl.PluralRules(language); } catch { rules = new Intl.PluralRules('en'); }
+ text = text[rules.select(vars.n)] ?? text.other;
+ }
+ return text.replace(/\{(\w+)\}/g, (placeholder, name) => name in vars ? vars[name] : placeholder);
+ }
+ const $ = id => document.getElementById(id);
+ const id = n => 'ch' + String(n).padStart(2, '0');
+ const esc = s => s.replace(/&/g, '&amp;').replace(/</g, '&lt;');
+ const HUES = ['#f4a48c', '#86c9e8', '#f3c95c', '#e8a0c8', '#8fd6b0', '#bba8ee', '#f0b45a'];
+
+ // Fixed interface text: data-t replaces an element's first text, data-t-label its aria-label.
+ function translatePage() {
+ for (const element of document.querySelectorAll('[data-t]')) element.firstChild.nodeValue = translate(element.dataset.t);
+ for (const element of document.querySelectorAll('[data-t-label]')) element.setAttribute('aria-label', translate(element.dataset.tLabel));
+ document.documentElement.style.setProperty('--done', JSON.stringify(translate('doneMark')));
+ document.documentElement.style.setProperty('--last', JSON.stringify(translate('lastMark')));
+ }
+
+ // Reading progress { done: [chapter numbers], last }, written by the lessons. The engine and this page derive the
+ // same key from the book's folder; a book that predates that passes its own key.
+ function progress(key) {
+ let P = {};
+ try {
+ const saved = JSON.parse(localStorage.getItem(key) || '{}');
+ if (saved && typeof saved === 'object' && !Array.isArray(saved)) P = saved;
+ } catch {}
+ return { last: P.last, done: new Set(Array.isArray(P.done) ? P.done.filter(n => Number.isInteger(n) && n > 0) : []) };
+ }
+
+ // The chapter cards, unit by unit, with progress, the header count, the cover's meta line and its resume button.
+ // A unit's optional third entry { unit, chapter, sample, href } numbers it from elsewhere in the book; a sample chapter,
+ // made to show another look, is not counted with the book's chapters, and a unit of samples has no unit number.
+ // With href, the sample lives in another book folder (its own progress): its card links there and leaves this book's
+ // numbering and progress alone. A chapter's own third entry { href, chapter } does the same for that chapter alone;
+ // without href, its chapter is only the number shown on the card.
+ // start.label is the number shown for start.chapter (folders keep the book's numbers; lessons set CHAPTER.label).
+ function contents(units, start, hues, P) {
+ let n = start.chapter - 1, total = 0, i = 0, away = 0; // i staggers the entrance, in reading order
+ const samples = new Set(), shown = k => k - start.chapter + (start.label ?? start.chapter);
+ $('units').innerHTML = units.map(([name, chs, o = {}], u) => {
+ if (o.chapter && !o.href) n = o.chapter - 1;
+ return `<section class="unit" style="--c:${hues[u % hues.length]};--i:${i++}">${Units.header(u, o.sample ? translate('samples') : translate('unit', { n: o.unit ?? u + start.unit }), name)}<div class="grid">` +
+ chs.map(([t, min, c = {}], k) => {
+ const href = c.href ?? o.href;
+ if (href) { away++; return `<a class="ch" href="${href}" style="--i:${i++}"><b>${c.chapter ?? (o.chapter ?? 1) + k}</b><span>${esc(t)}</span><small>${translate('minutes', { n: min })}</small></a>`; }
+ n++; if (o.sample) samples.add(n); else total++;
+ const cls = 'ch' + (P.done.has(n) ? ' done' : '') + (P.last === n ? ' last' : '');
+ return `<a class="${cls}" id="${id(n)}" href="${id(n)}/" style="--i:${i++}"><b>${c.chapter ?? shown(n)}</b><span>${esc(t)}</span><small>${translate('minutes', { n: min })}</small></a>`;
+ }).join('') + '</div></section>';
+ }).join('');
+ // A unit's sketch draws itself the first time the unit scrolls into view.
+ Units.watch();
+ const finished = [...P.done].filter(k => k >= start.chapter && k <= n && !samples.has(k)).length;
+ $('prog').innerHTML = finished ? translate('finished', { done: `<b>${finished}</b>`, n: total }) : translate('chapterCount', { n: total });
+ $('meta').textContent = translate('meta', {
+ chapters: translate('metaChapters', { n: total }),
+ samples: samples.size + away ? translate('metaSamples', { n: samples.size + away }) : '',
+ units: translate('metaUnits', { n: units.filter(x => !x[2]?.sample).length }) });
+ const last = Number.isInteger(P.last) && $(id(P.last));
+ if (last) {
+ const r = $('resume');
+ r.hidden = false;
+ r.href = last.getAttribute('href');
+ r.textContent = translate('resume', { n: last.querySelector('b').textContent });
+ }
+ }
+
+ // The guide, drawn the same way as in the lessons, in the page's chalk (ink) colour.
+ function lemniscate(cx, cy, a, k) {
+ let d = '';
+ for (let i = 0; i <= 96; i++) {
+ const t = i / 96 * 2 * Math.PI, sn = Math.sin(t), q = 1 + sn * sn;
+ d += (i ? 'L' : 'M') + (cx + a * Math.cos(t) / q).toFixed(1) + ' ' + (cy + k * a * sn * Math.cos(t) / q).toFixed(1);
+ }
+ return d + 'Z';
+ }
+ function guides(ink) {
+ for (const svg of document.querySelectorAll('svg.mascot')) {
+ svg.setAttribute('viewBox', '0 0 120 84');
+ svg.setAttribute('aria-hidden', 'true');
+ const ln = `fill="none" stroke="${ink}" stroke-linecap="round" stroke-linejoin="round"`;
+ svg.innerHTML = `<g class="mbody"><path class="loop" pathLength="1" d="${lemniscate(60, 40, 52, 1.5)}" ${ln} stroke-width="6"/><g class="face">` +
+ [33, 87].map(x => `<circle class="pupil" cx="${x}" cy="40" r="6.5" fill="${ink}"/><path class="joy" d="M${x - 7} 43Q${x} 32 ${x + 7} 43" ${ln} stroke-width="4"/>`).join('') +
+ `<path d="M55 62Q60 67 65 62" ${ln} stroke-width="3.5"/></g></g>`;
+ }
+ }
+
+ // The cover and the contents share this page: no hash or #book shows the cover, #contents or #chNN the contents.
+ // Lessons link back with #chNN, so the reader lands on the chapter they just left.
+ function views() {
+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;
+ function show(animate) {
+ const open = location.hash.length > 1 && location.hash !== '#book';
+ const apply = () => {
+ document.body.classList.toggle('open', open);
+ document.body.classList.toggle('stagger', animate && open);
+ const here = open ? $(location.hash.slice(1)) : null;
+ document.querySelectorAll('.here').forEach(e => e.classList.remove('here'));
+ if (here?.classList.contains('ch')) { here.scrollIntoView({ block: 'center' }); here.classList.add('here'); }
+ else scrollTo(0, 0);
+ if (animate) {
+ const heading = document.querySelector(open ? '#contents .home' : '#cover h1');
+ heading?.setAttribute('tabindex', '-1');
+ heading?.focus({ preventScroll: true });
+ }
+ };
+ if (animate && document.startViewTransition && !reduced && !CSS.supports('-moz-orient', 'inline')) {
+ const transition = document.startViewTransition(apply);
+ // Navigation can interrupt either promise; the new view is already applied.
+ transition.ready.catch(() => {});
+ transition.finished.catch(() => {});
+ } else apply();
+ }
+ addEventListener('hashchange', () => show(true));
+ show(false);
+
+ // Between pages, the chosen card grows into the lesson frame and the frame shrinks back into its card.
+ let named = null;
+ const name = el => {
+ if (named) named.style.viewTransitionName = '';
+ named = el;
+ if (el) el.style.viewTransitionName = 'lesson';
+ };
+ document.addEventListener('click', e => { const a = e.target.closest('a[href^="ch"]'); if (a) name(a); });
+ addEventListener('pagereveal', e => {
+ const target = (location.hash.length > 1 && $(location.hash.slice(1))?.closest('.ch')) || (named?.offsetParent && named);
+ name(e.viewTransition && target ? target : null);
+ e.viewTransition?.finished.then(() => name(null), () => name(null));
+ });
+ }
+
+ // units: [[unit title, [[chapter title, minutes], ...], { unit, chapter, sample, href }?], ...]. Chapters are numbered in
+ // order from start (a book whose scope starts mid-way keeps the original numbers in its folders, and may show them
+ // from start.label). hues: one colour per unit, cycling.
+ function book({ units, start = { unit: 1, chapter: 1 }, hues = HUES, progressKey, ink } = {}) {
+ translatePage();
+ contents(units, start, hues, progress(progressKey ?? 'animebook:progress:' + new URL('.', location.href).pathname));
+ guides(ink || getComputedStyle(document.documentElement).getPropertyValue('--chalk').trim() || '#ece8dc');
+ views();
+ }
+
+ return { book, translate };
+})();
diff --git a/site/little-red-riding-hood/lib/engine.css b/site/little-red-riding-hood/lib/engine.css
new file mode 100644
index 0000000..9b9be00
--- /dev/null
+++ b/site/little-red-riding-hood/lib/engine.css
@@ -0,0 +1,235 @@
+@import url(volume.css);
+@import url(book.css); /* this book's own settings and overrides (not shared), before the rules below */
+:root {
+ --page: #0f1613; --board: #1d2b27; --panel: #22322d; --edge: #3a5047;
+ --chalk: #ece8dc; --dim: #9aaba3; --faint: #5d7068;
+ --task: #f0b45a; --quiz: #86c9e8; --good: #8fd6b0; --bad: #f08c7a;
+ --ui: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
+ color-scheme: dark;
+}
+* { box-sizing: border-box; }
+html, body { height: 100%; margin: 0; overflow: hidden; background: var(--page); }
+body { color: var(--chalk); font: 26px/1.4 var(--ui); }
+button { font: inherit; color: inherit; cursor: pointer; }
+button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--task); outline-offset: 3px; }
+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));
+ 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;
+ background: radial-gradient(75% 75% at 50% 45%, rgba(0,0,0,0) 60%, rgba(0,0,0,.35)), var(--grain, none), #1d2b27; }
+#ui { position: absolute; left: 0; top: 0; width: 1600px; height: 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: rgba(15, 22, 19, .5); 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 > div > * { animation: rise .7s cubic-bezier(.2, .8, .2, 1) backwards; }
+.cover-t { animation-delay: .08s; }
+.cover .go { animation-delay: .18s; }
+.cover small { animation-delay: .26s; }
+@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 .paused-mark { display: grid; }
+.paused-mark div { padding: 14px 30px; border-radius: 999px; background: rgba(15, 22, 19, .85); color: var(--dim); font-size: 22px; }
+
+/* Question cards inside the picture. */
+.card { position: absolute; padding: 20px 26px; border-radius: 20px; background: rgba(34, 50, 45, .97); border: 1.5px solid var(--edge); border-left: 7px solid var(--quiz); box-shadow: 0 14px 44px rgba(0, 0, 0, .35); }
+.card.band { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pic head body acts" "pic fb body acts"; column-gap: 28px; align-items: center; align-content: center; min-height: 150px; }
+.band .mascot { grid-area: pic; }
+.band .head { grid-area: head; align-self: end; }
+.band .fb { grid-area: fb; align-self: start; }
+.band .body { grid-area: body; }
+.band .acts { grid-area: acts; }
+.side .mascot { float: right; margin: -2px -4px 6px 10px; }
+.kicker { margin: 0 0 4px; font-size: 20px; font-weight: 600; color: var(--quiz); }
+.prompt { margin: 0; font-size: 28px; line-height: 1.35; }
+.side .prompt { font-size: 24px; }
+.body:empty { display: none; }
+.side .body { margin-top: 14px; }
+.opts { display: flex; gap: 12px; flex-wrap: wrap; }
+.opt { padding: 8px 24px; border-radius: 999px; border: 2px solid var(--edge); background: transparent; color: var(--chalk); font-size: 24px; min-height: 58px; display: inline-flex; align-items: center; }
+.opt:hover:not(:disabled) { border-color: var(--dim); }
+.opt[aria-pressed="true"] { background: var(--c, var(--chalk)); border-color: var(--c, var(--chalk)); color: #1b2320; font-weight: 600; }
+.opt.good { border-color: var(--good); box-shadow: 0 0 0 3px rgba(143, 214, 176, .35); }
+.opt.bad { border-color: var(--bad); color: var(--bad); }
+.opt:disabled { cursor: default; }
+.fb { margin-top: 8px; font-size: 22px; line-height: 1.4; color: var(--chalk); }
+.fb:empty { display: none; }
+.fb.ok::before { content: "✓ "; color: var(--good); font-weight: 700; }
+.fb.no::before { content: "✗ "; color: var(--bad); font-weight: 700; }
+.fb ul { margin: 6px 0 0; padding-left: 22px; }
+.side .fb { max-height: 110px; overflow: auto; font-size: 20px; }
+.acts { display: flex; gap: 12px; align-items: center; }
+.side .acts { margin-top: 16px; }
+.side .acts { flex-wrap: wrap; gap: 10px; }
+.side .btn { padding: 8px 16px; font-size: 20px; }
+.card.side { padding: 18px 22px; }
+.btn { padding: 10px 28px; border-radius: 999px; border: 0; background: var(--chalk); color: var(--board); font-weight: 600; font-size: 22px; white-space: nowrap; }
+.btn.quiet { background: transparent; color: var(--dim); border: 1.5px solid var(--edge); }
+.btn.go { background: var(--quiz); color: #10242e; }
+.btn:disabled { background: var(--edge); color: var(--dim); cursor: default; }
+
+.grid .row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 34px; gap: 16px; align-items: center; padding: 5px 0 5px 12px; border-bottom: 1px solid #2e433b; }
+.grid .num { display: flex; justify-content: flex-end; align-items: center; font-size: 26px; }
+.grid.text .row { grid-template-columns: minmax(0, 1fr) auto 34px; }
+.grid.text .num { justify-content: flex-start; }
+.grid .opts { gap: 8px; }
+.grid .opt { padding: 3px 16px; min-height: 42px; font-size: 20px; }
+.grid .mark { font-weight: 700; text-align: center; }
+.grid .mark.good { color: var(--good); }
+.grid .mark.bad { color: var(--bad); }
+.grid .why { grid-column: 1 / -1; font-size: 19px; color: var(--dim); padding-left: 186px; }
+.grid.text .why { padding-left: 0; }
+.grid .why:empty { display: none; }
+
+.hit { cursor: pointer; }
+.hit .ring { fill: transparent; stroke: var(--chalk); stroke-width: 2.5; stroke-opacity: 0; }
+.hit:hover .ring, .hit:focus .ring { stroke-opacity: .7; }
+.hit.bad .ring { stroke: var(--bad); stroke-opacity: 1; }
+.hit.good .ring { stroke: var(--good); stroke-opacity: 1; stroke-width: 4; }
+.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: #16211d; border-top: 1px solid #2a3b35; }
+.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; }
+.is-playing .icon .i-play { display: none; }
+.is-playing .icon .i-pause { display: block; }
+.segs { flex: 1; display: flex; gap: 4px; height: 30px; align-items: center; min-width: 0; margin: 0 8px; }
+.seg { position: relative; display: block; min-width: 0; height: 8px; border-radius: 4px; background: #2f4640; border: 0; padding: 0; overflow: hidden; }
+.seg:hover { height: 12px; }
+.seg i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--chalk); }
+.seg.ask { background: #2d4a57; }
+.seg.ask i { background: var(--quiz); }
+.step { width: 300px; flex: none; color: var(--dim); font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
+/* 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;
+ 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; }
+ #bHelp { display: none; } /* keyboard shortcuts; room for the speed button on a phone */
+ #bar .icon.speed { width: 36px; min-width: 0; padding: 0; font-size: 12px; letter-spacing: -.3px; }
+ .segs { order: 1; }
+ .segs { min-width: 80px; margin: 0; }
+}
+.sound-note { position: absolute; left: 24px; top: 20px; margin: 0; padding: 8px 18px; border-radius: 12px; background: rgba(15, 22, 19, .85); color: var(--dim); font-size: 19px; }
+.sound-note[hidden] { display: none; }
+.blanks .brow { padding: 8px 0; border-bottom: 1px solid #2e433b; }
+.blanks .brow:last-child { border-bottom: 0; }
+.blanks .bline { line-height: 64px; white-space: nowrap; }
+.blanks .mark { display: inline-block; margin-left: 14px; font-weight: 700; }
+.blanks .mark.good { color: var(--good); animation: pop .35s ease-out; }
+.blanks .mark.bad { color: var(--bad); }
+.blanks .why { font-size: 19px; color: var(--dim); line-height: 1.35; }
+.blanks .why:empty { display: none; }
+.box { height: 52px; margin: 0 6px; padding: 0 6px; border: 0; border-bottom: 3px solid var(--quiz); border-radius: 8px 8px 0 0; background: rgba(236, 232, 220, .07); color: var(--chalk); font: 32px var(--math-font, "STIX Two Text", "Cambria Math", "Iowan Old Style", Palatino, Georgia, serif); text-align: center; vertical-align: -6px; }
+.box:focus { outline: none; background: rgba(134, 201, 232, .16); }
+.box.good { border-color: var(--good); }
+.box.bad { border-color: var(--bad); }
+.box:disabled { opacity: 1; }
+kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
+.opt kbd { margin: 0 .6em 0 0; }
+.keys { margin: 6px 0 0; font-size: 18px; color: var(--dim); }
+.keys kbd { margin: 0 .15em; }
+.grid .row.cur { background: rgba(236, 232, 220, .05); box-shadow: inset 4px 0 var(--quiz); }
+.help { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; display: grid; place-items: center; background: rgba(10, 16, 14, .72); }
+.help[hidden] { display: none; }
+.help-box { width: 1120px; 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; }
+.help dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; font-size: 22px; }
+.help dt { text-align: right; padding-right: 18px; white-space: nowrap; }
+.help dt kbd { margin: 0 0 0 .3em; opacity: .9; }
+.help dd { margin: 0; color: var(--dim); }
+.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: rgba(10, 16, 14, .82); color: var(--chalk); font-size: 28px; line-height: 1.35; text-align: center; pointer-events: none; }
+.caption[hidden] { display: none; }
+.icon.cc { font-size: 15px; font-weight: 700; color: var(--dim); }
+.icon.cc[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--board); }
+.card.side { overflow: auto; }
+svg.m { display: inline-block; overflow: visible; }
+.card b { font-weight: 700; } /* not 'bolder' (900 under a 600 prompt) */
+.card { animation: card-in .45s cubic-bezier(.2, .9, .3, 1.15); }
+.fb:not(:empty) { animation: fb-in .3s ease-out; }
+.opt.bad, .grid .mark.bad { animation: shake .4s; }
+.grid .mark.good { animation: pop .35s ease-out; }
+@keyframes card-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }
+@keyframes fb-in { from { opacity: 0; transform: translateY(8px); } }
+@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.3); } }
+@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
+/* Full-screen chapter practice. */
+.card.screen { height: 900px; padding: 50px 70px; border: 0; border-radius: 0; background: transparent; box-shadow: none; animation: screen-in .5s ease-out; max-height: none; overflow: visible; }
+.screen .kicker { font-size: 22px; }
+.screen .prompt { font-size: 40px; font-weight: 600; }
+.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 */
+/* Practice screens: the bottom 130 px hold the buttons. Long answers scroll inside the body, so the feedback under
+ them stays in view after a wrong answer adds a 'why' line to each row. */
+.card.screen:not(.sort):not(.fin) { padding-bottom: 130px; }
+.card.screen:not(.sort):not(.fin) > .head, .card.screen:not(.sort):not(.fin) > .fb { flex: none; }
+.card.screen:not(.sort):not(.fin) > .body { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
+.screen .acts { position: absolute; right: 70px; bottom: 48px; }
+.screen .grid .row { grid-template-columns: 200px minmax(0, 1fr) 40px; padding: 9px 0 9px 12px; }
+.screen .grid.text .row { grid-template-columns: minmax(0, 1fr) auto 40px; }
+.screen .grid .opt { font-size: 22px; min-height: 50px; padding: 4px 20px; }
+.screen .grid .why { padding-left: 216px; font-size: 20px; }
+.screen .grid.text .why { padding-left: 0; }
+#ui > .screen.sort { pointer-events: none; }
+.screen.sort > * { pointer-events: auto; }
+.screen.sort .head { position: absolute; right: 34px; top: 40px; width: 330px; }
+.screen.sort .prompt { font-size: 28px; }
+.screen.sort .fb { position: absolute; margin: 0; left: auto; right: 34px; bottom: 116px; width: 330px; max-height: 240px; overflow: auto; font-size: 20px; }
+.screen.sort .acts { right: 34px; }
+.fin .finwrap { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; padding-bottom: 60px; }
+.fin .mascot { margin-bottom: 28px; }
+.fin .fb, .fin .acts { position: static; }
+.fin .fb { order: 0; margin: 0; } /* result lines, not answer feedback: keep them above the buttons */
+.fin .acts { margin-top: 30px; }
+@keyframes screen-in { from { opacity: 0; } }
+
+/* The guide: an infinity sign whose loops are its eyes. */
+.mascot { display: block; flex: none; overflow: visible; }
+.mascot .mbody { transform-box: view-box; transform-origin: 60px 46px; animation: bob 3.4s ease-in-out infinite; }
+.mascot .eyes { transition: transform .3s; }
+.mascot .pupil { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
+.mascot .joy, .mascot .flat { display: none; }
+.mascot.happy .pupil { display: none; }
+.mascot.happy .joy { display: inline; }
+.mascot.happy .mbody { animation: hop .55s ease-out 2, bob 3.4s ease-in-out 1.1s infinite; }
+.mascot.oops .eyes { transform: translate(-3px, 4px); }
+.mascot.oops .smile { display: none; }
+.mascot.oops .flat { display: inline; }
+.mascot.oops .mbody { animation: wobble .5s ease-in-out, bob 3.4s ease-in-out .5s infinite; }
+@keyframes bob { 50% { transform: translateY(-3px) rotate(-2deg); } }
+@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
+@keyframes hop { 40% { transform: translateY(-12px) rotate(4deg); } }
+@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(6deg); } }
+@media (prefers-reduced-motion: reduce) { .card, .fb, .opt, .grid .mark, .mascot * { animation: none !important; } }
+
+a.icon { text-decoration: none; }
+a.btn { text-decoration: none; display: inline-block; }
+/* Page-to-page motion: the contents card grows into this frame, and shrinks back on the way out. */
+@view-transition { navigation: auto; }
+#frame { view-transition-name: lesson; }
+::view-transition-group(lesson) { animation-duration: .5s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
+::view-transition-old(lesson), ::view-transition-new(lesson) { height: 100%; object-fit: cover; }
+::view-transition-old(lesson) { animation-duration: .18s; }
+@media (prefers-reduced-motion: reduce) { .cover > div > * { animation: none; } ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }
+/* The finish screen speaks the same type as the chapter cover and the contents page. */
+.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; }
diff --git a/site/little-red-riding-hood/lib/engine.js b/site/little-red-riding-hood/lib/engine.js
new file mode 100644
index 0000000..883103d
--- /dev/null
+++ b/site/little-red-riding-hood/lib/engine.js
@@ -0,0 +1,2040 @@
+// Papermorph lesson engine: stage, drawing, timeline, questions, player.
+// A chapter page loads this file, defines CHAPTER and BEATS, then calls boot().
+'use strict';
+// A fast follow-up navigation can abort the incoming page transition.
+addEventListener('pagereveal', e => e.viewTransition?.ready.catch(() => {}));
+
+/* ---------- interface language ---------- */
+// The page's <html lang> picks the interface text; CHAPTER.language picks the audio folder. Set both alike.
+// A value is a string or plural forms { one, few, many, other } chosen by vars.n. Missing keys fall back to English.
+const TRANSLATIONS = {
+ en: {
+ decimalSign: '.', stageLabel: 'Lesson animation', stageLabelTitled: 'Lesson animation: {title}',
+ shortcuts: 'Keyboard shortcuts', lesson: 'Lesson', questions: 'Questions',
+ helpPlay: 'Play or pause', helpStep: 'Previous or next step', helpStepInQuestion: 'Change step during a question', helpRestart: 'Start over',
+ helpCaptions: 'Captions on or off', helpSpeed: 'Slower or faster', helpFullScreen: 'Full screen', helpList: 'Show this list',
+ helpChoose: 'Choose an answer or a ring', helpTrueFalse: 'True or false', helpRows: 'Move between rows',
+ helpNumberLine: 'Move along the number line, or pick a number to sort', helpEnter: 'Check, then continue',
+ helpShowAnswer: 'Show the answer', helpLeaveBox: 'Leave an answer box', helpClose: 'Press {key} to close.',
+ paused: 'Paused. Press space or click to continue.',
+ soundFailed: 'Sound could not play. The lesson continues with the on-screen text.',
+ startLesson: 'Start lesson', coverKeys: 'Press {space} to start, {help} for shortcuts.', spaceKey: 'Space',
+ chapterNumber: 'Chapter {n}', aboutMinutes: 'About {n} minutes, with sound and quick checks.',
+ allChapters: 'All chapters', playLabel: 'Play or pause (space)', backLabel: 'Previous step (left arrow)', restartLabel: 'Restart lesson',
+ volumeLabel: 'Adjust volume', volumeTitle: 'Volume (0 = muted)', volumeSlider: 'Volume',
+ helpLabel: 'Keyboard shortcuts (?)', speedLabel: 'Playback speed (< and >)', captionsLabel: 'Captions (C)', fullScreenLabel: 'Full screen', goToStep: 'Go to step {n}: {title}',
+ quickCheck: 'Quick check', countOf: '{k} of {n}', check: 'Check', showAnswer: 'Show answer', nextQuestion: 'Next question', continue: 'Continue',
+ correct: 'Correct. ', notQuite: 'Not quite. ', answerPrefix: 'Answer: ', keysPrefix: 'Keys: ',
+ hintMove: ' move, ', hintChoose: ' choose', hintChooseOrClickGrid: ' choose, or click the grid', hintMoveAlongLine: ' move along the line, ',
+ hintChooseOrClick: ' choose, or click', hintRow: ' row, ', hintTypeFraction: 'type numbers like 3/4 or −2 1/4, ', hintTypeNumber: 'type the number, ',
+ hintTypeDecimal: 'type the number, ', hintNextBox: ' next box, ', hintCheck: ' check, ', hintLeaveBox: ' leave the box',
+ hintPickNumber: ' pick a number, ', hintPickRing: ' choose its ring',
+ rowsRight: '{r} of {n} right. Fix the rows marked ✗ and check again.',
+ choicesShown: 'the correct choices are now selected.', numbersShown: 'the correct numbers are filled in.',
+ notPlacedYet: '{x} is not placed yet.',
+ realRingIsEmpty: '{x}: every real number is rational or irrational, so that space has no numbers of its own.',
+ ringsRight: '{r} of {n} in the right ring.', ringsShown: 'every number is now in its smallest ring.',
+ chipPlaced: '{x}, placed in {ring}', chipNotPlaced: '{x}, not placed', pointLabel: 'The point {v}', answerBox: 'Answer',
+ stepsLeftOfZero: '{n} steps left of 0',
+ natural: 'Natural', whole: 'Whole', integers: 'Integers', rational: 'Rational', irrational: 'Irrational', real: 'Real', integerColumn: 'Integer',
+ trueLabel: 'True', falseLabel: 'False',
+ chapterComplete: 'Chapter {n} complete', quickChecks: 'Quick checks', chapterPractice: 'Chapter practice',
+ firstTryScore: '{name}: {r} of {t} right on the first try.', notAttempted: '{name}: not attempted.',
+ watchAgain: 'Watch again', nextChapter: 'Next chapter',
+ },
+ ru: {
+ decimalSign: ',', stageLabel: 'Анимация урока', stageLabelTitled: 'Анимация урока: {title}',
+ shortcuts: 'Горячие клавиши', lesson: 'Урок', questions: 'Вопросы',
+ helpPlay: 'Пуск или пауза', helpStep: 'Предыдущий или следующий шаг', helpStepInQuestion: 'Сменить шаг во время вопроса', helpRestart: 'Начать сначала',
+ helpCaptions: 'Субтитры вкл. или выкл.', helpSpeed: 'Медленнее или быстрее', helpFullScreen: 'Полноэкранный режим', helpList: 'Показать этот список',
+ helpChoose: 'Выбрать ответ или круг', helpTrueFalse: 'Верно или неверно', helpRows: 'Перейти между строками',
+ helpNumberLine: 'Двигаться по числовой прямой или выбрать число для сортировки', helpEnter: 'Проверить, затем продолжить',
+ helpShowAnswer: 'Показать ответ', helpLeaveBox: 'Выйти из поля ответа', helpClose: 'Нажмите {key}, чтобы закрыть.',
+ paused: 'Пауза. Нажмите пробел или щёлкните, чтобы продолжить.',
+ soundFailed: 'Звук не воспроизводится. Урок продолжится с текстом на экране.',
+ startLesson: 'Начать урок', coverKeys: '{space} — начать, {help} — горячие клавиши.', spaceKey: 'Пробел',
+ chapterNumber: 'Глава {n}',
+ aboutMinutes: { one: 'Около {n} минуты, со звуком и проверками.', few: 'Около {n} минут, со звуком и проверками.',
+ many: 'Около {n} минут, со звуком и проверками.', other: 'Около {n} минуты, со звуком и проверками.' },
+ allChapters: 'Все главы', playLabel: 'Пуск или пауза (пробел)', backLabel: 'Предыдущий шаг (стрелка влево)', restartLabel: 'Начать урок заново',
+ volumeLabel: 'Настроить громкость', volumeTitle: 'Громкость (0 — без звука)', volumeSlider: 'Громкость',
+ helpLabel: 'Горячие клавиши (?)', speedLabel: 'Скорость воспроизведения (< и >)', captionsLabel: 'Субтитры (C)', fullScreenLabel: 'Полный экран', goToStep: 'Перейти к шагу {n}: {title}',
+ quickCheck: 'Проверь себя', countOf: '{k} из {n}', check: 'Проверить', showAnswer: 'Показать ответ', nextQuestion: 'Следующий вопрос', continue: 'Продолжить',
+ correct: 'Верно. ', notQuite: 'Не совсем. ', answerPrefix: 'Ответ: ', keysPrefix: 'Клавиши: ',
+ hintMove: ' двигаться, ', hintChoose: ' выбрать', hintChooseOrClickGrid: ' выбрать или щёлкнуть по сетке', hintMoveAlongLine: ' двигаться по прямой, ',
+ hintChooseOrClick: ' выбрать или щёлкнуть', hintRow: ' строка, ', hintTypeFraction: 'вводите числа вида 3/4 или −2 1/4, ', hintTypeNumber: 'введите число, ',
+ hintTypeDecimal: 'вводите числа вида 0,75, ', hintNextBox: ' следующее поле, ', hintCheck: ' проверить, ', hintLeaveBox: ' выйти из поля',
+ hintPickNumber: ' выбрать число, ', hintPickRing: ' выбрать его круг',
+ rowsRight: 'Верно {r} из {n}. Исправьте строки с ✗ и проверьте снова.',
+ choicesShown: 'правильные варианты отмечены.', numbersShown: 'правильные числа вписаны.',
+ notPlacedYet: '{x}: ещё не размещено.',
+ realRingIsEmpty: '{x}: каждое действительное число рационально или иррационально, поэтому своих чисел у этой области нет.',
+ ringsRight: 'В нужном круге: {r} из {n}.', ringsShown: 'каждое число теперь в своём наименьшем круге.',
+ chipPlaced: '{x}, в круге «{ring}»', chipNotPlaced: '{x}, не размещено', pointLabel: 'Точка {v}', answerBox: 'Ответ',
+ stepsLeftOfZero: { one: '{n} шаг влево от 0', few: '{n} шага влево от 0', many: '{n} шагов влево от 0', other: '{n} шага влево от 0' },
+ natural: 'Натуральные', whole: 'Целые неотрицательные', integers: 'Целые', rational: 'Рациональные', irrational: 'Иррациональные', real: 'Действительные', integerColumn: 'Целые',
+ trueLabel: 'Верно', falseLabel: 'Неверно',
+ chapterComplete: 'Глава {n} пройдена', quickChecks: 'Проверь себя', chapterPractice: 'Практика по главе',
+ firstTryScore: '{name}: {r} из {t} верно с первой попытки.', notAttempted: '{name}: не выполнялось.',
+ watchAgain: 'Смотреть снова', nextChapter: 'Следующая глава',
+ },
+ zh: {
+ decimalSign: '.', stageLabel: '课程动画', stageLabelTitled: '课程动画:{title}',
+ shortcuts: '键盘快捷键', lesson: '课程', questions: '题目',
+ helpPlay: '播放或暂停', helpStep: '上一步或下一步', helpStepInQuestion: '答题时切换步骤', helpRestart: '从头开始',
+ helpCaptions: '打开或关闭字幕', helpSpeed: '减速或加速', helpFullScreen: '全屏', helpList: '显示此列表',
+ helpChoose: '选择答案或圆环', helpTrueFalse: '对或错', helpRows: '在各行之间移动',
+ helpNumberLine: '在数轴上移动,或选一个数来分类', helpEnter: '检查,然后继续',
+ helpShowAnswer: '显示答案', helpLeaveBox: '离开答题框', helpClose: '按 {key} 关闭。',
+ paused: '已暂停。按空格键或点击继续。',
+ soundFailed: '声音无法播放。课程将借助屏幕上的文字继续。',
+ startLesson: '开始上课', coverKeys: '按 {space} 开始,按 {help} 查看快捷键。', spaceKey: '空格',
+ chapterNumber: '第 {n} 章', aboutMinutes: '约 {n} 分钟,含配音和随堂小测。',
+ allChapters: '全部章节', playLabel: '播放或暂停(空格)', backLabel: '上一步(左方向键)', restartLabel: '重新开始本课',
+ volumeLabel: '调节音量', volumeTitle: '音量(0 为静音)', volumeSlider: '音量',
+ helpLabel: '键盘快捷键(?)', speedLabel: '播放速度(< 和 >)', captionsLabel: '字幕(C)', fullScreenLabel: '全屏', goToStep: '跳到第 {n} 步:{title}',
+ quickCheck: '小测', countOf: '{k} / {n}', check: '检查', showAnswer: '显示答案', nextQuestion: '下一题', continue: '继续',
+ correct: '正确。', notQuite: '还不对。', answerPrefix: '答案:', keysPrefix: '按键:',
+ hintMove: ' 移动,', hintChoose: ' 选择', hintChooseOrClickGrid: ' 选择,或点击网格', hintMoveAlongLine: ' 沿数轴移动,',
+ hintChooseOrClick: ' 选择,或点击', hintRow: ' 换行,', hintTypeFraction: '可输入 3/4 或 −2 1/4 这样的数,', hintTypeNumber: '输入数字,',
+ hintTypeDecimal: '输入数字,', hintNextBox: ' 下一个框,', hintCheck: ' 检查,', hintLeaveBox: ' 离开答题框',
+ hintPickNumber: ' 选一个数,', hintPickRing: ' 选它所在的圆环',
+ rowsRight: '{n} 行中对了 {r} 行。改正标 ✗ 的行,再检查一次。',
+ choicesShown: '正确选项已经选上。', numbersShown: '正确的数已经填上。',
+ notPlacedYet: '{x} 还没有放好。',
+ realRingIsEmpty: '{x}:每个实数不是有理数就是无理数,所以这一块没有只属于它的数。',
+ ringsRight: '{n} 个中有 {r} 个放在了正确的圆环里。', ringsShown: '每个数现在都在它所属的最小圆环里。',
+ chipPlaced: '{x},放在「{ring}」', chipNotPlaced: '{x},未放置', pointLabel: '点 {v}', answerBox: '答案',
+ stepsLeftOfZero: '0 左边 {n} 步',
+ natural: '正整数', whole: '非负整数', integers: '整数', rational: '有理数', irrational: '无理数', real: '实数', integerColumn: '整数',
+ trueLabel: '对', falseLabel: '错',
+ chapterComplete: '第 {n} 章完成', quickChecks: '小测', chapterPractice: '本章练习',
+ firstTryScore: '{name}:第一次就答对 {r} / {t}。', notAttempted: '{name}:未作答。',
+ watchAgain: '再看一遍', nextChapter: '下一章',
+ },
+ ja: {
+ decimalSign: '.', stageLabel: '授業アニメーション', stageLabelTitled: '授業アニメーション:{title}',
+ shortcuts: 'キーボードショートカット', lesson: '授業', questions: '問題',
+ helpPlay: '再生/一時停止', helpStep: '前または次のステップ', helpStepInQuestion: '問題の途中でステップを移動', helpRestart: '最初から',
+ helpCaptions: '字幕のオン/オフ', helpSpeed: '遅く/速く', helpFullScreen: '全画面', helpList: 'この一覧を表示',
+ helpChoose: '答えまたは輪を選ぶ', helpTrueFalse: '正しい/誤り', helpRows: '行を移動',
+ helpNumberLine: '数直線上を移動、または分類する数を選ぶ', helpEnter: '答え合わせ、そして次へ',
+ helpShowAnswer: '答えを表示', helpLeaveBox: '解答欄から出る', helpClose: '{key} で閉じる。',
+ paused: '一時停止中。スペースキーかクリックで再開します。',
+ soundFailed: '音声を再生できません。画面の文字で授業を続けます。',
+ startLesson: '授業を始める', coverKeys: '{space} で開始、{help} でショートカット一覧。', spaceKey: 'スペース',
+ chapterNumber: '第{n}章', aboutMinutes: '約{n}分、音声と確認問題つき。',
+ allChapters: 'すべての章', playLabel: '再生/一時停止(スペース)', backLabel: '前のステップ(左矢印)', restartLabel: '授業を最初から',
+ volumeLabel: '音量を調整', volumeTitle: '音量(0 でミュート)', volumeSlider: '音量',
+ helpLabel: 'キーボードショートカット(?)', speedLabel: '再生速度(< と >)', captionsLabel: '字幕(C)', fullScreenLabel: '全画面', goToStep: 'ステップ {n}:{title} へ移動',
+ quickCheck: '確認問題', countOf: '{k} / {n}', check: '答え合わせ', showAnswer: '答えを見る', nextQuestion: '次の問題', continue: '続ける',
+ correct: '正解。', notQuite: 'おしい。', answerPrefix: '答え:', keysPrefix: 'キー:',
+ hintMove: ' 移動、', hintChoose: ' 選ぶ', hintChooseOrClickGrid: ' 選ぶ、またはマス目をクリック', hintMoveAlongLine: ' 数直線上を移動、',
+ hintChooseOrClick: ' 選ぶ、またはクリック', hintRow: ' 行、', hintTypeFraction: '3/4 や −2 1/4 のように入力、', hintTypeNumber: '数を入力、',
+ hintTypeDecimal: '数を入力、', hintNextBox: ' 次の欄、', hintCheck: ' 答え合わせ、', hintLeaveBox: ' 欄から出る',
+ hintPickNumber: ' 数を選ぶ、', hintPickRing: ' その輪を選ぶ',
+ rowsRight: '{n} 行中 {r} 行正解。✗ の行を直して、もう一度答え合わせ。',
+ choicesShown: '正しい選択肢を選びました。', numbersShown: '正しい数を入れました。',
+ notPlacedYet: '{x} はまだ置かれていません。',
+ realRingIsEmpty: '{x}:実数はどれも有理数か無理数なので、この部分だけに入る数はありません。',
+ ringsRight: '{n} 個中 {r} 個が正しい輪に入っています。', ringsShown: 'どの数も、入るいちばん小さい輪に移しました。',
+ chipPlaced: '{x}、「{ring}」に配置', chipNotPlaced: '{x}、未配置', pointLabel: '点 {v}', answerBox: '答え',
+ stepsLeftOfZero: '0 から左へ {n}',
+ natural: '自然数', whole: '0 以上の整数', integers: '整数', rational: '有理数', irrational: '無理数', real: '実数', integerColumn: '整数',
+ trueLabel: '正しい', falseLabel: '誤り',
+ chapterComplete: '第{n}章 完了', quickChecks: '確認問題', chapterPractice: '章末練習',
+ firstTryScore: '{name}:1 回目で {t} 問中 {r} 問正解。', notAttempted: '{name}:未挑戦。',
+ watchAgain: 'もう一度見る', nextChapter: '次の章へ',
+ },
+};
+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.
+function translate(key, vars = {}) {
+ const language = TRANSLATIONS[LANGUAGE]?.[key] !== undefined ? LANGUAGE : 'en';
+ let text = TRANSLATIONS[language][key] ?? key;
+ if (typeof text === 'object') {
+ try { pluralRules[language] ??= new Intl.PluralRules(language); } catch { pluralRules[language] = new Intl.PluralRules('en'); }
+ text = text[pluralRules[language].select(vars.n)] ?? text.other;
+ }
+ return text.replace(/\{(\w+)\}/g, (placeholder, name) => name in vars ? vars[name] : placeholder);
+}
+const DECIMAL_SIGN = translate('decimalSign'); // shown by num() and accepted by answer boxes
+const isLatinLetter = key => /^[a-z]$/i.test(key);
+// A letter shortcut on any keyboard layout: the typed letter, or the same physical key when the layout types a non-Latin letter.
+const isShortcut = (event, letter) => event.key.toLowerCase() === letter.toLowerCase()
+ || (isLatinLetter(letter) && !isLatinLetter(event.key) && event.code === 'Key' + letter.toUpperCase());
+// A punctuation shortcut (code 'Comma', 'Period') on a layout that types a non-Latin letter on that key.
+const 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')}">
+ <g id="scene"></g>
+ </svg>
+ <div id="ui"></div>
+ <div class="paused-mark"><div>${translate('paused')}</div></div>
+ <div class="caption" id="caption" hidden></div>
+ <div class="help" id="help" hidden role="dialog" aria-label="${translate('shortcuts')}">
+ <div class="help-box">
+ <h2>${translate('shortcuts')}</h2>
+ <div class="help-cols">
+ <div><h3>${translate('lesson')}</h3><dl>
+ <dt><kbd>${translate('spaceKey')}</kbd></dt><dd>${translate('helpPlay')}</dd>
+ <dt><kbd>←</kbd><kbd>→</kbd></dt><dd>${translate('helpStep')}</dd>
+ <dt><kbd>Shift</kbd><kbd>←</kbd><kbd>→</kbd></dt><dd>${translate('helpStepInQuestion')}</dd>
+ <dt><kbd>Home</kbd></dt><dd>${translate('helpRestart')}</dd>
+ <dt><kbd>C</kbd></dt><dd>${translate('helpCaptions')}</dd>
+ <dt><kbd>&lt;</kbd><kbd>&gt;</kbd></dt><dd>${translate('helpSpeed')}</dd>
+ <dt><kbd>F</kbd></dt><dd>${translate('helpFullScreen')}</dd>
+ <dt><kbd>?</kbd></dt><dd>${translate('helpList')}</dd>
+ </dl></div>
+ <div><h3>${translate('questions')}</h3><dl>
+ <dt><kbd>1</kbd>–<kbd>6</kbd></dt><dd>${translate('helpChoose')}</dd>
+ <dt><kbd>T</kbd><kbd>F</kbd></dt><dd>${translate('helpTrueFalse')}</dd>
+ <dt><kbd>↑</kbd><kbd>↓</kbd></dt><dd>${translate('helpRows')}</dd>
+ <dt><kbd>←</kbd><kbd>→</kbd></dt><dd>${translate('helpNumberLine')}</dd>
+ <dt><kbd>Enter</kbd></dt><dd>${translate('helpEnter')}</dd>
+ <dt><kbd>S</kbd></dt><dd>${translate('helpShowAnswer')}</dd>
+ <dt><kbd>Esc</kbd></dt><dd>${translate('helpLeaveBox')}</dd>
+ </dl></div>
+ </div>
+ <p class="help-close">${translate('helpClose', { key: '<kbd>Esc</kbd>' })}</p>
+ </div>
+ </div>
+ <p class="sound-note" id="soundNote" hidden>${translate('soundFailed')}</p>
+ <button class="cover" id="cover"><div>
+ <p class="cover-k" id="coverK"></p>
+ <h1 class="cover-t" id="coverT"></h1>
+ <span class="go"><svg width="24" height="24" viewBox="0 0 18 18"><path d="M3 1.5v15l13-7.5z" fill="currentColor"/></svg>${translate('startLesson')}</span>
+ <small><span id="coverMeta"></span> ${translate('coverKeys', { space: `<kbd>${translate('spaceKey')}</kbd>`, help: '<kbd>?</kbd>' })}</small>
+ </div></button>
+ <div id="bar">
+ <a class="icon" id="bHome" href="../" aria-label="${translate('allChapters')}" title="${translate('allChapters')}">
+ <svg viewBox="0 0 18 18"><path d="M2 2h6v6H2zM10 2h6v6h-6zM2 10h6v6H2zM10 10h6v6h-6z"/></svg>
+ </a>
+ <button class="icon" id="bPlay" aria-label="${translate('playLabel')}">
+ <svg class="i-play" viewBox="0 0 18 18"><path d="M4 2v14l12-7z"/></svg>
+ <svg class="i-pause" viewBox="0 0 18 18"><path d="M3.5 2h4v14h-4zM10.5 2h4v14h-4z"/></svg>
+ </button>
+ <button class="icon" id="bBack" aria-label="${translate('backLabel')}">
+ <svg viewBox="0 0 18 18"><path d="M3 2h2.5v14H3zM16 2v14L6.5 9z"/></svg>
+ </button>
+ <button class="icon" id="bRestart" aria-label="${translate('restartLabel')}">
+ <svg viewBox="0 0 18 18"><path d="M9 2.5a6.5 6.5 0 1 1-6.3 8.1l2-.5A4.5 4.5 0 1 0 9 4.5V7L4.5 3.5 9 0z"/></svg>
+ </button>
+ <div class="segs" id="segs"></div>
+ <div class="step" id="stepName"></div>
+ <button class="icon txt" id="bHelp" aria-label="${translate('helpLabel')}" title="${translate('helpLabel')}">?</button>
+ <button class="icon txt speed" id="bSpeed" aria-label="${translate('speedLabel')}" title="${translate('speedLabel')}">1×</button>
+ <button class="icon cc" id="bCC" aria-pressed="false" aria-label="${translate('captionsLabel')}" title="${translate('captionsLabel')}">CC</button>
+ <button class="icon" id="bFull" aria-label="${translate('fullScreenLabel')}">
+ <svg viewBox="0 0 18 18"><path d="M1 1h6v2H3v4H1zM11 1h6v6h-2V3h-4zM1 11h2v4h4v2H1zM15 11h2v6h-6v-2h4z"/></svg>
+ </button>
+ </div>
+</div>`);
+
+// Board colour, grain and vignette are a static CSS background of #stage (engine.css). The grain is a small noise
+// texture made once here: an SVG turbulence filter behind animated content is recomputed on every frame in Firefox.
+{
+ const c = document.createElement('canvas'); c.width = c.height = 256;
+ const x = c.getContext('2d'), d = x.createImageData(256, 256);
+ for (let i = 0, s = 7; i < d.data.length; i += 4) { s = s * 16807 % 2147483647; d.data.set([235, 242, 230, 4 + s % 12], i); }
+ x.putImageData(d, 0, 0);
+ document.getElementById('stage').style.setProperty('--grain', `url(${c.toDataURL()})`);
+}
+
+/* ---------- drawing helpers ---------- */
+const NS = 'http://www.w3.org/2000/svg';
+const COL = { nat: '#f4a48c', whole: '#86c9e8', int: '#f3c95c', rat: '#e8a0c8', irr: '#8fd6b0', real: '#bba8ee',
+ chalk: '#ece8dc', dim: '#9aaba3', faint: '#5d7068', task: '#f0b45a', good: '#8fd6b0', bad: '#f08c7a', board: '#1d2b27' };
+const UI = '"Avenir Next","Segoe UI","Helvetica Neue",Arial,sans-serif';
+// Book settings (lib/book.css, next to engine.css and imported by it): --math-font for numbers and formulas,
+// --progress-key for the localStorage key the cover and chapters share.
+const BOOK = getComputedStyle(document.documentElement);
+const bookSetting = name => BOOK.getPropertyValue(name).trim().replace(/^(["'])([^"']*)\1$/, '$2'); // unquote a lone string only
+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)
+const RIGHT = { x: 1258, y: 546, w: 330, cls: 'side', maxH: 346 }; // right of the number map
+const TOPR = { x: 960, y: 70, w: 624, cls: 'side', maxH: 470 }; // top right, above the number line
+const SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen' };
+const SORT_SCREEN = { x: 0, y: 0, w: 1600, cls: 'screen sort' };
+const $m = (...parts) => ({ m: parts });
+
+function mk(tag, attrs = {}, parent) {
+ const e = document.createElementNS(NS, tag);
+ for (const k in attrs) e.setAttribute(k, attrs[k]);
+ if (parent) parent.appendChild(e);
+ return e;
+}
+// Every animated element keeps a small state object; render() writes it to the DOM.
+// Keys: x y s r o (transform/opacity), d (0..1 stroke drawn), a_<attr> numeric attr, c_<attr> hex colour.
+function st(e) { return e._st || (e._st = { x: 0, y: 0, s: 1, r: 0, o: 1 }); }
+function put(e, o) { Object.assign(st(e), o); render(e); return e; }
+// Unchanged transform/opacity are not rewritten: per-frame updates of still elements cost repaints (notably in Firefox).
+function render(e) {
+ const s = e._st, tf = s.x || s.y || s.s !== 1 || s.r ? `translate(${s.x},${s.y}) rotate(${s.r}) scale(${s.s})` : null;
+ if (tf !== e._tf) { if (tf) e.setAttribute('transform', tf); else e.removeAttribute('transform'); e._tf = tf; }
+ if (s.o !== e._o) { e.setAttribute('opacity', s.o); e._o = s.o; }
+ if (s.d !== undefined) {
+ e.setAttribute('stroke-dashoffset', 1 - s.d);
+ e.style.visibility = s.d < .002 ? 'hidden' : '';
+ }
+ for (const k in s) {
+ if (k.startsWith('a_')) e.setAttribute(k.slice(2), s[k]);
+ else if (k.startsWith('c_')) e.setAttribute(k.slice(2), s[k]);
+ }
+}
+function G(parent, o = {}) { return put(mk('g', {}, parent), o); }
+function path(parent, d, attrs = {}, o = {}) {
+ const p = mk('path', { d, fill: 'none', 'stroke-linecap': 'round', 'stroke-linejoin': 'round', ...attrs }, parent);
+ if (o.d !== undefined) { p.setAttribute('pathLength', 1); p.setAttribute('stroke-dasharray', '1 1'); }
+ return put(p, o);
+}
+function T(parent, str, { x = 0, y = 0, size = 30, fill = COL.chalk, font = UI, weight = 500, anchor = 'start', o = 1 } = {}) {
+ const t = mk('text', { 'font-size': size, fill, 'font-family': font, 'font-weight': weight, 'text-anchor': anchor }, parent);
+ t.textContent = str;
+ t.style.whiteSpace = 'pre';
+ return put(t, { x, y, o });
+}
+const ctx2d = document.createElement('canvas').getContext('2d');
+function textW(str, size, italic = false) { ctx2d.font = `${italic ? 'italic ' : ''}${size}px ${MATH}`; return ctx2d.measureText(str).width; }
+const VAR = /(?<![A-Za-z°])(?:(?!(?:of|in|is|to|or|at|on|by|as|an|if|it|be|no|so|up|we|my)(?![A-Za-z]))[a-z]{1,2}|(?!(?:If|In|It|Is|On|At|No|So|Or|An|As|To|By|Up)(?![A-Za-z]))[a-z]?[A-Z]{1,3}[a-z]?)(?![A-Za-z])/g; // capitals: A, PV, nRT // short lowercase runs are variables (a, x, ab), except short English words
+const F = (n, d) => ({ f: [String(n), String(d)] }); // fraction
+const R = (x, i) => ({ r: x && x.f ? x : String(x), i: i && String(i) }); // root of a number or of F(n, d); i = index, e.g. 3 for a cube root
+const E = x => ({ sup: String(x) }); // exponent, raised after the part before it
+const TX = tex => ({ tex: String(tex) }); // LaTeX, drawn by MathJax; the book loads lib/mathjax.js right after this file
+const $tex = tex => $m(TX(tex)); // LaTeX inline in HTML text
+// MathJax takes this object as its configuration when lib/mathjax.js loads after the engine.
+window.MathJax ??= {
+ startup: { typeset: false }, // no page scan; formulas are converted on demand
+ svg: { fontCache: 'none', mtextInheritFont: true }, // self-contained paths; \text{} in the book's math font
+ tex: { packages: { '[-]': ['noerrors', 'noundefined'] }, // a typo stops the page, like a misspelt mark
+ formatError: (_, error) => { throw error; } },
+ options: { enableMenu: false },
+};
+const TEX_CACHE = new Map(); // TeX source -> { graphic, viewBox }; seek() redraws every earlier beat
+// A copy of the formula's MathJax drawing: units of 1/1000 em, baseline at y = 0; viewBox is [x, y, width, height].
+function texGraphic(tex) {
+ let drawn = TEX_CACHE.get(tex);
+ if (!drawn) {
+ if (!window.MathJax?.tex2svg) throw new Error(`TX('${tex}') needs lib/mathjax.js: load ../lib/mathjax.js right after engine.js`);
+ if (!document.getElementById('MJX-SVG-styles')) document.head.append(MathJax.svgStylesheet()); // draws table rules and frames
+ let svg;
+ try { svg = MathJax.tex2svg(tex, { display: false, family: MATH }).querySelector('svg'); } // family: \text{} is measured in the font it is drawn in
+ catch (error) { throw new Error(`TX('${tex}'): ${error.message}`); }
+ const graphic = mk('g');
+ graphic.append(...svg.childNodes);
+ drawn = { graphic, viewBox: svg.getAttribute('viewBox').split(' ').map(Number) };
+ TEX_CACHE.set(tex, drawn);
+ }
+ return { graphic: drawn.graphic.cloneNode(true), viewBox: drawn.viewBox };
+}
+// The part of a TeX formula marked \class{name}{...}, ready for tw/fx on c_color and o.
+// MathJax places the part with its own transform, so the tweens act on a group inside it.
+function texPart(el, name) {
+ const part = el.querySelector(`g.${CSS.escape(name)}`);
+ if (!part) throw new Error(`texPart: no \\class{${name}}{…} in this formula`);
+ if (!part._tweenGroup) {
+ const group = mk('g');
+ group.append(...part.childNodes);
+ part.append(group);
+ const color = part.closest('[color]')?.getAttribute('color'); // the formula's fill
+ put(group, /^#[\da-f]{6}$/i.test(color) ? { c_color: color } : {});
+ part._tweenGroup = group;
+ }
+ return part._tweenGroup;
+}
+const OV = x => ({ ov: String(x) }); // digits under a repeat bar: ['0.', OV('3')] is 0.333…
+// Math expression from parts: 'text' | F(n,d) | R(x) | E(exp) | OV(digits) | TX(tex). Baseline at y; anchor start/middle/end.
+// _ascent and _descent are the TeX parts' height above and below the baseline (0 without TX).
+function M(parent, parts, { x = 0, y = 0, size = 36, fill = COL.chalk, anchor = 'middle', o = 1, s = 1 } = {}) {
+ const g = G(parent, { x, y, o, s });
+ const inner = mk('g', {}, g);
+ const lw = size * .05;
+ const text = (str, tx, ty, sz) => {
+ const t = mk('text', { x: tx, y: ty, 'font-size': sz, 'font-family': MATH, fill }, inner);
+ t.style.whiteSpace = 'pre';
+ let w = 0, last = 0;
+ const run = (piece, italic) => {
+ if (!piece) return;
+ mk('tspan', italic ? { 'font-style': 'italic' } : {}, t).textContent = piece;
+ w += textW(piece, sz, italic);
+ };
+ for (const m of str.matchAll(VAR)) { run(str.slice(last, m.index), false); run(m[0], true); last = m.index + m[0].length; }
+ run(str.slice(last), false);
+ return w;
+ };
+ const rule = (x1, x2, yy) => mk('path', { d: `M${x1} ${yy}H${x2}`, stroke: fill, 'stroke-width': lw, 'stroke-linecap': 'round' }, inner);
+ let cx = 0, ascent = 0, descent = 0;
+ for (const p of parts) {
+ if (typeof p === 'string') cx += text(p, cx, 0, size);
+ else if (p.tex !== undefined) {
+ const { graphic, viewBox: [, top, w, h] } = texGraphic(p.tex), k = size / 1000; // 1000 units = 1 em = size
+ graphic.setAttribute('transform', `translate(${cx},0) scale(${k})`);
+ graphic.setAttribute('color', fill); // MathJax paints with currentColor
+ inner.append(graphic);
+ ascent = Math.max(ascent, -top * k);
+ descent = Math.max(descent, (top + h) * k);
+ cx += w * k;
+ } else if (p.f) {
+ const fs = size * .72, [n, d] = p.f, wn = textW(n, fs), wd = textW(d, fs);
+ const w = Math.max(wn, wd) + size * .2, bar = -size * .3;
+ text(n, cx + (w - wn) / 2, bar - size * .12, fs);
+ text(d, cx + (w - wd) / 2, bar + size * .62, fs);
+ rule(cx + size * .04, cx + w - size * .04, bar);
+ cx += w + size * .04;
+ } else if (p.r) {
+ const fr = typeof p.r === 'object', mid = fr ? -size * .12 : -size * .3, bot = fr ? size * .45 : size * .06, top = fr ? -size * 1.12 : -size * .82;
+ let x0 = cx + size * .04;
+ if (p.i) { const iw = textW(p.i, size * .42); text(p.i, x0, mid - size * .14, size * .42); x0 += Math.max(0, iw - size * .12); } // index in the radical's crook
+ let w;
+ if (fr) { // a fraction under the radical, laid out like F()
+ const fs = size * .72, [n, d] = p.r.f, wn = textW(n, fs), wd = textW(d, fs), bx = x0 + size * .56, bar = -size * .3;
+ w = Math.max(wn, wd) + size * .2;
+ text(n, bx + (w - wn) / 2, bar - size * .12, fs);
+ text(d, bx + (w - wd) / 2, bar + size * .62, fs);
+ mk('path', { d: `M${bx + size * .04} ${bar}H${bx + w - size * .04}`, stroke: fill, 'stroke-width': lw, 'stroke-linecap': 'round' }, inner);
+ } else { w = textW(p.r, size); text(p.r, x0 + size * .56, 0, size); }
+ mk('path', { d: `M${x0} ${mid}L${x0 + size * .1} ${mid - size * .06}L${x0 + size * .27} ${bot}L${x0 + size * .45} ${top}H${x0 + size * .56 + w + size * .06}`,
+ fill: 'none', stroke: fill, 'stroke-width': lw, 'stroke-linejoin': 'round', 'stroke-linecap': 'round' }, inner);
+ cx = x0 + size * .56 + w + size * .1;
+ } else if (p.sup !== undefined) {
+ cx += text(p.sup, cx + size * .03, -size * .45, size * .62) + size * .06;
+ } else if (p.ov !== undefined) {
+ const w = text(p.ov, cx, 0, size);
+ rule(cx + size * .04, cx + w - size * .02, -size * .8);
+ cx += w;
+ }
+ }
+ const dx = anchor === 'middle' ? -cx / 2 : anchor === 'end' ? -cx : 0;
+ inner.setAttribute('transform', `translate(${dx},0)`);
+ g._w = cx;
+ g._ascent = ascent;
+ g._descent = descent;
+ return g;
+}
+// Pill-shaped number token, centred on (x, y).
+function chip(parent, parts, color, { x = 0, y = 0, o = 1, s = 1, size = 34 } = {}) {
+ const g = G(parent, { x, y, o, s });
+ const rect = mk('rect', {}, g);
+ const m = M(g, parts, { size, y: size * .3 });
+ const w = Math.max(m._w + 36, 64);
+ let h = size * (parts.some(p => p.f) ? 1.75 : 1.45);
+ if (m._ascent) { // a TeX formula: centre it and grow the pill to fit
+ const above = Math.max(size * 1.05, m._ascent), below = Math.max(size * .45, m._descent);
+ put(m, { y: (above - below) / 2 });
+ h = Math.max(h, m._ascent + m._descent + size * .4);
+ }
+ for (const [k, v] of Object.entries({ x: -w / 2, y: -h / 2, width: w, height: h, rx: h / 2, fill: COL.board, stroke: color, 'stroke-width': 2.5 })) rect.setAttribute(k, v);
+ g._rect = rect;
+ return g;
+}
+// A row of math tokens laid out left to right. Items: string | parts array | { t, fill }.
+// Each token is centred on its own x, so it can move alone (swaps, sliding parentheses). Spacing comes from the strings.
+function tokens(parent, items, { x = 0, y = 0, size = 44, fill = COL.chalk, anchor = 'start', o = 1 } = {}) {
+ const els = items.map(it => {
+ const spec = it && it.t !== undefined ? it : { t: it };
+ return M(parent, [].concat(spec.t), { size, fill: spec.fill || fill, o });
+ });
+ return layRow(els, { x, y, size, anchor }, e => put(e, { x: e._px, y }));
+}
+// Place a row's tokens side by side. Each token keeps its planned centre in _px, so later steps
+// can be planned before earlier tweens have run.
+function layRow(els, { x, y, size, anchor }, move) {
+ const total = els.reduce((a, e) => a + e._w, 0);
+ let cx = anchor === 'middle' ? x - total / 2 : anchor === 'end' ? x - total : x;
+ for (const e of els) { e._px = cx + e._w / 2; move(e); cx += e._w; }
+ return Object.assign(els, { w: total, x, y, size, anchor });
+}
+// One simplification step: box tokens i..j, shrink them into a single result token, then close the gap.
+// Returns the new row. live = true runs on the question clock (inside ask) instead of the lesson clock.
+function collapse(row, i, j, parts, t0, { color = COL.task, fill = COL.chalk, live = false } = {}) {
+ const run = live ? fx : tw, p = row[0].parentNode, { size, y } = row;
+ const left = row[i]._px - row[i]._w / 2, right = row[j]._px + row[j]._w / 2;
+ let above = size * .95, height = size * 1.3;
+ const tall = row.slice(i, j + 1).filter(e => e._ascent); // TeX tokens may reach higher and lower than text
+ if (tall.length) {
+ above = Math.max(above, ...tall.map(e => e._ascent + 8));
+ height = above + Math.max(size * .35, ...tall.map(e => e._descent + 8));
+ }
+ const box = put(mk('rect', { rx: 10, fill: 'none', stroke: color, 'stroke-width': 3 }, p),
+ { o: 0, a_x: left - 8, a_y: y - above, a_width: right - left + 16, a_height: height });
+ run(box, { o: 1 }, t0, .3);
+ run(box, { o: 0 }, t0 + 1.2, .3);
+ const res = M(p, parts, { size, fill, o: 0, x: (left + right) / 2, y });
+ for (let k = i; k <= j; k++) run(row[k], { o: 0, s: .6 }, t0 + .8, .35);
+ run(res, { o: 1 }, t0 + .95, .35);
+ const next = [...row.slice(0, i), res, ...row.slice(j + 1)];
+ return layRow(next, row, e => run(e, { x: e._px }, t0 + 1.3, .5));
+}
+// Vertical number line at x; Yf maps a value to its y. Labels sit on the left.
+function vAxis(p, { x, Yf, lo, hi, step = 1, t0 = .1, unit = '' }) {
+ draw(path(p, `M${x} ${Yf(lo - .5)}V${Yf(hi + .5)}`, { stroke: COL.chalk, 'stroke-width': 3 }, { d: 0 }), t0, .8);
+ for (let v = lo; v <= hi; v += step) {
+ const g = G(p, { o: 0 });
+ path(g, `M${x - 9} ${Yf(v)}H${x + 9}`, { stroke: COL.dim, 'stroke-width': 2.5 });
+ T(g, num(v) + unit, { x: x - 46, y: Yf(v) + 9, size: 24, fill: v === 0 ? COL.chalk : COL.dim, font: MATH, anchor: 'end' });
+ show(g, t0 + .2 + Math.abs(v - lo) * .02);
+ }
+}
+// Thermometer from lo (bottom) to hi (top). set(v, t0, run) moves the column; run = tw (lesson) or fx (answer).
+function thermometer(p, { x = 800, bottom = 600, top = 200, lo = -10, hi = 15, step = 5, value = 0, color = COL.nat } = {}) {
+ const Yt = v => bottom - (v - lo) / (hi - lo) * (bottom - top), bulb = bottom + 32, g = G(p);
+ mk('rect', { x: x - 18, y: top - 24, width: 36, height: bulb - top + 24, rx: 18, fill: COL.board, stroke: COL.dim, 'stroke-width': 2.5 }, g);
+ mk('circle', { cx: x, cy: bulb, r: 26, fill: color }, g);
+ const merc = put(mk('rect', { x: x - 9, width: 18, rx: 9, fill: color }, g), { a_y: Yt(value), a_height: bulb - Yt(value) });
+ for (let v = lo; v <= hi; v += step) {
+ path(g, `M${x - 30} ${Yt(v)}H${x - 18}`, { stroke: COL.dim, 'stroke-width': 2 });
+ T(g, `${num(v)}°`, { x: x - 40, y: Yt(v) + 9, size: 24, fill: v === 0 ? COL.chalk : COL.dim, font: MATH, anchor: 'end' });
+ }
+ return { g, merc, Yt, set: (v, t0, run = tw, dur = 1.2) => run(merc, { a_y: Yt(v), a_height: bulb - Yt(v) }, t0, dur) };
+}
+/* ---------- fractions: rows with strikable parts, bars and brackets ---------- */
+// A row of fractions and symbols whose numerators and denominators can be struck out one by one.
+// items: { f: [n, d], fill } | 'symbol text'. The fraction bars sit on y.
+function fracRow(p, items, { x = 800, y = 300, size = 60, anchor = 'middle', o = 0 } = {}) {
+ const fs = size * .8, g = G(p, { o });
+ const els = items.map(it => {
+ if (typeof it === 'string') {
+ const w = textW(it, size);
+ return { w, draw(cx) { this.cx = cx; T(g, it, { x: cx, y: y + size * .33, size, font: MATH, fill: COL.chalk, anchor: 'middle' }); } };
+ }
+ const [n, d] = it.f.map(String), w = Math.max(textW(n, fs), textW(d, fs)) + size * .35, fill = it.fill || COL.chalk;
+ return { w, n, d, draw(cx) {
+ this.cx = cx;
+ path(g, `M${cx - w / 2 + 4} ${y}H${cx + w / 2 - 4}`, { stroke: fill, 'stroke-width': size * .055 });
+ this.num = T(g, n, { x: cx, y: y - size * .18, size: fs, font: MATH, fill, anchor: 'middle' });
+ this.den = T(g, d, { x: cx, y: y + size * .78, size: fs, font: MATH, fill, anchor: 'middle' });
+ } };
+ });
+ const total = els.reduce((a, e) => a + e.w, 0);
+ let cx = anchor === 'middle' ? x - total / 2 : x;
+ for (const e of els) { e.draw(cx + e.w / 2); cx += e.w; }
+ return Object.assign(els, { g, y, size, x0: anchor === 'middle' ? x - total / 2 : x, w: total });
+}
+// Strike the numerator ('num') or denominator ('den') of fraction k and write its reduced value beside it.
+function reduce(row, k, part, value, color, t0, run = tw) {
+ const e = row[k], { y, size } = row, top = part === 'num';
+ const cy = top ? y - size * .42 : y + size * .52, g = row.g;
+ const slash = path(g, `M${e.cx - size * .28} ${cy + size * .3}L${e.cx + size * .28} ${cy - size * .3}`, { stroke: color, 'stroke-width': 3.5 }, { d: 0 });
+ const nv = T(g, String(value), { x: e.cx + size * .02, y: top ? y - size * .92 : y + size * 1.36, size: size * .5, font: MATH, fill: color, anchor: 'middle', o: 0 });
+ run(slash, { d: 1 }, t0, .4); run(nv, { o: 1 }, t0 + .3, .4);
+ run(e[part], { o: .45 }, t0 + .3, .4);
+}
+function rect(p, x, y, w, h, fill, o = 0, stroke = 'none') {
+ return put(mk('rect', { x, y, width: w, height: h, fill, stroke, 'stroke-width': 2.5 }, p), { o });
+}
+function bracketH(p, x1, x2, y, label, color, t0) {
+ draw(path(p, `M${x1} ${y - 10}V${y}H${x2}V${y - 10}`, { stroke: color, 'stroke-width': 3 }, { d: 0 }), t0, .5);
+ show(T(p, label, { x: (x1 + x2) / 2, y: y + 32, size: 26, fill: color, font: MATH, anchor: 'middle', o: 0 }), t0 + .3);
+}
+
+/* ---------- decimal point that hops between digits (ch10, ch20) ---------- */
+// Digits in evenly spaced slots with a decimal point that can hop between them.
+// places = digits after the point (0 = point at the far right, hidden).
+function pointRow(p, digits, x, y, places, { size = 72, fill = COL.chalk, sign = '' } = {}) {
+ const g = G(p, { o: 0 }), w = size * .7, n = digits.length, x0 = x - n * w / 2;
+ if (sign) T(g, sign, { x: x0 - w * .6, y, size, fill, font: MATH, anchor: 'middle' });
+ const ds = [...digits].map((c, i) => T(g, c, { x: x0 + i * w + w / 2, y, size, fill, font: MATH, anchor: 'middle' }));
+ const px = k => x0 + (n - k) * w;
+ const dot = mk('circle', { r: size * .065, fill: COL.task }, g);
+ put(dot, { x: px(places), y: y - size * .02, o: places ? 1 : 0 });
+ const trail = path(g, '', { stroke: COL.task, 'stroke-width': 2.5, 'stroke-dasharray': '5 6' });
+ return { g, ds, dot, px, w,
+ hop(from, to, t0, run = tw, dur = .55) {
+ const steps = Math.abs(to - from);
+ run(dot, { o: 1 }, t0, .2);
+ let d = '';
+ for (let k = 0; k < steps; k++) {
+ const a = px(from + Math.sign(to - from) * k), b = px(from + Math.sign(to - from) * (k + 1));
+ d += `M${a} ${y - 10}Q${(a + b) / 2} ${y - size * .9} ${b} ${y - 10}`;
+ }
+ trail.setAttribute('d', d);
+ put(trail, { o: 0 }); run(trail, { o: .9 }, t0 + steps * dur, .3);
+ (run === tw ? prog : fxp)(q => {
+ const s = q * steps, k = Math.min(steps - 1, Math.floor(s)), f = s - k;
+ const a = px(from + Math.sign(to - from) * k), b = px(from + Math.sign(to - from) * (k + 1));
+ put(dot, { x: a + (b - a) * f, y: y - size * .02 - Math.sin(Math.PI * f) * size * .7 });
+ }, t0, steps * dur, lin);
+ } };
+}
+
+/* ---------- balance scale for equations (ch24, ch25) ---------- */
+// A balance scale. Its pans hang from the beam ends; tilt(deg, t0) rocks it (positive: left side down).
+function balance(p, { x = 800, y = 330, L = 300 } = {}) {
+ const g = G(p, { o: 0 });
+ path(g, `M${x} ${y}L${x - 50} ${y + 330}H${x + 50}Z`, { stroke: COL.dim, 'stroke-width': 3, fill: mix(COL.board, COL.dim, .15) });
+ const beam = G(g, { x, y });
+ path(beam, `M${-L} 0H${L}`, { stroke: COL.chalk, 'stroke-width': 6 });
+ mk('circle', { r: 10, fill: COL.chalk }, beam);
+ const pan = side => {
+ const pg = G(g, { x: x + side * L, y });
+ path(pg, 'M0 0L-90 110M0 0L90 110', { stroke: COL.dim, 'stroke-width': 2 });
+ path(pg, 'M-110 110Q0 150 110 110Z', { stroke: side < 0 ? COL.whole : COL.nat, 'stroke-width': 3, fill: mix(COL.board, side < 0 ? COL.whole : COL.nat, .2) });
+ return pg;
+ };
+ const Lp = pan(-1), Rp = pan(1);
+ let angle = 0;
+ const place = a => {
+ const r = a * Math.PI / 180, dx = L * Math.cos(r), dy = L * Math.sin(r);
+ put(beam, { r: -a }); put(Lp, { x: x - dx, y: y + dy }); put(Rp, { x: x + dx, y: y - dy });
+ };
+ return {
+ g, L: Lp, R: Rp,
+ // Content sits on a pan: text or math at (0, 90) in pan coordinates.
+ load(side, parts, color, t0, size = 44) { const e = M(side < 0 ? Lp : Rp, parts, { y: 96, size, fill: color, o: 0 }); show(e, t0); return e; },
+ tilt(a, t0, run = prog) { const from = angle; angle = a; run(q => place(from + (a - from) * back(q)), t0, .9); },
+ };
+}
+/* ---------- algebra tiles (ch23, ch25) ---------- */
+const XL = 120, UN = 30; // length of x, size of 1
+const TS = { x2: [XL, XL, COL.real], x: [UN, XL, COL.whole], y: [UN, 90, COL.nat], one: [UN, UN, COL.int] };
+function atile(p, kind, x, y, neg = false, o = 0) {
+ const [w, h, c] = TS[kind], g = G(p, { x, y, o, s: o ? 1 : .6 });
+ mk('rect', { x: -w / 2, y: -h / 2, width: w, height: h, rx: 5, fill: neg ? COL.board : mix(COL.board, c, .55), stroke: neg ? COL.bad : c, 'stroke-width': neg ? 3.5 : 2.5, 'stroke-dasharray': neg ? '7 5' : '' }, g);
+ g.kind = kind; g.neg = neg;
+ return g;
+}
+const popIn = (els, t0, step = .08) => els.forEach((e, i) => tw(e, { o: 1, s: 1 }, t0 + i * step, .35, back));
+// n tiles of a kind in a row starting at x.
+const tileRow = (p, kind, n, x, y, neg = false, gap = 12) => Array.from({ length: n }, (_, i) => atile(p, kind, x + i * (TS[kind][0] + gap), y, neg));
+// Pair each negative tile with a positive one: they move together and vanish.
+function cancel(pos, negs, t0) {
+ negs.forEach((n, i) => {
+ const a = pos[i];
+ tw(n, { x: st(a).x, y: st(a).y }, t0 + i * .3, .6);
+ tw(n, { o: 0, s: .5 }, t0 + i * .3 + .7, .3); tw(a, { o: 0, s: .5 }, t0 + i * .3 + .7, .3);
+ });
+}
+/* ---------- inequality graphs (ch26, ch27) ---------- */
+// Solution ray on the number line: endpoint v, closed or open circle, dir +1 (right) or −1 (left).
+function ray(p, v, closed, dir, t0, color = COL.task, run = tw) {
+ const end = X(dir > 0 ? 5.7 : -5.7), g = G(p, { o: 1 });
+ const line = path(g, `M${X(v)} ${Y0}H${end}`, { stroke: color, 'stroke-width': 7 }, { d: 0 });
+ const head = path(g, `M${end - 18 * dir} ${Y0 - 13}L${end} ${Y0}L${end - 18 * dir} ${Y0 + 13}`, { stroke: color, 'stroke-width': 6 }, { o: 0 });
+ const dot = G(g, { x: X(v), y: Y0, s: 0, o: 0 });
+ mk('circle', { r: 13, fill: closed ? color : COL.board, stroke: color, 'stroke-width': 4 }, dot);
+ run(dot, { s: 1, o: 1 }, t0, .4, back);
+ run(line, { d: 1 }, t0 + .3, .8); run(head, { o: 1 }, t0 + 1, .2);
+ return g;
+}
+// Segment between a and b on the number line, each end open or closed.
+function segment(p, a, b, ca, cb, t0, color = COL.task, run = tw) {
+ const g = G(p, { o: 1 });
+ const line = path(g, `M${X(a)} ${Y0}H${X(b)}`, { stroke: color, 'stroke-width': 7 }, { d: 0 });
+ const ends = [[a, ca], [b, cb]].map(([v, c]) => {
+ const d = G(g, { x: X(v), y: Y0, s: 0, o: 0 });
+ mk('circle', { r: 13, fill: c ? color : COL.board, stroke: color, 'stroke-width': 4 }, d);
+ run(d, { s: 1, o: 1 }, t0, .4, back);
+ return d;
+ });
+ run(line, { d: 1 }, t0 + .3, .8);
+ g.parentNode.appendChild(g); ends.forEach(e => g.appendChild(e));
+ return g;
+}
+/* ---------- equation steps (ch25 onward) ---------- */
+// One line of an equation or inequality with its sign at xEq, so a column of steps lines up. note: grey hint on the right.
+function eqLine(p, L, R, y, t0, { xEq = 760, fill = COL.chalk, size = 50, note, sym = '=', symFill, noteX = 1180 } = {}) {
+ const g = G(p, { o: 0 });
+ M(g, [].concat(L), { x: xEq - size * .6, y, size, fill, anchor: 'end' });
+ M(g, [sym], { x: xEq, y, size, fill: symFill || fill });
+ M(g, [].concat(R), { x: xEq + size * .6, y, size, fill, anchor: 'start' });
+ if (note) T(g, note, { x: noteX, y: y - 8, size: 26, fill: COL.task, weight: 600 });
+ show(g, t0);
+ return g;
+}
+/* ---------- data on a number line: dot plots (unit 7) ---------- */
+// Axis for data from lo to hi drawn between x0 and x1 at baseline y; every: label every n-th tick.
+// shape 'x' draws line-plot crosses instead of dots.
+// Returns D: D.V(value) -> x; D.dot(v, color, t0) stacks a dot above v; D.mark(v, color, t0, label) is a
+// balance triangle under the axis that can slide with D.slide(mark, v, t0).
+function dataLine(p, { lo, hi, x0 = 200, x1 = 1400, y = 600, step = 1, every = 1, t0 = .1, r = 13, size = 22, shape = 'dot' }) {
+ const V = v => x0 + (v - lo) / (hi - lo) * (x1 - x0), g = G(p, { o: 0 });
+ path(g, `M${x0 - 24} ${y}H${x1 + 24}`, { stroke: COL.dim, 'stroke-width': 3 });
+ for (let v = lo, i = 0; v <= hi + 1e-9; v += step, i++) {
+ path(g, `M${V(v)} ${y - 7}V${y + 7}`, { stroke: COL.dim, 'stroke-width': 2 });
+ if (i % every === 0) T(g, num(+v.toFixed(6)), { x: V(v), y: y + 26 + size, size, fill: COL.dim, font: MATH, anchor: 'middle' });
+ }
+ show(g, t0);
+ const D = {
+ g, V, y, r, count: {},
+ top: v => y - 6 - r - ((D.count[v] || 1) - 1) * (2 * r + 5),
+ dot(v, color, t0, { run = tw, into = p, from } = {}) {
+ D.count[v] = (D.count[v] || 0) + 1;
+ let d;
+ if (shape === 'x') { d = G(into); path(d, `M${-r * .75} ${-r * .75}L${r * .75} ${r * .75}M${r * .75} ${-r * .75}L${-r * .75} ${r * .75}`, { stroke: color, 'stroke-width': 5 }); }
+ else d = mk('circle', { r, fill: color, stroke: COL.board, 'stroke-width': 2 }, into);
+ put(d, { x: V(v), y: D.top(v), s: 0, o: 0 });
+ if (from !== undefined) { put(d, { y: from, s: 1 }); run(d, { o: 1 }, t0, .2); run(d, { y: D.top(v) }, t0, .7, back); }
+ else run(d, { s: 1, o: 1 }, t0, .45, back);
+ return d;
+ },
+ dots: (vals, color, t0, gap = .15, opts) => vals.map((v, i) => D.dot(v, color, t0 + i * gap, opts)),
+ mark(v, color, t0, label, { run = tw, into = p } = {}) {
+ const m = G(into, { x: V(v), y, o: 0 });
+ path(m, 'M0 4L-17 30H17Z', { fill: color, stroke: COL.board, 'stroke-width': 2 });
+ if (label) T(m, label, { y: 64 + size, size: 24, fill: color, weight: 600, anchor: 'middle' });
+ run(m, { o: 1 }, t0, .4);
+ return m;
+ },
+ slide: (m, v, t0, run = tw, dur = 1.2) => run(m, { x: V(v) }, t0, dur),
+ // Bracket above the data from a to b at height yb, with a label.
+ span(a, b, yb, label, color, t0, { run = tw, into = p } = {}) {
+ const g = G(into), l = path(g, `M${V(a)} ${yb + 12}V${yb}H${V(b)}V${yb + 12}`, { stroke: color, 'stroke-width': 3 }, { d: 0 });
+ run(l, { d: 1 }, t0, .6);
+ const t = M(g, [label], { x: (V(a) + V(b)) / 2, y: yb - 14, size: 28, fill: color, o: 0 });
+ run(t, { o: 1 }, t0 + .4, .4);
+ return g;
+ },
+ };
+ return D;
+}
+/* ---------- chance: number cubes, coins, spinners (unit 7) ---------- */
+// A number cube face showing n pips, centred on (x, y).
+const PIPS = { 1: [[0, 0]], 2: [[-1, -1], [1, 1]], 3: [[-1, -1], [0, 0], [1, 1]], 4: [[-1, -1], [1, -1], [-1, 1], [1, 1]],
+ 5: [[-1, -1], [1, -1], [0, 0], [-1, 1], [1, 1]], 6: [[-1, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [1, 1]] };
+function die(p, n, x, y, s = 96, o = 0) {
+ const g = G(p, { x, y, o, s: o ? 1 : .6 });
+ g._box = mk('rect', { x: -s / 2, y: -s / 2, width: s, height: s, rx: s * .18, fill: mix(COL.board, COL.chalk, .1), stroke: COL.chalk, 'stroke-width': 3 }, g);
+ PIPS[n].forEach(([a, b]) => mk('circle', { cx: a * s * .26, cy: b * s * .26, r: s * .085, fill: COL.chalk }, g));
+ return g;
+}
+// Spinner with equal sections; pointer starts straight up. land(k) is the rotation that points at section k.
+const SPIN = [COL.whole, COL.nat, COL.int, COL.whole, COL.irr, COL.nat, COL.whole, COL.int];
+function spinner(p, cx, cy, r, t0, cols = SPIN) {
+ const g = G(p, { x: cx, y: cy, o: 0 }), n = cols.length, secs = [];
+ cols.forEach((c, i) => {
+ const a1 = (-90 + i * 360 / n) * Math.PI / 180, a2 = (-90 + (i + 1) * 360 / n) * Math.PI / 180;
+ secs.push(path(g, `M0 0L${r * Math.cos(a1)} ${r * Math.sin(a1)}A${r} ${r} 0 0 1 ${r * Math.cos(a2)} ${r * Math.sin(a2)}Z`,
+ { fill: mix(COL.board, c, .7), stroke: COL.board, 'stroke-width': 3 }));
+ });
+ mk('circle', { r, fill: 'none', stroke: COL.chalk, 'stroke-width': 3 }, g);
+ const ptr = G(g);
+ path(ptr, `M0 ${r * .12}V${-r * .78}M-14 ${-r * .66}L0 ${-r * .8}L14 ${-r * .66}`, { stroke: COL.chalk, 'stroke-width': 7 });
+ mk('circle', { r: 12, fill: COL.chalk }, g);
+ show(g, t0);
+ return { g, secs, ptr, land: k => (k + .5) * 360 / n };
+}
+// Outline some spinner sections: a bright border that fades in.
+function outline(p, sp, ks, color, t0, run = tw) {
+ return ks.map(k => { const e = sp.secs[k].cloneNode(); e.setAttribute('fill', 'none'); e.setAttribute('stroke', color); e.setAttribute('stroke-width', 7); sp.g.insertBefore(e, sp.ptr); put(e, { o: 0 }); run(e, { o: 1 }, t0, .4); return e; });
+}
+// A coin face.
+function coin(p, side, x, y, t0, r = 34, run = tw) {
+ const g = G(p, { x, y, s: .5, o: 0 });
+ mk('circle', { r, fill: mix(COL.board, side === 'H' ? COL.int : COL.rat, .5), stroke: side === 'H' ? COL.int : COL.rat, 'stroke-width': 3 }, g);
+ T(g, side, { y: r * .36, size: r, fill: COL.chalk, weight: 700, anchor: 'middle' });
+ run(g, { s: 1, o: 1 }, t0, .45, back);
+ return g;
+}
+/* ---------- scaled axes for data and real-world graphs (ch41 onward) ---------- */
+// Axes with a scale on each; returns value -> pixel maps. ybreak draws a zigzag when y does not start at 0.
+function axes(p, { x0, y0, w, h, xs: [xlo, xhi, xst], ys: [ylo, yhi, yst], xl, yl, t0, ybreak }) {
+ const PX = v => x0 + (v - xlo) / (xhi - xlo) * w, PY = v => y0 - (v - ylo) / (yhi - ylo) * h, g = G(p, { o: 0 });
+ let d = '';
+ for (let v = xlo + xst; v <= xhi + 1e-9; v += xst) d += `M${PX(v)} ${y0}V${y0 - h}`;
+ for (let v = ylo + yst; v <= yhi + 1e-9; v += yst) d += `M${x0} ${PY(v)}H${x0 + w}`;
+ mk('path', { d, stroke: COL.chalk, 'stroke-opacity': .1, 'stroke-width': 1.5, fill: 'none' }, g);
+ path(g, `M${x0} ${y0 - h - 20}V${y0}H${x0 + w + 20}`, { stroke: COL.chalk, 'stroke-width': 3 });
+ if (ybreak) path(g, `M${x0 - 10} ${y0 - 22}L${x0 + 10} ${y0 - 30}M${x0 - 10} ${y0 - 34}L${x0 + 10} ${y0 - 42}`, { stroke: COL.chalk, 'stroke-width': 3 });
+ for (let v = xlo; v <= xhi + 1e-9; v += xst) T(g, String(v), { x: PX(v), y: y0 + 30, size: 20, fill: COL.dim, font: MATH, anchor: 'middle' });
+ for (let v = ylo; v <= yhi + 1e-9; v += yst) T(g, String(v), { x: x0 - 14, y: PY(v) + 7, size: 20, fill: COL.dim, font: MATH, anchor: 'end' });
+ T(g, xl, { x: x0 + w / 2, y: y0 + 66, size: 24, fill: COL.dim, anchor: 'middle' });
+ T(g, yl, { x: x0, y: y0 - h - 36, size: 24, fill: COL.dim, anchor: 'middle' });
+ show(g, t0);
+ return { PX, PY };
+}
+/* ---------- area grids for multiplying and factoring polynomials (ch51 onward) ---------- */
+// Area grid from (x0, y0): column widths ws, row heights hs, factor terms along the top and the left side.
+function areaGrid(p, x0, y0, ws, hs, colLab, rowLab, t0, { size = 40 } = {}) {
+ const xs = [x0], ys = [y0];
+ ws.forEach(w => xs.push(xs.at(-1) + w)); hs.forEach(h => ys.push(ys.at(-1) + h));
+ let d = '';
+ xs.forEach(x => { d += `M${x} ${y0}V${ys.at(-1)}`; }); ys.forEach(y => { d += `M${x0} ${y}H${xs.at(-1)}`; });
+ draw(path(p, d, { stroke: COL.chalk, 'stroke-width': 3 }, { d: 0 }), t0, .9);
+ colLab.forEach((l, j) => show(M(p, [].concat(l), { x: (xs[j] + xs[j + 1]) / 2, y: y0 - 22, size, fill: COL.whole, o: 0 }), t0 + .3 + j * .15));
+ rowLab.forEach((l, i) => show(M(p, [].concat(l), { x: x0 - 24, y: (ys[i] + ys[i + 1]) / 2 + size * .35, size, fill: COL.nat, anchor: 'end', o: 0 }), t0 + .3 + i * .15));
+ const box = (i, j, pad) => ({ x: xs[j] + pad, y: ys[i] + pad, width: xs[j + 1] - xs[j] - 2 * pad, height: ys[i + 1] - ys[i] - 2 * pad });
+ return {
+ xs, ys,
+ cell(i, j, parts, t0, { fill = COL.chalk, tint, run = tw, into = p } = {}) {
+ if (tint) { const r = put(mk('rect', { ...box(i, j, 3), fill: tint }, into), { o: 0 }); into.insertBefore(r, into.firstChild); run(r, { o: .3 }, t0, .4); }
+ const e = M(into, [].concat(parts), { x: (xs[j] + xs[j + 1]) / 2, y: (ys[i] + ys[i + 1]) / 2 + size * .35, size, fill, o: 0, s: .6 });
+ run(e, { o: 1, s: 1 }, t0, .4, back);
+ return e;
+ },
+ ring(i, j, color, t0, run = tw, into = p) { const r = put(mk('rect', { ...box(i, j, 8), rx: 12, fill: 'none', stroke: color, 'stroke-width': 4.5 }, into), { o: 0 }); run(r, { o: 1 }, t0, .3); return r; },
+ };
+}
+// A curved arrow from (x1, y1) to (x2, y2) bending up (h < 0) or down (h > 0).
+function arc(p, x1, y1, x2, y2, h, color, t0, run = tw) {
+ const mx = (x1 + x2) / 2, l = path(p, `M${x1} ${y1}Q${mx} ${y1 + h} ${x2} ${y2}`, { stroke: color, 'stroke-width': 3.5 }, { d: 0 });
+ run(l, { d: 1 }, t0, .5);
+ return l;
+}
+
+/* ---------- built-up fractions with math above and below the bar (ch60 onward) ---------- */
+// Width of math parts at a size, without leaving anything on the stage.
+function mathW(parts, size) { const e = M(scene, [].concat(parts), { size, o: 0 }), w = e._w; e.remove(); return w; }
+// A built-up fraction whose top and bottom are math parts (they may hold radicals); bar on y. Returns { g, w, t, b, x0 }.
+function frac(p, top, bot, x, y, t0, { size = 56, fill = COL.chalk, anchor = 'start', topFill, botFill } = {}) {
+ const g = G(p, { o: 0 });
+ const w = Math.max(mathW(top, size), mathW(bot, size)) + size * .3;
+ const x0 = anchor === 'middle' ? x - w / 2 : x;
+ const t = M(g, [].concat(top), { x: x0 + w / 2, y: y - size * .25, size, fill: topFill || fill });
+ const b = M(g, [].concat(bot), { x: x0 + w / 2, y: y + size * 1.05, size, fill: botFill || fill });
+ path(g, `M${x0} ${y}H${x0 + w}`, { stroke: fill, 'stroke-width': size * .05 });
+ if (t0 !== undefined) show(g, t0);
+ return { g, w, t, b, x0 };
+}
+
+/* ---------- coordinate plane (unit 6 onward) ---------- */
+// Grid centred on the origin at (cx, cy); u pixels per unit; x from x0 to x1, y from y0 to y1.
+// Returns { g, PX, PY, u, ... } with helpers to plot points, walk to a point, and draw lines.
+// The grid stays in p; marks go into P.layer (set it to the current panel so marks clear with the step) or opts.into.
+function plane(p, { cx = 800, cy = 450, u = 50, x0 = -6, x1 = 6, y0 = -6, y1 = 6, t0 = .1, labels = true, step = 1 } = {}) {
+ const PX = x => cx + x * u, PY = y => cy - y * u, g = G(p, { o: 0 });
+ let d = '';
+ for (let x = x0; x <= x1; x++) if (x) d += `M${PX(x)} ${PY(y0)}V${PY(y1)}`;
+ for (let y = y0; y <= y1; y++) if (y) d += `M${PX(x0)} ${PY(y)}H${PX(x1)}`;
+ mk('path', { d, stroke: COL.chalk, 'stroke-opacity': .1, 'stroke-width': 1.5, fill: 'none' }, g);
+ const ax = { stroke: COL.chalk, 'stroke-width': 3 };
+ path(g, `M${PX(x0 - .5)} ${cy}H${PX(x1 + .5)}M${PX(x1 + .5) - 14} ${cy - 9}L${PX(x1 + .5)} ${cy}L${PX(x1 + .5) - 14} ${cy + 9}`, ax);
+ path(g, `M${cx} ${PY(y0 - .5)}V${PY(y1 + .5)}M${cx - 9} ${PY(y1 + .5) + 14}L${cx} ${PY(y1 + .5)}L${cx + 9} ${PY(y1 + .5) + 14}`, ax);
+ T(g, 'x', { x: PX(x1 + .5) + 10, y: cy + 30, size: 28, fill: COL.dim, font: MATH, anchor: 'middle' }).setAttribute('font-style', 'italic');
+ T(g, 'y', { x: cx - 26, y: PY(y1 + .5) + 10, size: 28, fill: COL.dim, font: MATH, anchor: 'middle' }).setAttribute('font-style', 'italic');
+ if (labels) {
+ for (let x = x0; x <= x1; x += step) if (x) T(g, num(x), { x: PX(x), y: cy + 26, size: 18, fill: COL.dim, font: MATH, anchor: 'middle' });
+ for (let y = y0; y <= y1; y += step) if (y) T(g, num(y), { x: cx - 12, y: PY(y) + 6, size: 18, fill: COL.dim, font: MATH, anchor: 'end' });
+ }
+ show(g, t0, .5);
+ const P = {
+ g, PX, PY, u, cx, cy, x0, x1, y0, y1, layer: null,
+ dot(x, y, color, t0, { r = 10, label, run = tw, dx = 14, dy = -14, anchor = 'start', into = P.layer || p, open = false } = {}) {
+ const d = G(into, { x: PX(x), y: PY(y), s: 0, o: 0 });
+ mk('circle', open ? { r, fill: COL.board, stroke: color, 'stroke-width': 3.5 } : { r, fill: color, stroke: COL.board, 'stroke-width': 2 }, d);
+ run(d, { s: 1, o: 1 }, t0, .4, back);
+ if (label) { const l = M(into, [label], { x: PX(x) + dx, y: PY(y) + dy, size: 26, fill: color, anchor, o: 0 }); run(l, { o: 1 }, t0 + .2, .3); }
+ return d;
+ },
+ // Walk from the origin: along x, then along y, drawing arrows; then a dot.
+ walk(x, y, t0, { cx: colX = COL.whole, cy: colY = COL.nat, run = tw, color = COL.task, label, into = P.layer || p } = {}) {
+ const a = path(into, `M${PX(0)} ${PY(0)}H${PX(x)}`, { stroke: colX, 'stroke-width': 5 }, { d: 0 });
+ const b = path(into, `M${PX(x)} ${PY(0)}V${PY(y)}`, { stroke: colY, 'stroke-width': 5 }, { d: 0 });
+ run(a, { d: 1 }, t0, .3 + Math.abs(x) * .12, lin);
+ run(b, { d: 1 }, t0 + .4 + Math.abs(x) * .12, .3 + Math.abs(y) * .12, lin);
+ return P.dot(x, y, color, t0 + .8 + (Math.abs(x) + Math.abs(y)) * .12, { run, label, into });
+ },
+ // Arrow from (xa, ya) to (xb, yb) with an optional label beside its middle.
+ arrow(xa, ya, xb, yb, color, t0, { label, run = tw, into = P.layer || p } = {}) {
+ const a = [PX(xa), PY(ya)], b = [PX(xb), PY(yb)], L = Math.hypot(b[0] - a[0], b[1] - a[1]), ux = (b[0] - a[0]) / L, uy = (b[1] - a[1]) / L;
+ const l = path(into, `M${a[0]} ${a[1]}L${b[0]} ${b[1]}M${b[0] - 12 * ux - 8 * uy} ${b[1] - 12 * uy + 8 * ux}L${b[0]} ${b[1]}L${b[0] - 12 * ux + 8 * uy} ${b[1] - 12 * uy - 8 * ux}`, { stroke: color, 'stroke-width': 4 }, { d: 0 });
+ run(l, { d: 1 }, t0, .5);
+ if (label !== undefined) {
+ const vert = Math.abs(uy) > Math.abs(ux);
+ const t = M(into, [label], { x: (a[0] + b[0]) / 2 + (vert ? -24 : 0), y: (a[1] + b[1]) / 2 + (vert ? 9 : -12), size: 26, fill: color, anchor: vert ? 'end' : 'middle', o: 0 });
+ run(t, { o: 1 }, t0 + .3, .3);
+ }
+ return l;
+ },
+ // One slope step from (x, y): rise first (irr green), then run (real violet).
+ stair(x, y, rise, runX, t0, { run = tw, into = P.layer || p, labels = true } = {}) {
+ P.arrow(x, y, x, y + rise, COL.irr, t0, { label: labels ? num(rise) : undefined, run, into });
+ P.arrow(x, y + rise, x + runX, y + rise, COL.real, t0 + .6, { label: labels ? num(runX) : undefined, run, into });
+ },
+ // Shade the region where every a·x + b·y ≥ c in the list holds, clipped to the grid.
+ region(list, color, t0, { run = tw, into = P.layer || p, o = .22 } = {}) {
+ let pts = [[x0, y0], [x1, y0], [x1, y1], [x0, y1]];
+ for (const [a, b, c] of list) {
+ const f = ([x, y]) => a * x + b * y - c, next = [];
+ pts.forEach((v, i) => {
+ const w = pts[(i + 1) % pts.length], fv = f(v), fw = f(w);
+ if (fv >= 0) next.push(v);
+ if (fv * fw < 0) { const t = fv / (fv - fw); next.push([v[0] + t * (w[0] - v[0]), v[1] + t * (w[1] - v[1])]); }
+ });
+ pts = next;
+ }
+ const e = path(into, pts.length ? 'M' + pts.map(([x, y]) => `${PX(x)} ${PY(y)}`).join('L') + 'Z' : '', { fill: color, stroke: 'none' }, { o: 0 });
+ into.insertBefore(e, into.firstChild);
+ run(e, { o }, t0, .6);
+ return e;
+ },
+ half: (a, b, c, color, t0, opts) => P.region([[a, b, c]], color, t0, opts),
+ // Graph of y = f(x) for x from xa to xb, drawn on; the part outside the grid's y range is cut off.
+ fn(f, xa, xb, color, t0, { run = tw, w = 4, into = P.layer || p, n = 160, dur = 1.2 } = {}) {
+ let d = '', pen = false;
+ for (let i = 0; i <= n; i++) {
+ const x = xa + (xb - xa) * i / n, y = f(x), inside = y >= y0 - .5 && y <= y1 + .5;
+ if (inside) { d += `${pen ? 'L' : 'M'}${PX(x).toFixed(1)} ${PY(y).toFixed(1)}`; pen = true; } else pen = false;
+ }
+ const l = path(into, d, { stroke: color, 'stroke-width': w }, { d: 0 });
+ run(l, { d: 1 }, t0, dur);
+ return l;
+ },
+ // Line through two points, extended to the edge of the grid.
+ line(xa, ya, xb, yb, color, t0, { run = tw, w = 4, dash, into = P.layer || p } = {}) {
+ const dx = xb - xa, dy = yb - ya, ts = [];
+ const clip = (t, v, lo, hi) => { if (v >= lo - 1e-9 && v <= hi + 1e-9) ts.push(t); };
+ if (dx) { for (const X of [x0, x1]) { const t = (X - xa) / dx; clip(t, ya + t * dy, y0, y1); } }
+ if (dy) { for (const Y of [y0, y1]) { const t = (Y - ya) / dy; clip(t, xa + t * dx, x0, x1); } }
+ const t1 = Math.min(...ts), t2 = Math.max(...ts);
+ // A dashed line fades in: drawing it on would need the dash array for the reveal.
+ const l = path(into, `M${PX(xa + t1 * dx)} ${PY(ya + t1 * dy)}L${PX(xa + t2 * dx)} ${PY(ya + t2 * dy)}`, { stroke: color, 'stroke-width': w, ...(dash ? { 'stroke-dasharray': dash } : {}) }, dash ? { o: 0 } : { d: 0 });
+ run(l, dash ? { o: 1 } : { d: 1 }, t0, dash ? .6 : 1);
+ return l;
+ },
+ };
+ return P;
+}
+// Question: pick a grid point. ans = [x, y]; no(x, y) explains a wrong pick. Arrows move a cursor, Enter picks.
+// test(x, y), when given, accepts any point it approves; ans is then the point Show answer uses.
+const pickPoint = (P, ans, yes, no, onRight, test) => (body, api) => {
+ const L = qlayer();
+ let cur = [0, 0], locked = false;
+ const cursor = G(L, { x: P.PX(0), y: P.PY(0) });
+ mk('circle', { r: 16, fill: 'none', stroke: COL.task, 'stroke-width': 3 }, cursor);
+ let tag = null;
+ const moveTo = (x, y) => {
+ cur = [Math.max(P.x0, Math.min(P.x1, x)), Math.max(P.y0, Math.min(P.y1, y))];
+ put(cursor, { x: P.PX(cur[0]), y: P.PY(cur[1]) });
+ tag?.remove();
+ tag = M(L, [`(${num(cur[0])}, ${num(cur[1])})`], { x: P.PX(cur[0]) + 22, y: P.PY(cur[1]) - 18, size: 24, fill: COL.task, anchor: 'start' });
+ };
+ moveTo(0, 0);
+ const pick = () => {
+ if (locked) return;
+ const [x, y] = cur;
+ if (test ? test(x, y) : x === ans[0] && y === ans[1]) { P.dot(x, y, COL.good, 0, { run: fx, into: L }); onRight?.(); api.grade(true, typeof yes === 'function' ? yes(x, y) : yes); }
+ else { const d = P.dot(x, y, COL.bad, 0, { run: fx, r: 8, into: L }); fx(d, { o: 0 }, 1.2, .4); shakeFx(cursor); api.grade(false, no(x, y)); }
+ };
+ const hit = mk('rect', { x: P.PX(P.x0 - .5), y: P.PY(P.y1 + .5), width: (P.x1 - P.x0 + 1) * P.u, height: (P.y1 - P.y0 + 1) * P.u, fill: 'transparent' }, L);
+ L.insertBefore(hit, L.firstChild);
+ hit.style.cursor = 'crosshair';
+ hit.addEventListener('click', e => {
+ if (locked) return;
+ const s = $('stage'), pt = s.createSVGPoint(); pt.x = e.clientX; pt.y = e.clientY;
+ const q = pt.matrixTransform(s.getScreenCTM().inverse());
+ moveTo(Math.round((q.x - P.cx) / P.u), Math.round((P.cy - q.y) / P.u));
+ pick();
+ });
+ return {
+ reveal() { moveTo(...ans); P.dot(ans[0], ans[1], COL.good, 0, { run: fx, into: L }); onRight?.(); return typeof yes === 'function' ? yes(...ans) : yes; },
+ lock() { locked = true; },
+ hint: [kbd('←'), kbd('↑'), kbd('↓'), kbd('→'), translate('hintMove'), kbd('Enter'), translate('hintChooseOrClickGrid')],
+ key(e) {
+ if (locked) return false;
+ const d = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] }[e.key];
+ if (d) { moveTo(cur[0] + d[0], cur[1] + d[1]); return true; }
+ if (e.key === 'Enter') { pick(); return true; }
+ return false;
+ },
+ };
+};
+/* ---------- signed numbers: number-line moves and plus/minus tiles ---------- */
+const POS = COL.whole, NEG = COL.nat; // positive: blue, negative: coral
+// Integer number line from lo to hi with arrows at both ends, drawn into S.line.
+function numberLine(t0 = .1, lo = -8, hi = 8) {
+ const L = S.line;
+ draw(path(L, `M${X(lo - .7)} ${Y0}H${X(hi + .7)}`, { stroke: COL.chalk, 'stroke-width': 3 }, { d: 0 }), t0, .8);
+ for (const [x, d] of [[X(hi + .7), 1], [X(lo - .7), -1]]) {
+ show(path(L, `M${x - 15 * d} ${Y0 - 10}L${x} ${Y0}L${x - 15 * d} ${Y0 + 10}`, { stroke: COL.chalk, 'stroke-width': 3 }, { o: 0 }), t0 + .7, .3);
+ }
+ for (let v = lo; v <= hi; v++) show(tick(v), t0 + .2 + Math.abs(v) * .04, .4);
+}
+// A move along the number line from a to b, drawn as an arrow at height y. run = tw (lesson) or fx (answer).
+function move(p, a, b, y, t0, run = tw) {
+ const x1 = X(a), x2 = X(b), d = Math.sign(b - a), color = d > 0 ? POS : NEG;
+ const dur = .35 + Math.abs(b - a) * .09;
+ const line = path(p, `M${x1} ${y}H${x2}`, { stroke: color, 'stroke-width': 5 }, { d: 0 });
+ const head = path(p, `M${x2 - 15 * d} ${y - 11}L${x2} ${y}L${x2 - 15 * d} ${y + 11}`, { stroke: color, 'stroke-width': 5 }, { o: 0 });
+ const lab = T(p, (d > 0 ? '+' : '−') + Math.abs(b - a), { x: (x1 + x2) / 2, y: y - 16, size: 28, fill: color, font: MATH, anchor: 'middle', o: 0 });
+ const drop = path(p, `M${x2} ${y + 12}V${Y0 - 14}`, { stroke: color, 'stroke-width': 2, 'stroke-dasharray': '5 6' }, { o: 0 });
+ run(line, { d: 1 }, t0, dur, lin); run(head, { o: 1 }, t0 + dur - .1, .15);
+ run(lab, { o: 1 }, t0 + .2, .3); run(drop, { o: .8 }, t0 + dur, .3);
+}
+function landDot(p, v, t0, color = COL.chalk, run = tw) {
+ const g = G(p, { x: X(v), y: Y0, s: 0, o: 0 });
+ mk('circle', { r: 12, fill: color, stroke: COL.board, 'stroke-width': 2 }, g);
+ run(g, { s: 1, o: 1 }, t0, .45, back);
+ return g;
+}
+function tile(p, sign, x, y, o = 0) {
+ const c = sign > 0 ? POS : NEG, g = G(p, { x, y, o, s: o ? 1 : .6 });
+ mk('rect', { x: -27, y: -27, width: 54, height: 54, rx: 10, fill: mix(COL.board, c, .45), stroke: c, 'stroke-width': 2.5 }, g);
+ M(g, [sign > 0 ? '+' : '−'], { y: 13, size: 40 });
+ return g;
+}
+const tiles = (p, n, sign, x0, y, gap = 70) => Array.from({ length: n }, (_, i) => tile(p, sign, x0 + i * gap, y));
+const popAll = (els, t0, step = .08) => els.forEach((e, i) => tw(e, { o: 1, s: 1 }, t0 + i * step, .35, back));
+// Circle each plus/minus pair, then let the pairs vanish: they make zero.
+function cancelPairs(p, tops, bottoms, t0) {
+ tops.forEach((a, i) => {
+ const b = bottoms[i], x = st(a).x, y1 = st(a).y, y2 = st(b).y;
+ const ring = put(mk('rect', { rx: 18, fill: 'none', stroke: COL.dim, 'stroke-width': 2.5, 'stroke-dasharray': '8 6' }, p),
+ { o: 0, a_x: x - 38, a_y: y1 - 38, a_width: 76, a_height: y2 - y1 + 76 });
+ tw(ring, { o: 1 }, t0 + i * .2, .3);
+ for (const e of [a, b, ring]) tw(e, { o: 0, ...(e === ring ? {} : { s: .5 }) }, t0 + 1.4 + i * .1, .4);
+ });
+}
+function brace(p, a, b, y, label, color, t0) {
+ const x1 = X(a), x2 = X(b);
+ draw(path(p, `M${x1} ${y - 10}V${y}H${x2}V${y - 10}`, { stroke: color, 'stroke-width': 3 }, { d: 0 }), t0, .6);
+ show(T(p, label, { x: (x1 + x2) / 2, y: y + 34, size: 26, fill: color, anchor: 'middle', o: 0 }), t0 + .4);
+}
+
+// Inline math for HTML text.
+function mathEl(parts, size = 22) {
+ const svg = mk('svg', { class: 'm', 'font-weight': 400 }); // widths are measured at normal weight, so a bold prompt must not thicken the math
+ const m = M(svg, parts, { size, anchor: 'start', fill: 'currentColor' });
+ let top = size * 1.05, bottom = size * .45, h = size * 1.5;
+ if (m._ascent) { // a TeX formula may reach higher and lower than text
+ top = Math.max(top, m._ascent + size * .1);
+ bottom = Math.max(bottom, m._descent + size * .1);
+ h = top + bottom;
+ }
+ svg.setAttribute('viewBox', `0 ${-top} ${m._w + 2} ${h}`);
+ svg.setAttribute('width', m._w + 2);
+ svg.setAttribute('height', h);
+ svg.style.verticalAlign = `${-bottom}px`; // line up the math baseline with the text baseline
+ return svg;
+}
+
+/* ---------- number map geometry ---------- */
+const RINGS = {
+ real: { cx: 640, cy: 470, rx: 610, ry: 390, lx: 640, ly: 128 },
+ rat: { cx: 500, cy: 480, rx: 400, ry: 320, lx: 500, ly: 202 },
+ int: { cx: 500, cy: 510, rx: 300, ry: 250, lx: 500, ly: 302 },
+ whole: { cx: 500, cy: 540, rx: 210, ry: 180, lx: 500, ly: 400 },
+ nat: { cx: 500, cy: 570, rx: 125, ry: 110, lx: 500, ly: 500 },
+ irr: { cx: 1060, cy: 480, rx: 140, ry: 170, lx: 1060, ly: 360 },
+};
+const CHAIN = { nat: ['nat', 'whole', 'int', 'rat', 'real'], whole: ['whole', 'int', 'rat', 'real'], int: ['int', 'rat', 'real'], rat: ['rat', 'real'], irr: ['irr', 'real'], real: ['real'] };
+const ell = r => `M${r.cx} ${r.cy - r.ry}A${r.rx} ${r.ry} 0 1 1 ${r.cx} ${r.cy + r.ry}A${r.rx} ${r.ry} 0 1 1 ${r.cx} ${r.cy - r.ry}`;
+const inRing = (k, x, y) => { const r = RINGS[k]; return ((x - r.cx) / r.rx) ** 2 + ((y - r.cy) / r.ry) ** 2 <= 1; };
+function regionAt(x, y) {
+ for (const k of ['nat', 'whole', 'int', 'rat', 'irr', 'real']) if (inRing(k, x, y)) return k;
+ return null;
+}
+function buildVenn(parent, hidden) {
+ const out = {};
+ for (const k of ['real', 'rat', 'int', 'whole', 'nat', 'irr']) {
+ const r = RINGS[k], g = G(parent);
+ const fill = path(g, ell(r), { fill: mix(COL.board, COL[k], k === 'real' ? .1 : .16), stroke: 'none' }, { o: hidden ? 0 : 1 });
+ const stroke = path(g, ell(r), { stroke: COL[k], 'stroke-width': 3 }, hidden ? { d: 0, 'a_stroke-width': 3 } : { 'a_stroke-width': 3 });
+ const lab = T(g, NAME[k], { x: r.lx, y: r.ly, size: 26, fill: COL[k], weight: 600, anchor: 'middle', o: hidden ? 0 : 1 });
+ out[k] = { g, fill, stroke, lab };
+ }
+ return out;
+}
+
+/* ---------- timeline ---------- */
+let TW = [];
+const io = p => p < .5 ? 4 * p * p * p : 1 - (-2 * p + 2) ** 3 / 2;
+const out = p => 1 - (1 - p) ** 3;
+const back = p => 1 + 2.2 * (p - 1) ** 3 + 1.2 * (p - 1) ** 2;
+const lin = p => p;
+function tw(e, to, t0, dur = .6, ease = io) { TW.push({ e, to, t0, dur, ease }); }
+function prog(pf, t0, dur, ease = io) { TW.push({ pf, t0, dur, ease }); }
+const show = (e, t0, dur = .5) => tw(e, { o: 1 }, t0, dur);
+const hide = (e, t0, dur = .5) => tw(e, { o: 0 }, t0, dur);
+const draw = (e, t0, dur = .9) => tw(e, { d: 1 }, t0, dur);
+const pop = (e, t0) => tw(e, { s: 1, o: 1 }, t0, .45, back);
+function pulse(e, t0, k = 1.7) { tw(e, { s: k }, t0, .22, out); tw(e, { s: 1 }, t0 + .22, .4); }
+function glow(key, t0) {
+ const s = S.ring[key].stroke;
+ tw(s, { 'a_stroke-width': 9 }, t0, .22, out); tw(s, { 'a_stroke-width': 3 }, t0 + .25, .5);
+}
+function glowRun(key, t0) { CHAIN[key].forEach((k, i) => glow(k, t0 + i * .3)); }
+function stream(t, str, t0, dur) { prog(q => { t.textContent = str.slice(0, Math.round(q * str.length)); }, t0, dur, lin); }
+function mix(a, b, q) {
+ const h = c => [1, 3, 5].map(i => parseInt(c.slice(i, i + 2), 16));
+ const A = h(a), B = h(b);
+ return '#' + A.map((v, i) => Math.round(v + (B[i] - v) * q).toString(16).padStart(2, '0')).join('');
+}
+// A colour or attribute tween with no starting value in the state starts from the element's attribute.
+const fromAttr = (e, k) => k.startsWith('c_') ? e.getAttribute(k.slice(2)) : k.startsWith('a_') ? parseFloat(e.getAttribute(k.slice(2))) : undefined;
+function evalTo(t, list = TW) {
+ for (const w of list) {
+ if (w.done || t < w.t0) continue;
+ if (!w.go) { w.go = 1; if (w.e) { const s = st(w.e); w.from = {}; for (const k in w.to) w.from[k] = s[k] ?? fromAttr(w.e, k); } }
+ const p = w.dur ? Math.min(1, (t - w.t0) / w.dur) : 1, q = w.ease(p);
+ if (w.e) {
+ const s = st(w.e);
+ for (const k in w.to) s[k] = k.startsWith('c_') ? mix(w.from[k], w.to[k], q) : w.from[k] + (w.to[k] - w.from[k]) * q;
+ render(w.e);
+ } else w.pf(q);
+ if (p >= 1) w.done = 1;
+ }
+}
+
+/* ---------- world clock and camera ---------- */
+const soft = p => (1 - Math.cos(Math.PI * p)) / 2; // gentle in-out, for camera moves
+// Continuous motion: f(t) runs on every frame of the beat with t in seconds from its start (0..D).
+// Keep f a pure function of t, so pause, seek and ?beat=N&t=S show the same frame.
+const clockRun = (f, D) => { f(0); prog(q => f(q * D), 0, D, lin); };
+// A camera looks at a world group through the stage (or a box, for split screen and picture-in-picture).
+// The view {x, y, z, r} is the world point at the centre, the zoom (screen px per world px) and the roll in degrees.
+// 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];
+ const el = G(p, { x: bx + bw / 2, y: by + bh / 2 });
+ let hold = el;
+ if (box) {
+ const id = 'cam' + (++camN);
+ mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, rx: 18 }, mk('clipPath', { id }, mk('defs', {}, el)));
+ hold = G(el); hold.setAttribute('clip-path', `url(#${id})`);
+ mk('rect', { x: -bw / 2, y: -bh / 2, width: bw, height: bh, fill: bg }, hold);
+ }
+ 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 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.
+ function at(t, n = ops.length) {
+ const s = { ...v0 };
+ for (let i = 0; i < n && ops[i].t0 <= t; i++) {
+ const o = ops[i], a = o.from || (o.from = at(o.t0, i));
+ const q = o.dur ? o.ease(Math.min(1, (t - o.t0) / o.dur)) : 1, b = {};
+ for (const k in o.v) b[k] = val(o.v[k], t);
+ if ('z' in b) s.z = a.z * (b.z / a.z) ** q; // even zoom speed
+ // While zooming, x/y move so that one world point stays put on screen (when start and end allow it).
+ const u = 'z' in b && Math.abs(b.z - a.z) > 1e-6 * a.z ? (1 / s.z - 1 / a.z) / (1 / b.z - 1 / a.z) : q;
+ for (const k of ['x', 'y']) if (k in b) s[k] = a[k] + (b[k] - a[k]) * u;
+ if ('r' in b) s.r = a.r + (b.r - a.r) * q;
+ }
+ return s;
+ }
+ function apply(t) {
+ const s = at(t);
+ let sx = 0, sy = 0;
+ for (const k of shakes) if (t > k.t0 && t < k.t0 + k.dur) {
+ const e = k.amp * Math.min(1, (t - k.t0) / .3, (k.t0 + k.dur - t) / .3), w = 2 * Math.PI * k.hz * t;
+ sx += e * (Math.sin(w) + .5 * Math.sin(2.3 * w + 1)) / 1.5; sy += e * (Math.sin(1.7 * w + 2) + .5 * Math.sin(3.1 * w)) / 1.5;
+ }
+ const tf = `translate(${sx} ${sy}) rotate(${-s.r}) scale(${s.z}) translate(${-s.x} ${-s.y})`;
+ if (tf !== view._tf) view.setAttribute('transform', view._tf = tf);
+ const dx = s.x - v0.x, dy = s.y - v0.y;
+ for (const L of layers) put(L.g, { x: L.wrap ? dx - ((L.k * dx) % L.wrap + L.wrap) % L.wrap : (1 - L.k) * dx, y: (1 - L.k) * dy });
+ }
+ const cam = { el, world, at,
+ to(v, t0, dur = 1, ease = soft) { ops.push({ v, t0, dur, ease }); ops.sort((a, b) => a.t0 - b.t0); ops.forEach(o => delete o.from); return cam; },
+ cut: (v, t0) => cam.to(v, t0, 0),
+ shake(amp, t0, dur, hz = 7) { shakes.push({ amp, t0, dur, hz }); return cam; },
+ // Parallax layer: k < 1 is far (moves slower than the camera), k > 1 near. With wrap = W the layer's content
+ // repeats every W world px: draw one period plus the widest view, and the layer never runs out.
+ layer(k = 1, wrap) { const g = G(world); layers.push({ g, k, wrap }); return g; },
+ // Screen position of a world point at time t (k = 1 layers, no shake): for labels that track an object.
+ screen(wx, wy, t) {
+ const s = at(t), a = -s.r * Math.PI / 180, ux = (wx - s.x) * s.z, uy = (wy - s.y) * s.z;
+ return [bx + bw / 2 + ux * Math.cos(a) - uy * Math.sin(a), by + bh / 2 + ux * Math.sin(a) + uy * Math.cos(a)];
+ },
+ // Put a screen-space label (text, anchor middle, outside the camera) over world point (wx, wy) at time t, kept
+ // inside the frame or box by margin m; it fades out once the point itself leaves. Fade it in with a wrapper group.
+ track(el, wx, wy, t, m = 24) {
+ const [sx, sy] = cam.screen(wx, wy, t), str = el.textContent;
+ if (el._tw?.[0] !== str) el._tw = [str, el.getComputedTextLength() / 2];
+ const h = el._tw[1], away = Math.max(bx - sx, sx - bx - bw, 0);
+ put(el, { x: Math.min(bx + bw - m - h, Math.max(bx + m + h, sx)), y: sy, o: Math.max(0, 1 - away / 80) });
+ },
+ };
+ clockRun(apply, D);
+ return cam;
+}
+
+/* ---------- 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 X = v => AXIS.o + AXIS.u * v, Y0 = 610;
+const num = v => (v < 0 ? '−' : '') + String(Math.abs(v)).replace('.', DECIMAL_SIGN);
+function reset() {
+ scene.replaceChildren();
+ for (const k in S) delete S[k];
+ Object.assign(S, { dots: {}, tick: {}, rows: [], chips: [], samples: [], list: G(scene), line: G(scene), venn: G(scene) });
+}
+function tick(v) {
+ const g = G(S.line, { o: 0 });
+ path(g, `M${X(v)} ${Y0 - 11}V${Y0 + 11}`, { stroke: COL.dim, 'stroke-width': 2.5 });
+ T(g, num(v), { x: X(v), y: Y0 + 50, size: 30, fill: COL.dim, font: MATH, anchor: 'middle' });
+ return (S.tick[v] = g);
+}
+function dot(key, v, r = 9, name = v) {
+ const g = G(S.line, { x: X(v), y: Y0, s: 0, o: 0 });
+ mk('circle', { r, fill: COL[key], stroke: COL.board, 'stroke-width': 2 }, g);
+ return (S.dots[name] = g);
+}
+const arrow = (x, dir) => `M${x - 15 * dir} ${Y0 - 10}L${x} ${Y0}L${x - 15 * dir} ${Y0 + 10}`;
+function panel(t0) {
+ if (t0 < .5) S.cleared = true; // the old panel fades, or this is the first panel after the title
+ const old = S.panel;
+ if (old && t0 < .5) retire(old);
+ else if (old) { // a panel change later in the beat stays on the beat clock
+ hide(old, t0, .4);
+ prog(q => { if (q === 1) old.style.display = 'none'; }, t0 + .4, 0, lin);
+ }
+ return (S.panel = G(scene));
+}
+// Take a beat's old picture away on wall time: a 150 ms fade, then out of rendering. On the beat clock the fade would
+// wait for the new clip's audio to start (a few hundred ms in Firefox) with the old, frozen scene still showing.
+// While seeking, the pictures passed on the way were never seen: they go at once.
+let seeking = false;
+function retire(e) {
+ if (seeking) { e.style.display = 'none'; return; }
+ e.style.transition = 'opacity .15s linear';
+ e.style.opacity = '0';
+ setTimeout(() => { e.style.display = 'none'; }, 160);
+}
+function header(p, str, t0, x = 1000, y = 170) {
+ const h = T(p, str, { x, y, size: 30, fill: COL.dim, weight: 600, o: 0 });
+ show(h, t0);
+ return h;
+}
+
+/* ---------- question effects: run on wall time, independent of the lesson clock ---------- */
+let FX = [], clock = 0;
+function fx(e, to, delay = 0, dur = .5, ease = io) { FX.push({ e, to, t0: clock + delay, dur, ease }); }
+function fxp(pf, delay, dur, ease = io) { FX.push({ pf, t0: clock + delay, dur, ease }); }
+function finishFx() { FX.sort((a, b) => a.t0 - b.t0); evalTo(Infinity, FX); FX = []; }
+const pulseFx = (e, k = 1.8) => { if (!e) return; fx(e, { s: k }, 0, .22, out); fx(e, { s: 1 }, .22, .45); };
+const shakeFx = e => { if (!e) return; const x0 = st(e).x; fxp(q => put(e, { x: x0 + Math.sin(q * Math.PI * 6) * (1 - q) * 12 }), 0, .55, lin); };
+const glowFx = (key, delay = 0) => CHAIN[key].forEach((k, i) => {
+ const s = S.ring[k].stroke;
+ fx(s, { 'a_stroke-width': 9 }, delay + i * .28, .22, out); fx(s, { 'a_stroke-width': 3 }, delay + i * .28 + .25, .5);
+});
+function popDotFx(key, v, label) {
+ const L = S.q || qlayer();
+ const g = G(L, { x: X(v), y: Y0, s: 0, o: 0 });
+ mk('circle', { r: 7, fill: COL[key], stroke: COL.board, 'stroke-width': 2 }, g);
+ fx(g, { s: 1, o: 1 }, 0, .45, back);
+ if (label) fx(M(L, label, { x: X(v) + 10, y: Y0 + 56, size: 28, fill: COL[key], o: 0 }), { o: 1 }, .3, .4);
+}
+function floatText(str, x, y, colr) {
+ const t = T(S.q || qlayer(), str, { x, y: y + 14, size: 24, fill: colr, anchor: 'middle', weight: 600, o: 0 });
+ fx(t, { o: 1, y }, 0, .5, out);
+}
+function hopsFx(n) {
+ for (let k = 1; k <= -n; k++) {
+ const a = X(1 - k), b = X(-k);
+ fx(path(S.q, `M${a} ${Y0 - 12}Q${(a + b) / 2} ${Y0 - 84} ${b} ${Y0 - 12}`, { stroke: COL.int, 'stroke-width': 3 }, { d: 0 }), { d: 1 }, (k - 1) * .35, .35, lin);
+ }
+ floatText(translate('stepsLeftOfZero', { n: -n }), X(n / 2), Y0 - 100, COL.int);
+}
+
+/* ---------- shared answer columns ---------- */
+const FAMILIES = ['nat', 'whole', 'int', 'rat', 'irr', 'real'];
+const FAM_COLS = FAMILIES.map(k => [k, k === 'int' ? translate('integerColumn') : NAME[k], COL[k]]);
+const TF = [['t', translate('trueLabel'), null, 'T'], ['f', translate('falseLabel'), null, 'F']];
+function finishCard() {
+ const c = card(SCREEN, 'fin');
+ const sum = pre => Object.entries(SCORE).filter(([k]) => k.startsWith(pre)).reduce((a, [, v]) => [a[0] + v.right, a[1] + v.total], [0, 0]);
+ const line = (name, [r, t]) => h('p', 'fb', t ? translate('firstTryScore', { name, r, t }) : translate('notAttempted', { name }));
+ progress(p => { p.done = [...new Set([...(p.done || []), CHAPTER.number])]; });
+ const home = h('a', 'btn quiet', translate('allChapters'));
+ home.href = $('bHome').href;
+ const again = h('button', 'btn' + (CHAPTER.next ? ' quiet' : ' go'), [translate('watchAgain'), kbd(CHAPTER.next ? 'R' : 'Enter')]);
+ again.onclick = restart;
+ const next = CHAPTER.next && h('button', 'btn go', [translate('nextChapter'), kbd('Enter')]);
+ if (next) next.onclick = () => { location.href = CHAPTER.next; };
+ P.keys = e => e.key === 'Enter' ? ((next ? next.onclick() : restart()), true)
+ : isShortcut(e, 'r') ? (restart(), true) : false;
+ const guide = mascotEl(240);
+ c.append(h('div', 'finwrap', [guide, h('p', 'kicker', translate('chapterComplete', { n: CHAPTER.label ?? CHAPTER.number })), h('p', 'prompt', CHAPTER.title),
+ line(translate('quickChecks'), sum('c-')), line(translate('chapterPractice'), sum('p-')), h('div', 'acts', next ? [home, again, next] : [home, again])]));
+ setTimeout(() => mood(guide, 'happy'), 400);
+}
+
+/* ---------- in-picture cards ---------- */
+const $ = id => document.getElementById(id);
+// The volume control (volume.js, volume.css) lives in its own files next to this one, the same in every book.
+document.head.append(Object.assign(document.createElement('script'), { src: new URL('volume.js', document.currentScript.src) }));
+const kbd = s => h('kbd', '', s);
+const uiW = (str, size) => { ctx2d.font = `600 ${size}px ${UI}`; return ctx2d.measureText(str).width; };
+const RING_KEYS = ['nat', 'whole', 'int', 'rat', 'irr', 'real']; // number keys 1–6 in sorting questions
+const SCORE = {}; // question id -> first-attempt {right, total}
+
+function h(tag, cls, kids = []) {
+ const e = document.createElement(tag);
+ if (cls) e.className = cls;
+ for (const k of [].concat(kids)) e.append(k);
+ return e;
+}
+// Rich text: strings, DOM nodes, or $m(...) inline math.
+function rich(parts, size = 28) {
+ const s = document.createElement('span');
+ for (const p of [].concat(parts)) s.append(typeof p === 'string' || p instanceof Node ? p : mathEl(p.m, size));
+ return s;
+}
+// A card at pos; a band card keeps its bottom on the stage: when its content grows (a long question, feedback),
+// it moves up rather than running under the player bar.
+function card(pos, cls) {
+ const c = h('div', `card ${pos.cls} ${cls}`);
+ Object.assign(c.style, { left: pos.x + 'px', top: pos.y + 'px', width: pos.w + 'px' });
+ if (pos.maxH) c.style.maxHeight = pos.maxH + 'px';
+ $('ui').append(c);
+ if (pos.cls === 'band') {
+ const fit = () => { c.style.top = Math.max(16, Math.min(pos.y, 900 - 16 - c.offsetHeight)) + 'px'; };
+ const ro = new ResizeObserver(fit);
+ ro.observe(c); fit();
+ P.cleanup.push(() => ro.disconnect());
+ }
+ return c;
+}
+// The guide: an infinity sign whose two loops are its eyes. Drawn in SVG so it can blink, hop and wobble.
+function lemniscate(cx, cy, a, k) {
+ let d = '';
+ for (let i = 0; i <= 96; i++) {
+ const t = i / 96 * 2 * Math.PI, sn = Math.sin(t), q = 1 + sn * sn;
+ d += (i ? 'L' : 'M') + (cx + a * Math.cos(t) / q).toFixed(1) + ' ' + (cy + k * a * sn * Math.cos(t) / q).toFixed(1);
+ }
+ return d + 'Z';
+}
+function mascotEl(size = 100) {
+ const svg = mk('svg', { class: 'mascot', viewBox: '0 0 120 84', width: size, height: size * .7, 'aria-hidden': 'true' });
+ const body = mk('g', { class: 'mbody' }, svg);
+ const line = { fill: 'none', stroke: COL.chalk, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' };
+ mk('path', { d: lemniscate(60, 40, 52, 1.5), ...line, 'stroke-width': 6 }, body);
+ const eyes = mk('g', { class: 'eyes' }, body);
+ for (const x of [33, 87]) {
+ mk('circle', { class: 'pupil', cx: x, cy: 40, r: 6.5, fill: COL.chalk }, eyes);
+ mk('path', { class: 'joy', d: `M${x - 7} 43Q${x} 32 ${x + 7} 43`, ...line, 'stroke-width': 4 }, body);
+ }
+ mk('path', { class: 'smile', d: 'M55 62Q60 67 65 62', ...line, 'stroke-width': 3.5 }, body);
+ mk('path', { class: 'flat', d: 'M55 64H65', ...line, 'stroke-width': 3.5 }, body);
+ return svg;
+}
+function mood(el, m) {
+ el.classList.remove('happy', 'oops');
+ void el.getBoundingClientRect(); // restart the CSS animation
+ if (m) el.classList.add(m);
+}
+// A sequence of questions in one card. Each question: { id, prompt, build(body, api) -> { check?, reveal, lock? } }.
+function quiz(pos, qs, done, label = translate('quickCheck')) {
+ const c = card(pos, 'quiz');
+ let k = 0;
+ const show = () => {
+ const q = qs[k];
+ let first = true, resolved = false;
+ const fb = h('div', 'fb'), body = h('div', 'body'), acts = h('div', 'acts');
+ const bCheck = h('button', 'btn', [translate('check'), kbd('Enter')]), bShow = h('button', 'btn quiet', [translate('showAnswer'), kbd('S')]);
+ const bNext = h('button', 'btn go', [k < qs.length - 1 ? translate('nextQuestion') : translate('continue'), kbd('Enter')]);
+ bShow.hidden = bNext.hidden = true;
+ const guide = pos.cls === 'band' || pos.cls === 'side' ? mascotEl(pos.cls === 'band' ? 108 : 70) : null;
+ const say = (cls, parts) => { fb.className = 'fb ' + cls; fb.replaceChildren(rich(parts, 24)); fb.style.animation = 'none'; void fb.offsetWidth; fb.style.animation = ''; };
+ const resolve = () => {
+ resolved = true;
+ bCheck.hidden = bShow.hidden = true;
+ ctl.lock?.();
+ bNext.hidden = false;
+ bNext.focus({ preventScroll: true });
+ };
+ const api = {
+ grade(ok, msg, score) {
+ if (resolved) return;
+ if (first) { if (!Object.hasOwn(SCORE, q.id)) SCORE[q.id] = score || { right: +ok, total: 1 }; first = false; }
+ say(ok ? 'ok' : 'no', [ok ? translate('correct') : translate('notQuite'), ...[].concat(msg || [])]);
+ if (guide) {
+ mood(guide, ok ? 'happy' : 'oops');
+ if (!ok) setTimeout(() => { if (guide.classList.contains('oops')) mood(guide, null); }, 1600);
+ }
+ if (ok) resolve(); else bShow.hidden = false;
+ },
+ };
+ const ctl = q.build(body, api);
+ if (ctl.check) { bCheck.onclick = () => ctl.check(); acts.append(bCheck); }
+ acts.append(bShow, bNext);
+ bShow.onclick = () => { say('', [translate('answerPrefix'), ...[].concat(ctl.reveal())]); resolve(); };
+ bNext.onclick = () => { if (k < qs.length - 1) { k++; show(); } else done(); };
+ P.keys = e => {
+ if (e.key === 'Enter' && resolved) { bNext.click(); return true; }
+ if (!resolved && ctl.key?.(e)) return true;
+ if (e.key === 'Enter' && !resolved && ctl.check) { bCheck.click(); return true; }
+ if (isShortcut(e, 's') && !bShow.hidden) { bShow.click(); return true; }
+ return false;
+ };
+ const kick = label + (qs.length > 1 ? ' ' + translate('countOf', { k: k + 1, n: qs.length }) : '');
+ const head = h('div', 'head', [h('p', 'kicker', kick), h('p', 'prompt', [rich(q.prompt, pos.cls.startsWith('screen') ? 38 : 28)])]); // match the prompt's type size
+ if (ctl.hint) head.append(h('p', 'keys', [translate('keysPrefix'), ...ctl.hint]));
+ c.replaceChildren(...(guide ? [guide] : []), head, fb, body, acts);
+ };
+ show();
+}
+function qlayer() {
+ S.q?.remove();
+ S.q = G(scene);
+ S.q.classList.add('qlayer');
+ return S.q;
+}
+const keyAct = (el, fn) => el.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); fn(); } });
+
+/* ---------- question builders ---------- */
+// Single answer from buttons; each wrong option has its own explanation.
+const choice = (opts, right, yes, no, onRight) => (body, api) => {
+ const row = h('div', 'opts');
+ const bs = opts.map((o, i) => {
+ const b = h('button', 'opt', [kbd(String(i + 1)), rich(o, 32)]);
+ b.onclick = () => {
+ if (i === right) { b.classList.add('good'); onRight?.(); api.grade(true, yes); }
+ else { b.classList.add('bad'); b.disabled = true; api.grade(false, no[i]); }
+ };
+ row.append(b);
+ return b;
+ });
+ body.append(row);
+ return {
+ reveal() { bs[right].classList.add('good'); onRight?.(); return yes; },
+ lock() { bs.forEach(b => { b.disabled = true; }); },
+ key(e) { const b = bs[+e.key - 1]; if (!b || b.disabled) return false; b.click(); return true; },
+ };
+};
+// The shared body of the stage tap questions: each target ring is a focusable button that answers on click or Enter,
+// and ← / → move the focus between them. targets: [{ g, label, ok, wrong }], wrong() shakes and returns the explanation.
+const stageTap = (api, targets, show, yes, onRight, hint) => {
+ let locked = false, cur = -1;
+ const gs = targets.map(({ g, label, ok, wrong }) => {
+ g.classList.add('hit');
+ g.setAttribute('tabindex', 0);
+ g.setAttribute('role', 'button');
+ g.setAttribute('aria-label', label);
+ const act = () => {
+ if (locked) return;
+ if (ok) { g.classList.add('good'); onRight?.(); api.grade(true, yes); }
+ else { g.classList.add('bad'); api.grade(false, wrong()); }
+ };
+ g.addEventListener('click', act);
+ keyAct(g, act);
+ return g;
+ });
+ return {
+ reveal() { gs[show].classList.add('good'); onRight?.(); return yes; },
+ lock() { locked = true; },
+ hint,
+ key(e) {
+ const d = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0;
+ if (!d || locked) return false;
+ cur = cur < 0 ? (d > 0 ? 0 : gs.length - 1) : (cur + d + gs.length) % gs.length;
+ gs[cur].focus();
+ return true;
+ },
+ };
+};
+// Tap a point on the stage number line.
+const tap = (values, right, yes, no, onRight) => (body, api) => {
+ const L = qlayer();
+ const targets = values.map(v => {
+ const g = G(L, { x: X(v), y: Y0 });
+ mk('circle', { r: 30, class: 'ring' }, g);
+ return { g, label: translate('pointLabel', { v: num(v) }), ok: v === right, wrong: () => { shakeFx(S.dots[v]); return no(v); } };
+ });
+ return stageTap(api, targets, values.lastIndexOf(right), yes, onRight,
+ [kbd('←'), kbd('→'), translate('hintMoveAlongLine'), kbd('Enter'), translate('hintChoose')]);
+};
+// Tap one token of a stage token row, e.g. the operation to do first. idx: tappable token indexes.
+const tapEls = (row, idx, right, yes, no, onRight) => (body, api) => {
+ const L = qlayer();
+ const targets = idx.map(i => {
+ const e = row[i], w = e._w + 18, g = G(L, { x: e._px, y: row.y });
+ mk('rect', { class: 'ring', x: -w / 2, y: -row.size * .95, width: w, height: row.size * 1.3, rx: 12 }, g);
+ return { g, label: e.textContent.trim(), ok: i === right, wrong: () => { shakeFx(e); return no(i); } };
+ });
+ return stageTap(api, targets, idx.indexOf(right), yes, onRight,
+ [kbd('←'), kbd('→'), translate('hintMove'), kbd('Enter'), translate('hintChoose')]);
+};
+// Click one of several stage objects (table cells, bars, small graphs). items: [{ el, box: [x, y, w, h], label }].
+const pickEls = (items, right, yes, no, onRight) => (body, api) => {
+ const L = qlayer();
+ const targets = items.map((it, i) => {
+ const [x, y, w, hh] = it.box, g = G(L);
+ mk('rect', { class: 'ring', x, y, width: w, height: hh, rx: 12 }, g);
+ return { g, label: it.label, ok: i === right, wrong: () => { shakeFx(it.el); return no(i); } };
+ });
+ return stageTap(api, targets, right, yes, onRight,
+ [kbd('←'), kbd('→'), translate('hintMove'), kbd('Enter'), translate('hintChooseOrClick')]);
+};
+// Rows of toggles. items: { parts, ans: [keys], why }. parts are math parts (strings, F, R) unless text: true,
+// where they are rich text (strings and $m(...)). cols: [[key, label, colour?, shortcut?]]. multi: several per row.
+const grid = (items, cols, { multi = true, text = false } = {}) => (body, api) => {
+ const wrap = h('div', 'grid' + (text ? ' text' : ''));
+ const hot = cols.map((c, j) => c[3] || String(j + 1));
+ let cur = 0, locked = false;
+ const rows = items.map((it, ri) => {
+ const opts = h('div', 'opts'), mark = h('div', 'mark'), why = h('div', 'why');
+ const bs = cols.map(([key, lab, colr], j) => {
+ const b = h('button', 'opt', [kbd(hot[j]), lab]);
+ if (colr) b.style.setProperty('--c', colr);
+ b.setAttribute('aria-pressed', 'false');
+ b.onclick = () => {
+ const on = b.getAttribute('aria-pressed') !== 'true';
+ if (!multi) bs.forEach(x => x.setAttribute('aria-pressed', 'false'));
+ b.setAttribute('aria-pressed', String(on));
+ };
+ opts.append(b);
+ return b;
+ });
+ const el = h('div', 'row', [h('div', 'num', [text ? rich(it.parts, 26) : mathEl(it.parts, 32)]), opts, mark, why]);
+ el.addEventListener('click', () => { cur = ri; showCur(); });
+ wrap.append(el);
+ const picked = () => cols.filter((c, i) => bs[i].getAttribute('aria-pressed') === 'true').map(c => c[0]);
+ return { it, bs, mark, why, picked, el, played: false };
+ });
+ const single = rows.length === 1;
+ const showCur = () => rows.forEach((r, i) => {
+ const on = !single && !locked && i === cur;
+ r.el.classList.toggle('cur', on);
+ if (on && r.el.isConnected) r.el.scrollIntoView({ block: 'nearest' }); // a long practice list scrolls
+ });
+ showCur();
+ body.append(wrap);
+ const judge = r => {
+ const p = r.picked(), ok = p.length === r.it.ans.length && r.it.ans.every(k => p.includes(k));
+ r.mark.className = 'mark ' + (ok ? 'good' : 'bad');
+ r.mark.textContent = ok ? '✓' : '✗';
+ r.why.replaceChildren(ok || single ? '' : rich(r.it.why, 20));
+ if (ok && !r.played) { r.played = true; r.it.fx?.(); }
+ return ok;
+ };
+ return {
+ check() {
+ const right = rows.filter(judge).length;
+ const all = right === rows.length;
+ api.grade(all, single ? rows[0].it.why : all ? [] : [translate('rowsRight', { r: right, n: rows.length })], { right, total: rows.length });
+ },
+ reveal() {
+ for (const r of rows) {
+ r.bs.forEach((b, i) => b.setAttribute('aria-pressed', String(r.it.ans.includes(cols[i][0]))));
+ judge(r);
+ if (!single) r.why.replaceChildren(rich(r.it.why, 20));
+ }
+ return single ? rows[0].it.why : translate('choicesShown');
+ },
+ lock() { locked = true; showCur(); rows.forEach(r => r.bs.forEach(b => { b.disabled = true; })); },
+ hint: [...(single ? [] : [kbd('↑'), kbd('↓'), translate('hintRow')]), ...(/\d/.test(hot[0]) ? [kbd(hot[0]), '–', kbd(hot[hot.length - 1])] : hot.map(kbd)), translate('hintChoose')],
+ key(e) {
+ if (locked) return false;
+ if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && !single) {
+ cur = (cur + (e.key === 'ArrowDown' ? 1 : -1) + rows.length) % rows.length;
+ showCur();
+ return true;
+ }
+ const j = hot.findIndex(x => isShortcut(e, x));
+ if (j < 0) return false;
+ rows[cur].bs[j].click();
+ if (!multi && cur < rows.length - 1) { cur++; showCur(); }
+ return true;
+ },
+ };
+};
+// Exact value of a typed answer: integer, decimal, fraction a/b or mixed number "w a/b"; returns [num, den] or null.
+// Accepts −, – or - as the sign, and a decimal comma when DECIMAL_SIGN is ','. Never evaluates the text as code.
+function rat(str) {
+ let t = String(str).trim().replace(/^[−–]/, '-').replace(/\s+/g, ' ');
+ if (DECIMAL_SIGN === ',') t = t.replace(/^(-?\d+),(\d+)$/, '$1.$2'); // 0,75 where the decimal sign is a comma
+ let m = t.match(/^(-?)(\d+)(?:\.(\d+))?$/);
+ if (m) { const d = 10 ** (m[3] || '').length, n = (m[1] ? -1 : 1) * (Number(m[2]) * d + Number(m[3] || 0)); return Number.isSafeInteger(n) && Number.isSafeInteger(d) ? [n, d] : null; }
+ m = t.match(/^(-?)(?:(\d+) )?(\d+) ?\/ ?(\d+)$/);
+ if (m && Number(m[4]) > 0) { const d = Number(m[4]), n = (m[1] ? -1 : 1) * (Number(m[2] || 0) * d + Number(m[3])); return Number.isSafeInteger(n) && Number.isSafeInteger(d) ? [n, d] : null; }
+ return null;
+}
+const gcd = (a, b) => { a = Math.abs(a); b = Math.abs(b); while (b) [a, b] = [b, a % b]; return a; };
+const lowest = ([n, d]) => gcd(n, d) === 1;
+// Fill-in boxes inside math. rows: [{ parts: [math parts and { box: '21' }], why, hint?, fx? }].
+// test(values), when given, judges the whole row from the typed numbers (e.g. a factor pair in either order); the boxes' answers are still what Show answer fills in.
+// Answers are exact numbers: "−5", "-5", "0.5", "3/4" and "2 1/4" all work, and equal values match ("6/8" = "3/4")
+// unless the box has lowest: true. hint is shown after a wrong try, why after a right one.
+const blanks = rowsIn => (body, api) => {
+ const all = [];
+ const rows = rowsIn.map(it => {
+ const line = h('div', 'bline'), mark = h('span', 'mark'), why = h('div', 'why');
+ let run = [];
+ const flush = () => { if (run.length) line.append(mathEl(run, 34)); run = []; };
+ const boxes = [];
+ for (const p of it.parts) {
+ if (p && p.box !== undefined) {
+ flush();
+ const b = h('input', 'box');
+ Object.assign(b, { type: 'text', inputMode: 'decimal', autocomplete: 'off', spellcheck: false });
+ b.setAttribute('aria-label', translate('answerBox'));
+ b.dataset.ans = p.box;
+ if (p.lowest) b.dataset.lowest = '1';
+ b.style.width = `${Math.max(2, String(p.box).length) + 2}ch`;
+ line.append(b);
+ boxes.push(b);
+ all.push(b);
+ } else run.push(p);
+ }
+ flush();
+ line.append(mark);
+ body.append(h('div', 'brow', [line, why]));
+ return { it, boxes, mark, why, played: false };
+ });
+ body.classList.add('blanks');
+ const single = rows.length === 1;
+ const judge = r => {
+ let ok = true;
+ if (r.it.test) { // the row is judged as a whole, e.g. two factors in either order
+ const vals = r.boxes.map(b => rat(b.value));
+ ok = vals.every(Boolean) && !!r.it.test(vals.map(([n, d]) => n / d));
+ r.boxes.forEach(b => { b.classList.toggle('good', ok); b.classList.toggle('bad', !ok); });
+ } else for (const b of r.boxes) {
+ const want = rat(b.dataset.ans), got = rat(b.value);
+ const good = !!got && !!want && BigInt(got[0]) * BigInt(want[1]) === BigInt(want[0]) * BigInt(got[1]) && (!b.dataset.lowest || lowest(got));
+ b.classList.toggle('good', good);
+ b.classList.toggle('bad', !good);
+ ok = ok && good;
+ }
+ r.mark.className = 'mark ' + (ok ? 'good' : 'bad');
+ r.mark.textContent = ok ? '✓' : '✗';
+ r.why.replaceChildren(ok || single ? '' : rich(r.it.hint ?? r.it.why, 20));
+ if (ok && !r.played) { r.played = true; r.it.fx?.(); }
+ return ok;
+ };
+ requestAnimationFrame(() => all[0]?.focus({ preventScroll: true }));
+ return {
+ check() {
+ const right = rows.filter(judge).length, done = right === rows.length;
+ const msg = single ? (done ? rows[0].it.why : rows[0].it.hint ?? rows[0].it.why)
+ : done ? [] : [translate('rowsRight', { r: right, n: rows.length })];
+ api.grade(done, msg, { right, total: rows.length });
+ },
+ reveal() {
+ for (const r of rows) {
+ r.boxes.forEach(b => { b.value = b.dataset.ans.replace('-', '−'); }); // shown exactly as authored
+ judge(r);
+ if (!single) r.why.replaceChildren(rich(r.it.why, 20));
+ }
+ return single ? rows[0].it.why : translate('numbersShown');
+ },
+ lock() { all.forEach(b => { b.disabled = true; }); },
+ hint: [translate(all.some(b => b.dataset.ans.includes('/')) ? 'hintTypeFraction' : all.some(b => /[.,]/.test(b.dataset.ans)) ? 'hintTypeDecimal' : 'hintTypeNumber'),
+ kbd('Tab'), translate('hintNextBox'), kbd('Enter'), translate('hintCheck'), kbd('Esc'), translate('hintLeaveBox')],
+ };
+};
+// Drag number chips into the stage number map. items: [parts, smallest ring, explanation].
+const slot = (k, n) => {
+ if (k === 'real') return [[940, 210], [1000, 760], [820, 800]][n % 3]; // inside Real, outside every other ring
+ const r = RINGS[k];
+ return [r.lx + [-72, 72, 0][n % 3], r.ly + 50 + 56 * Math.floor(n / 2)];
+};
+const plain = parts => parts.map(p => typeof p === 'string' ? p : p.ov !== undefined ? p.ov + ' repeating' : p.tex !== undefined ? p.tex : p.f ? p.f.join('/') : p.sup !== undefined ? '^' + p.sup : (p.i ? p.i : '') + '√' + (p.r.f ? p.r.f.join('/') : p.r)).join('');
+const sorter = (items, trayXY) => (body, api) => {
+ const L = qlayer();
+ const bg = mk('rect', { width: 1600, height: 900, fill: 'transparent' }, L);
+ const svg = $('stage');
+ const pt = e => { const p = svg.createSVGPoint(); p.x = e.clientX; p.y = e.clientY; return p.matrixTransform(svg.getScreenCTM().inverse()); };
+ let sel = null, drag = null, locked = false;
+ const label = c => c.setAttribute('aria-label', c.region ? translate('chipPlaced', { x: c.say, ring: NAME[c.region] }) : translate('chipNotPlaced', { x: c.say }));
+ const outline = (c, colr, w = 2.5) => { c._rect.setAttribute('stroke', colr); c._rect.setAttribute('stroke-width', w); };
+ const choose = c => {
+ if (sel) outline(sel, COL.chalk);
+ sel = c;
+ if (sel) { outline(sel, COL.task, 4); L.append(sel); }
+ };
+ const select = c => choose(sel === c ? null : c);
+ // Number badges next to the ring names, for keys 1–6.
+ RING_KEYS.forEach((k, i) => {
+ const r = RINGS[k], g = G(L, { x: r.lx - uiW(NAME[k], 26) / 2 - 24, y: r.ly - 9 });
+ g.style.pointerEvents = 'none';
+ mk('circle', { r: 14, fill: COL.board, stroke: COL[k], 'stroke-width': 1.5 }, g);
+ T(g, String(i + 1), { y: 6.5, size: 18, fill: COL[k], anchor: 'middle', weight: 600 });
+ });
+ const place = (c, x, y) => {
+ c.region = regionAt(x, y);
+ if (!c.region) [x, y] = c.home;
+ put(c, { x, y });
+ outline(c, COL.chalk);
+ c.querySelector('.mark')?.remove();
+ if (sel === c) sel = null;
+ label(c);
+ };
+ const chips = items.map(([parts, answer, why], i) => {
+ const [x, y] = trayXY(i);
+ const c = chip(L, parts, COL.chalk, { x, y, size: 32 });
+ Object.assign(c, { answer, why, home: [x, y], region: null, say: plain(parts) });
+ c.classList.add('tok');
+ c.setAttribute('tabindex', 0);
+ c.setAttribute('role', 'button');
+ label(c);
+ c.addEventListener('pointerdown', e => {
+ if (locked) return;
+ e.preventDefault();
+ const p = pt(e);
+ drag = { dx: p.x - st(c).x, dy: p.y - st(c).y, sx: p.x, sy: p.y, moved: false };
+ L.append(c); // re-parent before capturing: moving a node drops its capture
+ c.setPointerCapture(e.pointerId);
+ });
+ c.addEventListener('pointermove', e => {
+ if (!drag) return;
+ const p = pt(e);
+ if (Math.hypot(p.x - drag.sx, p.y - drag.sy) > 6) drag.moved = true;
+ if (drag.moved) put(c, { x: p.x - drag.dx, y: p.y - drag.dy });
+ });
+ c.addEventListener('pointerup', () => {
+ if (!drag) return;
+ const moved = drag.moved;
+ drag = null;
+ if (moved) place(c, st(c).x, st(c).y); else select(c);
+ });
+ // A cancelled drag (a system gesture, a lost capture) drops the chip where it is instead of leaving it stuck to no pointer.
+ c.addEventListener('lostpointercapture', () => {
+ if (!drag) return;
+ const moved = drag.moved;
+ drag = null;
+ if (moved) place(c, st(c).x, st(c).y);
+ });
+ keyAct(c, () => { if (!locked) select(c); });
+ return c;
+ });
+ bg.addEventListener('pointerup', e => { if (sel && !locked) { const p = pt(e); place(sel, p.x, p.y); } });
+ return {
+ check() {
+ let right = 0;
+ const notes = h('ul');
+ for (const c of chips) {
+ c.querySelector('.mark')?.remove();
+ if (!c.region) { notes.append(h('li', '', translate('notPlacedYet', { x: c.say }))); continue; }
+ const ok = c.region === c.answer;
+ right += ok;
+ outline(c, ok ? COL.good : COL.bad, 4);
+ if (ok) { pulseFx(c, 1.25); glowFx(c.answer, right * .15); } else shakeFx(c);
+ const w = +c._rect.getAttribute('width');
+ T(c, ok ? '✓' : '✗', { x: w / 2 + 4, y: -16, size: 26, fill: ok ? COL.good : COL.bad, weight: 700 }).classList.add('mark');
+ if (!ok) notes.append(h('li', '', c.region === 'real'
+ ? translate('realRingIsEmpty', { x: c.say })
+ : c.why));
+ }
+ const all = right === chips.length;
+ api.grade(all, all ? [] : [translate('ringsRight', { r: right, n: chips.length }), notes], { right, total: chips.length });
+ },
+ reveal() {
+ const count = {};
+ chips.forEach((c, i) => {
+ const n = count[c.answer] = (count[c.answer] ?? -1) + 1;
+ const [x, y] = slot(c.answer, n);
+ c.region = c.answer;
+ c.querySelector('.mark')?.remove();
+ outline(c, COL.good, 4);
+ fx(c, { x, y }, i * .12, .8);
+ });
+ return translate('ringsShown');
+ },
+ lock() { locked = true; choose(null); },
+ hint: [kbd('←'), kbd('→'), translate('hintPickNumber'), kbd('1'), '–', kbd('6'), translate('hintPickRing')],
+ key(e) {
+ if (locked) return false;
+ const d = e.key === 'ArrowRight' || e.key === 'ArrowDown' ? 1 : e.key === 'ArrowLeft' || e.key === 'ArrowUp' ? -1 : 0;
+ if (d) {
+ const i = sel ? chips.indexOf(sel) : d > 0 ? -1 : 0;
+ choose(chips[(i + d + chips.length) % chips.length]);
+ return true;
+ }
+ const ring = RING_KEYS[+e.key - 1];
+ if (!ring || !sel) return false;
+ const c = sel;
+ place(c, ...slot(ring, chips.filter(x => x.region === ring && x !== c).length));
+ choose(chips.find(x => !x.region) || null);
+ return true;
+ },
+ };
+};
+
+/* ---------- player ---------- */
+const P = { i: 0, t: 0, end: 1, playing: false, waiting: false, done: false, started: false, audio: null, afail: false, stall: 0, cleanup: [], rate: 1, nextClip: null };
+function runBeat(i) {
+ TW = [];
+ const b = BEATS[i], tm = TIMINGS[b.id], pre = b.pre || 0; // pre: seconds of picture before the narration starts
+ const m = (k, off = 0) => {
+ if (!(k in tm.marks)) throw new Error(`${b.id}: missing mark ${k}`);
+ return pre + tm.marks[k] + off;
+ };
+ S.cleared = false;
+ b.run(m, pre + tm.dur);
+ if (S.cleared && b.lead !== false && !pre) leadIn();
+ TW.sort((a, c) => a.t0 - c.t0);
+ return Math.max(pre + tm.dur, ...TW.map(w => w.t0 + w.dur)) + .6;
+}
+// A beat that clears the picture must not leave it empty while the narration has started.
+// If nothing appears before LEAD_MAX, the opening group (every tween that starts within LEAD_GROUP s of the
+// first reveal) moves earlier so it begins at LEAD_AT, just after the old panel has faded. Later steps keep their word timing.
+const LEAD_AT = .4, LEAD_MAX = .8, LEAD_GROUP = 1.2;
+function leadIn() {
+ const reveals = TW.filter(w => {
+ if (!w.e) return false;
+ const s = st(w.e), to = w.to;
+ return (to.o > 0 && s.o === 0) || (to.s > 0 && s.s === 0) || (to.d > 0 && (s.d ?? 1) === 0);
+ });
+ if (!reveals.length) return;
+ const first = Math.min(...reveals.map(w => w.t0));
+ if (first <= LEAD_MAX) return;
+ for (const w of TW) if (w.t0 >= first && w.t0 < first + LEAD_GROUP) w.t0 -= first - LEAD_AT;
+}
+function stopAudio() {
+ const a = P.audio;
+ if (!a) return;
+ a.onerror = null; a.pause(); a.removeAttribute('src'); a.load();
+ P.audio = null;
+}
+function clearCards() {
+ $('ui').replaceChildren();
+ P.cleanup.forEach(f => f());
+ P.cleanup = [];
+ finishFx();
+ P.keys = null;
+ S.q?.remove();
+ delete S.q;
+}
+// Rebuild the scene from scratch and fast-forward every earlier beat, so any step starts from its exact picture.
+function seek(i, play = P.playing) {
+ stopAudio(); clearCards(); reset();
+ seeking = true;
+ try {
+ for (let k = 0; k < i; k++) { runBeat(k); evalTo(Infinity); }
+ start(i, play);
+ } finally { seeking = false; }
+}
+// Jump to a point inside beat i (frac of its narration); question beats always start at their beginning.
+function seekInto(i, frac) {
+ seek(i, true);
+ const pre = BEATS[i].pre || 0, t = BEATS[i].ask ? 0 : frac * (pre + TIMINGS[BEATS[i].id].dur);
+ if (t < .3) return;
+ P.t = t;
+ evalTo(t);
+ if (P.audio) P.audio.currentTime = Math.max(0, t - pre);
+}
+function start(i, play) {
+ stopAudio(); clearCards();
+ Object.assign(P, { i, t: 0, waiting: false, done: false, afail: false, stall: 0 });
+ P.end = runBeat(i);
+ evalTo(0);
+ const a = P.audio = beatClip(i, true);
+ a.volume = +($('volume')?.value ?? 1);
+ a.playbackRate = P.rate;
+ // An aborted or superseded load (fast stepping, a reload) is not a failure: only a real error for the current clip
+ // shows the note, and the note goes away as soon as a clip plays.
+ a.onerror = () => { if (P.audio === a && a.error && a.error.code !== MediaError.MEDIA_ERR_ABORTED) soundFailed(); };
+ a.onplaying = () => {
+ if (P.audio !== a) return;
+ $('soundNote').hidden = true;
+ if (P.afail) { P.afail = false; a.currentTime = Math.max(0, P.t - (BEATS[P.i].pre || 0)); } // sound came back late: rejoin the picture where it is
+ };
+ const b = BEATS[i];
+ if (b.ask) b.ask(() => { if (P.i === i) { evalTo(Infinity); start(i + 1, true); } });
+ setPlaying(play);
+ if (i + 1 < BEATS.length) beatClip(i + 1);
+}
+// The next beat's clip starts loading while this one plays, so a slow connection does not stall between beats.
+function beatClip(i, take) {
+ const src = `audio/${CHAPTER.language || 'en'}/${BEATS[i].id}.mp3`;
+ let a = P.nextClip?._src === src ? P.nextClip : null;
+ if (!a) {
+ if (P.nextClip && P.nextClip !== P.audio) { P.nextClip.removeAttribute('src'); P.nextClip.load(); } // abandon a stale preload
+ a = Object.assign(new Audio(src), { preload: 'auto', _src: src });
+ }
+ P.nextClip = take ? null : a;
+ return a;
+}
+// Playback speed: the audio clock drives the picture, so changing the clip's rate keeps them together.
+const SPEEDS = [.75, 1, 1.25, 1.5];
+function setSpeed(r) {
+ P.rate = r;
+ $('bSpeed').textContent = r + '×';
+ if (P.audio) P.audio.playbackRate = r;
+ try { localStorage.setItem('speed', String(r)); } catch {}
+}
+const stepSpeed = d => setSpeed(SPEEDS[Math.max(0, Math.min(SPEEDS.length - 1, SPEEDS.indexOf(P.rate) + d))]);
+function soundFailed() { P.afail = true; $('soundNote').hidden = false; }
+function setPlaying(v) {
+ P.playing = v;
+ const a = P.audio;
+ if (!a) return;
+ const lead = v && P.t < (BEATS[P.i]?.pre || 0);
+ if (v && !P.waiting && !a.ended && !P.afail && !lead) a.play().catch(e => { if (P.audio === a && e.name === 'NotAllowedError') soundFailed(); });
+ else if (lead && !a._unlocked) { // the clip starts later, outside this click: play it silently now so the browser allows that
+ a._unlocked = true; a.muted = true;
+ a.play().then(() => { if (P.t < (BEATS[P.i].pre || 0)) { a.pause(); a.currentTime = 0; } a.muted = false; }, () => { a.muted = false; });
+ } else a.pause();
+}
+function beatDone() {
+ evalTo(Infinity);
+ const b = BEATS[P.i];
+ if (b.ask) P.waiting = true;
+ else if (P.i < BEATS.length - 1) start(P.i + 1, true);
+ else { P.done = true; setPlaying(false); }
+}
+let last = performance.now();
+function frame(now) {
+ const dt = Math.min(.1, (now - last) / 1000);
+ last = now;
+ clock += dt;
+ if (FX.length) { evalTo(clock, FX); FX = FX.filter(w => !w.done); }
+ if (P.playing && !P.waiting && !P.done) {
+ const a = P.audio;
+ // While the clip plays, its clock drives the picture; before it starts or after it ends, wall time does.
+ const pre = BEATS[P.i].pre || 0;
+ if (a && P.t < pre) { // the picture's lead before the narration, on wall time; then the clip starts
+ P.t += dt * P.rate;
+ if (P.t >= pre && !P.afail) { a.muted = false; a.currentTime = P.t - pre; a.play().catch(e => { if (P.audio === a && e.name === 'NotAllowedError') soundFailed(); }); }
+ } else if (a && !P.afail && !a.ended) {
+ if (a.currentTime > 0) { P.t = Math.max(P.t, pre + a.currentTime); P.stall = 0; }
+ else if ((P.stall += dt) > (a.readyState < 2 ? 8 : 15)) soundFailed(); // nothing to play after 8 s, or stuck for 15
+ } else P.t += dt * P.rate;
+ evalTo(P.t);
+ if (P.t >= P.end) beatDone();
+ }
+ ui();
+ requestAnimationFrame(frame);
+}
+let segs = [];
+function buildSegs() {
+ segs = BEATS.map((b, i) => {
+ const s = h('button', 'seg' + (b.ask ? ' ask' : ''), [h('i')]);
+ s.style.flex = TIMINGS[b.id].dur + (b.ask ? 12 : 0);
+ s.title = b.title;
+ s.setAttribute('aria-label', translate('goToStep', { n: i + 1, title: b.title }));
+ // A click lands at that point of the step; keyboard activation (no pointer position) starts the step.
+ s.onclick = e => {
+ const r = s.getBoundingClientRect();
+ hideCover(); seekInto(i, e.detail ? (e.clientX - r.left) / r.width : 0);
+ };
+ $('segs').append(s);
+ return s.firstChild;
+ });
+}
+// ui() runs on every frame, paused or not: it writes only what changed, so an idle lesson does no layout work.
+let stepText = '';
+const setWidth = (f, w) => { if (f._w !== w) { f._w = w; f.style.width = w + '%'; } };
+function ui() {
+ segs.forEach((f, k) => setWidth(f, k < P.i || P.done ? 100 : k > P.i ? 0 : Math.min(100, P.t / P.end * 100)));
+ const fr = $('frame');
+ fr.classList.toggle('is-playing', P.playing && !P.done && !P.waiting);
+ fr.classList.toggle('paused', P.started && !P.playing && !P.waiting && !P.done && !BEATS[P.i].ask);
+ const step = `${P.i + 1} / ${BEATS.length} ${BEATS[P.i].title}`;
+ if (step !== stepText) { stepText = step; $('stepName').textContent = step; }
+ const b = BEATS[P.i];
+ let text = '';
+ if (captions && P.started && !b.ask && !P.done) {
+ for (const [t, line] of TIMINGS[b.id].cues) { if (t + (b.pre || 0) > P.t + .05) break; text = line; }
+ }
+ if (text !== capText) { capText = text; $('caption').textContent = text; $('caption').hidden = !text; }
+}
+let captions = false, capText = '';
+try { captions = localStorage.getItem('captions') === '1'; } catch {}
+function setCaptions(on) {
+ captions = on;
+ $('bCC').setAttribute('aria-pressed', String(on));
+ try { localStorage.setItem('captions', on ? '1' : '0'); } catch {}
+}
+setCaptions(captions);
+function hideCover() { P.started = true; $('cover').hidden = true; }
+function togglePlay() {
+ if (!P.started) { hideCover(); return setPlaying(true); }
+ if (P.waiting || P.done) return;
+ setPlaying(!P.playing);
+}
+const back1 = () => seek(P.t > 2.5 || P.i === 0 ? P.i : P.i - 1);
+const restart = () => { for (const k in SCORE) delete SCORE[k]; hideCover(); seek(0, true); };
+$('cover').onclick = togglePlay;
+$('stage').addEventListener('click', e => {
+ const b = BEATS[P.i];
+ if (!b.ask && !e.target.closest('.qlayer')) togglePlay();
+});
+$('bPlay').onclick = togglePlay;
+$('bBack').onclick = () => { hideCover(); back1(); };
+$('bRestart').onclick = restart;
+$('bCC').onclick = () => setCaptions(!captions);
+$('bSpeed').onclick = () => setSpeed(SPEEDS[(SPEEDS.indexOf(P.rate) + 1) % SPEEDS.length]);
+try { const r = +localStorage.getItem('speed'); if (SPEEDS.includes(r)) setSpeed(r); } catch {}
+$('bFull').onclick = () => toggleFull();
+const toggleFull = () => document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen?.();
+let helpResume = false;
+function toggleHelp() {
+ const open = $('help').hidden;
+ $('help').hidden = !open;
+ if (open) { helpResume = P.playing; if (P.playing) setPlaying(false); }
+ else if (helpResume) setPlaying(true);
+}
+// Review notes, only with ?review in the URL: N pauses and asks for a note on this moment, Shift+N copies every
+// note of the chapter (one line each, with the ?beat=N&t=S that reopens it) and offers to clear them.
+const REVIEW = new URLSearchParams(location.search).has('review');
+const REVIEW_KEY = 'papermorph:review:' + location.pathname;
+const reviewNotes = () => { try { return JSON.parse(localStorage.getItem(REVIEW_KEY) || '[]'); } catch { return []; } };
+function reviewNote() {
+ if (P.playing) setPlaying(false);
+ const at = `?beat=${P.i}&t=${P.t.toFixed(1)}`, note = prompt(`Note at ${BEATS[P.i].id} ${at}`);
+ if (!note) return;
+ try { localStorage.setItem(REVIEW_KEY, JSON.stringify([...reviewNotes(), `ch${String(CHAPTER.number).padStart(2, '0')} ${at} (${BEATS[P.i].id}): ${note}`])); } catch {}
+}
+function reviewCopy() {
+ const notes = reviewNotes(), text = notes.join('\n');
+ console.log(text);
+ navigator.clipboard?.writeText(text).catch(() => {});
+ if (confirm(`${notes.length} notes copied (also in the console). Clear them?`)) try { localStorage.removeItem(REVIEW_KEY); } catch {}
+}
+// Every action has a key. A question's own keys (P.keys) come first; Shift reaches the player during a question.
+document.addEventListener('keydown', e => {
+ if (e.altKey || e.metaKey || e.ctrlKey) return;
+ const k = e.key;
+ if (!$('help').hidden) { if (k === 'Escape' || k === '?') { e.preventDefault(); toggleHelp(); } return; }
+ if (e.target.matches?.('input')) { // Keep native input keys; only answer boxes use Enter to check.
+ if (k === 'Enter' && e.target.type !== 'range' && P.keys) { e.preventDefault(); P.keys(e); }
+ else if (k === 'Escape') e.target.blur();
+ return;
+ }
+ if (k === '?') { e.preventDefault(); toggleHelp(); return; }
+ if (REVIEW && isShortcut(e, 'n')) { e.preventDefault(); e.shiftKey ? reviewCopy() : reviewNote(); return; }
+ if ((k === 'Enter' || k === ' ') && e.target.closest?.('button, [tabindex], a')) return; // a Tab-focused control acts itself
+ if (!P.started) { if (k === ' ' || k === 'Enter') { e.preventDefault(); togglePlay(); } return; }
+ if (P.keys && !e.shiftKey && P.keys(e)) { e.preventDefault(); return; }
+ const free = e.shiftKey || !P.keys;
+ let used = true;
+ if (k === ' ') togglePlay();
+ else if (k === 'ArrowLeft' && free) back1();
+ else if (k === 'ArrowRight' && free) { if (P.i < BEATS.length - 1) seek(P.i + 1); }
+ else if (k === 'Home') restart();
+ else if (isShortcut(e, 'c')) setCaptions(!captions);
+ else if (k === '<' || k === ',' || isShortcutCode(e, 'Comma')) stepSpeed(-1);
+ else if (k === '>' || k === '.' || isShortcutCode(e, 'Period')) stepSpeed(1);
+ else if (isShortcut(e, 'f')) toggleFull();
+ else used = false;
+ if (used) e.preventDefault();
+});
+// 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));
+addEventListener('resize', fit);
+fit();
+
+// Start the lesson once the chapter page has defined CHAPTER and BEATS.
+// ?beat=N&t=S opens a paused frame, for reviewing a single moment.
+// Per-book progress shared with the cover/contents at the parent URL folder.
+const BOOK_PROGRESS_KEY = bookSetting('--progress-key') || 'animebook:progress:' + new URL('../', location.href).pathname;
+function progress(f) {
+ try {
+ const saved = JSON.parse(localStorage.getItem(BOOK_PROGRESS_KEY) || '{}');
+ const p = saved && typeof saved === 'object' && !Array.isArray(saved) ? saved : {};
+ p.done = Array.isArray(p.done) ? p.done.filter(n => Number.isInteger(n) && n > 0) : [];
+ f(p); localStorage.setItem(BOOK_PROGRESS_KEY, JSON.stringify(p));
+ } catch {}
+}
+function boot() {
+ $('coverK').textContent = translate('chapterNumber', { n: CHAPTER.label ?? CHAPTER.number });
+ $('coverT').textContent = CHAPTER.title;
+ $('bHome').href = `../#ch${String(CHAPTER.number).padStart(2, '0')}`;
+ progress(p => { p.last = CHAPTER.number; });
+ document.getElementById('stage').setAttribute('aria-label', translate('stageLabelTitled', { title: CHAPTER.title }));
+ $('coverMeta').textContent = translate('aboutMinutes', { n: num(CHAPTER.minutes) });
+ buildSegs();
+ const qs = new URLSearchParams(location.search);
+ if (qs.has('beat')) {
+ $('cover').hidden = true;
+ seek(+qs.get('beat'), false);
+ P.t = +(qs.get('t') || 0);
+ evalTo(P.t);
+ if (P.audio) P.audio.currentTime = Math.max(0, P.t - (BEATS[P.i].pre || 0));
+ } else seek(0, false);
+ requestAnimationFrame(frame);
+}
diff --git a/site/little-red-riding-hood/lib/paper.js b/site/little-red-riding-hood/lib/paper.js
new file mode 100644
index 0000000..9de6ad5
--- /dev/null
+++ b/site/little-red-riding-hood/lib/paper.js
@@ -0,0 +1,383 @@
+/* paper.js — a paper-cutout stop-motion kit on top of the engine.
+ Sets are baked bitmaps (img/sets/, from tools/little-red-riding-hood/bake.py); puppets are live SVG pieces with the
+ same paper filter. Everything moves on a 12 fps clock (on twos), each frame with its own small hand jitter, so
+ pause, seek and ?beat=N&t=S show exactly the frame a viewer would see. */
+'use strict';
+const FPS = 12;
+
+// Filters, mouths and patterns live in their own hidden SVG: the engine clears the scene at every beat.
+const PAPER_DEFS = `<defs>
+ <filter id="paper" x="-15%" y="-15%" width="130%" height="135%" color-interpolation-filters="sRGB">
+ <feTurbulence type="fractalNoise" baseFrequency="0.035" numOctaves="2" seed="3" result="warp"/>
+ <feDisplacementMap in="SourceGraphic" in2="warp" scale="3.5" xChannelSelector="R" yChannelSelector="G" result="cut"/>
+ <feTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="3" seed="7" result="fib"/>
+ <feColorMatrix in="fib" type="matrix" values="0 0 0 0 .25 0 0 0 0 .17 0 0 0 0 .08 .5 0 0 0 -.14" result="tint"/>
+ <feComposite in="tint" in2="cut" operator="in" result="grain"/>
+ <feMerge result="tex"><feMergeNode in="cut"/><feMergeNode in="grain"/></feMerge>
+ <feDropShadow in="tex" dx="2.5" dy="3.5" stdDeviation="2.2" flood-color="#2a1608" flood-opacity=".38"/>
+ </filter>
+ <pattern id="check" width="10" height="10" patternUnits="userSpaceOnUse">
+ <rect width="10" height="10" fill="#f6efe0"/><rect width="5" height="5" fill="#c8322f"/><rect x="5" y="5" width="5" height="5" fill="#c8322f"/>
+ </pattern>
+ <g id="mX"><path d="M-8,-1 Q0,6 8,-1" fill="none" stroke="#5a2a1e" stroke-width="2.6" stroke-linecap="round"/></g>
+ <g id="mA"><path d="M-7,1 L7,1" fill="none" stroke="#5a2a1e" stroke-width="2.6" stroke-linecap="round"/></g>
+ <g id="mB"><ellipse rx="6.5" ry="2.6" fill="#6b1f1f"/></g>
+ <g id="mC"><ellipse rx="7" ry="4.6" fill="#6b1f1f"/><ellipse cy="2.6" rx="4" ry="1.8" fill="#e07a78"/></g>
+ <g id="mD"><path d="M-9,-3 Q0,-5 9,-3 Q8,9 0,10 Q-8,9 -9,-3Z" fill="#6b1f1f"/><ellipse cy="6.5" rx="5" ry="2.6" fill="#e07a78"/></g>
+ <g id="mE"><ellipse rx="5" ry="6" fill="#6b1f1f"/></g>
+ <g id="mF"><circle r="3.6" fill="#6b1f1f"/></g>
+ <g id="mG"><ellipse rx="6.5" ry="2.6" fill="#6b1f1f"/><path d="M-5,-1.5 h10" stroke="#f6efe0" stroke-width="2"/></g>
+ <g id="mH"><ellipse rx="6" ry="3.8" fill="#6b1f1f"/><ellipse cy="-1" rx="2.6" ry="1.6" fill="#e07a78"/></g>
+ <radialGradient id="vignette" cx="50%" cy="45%" r="75%"><stop offset="60%" stop-color="#1e0f05" stop-opacity="0"/><stop offset="100%" stop-color="#1e0f05" stop-opacity=".45"/></radialGradient>
+</defs>`;
+document.body.insertAdjacentHTML('afterbegin', `<svg width="0" height="0" style="position:absolute" aria-hidden="true">${PAPER_DEFS}</svg>`);
+// The exposure flicker is an HTML layer over the stage: changing it every frame inside the SVG would repaint the whole picture.
+const FLICKER = document.getElementById('stage').insertAdjacentElement('afterend', Object.assign(document.createElement('div'),
+ { style: 'position:absolute;left:0;top:0;width:1600px;height:900px;background:#000;opacity:0;pointer-events:none;will-change:opacity' }));
+
+// Seeded noise in [-1, 1]: the same frame always gets the same jitter.
+function jit(f, k) { let h = Math.imul(f * 374761393 + k * 668265263, 1274126177); h ^= h >>> 13; h = Math.imul(h, 1103515245); return ((h ^ (h >>> 16)) >>> 0) / 2147483648 - 1; }
+const ease = x => x <= 0 ? 0 : x >= 1 ? 1 : x * x * (3 - 2 * x);
+const span = (t, a, b) => ease((t - a) / (b - a));
+
+// draw(q, f) runs once per 12 fps frame with q the frame's time; a pure function of time, like every beat clock.
+function stopClock(D, draw) { let last = null; clockRun(t => { const f = Math.floor(t * FPS + 1e-6); if (f === last) return; last = f; draw(f / FPS, f); }, D); }
+
+/* ---------- camera over a baked set ----------
+ A view {x, y, z} is the world point at the frame's centre and the zoom. Moves: to(view, t0, dur) eases each given
+ key from where the camera is at t0 (zooms keep one world point still, as the engine's camera does); cut(view, t0).
+ Layers slide by their parallax factor k against the base view. soft(t0, on) swaps the far layers (k < 1) for their
+ blurred copies: shallow focus on close shots (on = 'all' blurs the puppets' plane too, for a set seen behind a close-up). Puppets go in cam.stage, on the k = 1 plane in front of `after`. */
+function paperCam(p, setName, v0 = {}, { after = null, stages = [] } = {}) {
+ const root = mk('g', {}, p), view = mk('g', {}, root), world = mk('g', {}, view), layers = [], ops = [], softs = [], shakes = [];
+ let stage = null; const stageAt = {};
+ for (const L of SETS[setName]) {
+ const g = mk('g', {}, world), [x, y, width, height] = L.box, img = { x, y, width, height, preserveAspectRatio: 'none' };
+ const sharp = mk('image', { href: `../img/sets/${setName}/${L.name}.webp`, ...img }, g);
+ const blur = L.soft ? mk('image', { href: `../img/sets/${setName}/${L.name}-soft.webp`, ...img, visibility: 'hidden' }, g) : null;
+ layers.push({ g, k: L.k, sharp, blur });
+ if (stages.includes(L.name)) layers.push({ g: stageAt[L.name] = mk('g', {}, world), k: L.k });
+ if (L.name === (after || 'house') || (!after && L.k === 1 && !stage)) layers.push({ g: stage = mk('g', {}, world), k: 1 });
+ }
+ mk('rect', { width: 1600, height: 900, fill: 'url(#vignette)' }, root);
+ // Parallax is measured from the set's own framing (base), wherever the beat's first view is.
+ const base = { x: 800, y: 450, z: 1 }, start = { ...base, ...v0 };
+ function at(t, n = ops.length) {
+ const s = { ...start };
+ for (let i = 0; i < n && ops[i].t0 <= t; i++) {
+ const o = ops[i], a = o.from || (o.from = at(o.t0, i)), q = o.dur ? ease(Math.min(1, (t - o.t0) / o.dur)) : 1;
+ const v = {}; for (const k in o.v) v[k] = typeof o.v[k] === 'function' ? o.v[k](t) : o.v[k]; // a key may follow
+ if ('z' in v) s.z = a.z * (v.z / a.z) ** q;
+ const u = 'z' in v && Math.abs(v.z - a.z) > 1e-6 ? (1 / s.z - 1 / a.z) / (1 / v.z - 1 / a.z) : q;
+ for (const k of ['x', 'y']) if (k in v) s[k] = a[k] + (v[k] - a[k]) * u;
+ }
+ return s;
+ }
+ const cam = { root, world, stage, stageAt, at,
+ to(v, t0, dur = 1) { ops.push({ v, t0, dur }); ops.sort((a, b) => a.t0 - b.t0); ops.forEach(o => delete o.from); return cam; },
+ cut: (v, t0) => cam.to(v, t0, 0),
+ soft(t0, on) { softs.push([t0, on]); softs.sort((a, b) => a[0] - b[0]); return cam; },
+ shake(t0, dur, amp = 10) { shakes.push([t0, dur, amp]); return cam; },
+ apply(q, f) {
+ const s = at(q);
+ let sx = 0, sy = 0;
+ for (const [t0, d, amp] of shakes) if (q >= t0 && q < t0 + d) { sx += jit(f, 91) * amp; sy += jit(f, 92) * amp; }
+ view.setAttribute('transform', `translate(${800 + sx} ${450 + sy}) scale(${s.z}) translate(${-s.x} ${-s.y})`);
+ const dx = s.x - base.x, dy = s.y - base.y;
+ let soft = false; for (const [t0, on] of softs) if (q >= t0) soft = on;
+ for (const L of layers) {
+ L.g.setAttribute('transform', `translate(${((1 - L.k) * dx).toFixed(1)} ${((1 - L.k) * dy).toFixed(1)})`);
+ if (L.blur) { const b = soft === 'all' || (soft && L.k < 1); vis(L.blur, b); vis(L.sharp, !b); } // never 'visible': it would show through a hidden camera
+ }
+ FLICKER.style.opacity = (.02 + .02 * jit(f, 30)).toFixed(3); // the exposure flicker of real frames
+ },
+ };
+ return cam;
+}
+
+/* ---------- small live pieces ---------- */
+// Chimney smoke: paper puffs that rise, drift and fade, one cycle every `every` seconds.
+function smoke(parent, x, y, n = 4, every = 3.2) {
+ const puffs = Array.from({ length: n }, () => { const g = mk('g', {}, parent); g.innerHTML = '<g filter="url(#paper)"><circle r="20" fill="#f4ecdc"/></g>'; return g; });
+ bakeAll(parent);
+ return q => puffs.forEach((g, i) => {
+ const u = ((q / every + i / n) % 1 + 1) % 1;
+ tf(g, `translate(${(x + 60 * u + 12 * Math.sin(u * 6)).toFixed(1)},${(y - 190 * u).toFixed(1)}) scale(${((14 + 30 * u) / 20).toFixed(3)})`);
+ g.setAttribute('opacity', (Math.min(1, u * 5) * (1 - u) * .95).toFixed(2));
+ });
+}
+
+// The mouth shape a clip's cues give `t` seconds into it ('X' rest before and after).
+const mouthAt = (clip, t) => { let m = 'X'; if (t < 0) return m; for (const [at, k] of MOUTHS[clip] || []) { if (at > t) break; m = k; } return m; };
+
+/* ---------- puppets ----------
+ A puppet is paper pieces on brass pins, built at its hip (0, 0) facing right, feet near y 166. pose(o, f) sets the
+ whole state for frame f; any key left out keeps its rest value. turn (1 … -1) squashes the flat figure to turn it
+ round: through the thin middle (|turn| < .55) the front head shows, past it the figure is the mirrored profile. */
+const pinAt = (x, y) => `<circle cx="${x}" cy="${y}" r="3.4" fill="#caa24c" stroke="#7d5f22" stroke-width="1.2"/>`;
+const tf = (el, s) => { if (el._t !== s) el.setAttribute('transform', el._t = s); };
+const vis = (el, on) => { const v = on ? 'inherit' : 'hidden'; if (el._v !== v) el.setAttribute('visibility', el._v = v); };
+function legPiece(id, sock, shoe, thigh = 94, shin = 82, w = 18) {
+ const k = thigh - 8, f = k + shin - 10;
+ return `<g data-p="${id}"><g filter="url(#paper)"><rect x="${-w / 2}" y="-4" width="${w}" height="${thigh}" rx="8" fill="${sock}"/></g>
+ <g data-p="${id}k"><g filter="url(#paper)"><rect x="${-w / 2 + 1}" y="${k - 6}" width="${w - 2}" height="${shin}" rx="7" fill="${sock}"/><path d="M-10,${f} h22 q13,0 13,10 v4 h-37 z" fill="${shoe}"/></g>${pinAt(0, k)}</g></g>`;
+}
+// The basket with its checked cloth; its handle hangs from (14.5 + dx, -64 + dy).
+const basketSVG = (dx, dy, id = 'basket') => `<g data-p="${id}" filter="url(#paper)"><g transform="translate(${dx},${dy})">
+ <path d="M-18,-22 Q14,-86 46,-22" fill="none" stroke="#8a5a2a" stroke-width="6"/>
+ <path d="M-26,-24 L54,-24 L45,20 L-17,20 Z" fill="#b07a3e"/><path d="M-22,-8 L50,-8 M-19,6 L47,6" stroke="#8a5a2a" stroke-width="2.5"/>
+ <path d="M-24,-26 Q14,-42 52,-26 L54,-18 L-26,-18 Z" fill="url(#check)"/></g></g>`;
+// A front arm hanging from its shoulder (x, y): sleeve, forearm, hand; extra goes in the hand group.
+const frontArm = (id, x, y, sleeve, skin, up = 60, fore = 56, extra = '') => `<g data-p="${id}"><g filter="url(#paper)"><rect x="${x - 8.5}" y="${y - 6}" width="17" height="${up + 6}" rx="8" fill="${sleeve}"/></g>
+ <g data-p="${id}f"><g filter="url(#paper)"><rect x="${x - 6.5}" y="${y + up - 6}" width="13" height="${fore}" rx="6" fill="${skin}"/><circle cx="${x}" cy="${y + up + fore - 4}" r="9.5" fill="${skin}"/>${extra}</g>
+ ${pinAt(x, y + up - 2)}</g>${pinAt(x, y)}</g>`;
+// The raised index finger (with its thumb) on the hand at (x, y): on the face side, so it never reads as another gesture.
+const fingerSVG = (x, y, skin) => `<g data-p="finger" filter="url(#paper)"><rect x="${x + 2.5}" y="${y + 2}" width="6.5" height="24" rx="3.2" fill="${skin}"/><ellipse cx="${x - 9.5}" cy="${y - 4}" rx="5" ry="7.5" transform="rotate(-35,${x - 9.5},${y - 4})" fill="${skin}"/><path d="M${x - 6.5},${y + 5} q3,4 7,0" stroke="#c99878" stroke-width="1.6" fill="none"/></g>`;
+function armsF(P, o, j, sx, sy, up) { // the two front arms: r = screen right, l = screen left; 0 hangs down
+ tf(P.rArm, `rotate(${(o.rua + j(21) * .6).toFixed(2)},${sx},${sy})`); tf(P.rArmf, `rotate(${(o.rfa + j(22) * .6).toFixed(2)},${sx},${sy + up - 2})`);
+ tf(P.lArm, `rotate(${(o.lua + j(23) * .6).toFixed(2)},${-sx},${sy})`); tf(P.lArmf, `rotate(${(o.lfa + j(24) * .6).toFixed(2)},${-sx},${sy + up - 2})`);
+}
+// A bunch of flowers held at (x, y), kept upright by its group; `n` of its seven flowers show (bouquet: 0 … 7).
+const FLOWER_COLS = ['#d6493f', '#f6efe0', '#efae48', '#d6493f', '#e88ab0', '#f6efe0', '#efae48'];
+const bouquetSVG = (x, y, id) => `<g data-p="${id}"><g filter="url(#paper)"><path d="M${x},${y} l-14,-46 M${x},${y} l0,-54 M${x},${y} l14,-46 M${x},${y} l-24,-34 M${x},${y} l24,-34" stroke="#4f7a34" stroke-width="3"/></g>
+ ${FLOWER_COLS.map((c, i) => { const a = (-60 + i * 20) * Math.PI / 180, r = 44 + (i % 2) * 12;
+ return `<g data-p="${id}${i}" filter="url(#paper)"><circle cx="${(x + r * Math.sin(a)).toFixed(1)}" cy="${(y - r * Math.cos(a)).toFixed(1)}" r="9" fill="${c}"/><circle cx="${(x + r * Math.sin(a)).toFixed(1)}" cy="${(y - r * Math.cos(a)).toFixed(1)}" r="3" fill="#efae48"/></g>`; }).join('')}</g>`;
+function bouquetPose(P, id, n, rot, x, y) {
+ vis(P[id], n > 0); tf(P[id], `rotate(${rot.toFixed(2)},${x},${y})`);
+ for (let i = 0; i < 7; i++) vis(P[id + i], i < n);
+}
+function pieces(g) { const o = {}; g.querySelectorAll('[data-p]').forEach(e => o[e.dataset.p] = e); return o; }
+function face(h, o) { // eyes and mouth of one head
+ h.querySelectorAll('.eyeO').forEach(e => vis(e, !o.shut)); h.querySelectorAll('.eyeC').forEach(e => vis(e, !!o.shut));
+ h.querySelectorAll('.mouth').forEach(e => { const m = '#m' + (o.mouth || 'X'); if (e._m !== m) e.setAttribute('href', e._m = m); });
+}
+const REST_RED = { x: 0, y: 0, s: 1, turn: 1, near: 0, far: 0, kNear: 0, kFar: 0, cape: 3, ua: -8, fa: -78, basket: true, swing: 0, headR: 0, nod: 0, head: 'P', mouth: 'X', shut: false, hop: 0, rua: 6, rfa: -4, lua: -6, lfa: 4, bouquet: 0 };
+function redPuppet(parent) {
+ const g = mk('g', {}, parent);
+ g.innerHTML = `<g data-p="body">
+ <g data-p="capeB" filter="url(#paper)"><path d="M-12,-138 C-46,-118 -78,-30 -100,50 Q-40,64 14,44 L22,-118 Z" fill="#a92a27"/></g>
+ ${legPiece('legF', '#d8d1c2', '#2b1a10')}${legPiece('legN', '#f2ede1', '#3a2418')}
+ <g filter="url(#paper)"><path d="M-38,-46 L38,-46 C48,0 58,30 64,56 Q0,70 -64,56 C-58,30 -48,0 -38,-46 Z" fill="#2d4f86"/></g>
+ <g filter="url(#paper)"><path d="M6,-42 L36,-42 C44,0 50,30 54,52 Q30,60 8,58 Z" fill="#f4efe2"/></g>
+ <g filter="url(#paper)"><path d="M-28,-128 L26,-128 L34,-42 L-34,-42 Z" fill="#2d4f86"/><rect x="-8" y="-150" width="16" height="28" fill="#f6d2b5"/></g>
+ <g filter="url(#paper)"><path d="M-30,-152 Q5,-160 28,-140 L36,-94 Q0,-84 -50,-88 Q-48,-122 -30,-152 Z" fill="#c8322f"/></g>
+ <g data-p="headP"><g filter="url(#paper)">
+ <path d="M-50,-190 C-55,-252 32,-264 54,-214 C64,-188 58,-160 40,-148 L-40,-140 C-56,-150 -52,-172 -50,-190 Z" fill="#c8322f"/>
+ <circle cx="14" cy="-192" r="40" fill="#f6d2b5"/><circle cx="53" cy="-189" r="7" fill="#f6d2b5"/>
+ <path d="M-18,-214 Q16,-242 52,-210 Q32,-220 12,-205 Q-4,-214 -18,-198 Z" fill="#6b3b22"/>
+ <path d="M-46,-195 C-46,-247 42,-260 60,-212 C42,-240 -8,-242 -20,-196 C-24,-170 -16,-150 -6,-142 L-40,-140 C-52,-155 -48,-176 -46,-195 Z" fill="#b02c29"/>
+ <circle cx="31" cy="-176" r="8.5" fill="#ef9a8a" opacity=".8"/>
+ <g class="eyeO"><ellipse cx="34" cy="-198" rx="4.5" ry="6.2" fill="#22150e"/></g>
+ <g class="eyeC"><path d="M29,-197 Q34,-193 39,-197" fill="none" stroke="#22150e" stroke-width="2.4" stroke-linecap="round"/></g>
+ <use class="mouth" href="#mX" transform="translate(41,-172) scale(.85)"/></g>${pinAt(0, -146)}</g>
+ <g data-p="arm"><g filter="url(#paper)"><rect x="6" y="-134" width="17" height="64" rx="8" fill="#f4efe2"/></g>
+ <g data-p="fore"><g filter="url(#paper)"><rect x="8.5" y="-80" width="12" height="54" rx="6" fill="#f6d2b5"/><circle cx="14.5" cy="-26" r="9" fill="#f6d2b5"/></g>
+ ${basketSVG(0, 0)}${bouquetSVG(14.5, -26, 'bq')}${pinAt(14.5, -76)}</g>
+ ${pinAt(14.5, -128)}</g></g>
+ <g data-p="bodyF">
+ <g filter="url(#paper)"><path d="M-36,-140 L36,-140 L72,50 Q0,64 -72,50 Z" fill="#a92a27"/></g>
+ <g filter="url(#paper)"><rect x="-21" y="46" width="16" height="114" rx="7" fill="#f2ede1"/><rect x="5" y="46" width="16" height="114" rx="7" fill="#f2ede1"/>
+ <ellipse cx="-13" cy="164" rx="12" ry="7" fill="#3a2418"/><ellipse cx="13" cy="164" rx="12" ry="7" fill="#3a2418"/></g>
+ <g filter="url(#paper)"><path d="M-40,-46 L40,-46 C52,0 62,30 68,56 Q0,70 -68,56 C-62,30 -52,0 -40,-46 Z" fill="#2d4f86"/></g>
+ <g filter="url(#paper)"><path d="M-20,-42 L20,-42 L28,52 Q0,58 -28,52 Z" fill="#f4efe2"/></g>
+ <g filter="url(#paper)"><path d="M-30,-128 L30,-128 L38,-42 L-38,-42 Z" fill="#2d4f86"/><rect x="-8" y="-150" width="16" height="28" fill="#f6d2b5"/></g>
+ ${frontArm('lArm', -30, -126, '#f4efe2', '#f6d2b5', 54, 50, bouquetSVG(-30, -26, 'bqF'))}
+ ${frontArm('rArm', 30, -126, '#f4efe2', '#f6d2b5', 54, 50, basketSVG(15.5, 38, 'basketF'))}
+ <g filter="url(#paper)"><path d="M-40,-152 Q0,-166 40,-152 L52,-96 Q0,-82 -52,-96 Z" fill="#c8322f"/></g>
+ </g>
+ <g data-p="headF"><g filter="url(#paper)">
+ <ellipse cx="0" cy="-194" rx="62" ry="64" fill="#c8322f"/><circle cx="0" cy="-188" r="42" fill="#f6d2b5"/>
+ <path d="M-38,-200 Q0,-246 38,-200 Q20,-212 0,-210 Q-20,-212 -38,-200 Z" fill="#6b3b22"/>
+ <path d="M-61,-192 C-61,-264 61,-264 61,-192 C50,-238 -50,-238 -61,-192 Z" fill="#b02c29"/>
+ <circle cx="-23" cy="-176" r="8" fill="#ef9a8a" opacity=".8"/><circle cx="23" cy="-176" r="8" fill="#ef9a8a" opacity=".8"/>
+ <g class="eyeO"><ellipse cx="-14" cy="-196" rx="4.5" ry="6.2" fill="#22150e"/><ellipse cx="14" cy="-196" rx="4.5" ry="6.2" fill="#22150e"/></g>
+ <g class="eyeC"><path d="M-19,-195 Q-14,-191 -9,-195 M9,-195 Q14,-191 19,-195" fill="none" stroke="#22150e" stroke-width="2.4" stroke-linecap="round"/></g>
+ <use class="mouth" href="#mX" transform="translate(0,-166)"/></g></g>`;
+ bakeAll(g);
+ const P = pieces(g);
+ return { g, pose(o, f) {
+ o = { ...REST_RED, ...o };
+ const j = k => jit(f, k), front = o.head === 'F' || Math.abs(o.turn) < .55;
+ tf(g, `translate(${(o.x + j(1) * .8).toFixed(1)},${(o.y + o.hop + j(2) * .6).toFixed(1)}) scale(${o.s}) rotate(${(j(3) * .5).toFixed(2)})`);
+ tf(P.body, `scale(${o.turn.toFixed(3)},1)`); vis(P.body, !front); vis(P.bodyF, front);
+ armsF(P, o, j, 30, -126, 54);
+ tf(P.basketF, `rotate(${(-(o.rua + o.rfa) + o.swing).toFixed(2)},45.5,-26)`); vis(P.basketF, o.basket);
+ bouquetPose(P, 'bqF', o.bouquet, -(o.lua + o.lfa), -30, -26);
+ tf(P.legN, `rotate(${(o.near + j(4) * .6).toFixed(2)})`); tf(P.legNk, `rotate(${o.kNear.toFixed(2)},0,86)`);
+ tf(P.legF, `rotate(${(o.far + j(5) * .6).toFixed(2)})`); tf(P.legFk, `rotate(${o.kFar.toFixed(2)},0,86)`);
+ tf(P.capeB, `rotate(${(o.cape + j(6) * .5).toFixed(2)},-12,-138)`);
+ const ua = o.ua + j(7) * .6, fa = o.fa + j(8) * .6;
+ tf(P.arm, `rotate(${ua.toFixed(2)},14.5,-128)`); tf(P.fore, `rotate(${fa.toFixed(2)},14.5,-76)`);
+ tf(P.basket, `rotate(${(-(ua + fa) + o.swing).toFixed(2)},14.5,-64)`); vis(P.basket, o.basket);
+ bouquetPose(P, 'bq', o.bouquet, -(ua + fa) + 10, 14.5, -26);
+ vis(P.headP, !front); vis(P.headF, front);
+ const hr = `translate(0,${o.nod.toFixed(1)}) rotate(${(o.headR + j(9) * .7).toFixed(2)},0,-146)`;
+ tf(P.headP, hr); tf(P.headF, hr);
+ face(front ? P.headF : P.headP, o);
+ } };
+}
+// Blinks: closed for two frames at each listed time.
+const blinking = (q, times) => times.some(b => q >= b && q < b + 2 / FPS);
+
+// Mother: long green dress and apron, hair in a bun; one arm (the near one) that holds out, points or waves.
+// Feet at y 212. Her basket hangs from her hand.
+const REST_MOM = { x: 0, y: 0, s: 1, turn: 1, ua: 6, fa: -6, basket: false, finger: false, swing: 0, head: 'P', headR: 0, brow: 0, mouth: 'X', shut: false, hop: 0, rua: 6, rfa: -4, lua: -6, lfa: 4 };
+function motherPuppet(parent) {
+ const g = mk('g', {}, parent), skin = '#f2c9a6', dress = '#4f7a5a', hair = '#6b3b22', ink = '#22150e';
+ g.innerHTML = `<g data-p="body">
+ <g filter="url(#paper)"><path d="M20,198 h30 q12,0 12,9 v5 h-42 z M-14,198 h26 q10,0 10,9 v5 h-36 z" fill="#3a2418"/></g>
+ <g filter="url(#paper)"><path d="M-44,-14 L44,-14 C56,60 70,140 78,200 Q0,214 -78,200 C-70,140 -56,60 -44,-14 Z" fill="${dress}"/></g>
+ <g filter="url(#paper)"><path d="M10,-10 L44,-10 C54,60 62,130 68,190 Q40,198 14,196 Z" fill="#f4efe2"/></g>
+ <g filter="url(#paper)"><path d="M-34,-150 L30,-150 L44,-10 L-44,-10 Z" fill="${dress}"/><rect x="-9" y="-178" width="18" height="32" fill="${skin}"/>
+ <path d="M-28,-152 Q4,-140 32,-152 L34,-136 Q4,-124 -30,-136 Z" fill="#f4efe2"/></g>
+ <g data-p="headP"><g filter="url(#paper)">
+ <circle cx="-32" cy="-240" r="22" fill="${hair}"/>
+ <circle cx="14" cy="-212" r="42" fill="${skin}"/><circle cx="55" cy="-209" r="7.5" fill="${skin}"/>
+ <path d="M-38,-206 C-42,-262 40,-274 58,-226 Q30,-248 4,-238 Q-10,-228 -14,-202 Q-20,-180 -10,-170 L-34,-176 C-42,-188 -40,-198 -38,-206 Z" fill="${hair}"/>
+ <circle cx="33" cy="-196" r="8" fill="#ef9a8a" opacity=".7"/>
+ <g class="eyeO"><ellipse cx="36" cy="-218" rx="4.5" ry="6" fill="${ink}"/></g>
+ <g class="eyeC"><path d="M31,-217 Q36,-213 41,-217" fill="none" stroke="${ink}" stroke-width="2.4" stroke-linecap="round"/></g>
+ <path data-p="browP" d="M28,-233 L44,-231" stroke="${hair}" stroke-width="3.5" stroke-linecap="round"/>
+ <use class="mouth" href="#mX" transform="translate(42,-190) scale(.85)"/></g>${pinAt(0, -174)}</g>
+ <g data-p="arm"><g filter="url(#paper)"><rect x="8" y="-148" width="17" height="62" rx="8" fill="#f4efe2"/></g>
+ <g data-p="fore"><g filter="url(#paper)"><rect x="10" y="-92" width="13" height="58" rx="6" fill="${skin}"/><circle cx="16.5" cy="-32" r="10" fill="${skin}"/>
+ ${fingerSVG(16.5, -32, skin)}</g>
+ ${basketSVG(2, 32)}${pinAt(16.5, -88)}</g>${pinAt(16.5, -142)}</g></g>
+ <g data-p="bodyF">
+ <g filter="url(#paper)"><ellipse cx="-18" cy="206" rx="13" ry="7" fill="#3a2418"/><ellipse cx="18" cy="206" rx="13" ry="7" fill="#3a2418"/></g>
+ <g filter="url(#paper)"><path d="M-46,-14 L46,-14 C58,60 72,140 80,200 Q0,214 -80,200 C-72,140 -58,60 -46,-14 Z" fill="${dress}"/></g>
+ <g filter="url(#paper)"><path d="M-26,-10 L26,-10 L36,192 Q0,198 -36,192 Z" fill="#f4efe2"/></g>
+ <g filter="url(#paper)"><path d="M-36,-150 L36,-150 L46,-10 L-46,-10 Z" fill="${dress}"/><rect x="-9" y="-178" width="18" height="32" fill="${skin}"/>
+ <path d="M-30,-152 Q0,-138 30,-152 L32,-140 Q0,-124 -32,-140 Z" fill="#f4efe2"/></g>
+ ${frontArm('lArm', -32, -142, '#f4efe2', skin, 56, 58)}
+ ${frontArm('rArm', 32, -142, '#f4efe2', skin, 56, 58, fingerSVG(32, -32, skin).replace('data-p="finger"', 'data-p="fingerF"'))}
+ </g>
+ <g data-p="headF"><g filter="url(#paper)">
+ <circle cx="0" cy="-262" r="20" fill="${hair}"/><circle cx="0" cy="-210" r="44" fill="${skin}"/>
+ <path d="M-47,-206 C-50,-272 50,-272 47,-206 Q34,-240 0,-238 Q-34,-240 -47,-206 Z" fill="${hair}"/>
+ <circle cx="-25" cy="-194" r="8" fill="#ef9a8a" opacity=".7"/><circle cx="25" cy="-194" r="8" fill="#ef9a8a" opacity=".7"/>
+ <g class="eyeO"><ellipse cx="-15" cy="-214" rx="4.5" ry="6" fill="${ink}"/><ellipse cx="15" cy="-214" rx="4.5" ry="6" fill="${ink}"/></g>
+ <g class="eyeC"><path d="M-20,-213 Q-15,-209 -10,-213 M10,-213 Q15,-209 20,-213" fill="none" stroke="${ink}" stroke-width="2.4" stroke-linecap="round"/></g>
+ <path data-p="browL" d="M-23,-229 L-8,-228" stroke="${hair}" stroke-width="3.5" stroke-linecap="round"/>
+ <path data-p="browR" d="M8,-228 L23,-229" stroke="${hair}" stroke-width="3.5" stroke-linecap="round"/>
+ <use class="mouth" href="#mX" transform="translate(0,-186)"/></g></g>`;
+ bakeAll(g);
+ const P = pieces(g);
+ return { g, pose(o, f) {
+ o = { ...REST_MOM, ...o };
+ const j = k => jit(f, k), front = o.head === 'F' || Math.abs(o.turn) < .55;
+ tf(g, `translate(${(o.x + j(11) * .8).toFixed(1)},${(o.y + o.hop + j(12) * .6).toFixed(1)}) scale(${o.s}) rotate(${(j(13) * .5).toFixed(2)})`);
+ tf(P.body, `scale(${o.turn.toFixed(3)},1)`); vis(P.body, !front); vis(P.bodyF, front);
+ armsF(P, o, j, 32, -142, 56); vis(P.fingerF, o.finger);
+ const ua = o.ua + j(17) * .6, fa = o.fa + j(18) * .6;
+ tf(P.arm, `rotate(${ua.toFixed(2)},16.5,-142)`); tf(P.fore, `rotate(${fa.toFixed(2)},16.5,-88)`);
+ tf(P.basket, `rotate(${(-(ua + fa) + o.swing).toFixed(2)},16.5,-32)`); vis(P.basket, o.basket); vis(P.finger, o.finger);
+ vis(P.headP, !front); vis(P.headF, front);
+ const hr = `rotate(${(o.headR + j(19) * .7).toFixed(2)},0,-174)`;
+ tf(P.headP, hr); tf(P.headF, hr);
+ // brow > 0: worried (inner ends up)
+ tf(P.browP, `rotate(${(-12 * o.brow).toFixed(1)},28,-233)`);
+ tf(P.browL, `rotate(${(-14 * o.brow).toFixed(1)},-8,-228)`); tf(P.browR, `rotate(${(14 * o.brow).toFixed(1)},8,-228)`);
+ face(front ? P.headF : P.headP, o);
+ } };
+}
+
+/* ---------- baking puppet pieces ----------
+ Running the paper filter live on every piece costs too much once a close-up enlarges them, so every filtered
+ piece is drawn once to a bitmap (at RES px per unit) and replaced by that image. Parts that change (eyes, mouths,
+ brows, pieces with data-p) stay live; a filtered live part is baked on its own. Identical pieces share one bitmap. */
+const RES = 4, bakedReady = new Map(), bakedJobs = new Map(), PAPER_EXTRA = []; // extra defs (patterns) other files add
+// Pieces baked ahead of time (tools/little-red-riding-hood/bake_puppets.py): img/puppets/<hash>.webp, listed in
+// window.BAKED. A piece missing from it (just edited) is baked here in the browser; ?bake ignores the list.
+const BAKED = new URLSearchParams(location.search).has('bake') ? {} : (window.BAKED || {});
+const keyHash = k => { let h = 2166136261; for (let i = 0; i < k.length; i++) h = Math.imul(h ^ k.charCodeAt(i), 16777619); return (h >>> 0).toString(16).padStart(8, '0'); };
+const isLive = e => e.hasAttribute('data-p') || ['eyeO', 'eyeC', 'mouth'].some(c => e.classList.contains(c));
+function rasterize(svg, w, h) {
+ return new Promise((ok, no) => {
+ const img = new Image();
+ img.onload = () => { const c = document.createElement('canvas'); c.width = w; c.height = h; c.getContext('2d').drawImage(img, 0, 0, w, h); URL.revokeObjectURL(img.src); c.toBlob(b => ok(URL.createObjectURL(b))); };
+ img.onerror = no;
+ img.src = URL.createObjectURL(new Blob([svg], { type: 'image/svg+xml' }));
+ });
+}
+function bakeAll(root) {
+ // Measure everything first, then change the DOM: a getBBox after each change would lay the page out again every time.
+ const covered = el => { for (let c = el, a = el.parentNode; a && a !== root; c = a, a = a.parentNode) if (isLive(c)) return false; else if (a.hasAttribute?.('filter')) return true; return false; };
+ const items = [];
+ for (const el of root.querySelectorAll('[filter]')) {
+ if (covered(el)) continue; // drawn into a filtered ancestor's bitmap
+ const bb = el.getBBox(), x = Math.floor(bb.x - 10), y = Math.floor(bb.y - 10), w = Math.ceil(bb.width + 22), h = Math.ceil(bb.height + 24);
+ const clone = el.cloneNode(true);
+ ['transform', 'visibility', 'data-p', 'opacity'].forEach(a => clone.removeAttribute(a));
+ [...clone.children].forEach((c, i) => { if (isLive(el.children[i])) c.remove(); });
+ items.push({ el, x, y, w, h, html: clone.outerHTML });
+ }
+ const jobs = [];
+ for (const { el, x, y, w, h, html } of items) {
+ const key = `${x} ${y} ${w} ${h}|${html}`;
+ const apply = url => {
+ if (!el.hasAttribute('filter')) return;
+ el.removeAttribute('filter');
+ [...el.children].forEach(c => { if (!isLive(c)) c.remove(); });
+ el.insertBefore(mk('image', { href: url, x, y, width: w, height: h }), el.firstChild);
+ };
+ const file = BAKED[keyHash(key)];
+ if (file) { apply(`../img/puppets/${file}`); continue; }
+ if (bakedReady.has(key)) { apply(bakedReady.get(key)); continue; }
+ if (!bakedJobs.has(key)) bakedJobs.set(key, rasterize(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${w * RES}" height="${h * RES}" viewBox="${x} ${y} ${w} ${h}">${PAPER_DEFS}<defs>${PAPER_EXTRA.join('')}</defs>${html}</svg>`, w * RES, h * RES)
+ .then(url => (bakedReady.set(key, url), url)));
+ jobs.push(bakedJobs.get(key).then(apply));
+ }
+ return Promise.all(jobs);
+}
+// Build the book's pieces once at load, off screen, so their bitmaps are ready before the first beat needs them.
+function paperWarm(build) {
+ const svg = mk('svg', { width: 1, height: 1, style: 'position:absolute;left:-10px;top:-10px' });
+ document.body.appendChild(svg);
+ build(mk('g', {}, svg));
+ return bakeAll(svg).then(() => svg.remove());
+}
+
+/* ---------- walking ----------
+ A compass walk: the stance foot stays planted while the hip rides over it, so feet never slide. tau seconds into
+ the walk, `period` s per two steps; returns leg angles and knee bends (degrees), how far the hip has travelled (d)
+ and how far it has dropped from standing (drop), both in the puppet's own units. */
+function walk(tau, { L = 166, A = 22, period = 1, knee = 38 } = {}) {
+ tau = Math.max(0, tau);
+ const a = A * Math.PI / 180, ph = 2 * Math.PI * tau / period, j = Math.floor((ph + Math.PI / 2) / Math.PI);
+ const ts = (j % 2 ? 1 : -1) * a * Math.sin(ph), near = a * Math.sin(ph) * 180 / Math.PI;
+ const swing = knee * Math.max(0, Math.cos(ph - j * Math.PI)), nearStance = j % 2 === 1;
+ return { ph, d: j * 2 * L * Math.sin(a) - L * Math.sin(ts), drop: L * (1 - Math.cos(ts)),
+ near, far: -near, kNear: nearStance ? 0 : swing, kFar: nearStance ? swing : 0 };
+}
+
+// A tree trunk passing close in front of the camera, right to left: 'in' ends with the frame covered (a scene
+// ends), 'out' starts covered and uncovers it (the next scene begins).
+function trunkWipe(p, t0, dur, mode = 'in') {
+ const g = mk('g', {}, p);
+ g.innerHTML = `<g filter="url(#paper)"><path d="M0,-40 C40,200 -30,600 20,940 L2100,940 L2100,-40 Z" fill="#5a3b24"/>
+ ${[160, 420, 700, 980, 1300, 1600].map((x, i) => `<path d="M${x},-40 C${x + 30},${200 + i * 40} ${x - 40},${560 - i * 30} ${x + 10},940" stroke="#46301d" stroke-width="${10 + (i % 3) * 5}" fill="none"/>`).join('')}</g>`;
+ bakeAll(g);
+ const [a, b] = mode === 'in' ? [1650, -200] : [-200, -2150];
+ return q => { const u = Math.min(1, Math.max(0, (q - t0) / dur)); vis(g, mode === 'in' ? u > 0 : u < 1); tf(g, `translate(${(a + (b - a) * ease(u)).toFixed(0)},0)`); };
+}
+
+// A piece of the set that sits in front of puppets (a trunk, a bush, a blanket): drawn like a puppet piece, baked.
+function prop(parent, svg, attrs = {}) { const g = mk('g', attrs, parent); g.innerHTML = svg; bakeAll(g); return g; }
+
+// The iris closing on (cx, cy) between t0 and t0 + dur, as in old films; then black.
+function iris(p, t0, dur, cx, cy) {
+ const e = mk('path', { fill: '#120a05', 'fill-rule': 'evenodd' }, p);
+ return q => {
+ const u = (q - t0) / dur; vis(e, u > 0);
+ if (u <= 0) return;
+ const r = Math.max(0, 1900 * (1 - ease(Math.min(1, u))));
+ e.setAttribute('d', `M-50,-50 H1650 V950 H-50 Z M${cx - r},${cy} a${r},${r} 0 1 0 ${2 * r},0 a${r},${r} 0 1 0 ${-2 * r},0 Z`);
+ };
+}
+// The title card at the end: a paper label that drops in on its pin.
+function endCard(p, t0) {
+ const g = prop(p, `<g filter="url(#paper)"><rect x="560" y="330" width="480" height="240" rx="14" fill="#f3e9d2"/><rect x="580" y="350" width="440" height="200" rx="8" fill="none" stroke="#c8322f" stroke-width="5"/></g>
+ <text x="800" y="478" text-anchor="middle" font-family="Georgia, serif" font-size="78" font-style="italic" fill="#5a2a1e">The End</text>${pinAt(800, 342)}`);
+ return q => { const u = (q - t0) * FPS; vis(g, u >= 0); const d = [-60, -20, 8, -3, 0][Math.min(4, Math.max(0, Math.floor(u / 2)))]; tf(g, `translate(0,${d})`); };
+}
diff --git a/site/little-red-riding-hood/lib/units.css b/site/little-red-riding-hood/lib/units.css
new file mode 100644
index 0000000..e9c62cb
--- /dev/null
+++ b/site/little-red-riding-hood/lib/units.css
@@ -0,0 +1,79 @@
+/* The unit headers of a book's contents page, the same in every book: a strip of chalkboard per unit, with the unit's
+ label and title and a sketch of its ideas (UNIT_ART, from the book's own unit-art.js) drawn in the unit colour --c.
+ Markup and the scroll observer are in units.js. Uses the contents page's --book, --ui, --chalk and --ease. */
+.unit { position: relative; max-width: 1212px; margin: 0 auto; padding: 28px 16px 0; }
+.unit h2 { position: relative; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; min-height: 168px; margin: 0 0 16px; padding-top: 130px; font: 500 28px/1.2 var(--book); }
+.unit .grid { position: relative; }
+.unit::before { content: ""; position: absolute; inset: 0 16px auto; height: 208px; border-radius: 22px; pointer-events: none;
+ background: radial-gradient(ellipse 46% 90% at 74% 55%, color-mix(in srgb, var(--c) 11%, transparent), transparent 70%); }
+.unit-art { position: absolute; top: 20px; right: 28px; width: min(580px, 56%); height: auto; overflow: visible; pointer-events: none;
+ color: var(--c); fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
+.unit-art text { fill: currentColor; stroke: none; font-family: var(--book); font-style: italic; }
+.unit-art .a { color: var(--chalk); opacity: .55; }
+.unit-art .faint { opacity: .22; }
+.unit-art .d { stroke-dasharray: 1 1; stroke-dashoffset: 1; }
+.unit-art .t { opacity: 0; }
+.seen .unit-art .d { animation: art-draw 1.1s cubic-bezier(.5, 0, .3, 1) forwards; animation-delay: calc(var(--k) * 55ms + 120ms); }
+.seen .unit-art .t { animation: art-fade .6s ease-out forwards; animation-delay: calc(var(--k) * 55ms + 300ms); }
+.seen .unit-art .a.t { animation-name: art-fade-a; }
+@keyframes art-draw { to { stroke-dashoffset: 0; } }
+@keyframes art-fade { to { opacity: 1; } }
+@keyframes art-fade-a { to { opacity: .55; } }
+/* After the drawing, each sketch keeps one small motion that belongs to its topic. */
+.unit-art g { transform-box: fill-box; }
+.seen .unit-art .swap-a { animation: swap-a 6s var(--ease) 2.4s infinite; }
+.seen .unit-art .swap-b { animation: swap-b 6s var(--ease) 2.4s infinite; }
+@keyframes swap-a { 0%, 30%, 100% { transform: none; } 45%, 80% { transform: translate(80px, 0); } 37% { transform: translate(40px, -30px); } 88% { transform: translate(40px, 30px); } }
+@keyframes swap-b { 0%, 30%, 100% { transform: none; } 45%, 80% { transform: translate(-80px, 0); } 37% { transform: translate(-40px, 30px); } 88% { transform: translate(-40px, -30px); } }
+.seen .unit-art .step { animation: art-fade .6s ease-out forwards, step 4s ease-in-out infinite; animation-delay: calc(var(--k) * 55ms + 300ms), calc(var(--k) * 300ms + 2s); }
+@keyframes step { 0%, 20%, 100% { fill-opacity: 1; } 10% { fill-opacity: .3; } }
+.unit-art .hop, .unit-art .ride { offset-rotate: 0deg; }
+.seen .unit-art .hop { animation: art-fade .4s ease-out 2s forwards, along 3.4s linear 2s infinite; }
+.unit-art .orbit { offset-rotate: 0deg; }
+.seen .unit-art .orbit { animation: art-fade .4s ease-out 2s forwards, along 9s linear 2s infinite; }
+.seen .unit-art .ride { animation: art-fade .4s ease-out 2s forwards, along 4s ease-in-out 2s infinite alternate; }
+@keyframes along { from { offset-distance: 0%; } to { offset-distance: 100%; } }
+.unit-art .pie { stroke: currentColor; stroke-linecap: butt; stroke-dasharray: 0 100; }
+.seen .unit-art .pie { animation: art-fade .4s ease-out 1.6s forwards, pie 5s var(--ease) 1.6s infinite; }
+@keyframes pie { 0% { stroke-dasharray: 0 100; } 35%, 85% { stroke-dasharray: 25 100; } 100% { stroke-dasharray: 0 100; } }
+.seen .unit-art .tilt { transform-box: view-box; transform-origin: 300px 72px; animation: tilt 4.8s ease-in-out 2s infinite; }
+@keyframes tilt { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-4deg); } 60% { transform: rotate(2deg); } }
+.seen .unit-art .spin { transform-box: view-box; transform-origin: 320px 95px; animation: spin 5s cubic-bezier(.2, .7, .2, 1) 2s infinite; }
+@keyframes spin { from { transform: rotate(0); } 70%, to { transform: rotate(1530deg); } }
+.seen .unit-art .feed-in { animation: feed-in 4s ease-in-out 2s infinite; }
+.seen .unit-art .feed-out { opacity: 0; animation: feed-out 4s ease-in-out 2s infinite; }
+@keyframes feed-in { 0% { transform: none; opacity: 1; } 40% { transform: translate(100px, 0); opacity: 0; } 41%, 100% { transform: none; opacity: 0; } 95% { opacity: 1; } }
+@keyframes feed-out { 0%, 45% { transform: translate(-40px, 0); opacity: 0; } 70%, 90% { transform: none; opacity: 1; } 100% { opacity: 0; } }
+.unit-art .cell { opacity: .25; }
+.seen .unit-art .cell { animation: cell 5s ease-in-out infinite; animation-delay: calc(var(--j) * .5s + 2s); }
+@keyframes cell { 0%, 100% { opacity: .25; } 15%, 60% { opacity: 1; } }
+.unit-art .cut, .unit-art .shade { opacity: 0; }
+.seen .unit-art .cut { animation: cut 4s ease-in-out 2s infinite; }
+@keyframes cut { 0%, 100% { opacity: 0; } 30%, 70% { opacity: .5; } }
+.seen .unit-art .shade { animation: shade 1s ease-out 1.6s forwards; }
+@keyframes shade { to { opacity: .14; } }
+.seen .unit-art .diag { animation: art-draw 1.1s cubic-bezier(.5, 0, .3, 1) forwards, redraw 4s ease-in-out 2.5s infinite; }
+@keyframes redraw { 0%, 15% { stroke-dashoffset: 1; } 50%, 100% { stroke-dashoffset: 0; } }
+.seen .unit-art .root { animation: art-fade .4s ease-out 1.8s forwards, root 2.4s ease-in-out 2.2s infinite; }
+@keyframes root { 0%, 100% { r: 7px; } 50% { r: 11px; } }
+.seen .unit-art .breathe { transform-box: view-box; transform-origin: 380px 140px; animation: breathe 4s ease-in-out 2s infinite alternate; }
+@keyframes breathe { from { transform: scaleY(1); } to { transform: scaleY(.35); } }
+/* The label and the title share a line when they fit; a long title wraps below the label instead of running off. */
+.unit h2 .title { min-width: 0; text-wrap: balance; }
+.unit h2 .label { font: 600 14px var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--c); white-space: nowrap; }
+/* Keep the sketches cheap: each is its own layer, so its loop repaints only itself, and loops pause while their unit is
+ off screen or under the sticky bar (units.js toggles .live), so the bar's blur is not redrawn every frame. */
+.unit-art { will-change: transform; contain: layout style; }
+.unit:not(.live) .unit-art, .unit:not(.live) .unit-art * { animation-play-state: paused; }
+@media (max-width: 560px) {
+ .unit-art { width: calc(100% - 32px); right: 16px; opacity: .32; }
+ .unit h2 { min-height: 0; padding-top: 104px; font-size: 24px; }
+}
+@media (prefers-reduced-motion: reduce) {
+ .unit-art * { animation: none !important; }
+ .unit-art .d { stroke-dashoffset: 0; }
+ .unit-art .t, .unit-art .cell { opacity: 1; }
+ .unit-art .a.t { opacity: .55; }
+ .unit-art .shade { opacity: .14; }
+ .unit-art .pie { stroke-dasharray: 25 100; }
+}
diff --git a/site/little-red-riding-hood/lib/units.js b/site/little-red-riding-hood/lib/units.js
new file mode 100644
index 0000000..e9e8c27
--- /dev/null
+++ b/site/little-red-riding-hood/lib/units.js
@@ -0,0 +1,26 @@
+// The unit headers of a book's contents page, the same in every book; styled by units.css. The sketches come from
+// the book's own unit-art.js (window.UNIT_ART, one SVG body per unit, viewBox 0 0 600 180).
+// Units.header(u, label, title) the sketch and heading for unit u, as HTML to put first in its <section class="unit">
+// Units.watch() draw each sketch the first time its unit scrolls into view, and run its loop only
+// while the unit is on screen
+'use strict';
+(() => {
+ const esc = s => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;');
+ const header = (u, label, title) =>
+ `<svg class="unit-art" viewBox="0 0 600 180" aria-hidden="true">${window.UNIT_ART?.[u] || ''}</svg>` +
+ `<h2><span class="label">${esc(label)}</span><span class="title">${esc(title)}</span></h2>`;
+
+ function watch(root = document) {
+ const units = root.querySelectorAll('.unit');
+ if (!('IntersectionObserver' in window)) return units.forEach(u => u.classList.add('seen', 'live'));
+ // The first sight draws the sketch; leaving the screen (or sliding under the sticky bar) pauses it.
+ const first = new IntersectionObserver(es => es.forEach(e => {
+ if (e.isIntersecting) { e.target.classList.add('seen'); first.unobserve(e.target); }
+ }), { threshold: .25 });
+ const live = new IntersectionObserver(es => es.forEach(e => e.target.classList.toggle('live', e.isIntersecting)),
+ { rootMargin: '-64px 0px 0px 0px' });
+ units.forEach(u => { first.observe(u); live.observe(u); });
+ }
+
+ window.Units = { header, watch };
+})();
diff --git a/site/little-red-riding-hood/lib/volume.css b/site/little-red-riding-hood/lib/volume.css
new file mode 100644
index 0000000..195fe1f
--- /dev/null
+++ b/site/little-red-riding-hood/lib/volume.css
@@ -0,0 +1,24 @@
+/* Volume control for the player bar (volume.js); imported by engine.css. */
+.volume { display: flex; align-items: center; flex: none; width: 44px; height: 44px; overflow: hidden;
+ border: 1px solid var(--edge); border-radius: 999px; background: var(--panel); color: var(--chalk); transition: width .18s ease; }
+.volume .icon { width: 42px; height: 42px; border: 0; background: transparent; }
+.volume:hover, .volume:focus-within { width: 166px; gap: 10px; padding-right: 12px; }
+.volume:hover { background: #2b3f36; border-color: var(--faint); }
+.volume:has(:focus-visible) { outline: 2px solid var(--task); outline-offset: 3px; }
+.volume .icon:focus-visible { outline: none; }
+.volume input { appearance: none; flex: none; width: 0; height: 42px; margin: 0; opacity: 0; background: transparent; cursor: pointer; }
+.volume:hover input, .volume:focus-within input { width: 100px; opacity: 1; }
+.volume input:focus-visible { outline: none; }
+.volume input::-webkit-slider-runnable-track { height: 4px; border-radius: 999px;
+ background: linear-gradient(to right, var(--chalk) var(--volume, 100%), var(--faint) var(--volume, 100%)); }
+.volume input::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -4px; border: 0; border-radius: 50%; background: var(--chalk); }
+.volume input::-moz-range-track { height: 4px; border-radius: 999px; background: var(--faint); }
+.volume input::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--chalk); }
+.volume input::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--chalk); }
+@media (max-width: 700px) {
+ .volume { width: 36px; height: 40px; }
+ #bar .volume .icon { width: 34px; height: 38px; }
+ .volume:hover, .volume:focus-within { width: 158px; }
+ .volume input { height: 38px; }
+}
+@media (prefers-reduced-motion: reduce) { .volume { transition: none; } }
diff --git a/site/little-red-riding-hood/lib/volume.js b/site/little-red-riding-hood/lib/volume.js
new file mode 100644
index 0000000..8616688
--- /dev/null
+++ b/site/little-red-riding-hood/lib/volume.js
@@ -0,0 +1,20 @@
+/* Volume control for the player bar: a speaker button that opens a slider. engine.js loads this file and reads
+ #volume when it starts each beat's audio, so the control is the same in every book. */
+'use strict';
+{
+ document.getElementById('bHelp').insertAdjacentHTML('beforebegin', `<div class="volume">
+ <button class="icon" id="bVolume" aria-label="${translate('volumeLabel')}" aria-controls="volume" title="${translate('volumeTitle')}">
+ <svg viewBox="0 0 24 24" aria-hidden="true">
+ <path d="M3 9v6h4l5 4V5L7 9z" fill="currentColor"/>
+ <path d="M16 8a6 6 0 0 1 0 8m3-11a10 10 0 0 1 0 14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
+ </svg>
+ </button>
+ <input id="volume" type="range" min="0" max="1" step="0.05" value="1" aria-label="${translate('volumeSlider')}">
+ </div>`);
+ const input = document.getElementById('volume');
+ document.getElementById('bVolume').onclick = () => input.focus();
+ input.oninput = () => {
+ input.style.setProperty('--volume', +input.value * 100 + '%');
+ if (P.audio) P.audio.volume = +input.value;
+ };
+}