/* The coach's brain (#/brain).
 *
 * The stage is a dark viewport on the light workspace, built from the brand's
 * ink surface (--ink-surface #151C28). Inside it, colours are literal: they
 * are tuned for additive light on that dark ground, and the same values are
 * used by the WebGL scene, which cannot read CSS variables. The cards under
 * the stage use the normal tokens. */

.brain-stage {
  position: relative;
  height: clamp(460px, 72vh, 860px);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 60% at 50% 42%, rgba(128, 120, 240, 0.16) 0%, rgba(128, 120, 240, 0) 70%),
    radial-gradient(ellipse at 50% 40%, #1C2438 0%, var(--ink-surface) 58%, #0D121B 100%);
  color: var(--ink-on-dark);
  box-shadow: var(--shadow-md);
  isolation: isolate;
}
.brain-stage [hidden] { display: none !important; }

.brain-viewport {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: grab;
}
.brain-viewport:active { cursor: grabbing; }
.brain-canvas { display: block; }

.brain-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.brain-label,
.brain-lobe-label {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  will-change: transform, opacity;
}
.brain-label {
  margin: -10px 0 0 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(13, 18, 27, 0.6);
  font-size: 11px;
  line-height: 16px;
  font-weight: 500;
  color: #FFE7A3;
  transition: background 0.25s, color 0.25s;
}
.brain-label-core { color: #FFFFFF; font-weight: 700; font-size: 12px; }
.brain-label-skill { color: #B7F5D8; }
.brain-label-connector { color: #CFE0FF; }
.brain-label.unplaced { color: #9AA3BA; }
.brain-label.active { background: rgba(128, 120, 240, 0.55); color: #FFFFFF; }

.brain-lobe-label {
  translate: -50% -50%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: rgba(244, 245, 250, 0.9);
  text-shadow: 0 1px 6px rgba(13, 18, 27, 0.95);
}
.brain-lobe-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ── Heads-up controls ─────────────────────────────────────────────────── */
.brain-hud {
  position: absolute;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 2;
}
.brain-hud > * { pointer-events: auto; }
.brain-hud-top { top: 14px; align-items: center; }
.brain-hud-bottom { bottom: 14px; align-items: flex-end; flex-wrap: wrap; }

.brain-stats { font-size: 12.5px; color: var(--ink-on-dark-muted); }
.brain-stats b { color: var(--ink-on-dark); font-weight: 700; }
.brain-sep { margin: 0 8px; opacity: 0.5; }

.brain-search { display: flex; gap: 6px; }
.brain-search input {
  width: 250px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(244, 245, 250, 0.16);
  background: rgba(244, 245, 250, 0.08);
  color: var(--ink-on-dark);
  font: inherit;
  font-size: 13px;
}
.brain-search input::placeholder { color: #8E97AE; }
.brain-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.brain-btn {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid rgba(244, 245, 250, 0.18);
  background: rgba(244, 245, 250, 0.09);
  color: var(--ink-on-dark);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.brain-btn:hover { background: rgba(244, 245, 250, 0.17); }
.brain-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.brain-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.brain-actions { display: flex; gap: 8px; }

.brain-ticker {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 520px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-on-dark);
  text-shadow: 0 1px 4px rgba(13, 18, 27, 0.9);
}
.brain-ticker li { opacity: 0.45; }
.brain-ticker li:nth-last-child(2) { opacity: 0.7; }
.brain-ticker li:last-child { opacity: 1; }
.brain-when {
  display: inline-block;
  min-width: 44px;
  margin-right: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #8E97AE;
}

.brain-timeline {
  display: flex;
  flex-basis: 100%;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(13, 18, 27, 0.72);
}
.brain-timeline input[type="range"] { flex: 1; accent-color: var(--accent); }
.brain-time-label { font-size: 12.5px; color: var(--ink-on-dark); min-width: 210px; text-align: right; }

/* ── Hover tip and detail panel ────────────────────────────────────────── */
.brain-tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  max-width: 290px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(244, 245, 250, 0.12);
  background: rgba(13, 18, 27, 0.95);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-size: 12.5px;
  pointer-events: none;
}
.brain-tip-kind,
.brain-panel-kind {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9AA3BA;
}
.brain-tip-title { margin-top: 2px; font-weight: 600; color: #FFFFFF; }
.brain-tip-text { margin-top: 4px; line-height: 1.45; color: #C9CEDC; }

.brain-panel {
  position: absolute;
  top: 58px;
  right: 14px;
  z-index: 6;
  width: min(350px, calc(100% - 28px));
  max-height: calc(100% - 130px);
  padding: 16px 16px 14px;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(244, 245, 250, 0.12);
  background: rgba(13, 18, 27, 0.95);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}
.brain-panel-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9AA3BA;
  cursor: pointer;
}
.brain-panel-close:hover { background: rgba(244, 245, 250, 0.1); color: #FFFFFF; }
.brain-panel-title { margin: 4px 30px 6px 0; font-size: 15px; font-weight: 700; line-height: 1.35; color: #FFFFFF; }
.brain-panel-meta { margin: 0 0 8px; font-size: 12px; color: #9AA3BA; }
.brain-panel-text { margin: 0 0 12px; font-size: 13px; line-height: 1.55; color: #D5D9E5; white-space: pre-wrap; }
.brain-panel .btn { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.brain-hits { list-style: none; margin: 4px 0 10px; padding: 0; }
.brain-hit {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #E4E7F0;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.brain-hit:hover { background: rgba(244, 245, 250, 0.08); }

.brain-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  background: rgba(13, 18, 27, 0.3);
}
.brain-overlay-box {
  max-width: 440px;
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(13, 18, 27, 0.92);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}
.brain-overlay-box a { color: #B9B4FF; }
.brain-overlay-box .brain-btn { margin-left: 8px; }

.brain-fallback {
  height: 100%;
  overflow: auto;
  padding: 64px 28px 28px;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Under the stage ───────────────────────────────────────────────────── */
.brain-below {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}
.brain-legend,
.brain-notes {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.brain-seg {
  display: inline-flex;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  overflow: hidden;
}
.brain-seg-btn {
  padding: 5px 13px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.brain-seg-btn + .brain-seg-btn { border-left: 1px solid var(--rule-strong); }
.brain-seg-btn.on { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.brain-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.brain-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.brain-chip[disabled] { cursor: default; }
.brain-chip.on { border-color: var(--accent); background: var(--accent-soft); }
.brain-chip-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.brain-chip-n { color: var(--ink-faded); font-variant-numeric: tabular-nums; }
.brain-key {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-faded);
}
.brain-key span { display: inline-flex; align-items: center; gap: 6px; }
.brain-key i { display: inline-block; flex: none; }
.brain-key-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.brain-key-ring { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink-ghost); }
.brain-key-diamond { width: 8px; height: 8px; border: 2px solid var(--accent); transform: rotate(45deg); }
.brain-key-marker { width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle, #FFFFFF 0%, var(--accent) 60%, transparent 100%); }
.brain-muted { color: var(--ink-faded); font-size: 12.5px; }
.brain-h { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--ink); }
.brain-notes-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.55; color: var(--ink-soft); }
.brain-notes-list li + li { margin-top: 6px; }
.brain-waiting {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--fill-amber);
  font-size: 13px;
  color: var(--ink);
}
.brain-waiting a { color: var(--accent-deep); font-weight: 600; }

@media (max-width: 720px) {
  .brain-stage { height: clamp(440px, 74vh, 680px); border-radius: var(--radius-lg); }
  .brain-hud { left: 10px; right: 10px; }
  .brain-hud-top { flex-direction: column; align-items: stretch; gap: 8px; }
  .brain-search input { width: auto; flex: 1; }
  .brain-ticker { font-size: 11.5px; max-width: 100%; }
  .brain-ticker li:not(:nth-last-child(-n+2)) { display: none; }
  .brain-hud-bottom { gap: 8px; }
  .brain-actions { width: 100%; }
  .brain-actions .brain-btn { flex: 1; }
  .brain-panel { top: auto; left: 10px; right: 10px; bottom: 10px; width: auto; max-height: 58%; }
  .brain-below { grid-template-columns: minmax(0, 1fr); }
  .brain-time-label { min-width: 0; font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .brain-label { transition: none; }
}
