/* 🏋 TRAINING RUNS (js/training.js, 2026-09-15): the plan editor and the
   results sheet on #training-screen, the run card beside the board
   (#training-panel, the Excalibur run card's shape), the step's result flashed
   over the next run's start (#training-flash) and the card between passes
   (#training-pass). Loads after excalibur.css and shares nothing with it but
   the look. */

/* ------------------------------------------------------------ the screen */
.tr-panel { max-width: 760px; }
.tr-lead b { color: #fff; }
.tr-lead .tr-est { display: block; margin-top: 4px; color: rgba(255, 255, 255, .55); font-size: 12px; }
.tr-warn { margin: 8px auto; max-width: 560px; font-size: 12.5px; color: #ffd28a; line-height: 1.45; }
/* the presets and the copy-from list: chips in a row, the one the plan IS lit */
.tr-presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; margin: 10px 0 4px; }
.tr-chip {
  font: inherit; font-size: 12.5px; font-weight: 700; color: #cfd8e3; padding: 6px 12px; cursor: pointer;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .05);
}
.tr-chip:hover { border-color: rgba(255, 255, 255, .45); }
.tr-chip.on { border-color: rgba(52, 211, 255, .6); background: rgba(52, 211, 255, .14); color: #fff; }
.tr-chip:disabled { opacity: .45; cursor: default; }
.tr-copy { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: rgba(255, 255, 255, .7); }
.tr-copy select, .tr-pass select, .tr-step select {
  font: inherit; font-size: 12.5px; color: #fff; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 8px; padding: 4px 8px; max-width: 220px;
}
.tr-copy select option, .tr-pass select option, .tr-step select option { color: #000; }
.tr-saved { font-size: 11.5px; color: rgba(255, 255, 255, .5); text-align: center; margin: 2px 0 8px; min-height: 14px; }
.tr-saved b { color: #8ff0a4; font-weight: 700; }
/* the passes */
.tr-passes { display: flex; flex-direction: column; gap: 10px; margin: 6px 0; text-align: left; }
.tr-pass { border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px; background: rgba(0, 0, 0, .22); padding: 10px 12px; }
.tr-pass-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.tr-pass-head .tr-ph { font-size: 11px; font-weight: 900; letter-spacing: 2px; color: var(--gold); }
.tr-pass-head .tr-pwho { flex: 1; font-size: 12.5px; color: #cfd8e3; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tr-pass-head .tr-pwho small { color: rgba(255, 255, 255, .5); }
.tr-x {
  flex: none; font: inherit; font-size: 12px; color: rgba(255, 255, 255, .55); background: none; border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 7px; padding: 2px 8px; cursor: pointer;
}
.tr-x:hover { color: #ffb454; border-color: #ffb454; }
.tr-x:disabled { opacity: .3; cursor: default; }
.tr-steps { display: flex; flex-direction: column; gap: 4px; }
.tr-step { display: grid; grid-template-columns: 22px auto auto auto 1fr auto; align-items: center; gap: 8px; padding: 3px 0; font-size: 12.5px; }
.tr-step .tr-n { color: rgba(255, 255, 255, .45); font-variant-numeric: tabular-nums; font-weight: 800; }
.tr-step .ex-seg button { padding: 4px 10px; font-size: 12px; }
.tr-step .tr-tempo.off { visibility: hidden; }
.tr-step .tr-bpm { font-size: 11px; color: rgba(255, 255, 255, .45); white-space: nowrap; }
.tr-step .tr-ops { display: inline-flex; gap: 4px; }
.tr-add { font: inherit; font-size: 12px; color: var(--cyan); background: none; border: 0; cursor: pointer; padding: 4px 0; text-decoration: underline; text-align: left; }
.tr-add:disabled { color: rgba(255, 255, 255, .35); text-decoration: none; cursor: default; }
.tr-addpass { display: block; margin: 6px auto 2px; text-align: center; }
.tr-est-line { font-size: 11.5px; color: rgba(255, 255, 255, .5); margin-top: 6px; }
/* the options and the start */
.tr-opts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 10px 0 4px; }
#tr-start { margin-top: 8px; }
#tr-start:disabled { opacity: .45; cursor: default; }
/* past runs */
.tr-hist { margin: 14px 0 6px; padding: 10px 12px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 10px; background: rgba(0, 0, 0, .22); font-size: 12.5px; text-align: left; }
.tr-hist .ex-sum-h { font-size: 10.5px; font-weight: 900; letter-spacing: 2px; color: #8ff0a4; margin-bottom: 4px; }
.tr-hist table { width: 100%; border-collapse: collapse; }
.tr-hist td { padding: 4px 6px; border-top: 1px solid rgba(255, 255, 255, .08); vertical-align: middle; }
.tr-hist tr:first-child td { border-top: 0; }
.tr-hist .tr-when { color: #9aa6b5; white-space: nowrap; font-size: 12px; }
.tr-hist .tr-how { color: #cfd8e3; }
.tr-hist .tr-how small { display: block; color: #9aa6b5; font-size: 11.5px; }
.tr-hist .rp-btn { min-width: 34px; }
/* the results sheet */
.tr-results .tr-sum { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0 10px; }
.tr-sum-pass { padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .16); font-size: 12.5px; text-align: left; min-width: 150px; }
.tr-sum-pass small { display: block; font-size: 10.5px; letter-spacing: 2px; font-weight: 900; color: var(--gold); margin-bottom: 3px; }
.tr-sum-pass b { color: #fff; }
.tr-sum-pass .tr-strug { color: #ffb454; }
.tr-sum-pass .tr-left { color: rgba(255, 255, 255, .5); }
.tr-sheet-wrap { overflow-x: auto; margin: 6px -4px; }
.tr-sheet { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.tr-sheet th { font-size: 10.5px; font-weight: 900; letter-spacing: 1.5px; color: rgba(255, 255, 255, .5); padding: 6px 8px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, .18); white-space: nowrap; }
.tr-sheet td { padding: 6px 8px; border-top: 1px solid rgba(255, 255, 255, .08); vertical-align: top; text-align: left; }
.tr-sheet td.tr-phrase { white-space: nowrap; color: #fff; font-weight: 700; }
.tr-sheet td.tr-phrase small { display: block; color: rgba(255, 255, 255, .5); font-weight: 500; }
.tr-sheet td.na { color: rgba(255, 255, 255, .3); font-style: italic; }
.tr-sheet td.strug { background: rgba(255, 180, 84, .08); }
.tr-sheet .tr-fig { display: block; white-space: nowrap; }
.tr-sheet .tr-score { display: block; color: rgba(255, 255, 255, .5); font-size: 11px; }
.tr-sheet .tr-score b { color: #fff; }
.tr-sheet .tr-mark { color: #ffb454; font-weight: 800; }
.tr-sheet .tr-mark.ok { color: #8ff0a4; }
.tr-sheet .tr-runs { display: block; color: rgba(255, 255, 255, .45); font-size: 11px; }
.tr-sheet .tr-runs .rp-btn { min-width: 26px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.tr-res-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0 4px; }
.tr-note { font-size: 12px; color: rgba(255, 255, 255, .55); max-width: 560px; margin: 8px auto 0; line-height: 1.45; }

/* --------------------------------------------- the run card beside the board */
#training-panel {
  position: fixed; right: 14px; top: 128px; z-index: 40; width: 232px;
  display: flex; flex-direction: column; gap: 8px; box-sizing: border-box;
  background: rgba(8, 10, 22, 0.85); border: 1px solid rgba(215, 224, 234, 0.3);
  border-radius: 14px; padding: 12px; font-size: 12.5px; color: #d7e0ea;
  text-align: left;
}
body.sheet-on #training-panel { top: calc(var(--sheet-h, 164px) + 76px); }
#training-panel .sp-head { font-weight: 900; letter-spacing: 2px; font-size: 12px; color: var(--gold); }
#training-panel .lp-stage { color: var(--cyan); }
#training-panel .ex-lvchip .ex-lvn { font-size: 19px; }
#training-panel .tr-steps { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; }
#training-panel .tr-steps span { color: rgba(255, 255, 255, .5); }
#training-panel .tr-steps span.done { color: #8ff0a4; }
#training-panel .tr-steps span.now { color: #fff; font-weight: 800; }
#training-panel .tr-last { color: #cfd8e3; opacity: .9; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 6px; }
@media (max-width: 760px) { #training-panel { display: none; } }

/* --------------------------------------------------------------- the flash */
#training-flash {
  position: fixed; inset: 0; z-index: 55; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: transparent; transition: background .25s;
}
#training-flash.scrim { background: rgba(6, 8, 18, 0.9); }
#training-flash .ex-loading { color: #d7e0ea; font-size: 15px; font-weight: 700; letter-spacing: 1px; text-align: center; padding: 10px 22px; border-radius: 12px; background: rgba(8, 10, 22, .8); border: 1px solid rgba(215, 224, 234, .25); }
#training-flash .ex-loading.hidden { display: none; }
#training-flash .ex-loading small { display: block; margin-top: 4px; font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, .55); letter-spacing: 0; }
#training-flash .tr-fl-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 22px 34px; border-radius: 22px; background: rgba(8, 10, 22, .9);
  border: 1px solid rgba(215, 224, 234, .3); box-shadow: 0 18px 60px rgba(0, 0, 0, .55);
  opacity: 0; transform: scale(1.15) translateY(8px); transition: opacity .3s, transform .3s;
}
#training-flash.show .tr-fl-card { opacity: 1; transform: none; }
#training-flash.fade .tr-fl-card { opacity: 0; transform: scale(.96) translateY(-6px); transition: opacity .5s, transform .5s; }
#training-flash .lf-passed { font-size: clamp(22px, 3.6vw, 34px); }
#training-flash .lf-passed.tr-miss { color: #ffb454; }
#training-flash .tr-fl-line { font-size: 15px; color: #cfd8e3; font-variant-numeric: tabular-nums; max-width: 640px; line-height: 1.5; }
#training-flash .tr-fl-line b { color: #fff; }
#training-flash .tr-fl-next { font-size: 13px; color: var(--cyan); font-weight: 700; letter-spacing: .5px; }
#training-flash .tr-fl-next.hidden { display: none; }

/* -------------------------------------------------- the card between passes */
#training-pass { z-index: 56; }
.tr-pass-panel { max-width: 640px; }
.tr-pass-body { text-align: left; font-size: 13px; color: #d7e0ea; line-height: 1.5; }
.tr-pass-body .tr-pass-lead { margin-bottom: 8px; }
.tr-pass-body .tr-pass-lead b { color: #fff; }
.tr-rank { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; margin: 6px 0 10px; }
.tr-rank th { font-size: 10.5px; font-weight: 900; letter-spacing: 1.5px; color: rgba(255, 255, 255, .5); padding: 4px 8px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, .18); }
.tr-rank td { padding: 4px 8px; border-top: 1px solid rgba(255, 255, 255, .08); white-space: nowrap; }
.tr-rank tr.strug td { background: rgba(255, 180, 84, .08); }
.tr-rank td.tr-rk { color: rgba(255, 255, 255, .5); }
.tr-rank td.tr-sc b { color: #fff; }
.tr-rank td.tr-mark { color: #ffb454; font-weight: 800; }
.tr-rank tr:not(.strug) td.tr-mark { color: #8ff0a4; }
.tr-pass-next { margin: 6px 0 4px; color: #fff; }
.tr-pass-next small { display: block; color: rgba(255, 255, 255, .55); font-size: 12px; }
.tr-pass-actions { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 12px; }
@media (max-width: 560px) {
  .tr-step { grid-template-columns: 18px auto auto 1fr; }
  .tr-step .tr-bpm { display: none; }
  .tr-step .tr-ops { grid-column: 1 / -1; justify-content: flex-end; }
}
