/* =========================================================
   设计 token、页面骨架、导航栏、文章卡片、侧边栏、页脚
   深色模式的覆盖值集中在 responsive.css
   ========================================================= */

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

:root {
  /* 颜色 */
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-surface-2: #f8f9fa;
  --color-text: #334155;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;
  --color-heading: #0f172a;
  --color-brand-deep: #0b1e36;
  --color-brand-blue: #2563eb;
  --color-brand-hover: #1d4ed8;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;
  --color-card-shadow: rgba(0, 0, 0, 0.04);
  --color-card-hover-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  --color-tag-bg: #f1f5f9;
  --color-tag-text: #64748b;
  --color-tag-hover-bg: #eff6ff;
  --color-tag-hover-text: #2563eb;
  --color-accent-bg: #eff6ff;
  --color-accent-text: #1d4ed8;
  --color-accent-border: #bfdbfe;
  --color-code-inline: #e11d48;

  /* 字体：中文走系统字体，拉丁文与代码用 Web Font */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-display: 'Space Grotesk', 'Inter', -apple-system,
    'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, 'Courier New', monospace;

  /* 字号 */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* 间距 */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* 尺寸 */
  --max-width-wide: 1280px;
  --max-width-read: 800px;
  --nav-height: 64px;
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-brand-blue);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--color-brand-hover);
}

:focus-visible {
  outline: 2px solid var(--color-brand-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f8fafc;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ===================== 导航栏 ===================== */

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: linear-gradient(to right,
    rgba(6, 17, 36, 0.95), rgba(10, 30, 54, 0.95), rgba(5, 15, 29, 0.95));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(30, 58, 95, 0.5);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.nav-container {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
  height: 100%;
  display: flex;
  align-items: center;
}

.nav-brand-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.nav-logo {
  width: 36px;
  height: 36px;
  background: #123456;
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
  flex-shrink: 0;
}

.nav-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.nav-tagline {
  font-size: 10px;
  color: #94a3b8;
  white-space: nowrap;
}

.nav-center {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  height: 100%;
  margin-left: var(--space-8);
}

.nav-link {
  font-size: var(--text-sm);
  font-weight: 500;
  color: #cbd5e1;
  padding: 0 var(--space-4);
  height: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  white-space: nowrap;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-link:hover,
.nav-link.active {
  color: #60a5fa;
}

.nav-link.active {
  border-bottom-color: #60a5fa;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.nav-search {
  position: relative;
}

.nav-search-input {
  width: 200px;
  background: #0f243e;
  border: 1px solid #1c385c;
  border-radius: 999px;
  padding: 7px 36px 7px 16px;
  font-size: 12px;
  color: #e2e8f0;
  font-family: var(--font-sans);
  outline: none;
  transition: width 0.3s, border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.nav-search-input::placeholder {
  color: #64748b;
}

.nav-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.nav-search-input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px #60a5fa;
  width: 260px;
}

.nav-search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: #64748b;
  pointer-events: none;
}

/* 主题按钮 / 汉堡按钮 */
.nav-icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.nav-icon-btn:hover {
  background: #0f243e;
  border-color: #1c385c;
  color: #60a5fa;
}

.nav-icon-btn svg {
  width: 18px;
  height: 18px;
}

/* 浅色模式显示月亮（点击切到深色），深色模式显示太阳 */
.icon-sun { display: none; }
.icon-moon { display: block; }
[data-theme='dark'] .icon-sun { display: block; }
[data-theme='dark'] .icon-moon { display: none; }

.nav-mobile-toggle {
  display: none;
}

/* ===================== 骨架 ===================== */

.main-content {
  flex: 1;
  padding: var(--space-8) var(--space-4);
}

@media (min-width: 768px) {
  .main-content {
    padding: var(--space-10) var(--space-8);
  }
}

.container {
  max-width: var(--max-width-wide);
  margin: 0 auto;
}

.container--narrow {
  max-width: var(--max-width-read);
}

.home-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  align-items: start;
}

@media (min-width: 1024px) {
  .home-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: var(--space-8);
  }
}

.home-main {
  min-width: 0;
}

/* ===================== 筛选条 ===================== */

.filter-bar {
  background: var(--color-accent-bg);
  border: 1px solid var(--color-accent-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-xs);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.filter-bar-label {
  font-weight: 600;
  color: #1e40af;
}

.filter-bar-badge {
  background: #dbeafe;
  color: #1d4ed8;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  margin-left: var(--space-2);
}

.filter-bar-clear {
  font-weight: 500;
  text-decoration: underline;
  white-space: nowrap;
}

/* ===================== 区块标题 ===================== */

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-5);
}

.section-heading-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 800;
  font-size: var(--text-lg);
  color: var(--color-text);
}

.section-heading-bar {
  width: 6px;
  height: 20px;
  background: var(--color-brand-deep);
  border-radius: 999px;
  flex-shrink: 0;
}

.section-heading-count {
  color: var(--color-text-muted);
  font-weight: 400;
  font-size: var(--text-sm);
}

/* ===================== 文章卡片 ===================== */

.card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: var(--space-5) var(--space-6);
  transition: box-shadow 0.3s, border-color 0.3s, transform 0.3s;
}

.card:hover {
  box-shadow: var(--color-card-hover-shadow);
  border-color: var(--color-accent-border);
  transform: translateY(-2px);
}

.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.card-category {
  background: var(--color-accent-bg);
  color: var(--color-accent-text);
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 10px;
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: var(--space-3);
}

.card-title a {
  color: var(--color-heading);
}

.card-title a:hover {
  color: var(--color-brand-blue);
}

.card-excerpt {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-light);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 10px;
  font-weight: 500;
  padding: 3px 10px;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.tag:hover,
.tag--active {
  background: var(--color-tag-hover-bg);
  color: var(--color-tag-hover-text);
  border-color: var(--color-accent-border);
}

.card-read-more {
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.2s;
}

.card-read-more:hover {
  transform: translateX(4px);
}

.empty-state {
  text-align: center;
  padding: var(--space-16) 0;
  color: var(--color-text-muted);
}

.empty-state p {
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}

.empty-state a {
  font-size: var(--text-xs);
}

/* ===================== 侧边栏 ===================== */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

.sidebar-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: var(--space-5);
}

.sidebar-card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-card-title-bar {
  width: 6px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}

.sidebar-card-title-bar.blue { background: var(--color-brand-blue); }
.sidebar-card-title-bar.indigo { background: #6366f1; }
.sidebar-card-title-bar.amber { background: #f59e0b; }
.sidebar-card-title-bar.emerald { background: #10b981; }

.author-card {
  text-align: center;
}

.author-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0b1e36, #2563eb);
  color: #ffffff;
  font-size: var(--text-2xl);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-3);
  font-family: var(--font-display);
}

.author-name {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-heading);
}

.author-title {
  font-size: var(--text-xs);
  color: var(--color-brand-blue);
  font-weight: 500;
  background: var(--color-accent-bg);
  padding: 2px 12px;
  border-radius: 999px;
  display: inline-block;
  margin-top: var(--space-2);
}

.author-bio {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: var(--space-3);
  line-height: 1.7;
  text-align: left;
}

.author-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  border-top: 1px solid var(--color-border-light);
  border-bottom: 1px solid var(--color-border-light);
  padding: var(--space-4) 0;
  margin-top: var(--space-4);
}

.author-stat-label {
  font-size: 10px;
  color: var(--color-text-muted);
  display: block;
}

.author-stat-value {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  font-family: var(--font-mono);
}

.author-socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.social-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
}

.social-btn:hover {
  background: var(--color-tag-hover-bg);
  color: var(--color-brand-blue);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.recent-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.recent-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recent-link {
  font-size: var(--text-xs);
  color: var(--color-text);
  line-height: 1.6;
}

.recent-link:hover {
  color: var(--color-brand-blue);
}

.recent-date {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--color-text-muted);
}

/* ===================== 文章详情外壳 ===================== */

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-8);
  max-width: var(--max-width-read);
  margin: 0 auto;
  align-items: start;
}

/* 宽屏时右侧放常驻目录 */
@media (min-width: 1100px) {
  .article-layout {
    max-width: 1060px;
    grid-template-columns: minmax(0, var(--max-width-read)) 220px;
  }
}

.article-detail {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: 0 1px 3px var(--color-card-shadow);
  min-width: 0;
}

@media (min-width: 640px) {
  .article-detail {
    padding: var(--space-10) var(--space-8);
  }
}

.article-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border-light);
  margin-bottom: var(--space-6);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.back-link:hover {
  color: var(--color-brand-blue);
  border-color: var(--color-accent-border);
}

.breadcrumb-path {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.breadcrumb-sep {
  color: #cbd5e1;
}

.breadcrumb-current {
  color: var(--color-text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.article-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-heading);
  margin-bottom: var(--space-4);
}

@media (min-width: 640px) {
  .article-title {
    font-size: var(--text-3xl);
  }
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--color-border-light);
}

.meta-separator {
  color: var(--color-border);
}

.article-tags-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border-light);
  margin-top: var(--space-6);
}

.article-tags-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* 上一篇 / 下一篇 */
.post-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border-light);
}

@media (min-width: 640px) {
  .post-nav {
    grid-template-columns: 1fr 1fr;
  }
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  background: var(--color-surface-2);
  transition: border-color 0.2s, background 0.2s;
  min-width: 0;
}

a.post-nav-link:hover {
  border-color: var(--color-accent-border);
  background: var(--color-tag-hover-bg);
}

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

.post-nav-title {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.6;
}

a.post-nav-link:hover .post-nav-title {
  color: var(--color-brand-blue);
}

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

/* 占位项：保持左右对齐但不可见 */
.post-nav-empty {
  border-color: transparent;
  background: transparent;
  display: none;
}

@media (min-width: 640px) {
  .post-nav-empty {
    display: block;
  }
}

.load-error-text {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
}

.load-error-list {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  padding-left: var(--space-6);
  line-height: 1.8;
}

.load-error-text code,
.load-error-list code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--color-code-inline);
}

/* ===================== 加载中 / 404 ===================== */

.loading {
  display: flex;
  justify-content: center;
  padding: var(--space-16) 0;
}

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

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

.not-found {
  padding: var(--space-16) 0;
}

.not-found-title {
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 700;
  color: var(--color-border);
  line-height: 1;
  margin-bottom: var(--space-4);
}

.not-found-text {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-8);
}

/* ===================== 页脚 ===================== */

.footer {
  background: var(--color-brand-deep);
  color: #94a3b8;
  padding: var(--space-8) var(--space-6);
  margin-top: var(--space-12);
  text-align: center;
  font-size: var(--text-xs);
}

.footer-inner {
  max-width: var(--max-width-wide);
  margin: 0 auto;
}

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.footer-brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: 0.05em;
}

.footer-sep {
  color: #475569;
}

.footer-desc {
  color: #94a3b8;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.7;
}

.footer-copy {
  color: #64748b;
  font-family: var(--font-mono);
  margin-top: var(--space-3);
}

/* ===================== 回到顶部 ===================== */

.back-to-top {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 44px;
  height: 44px;
  background: var(--color-brand-deep);
  color: #ffffff;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.2s;
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: #1e293b;
  transform: translateY(-4px);
}

.back-to-top svg {
  width: 20px;
  height: 20px;
}

/* ===================== 工具类 ===================== */

.text-center {
  text-align: center;
}
