/* Claude 红皮书 — 站点样式
   由 tools/build_site.py 引用，可直接手改。 */

:root {
  color-scheme: light;
  --bg: #f3f1ea;
  --paper: #ffffff;
  --ink: #1d1b18;
  --ink-soft: #55504a;
  --muted: #857d73;
  --line: #e0d9cd;
  --line-soft: #ece6dc;
  --clay: #c15f3c;
  --clay-deep: #9d4426;
  --clay-wash: #fbf1ec;
  --slate: #2f6f66;
  --slate-wash: #e6f2f0;
  --code-bg: #211d1a;
  --code-ink: #f4ece4;
  --shadow: 0 18px 50px rgba(40, 30, 20, .10);
  --topbar-h: 66px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #16150f;
    --paper: #1e1c19;
    --ink: #f0ece5;
    --ink-soft: #c2bbb1;
    --muted: #938b81;
    --line: #34302a;
    --line-soft: #2a2621;
    --clay: #e0805c;
    --clay-deep: #f0a081;
    --clay-wash: #2b201b;
    --slate: #6fbdaf;
    --slate-wash: #1b2b28;
    --code-bg: #12100e;
    --code-ink: #f0e7de;
    --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 20px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei",
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- 顶部阅读进度条 ---------- */
.progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  height: 3px;
  background: transparent;
  pointer-events: none;
}
.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--clay), var(--slate));
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(16px, 4vw, 52px);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--clay);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.topnav a:hover { background: var(--line-soft); color: var(--ink); }
.topnav a.cta { background: var(--ink); color: var(--bg); }
.topnav a.cta:hover { background: var(--clay); color: #fff; }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 350px);
  align-items: center;
  gap: clamp(26px, 5vw, 64px);
  padding: clamp(40px, 6vw, 80px) clamp(18px, 7vw, 92px) clamp(36px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--clay-deep);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .06em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(42px, 8vw, 92px);
  line-height: 1.02;
  letter-spacing: -.01em;
}

.hero-lede {
  max-width: 720px;
  margin: 22px 0 0;
  color: var(--ink-soft);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}
.button-primary { background: var(--clay); color: #fff; }
.button-primary:hover { background: var(--clay-deep); }
.button-secondary {
  background: var(--slate-wash);
  border-color: color-mix(in srgb, var(--slate) 35%, transparent);
  color: var(--slate);
}

.hero-panel {
  display: grid;
  gap: 16px;
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.hero-panel div {
  display: grid;
  gap: 4px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line-soft);
}
.hero-panel div:last-child { padding-bottom: 0; border-bottom: 0; }
.panel-label { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.hero-panel strong { font-size: 17px; line-height: 1.45; }

/* ---------- 正文布局 ---------- */
.book-shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 880px);
  align-items: start;
  gap: clamp(24px, 4vw, 54px);
  max-width: 1260px;
  margin: 0 auto;
  padding: 40px clamp(16px, 4vw, 40px) 96px;
}

.toc-panel {
  position: sticky;
  top: calc(var(--topbar-h) + 22px);
  max-height: calc(100vh - var(--topbar-h) - 46px);
  overflow: auto;
  padding: 16px 0;
  border-right: 1px solid var(--line);
}
.toc-heading {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .08em;
}

/* 桌面端：目录常驻，不显示 <details> 的三角 */
.toc-panel > summary {
  list-style: none;
  cursor: default;
}
.toc-panel > summary::-webkit-details-marker { display: none; }
.toc-list { display: grid; gap: 1px; padding-right: 16px; }
.toc-link {
  display: block;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
  text-decoration: none;
}
.toc-link--sub {
  padding-left: 20px;
  color: var(--muted);
  font-size: 12.5px;
}
.toc-link:hover,
.toc-link.is-active {
  background: var(--clay-wash);
  color: var(--clay-deep);
}

.book-content {
  min-width: 0;
  padding: 34px clamp(18px, 4vw, 56px) 56px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.book-content > h1:first-child {
  margin-top: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.25;
}

.book-content h1,
.book-content h2,
.book-content h3,
.book-content h4 { line-height: 1.35; }

.book-content h1 {
  margin: 56px 0 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--clay);
  font-size: clamp(26px, 3.4vw, 36px);
}
.book-content h2 {
  margin: 44px 0 14px;
  padding-left: 13px;
  border-left: 5px solid var(--clay);
  font-size: clamp(21px, 2.6vw, 28px);
}
.book-content h3 {
  margin: 32px 0 11px;
  color: var(--clay-deep);
  font-size: clamp(18px, 2vw, 22px);
}
.book-content h4 { margin: 24px 0 9px; font-size: 17px; }

.book-content p,
.book-content li { font-size: 15.8px; }
.book-content p { margin: 0 0 14px; }
.book-content ul,
.book-content ol { margin: 0 0 18px; padding-left: 24px; }
.book-content li + li { margin-top: 5px; }

.book-content blockquote {
  margin: 20px 0;
  padding: 14px 18px;
  background: var(--clay-wash);
  border-left: 4px solid var(--clay);
  border-radius: 0 8px 8px 0;
}
.book-content blockquote p { margin: 0; color: var(--ink-soft); }
.book-content blockquote p + p { margin-top: 8px; }

.table-scroll {
  overflow-x: auto;
  margin: 18px 0 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.book-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.book-content th,
.book-content td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.book-content th:last-child,
.book-content td:last-child { border-right: 0; }
.book-content tr:last-child td { border-bottom: 0; }
.book-content th {
  background: var(--line-soft);
  font-weight: 800;
  white-space: nowrap;
}

.book-content code {
  padding: 2px 6px;
  background: var(--line-soft);
  border-radius: 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .9em;
  word-break: break-word;
}
.book-content pre {
  overflow-x: auto;
  margin: 18px 0 22px;
  padding: 17px 18px;
  background: var(--code-bg);
  border-radius: 10px;
}
.book-content pre code {
  padding: 0;
  background: transparent;
  color: var(--code-ink);
  font-size: 13.5px;
  line-height: 1.65;
  word-break: normal;
}

.book-content a {
  color: var(--clay-deep);
  font-weight: 600;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--clay) 40%, transparent);
}
.book-content img { max-width: 100%; height: auto; border-radius: 8px; }
.book-content hr { margin: 40px 0; border: 0; border-top: 1px solid var(--line); }

/* ---------- 页脚 / 回到顶部 ---------- */
.site-footer {
  padding: 30px clamp(16px, 4vw, 40px) 56px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
}
.site-footer a { color: var(--clay-deep); font-weight: 600; }

.back-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 25;
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 19px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.back-top.is-visible { display: block; }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .hero-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero-panel div { padding-bottom: 0; border-bottom: 0; }
  .book-shell { grid-template-columns: 1fr; }
  .toc-panel {
    position: static;
    max-height: none;
    padding: 16px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
  }
  .toc-list { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-right: 0; }

  /* 窄屏：48 条目录挡在正文前面没法读，折起来 */
  .toc-panel > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 4px 0;
    color: var(--ink);
    font-size: 15px;
    cursor: pointer;
    user-select: none;
  }
  .toc-panel > summary::after {
    content: "展开";
    color: var(--clay-deep);
    font-size: 13px;
    font-weight: 700;
  }
  .toc-panel[open] > summary { margin-bottom: 10px; }
  .toc-panel[open] > summary::after { content: "收起"; }
}

@media (max-width: 680px) {
  :root { --topbar-h: 60px; }
  .topbar { gap: 10px; padding-inline: 14px; }
  .topnav a { min-height: 34px; padding: 0 9px; font-size: 13px; }
  .topnav a[href="#toc"] { display: none; }
  .hero-actions { display: grid; grid-template-columns: 1fr; }
  .button { width: 100%; }
  .hero-panel { grid-template-columns: 1fr; }
  .book-shell { padding-inline: 12px; }
  .toc-list { grid-template-columns: 1fr; }
  .book-content { padding: 24px 15px 40px; }

  /* 窄屏上表格被挤成一列一个字，宁可横向滚一点 */
  .book-content table { min-width: 560px; }
}
