/* ==========================================================================
   在线体验页
   复用 style.css 的变量与 pages.css 的页头 / 区块骨架，仅补齐工作台
   ========================================================================== */

.demo-section { padding-top: 54px; }

.demo-workbench {
  display: grid;
  grid-template-columns: 1.02fr 1fr;
  gap: 22px;
  align-items: stretch;
}

.demo-panel {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  padding: 22px 22px 24px;
}

.demo-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.demo-panel-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -.006em;
  color: var(--ink);
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 7px;
  background: #eef2ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.demo-mode {
  font-size: 11.5px;
  font-weight: 650;
  padding: 4px 10px;
  border-radius: 100px;
  background: #f1f5f9;
  color: var(--muted);
  white-space: nowrap;
}
.demo-mode[data-state="sample"] { background: var(--amber-bg, #fef3c7); color: #92400e; }
.demo-mode[data-state="live"] { background: var(--green-bg, #dcfce7); color: #15803d; }
.demo-mode[data-state="off"] { background: #f1f5f9; color: var(--ink-4, #94a3b8); }

/* ---------- 上传区 ---------- */

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  padding: 30px 20px;
  border: 1.5px dashed #cbd5e1;
  border-radius: 14px;
  background: #fbfcff;
  cursor: pointer;
  text-align: center;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.dropzone:hover,
.dropzone:focus-visible { border-color: #a5b4fc; background: #f7f8ff; }
.dropzone.is-drag { border-color: var(--primary); background: #eef2ff; transform: scale(1.004); }
.dz-icon {
  display: inline-grid;
  place-items: center;
  width: 46px; height: 46px;
  margin-bottom: 12px;
  border-radius: 13px;
  background: #eef2ff;
  color: var(--primary);
}
.dz-title { font-size: 14.5px; font-weight: 650; color: var(--ink-2); }
.dz-hint { font-size: 12.5px; color: var(--muted-2); margin-top: 6px; }

/* ---------- 图片预览 ---------- */

.shot-preview { margin-top: 14px; }
.shot-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 120px;
  max-height: 260px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
  overflow: hidden;
}
.shot-frame img {
  max-width: 100%;
  max-height: 232px;
  object-fit: contain;
  border-radius: 6px;
}
.scan-line {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 44px;
  background: linear-gradient(180deg, rgba(79, 70, 229, 0), rgba(79, 70, 229, .16) 70%, rgba(79, 70, 229, .34));
  border-bottom: 1px solid rgba(79, 70, 229, .5);
  animation: scanDown 1.15s ease-in-out infinite;
  pointer-events: none;
}
@keyframes scanDown {
  0% { transform: translateY(-44px); opacity: 0; }
  18% { opacity: 1; }
  82% { opacity: 1; }
  100% { transform: translateY(260px); opacity: 0; }
}
.shot-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.shot-name {
  font-size: 12.5px;
  color: var(--muted-2);
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 示例缩略图 ---------- */

.demo-samples { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.samples-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-2);
}
.samples-tip { font-weight: 400; color: var(--muted-2); font-size: 11.5px; }
.samples-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.sample-thumb {
  display: grid;
  place-items: center;
  padding: 10px 12px;
  height: 88px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
  overflow: hidden;
}
.sample-thumb img { max-width: 100%; max-height: 66px; object-fit: contain; }
.sample-thumb:hover { border-color: #a5b4fc; transform: translateY(-2px); box-shadow: 0 8px 18px rgba(79, 70, 229, .12); }
.sample-thumb.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }

/* ---------- 结果区 ---------- */

.demo-status { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; }

.result-empty {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  flex: 1;
  min-height: 292px;
  padding: 30px 20px;
  border: 1px dashed #e2e8f0;
  border-radius: 14px;
  background: #fcfdff;
  text-align: center;
}
.empty-mark {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 44px;
  color: #e0e7ff;
  line-height: 1;
}
.result-empty p { font-size: 13px; color: var(--muted-2); line-height: 1.85; }

.result-loading {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  flex: 1;
  min-height: 292px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fcfdff;
}
.loading-bars { display: flex; gap: 5px; align-items: flex-end; height: 24px; }
.loading-bars i {
  display: block;
  width: 5px;
  border-radius: 3px;
  background: var(--primary);
  animation: barPulse 1s ease-in-out infinite;
}
.loading-bars i:nth-child(1) { height: 12px; animation-delay: 0s; }
.loading-bars i:nth-child(2) { height: 22px; animation-delay: .12s; }
.loading-bars i:nth-child(3) { height: 16px; animation-delay: .24s; }
@keyframes barPulse {
  0%, 100% { transform: scaleY(.55); opacity: .55; }
  50% { transform: scaleY(1); opacity: 1; }
}
.result-loading p { font-size: 13px; color: var(--muted); }

.result-body { display: flex; flex-direction: column; flex: 1; }
.result-preview {
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 116px;
  padding: 20px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcff;
  overflow-x: auto;
  color: var(--ink);
}
.result-preview mjx-container { max-width: 100%; }
.result-preview svg { max-width: 100%; height: auto; }
.result-preview.is-error { background: var(--red-bg, #fef2f2); border-color: #f6d5d5; }
.result-preview.is-error::before {
  content: "这段 LaTeX 还渲染不出来，检查一下括号和反斜杠";
  font-size: 12.5px;
  color: #b91c1c;
}

.result-editor { margin-top: 14px; }
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.editor-head label { font-size: 12px; font-weight: 650; color: var(--muted); letter-spacing: .02em; }
.editor-tools { display: flex; gap: 6px; }
#latexInput {
  width: 100%;
  resize: vertical;
  min-height: 108px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfe;
  color: var(--ink);
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.75;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
#latexInput:focus {
  outline: none;
  border-color: #a5b4fc;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}
.editor-note { font-size: 11.5px; color: var(--muted-2); margin-top: 8px; line-height: 1.7; }

.result-error {
  flex: 1;
  padding: 26px 24px;
  border: 1px solid #f6d5d5;
  border-radius: 14px;
  background: #fffafa;
}
.result-error strong { display: block; font-size: 14.5px; color: #991b1b; margin-bottom: 8px; }
.result-error p { font-size: 13px; color: #7f1d1d; line-height: 1.8; }
.error-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ---------- 说明三条 ---------- */

.demo-notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 30px;
}
.demo-note {
  padding: 18px 20px;
  border-left: 2px solid #e0e7ff;
}
.demo-note h3 { font-size: 13.5px; font-weight: 700; margin-bottom: 7px; }
.demo-note p { font-size: 12.5px; color: var(--muted); line-height: 1.8; }

/* ---------- 响应式 ---------- */

@media (max-width: 1000px) {
  .demo-workbench { grid-template-columns: 1fr; }
  .demo-notes { grid-template-columns: 1fr; gap: 4px; }
  .demo-note { border-left: none; border-top: 1px solid var(--line); padding: 14px 0 0; }
  .demo-note:first-child { border-top: none; padding-top: 0; }
}

@media (max-width: 560px) {
  .demo-panel { padding: 18px 16px 20px; border-radius: 16px; }
  .dropzone { padding: 24px 14px; }
  .sample-thumb { height: 76px; }
  .sample-thumb img { max-height: 54px; }
  .result-empty, .result-loading { min-height: 220px; }
  .samples-head { flex-direction: column; align-items: flex-start; gap: 3px; }
  .editor-head { flex-wrap: wrap; }
}

/* ---------- MathJax 基础样式 ----------
   tex-svg.js 单文件不带 CSS，缺了这几条会让辅助 MathML 也显示出来，
   看起来像同一个公式渲染了两遍 */
mjx-container[jax="SVG"] { direction: ltr; }
mjx-container[jax="SVG"] > svg { overflow: visible; min-height: 1px; min-width: 1px; }
mjx-container[jax="SVG"][display="true"] { display: block; text-align: center; margin: 0 auto; }
mjx-assistive-mml {
  position: absolute !important;
  top: 0; left: 0;
  clip: rect(1px, 1px, 1px, 1px);
  padding: 1px 0 0 0;
  border: 0;
  width: auto;
  overflow: hidden;
  display: block;
  user-select: none;
}
