/* ===========================================================================
   Basic Mathematics — the help ladder on an exercise card (src/ui/ladder.ts)
   Linked on chapter pages after game.css (tools/lib/shell.js PAGE_KINDS), so it can
   lean on the card's own rules there: a clue is an .ex-hint, and its offer line is an
   .ex-next. It sits in the reading panel, so it draws only on the paper tokens of
   src/styles/tokens.css (they follow html[data-panel], light paper unless the reader
   chose the dark one), every text colour on a solid background that the contrast pairs
   measure (--text and --hint-ink on --hint-soft, --muted on --surface and --surface-2,
   the focus ring on --hint-soft and --surface). No gradient, no glow, nothing that loops;
   its one fade is in tools/reading-column-allow.json.
   =========================================================================== */

/* the clues, above the answer box: read, then answer */
.ex-ladder { display: grid; gap: .5rem; margin: 0 0 .9rem; }
.ex-ladder .ex-clue { margin: 0; }
.ex-ladder .ex-hint-text {
  display: block; margin: 0; font-family: var(--sans); font-size: 1.0625rem; line-height: 1.55; color: var(--text);
}
/* an earlier clue stays, quieter, as an earlier hint did */
.ex-ladder .ex-clue[data-prev] .ex-hint-text { font-size: .9rem; color: var(--muted); }
/* focus lands on the clue just opened, so it is read; the ring shows where it went */
.ex-clue:focus { outline: none; }
.ex-clue:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }

/* the worked steps (the faded rung): a clue whose body is the solution's paragraphs */
.ex-ladder .ex-faded .ex-faded-steps > * { margin: 0 0 .5rem; font-family: var(--sans); font-size: 1.0625rem; line-height: 1.55; color: var(--text); }
.ex-ladder .ex-faded[data-prev] .ex-faded-steps > * { font-size: .9rem; color: var(--muted); }
.ex-ladder .ex-faded .ex-hint-text { margin-top: .25rem; font-size: .98rem; color: var(--muted); }

/* an authored note about a wrong answer, in the verdict's place of the detector's question */
.ex-feedback .ex-miss-note { display: block; margin: .3rem 0 0; font-size: .88rem; color: var(--muted); }

/* "Show a clue (1 of 2)": a ghost button, quieter than Check, never disabled */
.ex-form .ex-clue-btn { font-size: .9rem; }
.ex-clue-btn .ex-clue-of { font-family: var(--sans); font-weight: 500; color: var(--muted); }

/* after a miss: a question about the answer, between the verdict and the offer */
.ex-feedback .ex-ask {
  margin: 0 0 .3rem; font-family: var(--sans); font-size: .98rem; line-height: 1.45; color: var(--text);
}

/* The one motion, a fade as a clue opens, under the same conditions as game.css's
   motion block (which owns the keyframes): never in Study mode or with reduced motion,
   never for a clue restored on a reload, and once. A clue is an .ex-hint, which game.css
   fades in each time a card turns wrong; that is turned off here (same weight, later
   file), so a miss never replays a clue's fade. The opened clue keeps data-fresh, so its
   animation stays the same value and does not restart when the card's state changes. */
@media (prefers-reduced-motion: no-preference) {
  html:not([data-calm]):not([data-motion="reduce"]) .ex[data-state] .ex-ladder .ex-clue { animation: none; }
  html:not([data-calm]):not([data-motion="reduce"]) .ex .ex-ladder .ex-clue[data-fresh] { animation: fade var(--dur-state) ease-out; }
}

@media print {
  /* a clue that was open prints as it reads; the button is a control and goes with them */
  .ex-clue-btn { display: none !important; }
}

/* "Try one like it" (src/ui/twin.ts): a small panel under the solution, in the reading
   column's tokens, with no motion of its own */
.ex-twin-card { margin: .9rem 0 0; padding: .8rem 1rem; display: grid; gap: .6rem; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius); }
.ex-twin-card[hidden] { display: none; }
.ex-twin-q { font-family: var(--sans); font-size: 1.0625rem; line-height: 1.55; color: var(--text); }
.ex-twin-q > * { margin: 0; }
.ex-twin-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.ex-twin-label { font-size: .9rem; color: var(--muted); }
.ex-twin-row input[type="text"] { width: min(14rem, 100%); }
.ex-twin-verdict { margin: 0; min-height: 1.2em; font-size: .98rem; color: var(--text); }
.ex-twin-extras { display: grid; gap: .5rem; justify-items: start; }
.ex-twin-steps p { margin: 0 0 .4rem; font-size: .95rem; color: var(--muted); }
.ex-twin-card > .btn { justify-self: start; }
@media print { .ex-twin-btn, .ex-twin-card { display: none !important; } }

/* The change-approach card (src/ui/ladder.ts): after the verdict once the whole ladder is
   open and the exercise is still missed; calm, no motion of its own */
.ex-approach { margin: .8rem 0 0; padding: .8rem 1rem; display: grid; gap: .5rem; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: .98rem; color: var(--text); }
.ex-approach[hidden] { display: none; }
.ex-approach > p { margin: 0; }
.ex-approach-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
@media print { .ex-approach { display: none !important; } }

/* The support line (src/ui/ladder.ts): a guided card says where the shaky ground is and offers the
   worked example; one calm line before the form, the same in calm mode, nothing in print */
.ex-support { margin: .2rem 0 .7rem; padding: .5rem .8rem; border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: var(--radius); font-size: .95rem; color: var(--text); }
.ex-support .btn { margin-left: .4rem; }
@media print { .ex-support { display: none !important; } }

/* a narrow screen drops the "(1 of 2)" suffix; the button's aria-label keeps the full text */
@media (max-width: 400px) { .ex-clue-btn .ex-clue-of { display: none; } }
