/* ============ 变量与主题 ============ */
:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --card: rgba(22, 27, 34, 0.7);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent-1: #58a6ff;
  --accent-2: #bc8cff;
  --accent-3: #3fb950;
  --gradient: linear-gradient(135deg, #58a6ff, #bc8cff);
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --maxw: 860px;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-soft: #ffffff;
  --card: rgba(255, 255, 255, 0.75);
  --border: rgba(0, 0, 0, 0.08);
  --text: #1f2328;
  --text-dim: #57606a;
  --accent-1: #0969da;
  --accent-2: #8250df;
  --accent-3: #1a7f37;
  --gradient: linear-gradient(135deg, #0969da, #8250df);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
}

a { color: var(--accent-1); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ============ 星空粒子背景 ============ */
.stars {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* ============ 头部导航 ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
}
.logo:hover { text-decoration: none; }

.logo-mark { color: var(--accent-2); }

.site-nav { display: flex; gap: 6px; align-items: center; }

.site-nav a {
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  transition: color 0.2s, background 0.2s;
}
.site-nav a:hover { color: var(--text); background: var(--card); text-decoration: none; }
.site-nav a.active { color: var(--accent-1); background: var(--card); }

.theme-toggle {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.theme-toggle:hover { transform: scale(1.08); }

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

/* ============ 主页 Hero ============ */
.hero {
  padding: 80px 0 40px;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--accent-1);
  border: 1px solid var(--border);
  background: var(--card);
  padding: 6px 16px;
  border-radius: 999px;
  margin-bottom: 24px;
  backdrop-filter: blur(8px);
}

.hero-title {
  font-size: clamp(2.2rem, 6vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
  line-height: 1.2;
}

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin-bottom: 32px;
}

.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 20px rgba(88, 166, 255, 0.25);
}
.btn-primary:hover { box-shadow: 0 6px 28px rgba(88, 166, 255, 0.4); }

.btn-ghost {
  color: var(--text);
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(8px);
}
.btn-ghost:hover { background: var(--bg-soft); }

/* ============ 通用区块 ============ */
.section { padding: 32px 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-head h2 { font-size: 1.4rem; font-weight: 700; }
.more-link { color: var(--text-dim); font-size: 0.9rem; }
.more-link:hover { color: var(--accent-1); }

/* ============ 文章卡片 ============ */
.post-list { display: flex; flex-direction: column; gap: 14px; }

.post-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  backdrop-filter: blur(8px);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.post-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  border-color: rgba(88, 166, 255, 0.4);
  box-shadow: var(--shadow);
}

.post-date { color: var(--text-dim); font-size: 0.8rem; }
.post-title { color: var(--text); font-size: 1.15rem; margin: 4px 0 8px; }
.post-card:hover .post-title { color: var(--accent-1); }
.post-summary { color: var(--text-dim); font-size: 0.92rem; }

/* ============ 开发组卡片 ============ */
.dev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }

.dev-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(8px);
  transition: transform 0.2s ease, border-color 0.2s;
  will-change: transform;
}
.dev-card:hover { border-color: rgba(188, 140, 255, 0.4); }
.dev-card h3 { font-size: 1.05rem; margin-bottom: 10px; }
.dev-card p { color: var(--text-dim); font-size: 0.9rem; }

/* ============ 页面头 ============ */
.page-head { padding: 48px 0 24px; }
.page-head h1 { font-size: 2rem; font-weight: 800; }

/* ============ 单篇文章 ============ */
.post { padding: 32px 0; }
.post-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 12px; line-height: 1.3; }
.post-meta { display: flex; align-items: center; gap: 14px; color: var(--text-dim); font-size: 0.88rem; margin-bottom: 24px; }
.post-tags { display: flex; gap: 8px; }
.tag { color: var(--accent-2); border: 1px solid var(--border); padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; }

.post-content { font-size: 1.02rem; }
.post-content h2 { font-size: 1.5rem; margin: 28px 0 14px; }
.post-content h3 { font-size: 1.25rem; margin: 24px 0 12px; }
.post-content p { margin: 14px 0; }
.post-content a { text-decoration: underline; text-underline-offset: 3px; }
.post-content ul, .post-content ol { margin: 14px 0; padding-left: 28px; }
.post-content li { margin: 6px 0; }
.post-content code {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}
.post-content pre {
  background: #010409;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
}
.post-content pre code { background: none; border: none; padding: 0; }
.post-content blockquote {
  border-left: 3px solid var(--accent-2);
  padding: 4px 0 4px 16px;
  margin: 16px 0;
  color: var(--text-dim);
  background: var(--card);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.post-content img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.post-content table { border-collapse: collapse; width: 100%; margin: 16px 0; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.post-content th { background: var(--bg-soft); }

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

/* ============ 分页 ============ */
.pagination { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 32px; color: var(--text-dim); }
.pagination a { color: var(--accent-1); }

/* ============ 页脚 ============ */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 28px 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.footer-links a { margin-left: 16px; color: var(--text-dim); }
.footer-links a:hover { color: var(--text); }

/* ============ 滚动渐入动画 ============ */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ============ 响应式 ============ */
@media (max-width: 640px) {
  .hero { padding: 48px 0 24px; }
  .hero-title { font-size: 2rem; }
  .header-inner { gap: 8px; }
  .site-nav {
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
    order: 3;
    width: 100%;
    margin-top: 6px;
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { padding: 6px 10px; font-size: 0.85rem; white-space: nowrap; }
  .site-header .header-inner { flex-wrap: wrap; height: auto; padding: 8px 16px; }
  .footer-inner { flex-direction: column; text-align: center; }
  .post-nav { flex-direction: column; }
}

/* ============ 阅读进度条 ============ */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--gradient);
  z-index: 200;
  border-radius: 0 2px 2px 0;
  pointer-events: none;
}

/* ============ 回到顶部 ============ */
.to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(8px);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s, background 0.2s;
  z-index: 999;
  pointer-events: none;
}
.to-top.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.to-top:hover { background: var(--bg-soft); color: var(--accent-1); }

/* ============ 卡片 spotlight(鼠标光晕) ============ */
.dev-card, .post-card {
  position: relative;
  overflow: hidden;
}
.dev-card::before, .post-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), rgba(88, 166, 255, 0.08), transparent 40%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.dev-card:hover::before, .post-card:hover::before { opacity: 1; }

/* ============ View Transitions ============ */
@view-transition {
  navigation: auto;
}
::view-transition-old(root) {
  animation: vt-out 0.25s ease;
}
::view-transition-new(root) {
  animation: vt-in 0.25s ease;
}
@keyframes vt-out {
  to { opacity: 0; transform: scale(0.98); }
}
@keyframes vt-in {
  from { opacity: 0; transform: scale(1.02); }
}

/* ============ 搜索 ============ */
.search-toggle {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
  margin-right: 6px;
}
.search-toggle:hover { transform: scale(1.08); background: var(--bg-soft); }

.search-panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 300;
  padding: 12vh 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.search-box {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-dim);
  box-shadow: var(--shadow);
}
.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1.05rem;
}
.search-box input::placeholder { color: var(--text-dim); }
.search-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.search-close:hover { color: var(--text); }

.search-results {
  width: 100%;
  max-width: 560px;
  margin-top: 16px;
  overflow-y: auto;
  max-height: 60vh;
}
.search-list { display: flex; flex-direction: column; gap: 8px; }
.search-item {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  transition: border-color 0.2s, background 0.2s;
}
.search-item:hover {
  border-color: rgba(88, 166, 255, 0.4);
  background: var(--bg-soft);
  text-decoration: none;
}
.search-item-title { display: block; color: var(--text); font-weight: 600; font-size: 0.98rem; }
.search-item-date { display: block; color: var(--text-dim); font-size: 0.78rem; margin: 2px 0 4px; }
.search-item-snippet { display: block; color: var(--text-dim); font-size: 0.85rem; }

.search-empty {
  width: 100%;
  max-width: 560px;
  margin-top: 16px;
  text-align: center;
  color: var(--text-dim);
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* ============ 博客导航(标签) ============ */
.blog-nav { margin: 8px 0 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.blog-nav-group { margin-bottom: 10px; }
.blog-nav-label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 10px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.85rem;
  transition: border-color 0.2s, color 0.2s, transform 0.2s;
}
.tag-chip:hover {
  text-decoration: none;
  border-color: var(--accent-2);
  color: var(--accent-2);
  transform: translateY(-2px);
}
.tag-chip em { font-style: normal; color: var(--text-dim); font-size: 0.78rem; }
.tag-chip:hover em { color: var(--accent-2); }

/* ============ 标签云总览页 ============ */
.page-desc { color: var(--text-dim); font-size: 0.95rem; margin-top: 8px; }
.term-cloud { display: flex; flex-wrap: wrap; gap: 12px; padding: 20px 0; }
.term-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s, transform 0.2s;
}
.term-chip:hover {
  text-decoration: none;
  border-color: var(--accent-1);
  transform: translateY(-2px);
}
.term-count {
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.78rem;
  color: var(--accent-1);
}

/* ============ 归档页 ============ */
.archive { padding: 8px 0 24px; }
.archive-year { font-size: 1.5rem; font-weight: 800; margin: 28px 0 14px; color: var(--accent-1); }
.archive-list { display: flex; flex-direction: column; gap: 10px; }
.archive-item {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}
.archive-item:hover { background: var(--card); border-color: var(--border); text-decoration: none; }
.archive-date { color: var(--text-dim); font-size: 0.85rem; min-width: 44px; font-variant-numeric: tabular-nums; }
.archive-title { color: var(--text); font-weight: 500; }
.archive-item:hover .archive-title { color: var(--accent-1); }
.archive-tags { margin-left: auto; display: flex; gap: 6px; }

/* ============ 工具页 ============ */
.section-note { color: var(--text-dim); font-size: 0.95rem; margin-bottom: 8px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding: 20px 0; }
.tool-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.tool-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  border-color: rgba(88, 166, 255, 0.4);
  box-shadow: var(--shadow);
}
.tool-card h3 { font-size: 1.05rem; margin-bottom: 8px; color: var(--text); }
.tool-card p { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 12px; }
.tool-link { color: var(--accent-1); font-size: 0.85rem; }

/* 工具 widget */
.tool-widget {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 20px 0;
  backdrop-filter: blur(8px);
}
.tool-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.tool-row label { color: var(--text-dim); font-size: 0.9rem; min-width: 120px; }
.tool-row input {
  flex: 1;
  min-width: 180px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  outline: none;
}
.tool-row input:focus { border-color: var(--accent-1); }
.tool-row button {
  background: var(--gradient);
  border: none;
  color: #fff;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.2s;
}
.tool-row button:hover { opacity: 0.9; }
.tool-result {
  margin-top: 12px;
  padding: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 1rem;
  word-break: break-all;
}
