/* ============================================================
 * 408 数据结构可视化 - 共享样式
 * 暗色主题 · 大字号 · 清晰布局
 * ============================================================ */

:root {
  /* 背景色 */
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-tertiary: #334155;
  /* 主题色 */
  --accent: #38BDF8;
  --highlight: #FBBF24;
  --success: #34D399;
  --danger: #F87171;
  --pointer: #A78BFA;
  --sort: #FB923C;
  --search: #F472B6;
  /* 文字色 */
  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  /* 状态色 */
  --status-default: { fill: #1E293B; stroke: #475569; text: #CBD5E1; };
  --status-active: #38BDF8;
  --status-comparing: #FBBF24;
  --status-sorted: #34D399;
  --status-pivot: #A78BFA;
  --status-min: #34D399;
  --status-swapping: #F87171;
  --status-visited: #FB923C;
  --status-path: #FBBF24;
  --status-removed: #475569;
  --status-highlighted: #F472B6;
  /* 间距 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  /* 圆角 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  /* 字体 */
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
}

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

html, body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 15% 20%, rgba(56, 189, 248, 0.10), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(167, 139, 250, 0.08), transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(251, 191, 36, 0.03), transparent 60%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.4) 0%, transparent 30%, transparent 70%, rgba(15, 23, 42, 0.3) 100%);
  background-attachment: fixed;
}

/* 科技感网格线背景 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* 粒子光感 canvas */
#particle-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 6px; border: 2px solid var(--bg-primary); }
::-webkit-scrollbar-thumb:hover { background: #475569; }

::selection { background: rgba(56, 189, 248, 0.3); color: #F1F5F9; }

/* ============================================================
 * 布局
 * ============================================================ */

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }

/* 导航栏 */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  height: 64px;
}
.navbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 24px;
  height: 100%; display: flex; align-items: center; justify-content: space-between;
}
.navbar-logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: 700; color: var(--text-primary);
}
.navbar-logo .logo-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--pointer));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--bg-primary); font-weight: 800;
}
.navbar-links { display: flex; align-items: center; gap: 4px; }
.navbar-links a {
  padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 500;
  color: var(--text-secondary); transition: all 0.2s;
}
.navbar-links a:hover { color: var(--text-primary); background: rgba(148, 163, 184, 0.1); }
.navbar-links a.active { color: var(--accent); background: rgba(56, 189, 248, 0.12); }

main { padding-top: 64px; min-height: calc(100vh - 64px); }

footer {
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  padding: 24px; text-align: center; color: var(--text-dim); font-size: 13px;
}

/* ============================================================
 * 通用组件
 * ============================================================ */

/* 玻璃卡片 */
.glass {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-lg);
}
.glass-strong {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-lg);
}

/* 章节标题 */
.chapter-header {
  padding: 48px 0 32px;
}
.chapter-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(148, 163, 184, 0.1); font-size: 13px;
  color: var(--text-secondary); margin-bottom: 16px;
}
.chapter-title {
  font-size: 36px; font-weight: 800; line-height: 1.2;
  color: var(--text-primary); margin-bottom: 12px;
}
.chapter-subtitle {
  font-size: 18px; color: var(--text-muted); max-width: 720px;
}

/* 卡片网格 */
.card-grid {
  display: grid; gap: 20px;
}
.card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .card-grid.cols-2, .card-grid.cols-3, .card-grid.cols-4 { grid-template-columns: 1fr; }
}

/* 知识点卡片 */
.topic-card {
  display: block; padding: 20px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-lg);
  transition: all 0.25s;
}
.topic-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.topic-card-title {
  font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px;
}
.topic-card-desc {
  font-size: 14px; color: var(--text-muted); margin-bottom: 12px;
}
.topic-card-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge-high { background: rgba(251, 191, 36, 0.15); color: var(--highlight); }
.badge-mid { background: rgba(56, 189, 248, 0.15); color: var(--accent); }
.badge-low { background: rgba(100, 116, 139, 0.15); color: var(--text-dim); }
.badge-basic { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.badge-medium { background: rgba(251, 191, 36, 0.15); color: var(--highlight); }
.badge-hard { background: rgba(248, 113, 113, 0.15); color: var(--danger); }

/* ============================================================
 * 演示页面布局
 * ============================================================ */

.demo-page { padding: 24px 0 64px; }
.demo-header { margin-bottom: 24px; }
.demo-title-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.demo-title { font-size: 28px; font-weight: 800; color: var(--text-primary); }
.demo-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.demo-desc { color: var(--text-muted); font-size: 15px; max-width: 800px; }

.demo-layout {
  display: flex; flex-direction: column; gap: 20px;
}

/* 输入编辑器 */
.input-editor {
  padding: 16px; margin-bottom: 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-md);
}
.input-editor-title {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.05em;
}
.input-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.input-row label { font-size: 14px; color: var(--text-secondary); min-width: 80px; }
.input-row input, .input-row select {
  padding: 6px 12px; border-radius: 6px;
  background: var(--bg-secondary); border: 1px solid var(--bg-tertiary);
  color: var(--text-primary); font-size: 14px; font-family: var(--font-mono);
  min-width: 120px;
}
.input-row input:focus { border-color: var(--accent); }
.btn {
  padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--accent); color: var(--bg-primary);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-tertiary); color: var(--text-primary);
}
.btn-secondary:hover { background: #475569; }

/* 可视化区域 */
.viz-area {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-md);
  padding: 20px;
  min-height: 300px;
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
}
.viz-area svg { max-width: 100%; height: auto; max-height: 560px; }

/* 控制条 */
.control-bar {
  padding: 14px 16px; margin-top: 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-md);
}
.control-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.control-btn {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-tertiary); color: var(--text-primary);
  transition: all 0.2s; font-size: 16px;
}
.control-btn:hover { background: #475569; }
.control-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.control-btn.play {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--accent); color: var(--bg-primary);
}
.control-btn.play:hover { filter: brightness(1.1); }
.progress-bar {
  flex: 1; min-width: 200px; height: 8px;
  background: var(--bg-tertiary); border-radius: 4px;
  position: relative; cursor: pointer; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--pointer));
  border-radius: 4px; transition: width 0.15s;
}
.step-info {
  font-size: 13px; color: var(--text-muted); font-family: var(--font-mono);
  min-width: 80px; text-align: right;
}
.speed-select {
  padding: 6px 10px; border-radius: 6px;
  background: var(--bg-tertiary); color: var(--text-primary);
  border: none; font-size: 13px; cursor: pointer;
}

/* 代码面板 */
.code-panel {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-md);
  overflow: hidden; display: flex; flex-direction: column;
}
.code-header {
  padding: 10px 16px; border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted);
}
.code-dots { display: flex; gap: 6px; }
.code-dot { width: 12px; height: 12px; border-radius: 50%; }
.code-dot.red { background: #F87171; }
.code-dot.yellow { background: #FBBF24; }
.code-dot.green { background: #34D399; }
.code-content {
  padding: 14px 0; font-family: var(--font-mono);
  font-size: 13px; line-height: 1.7; overflow-x: auto;
}
.code-line {
  display: flex; padding: 0 16px; transition: background 0.2s;
  min-width: max-content;
}
.code-line.active {
  background: rgba(251, 191, 36, 0.12);
  border-left: 3px solid var(--highlight);
  padding-left: 13px;
}
.code-line-num {
  color: var(--text-dim); min-width: 32px; text-align: right;
  margin-right: 16px; user-select: none;
}
.code-line-text { color: var(--text-secondary); white-space: pre; }

/* 状态栏 */
.status-bar {
  padding: 12px 16px; margin-top: 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-md);
}
.status-desc {
  font-size: 15px; color: var(--text-primary); margin-bottom: 8px;
}
.status-meta { display: flex; gap: 12px; flex-wrap: wrap; }
.status-meta-item {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 6px; font-size: 13px;
  background: rgba(148, 163, 184, 0.1); color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* 算法原理说明 */
.principle-section { margin-top: 32px; }
.principle-title {
  font-size: 22px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
.principle-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
@media (max-width: 900px) {
  .principle-grid { grid-template-columns: 1fr; }
}
.principle-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-md);
  padding: 20px;
}
.principle-card-title {
  font-size: 16px; font-weight: 600; color: var(--text-primary);
  margin-bottom: 12px;
}
.principle-card-content {
  font-size: 14px; color: var(--text-secondary);
  line-height: 1.8;
}
.principle-card-content p { margin: 0; }
.principle-step {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 10px;
}
.principle-step:last-child { margin-bottom: 0; }
.step-num {
  flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #0F172A;
  font-family: var(--font-mono);
}
.step-text { flex: 1; padding-top: 2px; }
.principle-list {
  margin: 0; padding-left: 20px;
}
.principle-list li { margin-bottom: 6px; }
.principle-list li:last-child { margin-bottom: 0; }
.complex-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.complex-row {
  display: flex; justify-content: space-between;
  padding: 8px 12px;
  background: rgba(148, 163, 184, 0.06);
  border-radius: 6px;
}
.c-label { color: var(--text-muted); font-size: 13px; }
.c-value {
  color: var(--accent); font-weight: 600;
  font-family: var(--font-mono); font-size: 13px;
}

/* ============================================================
 * 首页专用
 * ============================================================ */

.hero {
  position: relative; overflow: hidden;
  min-height: 80vh; display: flex; align-items: center;
  padding: 80px 0;
}
.hero-bg-grid {
  position: absolute; inset: 0; opacity: 0.4;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
}
.hero-content { position: relative; z-index: 1; max-width: 800px; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 16px; border-radius: 999px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 13px; color: var(--text-secondary); margin-bottom: 24px;
}
.hero-title {
  font-size: 52px; font-weight: 800; line-height: 1.15; margin-bottom: 20px;
}
.hero-title .grad-blue {
  background: linear-gradient(135deg, #38BDF8, #A78BFA);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero-title .grad-amber {
  background: linear-gradient(135deg, #FBBF24, #F87171);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero-desc {
  font-size: 18px; color: var(--text-muted); margin-bottom: 32px; max-width: 640px;
}
.hero-buttons { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 48px; }
.btn-hero-primary {
  padding: 14px 28px; border-radius: 12px; font-size: 16px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--pointer));
  color: var(--bg-primary); transition: all 0.2s;
}
.btn-hero-primary:hover { transform: scale(1.05); }
.btn-hero-secondary {
  padding: 14px 28px; border-radius: 12px; font-size: 16px; font-weight: 600;
  background: rgba(30, 41, 59, 0.6); border: 1px solid rgba(148, 163, 184, 0.15);
  color: var(--text-primary); transition: all 0.2s;
}
.btn-hero-secondary:hover { background: rgba(51, 65, 85, 0.6); }

.hero-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; max-width: 640px;
}
@media (max-width: 700px) {
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-title { font-size: 36px; }
}
.hero-stat-card {
  padding: 16px; border-radius: 12px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.12);
}
.hero-stat-value { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hero-stat-label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* 章节卡片 */
.chapter-card {
  display: block; padding: 24px; border-radius: var(--radius-lg);
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.12);
  transition: all 0.3s;
}
.chapter-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
.chapter-card-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 16px;
}
.chapter-card-title {
  font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px;
}
.chapter-card-subtitle {
  font-size: 14px; color: var(--text-muted); margin-bottom: 16px;
}
.chapter-card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.chapter-card-tag {
  padding: 3px 10px; border-radius: 6px; font-size: 12px;
  background: rgba(148, 163, 184, 0.1); color: var(--text-secondary);
}

/* section 标题 */
.section { padding: 64px 0; }
.section-title {
  font-size: 32px; font-weight: 800; color: var(--text-primary); margin-bottom: 8px;
}
.section-desc { font-size: 16px; color: var(--text-muted); margin-bottom: 32px; }

/* 学习路径 */
.path-stage {
  display: flex; gap: 16px; margin-bottom: 16px; align-items: flex-start;
}
.path-num {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800;
}
.path-content {
  flex: 1; padding: 16px 20px; border-radius: 12px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.12);
}
.path-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.path-goal { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; }
.path-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.path-tag {
  padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 500;
}

/* 工具类 */
.text-center { text-align: center; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 32px; }
.hidden { display: none; }

/* 复杂度信息 */
.complexity-info {
  display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.complexity-badge {
  padding: 6px 14px; border-radius: 8px; font-size: 13px;
  background: rgba(148, 163, 184, 0.1);
}
.complexity-badge .label { color: var(--text-muted); margin-right: 6px; }
.complexity-badge .value { color: var(--highlight); font-family: var(--font-mono); font-weight: 600; }

/* 侧边栏 */
.demo-with-sidebar {
  display: flex; gap: 24px; padding: 32px 0;
}
.sidebar {
  width: 240px; flex-shrink: 0; position: sticky; top: 80px;
  align-self: flex-start; max-height: calc(100vh - 96px); overflow-y: auto;
}
.sidebar-section { margin-bottom: 24px; }
.sidebar-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); margin-bottom: 8px; padding: 0 12px;
}
.sidebar-link {
  display: block; padding: 8px 12px; border-radius: 8px;
  font-size: 14px; color: var(--text-secondary); transition: all 0.15s;
}
.sidebar-link:hover { background: rgba(148, 163, 184, 0.08); color: var(--text-primary); }
.sidebar-link.active { background: rgba(56, 189, 248, 0.12); color: var(--accent); font-weight: 600; }
.demo-content { flex: 1; min-width: 0; }
@media (max-width: 900px) {
  .demo-with-sidebar { flex-direction: column; }
  .sidebar { width: 100%; position: static; }
}
