/* ==========================================================================
   StudyOps — simplex.css
   simplex-format 代码块（线性规划模型 / 单纯形表）渲染样式

   与 668 同源：类名与规则直接来自
   `666——检测与复盘(实验性)/11——组卷工具/896css/simplex-renderer.css`（v1.4.0），
   只在最前面加一段主题变量垫片——原 CSS 吃 Obsidian 主题变量
   （--text-normal / --text-muted / --text-error / --background-secondary / --radius-s），
   503 里没有这些变量时边框与背景会整体失效，块会退化成「没有 CSS」的裸文本。
   ========================================================================== */

/* ---------- 主题变量垫片：把 Obsidian 变量映射到 503 token ---------- */
.simplex-format {
  --text-normal: var(--text);
  --text-muted: var(--sub);
  --text-error: var(--red-500);
  --background-secondary: var(--soft-panel);
  --radius-s: 6px;
}

.simplex-format {
  --simplex-line: var(--text-normal);
  width: 100%;
  margin: 1.25em auto;
  color: var(--text-normal);
  text-align: center;
}

.simplex-format__scroll {
  display: flex;
  justify-content: safe center;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25em 0 0.45em;
}

.simplex-format__model {
  display: inline-block;
  min-width: max-content;
  font-size: 1.05em;
}

.simplex-format__table {
  width: auto;
  min-width: max-content;
  margin: 0 auto;
  border-collapse: collapse;
  border-top: 4px double var(--simplex-line) !important;
  border-right: 0 !important;
  border-bottom: 4px double var(--simplex-line) !important;
  border-left: 0 !important;
  /* 隔离主题给普通 Markdown 表格添加的右下阴影。 */
  box-shadow: none !important;
  font-size: 1em;
  line-height: 1.35;
}

.simplex-format__table th,
.simplex-format__table td {
  min-width: 2.35em;
  padding: 0.22em 0.62em;
  border: 0 !important;
  background: transparent !important;
  color: var(--text-normal);
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

/* c_j 行下方有横线；跨两行的 theta 单元格只在表头底部落线。 */
.simplex-format__table .simplex-format__cj-row > :not(.simplex-format__theta),
.simplex-format__table .simplex-format__head-row > *,
.simplex-format__table .simplex-format__cj-row > .simplex-format__theta {
  border-bottom: 1px solid var(--simplex-line) !important;
}

/* 数据行之间不画横线。对偶法有 ratio 行时在其上方画线；否则仍在 sigma 行上方画线。 */
.simplex-format__table .simplex-format__ratio-row > *,
.simplex-format__table .simplex-format__summary-start > * {
  border-top: 1px solid var(--simplex-line) !important;
}

/* 唯一两条竖线：b 与 x1 之间、最后一个 x 与 theta 之间。 */
.simplex-format__table .simplex-format__after-b {
  border-right: 1px solid var(--simplex-line) !important;
}

.simplex-format__table .simplex-format__theta {
  border-left: 1px solid var(--simplex-line) !important;
  border-right: 0 !important;
}

.simplex-format__table tr > :first-child {
  border-left: 0 !important;
}

.simplex-format__table tr > :last-child {
  border-right: 0 !important;
}

.simplex-format__strong .katex,
.simplex-format__strong .MathJax,
.simplex-format__strong .mjx-chtml,
.simplex-format__strong .mjx-container,
.simplex-format__strong {
  font-weight: 700 !important;
}

.simplex-format__error,
.simplex-format__notice {
  max-width: 46em;
  margin: 0.45em auto 1em;
  padding: 0.55em 0.8em;
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius-s);
  background: var(--background-secondary);
  text-align: left;
  white-space: pre-wrap;
}

.simplex-format__error {
  border-left-color: var(--text-error);
  color: var(--text-error);
}

.simplex-format__notice {
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .simplex-format__table th,
  .simplex-format__table td {
    min-width: 1.9em;
    padding-right: 0.42em;
    padding-left: 0.42em;
  }
}

/* ---------- 503 答题卡内排版：题干区收紧上下留白，窄屏允许横向滑动 ---------- */
.qcard-stem .simplex-format {
  margin: 10px 0 6px;
  font-size: 1em;
}

.qcard-stem .simplex-format__model {
  font-size: 1em;
}

.qcard-stem .simplex-format .katex-display {
  margin: 2px 0;
}

.qcard-stem .simplex-format__scroll {
  padding: 0 0 2px;
}

/* KaTeX 未就绪/渲染失败时的裸代码兜底：至少是等宽块，不并进正文 */
.qcard-simplex-raw {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: var(--soft-panel);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--sub);
}
