/* ===================================================================
   各模块专属交互样式 (lab-modules.css)
   =================================================================== */

/* ---------------- 模块1: 展开与折叠实验室 ---------------- */
.unfold-grid-editor {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.unfold-canvas-2d-box {
  background: rgba(10, 15, 24, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  position: relative;
  min-height: 260px;
  height: 280px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
}

.unfold-canvas-2d-box:active {
  cursor: grabbing;
}

.unfold-canvas-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: 0 0;
  transition: transform 0.05s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 2D 矩形展开面块样式 */
.net-rect-face {
  position: absolute;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  font-family: var(--font-mono);
  font-weight: bold;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  user-select: none;
  box-sizing: border-box;
}

/* 2D 画布浮动控制条 */
.canvas-2d-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
  background: rgba(15, 23, 42, 0.8);
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.canvas-2d-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
}

.canvas-2d-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.canvas-2d-drag-tip {
  position: absolute;
  bottom: 8px;
  left: 10px;
  font-size: 0.7rem;
  color: var(--text-dim);
  pointer-events: none;
  z-index: 10;
}

.net-grid-table {
  border-collapse: separate;
  border-spacing: 4px;
}

.net-cell {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-dim);
}

.net-cell:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.net-cell.active-face {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border: 1px solid #60a5fa;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.net-cell.face-cut {
  background: rgba(244, 63, 94, 0.15);
  border: 1px dashed #f43f5e;
  color: #f43f5e;
  text-decoration: line-through;
  opacity: 0.6;
}

.net-cell.base-face {
  background: linear-gradient(135deg, #059669, #10b981) !important;
  border-color: #34d399 !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4) !important;
}

.net-cell.overlap-face {
  background: linear-gradient(135deg, #dc2626, #ef4444) !important;
  border-color: #f87171 !important;
  animation: pulseShake 0.4s infinite;
}

@keyframes pulseShake {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.unfold-templates-pill {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.4rem;
}

.template-pill-btn {
  padding: 0.35rem 0.65rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.template-pill-btn:hover, .template-pill-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

/* 11 种分类展开图选择面板 */
.categories-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.category-group-card {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.category-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 0.45rem;
}

.category-title-row .count-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-blue);
}

.category-btn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.net-pattern-btn {
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 5px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.net-pattern-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-blue);
  color: var(--text-main);
}

.net-pattern-btn.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.4), rgba(56, 189, 248, 0.4));
  border-color: var(--accent-blue);
  color: #ffffff;
  font-weight: bold;
}

/* 6面颜色图例徽章栏 */
.faces-legend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.face-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  background: rgba(15, 23, 42, 0.45);
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.face-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ---------------- 模块2: 三视图与小立方体工坊 ---------------- */
.views-layout-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.views-triple-display {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.view-card-mini {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.view-card-mini .v-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.view-card-mini .v-title .badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-blue);
}

.view-svg-container {
  width: 100%;
  aspect-ratio: 1;
  max-width: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topview-matrix-table {
  border-collapse: separate;
  border-spacing: 4px;
}

.topview-matrix-cell {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}

.topview-matrix-cell:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-blue);
}

.topview-matrix-cell.has-blocks {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
}

.cell-letter {
  font-size: 0.65rem;
  color: var(--accent-amber);
  font-family: var(--font-mono);
}

.cell-num {
  font-size: 0.9rem;
  font-weight: bold;
  font-family: var(--font-mono);
}

/* 左视图作答网格 */
.answer-grid-interactive {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(3, 34px);
  gap: 3px;
  margin: 0.5rem 0;
  border: 2px dashed rgba(90, 115, 150, 0.4);
  padding: 4px;
  border-radius: 8px;
  background: rgba(10, 15, 24, 0.4);
}

.answer-cell {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.answer-cell.painted {
  background: #3b82f6;
  box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.4);
}

/* ---------------- 模块3: 正方体截面与注水切片探究 ---------------- */
.section-shape-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-weight: bold;
  font-size: 0.9rem;
}

.section-shape-badge.tri {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid #38bdf8;
}

.section-shape-badge.quad {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid #34d399;
}

.section-shape-badge.penta {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid #fbbf24;
}

.section-shape-badge.hexa {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid #c084fc;
}

.preset-orientations-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.impossible-heptagon-card {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.1), rgba(15, 23, 42, 0.8));
  border: 1px solid rgba(244, 63, 94, 0.4);
  border-radius: 10px;
  padding: 0.85rem;
  margin-top: 0.75rem;
}

.impossible-title {
  color: #fda4af;
  font-size: 0.85rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.impossible-desc {
  font-size: 0.78rem;
  color: #e2e8f0;
  line-height: 1.5;
}

/* ---------------- 模块4: 长方体拼包与表面积优化 ---------------- */
.dimension-inputs-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.dim-input-box {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  display: flex;
  flex-direction: column;
}

.dim-input-box label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.dim-input-box input {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-size: 1.05rem;
  font-family: var(--font-mono);
  font-weight: bold;
  outline: none;
  width: 100%;
}

.packing-methods-selector {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.packing-method-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.packing-method-card:hover {
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(90, 115, 150, 0.5);
}

.packing-method-card.active {
  background: rgba(37, 99, 235, 0.15);
  border-color: var(--accent-blue);
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.25);
}

.packing-method-info {
  display: flex;
  flex-direction: column;
}

.method-name {
  font-size: 0.825rem;
  font-weight: bold;
  color: #ffffff;
}

.method-details {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.method-area-val {
  font-family: var(--font-mono);
  font-weight: bold;
  font-size: 0.95rem;
  color: var(--accent-emerald);
}

.comparison-table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.comparison-table th {
  background: rgba(15, 23, 42, 0.8);
  padding: 0.5rem;
  text-align: left;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.comparison-table td {
  padding: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
}

.comparison-table tr.highlight-best {
  background: rgba(16, 185, 129, 0.15);
}

.comparison-table tr.highlight-best td {
  color: #6ee7b7;
  font-weight: bold;
}

#unfold-canvas-2d-box { touch-action: none; }
.topview-matrix-cell { font: inherit; color: var(--text-main); width: 100%; }
.canvas-2d-btn { min-width: 36px; min-height: 36px; }
.net-rect-face span { white-space: nowrap; font-size: 0.7rem !important; }
#faces-legend-container { font-size: 0.75rem; line-height: 1.6; }

.views-observe-toolbar { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); }
.views-check { display: flex; align-items: center; gap: 0.5rem; color: var(--text-muted); font-size: 0.8rem; margin-top: 0.75rem; }
.views-board-size { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem; }
.views-board-size label { display: grid; gap: 0.35rem; font-size: 0.8rem; color: var(--text-muted); }
.views-board-size input { width: 72px; border: 1px solid var(--border-color); border-radius: 6px; padding: 0.45rem; background: var(--bg-primary); color: var(--text-main); font: inherit; }
.views-size-shortcuts { margin-top: 0.6rem; }
.views-size-shortcuts .btn-outline { padding: 0.4rem 0.6rem; font-size: 0.75rem; }
.views-matrix-scroll { overflow: auto; padding: 0.25rem; border: 1px solid var(--border-color); border-radius: 8px; max-height: 360px; }
.views-matrix-scroll .topview-matrix-cell { min-width: 42px; min-height: 42px; }
.topview-matrix-cell.is-selected { outline: 2px solid var(--accent-amber); outline-offset: 1px; }
.views-selected-editor { margin: 0.85rem 0; padding: 0.75rem; background: rgba(15, 23, 42, 0.5); border-radius: 8px; }
.view-card-mini { font: inherit; cursor: pointer; width: 100%; min-width: 0; padding: 0.6rem 0.3rem; }
.view-card-mini[hidden] { display: none; }
.view-card-mini:hover { border-color: var(--accent-blue); }
.view-card-mini.is-observed { border-color: var(--accent-amber); background: rgba(245, 158, 11, 0.08); }
.view-card-mini .v-title { flex-wrap: wrap; justify-content: center; gap: 0.25rem; }
.view-svg-container svg { width: 100%; height: 100%; }
.views-triple-display { gap: 0.4rem; }
button:disabled { opacity: 0.45; cursor: default; }
#views-camera-label { color: var(--accent-amber); font-size: 0.8rem; }

/* Net teaching: preview first, select a fixed face, then follow the fold. */
.net-preview-grid .net-pattern-btn { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 0.6rem 0.3rem; }
.net-preview-grid svg { width: 100%; height: 68px; }
.net-preview-grid .net-pattern-btn.active { outline: 2px solid var(--accent-amber); outline-offset: 1px; }
.category-group-card .learning-note { font-size: 0.72rem; }
#unfold-canvas-stage .net-rect-face { border-radius: 0; box-shadow: none; border: 1px solid rgba(255,255,255,0.7); font-size: 1rem; padding: 0; }
#unfold-canvas-stage .net-rect-face.is-bottom { outline: 3px solid var(--accent-amber); outline-offset: -4px; z-index: 2; }
#unfold-canvas-stage .net-rect-face.is-moving { box-shadow: inset 0 0 0 2px #fef08a; }
.net-fold-lines { position: absolute; pointer-events: none; z-index: 3; overflow: visible; }
.net-fold-lines line { stroke: #172033; stroke-width: 2; stroke-dasharray: 4 3; }
.net-fold-lines line.is-active { stroke: #fbbf24; stroke-width: 4; stroke-dasharray: none; }
.unfold-step-actions { margin-top: 0.75rem; }
.unfold-speed-label, .unfold-prediction-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: var(--text-muted); }
.unfold-speed-label { margin-top: 0.75rem; }
#panel-unfold select { background: var(--bg-primary); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 6px; padding: 0.5rem; font: inherit; }
.unfold-perimeter summary { cursor: pointer; font-size: 0.85rem; font-weight: 600; }
#faces-legend-container .face-legend-item { align-items: start; }
.unfold-library summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.unfold-library summary .tag { font-size: 0.7rem; color: var(--accent-blue); margin-left: 0.5rem; white-space: nowrap; }
.unfold-library:not([open]) { padding-bottom: 1.15rem; }

.cube-dimension-row { grid-template-columns: 1fr; max-width: 150px; }
#unfold-area-lesson[hidden], #unfold-volume-lesson[hidden] { display: none; }
.unfold-face-areas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; margin: 0.6rem 0; }
.unfold-area-face { background: var(--bg-primary); color: var(--text-main); border: 1px solid var(--border-color); border-left-width: 4px; border-radius: 6px; padding: 0.5rem; text-align: left; font: inherit; font-size: 0.75rem; cursor: pointer; }
.unfold-area-face[aria-pressed="true"] { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
#unfold-canvas-stage .net-rect-face.is-measured:not(.is-bottom) { outline: 3px solid var(--accent-blue); outline-offset: -4px; }
.measure-formula { white-space: pre-line; overflow-wrap: anywhere; font-size: 0.8rem; line-height: 1.8; padding: 0.75rem; background: rgba(15, 23, 42, 0.5); border-radius: 8px; margin-top: 0.75rem; }
.measure-result { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.75rem; font-size: 0.85rem; margin-top: 0.75rem; }
.measure-result strong { color: var(--accent-emerald); font-size: 1.35rem; overflow-wrap: anywhere; }
.measure-scaling { border-left: 3px solid var(--accent-amber); padding-left: 0.75rem; margin-top: 0.9rem; font-size: 0.8rem; line-height: 1.7; color: var(--text-muted); }

/* Neutral paper faces; only the identifying letters carry a face-specific color. */
#unfold-canvas-stage .net-rect-face { background-color: #b89564; background-image: var(--paper-texture); background-size: 100% 100%; color: #48341d; border-color: #775c3b; text-shadow: none; flex-direction: column; gap: 0.1rem; }
#unfold-canvas-stage .net-rect-face .face-letter { font-size: 1.15rem !important; font-weight: 800; }
#unfold-canvas-stage .net-rect-face .face-role { font-size: 0.65rem !important; }
#faces-legend-container .face-legend-item { background: #c6a775; color: #48341d; }
#faces-legend-container .face-letter { flex-shrink: 0; font-size: 0.95rem; }
.unfold-area-face { background: #c6a775; color: #48341d; border-left-width: 1px; }

/* General net controls and persistent geometry readings inside the 3D canvas. */
#unfold-axis-controls[hidden], #unfold-stage-perimeter-item[hidden] { display: none; }
.unfold-net-orientation { align-items: center; margin-bottom: 0.5rem; }
.unfold-face-label-option { margin: 0.5rem 0 0.75rem; }
#unfold-canvas-stage.hide-face-labels .face-letter,
#unfold-canvas-stage.hide-face-labels .face-role { visibility: hidden; }
#canvas-unfold-container .unfold-stage-metrics { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 4; display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; padding: 0.6rem 0.8rem; border: 1px solid var(--border-color); border-radius: 8px; background: rgba(15,20,28,0.88); color: var(--text-muted); font-size: 0.8rem; pointer-events: none; }
.unfold-stage-metrics > span { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem; }
.unfold-stage-metrics strong { color: var(--accent-emerald); font-size: 1rem; overflow-wrap: anywhere; }
.unfold-stage-metrics small { font-size: 0.65rem; color: var(--text-dim); }

/* Keep each preview caption and perimeter on one line; allow narrow lists to scroll. */
#unfold-pattern-library .net-preview-grid { grid-template-columns: repeat(3, minmax(max-content, 1fr)); overflow-x: auto; padding: 3px; }
#unfold-pattern-library .net-pattern-btn > span { white-space: nowrap; }
#unfold-pattern-library .net-pattern-btn > svg { width: 80px; max-width: 100%; }
#unfold-pattern-library .net-pattern-perimeter { color: var(--accent-emerald); font-size: 0.72rem; }

/* Animated dimension badges show a change of direction without stretching the solid. */
#unfold-axis-controls .unfold-speed-label { display: grid; }
#unfold-axis-order { width: 100%; min-width: 0; }
.unfold-axis-demo { margin-top: 0.75rem; padding: 0.6rem; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-primary); }
.unfold-axis-demo svg { display: block; width: 100%; height: auto; overflow: visible; }
.axis-demo-side { fill: #8b7352; stroke: #c6a775; stroke-width: 1.5; }
.axis-demo-face { fill: #c6a775; stroke: #fbbf24; stroke-width: 2; }
.axis-demo-face-name { fill: #48341d; font-size: 18px; font-weight: 600; text-anchor: middle; }
.axis-demo-edge { fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-dasharray: 4 3; }
.axis-demo-slot { fill: var(--text-muted); font-size: 13px; text-anchor: middle; }
.axis-demo-token { transition: transform 0.85s cubic-bezier(0.4, 0, 0.2, 1); }
.axis-demo-token.is-positioning { transition: none; }
.axis-demo-token rect { stroke-width: 1; }
.axis-demo-token[data-axis-token="0"] rect { fill: #173b50; stroke: #38bdf8; }
.axis-demo-token[data-axis-token="1"] rect { fill: #163d31; stroke: #34d399; }
.axis-demo-token[data-axis-token="2"] rect { fill: #43301a; stroke: #fbbf24; }
.axis-demo-token text { fill: var(--text-main); font-size: 15px; font-weight: 600; text-anchor: middle; dominant-baseline: middle; }
@media (prefers-reduced-motion: reduce) { .axis-demo-token { transition: none; } }
