/* Instant Lesson: a light, welcoming start page and a dark, call-style lesson room.
   Sections: tokens, base, buttons, start page, cards, lesson room (stage, tutor tile,
   self-view, shared screen, pictures on the shared screen, celebration, captions,
   controls, debug), tutor avatar, motion, wider screens. */

/* ---------- tokens ---------- */

:root {
  /* palette */
  --sun-50: #fffaf0;
  --sun-100: #fff1d6;
  --sun-200: #ffe3a8;
  --sun-400: #ffc940;
  --sun-500: #ffae1f;
  --coral-300: #ff9d8a;
  --coral-600: #e4572e;
  --cocoa-800: #4a2a18;
  --indigo-500: #4f46e5;
  --indigo-600: #4338ca;
  --indigo-800: #2f2a8f;
  --ink-900: #1c2140;
  --ink-700: #3d4468;
  --ink-500: #5c6485;
  --line-200: #e9e1d0;
  --line-400: #cfc6b2;
  --paper: #ffffff;
  --mint-400: #4fd6a8;
  --sky-400: #6cb6ff;
  --red-500: #e5484d;
  --red-600: #c93a40;
  --red-700: #c0392b;
  --rose-50: #ffeceb;
  --rose-300: #f3b3b0;
  --rose-800: #96181f;
  --night-950: #0b1024;
  --night-900: #121935;
  --night-800: #1b2447;
  --night-700: #27325e;
  --night-600: #36437a;
  --cloud-100: #eef1ff;
  --cloud-300: #b9c1e6;
  --chip: rgba(11, 16, 36, 0.74);
  --screen: #fffdf8; /* the surface of the tutor's shared screen */

  /* roles (light theme) */
  --bg: var(--sun-50);
  --text: var(--ink-900);
  --text-soft: var(--ink-500);
  --focus: var(--indigo-500);

  --radius-l: 28px;
  --radius-m: 18px;
  --radius-s: 12px;
  --shadow-card: 0 1px 0 rgba(28, 33, 64, 0.04), 0 22px 44px -22px rgba(28, 33, 64, 0.35);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

body[data-theme="room"] {
  --bg: var(--night-950);
  --text: var(--cloud-100);
  --text-soft: var(--cloud-300);
  --focus: var(--sun-400);
}

/* ---------- base ---------- */

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(60rem 30rem at 90% -10%, var(--sun-200), transparent 62%),
    radial-gradient(44rem 28rem at -10% 105%, #dde4ff, transparent 60%);
  background-attachment: fixed;
}

body[data-theme="room"] {
  background-image: radial-gradient(80rem 40rem at 50% -25%, var(--night-700), transparent 65%);
}

h1,
p {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Headings only receive focus from script when the view changes. */
h1[tabindex="-1"]:focus {
  outline: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.noscript {
  margin: 2rem auto;
  max-width: 32rem;
  padding: 1rem;
  text-align: center;
}

.icon {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--solid {
  fill: currentColor;
  stroke: none;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 3rem;
  padding: 0.7rem 1.4rem;
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

.btn--primary {
  background: var(--indigo-500);
  color: #fff;
  box-shadow: 0 6px 0 var(--indigo-800);
}

.btn--primary:hover {
  background: var(--indigo-600);
}

.btn--primary:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--indigo-800);
}

.btn--big {
  width: 100%;
  min-height: 4rem;
  font-size: 1.4rem;
}

.btn--ghost {
  width: 100%;
  background: transparent;
  color: var(--ink-700);
  border: 2px solid var(--line-400);
}

.btn--ghost:hover {
  background: var(--sun-50);
}

.btn--small {
  min-height: 2.5rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  background: var(--night-600);
  color: #fff;
}

.btn:disabled {
  opacity: 0.75;
  cursor: progress;
}

/* ---------- start page ---------- */

.start {
  padding: clamp(1.25rem, 5vw, 3rem) 1rem 3rem;
}

.start__wrap {
  max-width: 40rem;
  margin: 0 auto;
}

.start__header {
  margin-bottom: 1.5rem;
  text-align: center;
}

.avatar--hello {
  width: 9.5rem; /* Bilby is mostly ears: the face is about 60% of this */
  margin: 0 auto 0.25rem;
}

.start h1 {
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.start__subtitle {
  max-width: 30rem;
  margin: 0.6rem auto 0;
  font-size: 1.2rem;
  color: var(--ink-700);
}

.badge {
  display: inline-block;
  margin-top: 0.9rem;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  background: var(--sun-200);
  color: var(--cocoa-800);
  font-size: 0.9rem;
  font-weight: 800;
}

.panel {
  display: grid;
  gap: 1.25rem;
  padding: clamp(1.25rem, 5vw, 2rem);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-l);
  background: var(--paper);
  box-shadow: var(--shadow-card);
}

.field label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.3;
}

.field textarea {
  display: block;
  width: 100%;
  min-height: 3.75rem;
  padding: 0.85rem 1rem;
  border: 2px solid var(--line-400);
  border-radius: var(--radius-m);
  background: var(--sun-50);
  font-size: 1.15rem;
  line-height: 1.4;
  resize: vertical;
}

.field textarea::placeholder {
  color: var(--ink-500);
  opacity: 0.85;
}

.field textarea:focus-visible {
  border-color: var(--indigo-500);
  outline-offset: 1px;
}

.form-error {
  padding: 0.85rem 1rem;
  border: 2px solid var(--rose-300);
  border-radius: var(--radius-m);
  background: var(--rose-50);
  color: var(--rose-800);
  font-weight: 700;
}

/* The sentences for a child who typed that somebody is hurting or scaring them: calm, not red. */
.form-error--calm {
  border-color: var(--cloud-300);
  background: var(--cloud-100);
  color: var(--ink-900);
  font-weight: 600;
}

.notice {
  font-size: 1rem;
  color: var(--ink-700);
}

.notice a {
  color: var(--indigo-600);
  font-weight: 700;
}

/* ---------- cards (pre-join, expired, mic help, end, safe stop, error) ---------- */

.card-view {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.25rem;
}

.card {
  --focus: var(--indigo-500);
  display: grid;
  justify-items: center;
  gap: 1rem;
  width: min(100%, 32rem);
  padding: clamp(1.5rem, 6vw, 2.5rem);
  border-radius: 32px;
  background: var(--paper);
  color: var(--ink-900);
  text-align: center;
  box-shadow: var(--shadow-card);
}

.card h1 {
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  font-weight: 900;
  line-height: 1.2;
}

.card__body {
  font-size: 1.2rem;
  color: var(--ink-700);
}

.card__small {
  font-size: 0.9rem;
  color: var(--ink-500);
}

.card__actions {
  display: grid;
  gap: 0.9rem;
  width: 100%;
  margin-top: 0.5rem;
}

.card__actions:empty {
  display: none;
}

.avatar--card {
  width: 10rem;
}

/* A soft "pause" mark for the safe-stop card: calm, not a warning sign. */
.card__art--pause {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  background: #e6ebff;
}

.card__art--pause::before,
.card__art--pause::after {
  content: "";
  width: 0.8rem;
  height: 2rem;
  border-radius: 0.4rem;
  background: #8e9be0;
}

/* ---------- lesson room ---------- */

/* A grid of rows rather than a column of boxes: while the tutor shares a screen the captions
   are put into the stage's own row, over the bottom of the shared screen (see .captions). */
.room {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr; /* the line over the room, then the stage takes what is left */
  overflow-x: hidden; /* celebration stars may fly past the edge; never scroll sideways */
  overflow-x: clip;
  gap: 0.75rem;
  max-width: 82rem;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0.75rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

/* Sharing, the screen takes the whole width of the window, as it does in a video call. */
.room.is-presenting {
  max-width: none;
}

.room__top {
  display: flex;
  grid-row: 1;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.15rem 0.4rem;
}

.room__brand {
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-soft);
  overflow-wrap: anywhere; /* a lesson of a course names itself: "Social Studies · Unit 1 · Lesson 2: ..." */
}

.timer {
  flex: none;
  padding: 0.25rem 0.85rem;
  border-radius: 999px;
  background: var(--night-800);
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* The stage shows the tutor large. While the tutor is "presenting" (class is-presenting, set by
   app.js on the stage and on the room) the shared screen fills the stage, and the tutor and the
   child's own camera become two small tiles in its top right corner, as screen sharing looks in
   Zoom or Google Meet. Emily Zhang's review of the new version (2026-10-15): the shared screen
   was two thirds of the width under a big tutor tile, big captions and big buttons, the map was
   hard to read, and the tutor said "I can't zoom in". Both parts are positioned inside the
   stage, so its size never depends on which layout is showing. */
.stage {
  --tiles-w: clamp(8rem, 14vw, 13rem); /* presenting: width of the two small tiles */
  --tiles-gap: 0.4rem;
  --tiles-at: 0.6rem; /* presenting: how far the tiles and the pill keep from the screen's edges */
  --caption-room: 5rem; /* presenting: the strip at the bottom of the screen the captions sit in */
  --swap: 0.45s cubic-bezier(0.3, 0.1, 0.2, 1); /* the shared screen opening and closing */
  position: relative;
  grid-row: 2;
  grid-column: 1;
  min-height: 21rem;
}

/* The tutor and the self-view change place in one step when sharing starts or stops, so both
   ways they fade in instead of jumping. */
.stage__main {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  --self-width: clamp(9.5rem, 20vw, 13.5rem); /* picture-in-picture size on wide tiles */
  animation: self-back 0.35s ease backwards;
}

/* Presenting: a narrow column of two tiles in the top right corner, over the shared screen. */
.stage.is-presenting .stage__main {
  inset: var(--tiles-at) var(--tiles-at) auto auto;
  width: var(--tiles-w);
  gap: var(--tiles-gap);
  transform-origin: top right;
  animation: self-away 0.4s ease 0.1s backwards;
}

.tile {
  overflow: hidden;
  border-radius: var(--radius-l);
}

.stage.is-presenting .tile {
  border-radius: var(--radius-s);
}

/* tutor tile */

.tutor {
  --level: 0;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border: 3px solid transparent;
  background: radial-gradient(120% 95% at 50% 0%, var(--night-600), var(--night-800) 72%);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tutor.is-talking {
  border-color: var(--sun-400);
  box-shadow: 0 0 0 4px rgba(255, 201, 64, 0.16);
}

.stage.is-presenting .tutor {
  flex: none;
  width: 100%;
  aspect-ratio: 4 / 3;
}

.tutor__figure {
  position: absolute;
  inset: 3.6rem 1rem; /* clear of the chips in the tile's corners */
  max-width: 24rem;
  max-height: 24rem;
  margin: auto;
}

/* Presenting: the tile is small, so the tutor fills it and the two chips sit over its edges. */
.stage.is-presenting .tutor__figure {
  inset: 0.3rem 0.3rem 0;
}

/* The SVG scales itself to fit this box, whatever shape the tile is. */
.avatar--tutor,
.avatar--tutor .avatar__svg {
  width: 100%;
  height: 100%;
}

.avatar--tutor {
  transition: opacity 0.4s ease, filter 0.4s ease;
}

.tutor[data-state="connecting"] .avatar--tutor {
  opacity: 0.55;
  filter: saturate(0.5);
}

.status {
  position: absolute;
  z-index: 1; /* above the tutor's halo */
  top: 0.85rem;
  left: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  max-width: calc(100% - 1.7rem);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  background: var(--chip);
  font-size: 1.05rem;
  font-weight: 800;
}

.status__text,
.tile__who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Presenting: a small pill that says only what the tutor is doing ("Talking", "Listening"):
   app.js shortens the words, the tutor's name is on the tile already. */
.stage.is-presenting .status {
  top: 0.3rem;
  left: 0.3rem;
  gap: 0.3rem;
  max-width: calc(100% - 0.6rem);
  padding: 0.12rem 0.5rem;
  font-size: 0.72rem;
}

.status__dot {
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--cloud-300);
}

.stage.is-presenting .status__dot {
  width: 0.5rem;
  height: 0.5rem;
}

.status[data-state="connecting"] .status__dot {
  animation: pulse 1.2s ease-in-out infinite;
}

.status[data-state="talking"] .status__dot {
  background: var(--sun-400);
}

.status[data-state="listening"] .status__dot {
  background: var(--mint-400);
}

.status[data-state="thinking"] .status__dot {
  background: var(--sky-400);
  animation: pulse 0.9s ease-in-out infinite;
}

.status[data-state="muted"] .status__dot {
  background: var(--coral-300);
}

/* live microphone meter: shown while listening so the child sees they are heard */
.meter {
  display: none;
  align-items: flex-end;
  gap: 3px;
  height: 1.15rem;
}

.status[data-state="listening"] .meter {
  display: inline-flex;
}

.meter i {
  width: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.26);
  transition: background-color 0.08s linear;
}

.meter i:nth-child(1) { height: 35%; }
.meter i:nth-child(2) { height: 50%; }
.meter i:nth-child(3) { height: 65%; }
.meter i:nth-child(4) { height: 82%; }
.meter i:nth-child(5) { height: 100%; }

.meter i.is-on {
  background: var(--mint-400);
}

.stage.is-presenting .meter {
  gap: 2px;
  height: 0.7rem;
}

.stage.is-presenting .meter i {
  width: 3px;
}

.tile__name {
  position: absolute;
  z-index: 1;
  bottom: 0.85rem;
  left: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: calc(100% - 1.7rem);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: var(--chip);
  font-size: 1.1rem;
  font-weight: 800;
}

.stage.is-presenting .tile__name {
  bottom: 0.3rem;
  left: 0.3rem;
  gap: 0.3rem;
  max-width: calc(100% - 0.6rem);
  padding: 0.12rem 0.5rem;
  font-size: 0.78rem;
}

/* "AI tutor": the child is always told the tutor is an AI, on the small tile too. */
.tile__tag {
  flex: none;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  background: var(--sun-400);
  color: var(--night-950);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stage.is-presenting .tile__tag {
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  font-size: 0.55rem;
}

/* self-view: a compact strip on phones, a picture-in-picture tile on wider screens */

.self {
  display: grid;
  flex: none;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  align-items: center;
  column-gap: 0.75rem;
  padding: 0.45rem;
  border: 2px solid var(--night-700);
  border-radius: var(--radius-m);
  background: var(--night-900);
  animation: self-back 0.35s ease backwards;
}

.self__frame {
  position: relative;
  display: grid;
  grid-row: span 2;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-s);
  background: var(--night-700);
}

.self__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror, like every video call */
}

.self__placeholder .icon {
  display: block;
  width: 2.2rem;
  height: 2.2rem;
  color: var(--cloud-300);
}

.self__label {
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--text-soft);
}

.self__note {
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--sun-200);
}

/* "You", in the corner of the small tile while a screen is shared. */
.self__you {
  position: absolute;
  bottom: 0.3rem;
  left: 0.3rem;
  display: none;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--chip);
  color: var(--cloud-100);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.4;
}

/* Presenting: the second small tile, under the tutor's and not as tall. Its note folds away;
   the "You" chip says whose camera it is. */
.stage.is-presenting .self {
  position: relative;
  inset: auto;
  display: block;
  width: 100%;
  padding: 0;
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.7);
  animation: none;
}

.stage.is-presenting .self__frame {
  aspect-ratio: 2 / 1;
  border-radius: 0;
}

.stage.is-presenting .self__label,
.stage.is-presenting .self__note {
  display: none;
}

.stage.is-presenting .self__you {
  display: block;
}

/* shared screen: what the tutor is "presenting". It fills the stage. */

.share {
  position: absolute;
  inset: 0;
  visibility: hidden;
  opacity: 0;
  clip-path: inset(0 0 100% 0 round var(--radius-l)); /* closed: wiped away towards its top edge */
  transition: clip-path var(--swap), opacity 0.2s ease 0.25s, visibility 0s linear 0.45s;
}

.stage.is-presenting .share {
  visibility: visible;
  opacity: 1;
  clip-path: inset(0 0 0 0 round var(--radius-l));
  transition: clip-path var(--swap), opacity 0.2s ease, visibility 0s;
}

/* The screen itself: light, like paper, so pictures read well inside the dark room. */
.share__window {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 3px solid var(--mint-400);
  border-radius: var(--radius-l);
  background-color: var(--screen);
  background-image: radial-gradient(rgba(28, 33, 64, 0.08) 1.5px, transparent 1.6px);
  background-position: center;
  background-size: 1.5rem 1.5rem;
}

/* What is drawn keeps clear of what floats over the screen: the two tiles at its right, and the
   captions at its bottom while they are on. On an upright screen, where there is height to
   spare, the tiles have a strip across the top instead, beside the pill. On a screen held
   sideways the pill keeps a strip of its own at the top, or it covers the first words of a
   puzzle or a label on the map (review of 2026-10-15). */
.room .share__window {
  padding-top: calc(var(--tiles-at) * 2 + 1.8rem);
  padding-right: calc(var(--tiles-w) + var(--tiles-at) * 2);
}

.room:not(.captions-off) .share__window {
  padding-bottom: var(--caption-room);
}

@media (orientation: portrait) {
  .room .share__window {
    padding-top: calc(var(--tiles-w) * 1.25 + var(--tiles-gap) + var(--tiles-at) * 2);
    padding-right: 0;
  }
}

/* The pill over the top left corner: a green dot and "Bilby is sharing: Map of California"
   (app.js writes the words). */
.share__bar {
  position: absolute;
  z-index: 1;
  top: var(--tiles-at, 0.6rem);
  left: var(--tiles-at, 0.6rem);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: calc(100% - var(--tiles-w, 0rem) - var(--tiles-at, 0.6rem) * 3);
  padding: 0.3rem 0.85rem;
  border-radius: 1rem;
  background: var(--night-900);
  color: var(--cloud-100);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.3;
}

.share__dot {
  flex: none;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--mint-400);
}

.share__title {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* The part pictures are drawn in, and measured against (container units). */
.share__body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  color: var(--ink-900);
  container: share / size;
}

/* ---------- pictures on the shared screen (built by visuals.js) ---------- */

/* Every size below is a share of the screen: --cw and --ch are 1% of its width and height.
   --wait lets the screen slide open before the picture comes to life. Entrance animations
   only describe where a part comes from, so with motion switched off everything is simply there. */
.vis {
  --cw: 0.6vw; /* rough stand-ins for browsers without container units */
  --ch: 0.4vh;
  --wait: 0.35s;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--ch) * 4);
  padding: calc(var(--ch) * 5) calc(var(--cw) * 4);
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  animation: vis-fade 0.25s ease backwards;
}

.vis.has-title {
  --ch: 0.34vh; /* leave room for the caption */
}

@supports (width: 1cqw) {
  .vis {
    --cw: 1cqw;
    --ch: 1cqh;
  }

  .vis.has-title {
    --ch: 0.84cqh;
  }
}

.vis__title {
  flex: none;
  max-width: 100%;
  padding: 0.25em 0.9em;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--indigo-800);
  font-size: clamp(0.9rem, calc(var(--ch) * 7), 1.5rem);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
  animation: vis-rise 0.4s ease backwards;
  animation-delay: calc(var(--wait) + 0.2s);
}

.vis-emoji {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-weight: 400;
}

/* fraction: a pizza and the fraction beside it (under it on an upright screen) */

.vis-fraction {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--cw) * 6);
}

.vis-pizza {
  flex: none;
  width: min(calc(var(--ch) * 86), calc(var(--cw) * 46));
  aspect-ratio: 1;
  overflow: visible;
}

.vis-pizza__plate {
  fill: #fff;
  stroke: rgba(28, 33, 64, 0.1);
  stroke-width: 1.5;
}

.vis-slice {
  transform-origin: 100px 100px;
  animation: vis-pop 0.5s cubic-bezier(0.2, 1.3, 0.4, 1) backwards;
  animation-delay: calc(var(--wait) + var(--i) * 80ms);
}

.vis-slice.is-off {
  opacity: 0.22;
}

.vis-slice__crust {
  fill: #e2a657;
}

.vis-slice__sauce {
  fill: #e4572e;
}

.vis-slice__cheese {
  fill: #ffd257;
}

.vis-slice__topping {
  fill: #c83a26;
  stroke: #a52c1b;
  stroke-width: 1.5;
}

.vis-pizza__cut {
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
}

.vis-frac {
  display: grid;
  justify-items: center;
  font-size: min(calc(var(--ch) * 30), calc(var(--cw) * 15));
  line-height: 0.95;
  animation: vis-rise 0.4s ease backwards;
  animation-delay: calc(var(--wait) + 0.3s);
}

.vis-frac__num {
  color: var(--coral-600);
}

.vis-frac__bar {
  width: 100%;
  min-width: 1.1em;
  height: 0.09em;
  margin: 0.07em 0 0.09em;
  border-radius: 999px;
  background: var(--ink-900);
}

/* count: the things in rows of five, and the number counting up */

.vis-count {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--cw) * 6);
}

.vis-count__grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), auto);
  gap: 0.06em 0.14em;
  font-size: min(calc(var(--ch) * 64 / var(--rows)), calc(var(--cw) * 50 / var(--cols)), 9rem);
  line-height: 1.15;
}

.vis-count__item {
  animation: vis-pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
  animation-delay: calc(var(--wait) + var(--i) * var(--step));
}

.vis-count__num {
  min-width: calc(var(--digits) * 0.62em);
  color: var(--indigo-500);
  font-size: min(calc(var(--ch) * 46), calc(var(--cw) * 22));
  font-variant-numeric: tabular-nums;
  animation: vis-pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
  animation-delay: var(--wait);
  transition: color 0.2s ease, transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.vis-count__num.is-counting {
  color: var(--ink-500);
  transform: scale(0.84);
}

/* math: one sum, equation or row of numbers, as large as fits */

.vis-math {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(calc(var(--ch) * 46), calc(var(--cw) * 88 / var(--ems)), 12rem);
  font-variant-numeric: lining-nums;
  white-space: nowrap;
}

.vis-math > span {
  animation: vis-rise 0.4s ease backwards;
  animation-delay: calc(var(--wait) + var(--i) * 110ms);
}

.vis-math__op,
.vis-math__eq {
  margin: 0 0.24em;
  color: var(--indigo-500);
}

.vis-math__eq {
  color: var(--coral-600);
}

.vis-math__paren {
  color: var(--ink-500);
  font-weight: 700;
}

.vis-math__var {
  margin: 0 0.02em;
  color: var(--indigo-800);
  font-style: italic;
}

.vis-math__slash {
  margin: 0 0.04em;
  color: var(--ink-500);
  font-weight: 700;
}

.vis-math__sep {
  margin-right: 0.3em;
  color: var(--ink-500);
}

.vis-math__unit {
  color: var(--indigo-500);
}

.vis-math__ask {
  display: inline-grid;
  place-items: center;
  min-width: 1.15em;
  height: 1.3em;
  margin: 0 0.05em;
  border: 0.06em dashed var(--sun-500);
  border-radius: 0.2em;
  background: var(--sun-100);
  color: var(--cocoa-800);
}

/* picture: a drawing of ours (public/pictures/), as large as the screen allows, with its title */

.vis--picture {
  padding: calc(var(--ch) * 3) calc(var(--cw) * 3);
}

.vis-picture {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--ch) * 2);
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
}

.vis-picture__image {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  object-fit: contain;
  animation: vis-fade 0.4s ease backwards;
  animation-delay: var(--wait);
}

.vis-picture__title {
  flex: none;
  max-width: 100%;
  padding: 0.25em 0.9em;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--indigo-800);
  font-size: clamp(0.9rem, calc(var(--ch) * 6), 1.4rem);
  font-weight: 800;
  line-height: 1.2;
}

/* In the lesson room the pill over the shared screen names the picture (app.js reads the title
   from here), so the drawing gets the room the title took under it (2026-10-15). */
.share .vis-picture__title {
  display: none;
}

/* A drawing with named parts: the box of the part the tutor is speaking of lights up. */
.vis-picture__point {
  fill: none;
  stroke: var(--sun-500);
  stroke-width: 9;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.vis-picture__point.is-pointed {
  opacity: 1;
  animation: vis-point 1.4s ease-in-out infinite alternate;
}

@keyframes vis-point {
  from { stroke-width: 7; }
  to { stroke-width: 12; }
}

/* passage: words for the child to read aloud (Emily Zhang's review of 2026-10-21). Large, plain,
   well spaced and set left, as reading text should be for a young or a dyslexic reader. The type
   is fitted to the box (.vis-fit, below): the line height, letter spacing and word spacing are
   repeated in visuals.js (PASSAGE), which needs them to fit it. */
/* Words, code and a list of parts can fill the screen from top to bottom: they start under the
   pill that names the screen ("Bilby is sharing a screen"), which stands over its top left corner. */
.vis--passage,
.vis--code,
.vis--parts {
  padding-top: max(calc(var(--ch) * 5), 2.6rem);
}

.vis-passage {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  align-self: stretch;
  justify-content: center;
  min-height: 0;
}

.vis-passage__text {
  --fit-cap: clamp(2.2rem, 12cqh, 3.6rem);
  width: fit-content;
  max-width: 100%;
  margin: 0;
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: 0.015em;
  word-spacing: 0.14em;
  text-align: left;
  color: var(--ink-900);
}

.vis-passage__word {
  border-radius: 0.2em;
  transition: background-color 0.2s ease;
}

.vis-passage__word.is-pointed {
  background: var(--sun-200);
  box-shadow: 0 0 0 0.12em var(--sun-200);
}

/* code: lines of code as they are typed, with a labelled box for each name given a value. The
   sheet's width in ems (--ems) and its lines come from visuals.js; it takes --share of the height
   and leaves the rest to the boxes. */
.vis-code {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  align-self: stretch;
  justify-content: center;
  gap: calc(var(--ch) * 4);
  min-height: 0;
  font-weight: 600;
}

.vis-code__sheet {
  padding: 0.6em 1em 0.6em 0.6em;
  border-radius: 0.5em;
  background: var(--night-900);
  color: var(--cloud-100);
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: max(0.75rem, min(calc(var(--ch) * 100 * var(--share) / (var(--lines) * 1.5 + 1.2)), calc(var(--cw) * 92 / var(--ems)), 2.6rem));
  line-height: 1.5;
  text-align: left;
  white-space: pre;
}

.vis-code__line {
  display: flex;
  gap: 0.9em;
  animation: vis-fade 0.3s ease backwards;
  animation-delay: calc(var(--wait) + var(--i) * 0.12s);
}

.vis-code__n {
  min-width: 1.2em;
  color: var(--night-600);
  text-align: right;
  user-select: none;
}

.vis-code__text {
  font: inherit;
}

.vis-code__keyword { color: #ff9ecb; }
.vis-code__builtin { color: #8fd3ff; }
.vis-code__name { color: #ffffff; }
.vis-code__number { color: var(--sun-400); }
.vis-code__string { color: var(--mint-400); }
.vis-code__op { color: var(--cloud-300); }

.vis-code [data-point] {
  border-radius: 0.2em;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.vis-code__sheet .is-pointed {
  background: rgba(255, 201, 64, 0.28);
  box-shadow: 0 0 0 0.12em var(--sun-400);
}

.vis-code__boxes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6em 1.2em;
  max-width: 100%;
  font-size: max(0.75rem, min(calc(var(--ch) * 8), calc(var(--cw) * 4.5), 1.6rem));
}

.vis-code__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25em;
}

.vis-code__box-name {
  padding: 0.1em 0.6em;
  border-radius: 999px;
  background: var(--indigo-500);
  color: var(--paper);
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
}

.vis-code__box-value {
  min-width: 3.2em;
  padding: 0.4em 0.8em;
  border: 0.14em solid var(--indigo-500);
  border-radius: 0.35em;
  background: var(--paper);
  color: var(--ink-900);
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  text-align: center;
}

.vis-code__box .is-pointed {
  box-shadow: 0 0 0 0.18em var(--sun-400);
}

/* parts: the parts of one thing, named in order, beside the thing itself (over it on an upright
   screen). --rows and --chars (the longest name) come from visuals.js. */
.vis-parts {
  display: flex;
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
}

.vis-parts__inner {
  --row-ems: 1.95; /* one part in ems of its type: its line, its padding and the gap */
  --list-w: 58; /* the share of the width the list may take beside the thing */
  --list-h: 92; /* the share of the height it may take */
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  gap: calc(var(--cw) * 5);
  min-height: 0;
}

.vis-parts__thing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--ch) * 2);
}

.vis-parts__emoji {
  font-size: min(calc(var(--ch) * 40), calc(var(--cw) * 22), 11rem);
  line-height: 1;
}

.vis-parts__name {
  font-size: max(1rem, min(calc(var(--ch) * 8), calc(var(--cw) * 5), 2.2rem));
  font-weight: 900;
  color: var(--indigo-800);
}

.vis-parts__list {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: max(1rem, min(calc(var(--ch) * var(--list-h) / (var(--rows) * var(--row-ems))), calc(var(--cw) * var(--list-w) / (var(--chars) * 0.62 + 1.7)), 2.4rem));
  font-weight: 800;
  line-height: 1.2;
  text-align: left;
}

.vis-parts__part {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.2em 0.7em 0.2em 0.35em;
  border-radius: 999px;
  color: var(--ink-900);
  animation: vis-fade 0.3s ease backwards;
  animation-delay: calc(var(--wait) + var(--i) * 0.1s);
  transition: background-color 0.2s ease;
}

.vis-parts__part::before {
  content: "";
  flex: none;
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--coral-600);
}

.vis-parts__part.is-pointed {
  background: var(--sun-200);
}

@supports (width: 1cqw) {
  .vis-passage,
  .vis-parts {
    container-type: size;
  }

  /* A very short screen (a phone on its side with its bars showing) keeps the code and leaves the
     boxes out: the code is what the tutor is speaking of. */
  .vis-code {
    container-type: size;
  }

  @container (max-height: 15rem) {
    .vis-code__boxes {
      display: none;
    }

    .vis-code__sheet {
      --share: 0.9 !important;
    }
  }

  .vis-parts__inner {
    --cw: 1cqw;
    --ch: 1cqh;
  }

  /* An upright screen: the thing over its parts, the list as wide as the screen. */
  @container (max-aspect-ratio: 1 / 1) {
    .vis-parts__inner {
      --list-w: 90;
      --list-h: 62;
      flex-direction: column;
      gap: calc(var(--ch) * 3);
    }

    .vis-parts__emoji {
      font-size: min(calc(var(--ch) * 18), calc(var(--cw) * 30), 7rem);
    }
  }
}

/* teaching with the screen (Emily Zhang's "Visuals across all subjects", 2026-10-22): steps in
   order, a timeline, a bar chart, two things side by side, what two things share, a new word,
   rows of dots, fraction bars and base-ten blocks. Each is sized to its screen from what is on it
   (visuals.js sets --n things, --chars the longest, and for steps --cols and --rows). */
.vis--process,
.vis--timeline,
.vis--chart,
.vis--tchart,
.vis--venn,
.vis--term,
.vis--array,
.vis--fractionbars,
.vis--base10,
.vis--conceptmap,
.vis--storymap {
  padding-top: max(calc(var(--ch) * 5), 2.6rem);
}

.vis-teach {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  gap: calc(var(--ch) * 3);
  width: 100%;
  min-height: 0;
  margin: 0;
  font-weight: 800;
  color: var(--ink-900);
}

.vis-teach__name {
  margin: 0;
  color: var(--indigo-800);
  font-size: max(1rem, min(calc(var(--ch) * 8), calc(var(--cw) * 4.5), 2rem));
  font-weight: 900;
}

.vis-teach [data-point] {
  border-radius: 0.3em;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.vis-teach .is-pointed {
  background: var(--sun-200);
  box-shadow: 0 0 0 0.14em var(--sun-400);
}

/* process: numbered steps with an arrow to the next one */
.vis-process__steps {
  display: grid;
  grid-template-columns: repeat(var(--cols), auto);
  gap: 1.1em 1.6em;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: max(0.75rem, min(calc(var(--cw) * 90 / (var(--cols) * (var(--chars) * 0.6 + 2.2) + (var(--cols) - 1) * 1.6)), calc(var(--ch) * 62 / (var(--rows) * (var(--lines) * 1.25 + 1.3) + (var(--rows) - 1) * 1.1)), 2.6rem));
}

.vis-process__label {
  max-width: calc(var(--chars) * 0.6em);
  line-height: 1.25;
}

.vis-process__step {
  position: relative;
  grid-row: var(--r);
  grid-column: var(--c);
  display: flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.35em 0.7em 0.35em 0.4em;
  border: 0.1em solid var(--indigo-500);
  border-radius: 0.6em;
  background: var(--paper);
  animation: vis-fade 0.3s ease backwards;
  animation-delay: calc(var(--wait) + var(--i) * 0.12s);
}

.vis-process__n {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.4em;
  height: 1.4em;
  border-radius: 50%;
  background: var(--indigo-500);
  color: var(--paper);
  font-size: 0.8em;
}

.vis-process__step::after {
  position: absolute;
  color: var(--coral-600);
  font-weight: 900;
}

.vis-process__step.to-right::after { content: "→"; left: 100%; top: 50%; transform: translate(0.35em, -50%); }
.vis-process__step.to-left::after { content: "←"; right: 100%; top: 50%; transform: translate(-0.35em, -50%); }
.vis-process__step.to-down::after { content: "↓"; top: 100%; left: 50%; transform: translate(-50%, 0.05em); }
.vis-process__step.to-up::after { content: "↑"; bottom: 100%; left: 50%; transform: translate(-50%, -0.05em); }

.vis-process__return.is-upright-only {
  display: none;
}

.vis-process__return {
  margin: 0;
  padding: 0.1em 1em;
  border: 0.12em solid var(--coral-600);
  border-top: none;
  border-radius: 0 0 1em 1em;
  color: var(--coral-600);
  font-size: max(0.9rem, min(calc(var(--ch) * 6), 1.3rem));
}

/* timeline: events along a line, when above, what under */
.vis-timeline__events {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 0.6em;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: max(1rem, min(calc(var(--cw) * 94 / (var(--n) * var(--chars) * 0.36 + var(--n))), calc(var(--ch) * 9), 1.9rem));
}

.vis-timeline__events::before {
  position: absolute;
  top: 2.15em;
  right: 0;
  left: 0;
  height: 0.16em;
  border-radius: 1em;
  background: var(--indigo-500);
  content: "";
}

.vis-timeline__event {
  position: relative;
  display: grid;
  grid-template-rows: 1.6em 1.2em auto;
  justify-items: center;
  gap: 0.15em;
  padding: 0.1em;
  text-align: center;
  animation: vis-fade 0.3s ease backwards;
  animation-delay: calc(var(--wait) + var(--i) * 0.12s);
}

.vis-timeline__when {
  color: var(--indigo-800);
  font-weight: 900;
}

.vis-timeline__dot {
  width: 0.9em;
  height: 0.9em;
  border: 0.18em solid var(--paper);
  border-radius: 50%;
  background: var(--coral-600);
  box-shadow: 0 0 0 0.1em var(--coral-600);
}

.vis-timeline__what {
  font-weight: 700;
  line-height: 1.2;
}

/* chart: bars from the same base line, each with its amount over it and its label under it */
.vis-chart__plot {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1em;
  height: calc(var(--ch) * 62);
  font-size: max(0.9rem, min(calc(var(--cw) * 90 / (var(--n) * (var(--chars) * 0.6 + 1))), calc(var(--ch) * 7), 1.6rem));
}

.vis-chart__bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2em;
  height: 100%;
  padding: 0 0.2em;
}

.vis-chart__fill {
  width: 2.4em;
  height: calc((100% - 3.2em) * var(--h));
  min-height: 0.15em;
  border-radius: 0.3em 0.3em 0 0;
  background: var(--sky-400);
  animation: vis-rise 0.5s ease backwards;
  animation-delay: calc(var(--wait) + var(--i) * 0.1s);
}

.vis-chart__value {
  color: var(--indigo-800);
  font-weight: 900;
}

.vis-chart__label {
  padding-top: 0.2em;
  border-top: 0.12em solid var(--ink-700);
  font-weight: 700;
  white-space: nowrap;
}

.vis-chart__unit {
  margin: 0;
  color: var(--ink-500);
  font-size: max(0.9rem, min(calc(var(--ch) * 6), 1.2rem));
}

/* tchart: two columns with a line between them */
.vis-tchart {
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  font-size: max(1rem, min(calc(var(--cw) * 44 / (var(--chars) * 0.6 + 1.4)), calc(var(--ch) * 70 / (var(--n) * 1.7 + 2.2)), 2rem));
}

.vis-tchart__side {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0 0.8em;
}

.vis-tchart__side + .vis-tchart__side {
  border-left: 0.12em solid var(--line-400);
}

.vis-tchart__heading {
  margin: 0;
  padding: 0.15em 0.6em;
  border-bottom: 0.14em solid var(--indigo-500);
  color: var(--indigo-800);
  font-size: 1.15em;
  font-weight: 900;
}

.vis-tchart__items {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  margin: 0;
  padding: 0;
  list-style: none;
  font-weight: 700;
  text-align: center;
}

/* venn: two circles that overlap, each name over its circle */
.vis-venn {
  font-size: max(0.9rem, min(calc(var(--cw) * 30 / (var(--chars) * 0.6 + 1)), calc(var(--ch) * 46 / (var(--n) * 1.6 + 1)), 1.6rem));
}

.vis-venn__heads {
  display: flex;
  justify-content: space-around;
  width: min(100%, calc(var(--ch) * 150));
}

.vis-venn__head {
  margin: 0;
  color: var(--indigo-800);
  font-size: 1.15em;
  font-weight: 900;
}

.vis-venn__field {
  position: relative;
  width: min(100%, calc(var(--ch) * 150));
  aspect-ratio: 1.75 / 1;
  max-height: calc(var(--ch) * 78);
}

.vis-venn__circle {
  position: absolute;
  top: 0;
  width: 62%;
  height: 100%;
  border: 0.14em solid;
  border-radius: 50%;
}

.vis-venn__circle--left {
  left: 0;
  border-color: var(--indigo-500);
  background: rgba(79, 70, 229, 0.1);
}

.vis-venn__circle--right {
  right: 0;
  border-color: var(--coral-600);
  background: rgba(228, 87, 46, 0.1);
}

.vis-venn__zone {
  position: absolute;
  top: 50%;
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  margin: 0;
  padding: 0;
  list-style: none;
  font-weight: 700;
  text-align: center;
  transform: translateY(-50%);
}

.vis-venn__zone--left { left: 3%; width: 32%; }
.vis-venn__zone--both { left: 38%; width: 24%; }
.vis-venn__zone--right { right: 3%; width: 32%; }

/* conceptmap (2026-10-28): the big idea in the middle cell of a three by three grid, the ideas in
   the cells around it, a line from the middle to each */
.vis-conceptmap__map {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 0.8em 1.2em;
  /* Three cells across, each the widest line (--chars) and its padding, and two gaps; three rows of
     up to two lines. The type is the largest that fits both on the board. */
  width: min(100%, calc((var(--chars) * 1.8 + 9.6) * 1em));
  height: min(100%, 11.2em);
  font-size: max(0.85rem, min(calc(var(--cw) * 96 / (var(--chars) * 1.8 + 9.6)), calc(var(--ch) * 80 / 11.2), 1.8rem));
}

.vis-conceptmap__lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.vis-conceptmap__line {
  stroke: var(--indigo-500);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.vis-conceptmap__center,
.vis-conceptmap__idea {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.35em 0.6em;
  border-radius: 1em;
  text-align: center;
  line-height: 1.15;
  overflow-wrap: break-word;
}

.vis-conceptmap__center {
  grid-row: 2;
  grid-column: 2;
  border: 0.14em solid var(--indigo-500);
  background: var(--cloud-100);
  color: var(--indigo-800);
  font-size: 1.15em;
  font-weight: 900;
}

.vis-conceptmap__idea {
  grid-row: var(--r);
  grid-column: var(--c);
  align-self: center;
  border: 0.12em solid var(--line-400);
  background: var(--paper);
  font-weight: 700;
  animation: vis-rise 0.4s ease backwards;
  animation-delay: calc(var(--i, 0) * 90ms);
}

/* storymap (2026-10-28): who and where side by side, what happens under them in rows of cards.
   Its type is sized from the lines its cards take (--lh) and the widest line (--chars) on the
   inner block, whose nearest container is the board of the picture (.vis-teach). */
.vis-storymap__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  width: 100%;
  max-height: 100%;
  font-size: max(0.75rem, min(calc(var(--cw) * 92 / (var(--across) * (var(--chars) * 0.6 + 1.8) + (var(--across) - 1) * 1.4)), calc(var(--ch) * 92 / var(--lh)), 1.6rem));
}

.vis-storymap__inner .vis-teach__name {
  font-size: 1.15em;
  line-height: 1.2;
}

.vis-storymap__who,
.vis-storymap__events {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 1.4em;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.vis-storymap__who > *,
.vis-storymap__event {
  flex: 1 1 0;
  min-width: 0;
  max-width: calc((var(--chars) * 0.6 + 1.8) * 1em);
}

.vis-storymap__who > .vis-storymap__card--characters {
  max-width: calc((var(--chars) * 0.6 + 1.8) * 1.6em);
}

.vis-storymap__event {
  position: relative;
  display: flex;
}

.vis-storymap__event.has-next::after {
  content: "→";
  position: absolute;
  top: 50%;
  left: 100%;
  width: 1.4em;
  color: var(--indigo-500);
  font-weight: 900;
  text-align: center;
  transform: translateY(-50%);
}

.vis-storymap__card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1em;
  padding: 0.4em 0.6em;
  border: 0.12em solid var(--line-400);
  border-radius: 0.8em;
  background: var(--paper);
  text-align: center;
}

.vis-storymap__card--characters,
.vis-storymap__card--setting {
  border-color: var(--indigo-500);
}

.vis-storymap__head {
  margin: 0;
  color: var(--indigo-800);
  font-size: max(0.75rem, 0.8em);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
}

.vis-storymap__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 0.8em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.vis-storymap__text {
  margin: 0;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: break-word;
}

/* term: a new word, its picture and its meaning */
.vis-term__emoji {
  font-size: min(calc(var(--ch) * 26), calc(var(--cw) * 18), 7rem);
  line-height: 1;
}

.vis-term__word {
  margin: 0;
  color: var(--indigo-800);
  font-size: max(1.4rem, min(calc(var(--ch) * 20), calc(var(--cw) * 80 / (var(--chars) * 0.62)), 5rem));
  font-weight: 900;
  line-height: 1.1;
}

.vis-term__meaning {
  max-width: 36em;
  margin: 0;
  font-size: max(1rem, min(calc(var(--ch) * 8), calc(var(--cw) * 4), 1.8rem));
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

/* array: rows of dots */
.vis-array {
  max-width: calc(var(--cw) * 86);
  max-height: calc(var(--ch) * 66);
}

.vis-array__dot {
  fill: var(--coral-600);
}

.vis-array__caption {
  color: var(--indigo-800);
  font-size: max(1rem, min(calc(var(--ch) * 8), calc(var(--cw) * 5), 1.8rem));
}

/* fractionbars: bars of one length cut into parts, the parts taken coloured */
.vis-fbars {
  gap: 0.6em;
  font-size: max(1rem, min(calc(var(--ch) * 64 / (var(--n) * 2.6)), calc(var(--cw) * 4), 2rem));
}

.vis-fbars__row {
  display: flex;
  align-items: center;
  gap: 0.8em;
  width: min(100%, 30em);
}

.vis-fbars__name {
  display: grid;
  flex: none;
  justify-items: center;
  min-width: 1.6em;
  font-weight: 900;
  line-height: 1.05;
}

.vis-fbars__top {
  padding: 0 0.15em;
  border-bottom: 0.1em solid currentColor;
}

.vis-fbars__bar {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(var(--d), 1fr);
  height: 1.8em;
  border: 0.1em solid var(--indigo-500);
  border-radius: 0.3em;
  overflow: hidden;
}

.vis-fbars__part + .vis-fbars__part {
  border-left: 0.08em solid var(--indigo-500);
}

.vis-fbars__part.is-taken {
  background: var(--sun-400);
}

/* base10: hundreds, tens and ones, each group counted under it */
.vis-base10 {
  flex-direction: row;
  align-items: flex-end;
  gap: calc(var(--cw) * 4);
}

.vis-base10__group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--ch) * 2);
}

.vis-base10 {
  --block: min(calc(var(--ch) * 62 / (var(--flat-rows) * 10.6 + 3)), calc(var(--cw) * 84 / (var(--flat-cols) * 10.4 + 16)), calc(var(--ch) * 2.4));
}

.vis-base10__blocks {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 0.3em;
  font-size: var(--block);
}

.vis-base10__group--hundreds .vis-base10__blocks { max-width: calc(var(--flat-cols) * 10.3em); }
.vis-base10__group--tens .vis-base10__blocks { max-width: 12em; }
.vis-base10__group--ones .vis-base10__blocks { max-width: 4em; }

.vis-base10__flat { width: 10em; height: 10em; }
.vis-base10__rod { width: 1em; height: 10em; }
.vis-base10__cube { width: 1em; height: 1em; }

.vis-base10__face {
  fill: var(--mint-400);
  stroke: #1f8f69;
  stroke-width: 1.2;
}

.vis-base10__rod .vis-base10__face,
.vis-base10__cube .vis-base10__face {
  stroke-width: 0.6;
}

.vis-base10__grid {
  fill: none;
  stroke: #1f8f69;
  stroke-width: 0.6;
}

.vis-base10__count {
  margin: 0;
  color: var(--indigo-800);
  font-size: max(1rem, min(calc(var(--ch) * 7), calc(var(--cw) * 3.5), 1.6rem));
  font-weight: 900;
}

@supports (width: 1cqw) {
  .vis-teach {
    container-type: size;
  }

  /* An upright screen: steps stand in one column with arrows down, and a timeline goes down the
     screen. */
  @container (max-aspect-ratio: 1 / 1) {
    .vis-process__steps {
      grid-template-columns: auto;
      font-size: max(0.75rem, min(calc(100cqw * 0.88 / (var(--chars) * 0.6 + 3)), calc(100cqh * 0.72 / (var(--n) * (var(--lines) * 1.25 + 1.1) + (var(--n) - 1) * 0.9)), 2rem));
      gap: 0.9em;
    }

    .vis-process__step {
      grid-row: calc(var(--i) + 1);
      grid-column: 1;
    }

    .vis-process .vis-process__step::after {
      content: "↓";
      top: 100%;
      bottom: auto;
      right: auto;
      left: 50%;
      transform: translate(-50%, 0);
    }

    .vis-process .vis-process__step:last-child::after {
      content: none;
    }

    .vis-process__return.is-upright-only {
      display: block;
    }

    .vis-timeline__events {
      grid-template-columns: 1fr;
      font-size: max(1rem, min(calc(100cqh * 0.8 / (var(--n) * 2.4)), calc(100cqw * 0.9 / (var(--chars) * 0.6 + 4)), 1.6rem));
    }

    .vis-timeline__events::before {
      top: 0;
      bottom: 0;
      left: 4.85em;
      width: 0.16em;
      height: auto;
    }

    .vis-timeline__event {
      grid-template-columns: 4em 1.2em 1fr;
      grid-template-rows: auto;
      align-items: center;
      justify-items: start;
      text-align: left;
    }

    /* A concept map: the big idea on top, the ideas in two columns under it, each on a branch. */
    .vis-conceptmap__map {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      grid-template-rows: none;
      grid-auto-rows: auto;
      align-content: center;
      gap: 0.6em 0.8em;
      width: 100%;
      height: auto;
      max-height: 100%;
      font-size: max(0.85rem, min(calc(100cqw * 0.46 / (var(--chars) * 0.6 + 1.5)), calc(100cqh * 0.8 / (2.6 + (var(--n) + 1) / 2 * 2.6)), 1.6rem));
    }

    .vis-conceptmap__lines {
      display: none;
    }

    .vis-conceptmap__center {
      grid-row: 1;
      grid-column: 1 / -1;
      justify-self: center;
      margin-bottom: 0.3em;
    }

    .vis-conceptmap__idea {
      grid-row: auto;
      grid-column: auto;
      border-left: 0.3em solid var(--indigo-500);
    }

    /* A story map: who and where side by side still, what happens down the screen with an arrow
       down to what follows. */
    .vis-storymap__inner {
      font-size: max(0.75rem, min(calc(100cqw * 0.94 / (var(--echars) * 0.6 + 1.6)), calc(100cqw * 0.94 / (2 * (var(--wchars) * 0.6 + 1.6) + 0.6)), calc(100cqh * 0.94 / var(--uh)), 1.5rem));
    }

    .vis-storymap__who {
      gap: 0.6em;
    }

    .vis-storymap__events {
      flex-direction: column;
      align-items: center;
      gap: 1.1em;
    }

    .vis-storymap__event {
      width: 100%;
      max-width: none;
    }

    .vis-storymap__who > *,
    .vis-storymap__who > .vis-storymap__card--characters {
      max-width: none;
    }

    .vis-storymap__event.has-next::after {
      content: "↓";
      top: 100%;
      left: 50%;
      width: auto;
      transform: translate(-50%, 0);
    }
  }
}

/* place: one number, digit by digit, with the digit the tutor is speaking of in a box */

.vis-place {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(calc(var(--ch) * 46), calc(var(--cw) * 84 / var(--ems)), 12rem);
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}

.vis-place > span {
  animation: vis-rise 0.4s ease backwards;
  animation-delay: calc(var(--wait) + var(--i, 0) * 90ms);
}

.vis-place__digit {
  display: inline-grid;
  place-items: center;
  min-width: 0.66em;
  height: 1.3em;
}

.vis-place__digit.is-marked {
  min-width: 1.05em;
  margin: 0 0.1em;
  border: 0.06em solid var(--sun-500);
  border-radius: 0.2em;
  background: var(--sun-100);
  color: var(--cocoa-800);
}

.vis-place__sep {
  width: 0.36em;
  color: var(--ink-500);
  text-align: left;
}

/* word: the word very large, its picture above */

.vis-word {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--ch) * 2);
  max-width: 100%;
}

.vis-word__pic {
  font-size: min(calc(var(--ch) * 36), calc(var(--cw) * 34));
  line-height: 1.15;
  animation: vis-pop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
  animation-delay: var(--wait);
}

.vis-word__text {
  max-width: calc(var(--ems) * 1em + 0.5em);
  font-size: min(calc(var(--ch) * 30 / var(--lines)), calc(var(--cw) * 86 / var(--ems)), 10rem);
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.vis-word--plain .vis-word__text {
  font-size: min(calc(var(--ch) * 54 / var(--lines)), calc(var(--cw) * 86 / var(--ems)), 12rem);
}

.vis-word__chunk {
  display: inline-block;
  white-space: nowrap;
}

.vis-word__letter {
  display: inline-block;
  animation: vis-rise 0.35s ease backwards;
  animation-delay: calc(var(--wait) + 0.15s + var(--i) * 55ms);
}

/* scene, sequence: big pictures with a small label under each */

.vis-scene,
.vis-seq {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.vis-item {
  display: grid;
  justify-items: center;
  min-width: 0;
}

.vis-item__pic {
  line-height: 1.2;
}

.vis-item__label,
.vis-compare__label {
  margin-top: 0.4em;
  color: var(--ink-700);
  font-size: clamp(0.85rem, calc(var(--ch) * 6.5), 1.6rem);
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.vis-scene {
  gap: calc(var(--cw) * 6);
  font-size: min(calc(var(--ch) * 52), calc(var(--cw) * 62 / var(--count)));
}

.vis-scene .vis-item__label {
  max-width: 9em;
}

/* Each thing pops in with its label, then floats gently over its shadow. */
.vis-scene .vis-item {
  animation: vis-pop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
  animation-delay: calc(var(--wait) + var(--i) * 140ms);
}

.vis-scene .vis-item__pic {
  animation: vis-bob 3.2s ease-in-out infinite;
  animation-delay: calc(var(--wait) + 0.6s + var(--i) * 0.45s);
}

.vis-item__shadow {
  width: 0.6em;
  height: 0.07em;
  border-radius: 50%;
  background: rgba(28, 33, 64, 0.14);
  animation: vis-shadow 3.2s ease-in-out infinite;
  animation-delay: calc(var(--wait) + 0.6s + var(--i) * 0.45s);
}

.vis-seq {
  --pic: min(calc(var(--ch) * 44), calc(var(--cw) * 52 / var(--count)));
  gap: 0.1em;
  font-size: var(--pic);
}

.vis-seq .vis-item {
  flex: 0 1 1.25em;
  animation: vis-pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) backwards;
  animation-delay: calc(var(--wait) + var(--i) * 0.5s);
}

/* A label may reach half-way under the arrows on each side before it has to wrap. */
.vis-seq .vis-item__label {
  width: max-content;
  max-width: calc(var(--pic) * 1.85);
  font-size: clamp(0.72rem, min(calc(var(--ch) * 6), calc(var(--pic) * 0.3)), 1.45rem);
  overflow-wrap: break-word;
}

.vis-seq__arrow {
  flex: none;
  width: 0.42em;
  margin-top: 0.46em;
  fill: none;
  stroke: var(--indigo-500);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: vis-slide 0.35s ease backwards;
  animation-delay: calc(var(--wait) + var(--i) * 0.5s - 0.2s);
}

/* compare: a big one and a small one standing on the same line */

.vis-compare {
  display: grid;
  grid-template-columns: auto auto;
  align-items: end;
  justify-content: center;
  justify-items: center;
  column-gap: calc(var(--cw) * 7);
  font-size: min(calc(var(--ch) * 54), calc(var(--cw) * 38));
}

.vis-compare__pic {
  line-height: 1.12;
  transform-origin: 50% 100%;
  animation: vis-pop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
  animation-delay: var(--wait);
}

.vis-compare__pic--small {
  font-size: 0.42em;
  animation-delay: calc(var(--wait) + 0.45s);
}

.vis-compare__ground {
  grid-column: 1 / -1;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(28, 33, 64, 0.14);
}

.vis-compare__label {
  align-self: start;
  max-width: 9em;
  animation: vis-fade 0.4s ease backwards;
  animation-delay: calc(var(--wait) + 0.2s);
}

.vis-compare__label--small {
  animation-delay: calc(var(--wait) + 0.65s);
}

.vis-compare__label:empty {
  display: none;
}

/* shape: the outline is drawn, then the corners are counted */

.vis-shape-wrap {
  display: flex;
}

.vis-shape {
  width: min(calc(var(--ch) * 88), calc(var(--cw) * 60));
  aspect-ratio: 1;
  overflow: visible;
}

.vis-shape__fill {
  fill: #e3e6ff;
  animation: vis-fade 0.5s ease backwards;
  animation-delay: calc(var(--wait) + 0.5s);
}

.vis-shape__line {
  fill: none;
  stroke: var(--indigo-500);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1; /* the path's length is declared as 1, so this is one whole lap */
  animation: vis-draw 0.9s ease-in-out backwards;
  animation-delay: var(--wait);
}

.vis-shape__corner {
  transform-box: fill-box;
  transform-origin: center;
  animation: vis-pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
  animation-delay: calc(var(--wait) + 0.7s + var(--i) * 130ms);
}

.vis-shape__dot {
  fill: var(--coral-600);
  stroke: #fff;
  stroke-width: 3;
}

.vis-shape__count {
  fill: #fff;
  font-size: 12px;
  font-weight: 900;
  dominant-baseline: central;
  text-anchor: middle;
}

/* angles: two lines cross, then the corners across from each other light up */

.vis-angles-wrap,
.vis-tri-wrap {
  display: flex;
}

.vis-angles {
  width: min(calc(var(--ch) * 92), calc(var(--cw) * 62));
  aspect-ratio: 1;
  overflow: visible;
}

.vis-angles__line {
  stroke: var(--indigo-500);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 1;
  animation: vis-draw 0.6s ease-in-out backwards;
  animation-delay: calc(var(--wait) + var(--i) * 0.35s);
}

.vis-angles__wedge {
  fill: var(--sun-400);
  animation: vis-fade 0.4s ease backwards;
  animation-delay: calc(var(--wait) + 0.9s);
}

.vis-angles__wedge--other {
  fill: #dfe3ff;
}

.vis-angles__dot {
  fill: var(--coral-600);
  stroke: #fff;
  stroke-width: 2;
}

.vis-angles__label {
  transform-box: fill-box;
  transform-origin: center;
  animation: vis-pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
  animation-delay: calc(var(--wait) + 1.1s + var(--i) * 250ms);
}

.vis-angles__text,
.vis-tri__text {
  fill: var(--ink-900);
  font-size: 17px;
  font-weight: 900;
  dominant-baseline: central;
  text-anchor: middle;
}

.vis-angles__box {
  fill: var(--sun-100);
  stroke: var(--sun-500);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

/* triangle: the longest side first, then the two others rise from its ends */

.vis-tri {
  width: min(calc(var(--ch) * 118), calc(var(--cw) * 78));
  aspect-ratio: 4 / 3;
  overflow: visible;
}

.vis-tri__fill {
  fill: #e3e6ff;
  animation: vis-fade 0.5s ease backwards;
  animation-delay: calc(var(--wait) + 1.1s);
}

.vis-tri__side {
  stroke: var(--coral-600);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 1;
  animation: vis-draw 0.5s ease-in-out backwards;
  animation-delay: calc(var(--wait) + var(--i) * 0.35s);
}

.vis-tri__side--base {
  stroke: var(--indigo-500);
}

.vis-tri__gap {
  stroke: var(--ink-500);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 2 6;
  animation: vis-fade 0.4s ease backwards;
  animation-delay: calc(var(--wait) + 1.2s);
}

.vis-tri__end {
  fill: #fff;
  stroke: var(--coral-600);
  stroke-width: 3;
  animation: vis-fade 0.4s ease backwards;
  animation-delay: calc(var(--wait) + 1.2s);
}

.vis-tri__label {
  transform-box: fill-box;
  transform-origin: center;
  animation: vis-pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
  animation-delay: calc(var(--wait) + 0.6s + var(--i) * 200ms);
}

.vis-tri__text {
  font-size: 13px;
}

/* An upright screen (a phone held upright): stack what sat side by side. */
@container share (orientation: portrait) {
  .vis-fraction,
  .vis-count {
    flex-direction: column;
    gap: calc(var(--ch) * 3);
  }

  .vis-pizza {
    width: min(calc(var(--ch) * 54), calc(var(--cw) * 74));
  }

  .vis-frac {
    font-size: min(calc(var(--ch) * 14), calc(var(--cw) * 18));
  }

  .vis-count__grid {
    font-size: min(calc(var(--ch) * 50 / var(--rows)), calc(var(--cw) * 72 / var(--cols)), 9rem);
  }

  .vis-count__num {
    font-size: min(calc(var(--ch) * 22), calc(var(--cw) * 30));
  }

  .vis-shape,
  .vis-angles {
    width: min(calc(var(--ch) * 78), calc(var(--cw) * 84));
  }

  .vis-tri {
    width: min(calc(var(--ch) * 100), calc(var(--cw) * 92));
  }
}

/* ---------- the board's own kinds: problem, steps, numberline, grid, pattern ---------- */

/* What a tutor writes on a board. No emoji, and the colours of the equation above: navy
   numbers, indigo signs, an orange equals sign, a dashed gold box for what is asked.

   Two things are worked out here and not in visuals.js, because they depend on the room there
   is, which only the stylesheet knows. Type that wraps is fitted to its box (.vis-fit). And a
   part is switched on or off, or moved, by a length that is 1px when something holds and 0px
   when it does not: clamp(0px, (a - b) * 9999, 1px) is 1px exactly when a is larger than b. */

/* Type fitted to its box (problem, steps). An equation is one line and is fitted by its width
   alone (--ems). Words wrap, so visuals.js works out, for eight column widths in ems (--m0 to
   --m7), how tall the text stands in ems (--h0 to --h7). Each pair allows one type size: the
   box's width over the column or its height over the text, whichever is smaller. The largest of
   the eight is the best this shape of screen can do. A column narrower than --fit-comfort ems
   (about eighteen letters) is only taken where the type would otherwise go under 1rem.
   The box is the nearest sized ancestor (cqw and cqh are 1% of it), so a fitted block is always
   the child of one.

   --w0 to --w7 are the type sizes at which a column is exactly as wide as the box. The system
   font of Apple devices sets small type wider than large type (measured: about 6% wider at
   16px than at 32px, 10% at 12px), so a size under 1.625rem gives up 7% of what it lacks to
   1.625rem.

   The first pair is the text with every paragraph on one line (--whole is its type size). A
   block may ask for that whenever it is large enough (--fit-whole): the steps of a solution
   read best one to a line. Then the other seven are put out of reach (9999px less). */
.vis-fit {
  --fit-cap: 3rem;
  --fit-whole: 9999px; /* never, unless a block says otherwise */
  font-size: clamp(1rem, 3.6vw, 1.75rem); /* browsers without container units: a plain, readable size */
}

@supports (width: 1cqw) {
  .vis-fit {
    --w0: calc(100cqw / var(--m0));
    --w1: calc(100cqw / var(--m1));
    --w2: calc(100cqw / var(--m2));
    --w3: calc(100cqw / var(--m3));
    --w4: calc(100cqw / var(--m4));
    --w5: calc(100cqw / var(--m5));
    --w6: calc(100cqw / var(--m6));
    --w7: calc(100cqw / var(--m7));
    --whole: min(calc(var(--w0) - max(0px, 1.625rem - var(--w0)) * 0.07), calc(97cqh / var(--h0)));
    font-size: min(
      var(--fit-cap),
      max(1rem, calc(100cqw / var(--fit-comfort))),
      max(
        var(--whole),
        calc(
          max(
              min(calc(var(--w1) - max(0px, 1.625rem - var(--w1)) * 0.07), calc(97cqh / var(--h1))),
              min(calc(var(--w2) - max(0px, 1.625rem - var(--w2)) * 0.07), calc(97cqh / var(--h2))),
              min(calc(var(--w3) - max(0px, 1.625rem - var(--w3)) * 0.07), calc(97cqh / var(--h3))),
              min(calc(var(--w4) - max(0px, 1.625rem - var(--w4)) * 0.07), calc(97cqh / var(--h4))),
              min(calc(var(--w5) - max(0px, 1.625rem - var(--w5)) * 0.07), calc(97cqh / var(--h5))),
              min(calc(var(--w6) - max(0px, 1.625rem - var(--w6)) * 0.07), calc(97cqh / var(--h6))),
              min(calc(var(--w7) - max(0px, 1.625rem - var(--w7)) * 0.07), calc(97cqh / var(--h7)))
            ) - clamp(0px, calc((var(--whole) - var(--fit-whole)) * 9999), 9999px)
        )
      )
    );
  }
}

/* problem: a small label, the sentences, the question set apart, answers to choose from, and a
   figure beside the words (above them on an upright screen). The sizes in ems of the copy are
   repeated in visuals.js (CARD), which needs them to fit the type: change both together. */

.vis-problem {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-self: stretch;
  gap: calc(var(--ch) * 3);
  min-height: 0;
  text-align: left;
}

.vis-problem__title {
  flex: none;
  align-self: center;
  max-width: 100%;
  padding: 0.2em 0.85em;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--indigo-800);
  /* --ems is its width in ems: a long label takes smaller type before it takes a second line */
  font-size: clamp(1rem, min(calc(var(--ch) * 6.4), calc(var(--cw) * 92 / var(--ems))), 1.3rem);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-align: center;
  animation: vis-rise 0.4s ease backwards;
  animation-delay: var(--wait);
}

/* A very short screen (a phone in a browser, a phone lying down) has no room for the label:
   there the words of the problem get its place, and a little of the margin above and below.
   A narrow one (an upright phone) does without it too: its height changes with every caption
   under it, and a label that came and went with the captions would blink. */
@container share (max-height: 15rem) or (max-width: 30rem) {
  .vis--problem {
    padding-block: calc(var(--ch) * 3);
  }

  .vis-problem__title {
    display: none;
  }
}

.vis-problem__main {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: minmax(0, 1fr);
  gap: calc(var(--ch) * 4) calc(var(--cw) * 4);
  min-height: 0;
}

.vis-problem.has-figure .vis-problem__main {
  grid-template-columns: minmax(0, 34fr) minmax(0, 66fr);
}

.vis-problem.has-figure--flat .vis-problem__main {
  grid-template-columns: minmax(0, 46fr) minmax(0, 54fr);
}

.vis-problem__figure,
.vis-problem__text {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

/* The figure's place is a small screen of its own: the picture in it is drawn by its own kind's
   rules and sizes itself to this box, as it would to the whole screen. */
.vis-problem__figure {
  --cw: 0.2vw; /* without container units: small enough for its place */
  --ch: 0.2vh;
  text-align: center;
}

@supports (width: 1cqw) {
  .vis-problem__figure {
    --cw: 1cqw;
    --ch: 1cqh;
    container: share / size;
  }

  .vis-problem__text,
  .vis-steps {
    container-type: size;
  }
}

.vis-problem__copy {
  --fit-cap: clamp(3rem, 11cqh, 4.5rem);
  width: fit-content;
  max-width: 100%;
  font-weight: 700;
  line-height: 1.26;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.vis-problem__line,
.vis-problem__ask,
.vis-problem__choices {
  animation: vis-rise 0.4s ease backwards;
  animation-delay: calc(var(--wait) + 0.15s + var(--i) * 0.22s);
}

.vis-problem__line + .vis-problem__line {
  margin-top: 0.28em;
}

/* The question is what the child has to answer: the gold box of the equation's "?". */
.vis-problem__ask {
  width: fit-content;
  padding: 0.2em 0.55em;
  border: 0.07em dashed var(--sun-500);
  border-radius: 0.36em;
  background: var(--sun-100);
  color: var(--cocoa-800);
  font-weight: 900;
}

.vis-problem__line + .vis-problem__ask {
  margin-top: 0.45em;
}

.vis-problem__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 0.45em;
  margin-top: 0.6em;
  font-weight: 900;
  line-height: 1.2;
}

/* A chip: one answer to choose from, and nothing else. It carries no letter: the child answers
   aloud, and a letter said aloud is one more thing to mishear. No answer is ever marked as
   right. (The padding is repeated in visuals.js, CARD.chipExtra.) */
.vis-problem__choice {
  display: inline-flex;
  overflow: hidden;
  border-radius: 0.45em;
  background: #fff;
  box-shadow: inset 0 0 0 0.07em rgba(79, 70, 229, 0.35);
  font-variant-numeric: lining-nums;
  white-space: nowrap;
}

.vis-problem__answer {
  padding: 0.14em 0.65em;
}

/* steps: numbered lines that appear one after another, the last one (the result) underlined.
   Sizes in ems are repeated in visuals.js (STEP). */

.vis-steps {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  align-self: stretch;
  justify-content: center;
  min-height: 0;
  text-align: left;
}

.vis-steps__list {
  --fit-cap: clamp(3.25rem, 13cqh, 5rem);
  --fit-whole: 1.5rem; /* a step keeps to one line wherever that leaves the type this large */
  display: grid;
  gap: 0.36em;
  width: fit-content;
  max-width: 100%;
  font-weight: 800;
  line-height: 1.28;
}

.vis-step {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  animation: vis-rise 0.45s ease backwards;
  animation-delay: calc(var(--wait) + var(--i) * 0.5s);
}

/* The number of a step: as tall as one line, so a row is never taller than its words. */
.vis-step__n {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.45em;
  height: 1.45em;
  margin-top: 0.03em;
  border-radius: 50%;
  background: rgba(79, 70, 229, 0.12);
  color: var(--indigo-800);
  font-size: 0.85em;
  font-weight: 900;
  line-height: 1;
}

.vis-step__line {
  min-width: 0;
  overflow-wrap: break-word;
}

.vis-step__line--maths {
  font-variant-numeric: lining-nums;
  font-weight: 900;
}

/* A long line of maths wraps between these groups (before a sign), never inside one. */
.vis-step__group {
  display: inline-block;
  white-space: nowrap;
}

/* The signs of a sum that stands among words: the equation's colours, nothing else changed. */
.vis-step__sign {
  color: var(--indigo-500);
  font-weight: 900;
}

.vis-step__equals {
  color: var(--coral-600);
  font-weight: 900;
}

.vis-step.is-result .vis-step__line {
  border-bottom: 0.14em solid var(--sun-400);
}

.vis-step.is-result .vis-step__n {
  background: var(--sun-400);
  color: var(--cocoa-800);
}

/* numberline: ticks and numbers, marked numbers with a dot, jumps as arcs with their size.
   Places along the line are percentages (--x, --w). Heights in ems are repeated in visuals.js (NL).

   --tick is the distance from one tick to the next and --per the ems of room one number needs.
   The type is as large as lets every number be written, when that is at least 1rem; if not,
   as large as lets every second one be written, and so on. Which numbers then have room is
   switched by their max-width; numbers that are always written and stand too close move to
   rows of their own, and so does the size over every second of a run of short jumps. */

.vis-nl {
  --track: calc(var(--cw) * 84);
  --tick: calc(var(--track) / var(--n));
  --per: calc(var(--digits) * 0.64 + 0.5);
  --room: calc(var(--per) * 1em);
  --key-room: calc(var(--digits) * 0.67em + 0.22em); /* two numbers that must both be written may stand closer */
  --size-room: calc(var(--size-chars) * 0.66em + 0.3em);
  --all: calc(var(--tick) * 0.97 / var(--per)); /* the type size at which every number has room */
  --second: calc(var(--tick) * 1.94 / var(--per)); /* every second number */
  --fifth: calc(var(--tick) * 4.85 / var(--per)); /* every fifth */
  --least: 1rem; /* the smallest type */
  --tallest: calc(var(--ch) * 80 / var(--ems)); /* the type at which the line is as tall as the screen allows */
  flex: none;
  width: var(--track);
  padding-top: calc(var(--above) * 1em + clamp(0px, calc((var(--size-room) - var(--tick) * var(--narrow)) * 9999), 1.15em));
  padding-bottom: calc(
    1.95em + clamp(0px, calc((var(--key-room) - var(--tick) * var(--tight)) * 9999), 1.2em) +
      clamp(0px, calc((var(--key-room) - var(--tick) * var(--tighter)) * 9999), 1.2em)
  );
  color: var(--ink-900);
  /* Each of the last three is out of reach (9999px more) while it is under 1rem. */
  font-size: clamp(
    var(--least),
    min(
      var(--tallest),
      calc(var(--cw) * 5.2),
      calc(var(--all) + clamp(0px, calc((1rem - var(--all)) * 9999), 9999px)),
      calc(var(--second) + clamp(0px, calc((1rem - var(--second)) * 9999), 9999px)),
      calc(var(--fifth) + clamp(0px, calc((1rem - var(--fifth)) * 9999), 9999px))
    ),
    2.25rem
  );
  font-variant-numeric: lining-nums;
  line-height: 1.2;
}

/* As the figure of a problem the line has a place of its own and fills it. On a very small
   screen that place is low, and the line's type may then go a little under 1rem with the words. */
.vis-problem__figure .vis-nl {
  --least: 0.75rem;
  --tallest: calc(var(--ch) * 100 / var(--ems-least));
}

.vis-nl__line {
  position: relative;
  height: 0;
}

.vis-nl__line::before {
  content: "";
  position: absolute;
  top: -0.08em;
  right: -0.6em;
  left: -0.6em;
  height: 0.16em;
  border-radius: 999px;
  background: var(--ink-900);
  transform-origin: 0 50%;
  animation: vis-stretch 0.5s ease backwards;
  animation-delay: var(--wait);
}

.vis-nl__tick {
  position: absolute;
  top: 0;
  left: calc(var(--x) * 1%);
  width: 0.12em;
  height: 0.62em;
  border-radius: 999px;
  background: var(--ink-900);
  translate: -50% -50%;
  animation: vis-fade 0.3s ease backwards;
  animation-delay: calc(var(--wait) + 0.3s);
}

.vis-nl__tick.is-long {
  height: 0.95em;
}

.vis-nl__num {
  --fits-all: clamp(0px, calc((var(--tick) - var(--room)) * 9999), 1px); /* room for every number */
  --fits-second: clamp(0px, calc((var(--tick) * 2 - var(--room)) * 9999), 1px); /* for every second one */
  --fits-fifth: clamp(0px, calc((var(--tick) * 5 - var(--room)) * 9999), 1px); /* for every fifth */
  --clear: clamp(0px, calc((var(--tick) * var(--near) - (var(--own) + var(--digits)) * 0.32em - 0.5em) * 9999), 1px); /* far enough from a number that is always written (--own: its own digits) */
  --shown: var(--fits-all);
  position: absolute;
  top: 0.72em;
  left: calc(var(--x) * 1%);
  max-width: calc(min(var(--shown), var(--clear)) * 999);
  overflow: hidden;
  color: var(--ink-700);
  font-weight: 800;
  white-space: nowrap;
  translate: -50% 0;
  animation: vis-fade 0.3s ease backwards;
  animation-delay: calc(var(--wait) + 0.4s);
}

.vis-nl__num.is-2 {
  --shown: var(--fits-second);
}

/* Every fifth: when all fit, or when every second does not and every fifth does. */
.vis-nl__num.is-5 {
  --shown: max(var(--fits-all), min(1px - var(--fits-second), var(--fits-fifth)));
}

.vis-nl__num.is-10 {
  --shown: 1px;
}

/* Both ends, marked numbers and the ends of jumps: always written. One whose neighbour is too
   close (--close) stands in a lower row: every second of them (--row-of-2), or, where even the
   next but one is too close somewhere on the line (--closer), each in one of three rows. */
.vis-nl__num.is-key {
  --close: clamp(0px, calc((var(--key-room) - var(--tick) * var(--near)) * 9999), 1px);
  --closer: clamp(0px, calc((var(--key-room) - var(--tick) * var(--tighter)) * 9999), 1px);
  top: calc(
    0.72em +
      min(
        calc(var(--close) * 9999),
        max(
          min(calc(var(--closer) * 9999), calc(var(--row-of-3) * 1.2em)),
          min(calc((1px - var(--closer)) * 9999), calc(var(--row-of-2) * 1.2em))
        )
      )
  );
  max-width: none;
  overflow: visible;
  color: var(--ink-900);
  font-weight: 900;
}

.vis-nl__dot {
  position: absolute;
  top: 0;
  left: calc(var(--x) * 1%);
  width: 0.78em;
  height: 0.78em;
  border: 0.1em solid #fff;
  border-radius: 50%;
  background: var(--coral-600);
  translate: -50% -50%;
  animation: vis-pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
  animation-delay: calc(var(--wait) + 0.55s + var(--i) * 120ms);
}

/* A jump stands on the line between its two numbers; one over another is a level higher. */
.vis-nl__hop {
  position: absolute;
  bottom: 0.06em;
  left: calc(var(--x) * 1%);
  width: calc(var(--w) * 1%);
  height: calc(1.25em + var(--level) * 1.35em);
}

.vis-nl__arc {
  position: absolute;
  inset: 0;
  clip-path: inset(-0.6em); /* wider than the arc, so only the sweep below ever hides a part of it */
  animation: vis-sweep 0.45s ease-out backwards;
  animation-delay: calc(var(--wait) + 0.7s + var(--i) * 0.5s);
}

.vis-nl__hop.is-back .vis-nl__arc {
  animation-name: vis-sweep-back;
}

.vis-nl__bow {
  position: absolute;
  inset: 0;
  border: 0.14em solid var(--indigo-500);
  border-bottom: 0;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

/* The arrowhead: where the jump lands. */
.vis-nl__head {
  position: absolute;
  bottom: -0.02em;
  left: calc(100% - 0.07em);
  border: 0.3em solid transparent;
  border-top: 0.44em solid var(--indigo-500);
  border-bottom: 0;
  translate: -50% 0;
}

.vis-nl__hop.is-back .vis-nl__head {
  left: 0.07em;
}

.vis-nl__size {
  position: absolute;
  z-index: 1;
  bottom: calc(100% + 0.06em + clamp(0px, calc((var(--size-room) - var(--tick) * var(--ticks)) * 9999), 1.15em) * var(--odd));
  left: 50%;
  padding: 0 0.16em;
  border-radius: 0.3em;
  background: var(--screen); /* an arc that passes behind does not cross the number out */
  color: var(--indigo-500);
  font-weight: 900;
  white-space: nowrap;
  translate: -50% 0;
  animation: vis-rise 0.35s ease backwards;
  animation-delay: calc(var(--wait) + 0.95s + var(--i) * 0.5s);
}

/* grid: squares on squared paper, with a gap between them so they can be counted */

.vis-grid {
  --cell: min(calc(var(--cw) * 80 / var(--cols)), calc(var(--ch) * 78 / var(--rows)), 5rem);
  display: grid;
  flex: none;
  grid-template-columns: repeat(var(--cols), calc(var(--cell) * 0.92));
  grid-auto-rows: calc(var(--cell) * 0.92);
  gap: calc(var(--cell) * 0.08);
}

.vis-grid__cell {
  border-radius: 14%;
  animation: vis-pop 0.3s cubic-bezier(0.2, 1.4, 0.4, 1) backwards;
  animation-delay: calc(var(--wait) + var(--i) * var(--step));
}

.vis-grid__cell.is-on {
  background: var(--indigo-500);
}

.vis-grid__cell.is-off {
  border: max(2px, calc(var(--cell) * 0.045)) solid var(--cloud-300);
  background: #fff;
}

.vis-grid__cell.is-none {
  visibility: hidden;
}

/* pattern: a row of numbers and shapes; the missing one is the gold box of the equation's "?".
   --one is the size of a thing when all stand in one row, --two when the row is written as two.
   Two rows are taken only where one row would make the things smaller than 2.25rem and two
   rows make them larger: then the row may be no wider than its wider half (--ems-two). */

.vis-pattern {
  --one: min(calc(var(--ch) * 50), calc(var(--cw) * 90 / var(--ems)));
  --two: min(calc(var(--ch) * 36), calc(var(--cw) * 90 / var(--ems-two)));
  --split: clamp(0px, calc((min(var(--two), 2.25rem) - var(--one)) * 9999), 1px);
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.28em;
  max-width: calc(var(--ems-two) * 1em + 0.5em + (1px - var(--split)) * 9999);
  color: var(--ink-900);
  font-size: min(max(var(--one), calc(var(--two) - (1px - var(--split)) * 9999)), 8rem);
  line-height: 1;
}

.vis-pattern > * {
  flex: none;
  animation: vis-pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
  animation-delay: calc(var(--wait) + var(--i) * 110ms);
}

/* A shape without a colour is drawn in the board's ink. */
.vis-pattern__shape {
  display: block;
  width: 1em;
  height: 1em;
  overflow: visible;
  fill: var(--ink-900);
  stroke: var(--ink-900);
  stroke-width: 5;
  stroke-linejoin: round;
}

.vis-pattern__shape--red {
  fill: var(--red-500);
  stroke: var(--red-600);
}

.vis-pattern__shape--blue {
  fill: #3b82f6;
  stroke: #2563eb;
}

.vis-pattern__shape--green {
  fill: #2fae73;
  stroke: #1e8f5a;
}

.vis-pattern__shape--yellow {
  fill: var(--sun-400);
  stroke: #e09f00;
}

.vis-pattern__shape--purple {
  fill: #9057e8;
  stroke: #7440cc;
}

.vis-pattern__shape--orange {
  fill: #f5821f;
  stroke: #d66a0c;
}

/* A number is as wide as visuals.js reckoned (--w, in ems of the row). */
.vis-pattern__num {
  min-width: calc(var(--w) / 0.66 * 1em);
  font-size: 0.66em;
  font-variant-numeric: lining-nums;
  text-align: center;
}

.vis-pattern__ask {
  display: grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  border: 0.08em dashed var(--sun-500);
  border-radius: 0.25em;
  background: var(--sun-100);
  color: var(--cocoa-800);
  font-size: 0.64em;
}

/* Where the figure of a problem stands. Beside the words on a wide, low screen (above). A wide,
   low figure (an equation, a number line, a pattern) goes above the words on a narrow screen and
   on one that is less than twice as wide as it is tall; on an upright screen every figure does.
   A number line's place is as tall as the line is at 1rem (--figure-floor, from visuals.js) as
   long as that is under half of the room: past that the line and the words both get smaller. */
@container share (max-width: 34rem) or (max-aspect-ratio: 2 / 1) {
  .vis-problem.has-figure--flat .vis-problem__main {
    grid-template-rows: minmax(min(var(--figure-floor, 0px), 45%), 38fr) minmax(0, 62fr);
    grid-template-columns: minmax(0, 1fr);
  }
}

@container share (orientation: portrait) {
  .vis-problem.has-figure .vis-problem__main {
    grid-template-rows: minmax(0, 38fr) minmax(0, 62fr);
    grid-template-columns: minmax(0, 1fr);
  }

  .vis-problem.has-figure--flat .vis-problem__main {
    grid-template-rows: minmax(min(var(--figure-floor, 0px), 45%), 26fr) minmax(0, 74fr);
  }
}

/* ---------- celebration: stars around the tutor after a right answer ---------- */

/* A zero-size box that app.js puts at the middle of the tutor's face. */
.sparkles {
  position: absolute;
  z-index: 3;
  top: var(--y, 50%);
  left: var(--x, 50%);
  width: 0;
  height: 0;
  pointer-events: none;
}

/* One four-pointed star. visuals.js gives each its own path (--x0/--y0 to --x1/--y1), size, spin and delay. */
.sparkle {
  position: absolute;
  top: calc(var(--size) / -2);
  left: calc(var(--size) / -2);
  width: var(--size);
  height: var(--size);
  background: var(--sun-400);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: sparkle-fly 1.1s cubic-bezier(0.15, 0.7, 0.3, 1) var(--delay) both;
}

.sparkle--white {
  background: #fff;
}

.sparkle--coral {
  background: var(--coral-300);
}

.sparkle--mint {
  background: var(--mint-400);
}

.sparkle--sky {
  background: var(--sky-400);
}

.tutor.is-celebrating {
  animation: tutor-cheer 1.2s ease;
}

.tutor.is-celebrating .tutor__figure {
  animation: tutor-hop 0.75s cubic-bezier(0.3, 0.6, 0.4, 1);
}

/* captions */

.captions {
  display: grid;
  flex: none;
  align-content: center;
  gap: 0.15rem;
  min-height: 5.4rem;
  padding: 0.7rem 1.1rem;
  border-radius: 20px;
  background: var(--night-800);
  text-align: center;
}

.captions__prev {
  overflow: hidden;
  font-size: 1rem;
  color: var(--text-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.captions__now {
  font-size: clamp(1.2rem, 2.6vw, 1.6rem);
  font-weight: 700;
  line-height: 1.3;
}

/* Sharing: over the bottom of the shared screen, in the strip kept for them there (see
   .share__window), in a dark box only as wide as the words, as a video call shows captions.
   They are put into the stage's row of the room's grid, and above the stage. */
.room.is-presenting .captions {
  position: relative;
  z-index: 2;
  grid-row: 2;
  grid-column: 1;
  align-self: end;
  justify-self: center;
  max-width: min(48rem, calc(100% - 1.5rem));
  min-height: 0;
  margin-bottom: 0.65rem;
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius-s);
  background: rgba(18, 25, 53, 0.94);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.6);
}

.room.is-presenting .captions__prev {
  font-size: 0.85rem;
}

.room.is-presenting .captions__now {
  font-size: clamp(1.02rem, 1.9vw, 1.3rem);
  line-height: 1.25;
}

/* A phone has room over the screen for the sentence being said only, not the one before. */
@media (max-width: 39.99rem) {
  .room.is-presenting .captions__prev {
    display: none;
  }
}

/* controls: a slim bar of round buttons, as in a video call, and the red "End lesson" pill.
   The words of a round button are its name for a screen reader only (index.html). */

.controls {
  display: flex;
  flex: none;
  flex-wrap: wrap; /* a very narrow phone: two rows, never a page that scrolls sideways */
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.ctl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.ctl:active {
  transform: scale(0.94);
}

.ctl__icon {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  background: var(--night-700);
  transition: background-color 0.15s ease;
}

.ctl:hover .ctl__icon {
  background: var(--night-600);
}

.ctl .icon {
  width: 1.35rem;
  height: 1.35rem;
}

.ctl[aria-pressed="true"] .icon--off,
.ctl[aria-pressed="false"] .icon--on {
  display: none;
}

.ctl--toggle[aria-pressed="true"] .ctl__icon {
  background: var(--indigo-500);
}

.ctl--mute[aria-pressed="true"] .ctl__icon {
  background: var(--cloud-100);
  color: var(--night-950);
}

/* A thin line between the buttons and "End lesson", where there is room for it. */
.controls__gap {
  display: none;
  width: 1px;
  height: 1.75rem;
  margin: 0 0.3rem;
  background: var(--night-600);
}

/* White words on red-700 stand apart by 5.4 to 1, more than the 4.5 the accessibility
   guidelines ask for words of this size; on the brighter red-500 it was 3.9. The hover is a
   little lighter, as the round buttons are on this dark bar, and still 5.0 to 1. */
.ctl--end {
  padding: 0 0.9rem 0 0.75rem;
  background: var(--red-700);
  color: #fff;
}

.ctl--end:hover {
  background: var(--red-600);
}

.ctl--end .ctl__icon,
.ctl--end:hover .ctl__icon {
  width: auto;
  height: auto;
  background: none;
}

.ctl--end .icon {
  width: 1.2rem;
  height: 1.2rem;
}

.ctl__label {
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

/* debug tools (?debug=1 on a server with debug tools on) */

.debug {
  display: grid;
  flex: none;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  border: 1px dashed var(--night-600);
  border-radius: var(--radius-s);
  background: var(--night-900);
  color: var(--text-soft);
  font-size: 0.85rem;
}

.debug__form {
  display: flex;
  gap: 0.5rem;
}

.debug__form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--night-600);
  border-radius: 10px;
  background: var(--night-800);
  color: var(--text);
}

.debug__events {
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- the look of spec v2 (wave W6) ----------
   A page with the fourth mark (http.js writes data-tutor-v2-look="1" wherever family mode is)
   draws the line over the room as the H1 of spec v2's live session: 20px, weight 800, in the
   text colour (it names the tutor and the block the lesson is on). The tag of the tutor's tile
   is the badge "AI TUTOR" of the spec, a little bolder. Nothing here reaches a page without the
   mark, and nothing names a class of the tutor screens. */

html[data-tutor-v2-look="1"] .room__brand {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
}

html[data-tutor-v2-look="1"] .tile__tag {
  font-weight: 800;
}

/* ---------- tutor avatar ---------- */

.avatar__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* The drawing itself (Bilby) carries its own colours; everything that moves is in avatar.css. */

/* ---------- motion ---------- */

@keyframes pulse {
  50% { opacity: 0.35; }
}

/* The tutor and the self-view fading in at their new place when the stage switches layout. */
@keyframes self-away {
  from { opacity: 0; transform: scale(0.8); }
}

@keyframes self-back {
  from { opacity: 0; }
}

/* Pictures on the shared screen: each keyframe only says where a part comes from. */
@keyframes vis-fade {
  from { opacity: 0; }
}

@keyframes vis-pop {
  from { opacity: 0; transform: scale(0.3); }
}

@keyframes vis-rise {
  from { opacity: 0; transform: translateY(0.3em); }
}

@keyframes vis-slide {
  from { opacity: 0; transform: translateX(-0.3em); }
}

@keyframes vis-draw {
  from { stroke-dashoffset: 1; }
}

@keyframes vis-stretch {
  from { transform: scaleX(0); }
}

/* A jump on the number line is uncovered from where it starts to where it lands. */
@keyframes vis-sweep {
  from { clip-path: inset(-0.6em 100% -0.6em -0.6em); }
}

@keyframes vis-sweep-back {
  from { clip-path: inset(-0.6em -0.6em -0.6em 100%); }
}

@keyframes vis-bob {
  50% { transform: translateY(-6%); }
}

@keyframes vis-shadow {
  50% { opacity: 0.6; transform: scale(0.8); }
}

@keyframes sparkle-fly {
  0% { opacity: 0; transform: translate(var(--x0), var(--y0)) scale(0.2) rotate(0deg); }
  20% { opacity: 1; }
  65% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x1), var(--y1)) scale(1) rotate(var(--spin)); }
}

@keyframes tutor-cheer {
  25% {
    border-color: var(--sun-400);
    box-shadow: 0 0 0 6px rgba(255, 201, 64, 0.3), 0 0 2.5rem rgba(255, 201, 64, 0.4);
  }
}

@keyframes tutor-hop {
  30% { transform: translateY(-7%) rotate(-3deg); }
  55% { transform: translateY(0) rotate(2deg); }
  75% { transform: translateY(-2.5%) rotate(0deg); }
}

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

/* ---------- wider screens ---------- */

@media (min-width: 40rem) {
  .room {
    gap: 1rem;
    padding: 1rem 1.25rem;
  }

  .controls {
    gap: 0.6rem;
  }

  .ctl {
    min-height: 3.1rem;
  }

  .ctl__icon {
    width: 3.1rem;
    height: 3.1rem;
  }

  .ctl .icon {
    width: 1.45rem;
    height: 1.45rem;
  }

  .controls__gap {
    display: block;
  }

  .ctl--end {
    padding: 0 1.2rem 0 1rem;
  }

  .ctl--end .icon {
    width: 1.35rem;
    height: 1.35rem;
  }

  .ctl__label {
    font-size: 1rem;
  }
}

/* From here the tutor tile is wide enough for the self-view to float over its corner,
   picture-in-picture, so the tutor can use the full height. */
@media (min-width: 42.5rem) {
  .stage {
    min-height: 15rem;
  }

  /* Side insets keep the centred tutor clear of the self-view tile. */
  .tutor__figure {
    inset: 1.75rem calc(var(--self-width) + 1.6rem);
    max-width: 26rem;
    max-height: 26rem;
  }

  .self {
    position: absolute;
    right: 0.85rem;
    bottom: 0.85rem;
    display: block;
    width: var(--self-width);
    padding: 0;
    box-shadow: 0 12px 26px -12px rgba(0, 0, 0, 0.7);
    animation: none;
  }

  .self__frame {
    border-radius: 0;
  }

  .self__label,
  .self__note {
    max-height: 5rem;
    overflow: hidden;
    padding: 0.4rem 0.6rem 0.5rem;
    font-size: 0.78rem;
  }

  .self__note {
    padding-top: 0;
  }

  .tile__name {
    max-width: calc(100% - 16rem);
  }
}

/* Wide windows: the small tiles are larger, and so are the words on them. */
@media (min-width: 58rem) {
  .stage.is-presenting .status {
    top: 0.45rem;
    left: 0.45rem;
    padding: 0.18rem 0.6rem;
    font-size: 0.8rem;
  }

  .stage.is-presenting .tile__name {
    bottom: 0.45rem;
    left: 0.45rem;
    padding: 0.18rem 0.6rem;
    font-size: 0.85rem;
  }

  .stage.is-presenting .tile__tag {
    font-size: 0.6rem;
  }

  .self__you {
    bottom: 0.45rem;
    left: 0.45rem;
    font-size: 0.8rem;
  }
}
