/* =========================================================
 * canvas.css —— 2D 舞台 + 3D 成型预览场景
 * =========================================================
 * ⚠️ 移动端 .stage3d 必须给显式高度（height:56vh; min-height:320px），
 *    且 .stage3d 纵向 flex 要显式 align-items:stretch ——
 *    否则「3D 成型」在手机上点下去完全空白（见本文件末尾的媒体查询）。
 * ========================================================= */
.stage-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 10px;
}

.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 12px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.stage-bar .left, .stage-bar .right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.zoom { font-size: 12px; color: var(--muted); min-width: 44px; text-align: center; }

.stage-holder {
  position: relative;       /* 信息块 overlay 的定位基准（固定于可视区左上，不随画布滚动） */
  flex: 1 1 auto;
  display: flex;
  min-width: 0;
  min-height: 0;
}

.stage {
  flex: 1 1 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;   /* 视图由 viewBox 控制，不用滚动条 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;         /* 2D 画布不留内边距，图纸直接铺满（3D 视图靠 .scene 自身居中） */
  background-image: linear-gradient(#eceff3 1px, transparent 1px), linear-gradient(90deg, #eceff3 1px, transparent 1px);
  background-size: 40px 40px;
}

/* 2D 画布容器：必须精确铺满 .stage，否则 SVG 的 width:100% 会因循环依赖退化到默认 300×150 */
.stage-inner {
  flex: 1 1 auto;
  align-self: stretch;
  width: 100%;
  height: 100%;
  min-width: 0;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
}

.stage.no-grid { background-image: none; }

.stage-inner { margin: auto; }

#stage { display: block; }

/* ---------- 3D 成型预览 ---------- */
.stage3d {
  flex: 1 1 auto;
  background: radial-gradient(circle at 50% 35%, #ffffff 0%, #eef1f6 70%, #e6eaf0 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  /* 纵向排列：.scene 吃掉剩余高度，.bar3d 按内容自适应。
     以前 .bar3d 是 absolute + .scene 写死 inset 0 0 46px，
     换个设备高度就得重算那个魔数，容易漏。
     ⚠️ 必须显式 align-items:stretch —— .stage 的 align-items:center 会被继承，
     而列向 flex 里 align-items 管的是横向，继承下来会让 .scene 宽度塌成 0。 */
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.scene {
  position: relative;   /* .box3d 用 left/top:50% 定位，需要一个定位基准 */
  flex: 1 1 auto;
  min-height: 0;
  perspective: 1500px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  /* 触屏上禁掉默认手势，否则拖动旋转会带着整页一起滚 */
  touch-action: none;
}

.scene.drag { cursor: grabbing; }

/* 2D 预览：拖拽平移的光标 */
#stageWrap { cursor: grab; user-select: none; -webkit-user-select: none; }
#stageWrap.panning { cursor: grabbing; }
#stageWrap:active { cursor: grabbing; }

/* ---------- 3D 折叠预览 ----------
   3D 模型 = 2D 刀版本身：.fp 就是一块板面，按展开图坐标摆位；
   父子嵌套关系来自压痕（铰链），绕 transform-origin 处旋转即折叠。
   ⚠️ 从 .box3d 到 .fp 每一层都必须 preserve-3d，
      任何 filter / overflow:hidden / opacity<1 都会强制扁平化让折叠失效。 */
.box3d {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
  will-change: transform;
}

.box3d .fold,
.box3d .fpiece,
.box3d .fp {
  position: absolute;
  transform-style: preserve-3d;
}

.box3d .fold { inset: 0; }

.box3d .fp {
  background-repeat: repeat;
  box-shadow: inset 0 0 0 1px rgba(74, 48, 20, .16);
}

/* 展开 ←→ 闭合 滑块 */
.foldrow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.foldrow .fl { font-size: 12.5px; color: var(--ink2); white-space: nowrap; }

/* 当前折叠工序：把「先接头→成筒→内→外→内→外」这条顺序显式告诉用户 */
.foldrow input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 190px;
  height: 20px;
  background: transparent;
  cursor: pointer;
}

.foldrow input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #cfd6e2, #9aa6bb);
}

.foldrow input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #7b8698;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.foldrow input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #cfd6e2, #9aa6bb);
}

.foldrow input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #7b8698;
}

.bar3d {
  flex: 0 0 auto;
  min-height: 46px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(4px);
}

/* 控件一律不许被压扁：之前按钮里的四个字被挤成竖排一列 */
.bar3d .btn,
.bar3d .chk { flex: 0 0 auto; white-space: nowrap; }

/* 尺寸信息 + 当前折叠工序：都放画布左上角，不跟控件栏抢地方 */
.info3d {
  position: absolute;
  left: 12px;
  top: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink2);
  pointer-events: none;
}

.info3d > span {
  background: rgba(255, 255, 255, .82);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 9px;
  white-space: nowrap;
}

/* 工序标签：让「先接头→成筒→内→外→内→外」这条顺序显式可见 */
.info3d .step { color: #3f4a5c; }

select.mini2 { padding: 3px 6px; font-size: 12px; }

.tip3d {
  position: absolute;
  right: 12px;
  top: 10px;
  font-size: 11.5px;
  color: var(--muted);
  pointer-events: none;
}

/* ---------- 画布左上角信息块（图例 + 三套尺寸，对齐 Pacdora） ---------- */
