/* 《Anthropic Engineering 学习指南》网站版排版 */

:root {
  --book-accent: #2563eb;
  --book-accent-soft: #eff6ff;
  --book-border: #dbe3ef;
  --book-muted: #64748b;
  --book-panel: #f8fafc;
  --book-code: #0f172a;
  --book-case: #7c3aed;
  --book-summary: #047857;
  --book-practice: #b45309;
}

.book.color-theme-1 {
  --book-accent: #8b5e34;
  --book-accent-soft: #f6efe5;
  --book-border: #ded2c2;
  --book-muted: #76695d;
  --book-panel: #faf6ef;
  --book-code: #3c342d;
}

.book.color-theme-2 {
  --book-accent: #7dd3fc;
  --book-accent-soft: #172554;
  --book-border: #334155;
  --book-muted: #94a3b8;
  --book-panel: #111827;
  --book-code: #e2e8f0;
  --book-case: #c4b5fd;
  --book-summary: #6ee7b7;
  --book-practice: #fcd34d;
}

.page-inner {
  max-width: 980px;
  padding: 32px 48px 72px;
}

.markdown-section {
  font-family: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.markdown-section > h1:first-child {
  margin: 0 0 1.5rem;
  padding-bottom: 0.8rem;
  border-bottom: 2px solid var(--book-accent);
  font-size: 2.05em;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.markdown-section h2 {
  margin-top: 2.8rem;
  padding: 0.35rem 0 0.35rem 0.85rem;
  border-left: 4px solid var(--book-accent);
  line-height: 1.45;
}

.markdown-section h3 {
  margin-top: 2rem;
  line-height: 1.5;
}

.markdown-section p {
  margin: 0 0 1.15rem;
  text-align: justify;
  text-justify: inter-ideograph;
}

/* 标题后的第一个引用块是本章导读，chapter-meta 是章节元信息。 */
.markdown-section > h1:first-child + blockquote {
  margin: 0 0 0.9rem;
  padding: 1rem 1.2rem;
  border-left: 4px solid var(--book-accent);
  border-radius: 0 8px 8px 0;
  background: var(--book-accent-soft);
}

.markdown-section > h1:first-child + blockquote p {
  margin-bottom: 0.35rem;
}

.markdown-section > h1:first-child + blockquote ul {
  margin-bottom: 0;
}

.chapter-meta {
  display: grid;
  gap: 0.2rem;
  margin: 0 0 2rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--book-border);
  background: var(--book-panel);
  color: var(--book-muted);
  font-size: 0.9em;
  line-height: 1.65;
}

.chapter-meta span {
  min-width: 0;
}

.chapter-meta a {
  overflow-wrap: anywhere;
}

/* 贯穿案例、小结、实践任务使用稳定的视觉语义。 */
.markdown-section h2[id*="贯穿案例"] {
  border-left-color: var(--book-case);
  background: color-mix(in srgb, var(--book-case) 8%, transparent);
}

.markdown-section h2[id*="本章小结"] {
  border-left-color: var(--book-summary);
  background: color-mix(in srgb, var(--book-summary) 8%, transparent);
}

.markdown-section h2[id*="实践任务"] {
  border-left-color: var(--book-practice);
  background: color-mix(in srgb, var(--book-practice) 8%, transparent);
}

/* 图示：统一居中、限制尺寸、提供图号、说明和可点击原图。 */
.book-figure {
  margin: 1.5rem auto 2.25rem;
  padding: 1rem;
  border: 1px solid var(--book-border);
  border-radius: 10px;
  background: var(--book-panel);
  break-inside: avoid;
}

.book-figure--primary {
  margin-top: 1.2rem;
  border-top: 3px solid var(--book-accent);
}

.book-figure__link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  cursor: zoom-in;
}

.book-figure img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 760px;
  margin: 0 auto;
  object-fit: contain;
  background: #fff;
}

.book-figure--primary img {
  max-height: 700px;
}

.book-figure figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.4rem 0.8rem;
  margin-top: 0.9rem;
  color: var(--book-muted);
  font-size: 0.9em;
  line-height: 1.6;
  text-align: center;
}

.book-figure figcaption strong {
  color: inherit;
}

.book-figure__note {
  flex-basis: 100%;
}

.book-figure__source {
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--book-border);
  border-radius: 999px;
  font-size: 0.85em;
  white-space: nowrap;
}

.markdown-section pre {
  max-width: 100%;
  margin: 1.2rem 0 1.6rem;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
  line-height: 1.6;
  overflow: auto;
}

.markdown-section code {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.markdown-section table {
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 1.25rem auto 1.75rem;
  overflow-x: auto;
  border-collapse: collapse;
}

.markdown-section th {
  background: var(--book-panel);
}

.markdown-section blockquote:not(:first-of-type):not(:nth-of-type(2)) {
  border-left-color: var(--book-border);
}

@media (max-width: 720px) {
  .page-inner {
    padding: 24px 18px 56px;
  }

  .markdown-section {
    font-size: 15px;
    line-height: 1.78;
  }

  .markdown-section > h1:first-child {
    font-size: 1.75em;
  }

  .book-figure {
    margin-right: 0;
    margin-left: 0;
    padding: 0.65rem;
  }

  .book-figure img,
  .book-figure--primary img {
    max-height: none;
  }
}

@media print {
  .page-inner {
    max-width: none;
    padding: 0;
  }

  .markdown-section {
    font-size: 10.5pt;
    line-height: 1.65;
  }

  .book-figure,
  .markdown-section pre,
  .markdown-section table {
    break-inside: avoid;
  }

  .book-figure img,
  .book-figure--primary img {
    max-height: none;
  }

  .book-figure__source {
    display: none;
  }
}
