/* =============================================================================
   PRISM LEARN MODE — learn-mode.css
   Light mode only. Additive overrides scoped to body.mode-learn.
   Covers: Focus Mode, narration tooltip, experiment prompts, expand toggle,
           left-panel question list, stage theory panel, right panel tweaks.
   ============================================================================= */

/* ─── CSS CUSTOM PROPERTIES (light palette) ─────────────────────────────────
   Defines the Learn-mode colour tokens used throughout this file.
   All values are light-mode safe.
   --------------------------------------------------------------------------- */
body.mode-learn {
  --lm-accent:       #3b82f6;
  --lm-accent-dim:   rgba(59,130,246,0.10);
  --lm-accent-ring:  rgba(59,130,246,0.22);
  --lm-surface:      #ffffff;
  --lm-surface-2:    #f8fafc;
  --lm-border:       #e2e8f0;
  --lm-border-faint: rgba(0,0,0,0.06);
  --lm-text:         #1e293b;
  --lm-text-dim:     #64748b;
  --lm-text-muted:   #94a3b8;
  --lm-green:        #16a34a;
  --lm-green-bg:     rgba(22,163,74,0.08);
  --lm-amber:        #d97706;
  --lm-amber-bg:     rgba(217,119,6,0.08);
  --lm-red:          #dc2626;
  --lm-red-bg:       rgba(220,38,38,0.07);
  --lm-purple:       #7c3aed;
  --lm-purple-bg:    rgba(124,58,237,0.07);
}

/* ─── FOCUS MODE — canvas node dim / glow ───────────────────────────────────
   When body.lm-node-focused is set, unrelated nodes dim.
   --------------------------------------------------------------------------- */

body.mode-learn.lm-node-focused .node.lm-dimmed {
  opacity: 0.25;
  filter: saturate(0.15) brightness(1.05);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

body.mode-learn.lm-node-focused .node.lm-focused {
  opacity: 1;
  filter: none;
  box-shadow:
    0 0 0 2px var(--lm-accent),
    0 0 16px var(--lm-accent-ring);
  transition: box-shadow 0.2s ease;
}

body.mode-learn.lm-node-focused .node.lm-related {
  opacity: 1;
  filter: none;
  box-shadow: 0 0 0 1.5px var(--lm-accent-ring);
  transition: box-shadow 0.2s ease;
}

/* ─── FOCUS MODE — edge paths ─────────────────────────────────────────────── */

body.mode-learn.lm-node-focused .connection-path.lm-edge-dim {
  opacity: 0.1;
  transition: opacity 0.2s ease;
}

body.mode-learn.lm-node-focused .connection-path.lm-edge-focus {
  opacity: 1;
  stroke-width: 2.5 !important;
  filter: drop-shadow(0 0 3px var(--lm-accent-ring));
  transition: opacity 0.2s ease;
}

/* ─── NARRATION TOOLTIP ──────────────────────────────────────────────────────
   Appears bottom-centre of the canvas when a node is clicked.
   --------------------------------------------------------------------------- */

#lm-narration {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  z-index: 1200;
  background: #1e293b;
  color: #e2e8f0;
  font-size: var(--fs-xs);
  font-style: italic;
  line-height: 1.5;
  padding: 9px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  max-width: 440px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#lm-narration.lm-narration-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── EXPERIMENT PROMPTS ─────────────────────────────────────────────────────
   Rows injected into #stage-theory by learn-mode-ui.js.
   --------------------------------------------------------------------------- */

.lm-experiment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 12px 12px;
}

.lm-experiment-row {
  cursor: default;
  background: var(--lm-purple-bg);
  border: 1px solid rgba(124,58,237,0.18);
  border-left: 3px solid var(--lm-purple);
  border-radius: 8px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lm-exp-label {
  font-size: var(--fs-micro) !important;
  font-weight: 800 !important;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--lm-purple) !important;
  display: flex;
  align-items: center;
  gap: 4px;
}

.lm-exp-label::before {
  content: '⟩';
  font-style: normal;
}

.lm-exp-text {
  font-size: var(--fs-xs);
  color: #3b2f5e;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  line-height: 1.5;
}

/* ─── SECONDARY BREAKDOWN TOGGLE ─────────────────────────────────────────── */

.lm-secondary-breakdown {
  flex-direction: column;
  gap: 5px;
  margin-top: 4px;
}

.lm-expand-toggle {
  margin-top: 6px;
  font-size: var(--fs-xss);
  font-weight: 600;
  color: var(--lm-text-muted);
  background: none;
  border: none;
  padding: 2px 0;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}
.lm-expand-toggle:hover { color: var(--lm-accent); }

/* ─── SYSTEM BRIEF BADGE ─────────────────────────────────────────────────── */

.lm-brief-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lm-red);
  background: var(--lm-red-bg);
  border: 1px solid rgba(220,38,38,0.2);
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}

@keyframes lm-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.lm-brief-badge::before {
  content: '▊';
  font-size: var(--fs-micro);
  animation: lm-blink 1.1s step-end infinite;
}

/* ─── STAGE THEORY CONTAINER ─────────────────────────────────────────────── */

body.mode-learn .stage-theory {
  background: var(--lm-surface);
  padding: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #e2e8f0 transparent;
}

/* ─── LEFT PANEL — question list ─────────────────────────────────────────── */

body.mode-learn .learn-question-item {
  background: var(--lm-surface);
  border: 1px solid var(--lm-border);
  border-radius: 10px;
  padding: 11px 13px;
  gap: 5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

body.mode-learn .learn-question-item:hover {
  border-color: var(--lm-accent);
  box-shadow: 0 2px 10px var(--lm-accent-dim);
}

body.mode-learn .learn-question-item[data-active="true"] {
  border-color: var(--lm-accent);
  background: var(--lm-accent-dim);
}

body.mode-learn .learn-question-title {
  color: var(--lm-text);
  font-size: var(--fs-sm);
  font-weight: 600;
}

body.mode-learn .learn-question-desc {
  color: var(--lm-text-dim);
  font-size: var(--fs-xss);
  line-height: 1.45;
}

body.mode-learn .learn-question-item[data-difficulty="easy"]   .learn-question-diff { color: var(--lm-green); }
body.mode-learn .learn-question-item[data-difficulty="medium"] .learn-question-diff { color: var(--lm-amber); }
body.mode-learn .learn-question-item[data-difficulty="hard"]   .learn-question-diff { color: var(--lm-red);   }

/* Difficulty segment bar */
.lm-diff-bar { display: flex; gap: 2px; align-items: center; flex-shrink: 0; }
.lm-diff-seg { width: 8px; height: 4px; border-radius: 2px; background: #e2e8f0; }
[data-difficulty="easy"]   .lm-diff-seg:nth-child(-n+1) { background: var(--lm-green); }
[data-difficulty="medium"] .lm-diff-seg:nth-child(-n+2) { background: var(--lm-amber); }
[data-difficulty="hard"]   .lm-diff-seg:nth-child(-n+3) { background: var(--lm-red);   }

/* ─── RIGHT PANEL HEADER ─────────────────────────────────────────────────── */

body.mode-learn #right-panel .panel-header {
  background: var(--lm-surface);
  border-bottom: 0.5px solid var(--lm-border);
}

/* ─── LRP PROBLEM NAME PILL ──────────────────────────────────────────────── */

#lrp-problem-name {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0;
  color: var(--lm-text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: none;
  border: none;
}

/* Hide the sticky-header container once moved into panel-header — no visible UI there */
body.mode-learn #right-panel .panel-header #learn-sticky-header {
  display: none;
}

/* ─── LRP TAB BAR ────────────────────────────────────────────────────────── */

#lrp-header-tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--lm-surface);
  border-bottom: 1px solid var(--lm-border);
  padding: 0 12px;
  gap: 0;
  flex-shrink: 0;
}
#lrp-header-tabs::-webkit-scrollbar { display: none; }

/* ─── LRP PROBLEM PANE ───────────────────────────────────────────────────── */

#lrp-pane-problem { overflow-y: auto; background: var(--lm-surface); }

.lrp-problem { padding: 14px 16px 20px; display: flex; flex-direction: column; gap: 12px; }

.lrp-problem-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.lrp-problem-title {
  margin: 0;
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--lm-text);
  flex: 1 1 0;
  min-width: 0;
}

.lrp-problem-desc {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--lm-text-dim);
  line-height: 1.6;
}

.lrp-req-section { display: flex; flex-direction: column; gap: 6px; }

.lrp-req-heading {
  margin: 0;
  font-size: var(--fs-xss);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--lm-accent);
}

.lrp-req-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.lrp-req-list li { font-size: var(--fs-sm); color: var(--lm-text); line-height: 1.55; }

/* ─── LRP EMPTY STATE ────────────────────────────────────────────────────── */

.lrp-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 40px 20px; text-align: center; }
.lrp-empty-title { font-size: var(--fs-sm); font-weight: 600; color: var(--lm-text-dim); }
.lrp-empty-sub   { font-size: var(--fs-xs); color: var(--lm-text-muted); line-height: 1.5; }

/* ─── LRP SIMULATE FOOTER ────────────────────────────────────────────────── */

.lrp-sim-footer {
  flex-shrink: 0;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem 0.65rem;
  background: var(--lm-surface);
  border-top: 1px solid var(--lm-border);
}
.lrp-sim-footer .button { flex: 1; padding: 0.75rem 1.25rem; font-size: var(--fs-sm); border-radius: 10px; }

/* ─── STAGE PICKER ───────────────────────────────────────────────────────── */

/* Positioning context so the floating title pill anchors correctly */
body.mode-learn .simulation-panel {
  position: relative;
}

/* Problem title pill — sits at top of right panel content, centered */
body.mode-learn .learn-problem-title {
  display: block;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: 12px auto 0;
  padding: 5px 16px;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.92);
  border: 1px solid var(--lm-border);
  box-shadow: 0 1px 6px rgba(2, 6, 23, 0.07);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--lm-text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

body.mode-learn .learn-stage-picker {
  background: var(--lm-surface);
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--lm-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.mode-learn .learn-stage-picker-label,
body.mode-learn .learn-stage-picker label {
  color: var(--lm-text-muted);
  font-size: var(--fs-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin: 0;
}

/* ─── STAGE THEORY INNER SECTIONS ────────────────────────────────────────── */

body.mode-learn .stage-theory .guide-section-label {
  color: var(--lm-text-dim);
  font-size: var(--fs-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 14px 4px;
}

body.mode-learn .stage-theory .guide-breakdown-card {
  background: var(--lm-surface);
  border-color: var(--lm-border);
}

body.mode-learn .stage-theory details.guide-component-card {
  background: var(--lm-surface);
  border: 1px solid var(--lm-border);
  border-radius: 8px;
  margin: 0 12px 6px;
  overflow: hidden;
}

body.mode-learn .stage-theory details.guide-component-card summary {
  padding: 9px 12px;
  color: var(--lm-text);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  background: var(--lm-surface-2);
  transition: background 0.15s;
}

body.mode-learn .stage-theory details.guide-component-card summary:hover {
  background: var(--lm-accent-dim);
}

body.mode-learn .stage-theory details.guide-component-card .guide-component-card-body {
  padding: 10px 12px;
  border-top: 1px solid var(--lm-border);
}

body.mode-learn .stage-theory .guide-kb-value {
  font-size: var(--fs-xs);
  color: var(--lm-text-dim);
  line-height: 1.5;
}

body.mode-learn .stage-theory .guide-kb-row {
  padding: 5px 0;
  border-bottom: 1px solid var(--lm-border-faint);
}
body.mode-learn .stage-theory .guide-kb-row:last-child { border-bottom: none; }

body.mode-learn .guide-new-badge {
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: var(--lm-accent-dim);
  color: var(--lm-accent);
  border: 1px solid var(--lm-accent-ring);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ─── THEORY OVERLAY ─────────────────────────────────────────────────────── */

body.mode-learn .theory-overlay {
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(4px);
}

body.mode-learn .theory-overlay-inner {
  background: var(--lm-surface);
  border: 1px solid var(--lm-border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
  border-radius: 14px;
  overflow: hidden;
}

body.mode-learn .theory-overlay-header {
  background: var(--lm-surface-2);
  border-bottom: 1px solid var(--lm-border);
  padding: 20px 24px 16px;
}

body.mode-learn .theory-overlay-title {
  color: var(--lm-text);
  font-size: var(--fs-lg);
  font-weight: 700;
}

body.mode-learn .theory-overlay-desc {
  color: var(--lm-text-dim);
  font-size: var(--fs-sm);
  line-height: 1.5;
  margin-top: 5px;
}

body.mode-learn .theory-overlay-body {
  background: var(--lm-surface);
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

body.mode-learn .theory-section-title {
  font-size: var(--fs-xss);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lm-accent);
  margin-bottom: 8px;
}

body.mode-learn .theory-req-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }

body.mode-learn .theory-req-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 8px; }
body.mode-learn .theory-req-item.fr-item  { background: var(--lm-accent-dim);  border: 1px solid var(--lm-accent-ring); }
body.mode-learn .theory-req-item.nfr-item { background: var(--lm-purple-bg); border: 1px solid rgba(124,58,237,0.15); }

body.mode-learn .req-index {
  font-size: var(--fs-micro);
  font-weight: 700;
  background: var(--lm-accent-dim);
  color: var(--lm-accent);
  width: 18px; height: 18px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

body.mode-learn .req-text    { font-size: var(--fs-xs); color: var(--lm-text); line-height: 1.5; }
body.mode-learn .nfr-label   { font-size: var(--fs-micro); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--lm-purple); display: block; margin-bottom: 2px; }
body.mode-learn .nfr-detail  { font-size: var(--fs-xs); color: var(--lm-text-dim); line-height: 1.45; }

body.mode-learn .theory-difficulty-badge { font-size: var(--fs-micro); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; display: inline-block; margin-bottom: 6px; }
body.mode-learn .theory-difficulty-badge.diff-easy                                         { background: var(--lm-green-bg); color: var(--lm-green); border: 1px solid rgba(22,163,74,0.2);  }
body.mode-learn .theory-difficulty-badge.diff-intermediate,
body.mode-learn .theory-difficulty-badge.diff-medium                                       { background: var(--lm-amber-bg); color: var(--lm-amber); border: 1px solid rgba(217,119,6,0.2);  }
body.mode-learn .theory-difficulty-badge.diff-hard,
body.mode-learn .theory-difficulty-badge.diff-advanced                                     { background: var(--lm-red-bg);   color: var(--lm-red);   border: 1px solid rgba(220,38,38,0.2);  }

body.mode-learn .theory-concepts-tags { display: flex; flex-wrap: wrap; gap: 6px; }
body.mode-learn .theory-concept-chip  { font-size: var(--fs-xss); font-weight: 600; padding: 3px 10px; border-radius: 4px; background: var(--lm-purple-bg); border: 1px solid rgba(124,58,237,0.18); color: var(--lm-purple); }

body.mode-learn .theory-arch-row { display: grid; grid-template-columns: 130px 1fr; gap: 8px; padding: 7px 10px; background: var(--lm-surface-2); border: 1px solid var(--lm-border); border-radius: 7px; }
body.mode-learn .theory-arch-key { font-size: var(--fs-xss); font-weight: 600; color: var(--lm-text-dim); text-transform: capitalize; }
body.mode-learn .theory-arch-val { font-size: var(--fs-xs); color: var(--lm-text); }

body.mode-learn .theory-close-btn {
  background: var(--lm-surface-2);
  border: 1px solid var(--lm-border);
  color: var(--lm-text-dim);
  border-radius: 8px;
  padding: 5px 10px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
body.mode-learn .theory-close-btn:hover {
  background: var(--lm-accent-dim);
  color: var(--lm-accent);
  border-color: var(--lm-accent-ring);
}

/* ─── CANVAS — stage transition + bottleneck pulse ──────────────────────── */

@keyframes lm-node-arrive {
  from { opacity: 0; transform: scale(0.88) translateY(6px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

body.mode-learn.stage-transitioning .node.lm-new-node {
  animation: lm-node-arrive 0.35s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes lm-btk-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(220,38,38,0.3), 0 0 12px rgba(220,38,38,0.15); }
  50%       { box-shadow: 0 0 0 5px rgba(220,38,38,0.35), 0 0 24px rgba(220,38,38,0.25); }
}

body.mode-learn .node.btk-high {
  animation: lm-btk-pulse 0.9s ease-in-out infinite !important;
}
