/* 公开内容页（关于我们、使用指南、常见问题、数据来源与方法、研究方法列表与文章）共用的样式。
   这几页不加载工作台的 styles.css（约 400 KB），所以在这里按 DESIGN.md frontmatter 的 colors / colors-dark
   声明同名变量；下面的组件规则只用变量，不写色值。
   有意偏离：正文用 16/28（字号、行高都在 DESIGN.md 档位内），不用工作台长文的 body-long 14/24——
   这是对外长文页，读者多在手机上从头读到尾，16px 读起来不累；行宽仍按 640px（约 40 个汉字）收。 */
:root {
  color-scheme: light;
  --bg: #f1f2f7;
  --surface: #ffffff;
  --surface-soft: #f9fbfd;
  --surface-raised: #ffffff;
  --line: #e3e8ef;
  --line-soft: #eef1f5;
  --line-strong: #cfd7e3;
  --on-fill: #ffffff;
  --text: #111827;
  --muted: #5c6b80;
  --faint: #94a3b8;
  --blue: #2563eb;
  --primary-fill: #2563eb;
  --primary-pressed: #1f53c5;
  --primary-text: #1e4fbc;
  --font: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
  --fast: 120ms;
  --base: 200ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12151c;
  --surface: #191f2b;
  --surface-soft: #202735;
  --surface-raised: #283041;
  --line: rgba(255, 255, 255, 0.1);
  --line-soft: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e8ecf3;
  --muted: #94a3b8;
  --faint: #64748b;
  --blue: #6b8cff;
  --primary-text: #819dff;
}

* { box-sizing: border-box; }

html { scroll-padding-top: 88px; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/28px var(--font);
}

a { color: var(--blue); }

a:focus-visible,
button:focus-visible,
.cp-table:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.cp-skip {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--primary-fill);
  color: var(--on-fill);
  font: 500 14px/20px var(--font);
  text-decoration: none;
}

.cp-skip:focus { top: 12px; }

/* —— 顶栏 —— */
.cp-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.cp-header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1120px;
  height: 64px;
  margin: 0 auto;
  padding: 0 24px;
}

.cp-brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font: 600 16px/24px var(--font);
  text-decoration: none;
}

.cp-brand img { display: block; }

.cp-nav {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 24px;
  min-width: 0;
}

.cp-nav a {
  display: inline-flex;
  align-items: center;
  height: 40px;
  color: var(--muted);
  font: 500 14px/20px var(--font);
  text-decoration: none;
  white-space: nowrap;
  box-shadow: inset 0 -2px 0 transparent;
  transition: color var(--fast) var(--ease);
}

.cp-nav a:hover { color: var(--text); }

.cp-nav a[aria-current="page"] {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--blue);
}

.cp-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.cp-theme,
.cp-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border-radius: 8px;
  font: 500 14px/20px var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}

.cp-theme:active,
.cp-button:active { transform: scale(0.98); }

.cp-theme {
  width: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
}

.cp-theme span { font-size: 16px; line-height: 20px; }
.cp-moon { display: none; }
html[data-theme="dark"] .cp-sun { display: none; }
html[data-theme="dark"] .cp-moon { display: inline; }

.cp-button { padding: 0 16px; white-space: nowrap; }

.cp-button-secondary {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.cp-theme:hover,
.cp-button-secondary:hover { background: var(--surface-soft); }

.cp-button-primary {
  border: 0;
  background: var(--primary-fill);
  color: var(--on-fill);
}

.cp-button-primary:hover { background: color-mix(in srgb, var(--primary-fill) 92%, black); }
.cp-button-primary:active { background: var(--primary-pressed); }

/* —— 正文区：左侧本页目录，右侧文章 —— */
.cp-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-areas: "crumbs crumbs" "toc article";
  gap: 16px 40px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 24px 40px;
}

.cp-crumbs {
  grid-area: crumbs;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font: 400 13px/20px var(--font);
}

/* 文章页的面包屑末项是长标题：链接不被挤成两行，放不下时标题整段换到下一行 */
.cp-crumbs a { flex: none; color: var(--muted); }
.cp-crumbs a:hover { color: var(--text); }

.cp-toc {
  grid-area: toc;
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
}

.cp-toc-title {
  margin: 0 0 8px;
  color: var(--text);
  font: 600 14px/20px var(--font);
}

.cp-toc ul { margin: 0; padding: 0; list-style: none; }

.cp-toc a {
  display: block;
  padding: 4px 0;
  color: var(--muted);
  font: 400 13px/20px var(--font);
  text-decoration: none;
}

.cp-toc a:hover,
.cp-toc-compact a:hover { color: var(--text); }

/* 窄屏用可折叠的目录，默认收起，免得长目录把正文压到第二屏以下 */
.cp-toc-compact { display: none; }

.cp-article {
  grid-area: article;
  min-width: 0;
  max-width: 720px;
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.cp-article h1 {
  margin: 0 0 32px;
  font: 600 28px/36px var(--font);
}

.cp-section + .cp-section { margin-top: 40px; }

/* —— 研究方法文章：标题下的发布日期与出处；导语和第一节之间留出与节间相同的 40px —— */
.cp-article-head { margin-bottom: 32px; }
.cp-article .cp-article-head h1 { margin: 0 0 8px; }

.cp-article .cp-byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  margin: 0;
  color: var(--muted);
  font: 400 13px/20px var(--font);
  font-variant-numeric: tabular-nums;
}

.cp-lead { margin-bottom: 28px; }

/* —— 研究方法列表页：每篇一行，标题是导航链接（蓝色、无下划线） —— */
.cp-article .cp-entries {
  max-width: none;
  margin: 0 0 40px;
  padding: 0;
  list-style: none;
}

.cp-article .cp-entry + .cp-entry {
  margin-top: 0;
  border-top: 1px solid var(--line-soft);
}

.cp-entry { padding: 24px 0; }
.cp-entry:first-child { padding-top: 0; }

.cp-article .cp-entry h2 {
  margin: 0 0 8px;
  font: 600 18px/28px var(--font);
}

.cp-article .cp-entry h2 a {
  color: var(--blue);
  text-decoration: none;
}

.cp-article .cp-entry h2 a:hover { text-decoration: underline; }

.cp-article .cp-entry p { margin-bottom: 8px; }
.cp-article .cp-entry .cp-byline { margin: 0; }

.cp-article h2 {
  margin: 0 0 12px;
  font: 600 22px/32px var(--font);
}

.cp-article h3 {
  margin: 24px 0 8px;
  font: 600 18px/28px var(--font);
}

.cp-article p,
.cp-article ul,
.cp-article ol { max-width: 640px; margin: 0 0 12px; }

.cp-article ul,
.cp-article ol { padding-left: 24px; }

.cp-article li + li { margin-top: 8px; }
.cp-article li > ul { margin: 8px 0 0; }
.cp-article strong { font-weight: 600; }

/* 正文里的链接是引用链接：始终带下划线；外部网站加 ↗ */
.cp-article p a,
.cp-article li a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.cp-ext::after { content: " ↗"; }

.cp-faq-no {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* —— 表格：在自己的框里横向滚动，不撑宽页面 —— */
.cp-table {
  max-width: 100%;
  margin: 0 0 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.cp-table table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

.cp-table th,
.cp-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  font: 400 14px/20px var(--font);
  text-align: left;
  vertical-align: top;
}

.cp-table thead th {
  padding: 8px 16px;
  border-bottom-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font: 500 12px/16px var(--font);
  white-space: nowrap;
}

.cp-table tbody th { font-weight: 600; }
.cp-table tbody tr:last-child > * { border-bottom: 0; }

/* —— 风险提示（DESIGN.md“风险提示与免责声明”） —— */
.cp-risk {
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.cp-article .cp-risk h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  font: 600 14px/20px var(--font);
}

.cp-risk-icon,
.cp-footer-risk-icon {
  flex: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 16px;
}

.cp-article .cp-risk p {
  margin: 0;
  color: var(--muted);
  font: 400 12px/16px var(--font);
}

.cp-related {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.cp-related-title {
  margin: 0 0 8px;
  color: var(--muted);
  font: 500 13px/20px var(--font);
}

.cp-related ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cp-related li + li { margin-top: 0; }

.cp-article .cp-related a {
  font: 500 14px/20px var(--font);
  text-decoration: none;
}

.cp-article .cp-related a:hover { text-decoration: underline; }

/* —— 页脚：内容与首页页脚一致 —— */
.cp-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 400 13px/20px var(--font);
}

.cp-footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 24px;
}

.cp-footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 24px;
  padding-bottom: 24px;
}

.cp-footer-grid > * { min-width: 0; }
.cp-footer p { margin: 0 0 4px; }
.cp-footer a { color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.cp-footer a:hover { color: var(--text); text-decoration: underline; }

.cp-footer-brand b {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font: 600 18px/28px var(--font);
}

.cp-footer-title {
  color: var(--text);
  font-weight: 600;
}

.cp-footer ul { margin: 0; padding: 0; list-style: none; }
.cp-footer li { margin: 0 0 4px; }

.cp-footer .cp-footer-risk {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 24px;
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-soft);
  font: 400 12px/16px var(--font);
}

.cp-footer-legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font: 400 12px/16px var(--font);
}

/* —— 平板：目录放到文章上方 —— */
@media (max-width: 860px) {
  .cp-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "crumbs" "toc" "article";
  }

  .cp-toc { display: none; }

  .cp-toc-compact {
    display: block;
    grid-area: toc;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
  }

  .cp-toc-compact summary {
    display: flex;
    align-items: center;
    height: 44px;
    padding: 0 16px;
    color: var(--text);
    font: 600 14px/20px var(--font);
    cursor: pointer;
  }

  .cp-toc-compact summary:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
    border-radius: 12px;
  }

  .cp-toc-compact ul {
    margin: 0;
    padding: 0 16px 8px;
    list-style: none;
  }

  .cp-toc-compact a {
    display: flex;
    align-items: center;
    min-height: 44px;
    color: var(--muted);
    font: 400 14px/20px var(--font);
    text-decoration: none;
  }

  .cp-article { max-width: none; }
  .cp-footer-grid { grid-template-columns: 1fr 1fr; }
}

/* —— 手机：顶栏两行，导航横向滑动；热区补到 44px —— */
@media (max-width: 640px) {
  html { scroll-padding-top: 16px; }

  .cp-header { position: static; }

  .cp-header-inner {
    flex-wrap: wrap;
    gap: 0 12px;
    height: auto;
    padding: 12px 16px 0;
  }

  .cp-brand { flex: 1; }

  .cp-nav {
    order: 3;
    flex: 0 0 100%;
    justify-content: flex-start;
    gap: 20px;
    margin-top: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .cp-nav a { height: 44px; }

  .cp-theme::after,
  .cp-button::after {
    content: "";
    position: absolute;
    inset: -4px;
  }

  .cp-button { padding: 0 12px; }

  .cp-skip { height: 44px; }
  .cp-brand { min-height: 44px; }

  .cp-crumbs a { position: relative; }
  .cp-crumbs a::after {
    content: "";
    position: absolute;
    inset: -12px -10px;
  }

  .cp-layout { padding: 16px 16px 32px; }
  .cp-article { padding: 24px 16px; }

  .cp-article h1 { margin-bottom: 24px; font-size: 22px; line-height: 32px; }
  .cp-article-head { margin-bottom: 24px; }
  .cp-article .cp-article-head h1 { margin-bottom: 8px; }
  .cp-lead { margin-bottom: 20px; }
  .cp-article .cp-entries { margin-bottom: 32px; }
  .cp-article .cp-entry h2 { font-size: 16px; line-height: 24px; }
  .cp-entry { padding: 20px 0; }
  .cp-entry h2 a { position: relative; }
  .cp-entry h2 a::after {
    content: "";
    position: absolute;
    inset: -10px 0;
  }
  .cp-article h2 { font-size: 18px; line-height: 28px; }
  .cp-article h3 { font-size: 16px; line-height: 24px; }
  .cp-section + .cp-section { margin-top: 32px; }
  .cp-faq-no { letter-spacing: 0; }

  .cp-article .cp-related a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .cp-footer-inner { padding: 32px 16px; }
  .cp-footer-grid { grid-template-columns: 1fr; }
  .cp-footer li { margin: 0; }
  .cp-footer li a,
  .cp-footer-legal a { display: inline-flex; align-items: center; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .cp-nav a,
  .cp-theme,
  .cp-button { transition: none; }

  .cp-theme:active,
  .cp-button:active { transform: none; }
}
