/* ============================================================
   DeepInfer 交互式图解站 · 设计系统（dark blueprint / spec-sheet）
   全部颜色经 :root 变量引用，见 DESIGN.md
   ============================================================ */

:root {
  --bg: #0b0e13;
  --bg-grid: #131822;
  --surface: #12161f;
  --surface-2: #181e2a;
  --border: #242c3b;
  --border-strong: #36415a;
  --text: #e4e8f0;
  --muted: #8d97a9;
  --faint: #5b6577;
  --accent: #5eead4;
  --accent-dim: #1f4f49;
  --blue: #7cc4ff;
  --amber: #f5b942;
  --red: #ff7a7a;
  --green: #7ee787;
  --purple: #c9a8ff;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶部站点栏 + 进度条 ---------- */

.sitebar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 14, 19, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.sitebar-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  height: 48px;
}

.sitebar-brand {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: 0.5px;
}
.sitebar-brand:hover { text-decoration: none; color: var(--accent); }

.sitebar-nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.sitebar-nav::-webkit-scrollbar { display: none; }

.sitebar-nav a {
  font-size: 13px;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
.sitebar-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.sitebar-nav a.active { color: var(--accent); background: var(--accent-dim); }

.progress-track {
  height: 2px;
  background: var(--border);
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.1s linear;
}

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

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 20px 96px;
}

.page-wide { max-width: 960px; }

/* ---------- 首页 hero ---------- */

.hero {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 48px 40px;
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 200px at 20% 0%, rgba(94, 234, 212, 0.07), transparent 70%);
  pointer-events: none;
}

.hero-kicker {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 2px;
  margin-bottom: 12px;
}

.hero h1 {
  font-size: 40px;
  line-height: 1.25;
  margin: 0 0 16px;
}

.hero-sub {
  color: var(--muted);
  font-size: 17px;
  max-width: 640px;
  margin: 0 0 28px;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.stat-chip {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 13px;
}
.stat-chip b { color: var(--accent); font-size: 16px; display: block; }
.stat-chip span { color: var(--muted); }

/* ---------- 章节卡片网格 ---------- */

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 24px 0 48px;
}

.chapter-card {
  display: block;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
}
.chapter-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
}

.chapter-card .num {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  letter-spacing: 1px;
}
.chapter-card h3 { margin: 6px 0 8px; font-size: 17px; color: var(--text); }
.chapter-card p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.6; }

.chapter-card .done-flag {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--green);
  border: 1px solid var(--green);
  border-radius: 999px;
  padding: 1px 8px;
  display: none;
}
.chapter-card.done .done-flag { display: inline-block; }

/* ---------- 章页 ---------- */

.chapter-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
  margin-bottom: 32px;
}

.chapter-head .num {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 14px;
  letter-spacing: 2px;
}

.chapter-head h1 {
  font-size: 32px;
  margin: 8px 0 10px;
  line-height: 1.3;
}

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

h2 {
  font-size: 22px;
  margin: 48px 0 16px;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
  line-height: 1.4;
}

h3 { font-size: 17px; margin: 28px 0 10px; }

p { margin: 14px 0; }

ul, ol { padding-left: 24px; }
li { margin: 6px 0; }

strong { color: var(--text); }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--accent);
}

/* ---------- 事实分档徽章 ---------- */

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  border-radius: 4px;
  padding: 0 6px;
  margin: 0 2px;
  vertical-align: 1px;
  white-space: nowrap;
}
.tag-official { color: var(--amber); border: 1px solid var(--amber); }
.tag-third { color: var(--purple); border: 1px solid var(--purple); }
.tag-unverified { color: var(--muted); border: 1px dashed var(--faint); }
.tag-verified { color: var(--green); border: 1px solid var(--green); }

/* ---------- callout 四分法 ---------- */

.callout {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 10px;
  background: var(--surface);
  padding: 14px 18px;
  margin: 20px 0;
  font-size: 15px;
}
.callout .c-title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  margin-bottom: 6px;
  display: block;
}
.callout p { margin: 6px 0; }
.c-intuition { border-left-color: var(--accent); }
.c-intuition .c-title { color: var(--accent); }
.c-pitfall { border-left-color: var(--amber); }
.c-pitfall .c-title { color: var(--amber); }
.c-deep { border-left-color: var(--blue); }
.c-deep .c-title { color: var(--blue); }
.c-summary { border-left-color: var(--green); background: rgba(126, 231, 135, 0.04); }
.c-summary .c-title { color: var(--green); }

/* ---------- 公式块 ---------- */

.formula {
  font-family: Georgia, var(--mono), serif;
  font-style: italic;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 20px;
  margin: 18px 0;
  font-size: 17px;
  color: var(--text);
  overflow-x: auto;
}

/* ---------- 规格表 ---------- */

.spec-table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.spec-table th, .spec-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.spec-table th {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
  background: var(--surface-2);
}
.spec-table tr:nth-child(even) td { background: rgba(24, 30, 42, 0.5); }
.spec-table tr:last-child td { border-bottom: none; }
.spec-table td:first-child { font-family: var(--mono); white-space: nowrap; }

/* ---------- 演示卡片 ---------- */

.demo {
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  margin: 28px 0;
  overflow: hidden;
}

.demo-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 16px 20px 0;
}
.demo-head .demo-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 1px;
}
.demo-head h3 {
  margin: 0;
  font-size: 16px;
}

.demo-stage {
  margin: 14px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 16px;
  overflow: hidden;
}

.demo-stage canvas {
  display: block;
  width: 100%;
  height: auto;
}

.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: center;
  padding: 4px 20px 12px;
}

.ctl {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--muted);
}
.ctl label { white-space: nowrap; }
.ctl output {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  min-width: 52px;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 160px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.btn-group {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}
.btn-group button {
  background: var(--surface-2);
  color: var(--muted);
  border: none;
  border-right: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
}
.btn-group button:last-child { border-right: none; }
.btn-group button:hover { color: var(--text); }
.btn-group button.on {
  background: var(--accent-dim);
  color: var(--accent);
}

.preset {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: var(--sans);
}
.preset:hover { color: var(--accent); border-color: var(--accent); }

.btn-play {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--sans);
}
.btn-play:hover { background: var(--accent); color: var(--bg); }
.btn-play.playing { background: transparent; color: var(--amber); border-color: var(--amber); }

.demo-readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 20px 14px;
}

.readout {
  font-family: var(--mono);
  font-size: 13px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 5px 12px;
  color: var(--text);
}
.readout .r-label { color: var(--faint); margin-right: 6px; font-size: 12px; }
.readout.r-good { border-color: var(--green); color: var(--green); }
.readout.r-good .r-label { color: var(--green); opacity: 0.7; }
.readout.r-warn { border-color: var(--amber); color: var(--amber); }
.readout.r-warn .r-label { color: var(--amber); opacity: 0.7; }
.readout.r-bad { border-color: var(--red); color: var(--red); }
.readout.r-bad .r-label { color: var(--red); opacity: 0.7; }

.demo-note {
  border-top: 1px dashed var(--border);
  padding: 10px 20px 14px;
  font-size: 13.5px;
  color: var(--muted);
}
.demo-note::before { content: "▸ "; color: var(--accent); }

/* ---------- 演示内通用图形元素 ---------- */

.part-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.part {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s;
  user-select: none;
}
.part:hover { border-color: var(--blue); }
.part.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.part .p-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.part .p-status { font-family: var(--mono); font-size: 11px; }
.part.open .p-status { color: var(--green); }
.part.closed .p-status { color: var(--red); }
.part.open { border-left: 3px solid var(--green); }
.part.closed { border-left: 3px solid var(--red); }

.part-detail {
  margin-top: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--muted);
  min-height: 60px;
}
.part-detail b { color: var(--text); }

.bar-compare {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bar-row {
  display: grid;
  grid-template-columns: 180px 1fr 90px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.bar-row .b-label { color: var(--muted); }
.bar-row .b-track {
  height: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.bar-row .b-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}
.bar-row .b-val { font-family: var(--mono); font-size: 12.5px; color: var(--text); text-align: right; }

/* ---------- 章末三件套 ---------- */

.chapter-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 48px;
}
.chapter-nav a {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 16px 18px;
  color: var(--text);
  display: block;
}
.chapter-nav a:hover { border-color: var(--accent); text-decoration: none; }
.chapter-nav .nav-dir {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 1px;
  display: block;
  margin-bottom: 4px;
}
.chapter-nav .nav-title { font-size: 15px; font-weight: 700; }
.chapter-nav .next { text-align: right; }
.chapter-nav a.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.mark-done-wrap { text-align: center; margin-top: 40px; }
.mark-done {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 22px;
  font-size: 14px;
  cursor: pointer;
  font-family: var(--sans);
}
.mark-done:hover { border-color: var(--green); color: var(--green); }
.mark-done.done {
  border-color: var(--green);
  color: var(--green);
  background: rgba(126, 231, 135, 0.06);
}

/* ---------- 首页说明块 ---------- */

.section-block { margin: 40px 0; }
.section-block h2 { margin-top: 0; }

.legend-list { display: flex; flex-direction: column; gap: 10px; font-size: 14.5px; color: var(--muted); }

.footer {
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding-top: 24px;
  color: var(--faint);
  font-size: 13px;
}

@media (max-width: 640px) {
  .hero { padding: 32px 22px; }
  .hero h1 { font-size: 28px; }
  .chapter-head h1 { font-size: 24px; }
  .chapter-nav { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 70px; }
  input[type="range"] { width: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bar-row .b-fill { transition: none; }
  .chapter-card { transition: none; }
}
