/* ============================================================
   站点样式表 — 纯 CSS，零依赖
   主题：CSS 变量 + data-theme 切换
   ============================================================ */

:root {
  /* 亮色主题 */
  --bg:            #ffffff;
  --bg-soft:       #f7f8fa;
  --bg-elev:       #ffffff;
  --fg:            #16181d;
  --fg-soft:       #5c6470;
  --fg-mute:       #8b939e;
  --line:          #e6e8ec;
  --brand:         #7c3aed;
  --brand-soft:    #f2ecff;
  --brand-2:       #ec4899;
  --accent:        #16a34a;
  --shadow:        0 1px 2px rgba(16,24,40,.04), 0 8px 24px -12px rgba(16,24,40,.12);
  --shadow-lg:     0 2px 4px rgba(16,24,40,.05), 0 24px 48px -16px rgba(16,24,40,.18);
  --radius:        14px;
  --radius-sm:     9px;
  --maxw:          1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

[data-theme="dark"] {
  --bg:            #0d0f13;
  --bg-soft:       #14171d;
  --bg-elev:       #171b22;
  --fg:            #e8eaee;
  --fg-soft:       #a4abb6;
  --fg-mute:       #6f7784;
  --line:          #252a33;
  --brand:         #a78bfa;
  --brand-soft:    #221a33;
  --brand-2:       #f472b6;
  --accent:        #34d399;
  --shadow:        0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-lg:     0 2px 4px rgba(0,0,0,.5), 0 24px 48px -16px rgba(0,0,0,.7);
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .25s ease, color .25s ease;
}

img, svg, video { max-width: 100%; display: block; }

a {
  color: var(--brand);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color .15s ease;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  margin: 0 0 .6em;
  line-height: 1.25;
  letter-spacing: -.018em;
  font-weight: 700;
}
h1 { font-size: clamp(2rem, 4.4vw, 3.25rem); letter-spacing: -.03em; }
h2 { font-size: clamp(1.4rem, 2.6vw, 2rem); }
h3 { font-size: 1.14rem; }
p  { margin: 0 0 1.1em; }

code, kbd, pre { font-family: var(--mono); font-size: .9em; }
code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .12em .42em;
}
pre {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1.1em 1.2em;
  overflow-x: auto;
  line-height: 1.6;
}
pre code { background: none; border: 0; padding: 0; }

hr { border: 0; border-top: 1px solid var(--line); margin: 3rem 0; }

::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(--maxw);
  margin-inline: auto;
  padding-inline: 24px;
}
.wrap-narrow { max-width: 760px; }

.section { padding-block: clamp(56px, 8vw, 104px); }
.section-soft { background: var(--bg-soft); }

.eyebrow {
  display: inline-block;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: .9rem;
}

.lead {
  font-size: clamp(1.02rem, 1.5vw, 1.16rem);
  color: var(--fg-soft);
  max-width: 62ch;
}

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.site-header.scrolled {
  border-bottom-color: var(--line);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 1.02rem;
  color: var(--fg);
  letter-spacing: -.02em;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: -.03em;
  flex: none;
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav a {
  color: var(--fg-soft);
  font-size: .93rem;
  font-weight: 550;
  padding: 7px 12px;
  border-radius: 8px;
  transition: color .15s, background-color .15s;
}
.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--fg);
  background: var(--bg-soft);
  text-decoration: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-elev);
  color: var(--fg-soft);
  cursor: pointer;
  transition: color .15s, border-color .15s, transform .15s;
  flex: none;
}
.icon-btn:hover { color: var(--fg); border-color: var(--fg-mute); }
.icon-btn:active { transform: scale(.94); }

.nav-toggle { display: none; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: .95rem;
  font-weight: 620;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(47,107,255,.3), 0 8px 20px -10px rgba(47,107,255,.7);
}
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }

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

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding-block: clamp(72px, 11vw, 148px) clamp(60px, 9vw, 118px);
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  /* 用受限椭圆渐变代替 blur，避免被 overflow 裁出硬边 */
  background: radial-gradient(ellipse 78% 88% at 8% 0%, var(--brand-soft), transparent 72%);
  opacity: .9;
  pointer-events: none;
  z-index: 0;
}
.hero > .wrap { position: relative; z-index: 1; }
.hero h1 { max-width: 20ch; }
.hero .lead { margin-bottom: 2rem; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px 5px 9px;
  margin-bottom: 1.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  font-size: .82rem;
  font-weight: 550;
  color: var(--fg-soft);
}
.hero-badge .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  flex: none;
}

/* ---------- 卡片网格 ---------- */
.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 288px), 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  padding: 26px 24px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .22s cubic-bezier(.22,.68,.32,1), box-shadow .22s ease, border-color .22s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--brand) 34%, var(--line));
}
.card h3 { margin-bottom: .45em; }
.card p { color: var(--fg-soft); font-size: .94rem; margin-bottom: 0; }
.card-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand);
  margin-bottom: 1.1rem;
  flex: none;
}

/* ---------- 文章列表 ---------- */
.post-list { display: grid; gap: 0; }
.post-item {
  display: block;
  padding: 24px 4px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition: padding-left .18s ease;
}
.post-item:hover { padding-left: 10px; text-decoration: none; }
.post-item:first-child { border-top: 1px solid var(--line); }
.post-item h3 {
  margin-bottom: .3em;
  font-size: 1.16rem;
  transition: color .15s;
}
.post-item:hover h3 { color: var(--brand); }
.post-item p {
  margin: 0;
  color: var(--fg-soft);
  font-size: .93rem;
  max-width: 70ch;
}
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: .7em;
  font-size: .82rem;
  color: var(--fg-mute);
}
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: .76rem;
  font-weight: 600;
  color: var(--fg-soft);
}

/* ---------- 文章正文 ---------- */
.article { padding-block: clamp(44px, 6vw, 76px); }
.article-head { margin-bottom: 2.4rem; padding-bottom: 1.6rem; border-bottom: 1px solid var(--line); }
.article-head h1 { font-size: clamp(1.75rem, 3.4vw, 2.6rem); margin-bottom: .5rem; }
.article-body { font-size: 1.02rem; }
.article-body h2 { margin-top: 2.2em; font-size: 1.42rem; }
.article-body h3 { margin-top: 1.7em; }
.article-body ul, .article-body ol { padding-left: 1.4em; margin-bottom: 1.2em; }
.article-body li { margin-bottom: .45em; }
.article-body blockquote {
  margin: 1.6em 0;
  padding: .2em 0 .2em 1.2em;
  border-left: 3px solid var(--brand);
  color: var(--fg-soft);
}
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: .93rem;
}
.article-body th, .article-body td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.article-body th { color: var(--fg-soft); font-weight: 650; font-size: .85rem; }

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 44px 52px;
  background: var(--bg-soft);
  font-size: .9rem;
  color: var(--fg-soft);
}
.footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 36px 56px;
  justify-content: space-between;
}
.footer-brand { max-width: 30ch; }
.footer-brand p { margin: .8em 0 0; color: var(--fg-mute); font-size: .87rem; }
.footer-links { display: flex; gap: 56px; flex-wrap: wrap; }
.footer-col h4 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-mute);
  margin-bottom: 1em;
  font-weight: 700;
}
.footer-col a {
  display: block;
  color: var(--fg-soft);
  padding: 4px 0;
  font-size: .9rem;
}
.footer-bottom {
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  justify-content: space-between;
  color: var(--fg-mute);
  font-size: .84rem;
}

/* ---------- 进入动画 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .6s cubic-bezier(.22,.68,.32,1), transform .6s cubic-bezier(.22,.68,.32,1);
}
.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  body { font-size: 16px; }
  .nav {
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px 16px 18px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 11px 12px; font-size: .98rem; }
  /* 移动端：导航收进抽屉，汉堡与主题按钮常驻顶栏右侧 */
  .nav-toggle { display: grid; margin-left: auto; }
  .icon-btn.theme-toggle { margin-left: 6px; }
  .site-header .wrap { gap: 10px; }
  .footer-grid { flex-direction: column; gap: 32px; }
  .footer-links { gap: 36px; }
}

/* ==========================================================================
   列表工具条：搜索 + 页码
   用在博客列表（.post-list）与作品列表（.grid），由 main.js 第 6 节动态插入
   ========================================================================== */

.list-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .9rem;
  margin: 0 0 1.5rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex: 1 1 240px;
  max-width: 360px;
  padding: .55rem .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--fg-mute);
  transition: border-color .18s, box-shadow .18s, color .18s;
}
.search-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  color: var(--brand);
}
.search-box svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: .92rem;
}
.search-box input::placeholder { color: var(--fg-mute); }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }

.list-count {
  color: var(--fg-mute);
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
}

.list-empty {
  padding: 2.4rem 0;
  color: var(--fg-mute);
  font-size: .95rem;
}

.pager {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: 2.2rem;
}
.pager button {
  min-width: 40px;
  height: 38px;
  padding: 0 .85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--fg-soft);
  font: inherit;
  font-size: .88rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color .16s, color .16s, background .16s;
}
.pager button:hover:not(:disabled):not([aria-current]) {
  border-color: var(--brand);
  color: var(--brand);
}
.pager button[aria-current="page"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
.pager button:disabled { opacity: .4; cursor: default; }
.pager-gap {
  align-self: center;
  padding: 0 .25rem;
  color: var(--fg-mute);
}

/* 分页藏起来的元素：不能用 [hidden]，.card 自己的 display 会盖掉 UA 规则 */
.is-hidden { display: none !important; }

/* 翻页后 scrollIntoView 要给吸顶顶栏留出位置 */
[data-list] { scroll-margin-top: 92px; }

@media (max-width: 820px) {
  .search-box { max-width: none; flex-basis: 100%; }
  .pager button { min-width: 36px; height: 36px; padding: 0 .6rem; }
}
