/* ==========================================================
   个人网站样式表
   颜色、字体等全局变量都在 :root 中，方便统一修改
   ========================================================== */

:root {
  --accent-1: #6366f1;   /* 主色（靛蓝） */
  --accent-2: #a855f7;   /* 辅色（紫色） */
  --accent-3: #22d3ee;   /* 点缀色（青色） */

  --radius: 16px;
  --shadow: 0 8px 30px rgba(2, 6, 23, 0.08);
  --shadow-lg: 0 18px 50px rgba(2, 6, 23, 0.16);
  --max-width: 1100px;
  --nav-height: 68px;
}

/* 浅色主题（默认） */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8fc;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --header-bg: rgba(255, 255, 255, 0.78);
  --hero-bg: linear-gradient(150deg, #eef2ff 0%, #f5f3ff 45%, #ecfeff 100%);
}

/* 深色主题 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --bg-soft: #101a33;
  --card: #111a31;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --line: #1e293b;
  --header-bg: rgba(11, 17, 32, 0.8);
  --hero-bg: linear-gradient(150deg, #101c3d 0%, #1d1438 45%, #0d2b34 100%);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.5);
}

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

html {
  scroll-behavior: smooth;
}

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

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

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

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

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

section {
  scroll-margin-top: calc(var(--nav-height) + 12px);
}

.container {
  width: min(var(--max-width), 100% - 2.5rem);
  margin-inline: auto;
}

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

/* ---------- 顶部滚动进度条 ---------- */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2), var(--accent-3));
  z-index: 1200;
}

/* ---------- 导航栏 ---------- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  z-index: 1000;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.nav.scrolled {
  border-bottom-color: var(--line);
  box-shadow: 0 4px 20px rgba(2, 6, 23, 0.06);
}

.nav-inner {
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
}

.brand:hover {
  color: var(--accent-1);
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  padding: 0.45rem 0.85rem;
  border-radius: 10px;
  color: var(--text);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent-1);
  background: color-mix(in srgb, var(--accent-1) 8%, transparent);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-left: 0.4rem;
  border-radius: 50%;
  color: var(--text);
  background: color-mix(in srgb, var(--accent-1) 8%, transparent);
  transition: color 0.25s ease, transform 0.25s ease, background-color 0.25s ease;
}

.theme-toggle:hover {
  color: var(--accent-1);
  transform: rotate(18deg);
}

:root[data-theme="dark"] #icon-sun,
:root:not([data-theme="dark"]) #icon-moon {
  display: none;
}

/* 汉堡菜单按钮：移动端显示 */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 8px;
  border-radius: 10px;
}

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

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---------- 英雄区 ---------- */
.hero {
  position: relative;
  padding: calc(var(--nav-height) + 5rem) 0 7rem;
  text-align: center;
  background: var(--hero-bg);
  overflow: hidden;
}

.hero-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-greeting {
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-name {
  margin: 0.3rem 0 0.6rem;
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  line-height: 1.15;
  letter-spacing: 0.02em;
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero-type {
  min-height: 2rem;
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  color: var(--text);
}

.type-prefix {
  color: var(--muted);
}

.type-text {
  font-weight: 600;
  color: var(--accent-1);
}

.type-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  margin-left: 3px;
  vertical-align: text-bottom;
  background: var(--accent-2);
  animation: blink 0.9s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.hero-bio {
  max-width: 580px;
  margin: 1.2rem auto 0;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 2rem;
}

.hero-social {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.8rem;
}

.hero-social a {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text);
  background: color-mix(in srgb, var(--card) 80%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: color 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

.hero-social a:hover {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  transform: translateY(-3px);
}

.hero-social svg {
  width: 20px;
  height: 20px;
}

.hero-wave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  z-index: 1;
  line-height: 0;
}

.hero-wave path {
  fill: var(--bg);
  transition: fill 0.35s ease;
}

/* ---------- 通用区块 ---------- */
.section {
  padding: 5rem 0;
}

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

.section-title {
  text-align: center;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  position: relative;
}

.section-title::after {
  content: "";
  display: block;
  width: 64px;
  height: 4px;
  margin: 0.75rem auto 0;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
}

.section-subtitle {
  text-align: center;
  margin: 0.35rem 0 3rem;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.section-note {
  margin-top: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- 关于我 ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.6rem;
}

.about-card {
  padding: 2rem;
}

.about-card h3 {
  margin-bottom: 0.8rem;
  font-size: 1.2rem;
}

.about-card p + p {
  margin-top: 0.8rem;
}

.about-card p {
  color: var(--muted);
}

.about-card p strong {
  color: var(--text);
}

.info-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.info-list li {
  display: flex;
  gap: 1rem;
}

.info-label {
  flex: 0 0 5.2em;
  color: var(--muted);
}

.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  display: inline-block;
  padding: 0.16rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--accent-1);
  background: color-mix(in srgb, var(--accent-1) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-1) 25%, transparent);
}

/* ---------- 作品集 ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.6rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  padding: 1.8rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.project-thumb {
  display: grid;
  place-items: center;
  height: 130px;
  margin: -1.8rem -1.8rem 1.5rem;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 2.8rem;
  background:
    radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--accent-1) 35%, transparent), transparent 55%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, var(--accent-2) 35%, transparent), transparent 55%),
    var(--bg-soft);
}

.project-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.6rem;
}

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

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1.1rem 0 1.2rem;
}

.project-links {
  display: flex;
  gap: 1.2rem;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------- 联系 ---------- */
.contact-card {
  max-width: 720px;
  margin-inline: auto;
  padding: 2.5rem;
  text-align: center;
}

.contact-intro {
  color: var(--muted);
  margin-bottom: 1.8rem;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.75rem 1.7rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.98rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease, color 0.25s ease,
    background-color 0.25s ease, border-color 0.25s ease;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.45);
}

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

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

.contact-list {
  list-style: none;
  margin-top: 1.6rem;
  color: var(--muted);
  font-size: 0.94rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.8rem;
}

/* ---------- 页脚 ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 1.8rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.footer-links {
  display: flex;
  gap: 1.2rem;
}

/* ---------- 回到顶部 ---------- */
.back-to-top {
  position: fixed;
  right: 1.4rem;
  bottom: 1.4rem;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
  z-index: 900;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top svg {
  width: 20px;
  height: 20px;
}

/* ---------- 滚动显现动画 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

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

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .about-grid {
    grid-template-columns: 1fr;
  }

  .about-grid .about-card:first-child {
    order: 2;
  }
}

@media (max-width: 640px) {
  .nav-toggle {
    display: flex;
  }

  .nav-menu {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
    padding: 1rem 1.25rem 1.3rem;
    background: var(--header-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateY(-120%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.35s ease, opacity 0.35s ease, visibility 0.35s ease;
  }

  .nav-menu.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .nav-menu .nav-link {
    padding: 0.85rem 0.9rem;
  }

  .theme-toggle {
    position: absolute;
    right: 5.1rem;
    top: 0.85rem;
  }

  .hero {
    padding-top: calc(var(--nav-height) + 3.6rem);
  }

  .card {
    padding: 1.4rem;
  }

  .info-list li {
    flex-direction: column;
    gap: 0.15rem;
  }

  .contact-card {
    padding: 1.8rem 1.4rem;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

/* 尊重系统“减少动态效果”设置 */
@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;
  }
}
