/*
 * Trainer record styles (trainer-redesign): the recorder and the compare players of /7-days. Every rule sits under
 * [data-tool="trainer"] (contracts.md section 1); every value comes from tokens.css (TOKEN_SCOPE_BLOCK).
 */

/* CompareRow players (TX14 _player): round plays of TX_PLAY_SIZE_PX; today's on the accent, the step 1 take (the
   first row) on --surface-muted with ink, as the board draws the earlier recording */
[data-tool="trainer"] .compare-row__play {
  width: var(--tx-play-size);
  height: var(--tx-play-size);
  border-radius: var(--radius-pill);
  background: var(--tool-accent);
  color: var(--on-tool-accent);
}

[data-tool="trainer"] .compare-row:first-child .compare-row__play {
  background: var(--surface-muted);
  color: var(--ink);
}

/* RecordControl and BusyDisc (IMPL-016; kit.py .mic, TX05, TX13): an accent disc of TX_RECORD_SIZE_PX with a 30 px
   glyph at its centre and a static TX_RECORD_RING_READY_PX ring (::before) behind it; while recording the ring
   pulses outward by transform and opacity only (TX_RECORD_PULSE_MS, to TX_RING_RECORDING_SCALE, reach
   TX_RECORD_RING_RECORDING_PX). The recorder isolates, so the ring paints over the card but under the disc. Leaving
   a state takes EXIT_MS on --ease-exit; each new state enters over STATE_CHANGE_MS on --ease-enter. */
[data-tool="trainer"] .recorder {
  isolation: isolate;
  animation: tx-state-enter var(--tx-state-duration) var(--ease-enter) both;
}

[data-tool="trainer"] .record-control,
[data-tool="trainer"] .record-disc {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--tx-record-size);
  height: var(--tx-record-size);
  margin: var(--tx-record-ring-reach);
  border-radius: var(--radius-pill);
  background: var(--tool-accent);
  color: var(--on-tool-accent);
}

[data-tool="trainer"] .record-control {
  transition: transform var(--tx-press-duration) var(--ease-toggle);
}

[data-tool="trainer"] .record-control:active {
  transform: scale(var(--tx-press-scale));
}

[data-tool="trainer"] .record-control__icon {
  width: var(--tx-record-glyph-size);
  height: var(--tx-record-glyph-size);
}

[data-tool="trainer"] .record-control::before,
[data-tool="trainer"] .record-disc::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: calc(-1 * var(--tx-record-ring-ready));
  border-radius: var(--radius-pill);
  background: var(--tx-record-ring-bg);
  transition:
    transform var(--tx-exit-duration) var(--ease-exit),
    opacity var(--tx-exit-duration) var(--ease-exit);
}

[data-tool="trainer"] .recorder[data-state="recording"] .record-control::before {
  animation: tx-record-ring-pulse var(--tx-record-pulse-duration) var(--ease-toggle) infinite;
}

/* RecorderTimer at TX_TIMER_SIZE with tabular figures, first in the column; the level bars (kit.py .levels, ten
   TX_LEVEL_BAR_WIDTH_PX bars TX_LEVEL_BAR_GAP_PX apart) drawn by the recorder's ::before between it and the disc:
   decoration only, the build has no level element (contracts.md section 6) */
[data-tool="trainer"] .recorder__timer {
  order: -1;
  color: var(--ink);
  font-size: var(--tx-timer-size);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

[data-tool="trainer"] .recorder[data-state="recording"]::before {
  --bar: linear-gradient(var(--tool-accent), var(--tool-accent));
  --pitch: calc(var(--tx-level-bar-width) + var(--tx-level-bar-gap));
  content: "";
  width: calc(10 * var(--tx-level-bar-width) + 9 * var(--tx-level-bar-gap));
  height: var(--tx-level-bars-height);
  background-image:
    var(--bar), var(--bar), var(--bar), var(--bar), var(--bar),
    var(--bar), var(--bar), var(--bar), var(--bar), var(--bar);
  background-repeat: no-repeat;
  background-size:
    var(--tx-level-bar-width) 10px, var(--tx-level-bar-width) 18px, var(--tx-level-bar-width) 26px,
    var(--tx-level-bar-width) 14px, var(--tx-level-bar-width) 22px, var(--tx-level-bar-width) 30px,
    var(--tx-level-bar-width) 16px, var(--tx-level-bar-width) 24px, var(--tx-level-bar-width) 12px,
    var(--tx-level-bar-width) 20px;
  background-position:
    0 50%, calc(1 * var(--pitch)) 50%, calc(2 * var(--pitch)) 50%, calc(3 * var(--pitch)) 50%,
    calc(4 * var(--pitch)) 50%, calc(5 * var(--pitch)) 50%, calc(6 * var(--pitch)) 50%,
    calc(7 * var(--pitch)) 50%, calc(8 * var(--pitch)) 50%, calc(9 * var(--pitch)) 50%;
}

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

@keyframes tx-record-ring-pulse {
  from {
    transform: scale(1);
    opacity: 1;
  }

  to {
    transform: scale(var(--tx-ring-recording-scale));
    opacity: var(--tx-record-pulse-opacity-end);
  }
}

@keyframes tx-state-enter {
  from {
    transform: translateY(var(--space-xs));
    opacity: 0;
  }

  to {
    transform: none;
    opacity: 1;
  }
}

/* Reduced motion (IMPL-019; ui.md MotionName reduced): the recording ring stands still at TX_RING_RECORDING_SCALE,
   shown by a one-shot fade (the TEST-048 guard wants an opacity-only replacement for the pulse); no press scale;
   the state enters by opacity within REDUCED_FADE_MS */
@media (prefers-reduced-motion: reduce) {
  [data-tool="trainer"] .recorder {
    animation: tx-fade-in var(--tx-reduced-fade) var(--ease-toggle) both;
  }

  [data-tool="trainer"] .recorder[data-state="recording"] .record-control::before {
    transform: scale(var(--tx-ring-recording-scale));
    animation: tx-fade-in var(--tx-reduced-fade) var(--ease-toggle) both;
  }

  [data-tool="trainer"] .record-control,
  [data-tool="trainer"] .record-control::before,
  [data-tool="trainer"] .record-disc::before {
    transition: opacity var(--tx-reduced-fade) var(--ease-toggle);
  }

  [data-tool="trainer"] .record-control:active {
    transform: none;
  }
}

@keyframes tx-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}
