/* ==========================================================
   Helios 技术教程 · 统一设计系统（课本 / 讲义质感）
   纸面 + 墨色 + 两色批注（Kotlin 朱砂红 · LVGL 矿物青）。
   两条技术线共用同一套组件，仅强调色 accent 随 body.track-* 切换。
   ========================================================== */

/* ===== 1. Design Tokens ===== */
:root {
  /* 纸面与墨色 */
  --paper: #faf8f4;
  --paper-deep: #f1ede4;
  --paper-soft: #f6f3ec;
  --hairline: #e2dccf;
  --hairline-soft: #ece7db;
  --ink: #26292f;
  --ink-secondary: #5b6069;
  --muted: #8b8f97;

  /* 代码（Catppuccin 深色，纸上留白对比） */
  --code-bg: #1e1e2e;
  --code-ink: #cdd6f4;
  --code-border: #313244;

  /* 强调色（默认 Kotlin 朱砂红） */
  --accent: #b3402f;
  --accent-strong: #8f2f22;
  --accent-soft: #f4e5e0;
  --on-accent: #ffffff;

  /* 语义色 */
  --tip-bg: var(--paper-deep);
  --tip-border: var(--accent);
  --warn-bg: #faf3df;
  --warn-border: #b98313;
  --success: #44745a;
  --success-soft: #e4ede7;

  /* 字体 */
  --font-serif: "Source Han Serif SC", "Noto Serif CJK SC", "Noto Serif SC", "Songti SC", "STSong", "SimSun", "Georgia", "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  /* 圆角（印刷感：克制） */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-full: 999px;

  /* 阴影（带暖色） */
  --shadow-sm: 0 1px 2px rgba(70, 60, 40, 0.05);
  --shadow-md: 0 4px 18px rgba(70, 60, 40, 0.10);
}

body.track-lvgl {
  --accent: #35536b;
  --accent-strong: #2a4154;
  --accent-soft: #e3eaef;
  --tip-bg: var(--paper-deep);
}

body.track-epub {
  --accent: #9a6a1f;
  --accent-strong: #7a5216;
  --accent-soft: #f3ead9;
  --tip-bg: var(--paper-deep);
}

body.track-sifli {
  --accent: #6a4f7a;
  --accent-strong: #523a5e;
  --accent-soft: #ece4f0;
  --tip-bg: var(--paper-deep);
}

body.track-cpp {
  --accent: #4a6b5d;
  --accent-strong: #385144;
  --accent-soft: #e6ece8;
  --tip-bg: var(--paper-deep);
}

body.track-graphics {
  --accent: #8a6d3b;
  --accent-strong: #6d5430;
  --accent-soft: #f0e9dc;
  --tip-bg: var(--paper-deep);
}

/* ===== 2. Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.85;
  color: var(--ink);
  background: var(--paper);
}
a { color: var(--accent-strong); }
a:hover { text-decoration: underline; }

/* ===== 3. 顶部导航 ===== */
.top-nav {
  background: rgba(250, 248, 244, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.top-nav .nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.top-nav a {
  color: var(--ink-secondary);
  padding: 14px 14px;
  font-size: 14px;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.top-nav a:hover { color: var(--ink); text-decoration: none; }
.top-nav a.active {
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}
.top-nav .brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  padding: 13px 18px 13px 14px;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.top-nav .brand::before {
  content: "印";
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: var(--accent);
  padding: 3px 4px;
  border-radius: 2px;
  letter-spacing: 0;
}
/* ===== 4. 布局 ===== */
.container { max-width: 860px; margin: 0 auto; padding: 56px 24px 96px; }

/* ===== 5. 排版 ===== */
h1 {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
  letter-spacing: 0.01em;
}
.chapter-subtitle {
  color: var(--muted);
  font-size: 1rem;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--hairline);
}
h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 52px;
  margin-bottom: 16px;
  padding-left: 12px;
  border-left: 2px solid var(--accent);
}
h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: 32px;
  margin-bottom: 12px;
}
p { margin-bottom: 16px; }
ul, ol { margin-bottom: 16px; padding-left: 28px; }
li { margin-bottom: 6px; }
strong { color: var(--ink); }
small { color: var(--muted); }

/* ===== 6. 代码 ===== */
code { font-family: var(--font-mono); font-size: 0.9em; }
p code, li code, td code, h3 code {
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
}
pre {
  position: relative;
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 20px 24px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: 24px;
  line-height: 1.6;
  font-size: 0.9rem;
  border: 1px solid var(--code-border);
}
pre code { background: none; color: inherit; padding: 0; font-size: inherit; }

/* Catppuccin 语法高亮 */
.kw { color: #cba6f7; }
.type { color: #f9e2af; }
.str { color: #a6e3a1; }
.num { color: #fab387; }
.cmt { color: #6c7086; font-style: italic; }
.fn { color: #89b4fa; }
.ann { color: #f38ba8; }
.op { color: #89dceb; }
.param { color: #eba0ac; }

/* 复制按钮 */
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #45475a;
  color: #cdd6f4;
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  font-family: inherit;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: #585b70; }
.copy-btn.copied { background: #a6e3a1; color: #1e1e2e; }

/* ===== 7. 导师卡片（书页边注风） ===== */
.mentor-card {
  background: var(--paper-deep);
  border-left: 3px solid var(--accent);
  padding: 22px 26px;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  margin-bottom: 40px;
}
.mentor-card .mentor-header { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.mentor-card .mentor-icon { font-size: 2.2rem; line-height: 1; }
.mentor-card .mentor-info h3 {
  font-family: var(--font-serif);
  color: var(--accent-strong);
  font-size: 1.1rem;
  margin: 0 0 2px 0;
}
.mentor-card .mentor-info .mentor-method { color: var(--muted); font-size: 0.85rem; margin: 0; }
.mentor-quote {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-secondary);
  line-height: 1.9;
  margin: 12px 0 0;
  padding-left: 16px;
  border-left: 1px solid var(--hairline);
}
.mentor-quote p { margin-bottom: 8px; }

/* ===== 8. 提示与警告 ===== */
.tip {
  background: var(--tip-bg);
  border-left: 3px solid var(--tip-border);
  padding: 16px 20px;
  margin: 24px 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.tip-title { font-weight: 700; color: var(--accent-strong); margin-bottom: 4px; }
.warning {
  background: var(--warn-bg);
  border-left: 3px solid var(--warn-border);
  padding: 16px 20px;
  margin: 24px 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.warning .tip-title { color: #8a5b0a; }

/* C++ 对比提示（Kotlin 章节内容依赖此组件） */
.cpp-note {
  background: var(--success-soft);
  border-left: 3px solid var(--success);
  padding: 16px 20px;
  margin: 24px 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.cpp-note .tip-title { color: var(--success); }

/* ===== 9. 对比表格 ===== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 0.95rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
}
th { background: var(--ink); color: #f5f3ee; padding: 10px 16px; text-align: left; font-weight: 600; }
td { padding: 10px 16px; border-bottom: 1px solid var(--hairline-soft); }
tr:nth-child(even) td { background: var(--paper-soft); }
tr:last-child td { border-bottom: none; }

/* ===== 10. 练习 ===== */
.exercise {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin: 48px 0 24px;
}
.exercise > h2 { color: var(--accent-strong); border-left: none; padding-left: 0; margin-top: 0; font-size: 1.4rem; }
.exercise-item { margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); }
.exercise-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.exercise-item h3 { margin-top: 0; }
.exercise-item .difficulty {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  margin-left: 8px;
  vertical-align: middle;
}
.difficulty-easy { background: var(--success-soft); color: var(--success); }
.difficulty-medium { background: #f5ead0; color: #7a5c10; }
.difficulty-hard { background: #f6e0e2; color: #933a44; }
details { margin: 8px 0; }
details summary { cursor: pointer; color: var(--accent-strong); font-weight: 600; font-size: 0.9rem; padding: 6px 0; user-select: none; }
details summary:hover { color: var(--accent); }
details[open] summary { margin-bottom: 8px; }
details .answer-content {
  background: var(--paper);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
}

/* ===== 11. 底部导航 ===== */
.bottom-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--hairline);
}
.bottom-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-strong);
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  transition: background 0.15s;
}
.bottom-nav a:hover { background: var(--accent-soft); text-decoration: none; }
.bottom-nav .placeholder { width: 120px; }

/* ===== 12. 门户页（两卷书） ===== */
.hero { text-align: center; padding: 80px 0 40px; }
.hero-eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.hero h1 { font-size: 3rem; margin-bottom: 14px; }
.hero .tagline { font-size: 1.1rem; color: var(--muted); margin-bottom: 52px; font-family: var(--font-serif); }
.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  max-width: 760px;
  margin: 0 auto;
}
.track-card {
  display: block;
  position: relative;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 30px 28px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  color: var(--ink);
}
.track-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); text-decoration: none; }
.track-card .track-vol {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: transparent;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.track-card .track-icon { font-size: 2rem; display: block; margin-bottom: 10px; }
.track-card h2 { font-size: 1.4rem; margin: 0 0 8px; border: none; padding: 0; color: var(--ink); }
.track-card p { color: var(--muted); font-size: 0.95rem; margin-bottom: 16px; }
.track-card .track-meta { font-size: 0.85rem; color: var(--muted); }
.track-card .track-cta { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-strong); font-weight: 600; margin-top: 14px; }
.track-card.kotlin { --accent: #b3402f; }
.track-card.lvgl { --accent: #35536b; }
.track-card.epub { --accent: #9a6a1f; }
.track-card.sifli { --accent: #6a4f7a; }
.track-card.cpp { --accent: #4a6b5d; }
.track-card.graphics { --accent: #8a6d3b; }

/* ===== 13. 目录页 TOC ===== */
.track-hero { text-align: center; padding: 64px 0 8px; }
.track-eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.track-hero h1 { margin-bottom: 8px; }
.track-hero .tagline { color: var(--muted); margin-bottom: 8px; font-family: var(--font-serif); }
.toc { max-width: 680px; margin: 28px auto 0; }
.toc-part { margin-bottom: 36px; }
.toc-part h2 {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-strong);
  border-left: none;
  padding-left: 0;
  margin-top: 0;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border-bottom: 1px solid var(--hairline-soft);
  padding-bottom: 8px;
}
.toc-list { list-style: none; padding: 0; }
.toc-list li { margin-bottom: 0; }
.toc-list a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 14px;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background 0.15s, padding-left 0.15s;
}
.toc-list a:hover { background: var(--paper-deep); padding-left: 20px; text-decoration: none; }
.toc-list .chapter-num {
  font-family: var(--font-serif);
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}
.toc-list small { color: var(--muted); font-size: 0.8rem; margin-left: auto; white-space: nowrap; }
.toc-footer { text-align: center; margin-top: 44px; }
.start-btn {
  display: inline-block;
  margin-top: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  padding: 10px 26px;
  border-radius: var(--radius-md);
  transition: background 0.15s;
}
.start-btn:hover { background: var(--accent-strong); text-decoration: none; }

/* ===== 14. 响应式 ===== */
@media (max-width: 768px) {
  .container { padding: 32px 16px 64px; }
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.3rem; }
  pre { padding: 14px 16px; font-size: 0.82rem; }
  .top-nav a { padding: 12px 10px; font-size: 13px; }
  .hero h1 { font-size: 2.2rem; }
  table { font-size: 0.85rem; }
  th, td { padding: 8px 10px; }
}
@media (max-width: 480px) {
  .top-nav .nav-inner { justify-content: center; }
  .bottom-nav { flex-direction: column; gap: 12px; }
  .bottom-nav .placeholder { display: none; }
  .track-grid { grid-template-columns: 1fr; }
}

/* ===== 15. 动效与无障碍 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
