/* =====================================================================
   Athlitz theme — ANALYSIS
   Video stage, replay bar, results: score, key numbers, legends, shots,
   improvements, frames, coaching notes, vitals, 3D view, captured frame.
   ===================================================================== */

/* ---------- stage / player ---------- */
.stage { position: relative; margin-top: 20px; display: none; }
.stage video, .stage canvas { width: 100%; display: block; max-height: 50vh; object-fit: contain; }
.stage video { background: var(--panel); }
.stage canvas { position: absolute; top: 0; left: 0; pointer-events: none; }
.stage video::-webkit-media-controls { z-index: 4; }
.stage.compact { margin-top: 10px; }
.stage.compact video, .stage.compact canvas { max-height: 30vh; }
.stage.replaying video { outline: 2px solid var(--lime); outline-offset: -2px; }

.progress-outer { height: 6px; background: var(--line); margin-top: 12px; overflow: hidden; }
.progress-inner { height: 100%; width: 0%; background: var(--ink); transition: width 200ms linear; }

.playpad {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 76px; height: 76px; border-radius: 50%; z-index: 3;
  border: 0; background: var(--lime); color: var(--ink); font-size: 24px; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  transition: transform 160ms var(--ease-out);
}
.playpad.show { display: flex; }
.playpad:active { transform: translate(-50%, -50%) scale(.94); }

.replaybar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.replaybar .rlabel { font-family: var(--f-mono); font-size: 11.5px; text-transform: uppercase; margin-right: 6px; }

/* ---------- big score ---------- */
.bigscore {
  display: flex; align-items: flex-end; gap: 32px; flex-wrap: wrap; margin-top: 8px;
  padding: 24px 0; border-top: 1.5px solid var(--ink); border-bottom: 1px solid var(--line);
}
.bigscore .num {
  font-family: var(--f-display); font-weight: 500; font-size: clamp(96px, 20vw, 176px);
  line-height: .8; letter-spacing: -.07em; color: var(--ink);
}
.bigscore .grade {
  font-family: var(--f-mono); font-size: 12px; text-transform: uppercase; margin-top: 14px;
  display: inline-flex; align-items: center; gap: 8px;
}
.bigscore .grade:not(:empty)::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); }
.subscore { margin: 10px 0; }
.subscore .name { font-size: 13px; display: flex; justify-content: space-between; margin-bottom: 5px; }
.bar-outer { height: 6px; background: var(--line); overflow: hidden; }
.bar-inner { height: 100%; background: var(--ink); transform-origin: left; transition: width 500ms var(--ease-out); }
.savestate { font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; color: var(--muted); margin: 10px 0 0; min-height: 1em; }
.savestate.ok { color: var(--good); }

/* ---------- key numbers ---------- */
.scoreboard {
  margin-top: 8px; background: var(--panel); color: var(--cream);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.stat { padding: 18px 18px 16px; border-right: 1px solid rgba(243,242,238,.1); border-bottom: 1px solid rgba(243,242,238,.1); }
.stat .v { font-family: var(--f-display); font-weight: 500; font-size: clamp(36px, 7vw, 52px); line-height: .9; letter-spacing: -.05em; color: var(--cream); }
.stat .v.brass { color: var(--lime); }
.stat .l { font-family: var(--f-mono); font-size: 10.5px; text-transform: uppercase; color: rgba(243,242,238,.55); margin-top: 10px; }

/* ---------- legends ---------- */
.legend-card { background: var(--card); border: 1px solid var(--line); padding: 20px 22px; margin-top: -1px; }
.legend-card:first-child { margin-top: 14px; }
.legend-card.best { border: 1.5px solid var(--ink); position: relative; z-index: 1; }
.legend-name { font-family: var(--f-display); font-weight: 500; font-size: 30px; line-height: 1; letter-spacing: -.03em; text-transform: uppercase; }
.legend-sim {
  float: right; font-family: var(--f-mono); font-size: 13px; background: var(--lime); color: var(--ink);
  padding: 4px 10px; border-radius: 999px;
}
#legends.grouped .legend-card.best { border-width: 1px; border-color: var(--line); }
#legends.grouped .legend-card.best .legend-sim { background: var(--line); }
.hand-badge {
  display: inline-block; font-family: var(--f-mono); font-size: 10.5px; text-transform: uppercase;
  border: 1px solid var(--ink); border-radius: 999px; padding: 1px 8px; vertical-align: middle; margin-left: 8px;
}
.compare-row { display: grid; grid-template-columns: 1fr 72px 72px; gap: 8px; font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.compare-row.head { font-family: var(--f-mono); font-size: 10.5px; text-transform: uppercase; color: var(--muted); }
.guess-btn {
  margin-top: 14px; background: transparent; border: 1px dashed var(--ink); color: var(--ink);
  padding: 8px 14px; font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; cursor: pointer;
  transition: background-color 150ms ease, transform 160ms var(--ease-out);
}
.guess-btn:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { .guess-btn:hover { background: var(--lime); } }
.guess-box { margin-top: 10px; }
.guess-input { width: 60%; max-width: 260px; }
.guess-check {
  padding: 12px 16px; margin-left: 6px; border: 0; background: var(--ink); color: var(--lime);
  font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; cursor: pointer;
}
.guess-result { margin: 8px 0 0; font-size: 14px; font-weight: 500; }

/* ---------- detected shots ---------- */
.shot-card {
  background: var(--card); border: 1px solid var(--line); padding: 16px 20px; margin-top: -1px; cursor: pointer;
  transition: background-color 150ms ease;
}
.shot-card.sel { border: 1.5px solid var(--ink); background: var(--lime-soft); position: relative; z-index: 1; }
.shot-card .t { font-family: var(--f-display); font-weight: 500; font-size: 28px; letter-spacing: -.03em; text-transform: uppercase; line-height: 1.05; }
.shot-card .sc { float: right; font-family: var(--f-display); font-size: 36px; letter-spacing: -.05em; line-height: 1; }
.shot-card .conf { font-family: var(--f-mono); font-size: 10.5px; text-transform: uppercase; }
.shot-card .desc { font-size: 14px; margin: 6px 0 0; line-height: 1.5; }
.conf-high, .conf-user { color: var(--good); }
.conf-medium { color: var(--brass); }
.conf-low { color: var(--seam); }
.reclass { display: block; margin-top: 10px; font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; color: var(--muted); }
.reclass select { margin-left: 6px; padding: 5px 8px; width: auto; font-size: 12px; cursor: pointer; }
.tag-unsure { font-family: var(--f-mono); font-size: 10px; text-transform: uppercase; color: var(--seam); border: 1px solid var(--seam); border-radius: 999px; padding: 1px 7px; vertical-align: middle; }
.gate-row { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; flex-wrap: wrap; }
.gate-toggle { font-size: 13px; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.gate-hint { font-size: 12px; color: var(--seam); }
.note.certain { color: var(--good); font-weight: 500; }

/* ---------- improvements ---------- */
.improve { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--lime); padding: 16px 18px; margin-top: -1px; }
.improve:first-child { margin-top: 12px; }
.improve .area { font-family: var(--f-display); font-weight: 500; font-size: 24px; letter-spacing: -.03em; text-transform: uppercase; }
.improve .drill { font-size: 14px; }
.improve .drill strong { background: var(--lime-soft); padding: 0 3px; }
.fixfirst { margin-top: 20px; background: var(--panel); color: var(--cream); padding: 18px 22px; }
.fixfirst strong { font-family: var(--f-mono); font-size: 11.5px; text-transform: uppercase; color: var(--lime); font-weight: 500; }

/* ---------- best frame picker ---------- */
.frames { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.frame {
  border: 1px solid var(--line); overflow: hidden; background: var(--card);
  cursor: pointer; padding: 0; text-align: left; font: inherit; color: var(--ink);
  transition: transform 200ms var(--ease-out), border-color 150ms ease;
}
.frame:active { transform: scale(.98); }
.frame img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; background: var(--panel); filter: grayscale(.35); transition: filter 200ms ease; }
.frame .fl {
  display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 8px 10px;
  font-family: var(--f-mono); font-size: 11px; text-transform: uppercase;
}
.frame .fl span:last-child { color: var(--muted); }
.frame.sel { border: 1.5px solid var(--ink); }
.frame.sel img { filter: none; }
.frame.sel .fl { background: var(--lime); }
.frame.sel .fl span:last-child { color: var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .frame:hover { transform: translateY(-3px); border-color: var(--ink); }
  .frame:hover img { filter: none; }
}

/* ---------- coaching notes ---------- */
.cnotes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 12px; }
.cnote { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--lime); padding: 12px 14px; }
.cnote.good { border-left-color: var(--good); }
.cnote.bad { border-left-color: var(--seam); }
.cnote .cn-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; }
.cnote .cn-h strong { font-family: var(--f-display); font-weight: 500; font-size: 26px; letter-spacing: -.04em; color: var(--ink); }
.cnote .cn-t { font-size: 12px; color: var(--muted); margin-top: 3px; }
.cnote.good .cn-t { color: var(--good); font-weight: 500; }
.cnote.bad .cn-t { color: var(--seam); font-weight: 500; }
.cnote .cn-f { font-size: 13px; margin-top: 6px; line-height: 1.45; }

/* ---------- vitals (yoga / racket results) ---------- */
.vitals { margin-top: 12px; background: var(--panel); overflow: hidden; display: flex; flex-direction: column; }
.vital-row { display: grid; grid-template-columns: 1.3fr .9fr 1fr 1.2fr; gap: 8px; align-items: center; padding: 13px 18px; font-size: 13px; border-bottom: 1px solid rgba(243,242,238,.08); }
.vital-head { font-family: var(--f-mono); font-size: 10.5px; text-transform: uppercase; color: var(--lime); background: transparent !important; padding-bottom: 9px; }
.vital-name { color: var(--cream); font-weight: 500; }
.vital-val { color: var(--cream); font-family: var(--f-display); font-size: 20px; letter-spacing: -.03em; }
.vital-target { color: rgba(243,242,238,.55); }
.vital-dev-ok { color: var(--lime); font-weight: 500; }
.vital-dev-warn { color: #E9C46A; font-weight: 500; }
.vital-dev-bad { color: #F08A73; font-weight: 500; }

/* ---------- 3D pose viewer ---------- */
#pose3d.hidden { display: none; }
.p3d-wrap { display: grid; grid-template-columns: 1fr 240px; gap: 14px; align-items: start; }
.p3d-canvas { background: var(--panel); overflow: hidden; min-height: 260px; cursor: grab; }
.p3d-canvas:active { cursor: grabbing; }
.p3d-canvas canvas { display: block; width: 100%; height: 100%; }
.p3d-side { display: flex; flex-direction: column; gap: 10px; }
.p3d-metrics { background: var(--card); border: 1.5px solid var(--ink); padding: 4px 14px; }
.p3d-metrics.weak { border-color: var(--seam); }
.p3d-m { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.p3d-m:last-child { border-bottom: 0; }
.p3d-m span { font-family: var(--f-mono); font-size: 10.5px; text-transform: uppercase; color: var(--muted); }
.p3d-m strong { font-family: var(--f-display); font-weight: 500; font-size: 24px; letter-spacing: -.03em; }
.p3d-conf span, .p3d-conf strong { color: var(--muted); }
.p3d-metrics.weak .p3d-conf strong { color: var(--seam); }
.p3d-caveat { font-size: 11.5px; line-height: 1.5; color: var(--muted); margin: 0; }
.p3d-transport { align-items: center; }
.p3d-scrub { flex: 1; min-width: 140px; accent-color: var(--ink); height: 26px; }

/* ---------- captured frame ---------- */
#freeze.hidden { display: none; }
.freeze-wrap { display: grid; grid-template-columns: 320px 1fr; gap: 24px; align-items: start; }
.freeze-photo { overflow: hidden; background: var(--panel); min-height: 160px; }
.freeze-panel { min-width: 0; }
.freeze-h { font-family: var(--f-mono); font-weight: 400; font-size: 12px; text-transform: uppercase; margin: 0 0 12px; }
.freeze-score { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.freeze-score .fs-num { font-family: var(--f-display); font-size: 92px; line-height: .8; letter-spacing: -.06em; color: var(--ink); }
.freeze-score .fs-grade { font-family: var(--f-mono); font-size: 12px; text-transform: uppercase; }
table.vitals { width: 100%; border-collapse: collapse; font-size: 14px; color: var(--ink); background: transparent; display: table; }
table.vitals th { text-align: left; font-family: var(--f-mono); font-weight: 400; font-size: 10.5px; text-transform: uppercase; color: var(--muted); border-bottom: 1.5px solid var(--ink); padding: 8px; }
table.vitals td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
table.vitals tr.off td:first-child { box-shadow: inset 3px 0 0 var(--seam); }
ul.freeze-tips { margin: 8px 0 0; padding-left: 18px; font-size: 14px; line-height: 1.6; }
ul.freeze-tips li.major { color: var(--seam); font-weight: 500; }
.freeze-note { margin: 14px 0 0; border-left: 2px solid var(--lime); padding-left: 10px; }

.nextrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 40px; }

@media (max-width: 720px) {
  .stage video, .stage canvas { max-height: 44vh; }
  .stage.compact video, .stage.compact canvas { max-height: 26vh; }
  .p3d-wrap, .freeze-wrap { grid-template-columns: 1fr; }
  .p3d-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  table.vitals { font-size: 13px; }
  table.vitals td, table.vitals th { padding: 7px 5px; }
  .vital-row { padding: 11px 12px; font-size: 12px; }
}
@media (max-width: 560px) {
  .frames { grid-template-columns: repeat(2, 1fr); }
  .compare-row { grid-template-columns: 1fr 56px 56px; font-size: 12px; }
  .bigscore { gap: 18px; }
}

/* ---------- compared with your last scan ---------- */
.compare-card { border: 1.5px solid var(--ink); background: var(--card); padding: 16px 18px; margin: 4px 0 18px; }
.cmp-h { font-family: var(--f-display); font-size: 17px; font-weight: 600; margin: 0 0 10px; letter-spacing: -.01em; }
.cmp-when { font-family: var(--f-mono); font-size: 11px; font-weight: 400; color: var(--muted); text-transform: uppercase; margin-left: 6px; white-space: nowrap; }
.cmp-total { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-family: var(--f-display); }
.cmp-prev { font-size: 28px; color: var(--muted); }
.cmp-arrow { font-size: 20px; color: var(--muted); }
.cmp-now { font-size: 44px; font-weight: 500; letter-spacing: -.04em; line-height: 1; }
.cmp-d { font-family: var(--f-mono); font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(17,17,17,.06); color: var(--muted); white-space: nowrap; }
.cmp-total .cmp-d { font-size: 14px; }
.cmp-d.up { background: var(--lime); color: var(--ink); }
.cmp-d.down { background: rgba(214,69,50,.12); color: var(--seam); }
.cmp-sum { font-size: 13.5px; margin: 10px 0 0; line-height: 1.5; }
.cmp-rows { margin-top: 12px; border-top: 1px solid var(--line); }
.cmp-row { display: grid; grid-template-columns: 1fr 48px 48px 78px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.cmp-row span:nth-child(2), .cmp-row span:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
.cmp-row span:nth-child(2) { color: var(--muted); }
.cmp-row span:last-child { justify-self: end; }
.cmp-row.head { font-family: var(--f-mono); font-size: 10.5px; text-transform: uppercase; color: var(--muted); padding: 6px 0; }
.cmp-pb { margin-top: 12px; background: var(--ink); color: var(--lime); padding: 10px 12px; font-weight: 600; font-size: 14px; }
