/* 博客与用户指南页面样式 — 依赖 styles.css 的设计变量 */

.content-body {
  background:
    radial-gradient(circle at 88% 6%, oklch(0.92 0.08 350 / 0.68), transparent 28rem),
    linear-gradient(180deg, var(--bg), oklch(0.975 0.012 270));
}

.content-body .nav-links a[aria-current="page"] {
  color: var(--primary-deep);
  font-weight: 900;
  text-decoration: underline;
  text-decoration-color: var(--pink);
  text-decoration-thickness: 0.14rem;
  text-underline-offset: 0.5rem;
}

.content-body .site-header,
.content-body .site-header[data-scrolled] {
  background: transparent;
  box-shadow: none;
}

/* ---------- 页头横幅 ---------- */

.content-hero {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(3rem, 7vw, 5.5rem) 0 clamp(1.8rem, 4vw, 3rem);
}

.content-kicker {
  margin: 0 0 1rem;
  color: var(--primary);
  font-size: 0.94rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.content-hero h1 {
  max-width: 16em;
  margin-bottom: 1.2rem;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  line-height: 1.05;
}

.content-hero .lede {
  max-width: 38rem;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  line-height: 1.75;
  text-wrap: pretty;
}

/* ---------- 博客卡片网格 ---------- */

.post-grid-wrap,
.guide-list-wrap {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding-bottom: clamp(4rem, 8vw, 7rem);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.1rem;
}

.post-card {
  --card-wash: oklch(0.62 0.15 270 / 0.1);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  overflow: hidden;
  padding: 1.7rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  text-decoration: none;
  transition:
    transform 260ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 260ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 260ms ease;
}

.post-card::after {
  position: absolute;
  right: -3rem;
  bottom: -3.5rem;
  width: 9rem;
  aspect-ratio: 1;
  background: var(--card-wash);
  border-radius: 50%;
  content: "";
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.post-card:hover {
  border-color: transparent;
  box-shadow: 0 22px 46px oklch(0.22 0.06 276 / 0.18);
  transform: translateY(-6px);
}

.post-card:hover::after {
  transform: scale(1.15);
}

.post-card time {
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.post-card h2 {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.post-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.read-more {
  margin-top: auto;
  color: var(--primary);
  font-size: 0.95rem;
  font-weight: 800;
}

.read-more .arrow {
  display: inline-block;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.post-card:hover .arrow {
  transform: translateX(4px);
}

.empty-note {
  padding: 3rem 2rem;
  color: var(--muted);
  text-align: center;
  background: var(--white);
  border: 1px dashed var(--line);
  border-radius: 1.25rem;
}

/* ---------- 用户指南列表 ---------- */

.guide-list {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 1.4rem;
  align-items: center;
  padding: 1.5rem 1.7rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  text-decoration: none;
  transition:
    transform 260ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 260ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 260ms ease;
}

.guide-card:hover {
  border-color: transparent;
  box-shadow: 0 22px 46px oklch(0.22 0.06 276 / 0.18);
  transform: translateY(-4px);
}

.guide-index {
  color: var(--primary);
  font-size: 2rem;
  font-weight: 950;
  letter-spacing: -0.04em;
  opacity: 0.55;
}

.guide-title {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 1.25rem;
  font-weight: 800;
}

.guide-summary {
  display: block;
  color: var(--muted);
  line-height: 1.65;
}

.guide-arrow {
  color: var(--primary);
  font-size: 1.3rem;
  font-weight: 900;
}

/* ---------- 文章页 ---------- */

.article-page {
  width: min(820px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(4rem, 8vw, 6rem);
}

.back-link {
  display: inline-block;
  margin-bottom: 2rem;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  color: var(--primary);
}

.article-page h1,
.doc-main h1 {
  max-width: none;
  margin-bottom: 1rem;
  font-size: clamp(2.1rem, 5vw, 3.3rem);
  line-height: 1.15;
}

.article-meta {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- 正文排版（博客详情 / 指南正文共用） ---------- */

.post-content {
  margin-top: 2.2rem;
}

.post-content p {
  margin-bottom: 1.15rem;
  font-size: 1.04rem;
  line-height: 1.88;
  text-wrap: pretty;
}

.post-content h2 {
  margin: 2.4rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.72rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.post-content h3 {
  margin: 1.9rem 0 0.8rem;
  font-size: 1.32rem;
}

.post-content h4 {
  margin: 1.5rem 0 0.6rem;
  font-size: 1.12rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1.15rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.45rem;
  line-height: 1.8;
}

.post-content blockquote {
  margin: 1.4rem 0;
  padding: 1rem 1.3rem;
  background: var(--surface);
  border-left: 4px solid var(--primary);
  border-radius: 0.25rem 1rem 1rem 0.25rem;
  color: var(--muted);
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

.post-content pre {
  margin: 1.4rem 0;
  padding: 1.1rem 1.25rem;
  overflow: auto;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  font-size: 0.92rem;
  line-height: 1.6;
}

.post-content code {
  padding: 0.15em 0.45em;
  background: var(--surface-strong);
  border-radius: 0.45rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: 0.9em;
}

.post-content pre code {
  padding: 0;
  background: none;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
}

.post-content table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.98rem;
}

.post-content th,
.post-content td {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  line-height: 1.6;
  text-align: left;
  vertical-align: top;
}

.post-content th {
  background: var(--surface);
  font-weight: 800;
  white-space: nowrap;
}

.post-content a {
  color: var(--primary);
  font-weight: 700;
}

.post-content hr {
  margin: 2.2rem 0;
  border: none;
  border-top: 1px solid var(--line);
}

.post-content ul[data-type="taskList"] {
  padding-left: 0.25rem;
  list-style: none;
}

.post-content ul[data-type="taskList"] li {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.post-content ul[data-type="taskList"] li > label {
  margin-top: 0.4rem;
}

.post-content ul[data-type="taskList"] input[type="checkbox"] {
  accent-color: var(--primary);
}

.post-content ul[data-type="taskList"] li > div {
  flex: 1;
  min-width: 0;
}

.post-content ul[data-type="taskList"] li > div p:last-child {
  margin-bottom: 0;
}

/* ---------- 指南文档页（飞书式阅读布局） ---------- */

.doc-layout {
  display: grid;
  grid-template-columns: clamp(280px, 22vw, 340px) minmax(0, 1fr);
  gap: clamp(1.5rem, 2.4vw, 2.75rem);
  align-items: start;
  /* 贴齐页面左右边缘，目录因此紧靠页面左侧 */
  width: calc(100% - 2.5rem);
  max-width: none;
  margin: 0 auto;
  padding: clamp(2.5rem, 5vw, 4rem) 0 clamp(4rem, 8vw, 6rem);
}

.doc-toc {
  position: sticky;
  top: 5.5rem;
  padding: 1.4rem 0 1.4rem 1.3rem;
  border-left: 2px solid var(--line);
}

.doc-toc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.doc-toc-title {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1.35;
}

.doc-toc-sub {
  margin: 0;
  color: var(--primary);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.doc-toc-mini {
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.doc-toc-mini:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.doc-toc .toc-list {
  display: grid;
  gap: 0.62rem;
  max-height: 68vh;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
}

.doc-toc .toc-list .toc-list {
  gap: 0.5rem;
  margin-top: 0.62rem;
  padding-left: 1.15rem;
}

.doc-toc .toc-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  margin-right: 0.15rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.62rem;
  cursor: pointer;
  vertical-align: middle;
  transition: transform 0.18s ease;
}

.doc-toc .toc-caret:hover {
  color: var(--primary);
}

.doc-toc .toc-caret::before {
  content: "";
  display: block;
  width: 0.46rem;
  height: 0.46rem;
  margin-top: -0.18rem;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
}

.doc-toc .toc-caret-empty::before {
  border: 0;
}

.doc-toc li.is-collapsed > .toc-caret {
  transform: rotate(-90deg);
}

.doc-toc li.is-collapsed > .toc-list {
  display: none;
}

.doc-toc a {
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.55;
  text-decoration: none;
}

.doc-toc .toc-list .toc-list a {
  font-size: 0.98rem;
}

.doc-toc a:hover {
  color: var(--primary);
}

.doc-toc a[aria-current="true"] {
  color: var(--primary);
  font-weight: 800;
}

/* 目录整体收起后的浮标 */
.doc-toc-fab {
  position: fixed;
  top: 6.5rem;
  left: 0.9rem;
  z-index: 30;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px oklch(0.22 0.04 276 / 0.1);
}

.doc-toc-fab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.doc-layout.is-toc-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.doc-layout.is-toc-collapsed .doc-toc {
  display: none;
}

.doc-layout.is-toc-collapsed .doc-main {
  width: min(820px, 100%);
  margin: 0 auto;
}

/* 锚点跳转时给吸顶头部留出空间 */
main [id^="sec-"] {
  scroll-margin-top: 6rem;
}

html {
  scroll-behavior: smooth;
}

.doc-main {
  min-width: 0;
  /* 目录贴近左侧后正文列会变宽，这里限制阅读宽度 */
  max-width: 1000px;
}

.doc-breadcrumb {
  margin-bottom: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.doc-breadcrumb .back-link {
  margin-bottom: 0;
  color: var(--primary);
  font-weight: 800;
}

.doc-content {
  margin-top: 1.8rem;
}

/* ---------- 响应式 ---------- */

@media (max-width: 1024px) {
  .doc-layout {
    width: calc(100% - 2rem);
  }

  .doc-main {
    max-width: none;
  }
}

@media (max-width: 860px) {
  .doc-layout {
    grid-template-columns: 1fr;
  }

  .doc-toc {
    position: static;
    width: 100%;
    padding: 1rem 1.1rem;
    border-left: none;
    border-top: 2px solid var(--line);
    border-bottom: 2px solid var(--line);
  }

  .doc-toc .toc-list {
    max-height: none;
  }

  .doc-toc-fab {
    top: auto;
    bottom: 1rem;
  }

  .doc-layout.is-toc-collapsed .doc-main,
  .doc-layout.is-toc-empty .doc-main {
    width: 100%;
  }
}

/* ---------- 深色模式 ---------- */

@media (prefers-color-scheme: dark) {
  .content-body {
    --bg: oklch(0.17 0.025 276);
    --surface: oklch(0.23 0.03 276);
    --surface-strong: oklch(0.28 0.04 276);
    --ink: oklch(0.93 0.016 270);
    --muted: oklch(0.76 0.025 270);
    --line: oklch(0.34 0.035 276);
    --white: oklch(0.22 0.03 276);
    --primary: oklch(0.69 0.16 270);
    --primary-deep: oklch(0.82 0.09 270);
    background:
      radial-gradient(circle at 88% 6%, oklch(0.38 0.12 350 / 0.45), transparent 28rem),
      var(--bg);
  }

  .content-body .post-card,
  .content-body .guide-card {
    background: var(--surface);
  }

  .content-body .post-card:hover,
  .content-body .guide-card:hover {
    background: var(--surface-strong);
  }
}

/* 英文标题用拉丁字母，同字号下比中文宽约一倍：单独给出英文尺寸，
   使英文页标题与中文页保持相同的行数观感（中文 1 行 → 英文 1–2 行） */
html[lang="en"] .content-hero h1 {
  max-width: 20em;
  font-size: clamp(1.9rem, 4.2vw, 3.1rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

@media (max-width: 560px) {
  html[lang="en"] .content-hero h1 {
    font-size: clamp(1.6rem, 8vw, 2.4rem);
  }
}

/* ---------- 博客封面图 ---------- */
/* 列表卡片：图片在卡片顶部通栏。卡片自身有 1.7rem 内边距，
   用负外边距抵消后上/左/右贴到卡片边缘，圆角逐面由卡片的 overflow: hidden 裁出。 */
.post-card-cover {
  display: block;
  margin: -1.7rem -1.7rem 0;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: color-mix(in oklch, currentColor 8%, transparent);
}

.post-card-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.post-card:hover .post-card-cover img {
  transform: scale(1.04);
}

/* 文章页：标题与信息条之下的通栏封面 */
.article-cover {
  margin: 1.5rem 0 2.2rem;
  overflow: hidden;
  border-radius: 1.1rem;
  background: color-mix(in oklch, currentColor 8%, transparent);
}

.article-cover img {
  display: block;
  width: 100%;
  max-height: 620px;
  /* 竖图/方图会被裁到 620px 以内，避免一张图占满整屏；横图（约 16:10）不受影响 */
  object-fit: cover;
}

/* 文章没有小标题时目录为空元素，它会被 hidden 隐藏而脱离网格，
   只剩正文一项就会被塞进目录那一窄列 —— 这里让正文独占整行 */
.doc-layout.is-toc-empty {
  grid-template-columns: minmax(0, 1fr);
}

/* 单列时正文成了唯一一列，但 .doc-main 自带 1000px 上限且不居中，
   整块内容会贴在页面左边、右侧空一大片 —— 这里与「用户手动折叠目录」
   （is-toc-collapsed）保持同一种观感：收窄到舒适阅读宽度并居中 */
.doc-layout.is-toc-empty .doc-main {
  width: min(820px, 100%);
  margin: 0 auto;
}

/* ---------- 词库：分类筛选条 + 分类搜索 ---------- */
.vocab-filters-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem 1rem;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto clamp(1.5rem, 3vw, 2.4rem);
}

.vocab-filters {
  display: flex;
  flex: 1 1 26rem;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
}

.vocab-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms ease;
}

.vocab-filter:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.vocab-filter[aria-current="page"] {
  border-color: transparent;
  background: var(--primary);
  color: var(--white);
}

.vocab-filter-count {
  padding: 0 0.4rem;
  border-radius: 999px;
  background: oklch(0.5 0.02 270 / 0.14);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.6;
}

.vocab-filter[aria-current="page"] .vocab-filter-count {
  background: oklch(1 0 0 / 0.28);
  color: var(--white);
}

/* 搜索过滤靠 hidden 属性，必须显式压过 .vocab-filter 的 display */
.vocab-filters [hidden] {
  display: none !important;
}

.vocab-search {
  position: relative;
  flex: 0 1 15rem;
  min-width: 12rem;
}

.vocab-search input {
  width: 100%;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.94rem;
}

.vocab-search input:focus-visible {
  border-color: transparent;
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.vocab-search-empty {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0.95rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .vocab-search {
    flex: 1 1 100%;
  }
}

/* ---------- 词库卡片底部的「作者 + 下载」一行 ---------- */
/* 卡片里多了一个下载链接，外层不能再是 <a>（a 套 a 非法），
   改成 article + 内部正文链接；盒子外观与 hover 抬升仍由 .post-card 提供 */
.vocab-card-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.8rem;
  color: inherit;
  text-decoration: none;
}

.vocab-card-foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.35rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.vocab-author {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vocab-download {
  flex: none;
  padding: 0.28rem 0.9rem;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: var(--white);
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
  transition: background 180ms ease, color 180ms ease;
}

.vocab-download:hover {
  background: var(--primary);
  color: var(--white);
}

/* 词库条目详情页：标题下方的下载按钮 */
.vocab-download-bar {
  margin: 1.2rem 0 0;
}

/* ---------- 打印 / 另存为 PDF ---------- */
/* 「下载 PDF」是发布时生成的静态文件（服务端 pdfkit 生成）；
   这一段是给「用户自己按 Ctrl+P」用的：把导航、页脚、目录、返回链接、按钮全部去掉，
   只留正文，并把多列布局压平。浏览器自带的页眉页脚可在打印对话框里关掉 */
@media print {
  @page {
    margin: 16mm 14mm;
  }

  .site-header,
  .site-footer,
  .lang-switch,
  .doc-toc,
  .doc-toc-fab,
  .doc-breadcrumb,
  .vocab-download-bar,
  .back-link,
  .vocab-filters-wrap,
  .toc-caret {
    display: none !important;
  }

  html,
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .doc-layout,
  .doc-layout.is-toc-empty {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
  }

  .doc-main {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .doc-main h1 {
    margin-bottom: 0.6rem;
    font-size: 19pt;
    line-height: 1.25;
  }

  .post-content,
  .doc-content {
    font-size: 11.5pt;
    line-height: 1.7;
  }

  .post-content h2,
  .doc-content h2 {
    margin-top: 1.4rem;
    font-size: 15pt;
  }

  .post-content h3,
  .doc-content h3 {
    margin-top: 1.1rem;
    font-size: 13pt;
  }

  /* 标题不要孤零零留在页尾；成块的元素尽量不要被切断 */
  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
    page-break-after: avoid;
  }

  p,
  li,
  blockquote,
  table,
  figure {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  img {
    max-width: 100% !important;
    break-inside: avoid;
  }

  /* 打印时不要把网址展开在链接后面，正文里塞满 URL 很难看 */
  a {
    color: inherit;
    text-decoration: none;
  }

  a[href]::after {
    content: "";
  }

  /* 列表页万一被打印：卡片压成单列，去掉投影 */
  .post-grid {
    display: block;
  }

  .post-card {
    margin-bottom: 1rem;
    box-shadow: none;
    break-inside: avoid;
  }

  .vocab-card-foot {
    border-top-color: #ccc;
  }
}
