/* ==========================================================================
   Motion Analysis Lab — style.css
   Serious "lab" colors first, then the reveal colors.
   Canvas effect colors (pink background, ears, blush) are in CONFIG.look (app.js).
   ========================================================================== */
:root {
  /* Phase 1–2 · lab */
  --lab-bg: #090e0d;
  --lab-panel: #0f1716;
  --lab-line: rgba(140, 255, 225, .14);
  --lab-text: #d6ece6;
  --lab-dim: #7f9a93;
  --lab-accent: #2fd9b9;
  --lab-warn: #ffb547;
  --lab-info: #9fd3ff;
  --rec: #ff4d5e;
  /* Phase 3 · complete + processing */
  --teal-black: #03211d;
  --teal: #2fd9b9;
  --purple-deep: #2a0a5e;
  --purple: #6a1bd1;
  /* Phase 4 · reveal */
  --pink: #ff2fd0;
  --magenta-dark: #a8086e;
  --blue-light: #b9e3ff;
  --ink: #1d1a22;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  overflow: hidden;
  background: var(--lab-bg);
  color: var(--lab-text);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); }
#app { position: relative; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden; }

/* Screens are stacked; only the active one is visible.
   (Opacity, not display:none, so the <video> elements keep playing.) */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; z-index: 1;
  transition: opacity .35s ease;
}
.screen.is-active { opacity: 1; pointer-events: auto; z-index: 2; }

/* ===================== Phase 1–2 · LAB ===================== */
.screen--lab {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "preview" "side";
  align-items: stretch;
  justify-content: stretch;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  background: var(--lab-bg);
}
/* Laptop / desktop: big preview on the left, instructions on the right */
@media (min-width: 860px) and (min-aspect-ratio: 1/1) {
  .screen--lab {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "top top" "preview side";
    gap: 16px;
    padding: 20px;
  }
}

.topbar {
  grid-area: top;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 10.5px; letter-spacing: .16em; color: var(--lab-dim);
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--lab-text); }
.brand::before { content: ""; width: 8px; height: 8px; border: 1px solid var(--lab-accent); }
.topbar__right { display: flex; align-items: center; gap: 14px; }
.rec-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--lab-text); }
.rec-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--rec); animation: blink 1.2s infinite; }
.rec-chip.is-paused { opacity: .45; }
.rec-chip.is-paused i { animation: none; }

.preview {
  grid-area: preview;
  position: relative; min-height: 0; overflow: hidden;
  border: 1px solid var(--lab-line); border-radius: 14px;
  background: #050807;
}
.preview video, .preview canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.preview video { object-fit: cover; transform: scaleX(-1); }
.preview__empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11px; letter-spacing: .22em; color: var(--lab-dim);
}
.preview.has-video .preview__empty { display: none; }
.brackets {
  position: absolute; inset: 14px; pointer-events: none;
  --c: rgba(47, 217, 185, .55); --l: 22px; --t: 1.5px;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) var(--t),
    linear-gradient(var(--c), var(--c)) top left / var(--t) var(--l),
    linear-gradient(var(--c), var(--c)) top right / var(--l) var(--t),
    linear-gradient(var(--c), var(--c)) top right / var(--t) var(--l),
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--t),
    linear-gradient(var(--c), var(--c)) bottom left / var(--t) var(--l),
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--t),
    linear-gradient(var(--c), var(--c)) bottom right / var(--t) var(--l);
  background-repeat: no-repeat;
}
.scan {
  position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(47, 217, 185, .85), transparent);
  box-shadow: 0 0 14px rgba(47, 217, 185, .55);
  opacity: 0; pointer-events: none;
}
.preview.is-scanning .scan { opacity: 1; animation: scan 2.4s linear infinite; }

.chip {
  position: absolute;
  display: inline-flex; align-items: center; gap: 6px;
  max-width: calc(50% - 20px);
  padding: 4px 8px; border-radius: 6px;
  font-size: 10px; letter-spacing: .14em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--lab-dim);
  background: rgba(5, 10, 9, .62);
  border: 1px solid var(--lab-line);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.chip::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip--tl { top: 12px; left: 12px; }
.chip--tr { top: 12px; right: 12px; }
.chip--warn { bottom: 12px; right: 12px; max-width: calc(100% - 24px); }
.chip[data-tone="ok"] { color: var(--lab-accent); }
.chip[data-tone="warn"] { color: var(--lab-warn); }
.chip[data-tone="info"] { color: var(--lab-info); }
.metrics { position: absolute; left: 12px; bottom: 12px; font-size: 10px; letter-spacing: .12em; color: var(--lab-dim); }
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: clamp(64px, 14vmin, 150px); font-weight: 200;
  color: rgba(230, 255, 248, .92);
  text-shadow: 0 0 30px rgba(0, 0, 0, .55);
  pointer-events: none;
}

.side { grid-area: side; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.steps { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.steps span { height: 3px; border-radius: 2px; background: var(--lab-line); transition: background .3s; }
.steps span.active { background: rgba(47, 217, 185, .45); }
.steps span.done { background: var(--lab-accent); }

.card { padding: 14px; border: 1px solid var(--lab-line); border-radius: 14px; background: var(--lab-panel); }
.kicker { margin: 0 0 4px; font-size: 10px; letter-spacing: .18em; color: var(--lab-dim); }
.intro h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.intro p { margin: 0 0 14px; font-size: 13px; line-height: 1.5; color: #b5cbc5; }
.btn-lab {
  appearance: none; width: 100%;
  padding: 12px 16px; border-radius: 10px;
  border: 1px solid rgba(47, 217, 185, .6);
  background: rgba(47, 217, 185, .12);
  color: #c9fff4;
  font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer; transition: background .2s, opacity .2s;
}
.btn-lab:hover:not(:disabled) { background: rgba(47, 217, 185, .2); }
.btn-lab:disabled { opacity: .45; cursor: default; }

.panel { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.panel__icon { position: relative; width: 64px; height: 64px; }
.panel__icon svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 2; }
.ring__bg { stroke: var(--lab-line); }
.ring__fg { stroke: var(--lab-accent); stroke-linecap: round; stroke-dasharray: 188.5; stroke-dashoffset: 188.5; }
.glyph {
  padding: 13px; color: #cfe9e2;
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.panel__text h2 { margin: 0 0 4px; font-size: 12.5px; font-weight: 600; letter-spacing: .1em; }
.panel__instr { margin: 0; font-size: 14px; line-height: 1.4; color: #e3f3ef; }
.panel__timer { min-width: 42px; text-align: right; font-size: 14px; color: var(--lab-accent); }

.lab-error {
  margin: 0; padding: 8px 12px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.4;
  color: #ffd2a1; background: rgba(255, 181, 71, .08); border: 1px solid rgba(255, 181, 71, .35);
}
.bar { height: 2px; overflow: hidden; border-radius: 2px; background: var(--lab-line); }
.bar span { display: block; width: 0; height: 100%; background: var(--lab-accent); transition: width .2s linear; }
.bar-label { margin: 0; font-size: 10px; letter-spacing: .16em; color: var(--lab-dim); }
.privacy { margin: 0; font-size: 11px; color: var(--lab-dim); }
.privacy::before { content: "🔒 "; }

/* ===================== Phase 3a · COMPLETE ===================== */
.screen--complete {
  gap: 16px; color: #c9fff4;
  background: radial-gradient(circle at 50% 45%, #0a3a33 0%, var(--teal-black) 65%);
}
.check { width: 56px; height: 56px; }
.check circle { fill: none; stroke: var(--teal); stroke-width: 2; stroke-dasharray: 151; stroke-dashoffset: 151; }
.check path {
  fill: none; stroke: var(--teal); stroke-width: 2.6;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
}
.screen--complete.is-active .check circle { animation: draw .6s ease forwards; }
.screen--complete.is-active .check path { animation: draw .35s .5s ease forwards; }
.label { margin: 0; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; }

/* ===================== Phase 3b · PROCESSING ===================== */
.screen--processing {
  gap: 14px; color: #f1e6ff;
  background: radial-gradient(circle at 50% 45%, var(--purple) 0%, #4a1399 35%, var(--purple-deep) 80%);
}
.progress {
  width: min(62%, 300px); height: 6px; overflow: hidden; border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.progress span {
  display: block; width: 0%; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #ff4fd8, #b04dff 60%, #7b3cff);
  transition: width .2s linear;
}
.status { margin: 0; padding: 0 20px; font-size: 10.5px; letter-spacing: .16em; text-align: center; text-transform: uppercase; opacity: .85; }
.privacy--dark { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); color: rgba(241, 230, 255, .6); }

/* ===================== Phase 4 · REVEAL ===================== */
.screen--reveal { background: var(--pink); }
.play-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; } /* hidden under the canvas */
#stage { position: absolute; inset: 0; z-index: 1; display: block; width: 100%; height: 100%; }
.controls {
  position: absolute; z-index: 2;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.pill {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 12px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .28);
  font: 600 11px/1 var(--ui); letter-spacing: .01em;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform .12s, opacity .2s, background .2s;
}
.pill:active:not(:disabled) { transform: scale(.96); }
.pill--pink { background: var(--magenta-dark); color: #ffe6f6; box-shadow: 0 2px 8px rgba(90, 0, 60, .25); }
.pill--blue { background: var(--blue-light); color: #0d3550; border-color: rgba(13, 53, 80, .18); box-shadow: 0 2px 8px rgba(0, 40, 80, .18); }
/* While the clip renders, the disabled button fills up like a progress bar */
.pill--blue:disabled {
  background: linear-gradient(90deg, rgba(185, 227, 255, .85) var(--p, 0%), rgba(185, 227, 255, .35) var(--p, 0%));
  color: rgba(13, 53, 80, .55); box-shadow: none; cursor: not-allowed;
}

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes blink { 50% { opacity: .25; } }
@keyframes scan { from { top: 0%; } to { top: 100%; } }
@media (prefers-reduced-motion: reduce) { .screen { transition: none; } }
/* ===================== Pose recognition UI ===================== */
.criteria {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 2px 0 0; padding: 0; list-style: none;
}
.criteria:empty { display: none; }
.criteria li {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 6px;
  font-size: 10px; letter-spacing: .12em; color: var(--lab-dim);
  border: 1px solid var(--lab-line);
  transition: color .2s, border-color .2s, background .2s;
}
.criteria li::before { content: ""; width: 8px; height: 8px; border-radius: 2px; border: 1px solid currentColor; }
.criteria li.ok { color: var(--lab-accent); border-color: rgba(47, 217, 185, .45); background: rgba(47, 217, 185, .08); }
.criteria li.ok::before { background: currentColor; }
.panel__hint { grid-column: 1 / -1; margin: 0; font-size: 13px; line-height: 1.4; color: #ffd59a; }
.panel__hint:empty { display: none; }
.panel__hint::before { content: "→ "; color: var(--lab-dim); }
.btn-skip {
  grid-column: 1 / -1; justify-self: start;
  appearance: none; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--lab-line); background: transparent; color: var(--lab-dim);
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase; cursor: pointer;
}
.btn-skip:hover { color: var(--lab-text); border-color: rgba(140, 255, 225, .3); }
/* ===================== Music edit ===================== */
.screen--reveal { background: #fff; }
#stage { object-fit: contain; }
.btn-view {
  appearance: none; margin-top: 6px;
  padding: 11px 22px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .45);
  background: rgba(255, 255, 255, .08);
  color: #f6ecff;
  font: 600 11px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase;
  cursor: pointer; transition: background .2s;
}
.btn-view:hover { background: rgba(255, 255, 255, .16); }