/* ── 算法与数据结构 Tutorial — Academic Clean Design ── */
:root {
  --ink: #1a1a2e;
  --ink-light: #2d2d44;
  --accent: #5B4FBE;
  --accent-light: #EEF0FF;
  --accent-dim: #7B6FDE;
  --green: #27AE60;
  --green-light: #E8F8F5;
  --red: #E74C3C;
  --red-light: #FDEDEC;
  --orange: #E67E22;
  --orange-light: #FEF9E7;
  --paper: #FAFAF8;
  --paper-warm: #F5F5F0;
  --border: #E0DFD8;
  --border-dark: #C8C6BC;
  --text: #1a1a2e;
  --text-secondary: #4A4A6A;
  --text-muted: #8888AA;
  --mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
  --radius: 8px;
  --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--paper);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ── NAV ── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250,250,248,0.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); padding: 0 28px; height: 52px;
  display: flex; align-items: center; gap: 16px;
  font-family: -apple-system, 'Inter', sans-serif;
}
.nav-back { color: var(--accent); text-decoration: none; font-size: 0.88rem; display: flex; align-items: center; gap: 4px; }
.nav-back::before { content: '‹'; font-size: 1.3rem; }
.nav-title { font-size: 0.9rem; 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;
  font-family: -apple-system, sans-serif;
}

/* ── HERO ── */
.hero {
  background: linear-gradient(165deg, var(--ink) 0%, var(--ink-light) 50%, #1a2550 100%);
  color: #fff; padding: 80px 24px 70px; text-align: center; position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle 2px at 20% 30%, rgba(255,255,255,0.06) 0%, transparent 0%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(91,79,190,0.12) 0%, transparent 60%);
  background-size: 40px 40px, 100% 100%;
}
.hero-icon { font-size: 3.5rem; margin-bottom: 14px; position: relative; }
.hero-eyebrow {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 400; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--accent-dim); margin-bottom: 12px; position: relative;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 700; letter-spacing: -0.01em;
  line-height: 1.2; position: relative; margin-bottom: 16px;
  font-family: -apple-system, 'Inter', sans-serif;
}
.hero-sub { font-size: 0.98rem; color: rgba(255,255,255,0.65); max-width: 520px; margin: 0 auto 28px; position: relative; font-family: -apple-system, sans-serif; }
.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 12px; border-radius: 20px;
  font-family: var(--mono);
}

/* ── CONTAINER ── */
.container { max-width: 860px; margin: 0 auto; padding: 36px 24px 80px; font-family: -apple-system, 'Inter', sans-serif; }

/* ── CARDS ── */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.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.93rem; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.list-desc { font-size: 0.8rem; color: var(--text-muted); }
.list-chevron { color: var(--border-dark); 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-muted); margin: 30px 0 10px 2px; font-family: -apple-system, sans-serif;
}

/* ── CHAPTER PAGE ── */
.chapter-hero {
  background: linear-gradient(135deg, var(--accent) 0%, #3A2F9E 100%);
  color: #fff; padding: 56px 24px 48px; text-align: center;
}
.chapter-hero .ch-num {
  font-size: 0.68rem; font-weight: 400; letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(255,255,255,0.65); margin-bottom: 10px; font-family: var(--mono);
}
.chapter-hero h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); font-weight: 700; margin-bottom: 12px; font-family: -apple-system, sans-serif; }
.chapter-hero p { color: rgba(255,255,255,0.78); font-size: 0.93rem; max-width: 520px; margin: 0 auto; font-family: -apple-system, sans-serif; }

/* ── CONTENT ── */
.content { max-width: 760px; margin: 0 auto; padding: 44px 24px 80px; font-family: -apple-system, 'Inter', sans-serif; }

h2 {
  font-size: 1.35rem; font-weight: 700; color: var(--text); margin: 44px 0 14px;
  padding-bottom: 10px; border-bottom: 2px solid var(--accent-light); letter-spacing: -0.01em;
}
h2:first-child { margin-top: 0; }
h2::before { content: '§ '; color: var(--accent); font-size: 0.9em; }
h3 { font-size: 1.05rem; font-weight: 700; color: var(--text); margin: 28px 0 10px; }
h4 { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin: 18px 0 8px; }

p { margin-bottom: 14px; color: var(--text-secondary); font-size: 0.93rem; line-height: 1.8; }

/* 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;
}
.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: var(--accent-light); color: #2E206A; border-left: 3px solid var(--accent); }
.callout.tip { background: var(--green-light); color: #1A5C3A; border-left: 3px solid var(--green); }
.callout.warning { background: var(--orange-light); color: #7D4A0A; border-left: 3px solid var(--orange); }
.callout.danger { background: var(--red-light); color: #7B1C1C; border-left: 3px solid var(--red); }

/* Code */
pre {
  background: var(--ink); color: #E8E8F0;
  border-radius: var(--radius); padding: 18px 20px; overflow-x: auto;
  font-size: 0.83rem; line-height: 1.7; margin: 14px 0; position: relative;
}
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.25);
}
code { font-family: var(--mono); }
p code, li code, td code {
  background: var(--accent-light); color: var(--accent); padding: 2px 6px; border-radius: 4px; font-size: 0.85em;
}
.kw { color: #BF80FF; }
.ty { color: #7FD8FC; }
.st { color: #A8E87F; }
.cm { color: #6878AA; }
.fn { color: #FFD080; }
.nu { color: #FF9080; }
.at { color: #80FFCF; }
.pr { color: #7FD8FC; }

/* Complexity badge */
.complexity {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink); color: #E8E8F0; padding: 6px 14px;
  border-radius: 6px; font-family: var(--mono); font-size: 0.82rem;
  margin: 4px 4px 4px 0;
}
.complexity .label { color: rgba(255,255,255,0.5); font-size: 0.7rem; }
.complexity .val { color: #FFD080; font-weight: 700; }
.complexity.good .val { color: #A8E87F; }
.complexity.bad .val { color: #FF9080; }

/* Visual box */
.visual-box {
  background: var(--paper-warm); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin: 16px 0; text-align: center; font-family: var(--mono); font-size: 0.85rem;
}
.visual-box .label { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.1em; }
.array-vis {
  display: inline-flex; gap: 0; border: 1px solid var(--border-dark); border-radius: 4px; overflow: hidden;
}
.array-cell {
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--border-dark); font-weight: 700; color: var(--accent);
  background: #fff; font-size: 0.95rem;
}
.array-cell:last-child { border-right: none; }
.array-cell.highlight { background: var(--accent-light); }
.array-cell.current { background: var(--accent); color: #fff; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 0.86rem; }
th { background: var(--accent-light); color: var(--accent); font-weight: 700; padding: 10px 14px; text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
td { padding: 10px 14px; border-top: 1px solid var(--border); color: var(--text-secondary); }

/* 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); font-family: var(--mono); font-size: 0.83rem; }
.def-desc { color: var(--text-secondary); }

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

/* Two col */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
@media (max-width: 600px) { .two-col { grid-template-columns: 1fr; } .def-list li { grid-template-columns: 1fr; } }

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

/* 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: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: inherit; transition: border-color 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.chapter-nav a:hover { border-color: var(--accent); }
.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.88rem; }
.prev { text-align: left; } .next { text-align: right; }

/* Overview grid */
.overview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 14px 0; }
.overview-card { background: var(--paper-warm); 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; }
.overview-card p { font-size: 0.78rem; margin: 0; color: var(--text-muted); line-height: 1.5; }

/* Site footer */
.site-footer { border-top: 1px solid var(--border); padding: 28px 24px; text-align: center; font-size: 0.78rem; color: var(--text-muted); font-family: -apple-system, sans-serif; }
.site-footer a { color: var(--accent); text-decoration: none; }
