/* ══════════════════════════════════════════════
   旺财博客 — 全局样式
   暗色/亮色主题 + 响应式布局
   ══════════════════════════════════════════════ */

/* ── CSS Variables (Dark default) ──────────── */
:root {
  --bg: #0a0a0f;
  --bg-alt: #0f0f17;
  --card: #16161e;
  --card-hover: #1e1e29;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-subtle: rgba(99, 102, 241, 0.12);
  --text: #e4e4e7;
  --text-secondary: #a1a1aa;
  --muted: #71717a;
  --border: #27272a;
  --border-light: #1f1f28;
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
  --font-sans: -apple-system, BlinkMacSystemFont, "Noto Sans SC", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  /* code highlight (dark) */
  --hl-bg: #1a1a24;
  --hl-text: #e4e4e7;
}

/* ── Light theme (system preference) ───────── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f8f8fa;
    --bg-alt: #f0f0f4;
    --card: #ffffff;
    --card-hover: #f4f4f8;
    --accent: #4f46e5;
    --accent-hover: #6366f1;
    --accent-subtle: rgba(79, 70, 229, 0.08);
    --text: #18181b;
    --text-secondary: #52525b;
    --muted: #a1a1aa;
    --border: #e4e4e7;
    --border-light: #f0f0f4;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
    --hl-bg: #f4f4f8;
    --hl-text: #18181b;
  }
}

/* ── Light theme (manual override) ─────────── */
:root[data-theme="light"] {
  --bg: #f8f8fa;
  --bg-alt: #f0f0f4;
  --card: #ffffff;
  --card-hover: #f4f4f8;
  --accent: #4f46e5;
  --accent-hover: #6366f1;
  --accent-subtle: rgba(79, 70, 229, 0.08);
  --text: #18181b;
  --text-secondary: #52525b;
  --muted: #a1a1aa;
  --border: #e4e4e7;
  --border-light: #f0f0f4;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
  --hl-bg: #f4f4f8;
  --hl-text: #18181b;
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

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

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

/* ── Container ─────────────────────────────── */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header / Nav ──────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  backdrop-filter: blur(12px);
  transition: background var(--transition), border-color var(--transition);
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.site-logo:hover {
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: all var(--transition);
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Hero ──────────────────────────────────── */
.hero {
  padding: 64px 0 48px;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 500px;
  margin: 0 auto;
}

/* ── Post Cards ────────────────────────────── */
.posts-grid {
  display: grid;
  gap: 20px;
  padding: 0 0 64px;
}

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}
.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-subtle);
  background: var(--card-hover);
}

.post-card-cover {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--border-light);
}

.post-card-body {
  padding: 20px 24px 24px;
}

.post-card-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.post-card-tag {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 500;
}

.post-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 8px;
  color: var(--text);
}

.post-card-excerpt {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.post-card-author {
  font-weight: 600;
  color: var(--text-secondary);
}

/* ── Article detail ────────────────────────── */
.article {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

.article-header {
  text-align: center;
  margin-bottom: 48px;
}

.article-header h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 16px;
  line-height: 1.3;
}

.article-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
}

.article-meta .author {
  font-weight: 600;
  color: var(--text-secondary);
}

.article-tags {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.article-tag {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 500;
}

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.9rem;
}
.article-back:hover {
  color: var(--accent);
}

/* ── Article content (Markdown) ────────────── */
.article-body {
  font-size: 1.05rem;
  line-height: 1.85;
}

.article-body h1, .article-body h2, .article-body h3,
.article-body h4, .article-body h5, .article-body h6 {
  margin: 2em 0 0.6em;
  font-weight: 700;
  line-height: 1.3;
}
.article-body h1 { font-size: 1.8rem; }
.article-body h2 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.article-body h3 { font-size: 1.15rem; }

.article-body p {
  margin: 1em 0;
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.5em 0;
  padding: 0.5em 1em;
  color: var(--text-secondary);
  background: var(--accent-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.article-body ul, .article-body ol {
  margin: 1em 0;
  padding-left: 1.5em;
}

.article-body li {
  margin: 0.4em 0;
}

.article-body img {
  border-radius: var(--radius);
  margin: 1.5em auto;
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
}
.article-body th, .article-body td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}
.article-body th {
  background: var(--accent-subtle);
  font-weight: 600;
}

/* Code blocks */
.article-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--hl-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.article-body pre {
  background: var(--hl-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 1.5em 0;
  font-size: 0.88em;
  line-height: 1.6;
}

.article-body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

/* ── Footer ────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Empty / Loading states ────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}

.empty-state p {
  font-size: 1.1rem;
  margin-top: 8px;
}

.loading {
  display: flex;
  justify-content: center;
  padding: 48px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Pagination ────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 0 48px;
}

.pagination button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition);
}
.pagination button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pagination .page-info {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 8px;
}

/* ── About page ────────────────────────────── */
.about-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 24px;
}

.about-page h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 16px;
}

.about-page .intro {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 48px;
}

.authors-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

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

.author-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  transition: all var(--transition);
}
.author-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent-subtle);
}

.author-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 16px;
  background: var(--accent-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.author-card h2 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.author-card .role {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 12px;
}

.author-card .bio {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.75rem; }
  .hero p { font-size: 1rem; }
  .post-card-body { padding: 16px; }
  .post-card-title { font-size: 1.1rem; }
  .article-header h1 { font-size: 1.5rem; }
  .nav-links { gap: 16px; }
}
