/* ============================================================
   视频流水线 · 交互图解 — 设计系统 v2（终端美学重构版）
   Direction: Developer CLI Workbench / Theme: dark
   Tokens from DESIGN.md；命令与输出是一等内容，不是装饰
   ============================================================ */

:root {
  --canvas: #070A0D;
  --surface: #0D1318;
  --surface-alt: #141D22;
  --text: #F4F7F5;
  --muted: #8FA39A;
  --accent: #4ADE80;
  --accent-strong: #22C55E;
  --accent-soft: rgba(74, 222, 128, 0.10);
  --border: #26352E;

  --good: #4ADE80;
  --good-soft: rgba(74, 222, 128, 0.10);
  --warn: #F0B429;
  --warn-soft: rgba(240, 180, 41, 0.10);
  --bad: #F87171;
  --bad-soft: rgba(248, 113, 113, 0.10);

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 14px 44px rgba(0, 0, 0, 0.5);

  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "JetBrains Mono", Menlo, monospace;

  --content-w: 780px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(74, 222, 128, 0.25); }

h1, h2, h3, h4 {
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -0.01em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: none; }

code, kbd {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.4em;
  color: var(--accent);
}

/* ---------------- 终端标题栏（全站顶部） ---------------- */

.term-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 19, 24, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.term-bar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.term-dots { display: inline-flex; gap: 6px; }
.term-dots i {
  width: 11px; height: 11px;
  border-radius: 50%;
  display: inline-block;
}
.term-dots i:nth-child(1) { background: #F87171; }
.term-dots i:nth-child(2) { background: #F0B429; }
.term-dots i:nth-child(3) { background: #4ADE80; }

.term-path { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.term-path a { color: var(--accent); }
.term-path b { color: var(--text); font-weight: 600; }

.term-bar-links {
  margin-left: auto;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.term-bar-links::-webkit-scrollbar { display: none; }
.term-bar-links a {
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
.term-bar-links a:hover { background: var(--surface-alt); color: var(--accent); }
.term-bar-links a.active { color: var(--accent); background: var(--accent-soft); }

/* 阅读进度条 */
.read-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
  z-index: 60;
  transition: width 0.1s linear;
}

/* ---------------- 章节页 shell：左侧目录树 + 右内容 ---------------- */

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 36px;
}

@media (min-width: 960px) {
  .shell { grid-template-columns: 250px minmax(0, 1fr); }
}

.side { display: none; }
@media (min-width: 960px) {
  .side {
    display: block;
    position: sticky;
    top: 76px;
    align-self: start;
    font-family: var(--font-mono);
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    padding: 16px 16px 14px;
  }
}

.side .side-cmd {
  color: var(--muted);
  margin-bottom: 10px;
  user-select: none;
}
.side .side-cmd::before { content: "$ "; color: var(--accent); }

.side a {
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: var(--muted);
  padding: 5px 8px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
}
.side a:hover { background: var(--surface-alt); color: var(--text); }
.side a.active { color: var(--accent); background: var(--accent-soft); }
.side a.active::before { content: "▸ "; }
.side a .side-num { color: var(--border); flex: none; }
.side a.active .side-num { color: var(--accent); }

.side .side-progress {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
}
.side .side-progress .bar {
  display: block;
  margin-top: 6px;
  letter-spacing: 1px;
  color: var(--accent);
}

/* ---------------- 页面容器 ---------------- */

.page {
  max-width: var(--content-w);
  padding: 44px 0 80px;
  min-width: 0;
}

.page-wide {
  max-width: 1240px;
  margin: 0 auto;
  padding: 36px 20px 80px;
}

/* ---------------- 章节正文排版 ---------------- */

.chapter-head { margin-bottom: 34px; }

.chapter-kicker {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.chapter-kicker::before { content: "// "; color: var(--muted); }

.chapter-head h1 {
  font-size: clamp(28px, 4.5vw, 38px);
  margin: 0 0 14px;
}

.chapter-head .lede {
  font-size: 17px;
  color: var(--muted);
  margin: 0;
}

.page h2 {
  font-size: 24px;
  margin: 58px 0 16px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}
.page h2::before {
  content: "## ";
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 400;
}
.page h3 {
  font-size: 19px;
  margin: 36px 0 12px;
}
.page h3::before {
  content: "### ";
  font-family: var(--font-mono);
  color: var(--muted);
  font-weight: 400;
  font-size: 0.8em;
}
.page p { margin: 14px 0; }
.page ul, .page ol { padding-left: 24px; }
.page li { margin: 7px 0; }
.page li::marker { color: var(--accent); font-family: var(--font-mono); }
.page strong { color: var(--accent); font-weight: 700; }

.math-inline {
  font-family: var(--font-mono);
  white-space: nowrap;
}

.formula {
  display: block;
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.7;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 22px 0;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.formula::before {
  content: "$ ";
  color: var(--muted);
}
.formula sub, .formula sup { font-size: 0.7em; }

/* ---------------- 提示框（callout）：终端输出风格 ---------------- */

.callout {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left-width: 3px;
  padding: 14px 18px;
  margin: 24px 0;
  font-size: 15px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.callout .callout-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
}
.callout p:last-child { margin-bottom: 0; }
.callout p:first-of-type { margin-top: 0; }

.callout-intuition { border-left-color: var(--accent); background: var(--accent-soft); }
.callout-intuition .callout-title { color: var(--accent); }

.callout-pitfall { border-left-color: var(--warn); background: var(--warn-soft); }
.callout-pitfall .callout-title { color: var(--warn); }

.callout-math { border-left-color: var(--muted); background: var(--surface-alt); }
.callout-math .callout-title { color: var(--text); }

.callout-good { border-left-color: var(--good); background: var(--good-soft); }
.callout-good .callout-title { color: var(--good); }

/* ---------------- 交互演示：终端面板 ---------------- */

.demo {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin: 30px 0;
  overflow: hidden;
}

.demo-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
.demo-head::before {
  content: "";
  width: 44px;
  height: 11px;
  flex: none;
  background:
    radial-gradient(circle at 6px 5.5px, #F87171 4.5px, transparent 5px),
    radial-gradient(circle at 22px 5.5px, #F0B429 4.5px, transparent 5px),
    radial-gradient(circle at 38px 5.5px, #4ADE80 4.5px, transparent 5px);
}
.demo-head h4 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.demo-head .demo-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.demo-body {
  padding: 18px 18px 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

@media (min-width: 780px) {
  .demo-body.has-side {
    grid-template-columns: minmax(0, 1fr) 250px;
  }
}

.demo canvas, .demo svg.demo-figure {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  background: var(--canvas);
  border: 1px solid var(--border);
  touch-action: manipulation;
}

.demo-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.demo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.demo-row.wrap-gap { row-gap: 8px; }

.demo-note {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  margin: 12px 2px 0;
}
.demo-note::before { content: "# "; color: var(--accent); }

/* ---------------- 控件 ---------------- */

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #070A0D;
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #070A0D; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-group { display: inline-flex; border-radius: 7px; overflow: hidden; border: 1px solid var(--border); }
.btn-group .btn { border: 0; border-radius: 0; }
.btn-group .btn + .btn { border-left: 1px solid var(--border); }
.btn-group .btn.on { background: var(--accent); color: #070A0D; }
.btn-group .btn.on:hover { color: #070A0D; }

.ctl { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.ctl label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
}
.ctl label output {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 12.5px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 4px;
  background: var(--accent);
  border: none;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
  margin-top: -7px;
}
input[type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 4px;
  background: var(--accent);
  border: none;
}

select, input[type="number"], input[type="text"] {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
}
select:focus, input[type="number"]:focus, input[type="text"]:focus {
  outline: 2px solid rgba(74, 222, 128, 0.35);
  border-color: var(--accent);
}

/* 数值读出徽章：终端输出风格 */
.readout {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  min-width: 86px;
}
.readout b {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
  font-weight: 700;
}
.readout.readout-accent b { color: var(--accent); }
.readout.readout-good b { color: var(--good); }
.readout.readout-bad b { color: var(--bad); }

/* ---------------- 静态配图 ---------------- */

.figure {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 26px 0;
  box-shadow: var(--shadow-sm);
}
.figure svg { display: block; width: 100%; height: auto; }
.figure figcaption {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  margin-top: 12px;
}

/* ---------------- 章节结尾导航 ---------------- */

.chapter-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 64px;
}
.chapter-nav a {
  display: block;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--text);
  font-family: var(--font-mono);
  transition: all 0.15s ease;
}
.chapter-nav a:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.chapter-nav .cn-label { font-size: 11.5px; color: var(--muted); display: block; }
.chapter-nav .cn-label::before { content: "$ cd "; color: var(--accent); }
.chapter-nav .cn-title { font-weight: 700; font-size: 13.5px; }
.chapter-nav a.next { text-align: right; }
.chapter-nav a.disabled { opacity: 0.45; pointer-events: none; }

.mark-done {
  margin-top: 44px;
  display: flex;
  justify-content: center;
}

/* ---------------- 首页：终端 hero + 目录式章节列表 ---------------- */

.hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-top: 24px;
  box-shadow: var(--shadow-lg);
}

.hero-titlebar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}
.hero-titlebar::before {
  content: "";
  width: 44px;
  height: 11px;
  flex: none;
  background:
    radial-gradient(circle at 6px 5.5px, #F87171 4.5px, transparent 5px),
    radial-gradient(circle at 22px 5.5px, #F0B429 4.5px, transparent 5px),
    radial-gradient(circle at 38px 5.5px, #4ADE80 4.5px, transparent 5px);
}

.hero-body {
  position: relative;
  padding: clamp(28px, 5vw, 52px) clamp(20px, 4vw, 44px);
}
.hero-body canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.3;
}
.hero-inner { position: relative; max-width: 720px; }

.hero .hero-kicker {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent);
  border: 1px solid var(--border);
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.hero h1 {
  font-size: clamp(30px, 5vw, 46px);
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}
.hero h1 .mono { font-family: var(--font-mono); color: var(--accent); }
.hero p {
  font-size: clamp(15px, 1.8vw, 17px);
  color: var(--muted);
  margin: 0 0 26px;
  max-width: 600px;
}
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .btn { font-size: 13.5px; padding: 10px 20px; }

.section-head { margin: 64px 0 22px; }
.section-head h2 { font-size: 26px; margin: 0 0 8px; }
.section-head h2::before {
  content: "$ ";
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 400;
}
.section-head p { color: var(--muted); margin: 0; font-family: var(--font-mono); font-size: 13px; }

/* 目录式章节列表（代替卡片网格） */
.chapter-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.chapter-list .list-cmd {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.chapter-list .list-cmd::before { content: "$ "; color: var(--accent); }

.chapter-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: baseline;
  padding: 16px 18px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}
.chapter-card:last-child { border-bottom: none; }
.chapter-card:hover { background: var(--surface-alt); }
.chapter-card .cc-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}
.chapter-card h3 {
  font-size: 16.5px;
  margin: 0 0 4px;
}
.chapter-card p {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}
.chapter-card .cc-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chapter-card .cc-badge {
  font-weight: 700;
  color: var(--good);
  display: none;
}
.chapter-card.done .cc-badge { display: inline-block; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.feature-card .fc-icon {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  display: block;
}
.feature-card .fc-icon::before { content: "> "; color: var(--muted); }
.feature-card h3 { font-size: 16px; margin: 0 0 8px; }
.feature-card p { font-size: 13.5px; color: var(--muted); margin: 0; line-height: 1.7; }

.about-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  font-size: 15px;
}
.about-block p { margin: 10px 0; }
.about-block .muted { color: var(--muted); font-size: 13.5px; }

/* ---------------- 页脚 ---------------- */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 80px;
  background: var(--surface);
}
.site-footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}
.site-footer-inner span::before { content: "# "; color: var(--accent); }

/* ---------------- 小屏适配 ---------------- */

@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .term-bar-links { display: none; }
  .chapter-nav { grid-template-columns: 1fr; }
  .chapter-nav a.next { text-align: left; }
  .chapter-card { grid-template-columns: 40px minmax(0, 1fr); }
  .chapter-card .cc-meta { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
