/* ── TraderTV Academy ─────────────────────────────────────────────────────
   Academy-specific UI: interactive cards (rendered from ```academy-card
   fences in any conversation that emits them) plus, further below, the
   domain-scoped chrome (top bar / rail / workspace) that only activates
   under body[data-domain="tradertv-academy"].
   All colors come from the style.css design tokens → light + dark for free. */

/* ── Cards ── */

.academy-card {
  margin: 10px 0 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 560px;
}

.academy-card + .academy-card {
  margin-top: 12px;
}

.ac-head {
  margin-bottom: 8px;
}

.ac-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: 999px;
  padding: 2px 8px;
  margin-bottom: 6px;
}

.ac-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.ac-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ac-goal {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin: 6px 0;
}

.ac-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.ac-step {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
}

.ac-terms {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.ac-terms li {
  padding: 3px 0;
  border-top: 1px solid var(--border-soft);
}

.ac-terms li:first-child {
  border-top: none;
}

/* Buttons */

.ac-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.ac-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ac-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--text-dim);
}

.ac-btn.ac-primary {
  color: var(--btn-fg);
  background: var(--btn-bg);
  border-color: var(--btn-bg);
}

.ac-btn.ac-primary:hover:not(:disabled) {
  background: var(--btn-bg-hover);
}

.ac-btn:focus-visible,
.ac-choice:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ac-btn:disabled,
.ac-choice:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Quiz */

.ac-prompt {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  margin: 8px 0 10px;
}

.ac-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ac-choice {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ac-choice:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.ac-choice.ac-chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
  opacity: 1;
}

.ac-choice-label {
  flex: none;
  font-weight: 700;
  color: var(--accent);
  min-width: 18px;
}

/* Quiz result */

.ac-score {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 2px;
}

.ac-score-pct {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}

.ac-band {
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
  border: 1px solid var(--border);
}

.ac-band.ac-good {
  color: var(--ok);
  background: var(--ok-soft-bg);
  border-color: var(--ok);
}

.ac-band.ac-warn {
  color: var(--warn-soft-fg);
  background: var(--warn-soft-bg);
  border-color: var(--warn-soft-border);
}

.ac-band.ac-attention {
  color: var(--danger);
  background: var(--danger-soft-bg);
  border-color: var(--danger-soft-border);
}

.ac-score-detail {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

/* P8 mission + journal */

.ac-framing {
  font-size: 13px;
  font-style: italic;
  color: var(--text-secondary);
  background: var(--warn-soft-bg);
  border: 1px solid var(--warn-soft-border);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 8px 0;
}

.ac-mission-steps,
.ac-journal-prompts {
  margin: 8px 0 4px 20px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.ac-mission-steps li,
.ac-journal-prompts li {
  margin: 4px 0;
}

.ac-hint {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 8px 0 0;
}

/* Progress + course map */

.ac-overall {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
}

.ac-overall-pct {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  min-width: 52px;
}

.ac-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}

.ac-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s;
}

.ac-chapters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ac-chapter-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.ac-chapter-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.ac-chapter-pct {
  font-size: 12px;
  color: var(--text-muted);
}

.ac-next {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 10px 0 0;
}

.ac-map-lessons {
  list-style: none;
  margin: 2px 0 6px;
  padding: 0;
}

.ac-map-lessons li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 3px 0;
  border-bottom: 1px solid var(--border-soft);
}

.ac-map-lessons li:last-child {
  border-bottom: none;
}

.ac-map-lessons li.ac-locked {
  color: var(--text-dim);
}

.ac-map-lessons .ac-status {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.ac-lock {
  font-size: 11px;
}

/* next-actions chip row: bare buttons, no card chrome */

.academy-card.ac-next-actions {
  background: transparent;
  border: none;
  padding: 0;
}

.academy-card.ac-next-actions .ac-actions {
  margin-top: 6px;
}

/* Streaming placeholder */

.academy-card.ac-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.ac-spinner {
  width: 12px;
  height: 12px;
  flex: none;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ac-spin 0.9s linear infinite;
}

@keyframes ac-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Academy chrome (active only under body[data-domain="tradertv-academy"]) ── */

/* Top bar — reuses the reserved .top-bar class (style.css keeps it display:none
   everywhere else). In-flow first child of .main, so the fixed masquerade
   banner's .app-container offset composes with it untouched. */

body[data-domain="tradertv-academy"] .top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: none;
  padding: 0 20px;
  height: 46px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.top-bar-brand {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.top-bar-mission {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1;
  border-left: 1px solid var(--border);
  padding-left: 16px;
}

.top-bar-mission-caption {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

.top-bar-mission-label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar-p8 {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-bg);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.top-bar-p8:hover {
  background: var(--btn-bg-hover);
}

.top-bar-p8:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .top-bar-mission-caption {
    display: none;
  }
}

/* Utility rail: Progress + Journal only exist in academy scope. Automations is
   hidden here too, but that is not this file's job — initAutomations() gates it
   to agent-automation across all domains. */

.academy-nav-item {
  display: none;
}

body[data-domain="tradertv-academy"] .academy-nav-item {
  display: flex;
}

.academy-nav-icon {
  display: inline-flex;
  align-items: center;
}

/* ── Video workspace ── */

.academy-workspace {
  position: fixed;
  top: 0;
  right: 0;
  width: 560px;
  max-width: 92vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.06);
  transform: translateX(100%);
  transition: transform 180ms ease-out, width 180ms ease-out;
  display: flex;
  flex-direction: column;
  z-index: 200;
  min-width: 360px;
}

.academy-workspace.open {
  transform: translateX(0);
}

.academy-workspace.expanded {
  width: 92vw;
}

/* Mirror the other fixed drawers under the masquerade banner offset. */
body.masquerading .academy-workspace {
  top: 36px;
  height: calc(100vh - 36px);
}

/* Docked mode: on wide screens the open workspace pushes the chat column left
   instead of overlaying it — true side-by-side lesson + tutor. The expanded
   (92vw) state stays an overlay. */
@media (min-width: 1200px) {
  body.academy-workspace-open .main {
    padding-right: 560px;
  }
}

.academy-workspace-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.academy-workspace-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.academy-workspace-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.academy-workspace-actions {
  display: flex;
  gap: 4px;
  flex: none;
}

.academy-workspace-btn {
  font: inherit;
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 7px;
  cursor: pointer;
}

.academy-workspace-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.academy-workspace-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.academy-workspace-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}

.academy-workspace-video {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}

.academy-workspace-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.academy-workspace-novideo {
  font-size: 13.5px;
  color: var(--text-secondary);
  background: var(--warn-soft-bg);
  border: 1px solid var(--warn-soft-border);
  border-radius: 8px;
  padding: 10px 12px;
}

.academy-workspace-h {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 16px 0 6px;
}

.academy-workspace-goal {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.academy-workspace-terms {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.academy-workspace-terms li {
  padding: 5px 0;
  border-top: 1px solid var(--border-soft);
}

.academy-workspace-terms li:first-child {
  border-top: none;
}

.academy-workspace-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.academy-workspace-hint {
  font-size: 12.5px;
  color: var(--text-muted);
}
