/* ==========================================================
   jiusigis.com 全站样式（唯一样式表；构建器引用时带内容哈希）
   注意：线上 CSP 不允许 style 属性，所有样式都写在这里。
   ========================================================== */

:root {
  --brand: #176f4a;
  --brand-deep: #0f5f3f;
  --brand-light: #1f8a5f;
  --brand-soft: rgba(23, 111, 74, 0.1);

  --ink: #1b2733;
  --ink-muted: #5a6a7a;
  --line: #dbe3ec;
  --surface: #ffffff;
  --surface-tint: #f4f7fa;
  --code-bg: #f6f8f7;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC",
    "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, SFMono-Regular, Menlo, "Microsoft YaHei",
    monospace;

  --wrap: 1120px;
  --prose: 46rem;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(11, 37, 64, 0.06), 0 2px 8px rgba(11, 37, 64, 0.06);
  --shadow-md: 0 6px 24px rgba(11, 37, 64, 0.1);
}

/* ---------- 基础 ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}
main { flex: 1 0 auto; }
h1, h2, h3, h4, h5, h6 { line-height: 1.35; }
img { max-width: 100%; height: auto; }
a { color: var(--brand-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--brand-light); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
@media (max-width: 560px) { .wrap { padding: 0 16px; } }
/* 只设上下，左右留给 .wrap 的页边距（两个 class 常一起用） */
.section { padding-top: 36px; padding-bottom: 56px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  padding: 10px 16px;
  background: var(--brand-deep);
  color: #fff;
}
.skip-link:focus { left: 12px; top: 12px; text-decoration: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- 页头 ---------- */

.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  min-height: 60px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.brand:hover { color: var(--brand-deep); text-decoration: none; }
.brand__mark { display: block; width: 34px; height: 34px; border-radius: 9px; }
.brand__text { display: grid; line-height: 1.15; }
.brand__name { font-size: 16px; letter-spacing: 0.4px; }
.brand__domain { font-size: 11px; font-weight: 500; color: var(--ink-muted); }

.site-nav { display: flex; gap: 2px; margin-left: auto; }
.site-nav a { padding: 7px 12px; border-radius: 8px; font-size: 15px; color: var(--ink); }
.site-nav a:hover { background: var(--surface-tint); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--brand-deep); font-weight: 700; }
.site-header__cta { flex: 0 0 auto; }

@media (max-width: 720px) {
  .site-header__inner { min-height: auto; padding-top: 12px; padding-bottom: 12px; }
  .site-nav { margin-left: 0; width: 100%; order: 3; }
  .site-header__cta { margin-left: auto; }
}
@media (max-width: 480px) { .site-nav a { padding: 6px 9px; } }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-deep); }
.btn--ghost { border-color: var(--line); color: var(--ink); background: var(--surface); }
.btn--ghost:hover { background: var(--surface-tint); }

/* ---------- 首页（门户式：一屏文案 + 入口卡片） / 子页头 ---------- */

.hero,
.page-head {
  background:
    radial-gradient(820px 320px at 88% -12%, rgba(23, 111, 74, 0.1), transparent 62%),
    var(--surface-tint);
  border-bottom: 1px solid var(--line);
}

.hero { position: relative; overflow: hidden; }
.hero__inner { padding-top: 52px; padding-bottom: 56px; }
@media (min-width: 900px) {
  .hero__inner {
    min-height: min(64vh, calc(100vh - 60px - 48px));
    display: flex;
    align-items: center;
  }
}

.hero__grid { width: 100%; display: grid; gap: 36px; }
@media (min-width: 900px) {
  .hero__grid {
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
    gap: 48px;
    align-items: center;
  }
}

.hero__kicker { margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: 0.6px; color: var(--brand-deep); }
.hero__title {
  margin: 0 0 20px;
  max-width: 16em;
  font-size: clamp(26px, 3.1vw, 38px);
  font-weight: 700;
  letter-spacing: -0.3px;
}
.hero__desc { margin: 0 0 14px; max-width: 34em; font-size: 16px; color: var(--ink-muted); }
.hero__desc:last-of-type { margin-bottom: 0; }
.hero__desc strong { color: var(--ink); font-weight: 600; }

.hero__org { margin: 22px 0 0; font-size: 14px; color: var(--ink-muted); }
.hero__org a { font-weight: 600; color: var(--brand-deep); }
.hero__org a:hover { text-decoration: underline; }
.hero__org-sep { margin: 0 6px; color: #ccdcd2; }
.hero__org-url { font-weight: 500; }

.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 0; }

.entry-stack { display: grid; gap: 14px; }
.entry-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 104px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.entry-card:hover {
  border-color: var(--brand-light);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.entry-card__icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--brand-soft);
  color: var(--brand-deep);
}
.entry-card__body { display: grid; gap: 3px; min-width: 0; }
.entry-card__title { font-size: 17px; font-weight: 700; }
.entry-card__desc { font-size: 14px; color: var(--ink-muted); }
.entry-card__go { margin-left: auto; flex: 0 0 auto; color: var(--ink-muted); }
.entry-card:hover .entry-card__go { color: var(--brand-deep); }

.page-head { padding: 40px 0 28px; }
.page-head__title { margin: 0 0 6px; font-size: clamp(24px, 2.8vw, 32px); }
.page-head__desc { margin: 0; font-size: 15px; color: var(--ink-muted); }

.empty {
  margin: 0;
  padding: 28px 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-tint);
  color: var(--ink-muted);
  text-align: center;
}

/* ---------- 文章列表 ---------- */

.post-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.post-item__link {
  display: grid;
  gap: 6px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.post-item__link:hover { border-color: var(--brand-light); box-shadow: var(--shadow-md); text-decoration: none; }
.post-item__meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-muted); }
.post-item__title { font-size: 18px; font-weight: 700; line-height: 1.45; }
.post-item__summary { font-size: 15px; color: var(--ink-muted); }
.post-item__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.tag {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: 12.5px;
  line-height: 1.7;
}
a.tag:hover { background: var(--brand); color: #fff; text-decoration: none; }
.badge {
  padding: 0 7px;
  border-radius: 6px;
  background: #fff4d6;
  color: #7a5200;
  font-size: 12px;
}
.badge--pin {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-height: 96px;
  margin: 0 0 18px;
  overflow-y: auto;
}
.chip {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand); color: #fff; }
.chip__count { margin-left: 5px; font-size: 12px; opacity: 0.75; }
#tag-empty { margin-bottom: 18px; }

/* ---------- 文章页布局（目录在正文上方，只列二级标题） ---------- */

.post { max-width: var(--prose); margin: 0 auto; }

.crumb { display: flex; gap: 8px; margin: 0 0 14px; font-size: 13px; color: var(--ink-muted); }
.post-header { margin-bottom: 28px; }
.post-title { margin: 0 0 10px; font-size: clamp(24px, 3vw, 32px); }
.post-subtitle { margin: 0 0 12px; font-size: 17px; color: var(--ink-muted); }
.post-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; font-size: 14px; color: var(--ink-muted); }
.post-meta .dot { color: var(--line); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.draft-banner {
  margin: 0 0 14px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: #fff4d6;
  color: #7a5200;
  font-size: 14px;
}

.post-toc { margin: 0 0 28px; font-size: 14px; }
.post-toc details {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-tint);
}
.post-toc summary { font-weight: 700; color: var(--ink-muted); cursor: pointer; }
.post-toc ol { margin: 8px 0 0; padding: 0; list-style: none; }
/* 条目多时宽屏竖排分两栏（先左后右），一屏看完 */
@media (min-width: 640px) {
  .post-toc ol { columns: 2; column-gap: 20px; }
  .post-toc li { break-inside: avoid; }
}
.post-toc li { margin: 0; }
.post-toc a {
  display: block;
  padding: 3px 0 3px 10px;
  border-left: 2px solid transparent;
  color: var(--ink);
  line-height: 1.5;
}
.post-toc a:hover { border-left-color: var(--brand); color: var(--brand); text-decoration: none; }

.post-footer { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.post-license { margin: 0 0 20px; font-size: 13.5px; color: var(--ink-muted); word-break: break-all; }
.post-nav { display: grid; gap: 12px; }
@media (min-width: 640px) { .post-nav { grid-template-columns: 1fr 1fr; } }
.post-nav a {
  display: grid;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-weight: 600;
}
.post-nav a:hover { border-color: var(--brand-light); text-decoration: none; }
.post-nav__label { font-size: 12.5px; font-weight: 400; color: var(--ink-muted); }
.post-nav__newer { text-align: right; }
@media (min-width: 640px) { .post-nav__newer:only-child { grid-column: 2; } }

/* ---------- 正文排版 ---------- */

.prose { overflow-wrap: break-word; }
.prose--page { max-width: var(--prose); }
.prose > :first-child { margin-top: 0; }
.prose > h2:first-child { padding-top: 0; border-top: 0; }
.prose p { margin: 0 0 1em; }
.prose a { text-decoration: underline; text-decoration-color: rgba(15, 95, 63, 0.35); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: currentColor; }

.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 { position: relative; scroll-margin-top: 16px; }
.prose h2 { margin: 2.2em 0 0.8em; padding-top: 0.9em; border-top: 1px solid var(--line); font-size: 21px; }
.prose h3 { margin: 1.8em 0 0.6em; font-size: 18px; }
.prose h4 { margin: 1.5em 0 0.5em; font-size: 16px; }
.prose h5,
.prose h6 { margin: 1.3em 0 0.5em; font-size: 15px; color: var(--ink-muted); }
.prose .anchor {
  margin-left: 0.4em;
  color: var(--ink-muted);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.prose :is(h2, h3, h4, h5, h6):hover .anchor,
.prose .anchor:focus { opacity: 1; }

.prose ul,
.prose ol { margin: 0 0 1em; padding-left: 1.5em; }
.prose li { margin: 0.3em 0; }
.prose li > p { margin: 0.4em 0; }
.prose li > ul,
.prose li > ol { margin: 0.3em 0; }
.prose .task-list { padding-left: 0.4em; list-style: none; }
.prose .task-box { display: inline-block; width: 1.4em; color: var(--brand); }

.prose blockquote {
  margin: 0 0 1.2em;
  padding: 12px 16px;
  border-left: 3px solid var(--brand);
  background: var(--surface-tint);
  color: #34424f;
}
.prose blockquote > :last-child { margin-bottom: 0; }

.prose hr { margin: 2.2em 0; border: 0; border-top: 1px solid var(--line); }
/* 分隔线紧跟二级标题时只留一条线 */
.prose hr + h2 { margin-top: 0; padding-top: 0; border-top: 0; }
.prose del { color: var(--ink-muted); }

.prose code { font-family: var(--font-mono); font-size: 0.9em; }
.prose :not(pre) > code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-tint);
  overflow-wrap: anywhere;
}
.prose pre {
  position: relative;
  margin: 0 0 1.2em;
  padding: 14px 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--code-bg);
  font-size: 13.5px;
  line-height: 1.6;
  tab-size: 4;
}
.prose pre[data-lang] { padding-top: 26px; }
.prose pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 5px;
  right: 10px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  color: var(--ink-muted);
}
.prose pre code { color: var(--ink); }

.prose .table-wrap { margin: 0 0 1.2em; overflow-x: auto; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; }
.prose th,
.prose td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--surface-tint); font-weight: 700; white-space: nowrap; }
.prose .align-center { text-align: center; }
.prose .align-right { text-align: right; }

/* ---------- 阶段时间线：「## 五个阶段一览」下的表格自动竖排 ---------- */

.prose h2#五个阶段一览 + .table-wrap table,
.prose h2#五个阶段一览 + .table-wrap tbody,
.prose h2#五个阶段一览 + .table-wrap tr,
.prose h2#五个阶段一览 + .table-wrap th,
.prose h2#五个阶段一览 + .table-wrap td { display: block; width: 100%; }
.prose h2#五个阶段一览 + .table-wrap thead { display: none; }
.prose h2#五个阶段一览 + .table-wrap tbody tr {
  position: relative;
  margin: 0 0 16px;
  padding: 12px 16px 12px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-tint);
}
/* 时间线：卡片左侧留 26px 放竖线与节点 */
.prose h2#五个阶段一览 + .table-wrap tbody { position: relative; padding-left: 26px; }
.prose h2#五个阶段一览 + .table-wrap tbody::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 14px;
  bottom: 26px;
  width: 2px;
  background: var(--line);
}
.prose h2#五个阶段一览 + .table-wrap tbody tr::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--surface);
}
.prose h2#五个阶段一览 + .table-wrap td { border: 0; padding: 0; }
.prose h2#五个阶段一览 + .table-wrap td:nth-child(1) {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 15.5px;
}
.prose h2#五个阶段一览 + .table-wrap td:nth-child(2) {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--ink-muted);
}
.prose h2#五个阶段一览 + .table-wrap td:nth-child(3) { margin: 0 0 4px; }
.prose h2#五个阶段一览 + .table-wrap td:nth-child(4) { margin: 0 0 6px; color: var(--ink-muted); }
.prose h2#五个阶段一览 + .table-wrap td:nth-child(5) { font-size: 14px; }

.prose img { border-radius: var(--radius); }
.prose figure { margin: 0 0 1.4em; text-align: center; }
.prose figure img { display: block; margin: 0 auto; border: 1px solid var(--line); background: var(--surface-tint); }
.prose figcaption { margin-top: 8px; font-size: 13.5px; color: var(--ink-muted); }

/* ---------- 代码高亮（token 由 tools/lib/highlight.mjs 生成） ---------- */

.tok-c { color: #6b7b74; font-style: italic; } /* 注释 */
.tok-s { color: #9a5b13; }                     /* 字符串 */
.tok-n { color: #17607a; }                     /* 数字 */
.tok-k { color: #166b47; font-weight: 600; }   /* 关键字 */
.tok-f { color: #1c4f8a; }                     /* 函数 / 命令 */
.tok-p { color: #6b3f8f; }                     /* 属性 / 键 */
.tok-t { color: #0b6674; }                     /* 类型 / 标签 */
.tok-a { color: #8a5600; }                     /* 参数 / HTML 属性 */
.tok-m { color: #7a4a6a; }                     /* 元信息 */
.tok-v { color: #a0365e; }                     /* 变量 */
.tok-i { display: inline-block; min-width: 100%; background: #e6f6ec; color: #135c33; }
.tok-d { display: inline-block; min-width: 100%; background: #fdecec; color: #8f1d1d; }

/* ---------- 页脚 ---------- */

.site-footer { border-top: 1px solid var(--line); background: var(--surface); }
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  min-height: 52px;
  padding-top: 14px;
  padding-bottom: 14px;
  font-size: 13px;
  color: var(--ink-muted);
}
.site-footer__inner p { margin: 0; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.site-footer__links a { color: var(--ink-muted); }
.site-footer__links a:hover { color: var(--brand-deep); }

/* ---------- 打印 ---------- */

@media print {
  .site-header, .site-footer, .post-toc, .post-nav, .skip-link, .prose .anchor { display: none !important; }
  .prose pre { white-space: pre-wrap; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: var(--ink-muted); }
}
