/*
 * Trainer frame styles (trainer-redesign): the page column, status row, buttons, text link, plain and practice
 * cards of /7-days. Every rule sits under [data-tool="trainer"] (contracts.md section 1); every value comes from
 * tokens.css (TOKEN_SCOPE_BLOCK). Linked after the screen sheets, so these rules win at equal specificity.
 */

/* TrainerPage (trainer_frame.py phone): one column at TX_PHONE_PADDING, no wider than TX_MAIN_MAX_PX; the
   bottom padding keeps the home indicator clear (UX-008) */
[data-tool="trainer"] main.trainer-page {
  max-width: var(--tx-main-max);
  padding: var(--tx-padding-top) var(--tx-padding-inline) calc(var(--tx-padding-bottom) + env(safe-area-inset-bottom));
  background: var(--bg);
}

[data-tool="trainer"] .trainer-view {
  padding: 0;
}

/* StatusRow and LangSwitch: on the ground, no tint; the pressed code in --ink and heavier, the other in
   --ink-2 (aria-pressed and the weight carry the state with the colour, UX-004) */
[data-tool="trainer"] .status-row {
  min-height: var(--tap-min);
  padding-top: 0;
  background: transparent;
}

[data-tool="trainer"] .lang-switch__code {
  background: transparent;
  color: var(--ink-2);
  font-size: var(--tx-meta-size);
  font-weight: 500;
}

[data-tool="trainer"] .lang-switch__code[aria-pressed="true"] {
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

/* PrimaryButton and SecondaryButton (kit.py .btn, .ghost): pills; one accent primary per screen (UX-002) */
[data-tool="trainer"] .button {
  border-radius: var(--radius-pill);
}

[data-tool="trainer"] .button--primary {
  min-height: var(--tx-button-min-height);
  padding-inline: var(--tx-button-padding-x);
  background: var(--tool-accent);
  color: var(--on-tool-accent);
  font-size: var(--tx-button-font-size);
  font-weight: 600;
}

[data-tool="trainer"] .button--secondary {
  min-height: var(--tx-secondary-min-height);
  border: var(--tx-secondary-border-width) solid var(--option-line);
  background: transparent;
  color: var(--ink);
  font-size: var(--tx-secondary-font-size);
  font-weight: 600;
}

[data-tool="trainer"] .action-bar .button--secondary {
  min-height: var(--tx-secondary-footer-min-height);
}

/* TextLink (kit.py .link): accent ink, underlined */
[data-tool="trainer"] .text-link {
  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);
}

/* A TextLink inside a card or a part body keeps its own width at the start of the line, as kit.py draws links */
[data-tool="trainer"] :is(.card, .part-body) .text-link {
  align-self: flex-start;
}

/* ActionBar (trainer_frame.py phone footer): stacked, primary first, under the body */
[data-tool="trainer"] .action-bar,
[data-tool="trainer"] .trainer-actions {
  gap: var(--space-sm);
  padding-top: var(--space-lg);
}

/* PlainCard (kit.py .panel.plain), a slot: ground, border, radius and padding only, so every notice shares one
   frame; the built notice lines take it without a markup change (FR-013) */
[data-tool="trainer"] .card--plain,
[data-tool="trainer"] .storage-notice,
[data-tool="trainer"] .no-mic__notice,
[data-tool="trainer"] .compare-missing,
[data-tool="trainer"] .trainer-failure > .instruction-line,
[data-tool="trainer"] .feedback-rows,
[data-tool="trainer"] .compare-row.card {
  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);
}

/* The notice lines (ux.md Error Presentation): ink text after the alert icon, drawn in --error */
[data-tool="trainer"] .storage-notice,
[data-tool="trainer"] .no-mic__notice,
[data-tool="trainer"] .compare-missing,
[data-tool="trainer"] .trainer-failure > .instruction-line {
  display: flex;
  align-items: flex-start;
  gap: var(--tx-notice-icon-gap);
  color: var(--ink);
}

[data-tool="trainer"] .storage-notice::before,
[data-tool="trainer"] .no-mic__notice::before,
[data-tool="trainer"] .compare-missing::before,
[data-tool="trainer"] .trainer-failure > .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;
}

/* PracticeCard (kit.py .card), a slot: a white card with a soft hairline in light; dark values in tokens.css */
[data-tool="trainer"] .card--panel {
  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);
}

/* Part type (KD-T16, KD-T17; kit.py .hero-en, .body): the one English sentence of a screen (the launch question)
   at TX_HERO_EN_SIZE, English in lists (shadow and frame sentences included, TEST-043 and the owner ruling of 18
   November 2026) at TX_EN_LIST_SIZE, both above every other size; the Ukrainian under it regular in --ink. Kept
   here, not in trainer-parts.css, whose trainer-rework type check (TEST-028) pins its three styles */
[data-tool="trainer"] .launch-drill__question {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--tx-hero-en-size);
  font-weight: 800;
  line-height: var(--tx-hero-en-line-height);
  letter-spacing: var(--tx-hero-en-tracking);
  overflow-wrap: anywhere;
}

[data-tool="trainer"] .phrase-card__en,
[data-tool="trainer"] .recall-row__en,
[data-tool="trainer"] .launch-drill__hint,
[data-tool="trainer"] .word-assembler__slots {
  font-family: var(--font-display);
  font-size: var(--tx-en-list-size);
  font-weight: 700;
  line-height: var(--tx-en-list-line-height);
  overflow-wrap: anywhere;
}

[data-tool="trainer"] :is(.phrase-card__uk, .launch-drill__uk,
  .word-assembler__uk, .phrase-chip__uk, .phrase-card__example) {
  color: var(--ink);
  font-size: var(--tx-uk-size);
  font-weight: 400;
  line-height: var(--tx-uk-line-height);
}

[data-tool="trainer"] .launch-drill__count {
  font-size: var(--tx-h2-size);
}

[data-tool="trainer"] .trainer-band .instruction-line {
  color: var(--ink-2);
  font-size: var(--tx-lead-size);
  line-height: var(--tx-lead-line-height);
}

/* SprintCard label at TX_LABEL (the rest of its rule in trainer-speaking.css) */
[data-tool="trainer"] .sprint-card__rescue-label {
  font-size: var(--tx-label-size);
}

/* SphereAvatar (kit.py .avatar): the goose round at TX_SPHERE_AVATAR_PX on the soft accent; a file that fails
   to load leaves the soft accent disc at its size (goose-missing) */
[data-tool="trainer"] .goose-avatar {
  display: block;
  flex: none;
  width: var(--tx-sphere-avatar-size);
  height: var(--tx-sphere-avatar-size);
  overflow: hidden;
  border-radius: 50%;
  background: var(--tool-accent-soft);
}

[data-tool="trainer"] .goose-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* LevelMark and SphereAvatar on the pick cards (kit.py .pick, stairs): at the start of the card on the phone, the
   words beside it; above the words on the desktop. The filled steps in the accent, the outline in the card's ink */
[data-tool="trainer"] .level-card,
[data-tool="trainer"] .sphere-chip {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: var(--tx-pick-gap-inner);
  row-gap: var(--space-2xs);
}

[data-tool="trainer"] .level-card > span,
[data-tool="trainer"] .sphere-chip > span {
  grid-column: 2;
}

[data-tool="trainer"] .level-card .level-mark {
  grid-row: 1 / span 3;
  width: var(--tx-level-mark-size);
  height: var(--tx-level-mark-size);
}

[data-tool="trainer"] .sphere-chip .goose-avatar {
  grid-row: 1 / span 2;
}

[data-tool="trainer"] .level-mark__step--on {
  fill: var(--tool-accent);
}

@media (min-width: 64rem) {
  [data-tool="trainer"] .level-card,
  [data-tool="trainer"] .sphere-chip {
    grid-template-columns: 1fr;
    align-content: start;
  }

  [data-tool="trainer"] .level-card > span,
  [data-tool="trainer"] .sphere-chip > span,
  [data-tool="trainer"] .level-card .level-mark,
  [data-tool="trainer"] .sphere-chip .goose-avatar {
    grid-row: auto;
    grid-column: 1;
  }
}

/* StepPills (contracts.md section 5): never on the phone; the desktop header row shows them (PILLS_SHOWN_ON) */
[data-tool="trainer"] .trainer-steps {
  display: none;
}

/* Desktop (trainer_frame.py desk; KD-T07, KD-T09, KD-T13): the header row across the page with the pills centred in
   it on step pages, where the menu leaves (display: none, so it leaves the Tab order too); the column below in
   TX_LAYOUT_PADDING at TX_MAIN_MAX_PX, TX_MAIN_WIDE_PX on compare, TX_STAGE_WIDTH_PX on the stage states, picked by
   :has() on the view; the stage centres its content TX_STAGE_GAP_PX apart; action bars in one row */
@media (min-width: 64rem) {
  [data-tool="trainer"] body {
    position: relative;
  }

  [data-tool="trainer"] body > .site-header {
    box-sizing: border-box;
    align-items: center;
    height: var(--tx-header-height);
    max-width: none;
    padding: 0 var(--tx-header-padding-x);
    border-bottom: var(--hairline-width) solid var(--tx-header-line);
  }

  [data-tool="trainer"] body > .site-header .wordmark {
    font-size: var(--tx-wordmark-size);
  }

  [data-tool="trainer"]:has(.trainer-steps:not([hidden])) .site-nav {
    display: none;
  }

  [data-tool="trainer"] .trainer-steps:not([hidden]) {
    position: absolute;
    top: 0;
    left: 50%;
    display: flex;
    align-items: center;
    height: var(--tx-header-height);
    transform: translateX(-50%);
  }

  [data-tool="trainer"] .trainer-steps__list {
    display: flex;
    gap: var(--tx-pill-gap);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* StepPills (kit.py .day): current its number on the accent, done a tick on the soft accent (the number stays in
     the text, at size 0), upcoming its number on --surface-muted; aria-current and the tick carry the state too */
  [data-tool="trainer"] .trainer-steps__mark {
    display: flex;
    align-items: center;
    justify-content: center;
    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;
  }

  [data-tool="trainer"] .trainer-steps__item[aria-current="step"] .trainer-steps__mark {
    background: var(--tool-accent);
    color: var(--on-tool-accent);
  }

  [data-tool="trainer"] .trainer-steps__item--done .trainer-steps__mark {
    background: var(--tool-accent-soft);
    color: var(--tool-accent-ink);
    font-size: 0;
  }

  [data-tool="trainer"] main.trainer-page {
    box-sizing: content-box;
    width: auto;
    max-width: var(--tx-main-max);
    margin-inline: auto;
  }

  [data-tool="trainer"] main.trainer-page:has(.compare-recordings) {
    max-width: var(--tx-main-wide);
  }

  [data-tool="trainer"] main.trainer-page:has(#trainer-view > :is(.trainer-week, .trainer-chooser)),
  [data-tool="trainer"] main.trainer-page:has(:is(.week-summary, .check-failed)) {
    max-width: var(--tx-stage-width);
  }

  [data-tool="trainer"] main:has(#trainer-view > :is(.trainer-week, .trainer-chooser)) #trainer-view > *,
  [data-tool="trainer"] main:has(:is(.week-summary, .check-failed)) #trainer-view > * {
    align-items: center;
    row-gap: var(--tx-stage-gap);
    text-align: center;
  }

  [data-tool="trainer"] main:has(#trainer-view > :is(.trainer-week, .trainer-chooser)) .action-bar,
  [data-tool="trainer"] main:has(:is(.week-summary, .check-failed)) .action-bar {
    justify-content: center;
    margin-top: 0;
  }

  [data-tool="trainer"] .trainer-chooser .action-bar {
    flex-direction: column;
  }

  [data-tool="trainer"] main:has(#trainer-view > :is(.trainer-week, .trainer-chooser)) .button--primary,
  [data-tool="trainer"] main:has(:is(.week-summary, .check-failed)) .button--primary {
    padding-inline: var(--tx-button-padding-x-stage);
  }

  [data-tool="trainer"] .action-bar,
  [data-tool="trainer"] .trainer-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
}

/* WaitDots (IMPL-016, kit.py .dots): WAIT_DOT_COUNT dots of TX_WAIT_DOT_SIZE_PX, TX_WAIT_DOT_GAP_PX apart, fading in
   turn over WAIT_DOTS_CYCLE_MS (each a third of the cycle later), opacity only; they take the colour they sit on */
[data-tool="trainer"] .wait-dots {
  display: inline-flex;
  align-items: center;
  gap: var(--tx-wait-dot-gap);
}

[data-tool="trainer"] .wait-dots__dot {
  width: var(--tx-wait-dot-size);
  height: var(--tx-wait-dot-size);
  border-radius: var(--radius-pill);
  background: currentColor;
  animation: tx-wait-dot-fade var(--tx-wait-dots-cycle) var(--ease-toggle) infinite;
}

[data-tool="trainer"] .wait-dots__dot:nth-child(2) {
  animation-delay: var(--tx-wait-dot-step);
}

[data-tool="trainer"] .wait-dots__dot:nth-child(3) {
  animation-delay: calc(2 * var(--tx-wait-dot-step));
}

@keyframes tx-wait-dot-fade {
  0%,
  100% {
    opacity: var(--tx-wait-dot-opacity-3);
  }

  33% {
    opacity: 1;
  }
}

/* GooseFigure (IMPL-017, ui.md; data-model.md Goose): a decorative picture drawn at the height its pose sets
   (TX_GOOSE_DRAWN_HEIGHTS) and the file's own ratio, never wider than 1.5 times that height (TX_GOOSE_DRAWN_RULE);
   the img's width and height attributes keep the box when the file fails, and the empty alt draws no broken mark */
[data-tool="trainer"] .goose {
  --goose-height: var(--tx-goose-week-height);
  display: block;
  flex: none;
  max-width: calc(var(--tx-goose-max-ratio) * var(--goose-height));
}

[data-tool="trainer"] .goose--ready {
  --goose-height: var(--tx-goose-ready-height);
}

[data-tool="trainer"] .goose--offline {
  --goose-height: var(--tx-goose-offline-height);
}

[data-tool="trainer"] .goose img {
  display: block;
  width: auto;
  max-width: 100%;
  height: var(--goose-height);
  object-fit: contain;
}

/* Reduced motion (IMPL-019, ui.md MotionName reduced): the dots stand still at WAIT_DOT_OPACITIES */
@media (prefers-reduced-motion: reduce) {
  [data-tool="trainer"] .wait-dots__dot {
    animation: none;
  }

  [data-tool="trainer"] .wait-dots__dot:nth-child(2) {
    opacity: var(--tx-wait-dot-opacity-2);
  }

  [data-tool="trainer"] .wait-dots__dot:nth-child(3) {
    opacity: var(--tx-wait-dot-opacity-3);
  }
}

/* Screens without a board (IMPL-020, FR-002, UX-004): the small line at TX_TINY_SIZE, the phrase labels and group
   titles at TX_LABEL, so every size comes from the --tx-* scale; TextField (settings transfer): the error message in
   --error after the alert icon (validation_error, ux.md Error Presentation) */
[data-tool="trainer"] .small-line {
  font-size: var(--tx-tiny-size);
  line-height: var(--tx-tiny-line-height);
}

[data-tool="trainer"] :is(.phrase-card__label, .phrase-group-title) {
  font-size: var(--tx-label-size);
  font-weight: 600;
  letter-spacing: var(--tx-label-tracking);
  text-transform: uppercase;
}

[data-tool="trainer"] .transfer-message[data-state="error"] {
  display: flex;
  align-items: flex-start;
  gap: var(--tx-notice-icon-gap);
}

[data-tool="trainer"] .transfer-message[data-state="error"]::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;
}

/* A heading focused on a screen change (tabindex="-1") is a reading position, not a control: no ring (IMPL-022) */
[data-tool="trainer"] [tabindex="-1"]:focus {
  outline: none;
}
