/* ===================================================================
   几何空间探索实验室 (MathSpace 3D Geometric Lab)
   现代数学教学与空间几何探究平台
   =================================================================== */

:root {
  --bg-primary: #0f141c;
  --bg-secondary: #161e2b;
  --bg-tertiary: #1f2b3e;
  --bg-card: rgba(26, 36, 52, 0.75);
  --bg-card-hover: rgba(35, 49, 70, 0.85);
  --border-color: rgba(90, 115, 150, 0.25);
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-blue: #38bdf8;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-indigo: #6366f1;
  --accent-purple: #8b5cf6;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
}

/* 顶部导航栏 */
.header-bar {
  background: rgba(15, 20, 28, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #0284c7, #6366f1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2;
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #f8fafc, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 模块切换导航 */
.nav-tabs {
  display: flex;
  gap: 0.5rem;
  background: rgba(22, 30, 43, 0.8);
  padding: 0.25rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.tab-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}

.tab-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  font-family: var(--font-mono);
}

/* 顶部操作区 */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* 主内容容器 */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.5rem;
  gap: 1rem;
  max-width: 1720px;
  width: 100%;
  margin: 0 auto;
}

/* 模块面板基础布局 */
.tab-panel {
  display: none;
  flex: 1;
  animation: fadeIn 0.3s ease forwards;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

/* 左右分栏工作台 */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 1.25rem;
  flex: 1;
  min-height: 640px;
}

@media (max-width: 1200px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* 3D 舞台与主视区卡片 */
.stage-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  position: relative;
}

.stage-header {
  padding: 0.75rem 1.25rem;
  background: rgba(15, 20, 28, 0.6);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stage-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.stage-title .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.stage-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stage-canvas-container {
  flex: 1;
  position: relative;
  min-height: 480px;
  background: radial-gradient(circle at center, #182333 0%, #0c121a 100%);
  cursor: grab;
}

.stage-canvas-container:active {
  cursor: grabbing;
}

.stage-canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* 3D 浮动提示与辅助层 */
.stage-overlay-tips {
  position: absolute;
  bottom: 12px;
  left: 14px;
  background: rgba(15, 20, 28, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stage-overlay-tips kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  color: var(--text-main);
}

/* 右侧控制与原题解析卡片 */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  color: #ffffff;
}

.card-title .tag {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* 试卷原题展示小条 */
.question-snippet {
  background: rgba(15, 23, 42, 0.6);
  border-left: 3px solid var(--accent-blue);
  padding: 0.75rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.825rem;
  line-height: 1.5;
  color: var(--text-main);
  margin-bottom: 0.85rem;
}

.question-snippet .q-badge {
  display: inline-block;
  font-weight: bold;
  color: var(--accent-blue);
  margin-right: 0.3rem;
}

/* 交互控制组 */
.control-group {
  margin-bottom: 0.9rem;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.control-label span.val {
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-weight: 600;
}

/* 按钮与选项卡组 */
.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-accent {
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-accent:hover {
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.5);
}

.btn-outline {
  padding: 0.5rem 0.8rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 7px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-outline.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  font-weight: 600;
}

/* 滑动条美化 */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-blue);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
  transition: transform 0.1s;
}

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

/* 结论与状态提示卡 */
.status-banner {
  padding: 0.8rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.45;
  margin-top: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.status-banner.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
}

.status-banner.warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

.status-banner.danger {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fecdd3;
}

.status-banner.info {
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #bae6fd;
}

/* 数据看板小表格与指标卡 */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.metric-card {
  background: rgba(15, 23, 42, 0.45);
  padding: 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-card .label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.metric-card .value {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  margin-top: 0.2rem;
}

/* 核心知识点收折面板 */
.knowledge-drawer {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  margin-top: 0.75rem;
}

.knowledge-header {
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
  transition: color 0.2s;
}

.knowledge-header:hover {
  color: var(--text-main);
}

.knowledge-body {
  padding: 0.85rem;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #cbd5e1;
  border-top: 1px solid var(--border-color);
  background: rgba(10, 15, 24, 0.3);
}

.knowledge-body ol, .knowledge-body ul {
  padding-left: 1.2rem;
  margin-top: 0.4rem;
}

.knowledge-body li {
  margin-bottom: 0.3rem;
}

/* 底栏 */
.footer-bar {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: auto;
}

/* Teaching controls remain usable on a projector, tablet, and keyboard. */
button:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent-amber);
  outline-offset: 3px;
}
button[hidden] { display: none; }
.workspace-grid { grid-template-columns: minmax(0, 1fr) 420px; align-items: start; }
.stage-card { min-width: 0; position: sticky; top: 90px; }
.stage-canvas-container { height: min(65vh, 720px); flex: auto; }
.stage-canvas-container canvas { position: absolute; inset: 0; }
.stage-overlay-tips { z-index: 1; flex-wrap: wrap; right: 14px; }
.stage-header, .stage-toolbar { flex-wrap: wrap; gap: 0.6rem; }
.learning-note { color: var(--text-muted); font-size: 0.8rem; line-height: 1.6; margin: 0.4rem 0; }
.lesson-prompt { color: var(--text-main); border-left: 3px solid var(--accent-blue); padding: 0.5rem 0.8rem; }
.axis-control { font-size: 0.75rem; color: var(--text-muted); display: grid; gap: 0.5rem; }
.viewport-error { padding: 2rem; color: #fde68a; }
@media (max-width: 1200px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .stage-card { position: relative; top: auto; }
  .header-bar { flex-wrap: wrap; gap: 0.75rem; }
  .nav-tabs { order: 3; width: 100%; overflow-x: auto; }
}
@media (max-width: 600px) {
  .header-bar { padding: 0.65rem; }
  .main-container { padding: 0.75rem; }
  .brand-text h1 { font-size: 0.95rem; }
  .brand-text p { font-size: 0.65rem; }
  .tab-btn { padding: 0.6rem 0.65rem; font-size: 0.8rem; }
  .stage-header { padding: 0.75rem; }
  .stage-canvas-container { min-height: 340px; height: 48vh; }
  .panel-card { padding: 0.85rem; }
  .stage-overlay-tips { font-size: 0.65rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* The stage fills the visible teaching area without following a long sidebar. */
.stage-card { top: calc(var(--app-header-height, 78px) + 12px); }
.stage-card > .stage-header, .stage-card > .views-observe-toolbar { flex-shrink: 0; }
.stage-card > .stage-canvas-container { flex: 1 1 0; min-height: 0; height: auto; }
@media (max-width: 1200px) {
  .stage-card { top: auto; }
}
