/* 3D-first judge UI, full viewport for protocol visualization, notes on demand */

:root {
  --ui-ink: #f4f7ed;
  --ui-ink-dim: #c6d0bf;
  --ui-ink-muted: #829080;
  --ui-panel: rgba(11, 15, 13, 0.94);
  --ui-line: #263428;
  --ui-line-soft: #172019;
  --ui-accent: #78d7ff;
  --ui-signal: #1fff7e;
  --ui-void: #030403;
  --ui-font: "Inter", system-ui, -apple-system, sans-serif;
  --ui-mono: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--ui-void);
  color: var(--ui-ink);
  font-family: var(--ui-font);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.11;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 72px 72px;
}

#viewport { position: fixed; inset: 0; z-index: 0; }

.hud { position: fixed; z-index: 10; pointer-events: none; }
.hud > * { pointer-events: auto; }

/* ── Compact top bar (minimal footprint) ─────────────────────────────── */

.top-bar {
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(3, 4, 3, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--ui-line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ui-accent);
  text-decoration: none;
  min-width: 0;
  transition: color 180ms ease;
}

.brand:hover,
.brand:focus-visible { color: var(--ui-signal); outline: none; }

/* Same lockup as the site nav: the capsule mark in a hairline square. */
.brand-mark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(244, 247, 237, 0.78);
  background: #050505;
}

.brand-mark svg { width: 26px; height: 26px; overflow: visible; }

.brand strong {
  display: inline;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: none;
  color: var(--ui-ink);
  margin-left: 8px;
  letter-spacing: -0.01em;
}

.top-actions, .top-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sim-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ui-ink-dim);
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid var(--ui-line);
  background: rgba(11, 15, 13, 0.72);
  border-radius: 0;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.sim-link:hover {
  color: var(--ui-signal);
  border-color: var(--ui-signal);
  background: rgba(31, 255, 126, 0.08);
}

.step-counter {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ui-ink-muted);
  white-space: nowrap;
}

.step-counter span {
  color: var(--ui-accent);
  font-weight: 700;
}

/* ── Step dock (always visible, one line) ────────────────────────────── */

.step-dock {
  left: 14px;
  right: 14px;
  bottom: 82px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(11, 15, 13, 0.92);
  border: 1px solid var(--ui-line);
  border-radius: 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
  max-width: 820px;
  margin: 0 auto;
  pointer-events: auto;
}

.dock-text {
  flex: 1;
  min-width: 0;
}

.dock-hint {
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--ui-ink-muted);
  margin-top: 4px;
  padding-left: 2px;
}

.dock-hint.is-empty {
  display: none;
}

.note-bullets {
  margin-top: 8px;
}

.note-bullets li {
  font-size: 0.86rem;
  line-height: 1.4;
}

.dock-tag {
  font-family: var(--ui-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ui-accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.dock-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ui-ink);
  min-width: 0;
  line-height: 1.3;
}

.notes-open-btn {
  flex-shrink: 0;
  border: 1px solid var(--ui-line);
  background: rgba(11, 15, 13, 0.72);
  color: var(--ui-ink-dim);
  font-family: var(--ui-font);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 0;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.notes-open-btn:hover {
  border-color: var(--ui-signal);
  color: var(--ui-signal);
  background: rgba(31, 255, 126, 0.08);
}

body.notes-open .notes-open-btn {
  background: var(--ui-signal);
  border-color: var(--ui-signal);
  color: var(--ui-void);
}

/* ── Notes drawer (hidden by default) ────────────────────────────────── */

.side-panel.notes-drawer {
  top: 0;
  left: 0;
  bottom: 0;
  width: min(400px, 92vw);
  max-width: 400px;
  border: none;
  border-right: 1px solid var(--ui-line);
  border-radius: 0;
  padding: 0;
  transform: translateX(-105%);
  transition: transform 0.28s ease;
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(11, 15, 13, 0.98);
}

body.notes-open .side-panel.notes-drawer {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--ui-line);
  background: rgba(16, 23, 17, 0.98);
  flex-shrink: 0;
}

.drawer-head h1 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
}

.drawer-head .step-tag {
  margin-bottom: 4px;
}

#notes-close {
  border: none;
  background: rgba(244, 247, 237, 0.06);
  color: var(--ui-ink-muted);
  width: 36px;
  height: 36px;
  border-radius: 0;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

#notes-close:hover {
  background: rgba(31, 255, 126, 0.12);
  color: var(--ui-signal);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 24px;
}

.note-block {
  margin-bottom: 10px;
  border: 1px solid var(--ui-line);
  border-radius: 0;
  background: rgba(11, 15, 13, 0.88);
  overflow: hidden;
}

.note-block summary {
  padding: 12px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ui-ink-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.note-block summary::-webkit-details-marker { display: none; }

.note-block summary::before {
  content: "▸ ";
  color: var(--ui-accent);
}

.note-block[open] summary::before { content: "▾ "; }

.note-block[open] summary {
  border-bottom: 1px solid var(--ui-line);
  background: rgba(16, 23, 17, 0.98);
}

.note-block .note-content {
  padding: 14px 16px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ui-ink-dim);
  font-weight: 500;
}

.note-block .note-content.note-summary {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ui-ink);
}

.detail-list { list-style: none; padding: 0; margin: 0; }

.detail-list li {
  font-size: 0.92rem;
  padding: 8px 0 8px 20px;
  border-bottom: 1px solid var(--ui-line-soft);
  line-height: 1.45;
  position: relative;
}

.detail-list li::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--ui-accent);
  font-weight: 700;
}

.component-key {
  margin-top: 4px;
  padding: 0;
  border: none;
  background: transparent;
}

.component-key-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 14px 16px;
}

.component-key-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex-shrink: 0;
  border: 1px solid var(--ui-line);
}

.swatch-pink { background: #e879a8; }
.swatch-blue { background: #3b82f6; }
.swatch-green { background: #22c55e; }
.swatch-gold { background: #eab308; }
.swatch-teal { background: #14b8a6; }
.swatch-cream { background: #f0e8cc; }
.swatch-red { background: #ef4444; }
.swatch-magenta { background: #de1e6a; }

.legend-box { margin: 0; padding: 14px 16px; border: none; background: transparent; }
.legend-box.is-empty { display: none; }
.legend-box #legend { font-size: 0.92rem; line-height: 1.5; }

.notes-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 3, 0.62);
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

body.notes-open .notes-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* ── Bottom controls ────────────────────────────────────────────────── */

.bottom-bar {
  bottom: 0; left: 0; right: 0;
  padding: 10px 14px 12px;
  background: linear-gradient(to top, rgba(3, 4, 3, 0.96), transparent);
}

.progress-track {
  height: 4px;
  background: var(--ui-line);
  margin-bottom: 10px;
  border-radius: 0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ui-accent), var(--ui-signal));
  transition: width 0.35s ease;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.controls button {
  border: 1px solid var(--ui-line);
  background: rgba(11, 15, 13, 0.88);
  color: var(--ui-ink);
  padding: 12px 18px;
  font-family: var(--ui-font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 0;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.controls button:hover:not(:disabled) {
  border-color: var(--ui-signal);
  color: var(--ui-signal);
  background: rgba(31, 255, 126, 0.08);
}

.controls button:disabled { opacity: 0.35; cursor: not-allowed; }

.controls button.primary {
  border-color: var(--ui-signal);
  background: var(--ui-signal);
  color: var(--ui-void);
  min-width: 140px;
}

.controls button.primary:hover:not(:disabled) {
  background: var(--ui-signal);
  color: var(--ui-void);
  border-color: var(--ui-signal);
}

.step-jump, .step-jump-wrap { flex: 1 1 200px; max-width: 360px; min-width: 0; }

.step-jump select, #step-jump {
  width: 100%;
  padding: 12px 32px 12px 12px;
  border: 1px solid var(--ui-line);
  border-radius: 0;
  background: rgba(11, 15, 13, 0.88);
  color: var(--ui-ink);
  font-family: var(--ui-font);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23829080' d='M0 0l6 8 6-8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.keyboard-hint, .hint {
  display: none;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

body.theme-ambitious {
  --ui-accent: #ff7a54;
  --ui-signal: #ff7a54;
}

body.theme-ambitious .controls button.primary {
  border-color: var(--ui-signal);
  background: var(--ui-signal);
  color: var(--ui-void);
}

@media (max-width: 640px) {
  .brand strong { display: block; margin-left: 0; margin-top: 2px; }
  .step-dock { flex-wrap: wrap; bottom: 78px; }
  .dock-title { white-space: normal; }
  .controls { gap: 8px; }
  .step-jump, .step-jump-wrap { order: -1; flex: 1 1 100%; max-width: none; }
}

.seq-playback-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
  pointer-events: auto;
}

.seq-playback-controls button {
  font-family: var(--ui-font);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 12px;
  border: 1px solid var(--ui-line);
  border-radius: 0;
  background: rgba(11, 15, 13, 0.88);
  color: var(--ui-ink);
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.seq-playback-controls button:disabled { opacity: 0.35; cursor: not-allowed; }

.seq-playback-controls button:hover:not(:disabled) {
  border-color: var(--ui-signal);
  color: var(--ui-signal);
  background: rgba(31, 255, 126, 0.08);
}

.seq-progress-track {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 118px;
  height: 3px;
  background: rgba(38, 52, 40, 0.65);
  z-index: 11;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.seq-progress-track.is-active { opacity: 1; }

.seq-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ui-accent), var(--ui-signal));
  transition: width 0.08s linear;
}
