/*
 * The trainer screens outside a step (trainer-rework ui.md): the choosers (TR03, TR03a), the week (TR04 to
 * TR06, TR50), the review (TR46) and the settings (TR56); CompareRecordings moved to trainer-speaking.css when
 * this file reached 500 lines (trainer-redesign IMPL-013). Every value comes from tokens.css; the page frame
 * lives in trainer.css and the part bodies in trainer-parts.css. Split from trainer.css to keep each file
 * under 500 lines.
 */

/* Choosers (TX20, TX21; kit.py .pick): radio cards at TX_PICK_RADIUS_PX with a CONTROL_LINE border (KD-T19); the
   chosen card takes the selected line and fill and its tick, so the state never rests on colour alone (UX-004) */
.trainer-chooser .trainer-heading {
  font-size: var(--tx-chooser-h1-size);
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: var(--tx-pick-gap);
}

.choice-option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  min-height: var(--tap-min);
  padding: var(--tx-pick-padding) calc(var(--tx-pick-padding) + var(--tx-pick-tick-room)) var(--tx-pick-padding)
    var(--tx-pick-padding);
  border: var(--tx-pick-border-width) solid var(--option-line);
  border-radius: var(--tx-pick-radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
}

.choice-option[aria-checked="true"] {
  border-color: var(--selected-line);
  background: var(--selected-bg);
  color: var(--tx-pick-selected-ink);
}

.choice-tick {
  position: absolute;
  top: var(--tx-pick-padding);
  right: var(--tx-pick-padding);
  color: var(--tx-pick-selected-label);
}

.choice-label {
  color: var(--tool-accent-ink);
  font-size: var(--tx-label-size);
  font-weight: 700;
  letter-spacing: var(--tx-label-tracking);
}

.choice-title {
  font-size: var(--tx-lead-size);
  font-weight: 700;
  line-height: var(--tx-pick-title-line-height);
}

.choice-sample,
.choice-line {
  color: var(--ink-2);
  font-size: var(--tx-tiny-size);
  line-height: var(--tx-tiny-line-height);
}

.choice-option[aria-checked="true"] .choice-label {
  color: var(--tx-pick-selected-label);
}

.choice-option[aria-checked="true"] :is(.choice-sample, .choice-line) {
  color: var(--tx-pick-selected-muted);
}

/* Week (TX01; trainer_screens.py _path): the banner on the trainer tint, the counter ring in the accent, phase
   titles at TX_LABEL over plain rows; a row is a TX_PILL_SIZE_PX disc (done: tick on the soft accent; next: its
   number on the accent with a heavier heading in --ink; upcoming: its number on --surface-muted) beside its heading.
   The tick, the weight and the number carry the state with the colour (UX-004) */
.done-banner {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin: 0;
  border-color: transparent;
  background: var(--tool-tint);
  color: var(--ink);
  font-weight: 600;
}

.done-banner .choice-tick {
  position: static;
  color: var(--tool-accent-ink);
}

.trainer-week {
  padding-top: var(--space-md);
}

/* The ready goose (TX01) sits beside the heading on the phone: two tracks, every other child across both; dense
   placement puts the heading into the first track of the goose's row, where a word too long at 200 % text breaks */
.trainer-week {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-auto-flow: row dense;
  align-items: center;
}

.trainer-week > * {
  grid-column: 1 / -1;
}

.trainer-week > .goose {
  grid-column: 2;
}

.trainer-week > .trainer-heading {
  grid-column: 1;
  overflow-wrap: break-word;
}

/* LevelLine (trainer_frame.py level_line): the level mark at TX_LEVEL_LINE_MARK_PX before the words in the label
   type; a long line wraps and the mark stays on its first line (CHK025) */
.level-line {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
  margin: 0;
  color: var(--ink-2);
  font-size: var(--tx-label-size);
  font-weight: 600;
  letter-spacing: var(--tx-label-tracking);
  text-transform: uppercase;
}

.level-line .level-mark {
  flex: none;
  width: var(--tx-level-line-mark-size);
  height: var(--tx-level-line-mark-size);
  color: var(--ink);
}

.week-counter {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.week-counter__ring {
  flex: none;
  width: var(--tx-counter-size);
  height: var(--tx-counter-size);
  border: var(--tx-counter-ring-width) solid var(--tool-accent);
  border-radius: var(--radius-pill);
  font-weight: 800;
  color: var(--tool-accent-ink);
}

.week-counter__line {
  margin: 0;
}

.storage-notice {
  margin: 0;
}

.phase-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.phase-group__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;
}

/* TAP_GAP between the step rows (UX-005) */
.phase-group__rows {
  display: flex;
  flex-direction: column;
  gap: var(--tap-gap);
}

.step-row,
.review-row {
  display: flex;
  align-items: flex-start;
  gap: var(--tx-step-row-gap);
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--tx-step-row-padding-y) 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--tx-lead-size);
  line-height: var(--tx-step-row-line-height);
  text-align: left;
}

.step-row__heading {
  padding-top: var(--tx-step-heading-offset);
}

.step-row[data-status="next"] {
  color: var(--ink);
  font-weight: 600;
}

.step-row__disc {
  flex: none;
  width: var(--tx-pill-size);
  height: var(--tx-pill-size);
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--ink-2);
  font-family: var(--font-display);
  font-size: var(--tx-pill-number-size);
  font-weight: 700;
}

.step-row[data-status="next"] .step-row__disc {
  background: var(--tool-accent);
  color: var(--on-tool-accent);
}

.step-row[data-status="done"] .step-row__disc,
.review-row .step-row__disc {
  background: var(--tool-accent-soft);
  color: var(--tool-accent-ink);
}

.step-row__disc .choice-tick,
.step-row__disc .review-icon {
  position: static;
  width: var(--tx-pill-tick-size);
  height: var(--tx-pill-tick-size);
  color: inherit;
  stroke-width: var(--tx-pill-tick-stroke);
}

.week-settings {
  margin: 0;
  text-align: center;
}

/* Settings (TR56): rows, transfer, reset */
.trainer-settings,
.settings-rows,
.progress-transfer {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.settings-row {
  margin: 0;
}

.transfer-message,
.transfer-copied {
  margin: 0;
}

.transfer-message[data-state="error"] {
  color: var(--error);
}

.transfer-message[data-state="error"]::before {
  content: "! ";
  font-weight: 700;
}

.transfer-message[data-state="restored"] {
  color: var(--ok);
}

.transfer-message[data-state="restored"]::before {
  content: "✓ ";
}

/* WeekSummary and ProgrammeDoor (TX15): stats on cards with the value in the accent ink at TX_STAT_SIZE; the door
   a card (no pastel) whose button is the one primary, so the part's finish action draws as a TextLink (CHK021) */
.week-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.week-summary__stat,
.programme-door {
  padding: var(--tx-card-padding);
  border: var(--tx-card-border-width) solid var(--tx-card-line);
  border-top: var(--tx-card-top-width) solid var(--tx-card-top-line);
  border-radius: var(--tx-card-radius);
  background: var(--tx-card-bg);
}

/* ProgrammeDoor, a ruled section (ui.md): in light the card's hairline, in dark the 2 px accent rule and its gap
   (TX_DARK_RULE) in place of the card */
.programme-door {
  padding-top: var(--tx-rule-gap);
  border-top: var(--tx-rule-width) solid var(--tx-rule-line);
}

.week-summary__stat {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-sm);
  margin: 0;
}

.week-summary__value {
  flex: none;
  white-space: nowrap;
  color: var(--tool-accent-ink);
  font-family: var(--font-display);
  font-size: var(--tx-stat-size);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.trainer-part:has(.week-summary) .action-bar .button--primary {
  min-height: var(--tap-min);
  padding: 0;
  background: transparent;
  color: var(--tool-accent-ink);
  font-size: var(--tx-link-font-size);
  font-weight: 600;
  text-decoration-line: underline;
  text-underline-offset: var(--tx-link-underline-offset);
}

.week-summary__copied {
  margin: 0;
}

.week-summary__text {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
}

.programme-door {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.programme-door__heading {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--tx-h2-size);
}

.programme-door__line {
  margin: 0;
}

/* CheckFailed (TX18): the band's line on PlainCard with the alert icon; retry the primary, the teacher action
   outlined, skip as a TextLink (kit.py .link) */
.check-failed,
.check-failed__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.check-failed__notice {
  display: flex;
  justify-content: center;
  padding: var(--space-lg) 0;
}

.trainer-part:has(.check-failed) .trainer-band .instruction-line {
  display: flex;
  align-items: flex-start;
  gap: var(--tx-notice-icon-gap);
  padding: var(--tx-plain-padding);
  border: var(--tx-plain-border-width) solid var(--tx-plain-line);
  border-radius: var(--tx-plain-radius);
  background: var(--tx-plain-bg);
  color: var(--ink);
}

.trainer-part:has(.check-failed) .trainer-band .instruction-line::before {
  content: "";
  flex: none;
  width: var(--tx-notice-icon-size);
  height: var(--tx-notice-icon-size);
  margin-top: var(--tx-notice-icon-offset);
  background: var(--error);
  -webkit-mask: var(--tx-icon-alert) center / contain no-repeat;
  mask: var(--tx-icon-alert) center / contain no-repeat;
}

.check-failed__actions > button.button--secondary {
  min-height: var(--tap-min);
  border: 0;
  background: transparent;
  color: var(--tool-accent-ink);
  font-size: var(--tx-link-font-size);
  font-weight: 600;
  text-decoration-line: underline;
  text-underline-offset: var(--tx-link-underline-offset);
}

.check-failed__teacher-line {
  margin: 0;
  color: var(--ink-2);
}

/* Desktop stage rows (trainer_desk_stage.py): the week's phases side by side with every row a card, seven across
   (KD-T20); the chooser cards three across in TX_STAGE_ROW_PX. The summary, check failed and compare rows sit in
   trainer-speaking.css (this file keeps under 500 lines); the stage itself is set in trainer-frame.css */
@media (min-width: 64rem) {
  .trainer-week {
    display: grid;
    grid-template-columns: 2fr 3fr 2fr;
    align-content: start;
    column-gap: var(--tx-card-row-gap);
    justify-items: center;
  }

  .trainer-week > :not(.phase-group) {
    grid-column: 1 / -1;
  }

  .trainer-week > .goose,
  .trainer-week > .trainer-heading {
    grid-column: 1 / -1;
  }

  .trainer-week > .phase-group {
    grid-column: auto;
  }

  .trainer-week > .goose {
    order: -1;
  }

  .phase-group {
    align-self: start;
    justify-self: stretch;
    text-align: left;
  }

  .phase-group__rows {
    display: grid;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    gap: var(--tx-card-row-gap);
  }

  .step-row,
  .review-row {
    flex-direction: column;
    gap: var(--tx-card-row-gap);
    height: 100%;
    padding: var(--tx-week-card-padding);
    border: var(--tx-card-border-width) solid var(--tx-card-line);
    border-top: var(--tx-card-top-width) solid var(--tx-card-top-line);
    border-radius: var(--tx-card-radius);
    background: var(--tx-card-bg);
    font-size: var(--tx-tiny-size);
    line-height: var(--tx-tiny-line-height);
  }

  .step-row[data-status="next"] {
    border-color: var(--selected-line);
    background: var(--tool-accent-soft);
  }

  .step-row__heading {
    padding-top: 0;
  }

  .choice-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--tx-card-row-gap);
    width: var(--tx-stage-row);
    max-width: 100%;
  }

}
