/*
 * Trainer talk styles (trainer-talk): the in-page AI talk of /7-days (steps 2 and 5), its start, thread, answer
 * dock and end screens. Every rule sits under [data-tool="trainer"]; every value comes from tokens.css
 * (TOKEN_SCOPE_BLOCK). Linked after trainer-step-results.css; the capped trainer stylesheets take no talk rules.
 */

/* TalkFrame (IMPL-003, TX08): the header label centred in --ink at the meta size, no parts bar; on the phone one
   column, the side column (DeskNotes) hidden */
[data-tool="trainer"] .talk-frame {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

[data-tool="trainer"] .talk-frame__label {
  margin: 0;
  color: var(--ink);
  font-size: var(--tx-meta-size);
  font-weight: 600;
  text-align: center;
}

[data-tool="trainer"] .talk-frame__side {
  display: none;
}

/* TalkStart (TX08, TX12): heading, the length line in the lead type, the partner line in --ink-2, «Завдання» as a
   label, the chips wrapping, the feedback note; «Почати розмову» with the privacy line under it sticks to the bottom
   as every primary of the trainer does */
[data-tool="trainer"] .talk-start {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-top: var(--space-md);
}

[data-tool="trainer"] .talk-length {
  margin: 0;
  color: var(--ink);
  font-size: var(--tx-lead-size);
  line-height: var(--tx-lead-line-height);
}

[data-tool="trainer"] .talk-partner {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--fs-body);
  line-height: var(--tx-uk-line-height);
}

[data-tool="trainer"] .talk-tasks-label {
  margin: var(--space-md) 0 0;
  color: var(--ink-2);
  font-size: var(--tx-label-size);
  font-weight: 600;
  letter-spacing: var(--tx-label-tracking);
  text-transform: uppercase;
}

/* TaskChips (UX-007): a wrapping row of status chips (not controls), English at the meta size, under
   TALK_EN_TEXT_MAX */
[data-tool="trainer"] .talk-tasks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin: 0;
  padding: 0;
  list-style: none;
}

[data-tool="trainer"] .task-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--tx-chip-tick-gap);
  min-height: var(--space-xl);
  padding: 0 var(--space-md);
  border: var(--tx-secondary-border-width) solid var(--option-line);
  border-radius: var(--radius-pill);
  color: var(--ink);
  font-size: var(--tx-meta-size);
  font-weight: 600;
}

/* A ticked chip (IMPL-012): the selected fill of the frame colour, the tick glyph before the text; the hidden word
   «виконано» says it to assistive tech (UX-002: never colour alone) */
[data-tool="trainer"] .task-chip[data-met="true"] {
  border-color: var(--tool-accent);
  background: var(--tool-accent-soft);
  color: var(--tool-accent-ink);
}

[data-tool="trainer"] .task-chip__tick {
  flex: none;
  width: var(--tx-chip-tick-size);
  height: var(--tx-chip-tick-size);
}

/* PhraseMark: a task phrase in the learner's turn, frame-colour ink at weight 700 */
[data-tool="trainer"] .phrase-mark {
  color: var(--tool-accent-ink);
  font-weight: 700;
}

[data-tool="trainer"] .talk-feedback-note {
  margin: var(--space-xs) 0 0;
}

[data-tool="trainer"] .talk-start__actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
  background: var(--bg);
}

[data-tool="trainer"] .talk-privacy {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--tx-tiny-size);
  line-height: var(--tx-tiny-line-height);
  text-align: center;
}

/* DeskNotes (TX08 desktop): the talk goose over three panel cards, each a label title and a body line */
[data-tool="trainer"] .talk-notes {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

[data-tool="trainer"] .talk-notes .goose--talk {
  --goose-height: var(--tx-goose-card-height);
  align-self: center;
}

[data-tool="trainer"] .talk-note__title {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--tx-label-size);
  font-weight: 600;
  letter-spacing: var(--tx-label-tracking);
  text-transform: uppercase;
}

[data-tool="trainer"] .talk-note__line {
  margin: var(--space-xs) 0 0;
  color: var(--ink);
  font-size: var(--fs-body);
  line-height: var(--tx-uk-line-height);
}

/* A label read by assistive tech only (the turn labels, the talk's heading): clipped, never display: none */
[data-tool="trainer"] .talk-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The talk (TX09, TX10, IMPL-009): ticked chips at the top, the thread, the state line and the dock pinned at the
   bottom of the viewport above the safe area */
[data-tool="trainer"] .talk-live {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-height: 60dvh;
}

[data-tool="trainer"] .talk-thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* TurnBubble: the partner's on the left on the plain surface with the avatar and the speaker, the learner's on the
   right on the soft accent; English at the body-large size, under TALK_EN_TEXT_MAX */
[data-tool="trainer"] .turn {
  display: flex;
  align-items: flex-end;
  gap: var(--space-xs);
}

[data-tool="trainer"] .turn--learner {
  justify-content: flex-end;
}

[data-tool="trainer"] .turn__bubble {
  max-width: 86%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-panel);
}

[data-tool="trainer"] .turn--partner .turn__bubble {
  border: var(--hairline-width) solid var(--tx-plain-line);
  border-bottom-left-radius: var(--space-2xs);
  background: var(--tx-plain-bg);
}

[data-tool="trainer"] .turn--learner .turn__bubble {
  border-bottom-right-radius: var(--space-2xs);
  background: var(--tool-accent-soft);
}

[data-tool="trainer"] .turn__text {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-body-lg);
  font-weight: 500;
  line-height: var(--tx-en-list-line-height);
}

[data-tool="trainer"] .turn .goose-avatar {
  width: var(--space-2xl);
  height: var(--space-2xl);
}

/* SpeakerButton: a TAP_MIN icon button in --ink-2, the frame colour while its turn plays */
[data-tool="trainer"] .speaker-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: var(--tap-min);
  height: var(--tap-min);
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-2);
}

[data-tool="trainer"] .speaker-button[aria-pressed="true"] {
  color: var(--tool-accent-ink);
}

[data-tool="trainer"] .talk-state {
  margin: 0;
  color: var(--ink-2);
  text-align: center;
}

[data-tool="trainer"] .talk-dock {
  position: sticky;
  bottom: 0;
  z-index: 1;
  padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
  background: var(--bg);
}

[data-tool="trainer"] .talk-dock[hidden] {
  display: none;
}

[data-tool="trainer"] .talk-dock .record-control:disabled {
  opacity: var(--tx-record-disabled-opacity);
}

[data-tool="trainer"] .talk-dock .record-control .wait-dots {
  color: var(--on-tool-accent);
}

[data-tool="trainer"] .talk-dock__hint,
[data-tool="trainer"] .talk-timer {
  color: var(--ink-2);
  font-size: var(--tx-tiny-size);
  line-height: var(--tx-tiny-line-height);
}

[data-tool="trainer"] .talk-timer {
  font-variant-numeric: tabular-nums;
}

/* HelpChips (IMPL-015, TX09): a wrapping row of the built chips; a switched-off chip keeps its place at the disabled
   opacity of the record control */
[data-tool="trainer"] .help-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-xs);
}

[data-tool="trainer"] .help-chips[hidden],
[data-tool="trainer"] .help-chip[hidden] {
  display: none;
}

[data-tool="trainer"] :is(.help-chip, .speaker-button)[aria-disabled="true"] {
  opacity: var(--tx-record-disabled-opacity);
}

/* TextAnswer (IMPL-017, TA05): the upper-case label, the built text area in English under TALK_EN_TEXT_MAX, the limit
   line, then «Надіслати» over the centred «Говорити голосом», pinned at the bottom as the dock is */
[data-tool="trainer"] .talk-text-answer {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding-top: var(--space-sm);
  padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
  border-top: var(--hairline-width) solid var(--line);
  background: var(--bg);
}

[data-tool="trainer"] .talk-text-label {
  color: var(--ink-2);
  font-size: var(--tx-label-size);
  font-weight: 600;
  letter-spacing: var(--tx-label-tracking);
  text-transform: uppercase;
}

[data-tool="trainer"] .talk-turn-field {
  font-size: var(--tx-en-list-size);
  line-height: var(--tx-en-list-line-height);
}

[data-tool="trainer"] .talk-text-limit {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--tx-tiny-size);
  line-height: var(--tx-tiny-line-height);
}

[data-tool="trainer"] .talk-text-answer__actions {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-sm);
  text-align: center;
}

/* TalkEnd (TX11, IMPL-014): the heading row with the success goose, the chips, the CorrectionCard and the one primary;
   the wordings in English at TX_EN_LIST_SIZE, the learner's in --ink-2 above the better one in --ink */
[data-tool="trainer"] .talk-end {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-md);
  padding-top: var(--space-md);
}

[data-tool="trainer"] .talk-end .goose--success {
  --goose-height: var(--tx-goose-done-height);
  align-self: flex-end;
}

[data-tool="trainer"] .correction-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xs);
  align-self: stretch;
}

[data-tool="trainer"] .correction-card__title {
  margin: 0 0 var(--space-xs);
  color: var(--ink);
  font-size: var(--tx-h2-size);
}

[data-tool="trainer"] .wording-pair {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

[data-tool="trainer"] .wording-pair p {
  margin: 0;
  font-size: var(--tx-en-list-size);
  line-height: var(--tx-en-list-line-height);
}

[data-tool="trainer"] .wording-pair__original {
  color: var(--ink-2);
}

[data-tool="trainer"] .wording-pair__corrected {
  color: var(--ink);
  font-weight: 600;
}

/* DiffMark: never a strike look; the old words dotted-underlined, the new ones in the frame colour, solid underline */
[data-tool="trainer"] .diff-old {
  color: inherit;
  text-decoration: underline dotted;
  text-underline-offset: var(--tx-link-underline-offset);
}

[data-tool="trainer"] .diff-new {
  color: var(--tool-accent-ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: var(--tx-link-underline-offset);
}

[data-tool="trainer"] :is(.talk-end__actions, .talk-closing) {
  position: sticky;
  bottom: 0;
  z-index: 1;
  align-self: stretch;
  padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
  background: var(--bg);
}

[data-tool="trainer"] .talk-closing[hidden] {
  display: none;
}

/* Desktop (TX_LAYOUT_FOR stage): the main column two thirds, the side notes one third at the layout width */
@media (min-width: 64rem) {
  [data-tool="trainer"] main.trainer-page:has(#trainer-view > .talk-frame) {
    max-width: var(--tx-stage-width);
  }

  [data-tool="trainer"] .talk-frame__columns {
    display: grid;
    grid-template-columns: 2fr 1fr;
    align-items: start;
    gap: var(--space-2xl);
  }

  [data-tool="trainer"] .talk-frame__side {
    display: block;
  }

  [data-tool="trainer"] .talk-start > .goose--talk {
    display: none;
  }

  /* The end screen has no side notes: its stage takes the whole width */
  [data-tool="trainer"] .talk-frame__columns:has(> .talk-frame__side:empty) {
    grid-template-columns: 1fr;
  }

  [data-tool="trainer"] .talk-start__actions {
    position: static;
    flex-direction: row;
    align-items: center;
  }

  [data-tool="trainer"] .talk-dock {
    flex-direction: row;
    gap: var(--space-lg);
    text-align: left;
  }

  [data-tool="trainer"] .talk-dock .space-hint {
    display: inline;
  }

  /* The end screen is a stage: goose above the centred heading (TX11 desktop) */
  [data-tool="trainer"] .talk-end {
    align-items: center;
    text-align: center;
  }

  [data-tool="trainer"] .talk-end .goose--success {
    align-self: center;
  }

  [data-tool="trainer"] .talk-end .correction-card {
    align-self: center;
    width: min(100%, var(--tx-main-max));
    text-align: left;
  }

  [data-tool="trainer"] :is(.talk-end__actions, .talk-closing) {
    position: static;
    justify-content: center;
  }
}
