/* =========================================================
   三角形全等探究（SAS）- 样式表
   现代化教育课件设计：双色主题、卡片投影、清晰数学标注
   ========================================================= */

:root {
  /* 浅色主题色彩系统 */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-color: #e2e8f0;
  
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  
  --accent-pink: #e11d48;     /* △ABC 经典红粉 */
  --accent-blue: #0284c7;     /* △A'B'C' 教学蓝 */
  --accent-purple: #9333ea;   /* 重合混合紫 */
  --accent-green: #16a34a;    /* 验证成功绿 */
  --accent-amber: #d97706;    /* 夹角重点橙 */
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
}

body.theme-dark {
  /* 护眼黑板主题色彩系统 */
  --bg-primary: #151d28;
  --bg-secondary: #1e293b;
  --bg-tertiary: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  
  --primary-color: #38bdf8;
  --primary-hover: #7dd3fc;
  --primary-light: rgba(56, 189, 248, 0.15);
  
  --accent-pink: #fb7185;
  --accent-blue: #38bdf8;
  --accent-purple: #c084fc;
  --accent-green: #4ade80;
  --accent-amber: #fbbf24;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ================= 头部与导航栏 ================= */
.app-header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-left h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary-color);
  border-radius: 9999px;
  white-space: nowrap;
}

.nav-tabs {
  display: flex;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background-color: rgba(0, 0, 0, 0.04);
}

body.theme-dark .tab-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: var(--bg-secondary);
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.header-right {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1.1rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--primary-light);
  border-color: var(--primary-color);
}

/* ================= 核心内容容器 ================= */
.main-container {
  flex: 1;
  padding: 18px 24px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.tab-content {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 左右分栏布局 */
.layout-split {
  display: grid;
  grid-template-columns: 430px 1fr;
  gap: 20px;
  align-items: stretch;
  min-height: calc(100vh - 160px);
}

@media (max-width: 1050px) {
  .layout-split {
    grid-template-columns: 1fr;
  }
}

/* 通用卡片容器 */
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-tertiary);
}

.card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary-color);
  font-weight: 600;
}

.card-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 6px 0;
}

/* ================= 表单与滑块控制 ================= */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
}

.val-badge {
  font-family: monospace;
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  color: var(--primary-color);
  font-size: 0.88rem;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border-color);
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  box-shadow: 0 0 2px rgba(0,0,0,0.3);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* ================= 步骤引导与信息面板 ================= */
.step-guide h4 {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--text-main);
}

.step-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.btn-step {
  padding: 7px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.btn-step:hover {
  background: var(--bg-tertiary);
}

.btn-step.active {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

.btn-step.done {
  border-color: var(--accent-green);
  color: var(--accent-green);
  background: rgba(22, 163, 74, 0.08);
}

.step-explanation {
  background: var(--bg-tertiary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
  border-left: 3px solid var(--primary-color);
}

.info-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.info-card.highlight-danger {
  border-color: var(--accent-pink);
  background: rgba(225, 29, 72, 0.08);
}

.info-header {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--text-main);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.info-item {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.info-item .label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.info-item .value {
  font-family: monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-color);
}

.math-law-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ================= 画布区域 ================= */
.canvas-card {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.canvas-toolbar {
  padding: 10px 18px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.canvas-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.canvas-container {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 480px;
  background: radial-gradient(circle, var(--border-color) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: var(--bg-secondary);
  cursor: crosshair;
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-footer {
  padding: 8px 18px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

.color-box.line-c { background: #2563eb; }
.color-box.angle-a { background: #ea580c; }
.color-box.line-b { background: #16a34a; }
.color-box.line-a { background: #dc2626; border: 1px dashed #fff; }
.color-box.wood-bar { background: #b45309; }
.color-box.rubber-band { background: #ec4899; }
.color-box.angle-marker { background: #f59e0b; }
.color-box.tri-target { background: #e11d48; }
.color-box.tri-mover { background: #0284c7; }
.color-box.tri-overlap { background: #9333ea; }
.color-box.tri-target-dashed { border: 2px dashed #94a3b8; background: rgba(148, 163, 184, 0.1); }
.color-box.tri-playable { background: #10b981; }
.color-box.handle-point { background: #f97316; border-radius: 50%; }

/* ================= 按钮样式 ================= */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--primary-color);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.btn-large {
  padding: 12px 20px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ================= 探究 2：活动铰链特殊样式 ================= */
.toggle-mode-box {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 4px;
}

.mode-btn {
  flex: 1;
  padding: 7px 10px;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--bg-secondary);
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  line-height: 1.5;
}

.alert-info {
  background: var(--primary-light);
  color: var(--primary-color);
  border-left: 4px solid var(--primary-color);
}

.alert-warning {
  background: rgba(217, 119, 6, 0.12);
  color: var(--accent-amber);
  border-left: 4px solid var(--accent-amber);
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.action-buttons .btn {
  flex: 1;
}

.hinge-status-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.status-badge.unlocked {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.status-badge.locked {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

/* ================= 探究 3：教材叠合动画特殊样式 ================= */
.book-quote-box {
  background: rgba(225, 29, 72, 0.06);
  border-left: 4px solid var(--accent-pink);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.quote-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent-pink);
  margin-bottom: 4px;
}

.quote-text {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.5;
  font-style: italic;
}

/* 步骤指示条 */
.superposition-stepper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  margin: 6px 0;
  padding: 0 4px;
}

.superposition-stepper::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 10px;
  right: 10px;
  height: 2px;
  background: var(--border-color);
  z-index: 1;
}

.step-node {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.node-idx {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  transition: all 0.2s;
}

.node-txt {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.step-node.active .node-idx {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.step-node.active .node-txt {
  color: var(--primary-color);
}

.step-node.completed .node-idx {
  border-color: var(--accent-green);
  background: var(--accent-green);
  color: #fff;
}

/* 动态旁白卡片 */
.narration-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border-left: 4px solid var(--primary-color);
  transition: all 0.3s;
}

.narration-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.narration-header h4 {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-main);
}

.narration-body {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-main);
}

.narration-math {
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-weight: 700;
  color: var(--primary-color);
  font-size: 0.9rem;
  border: 1px dashed var(--border-color);
}

.playback-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.playback-controls .btn {
  flex: 1;
}

.playback-controls .btn-icon {
  flex: 0 0 38px;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.speed-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
}

.speed-btn.active {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

.theorem-card {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(147, 51, 234, 0.08));
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.theorem-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary-color);
  margin-bottom: 4px;
}

.theorem-text {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-main);
}

.status-pill {
  font-size: 0.78rem;
  padding: 3px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  color: var(--text-muted);
}

/* ================= 探究 4：动手实验室 ================= */
.playground-metrics {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.metric-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.86rem;
}

.metric-val {
  font-family: monospace;
  font-weight: 700;
  color: var(--primary-color);
}

.progress-bar-container {
  flex: 1;
  margin: 0 10px;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #10b981);
  border-radius: 4px;
  transition: width 0.15s ease;
}

.metric-percent {
  font-family: monospace;
  font-weight: 700;
  width: 40px;
  text-align: right;
  color: var(--accent-green);
}

.congrats-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(59, 130, 246, 0.15));
  border: 2px solid var(--accent-green);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  margin-top: 14px;
  animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.congrats-icon {
  font-size: 2.2rem;
  margin-bottom: 4px;
}

.congrats-box h4 {
  font-size: 1.05rem;
  color: var(--accent-green);
  margin-bottom: 6px;
}

.congrats-box p {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.5;
}

@keyframes bounceIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ================= 探究 5：随堂测验 ================= */
.quiz-container {
  max-width: 860px;
  margin: 0 auto;
}

.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.quiz-item {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.quiz-title {
  font-size: 0.98rem;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.6;
}

.q-num {
  width: 24px;
  height: 24px;
  background: var(--primary-color);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-opt {
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-opt:hover {
  background: var(--primary-light);
  border-color: var(--primary-color);
}

.quiz-opt.selected-correct {
  background: rgba(34, 197, 94, 0.18);
  border-color: var(--accent-green);
  color: var(--accent-green);
  font-weight: 700;
}

.quiz-opt.selected-wrong {
  background: rgba(239, 68, 68, 0.18);
  border-color: #ef4444;
  color: #ef4444;
  font-weight: 700;
}

.quiz-feedback {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  line-height: 1.5;
}

.quiz-feedback.correct {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  border-left: 4px solid var(--accent-green);
}

.quiz-feedback.wrong {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-left: 4px solid #ef4444;
}

/* ================= 页脚 ================= */
.app-footer {
  text-align: center;
  padding: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}
