/*
 * Thinking 文章共用样式
 * 所有 /thinking/<slug>/ 文章页引用此文件，保证页面框架一致：
 * 头部（返回链接 / 路径 / 标题 / 副标题 / 信息栏）→ 目录导航 → 正文 → 页脚。
 * 目录、小节编号、阅读时长由 article.js 自动生成。
 */
/* 中文引号用中文字体渲染，避免 Inter 的窄引号挤在汉字之间 */
@font-face {
  font-family: "CJK Quotes";
  src: local("PingFang SC"), local("Hiragino Sans GB"), local("Microsoft YaHei"), local("Noto Sans CJK SC"), local("Source Han Sans SC");
  unicode-range: U+2018-2019, U+201C-201D, U+2014, U+2026;
}

:root {
  color-scheme: light;
  --bg: #f1ece4;
  --paper: #f7f3eb;
  --ink: #18161a;
  --ink-2: #2c2925;
  --muted: #7a756c;
  --line: #d0c9bb;
  --warm: #5c4838;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "CJK Quotes", Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 16px;
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.article-shell {
  max-width: 860px;
  margin: 0 auto;
  padding: 52px 30px 96px;
}

.backlink {
  display: inline-flex;
  margin-bottom: 40px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: color 0.18s ease;
}

.backlink:hover { color: var(--warm); }

.article-kicker {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.article-kicker::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(34px, 6vw, 62px);
  line-height: 1.08;
  letter-spacing: -0.045em;
  font-weight: 800;
}

.em {
  font-family: 'Space Grotesk', Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-style: normal;
  font-weight: 800;
  color: var(--warm);
  letter-spacing: -0.045em;
}

.subtitle {
  max-width: 680px;
  margin: 26px 0 0;
  color: var(--ink-2);
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.62;
  letter-spacing: -0.012em;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

article {
  margin: 64px 0 0;
}

h2 {
  margin: 52px 0 18px;
  font-size: clamp(23px, 2.5vw, 30px);
  line-height: 1.24;
  letter-spacing: -0.022em;
}

p {
  margin: 0 0 21px;
  color: var(--ink-2);
}

strong {
  color: var(--ink);
  font-weight: 700;
}

.keyline {
  font-weight: 700;
  text-decoration-line: underline;
  text-decoration-color: color-mix(in oklab, var(--warm) 64%, transparent);
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.2em;
  text-decoration-skip-ink: auto;
}

.lead {
  font-size: clamp(19px, 2vw, 23px);
  line-height: 1.68;
  letter-spacing: -0.014em;
  color: var(--ink);
}

.pullquote {
  margin: 42px 0;
  padding: 26px 0 26px 24px;
  border-left: 2px solid var(--warm);
  color: var(--ink);
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.42;
  letter-spacing: -0.022em;
  font-weight: 600;
}

.note {
  margin: 36px 0;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in oklab, var(--paper) 74%, transparent);
}

.note p:last-child { margin-bottom: 0; }

ol,
ul {
  margin: 18px 0 28px;
  padding-left: 1.25em;
  color: var(--ink-2);
}

li {
  margin: 10px 0;
  padding-left: 4px;
}

.ability-list {
  list-style: none;
  padding: 0;
  margin: 26px 0 34px;
  border-top: 1px solid var(--line);
}

.ability-list li {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 20px;
  margin: 0;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.ability-list b {
  color: var(--ink);
  font-size: 15px;
  letter-spacing: -0.006em;
}

.ability-list span { color: var(--ink-2); }

.closing {
  margin-top: 60px;
  padding-top: 32px;
  border-top: 1px solid var(--ink);
  font-size: clamp(19px, 2vw, 24px);
  line-height: 1.62;
  letter-spacing: -0.016em;
  color: var(--ink);
}

.page-foot {
  margin: 60px 0 0;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  margin: 26px 0 34px;
  overflow-x: auto;
  border-top: 1px solid var(--ink);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.62;
}

th,
td {
  padding: 14px 16px 14px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  color: var(--ink-2);
}

th {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

td b { color: var(--ink); }

.questions {
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
  counter-reset: q;
  border-top: 1px solid var(--line);
}

.questions li {
  position: relative;
  margin: 0;
  padding: 14px 0 14px 44px;
  border-bottom: 1px solid var(--line);
  counter-increment: q;
}

.questions li::before {
  content: "Q" counter(q);
  color: var(--warm);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  position: absolute;
  left: 0;
  top: 17px;
}

@media (max-width: 680px) {
  .article-shell { padding: 34px 22px 72px; }
  .backlink { margin-bottom: 34px; }
  .article-kicker { margin-bottom: 24px; }
  article { margin-top: 48px; }
  h1 { letter-spacing: -0.038em; }
  h2 { margin-top: 44px; }
  .ability-list li { grid-template-columns: 1fr; gap: 6px; }
  .pullquote { padding-left: 20px; }
}

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

article h2, [data-toc] { scroll-margin-top: 28px; }

.toc {
  margin: 40px 0 0;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toc-label {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.toc-label::-webkit-details-marker { display: none; }
.toc-label::after { content: " ＋"; }
.toc-details[open] .toc-label::after { content: " －"; }

.toc ol {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: 28px;
  counter-reset: toc;
}

.toc li {
  margin: 0;
  padding: 0;
  break-inside: avoid;
  counter-increment: toc;
}

.toc a {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.5;
  text-decoration: none;
  transition: color 0.18s ease;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}

.toc a:hover,
.toc a.active { color: var(--warm); }

.toc a.active { font-weight: 700; }
.toc a.active::before { color: var(--warm); }

@media (min-width: 1280px) {
  .toc {
    position: fixed;
    top: 120px;
    left: max(24px, calc(50% - 430px - 210px));
    width: 180px;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .toc ol { columns: 1; border-left: 1px solid var(--line); }
  .toc-label { cursor: default; pointer-events: none; }
  .toc-label::after { content: none; }
  .toc a { padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent; font-size: 14px; }
  .toc a.active { border-left-color: var(--warm); }
}

@media (max-width: 680px) {
  .toc ol { columns: 1; }
}

article > p,
article > ul,
article > ol,
article > h2,
article > .pullquote {
  max-width: 680px;
}

article p,
article li { font-size: 17px; }

.takeaway {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.7;
}

@media (max-width: 680px) {
  .stack thead { display: none; }
  .stack tr { display: block; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .stack td { display: block; padding: 2px 0; border: 0; }
  .stack td:first-child { margin-bottom: 4px; }
  .stack td[data-label]::before {
    content: attr(data-label) "：";
    color: var(--muted);
    font-size: 13px;
  }
  .stack.compare td:first-child { width: auto; }
}

/* ── 中文排版细节 ── */
body {
  line-break: strict;
  text-spacing-trim: trim-start;
  text-autospace: normal;
  hanging-punctuation: allow-end;
}

h1, h2, .pullquote { text-wrap: balance; }
/* 标题只在标点和空格处换行，避免把“全家桶”拆开 */
h1 { word-break: keep-all; }
p, li, td { text-wrap: pretty; }

/* 小节编号：由 article.js 写入 data-num，与目录序号一一对应 */
article h2[data-num]::before {
  content: attr(data-num);
  display: block;
  margin-bottom: 8px;
  color: var(--warm);
  font-family: Inter, sans-serif;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

article h2[data-num] {
  margin-top: 72px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

/* 强调层级：下划线句子里的数字不再叠加荧光底 */
.keyline .num { background: none; padding: 0; }

.takeaway { margin-bottom: 24px; }

@media (max-width: 680px) {
  article h2[data-num] { margin-top: 56px; padding-top: 22px; }
  h1 { font-size: 32px; }
}

.tldr {
  margin: 0 0 12px;
  padding: 24px 26px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in oklab, var(--paper) 74%, transparent);
}

.tldr-label {
  margin-bottom: 4px;
  color: var(--warm);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.tldr ol { margin-top: 8px; }

.compare td:first-child { width: 22%; }
.compare td:nth-child(2) { color: var(--muted); }

.num {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: linear-gradient(transparent 62%, color-mix(in oklab, var(--warm) 22%, transparent) 62%);
  padding: 0 1px;
}

.aside { color: var(--muted); font-size: 14px; }

.timebars { margin: 28px 0 34px; }

.timebar-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.timebar-label { color: var(--muted); font-size: 14px; font-weight: 600; }

.timebar {
  display: flex;
  height: 38px;
  overflow: hidden;
  border-radius: 6px;
}

.seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

.seg-think { background: var(--warm); color: var(--paper); }
.seg-code { background: var(--line); color: var(--ink-2); }
.seg-verify { background: var(--ink); color: var(--paper); }

.timebar-note { margin: 10px 0 0 56px; color: var(--muted); font-size: 14px; }

.refs { font-size: 15px; }

@media (max-width: 680px) {
  .tldr { padding: 20px 20px 4px; }
  .timebar-note { margin-left: 0; }
}

/* ── 版面收紧（2026-10-10 反馈）：标题缩小、间距收紧、减少横线、模块描边变浅 ── */
:root { --hairline: color-mix(in oklab, var(--line) 55%, transparent); }

h1 {
  font-size: clamp(28px, 3.6vw, 42px);
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.subtitle { margin-top: 18px; font-size: clamp(17px, 1.6vw, 19px); }

.meta { margin-top: 20px; padding-top: 0; border-top: 0; }

article { margin-top: 32px; }

.toc { margin-top: 28px; }

/* 小节之间只靠留白和编号区分，不再加横线 */
article h2[data-num] { margin-top: 56px; padding-top: 0; border-top: 0; }

/* 卡片模块：去掉深色描边，只用浅底色 */
.tldr,
.note {
  border: 0;
  background: color-mix(in oklab, var(--paper) 88%, var(--line) 12%);
}

.toc { border-color: var(--hairline); }

/* 表格和列表的分隔线统一变浅 */
.table-wrap { border-top: 1px solid var(--line); }
th, td { border-bottom-color: var(--hairline); }
.ability-list,
.questions { border-top-color: var(--hairline); }
.ability-list li,
.questions li { border-bottom-color: var(--hairline); }
.page-foot { border-top-color: var(--hairline); }

@media (max-width: 680px) {
  h1 { font-size: 28px; }
  article h2[data-num] { margin-top: 48px; }
  .stack tr { border-bottom-color: var(--hairline); }
}

/* ── 顶部导航条：阅读时随时可以返回（由 article.js 生成） ── */
.article-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.article-bar.scrolled { border-bottom-color: var(--hairline); }

.article-bar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1240px;
  height: 52px;
  margin: 0 auto;
  padding: 0 24px;
  font-size: 14px;
}

.article-bar a {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.18s ease;
}

.article-bar a:hover { color: var(--warm); }

.article-bar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.article-bar.show-title .article-bar-title { opacity: 1; transform: none; }

.article-bar-progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 100%;
  background: var(--warm);
  transform: scaleX(0);
  transform-origin: left center;
}

/* 有了顶部导航条，正文里的返回链接不再重复显示 */
.article-bar ~ main .backlink { display: none; }

article h2, [data-toc] { scroll-margin-top: 76px; }

@media (min-width: 1280px) {
  .toc { top: 132px; }
}

@media (max-width: 680px) {
  .article-bar-inner { height: 48px; padding: 0 20px; gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .article-bar-title { transition: none; }
}
