/*
 * Proof Reading's identity (specification PR6, PE6): a title page from an old
 * book, set on warm paper, with crust browns for the accents and a loaf for
 * the mark. Prompts and passages are set in a bookish serif, controls in the
 * system's own sans, both from fonts already on the device, since nothing may
 * load from another origin.
 *
 * Served from 'self' only: the content security policy allows no inline
 * style, no data: image and no other origin, so the loaf is drawn with CSS
 * shapes and gradients rather than an image file.
 *
 * Accessibility (datum 0.16): every colour pair below meets WCAG 2.2 AA in
 * both schemes (client/colour-contrast.test.ts measures every pair, PT20);
 * outcomes are told by border shape, a symbol and words as well as by
 * colour; focus is a blue ring that no other part of the palette uses, so
 * it stands out in both schemes; every control is at least 44 by 44 CSS
 * pixels; and nothing moves when a reduced motion preference is set.
 */

/*
 * The two palettes, each colour written once as light-dark(light, dark).
 * light-dark() takes the first colour where the element's used color-scheme
 * is light and the second where it is dark, so which palette shows is decided
 * by color-scheme alone, and native controls and scroll bars follow it too:
 *
 * - no choice made: "light dark" here, so the system preference decides
 * - a choice made with the toggle (PT14): the client sets data-colour-scheme
 *   on the root element, and the rules below pin color-scheme to that scheme
 *
 * color-scheme is inherited, so every element resolves these against the
 * root's scheme. light-dark() is in Chrome 123, Firefox 120 and Safari 17.5
 * (MDN browser compatibility data, read 28 November 2026), which covers the
 * current and previous releases of each.
 *
 * Light: cream paper and dark brown ink, legible in daylight. Dark: a well
 * baked crust, with golden accents rather than brown ones.
 */
:root {
  color-scheme: light dark;

  --paper: light-dark(#f5ecd9, #1b1510);
  --page: light-dark(#fffaf0, #271e17);
  --ink: light-dark(#2a1f16, #f2e7d5);
  --ink-muted: light-dark(#5c4632, #cdb89c);
  --crust: light-dark(#8b4513, #e0a160);
  --crust-pressed: light-dark(#6b3410, #f0bd85);
  --on-crust: light-dark(#fffaf0, #1b1510);
  --rule: light-dark(#8a6a4a, #a88a6a);
  --correct: light-dark(#2e6b34, #8fd19a);
  --correct-wash: light-dark(#e6f0dc, #1f3322);
  --incorrect: light-dark(#a3271d, #f4a093);
  --incorrect-wash: light-dark(#f9e3dd, #3d1f1b);
  --focus: light-dark(#1d4f91, #8fbcff);
  --loaf: light-dark(#b8732f, #c98a45);
  --loaf-outline: light-dark(#5a3212, #3a200b);
  /* The same pale crumb in both schemes, seen only inside the loaf. */
  --crumb: #f3dcb2;

  /*
   * The kneading and the bake (PT15), from the approved prototype's light and
   * dark values (docs/prototypes/kneading-and-bake.html): raw dough and the
   * shadow under it, the dent a hand presses into it, golden then baked
   * crust as it browns, the pale slashes opening in it, and the oven's glow.
   * They are decorative, seen only while the dough moves and in the result's
   * loaf, which assistive technology does not see and the words beside it
   * say in full, so no contrast ratio applies to them.
   */
  --dough: light-dark(#f1dcb4, #e6cc9c);
  --dough-shadow: light-dark(#d6b483, #a9855a);
  --dough-dent: light-dark(rgba(150, 110, 60, 0.35), rgba(90, 60, 25, 0.45));
  --golden: light-dark(#d9a052, #d29a4c);
  --baked: light-dark(#9a5422, #a65c28);
  --baked-deep: light-dark(#6e3815, #7a4019);
  --slash: light-dark(#f3d9a6, #f0d29a);
  --oven: light-dark(rgba(230, 120, 40, 0.28), rgba(240, 120, 30, 0.32));

  /*
   * The bakery's shop (PT33), from the approved prototype
   * (docs/prototypes/bakery.html): the shop by day in light, by lamplight in
   * dark. The wall is limewash over faint brick courses by day and sooty
   * brick in mortar by night, mottled, with a lamp's glow at the top. The
   * awning is crust brown and cream canvas. The sign is dark oak with cream
   * letters, hung on cords. The table is pale scrubbed oak by day and dark
   * oak by night, its grain and a dusting of flour drawn over it. The record
   * is a slate in a wooden frame, written in chalk. Each recipe card is the
   * page colour, held by a strip of tape. The counter's front is dark wood
   * with the storage note in cream. Text sits only on the sign, the wall, the
   * slate, the counter or a card, and client/colour-contrast.test.ts measures
   * each against the texture's strongest overlap.
   */
  --wall: light-dark(#efe4cc, #3a2a1f);
  --wall-brick: light-dark(rgba(150, 105, 60, 0.07), #2b1a12);
  --wall-mottle: light-dark(rgba(160, 120, 70, 0.1), rgba(0, 0, 0, 0.22));
  --lamp: light-dark(rgba(255, 250, 235, 0.3), rgba(255, 190, 110, 0.16));
  --awning-stripe: light-dark(#8b4513, #5e2f10);
  --awning-cream: light-dark(#f4ead5, #d9cbb0);
  --awning-shade: light-dark(rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.3));
  --sign: light-dark(#5a3417, #3a2010);
  --sign-deep: light-dark(#4a2a12, #2e190c);
  --sign-edge: light-dark(#33200e, #1c0f07);
  --sign-grain: rgba(0, 0, 0, 0.12);
  --sign-text: #f6ead2;
  --rope: light-dark(#3b2a1c, #8a6a4a);
  --wood: light-dark(#d8b98e, #4e3420);
  --wood-light: light-dark(#e4c9a2, #5a3c24);
  --grain: light-dark(rgba(90, 55, 25, 0.1), rgba(0, 0, 0, 0.28));
  --flour: light-dark(rgba(255, 255, 255, 0.55), rgba(255, 240, 210, 0.07));
  --slate: light-dark(#2e3833, #222a26);
  --slate-sheen: rgba(255, 255, 255, 0.06);
  --chalk: light-dark(#f1efe6, #ece9de);
  --chalk-muted: light-dark(#c9cfc6, #b9bfb5);
  --frame: light-dark(#7a5230, #4a2f19);
  --tape: light-dark(rgba(244, 234, 213, 0.75), rgba(217, 203, 176, 0.6));
  --counter: light-dark(#7a522e, #3a2514);
  --counter-text: #f2e4c9;
  --shadow: light-dark(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.45));

  /*
   * The bakery's props (PT34), every piece in the flour sacks' soft hessian
   * finish (docs/BAKERY_THEME_PLAN.md section 8): soft brown outlines rather
   * than black ink, tone for shade and creases, a pale highlight on rounded
   * sides, and fine textures (the weave, flecks of flour, wood grain) instead
   * of hatching. By day in light, by lamplight in dark, as the prototype.
   * All of it is decoration hidden from assistive technology, so no contrast
   * ratio applies, and client/colour-contrast.test.ts names each as such.
   */
  --prop-line: light-dark(#8a6a45, #4a3520);
  --prop-shade: light-dark(rgba(120, 85, 45, 0.28), rgba(0, 0, 0, 0.3));
  --prop-light: light-dark(rgba(255, 255, 255, 0.4), rgba(255, 240, 210, 0.12));
  --sack: light-dark(#dcc69c, #a48f6e);
  --twine: light-dark(#6e4a2a, #3a2412);
  --stencil: light-dark(#8f3a24, #6e2c1a);
  --enamel: light-dark(#e9dcc0, #b9a27e);
  --tint: light-dark(#f7efdd, #5b4330);
  --wood-dark: light-dark(#8a5f36, #3a2514);
  --copper: light-dark(#b86a3c, #8f512c);
  --steel: light-dark(#cfcac0, #8e887d);
  --wicker: light-dark(#c99c5e, #7f5c33);
  --brick: light-dark(#b5673f, #6e3a22);
  --mortar: light-dark(#e6d6bb, #3e2a1c);
  --mouth: light-dark(#2a1a10, #120a05);
  --fire: light-dark(#f2a33a, #ffb547);
  --glow: light-dark(rgba(242, 150, 50, 0.18), rgba(255, 150, 40, 0.38));
  --glass: light-dark(rgba(220, 235, 240, 0.16), rgba(180, 200, 210, 0.07));
  --glass-shine: light-dark(rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.1));
  --case-back: light-dark(#6e4a2c, #24160c);
  --case-light: light-dark(#9a7048, #6a4422);
  --price: light-dark(#5c4632, #f2e7d5);

  /* The awning's depth, and the drop of the cords from it to the sign. */
  --awning-height: clamp(3.25rem, 6vw, 5rem);
  --sign-drop: max(2.25rem, calc(var(--toggle-top) + var(--touch-target) + 0.5rem - var(--awning-height)));

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --sans: system-ui, sans-serif;

  /* 44 CSS pixels, or more when the player has set a larger text size. */
  --touch-target: max(44px, 2.75rem);
  --radius: 0.5rem;

  /*
   * Where the light and dark toggle floats: just inside the top right corner,
   * and inside the phone's safe area where the display has notches or rounded
   * corners. The insets are 0 on a rectangular viewport, and 0 too on iOS
   * unless the page asks for viewport-fit=cover, which it does not, so today
   * this is a safeguard rather than a change. While the page's scroll is
   * locked (PT36) it also stands clear of any scroll bar gutter the lock
   * gives back, which is otherwise unset.
   */
  --toggle-top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
  --toggle-right: calc(env(safe-area-inset-right, 0px) + 0.5rem + var(--scroll-lock-gutter, 0px));

  font-family: var(--sans);
  font-size: 100%;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* The player's choice, once made, wins over the system preference. */
:root[data-colour-scheme="light"] {
  color-scheme: light;
}

:root[data-colour-scheme="dark"] {
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/*
 * The scroll bar's room is always kept, so the page's width never changes as
 * the scroll bar comes and goes, and the shop's layout cannot flip between
 * widths as it does (docs/BAKERY_THEME_PLAN.md, section 7). Below the
 * counter, on a page shorter than the window, the counter's wood runs on to
 * the floor.
 */
html {
  scrollbar-gutter: stable;
  background: var(--counter);
}

/*
 * No scrolling while the kneading or the bake plays (PT36): each stage is
 * measured and placed as it starts, so a page scrolled under it would leave
 * the animation in odd places. Overflow hidden stops the wheel, touch and
 * the keyboard in every engine, while the game's own scrolls still move the
 * page. The class is set by script only while a transition plays, never
 * under reduced motion, and Skip or Escape end it at once. Where an engine
 * drops the scroll bar's gutter under overflow hidden (Chromium with classic
 * scroll bars), script measures the room lost into the custom property, and
 * it is given back at the right edge, the light and dark toggle included,
 * so nothing moves sideways.
 */
html.transition-scroll-locked {
  overflow: hidden;
  padding-right: var(--scroll-lock-gutter, 0px);
}

/*
 * The shop (PT33): a grid of three columns, the game's 42rem column between
 * two side tracks, and five rows: the masthead, room for a back shelf, the
 * table, room for a display case, and the counter. The side tracks take
 * whatever the column leaves, so they are empty below 42rem and hold the
 * wall either side of the table above it; the awning and the counter span
 * all three. The back shelf, the display case and the gutters' art come
 * later (PT34), into the rows and tracks kept for them here.
 *
 * The body's background is the wall: by day limewash over faint brick
 * courses, by night sooty brick, both mottled, with a lamp's glow at the top.
 * Each brick course is a conic gradient's quarter, the second course moved
 * half a brick along, so the bricks are drawn without an image file.
 */
body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 42rem) minmax(0, 1fr);
  grid-template-rows: auto auto auto auto auto;
  margin: 0;
  background-color: var(--wall);
  background-image:
    radial-gradient(ellipse 60% 22rem at 50% 0%, var(--lamp), transparent 70%),
    radial-gradient(circle at 20% 30%, var(--wall-mottle) 0 8rem, transparent 14rem),
    radial-gradient(circle at 80% 70%, var(--wall-mottle) 0 10rem, transparent 18rem),
    radial-gradient(circle at 60% 20%, var(--wall-mottle) 0 6rem, transparent 11rem),
    conic-gradient(at calc(100% - 2px) calc(50% - 2px), transparent 0 75%, var(--wall-brick) 0),
    conic-gradient(at calc(100% - 2px) calc(50% - 2px), transparent 0 75%, var(--wall-brick) 0);
  background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 2rem 1.5rem;
  background-size: auto, auto, auto, auto, 4rem 3rem, 4rem 3rem;
  color: var(--ink);
  /* A long word or link in a 320 pixel column wraps rather than overflowing. */
  overflow-wrap: break-word;
}

body > header {
  grid-column: 1 / -1;
  grid-row: 1;
}

body > main {
  grid-column: 2;
  grid-row: 3;
  padding-inline: 1rem;
}

body > footer {
  grid-column: 1 / -1;
  grid-row: 5;
}

/*
 * Visible focus for every focusable element (datum 0.16). The offset puts the
 * ring on the paper beside a control rather than on it, so it keeps its
 * contrast whatever the control's own colour.
 */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Present for assistive technology, hidden from sight. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/*
 * The masthead (PT33): the shop's front. A striped canvas awning runs across
 * the top of the window, its lower edge cut into scallops by a mask; the
 * title hangs below it on a wooden sign, by two cords; the tagline is
 * written on the wall beneath.
 */
.masthead {
  padding-bottom: 1.25rem;
  text-align: center;
}

.masthead::before {
  --scallop: 1.25rem;

  content: "";
  display: block;
  height: var(--awning-height);
  background:
    linear-gradient(to bottom, var(--awning-shade), transparent 35%, transparent 70%, var(--awning-shade)),
    repeating-linear-gradient(90deg, var(--awning-stripe) 0 2.5rem, var(--awning-cream) 2.5rem 5rem);
  -webkit-mask:
    linear-gradient(#000 0 0) top / 100% calc(100% - var(--scallop)) no-repeat,
    radial-gradient(circle at 50% 0, #000 calc(var(--scallop) - 0.5px), transparent var(--scallop)) bottom / 2.5rem var(--scallop) repeat-x;
  mask:
    linear-gradient(#000 0 0) top / 100% calc(100% - var(--scallop)) no-repeat,
    radial-gradient(circle at 50% 0, #000 calc(var(--scallop) - 0.5px), transparent var(--scallop)) bottom / 2.5rem var(--scallop) repeat-x;
}

/*
 * The sign. It hangs far enough below the awning that the floating toggle,
 * whose top right corner overlaps the awning, ends at least half a rem above
 * the sign's top even where a notch's safe area inset moves the toggle down
 * (--sign-drop). Its loaf sits above the words on a phone, where the words
 * take the sign's width, and beside them from 30rem.
 */
.masthead h1 {
  position: relative;
  width: fit-content;
  max-width: calc(100% - 2rem);
  margin: var(--sign-drop) auto 0;
  padding: 0.75rem 1rem 0.85rem;
  border: 2px solid var(--sign-edge);
  border-radius: 0.6rem;
  background:
    repeating-linear-gradient(0deg, transparent 0 0.55rem, var(--sign-grain) 0.55rem 0.6rem),
    linear-gradient(var(--sign), var(--sign-deep));
  box-shadow: 0 3px 0 var(--sign-edge), 0 6px 8px var(--shadow);
  font-family: var(--serif);
  font-size: clamp(2rem, 1.5rem + 2.5vw, 2.75rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--sign-text);
}

/* The two cords, from the awning's edge to the sign's top, drawn as dashes of twine. */
.masthead h1::after {
  content: "";
  position: absolute;
  right: 18%;
  bottom: calc(100% + 2px);
  left: 18%;
  height: var(--sign-drop);
  background:
    repeating-linear-gradient(to bottom, var(--rope) 0 4px, transparent 4px 6px) left / 2px 100% no-repeat,
    repeating-linear-gradient(to bottom, var(--rope) 0 4px, transparent 4px 6px) right / 2px 100% no-repeat;
}

@media (min-width: 30rem) {
  .masthead h1 {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    padding: 0.85rem 1.75rem 0.95rem;
  }
}

/*
 * The loaf mark: a bloomer, domed on top with a flat base, its slashes
 * showing pale crumb. Decorative only, and empty, so assistive technology
 * ignores it.
 */
.masthead h1::before,
.record-loaf dd::before {
  content: "";
  display: block;
  width: 3.25rem;
  height: 1.75rem;
  border: 2px solid var(--loaf-outline);
  border-radius: 50% 50% 0.35rem 0.35rem / 90% 90% 0.35rem 0.35rem;
  background-color: var(--loaf);
  background-image: repeating-linear-gradient(
    120deg,
    transparent 0 0.55rem,
    var(--crumb) 0.55rem 0.7rem,
    transparent 0.7rem 0.95rem
  );
}

.masthead h1::before {
  margin: 0 auto 0.5rem;
}

@media (min-width: 30rem) {
  .masthead h1::before {
    flex: none;
    margin: 0;
  }
}

/* Written on the wall, under the lamp's glow. */
.tagline {
  max-width: 30rem;
  margin: 1rem auto 0;
  padding-inline: 1rem;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-muted);
}

/*
 * The table (PT33): the content column is a scrubbed wooden table, its
 * planks' seams and grain drawn over a lighter band of oak, with flour
 * dusted on it. Nothing is written on the wood itself: every text sits on a
 * card, a slip, the chalkboard or a button, and only the buttons' fills and
 * the focus ring are measured against the wood.
 */
main {
  /* Positioned, so the answered question can be held where it stood while it is kneaded away (PR19). */
  position: relative;
  padding-block: 1.5rem 2rem;
  border-radius: 0.4rem 0.4rem 0 0;
  background-color: var(--wood);
  background-image:
    radial-gradient(ellipse 9rem 4rem at 18% 22%, var(--flour), transparent 70%),
    radial-gradient(ellipse 7rem 3rem at 82% 64%, var(--flour), transparent 70%),
    radial-gradient(ellipse 5rem 2rem at 40% 88%, var(--flour), transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 7rem, var(--grain) 7rem calc(7rem + 2px)),
    repeating-linear-gradient(90deg, transparent 0 0.9rem, var(--grain) 0.9rem 1rem, transparent 1rem 2.3rem, var(--grain) 2.3rem 2.35rem),
    linear-gradient(90deg, var(--wood) 0%, var(--wood-light) 30%, var(--wood) 55%, var(--wood-light) 80%, var(--wood) 100%);
  box-shadow: 0 10px 24px var(--shadow);
}

main:focus {
  outline: none;
}

/*
 * The game's number, set like a book's chapter title, on a paper ticket laid
 * on the table, so its words sit on the page colour rather than the wood.
 */
main h2 {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 1.25rem;
  padding: 0.125rem 1.25rem 0.25rem;
  border-radius: 0.2rem;
  background: var(--page);
  box-shadow: 0 2px 6px var(--shadow);
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 600;
  font-variant-caps: small-caps;
  letter-spacing: 0.04em;
  text-align: center;
}

h3 {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--crust);
}

/* Single line breaks inside a run are kept by the markup parser (PT5) for a verse line or a table row. */
.formatted-text p {
  white-space: pre-line;
}

.notice {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--crust);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--page);
}

/*
 * Any other words straight on the table (loading, the date the first game
 * starts, the words shown without JavaScript) are on a paper slip, as the
 * notice is.
 */
main > p:not(.notice),
main > noscript > p {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: 0.2rem;
  background: var(--page);
}

/*
 * The player's record, three entries in a baker's ledger, chalked on a slate
 * in a wooden frame propped on the table (PT33).
 */
.record {
  margin-bottom: 2rem;
  padding: 0.75rem 1rem 1rem;
  border: 0.55rem solid var(--frame);
  border-radius: 0.35rem;
  background-color: var(--slate);
  background-image: radial-gradient(ellipse at 30% 30%, var(--slate-sheen), transparent 60%);
  box-shadow: 0 4px 8px var(--shadow);
  color: var(--chalk);
}

.record h3 {
  color: var(--chalk-muted);
}

.record dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.record dt {
  font-size: 0.875rem;
  color: var(--chalk-muted);
}

.record dd {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.3;
}

.record-loaf dd::before {
  display: inline-block;
  width: 1.75rem;
  height: 1rem;
  margin-right: 0.4rem;
  vertical-align: -0.05em;
  background-image: repeating-linear-gradient(
    120deg,
    transparent 0 0.35rem,
    var(--crumb) 0.35rem 0.45rem,
    transparent 0.45rem 0.6rem
  );
}

/*
 * The recipe cards (PT33): the question being played, the questions read
 * back after the result, and the result itself, each a card of the page
 * colour lying on the table, held by a strip of tape across its top. The
 * text on a card keeps the page's measured colours; the options, the reveal,
 * the passage, the source and the buttons inside it keep their own look.
 */
.question,
.completion {
  position: relative;
  margin-top: 2rem;
  padding: 1.5rem 1.25rem 1.25rem;
  border-radius: 0.2rem;
  background: var(--page);
  box-shadow: 0 6px 14px var(--shadow);
}

.question::before,
.completion::before {
  content: "";
  position: absolute;
  top: -0.6rem;
  left: 50%;
  width: 6rem;
  height: 1.3rem;
  background: var(--tape);
  transform: translateX(-50%) rotate(-2deg);
}

.record + .question {
  margin-top: 0;
}

/*
 * The result's card stands its heading and loaf mark lower under the tape,
 * and needs little room at its foot, where the copy status already keeps a
 * line. The bake centres the result on the screen and sweeps the loaf onto
 * its mark (PT15); on a short phone the result fills the screen, so the mark
 * is lowered while the card stays no taller, keeping the loaf clear of the
 * Skip control in the top corner.
 */
.completion {
  padding-block: 2.5rem 0.5rem;
}

/*
 * On a phone the card's margins are narrower, so its words keep nearly the
 * width they had on the plain page and a question still fits the screen
 * (PR19): every line a margin takes from the prompt, the options or the
 * passage is a line of height the question loses.
 */
@media (max-width: 30rem) {
  .question,
  .completion {
    padding-inline: 0.75rem;
  }
}

.prompt {
  margin-bottom: 1rem;
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.45;
}

.prompt p {
  margin: 0 0 0.5rem;
}

/* Options are index cards: a whole card is the target, never just its text. */
.options {
  display: grid;
  gap: 0.625rem;
}

.option {
  display: block;
  width: 100%;
  min-height: var(--touch-target);
  margin: 0;
  padding: 0.75rem 1rem;
  border: 2px solid var(--rule);
  border-radius: var(--radius);
  background: var(--page);
  color: var(--ink);
  font: inherit;
  font-size: 1.0625rem;
  text-align: start;
  cursor: pointer;
}

.option[data-state="open"]:hover {
  border-color: var(--crust);
  background: var(--paper);
}

.option[aria-disabled="true"] {
  cursor: default;
}

.option-text,
.option-marker {
  display: block;
}

.option-marker {
  margin-top: 0.25rem;
  font-size: 0.9375rem;
  font-weight: 700;
}

/* Chosen and waiting for the reveal: a heavier border, and the words "Your answer". */
.option[data-state="chosen"] {
  border-width: 3px;
  border-color: var(--crust);
}

/* Not chosen and not the answer: quieter text, still at full contrast. */
.option[data-state="locked"],
.option[data-state="not-chosen"] {
  color: var(--ink-muted);
}

/*
 * Outcomes differ by border shape (double for correct, dashed for incorrect),
 * by a symbol and by the words inside each option, never by colour alone
 * (datum 0.16). The symbols carry empty alternative text, since the words
 * beside them already say the same thing to assistive technology.
 */
.option[data-state="chosen-correct"],
.option[data-state="correct"] {
  border: 5px double var(--correct);
  background: var(--correct-wash);
}

.option[data-state="chosen-incorrect"] {
  border: 3px dashed var(--incorrect);
  background: var(--incorrect-wash);
}

.option[data-state="chosen-correct"] .option-marker,
.option[data-state="correct"] .option-marker,
.verdict[data-outcome="correct"] {
  color: var(--correct);
}

.option[data-state="chosen-incorrect"] .option-marker,
.verdict[data-outcome="incorrect"] {
  color: var(--incorrect);
}

.option[data-state="chosen-correct"] .option-marker::before,
.option[data-state="correct"] .option-marker::before,
.verdict[data-outcome="correct"]::before {
  content: "\2713\00a0" / "";
}

.option[data-state="chosen-incorrect"] .option-marker::before,
.verdict[data-outcome="incorrect"]::before {
  content: "\2717\00a0" / "";
}

.reveal,
.reveal-waiting {
  margin-top: 1rem;
}

.reveal-waiting {
  font-style: italic;
  color: var(--ink-muted);
}

.verdict {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
}

.attribution {
  margin: 0 0 0.75rem;
  color: var(--ink-muted);
}

/* Padded to a full touch target, since the link is the way to the book. */
.attribution a {
  display: inline-block;
  min-height: var(--touch-target);
  padding-block: 0.625rem;
  color: var(--crust);
  font-family: var(--serif);
  font-style: italic;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.new-tab-hint {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-style: normal;
}

/* The full passage scrolls (PD6); the source above it stays in view (PR13). */
.note {
  max-height: 16rem;
  overflow-y: auto;
  padding: 0.25rem 1rem;
  border-left: 4px solid var(--crust);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--page);
  font-family: var(--serif);
  font-size: 1.0625rem;
}

/*
 * During play the passage gives way rather than the page (PR19): it may be as
 * tall as the dynamic viewport less everything else in the question, which
 * views/question-fit.ts measures into --passage-allowance, so the options, the
 * reveal and the way on fit on a phone's screen without scrolling the page.
 * 100dvh follows the browser's toolbars as they come and go. It never goes
 * below 7rem, about four lines, so where nothing can make the question fit
 * (a narrow screen at 200 percent zoom) the page scrolls, as it must for
 * WCAG 1.4.10 and 1.4.4; the page itself is never locked. Until the allowance
 * is measured, the 16rem above holds.
 */
.current-question .note {
  max-height: max(7rem, 100dvh - var(--passage-allowance, 100dvh - 16rem));
}

/* Every other button: crust brown, with the paper's colour for its words. */
button:not(.option) {
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  padding: 0.625rem 1.25rem;
  border: 2px solid var(--crust);
  border-radius: var(--radius);
  background: var(--crust);
  color: var(--on-crust);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:not(.option):hover,
button:not(.option):active {
  border-color: var(--crust-pressed);
  background: var(--crust-pressed);
}

/*
 * The light and dark toggle (PT14): a round button floating in the top right
 * corner as the page scrolls, showing a sun when the page is light and a
 * moon when it is dark, so the icon agrees with aria-pressed on its "Dark
 * mode" name. Its words are visually hidden; the icon is drawn on ::before,
 * which is empty, so assistive technology reads only the name. The selectors
 * carry the element type so they outrank the crust coloured button rules
 * above, which would otherwise fill it.
 */
button.colour-scheme-toggle {
  /* The face colour, used again for the gap between the sun and its rays. */
  --toggle-face: var(--page);

  position: fixed;
  top: var(--toggle-top);
  right: var(--toggle-right);
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--touch-target);
  height: var(--touch-target);
  padding: 0;
  border: 2px solid var(--rule);
  border-radius: 50%;
  background: var(--toggle-face);
  /*
   * A halo of the page colour round the ring (PT33). The toggle floats over
   * the awning, whose crust stripes the ring could not stand out from; with
   * the halo the ring always has the page colour on both sides, a pair
   * measured at 3:1, whatever is behind the toggle.
   */
  box-shadow: 0 0 0 3px var(--page);
  color: var(--ink);
}

button.colour-scheme-toggle:hover,
button.colour-scheme-toggle:active {
  --toggle-face: var(--paper);

  border-color: var(--crust);
  background: var(--toggle-face);
}

/* The sun: a disc, a ring of the face colour, then eight rays cut by a conic gradient and clipped round. */
button.colour-scheme-toggle::before {
  content: "";
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background:
    radial-gradient(circle closest-side, currentColor 0 46%, var(--toggle-face) 46% 62%, transparent 62%),
    repeating-conic-gradient(from -8deg, currentColor 0deg 16deg, transparent 16deg 45deg);
}

/* The moon: a crescent, the inset shadow of a disc with no fill of its own. */
button.colour-scheme-toggle[aria-pressed="true"]::before {
  width: 1.25rem;
  height: 1.25rem;
  background: transparent;
  box-shadow: inset 0.45rem -0.2rem 0 0 currentColor;
}

.next-step {
  display: block;
  margin: 1.5rem auto 0;
}

/*
 * On a screen no taller than a large phone (56rem, 896 pixels at the default
 * text size), the question being played is set a little closer, so that its
 * options, reveal and way on fit together without scrolling the page (PR19).
 * Only the space between things changes: every target stays at least 44
 * pixels and the text keeps its size. The spacing is set so a question fits
 * at 390 by 844 even where the serif and sans fall back to wide faces, as
 * Android's Noto and Linux's DejaVu do, not only Apple's narrower ones. :where() keeps these rules no more
 * specific than the ones they adjust, so a later rule still wins over them.
 */
@media (max-height: 56rem) {
  /*
   * The card's foot, under the reveal, closes up too; this rule follows the
   * card's own, so it wins. It is set on every question card rather than the
   * current one alone, so the answered question keeps its height when it is
   * held for the kneading and is no longer the current question (PT32).
   */
  .question {
    padding-bottom: 0.75rem;
  }

  :where(.current-question) .prompt {
    margin-bottom: 0.5rem;
  }

  :where(.current-question) .options {
    gap: 0.375rem;
  }

  :where(.current-question) .option {
    padding-block: 0.5rem;
  }

  :where(.current-question) .reveal,
  :where(.current-question) .reveal-waiting {
    margin-top: 0.5rem;
  }

  :where(.current-question) .verdict {
    margin-bottom: 0.25rem;
  }

  :where(.current-question) .attribution {
    margin-bottom: 0.25rem;
  }

  :where(.current-question) + .next-step {
    margin-top: 0.5rem;
  }
}

/*
 * The result reads as two parts: the loaf beside its marks and score, then
 * the share box below a rule. The loaf spans the two rows at its right, so
 * three short lines stack as one block instead of four rows of different
 * sizes down the left edge.
 */
.completion {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 1.25rem;
  align-items: center;
}

.completion > * {
  grid-column: 1 / -1;
}

.completion > .result-loaf {
  grid-column: 1;
  grid-row: span 2;
  align-self: center;
}

.completion > .result-marks,
.completion > .score {
  grid-column: 2;
}

.completion > button {
  justify-self: start;
}

.completion h3 {
  margin-bottom: 1rem;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.score {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.35;
}

/*
 * The result's loaf (PT15): the bloomer the bake sweeps onto, drawn as the
 * baked dough is at the end of its sweep, with the same slashes, so the hand
 * over from the moving loaf to this one is barely seen. Decorative and
 * hidden from assistive technology; the score says the result in words.
 */
.result-loaf {
  position: relative;
  width: 5.5rem;
  height: 3.2rem;
  margin: 0;
  border: 1px solid var(--baked-deep);
  border-radius: 50% 50% 16% 16% / 78% 78% 22% 22%;
  background-color: var(--baked);
  box-shadow: 0 2px 0 var(--baked-deep), inset 0 -0.2rem 0 var(--baked-deep);
}

.result-loaf::before {
  content: "";
  position: absolute;
  inset: 18% 14% 30% 14%;
  border-radius: 50% 50% 20% 20%;
  background: repeating-linear-gradient(115deg, transparent 0 18%, var(--slash) 18% 23%, transparent 23% 36%);
  opacity: 0.9;
}

/* One mark per question, the share text's glyphs, with their outcome in words for assistive technology. */
.result-marks {
  display: flex;
  gap: 0.75rem;
  min-height: 2.6rem;
  margin: 0 0 0.25rem;
  padding: 0;
  font-size: 1.75rem;
  line-height: 1.3;
  list-style: none;
}

/*
 * The kneading and bake overlay (PT15): fixed over the page, never in the
 * way of a pointer, hidden from assistive technology, and present only while
 * a transition plays. The stage is placed by script over the card being
 * kneaded; inside it, as in the prototype, the oven's glow sits behind the
 * tray line, the caption and the dough.
 */
.bakehouse {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.bakehouse-stage {
  position: absolute;
}

.bakehouse-oven {
  position: absolute;
  inset: -0.5rem;
  border-radius: 1rem;
  background: radial-gradient(ellipse at 50% 80%, var(--oven), transparent 70%);
  opacity: 0;
}

.bakehouse-tray {
  position: absolute;
  right: 15%;
  bottom: 3.2rem;
  left: 15%;
  height: 0;
  border-top: 4px solid var(--rule);
  border-radius: 2px;
  opacity: 0;
}

.bakehouse-caption {
  position: absolute;
  right: 0;
  bottom: 0.6rem;
  left: 0;
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-muted);
  text-align: center;
  opacity: 0;
}

/* The card that becomes the dough: the page's colour and rule, as the prototype's card. */
.bakehouse-dough {
  position: absolute;
  inset: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background-color: var(--page);
  opacity: 0;
}

/* The dent: the heel of a hand pressing into the dough. */
.bakehouse-dent {
  position: absolute;
  top: 27%;
  left: 30%;
  width: 38%;
  height: 46%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, var(--dough-dent), transparent 70%);
  opacity: 0;
}

/* The loaf's slashes, opening as it bakes. */
.bakehouse-slashes {
  position: absolute;
  inset: 18% 14% 30% 14%;
  border-radius: 50% 50% 20% 20%;
  background: repeating-linear-gradient(115deg, transparent 0 18%, var(--slash) 18% 23%, transparent 23% 36%);
  opacity: 0;
}

/*
 * The Skip control (PT28, WCAG 2.2.2), present only while a transition plays.
 * It floats in the top left corner, the opposite corner from the light and
 * dark toggle and where a skip link is usually found. The dough and its
 * caption sit in the lower part of a stage at least six tenths as tall as
 * the column is wide, and the loaf lands on a mark below the result's
 * heading, so the corner stays clear of all three even at 320 pixels; the
 * browser tests watch every frame to hold it to that. It keeps the crust
 * coloured button look, a full touch target and the focus ring of every
 * other button, and is stacked above the overlay so the dough never paints
 * over it.
 */
button.skip-transition {
  position: fixed;
  top: var(--toggle-top);
  left: calc(env(safe-area-inset-left, 0px) + 0.5rem);
  z-index: 2;
}

/*
 * The answered question, held where it stood while it is kneaded away and
 * the next question is drawn in its place (PR19); its top, left and width
 * are set by script.
 */
.transition-retired {
  position: absolute;
  margin: 0;
}

/* What a transition will show, hidden from its first frame until it is shown. */
.transition-hidden {
  opacity: 0;
}

.completion label {
  display: block;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-weight: 600;
}

.share-text {
  display: block;
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--rule);
  border-radius: var(--radius);
  background: var(--page);
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

.copy-status {
  min-height: 1.5em;
}

/*
 * The counter's wooden front (PT33), across the whole window, shaded under
 * the table's edge, with the storage note written on it in cream.
 */
footer {
  padding: 1rem 1rem 1.25rem;
  background-color: var(--counter);
  background-image:
    linear-gradient(to bottom, var(--shadow), transparent 0.5rem),
    repeating-linear-gradient(90deg, transparent 0 1.1rem, var(--grain) 1.1rem 1.18rem);
  font-size: 0.875rem;
  text-align: center;
  color: var(--counter-text);
}

footer p {
  max-width: 40rem;
  margin: 0 auto;
}

/*
 * The bakery's props (PT34, docs/BAKERY_THEME_PLAN.md section 7): the hidden
 * sprite in index.html and the pieces that place its symbols. Each piece is
 * decoration: aria-hidden in the markup, nothing focusable, and no pointer
 * events here, so a click goes through to the page beneath. The art is
 * coloured by these classes alone, so it follows the light and dark toggle
 * as the rest of the page does. Outline, its width and the line ends are
 * inherited, which reaches the shapes inside each <use>'s copy of a symbol,
 * where a selector naming an ancestor outside the symbol would not.
 *
 * The widths follow the shop's media queries (PT33): below 34rem the back
 * shelf, table and display case; from 34rem two utensils hang either side of
 * the sign; from 52rem the back shelf moves out to the gutters, each at least
 * 9.5rem wide, so up to about 61rem the column is a little under 42rem.
 */
.scene {
  pointer-events: none;
  fill: none;
  stroke: var(--prop-line);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scene svg {
  display: block;
}

.scene-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Fills, each a material. */
.p-sack { fill: var(--sack); }
.p-enamel { fill: var(--enamel); }
.p-tint { fill: var(--tint); }
.p-wood { fill: var(--wood); }
.p-wood-dk { fill: var(--wood-dark); }
.p-dough { fill: var(--dough); }
.p-loaf { fill: var(--loaf); }
.p-golden { fill: var(--golden); }
.p-copper { fill: var(--copper); }
.p-steel { fill: var(--steel); }
.p-wicker { fill: var(--wicker); }
.p-brick { fill: url(#bricks); }
.p-mouth { fill: var(--mouth); stroke: none; }
.p-fire { fill: url(#fire); stroke: none; }
.p-flame { fill: var(--fire); stroke: var(--fire); }
.p-case { fill: url(#case-light); stroke: none; }
.p-glass { fill: var(--glass); stroke: none; }
.p-shine { fill: var(--glass-shine); stroke: none; }

/* Tone, never ink: shade, creases, highlights and the fine textures laid over a fill. */
.p-shade,
.p-crease,
.p-hi,
.p-weave,
.p-speck,
.p-grain {
  stroke: none;
}

.p-shade { fill: var(--prop-shade); }
.p-crease { fill: var(--prop-shade); opacity: 0.55; }
.p-hi { fill: var(--prop-light); }
.p-weave { fill: url(#weave); }
.p-speck { fill: url(#speck); }
.p-grain { fill: url(#grain); }

/* Lines. */
.p-ln,
.p-wire,
.p-twine,
.p-slash {
  fill: none;
}

.p-thin { stroke-width: 0.9; }
.p-wire { stroke: var(--steel); stroke-width: 1.6; }
.p-twine { stroke: var(--twine); stroke-width: 2.4; }
.p-slash { stroke: var(--slash); }

/* The sprite's patterns and gradients. */
.p-weave-line { stroke: var(--prop-line); stroke-width: 0.35; opacity: 0.45; }
.p-speck-dot { stroke: var(--prop-light); stroke-width: 0.9; }
.p-grain-line { stroke: var(--prop-shade); stroke-width: 0.6; }
.p-brick-face { fill: var(--brick); stroke: none; }
.p-mortar { stroke: var(--mortar); stroke-width: 1; }
.p-fire-a { stop-color: var(--fire); }
.p-fire-b { stop-color: var(--fire); stop-opacity: 0; }
.p-case-top { stop-color: var(--case-light); }
.p-case-bottom { stop-color: var(--case-back); }

/* Words drawn in the art: the sack's stencil and the case's name tags, both hidden from assistive technology. */
.p-stencil,
.p-tag {
  stroke: none;
  font-family: var(--serif);
  text-anchor: middle;
}

.p-stencil {
  fill: var(--stencil);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
  opacity: 0.85;
}

.p-tag {
  fill: var(--price);
  font-size: 12px;
}

/* The utensils hang from a rail either side of the sign, from 34rem. */
.scene-rail {
  display: none;
}

@media (min-width: 34rem) {
  .masthead {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    column-gap: 1rem;
    align-items: start;
  }

  .masthead::before {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .masthead h1 {
    grid-column: 2;
    grid-row: 2;
    max-width: none;
  }

  .scene-rail {
    display: block;
    grid-row: 2;
    margin-top: -0.4rem;
  }

  .scene-rail-left {
    grid-column: 1;
    padding-left: 1rem;
  }

  .scene-rail-right {
    grid-column: 3;
    padding-right: 1rem;
  }

  .scene-rail svg {
    width: min(8.5rem, 100%);
    height: auto;
    overflow: visible;
  }

  .scene-rail-left svg {
    margin-left: auto;
  }

  .tagline {
    grid-column: 1 / -1;
    grid-row: 3;
  }
}

/* The back shelf: the props in a row above the table, below 52rem. */
.scene-shelf {
  grid-column: 2;
  grid-row: 2;
  padding: 0 1.25rem 0.5rem;
}

.scene-shelf svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

/*
 * The gutters, from 52rem, each standing on the counter beside the table:
 * the top piece against the wall at the table's top, the bottom piece on its
 * plank just above the display case. Contained in size, so the art never
 * makes the table's row taller; each piece shrinks to half the gutter's
 * height where the table is short.
 */
.scene-gutter {
  display: none;
}

@media (min-width: 52rem) {
  body {
    grid-template-columns: minmax(9.5rem, 1fr) minmax(0, 42rem) minmax(9.5rem, 1fr);
  }

  .scene-gutter {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    justify-content: space-between;
    grid-row: 3;
    padding: 1rem 0.75rem 0;
    contain: size;
  }

  .scene-gutter svg {
    width: min(300px, 100%);
    height: auto;
    max-height: calc(50% - 0.75rem);
    overflow: visible;
  }

  .scene-shelf {
    display: none;
  }
}

.scene-gutter-left {
  grid-column: 1;
}

.scene-gutter-right {
  grid-column: 3;
  background: radial-gradient(ellipse 70% 30% at 50% 88%, var(--glow), transparent 70%);
}

/* The display case, across the counter above the storage note. */
.scene-case {
  grid-column: 1 / -1;
  grid-row: 4;
}

.scene-case svg {
  width: 100%;
  height: clamp(8.5rem, 13vw, 11rem);
}

/* Colour changes on hover only when motion is welcome; nothing moves at all otherwise. */
@media (prefers-reduced-motion: no-preference) {
  .option,
  button:not(.option) {
    transition: background-color 120ms ease-out, border-color 120ms ease-out;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/*
 * In forced colours (Windows contrast themes) box shadows and author colours
 * are dropped, which would leave the light and dark toggle blank, so its icon
 * keeps its drawing in the system's own button colours. Last in the
 * stylesheet, so these rules win over every rule they undo.
 */
@media (forced-colors: active) {
  button.colour-scheme-toggle {
    --toggle-face: ButtonFace;
  }

  button.colour-scheme-toggle::before {
    forced-color-adjust: none;
    color: ButtonText;
  }

  /*
   * The bakery's shop (PT33) gives way to the plain layout: no wall, awning,
   * grain, flour, slate, tape or shadow, only the system's own colours. The
   * awning, the sign's cords and the cards' tape are not drawn at all; the
   * sign, the game's heading and the cards keep a border, so each is still a
   * box of its own.
   */
  body,
  .masthead h1,
  main,
  main h2,
  .record,
  .question,
  .completion,
  footer {
    background-image: none;
    box-shadow: none;
  }

  .masthead::before,
  .masthead h1::after,
  .question::before,
  .completion::before {
    display: none;
  }

  main h2,
  .question,
  .completion {
    border: 1px solid CanvasText;
  }

  /* The props (PT34) are not drawn at all. */
  .scene {
    display: none;
  }
}
