/* ==========================================================================
   清梦徐徐 · 站点样式
   设计基调：暖白底 + 靛蓝主色，克制的圆角与留白，深色模式自动跟随。
   ========================================================================== */

:root {
  --bg: #fbfaf9;
  --bg-soft: #f3f1ee;
  --bg-elev: #ffffff;
  --text: #191819;
  --text-soft: #56545e;
  --text-mute: #8b8894;
  --line: #e8e5e0;
  --line-soft: #f0eeea;
  --brand: #4f46e5;
  --brand-soft: #eef0ff;
  --brand-2: #0d9488;
  --code-bg: #1d1c22;
  --code-text: #e6e4f0;
  --shadow-sm: 0 1px 2px rgba(24, 22, 20, .05), 0 1px 3px rgba(24, 22, 20, .04);
  --shadow-md: 0 6px 16px -6px rgba(24, 22, 20, .12), 0 2px 6px rgba(24, 22, 20, .05);
  --shadow-lg: 0 18px 40px -18px rgba(24, 22, 20, .22), 0 4px 12px rgba(24, 22, 20, .06);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --wrap: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC",
    Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #0c0c10;
  --bg-soft: #14141a;
  --bg-elev: #16161d;
  --text: #eceaea;
  --text-soft: #a8a5b3;
  --text-mute: #7b7887;
  --line: #26262f;
  --line-soft: #1d1d25;
  --brand: #8b85ff;
  --brand-soft: #1e1b3a;
  --brand-2: #2dd4bf;
  --code-bg: #101015;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 20px -8px rgba(0, 0, 0, .6);
  --shadow-lg: 0 22px 48px -22px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .25s ease, color .25s ease;
}

img { max-width: 100%; height: auto; display: block; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--brand); color: #fff; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 22px;
}

/* ---------------------------------------------------------------- 顶部导航 */

.progress-bar {
  position: fixed;
  inset: 0 auto auto 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  z-index: 100;
  transition: width .1s linear;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color .25s ease, background-color .25s ease;
}

.site-header.is-stuck {
  border-bottom-color: var(--line);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 66px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .01em;
  font-size: 17px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  display: block;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 14.5px;
  color: var(--text-soft);
  transition: color .18s ease, background-color .18s ease;
}

.nav-links a:hover { color: var(--text); background: var(--bg-soft); }

.nav-links a[aria-current="page"] {
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 600;
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text-soft);
  cursor: pointer;
  padding: 0;
  transition: color .18s ease, border-color .18s ease, transform .18s ease;
}

.icon-btn:hover { color: var(--brand); border-color: var(--brand); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 17px; height: 17px; }

.nav-toggle { display: none; }

html[data-theme="light"] .icon-moon,
html[data-theme="dark"] .icon-sun { display: none; }

/* ------------------------------------------------------------------- 首页 */

.hero {
  position: relative;
  overflow: hidden;
  padding: 78px 0 66px;
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .34;
  pointer-events: none;
}

.hero::before {
  width: 420px; height: 420px;
  background: var(--brand);
  top: -170px; right: -80px;
}

.hero::after {
  width: 320px; height: 320px;
  background: var(--brand-2);
  bottom: -180px; left: -110px;
  opacity: .22;
}

.hero-inner { position: relative; z-index: 1; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  font-size: 13px;
  color: var(--text-soft);
  box-shadow: var(--shadow-sm);
}

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px color-mix(in srgb, #22c55e 22%, transparent);
}

.hero h1 {
  margin: 22px 0 0;
  font-size: clamp(34px, 6.2vw, 58px);
  line-height: 1.16;
  letter-spacing: -.022em;
  font-weight: 800;
}

.hero h1 .grad {
  background: linear-gradient(100deg, var(--brand), var(--brand-2) 82%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-lead {
  margin: 20px 0 0;
  max-width: 46ch;
  font-size: clamp(15.5px, 1.6vw, 18px);
  color: var(--text-soft);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease,
    border-color .18s ease, color .18s ease;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.btn-ghost {
  background: var(--bg-elev);
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-2px); }

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 34px;
  margin-top: 48px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.stat b {
  display: block;
  font-size: 24px;
  letter-spacing: -.01em;
  font-weight: 750;
}

.stat span { font-size: 13.5px; color: var(--text-mute); }

/* -------------------------------------------------------------- 通用区块 */

.section { padding: 62px 0; }
.section-tight { padding: 44px 0; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(22px, 2.6vw, 28px);
  letter-spacing: -.015em;
  font-weight: 750;
}

.section-head p {
  margin: 7px 0 0;
  color: var(--text-mute);
  font-size: 14.5px;
}

.more-link {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--brand);
  white-space: nowrap;
}
.more-link:hover { text-decoration: underline; text-underline-offset: 4px; }

/* --------------------------------------------------------------- 文章卡片 */

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

.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
}

.post-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
  letter-spacing: -.008em;
  font-weight: 700;
}

.post-card h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.post-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.68;
  flex: 1;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-mute);
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.6;
}

.tag-brand { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

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

.archive { list-style: none; margin: 0; padding: 0; }

.archive li {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 15px 4px;
  border-bottom: 1px solid var(--line-soft);
}

.archive li:first-child { border-top: 1px solid var(--line-soft); }

.archive time {
  flex: none;
  width: 96px;
  font-size: 13.5px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}

.archive a {
  font-size: 15.5px;
  font-weight: 550;
  transition: color .16s ease;
}

.archive a:hover { color: var(--brand); }

.archive .archive-tags { margin-left: auto; display: flex; gap: 6px; }

@media (max-width: 620px) {
  .archive li { flex-wrap: wrap; gap: 6px 12px; }
  .archive time { width: auto; }
  .archive .archive-tags { display: none; }
}

/* ------------------------------------------------------------- 关于 / 卡片 */

.about-grid {
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  gap: 34px;
  align-items: start;
}

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

.card {
  padding: 26px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
}

.card h3 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
}

.stack-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }

.kv { margin: 0; padding: 0; list-style: none; font-size: 14.5px; }
.kv li { display: flex; gap: 12px; padding: 7px 0; color: var(--text-soft); }
.kv b { flex: none; width: 62px; color: var(--text); font-weight: 600; }

/* --------------------------------------------------------------- 文章正文 */

.post-header { padding: 54px 0 26px; border-bottom: 1px solid var(--line); }

.crumb { font-size: 14px; color: var(--text-mute); margin-bottom: 16px; }
.crumb a:hover { color: var(--brand); }

.post-header h1 {
  margin: 0;
  font-size: clamp(27px, 4.4vw, 40px);
  line-height: 1.25;
  letter-spacing: -.02em;
  font-weight: 780;
}

.post-header .post-meta { margin-top: 18px; font-size: 14px; }

.post-body {
  max-width: 736px;
  margin: 0 auto;
  padding: 44px 0 30px;
  font-size: 16.5px;
  line-height: 1.82;
  color: #26252a;
}

html[data-theme="dark"] .post-body { color: #d9d7e2; }

.post-body h2 {
  margin: 2.2em 0 .7em;
  font-size: 23px;
  line-height: 1.4;
  letter-spacing: -.014em;
  font-weight: 730;
  scroll-margin-top: 90px;
}

.post-body h3 {
  margin: 1.8em 0 .6em;
  font-size: 18.5px;
  font-weight: 700;
  scroll-margin-top: 90px;
}

.post-body p { margin: 0 0 1.15em; }

.post-body a {
  color: var(--brand);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

.post-body ul, .post-body ol { margin: 0 0 1.2em; padding-left: 1.35em; }
.post-body li { margin: .35em 0; }
.post-body li::marker { color: var(--brand); }

.post-body blockquote {
  margin: 1.5em 0;
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--brand);
  color: var(--text-soft);
  font-size: 15.5px;
}

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

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

.post-body table {
  width: 100%;
  margin: 1.6em 0;
  border-collapse: collapse;
  font-size: 14.5px;
}

.post-body th,
.post-body td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
}

.post-body th {
  font-weight: 650;
  color: var(--text);
  background: var(--bg-soft);
  border-bottom-color: var(--line);
  white-space: nowrap;
}

.post-body tbody tr:hover { background: var(--bg-soft); }

.post-body td:first-child { color: var(--text-soft); }

.post-body code {
  font-family: var(--mono);
  font-size: .885em;
  padding: .16em .42em;
  border-radius: 5px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  color: var(--text);
}

.post-body pre {
  position: relative;
  margin: 1.5em 0;
  padding: 18px 20px;
  overflow-x: auto;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  line-height: 1.68;
}

.post-body pre code {
  background: none;
  border: 0;
  padding: 0;
  color: var(--code-text);
  font-size: 13.6px;
}

.copy-btn {
  position: absolute;
  top: 9px;
  right: 9px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 7px;
  background: rgba(255, 255, 255, .07);
  color: #cfcde0;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  opacity: 0;
  transition: opacity .2s ease, background-color .2s ease;
}

pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { background: rgba(255, 255, 255, .16); }

/* 代码高亮（构建期生成的 span） */
.tok-kw { color: #c792ea; }
.tok-str { color: #a5e8a1; }
.tok-num { color: #f7a06b; }
.tok-com { color: #6f6d80; font-style: italic; }
.tok-fn { color: #7cc7ff; }
.tok-ty { color: #ffd479; }

.post-footer {
  max-width: 736px;
  margin: 0 auto;
  padding: 26px 0 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
}

.post-nav {
  max-width: 736px;
  margin: 0 auto;
  padding-bottom: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.post-nav a {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  transition: border-color .18s ease, transform .18s ease;
}

.post-nav a:hover { border-color: var(--brand); transform: translateY(-2px); }
.post-nav span { display: block; font-size: 12.5px; color: var(--text-mute); }
.post-nav b { font-size: 14.5px; font-weight: 600; }
.post-nav .next { text-align: right; }

@media (max-width: 620px) {
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .next { text-align: left; }
}

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

.site-footer {
  margin-top: 40px;
  padding: 40px 0 34px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 22px;
}

.footer-brand b { font-size: 16px; }
.footer-brand p {
  margin: 8px 0 0;
  max-width: 34ch;
  font-size: 14px;
  color: var(--text-mute);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14.5px;
}

.footer-links a { color: var(--text-soft); }
.footer-links a:hover { color: var(--brand); }

.footer-bottom {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  font-size: 13.5px;
  color: var(--text-mute);
}

/* 备案号：必须可点击跳转工信部 */
.beian {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-mute);
}

.beian:hover { color: var(--brand); }
.beian svg { width: 13px; height: 13px; flex: none; opacity: .8; }

/* ------------------------------------------------------------------- 404 */

.notfound {
  min-height: 62vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 70px 0;
}

.notfound .code {
  font-size: clamp(70px, 16vw, 130px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.04em;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* --------------------------------------------------------------- 动效/响应 */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .5s ease, transform .5s cubic-bezier(.2, .7, .3, 1);
}

.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

@media (max-width: 760px) {
  .nav-toggle { display: grid; }

  .nav-links {
    position: absolute;
    top: 66px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px 16px 16px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    display: none;
  }

  .nav-links.is-open { display: flex; }
  .nav-links a { padding: 11px 14px; border-radius: 10px; }

  .hero { padding: 52px 0 44px; }
  .hero-stats { gap: 24px 30px; }
  .section { padding: 46px 0; }
  .post-body { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
