/* ── Node.js / Bun 后端教程 ── */
: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: #56d364;
  --accent-2: #86efac;
  --bun: #fef3c7;
  --bun-accent: #f472b6;
  --accent-glow: rgba(86,211,100,0.12);
  --blue: #79c0ff;
  --orange: #ffa657;
  --red: #ff7b72;
  --purple: #d2a8ff;
  --yellow: #e3b341;
  --radius: 10px;
  --radius-lg: 14px;
  --mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ── Navigation ── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13,17,23,0.96);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 52px;
  display: flex; align-items: center; gap: 16px;
}
.nav-back {
  color: var(--accent-2); text-decoration: none;
  font-size: 0.88rem; display: flex; align-items: center; gap: 4px;
  transition: color 0.2s;
}
.nav-back:hover { color: var(--bun); }
.nav-back::before { content: '‹'; font-size: 1.3rem; }
.nav-title { font-size: 0.92rem; font-weight: 600; flex: 1; color: var(--text); }
.nav-badge {
  background: var(--accent); color: #fff;
  font-size: 0.65rem; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
}
.nav-bun-badge {
  background: var(--bun); color: #1a0a00;
  font-size: 0.65rem; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
}

/* ── Hero (index page) ── */
.hero {
  background:
    radial-gradient(ellipse 70% 50% at 30% 0%, rgba(86,211,100,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 10%, rgba(254,243,199,0.04) 0%, transparent 50%),
    var(--surface);
  color: var(--text);
  padding: 80px 24px 70px;
  text-align: center;
  position: relative; overflow: hidden;
  border-bottom: 1px solid var(--border-bright);
}
.hero::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(to bottom, var(--accent), var(--bun), var(--accent-2));
}
.hero-icon { font-size: 4rem; margin-bottom: 14px; display: inline-block; position: relative; }
.hero-eyebrow {
  font-family: var(--mono); font-size: 0.7rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent-2); margin-bottom: 12px;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 700;
  letter-spacing: -0.02em; margin-bottom: 16px;
}
.hero h1 span.bun-color { color: var(--bun); }
.hero h1 span.node-color { color: var(--accent-2); }
.hero-sub {
  font-size: 0.98rem; color: var(--text-2);
  max-width: 540px; margin: 0 auto 28px;
}
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  background: rgba(104,160,99,0.08);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.75rem; padding: 4px 12px;
  border-radius: 20px; font-family: var(--mono);
}
.chip.bun {
  background: rgba(251,240,223,0.08);
  border-color: rgba(251,240,223,0.2);
  color: var(--bun);
}

/* ── Index Container ── */
.container { max-width: 860px; margin: 0 auto; padding: 36px 24px 80px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px; margin-bottom: 14px;
}
.card-list { list-style: none; }
.card-list li { border-bottom: 1px solid var(--border); }
.card-list li:last-child { border-bottom: none; }
.card-list a {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 10px; text-decoration: none; color: inherit;
  border-radius: var(--radius); transition: background 0.15s;
}
.card-list a:hover { background: var(--accent-glow); }
.list-num {
  width: 28px; height: 28px;
  background: var(--accent); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; flex-shrink: 0;
  font-family: var(--mono);
}
.list-content { flex: 1; }
.list-title { font-size: 0.93rem; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.list-desc { font-size: 0.8rem; color: var(--text-3); }
.list-chevron { color: var(--text-3); font-size: 1rem; align-self: center; }
.section-label {
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-3); margin: 30px 0 10px 2px;
}

.overview-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px; margin: 14px 0;
}
.overview-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.overview-card .ov-icon { font-size: 1.4rem; margin-bottom: 8px; }
.overview-card h3 { font-size: 0.88rem; margin: 0 0 5px; color: var(--text); }
.overview-card p { font-size: 0.78rem; margin: 0; color: var(--text-3); line-height: 1.5; }

/* ── Chapter Hero ── */
.chapter-hero {
  background:
    radial-gradient(ellipse 60% 80% at 50% -10%, rgba(86,211,100,0.12) 0%, transparent 60%),
    linear-gradient(160deg, #161b22 0%, #0d1117 60%, #161b22 100%);
  border-bottom: 1px solid var(--border-bright);
  color: var(--text);
  padding: 56px 24px 48px;
  text-align: center;
  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), transparent);
}
.chapter-hero .ch-num {
  font-size: 0.68rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent-2); margin-bottom: 10px; font-family: var(--mono);
}
.chapter-hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 700;
  margin-bottom: 12px; color: var(--text);
}
.chapter-hero p { color: var(--text-2); font-size: 0.93rem; max-width: 520px; margin: 0 auto; }

/* ── Content ── */
.content { max-width: 760px; margin: 0 auto; padding: 44px 24px 80px; }

h2 {
  font-size: 1.35rem; font-weight: 700; color: var(--text);
  margin: 44px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-bright);
}
h2:first-child { margin-top: 0; }
h3 { font-size: 1.05rem; font-weight: 700; color: var(--text); margin: 28px 0 10px; }
h4 {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-3); margin: 18px 0 8px;
}
p { margin-bottom: 14px; color: var(--text-2); font-size: 0.93rem; line-height: 1.8; }
strong { color: var(--text); }

/* ── Callouts ── */
.callout {
  border-radius: var(--radius); padding: 14px 16px; margin: 18px 0;
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 0.87rem; line-height: 1.65; border: 1px solid;
}
.callout-icon { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }
.callout p { margin: 0; color: inherit; font-size: inherit; }
.callout strong { display: block; margin-bottom: 3px; font-weight: 700; }
.callout.info {
  background: rgba(104,160,99,0.08);
  border-color: rgba(104,160,99,0.3);
  color: var(--accent-2);
}
.callout.info strong { color: var(--accent-2); }
.callout.tip {
  background: rgba(251,240,223,0.05);
  border-color: rgba(251,240,223,0.2);
  color: var(--bun);
}
.callout.tip strong { color: var(--bun); }
.callout.warning {
  background: rgba(251,191,36,0.08);
  border-color: rgba(251,191,36,0.25);
  color: var(--yellow);
}
.callout.warning strong { color: var(--yellow); }
.callout.danger {
  background: rgba(248,113,113,0.08);
  border-color: rgba(248,113,113,0.3);
  color: var(--red);
}
.callout.danger strong { color: var(--red); }

/* ── Code ── */
pre {
  background: #090d12;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 0.84rem; line-height: 1.7;
  margin: 14px 0; position: relative;
  font-family: var(--mono);
}
pre.no-prompt::before { content: ''; }
pre::before { content: ''; } /* no prompt by default */
pre .lang-label {
  position: absolute; top: 8px; right: 12px;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: rgba(180,185,210,0.4);
}
code { font-family: var(--mono); }
p code, li code, td code {
  background: rgba(104,160,99,0.12);
  color: var(--accent-2);
  padding: 2px 6px; border-radius: 4px; font-size: 0.85em;
}

/* Syntax highlighting */
.kw  { color: #56d364; font-weight: 700; }   /* keyword */
.ty  { color: #67e8f9; }                       /* type — cyan */
.st  { color: #fbbf24; }                       /* string — yellow */
.cm  { color: #8b949e; font-style: italic; }   /* comment */
.fn  { color: #a3e635; }                       /* function — lime */
.nu  { color: #c084fc; }                       /* number — purple */
.at  { color: var(--orange); }                 /* attr — orange */
.pr  { color: var(--blue); }                   /* property — blue */
.bun-kw { color: var(--bun); font-weight: 700; } /* bun keyword */

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 0.86rem; }
th {
  background: var(--card);
  color: var(--text-2); font-weight: 700;
  padding: 10px 14px; text-align: left;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-bright);
}
td { padding: 10px 14px; border-top: 1px solid var(--border); color: var(--text-2); }
tr:hover td { background: rgba(104,160,99,0.04); }

/* ── Def list ── */
.def-list { list-style: none; }
.def-list li {
  padding: 12px 0; border-bottom: 1px solid var(--border);
  display: grid; grid-template-columns: 160px 1fr; gap: 16px; font-size: 0.88rem;
}
.def-list li:last-child { border-bottom: none; }
.def-term { font-weight: 700; color: var(--accent-2); font-family: var(--mono); font-size: 0.83rem; }
.def-desc { color: var(--text-2); }

/* ── Progress ── */
.progress { height: 4px; background: var(--border); border-radius: 2px; margin-bottom: 32px; }
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
}

/* ── Two col ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }

/* ── Lists ── */
.content ul, .content ol {
  padding-left: 22px; margin: 10px 0 14px;
  color: var(--text-2); font-size: 0.91rem; line-height: 1.85;
}

/* ── Compare block ── */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.compare-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.compare-box.node { border-top: 3px solid var(--accent); }
.compare-box.bun  { border-top: 3px solid var(--bun); }
.compare-title {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; margin-bottom: 10px;
}
.compare-box.node .compare-title { color: var(--accent-2); }
.compare-box.bun  .compare-title { color: var(--bun); }
.compare-box pre { margin: 0; background: transparent; border: none; padding: 0; font-size: 0.8rem; }

/* ── Perf badge ── */
.perf-badge {
  display: inline-block;
  background: rgba(134,196,128,0.15);
  border: 1px solid rgba(134,196,128,0.35);
  color: var(--accent-2);
  font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
  padding: 3px 10px; border-radius: 20px; margin-left: 8px;
}
.perf-badge.fast {
  background: rgba(163,230,53,0.12);
  border-color: rgba(163,230,53,0.3);
  color: #a3e635;
}
.perf-badge.bun {
  background: rgba(251,240,223,0.1);
  border-color: rgba(251,240,223,0.25);
  color: var(--bun);
}

/* ── Chapter Nav ── */
.chapter-nav {
  display: flex; gap: 12px; margin-top: 48px;
  padding-top: 22px; border-top: 1px solid var(--border);
}
.chapter-nav a {
  flex: 1; display: flex; flex-direction: column; gap: 4px;
  padding: 14px; background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none; color: inherit; transition: border-color 0.2s;
}
.chapter-nav a:hover { border-color: var(--accent); }
.nav-dir { font-size: 0.7rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em; }
.nav-title-text { font-weight: 600; color: var(--accent-2); font-size: 0.88rem; }
.prev { text-align: left; }
.next { text-align: right; }

/* ── Site footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px; text-align: center;
  font-size: 0.78rem; color: var(--text-3);
}
.site-footer a { color: var(--accent-2); text-decoration: none; }
.site-footer a:hover { color: var(--bun); }

@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }
  .compare { grid-template-columns: 1fr; }
  .def-list li { grid-template-columns: 1fr; }
}
