/* trainer.css — the CV Punch Trainer HUD. Design tokens (colors, fonts) come from
   ../styles.css; this file lays out the stage + heads-up display. */

.trainer-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---- Top bar ---- */
.trainer-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px clamp(14px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.trainer-top .back {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  white-space: nowrap;
}
.trainer-top .back:hover { color: var(--text); }
.trainer-title {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; letter-spacing: -0.02em; font-size: 15px;
  margin-right: auto;
}
.trainer-title .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.trainer-title .beta {
  font-family: var(--mono); font-weight: 700; font-size: 10.5px;
  letter-spacing: 0.02em; text-transform: none; color: var(--muted-2);
  align-self: center;
}
.trainer-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* segmented control */
.seg {
  display: inline-flex; padding: 3px; gap: 3px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 7px; cursor: pointer;
}
.seg button.active { background: var(--text); color: var(--bg); }

/* ---- Main split ---- */
.trainer-main {
  flex: 1; display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px; align-items: start;
  padding: 18px clamp(14px, 4vw, 40px);
  max-width: 1400px; width: 100%; margin: 0 auto;
}
@media (max-width: 900px) {
  .trainer-main { grid-template-columns: 1fr; }
}

.stage-wrap { display: flex; flex-direction: column; gap: 10px; }

.stage {
  position: relative;
  aspect-ratio: 16 / 10;
  width: 100%;
  background: #06070b;
  border: 1px solid var(--line);
  border-radius: 16px; overflow: hidden;
}
/* Camera is shown mirrored (gym-mirror feel); overlay is mirrored to match in JS. */
.stage.mirror #video { transform: scaleX(-1); }
#video, #overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
#video { object-fit: contain; background: #000; }
#overlay { pointer-events: none; }

.stage-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 24px; text-align: center;
}
.stage-empty-inner { max-width: 460px; }
.stage-empty .glove { font-size: 46px; }
.stage-empty h2 { font-size: 22px; margin: 8px 0 8px; letter-spacing: -0.02em; }
.stage-empty p { color: var(--muted); font-size: 14.5px; line-height: 1.6; }
.stage-empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 18px 0 10px; }
.stage-empty .fineprint { font-size: 12px; color: var(--muted-2); margin-top: 10px; }

.live-chips {
  position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; flex-wrap: wrap;
}
.chip {
  font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  padding: 5px 9px; border-radius: 999px;
  background: rgba(6,10,14,0.72); border: 1px solid var(--line);
  color: var(--muted); backdrop-filter: blur(4px);
}
.chip.good { color: #fff; background: color-mix(in srgb, var(--good) 78%, #06120a); border-color: transparent; }
.chip.bad  { color: #fff; background: color-mix(in srgb, var(--critical) 80%, #120606); border-color: transparent; }

.score-flash {
  position: absolute; top: 12px; right: 12px;
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 16px; border-radius: 14px;
  background: rgba(6,10,14,0.66); border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  animation: pop 0.34s cubic-bezier(.2,.9,.3,1.3);
}
.score-flash .sf-type { font-family: var(--mono); font-weight: 700; font-size: 13px; letter-spacing: 0.06em; color: var(--muted); }
.score-flash .sf-score { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.status {
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  min-height: 18px; padding: 0 4px;
}
.status.rec { color: var(--accent); }

/* ---- HUD panels ---- */
.hud { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 15px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 700; }
.last-type {
  font-family: var(--mono); font-weight: 700; font-size: 12px; letter-spacing: 0.06em;
  color: var(--text); padding: 3px 8px; border-radius: 6px; background: var(--panel-2);
}

.ring-row { display: flex; gap: 14px; align-items: center; }
.ring { position: relative; width: 108px; height: 108px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .ring-bg { stroke: var(--panel-2); }
.ring .ring-fg {
  stroke: var(--muted); stroke-linecap: round;
  stroke-dasharray: 327; stroke-dashoffset: 327;
  transition: stroke-dashoffset 0.5s ease, stroke 0.5s ease;
}
.ring-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 30px; font-weight: 800; letter-spacing: -0.03em;
}
.dims { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.dim { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; align-items: center; }
.dim .dname { font-size: 11.5px; color: var(--muted); grid-column: 1; }
.dim .dval { font-family: var(--mono); font-size: 11.5px; font-weight: 700; grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.dim .bar { grid-column: 1; height: 5px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.dim .bar > span { display: block; height: 100%; width: 0; border-radius: 3px; transition: width 0.5s ease, background 0.5s ease; }
.dim.na .dname { opacity: 0.55; }
.dim.na .dval { color: var(--muted-2); }

.notes {
  margin-top: 13px; font-size: 13px; line-height: 1.55; color: var(--text-2);
  border-top: 1px dashed var(--line); padding-top: 11px;
}
.notes ul { margin: 0; padding-left: 18px; }
.notes li { margin: 3px 0; }
.notes .clean { color: var(--good); }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { background: var(--panel-2); border-radius: 10px; padding: 10px 8px; text-align: center; }
.tval { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.tlabel { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 3px; }

.feed { display: flex; flex-direction: column; gap: 6px; max-height: 230px; overflow-y: auto; }
.feed-empty { color: var(--muted-2); font-size: 13px; padding: 6px 2px; }
.feed-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center;
  padding: 7px 9px; border-radius: 9px; background: var(--panel-2);
  animation: slidein 0.28s ease;
}
@keyframes slidein { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
.feed-row .fr-type { font-family: var(--mono); font-weight: 700; font-size: 11px; letter-spacing: 0.05em; }
.feed-row .fr-meta { font-size: 11px; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-row .fr-score { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }

/* ---- Explainer ---- */
.explainer {
  max-width: 1100px; margin: 10px auto 60px; padding: 0 clamp(14px, 4vw, 40px);
}
.explainer > h2 { font-size: 22px; letter-spacing: -0.02em; margin-bottom: 18px; }
.explainer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 820px) { .explainer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .explainer-grid { grid-template-columns: 1fr; } }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 15px; }
.step-n {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: var(--bg);
  background: var(--text); margin-bottom: 9px;
}
.step h4 { font-size: 15px; margin-bottom: 5px; }
.step p { font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.credit { margin-top: 18px; font-size: 13.5px; color: var(--text-2); line-height: 1.6; }
.credit code { font-family: var(--mono); font-size: 0.9em; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.tips { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.tips summary { cursor: pointer; padding: 12px 15px; font-weight: 600; font-size: 14px; }
.tips[open] summary { border-bottom: 1px solid var(--line); }
.tips ul { margin: 0; padding: 12px 15px 14px 32px; color: var(--muted); font-size: 13px; line-height: 1.7; }

/* ---- Debug readout ---- */
.dbg-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none; }
.dbg-toggle input { accent-color: var(--text); }
.dbg {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  line-height: 1.7;
}
.dbg span { color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.04em; font-size: 10.5px; }
.dbg b.v { color: var(--text); font-weight: 700; }
.dbg b.v.hot { color: var(--good); }

/* ---- Buttons (trainer-scoped sizes) ---- */
.btn.lg { padding: 11px 18px; font-size: 14.5px; }
.btn.btn-tiny { padding: 4px 9px; font-size: 11px; }
.btn.recording { background: var(--critical); border-color: transparent; color: #fff; }
