/* RAG 向量数据库教程 — 深海蓝 AI 科技风 */
: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.26);
  --text: #e6edf3;
  --text-2: #adbac7;
  --text-3: #768390;
  --accent: #00b4d8;
  --accent-2: #0077b6;
  --accent-glow: rgba(0,180,216,0.2);
  --green: #4ade80;
  --orange: #fb923c;
  --red: #f87171;
  --purple: #c084fc;
  --yellow: #fbbf24;
  --radius: 10px;
  --radius-lg: 14px;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Pro Text', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  line-height: 1.75;
  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.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-back {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.nav-back::before { content: '←'; }
.nav-back:hover { color: #fff; }

.nav-sep { color: var(--text-3); font-size: 0.875rem; }

.nav-title {
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── INDEX HERO (首页) ─────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  padding: 6rem 2rem 5rem;
  text-align: center;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(0,180,216,0.08) 0%, #161b22 50%, #0d1117 100%);
}

/* 粒子/向量流动动画 */
.hero-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0;
  animation: float-particle linear infinite;
}
.particle:nth-child(1)  { left:8%;  animation-duration:7s;  animation-delay:0s;   width:3px; height:3px; }
.particle:nth-child(2)  { left:15%; animation-duration:9s;  animation-delay:1.2s; }
.particle:nth-child(3)  { left:23%; animation-duration:6s;  animation-delay:2.5s; width:2px; height:8px; border-radius:2px; }
.particle:nth-child(4)  { left:31%; animation-duration:8s;  animation-delay:0.7s; }
.particle:nth-child(5)  { left:40%; animation-duration:11s; animation-delay:3s;   width:3px; height:3px; }
.particle:nth-child(6)  { left:50%; animation-duration:7s;  animation-delay:1.8s; background:var(--accent-2); }
.particle:nth-child(7)  { left:58%; animation-duration:9s;  animation-delay:0.4s; }
.particle:nth-child(8)  { left:66%; animation-duration:6s;  animation-delay:2.1s; width:2px; height:10px; border-radius:2px; }
.particle:nth-child(9)  { left:74%; animation-duration:8s;  animation-delay:3.5s; }
.particle:nth-child(10) { left:83%; animation-duration:10s; animation-delay:0.9s; width:3px; height:3px; }
.particle:nth-child(11) { left:91%; animation-duration:7s;  animation-delay:2.8s; background:rgba(192,132,252,0.7); }
.particle:nth-child(12) { left:5%;  animation-duration:12s; animation-delay:1.5s; background:rgba(0,180,216,0.5); width:1px; height:14px; border-radius:2px; }

/* 流动连线 */
.flow-line {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,180,216,0.4), transparent);
  animation: flow-h linear infinite;
  opacity: 0;
}
.flow-line:nth-child(13) { width:200px; top:25%; animation-duration:5s;  animation-delay:0s;   left:-200px; }
.flow-line:nth-child(14) { width:300px; top:45%; animation-duration:7s;  animation-delay:2s;   left:-300px; }
.flow-line:nth-child(15) { width:150px; top:65%; animation-duration:4.5s;animation-delay:1s;   left:-150px; }
.flow-line:nth-child(16) { width:250px; top:75%; animation-duration:6s;  animation-delay:3.5s; left:-250px; }

@keyframes float-particle {
  0%   { transform: translateY(100vh) scale(0); opacity: 0; }
  10%  { opacity: 0.9; }
  90%  { opacity: 0.6; }
  100% { transform: translateY(-20px) scale(1); opacity: 0; }
}
@keyframes flow-h {
  0%   { transform: translateX(0);    opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 0.7; }
  100% { transform: translateX(calc(100vw + 300px)); opacity: 0; }
}

.hero-badge {
  display: inline-block;
  background: rgba(0,180,216,0.1);
  border: 1px solid var(--border-bright);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.3rem 0.9rem;
  border-radius: 100px;
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: #fff;
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
}

.hero h1 span {
  background: linear-gradient(135deg, var(--accent), #90e0ef);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--text-2);
  max-width: 640px;
  margin: 0 auto 2.5rem;
  position: relative;
  z-index: 1;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.stat-item { text-align: center; }
.stat-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  display: block;
  line-height: 1.1;
}
.stat-label { font-size: 0.78rem; color: var(--text-3); }

/* ── CHAPTER HERO ──────────────────────────── */
.chapter-hero {
  background: radial-gradient(ellipse at top, #161b22 0%, #0d1117 70%);
  position: relative;
  overflow: hidden;
  padding: 3.5rem 2rem 3rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.chapter-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 80% at 50% 120%, rgba(0,180,216,0.18) 0%, transparent 65%);
  pointer-events: none;
}
.ch-num {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
  opacity: 0.8;
}
.chapter-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.75rem;
  position: relative;
  z-index: 1;
}
.chapter-hero p {
  color: var(--text-2);
  font-size: 1rem;
  max-width: 580px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

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

.content h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: #fff;
  margin: 2.8rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.content h2::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.2em;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  flex-shrink: 0;
}

.content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.8rem 0 0.6rem;
}

.content p { color: var(--text-2); margin-bottom: 1rem; }
.content ul, .content ol { color: var(--text-2); padding-left: 1.5rem; margin-bottom: 1rem; }
.content li { margin-bottom: 0.35rem; }
.content strong { color: var(--text); }

/* ── CONTAINER (index page sections) ──────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
}
.section-sub {
  color: var(--text-2);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

/* ── CARD LIST (index chapters) ────────────── */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 3rem 0;
}

.chapter-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}
.chapter-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity 0.2s;
}
.chapter-card:hover {
  background: var(--card-hover);
  border-color: var(--border-bright);
  transform: translateX(4px);
}
.chapter-card:hover::before { opacity: 1; }

.ch-badge {
  width: 44px;
  height: 44px;
  background: rgba(0,180,216,0.1);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  letter-spacing: 0.05em;
}

.ch-info { flex: 1; }
.ch-title {
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 0.2rem;
}
.ch-desc { font-size: 0.83rem; color: var(--text-3); }

.ch-arrow {
  color: var(--text-3);
  font-size: 1.1rem;
  transition: color 0.2s, transform 0.2s;
}
.chapter-card:hover .ch-arrow {
  color: var(--accent);
  transform: translateX(4px);
}

/* ── CALLOUT BOXES ─────────────────────────── */
.callout {
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-left: 3px solid;
  font-size: 0.93rem;
}
.callout-title {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}
.callout p { margin-bottom: 0; font-size: 0.93rem; }

.callout.info {
  background: rgba(0,180,216,0.08);
  border-color: rgba(0,180,216,0.5);
}
.callout.info .callout-title { color: var(--accent); }
.callout.info p { color: #90cfe8; }

.callout.tip {
  background: rgba(74,222,128,0.07);
  border-color: rgba(74,222,128,0.45);
}
.callout.tip .callout-title { color: var(--green); }
.callout.tip p { color: #a7f3c4; }

.callout.warning {
  background: rgba(251,146,60,0.08);
  border-color: rgba(251,146,60,0.45);
}
.callout.warning .callout-title { color: var(--orange); }
.callout.warning p { color: #fcd2a0; }

.callout.danger {
  background: rgba(248,113,113,0.07);
  border-color: rgba(248,113,113,0.45);
}
.callout.danger .callout-title { color: var(--red); }
.callout.danger p { color: #fca5a5; }

.callout.purple {
  background: rgba(192,132,252,0.07);
  border-color: rgba(192,132,252,0.4);
}
.callout.purple .callout-title { color: var(--purple); }
.callout.purple p { color: #d8b4fe; }

/* ── CODE BLOCKS ───────────────────────────── */
pre {
  background: #090d12;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.7;
  margin: 1.25rem 0;
  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: monospace;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', Menlo, monospace;
  color: #cce8ff;
}
p code, li code {
  background: rgba(0,180,216,0.12);
  border: 1px solid rgba(0,180,216,0.2);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-size: 0.85em;
  color: var(--accent);
}

/* syntax highlight */
.kw { color: var(--purple); }          /* keywords */
.ty { color: var(--accent); }          /* types */
.st { color: var(--yellow); }          /* strings */
.cm { color: #5c8a9a; font-style: italic; } /* comments */
.fn { color: #4ade80; }                /* functions */
.nu { color: #f9a8d4; }               /* numbers */
.at { color: var(--orange); }          /* attributes/decorators */
.pr { color: var(--text-2); }          /* punctuation */
.bi { color: #60cdff; }               /* builtins */

/* ── DEF LIST ──────────────────────────────── */
.def-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.def-item {
  display: grid;
  grid-template-columns: 200px 1fr;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}
.def-item:last-child { border-bottom: none; }
.def-term {
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: flex-start;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  border-right: 1px solid var(--border);
  word-break: break-all;
}
.def-desc {
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  line-height: 1.65;
}

/* ── TABLE ─────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead th {
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 600;
  padding: 0.75rem 1rem;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-bright);
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(0,180,216,0.04); }
td {
  padding: 0.7rem 1rem;
  color: var(--text-2);
  vertical-align: top;
}
td strong { color: var(--text); }
td code {
  background: rgba(0,180,216,0.1);
  color: var(--accent);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.83em;
}

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

.col-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.col-card h4 {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  letter-spacing: 0.03em;
}
.col-card p, .col-card li { font-size: 0.875rem; color: var(--text-2); }
.col-card ul { padding-left: 1.2rem; }

/* ── FLOW DIAGRAM ──────────────────────────── */
.flow-diagram {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 1.5rem 0;
  flex-wrap: wrap;
  justify-content: center;
}
.flow-step {
  background: var(--card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text);
  min-width: 110px;
}
.flow-step strong {
  display: block;
  color: var(--accent);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
}
.flow-arrow {
  color: var(--accent);
  font-size: 1.2rem;
  padding: 0 0.3rem;
  flex-shrink: 0;
}

/* ── METRIC CARDS ──────────────────────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  text-align: center;
}
.metric-val {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.4rem;
}
.metric-label { font-size: 0.8rem; color: var(--text-3); }

/* ── PROGRESS ──────────────────────────────── */
.progress {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  margin-bottom: 2.5rem;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), #90e0ef);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ── CHAPTER NAV ───────────────────────────── */
.chapter-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.chapter-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  transition: background 0.2s, border-color 0.2s;
}
.chapter-nav a:hover {
  background: var(--card-hover);
  border-color: var(--border-bright);
}
.chapter-nav .prev { align-items: flex-start; }
.chapter-nav .next { align-items: flex-end; }
.chapter-nav .nav-dir {
  font-size: 0.75rem;
  color: var(--text-3);
  font-weight: 500;
}
.chapter-nav .nav-title-text {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}
@media (max-width: 500px) {
  .chapter-nav { grid-template-columns: 1fr; }
}

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

/* ── INDEX OVERVIEW CARD ───────────────────── */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 2rem 0 3rem;
}
.overview-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.overview-card h3 {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.overview-card p { font-size: 0.85rem; color: var(--text-2); }

/* ── TAG / BADGE ───────────────────────────── */
.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15em 0.55em;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.tag-blue { background: rgba(0,180,216,0.15); color: var(--accent); }
.tag-green { background: rgba(74,222,128,0.12); color: var(--green); }
.tag-purple { background: rgba(192,132,252,0.12); color: var(--purple); }
.tag-orange { background: rgba(251,146,60,0.12); color: var(--orange); }

/* ── HIGHLIGHT BOX ─────────────────────────── */
.highlight-box {
  background: linear-gradient(135deg, rgba(0,119,182,0.12), rgba(0,180,216,0.06));
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.5rem 0;
}
.highlight-box h3 {
  color: var(--accent);
  font-size: 1rem;
  margin-bottom: 0.75rem;
}
.highlight-box p, .highlight-box li { color: var(--text-2); font-size: 0.9rem; }
.highlight-box ul { padding-left: 1.2rem; }

/* ── SCROLL ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── RESPONSIVE ────────────────────────────── */
@media (max-width: 768px) {
  .nav { padding: 0 1rem; }
  .hero { padding: 4rem 1.25rem 3.5rem; }
  .content { padding: 2rem 1.25rem 3rem; }
  .container { padding: 0 1.25rem; }
  .def-item { grid-template-columns: 1fr; }
  .def-term { border-right: none; border-bottom: 1px solid var(--border); }
}
