/* ============================================================
   blog.css — 与 AI 同行
   Style: Light Modern Tech Publication
   Inspired by: Linear × Vercel × Stripe
   Version: 20260603d
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Noto+Sans+SC:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-muted: #f4f4f5;
  --surface: #ffffff;
  --text: #09090b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;
  --border: #e4e4e7;
  --border-light: #f4f4f5;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --accent-glow: rgba(79,70,229,.08);
  --green: #059669;
  --green-light: #ecfdf5;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --rose: #e11d48;
  --rose-light: #fff1f2;
  --cyan: #0891b2;
  --cyan-light: #ecfeff;
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --max-w: 860px;
  --max-w-wide: 1100px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.06);
  --transition: .18s cubic-bezier(.4,0,.2,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(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }
::selection { background: var(--accent); color: #fff; }

/* ---- Container ---- */
.container {
  width: 100%;
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Site Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px) saturate(200%);
  -webkit-backdrop-filter: blur(12px) saturate(200%);
  border-bottom: 1px solid var(--border);
}

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

.brand {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 2px;
}
.brand:hover { text-decoration: none; color: var(--text); }

.top-nav { display: flex; gap: 2px; }

.top-nav a {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all var(--transition);
}
.top-nav a:hover {
  color: var(--text);
  background: var(--bg-muted);
  text-decoration: none;
}

/* ---- Main ---- */
.main-shell {
  padding: 40px 0 80px;
  min-height: 70vh;
}

/* ---- Home Hero ---- */
.home-hero {
  margin-bottom: 40px;
  padding: 56px 0 48px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.home-hero::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 80px; height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.home-hero .eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

.home-hero h1 {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -.04em;
  color: var(--text);
  margin-bottom: 16px;
}

.home-hero p {
  color: var(--text-secondary);
  font-size: 16px;
  max-width: 600px;
  line-height: 1.65;
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.search-form { display: flex; gap: 8px; }

.search-form input[type="search"] {
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: 260px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-form input[type="search"]::placeholder { color: var(--text-muted); }
.search-form input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn:hover {
  background: var(--bg-muted);
  border-color: var(--border);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(79,70,229,.25);
}

/* ---- Badge ---- */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent);
  letter-spacing: .02em;
}

/* ---- Post Grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.post-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--bg);
  text-decoration: none;
  color: var(--text);
  transition: background var(--transition);
}
.post-card:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}

.post-card .badge { margin-bottom: 12px; align-self: flex-start; }

.post-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.post-date {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: .02em;
  padding: 2px 8px;
  background: var(--bg-muted);
  border-radius: 4px;
}

.post-card h2 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -.01em;
  margin-bottom: 8px;
  color: var(--text);
}

.post-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card .meta {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin-top: 40px;
  font-size: 13px;
  color: var(--text-muted);
}
.pagination a {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  background: var(--bg);
  transition: all var(--transition);
}
.pagination a:hover {
  background: var(--bg-muted);
  text-decoration: none;
  color: var(--text);
}

/* ---- Empty State ---- */
.empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ---- Article Page ---- */
.article {
  max-width: var(--max-w);
  margin: 0 auto;
}

.article-head {
  padding-bottom: 24px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.article-head::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 60px; height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.article-head .badge { margin-bottom: 14px; }

.article-head h1 {
  font-size: clamp(26px, 4.5vw, 40px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -.035em;
  margin-bottom: 10px;
  color: var(--text);
}

.article-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.article-content {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
}
.article-content > h1:first-child,
.article-content .report-title { display: none; }

.article-content h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin: 36px 0 14px;
  letter-spacing: -.02em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.article-content h2::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 32px; height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.article-content h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 28px 0 10px;
}

.article-content p { margin-bottom: 16px; }

.article-content strong { color: var(--text); font-weight: 700; }

.article-content ul, .article-content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}
.article-content li { margin-bottom: 6px; }

.article-content img {
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 20px;
}
.article-content th, .article-content td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}
.article-content th {
  background: var(--bg-muted);
  font-weight: 700;
  font-size: 12px;
  color: var(--text);
  letter-spacing: .02em;
}
.article-content td { color: var(--text-secondary); }

.article-content pre {
  background: #1a1a1a;
  color: #e4e4e7;
  padding: 18px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  margin-bottom: 16px;
}

.article-content code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--bg-muted);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
}
.article-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* ---- Back Row ---- */
.back-row {
  display: flex;
  gap: 8px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* ---- Post Navigation (Prev/Next) ---- */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 32px;
  overflow: hidden;
}

.post-nav-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  background: var(--bg);
  text-decoration: none;
  transition: background var(--transition);
}
.post-nav-item:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}

.post-nav-next {
  text-align: right;
}

.post-nav-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .02em;
}

.post-nav-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Site Footer ---- */
.site-footer {
  text-align: center;
  padding: 32px 20px 48px;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.site-footer a { color: var(--accent); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .header-shell {
    height: auto;
    padding: 12px 0;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  .top-nav { width: 100%; overflow-x: auto; }
  .grid { grid-template-columns: 1fr; }
  .search-form input[type="search"] { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .home-hero { padding: 36px 0 32px; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-next { text-align: left; }
}

/* ============================================================
   Dark Mode — activated by [data-theme="dark"] on <html>
   ============================================================ */

[data-theme="dark"] {
  --bg: #09090b;
  --bg-subtle: #18181b;
  --bg-muted: #27272a;
  --surface: #09090b;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --border: #27272a;
  --border-light: #3f3f46;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-light: rgba(99,102,241,.15);
  --accent-glow: rgba(99,102,241,.12);
  --green: #34d399;
  --green-light: rgba(52,211,153,.12);
  --amber: #fbbf24;
  --amber-light: rgba(251,191,36,.12);
  --rose: #fb7185;
  --rose-light: rgba(251,113,133,.12);
  --cyan: #22d3ee;
  --cyan-light: rgba(34,211,238,.12);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,.3);
}

[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

[data-theme="dark"] .site-header {
  background: rgba(9,9,11,.9);
  border-bottom-color: var(--border);
}

[data-theme="dark"] .search-form input[type="search"] {
  background: var(--bg-subtle);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .post-card {
  background: var(--bg-subtle);
}
[data-theme="dark"] .post-card:hover {
  background: var(--bg-card);
}

[data-theme="dark"] .post-date {
  background: var(--bg-muted);
  color: var(--text-muted);
}

[data-theme="dark"] .post-nav-item {
  background: var(--bg-subtle);
}
[data-theme="dark"] .post-nav-item:hover {
  background: var(--bg-card);
}

[data-theme="dark"] .article-content pre {
  background: #0f0f12;
  border-color: var(--border);
}

[data-theme="dark"] .article-content code {
  background: var(--bg-muted);
  color: var(--accent);
  border-color: var(--border);
}

/* ---- Theme Toggle Button ---- */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
  margin-left: 4px;
}
.theme-toggle:hover {
  background: var(--bg-muted);
  color: var(--text);
  border-color: var(--border-light);
}

/* Show sun in light mode, moon in dark mode */
.theme-icon-dark { display: none; }
.theme-icon-light { display: block; }
[data-theme="dark"] .theme-icon-dark { display: block; }
[data-theme="dark"] .theme-icon-light { display: none; }
