/* ===== 阿巴阿巴 · 阅读教程文档 ===== */

/* ---------- 主题变量 ---------- */
:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --bg-grad: linear-gradient(180deg, #f5f7fa 0%, #eef2f7 100%);
  --surface: #ffffff;
  --surface-2: #f0f4f8;
  --text: #1a1f2e;
  --text-2: #3d4a5c;
  --muted: #6b7785;
  --line: #e2e8ef;
  --accent: #2563eb;
  --accent-2: #1e40af;
  --accent-soft: #dbeafe;
  --accent-glow: rgba(37, 99, 235, 0.12);
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --warn-line: #fcd34d;
  --ok: #059669;
  --ok-soft: #d1fae5;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --sidebar-w: 264px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1219;
  --bg-grad: linear-gradient(180deg, #0f1219 0%, #141821 100%);
  --surface: #181c26;
  --surface-2: #1e2330;
  --text: #e8ecf2;
  --text-2: #c0c9d6;
  --muted: #8b95a5;
  --line: #2a3140;
  --accent: #60a5fa;
  --accent-2: #3b82f6;
  --accent-soft: #1a2536;
  --accent-glow: rgba(96, 165, 250, 0.15);
  --warn: #fbbf24;
  --warn-soft: #2a2010;
  --warn-line: #92400e;
  --ok: #34d399;
  --ok-soft: #0c2a20;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.4);
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg-grad);
  color: var(--text);
  font-family: "HarmonyOS Sans SC", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.8;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .35s ease, color .35s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color .2s ease, background-color .2s ease;
}
a:hover { color: var(--accent-2); }

button { font: inherit; color: inherit; }

::selection { background: var(--accent-glow); }

/* ---------- 阅读进度条 ---------- */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 100;
  transition: width .1s linear;
  border-radius: 0 3px 3px 0;
}

/* ---------- 顶部移动端栏 ---------- */
.mobilebar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.mobilebar .brand { font-size: 18px; font-weight: 700; }

/* ---------- 布局骨架 ---------- */
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px 20px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 40;
  overflow-y: auto;
}

.sidebar .brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
  padding: 0 4px;
}
.sidebar .brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

/* ---------- 目录导航 ---------- */
.toc {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toc-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 10px 8px;
}
.toc a {
  position: relative;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.45;
  transition: all .2s ease;
}
.toc a::before {
  content: "";
  width: 3px;
  height: 0;
  background: var(--accent);
  border-radius: 2px;
  margin-right: 0;
  transition: height .2s ease, margin-right .2s ease;
  flex-shrink: 0;
}
.toc a:hover {
  color: var(--accent);
  background: var(--accent-soft);
}
.toc a:hover::before { height: 16px; margin-right: 8px; }
.toc a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.toc a[aria-current="page"]::before { height: 16px; margin-right: 8px; }

/* ---------- 主题切换按钮 ---------- */
.theme-toggle {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: all .2s ease;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.theme-toggle:active { transform: translateY(0); }
.theme-toggle svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- 菜单按钮(移动端) ---------- */
.menu-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: all .2s ease;
}
.menu-toggle:hover { border-color: var(--accent); color: var(--accent); }
.menu-toggle svg { width: 18px; height: 18px; }

/* ---------- 遮罩层(移动端) ---------- */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 35;
  opacity: 0;
  transition: opacity .25s ease;
}
.overlay.show { display: block; opacity: 1; }

/* ---------- 主内容区 ---------- */
main {
  padding: 48px clamp(24px, 5vw, 80px) 64px;
  min-width: 0;
}

.document {
  max-width: 780px;
  margin: 0 auto;
  animation: pageEnter .45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 章节标题区 ---------- */
.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 3.5vw, 34px);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.divider {
  width: 40px;
  height: 3px;
  margin: 20px 0 28px;
  background: var(--accent);
  border-radius: 2px;
}

.intro {
  margin: 0 0 32px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

/* ---------- 内容区段 ---------- */
.section {
  padding: 24px 0;
  border-top: 1px solid var(--line);
}
.section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

h2 {
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

p {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.85;
  color: var(--text-2);
}

/* ---------- 步骤列表 ---------- */
.step-list { counter-reset: step; }
.step {
  position: relative;
  padding: 24px 0 24px 52px;
  border-top: 1px solid var(--line);
  counter-increment: step;
}
.step:first-of-type { border-top: 0; padding-top: 0; }
.step::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 24px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--accent-glow);
  transition: transform .25s ease, box-shadow .25s ease;
}
.step:first-of-type::before { top: 0; }
.step:hover::before {
  transform: scale(1.1);
  box-shadow: 0 0 0 6px var(--accent-glow);
}
.step h2 { margin-bottom: 10px; }

/* ---------- 提示框 ---------- */
.notice {
  padding: 16px 18px;
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: 28px;
}

/* ---------- 套餐信息 ---------- */
.plan {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
  border: 1px solid var(--line);
}

/* ---------- 资源列表 ---------- */
.resource-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}
.resource-list li {
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.resource-list li:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* ---------- 推荐卡片 ---------- */
.recommend-card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
}
.recommend-card + .recommend-card { margin-top: 16px; }
.recommend-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: var(--accent);
}

/* ---------- 链接卡片 ---------- */
.link-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: all .25s ease;
}
.link-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.link-card .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 1px;
}
.link-card .content { flex: 1; min-width: 0; }
.link-card .url {
  font-size: 13px;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.5;
}
.link-card .desc { font-size: 14px; color: var(--text-2); margin-top: 4px; }

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}
.empty-state .icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--muted);
  opacity: 0.5;
}
.empty-state p { color: var(--muted); }

/* ---------- 翻页导航 ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.pager a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  background: var(--surface);
  transition: all .25s ease;
}
.pager a:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.pager .next { margin-left: auto; }
.pager span { flex: 1; }

/* ---------- 二维码 ---------- */
.qr-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 18px;
}
.qr-codes figure {
  width: min(200px, 100%);
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform .25s ease, box-shadow .25s ease;
}
.qr-codes figure:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.qr-codes img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.qr-codes figcaption {
  padding: 10px 4px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

/* ---------- 首页特有 ---------- */
.hero-card {
  padding: 40px 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
}
.hero-card h1 { font-size: clamp(28px, 5vw, 40px); }
.hero-card .divider { margin: 20px auto 24px; }
.hero-card .intro { margin-bottom: 28px; }

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 28px;
}
.chapter-grid a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .25s ease;
}
.chapter-grid a:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.chapter-grid .num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- 逐句动画 ---------- */
.animate-in {
  opacity: 0;
  transform: translateY(8px);
  animation: fadeUp .5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 响应式: 平板 ---------- */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  main { padding: 40px clamp(20px, 4vw, 60px) 56px; }
}

/* ---------- 响应式: 手机 ---------- */
@media (max-width: 780px) {
  .shell { display: block; }
  .progress-bar { left: 0; }

  .mobilebar { display: flex; }

  .overlay { display: none; }
  .overlay.show { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    padding: 20px 16px;
    border-right: 1px solid var(--line);
    border-bottom: none;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 45;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .brand { display: block; font-size: 20px; }

  .theme-toggle { margin-top: 16px; }

  main { padding: 32px 18px 40px; }
  .document { max-width: 100%; }

  .step { padding-left: 44px; }
  .step::before { width: 28px; height: 28px; font-size: 13px; }

  .chapter-grid { grid-template-columns: 1fr; }

  .hero-card { padding: 28px 20px; }

  .qr-codes figure { width: min(160px, 100%); }

  .pager a { padding: 8px 12px; font-size: 13px; }
}

/* ---------- 无障碍: 减少动画 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
