/* AI Agent 框架实战 — common.css */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --card: #1c2128;
  --card-hover: #262c36;
  --border: rgba(180,185,210,0.12);
  --border-bright: rgba(180,185,210,0.28);
  --text: #e6edf3;
  --text-2: #adbac7;
  --text-3: #768390;
  --accent: #a78bfa;
  --accent-2: #c4b5fd;
  --accent-glow: rgba(167,139,250,0.15);
  --green: #56d364;
  --blue: #79c0ff;
  --red: #ff7b72;
  --purple: #d2a8ff;
  --cyan: #39d5ff;
  --radius: 10px;
  --radius-lg: 14px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
}

/* ── NAV ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 2rem;
  height: 56px;
  background: rgba(13,17,23,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-back {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  opacity: 0.85;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.nav-back::before { content: '←'; font-size: 1rem; }
.nav-back:hover { opacity: 1; }

.nav-title {
  flex: 1;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-2);
  font-weight: 500;
}

/* ── HERO (index page) ── */
.hero {
  position: relative;
  overflow: hidden;
  padding: 6rem 2rem 5rem;
  text-align: center;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, #1e1640 0%, #161b22 40%, #0d1117 100%);
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(245,158,11,0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(251,191,36,0.05) 0%, transparent 40%),
    radial-gradient(circle at 60% 80%, rgba(245,158,11,0.04) 0%, transparent 40%);
  pointer-events: none;
}

/* Neural network animation canvas area */
.neural-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.neural-bg .node {
  position: absolute;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow), 0 0 20px var(--accent-glow);
  animation: nodePulse 3s ease-in-out infinite;
}

.neural-bg .node:nth-child(1)  { width:8px;  height:8px;  left:10%;  top:20%; animation-delay:0s;    opacity:0.7; }
.neural-bg .node:nth-child(2)  { width:6px;  height:6px;  left:25%;  top:60%; animation-delay:0.4s;  opacity:0.5; }
.neural-bg .node:nth-child(3)  { width:10px; height:10px; left:45%;  top:15%; animation-delay:0.8s;  opacity:0.8; }
.neural-bg .node:nth-child(4)  { width:7px;  height:7px;  left:65%;  top:45%; animation-delay:1.2s;  opacity:0.6; }
.neural-bg .node:nth-child(5)  { width:9px;  height:9px;  left:80%;  top:25%; animation-delay:0.6s;  opacity:0.7; }
.neural-bg .node:nth-child(6)  { width:5px;  height:5px;  left:90%;  top:70%; animation-delay:1.6s;  opacity:0.4; }
.neural-bg .node:nth-child(7)  { width:7px;  height:7px;  left:35%;  top:75%; animation-delay:2.0s;  opacity:0.55;}
.neural-bg .node:nth-child(8)  { width:8px;  height:8px;  left:55%;  top:65%; animation-delay:1.0s;  opacity:0.65;}
.neural-bg .node:nth-child(9)  { width:6px;  height:6px;  left:72%;  top:85%; animation-delay:1.8s;  opacity:0.45;}
.neural-bg .node:nth-child(10) { width:9px;  height:9px;  left:15%;  top:82%; animation-delay:2.4s;  opacity:0.6; }

.neural-bg .line {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(245,158,11,0.3), transparent);
  transform-origin: left center;
  animation: lineFlash 4s ease-in-out infinite;
}
.neural-bg .line:nth-child(11) { width:200px; left:10%; top:20%; transform:rotate(22deg);  animation-delay:0.2s; }
.neural-bg .line:nth-child(12) { width:240px; left:25%; top:60%; transform:rotate(-15deg); animation-delay:1.0s; }
.neural-bg .line:nth-child(13) { width:180px; left:45%; top:15%; transform:rotate(35deg);  animation-delay:0.5s; }
.neural-bg .line:nth-child(14) { width:160px; left:65%; top:45%; transform:rotate(-28deg); animation-delay:1.5s; }
.neural-bg .line:nth-child(15) { width:220px; left:35%; top:75%; transform:rotate(12deg);  animation-delay:2.0s; }
.neural-bg .line:nth-child(16) { width:190px; left:15%; top:82%; transform:rotate(-40deg); animation-delay:0.8s; }

@keyframes nodePulse {
  0%, 100% { transform: scale(1);   opacity: var(--op, 0.6); }
  50%       { transform: scale(1.5); opacity: 1; }
}
@keyframes lineFlash {
  0%, 100% { opacity: 0.1; }
  50%       { opacity: 0.6; }
}

.hero-badge {
  display: inline-block;
  padding: 0.3rem 1rem;
  border: 1px solid var(--border-bright);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--accent-2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  background: rgba(245,158,11,0.08);
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 1.2rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 50%, #fff8e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-2);
  max-width: 600px;
  margin: 0 auto 2.5rem;
  line-height: 1.8;
  position: relative;
}

.hero-meta {
  display: flex;
  justify-content: center;
  gap: 2rem;
  font-size: 0.85rem;
  color: var(--text-3);
  position: relative;
}
.hero-meta span { display: flex; align-items: center; gap: 0.4rem; }

/* ── CONTAINER ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

.section-header {
  text-align: center;
  margin-bottom: 3rem;
}
.section-header h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.section-header p {
  color: var(--text-3);
  font-size: 0.95rem;
}

/* ── CARDS (index) ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  opacity: 0;
  transform: translateY(20px);
  animation: cardIn 0.5s ease forwards;
}
.card:hover {
  background: var(--card-hover);
  border-color: var(--border-bright);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(245,158,11,0.12);
}

@keyframes cardIn {
  to { opacity: 1; transform: translateY(0); }
}

.card-num {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.7;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.card-desc {
  font-size: 0.85rem;
  color: var(--text-3);
  line-height: 1.6;
  flex: 1;
}
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}
.tag {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: rgba(245,158,11,0.1);
  color: var(--accent-2);
  border: 1px solid rgba(245,158,11,0.2);
}

/* ── CHAPTER HERO ── */
.chapter-hero {
  padding: 4.5rem 2rem 3.5rem;
  text-align: center;
  background: radial-gradient(ellipse at top, #1e1640 0%, #161b22 50%, #0d1117 100%);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.chapter-hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}

.ch-num {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.6;
  margin-bottom: 1rem;
}
.chapter-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--accent-2), var(--text));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.chapter-hero p {
  font-size: 1rem;
  color: var(--text-2);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.8;
}

/* ── CONTENT ── */
.content {
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
}

.content h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  margin: 3rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.content h2::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 40px;
  height: 1px;
  background: var(--accent);
}

.content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-2);
  margin: 2rem 0 0.75rem;
}

.content p {
  color: var(--text-2);
  margin-bottom: 1.2rem;
  line-height: 1.85;
}

.content ul, .content ol {
  color: var(--text-2);
  padding-left: 1.5rem;
  margin-bottom: 1.2rem;
}
.content li { margin-bottom: 0.4rem; line-height: 1.7; }

/* ── PROGRESS ── */
.progress {
  width: 100%;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  margin-bottom: 3rem;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: width 0.6s ease;
}

/* ── DEF LIST ── */
.def-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.def-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--accent);
}
.def-term {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-2);
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}
.def-desc {
  font-size: 0.9rem;
  color: var(--text-3);
  line-height: 1.7;
}

/* ── CALLOUT ── */
.callout {
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-left: 3px solid;
  font-size: 0.92rem;
  line-height: 1.7;
}
.callout strong { display: block; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.4rem; }

.callout.info {
  background: rgba(245,158,11,0.08);
  border-color: var(--accent);
  color: var(--text-2);
}
.callout.info strong { color: var(--accent); }

.callout.tip {
  background: rgba(74,222,128,0.07);
  border-color: var(--green);
  color: var(--text-2);
}
.callout.tip strong { color: var(--green); }

.callout.warning {
  background: rgba(251,191,36,0.07);
  border-color: var(--accent-2);
  color: var(--text-2);
}
.callout.warning strong { color: var(--accent-2); }

.callout.danger {
  background: rgba(248,113,113,0.08);
  border-color: var(--red);
  color: var(--text-2);
}
.callout.danger strong { color: var(--red); }

/* ── CODE ── */
pre {
  background: #090c10;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  line-height: 1.75;
  position: relative;
}
pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 0.7rem;
  color: var(--text-3);
  font-family: inherit;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', Consolas, monospace;
  font-size: 0.875em;
}
p code, li code {
  background: rgba(245,158,11,0.1);
  color: var(--accent-2);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

/* Code highlight */
.kw { color: #f59e0b; font-weight: 600; }   /* keyword — gold */
.fn { color: #fbbf24; }                       /* function — amber */
.st { color: #4ade80; }                       /* string — green */
.cm { color: #8b949e; font-style: italic; }  /* comment */
.ty { color: #22d3ee; }                       /* type — cyan */
.nu { color: #c084fc; }                       /* number — purple */
.at { color: #f87171; }                       /* attr/decorator — red */
.pr { color: #60a5fa; }                       /* property — blue */

/* ── TWO COL ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin: 1.5rem 0;
}
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }

.two-col-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.two-col-item h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.75rem;
}
.two-col-item ul {
  font-size: 0.875rem;
  color: var(--text-3);
  padding-left: 1.2rem;
}
.two-col-item li { margin-bottom: 0.35rem; }

/* ── ASCII FLOW ── */
.ascii-flow {
  background: #090c10;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  margin: 1.5rem 0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.9;
  color: var(--text-2);
  overflow-x: auto;
  white-space: pre;
}

/* ── COMPARE TABLE ── */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.875rem;
}
.compare-table th {
  background: var(--surface-2);
  color: var(--accent-2);
  font-weight: 600;
  padding: 0.75rem 1rem;
  text-align: left;
  border: 1px solid var(--border);
}
.compare-table td {
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: top;
}
.compare-table tr:nth-child(even) td { background: rgba(245,158,11,0.03); }
.compare-table tr:hover td { background: rgba(245,158,11,0.06); }

/* ── CHAPTER NAV ── */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.chapter-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.875rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s;
  min-width: 0;
  max-width: 48%;
}
.chapter-nav a:hover {
  background: var(--card);
  border-color: var(--border-bright);
}
.chapter-nav .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}
.chapter-nav .title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chapter-nav .prev { align-items: flex-start; }
.chapter-nav .next { align-items: flex-end; margin-left: auto; }

/* ── SITE FOOTER ── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.82rem;
  color: var(--text-3);
  border-top: 1px solid var(--border);
}
.site-footer a {
  color: var(--accent);
  text-decoration: none;
  opacity: 0.8;
}
.site-footer a:hover { opacity: 1; }

/* ── HIGHLIGHT BOX ── */
.highlight-box {
  background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(251,191,36,0.04));
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

/* ── STEP LIST ── */
.step-list {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}
.step-list li {
  counter-increment: step;
  padding: 0.75rem 0.75rem 0.75rem 3.5rem;
  position: relative;
  border-left: 1px solid var(--border);
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-2);
  font-size: 0.92rem;
  line-height: 1.7;
}
.step-list li::before {
  content: counter(step);
  position: absolute;
  left: -1.5rem;
  top: 0.65rem;
  width: 2rem;
  height: 2rem;
  background: var(--card);
  border: 1px solid var(--border-bright);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .nav { padding: 0 1rem; }
  .content { padding: 2rem 1.25rem 4rem; }
  .chapter-hero { padding: 3rem 1.25rem 2.5rem; }
  .container { padding: 3rem 1.25rem; }
  .ascii-flow { font-size: 0.72rem; padding: 1rem; }
  .compare-table { font-size: 0.8rem; }
  .chapter-nav { flex-direction: column; }
  .chapter-nav a { max-width: 100%; }
}
