/* ==========================================================================
   个人主页样式 —— 简约现代
   --------------------------------------------------------------------------
   目录：
   01. 变量与基础
   02. 通用组件（按钮 / 图标 / 标签）
   03. 顶部导航
   04. Hero 首页
   05. 板块通用
   06. 关于我
   07. 技能
   08. 项目
   09. 博客
   10. 联系
   11. 页脚
   12. 滚动浮现动画
   13. 响应式
   ========================================================================== */

/* ---------- 01. 变量与基础 ---------- */
:root {
  /* 浅色主题 */
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #4f46e5;            /* 强调色（链接 / 高亮） */
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;       /* 强调色浅底 */
  --btn-bg: #4f46e5;            /* 主按钮背景 */
  --btn-bg-hover: #4338ca;
  --btn-text: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.1);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.12);
  --radius: 14px;
  --nav-h: 64px;
}

[data-theme="dark"] {
  /* 深色主题 */
  --bg: #0f172a;
  --bg-alt: #151f36;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #2c3a57;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --btn-bg: #6366f1;
  --btn-bg-hover: #818cf8;
  --btn-text: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.45);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

img {
  max-width: 100%;
  display: block;
}

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

ul {
  list-style: none;
}

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

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

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 02. 通用组件 ---------- */
.icon {
  width: 20px;
  height: 20px;
  display: block;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease,
    color 0.2s ease, border-color 0.2s ease;
}

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

.btn-primary:hover {
  background: var(--btn-bg-hover);
  color: var(--btn-text);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  border: 1px solid var(--border);
  color: var(--text);
  background: transparent;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

.btn-lg {
  padding: 15px 38px;
  font-size: 1.08rem;
}

/* 圆形图标按钮 */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg);
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease,
    box-shadow 0.2s ease;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* ---------- 03. 顶部导航 ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.site-header.scrolled {
  border-bottom-color: var(--border);
}

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

.nav-logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text);
}

.nav-logo:hover {
  color: var(--accent);
}

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

.nav-link {
  display: block;
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.95rem;
  transition: color 0.2s ease, background 0.2s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-alt);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

/* 主题切换按钮 */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-left: 8px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.icon-sun {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

/* 汉堡菜单按钮（移动端显示） */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-toggle span {
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---------- 04. Hero 首页 ---------- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: calc(var(--nav-h) + 48px) 0 64px;
}

.hero-inner {
  text-align: center;
  max-width: 760px;
  margin: 0 auto;
}

.avatar {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  margin: 0 auto 28px;
  box-shadow: 0 8px 30px rgba(79, 70, 229, 0.25);
}

.hero-greeting {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.hero-name {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.2;
  margin-bottom: 14px;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 560px;
  margin: 0 auto 36px;
}

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

.hero-socials {
  margin-top: 40px;
  display: flex;
  gap: 14px;
  justify-content: center;
}

/* ---------- 05. 板块通用 ---------- */
.section {
  padding: 96px 0;
  scroll-margin-top: calc(var(--nav-h) + 12px);
}

.section-alt {
  background: var(--bg-alt);
}

.section-head {
  text-align: center;
  margin-bottom: 56px;
}

.section-eyebrow {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.section-title {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-top: 10px;
}

.section-desc {
  color: var(--text-muted);
  margin: 14px auto 0;
  max-width: 560px;
}

/* ---------- 06. 关于我 ---------- */
.about-body {
  max-width: 680px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
  font-size: 1.05rem;
}

.about-body .hl {
  color: var(--accent);
  font-weight: 600;
}

.about-facts {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 44px;
}

.about-facts li {
  min-width: 160px;
  text-align: center;
  padding: 18px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.about-facts span {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.about-facts b {
  display: block;
  margin-top: 6px;
  font-size: 1.05rem;
}

/* ---------- 07. 技能 ---------- */
.skills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 720px;
  margin: 0 auto;
}

.tag {
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--text);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease,
    transform 0.2s ease;
}

.tag:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}

/* ---------- 08. 项目 ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.project-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.project-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.project-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  flex: 1;
}

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

.mini-tag {
  font-size: 0.78rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 500;
}

.project-links {
  display: flex;
  gap: 18px;
  font-size: 0.92rem;
  font-weight: 600;
}

.project-links a:hover {
  text-decoration: underline;
}

.more-link {
  text-align: center;
  margin-top: 40px;
  font-size: 0.98rem;
}

/* ---------- 09. 博客 ---------- */
.blog-list {
  max-width: 720px;
  margin: 0 auto;
}

.blog-item {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 20px 10px;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}

.blog-item:hover {
  background: var(--bg-alt);
}

.blog-date {
  color: var(--text-muted);
  font-size: 0.85rem;
  min-width: 92px;
  font-variant-numeric: tabular-nums;
}

.blog-title {
  color: var(--text);
  font-weight: 600;
  flex: 1;
  transition: color 0.2s ease;
}

.blog-item:hover .blog-title {
  color: var(--accent);
}

.blog-arrow {
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
}

.blog-item:hover .blog-arrow {
  color: var(--accent);
  transform: translateX(4px);
}

/* 博客入口 */
.blog-cta {
  text-align: center;
  margin-top: 8px;
}

/* ---------- 10. 联系 ---------- */
.contact-inner {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

.contact-inner .section-head {
  margin-bottom: 36px;
}

.contact-links {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 36px;
}

.contact-note {
  color: var(--text-muted);
  margin-top: 28px;
  font-size: 0.95rem;
}

/* ---------- 11. 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ---------- 12. 滚动浮现动画 ---------- */
/* 仅在启用了 JS 时才隐藏元素，保证无 JS 时内容可见 */
.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.js .reveal.visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
  }
}

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

@media (max-width: 768px) {
  .section {
    padding: 72px 0;
  }

  /* 移动端导航 */
  .nav-toggle {
    display: flex;
  }

  .nav-menu {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    display: none;
    padding: 10px 8px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-link {
    padding: 12px 16px;
  }

  .theme-toggle {
    margin-left: 0;
    align-self: flex-start;
  }

  .hero {
    min-height: auto;
    padding-top: calc(var(--nav-h) + 56px);
  }

  .blog-date {
    min-width: 80px;
  }
}

@media (max-width: 560px) {
  .projects-grid {
    grid-template-columns: 1fr;
  }

  .about-facts li {
    min-width: 140px;
  }
}
