/* ============================================================
   个人博客静态页样式表
   结构：
   1. 主题变量（浅色/深色）
   2. 基础重置与通用排版
   3. 通用组件：容器、按钮、卡片、标签
   4. 顶部导航
   5. Hero 首屏
   6. 内容区块：关于我 / 文章 / 项目 / 联系
   7. 页脚 + 回到顶部
   8. 滚动进入动画
   9. 响应式断点
   ============================================================ */

/* ---------- 1. 主题变量 ---------- */
:root {
  /* 品牌色与背景 */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --bg: #f8fafc;
  --bg-alt: #eef2f7;
  --surface: #ffffff;

  /* 文字 */
  --text: #0f172a;
  --text-muted: #52627a;

  /* 边框、阴影、圆角 */
  --border: #e2e8f0;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lift: 0 12px 28px rgba(37, 99, 235, 0.16);
  --radius: 16px;

  /* 布局 */
  --max-width: 1100px;
  --header-height: 64px;
}

/* 深色主题：只需覆盖变量，页面所有颜色会自动跟着变 */
[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-dark: #60a5fa;
  --primary-soft: rgba(59, 130, 246, 0.16);
  --bg: #0f172a;
  --bg-alt: #131f36;
  --surface: #1e293b;

  --text: #e8eef7;
  --text-muted: #9aa9be;

  --border: #2c3a52;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 12px 28px rgba(0, 0, 0, 0.5);
}

/* 让浏览器原生控件（滚动条、表单）也跟随主题 */
html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

/* ---------- 2. 基础重置 ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  /* 导航点击滚动时预留出固定导航栏的高度，避免标题被挡住 */
  scroll-padding-top: calc(var(--header-height) + 12px);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  /* 主题切换时颜色平滑过渡 */
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover { color: var(--primary-dark); }

ul { list-style: none; }

/* 键盘焦点样式：保证 Tab 键能看清当前焦点在哪 */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* 无障碍跳转链接：平时藏在屏幕外，获得焦点才出现 */
.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 999;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 12px;
  color: #fff;
}

/* ---------- 3. 通用组件 ---------- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease,
              box-shadow 0.2s ease, color 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover { background-color: var(--primary-dark); color: #fff; }

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

/* 卡片：圆角 16px + 轻阴影，hover 时轻微上浮 */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: transform 0.25s ease, box-shadow 0.25s ease,
              border-color 0.25s ease, background-color 0.3s ease;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
  border-color: var(--primary);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tag {
  display: inline-block;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  background-color: var(--primary-soft);
  border-radius: 999px;
}
.tag-outline {
  color: var(--text-muted);
  background-color: transparent;
  border: 1px solid var(--border);
}
.tag-list-sm .tag { font-size: 12px; padding: 3px 10px; }

/* 区块通用间距与标题 */
.section { padding: 76px 0; }
.section-alt { background-color: var(--bg-alt); }

.section-head { margin-bottom: 36px; }
.section-title {
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.section-sub {
  margin-top: 6px;
  color: var(--text-muted);
}
/* 标题下的小蓝条 */
.section-title::after {
  content: "";
  display: block;
  width: 44px;
  height: 4px;
  margin-top: 12px;
  border-radius: 999px;
  background-color: var(--primary);
}

/* ---------- 4. 顶部导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  /* 半透明毛玻璃效果；老浏览器不支持 color-mix 时会退回上一行的纯色 */
  background-color: var(--surface);
  background-color: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(10px);
  transition: border-color 0.25s ease, box-shadow 0.25s ease,
              background-color 0.3s ease;
}
/* 页面向下滚动后由 JS 加上 .is-scrolled，出现描边和阴影 */
.site-header.is-scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
}
.logo-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #fff;
  font-size: 16px;
  background-image: linear-gradient(135deg, #3b82f6, #2563eb 60%, #1e40af);
}
.logo-text { font-size: 16px; }

.nav-list {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-link {
  display: block;
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.nav-link:hover {
  color: var(--primary);
  background-color: var(--primary-soft);
}
.nav-link.is-active {
  color: var(--primary);
  background-color: var(--primary-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 图标按钮（主题切换 / 汉堡菜单共用） */
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease,
              color 0.2s ease;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }

.icon { width: 20px; height: 20px; }

/* 主题按钮里的两个图标：根据当前主题只显示其中一个 */
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* 汉堡按钮：默认隐藏，移动端才出现 */
.hamburger {
  display: none;
  position: relative;
}

/* ---------- 5. Hero 首屏 ---------- */
.hero {
  position: relative;
  padding: 90px 0 80px;
  text-align: center;
  overflow: hidden;
  /* 柔和渐变背景 */
  background-image:
    radial-gradient(900px 420px at 15% 0%, rgba(37, 99, 235, 0.16), transparent 70%),
    radial-gradient(700px 380px at 85% 10%, rgba(99, 102, 241, 0.14), transparent 70%);
}

.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 头像占位：圆形渐变 + 首字母 */
.avatar {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  color: #fff;
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background-image: linear-gradient(135deg, #60a5fa, #2563eb 55%, #1e3a8a);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.35);
  /* 外圈光晕 */
  outline: 6px solid var(--primary-soft);
}

.hero-name {
  margin-top: 24px;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.hero-role {
  margin-top: 8px;
  font-size: clamp(15px, 2vw, 18px);
  font-weight: 600;
  color: var(--primary);
}
.hero-desc {
  max-width: 560px;
  margin-top: 12px;
  color: var(--text-muted);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 28px;
}

/* ---------- 6. 各内容区块 ---------- */
.about-grid { max-width: 780px; }
.about-card p + p { margin-top: 14px; }
.skill-title {
  margin: 22px 0 12px;
  font-size: 15px;
  color: var(--text-muted);
}

/* 卡片网格：桌面 2 列，平板/手机自动变成 1 列 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.post-card,
.project-card {
  display: flex;
  flex-direction: column;
}
.card-title {
  font-size: 18px;
  line-height: 1.5;
}
.card-link { color: var(--text); }
.card-link:hover { color: var(--primary); }
/* 卡片整体可点击时，让覆盖层撑满整张卡片 */
.post-card { position: relative; }
.post-card .card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}
.card-desc {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 15px;
}
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}
.project-card .tag-list { margin-top: 18px; }

.project-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 16px;
  border-radius: 12px;
  color: var(--primary);
  background-color: var(--primary-soft);
}
.project-icon svg { width: 24px; height: 24px; }

/* 联系方式卡片 */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}
.contact-link {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  color: var(--text);
}
.contact-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--primary);
  background-color: var(--primary-soft);
}
.contact-icon svg { width: 22px; height: 22px; }
.contact-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
}
.contact-value {
  display: block;
  font-weight: 600;
  word-break: break-all;
}

/* ---------- 7. 页脚 + 回到顶部 ---------- */
.site-footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  background-color: var(--surface);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 90;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background-color: var(--primary);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
  /* 默认隐藏，JS 添加 .is-visible 后淡入 */
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease,
              visibility 0.25s ease, background-color 0.2s ease;
}
.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover { background-color: var(--primary-dark); }
.back-to-top svg { width: 22px; height: 22px; }

/* ---------- 8. 滚动进入动画 ---------- */
/* 默认：元素稍微下移并透明；加上 .is-visible 后归位 */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* 用户系统里开了「减少动态效果」，就全部取消动画 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .card:hover, .btn:hover { transform: none; }
}

/* ---------- 9. 响应式 ---------- */
/* 平板：卡片网格改成 1 列，联系卡片改成 2 列 */
@media (max-width: 900px) {
  .card-grid { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 手机：导航收起成汉堡菜单 */
@media (max-width: 768px) {
  .section { padding: 56px 0; }
  .hero { padding: 64px 0 56px; }

  .hamburger { display: grid; }

  /* 汉堡三条线 */
  .hamburger .bar {
    position: absolute;
    left: 50%;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background-color: currentColor;
    transform: translateX(-50%);
    transition: transform 0.25s ease, opacity 0.2s ease;
  }
  .hamburger .bar:nth-child(1) { top: 14px; }
  .hamburger .bar:nth-child(2) { top: 19px; }
  .hamburger .bar:nth-child(3) { top: 24px; }
  /* 打开状态变成叉号 */
  .hamburger.is-open .bar:nth-child(1) { transform: translateX(-50%) translateY(5px) rotate(45deg); }
  .hamburger.is-open .bar:nth-child(2) { opacity: 0; }
  .hamburger.is-open .bar:nth-child(3) { transform: translateX(-50%) translateY(-5px) rotate(-45deg); }

  /* 下拉式菜单面板 */
  .nav {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    padding: 10px 20px 18px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    /* 默认收起：用 display 控制，键盘也不会误入 */
    display: none;
  }
  .nav.is-open { display: block; }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }
  .nav-link { padding: 12px 14px; font-size: 16px; }
}

@media (max-width: 560px) {
  .contact-grid { grid-template-columns: 1fr; }
  .avatar { width: 96px; height: 96px; font-size: 38px; }
  .header-actions { gap: 6px; }
  .back-to-top { right: 14px; bottom: 16px; }
}
