/* ============================================================
   MathLingua · 可视化教具样式 (Visual Manipulatives)
   ============================================================ */

.vm {
  width: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  position: relative;
}
.vm-row { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.vm-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }

.vm-note {
  font-size: 12px; font-weight: 800; color: var(--text-soft);
  text-align: center; line-height: 1.4;
}
.vm-note b { color: var(--blue-deep); }

.vm-sum {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--yellow-soft); color: var(--yellow-deep);
  border-radius: var(--radius-pill);
  padding: 5px 14px;
  font-size: 15px; font-weight: 900;
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  font-variant-numeric: tabular-nums;
}
.vm-sum.show { opacity: 1; transform: none; }

.vm-tag {
  font-size: 11px; font-weight: 800; color: var(--blue-deep);
  background: var(--blue-soft);
  padding: 2px 8px; border-radius: var(--radius-pill);
}

/* 飞行动画层 */
.vm-fly-layer {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 20;
  overflow: visible;
}
.vm-fly {
  position: absolute; left: 0; top: 0;
  display: grid; place-items: center;
  font-size: 18px; line-height: 1;
  will-change: transform;
}

/* ===================== 十格阵 ===================== */
.tf-box { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tf-frame {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  background: #fff;
  border: 3px solid #cfe2ef;
  border-radius: 12px;
  padding: 5px;
  box-shadow: 0 3px 0 #eaf2f8;
}
.tf-cell {
  width: 30px; height: 30px;
  border: 2px solid #eaf1f7;
  border-radius: 7px;
  background: #f8fcff;
  display: grid; place-items: center;
  transition: background 0.25s ease, border-color 0.25s ease;
}
.tf-cell.hl { background: var(--yellow-soft); border-color: #ffe08a; }
.tf-cell.full { background: #f2ffe9; border-color: #cbeab3; }
.tf-dot {
  width: 21px; height: 21px; border-radius: 50%;
  opacity: 0; transform: scale(0.2);
  transition: transform 0.32s cubic-bezier(0.2, 1.5, 0.4, 1), opacity 0.22s ease;
}
.tf-dot.on { opacity: 1; transform: scale(1); }
.tf-dot.c-green { background: radial-gradient(circle at 32% 28%, #b6f07a, #58cc02); }
.tf-dot.c-orange { background: radial-gradient(circle at 32% 28%, #ffcf8a, #ff9600); }
.tf-dot.c-blue { background: radial-gradient(circle at 32% 28%, #a9e3ff, #1cb0f6); }
.tf-cap { font-size: 11px; font-weight: 800; color: var(--text-muted); }

/* ===================== 数轴 ===================== */
.nl-svg { width: 100%; max-width: 360px; height: auto; display: block; }
.nl-tick { stroke: #dbe7ee; stroke-width: 1.5; }
.nl-tick.major { stroke: #b9cddb; stroke-width: 2.4; }
.nl-label { font-size: 9px; fill: #9aabba; font-weight: 700; font-family: inherit; }
.nl-label.hl { fill: #0b6f9e; font-weight: 900; }
.nl-line { stroke: #cfe0ea; stroke-width: 3; stroke-linecap: round; }
.nl-jump { fill: none; stroke: #ff9600; stroke-width: 2.6; stroke-linecap: round; opacity: 0; transition: opacity 0.2s ease; }
.nl-jump.show { opacity: 1; }
.nl-frog { font-size: 16px; }

/* ===================== 乘法阵列 ===================== */
.ag-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ag-grid { display: grid; gap: 4px; }
.ag-cell {
  display: grid; place-items: center;
  border-radius: 6px;
  background: #fff7ed;
  border: 2px solid #ffe3c4;
  opacity: 0.42;
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.25s ease;
}
.ag-cell.lit { opacity: 1; transform: scale(1.04); background: #fff1e0; }
.ag-cell.rowhl { background: var(--yellow-soft); border-color: #ffd979; }
.ag-cell .ag-emoji { font-size: 15px; line-height: 1; }
.ag-cell.cover::after {
  content: "?";
  position: absolute;
  font-size: 13px; color: #b26b00;
}
.ag-cell.cover { position: relative; background: #fff8ea; border: 2px dashed #ffd285; opacity: 1; }
.ag-rowlabel { font-size: 10px; color: var(--text-muted); font-weight: 800; }
.ag-side { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.ag-stack { display: flex; align-items: flex-start; gap: 6px; }

/* ===================== 分物装盘 ===================== */
.plates { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: flex-start; }
.plate {
  width: 74px; height: 74px;
  border-radius: 50%;
  border: 3px dashed #cfe0ec;
  background: #fbfdff;
  display: grid; place-items: center;
  position: relative;
  transition: border-color 0.3s ease, background 0.3s ease;
}
.plate.filled { border-style: solid; border-color: #ffd479; background: #fffdf6; }
.plate-inner { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; }
.plate-inner .candy { font-size: 13px; line-height: 1; }
.plate-num {
  position: absolute; bottom: -9px;
  background: var(--blue-soft); color: var(--blue-deep);
  font-size: 10px; font-weight: 900;
  padding: 1px 7px; border-radius: var(--radius-pill);
}
.rest-zone {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 2px dashed #ffd0d0;
  background: #fff8f8;
  min-width: 92px;
}
.rest-zone .rest-candies { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
.rest-zone .rest-cap { font-size: 10px; font-weight: 800; color: var(--red-dark); }

/* ===================== 线段图 Bar Model ===================== */
.bm { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.bm-row { display: flex; align-items: center; gap: 6px; }
.bm-label {
  flex: none; width: 56px;
  font-size: 10.5px; font-weight: 800; color: var(--text-muted);
  line-height: 1.25;
  text-align: right;
}
.bm-track {
  flex: 1; display: flex;
  height: 32px;
  border-radius: 9px;
  border: 2px solid #dce9f2;
  background: #fff;
  overflow: hidden;
  position: relative;
}
.bm-seg {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 900; color: #fff;
  transition: width 0.45s cubic-bezier(0.2, 0.9, 0.3, 1), background 0.3s ease;
  border-right: 2px solid rgba(255, 255, 255, 0.55);
  overflow: hidden; white-space: nowrap;
}
.bm-seg:last-child { border-right: none; }
.bm-seg.green { background: #7fd63f; }
.bm-seg.blue { background: #4cc4f8; }
.bm-seg.orange { background: #ffab3d; }
.bm-seg.purple { background: #c793f5; }
.bm-seg.hollow { background: #fff; color: var(--text-muted); border: 2px dashed #cfdde7; }
.bm-brace {
  font-size: 11px; font-weight: 900; color: var(--orange-dark);
  text-align: center;
  opacity: 0; transform: translateY(-3px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.bm-brace.show { opacity: 1; transform: none; }
.bm-gap { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; color: var(--text-muted); }
.bm-mark {
  position: absolute; top: 0; bottom: 0; width: 3px;
  background: var(--red);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.bm-mark.show { opacity: 1; }

/* ===================== 图形 ===================== */
.shp-svg { max-width: 220px; width: 100%; height: auto; }
.shp-side { stroke: #0b6f9e; stroke-width: 3.4; fill: none; stroke-linejoin: round; }
.shp-side.hl { stroke: #ff9600; stroke-width: 5; }
.shp-face { fill: #d6f0ff; stroke: #1cb0f6; stroke-width: 3.4; stroke-linejoin: round; }
.shp-name { font-size: 11px; fill: #7b8c99; font-weight: 800; }

/* ===================== 面积格子 ===================== */
.ga-svg { max-width: 320px; width: 100%; height: auto; }
.ga-cell { fill: #fff; stroke: #d9e8f2; stroke-width: 1; transition: fill 0.3s ease; }
.ga-cell.on { fill: #ffd76b; stroke: #e8b93c; }
.ga-cell.edge { fill: #b7e59b; stroke: #7cc94a; }
.ga-outline { fill: none; stroke: #4b4b4b; stroke-width: 2.4; stroke-dasharray: 6 5; }
.ga-label { font-size: 10px; fill: #7b8c99; font-weight: 800; }
.ga-unit { fill: #ffe9a8; stroke: #e5a500; stroke-width: 1.4; }

/* ===================== 钟表 ===================== */
.clk-svg { width: 190px; height: 190px; max-width: 60vw; }
.clk-face { fill: #fff; stroke: #cfe2ef; stroke-width: 4; }
.clk-tick { stroke: #dbe8f1; stroke-width: 2; }
.clk-tick.major { stroke: #a9c6d8; stroke-width: 3; }
.clk-num { font-size: 11px; fill: #6b7c88; font-weight: 900; text-anchor: middle; font-family: inherit; }
.clk-hand {
  transform-box: view-box;
  transform-origin: 100px 100px;
  transition: transform 0.9s cubic-bezier(0.34, 1.2, 0.64, 1);
  stroke-linecap: round;
}
.clk-hour { stroke: #4b4b4b; stroke-width: 6; }
.clk-min { stroke: #1cb0f6; stroke-width: 4; }
.clk-center { fill: #ff9600; stroke: #fff; stroke-width: 2; }
.clk-digital {
  font-size: 20px; font-weight: 900; color: var(--blue-deep);
  letter-spacing: 1px;
  background: var(--blue-soft);
  padding: 3px 14px; border-radius: var(--radius-pill);
  opacity: 0; transform: scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
  font-variant-numeric: tabular-nums;
}
.clk-digital.show { opacity: 1; transform: none; }

/* ===================== 立体图形 ===================== */
.solid-svg { max-width: 220px; width: 100%; height: auto; }
.solid-face { fill: #d6f0ff; stroke: #1cb0f6; stroke-width: 3; stroke-linejoin: round; }
.solid-face.back { fill: #bfe7fb; }
.solid-face.top { fill: #e6f7ff; }
.solid-edge { stroke: #1899d6; stroke-width: 2; }
.solid-label { font-size: 11px; fill: #7b8c99; font-weight: 800; }

/* ===================== 分数披萨 ===================== */
.fp-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.fp-svg { width: 168px; height: 168px; max-width: 52vw; }
.fp-slice {
  transform-box: view-box;
  transform-origin: 90px 90px;
  transition: transform 0.4s cubic-bezier(0.2, 1.2, 0.4, 1), opacity 0.3s ease;
}
.fp-slice.on { transform: scale(1); }
.fp-caption { font-size: 12px; font-weight: 800; color: var(--text-soft); }
.fp-fraction { font-size: 22px; font-weight: 900; color: var(--purple-dark); }

/* ===================== 分数长条 ===================== */
.fb { width: 100%; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.fb-bar {
  display: flex; width: 100%; max-width: 320px;
  height: 40px; border-radius: 10px;
  border: 2px solid #e2d3ef; background: #fff; overflow: hidden;
}
.fb-cell {
  flex: 1;
  border-right: 1px solid #ecdff7;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 800; color: #b39fc4;
  background: #fff;
  transition: background 0.35s ease, color 0.35s ease;
}
.fb-cell:last-child { border-right: none; }
.fb-cell.a { background: #c793f5; color: #fff; }
.fb-cell.b { background: #ffab3d; color: #fff; }
.fb-cell.sum { background: #58cc02; color: #fff; }
.fb-cell.ghost { background: #faf6ff; }
.fb-eq { font-size: 15px; font-weight: 900; color: var(--text); letter-spacing: 1px; }

/* ===================== 小数数轴放大镜 ===================== */
.dl-wrap { position: relative; width: 100%; max-width: 340px; }
.dl-svg { width: 100%; height: auto; display: block; }
.dl-tick { stroke: #dbe7ee; stroke-width: 1.4; }
.dl-tick.major { stroke: #b9cddb; stroke-width: 2.2; }
.dl-label { font-size: 8px; fill: #9aabba; font-weight: 700; font-family: inherit; }
.dl-marker {
  opacity: 0;
  transition: opacity 0.3s ease;
}
.dl-marker.show { opacity: 1; }
.dl-magnifier {
  position: absolute; top: -4px;
  width: 54px; height: 54px; border-radius: 50%;
  border: 3px solid #ffc800;
  background: rgba(255, 252, 238, 0.72);
  box-shadow: 0 4px 10px rgba(229, 165, 0, 0.28);
  transform: translate(-50%, 0);
  transition: left 0.7s cubic-bezier(0.3, 0.9, 0.4, 1);
  pointer-events: none;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 900; color: #b26b00;
}
.dl-magnifier::after {
  content: "";
  position: absolute; bottom: -12px; left: 50%;
  width: 4px; height: 12px; background: #e5a500;
  transform: translateX(-50%); border-radius: 2px;
}

/* ===================== 行程相遇 ===================== */
.mt { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.mt-road {
  position: relative;
  height: 62px;
  border-radius: 12px;
  background: repeating-linear-gradient(90deg, #f3f7fa 0 22px, #eaf1f6 22px 44px);
  border: 2px solid #e2edf4;
  overflow: hidden;
}
.mt-road::after {
  content: "";
  position: absolute; left: 6%; right: 6%; top: 50%;
  border-top: 3px dashed #d3e2ec;
  transform: translateY(-50%);
}
.mt-car {
  position: absolute; top: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px; line-height: 1;
  transition: left 1.2s linear;
  z-index: 2;
}
.mt-car.b { transform: translate(-50%, -50%) scaleX(-1); }
.mt-flag {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 3;
}
.mt-flag.show { opacity: 1; }
.mt-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); font-weight: 800; }
.mt-note { display: flex; gap: 10px; justify-content: center; font-size: 11px; font-weight: 800; color: var(--text-soft); flex-wrap: wrap; }

/* ===================== 天平 ===================== */
.bl-svg { width: 100%; max-width: 320px; height: auto; }
.bl-beam { stroke: #4b4b4b; stroke-width: 6; stroke-linecap: round; }
.bl-string { stroke: #b9c9d4; stroke-width: 1.6; }
.bl-pan { fill: #fff3d6; stroke: #e5a500; stroke-width: 3; }
.bl-base { fill: #dbe9f3; stroke: #b9cddb; stroke-width: 2; }
.bl-item { font-size: 15px; }
.bl-eq { font-size: 17px; font-weight: 900; color: var(--text); letter-spacing: 1px; }
.bl-eq b { color: var(--green-deep); }

/* ===================== 通用：教具内小卡 ===================== */
.vm-card {
  background: #fff; border-radius: 12px;
  border: 2px solid #e9f1f7;
  padding: 6px 10px;
  font-size: 12px; font-weight: 800; color: var(--text-soft);
  text-align: center;
  line-height: 1.4;
}
.vm-card b { color: var(--blue-deep); }

@media (max-width: 360px) {
  .tf-cell { width: 24px; height: 24px; }
  .tf-dot { width: 16px; height: 16px; }
  .plate { width: 64px; height: 64px; }
  .clk-svg { width: 164px; height: 164px; }
  .fp-svg { width: 146px; height: 146px; }
}

/* ===================== 糖果出现动画 ===================== */
.candy {
  display: inline-block;
  opacity: 0;
  transform: scale(0.3);
  transition: opacity 0.25s ease, transform 0.32s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.candy.on { opacity: 1; transform: scale(1); }

.rest-zone { transition: opacity 0.3s ease, transform 0.3s ease; }

/* ============================================================
   桌面端放大：教具舞台更宽阔，标识更清晰
   ============================================================ */
@media (min-width: 981px) {
  .visual-stage .vm { gap: 16px; }
  .visual-stage .vm-sum { font-size: 18px; padding: 7px 18px; }
  .visual-stage .vm-tag { font-size: 12.5px; padding: 3px 11px; }
  .visual-stage .vm-note { font-size: 13.5px; }
  .visual-stage .vm-card { font-size: 13.5px; padding: 9px 14px; }

  /* 十格阵 */
  .visual-stage .tf-frame { gap: 7px; padding: 10px; border-radius: 18px; border-width: 4px; }
  .visual-stage .tf-cell { width: 54px; height: 54px; border-radius: 11px; }
  .visual-stage .tf-dot { width: 40px; height: 40px; }
  .visual-stage .tf-cap { font-size: 13px; }

  /* 数轴 / 小数数轴 */
  .visual-stage .nl-svg { max-width: 620px; }
  .visual-stage .dl-wrap { max-width: 560px; }
  .visual-stage .dl-magnifier { width: 64px; height: 64px; font-size: 15px; }

  /* 乘法果园 */
  .visual-stage .ag-cell .ag-emoji { font-size: 20px; }
  .visual-stage .ag-rowlabel { font-size: 11.5px; }

  /* 分物装盘 */
  .visual-stage .plate { width: 96px; height: 96px; }
  .visual-stage .plate-inner .candy { font-size: 17px; }
  .visual-stage .rest-zone { min-width: 118px; padding: 12px 16px; }

  /* 线段图 */
  .visual-stage .bm { max-width: 640px; gap: 12px; }
  .visual-stage .bm-label { width: 72px; font-size: 12px; }
  .visual-stage .bm-track { height: 42px; }
  .visual-stage .bm-seg { font-size: 13px; }
  .visual-stage .bm-brace { font-size: 12.5px; }

  /* 图形 / 面积 / 立体 */
  .visual-stage .shp-svg { max-width: 300px; }
  .visual-stage .ga-svg { max-width: 420px; }
  .visual-stage .solid-svg { max-width: 300px; }

  /* 钟表 */
  .visual-stage .clk-svg { width: 250px; height: 250px; max-width: none; }
  .visual-stage .clk-digital { font-size: 24px; }

  /* 分数披萨 / 长条 */
  .visual-stage .fp-svg { width: 240px; height: 240px; max-width: none; }
  .visual-stage .fp-caption { font-size: 13px; }
  .visual-stage .fp-fraction { font-size: 26px; }
  .visual-stage .fb-bar { max-width: 460px; height: 54px; }
  .visual-stage .fb-cell { font-size: 12px; }
  .visual-stage .fb-eq { font-size: 18px; }

  /* 行程 / 天平 */
  .visual-stage .mt-road { height: 92px; }
  .visual-stage .mt-car { font-size: 34px; }
  .visual-stage .mt-scale, .visual-stage .mt-note { font-size: 12px; }
  .visual-stage .bl-svg { max-width: 420px; }
  .visual-stage .bl-eq { font-size: 19px; }

  /* 弹窗里的教具（同样放大） */
  .modal .tf-cell { width: 40px; height: 40px; }
  .modal .tf-dot { width: 28px; height: 28px; }
  .modal .clk-svg { width: 230px; height: 230px; max-width: none; }
  .modal .fp-svg { width: 200px; height: 200px; max-width: none; }
  .modal .nl-svg { max-width: 520px; }
  .modal .fb-bar { max-width: 440px; height: 50px; }
  .modal .bm-track { height: 40px; }
  .modal .plate { width: 88px; height: 88px; }
}
