/* ==========================================
   base.css — 全局基础样式、CSS 变量、字体
   ========================================== */

/* ---------- CSS 变量（全局配色与尺寸） ---------- */
:root {
  /* 主色调：纯白 / 暖白 */
  --color-bg: #FAFAF8;
  --color-surface: #FFFFFF;
  /* 文字色：深炭黑（正文）/ 次要灰（辅助信息） */
  --color-text: #1A1A1A;
  --color-text-secondary: #6B6B6B;
  /* 强调色：暖琥珀 / 冷灰（仅点缀，不大面积使用） */
  --color-accent: #C8924A;
  --color-accent-cool: #8A8A8A;
  /* 状态色：错误 / 成功 */
  --color-error: #C84040;
  --color-success: #4A8C4A;
  /* 导航玻璃效果参数（Apple 风格高透光） */
  --glass-blur: 28px;
  --glass-bg: rgba(255, 255, 255, 0.38);
  --glass-border: rgba(255, 255, 255, 0.25);
  --glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
  --glass-highlight: rgba(255, 255, 255, 0.6);
  /* 圆角 */
  --radius-nav: 20px;
  --radius-card: 12px;
  /* 最大内容宽度 */
  --max-width: 720px;
  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", Menlo,
    Monaco, Consolas, monospace;
}

/* ---------- 暗色模式 ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1A1A1C;
    --color-surface: #242426;
    --color-text: #E6E6E6;
    --color-text-secondary: #9A9A9A;
    --color-accent: #D4A24E;
    --color-accent-cool: #7A7A7A;
    --color-error: #D45555;
    --color-success: #5A9A5A;
    --glass-blur: 28px;
    --glass-bg: rgba(30, 30, 32, 0.45);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.24), 0 1px 4px rgba(0, 0, 0, 0.14);
    --glass-highlight: rgba(255, 255, 255, 0.06);
  }
  /* 暗色模式：文章卡片背景微调 */
  .article-card {
    background: var(--color-surface);
    border-color: rgba(255, 255, 255, 0.06);
  }
  .article-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
  }
  /* 暗色模式：导航按钮 hover */
  .nav-btn:hover,
  .nav-search-btn:hover,
  .social-icon:hover {
    background: rgba(255, 255, 255, 0.06);
  }
  .nav-btn.active {
    background: rgba(255, 255, 255, 0.08);
  }
  /* 暗色模式：搜索输入框背景 */
  .nav-search-wrapper.expanded .nav-search-input {
    background: rgba(255, 255, 255, 0.06);
  }
  /* 暗色模式：搜索结果 hover */
  .search-result-item:hover {
    background: rgba(255, 255, 255, 0.06);
  }
  /* 暗色模式：归档项 hover */
  .archive-item:hover,
  .recent-post-item:hover {
    background: rgba(255, 255, 255, 0.03);
  }
  .recent-post-item {
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }
  /* 暗色模式：归档年份分隔线 */
  .archive-year {
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }
  /* 暗色模式：搜索无结果文字 */
  .search-empty {
    color: var(--color-text-secondary);
  }
  /* 暗色模式：滚动条 */
  ::-webkit-scrollbar-thumb {
    background: #555;
  }
  ::-webkit-scrollbar-track {
    background: transparent;
  }
  /* 暗色模式：选中文字 */
  ::selection {
    color: #1A1A1C;
    background: var(--color-accent);
  }
}

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

/* ---------- 无障碍：跳过导航链接 ---------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 9999;
  padding: 10px 20px;
  background: var(--color-text);
  color: var(--color-bg);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 16px;
}

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

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.7;
  min-height: 100vh;
  /* 为固定导航预留空间 */
  padding-top: 90px;
  padding-bottom: 80px;
}

/* ---------- 链接 ---------- */
a {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* ---------- 标题 ---------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

/* ---------- 段落 ---------- */
p {
  margin-bottom: 1rem;
}

/* ---------- 图片 ---------- */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ---------- 选中文字样式 ---------- */
::selection {
  background: var(--color-accent);
  color: var(--color-surface);
}

/* ---------- 滚动条（Webkit） ---------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-accent-cool);
  border-radius: 3px;
}

/* ========== 动效关键帧 ========== */

/* 淡入上浮 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 纯淡入 */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 轻微上浮（页面容器入场） */
@keyframes contentEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 背景光斑缓慢漂移 */
@keyframes ambientFloat {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(40px, -20px) scale(1.08); }
  66%  { transform: translate(-20px, 30px) scale(0.94); }
  100% { transform: translate(0, 0) scale(1); }
}

/* 导航栏入场 */
@keyframes navSlideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* 脉冲提示（搜索图标等） */
@keyframes subtlePulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

/* ---------- 页面容器入场动画 ---------- */
.page-container {
  animation: contentEnter 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

/* ---------- 文章卡片交错入场 ---------- */
.article-list .article-card {
  opacity: 0;
  animation: fadeInUp 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.article-list .article-card:nth-child(1)  { animation-delay: 0.05s; }
.article-list .article-card:nth-child(2)  { animation-delay: 0.1s;  }
.article-list .article-card:nth-child(3)  { animation-delay: 0.15s; }
.article-list .article-card:nth-child(4)  { animation-delay: 0.2s;  }
.article-list .article-card:nth-child(5)  { animation-delay: 0.25s; }
.article-list .article-card:nth-child(6)  { animation-delay: 0.3s;  }
.article-list .article-card:nth-child(7)  { animation-delay: 0.35s; }
.article-list .article-card:nth-child(8)  { animation-delay: 0.4s;  }
.article-list .article-card:nth-child(9)  { animation-delay: 0.45s; }
.article-list .article-card:nth-child(10) { animation-delay: 0.5s;  }

/* 最近文章项入场 */
.recent-post-item {
  opacity: 0;
  animation: fadeInUp 0.4s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.recent-post-item:nth-child(1) { animation-delay: 0.05s; }
.recent-post-item:nth-child(2) { animation-delay: 0.12s; }
.recent-post-item:nth-child(3) { animation-delay: 0.19s; }
.recent-post-item:nth-child(4) { animation-delay: 0.26s; }
.recent-post-item:nth-child(5) { animation-delay: 0.33s; }

/* 归档项入场 */
.archive-item {
  opacity: 0;
  animation: fadeInUp 0.4s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
.archive-item:nth-child(1)  { animation-delay: 0.04s; }
.archive-item:nth-child(2)  { animation-delay: 0.08s; }
.archive-item:nth-child(3)  { animation-delay: 0.12s; }
.archive-item:nth-child(4)  { animation-delay: 0.16s; }
.archive-item:nth-child(5)  { animation-delay: 0.20s; }
.archive-item:nth-child(6)  { animation-delay: 0.24s; }
.archive-item:nth-child(7)  { animation-delay: 0.28s; }
.archive-item:nth-child(8)  { animation-delay: 0.32s; }
.archive-item:nth-child(9)  { animation-delay: 0.36s; }
.archive-item:nth-child(10) { animation-delay: 0.40s; }

/* 减少动画偏好适配 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
