/* =================================================================
 * SRE Wiki v2.0 — Design System
 * 风格：克制优雅 (Vercel/Linear 风) · 粉紫保留为强调色
 *
 * 包含：
 *   - 设计 token (颜色 / 间距 / 圆角 / 阴影 / 字号 / 字体)
 *   - 基础组件 (nav / btn / eyebrow / section / card / footer)
 *   - 重置 + 基础排版
 *
 * 配套：
 *   - css/animation.css (动效)
 *   - js/animation.js  (动效脚本)
 * ================================================================= */

:root {
  /* ── 颜色 ── */
  --bg: #fafaf9;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.72);
  --bg-soft: rgba(255, 255, 255, 0.5);

  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;
  --text-faint: #d4d4d8;

  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.12);
  --border-accent: rgba(196, 69, 105, 0.25);

  /* 强调色 — 粉紫渐变 */
  --accent-from: #ff6b9d;
  --accent-to: #c44569;
  --accent-solid: #c44569;
  --accent-soft: rgba(196, 69, 105, 0.08);

  /* 状态色 */
  --ok-bg: rgba(22, 163, 74, 0.08);
  --ok-fg: #15803d;
  --warn-bg: rgba(234, 88, 12, 0.08);
  --warn-fg: #c2410c;
  --neutral-bg: rgba(0, 0, 0, 0.04);
  --neutral-fg: #52525b;

  /* ── 间距（8 级）── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;
  --sp-9: 96px;

  /* ── 圆角 ── */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* ── 阴影（克制）── */
  --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --sh-md: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
  --sh-lg: 0 4px 8px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.06);
  --sh-accent: 0 8px 24px rgba(196, 69, 105, 0.18);

  /* ── 字体 ── */
  --f-display: 'Outfit', system-ui, -apple-system, 'PingFang SC', sans-serif;
  --f-body: 'Outfit', system-ui, -apple-system, 'PingFang SC', sans-serif;
  --f-mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;

  /* ── 动效曲线 ── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg);
  font-feature-settings: 'cv11', 'ss01';
}
a { color: inherit; text-decoration: none; }

/* ============================================================
 * 背景：aurora 渐变 + dotted grid（克制版）
 * 与 animation.css 的 .bg-mesh / .bg-blob 协作
 * ============================================================ */
.bg-aurora {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 154, 158, 0.16) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 30%, rgba(254, 207, 239, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 50% 30% at 20% 20%, rgba(189, 153, 244, 0.06) 0%, transparent 60%);
}
.bg-grid {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 60%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 60%);
}

/* ============================================================
 * Container
 * ============================================================ */
.container { max-width: 1100px; margin: 0 auto; padding: 0 32px; }
.wrapper   { max-width: 1100px; margin: 0 auto; padding: 0 32px 80px; }

/* ============================================================
 * Top Nav (sticky)
 * ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: rgba(250, 250, 249, 0.72);
  border-bottom: 1px solid var(--border);
}
.site-header .nav-inner {
  max-width: 1100px; margin: 0 auto; padding: 14px 32px;
  display: flex; align-items: center; justify-content: space-between;
}
.site-title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.site-title a { display: flex; align-items: center; gap: 8px; }
.site-title .mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent-from), var(--accent-to));
}
.nav-links { display: flex; gap: 4px; list-style: none; }
.nav-links a {
  padding: 6px 12px; font-size: 14px; color: var(--text-secondary);
  border-radius: var(--r-md);
  transition: all 0.2s var(--ease-out);
}
.nav-links a:hover { color: var(--text-primary); background: var(--neutral-bg); }
.nav-links a.active { color: var(--text-primary); font-weight: 600; }

/* ============================================================
 * Hero
 * ============================================================ */
.hero { padding: 120px 0 96px; text-align: center; position: relative; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 32px;
  backdrop-filter: blur(8px);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.6);
  animation: live-pulse 2s ease-in-out infinite;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}
.hero-title {
  font-family: var(--f-display);
  font-size: clamp(40px, 6.5vw, 72px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
  max-width: 800px;
  margin: 0 auto 24px;
}
.hero-title .grad {
  background: linear-gradient(120deg, #c44569 0%, #ff6b9d 50%, #ff9a9e 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: grad-shift 8s ease-in-out infinite;
}
@keyframes grad-shift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
.hero-desc {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 40px;
  line-height: 1.6;
}
.hero-actions { display: inline-flex; gap: 10px; }

/* ============================================================
 * Button
 * ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px;
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--text-primary);
  color: white;
  box-shadow: var(--sh-md);
}
.btn-primary:hover { background: #000; transform: translateY(-1px); box-shadow: var(--sh-lg); }
.btn-ghost {
  background: var(--bg-glass);
  color: var(--text-primary);
  border-color: var(--border-strong);
  backdrop-filter: blur(8px);
}
.btn-ghost:hover { background: var(--bg-elevated); border-color: var(--text-primary); }

.scroll-hint {
  position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%);
  color: var(--text-muted); font-size: 12px; letter-spacing: 0.04em;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: scroll-bob 2.4s ease-in-out infinite;
}
.scroll-hint .arrow { width: 16px; height: 16px; opacity: 0.6; }
@keyframes scroll-bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(6px); }
}

/* ============================================================
 * Stats
 * ============================================================ */
.stats-bar {
  display: flex; justify-content: center; gap: 0;
  padding: 80px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 0 -32px;
  padding-left: 32px; padding-right: 32px;
}
.stat-item {
  flex: 1; max-width: 200px; text-align: center;
  padding: 0 24px;
  position: relative;
}
.stat-item + .stat-item::before {
  content: ""; position: absolute; left: 0; top: 20%; height: 60%;
  width: 1px; background: var(--border);
}
.stat-num {
  font-family: var(--f-display);
  font-size: 48px; font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1;
}
.stat-num .suffix {
  font-size: 0.4em; color: var(--text-muted); font-weight: 500;
  letter-spacing: 0; margin-left: 2px;
}
.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 500;
}

/* ============================================================
 * Section header
 * ============================================================ */
.section-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 32px;
  gap: 24px;
}
.section-title {
  font-family: var(--f-display);
  font-size: 28px; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.section-title .sub {
  display: block;
  font-size: 14px; font-weight: 400;
  color: var(--text-muted);
  margin-top: 6px;
  letter-spacing: 0;
}
.section-meta {
  font-size: 13px; color: var(--text-muted);
  font-family: var(--f-mono);
  white-space: nowrap;
}
.section { padding: 96px 0; }
.section + .section { padding-top: 0; }

/* ============================================================
 * Cat card (3 列)
 * ============================================================ */
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  transition: all 0.25s var(--ease-out);
  cursor: pointer;
}
.cat-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}
.cat-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
  color: var(--accent-solid);
  margin-bottom: 16px;
}
.cat-icon svg { width: 20px; height: 20px; }
.cat-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.cat-count {
  font-size: 13px; color: var(--text-muted);
  font-family: var(--f-mono);
}

/* ============================================================
 * Article card (2 列)
 * ============================================================ */
.article-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.article-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  display: flex; flex-direction: column; gap: 12px;
  transition: all 0.25s var(--ease-out);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.article-card::before {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent-from), var(--accent-to));
  transition: width 0.4s var(--ease-out);
}
.article-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}
.article-card:hover::before { width: 100%; }
.article-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
}
.article-title {
  font-weight: 600; font-size: 15px;
  line-height: 1.4;
  color: var(--text-primary);
}
.article-tag {
  flex-shrink: 0;
  padding: 2px 8px;
  background: var(--neutral-bg);
  color: var(--text-secondary);
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--f-mono);
  letter-spacing: 0.02em;
}
.article-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.article-foot {
  display: flex; align-items: center; gap: 6px;
  margin-top: auto;
  padding-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--f-mono);
}
.article-arrow {
  margin-left: auto; opacity: 0.4;
  transition: transform 0.2s, opacity 0.2s;
  display: flex; align-items: center;
}
.article-arrow svg { width: 16px; height: 16px; }
.article-card:hover .article-arrow { transform: translateX(3px); opacity: 1; }

/* ============================================================
 * Project card (状态卡 + 左色条)
 * ============================================================ */
.projects-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.project-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-solid);
  border-radius: var(--r-lg);
  padding: 24px;
  transition: all 0.25s var(--ease-out);
  cursor: pointer;
  position: relative;
  display: block;
  text-decoration: none;
  color: inherit;
}
.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
  border-color: var(--border-strong);
}
.project-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
  gap: 12px;
}
.project-name {
  font-weight: 600; font-size: 15px;
  color: var(--text-primary);
}
.project-pill {
  padding: 3px 10px;
  background: var(--accent-soft);
  color: var(--accent-solid);
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--f-mono);
  white-space: nowrap;
}
.project-pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.project-pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.project-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.project-meta {
  display: flex; gap: 12px; margin-top: 16px;
  font-size: 12px; color: var(--text-muted);
  font-family: var(--f-mono);
}
.project-meta span:first-child { margin-left: 0; }
.status-pill {
  display: inline-block;
  padding: 2px 10px;
  background: linear-gradient(135deg, rgba(255,154,158,0.25), rgba(196,69,105,0.18));
  border: 1px solid rgba(196,69,105,0.3);
  color: #c44569;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.6rem;
  vertical-align: middle;
  letter-spacing: 0.3px;
}

/* ============================================================
 * Footer
 * ============================================================ */
.site-footer {
  margin-top: 80px;
  padding: 48px 0 64px;
  border-top: 1px solid var(--border);
}
.site-footer .footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.footer-links { display: flex; gap: 16px; list-style: none; }
.footer-links a { transition: color 0.2s; }
.footer-links a:hover { color: var(--text-primary); }

/* ============================================================
 * Accessibility
 * ============================================================ */

/* Focus ring —— 键盘可见，鼠标点击不显示 */
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--accent-solid);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Skip-to-content link —— 键盘 Tab 第一个出现 */
.skip-link {
  position: absolute; top: -100px; left: 16px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-weight: 600;
  text-decoration: none;
  z-index: 100000;
  box-shadow: var(--sh-md);
  transition: top 0.2s var(--ease-out);
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 16px;
  outline: 2px solid var(--accent-solid);
  outline-offset: 2px;
}

/* 屏幕阅读器专属文字 */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* 减少动效偏好 —— 关闭所有装饰动效 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .bg-mesh, .blob { display: none !important; }
  .particles { display: none !important; }
}

/* High contrast mode (Windows / macOS 系统级增强) */
@media (prefers-contrast: more) {
  :root {
    --border: rgba(0, 0, 0, 0.4);
    --border-strong: rgba(0, 0, 0, 0.6);
    --text-secondary: #27272a;
  }
  body.dark-mode {
    --border: rgba(255, 255, 255, 0.4);
    --border-strong: rgba(255, 255, 255, 0.6);
    --text-secondary: #d4d4d8;
  }
}

/* ============================================================
 * Dark mode (基础支持)
 * ============================================================ */
body.dark-mode {
  --bg: #0a0a0a;
  --bg-elevated: #18181b;
  --bg-glass: rgba(24, 24, 27, 0.72);
  --bg-soft: rgba(24, 24, 27, 0.5);
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-faint: #3f3f46;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --neutral-bg: rgba(255, 255, 255, 0.06);
  --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-md: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  --sh-lg: 0 4px 8px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.4);
}
body.dark-mode .site-header {
  background: rgba(10, 10, 10, 0.72);
}
body.dark-mode .bg-grid { opacity: 0.4; }
body.dark-mode .live-dot { background: #4ade80; }

/* ============================================================
 * Mobile
 * ============================================================ */
@media (max-width: 768px) {
  .container, .wrapper { padding: 0 20px; }
  .site-header .nav-inner { padding: 12px 20px; }
  .hero { padding: 64px 0 48px; }
  .stats-bar {
    flex-direction: column; gap: 32px; padding: 48px 20px;
  }
  .stat-item + .stat-item::before {
    left: 30%; top: -16px; width: 40%; height: 1px;
  }
  .cat-grid, .article-grid, .projects-grid { grid-template-columns: 1fr; }
  .section { padding: 64px 0; }
  .section-header { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
 * 旧 card 反向兼容（给项目页用）
 * ============================================================ */
.back-link {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-secondary); text-decoration: none; font-weight: 500;
  margin-bottom: 32px; padding: 8px 14px; border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: all 0.2s var(--ease-out);
}
.back-link:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  transform: translateX(-2px);
}

/* ============================================================
 * 文章侧边 TOC（仅文章页生效，js/toc.js 注入）
 * ============================================================ */
.article-toc {
  position: fixed;
  right: 24px; top: 88px;
  width: 220px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 16px 0;
  z-index: 50;
}
.article-toc::-webkit-scrollbar { width: 4px; }
.article-toc::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.toc-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; padding: 0 16px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--f-mono);
}
.toc-progress {
  color: var(--accent-solid);
  font-variant-numeric: tabular-nums;
}
.article-toc ol {
  list-style: none;
  padding: 0; margin: 0;
  border-left: 1px solid var(--border);
}
.article-toc li { margin: 0; }
.article-toc li.l3 { padding-left: 14px; }
.article-toc a {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 13px;
  margin-left: -1px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12.5px;
  line-height: 1.4;
  border-left: 1px solid transparent;
  transition: all 0.15s var(--ease-out);
}
.article-toc a:hover { color: var(--text-primary); }
.article-toc a.is-active {
  color: var(--accent-solid);
  border-left-color: var(--accent-solid);
  font-weight: 600;
}
.toc-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.article-toc a.is-active .toc-dot { background: var(--accent-solid); }

@media (max-width: 1400px) {
  .article-toc { display: none; }
}

/* ============================================================
 * 阅读进度环（右下角 ↑ 升级版）
 * ============================================================ */
.scroll-progress {
  position: fixed;
  bottom: 24px; right: 24px; z-index: 999;
  width: 48px; height: 48px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--sh-md);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
  padding: 0;
}
.scroll-progress.visible { opacity: 1; pointer-events: auto; }
.scroll-progress:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-lg);
  border-color: var(--border-strong);
}
.scroll-progress svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.scroll-progress .bg {
  fill: none; stroke: var(--border); stroke-width: 2.5;
}
.scroll-progress .fg {
  fill: none; stroke: var(--accent-solid); stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dasharray 0.1s linear;
}
.scroll-progress .arrow {
  position: relative; z-index: 1;
  width: 18px; height: 18px;
  color: var(--text-primary);
  font-size: 18px; font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
body.dark-mode .scroll-progress { background: var(--bg-elevated); }
body.dark-mode .scroll-progress .bg { stroke: var(--border); }
