/* ============================================================
   AI Agent 完整教程 — 共享样式表
   基于 Claude Code 实战 | 入门→进阶→高阶
   支持浅色/深色主题切换（默认浅色）
   ============================================================ */

/* ============================================================
   浅色主题 — 默认
   ============================================================ */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #4f46e5;
  --secondary: #0891b2;
  --accent: #d97706;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #ffffff;
  --bg-card: #f8fafc;
  --bg-code: #f1f5f9;
  --bg-callout: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-heading: #0f172a;
  --border: #e2e8f0;
  --nav-bg: rgba(255, 255, 255, 0.92);
  --code-text: #1e293b;
  --table-stripe: #f1f5f9;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.12);
  --max-width: 960px;
  --toggle-bg: #f1f5f9;
  --toggle-border: #e2e8f0;
}

/* ============================================================
   深色主题
   ============================================================ */
[data-theme="dark"] {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #a5b4fc;
  --secondary: #06b6d4;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-code: #0d1117;
  --bg-callout: rgba(30, 41, 59, 0.5);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-heading: #f1f5f9;
  --border: #334155;
  --nav-bg: rgba(15, 23, 42, 0.95);
  --code-text: #c9d1d9;
  --table-stripe: rgba(30, 41, 59, 0.3);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.45);
  --toggle-bg: #334155;
  --toggle-border: #475569;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
  transition: background 0.35s ease, color 0.35s ease;
}

/* ============================================================
   Theme Toggle Button
   ============================================================ */
.theme-toggle {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--toggle-border);
  background: var(--toggle-bg);
  cursor: pointer;
  font-size: 1.15rem;
  transition: all 0.25s ease;
  line-height: 1;
  padding: 0;
}

.theme-toggle:hover {
  transform: scale(1.1);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* ============================================================
   Navigation
   ============================================================ */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  transition: background 0.35s ease, border-color 0.35s ease;
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 1.25rem;
}

.nav-brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.35s ease;
}

[data-theme="dark"] .nav-brand {
  color: var(--primary-light);
}

.nav-brand span { color: var(--text); transition: color 0.35s ease; }

.nav-links {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

[data-theme="dark"] .nav-links a:hover,
[data-theme="dark"] .nav-links a.active {
  color: var(--primary-light);
  background: rgba(99, 102, 241, 0.15);
}

/* ============================================================
   Container
   ============================================================ */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ============================================================
   Typography
   ============================================================ */
h1 {
  font-size: 2.2rem;
  color: var(--text-heading);
  margin-bottom: 0.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  transition: color 0.35s ease;
}
h2 {
  font-size: 1.65rem;
  color: var(--text-heading);
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
  font-weight: 700;
  transition: color 0.35s ease, border-color 0.35s ease;
}
h3 {
  font-size: 1.3rem;
  color: var(--text-heading);
  margin: 2rem 0 0.75rem;
  font-weight: 600;
  transition: color 0.35s ease;
}
h4 {
  font-size: 1.1rem;
  color: var(--primary);
  margin: 1.5rem 0 0.5rem;
  font-weight: 600;
  transition: color 0.35s ease;
}

[data-theme="dark"] h4 { color: var(--primary-light); }

p { margin-bottom: 1rem; }
a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
[data-theme="dark"] a { color: var(--primary-light); }
a:hover { text-decoration: underline; }

strong { color: var(--text-heading); font-weight: 600; transition: color 0.35s ease; }
em { color: var(--secondary); font-style: normal; }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  text-align: center;
  padding: 3rem 1.5rem;
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(6,182,212,0.04));
  border-radius: var(--radius-lg);
  margin-bottom: 2.5rem;
  border: 1px solid var(--border);
  transition: background 0.35s ease, border-color 0.35s ease;
}

[data-theme="dark"] .hero {
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(6,182,212,0.08));
}

.hero h1 {
  font-size: 2.6rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .hero h1 {
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 640px;
  margin: 0 auto 1rem;
}

/* ============================================================
   Stage Cards
   ============================================================ */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.stage-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all 0.25s;
  text-decoration: none;
  color: var(--text);
  display: block;
}

.stage-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  text-decoration: none;
}

.stage-card .stage-num {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  margin-bottom: 0.75rem;
}

.stage-card h3 { margin: 0 0 0.5rem; font-size: 1.15rem; border: none; padding: 0; }
.stage-card p { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

/* ============================================================
   Module List
   ============================================================ */
.module-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.module-list li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.6rem;
  transition: all 0.2s;
}

.module-list li:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.04);
}

[data-theme="dark"] .module-list li:hover {
  background: rgba(99, 102, 241, 0.08);
}

.module-list li a {
  font-weight: 600;
  font-size: 1.05rem;
  display: block;
  margin-bottom: 0.25rem;
}

.module-list li .mod-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ============================================================
   Code Blocks
   ============================================================ */
pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.875rem;
  line-height: 1.6;
  transition: background 0.35s ease, border-color 0.35s ease;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 0.875em;
  background: rgba(99, 102, 241, 0.08);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--primary);
}

[data-theme="dark"] code {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
}

pre code {
  background: none;
  padding: 0;
  color: var(--code-text);
  font-size: 0.85rem;
  transition: color 0.35s ease;
}

h2 code, h3 code, h4 code { font-size: 0.9em; }

/* ============================================================
   Callouts / Admonitions
   ============================================================ */
.callout {
  border-left: 4px solid;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  background: var(--bg-callout);
  transition: background 0.35s ease;
}

.callout-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.callout-tip { border-color: var(--success); }
.callout-tip .callout-title { color: var(--success); }
.callout-warning { border-color: var(--warning); }
.callout-warning .callout-title { color: var(--warning); }
.callout-danger { border-color: var(--danger); }
.callout-danger .callout-title { color: var(--danger); }
.callout-info { border-color: var(--secondary); }
.callout-info .callout-title { color: var(--secondary); }

/* ============================================================
   Steps
   ============================================================ */
.step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1rem 0;
  counter-increment: step-counter;
  transition: background 0.35s ease, border-color 0.35s ease;
}

.step::before {
  content: "Step " counter(step-counter);
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  margin-bottom: 0.5rem;
}

.steps-wrapper { counter-reset: step-counter; }

/* ============================================================
   Tables
   ============================================================ */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.65rem 0.9rem;
  text-align: left;
  transition: border-color 0.35s ease;
}

th {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-heading);
  font-weight: 600;
  transition: background 0.35s ease, color 0.35s ease;
}

[data-theme="dark"] th {
  background: rgba(99, 102, 241, 0.15);
}

tr:nth-child(even) {
  background: var(--table-stripe);
  transition: background 0.35s ease;
}

/* ============================================================
   Architecture Diagrams
   ============================================================ */
.arch-diagram {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin: 1.5rem 0;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre;
  color: var(--primary);
  transition: background 0.35s ease, border-color 0.35s ease, color 0.35s ease;
}

[data-theme="dark"] .arch-diagram {
  color: var(--primary-light);
}

/* ============================================================
   Tags / Badges
   ============================================================ */
.tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15em 0.55em;
  border-radius: 100px;
  font-weight: 600;
  margin-right: 0.3rem;
}

.tag-beginner { background: rgba(16, 185, 129, 0.12); color: #059669; }
.tag-intermediate { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.tag-advanced { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.tag-claude { background: rgba(99, 102, 241, 0.12); color: #4f46e5; }

[data-theme="dark"] .tag-beginner { background: rgba(16, 185, 129, 0.18); color: var(--success); }
[data-theme="dark"] .tag-intermediate { background: rgba(245, 158, 11, 0.18); color: var(--warning); }
[data-theme="dark"] .tag-advanced { background: rgba(239, 68, 68, 0.18); color: var(--danger); }
[data-theme="dark"] .tag-claude { background: rgba(99, 102, 241, 0.18); color: var(--primary-light); }

/* ============================================================
   Exercise Box
   ============================================================ */
.exercise {
  background: linear-gradient(135deg, rgba(99,102,241,0.04), rgba(6,182,212,0.03));
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 2rem 0;
  transition: background 0.35s ease;
}

[data-theme="dark"] .exercise {
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(6,182,212,0.05));
}

.exercise h3 {
  color: var(--primary);
  margin-top: 0;
  border: none;
  padding: 0;
}

[data-theme="dark"] .exercise h3 { color: var(--primary-light); }

/* ============================================================
   FAQ
   ============================================================ */
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  transition: background 0.35s ease, border-color 0.35s ease;
}

.faq-item .q {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.35rem;
  transition: color 0.35s ease;
}

[data-theme="dark"] .faq-item .q { color: var(--primary-light); }

.faq-item .a { color: var(--text-muted); font-size: 0.9rem; }

/* ============================================================
   Knowledge Map
   ============================================================ */
.knowledge-map {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.5rem 0;
}

.km-level {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: background 0.35s ease, border-color 0.35s ease;
}

.km-level h3 {
  margin: 0 0 0.75rem;
  border: none;
  padding: 0;
}

.km-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.km-item {
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.15);
  padding: 0.35rem 0.75rem;
  border-radius: 100px;
  font-size: 0.8rem;
  color: var(--primary);
  transition: all 0.35s ease;
}

[data-theme="dark"] .km-item {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.25);
  color: var(--primary-light);
}

/* ============================================================
   Footer
   ============================================================ */
footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  transition: border-color 0.35s ease;
}

/* ============================================================
   Progress Bar
   ============================================================ */
.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 0 2px 2px 0;
  margin: 1rem 0 2rem;
  transition: background 0.35s ease;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: inherit;
  transition: width 0.3s;
}

/* ============================================================
   Tabs
   ============================================================ */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
  transition: border-color 0.35s ease;
}

.tab-btn {
  padding: 0.6rem 1.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn.active, .tab-btn:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

[data-theme="dark"] .tab-btn.active,
[data-theme="dark"] .tab-btn:hover {
  color: var(--primary-light);
}

/* ============================================================
   Checklist
   ============================================================ */
.checklist {
  list-style: none;
  padding: 0;
}

.checklist li {
  padding: 0.4rem 0;
  font-size: 0.95rem;
}

.checklist li::before {
  content: "☐ ";
  color: var(--text-muted);
  margin-right: 0.5rem;
}

/* ============================================================
   Print Styles — 始终浅色
   ============================================================ */
@media print {
  :root, [data-theme="dark"] {
    --bg: white;
    --bg-card: white;
    --bg-code: #f5f5f5;
    --text: #1a1a1a;
    --text-heading: #0f172a;
    --border: #ddd;
    --code-text: #1a1a1a;
  }
  body { background: white; color: #1a1a1a; }
  .top-nav { position: static; }
  .theme-toggle { display: none; }
  pre { background: #f5f5f5; border-color: #ddd; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.35rem; }
  .hero h1 { font-size: 1.9rem; }
  .stage-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .container { padding: 1.25rem 1rem; }
  .theme-toggle { width: 34px; height: 34px; font-size: 1rem; }
}

@media print {
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
}
