/* ==========================================================================
   Rain · 文章页样式
   --------------------------------------------------------------------------
   01. 文章页框架（头部 / 底部操作）
   02. 正文基础排版
   03. 正文特殊块：引言 / 目标 / 内联目录 / 提示框
   04. 代码块与语法高亮
   05. 对比表格 / SVG 图示 / 折叠问答
   --------------------------------------------------------------------------
   正文沿用原稿的类名（preface / goals / box / codeblock / cmp / fold 等），
   这里只负责把它们重绘成与全站一致的蓝色系风格，正文 HTML 无需改动。
   ========================================================================== */

/* ==========================================================================
   01. 文章页框架
   ========================================================================== */
.post {
  max-width: 46rem;
  margin-top: 1.6rem;
}

.post-chapter {
  font-family: 'Baloo 2', 'Noto Sans SC', sans-serif;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue);
}

.post-title {
  margin-top: 0.5rem;
  font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.3rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
  font-size: 0.8rem;
  color: var(--ink-mute);
}

.post-meta a {
  color: var(--ink-mute);
  text-decoration: none;
  transition: color 0.25s;
}

.post-meta a:hover {
  color: var(--blue);
}

/* —— 文章标签（文末，点击跳转到对应专栏）—— */
.post-tags-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-top: 2.8rem;
}

.post-tags-block__label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
}

.post-tag {
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--blue);
  text-decoration: none;
  transition: transform 0.25s var(--ease-pop), background 0.25s, color 0.25s, border-color 0.25s;
}

.post-tag:hover,
.post-tag:focus-visible {
  transform: translateY(-2px);
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.8rem;
  padding-top: 1.6rem;
  border-top: 1px dashed var(--line);
}

/* ==========================================================================
   02. 正文基础排版
   ========================================================================== */
.post-body {
  margin-top: 2rem;
  font-size: 1rem;
  line-height: 1.9;
  color: var(--ink-soft);
}

.post-body h2 {
  position: relative;
  margin: 2.8rem 0 1.1rem;
  padding-left: 0.9rem;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.post-body h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.28em;
  width: 4px;
  height: 0.9em;
  border-radius: 999px;
  background: linear-gradient(var(--blue), var(--indigo));
}

.post-body h3 {
  margin: 2.1rem 0 0.8rem;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
}

.post-body h4 {
  margin: 1.6rem 0 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.post-body p {
  margin: 1.05rem 0;
}

.post-body b,
.post-body strong {
  font-weight: 700;
  color: var(--ink);
}

.post-body em {
  font-style: italic;
}

.post-body ul,
.post-body ol {
  margin: 1.05rem 0;
  padding-left: 1.35rem;
}

.post-body li {
  margin: 0.5rem 0;
}

.post-body li::marker {
  color: var(--blue);
}

.post-body a {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--blue-soft);
  transition: text-decoration-color 0.25s;
}

.post-body a:hover {
  text-decoration-color: var(--blue);
}

.post-body hr {
  margin: 2.4rem 0;
  border: none;
  border-top: 1px dashed var(--line);
}

/* 行内代码 */
.post-body code.inline {
  padding: 0.12em 0.45em;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.87em;
  color: var(--blue);
  word-break: break-word;
}

/* ==========================================================================
   03. 引言 / 目标 / 内联目录 / 提示框
   ========================================================================== */

/* —— 引言 —— */
.preface {
  margin: 1.8rem 0;
  padding: 1.1rem 1.3rem;
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--surface-2);
}

.preface p {
  margin: 0.6rem 0;
}

.preface p:first-child {
  margin-top: 0;
}

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

/* —— 本章目标 —— */
.goals {
  margin: 1.8rem 0;
  padding: 1.2rem 1.4rem;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--blue-soft), var(--surface) 72%);
}

.goals .gt {
  margin-bottom: 0.6rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--blue);
}

.goals ul {
  margin: 0;
  padding-left: 1.2rem;
}

.goals li {
  margin: 0.4rem 0;
  font-size: 0.92rem;
}

/* —— 内联目录 —— */
.toc-inline {
  margin: 1.8rem 0;
  padding: 1.2rem 1.4rem;
  border-radius: var(--r-lg);
  border: 1px dashed var(--line);
  background: var(--surface);
}

.toc-inline .tt {
  margin-bottom: 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}

.toc-inline ol {
  margin: 0;
  padding-left: 1.3rem;
}

.toc-inline li {
  margin: 0.35rem 0;
  font-size: 0.92rem;
}

.toc-inline a {
  color: var(--ink-soft);
  text-decoration: none;
}

.toc-inline a:hover {
  color: var(--blue);
}

/* —— 提示框（box / key / why / hint）—— */
.box {
  margin: 1.8rem 0;
  padding: 1.1rem 1.3rem;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.box .bt {
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.box p {
  margin: 0.6rem 0;
}

.box p:first-of-type {
  margin-top: 0;
}

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

.box.why {
  border-left-color: var(--indigo);
  background: linear-gradient(135deg, var(--indigo-soft), var(--surface) 68%);
}

.box.hint {
  border-left-color: var(--cyan);
  background: linear-gradient(135deg, var(--cyan-soft), var(--surface) 68%);
}

/* ==========================================================================
   04. 代码块与语法高亮
   ========================================================================== */
.codeblock {
  margin: 1.8rem 0;
  border-radius: var(--r-lg);
  border: 1px solid #1e293b;
  background: #0f172a;
  overflow: hidden;
}

.codeblock .bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.codeblock .name {
  font-size: 0.76rem;
  font-weight: 600;
  color: #94a3b8;
}

.codeblock .spacer {
  flex: 1;
}

.codeblock .copy {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: #cbd5e1;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}

.codeblock .copy:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.codeblock pre.code {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.75;
  color: #e2e8f0;
  tab-size: 4;
}

.codeblock pre.code code {
  font-family: inherit;
}

/* 语法高亮（沿用原稿的 tk-* 类名） */
.tk-com { color: #64748b; font-style: italic; }
.tk-kw { color: #c084fc; }
.tk-ty { color: #7dd3fc; }
.tk-num { color: #fdba74; }
.tk-str { color: #86efac; }

/* 正文里单独的 pre（非 codeblock 结构） */
.post-body > pre {
  margin: 1.8rem 0;
  padding: 1rem 1.1rem;
  border-radius: var(--r-lg);
  background: #0f172a;
  color: #e2e8f0;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.75;
}

/* ==========================================================================
   05. 对比表格 / SVG 图示 / 折叠问答
   ========================================================================== */

/* —— 对比表格 —— */
.table-wrap {
  margin: 1.8rem 0;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  overflow-x: auto;
}

table.cmp {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table.cmp th,
table.cmp td {
  padding: 0.75rem 0.95rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

table.cmp th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

table.cmp th.cpp {
  color: #0369a1;
}

table.cmp th.cs {
  color: var(--blue);
}

table.cmp td {
  color: var(--ink-soft);
  line-height: 1.75;
}

table.cmp tbody tr:last-child td {
  border-bottom: none;
}

/* —— SVG 图示：原图配色为浅色系，统一用白底承载，两个主题下都清晰 —— */
figure.diagram {
  display: flex;
  justify-content: center;
  margin: 1.8rem 0;
  padding: 1rem;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: #ffffff;
  overflow-x: auto;
}

figure.diagram svg {
  max-width: 100%;
  height: auto;
}

/* —— 折叠问答（原生 details，无需 JS）—— */
details.fold {
  margin: 1rem 0;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.25s;
}

details.fold[open] {
  border-color: var(--blue-soft);
}

details.fold summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.95rem 1.2rem;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  transition: background 0.25s;
}

details.fold summary::-webkit-details-marker {
  display: none;
}

details.fold summary:hover {
  background: var(--surface-2);
}

/* 展开指示箭头 */
details.fold summary::after {
  content: '';
  flex: none;
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink-mute);
  border-bottom: 2px solid var(--ink-mute);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.3s var(--ease-pop);
}

details.fold[open] summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
}

/* 「点开看答案」提示，展开后隐藏 */
details.fold summary .hint {
  flex: none;
  margin-left: auto;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--blue-soft);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--blue);
}

html.dark details.fold summary .hint {
  color: #93c5fd;
}

details.fold[open] summary .hint {
  display: none;
}

details.fold .body {
  padding: 0 1.2rem 1.3rem;
  font-size: 0.93rem;
  line-height: 1.85;
  color: var(--ink-soft);
}

details.fold .body > *:first-child {
  margin-top: 0;
}

details.fold .body > *:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   06. 响应式
   ========================================================================== */
@media (max-width: 640px) {
  .post-body {
    font-size: 0.95rem;
  }

  .post-body h2 {
    font-size: 1.18rem;
  }

  .codeblock pre.code {
    font-size: 0.78rem;
  }

  details.fold summary {
    font-size: 0.88rem;
    padding: 0.85rem 1rem;
  }
}
