/* ============================================
   八千里路云和月 - 个人技术分享网站 样式表
   ============================================ */

/* ---------- CSS 变量 ---------- */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fb;
  --bg-tertiary: #f1f3f6;
  --text-primary: #1a1a2e;
  --text-secondary: #5a5f72;
  --text-muted: #9498a8;
  --accent: #4f46e5;
  --accent-light: #818cf8;
  --accent-bg: #eef2ff;
  --border: #e5e7eb;
  --border-light: #f0f0f5;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* 代码主题 */
  --code-bg: #1e1e2e;
  --code-text: #cdd6f4;
  --code-keyword: #cba6f7;
  --code-fn: #89b4fa;
  --code-string: #a6e3a1;
  --code-type: #f9e2af;
  --code-param: #f38ba8;
  --code-bool: #fab387;
  --code-comment: #6c7086;

  --font-sans: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* 暗色主题 */
[data-theme="dark"] {
  --bg-primary: #0f0f1a;
  --bg-secondary: #16162a;
  --bg-tertiary: #1e1e36;
  --text-primary: #e4e4ef;
  --text-secondary: #a0a4b8;
  --text-muted: #6b6f85;
  --accent: #818cf8;
  --accent-light: #a5b4fc;
  --accent-bg: #1e1b4b;
  --border: #2a2a45;
  --border-light: #222240;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

/* ---------- 全局重置 ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

ul, ol {
  list-style: none;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 头部导航 ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(12px);
  transition: background var(--transition), border-color var(--transition);
  height: 64px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  transition: color var(--transition);
}

.logo-icon {
  font-size: 1.5rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.nav-link:hover {
  color: var(--accent);
  background: var(--accent-bg);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}

.theme-toggle {
  margin-left: 12px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.icon-sun { display: inline; }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: inline; }

/* ---------- Hero 区域 ---------- */
.hero {
  padding: 80px 0 60px;
  overflow: hidden;
}

.hero .container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  align-items: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 50px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 24px;
}

.hero-title {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

.hero-highlight {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -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: 32px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 48px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.3);
}

.btn-outline {
  border-color: var(--border);
  background: transparent;
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.hero-stats {
  display: flex;
  gap: 40px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Hero 视觉区域 */
.hero-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-shapes {
  position: absolute;
  inset: 0;
}

.shape {
  position: absolute;
  border-radius: 50%;
  opacity: 0.15;
  filter: blur(60px);
}

.shape-1 {
  width: 200px; height: 200px; background: var(--accent);
  top: 10%; right: 10%; animation: float1 6s ease-in-out infinite;
}
.shape-2 {
  width: 150px; height: 150px; background: #06b6d4;
  bottom: 20%; left: 5%; animation: float2 8s ease-in-out infinite;
}
.shape-3 {
  width: 100px; height: 100px; background: #f59e0b;
  top: 40%; right: 30%; animation: float3 7s ease-in-out infinite;
}
.shape-4 {
  width: 80px; height: 80px; background: #10b981;
  bottom: 10%; right: 20%; animation: float1 5s ease-in-out infinite;
}

@keyframes float1 {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.05); }
}
@keyframes float2 {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(15px) scale(0.95); }
}
@keyframes float3 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(10px, -15px); }
}

/* 代码卡片 */
.hero-code-card {
  position: relative; z-index: 1;
  background: var(--code-bg);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px;
}

.code-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
}
.code-dot { width: 12px; height: 12px; border-radius: 50%; }
.code-dot.red { background: #ff5f57; }
.code-dot.yellow { background: #febc2e; }
.code-dot.green { background: #28c840; }

.code-filename {
  margin-left: auto; font-size: 0.75rem;
  color: var(--code-comment); font-family: var(--font-mono);
}

.code-block {
  font-family: var(--font-mono); font-size: 0.85rem;
  line-height: 1.8; color: var(--code-text); overflow-x: auto;
}
.code-block .keyword { color: var(--code-keyword); }
.code-block .fn { color: var(--code-fn); }
.code-block .string { color: var(--code-string); }
.code-block .type { color: var(--code-type); }
.code-block .param { color: var(--code-param); }
.code-block .bool { color: var(--code-bool); }
.code-block .comment { color: var(--code-comment); }

/* ---------- 通用 Section ---------- */
.section { padding: 72px 0; }
.section-alt { background: var(--bg-secondary); transition: background var(--transition); }

.section-header {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: 40px; flex-wrap: wrap;
}
.section-title { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.01em; }
.section-subtitle { color: var(--text-muted); font-size: 0.95rem; }
.section-more {
  margin-left: auto; color: var(--accent);
  font-size: 0.9rem; font-weight: 500; transition: color var(--transition);
}
.section-more:hover { color: var(--accent-light); }

/* ---------- 文章卡片 ---------- */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

.article-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: all var(--transition);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 16px;
}
.article-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-light);
}

.card-category {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 50px;
  font-size: 0.75rem; font-weight: 600; width: fit-content;
}
.cat-frontend { background: #ede9fe; color: #7c3aed; }
.cat-backend { background: #dbeafe; color: #2563eb; }
.cat-architecture { background: #fef3c7; color: #d97706; }
.cat-devops { background: #d1fae5; color: #059669; }
.cat-ai { background: #fce7f3; color: #db2777; }

[data-theme="dark"] .cat-frontend { background: #3b1f82; color: #c4b5fd; }
[data-theme="dark"] .cat-backend { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .cat-architecture { background: #5c3d0e; color: #fde68a; }
[data-theme="dark"] .cat-devops { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .cat-ai { background: #5c1337; color: #f9a8d4; }

.card-title {
  font-size: 1.15rem; font-weight: 600; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.card-excerpt {
  font-size: 0.9rem; color: var(--text-secondary); line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; flex: 1;
}
.card-meta {
  display: flex; align-items: center; gap: 12px;
  font-size: 0.8rem; color: var(--text-muted);
}
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.card-tag {
  padding: 3px 10px; border-radius: 50px; font-size: 0.7rem;
  background: var(--bg-tertiary); color: var(--text-muted);
  transition: all var(--transition);
}

/* ---------- 分类卡片 ---------- */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.category-card {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  text-align: center; cursor: pointer; transition: all var(--transition);
}
.category-card:hover {
  transform: translateY(-3px); box-shadow: var(--shadow-md);
  border-color: var(--accent-light);
}
.category-icon { font-size: 2rem; margin-bottom: 12px; }
.category-name { font-weight: 600; font-size: 1rem; margin-bottom: 4px; }
.category-count { font-size: 0.8rem; color: var(--text-muted); }

/* ---------- 文章列表页 ---------- */
.page-header { padding: 48px 0 0; }
.page-title { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.01em; }
.page-desc { color: var(--text-muted); margin-top: 8px; }

.filter-bar { padding-top: 32px; padding-bottom: 0; }
.filter-inner { display: flex; flex-direction: column; gap: 16px; }

.search-box {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border: 1px solid var(--border);
  border-radius: var(--radius-xl); background: var(--bg-primary);
  transition: all var(--transition); max-width: 480px;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.search-icon { font-size: 1rem; opacity: 0.5; }
.search-box input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 0.95rem; color: var(--text-primary); font-family: var(--font-sans);
}
.search-box input::placeholder { color: var(--text-muted); }

.filter-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-tag {
  padding: 8px 20px; border-radius: 50px; font-size: 0.85rem;
  font-weight: 500; cursor: pointer; border: 1px solid var(--border);
  background: var(--bg-primary); color: var(--text-secondary);
  transition: all var(--transition); font-family: var(--font-sans);
}
.filter-tag:hover { border-color: var(--accent-light); color: var(--accent); }
.filter-tag.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.article-count { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; }

.article-list { display: flex; flex-direction: column; gap: 16px; }
.article-list-item {
  display: flex; align-items: center; gap: 24px;
  padding: 24px 28px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--bg-primary);
  transition: all var(--transition); cursor: pointer;
}
.article-list-item:hover {
  transform: translateX(4px); box-shadow: var(--shadow-md);
  border-color: var(--accent-light);
}
.list-item-date { font-size: 0.8rem; color: var(--text-muted); min-width: 90px; flex-shrink: 0; }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.list-item-excerpt {
  font-size: 0.85rem; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-item-category { flex-shrink: 0; }

.empty-state { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }

/* ---------- 文章详情页 ---------- */
.article-hero { padding: 40px 0 32px; border-bottom: 1px solid var(--border-light); }
.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.9rem; color: var(--text-muted);
  margin-bottom: 24px; transition: color var(--transition);
}
.back-link:hover { color: var(--accent); }

.article-meta-top {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.article-category-tag {
  padding: 4px 14px; border-radius: 50px;
  font-size: 0.8rem; font-weight: 600;
}
.article-date, .article-read-time { font-size: 0.85rem; color: var(--text-muted); }
.article-title {
  font-size: 2.2rem; font-weight: 700; line-height: 1.3;
  letter-spacing: -0.01em; margin-bottom: 16px;
}
.article-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.article-tag {
  padding: 5px 14px; border-radius: 50px; font-size: 0.8rem;
  background: var(--bg-tertiary); color: var(--text-secondary);
}

/* 文章内容布局 */
.article-content-wrapper {
  display: grid; grid-template-columns: 200px 1fr;
  gap: 48px; align-items: start;
}

/* 目录 */
.article-toc {
  position: sticky; top: 88px; padding: 20px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-primary);
}
.article-toc h4 {
  font-size: 0.85rem; font-weight: 700; margin-bottom: 12px;
  color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: 0.05em;
}
.toc-list { display: flex; flex-direction: column; gap: 2px; }
.toc-item {
  padding: 6px 10px; border-radius: var(--radius-sm);
  font-size: 0.85rem; color: var(--text-muted);
  cursor: pointer; transition: all var(--transition);
  border-left: 2px solid transparent;
}
.toc-item:hover { color: var(--accent); background: var(--accent-bg); }
.toc-item.active {
  color: var(--accent); background: var(--accent-bg);
  border-left-color: var(--accent); font-weight: 500;
}
.toc-item.level-2 { padding-left: 22px; }

/* 文章正文 */
.article-content { font-size: 1.05rem; line-height: 1.9; color: var(--text-primary); }
.article-content h2 {
  font-size: 1.6rem; font-weight: 700; margin: 48px 0 20px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border-light);
}
.article-content h3 { font-size: 1.25rem; font-weight: 600; margin: 36px 0 16px; }
.article-content p { margin-bottom: 20px; color: var(--text-secondary); }
.article-content ul, .article-content ol { margin: 12px 0 20px 20px; }
.article-content li { margin-bottom: 6px; color: var(--text-secondary); list-style: disc; }
.article-content ol li { list-style: decimal; }
.article-content strong { color: var(--text-primary); }
.article-content a {
  color: var(--accent); border-bottom: 1px solid transparent;
  transition: border-color var(--transition);
}
.article-content a:hover { border-bottom-color: var(--accent); }
.article-content blockquote {
  margin: 24px 0; padding: 16px 24px;
  border-left: 4px solid var(--accent); background: var(--accent-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}
.article-content blockquote p { margin: 0; }
.article-content pre {
  margin: 24px 0; border-radius: var(--radius-md);
  overflow-x: auto; background: var(--code-bg) !important;
}
.article-content pre code {
  font-family: var(--font-mono); font-size: 0.88rem;
  padding: 20px 24px; display: block; line-height: 1.7;
}
.article-content code {
  font-family: var(--font-mono); font-size: 0.88em;
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg-tertiary); color: var(--accent);
}
.article-content pre code {
  color: var(--code-text); background: transparent;
  padding: 0; border-radius: 0;
}
.article-content hr { border: none; border-top: 1px solid var(--border-light); margin: 40px 0; }

/* 上一篇 / 下一篇 */
.nav-posts { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.nav-post {
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 24px; border: 1px solid var(--border);
  border-radius: var(--radius-md); transition: all var(--transition);
  cursor: pointer; background: var(--bg-primary);
}
.nav-post:hover { border-color: var(--accent-light); box-shadow: var(--shadow-md); }
.nav-post.prev { align-items: flex-start; }
.nav-post.next { align-items: flex-end; text-align: right; }
.nav-post-label {
  font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.nav-post-title { font-size: 0.95rem; font-weight: 500; color: var(--text-primary); }

/* ---------- 页脚 ---------- */
.footer {
  padding: 48px 0 24px; border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
}
.footer-inner {
  display: flex; justify-content: space-between;
  gap: 48px; flex-wrap: wrap; margin-bottom: 32px;
}
.footer-brand { display: flex; flex-direction: column; gap: 8px; }
.footer-brand .logo-icon { font-size: 2rem; }
.footer-brand .logo-text { font-size: 1.25rem; font-weight: 700; }
.footer-brand p { font-size: 0.85rem; color: var(--text-muted); }
.footer-links { display: flex; gap: 64px; flex-wrap: wrap; }
.footer-col h4 {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-secondary); margin-bottom: 12px;
}
.footer-col a {
  display: block; font-size: 0.88rem; color: var(--text-muted);
  padding: 4px 0; transition: color var(--transition);
}
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  padding-top: 20px; border-top: 1px solid var(--border-light);
  text-align: center;
}
.footer-bottom p { font-size: 0.8rem; color: var(--text-muted); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .hero .container { grid-template-columns: 1fr; gap: 48px; }
  .hero-title { font-size: 2.2rem; }
  .hero-visual { order: -1; display: none; }
  .article-content-wrapper { grid-template-columns: 1fr; }
  .article-toc { display: none; }
  .nav-posts { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .hero-title { font-size: 1.8rem; }
  .hero-stats { gap: 24px; }
  .articles-grid { grid-template-columns: 1fr; }
  .article-list-item { flex-direction: column; align-items: flex-start; gap: 8px; }
  .list-item-date { min-width: unset; }
  .section-header { flex-direction: column; gap: 4px; }
  .section-more { margin-left: 0; }
  .footer-inner { flex-direction: column; }
  .footer-links { gap: 32px; }
}
