/* 汽车是怎么工作的 —— 暗色长文体，参照 Bartosz Ciechanowski 的排版与交互风格 */

:root {
  --bg: #15171a;
  --panel: #1b1e22;
  --panel-2: #202429;
  --ink: #dcd8d0;
  --dim: #989ea5;
  --line: #2c3136;
  --amber: #d9a441;
  --blue: #79a9c6;
  --green: #93bf93;
  --red: #cd7f70;
  --steel: #8b949c;
  --measure: 41rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "Times New Roman", serif;
  font-size: 17.5px;
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--amber);
  z-index: 60;
  transition: width .12s linear;
}

/* ---------- 版心 ---------- */

main { max-width: 68rem; margin: 0 auto; padding: 0 1.5rem 8rem; }

article > header {
  padding: 12vh 0 1vh;
  max-width: var(--measure);
  margin: 0 auto;
}
.kicker {
  font-family: "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: .74rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 1.6rem;
}
h1 {
  font-size: clamp(2.3rem, 5.4vw, 3.5rem);
  line-height: 1.16;
  font-weight: 400;
  margin: 0 0 1.4rem;
  letter-spacing: .01em;
}
.standfirst { font-size: 1.16rem; color: var(--dim); line-height: 1.7; }
.standfirst em { color: var(--ink); font-style: normal; }
.meta {
  margin-top: 3rem;
  font-family: "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: .78rem;
  color: #6f757b;
  letter-spacing: .04em;
}

section { margin: 0 auto; max-width: var(--measure); }

h2 {
  font-weight: 400;
  font-size: 1.9rem;
  line-height: 1.3;
  margin: 7rem 0 .4rem;
  letter-spacing: .01em;
}
h2 .num {
  display: block;
  font-family: "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: .72rem;
  letter-spacing: .24em;
  color: var(--amber);
  margin-bottom: .9rem;
}
h3 {
  font-weight: 400;
  font-size: 1.28rem;
  margin: 4.2rem 0 .3rem;
  color: #ece8e0;
}
h3 .tag {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .62em;
  color: #6f757b;
  letter-spacing: .06em;
  margin-left: .6em;
  vertical-align: .35em;
}
p { margin: 1.35rem 0; }
p.lead { font-size: 1.1rem; color: #e7e3db; }
a { color: var(--blue); text-decoration: none; border-bottom: 1px solid #33454f; }
a:hover { border-color: var(--blue); }
strong { color: #f0ece4; font-weight: 400; }
.term { color: var(--amber); }
.kw { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .86em; color: #cfd4d9; }

.note {
  border-left: 2px solid #3a4046;
  padding: .1rem 0 .1rem 1.1rem;
  margin: 2.2rem 0;
  font-size: .93rem;
  line-height: 1.72;
  color: var(--dim);
}
.note b { color: #b9bec4; font-weight: 400; }
.eq {
  margin: 2rem auto;
  padding: 1.1rem 1.3rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .92rem;
  line-height: 1.9;
  color: #d7dce1;
  overflow-x: auto;
  white-space: pre;
}

ul.clean { padding-left: 1.1rem; }
ul.clean li { margin: .5rem 0; }
table.spec {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: .9rem;
  font-family: "Helvetica Neue", "PingFang SC", sans-serif;
}
table.spec th, table.spec td {
  text-align: left;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.spec th { color: var(--amber); font-weight: 400; letter-spacing: .04em; font-size: .78rem; }
table.spec td:first-child { color: #ece8e0; white-space: nowrap; }
table.spec td { color: var(--dim); }

/* ---------- 图形容器 ---------- */

figure.fig {
  margin: 3.4rem auto;
  padding: 0;
  max-width: 62rem;
}
.stage {
  position: relative;
  background: radial-gradient(120% 140% at 50% 0%, #23272c 0%, #1a1d21 55%, #161a1d 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.stage svg { display: block; width: 100%; height: auto; touch-action: none; }
figcaption {
  margin: .85rem .2rem 0;
  font-size: .84rem;
  line-height: 1.7;
  color: #7f858c;
}
figcaption b { color: #a9aeb4; font-weight: 400; }

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

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .9rem;
  padding: .75rem .85rem;
  border-top: 1px solid var(--line);
  background: rgba(12, 14, 16, .55);
  font-family: "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: .78rem;
}
.ctl {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--dim);
  letter-spacing: .02em;
}
.ctl .val {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .74rem;
  color: var(--amber);
  min-width: 5.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 128px;
  height: 22px;
  background: transparent;
  cursor: ew-resize;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 3px;
  background: #3a4046;
  border-radius: 2px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  margin-top: -6px;
  border-radius: 50%;
  background: #e6e2da;
  border: none;
  box-shadow: 0 0 0 1px #101214, 0 2px 6px rgba(0,0,0,.5);
}
input[type=range]::-moz-range-track { height: 3px; background: #3a4046; border-radius: 2px; }
input[type=range]::-moz-range-thumb {
  width: 15px; height: 15px; border: none; border-radius: 50%; background: #e6e2da;
}
button.pill {
  font: inherit;
  color: var(--dim);
  background: transparent;
  border: 1px solid #3a4046;
  border-radius: 999px;
  padding: .22rem .8rem;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
button.pill:hover { color: var(--ink); border-color: #59616a; }
button.pill[aria-pressed=true], button.pill.on {
  color: #16181b;
  background: var(--amber);
  border-color: var(--amber);
}
button.pill.ghost[aria-pressed=true] { background: #3d4a52; color: #eaf1f5; border-color: #55666f; }
.pill-row { display: inline-flex; gap: .35rem; flex-wrap: wrap; }
.readout {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .74rem;
  color: var(--dim);
  letter-spacing: .02em;
}
.readout span { color: var(--amber); font-variant-numeric: tabular-nums; }
.hint {
  padding: .55rem .85rem;
  border-top: 1px dashed #2c3136;
  font-family: "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: .74rem;
  color: #6f757b;
  background: rgba(0,0,0,.18);
}

/* ---------- 侧栏目录 ---------- */

nav#toc {
  position: fixed;
  top: 50%;
  right: 1.2rem;
  transform: translateY(-50%);
  z-index: 50;
  font-family: "Helvetica Neue", "PingFang SC", sans-serif;
  font-size: .72rem;
  line-height: 1.9;
  display: none;
}
@media (min-width: 1360px) { nav#toc { display: block; } }
nav#toc a {
  display: block;
  color: #5f666d;
  border: none;
  padding-left: .9rem;
  border-left: 1px solid var(--line);
  transition: color .15s, border-color .15s;
}
nav#toc a:hover { color: var(--ink); }
nav#toc a.active { color: var(--amber); border-left-color: var(--amber); }

/* ---------- 章节过渡 ---------- */

.rule {
  max-width: var(--measure);
  margin: 11rem auto 0;
  border: none;
  border-top: 1px solid var(--line);
}
.pullquote {
  max-width: var(--measure);
  margin: 5rem auto;
  font-size: 1.3rem;
  line-height: 1.7;
  color: #e7e3db;
  text-align: center;
}

/* ---------- SVG 通用 ---------- */

svg text {
  font-family: "Helvetica Neue", "PingFang SC", sans-serif;
  fill: #9aa0a6;
  font-size: 12px;
}
svg text.small { font-size: 10.5px; fill: #7f858c; }
svg text.big { font-size: 15px; fill: #dcd8d0; }
svg text.val { fill: var(--amber); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
svg text.hd { fill: #6f757b; font-size: 10.5px; letter-spacing: .1em; }
svg .stroke { fill: none; stroke: #6f7982; stroke-width: 2; }
svg .thin { fill: none; stroke: #454c53; stroke-width: 1; }
svg .metal { fill: #3b4249; stroke: #5d666e; stroke-width: 1.4; }
svg .metal-l { fill: #4a5259; stroke: #727b83; stroke-width: 1.4; }
svg .metal-d { fill: #2b3136; stroke: #4a525a; stroke-width: 1.2; }
svg .dim { fill: #6f757b; }
svg .hot { fill: #cd7f70; }
svg .cold { fill: #79a9c6; }
svg .fade { opacity: .13; transition: opacity .5s; }
svg .gone { opacity: 0; pointer-events: none; transition: opacity .25s; }
svg .arrow { fill: none; stroke: var(--amber); stroke-width: 2.5; }
svg .flow { stroke-dasharray: 7 9; animation: flowdash 1s linear infinite; }
@keyframes flowdash { to { stroke-dashoffset: -16; } }
svg .pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .35 } 50% { opacity: 1 } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  svg .flow, svg .pulse { animation: none; }
}

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

footer.end {
  max-width: var(--measure);
  margin: 10rem auto 0;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  font-size: .86rem;
  color: #7f858c;
}
footer.end h4 { color: var(--ink); font-weight: 400; margin: 2rem 0 .4rem; }
