/* Pyodide-based `mp-cell--animate` cells for courses that don't ship the
   full math-with-python cell infrastructure (pre-algebra, algebra-1).
   Class names match math-with-python's inline styles so future refactors
   can consolidate if that becomes a priority. */

.mp-cell { margin: 18px 0; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }

.mp-cell-code { font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: #0b111c; color: #f0ece2; padding: 12px 14px;
  border-radius: 8px; overflow-x: auto; font-size: 0.88rem;
  white-space: pre; margin: 0; border: 1px solid #1c2b3f; }

.mp-cell-toolbar { margin-top: 10px; display: flex; align-items: center; gap: 8px; }

.mp-cell-run { padding: 6px 14px; border-radius: 100px;
  background: var(--gold); color: #ffffff; border: none;
  font-weight: 700; cursor: pointer; font-size: 0.86rem;
  transition: filter 0.15s ease; }
.mp-cell-run:hover:not(:disabled) { filter: brightness(1.06); }
.mp-cell-run:disabled { opacity: 0.5; cursor: default; }

.mp-cell-status { font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem; color: var(--text-muted); }

.mp-cell-output { margin-top: 12px; padding: 10px 14px;
  background: #0b111c; border-left: 3px solid var(--gold);
  border-radius: 4px;
  color: #f0ece2; font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.88rem; white-space: pre-wrap; }
.mp-cell-output img { max-width: 100%; height: auto; display: block; margin: 8px 0; }
.mp-cell-output:empty { display: none; }

/* Animate cells hide the raw code entirely — student just clicks Run. */
.mp-cell--animate .mp-cell-code { display: none; }
.mp-cell--animate .mp-cell-run { padding: 10px 22px; font-size: 0.95rem; }

/* Reset the pre-wrap + block-image inheritance from .mp-cell-output so
   matplotlib's to_jshtml() output renders as authored (buttons inline,
   initial frame img not forced to display:block/margin). */
.mp-cell-html-out { white-space: normal; margin-top: 12px; text-align: center; color: #ddd; }
.mp-cell-html-out img { display: inline-block; margin: 0; max-width: 100%; height: auto; }
.mp-cell-html-out .anim-buttons { display: inline-block; margin: 6px 0; }
.mp-cell-html-out button { display: inline-block; }

/* Grapher cell — student types an expression, gets a plot. Reuses the
   same runner + output element as animate cells; visible only when
   the cell has both mp-cell and mp-cell--grapher classes. */
.mp-cell--grapher .mp-cell-code { display: none; }
.mp-cell--grapher .mp-cell-grapher-input {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  font-family: 'JetBrains Mono', monospace; font-size: 0.95rem;
}
.mp-cell--grapher .mp-cell-grapher-input label {
  color: var(--text); font-weight: 700; white-space: nowrap;
}
.mp-cell-grapher-expr {
  flex: 1; padding: 8px 12px; border-radius: 6px;
  border: 1px solid var(--border); background: #f7f5ef; color: #0f2e4a;
  font: inherit;
}
.mp-cell-grapher-expr:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.mp-cell--grapher .mp-cell-run { padding: 8px 16px; font-size: 0.9rem; }

/* Step-check cell — student types algebra steps, SymPy verifies each. */
.mp-cell--stepcheck .mp-cell-code { display: none; }
.mp-cell--stepcheck .mp-cell-stepcheck-problem {
  font-family: 'JetBrains Mono', monospace; font-weight: 700;
  font-size: 1.05rem;
  /* Fixed dark color rather than var(--text) — background is a hardcoded
     light beige, so a theme-driven light --text (dark-mode default) would
     render invisible on it. */
  color: #0f2e4a;
  margin: 8px 0 12px;
  padding: 8px 12px; background: #eee9d8; border-left: 4px solid var(--gold);
  border-radius: 4px;
}
.mp-cell-stepcheck-input {
  width: 100%; min-height: 120px; padding: 10px 12px;
  border-radius: 6px; border: 1px solid var(--border); background: #f7f5ef;
  color: #0f2e4a; font-family: 'JetBrains Mono', monospace; font-size: 0.9rem;
  line-height: 1.6; resize: vertical;
}
.mp-cell-stepcheck-input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.mp-cell--stepcheck .mp-cell-run { padding: 8px 16px; font-size: 0.9rem; }
.mp-cell--stepcheck .mp-cell-output { white-space: pre-wrap; font-size: 0.92rem; }

/* Practice-problem walkthrough / wizard tabs. Cards that ship a solve
   wizard show two tabs at the top of the ex-worked-content column: the
   authored walkthrough (default) and the wizard (Try it yourself). Graph
   illustration stays visible in both modes since it lives in the sibling
   .ex-illustration column, outside the tab-switched area. Shared across
   algebra-1 and pre-algebra practice cards. */
.problem-tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.problem-tab {
  padding: 8px 16px;
  background: transparent; border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted); font: inherit;
  font-size: 0.88rem; font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.problem-tab:hover { color: var(--text); }
.problem-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.problem-panel { display: none; }
.problem-panel.active { display: block; }

/* When the wizard's try-panel is showing, the student's attention is on
   the ops, not the illustration — shrink the graph column so the wizard
   has more horizontal room. Walkthrough tab keeps the full-size graph. */
.problem .ex-worked-row:has(.problem-panel--try.active) {
  grid-template-columns: minmax(0, 1fr) 260px;
}

/* Solve wizard — no typing, just an operation menu. The running history
   IS the primary display: each row is a KaTeX-rendered equation with a
   short "(after ...)" tag. Ops are grouped into two labeled sections so
   the visual hierarchy matches the student's mental model: simplify one
   side vs. balance both sides. Reset floats top-right as a subtle
   secondary action. */
.mp-cell--solvewizard { padding: 12px 14px; }
.wizard-ops {
  position: relative;
  display: flex; flex-direction: column;
  gap: 10px; margin: 0 0 12px;
}
.wizard-op-group { display: flex; flex-direction: column; gap: 5px; }
.wizard-op-label {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--text-muted);
}
.wizard-op-buttons {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.wizard-op-row { display: inline-flex; gap: 4px; align-items: stretch; }
.wizard-op {
  padding: 7px 12px; border-radius: 6px;
  background: #f7f5ef; color: #0f2e4a;
  border: 1px solid var(--border);
  font: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: filter 0.15s ease;
}
.wizard-op:hover:not(:disabled) { filter: brightness(0.97); border-color: var(--gold); }
.wizard-op:disabled { opacity: 0.5; cursor: default; }
.wizard-op--reset {
  position: absolute; top: 0; right: 0;
  background: transparent; color: var(--text-muted);
  padding: 4px 8px; font-size: 0.78rem;
}
.wizard-arg {
  width: 72px; padding: 7px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: #f7f5ef; color: #0f2e4a;
  font: inherit; font-size: 0.9rem; text-align: center;
  font-family: 'JetBrains Mono', monospace;
}
.wizard-arg:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
/* Running-history display. Each line is one solved step; all lines stay
   visible so the student sees the whole chain from start to solution. */
.wizard-history {
  list-style: none; margin: 0; padding: 12px 14px;
  background: #f3efe4; border-left: 3px solid var(--gold);
  border-radius: 4px; color: #0f2e4a;
}
.wizard-history:empty { display: none; }
.wizard-history li {
  display: flex; align-items: baseline; gap: 14px;
  padding: 4px 0; border-bottom: 1px dashed #d8d1bd; line-height: 1.6;
}
.wizard-history li:last-child { border-bottom: 0; }
.wizard-history li:last-child .wizard-line-math { font-weight: 700; }
.wizard-line-math { font-size: 1.05rem; flex: 1; }
.wizard-line-tag {
  font-family: 'JetBrains Mono', monospace; font-size: 0.78rem;
  color: #6b6b6b; white-space: nowrap;
}
/* Inequality direction-flip callout — appears next to the op tag on the
   step where the wizard reversed <, >, ≤, ≥ (mul or div by a negative).
   Red so the student's eye lands on the exact rule they most often
   forget in their own work. */
.wizard-line-flip {
  font-family: 'JetBrains Mono', monospace; font-size: 0.78rem;
  font-weight: 700; color: #c94f42; white-space: nowrap;
}
.wizard-status {
  font-family: 'JetBrains Mono', monospace; font-size: 0.9rem;
  font-weight: 700; margin-top: 8px;
}
.wizard-status:empty { display: none; }
