/* Read it to me. Monochrome like everything else: the only colour on this control is
   the sentence being spoken, and even that is a greyscale wash plus a rule, because
   AGENTS.md §2 allows colour only where it carries meaning about correctness.

   The control sits ABOVE the lesson column rather than beside it: on a phone the
   column is the whole width, and a floating control would cover the words a child is
   following. It is `position: sticky` at the top so Pause and Replay stay reachable
   after the reader has scrolled into the lesson, and it is a normal block at the top
   of the page for a keyboard or screen-reader user. */

.ra {
  max-width: min(var(--measure), 100%);
  margin: 0 auto var(--space-4);
}

.ra-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.ra-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 var(--space-3);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  line-height: 1.2;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  cursor: pointer;
}

.ra-btn[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
}

.ra-btn.ra-icon-only {
  justify-content: center;
  padding: 0;
  border-color: var(--line);
}

.ra-icon {
  font-size: 0.85em;
  line-height: 1;
}

.ra-speed {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: var(--muted);
}

.ra-speed select {
  min-height: var(--tap);
  padding: 0 var(--space-2);
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.ra-note,
.ra-why {
  margin: var(--space-2) 0 0;
  font-family: var(--font-ui);
  font-size: var(--step--1);
  line-height: 1.45;
  color: var(--muted);
}

/* THE QUIET DOOR (a pupil's session, no local voice).
 *
 * When this device has no voice that stays on it, the control is not built — a
 * network voice would send the lesson to a third party — and what remains is one
 * text-weight line a child can press, which prints one calm sentence. It is a
 * button so it is reachable by keyboard and by VoiceOver, and it looks like a
 * sentence rather than a control, because a six-year-old should not be invited to
 * play with it. */
.ra-quiet {
  appearance: none;
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  min-height: var(--tap);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

.ra-quiet:hover { color: var(--fg); }

/* NOTHING VISIBLE, NO SPACE TAKEN. An adult's or a guest's page carries no
   read-aloud text at all when the device cannot speak (the reason is kept in the
   DOM, hidden, for the gates and for `state()`): the refusal belongs in Settings,
   not under every worked example. `:has` decides from what was actually built, so
   the rule cannot disagree with the module's own decision. */
.ra-off:not(:has(.ra-quiet)) {
  display: none;
}
.ra-off:has(.ra-quiet) {
  margin-bottom: var(--space-2);
}

/* The sentence being spoken. A wash and a left rule rather than a colour, so it reads
   in high contrast and in a print stylesheet as "this line", not "this colour". */
.ra-saying {
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  box-shadow: -0.35rem 0 0 0 var(--fg);
  border-radius: 2px;
  scroll-margin-block: 6rem;
}

@media (prefers-reduced-motion: no-preference) {
  .ra-saying { transition: background 120ms ease-out; }
}

/* A sticky bar only where there is room for it. On a phone the lesson column is the
   whole width and a sticky control would eat a third of the screen, so it scrolls
   away with the page and Pause is reachable by scrolling up — the same trade the
   bottom tab bar makes. */
@media (min-width: 48rem) {
  .ra { position: sticky; top: 0; z-index: 3; }
}

.ra-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Never print the control, and never let it appear in a screenshot of the lesson a
   teacher is projecting. */
@media print {
  .ra { display: none; }
}

/* ------------------------------------------------------------------ tap to count */

/* A counting figure is a set of buttons. The ring on the last one tapped is the rule
   the lesson teaches — "the last number you say is the count" — so it is the only
   decoration, and it is a second stroke rather than a colour. */
.viz-tap_count .tc-hit {
  cursor: pointer;
  outline: none;
}

.viz-tap_count .tc-hit:focus-visible > circle,
.viz-tap_count .tc-hit:focus-visible > rect,
.viz-tap_count .tc-hit:focus-visible > polygon {
  stroke-width: 3;
}

/* The tap target is bigger than the drawn shape, because a five-year-old aims at a
   fingertip's centre and not at a 1.5px outline. `pointer-events: bounding-box` is not
   available everywhere, so the padded target comes from the `<g>`'s own box. */
.viz-tap_count .tc-hit {
  pointer-events: all;
}

.viz-tap_count .tc-n {
  fill: var(--fg);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}

.viz-tap_count .tc-last > circle,
.viz-tap_count .tc-last > rect,
.viz-tap_count .tc-last > polygon {
  stroke-width: 3;
}

/* A counted object is filled, so the eye can see how far along the count is without
   reading the numbers. */
.viz-tap_count .tc-hit[aria-pressed="true"] > circle,
.viz-tap_count .tc-hit[aria-pressed="true"] > rect,
.viz-tap_count .tc-hit[aria-pressed="true"] > polygon {
  fill: currentColor;
  fill-opacity: 0.18;
}

.tc-live {
  margin: var(--space-2) 0 0;
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: var(--muted);
  min-height: 1.5em;
}

.tc-reset {
  margin-top: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-3);
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

/* ------------------------------------------------------------ the early-reader view */

/* The short lesson opens first in the two courses that serve children. It is set a
   little larger with more leading than the full lesson, because it is read by someone
   for whom letter shapes still take effort — and the same tokens scale it with the
   text-size setting on the account page. */
.ln-lesson-young {
  font-size: 1.06em;
  line-height: 1.65;
}

.ln-lesson-young h2,
.ln-lesson-young h3 {
  margin-top: var(--space-5);
}

.ln-lesson-young p {
  margin-bottom: var(--space-4);
}

.ln-more {
  margin: var(--space-4) 0 var(--space-5);
}

.ln-full {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}
