/* ══════════════════════════════════════════════════════════════════════════
   tutor.css — the lesson card of a language tutor (language-tutor/)
   ──────────────────────────────────────────────────────────────────────────
   Drawn by public/js/fmt.js _tutorCard from a ```hz-tutor marker; walked by
   public/js/addons/tutor-addon.js. One card surface (.hz-card), one step
   visible at a time, the taught language set large with its Listen button,
   the learner's language quiet beneath it. Every colour, radius, space and
   size is a design-system token (public/css/design-system/tokens.css); the
   quiz options are the .hz-option atom with its verdict modifiers, the step
   dots the .hz-steps atom, the kind label the .hz-kicker atom, the feedback a
   .hz-callout, the buttons the .hz-btn atom — the learning atoms of atoms.css,
   so the card inherits the system's hover / press / focus / reduced-motion
   and the next quiz or wizard composes the same parts.
   Light mode is a token swap, not an override. RTL: logical properties; the
   taught text carries its own `dir`.
   ══════════════════════════════════════════════════════════════════════════ */

/* Sized for the chat it lives in: the whole card — head, a step, Back / Next —
   fits the visible thread of a 360×640 phone and of the Telegram Mini App with
   its composer and chips, so Next never hides below the fold. The head carries
   the progress (no footer row of dots), an example's reading and meaning share a
   line, and a phone's card pads at 12px: it already sits inside the reply card. */
.hz-tutor {
  display: grid;
  gap: var(--hz-space-3);
  margin: var(--hz-space-2) 0;
  padding: var(--hz-space-3);
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
}
@media (min-width: 600px) {
  .hz-tutor { padding: var(--hz-space-4); }
}
.hz-tutor__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--hz-space-3);
}
.hz-tutor__icon {
  width: var(--hz-space-10);
  height: var(--hz-space-10);
  border-radius: var(--hz-radius-12);
  display: grid;
  place-items: center;
  color: var(--hz-text-onbrand);
  background: var(--hz-brand-gradient);
}
.hz-tutor__icon svg { stroke: currentColor; }
.hz-tutor__headbody { min-width: 0; display: grid; gap: var(--hz-space-1); }
.hz-tutor__name {
  font-weight: var(--hz-weight-bold);
  font-size: var(--hz-text-md);
  line-height: var(--hz-leading-snug);
  /* Two lines before an ellipsis: a lesson's name is worth reading whole. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.hz-tutor__meta {
  /* "Lesson · 7 cards" — for screen readers; the dots under the title say it. */
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.hz-tutor__dots { min-height: 16px; }
/* ♪ sound effects on / off (tutor-addon.js): a quiet control in the head's
   corner — the brand tint of a pressed icon button says "on", the slash "off". */
.hz-tutor__sfx { align-self: start; border-color: transparent; color: var(--hz-text-meta); }
.hz-tutor__sfx[aria-pressed="true"] { border-color: transparent; }
.hz-tutor__sfx[hidden] { display: none; } /* no Web Audio: no ♪ (tutor-addon.js) — .hz-btn sets a display */
.hz-tutor__sfx-slash { display: none; }
.hz-tutor__sfx.is-off .hz-tutor__sfx-slash { display: inline; }

/* ── Steps ───────────────────────────────────────────────────────────────── */
.hz-tutor__body { min-width: 0; }
.hz-tutor__step { display: grid; gap: var(--hz-space-2); }
.hz-tutor__step[hidden] { display: none; }

.hz-tutor__row {
  display: flex;
  align-items: center;
  gap: var(--hz-space-2);
  min-width: 0;
}
.hz-tutor__target {
  /* As wide as its words, at the row's start: the taught text keeps its own
     direction (dir) but lines up with the reader's screen — Arabic in a Russian
     app starts at the left, over its reading and meaning, never stranded at
     the far side of the row next to the 🔊. */
  flex: 0 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  unicode-bidi: isolate;
}
.hz-tutor__row > .hz-tutor__listen { margin-inline-start: auto; }
.hz-tutor__main .hz-tutor__target {
  font-size: var(--hz-text-xl);
  font-weight: var(--hz-weight-bold);
  line-height: var(--hz-leading-snug);
  letter-spacing: var(--hz-tracking-tight);
}
.hz-tutor__pron {
  font-size: var(--hz-text-sm);
  color: var(--hz-text-meta);
  font-style: italic;
}
.hz-tutor__gloss {
  font-size: var(--hz-text-base);
  color: var(--hz-text);
  line-height: var(--hz-leading-normal);
}
.hz-tutor__gloss--small { font-size: var(--hz-text-sm); color: var(--hz-text-meta); }
/* An example's reading · meaning: one line, wrapping only when it must. */
.hz-tutor__sub {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--hz-space-2);
  line-height: var(--hz-leading-snug);
}
.hz-tutor__sep { color: var(--hz-text-subtle); }
.hz-tutor__example {
  display: grid;
  gap: 2px;
  padding: var(--hz-space-2) var(--hz-space-2) var(--hz-space-2) var(--hz-space-3);
  border-radius: var(--hz-radius-12);
  background: var(--hz-surface-fill);
}
.hz-tutor__example .hz-tutor__target { font-size: var(--hz-text-base); font-weight: var(--hz-weight-semibold); line-height: var(--hz-leading-snug); }
/* A small-caps label: caps need air between letters, never a display heading's
   negative tracking (it fused "A FIRST WORD" into "AFIRSTWORD"). The eyebrow
   tracking is 0 for Arabic and Hindi screens (tokens.css), as their scripts need. */
.hz-tutor__label {
  font-size: var(--hz-text-2xs);
  font-weight: var(--hz-weight-semibold);
  letter-spacing: var(--hz-panel-head-eyebrow-tracking);
  text-transform: uppercase;
  color: var(--hz-text-meta);
}
.hz-tutor__title {
  font-size: var(--hz-text-lg);
  font-weight: var(--hz-weight-bold);
  line-height: var(--hz-leading-snug);
}
.hz-tutor__rule {
  font-size: var(--hz-text-base);
  line-height: var(--hz-leading-normal);
  padding-inline-start: var(--hz-space-3);
  border-inline-start: 3px solid var(--hz-brand);
}
.hz-tutor__q {
  font-size: var(--hz-text-md);
  font-weight: var(--hz-weight-semibold);
  line-height: var(--hz-leading-snug);
}
.hz-tutor__score {
  font-size: var(--hz-text-2xl);
  font-weight: var(--hz-weight-extrabold);
  color: var(--hz-success-ink);
}
.hz-tutor__learned { display: flex; flex-wrap: wrap; gap: var(--hz-space-2); }
/* A learned item is the .hz-pill atom with its Listen button tucked in. */
.hz-tutor__chip { gap: var(--hz-space-1); padding-inline-end: var(--hz-space-1); }
.hz-tutor__chip .hz-tutor__target { font-weight: inherit; font-size: var(--hz-text-md); }
.hz-tutor__chip .hz-tutor__listen { width: 32px; height: 32px; min-width: 0; min-height: 0; }
.hz-tutor__chip .hz-tutor__listen svg { width: 16px; height: 16px; }
/* The Arabic script sits small beside Latin at one size: a learned letter or word reads at a glance. */
.hz-tutor__chip .hz-tutor__target:is(:lang(ar), :lang(fa), :lang(ur)) { font-size: var(--hz-text-xl); line-height: 1.2; }

/* ── A letter: the glyph, its name beside it, the 🔊 at the end ──────────── */
.hz-tutor__glyph { gap: var(--hz-space-3); }
.hz-tutor__glyph .hz-tutor__target {
  flex: none;
  font-size: clamp(44px, 7vh, 60px);
  /* Room for the marks above and below a letter (Arabic dots and vowels). */
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: 0;
}
.hz-tutor__glyph .hz-tutor__letter-name { flex: 1; min-width: 0; font-size: var(--hz-text-md); }

/* ── Listen / Say ────────────────────────────────────────────────────────── */
/* 🔊 is the card's most-used control: a round, tinted button with a clear glyph
   (the .hz-btn--icon atom's tap box, its own face) — never a bare 18px icon.
   The step's own line gets the large one; it fills with the brand while it
   plays (aria-pressed, set by tutor-addon.js). */
.hz-tutor__listen {
  flex: none;
  height: var(--hz-tap-min);
  border-radius: var(--hz-radius-full);
  color: var(--hz-brand-ink);
  background: var(--hz-brand-soft);
  border: 1px solid transparent;
}
.hz-tutor__listen svg { width: 20px; height: 20px; }
.hz-tutor__listen--lg { width: 52px; min-width: 52px; height: 52px; }
.hz-tutor__listen--lg svg { width: 24px; height: 24px; }
@media (hover: hover) and (pointer: fine) {
  .hz-tutor__listen:hover { border-color: var(--hz-brand-border); }
}
.hz-tutor__listen:focus-visible { outline: 2px solid var(--hz-brand); outline-offset: 2px; }
/* The app-wide focus ring (app.css `button:focus-visible`) takes the PARENT's
   corners (`border-radius: inherit`): a focused or just-tapped 🔊 turned into a
   square box, Next and the options lost their curves. Each keeps its own shape. */
.hz-tutor .hz-tutor__listen:focus-visible { border-radius: var(--hz-radius-full); }
.hz-tutor .hz-btn:not(.hz-tutor__listen):focus-visible { border-radius: var(--hz-btn-radius); }
.hz-tutor .hz-option:focus-visible { border-radius: var(--hz-option-radius); }
.hz-tutor__listen.is-playing,
.hz-tutor__listen[aria-pressed="true"] { color: var(--hz-text-onbrand); background: var(--hz-brand); border-color: transparent; }
.hz-tutor__play.is-playing { color: var(--hz-brand); border-color: var(--hz-brand-border); }
/* The clip is being made (the first time anyone hears this line takes a few
   seconds): the speaker breathes, the button stays live — a tap cancels. */
.hz-tutor__listen.is-loading svg,
.hz-tutor__play.is-loading svg { animation: hz-tutor-wait 1s ease-in-out infinite; }
@keyframes hz-tutor-wait { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.hz-tutor__play,
.hz-tutor__say { width: 100%; gap: var(--hz-space-2); }
.hz-tutor__say.is-listening {
  animation: hz-tutor-pulse 1.25s ease-out infinite;
}
@keyframes hz-tutor-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--hz-brand) 55%, transparent); }
  65%  { box-shadow: 0 0 0 10px color-mix(in srgb, var(--hz-brand) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--hz-brand) 0%, transparent); }
}
.hz-tutor__say.is-done { background: var(--hz-success); }
.hz-tutor__heard {
  font-size: var(--hz-text-sm);
  color: var(--hz-text-meta);
  font-style: italic;
  unicode-bidi: isolate;
}
.hz-tutor__self { display: grid; gap: var(--hz-space-2); }


/* ── Options (atoms) ─────────────────────────────────────────────────────── */
.hz-tutor__options { margin-top: var(--hz-space-1); }
.hz-tutor__option { min-height: var(--hz-tap-min); padding-block: var(--hz-space-2); }
.hz-tutor__option-label { unicode-bidi: isolate; }
/* An answer in the taught script (dir="rtl" in a left-to-right screen, or the
   reverse) lines up with the screen like every other option — not at the far edge. */
html:not([dir="rtl"]) .hz-tutor__option-label { text-align: left; }
html[dir="rtl"] .hz-tutor__option-label { text-align: right; }
/* An answer in the taught Arabic script reads at a glance (ب / ت / ث differ by a dot).
   Only a label fmt.js marked with the taught language's `lang` — never one that merely
   inherits an Arabic screen's: an English answer on an Arabic screen keeps its size. */
.hz-tutor__option-label:is([lang="ar"], [lang="fa"], [lang="ur"]) { font-size: var(--hz-text-xl); line-height: 1.3; }
/* A listen card plays before it shows: its options wait, slightly veiled, until the clip has been heard once. */
.hz-tutor__step--listen:not(.is-heard) .hz-tutor__options { opacity: .55; }

/* ── Feedback (the callout atom) ────────────────────────────────────────── */
.hz-tutor__feedback[hidden] { display: none; }
.hz-tutor__feedback .hz-callout-b { display: grid; gap: 2px; font-size: var(--hz-text-sm); line-height: var(--hz-leading-normal); }
/* The verdict's words in the text colour: the tone is the callout's icon (a check, a cross — tutor-addon.js
   `_paintVerdict`), since the success ink on its tint is under AA in the light theme. */
.hz-tutor__verdict { font-weight: var(--hz-weight-bold); color: var(--hz-text); }
.hz-tutor__why { color: var(--hz-text); }
/* A word of the person's typed answer that is not in the right one. */
.hz-tutor__diff { background: none; color: inherit; font-weight: var(--hz-weight-semibold); text-decoration: underline wavy var(--hz-danger-ink); text-underline-offset: 3px; text-decoration-skip-ink: none; }
/* The "why", the answer line and the question are in whichever language the
   tutor wrote them — each keeps its own direction, so an English sentence in an
   Arabic screen (or the reverse) keeps its full stop where it belongs. */
.hz-tutor__feedback .hz-callout-b > *, .hz-tutor__q, .hz-tutor__gloss, .hz-tutor__rule, .hz-tutor__meta { unicode-bidi: plaintext; }

/* ── Type ─────────────────────────────────────────────────────────────────── */
.hz-tutor__form { display: flex; gap: var(--hz-space-2); align-items: stretch; }
.hz-tutor__input { flex: 1; min-width: 0; }
.hz-tutor__check { flex: none; }


/* ── Foot: status, actions ───────────────────────────────────────────────── */
.hz-tutor__foot {
  display: grid;
  gap: var(--hz-space-2);
  padding-top: var(--hz-space-1);
}
.hz-tutor__status {
  min-height: 1.2em;
  font-size: var(--hz-text-sm);
  font-weight: var(--hz-weight-semibold);
  color: var(--hz-success-ink);
}
.hz-tutor__status:empty { display: none; }
.hz-tutor__actions { display: flex; gap: var(--hz-space-2); justify-content: flex-end; }
.hz-tutor__actions [hidden] { display: none; }
.hz-tutor__next { min-width: 112px; }
.hz-tutor.is-readonly .hz-tutor__actions { display: none; }

/* Inside the agent bubble the card is the whole message: no bubble padding doubling. */
.bub > .hz-tutor:only-child { margin: 0; }

/* A short screen (a phone on its side, the Mini App half-open, a keyboard up):
   the glyph and the step's line come down a size, so the step still fits. */
@media (max-height: 560px) {
  .hz-tutor { gap: var(--hz-space-2); }
  .hz-tutor__main .hz-tutor__target { font-size: var(--hz-text-lg); }
  .hz-tutor__glyph .hz-tutor__target { font-size: 40px; }
}

@media (forced-colors: active) {
  .hz-tutor__listen { border-color: ButtonText; }
  .hz-tutor__listen[aria-pressed="true"] { background: Highlight; color: HighlightText; }
}

@media (prefers-reduced-motion: reduce) {
  .hz-tutor__say.is-listening { animation: none; outline: 2px solid var(--hz-brand); }
  .hz-tutor__listen.is-loading svg,
  .hz-tutor__play.is-loading svg { animation: none; opacity: .5; }
}
