/* 动画演示页 — 变量对齐 v2 tokens */

.algo-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: calc(100vh - var(--nav-height));
}

.algo-sidebar {
  background: var(--bg-sidebar);
  color: var(--text);
  padding: 24px 16px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
}

.algo-sidebar h3 {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 6px 8px;
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.algo-sidebar h3::before {
  content: '▾';
  font-size: 0.6rem;
  transition: transform 0.2s;
}

.algo-sidebar h3.collapsed::before { transform: rotate(-90deg); }

.algo-sidebar .algo-list {
  list-style: none;
  overflow: hidden;
  transition: max-height 0.3s ease;
  max-height: 2000px;
  margin-bottom: 20px;
}

.algo-sidebar .algo-list.collapsed {
  max-height: 0;
  margin-bottom: 0;
}

.algo-sidebar .algo-list li { margin-bottom: 4px; }

.algo-sidebar .algo-list li a {
  display: block;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  text-decoration: none;
}

.algo-sidebar .algo-list li a:hover,
.algo-sidebar .algo-list li a.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.algo-main {
  padding: 32px 40px 64px;
  overflow-y: auto;
  background: var(--bg);
  max-width: 960px;
}

.algo-main h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin-bottom: 8px;
}

.algo-main p {
  margin-bottom: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.stats-bar {
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.stat-value {
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
}

.vis-container {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}

.vis-canvas-wrap {
  padding: 24px;
  min-height: 320px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
}

.vis-canvas-wrap.horizontal { flex-direction: row; align-items: flex-end; }

.bar {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
  border-radius: 4px 4px 0 0;
  transition: height 0.1s ease, background 0.2s ease;
  min-width: 8px;
  max-width: 60px;
  flex: 1;
}

.bar.comparing { background: linear-gradient(180deg, var(--warning) 0%, #e09500 100%); }
.bar.swapping { background: linear-gradient(180deg, #db4437 0%, #c62828 100%); }
.bar.sorted { background: linear-gradient(180deg, var(--success) 0%, #087a43 100%); }
.bar.pivot { background: linear-gradient(180deg, var(--accent) 0%, #5b21b6 100%); }
.bar.found { background: linear-gradient(180deg, var(--success) 0%, #087a43 100%); }

.bar-label {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-family: var(--font-mono);
}

.cell {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-family: var(--font-mono);
  transition: all 0.2s ease;
  background: var(--bg-elevated);
}

.cell.compared { border-color: var(--warning); background: #fff8e1; }
.cell.found { border-color: var(--success); background: #e8f5e9; }
.cell.current { border-color: var(--primary); background: var(--primary-soft); }

html[data-theme="dark"] .cell.compared { background: #422006; }
html[data-theme="dark"] .cell.found { background: #052e16; }

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.controls label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.controls input[type="range"] {
  width: 100px;
  accent-color: var(--primary);
}

.speed-display {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  min-width: 40px;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s ease;
}

.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.code-panel {
  --code-bg: #1e1e1e;
  --code-header-bg: #2d2d2d;
  --code-text: #d4d4d4;
  --code-border: #333;
  background: var(--code-bg);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid var(--code-border);
}

.code-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--code-header-bg);
  border-bottom: 1px solid var(--code-border);
}

.code-panel-header span {
  font-size: 0.78rem;
  color: #999;
  font-family: var(--font-mono);
}

.code-panel code .sh-keyword { color: #569cd6; }
.code-panel code .sh-type { color: #4ec9b0; }
.code-panel code .sh-function { color: #dcdcaa; }
.code-panel code .sh-string { color: #ce9178; }
.code-panel code .sh-number { color: #b5cea8; }
.code-panel code .sh-comment { color: #6a9955; font-style: italic; }
.code-panel code .sh-preprocessor { color: #c586c0; }
.code-panel code .sh-operator { color: #d4d4d4; }
.code-panel code .sh-constant { color: #4fc1ff; }

.code-panel pre {
  padding: 20px;
  margin: 0;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.7;
  tab-size: 4;
}

.code-panel code {
  color: var(--code-text);
  font-family: var(--font-mono);
}

.sh-keyword { color: #569cd6; }
.sh-type { color: #4ec9b0; }
.sh-function { color: #dcdcaa; }
.sh-string { color: #ce9178; }
.sh-number { color: #b5cea8; }
.sh-comment { color: #6a9955; font-style: italic; }
.sh-preprocessor { color: #c586c0; }
.sh-operator { color: #d4d4d4; }
.sh-constant { color: #4fc1ff; }
.sh-escape { color: #d7ba7d; }

.btn-sm { padding: 6px 14px; font-size: 0.85rem; }

@media (max-width: 900px) {
  .algo-layout { grid-template-columns: 1fr; }
  .algo-sidebar {
    position: static;
    height: auto;
    max-height: 240px;
  }
  .algo-main { padding: 24px 20px 48px; }
}
