/* ================================================================
   Shuttlestepz V2 — trainer.css
   Trainer screen: layout, direction display, timer, court map
   ================================================================ */

/* ── PAGE SHELL ───────────────────────────────────────────────── */
.trainer-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--clr-bg);
  position: relative;
}

/* ── SESSION TOPBAR ───────────────────────────────────────────── */
.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
  gap: 16px;
}

.session-bar__brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.session-bar__brand em { color: var(--clr-brand); font-style: normal; }

.session-bar__stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── INLINE STAT CHIP ─────────────────────────────────────────── */
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 14px;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  gap: 1px;
  min-width: 60px;
}
.chip__label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  color: var(--clr-text-3);
  text-transform: uppercase;
}
.chip__value {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--clr-text-1);
  line-height: 1;
  letter-spacing: 0.02em;
}
.chip__value--brand { color: var(--clr-brand); }
.chip__value--warn  { color: var(--clr-warn);  }
.chip__value--miss  { color: var(--clr-miss);  }

/* ── MAIN TRAINER GRID ────────────────────────────────────────── */
.trainer-main {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr 220px;
  grid-template-rows: 1fr;
  gap: 0;
  padding: 0;
  min-height: 0;
}

/* ── LEFT PANEL: controls + progress ─────────────────────────── */
.panel-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px 20px 20px;
  border-right: 1px solid var(--clr-border);
  overflow-y: auto;
}

/* ── CENTER: direction display ────────────────────────────────── */
.panel-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Radial glow behind the direction box */
.panel-center::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--clr-brand-glow) 0%, transparent 65%);
  opacity: 0;
  transition: opacity 0.6s;
  pointer-events: none;
}
.panel-center.is-active::before { opacity: 1; }
.panel-center.is-hit::before    { background: radial-gradient(circle, rgba(0,212,168,0.28) 0%, transparent 65%); opacity: 1; }
.panel-center.is-miss::before   { background: radial-gradient(circle, rgba(255,71,87,0.2) 0%, transparent 65%); opacity: 1; }

/* ── DIRECTION DISPLAY ────────────────────────────────────────── */
.direction-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.direction-display__pre {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.22em;
  color: var(--clr-text-3);
  text-transform: uppercase;
  height: 14px;
}

.direction-display__text {
  font-family: var(--font-display);
  font-size: clamp(4rem, 10vw, 8rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--clr-text-1);
  line-height: 0.9;
  transition: color 0.1s, transform 0.15s;
  user-select: none;
}

.direction-display__text.state-idle    { color: var(--clr-text-3); }
.direction-display__text.state-waiting { color: var(--clr-text-2); }
.direction-display__text.state-signal  { color: var(--clr-text-1); }
.direction-display__text.state-hit     { color: var(--clr-hit); }
.direction-display__text.state-miss    { color: var(--clr-miss); }

/* Flash animation when signal appears */
@keyframes signalFlash {
  0%   { transform: scale(0.88); opacity: 0.4; }
  60%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.direction-display__text.anim-flash {
  animation: signalFlash 0.25s var(--ease-out) forwards;
}

/* Hit burst */
@keyframes hitBurst {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.direction-display__text.anim-hit {
  animation: hitBurst 0.3s var(--ease-out);
}

/* ── DIRECTION ARROW ICON ─────────────────────────────────────── */
.direction-display__arrow {
  font-size: 2.5rem;
  color: var(--clr-brand);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  transform: scale(0.8);
}
.direction-display__arrow.visible {
  opacity: 1;
  transform: scale(1);
}

/* ── REACTION TIME DISPLAY ────────────────────────────────────── */
.reaction-display {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  color: var(--clr-brand);
  min-height: 24px;
  opacity: 0;
  transition: opacity 0.3s;
}
.reaction-display.visible { opacity: 1; }

/* ── KEYBOARD HINT ────────────────────────────────────────────── */
.key-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border-2);
  border-bottom: 3px solid var(--clr-border-2);
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--clr-text-2);
  transition: all 0.1s;
  user-select: none;
}
.key.is-pressed {
  border-bottom-width: 1px;
  transform: translateY(2px);
  background: var(--clr-brand-dim);
  border-color: var(--clr-brand);
  color: var(--clr-brand);
}
.key-hint__sep {
  font-size: 0.7rem;
  color: var(--clr-text-3);
  font-family: var(--font-mono);
}

/* ── TIMER RING (SVG-based) ───────────────────────────────────── */
.timer-ring-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}
.timer-ring {
  transform: rotate(-90deg);
}
.timer-ring__track {
  stroke: var(--clr-surface-3);
  fill: none;
}
.timer-ring__fill {
  fill: none;
  stroke: var(--clr-brand);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear, stroke 0.3s;
}
.timer-ring__fill--urgent { stroke: var(--clr-warn); }
.timer-ring__fill--overdue { stroke: var(--clr-miss); }
.timer-ring__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--clr-text-1);
  letter-spacing: 0.02em;
}

/* ── COURT MAP (mini) ─────────────────────────────────────────── */
.court-map {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  aspect-ratio: 1.2;
  width: 100%;
}
.court-map__cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--clr-border);
  border-radius: var(--r-xs);
  background: var(--clr-surface-2);
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clr-text-3);
  cursor: default;
  transition: all 0.2s;
  padding: 6px 2px;
  text-align: center;
  line-height: 1.3;
}
.court-map__cell--center {
  background: var(--clr-surface-3);
  color: var(--clr-text-2);
  border-color: var(--clr-border-2);
  font-size: 1rem;
}
.court-map__cell--active {
  background: var(--clr-brand-dim);
  border-color: var(--clr-brand);
  color: var(--clr-brand);
  box-shadow: 0 0 10px var(--clr-brand-glow);
}
.court-map__cell--hit {
  background: rgba(0,212,168,0.18);
  border-color: var(--clr-brand);
  color: var(--clr-brand);
}
.court-map__cell--miss {
  background: rgba(255,71,87,0.12);
  border-color: var(--clr-miss);
  color: var(--clr-miss);
}

/* ── RIGHT PANEL: court map + round history ───────────────────── */
.panel-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 20px 20px 16px;
  border-left: 1px solid var(--clr-border);
  overflow-y: auto;
}

/* ── ROUND HISTORY DOTS ───────────────────────────────────────── */
.round-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.round-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--clr-surface-3);
  border: 1px solid var(--clr-border);
  transition: all 0.3s var(--ease-out);
}
.round-dot--hit    { background: var(--clr-hit);  border-color: var(--clr-hit);  box-shadow: 0 0 6px var(--clr-brand-glow); }
.round-dot--miss   { background: var(--clr-miss); border-color: var(--clr-miss); }
.round-dot--active { background: var(--clr-warn); border-color: var(--clr-warn); animation: dotPulse 0.7s ease-in-out infinite; }

@keyframes dotPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,165,2,0.4); }
  50%       { transform: scale(1.3); box-shadow: 0 0 0 4px rgba(255,165,2,0); }
}

/* ── PROGRESS THROUGH SESSION ─────────────────────────────────── */
.session-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.session-progress__label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--clr-text-3);
  text-transform: uppercase;
}

/* ── DIFFICULTY SELECTOR ──────────────────────────────────────── */
.diff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-ui);
}
.diff-btn:hover { border-color: var(--clr-border-2); }
.diff-btn.is-active {
  background: var(--clr-brand-dim);
  border-color: var(--clr-brand);
}
.diff-btn__name {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--clr-text-1);
}
.diff-btn.is-active .diff-btn__name { color: var(--clr-brand); }
.diff-btn__sub {
  font-size: 0.6rem;
  color: var(--clr-text-3);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* ── PANEL SECTION HEADER ─────────────────────────────────────── */
.panel-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel-section__title {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--clr-text-3);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--clr-border);
}

/* ── START/STOP BUTTONS ───────────────────────────────────────── */
.start-stop-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── STATE: SETUP SCREEN (before session starts) ──────────────── */
.setup-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 9, 10, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: var(--z-overlay);
  backdrop-filter: blur(4px);
}
.setup-overlay__title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  color: var(--clr-text-1);
  max-width: 480px;
}
.setup-overlay__sub {
  font-size: 0.9rem;
  color: var(--clr-text-2);
  text-align: center;
  max-width: 380px;
  line-height: 1.6;
}

/* ── STATE: WAITING (between rounds) ──────────────────────────── */
.waiting-dots {
  display: flex;
  gap: 8px;
}
.waiting-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--clr-text-3);
  animation: waitBounce 1.2s ease-in-out infinite;
}
.waiting-dot:nth-child(2) { animation-delay: 0.2s; }
.waiting-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes waitBounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1; }
}

/* ── FEEDBACK BAR (bottom of center panel) ────────────────────── */
.feedback-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-full);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--clr-text-2);
  white-space: nowrap;
  transition: all 0.3s var(--ease-out);
  opacity: 0;
}
.feedback-bar.visible { opacity: 1; }
.feedback-bar--hit  { color: var(--clr-hit);  border-color: rgba(0,212,168,0.35); background: rgba(0,212,168,0.07); }
.feedback-bar--miss { color: var(--clr-miss); border-color: rgba(255,71,87,0.35);  background: rgba(255,71,87,0.07); }
.feedback-bar--warn { color: var(--clr-warn); border-color: rgba(255,165,2,0.35);  background: rgba(255,165,2,0.07); }

/* ── FLASH OVERLAY (full-screen hit/miss flash) ───────────────── */
.flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-overlay);
  opacity: 0;
}
@keyframes flashGreen { 0% { opacity: 0.18; } 100% { opacity: 0; } }
@keyframes flashRed   { 0% { opacity: 0.15; } 100% { opacity: 0; } }

.flash-overlay--hit  { background: var(--clr-hit);  animation: flashGreen 0.4s ease forwards; }
.flash-overlay--miss { background: var(--clr-miss); animation: flashRed 0.4s ease forwards; }

/* ── RESULTS SCREEN ───────────────────────────────────────────── */
.results-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px 80px;
}
.results-hero {
  text-align: center;
  margin-bottom: 40px;
}
.results-hero__grade {
  font-family: var(--font-display);
  font-size: 6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--clr-brand);
  line-height: 0.9;
  text-shadow: 0 0 60px var(--clr-brand-glow);
}
.results-hero__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--clr-text-3);
  text-transform: uppercase;
  margin-top: 8px;
}
.results-hero__title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--clr-text-1);
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── DIRECTION BREAKDOWN BARS ─────────────────────────────────── */
.breakdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.breakdown__row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.breakdown__name {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--clr-text-2);
  text-transform: uppercase;
  min-width: 90px;
}
.breakdown__bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--clr-surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}
.breakdown__bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 1s var(--ease-out);
  width: 0;
}
.breakdown__pct {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 32px;
  text-align: right;
}

/* ── RESPONSIVE TRAINER ───────────────────────────────────────── */
@media (max-width: 960px) {
  .trainer-main {
    grid-template-columns: 200px 1fr;
    grid-template-rows: 1fr auto;
  }
  .panel-right { display: none; }
}

@media (max-width: 680px) {
  .trainer-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .panel-left {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--clr-border);
    padding: 12px 16px;
    overflow-x: auto;
  }
  .session-bar__stats { display: none; }
  .direction-display__text {
    font-size: clamp(3rem, 16vw, 5rem);
  }
}