new game
Build and Push Docker Images / build-and-push (push) Successful in 19s

This commit is contained in:
Bram committed 2026-11-18 14:44:36 +01:00
1 parent 3f8984bb09
commit 97b2fa58a5
6 files changed
+1196 -180

No files matched your search

+556 -17
View File
@@ -64,6 +64,12 @@
<path d="M44 28h4c5 0 8 3 8 8s-3 8-8 8h-4"/>
<path d="M22 16c0-3 3-4 3-7M31 16c0-3 3-4 3-7M40 16c0-3 3-4 3-7"/>
<path d="M14 55h32"/>
</svg>`,
book: `
<svg viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
<path d="M32 17c-6-4-14-5-21-3v34c7-2 15-1 21 3 6-4 14-5 21-3V14c-7-2-15-1-21 3Z"/>
<path d="M32 17v34"/>
<path d="M15 21c5-1 10 0 14 2M49 21c-5-1-10 0-14 2"/>
</svg>`
};
@@ -88,10 +94,21 @@
dialogAuthor: $("#book-dialog-author"),
dialogIntro: $("#book-dialog-intro"),
dialogQuote: $("#book-dialog-quote"),
quizTask: $("#quiz-task"),
memoryTask: $("#memory-task"),
shelfTask: $("#shelf-task"),
question: $("#book-question"),
options: $("#book-options"),
memoryPrompt: $("#memory-prompt"),
memoryStats: $("#memory-stats"),
memoryGrid: $("#memory-grid"),
shelfPrompt: $("#shelf-prompt"),
shelfHelp: $("#shelf-help"),
shelfTray: $("#shelf-tray"),
shelfRacks: $("#shelf-racks"),
feedback: $("#book-feedback"),
hint: $("#book-hint"),
minigameRetry: $("#minigame-retry"),
stamp: $("#letter-stamp"),
stampLetter: $("#stamp-letter"),
doneBtn: $("#book-done-btn"),
@@ -138,6 +155,14 @@
return list[Math.floor(Math.random() * list.length)];
}
function shuffle(list) {
for (let index = list.length - 1; index > 0; index -= 1) {
const swapIndex = Math.floor(Math.random() * (index + 1));
[list[index], list[swapIndex]] = [list[swapIndex], list[index]];
}
return list;
}
function renderEmblem(name) {
return EMBLEMS[name] || EMBLEMS.star;
}
@@ -234,6 +259,16 @@
playTone({ freq: 180, endFreq: 140, type: "sine", duration: 0.18, gain: 0.05, delay: 0.08 });
}
function playFlip() {
playNoise({ duration: 0.08, gain: 0.05, frequency: 1900 });
playTone({ freq: 430, endFreq: 520, type: "sine", duration: 0.07, gain: 0.025 });
}
function playMatch() {
playTone({ freq: 587.33, endFreq: 587.33, type: "triangle", duration: 0.12, gain: 0.06 });
playTone({ freq: 880, endFreq: 880, type: "sine", duration: 0.18, gain: 0.05, delay: 0.08 });
}
function playUnlock() {
playNoise({ duration: 0.07, gain: 0.08, frequency: 2500 });
playTone({ freq: 340, endFreq: 120, type: "square", duration: 0.13, gain: 0.05 });
@@ -376,7 +411,11 @@
letter: "",
answerIndex: null,
doneText: "",
explanation: ""
explanation: "",
memory: null,
shelf: null,
minigameDone: false,
completing: false
};
state.books.set(meta.id, book);
@@ -387,6 +426,10 @@
}
});
els.shelves.forEach((shelf) => {
shelf.hidden = shelf.children.length === 0;
});
buildSlots();
updateProgress();
updateSlots();
@@ -450,6 +493,7 @@
book.answerIndex = saved.answer;
book.doneText = saved.done;
book.explanation = saved.explanation;
book.minigameDone = true;
book.element.classList.add("is-solved");
book.element.setAttribute(
"aria-label",
@@ -457,7 +501,7 @@
);
}
function renderOptions(book) {
function renderQuiz(book) {
els.options.replaceChildren();
const keys = ["A", "B", "C", "D", "E", "F"];
@@ -489,7 +533,6 @@
button.classList.add("is-correct");
}
});
showSolvedState(book);
}
}
@@ -514,6 +557,7 @@
return;
}
const kind = book.meta.kind || "quiz";
state.currentBookId = id;
state.bookReturnFocus = document.activeElement;
state.requestSerial += 1;
@@ -524,17 +568,45 @@
els.dialogAuthor.textContent = book.meta.author;
els.dialogIntro.textContent = book.meta.intro;
els.dialogQuote.textContent = book.meta.quote;
els.question.textContent = book.meta.question;
els.quizTask.hidden = true;
els.memoryTask.hidden = true;
els.shelfTask.hidden = true;
els.options.replaceChildren();
els.memoryGrid.replaceChildren();
els.shelfTray.replaceChildren();
els.shelfRacks.replaceChildren();
els.feedback.textContent = "";
els.feedback.className = "feedback";
els.hint.hidden = true;
els.hint.textContent = "";
els.minigameRetry.hidden = true;
els.stamp.hidden = true;
els.stamp.classList.remove("is-visible");
els.doneBtn.hidden = true;
els.doneBtn.textContent = "Terug naar de kast";
renderOptions(book);
if (kind === "quiz") {
els.quizTask.hidden = false;
els.question.textContent = book.meta.question;
renderQuiz(book);
} else if (kind === "memory") {
els.memoryTask.hidden = false;
els.memoryPrompt.textContent = book.meta.prompt;
renderMemory(book);
} else if (kind === "shelf") {
els.shelfTask.hidden = false;
els.shelfPrompt.textContent = book.meta.prompt;
renderShelf(book);
}
if (book.solved) {
showSolvedState(book);
} else if (book.minigameDone) {
els.feedback.textContent = "Je hebt de opdracht al voltooid. Rond het boek af om de letter te vinden.";
els.minigameRetry.hidden = false;
}
els.bookModal.hidden = false;
syncBodyLock();
@@ -545,11 +617,447 @@
els.doneBtn.focus();
return;
}
const firstOption = $(".option", els.options);
(firstOption || els.bookClose).focus();
if (book.minigameDone) {
els.minigameRetry.focus();
return;
}
const focusTarget = kind === "memory"
? $(".memory-card", els.memoryGrid)
: kind === "shelf"
? $(".shelf-item", els.shelfTray)
: $(".option", els.options);
(focusTarget || els.bookClose).focus();
}, 90);
}
function ensureMemory(book) {
if (!book.memory) {
const deck = [];
book.meta.pairs.forEach((pair) => {
deck.push({ pairId: pair.id, label: pair.label, emblem: pair.emblem });
deck.push({ pairId: pair.id, label: pair.label, emblem: pair.emblem });
});
book.memory = {
deck: shuffle(deck),
flipped: [],
matched: new Set(),
lock: false,
timer: null,
mistakes: 0,
done: false
};
}
if (book.solved) {
book.meta.pairs.forEach((pair) => book.memory.matched.add(pair.id));
book.memory.flipped = [];
book.memory.lock = false;
book.memory.done = true;
if (book.memory.timer) {
window.clearTimeout(book.memory.timer);
book.memory.timer = null;
}
}
return book.memory;
}
function renderMemory(book) {
const memory = ensureMemory(book);
const total = book.meta.pairs.length;
els.memoryStats.textContent = `${memory.matched.size} van ${total} paren gevonden`;
els.memoryGrid.replaceChildren();
memory.deck.forEach((card, index) => {
const matched = memory.matched.has(card.pairId);
const flipped = memory.flipped.includes(index);
const button = document.createElement("button");
button.type = "button";
button.className = "memory-card";
if (matched || flipped) {
button.classList.add("is-flipped");
}
if (matched) {
button.classList.add("is-matched");
}
button.disabled = book.solved;
button.dataset.index = String(index);
button.setAttribute(
"aria-label",
matched
? `${card.label}, gevonden`
: flipped
? `${card.label}, omgedraaid`
: `Dichte kaart ${index + 1}`
);
button.setAttribute("aria-pressed", String(matched || flipped));
const inner = document.createElement("span");
inner.className = "memory-inner";
const back = document.createElement("span");
back.className = "memory-face memory-back";
const backMark = document.createElement("span");
backMark.className = "memory-back-mark";
backMark.innerHTML = renderEmblem("book");
back.appendChild(backMark);
const front = document.createElement("span");
front.className = "memory-face memory-front";
const emblem = document.createElement("span");
emblem.className = "memory-emblem";
emblem.innerHTML = renderEmblem(card.emblem);
const label = document.createElement("span");
label.className = "memory-label";
label.textContent = card.label;
front.append(emblem, label);
inner.append(back, front);
button.appendChild(inner);
button.addEventListener("click", () => flipMemoryCard(book, index));
els.memoryGrid.appendChild(button);
});
}
function flipMemoryCard(book, index) {
const memory = ensureMemory(book);
if (book.solved || memory.done || memory.lock || memory.flipped.includes(index)) {
return;
}
const card = memory.deck[index];
if (!card || memory.matched.has(card.pairId)) {
return;
}
memory.flipped.push(index);
const buttons = $$(".memory-card", els.memoryGrid);
const button = buttons[index];
if (button) {
button.classList.add("is-flipped");
button.setAttribute("aria-label", `${card.label}, omgedraaid`);
button.setAttribute("aria-pressed", "true");
}
playFlip();
if (memory.flipped.length < 2) {
return;
}
const [firstIndex, secondIndex] = memory.flipped;
const first = memory.deck[firstIndex];
const second = memory.deck[secondIndex];
if (!first || !second) {
memory.flipped = [];
return;
}
if (first.pairId === second.pairId) {
memory.matched.add(first.pairId);
memory.flipped = [];
playMatch();
[firstIndex, secondIndex].forEach((cardIndex) => {
const cardButton = buttons[cardIndex];
if (cardButton) {
cardButton.classList.add("is-matched");
cardButton.setAttribute("aria-label", `${first.label}, gevonden`);
}
});
els.memoryStats.textContent = `${memory.matched.size} van ${book.meta.pairs.length} paren gevonden`;
els.feedback.className = "feedback is-correct";
els.feedback.textContent = `Gevonden: ${first.label}.`;
if (memory.matched.size === book.meta.pairs.length) {
memory.done = true;
book.minigameDone = true;
els.memoryStats.textContent = `${book.meta.pairs.length} van ${book.meta.pairs.length} paren gevonden.`;
els.feedback.textContent = "Alle paren gevonden. Het boek is bijna uit.";
memory.timer = window.setTimeout(() => completeMinigame(book), 550);
}
return;
}
memory.lock = true;
memory.mistakes += 1;
playWrong();
els.feedback.className = "feedback is-error";
els.feedback.textContent = "Bijna. Onthoud de plek en probeer opnieuw.";
if (memory.mistakes >= 2) {
els.hint.textContent = book.meta.hint;
els.hint.hidden = false;
}
memory.timer = window.setTimeout(() => {
memory.flipped = [];
memory.lock = false;
if (state.currentBookId === book.id) {
$$(".memory-card", els.memoryGrid).forEach((cardButton, cardIndex) => {
if (memory.matched.has(memory.deck[cardIndex].pairId)) {
return;
}
cardButton.classList.remove("is-flipped");
cardButton.setAttribute("aria-label", `Dichte kaart ${cardIndex + 1}`);
cardButton.setAttribute("aria-pressed", "false");
});
}
memory.timer = null;
}, 850);
}
function ensureShelf(book) {
if (!book.shelf) {
book.shelf = {
items: shuffle(book.meta.items.map((item) => ({ ...item }))),
placed: {},
selectedId: null,
mistakes: 0,
done: false,
timer: null
};
}
if (book.solved) {
book.meta.items.forEach((item) => {
book.shelf.placed[item.id] = item.shelf;
});
book.shelf.selectedId = null;
book.shelf.done = true;
if (book.shelf.timer) {
window.clearTimeout(book.shelf.timer);
book.shelf.timer = null;
}
}
return book.shelf;
}
function createMiniBook(item, placed) {
const element = document.createElement(placed ? "span" : "button");
if (!placed) {
element.type = "button";
}
element.className = `shelf-item${placed ? " is-placed" : ""}`;
element.style.setProperty("--item-cover", item.color || "#2e4a30");
element.style.setProperty("--item-cover-2", item.color2 || "#557c4c");
element.style.setProperty("--item-ink", item.ink || "#f7eedb");
const emblem = document.createElement("span");
emblem.className = "mini-emblem";
emblem.setAttribute("aria-hidden", "true");
emblem.innerHTML = renderEmblem(item.emblem);
const label = document.createElement("span");
label.className = "mini-label";
label.textContent = item.label;
element.append(emblem, label);
return element;
}
function renderShelf(book) {
const shelf = ensureShelf(book);
const placedCount = Object.keys(shelf.placed).length;
const total = book.meta.items.length;
els.shelfPrompt.textContent = book.meta.prompt;
els.shelfHelp.textContent = book.solved || shelf.done
? `Alle ${total} boeken staan op hun plek.`
: `${placedCount} van ${total} boeken geplaatst. Klik op een boek en daarna op het juiste rek.`;
els.shelfTray.replaceChildren();
shelf.items.forEach((item) => {
if (shelf.placed[item.id]) {
return;
}
const button = createMiniBook(item, false);
button.dataset.id = item.id;
button.dataset.label = item.label;
const selected = shelf.selectedId === item.id;
button.classList.toggle("is-selected", selected);
button.setAttribute("aria-pressed", String(selected));
button.setAttribute("aria-label", `${item.label}${selected ? ", geselecteerd" : ""}`);
button.addEventListener("click", () => selectShelfItem(book, item.id));
els.shelfTray.appendChild(button);
});
els.shelfRacks.replaceChildren();
book.meta.shelves.forEach((shelfMeta) => {
const placedItem = book.meta.items.find(
(item) => shelf.placed[item.id] === shelfMeta.id
);
const rack = document.createElement("button");
rack.type = "button";
rack.className = "rack";
if (placedItem) {
rack.classList.add("is-filled");
}
if (shelf.selectedId) {
rack.classList.add("is-targetable");
}
rack.disabled = book.solved || shelf.done;
rack.setAttribute(
"aria-label",
placedItem
? `${shelfMeta.label}: ${placedItem.label} staat op zijn plek.`
: `Plaats het geselecteerde boek in ${shelfMeta.label}.`
);
const label = document.createElement("span");
label.className = "rack-label";
label.textContent = shelfMeta.label;
const hint = document.createElement("span");
hint.className = "rack-hint";
hint.textContent = shelfMeta.hint;
const slot = document.createElement("span");
slot.className = "rack-slot";
if (placedItem) {
slot.appendChild(createMiniBook(placedItem, true));
}
rack.append(label, hint, slot);
rack.addEventListener("click", () => chooseShelf(book, shelfMeta.id));
els.shelfRacks.appendChild(rack);
});
}
function selectShelfItem(book, itemId) {
const shelf = ensureShelf(book);
if (book.solved || shelf.done) {
return;
}
const item = shelf.items.find((entry) => entry.id === itemId);
shelf.selectedId = shelf.selectedId === itemId ? null : itemId;
$$(".shelf-item", els.shelfTray).forEach((button) => {
const selected = button.dataset.id === shelf.selectedId;
button.classList.toggle("is-selected", selected);
button.setAttribute("aria-pressed", String(selected));
button.setAttribute(
"aria-label",
`${button.dataset.label}${selected ? ", geselecteerd" : ""}`
);
});
$$(".rack", els.shelfRacks).forEach((rack) => {
rack.classList.toggle("is-targetable", Boolean(shelf.selectedId));
});
els.feedback.className = "feedback";
els.feedback.textContent = shelf.selectedId && item
? `Kies een rek voor ${item.label}.`
: "Kies een boek en daarna een rek.";
playFlip();
}
function chooseShelf(book, shelfId) {
const shelf = ensureShelf(book);
if (book.solved || shelf.done) {
return;
}
if (!shelf.selectedId) {
els.feedback.className = "feedback is-error";
els.feedback.textContent = "Kies eerst een boek uit de stapel.";
playWrong();
return;
}
const item = shelf.items.find((entry) => entry.id === shelf.selectedId);
if (!item) {
return;
}
if (item.shelf !== shelfId) {
shelf.mistakes += 1;
playWrong();
els.feedback.className = "feedback is-error";
els.feedback.textContent = `${item.label} hoort niet bij dit rek. Kijk naar het onderwerp.`;
if (shelf.mistakes >= 2) {
els.hint.textContent = book.meta.hint;
els.hint.hidden = false;
}
const racks = $$(".rack", els.shelfRacks);
const targetIndex = book.meta.shelves.findIndex((entry) => entry.id === shelfId);
const rack = racks[targetIndex];
if (rack) {
rack.classList.remove("is-wrong");
void rack.offsetWidth;
rack.classList.add("is-wrong");
window.setTimeout(() => rack.classList.remove("is-wrong"), 400);
}
return;
}
shelf.placed[item.id] = shelfId;
shelf.selectedId = null;
playMatch();
if (Object.keys(shelf.placed).length === book.meta.items.length) {
shelf.done = true;
book.minigameDone = true;
els.feedback.className = "feedback is-correct";
els.feedback.textContent = "Alle boeken staan op hun plek. Het boek is bijna uit.";
renderShelf(book);
shelf.timer = window.setTimeout(() => completeMinigame(book), 550);
return;
}
els.feedback.className = "feedback is-correct";
els.feedback.textContent = `${item.label} staat goed.`;
renderShelf(book);
const nextItem = $(".shelf-item", els.shelfTray);
if (nextItem) {
nextItem.focus();
}
}
async function completeMinigame(book) {
if (!book || book.solved || book.completing) {
return;
}
const serial = ++state.requestSerial;
state.requestInFlight = true;
book.completing = true;
const isCurrent = () => serial === state.requestSerial && state.currentBookId === book.id;
els.minigameRetry.hidden = true;
els.feedback.className = "feedback";
els.feedback.textContent = "De laatste bladzijde wordt geschreven...";
ensureAudio();
try {
const response = await fetch("/api/complete", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ bookId: book.id })
});
const data = await response.json().catch(() => ({}));
if (!response.ok) {
throw new Error(data.error || "De leeshoek is even niet bereikbaar.");
}
book.completing = false;
markSolved(book, data, null, isCurrent());
} catch (error) {
book.completing = false;
if (isCurrent()) {
els.feedback.className = "feedback is-error";
els.feedback.textContent = `${error.message} Het boek is bijna klaar; probeer het nog eens.`;
els.minigameRetry.hidden = false;
playWrong();
}
} finally {
if (serial === state.requestSerial) {
state.requestInFlight = false;
}
}
}
async function answerBook(book, index) {
if (book.solved || state.requestInFlight) {
return;
@@ -653,12 +1161,14 @@
setLog(book.doneText || `Juist. De letter ${book.letter} is gevonden.`, "done");
if (updateDialog) {
$$(".option", els.options).forEach((button, index) => {
button.disabled = true;
if (index === answerIndex) {
button.classList.add("is-correct");
}
});
if ((book.meta.kind || "quiz") === "quiz") {
$$(".option", els.options).forEach((button, index) => {
button.disabled = true;
if (index === answerIndex) {
button.classList.add("is-correct");
}
});
}
showSolvedState(book);
window.setTimeout(() => els.doneBtn.focus(), 260);
}
@@ -686,8 +1196,9 @@
playUnlock();
}
if (wasLocked && announce) {
const word = state.order.map((book) => book.letter).join("");
setLog(
"Alle acht boeken zijn gelezen. De letters vormen LEESHOEK — de lade klikt open!",
`Alle ${state.order.length} boeken zijn gelezen. De letters vormen ${word} — de lade klikt open!`,
"done"
);
}
@@ -769,6 +1280,17 @@
if (els.bookModal.hidden) {
return;
}
const book = state.currentBookId ? state.books.get(state.currentBookId) : null;
if (book && book.memory) {
if (book.memory.timer) {
window.clearTimeout(book.memory.timer);
book.memory.timer = null;
}
book.memory.flipped = [];
book.memory.lock = false;
}
els.bookModal.hidden = true;
state.currentBookId = null;
state.requestInFlight = false;
@@ -799,12 +1321,22 @@
function resetGame() {
state.books.forEach((book) => {
if (book.memory && book.memory.timer) {
window.clearTimeout(book.memory.timer);
}
if (book.shelf && book.shelf.timer) {
window.clearTimeout(book.shelf.timer);
}
book.solved = false;
book.attempts = 0;
book.letter = "";
book.answerIndex = null;
book.doneText = "";
book.explanation = "";
book.memory = null;
book.shelf = null;
book.minigameDone = false;
book.completing = false;
book.element.classList.remove("is-solved");
book.element.setAttribute(
"aria-label",
@@ -821,6 +1353,7 @@
updateProgress();
updateSlots();
els.secret.classList.remove("is-complete");
els.minigameRetry.hidden = true;
els.log.className = "log";
setLog("Nieuwe ronde, dezelfde kast. Kies een boek en begin opnieuw.", "done");
closeVoucher();
@@ -970,7 +1503,7 @@
setText("#game-subtitle", config.subtitle);
setText(
"#voucher-lead",
`${config.recipient}, je hebt alle acht boeken gelezen. Achter de kast lag een envelop met iets om zelf een nieuw verhaal uit te kiezen.`
`${config.recipient}, je hebt alle ${config.books.length} boeken gelezen. Achter de kast lag een envelop met iets om zelf een nieuw verhaal uit te kiezen.`
);
if (config.title) {
@@ -1023,6 +1556,12 @@
els.playAgain.addEventListener("click", resetGame);
els.copyButton.addEventListener("click", copyCode);
els.drawer.addEventListener("click", handleDrawer);
els.minigameRetry.addEventListener("click", () => {
const book = state.currentBookId ? state.books.get(state.currentBookId) : null;
if (book && (book.meta.kind === "memory" || book.meta.kind === "shelf")) {
completeMinigame(book);
}
});
$$("[data-close]").forEach((node) => {
node.addEventListener("click", () => {
@@ -1078,7 +1617,7 @@
if (state.solvedCount === state.order.length) {
unlockDrawer({ announce: false, sound: false });
setLog(
"Welkom terug. Alle acht boeken zijn al gelezen — de lade staat op je te wachten.",
`Welkom terug. Alle ${state.order.length} boeken zijn al gelezen — de lade staat op je te wachten.`,
"done"
);
} else if (state.solvedCount > 0) {
@@ -1087,7 +1626,7 @@
"done"
);
} else {
setLog("De kast staat klaar. Kies een boek en los de kleine opdracht op.");
setLog("De kast staat klaar: twee vragen en twee minigames. Kies een boek.");
}
} catch (error) {
setLog(`De boekenkast kon niet geladen worden: ${error.message}`, "warning");
+28 -9
View File
@@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#101b16">
<meta name="description" content="Lees de acht boeken van Mama's geheime leeshoek en open de lade met de cadeaubon.">
<meta name="description" content="Open de vier boeken van Mama's geheime leeshoek en open de lade met de cadeaubon.">
<title>Mama's Geheime Leeshoek</title>
<link rel="stylesheet" href="style.css">
</head>
@@ -13,14 +13,14 @@
<header class="hero">
<p class="eyebrow">Een verhaal voor <span id="recipient-name">Mama</span></p>
<h1 id="game-title">Mama's Geheime Leeshoek</h1>
<p class="tagline" id="game-subtitle">Lees de acht boeken, vind het geheimwoord en open de lade.</p>
<p class="tagline" id="game-subtitle">Open de vier boeken, vind het geheimwoord en open de lade.</p>
</header>
<main class="game-shell" id="game-shell">
<div class="hud">
<div class="progress" aria-live="polite">
<div class="progress-copy">
<span id="progress-text">0 / 8 boeken gelezen</span>
<span id="progress-text">0 / 4 boeken gelezen</span>
<span id="progress-percent">0%</span>
</div>
<div class="progress-track" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" id="progress-track">
@@ -75,10 +75,10 @@
</section>
<div class="underbar">
<p class="log" id="log" role="status" aria-live="polite">De kast staat klaar. Kies een boek en los de kleine opdracht op.</p>
<p class="log" id="log" role="status" aria-live="polite">De kast staat klaar: twee vragen en twee minigames. Kies een boek.</p>
</div>
<p class="controls-hint">Klik op een boek om het te openen. Er is geen tijdsdruk — elk verhaal wacht geduldig.</p>
<p class="controls-hint">Klik op een boek. Twee boeken stellen een vraag, twee boeken zijn een minigame. Er is geen tijdsdruk.</p>
</main>
<footer class="footer">
@@ -106,11 +106,30 @@
<div class="book-page page-right">
<div class="task">
<p class="task-kicker">Opdracht</p>
<h3 id="book-question">Vraag</h3>
<div class="options" id="book-options" role="group" aria-label="Kies je antwoord"></div>
<div class="task-panel" id="quiz-task">
<p class="task-kicker">Opdracht</p>
<h3 id="book-question">Vraag</h3>
<div class="options" id="book-options" role="group" aria-label="Kies je antwoord"></div>
</div>
<div class="task-panel" id="memory-task" hidden>
<p class="task-kicker">Minigame &middot; Memory</p>
<h3 id="memory-prompt">Vind alle paren.</h3>
<p class="minigame-meta" id="memory-stats"></p>
<div class="memory-grid" id="memory-grid" role="grid" aria-label="Memoryspel"></div>
</div>
<div class="task-panel" id="shelf-task" hidden>
<p class="task-kicker">Minigame &middot; Boekenrek</p>
<h3 id="shelf-prompt">Zet elk boek in het juiste rek.</h3>
<p class="minigame-meta" id="shelf-help"></p>
<div class="shelf-tray" id="shelf-tray" aria-label="Nog te plaatsen boeken"></div>
<div class="shelf-racks" id="shelf-racks"></div>
</div>
<p class="feedback" id="book-feedback" role="status" aria-live="polite"></p>
<p class="hint" id="book-hint" hidden></p>
<button type="button" class="secondary-btn minigame-retry" id="minigame-retry" hidden>Probeer opnieuw</button>
<div class="letter-stamp" id="letter-stamp" aria-hidden="true" hidden>
<span class="stamp-letter" id="stamp-letter">L</span>
<span class="stamp-caption">gevonden</span>
@@ -126,7 +145,7 @@
<section class="voucher" role="dialog" aria-modal="true" aria-labelledby="voucher-title" aria-describedby="voucher-lead">
<p class="voucher-kicker">Gevonden in de geheime lade</p>
<h2 id="voucher-title">Een boek naar keuze</h2>
<p class="voucher-lead" id="voucher-lead">Mama, je hebt alle acht boeken gelezen. Achter de kast lag een envelop met iets om zelf een nieuw verhaal uit te kiezen.</p>
<p class="voucher-lead" id="voucher-lead">Mama, je hebt alle vier boeken gelezen. Achter de kast lag een envelop met iets om zelf een nieuw verhaal uit te kiezen.</p>
<div class="voucher-card">
<span class="voucher-label">Cadeaubon</span>
+391
View File
@@ -1154,6 +1154,356 @@ h1 {
color: #fff;
}
.minigame-meta {
margin: 6px 0 14px;
color: #7a6440;
font-size: clamp(.76rem, 1.5vw, .84rem);
font-weight: 700;
line-height: 1.45;
}
.memory-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: clamp(6px, 1.2vw, 10px);
margin: 0 0 14px;
}
.memory-card {
position: relative;
aspect-ratio: 3 / 4;
padding: 0;
border: 0;
background: none;
cursor: pointer;
perspective: 800px;
-webkit-tap-highlight-color: transparent;
}
.memory-inner {
position: absolute;
inset: 0;
transform-style: preserve-3d;
transition: transform .35s cubic-bezier(.2, .8, .3, 1);
}
.memory-card.is-flipped .memory-inner {
transform: rotateY(180deg);
}
.memory-face {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 5px;
overflow: hidden;
border-radius: 5px;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
}
.memory-back {
border: 1px solid #8a6a2f;
background:
radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .12), transparent 38%),
repeating-linear-gradient(45deg, rgba(240, 201, 106, .05) 0 6px, transparent 6px 12px),
linear-gradient(150deg, #2e4a30, #182f22);
color: var(--brass-bright);
box-shadow:
inset 0 0 0 3px rgba(240, 201, 106, .14),
0 4px 8px rgba(0, 0, 0, .2);
}
.memory-back-mark {
display: grid;
place-items: center;
width: 56%;
aspect-ratio: 1;
border: 1px solid rgba(240, 201, 106, .35);
border-radius: 50%;
background: rgba(0, 0, 0, .14);
}
.memory-back-mark svg {
width: 62%;
height: 62%;
opacity: .85;
}
.memory-front {
transform: rotateY(180deg);
border: 1px solid #b89a5c;
background:
radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .8), transparent 40%),
linear-gradient(180deg, #fff9ea, #ecdbb6);
color: #5c4724;
}
.memory-front svg {
width: 58%;
height: 40%;
overflow: visible;
}
.memory-emblem {
display: grid;
place-items: center;
width: 58%;
height: 40%;
}
.memory-emblem svg {
width: 100%;
height: 100%;
overflow: visible;
}
.memory-label {
max-width: 96%;
padding: 0 2px;
overflow: hidden;
font-family: var(--serif);
font-size: clamp(.5rem, 1.2vw, .68rem);
font-weight: 700;
line-height: 1.1;
text-align: center;
text-overflow: ellipsis;
}
.memory-card.is-matched .memory-front {
border-color: #5f7d4f;
background:
radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .8), transparent 40%),
linear-gradient(180deg, #f3f8e6, #dfecc9);
box-shadow: 0 0 0 2px rgba(95, 125, 79, .42);
}
.memory-card.is-matched {
cursor: default;
}
.memory-card:focus-visible {
outline: 2px solid var(--brass-dark);
outline-offset: 2px;
border-radius: 5px;
}
.memory-card.is-matched:focus-visible {
outline-color: #5f7d4f;
}
.memory-card:disabled {
cursor: default;
}
.shelf-tray {
display: flex;
flex-wrap: wrap;
gap: 7px;
min-height: 62px;
margin-bottom: 10px;
padding: 9px;
border: 1px dashed rgba(154, 107, 35, .45);
border-radius: 9px;
background: rgba(185, 154, 92, .09);
}
.shelf-tray:empty::after {
content: "Alle boeken staan op hun plek.";
align-self: center;
width: 100%;
color: #7a6440;
font-size: .8rem;
font-style: italic;
text-align: center;
}
.shelf-item {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 4px;
width: clamp(58px, 11vw, 76px);
min-height: clamp(72px, 14vw, 94px);
padding: 7px 5px 6px 8px;
border: 1px solid rgba(255, 255, 255, .2);
border-radius: 3px 6px 6px 3px;
background:
radial-gradient(circle at 28% 18%, rgba(255, 255, 255, .14), transparent 40%),
linear-gradient(150deg, var(--item-cover, #2e4a30), var(--item-cover-2, #557c4c));
color: var(--item-ink, #f7eedb);
box-shadow: 0 4px 9px rgba(0, 0, 0, .24), inset 0 0 0 1px rgba(255, 255, 255, .1);
cursor: pointer;
transition: transform .15s, box-shadow .15s, border-color .15s;
}
.shelf-item::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 5px;
border-radius: 3px 0 0 3px;
background: linear-gradient(90deg, rgba(0, 0, 0, .4), rgba(255, 255, 255, .08));
}
.shelf-item.is-placed {
cursor: default;
}
.shelf-item:not(.is-placed):hover {
transform: translateY(-2px);
box-shadow: 0 8px 14px rgba(0, 0, 0, .28), 0 0 0 1px rgba(240, 201, 106, .55);
}
.shelf-item.is-selected {
border-color: var(--brass-bright);
box-shadow: 0 0 0 2px var(--brass), 0 8px 14px rgba(0, 0, 0, .28);
transform: translateY(-3px);
}
.shelf-item:focus-visible {
outline: 2px solid var(--brass-dark);
outline-offset: 2px;
}
.mini-emblem {
display: grid;
place-items: center;
width: 28px;
height: 28px;
}
.mini-emblem svg {
width: 100%;
height: 100%;
overflow: visible;
}
.mini-label {
display: -webkit-box;
max-width: 100%;
overflow: hidden;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
font-family: var(--serif);
font-size: clamp(.5rem, 1.15vw, .62rem);
font-weight: 700;
line-height: 1.1;
text-align: center;
overflow-wrap: anywhere;
}
.shelf-racks {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 8px;
}
.rack {
position: relative;
display: flex;
flex-direction: column;
gap: 4px;
min-height: 108px;
padding: 9px;
border: 1px solid #c8b48a;
border-radius: 8px;
background: rgba(255, 255, 255, .3);
color: #4b3a20;
font: inherit;
text-align: left;
cursor: pointer;
transition: border-color .15s, background .15s, box-shadow .15s;
}
.rack:hover,
.rack.is-targetable {
border-color: #8a6a2f;
background: #fffaf0;
}
.rack.is-targetable {
box-shadow: inset 0 0 0 1px rgba(138, 106, 47, .18);
}
.rack.is-filled {
border-color: #8fa47b;
background: rgba(232, 240, 217, .58);
}
.rack.is-wrong {
border-color: #a34a3d;
animation: rack-shake .32s ease;
}
.rack:focus-visible {
outline: 2px solid var(--brass-dark);
outline-offset: 2px;
}
.rack:disabled {
cursor: default;
}
.rack-label {
font-size: clamp(.62rem, 1.3vw, .72rem);
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
}
.rack-hint {
color: #7a6440;
font-size: clamp(.56rem, 1.15vw, .64rem);
line-height: 1.3;
}
.rack-slot {
display: flex;
align-items: center;
justify-content: center;
min-height: 58px;
margin-top: auto;
border: 1px dashed rgba(154, 107, 35, .36);
border-radius: 6px;
background: rgba(255, 255, 255, .22);
}
.rack.is-filled .rack-slot {
border-style: solid;
border-color: #8fa47b;
background: rgba(255, 255, 255, .38);
}
.rack .shelf-item {
width: 76px;
min-height: 72px;
box-shadow: none;
}
.rack .shelf-item:hover {
transform: none;
}
.minigame-retry {
align-self: flex-start;
margin-bottom: 14px;
}
@keyframes rack-shake {
0%, 100% { transform: translateX(0); }
30% { transform: translateX(-5px); }
62% { transform: translateX(4px); }
84% { transform: translateX(-2px); }
}
.feedback {
min-height: 2.7em;
margin: 0;
@@ -1612,6 +1962,35 @@ h1 {
gap: 10px;
}
.memory-grid {
gap: 6px;
}
.memory-label {
font-size: .54rem;
}
.shelf-tray {
padding: 7px;
gap: 6px;
}
.shelf-tray .shelf-item {
width: 66px;
min-height: 76px;
padding: 6px 4px 5px 7px;
}
.rack {
min-height: 100px;
padding: 7px;
}
.rack .shelf-item {
width: 52px;
min-height: 66px;
}
.primary-btn {
align-self: stretch;
text-align: center;
@@ -1626,6 +2005,18 @@ h1 {
.shelf {
gap: 5px;
}
.memory-grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.memory-label {
font-size: .58rem;
}
.rack-hint {
display: none;
}
}
@media (prefers-reduced-motion: reduce) {