/*
 * The trainer page /7-days (trainer-rework ui.md; boards TR01 to TR57, TR03a, TR10a; trainer-redesign boards
 * TX01 to TX21): the page, the band, the screens, focus and target rules. Every value comes from tokens.css (the
 * tool accent family and the --tx-* tokens; no step colour, KD-T04); no rule here branches on the colour scheme.
 * Part bodies live in trainer-parts.css. The keyframes stay at the end of the file, after every media query.
 */

.trainer-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
}

.lang-switch {
  display: inline-flex;
  gap: var(--tap-gap);
}

.lang-switch__code {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-small);
  font-weight: 700;
}

.trainer-view {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 0 var(--space-md) var(--space-screen-bottom);
}

.trainer-view > * {
  min-width: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-md);
}

.trainer-view > [hidden] {
  display: none;
}

.trainer-heading {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--tx-h1-size);
  font-weight: 800;
  line-height: var(--tx-h1-line-height);
  letter-spacing: var(--tx-heading-tracking);
  color: var(--ink);
}

/* Stage screens (data-model.md TX_LAYOUT_FOR stage) take the stage heading size */
.trainer-week .trainer-heading {
  font-size: var(--tx-h1-size-stage);
}

.instruction-line,
.session-line {
  margin: 0;
  font-size: var(--fs-body);
  line-height: 1.5;
}

.small-line {
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.45;
  color: var(--ink-2);
  text-align: center;
}

.text-link {
  min-height: var(--tap-min);
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.trainer-actions,
.action-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: auto;
  padding-top: var(--space-lg);
}

/* ActionBar sticks to the bottom safe area on the phone (ui.md, Responsive Adaptations) */
.trainer-part .action-bar,
.trainer-overview .action-bar {
  position: sticky;
  bottom: 0;
  z-index: 1;
  padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
  background: var(--bg);
}

.welcome-change-level {
  margin: 0;
  text-align: center;
}

/* Welcome (TR01, TR02): the arch, then the copy and the flow rows */
.trainer-welcome {
  padding-top: var(--space-md);
}

.week-arch {
  flex-direction: column;
  align-self: center;
  width: 190px;
  height: 170px;
  border-radius: var(--radius-arch);
  /* WeekArch (ui.md): the numeral in the accent ink on the soft accent */
  background: var(--tool-accent-soft);
}

.week-arch__numeral {
  font-family: var(--font-display);
  font-size: var(--fs-band);
  font-weight: 800;
  line-height: 1;
  color: var(--tool-accent-ink);
}

.week-arch__label {
  font-size: var(--fs-body);
  font-weight: 700;
  color: var(--ink-2);
}

.flow-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  grid-template-rows: auto auto;
  column-gap: var(--space-md);
  animation: trainer-flow-in var(--trainer-flow-row-duration) var(--ease-enter) both;
}

.flow-row:nth-child(1) {
  animation-delay: 0ms;
}

.flow-row:nth-child(2) {
  animation-delay: var(--trainer-flow-stagger);
}

.flow-row:nth-child(3) {
  animation-delay: calc(var(--trainer-flow-stagger) * 2);
}

.flow-row__disc {
  grid-row: span 2;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--tool-accent-soft);
  color: var(--tool-accent-ink);
}

.flow-row__label {
  padding-top: var(--space-2xs);
  font-weight: 700;
}

.flow-row__line {
  color: var(--ink-2);
}

/* Discs and rings: content centred */
.flow-row__disc,
.part-row__number,
.step-row__disc,
.week-counter__ring,
.week-arch {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Band of the overview and part screens (TX02 to TX05): no tint and no step colour (FR-004); the part bar on top,
   then the title */
.trainer-band {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin: 0;
  padding: 0;
  background: transparent;
}

/* The step label keeps its lower-case «з» (STEP_LABEL_RULE), so it is set as meta, not as an upper-case label */
.step-label {
  margin: 0;
  color: var(--tool-accent-ink);
  font-size: var(--tx-meta-size);
  font-weight: 600;
}

.step-numeral {
  position: absolute;
  top: 0;
  right: 0;
  font-family: var(--font-display);
  font-size: var(--fs-band);
  font-weight: 800;
  line-height: 1;
  color: var(--tool-accent);
  opacity: 0.16;
}

/* PartTitle (KD-T16): the part name is meta-sized, so the English stays the largest type */
.trainer-part .trainer-heading {
  font-family: var(--font-body);
  font-size: var(--tx-part-title-size);
  font-weight: var(--tx-part-title-weight);
  line-height: var(--tx-part-title-line-height);
  letter-spacing: 0;
}

/* The stage parts (week summary TX15, check failed TX18) keep a stage heading, as their boards draw it */
.trainer-part:has(:is(.week-summary, .check-failed)) .trainer-heading {
  font-family: var(--font-display);
  font-size: var(--tx-h1-size-stage);
  font-weight: 800;
  line-height: var(--tx-h1-line-height);
  letter-spacing: var(--tx-heading-tracking);
}

/* Part frame: the bar (meta label, TX_PART_SEGMENT segments done in the accent), the body slot, the action bar */
.part-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.part-bar__label {
  margin: 0;
  color: var(--ink);
  font-size: var(--tx-meta-size);
  font-weight: 600;
}

.part-bar__track {
  display: flex;
  gap: var(--tx-part-segment-gap);
}

.part-bar__segment {
  flex: 1;
  height: var(--tx-part-segment-height);
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
}

.part-bar__segment--done {
  background: var(--tool-accent);
}

/* PartBody, a slot: layout only */
.part-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Overview (TR10 and the other step overviews) */
.zone-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ZoneChip (KD-T18): every zone on the one trainer tint, told apart by its number and name, never by colour */
.zone-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-sm) var(--space-2xs) var(--space-2xs);
  border-radius: var(--radius-pill);
  background: var(--tool-tint);
  color: var(--ink);
  font-size: var(--fs-small);
  font-weight: 600;
}

.zone-chip::before {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tx-zone-badge-size);
  height: var(--tx-zone-badge-size);
  border-radius: var(--radius-pill);
  background: var(--tool-accent);
  color: var(--on-tool-accent);
  font-weight: 800;
}

.zone-chip--1::before {
  content: "1";
}

.zone-chip--2::before {
  content: "2";
}

.zone-chip--3::before {
  content: "3";
}

.part-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin: 0;
  padding: 0;
  list-style: none;
}

.part-row {
  display: grid;
  grid-template-columns: var(--tx-part-tile-size) 1fr auto;
  align-items: center;
  gap: var(--tx-step-row-gap);
  padding: var(--tx-step-row-gap) 0;
  border-bottom: 1px solid var(--surface-muted);
}

/* PartRow (kit.py .part .pic): the number on a soft accent tile */
.part-row__number {
  width: var(--tx-part-tile-size);
  height: var(--tx-part-tile-size);
  border-radius: var(--tx-part-tile-radius);
  background: var(--tool-accent-soft);
  color: var(--tool-accent-ink);
  font-weight: 700;
}

.part-row__minutes {
  font-size: var(--tx-tiny-size);
  color: var(--ink-2);
}

/* Loading (TR53) and the content failure */
.trainer-skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md);
}

.trainer-skeleton[hidden] {
  display: none;
}

.trainer-skeleton__block {
  height: 72px;
  border-radius: var(--radius-card);
  background: var(--surface-muted);
  animation: trainer-shimmer 1200ms var(--ease-toggle) infinite alternate;
}

.trainer-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.trainer-noscript {
  padding: var(--space-lg) var(--space-md);
}

@media (min-width: 64rem) {
  .trainer-part .action-bar,
  .trainer-overview .action-bar {
    position: static;
  }

  .trainer-view {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flow-row {
    animation-name: trainer-flow-fade;
    animation-duration: var(--tx-reduced-fade);
  }

  .trainer-skeleton__block {
    animation: none;
  }
}

@keyframes trainer-flow-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes trainer-flow-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes trainer-shimmer {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.6;
  }
}
