/* ================================================
   Race Demo — Side-by-Side Rename Race
   pandō vs standard agent: correctness + speed
   ================================================ */

/* --- Container & Layout --- */

.race-container {
  --demo-bg: var(--vscode-editor-background, #0c0c0c);
  --demo-bg-alt: var(--vscode-sideBar-background, #111111);
  --demo-surface-1: color-mix(in srgb, var(--vscode-editorWidget-background, #151515) 70%, transparent);
  --demo-surface-2: color-mix(in srgb, var(--vscode-editorWidget-background, #151515) 40%, transparent);
  --demo-border: color-mix(in srgb, var(--vscode-panel-border, #2a2a2a) 70%, transparent);
  --demo-text: var(--vscode-foreground, #d4d4d4);
  --demo-text-muted: var(--vscode-descriptionForeground, rgba(255, 255, 255, 0.55));
  --demo-text-faint: color-mix(in srgb, var(--vscode-descriptionForeground, rgba(255, 255, 255, 0.45)) 70%, transparent);
  --demo-accent-blue: var(--vscode-terminal-ansiBlue, #569cd6);
  --demo-accent-cyan: var(--vscode-terminal-ansiCyan, #4ec9b0);
  --demo-accent-yellow: var(--vscode-terminal-ansiYellow, #d7ba7d);
  --demo-accent-green: var(--vscode-terminal-ansiGreen, #6a9955);
  --demo-accent-red: var(--vscode-terminal-ansiRed, #d16969);
  --demo-accent-amber: #d7a24e;
  --pando-green: var(--color-accent, #2d5a3d);
  --panel-left-accent: color-mix(in srgb, var(--pando-green) 72%, #8fd3a6);
  --panel-right-accent: var(--demo-accent-yellow);
  display: flex;
  flex-direction: column;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--demo-bg);
  overflow: hidden;
  font-family: 'Geist Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  color: var(--demo-text);
}

/* --- Grid: Two Panels --- */

.race-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* --- Panel --- */

.race-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.race-panel-left {
  border-right: 1px solid var(--demo-border);
}

/* --- Panel Header --- */

.race-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--demo-surface-2);
  border-bottom: 1px solid var(--demo-border);
  flex-shrink: 0;
}

.race-panel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.race-panel-left .race-panel-dot {
  background: var(--panel-left-accent);
}

.race-panel-right .race-panel-dot {
  background: var(--panel-right-accent);
}

.race-panel-label {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.race-panel-left .race-panel-label {
  color: var(--panel-left-accent);
}

.race-panel-right .race-panel-label {
  color: var(--panel-right-accent);
}

/* --- Live Timer in Header --- */

.race-timer {
  margin-left: auto;
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--demo-text-muted);
  transition: color 300ms ease;
  min-width: 3.2em;
  text-align: right;
}

.race-panel-left .race-timer.is-done {
  color: var(--panel-left-accent);
}

.race-panel-right .race-timer.is-fail-done {
  color: var(--demo-accent-red);
}

/* --- Log Area --- */

.race-log {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
  scroll-behavior: smooth;
}

.race-log::-webkit-scrollbar {
  width: 4px;
}

.race-log::-webkit-scrollbar-track {
  background: transparent;
}

.race-log::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--demo-text-faint) 35%, transparent);
  border-radius: 2px;
}

/* --- Log Line --- */

.race-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 10px 2px 12px;
  font-size: 11px;
  line-height: 1.55;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.race-line.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Phase-gap separator */
.race-line-gap {
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid color-mix(in srgb, var(--demo-border) 50%, transparent);
}

/* Left-border accent */
.race-panel-left .race-line {
  border-left: 2px solid color-mix(in srgb, var(--demo-border) 70%, transparent);
}

.race-panel-right .race-line {
  border-left: 2px solid color-mix(in srgb, var(--demo-border) 70%, transparent);
}

/* --- Line type colors --- */

.race-line-read {
  color: color-mix(in srgb, var(--demo-text-faint) 85%, var(--demo-text));
}

.race-line-search {
  color: var(--demo-accent-blue);
}

.race-line-update {
  color: var(--demo-accent-yellow);
}

.race-line-find {
  color: var(--demo-accent-cyan);
}

.race-line-rename {
  color: var(--demo-accent-green);
}

.race-line-result {
  color: var(--demo-text);
  font-weight: 500;
}

.race-line-result .race-line-check {
  color: var(--demo-accent-green);
}

/* bash — faint grey (timestamp/utility) */
.race-line-bash {
  color: var(--demo-text-faint);
}

/* pause — amber italic (asked user / stall) */
.race-line-pause {
  color: var(--demo-accent-amber);
  font-style: italic;
}

/* error — dim red italic (retry) */
.race-line-error {
  color: color-mix(in srgb, var(--demo-accent-red) 65%, var(--demo-text-faint));
  font-style: italic;
}

/* fail — red bold (wrong conclusion) */
.race-line-fail {
  color: var(--demo-accent-red);
  font-weight: 600;
}

.race-line-fail .race-line-warn {
  color: var(--demo-accent-amber);
}

/* intervention — user stepping in, amber highlight */
.race-line-intervention {
  color: var(--demo-accent-amber);
  font-weight: 600;
  font-style: italic;
}

/* admit — agent admitting mistake, red italic */
.race-line-admit {
  color: var(--demo-accent-red);
  font-weight: 600;
}

.race-line-admit .race-line-x {
  color: var(--demo-accent-red);
}

/* Keep all pandō-side operation highlights on one brand-green accent */
.race-panel-left .race-line-find,
.race-panel-left .race-line-rename,
.race-panel-left .race-line-result .race-line-check {
  color: var(--panel-left-accent);
}

/* pandō error lines: muted green-red instead of pure red */
.race-panel-left .race-line-error {
  color: color-mix(in srgb, var(--demo-accent-red) 50%, var(--demo-text-faint));
}

/* Result lines: indent like Claude Code ⎿ output, hide step number */
.race-line-result,
.race-line-error {
  padding-left: 38px;
  border-left-color: transparent;
}

.race-line-result .race-line-num,
.race-line-error .race-line-num {
  display: none;
}

/* --- Annotation notes --- */

.race-note {
  display: block;
  font-size: 9px;
  line-height: 1.3;
  color: var(--demo-text-faint);
  font-style: italic;
  font-weight: 400;
  margin-top: 1px;
  opacity: 0.75;
}

/* --- Step number prefix --- */

.race-line-num {
  color: var(--demo-text-faint);
  flex-shrink: 0;
  font-size: 9px;
}

.race-line-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

/* --- Done Badge --- */

.race-done-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 4px;
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 8px 12px;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 250ms ease, transform 250ms ease;
}

.race-done-badge.is-visible {
  opacity: 1;
  transform: scale(1);
}

.race-panel-left .race-done-badge {
  background: color-mix(in srgb, var(--panel-left-accent) 14%, var(--demo-surface-1));
  color: var(--panel-left-accent);
  border: 1px solid color-mix(in srgb, var(--panel-left-accent) 35%, transparent);
}

.race-panel-right .race-done-badge {
  background: color-mix(in srgb, var(--panel-right-accent) 14%, var(--demo-surface-1));
  color: var(--panel-right-accent);
  border: 1px solid color-mix(in srgb, var(--panel-right-accent) 35%, transparent);
}

/* Fail-state done badge */
.race-done-badge.is-fail {
  background: color-mix(in srgb, var(--demo-accent-red) 12%, var(--demo-surface-1));
  color: var(--demo-accent-red);
  border: 1px solid color-mix(in srgb, var(--demo-accent-red) 30%, transparent);
}

/* --- Verdict Overlay — collapsed until race ends, then slides open --- */

.race-verdict {
  position: relative;
  background: color-mix(in srgb, #0c0c0c 92%, transparent);
  border-top: 1px solid transparent;
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  /* Collapsed: zero height, no space taken */
  max-height: 0;
  padding: 0 20px;
  opacity: 0;
  overflow: hidden;
  transition: max-height 500ms cubic-bezier(0.4, 0, 0.2, 1),
              padding 500ms cubic-bezier(0.4, 0, 0.2, 1),
              opacity 400ms ease 80ms,
              border-top-color 300ms ease;
  pointer-events: none;
  z-index: 5;
}

.race-verdict.is-visible {
  max-height: 250px;
  padding: 14px 20px 10px;
  border-top-color: var(--demo-border);
  opacity: 1;
}

.race-verdict-col {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.race-verdict-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

.race-verdict-big {
  font-family: 'Geist Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.race-verdict-accuracy {
  font-family: 'Geist Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.race-verdict-note {
  font-size: 10px;
  opacity: 0.55;
  white-space: nowrap;
  line-height: 1.35;
}

/* Pass column (pandō) — green theme */
.race-verdict-pass {
  color: var(--panel-left-accent);
}

.race-verdict-pass .race-verdict-title {
  color: var(--panel-left-accent);
  text-transform: none;
}

/* Fail column (standard) — red theme */
.race-verdict-fail {
  color: var(--demo-accent-red);
}

.race-verdict-fail .race-verdict-title {
  color: var(--demo-accent-amber);
}

/* "27 MISSED" red pill */
.race-verdict-miss {
  display: inline-block;
  background: color-mix(in srgb, var(--demo-accent-red) 22%, transparent);
  color: var(--demo-accent-red);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--demo-accent-red) 35%, transparent);
  margin-left: 4px;
  animation: verdict-pulse 2s ease-in-out infinite;
}

@keyframes verdict-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* --- Responsive --- */

@media (min-width: 1280px) {
  .race-container {
    aspect-ratio: 16 / 9;
  }

  .race-line {
    font-size: 12px;
  }

  .race-note {
    font-size: 9.5px;
  }

  .race-verdict-big {
    font-size: 26px;
  }
}

@media (max-width: 1024px) {
  .race-line {
    font-size: 10.5px;
  }

  .race-panel-header {
    padding: 6px 10px;
  }

  .race-verdict.is-visible {
    padding: 10px 14px 8px;
  }

  .race-verdict-big {
    font-size: 20px;
  }
}

@media (max-width: 768px) {
  .race-container {
    aspect-ratio: auto;
    height: 480px;
  }

  .race-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .race-panel-left {
    border-right: none;
    border-bottom: 1px solid var(--demo-border);
  }

  .race-line {
    font-size: 10px;
    padding: 1px 8px 1px 10px;
  }

  .race-line-num {
    display: none;
  }

  .race-note {
    font-size: 8.5px;
  }

  .race-panel-label {
    font-size: 10px;
  }

  .race-timer {
    font-size: 10px;
  }

  /* Verdict stacks to single column */
  .race-verdict.is-visible {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px 12px 8px;
    max-height: 350px;
  }

  .race-verdict-big {
    font-size: 18px;
  }

  .race-verdict-accuracy {
    font-size: 11px;
  }

  .race-verdict-note {
    font-size: 9px;
  }

}

@media (max-width: 480px) {
  .race-container {
    height: 400px;
  }

  .race-line {
    font-size: 9.5px;
  }

  .race-panel-header {
    padding: 5px 8px;
    gap: 6px;
  }

  .race-verdict.is-visible {
    padding: 8px 10px;
    gap: 8px;
  }

  .race-verdict-big {
    font-size: 16px;
  }
}

/* --- Reduced Motion --- */

@media (prefers-reduced-motion: reduce) {
  .race-line {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .race-done-badge {
    opacity: 1;
    transform: none;
    transition: none;
    animation: none !important;
  }

  .race-verdict {
    transition: none;
  }

  .race-verdict.is-visible {
    max-height: 250px;
    padding: 14px 20px 10px;
    opacity: 1;
  }

  .race-verdict-miss {
    animation: none;
  }

  .race-log {
    scroll-behavior: auto;
  }

  .race-timer {
    transition: none;
  }
}
