/* ── Pandas 数据分析 Tutorial — Clean Academic Style ── */
:root {
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --accent-mid: #3b82f6;
  --green: #16a34a;
  --green-light: #dcfce7;
  --orange: #d97706;
  --orange-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-warm: #f1f5f9;
  --text: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-mid: #d1d5db;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  --sans: -apple-system, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── NAV ── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--text);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 24px; height: 52px;
  display: flex; align-items: center; gap: 16px;
}
.nav-back {
  color: #93c5fd; text-decoration: none; font-size: 0.875rem;
  display: flex; align-items: center; gap: 5px; transition: color 0.15s;
}
.nav-back:hover { color: #bfdbfe; }
.nav-back::before { content: '←'; font-size: 1rem; }
.nav-title {
  font-size: 0.9rem; font-weight: 600; flex: 1;
  color: #f1f5f9; letter-spacing: -0.01em;
}
.nav-badge {
  background: var(--accent); color: #fff;
  font-size: 0.68rem; font-weight: 700;
  padding: 3px 10px; border-radius: 20px; letter-spacing: 0.03em;
}

/* ── HERO (index) ── */
.hero {
  background: linear-gradient(150deg, #0f172a 0%, #1e3a5f 55%, #172554 100%);
  color: #fff; padding: 80px 24px 72px;
  text-align: center; position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0; opacity: 0.025;
  background-image:
    linear-gradient(rgba(255,255,255,0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.5) 1px, transparent 1px);
  background-size: 40px 40px;
}
.hero-icon { font-size: 3.5rem; margin-bottom: 16px; position: relative; display: inline-block; }
.hero-eyebrow {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: #93c5fd; margin-bottom: 14px; position: relative;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem); font-weight: 800;
  letter-spacing: -0.03em; position: relative; margin-bottom: 16px;
  line-height: 1.15;
}
.hero-sub {
  font-size: 1rem; color: rgba(255,255,255,0.65);
  max-width: 540px; margin: 0 auto 32px; position: relative; line-height: 1.7;
}
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; position: relative; }
.chip {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.75); font-size: 0.75rem;
  padding: 4px 13px; border-radius: 20px; font-family: var(--mono);
}

/* ── CONTAINER ── */
.container { max-width: 860px; margin: 0 auto; padding: 40px 24px 80px; }

/* ── SECTION LABEL ── */
.section-label {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-muted);
  margin: 32px 0 10px 2px;
}

/* ── CARDS (index) ── */
.card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card p { font-size: 0.94rem; color: var(--text-secondary); line-height: 1.75; margin-bottom: 10px; }
.card p:last-child { margin-bottom: 0; }

.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-light); }
.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.94rem; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.list-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }
.list-chevron { color: var(--border-mid); font-size: 1rem; align-self: center; }

/* ── CHAPTER HERO ── */
.chapter-hero {
  background: linear-gradient(135deg, var(--accent) 0%, #1d4ed8 100%);
  color: #fff; padding: 56px 24px 48px; text-align: center;
}
.chapter-hero .ch-num {
  font-size: 0.68rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(255,255,255,0.55); margin-bottom: 10px; font-family: var(--mono);
}
.chapter-hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 800;
  margin-bottom: 12px; line-height: 1.2;
}
.chapter-hero p { color: rgba(255,255,255,0.72); font-size: 0.95rem; max-width: 540px; margin: 0 auto; }

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

h2 {
  font-size: 1.4rem; font-weight: 700; color: var(--text);
  margin: 48px 0 16px; padding-bottom: 10px;
  border-bottom: 2px solid var(--accent-light);
}
h2:first-child { margin-top: 0; }
h3 { font-size: 1.08rem; font-weight: 700; color: var(--text); margin: 32px 0 12px; }
h4 {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted); margin: 20px 0 8px;
}

p { margin-bottom: 16px; color: var(--text-secondary); font-size: 1rem; line-height: 1.8; }
p:last-child { margin-bottom: 0; }

.content ul, .content ol {
  padding-left: 24px; margin: 10px 0 16px;
  color: var(--text-secondary); font-size: 0.97rem; line-height: 1.85;
}
.content li { margin-bottom: 5px; }

/* ── CALLOUTS ── */
.callout {
  border-radius: var(--radius); padding: 14px 18px; margin: 20px 0;
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 0.9rem; line-height: 1.7;
}
.callout-icon { font-size: 1.05rem; flex-shrink: 0; margin-top: 1px; }
.callout p { margin: 0; color: inherit; font-size: inherit; line-height: 1.7; }
.callout strong { display: block; margin-bottom: 3px; font-weight: 700; }
.callout.info  { background: var(--accent-light); color: #1e3a5f; border-left: 3px solid var(--accent); }
.callout.tip   { background: var(--green-light);  color: #14532d; border-left: 3px solid var(--green); }
.callout.warning { background: var(--orange-light); color: #78350f; border-left: 3px solid var(--orange); }
.callout.danger  { background: var(--red-light);    color: #7f1d1d; border-left: 3px solid var(--red); }

/* ── CODE ── */
pre {
  background: var(--code-bg); color: var(--code-text);
  border-radius: var(--radius); padding: 20px 22px;
  overflow-x: auto; font-size: 0.875rem; line-height: 1.7;
  margin: 16px 0; position: relative;
  border: 1px solid rgba(255,255,255,0.05);
}
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(255,255,255,0.22);
}
code { font-family: var(--mono); }
p code, li code, td code, h3 code {
  background: var(--accent-light); color: var(--accent);
  padding: 2px 7px; border-radius: 4px; font-size: 0.855em;
}

/* Syntax highlighting */
.kw { color: #7dd3fc; font-weight: 600; }   /* keywords */
.ty { color: #67e8f9; }                      /* types */
.st { color: #86efac; }                      /* strings */
.cm { color: #64748b; font-style: italic; }  /* comments */
.fn { color: #fde68a; }                      /* functions */
.nu { color: #fca5a5; }                      /* numbers */
.at { color: #a5f3fc; }                      /* attributes/decorators */
.pr { color: #c4b5fd; }                      /* properties */

/* ── DEF LIST ── */
.def-list { list-style: none; }
.def-list li {
  padding: 13px 0; border-bottom: 1px solid var(--border);
  display: grid; grid-template-columns: 180px 1fr; gap: 16px; font-size: 0.91rem;
}
.def-list li:last-child { border-bottom: none; }
.def-term { font-weight: 700; color: var(--accent); font-family: var(--mono); font-size: 0.86rem; word-break: break-word; }
.def-desc { color: var(--text-secondary); line-height: 1.75; }

/* ── TWO COL ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.two-col .card { margin-bottom: 0; }

/* ── PROGRESS ── */
.progress { height: 4px; background: var(--border); border-radius: 2px; margin-bottom: 32px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), #60a5fa); border-radius: 2px; transition: width 0.3s; }

/* ── TABLE ── */
table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 0.875rem; }
th {
  background: var(--bg-warm); color: var(--text); font-weight: 700;
  padding: 10px 14px; text-align: left; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border-mid);
}
td { padding: 10px 14px; border-top: 1px solid var(--border); color: var(--text-secondary); }
tr:hover td { background: var(--bg-soft); }

/* ── CHAPTER NAV ── */
.chapter-nav {
  display: flex; gap: 12px; margin-top: 52px;
  padding-top: 24px; border-top: 1px solid var(--border);
}
.chapter-nav a {
  flex: 1; display: flex; flex-direction: column; gap: 5px;
  padding: 14px 16px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.chapter-nav a:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(37,99,235,0.12); }
.nav-dir { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.nav-title-text { font-weight: 600; color: var(--accent); font-size: 0.9rem; }
.prev { text-align: left; }
.next { text-align: right; }

/* ── FOOTER ── */
.site-footer {
  border-top: 1px solid var(--border); padding: 28px 24px;
  text-align: center; font-size: 0.8rem; color: var(--text-muted);
  background: var(--bg-soft);
}
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ── OVERVIEW GRID ── */
.overview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 16px 0; }
.overview-card {
  background: var(--bg-soft); 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.9rem; margin: 0 0 5px; font-weight: 600; }
.overview-card p { font-size: 0.8rem; margin: 0; color: var(--text-muted); line-height: 1.55; }

/* ── VERSION BADGE ── */
.version-badge {
  display: inline-block; background: var(--accent); color: #fff;
  font-size: 0.7rem; font-weight: 700; padding: 2px 8px;
  border-radius: 4px; font-family: var(--mono); vertical-align: middle;
  margin-left: 6px;
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }
  .def-list li { grid-template-columns: 1fr; }
  .chapter-nav { flex-direction: column; }
  .content { padding: 32px 16px 60px; }
  h2 { font-size: 1.25rem; }
  p { font-size: 0.97rem; }
}
