﻿/* =========================================================
   星辰博客 · 主样式表
   设计：响应式 + 暗色模式（CSS 变量控制）
   ========================================================= */

/* ---------- 主题变量 ---------- */
:root {
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.1);
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);

  --bg: #ffffff;
  --bg-alt: #f6f7fb;
  --surface: #ffffff;
  --text: #1e2233;
  --text-secondary: #5b6078;
  --border: #e6e8f0;

  --shadow-sm: 0 2px 10px rgba(30, 34, 51, 0.06);
  --shadow-md: 0 10px 30px rgba(30, 34, 51, 0.1);
  --shadow-lg: 0 24px 60px rgba(79, 70, 229, 0.18);

  --radius: 16px;
  --radius-sm: 10px;
  --container: 1080px;
  --header-h: 66px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
          -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0f1120;
  --bg-alt: #161930;
  --surface: #191d36;
  --text: #eef0ff;
  --text-secondary: #a5abc8;
  --border: #2a2f4e;
  --primary-soft: rgba(129, 140, 248, 0.14);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
}

/* ---------- 基础 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style-position: inside; }
button { font-family: inherit; cursor: pointer; }

.container {
  width: min(var(--container), 100% - 48px);
  margin-inline: auto;
}

::selection { background: var(--primary-soft); color: var(--primary); }

/* ---------- 通用组件 ---------- */
.badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
}

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 26px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 30px 70px rgba(79, 70, 229, 0.3); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); }

.btn-sm { padding: 9px 18px; font-size: 14px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: color 0.2s ease, border-color 0.2s ease;
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.tag {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
}

.text-link { color: var(--primary); font-weight: 600; font-size: 14px; }
.text-link:hover { text-decoration: underline; }

/* ---------- 导航栏 ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: var(--header-h);
  background: transparent;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.site-header.scrolled {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 700;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gradient);
  color: #fff;
}
.brand-logo svg { width: 20px; height: 20px; }

.nav-links { display: flex; gap: 6px; }

.nav-link {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.2s ease, background 0.2s ease;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }

.nav-actions { display: flex; align-items: center; gap: 10px; }

.menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 0 10px;
}
.menu-btn span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn.open span:nth-child(2) { opacity: 0; }
.menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- 博客头部 ---------- */
.blog-hero {
  position: relative;
  padding: calc(var(--header-h) + 64px) 0 40px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(600px 340px at 85% 10%, rgba(139, 92, 246, 0.18), transparent 65%),
    radial-gradient(500px 300px at 10% 30%, rgba(79, 70, 229, 0.14), transparent 60%);
}
[data-theme="dark"] .hero-bg {
  background:
    radial-gradient(600px 340px at 85% 10%, rgba(139, 92, 246, 0.22), transparent 65%),
    radial-gradient(500px 300px at 10% 30%, rgba(79, 70, 229, 0.18), transparent 60%);
}

.blog-hero-inner { text-align: center; }

.hero-title {
  margin: 18px 0 14px;
  font-size: clamp(32px, 5.5vw, 52px);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.hero-sub {
  max-width: 640px;
  margin-inline: auto;
  font-size: 17px;
  color: var(--text-secondary);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 26px;
}

/* ---------- 博客布局 ---------- */
.section { padding: 56px 0 96px; }

.blog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 36px;
  align-items: start;
}

/* ---------- 工具条（标题/搜索/筛选） ---------- */
.blog-toolbar { margin-bottom: 26px; }

.blog-title { font-size: 24px; font-weight: 800; margin-bottom: 16px; }

.blog-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
}
.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 10px 14px 10px 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

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

.chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
}
.chip:hover { color: var(--primary); border-color: var(--primary); }
.chip.active {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
}

/* ---------- 文章卡片 ---------- */
.post-list { display: flex; flex-direction: column; gap: 18px; }

.post-card {
  padding: 26px 28px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.post-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--primary) 40%, transparent); }

.post-card time {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.post-card h3 {
  margin: 8px 0 10px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
}
.post-card h3 a { transition: color 0.2s ease; }
.post-card h3 a:hover { color: var(--primary); }

.post-card p { color: var(--text-secondary); font-size: 15px; margin-bottom: 14px; }

.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
}
.post-meta .text-link { margin-left: auto; }

.read-time::before { content: "⏱ "; }

.empty-tip {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---------- 侧边栏 ---------- */
.sidebar { display: flex; flex-direction: column; gap: 18px; position: sticky; top: calc(var(--header-h) + 20px); }

.widget {
  padding: 22px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.widget h4 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.widget p { font-size: 14px; color: var(--text-secondary); margin-top: 8px; }

.widget-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-inline: auto;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
}
.widget h3 { text-align: center; margin-top: 12px; font-size: 18px; font-weight: 700; }
.widget > .text-link { display: block; text-align: center; margin-top: 12px; }

.widget-list li { border-bottom: 1px dashed var(--border); }
.widget-list li:last-child { border-bottom: none; }
.widget-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}
.widget-list a:hover { color: var(--primary); }
.widget-list .count {
  font-size: 12px;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.contact-widget li { padding: 8px 0; font-size: 14px; color: var(--text-secondary); word-break: break-all; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud .tag { border: none; padding: 5px 12px; }

/* ---------- 文章详情页 ---------- */
.post-page { padding: calc(var(--header-h) + 48px) 0 72px; }

.post-container { max-width: 760px; }

.post-header { margin-bottom: 36px; }

.post-title {
  margin: 16px 0 12px;
  font-size: clamp(26px, 4.5vw, 38px);
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ---------- 正文排版 ---------- */
.prose { font-size: 16.5px; }

.prose p { margin-bottom: 1.4em; }
.prose h2 {
  margin: 2em 0 0.8em;
  font-size: 1.45em;
  font-weight: 800;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--border);
}
.prose h3 { margin: 1.8em 0 0.6em; font-size: 1.2em; font-weight: 700; }

.prose ul, .prose ol { margin: 0 0 1.4em 0.4em; }
.prose li { margin-bottom: 0.5em; padding-left: 0.3em; }

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

.prose a { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.prose a:hover { text-decoration: none; }

.prose blockquote {
  margin: 1.8em 0;
  padding: 16px 22px;
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--primary-soft);
  color: var(--text-secondary);
  font-style: normal;
}
.prose blockquote p { margin: 0; }

.prose code {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--primary);
}

.prose pre {
  margin: 1.6em 0;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  background: #0f1120;
  border: 1px solid var(--border);
  overflow-x: auto;
  line-height: 1.7;
}
.prose pre code {
  padding: 0;
  background: none;
  border: none;
  color: #d7dcff;
  font-size: 13.5px;
}

.prose hr { margin: 2.4em 0; border: none; border-top: 1px solid var(--border); }

.prose img { margin: 1.6em auto; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }

/* ---------- 上一篇/下一篇 ---------- */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.post-nav-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.post-nav-item:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.post-nav-item span { font-size: 12px; color: var(--text-secondary); }
.post-nav-item strong { font-size: 14px; font-weight: 600; }

/* ---------- 关于页 ---------- */
.about-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 900px;
}

.about-card {
  padding: 28px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.about-card:first-child { grid-column: 1 / -1; }
.about-card h2 { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.about-card p { color: var(--text-secondary); font-size: 15px; margin-bottom: 10px; }
.about-card ul { list-style: none; }
.about-card li { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 15px; }
.about-card li:last-child { border-bottom: none; }
.about-card a { color: var(--primary); font-weight: 600; }
.about-card a:hover { text-decoration: underline; }

/* ---------- 页脚 ---------- */
.site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: grid;
  grid-template-columns: 1.4fr 2fr;
  gap: 40px;
  padding: 48px 0 32px;
}

.footer-brand p { margin-top: 12px; color: var(--text-secondary); font-size: 14px; }

.footer-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.footer-col h4 { margin-bottom: 12px; font-size: 14px; font-weight: 700; }
.footer-col a {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  transition: color 0.2s ease;
}
.footer-col a:hover { color: var(--primary); }

.footer-bottom {
  padding: 16px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- 返回顶部 ---------- */
.back-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}
.back-top svg { width: 20px; height: 20px; }
.back-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }

/* ---------- 滚动出现动画 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .blog-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar .widget { flex: 1 1 240px; }
}

@media (max-width: 860px) {
  .nav-links {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 4px;
    padding: 16px 24px 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transform: translateY(-16px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
  }
  .nav-links.open { transform: translateY(0); opacity: 1; visibility: visible; }
  .nav-link { display: block; padding: 12px 16px; font-size: 16px; }
  .menu-btn { display: flex; }
  .nav-cta { display: none; }
  .post-nav { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .section { padding: 40px 0 64px; }
  .blog-hero { padding-top: calc(var(--header-h) + 48px); }
  .post-card { padding: 22px 20px; }
  .blog-controls { flex-direction: column; align-items: stretch; }
  .filter-chips { justify-content: center; }
  .about-wrap { grid-template-columns: 1fr; }
  .about-card:first-child { grid-column: auto; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
  .footer-links { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  * { animation: none !important; transition: none !important; }
}
