/* ===== 基础重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ===== 亮色变量 ===== */
:root {
  --bg: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  --card-bg: rgba(255,255,255,0.75);
  --card-border: rgba(255,255,255,0.3);
  --text: #1a1a2e;
  --text-secondary: #555;
  --border: rgba(0,0,0,0.08);
  --accent: #4361ee;
  --accent-light: #4895ef;
  --radius: 16px;
  --shadow: 0 4px 15px rgba(0,0,0,0.06);
  --shadow-hover: 0 8px 30px rgba(67,97,238,0.15);
  --nav-bg: rgba(245,247,250,0.82);
  --progress-color: #4361ee;
}

/* ===== 暗色变量 ===== */
[data-theme="dark"] {
  --bg: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  --card-bg: rgba(31,41,55,0.78);
  --card-border: rgba(255,255,255,0.08);
  --text: #e5e7eb;
  --text-secondary: #9ca3af;
  --border: rgba(255,255,255,0.06);
  --accent: #60a5fa;
  --accent-light: #93c5fd;
  --shadow: 0 4px 15px rgba(0,0,0,0.3);
  --shadow-hover: 0 8px 30px rgba(96,165,250,0.2);
  --nav-bg: rgba(15,12,41,0.86);
  --progress-color: #60a5fa;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  margin: 0;
  padding: 0 20px 40px;
  transition: background 0.5s ease, color 0.3s ease;
}

/* ===== Loading 遮罩 ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: opacity 0.5s ease;
}
.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 进度条 ===== */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--progress-color);
  z-index: 9999;
  transition: width 0.2s ease;
  border-radius: 0 2px 2px 0;
}
.progress-bar.active {
  width: 100%;
  transition: width 1.5s ease;
}

/* ===== 导航 ===== */
.nav {
  position: sticky;
  top: 0;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  z-index: 100;
  flex-wrap: wrap;
  gap: 10px;
}
.nav-brand {
  font-weight: 800;
  font-size: 1.2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-links { display: flex; gap: 18px; }
.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.93rem;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.2s;
  position: relative;
}
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s;
}
.nav-links a:hover { color: var(--accent); background: rgba(67,97,238,0.05); }
.nav-links a.active {
  color: var(--accent);
  font-weight: 600;
  background: rgba(67,97,238,0.1);
  border-radius: 8px;
}
.nav-links a.active::after { width: 80%; }

.nav-right {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-input {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 16px;
  font-size: 0.9rem;
  outline: none;
  color: var(--text);
  width: 170px;
  transition: all 0.3s;
  backdrop-filter: blur(4px);
}
.search-input:focus {
  width: 230px;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(67,97,238,0.2);
}

/* ===== 搜索结果 ===== */
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  width: 350px;
  max-height: 380px;
  overflow-y: auto;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.12);
  padding: 8px;
  z-index: 210;
}
.search-results.hidden { display: none; }
.search-result-item {
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}
.search-result-item:hover { background: var(--border); }
.search-result-type {
  font-size: 0.77rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 2px;
}
.search-result-title { font-weight: 600; font-size: 0.95rem; }
.search-result-snippet { font-size: 0.85rem; color: var(--text-secondary); }

/* ===== 主题按钮 ===== */
.theme-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}
.theme-btn:hover { 
  transform: scale(1.1);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(67,97,238,0.3);
}

/* ===== Hero ===== */
.hero {
  margin-bottom: 42px;
  padding: 40px 0 20px;
  opacity: 0;
  animation: fadeSlideUp 0.8s ease-out forwards;
}
.hero h1 { 
  font-size: 2.8rem; 
  margin-bottom: 0.3rem; 
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero .subtitle { color: var(--text-secondary); font-size: 1.15rem; }
.hero-intro { color: var(--text-secondary); font-size: 0.98rem; margin-top: 12px; }

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 区块 ===== */
.section { margin-bottom: 34px; scroll-margin-top: 72px; }
.section.hidden { display: none; }
.section.active-section { display: block; animation: slideFadeIn 0.4s ease; }

@keyframes slideFadeIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.section-title {
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 18px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  position: relative;
}
.section-title::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 50px;
  height: 2px;
  background: var(--accent);
}

/* ===== 卡片通用 ===== */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}
.card-name { font-weight: 600; font-size: 1.05rem; }
.card-desc { color: var(--text-secondary); font-size: 0.91rem; margin-top: 3px; }

/* ===== 文章/随笔卡片 ===== */
.article-card, .essay-card {
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.article-card:hover, .essay-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}
.article-title, .essay-title { font-weight: 700; font-size: 1.12rem; margin-bottom: 3px; }
.article-date, .essay-date { color: var(--text-secondary); font-size: 0.83rem; margin-bottom: 6px; }
.article-excerpt, .essay-excerpt { color: var(--text); font-size: 0.94rem; }

/* ===== 详情视图 ===== */
.detail-view {
  max-width: 750px;
  margin: 0 auto;
  padding: 20px 0;
}
.detail-view.hidden { display: none; }
.back-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
  margin-bottom: 20px;
  backdrop-filter: blur(4px);
}
.back-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.detail-content {
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 26px 30px;
  box-shadow: var(--shadow);
}
.detail-content h1 { font-size: 1.8rem; margin-bottom: 8px; }
.detail-content .meta { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 20px; }
.detail-content p { margin-bottom: 14px; }
.detail-content strong { font-weight: 700; }
.detail-content em { font-style: italic; }
.detail-content code {
  background: var(--border);
  padding: 2px 8px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.87em;
}
.detail-content blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 18px;
  margin: 14px 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* ===== 关于页 ===== */
.about-bio { margin-bottom: 18px; font-size: 1.05rem; }
.about-skills { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.about-skill {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 16px;
  font-size: 0.88rem;
  transition: all 0.2s;
}
.about-skill:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}
.about-links { display: flex; gap: 20px; }
.about-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  position: relative;
}
.about-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s;
}
.about-links a:hover::after { width: 100%; }

/* ===== 滚动淡入 ===== */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== 页脚 ===== */
.footer {
  margin-top: 58px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.84rem;
}

/* ===== 响应式 ===== */
@media (max-width: 650px) {
  .hero h1 { font-size: 2rem; }
  .nav-links { gap: 10px; }
  .search-input { width: 130px; }
  .search-input:focus { width: 170px; }
  .search-results { right: 0; width: calc(100vw - 40px); }
  body { padding: 0 12px 30px; }
}