/* ============================================
   璀璨群星号 — 个人博客模板
   精华来源：PaperMod / Terminal / Spotlight / 自研
   纯 CSS + CSS Variables，无框架依赖
   ============================================ */

/* ---------- CSS 变量（主题系统）---------- */
:root {
  /* 浅色主题 */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --bg-code: #f1f5f9;
  --bg-hover: #f1f5f9;
  --bg-search: rgba(255, 255, 255, 0.95);
  --bg-tag: #e2e8f0;
  --bg-tag-hover: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-link: #2563eb;
  --text-link-hover: #1d4ed8;
  --text-code: #e11d48;

  --border-color: #e2e8f0;
  --border-light: #f1f5f9;

  --accent: #2563eb;
  --accent-light: #dbeafe;
  --accent-hover: #1d4ed8;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --navbar-height: 64px;
  --container-max: 1120px;
  --sidebar-width: 300px;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-code: #334155;
  --bg-hover: #334155;
  --bg-search: rgba(15, 23, 42, 0.95);
  --bg-tag: #334155;
  --bg-tag-hover: #475569;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-link: #60a5fa;
  --text-link-hover: #93bbfd;
  --text-code: #fb7185;

  --border-color: #334155;
  --border-light: #1e293b;

  --accent: #3b82f6;
  --accent-light: #1e3a5f;
  --accent-hover: #60a5fa;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.3);
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  color: var(--text-link-hover);
}

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

ul, ol {
  list-style: none;
}

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

/* ---------- 导航栏 ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-search);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  height: var(--navbar-height);
  transition: background 0.3s ease;
}

.navbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

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

.navbar__brand:hover {
  color: var(--text-primary);
}

.navbar__logo {
  font-size: 1.5rem;
}

.navbar__nav {
  display: flex;
  gap: 8px;
}

.navbar__link {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.925rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.navbar__link:hover,
.navbar__link.active {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.navbar__link.active {
  font-weight: 600;
}

.navbar__link--accent {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.navbar__link--accent:hover {
  background: var(--accent);
  color: #fff;
}

.navbar__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* 主题切换图标 */
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

.navbar__hamburger {
  display: none;
}

/* ---------- 搜索面板 ---------- */
.search-panel {
  display: none;
  background: var(--bg-search);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
  position: sticky;
  top: var(--navbar-height);
  z-index: 99;
  animation: slideDown 0.2s ease;
}

.search-panel.active {
  display: block;
}

.search-panel__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 16px;
}

.search-panel__inner svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-panel__inner input {
  flex: 1;
  border: none;
  background: none;
  font-size: 1rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  outline: none;
}

.search-panel__inner input::placeholder {
  color: var(--text-muted);
}

.search-panel__inner kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-muted);
}

/* ---------- Hero 区域 ---------- */
.hero {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--border-color);
}

.hero__greeting {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.hero__name {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero__desc {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 24px;
}

.hero__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tag);
  text-decoration: none;
  transition: all 0.2s ease;
}

.tag:hover {
  background: var(--bg-tag-hover);
  color: var(--text-primary);
}

.tag--sm {
  padding: 2px 10px;
  font-size: 0.75rem;
}

/* ---------- 主布局 ---------- */
.main {
  padding: 48px 0;
}

.main__layout {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: 48px;
  align-items: start;
}

/* ---------- 文章卡片 ---------- */
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 28px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.post-card {
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  transition: all 0.25s ease;
}

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

.post-card__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.post-card__reading::before {
  content: '·';
  margin-right: 12px;
}

.post-card__title {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 10px;
}

.post-card__title a {
  color: var(--text-primary);
  text-decoration: none;
}

.post-card__title a:hover {
  color: var(--accent);
}

.post-card__excerpt {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.pagination__current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

.pagination__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.pagination__link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.pagination__next {
  margin-left: auto;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ---------- 侧边栏 ---------- */
.sidebar__card {
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.sidebar__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar__about {
  text-align: center;
}

.sidebar__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 14px;
  border: 3px solid var(--accent);
}

.sidebar__about p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.sidebar__list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.sidebar__list li:last-child {
  border-bottom: none;
}

.sidebar__list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.sidebar__list a:hover {
  color: var(--accent);
}

.sidebar__count {
  font-size: 0.8rem;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-tag);
  color: var(--text-muted);
}

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

/* ---------- 页脚 ---------- */
.footer {
  margin-top: 48px;
  padding: 32px 0;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.footer__copyright {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer__links {
  display: flex;
  gap: 16px;
}

.footer__links a {
  color: var(--text-muted);
  transition: color 0.2s;
}

.footer__links a:hover {
  color: var(--accent);
}

.footer__powered {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer__powered a {
  color: var(--text-muted);
  text-decoration: underline;
}

/* ---------- 动画 ---------- */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 文章卡片入场动画 */
.post-card {
  animation: fadeIn 0.4s ease both;
}

.post-card:nth-child(1) { animation-delay: 0.05s; }
.post-card:nth-child(2) { animation-delay: 0.1s; }
.post-card:nth-child(3) { animation-delay: 0.15s; }
.post-card:nth-child(4) { animation-delay: 0.2s; }
.post-card:nth-child(5) { animation-delay: 0.25s; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .main__layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .sidebar__card {
    margin-bottom: 0;
  }
}

@media (max-width: 768px) {
  :root {
    --navbar-height: 56px;
  }

  .container {
    padding: 0 16px;
  }

  .navbar__nav {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    flex-direction: column;
    padding: 24px;
    gap: 4px;
    z-index: 98;
    animation: slideDown 0.2s ease;
  }

  .navbar__nav.active {
    display: flex;
  }

  .navbar__link {
    font-size: 1.1rem;
    padding: 12px 16px;
  }

  .navbar__hamburger {
    display: flex;
  }

  .hero {
    padding: 40px 0 32px;
  }

  .hero__name {
    font-size: 2rem;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 32px 0;
  }

  .post-card {
    padding: 20px;
  }

  .pagination {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .hero__desc {
    font-size: 1rem;
  }

  .hero__tags {
    gap: 6px;
  }

  .post-card__title {
    font-size: 1.1rem;
  }
}

/* ---------- 打印样式 ---------- */
@media print {
  .navbar, .sidebar, .footer, .search-panel {
    display: none;
  }

  body {
    color: #000;
    background: #fff;
  }

  .main__layout {
    grid-template-columns: 1fr;
  }
}

/* ---------- 无障碍 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 选中文本 */
::selection {
  background: var(--accent);
  color: #fff;
}
