/* ========== 基础重置 ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-hover: #1a1a26;
  --border: #1e1e2e;
  --text: #e4e4e7;
  --text-dim: #71717a;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --radius: 12px;
  --max-w: 1100px;
  --nav-bg: rgba(10, 10, 15, 0.8);
  --nav-bg-scroll: rgba(10, 10, 15, 0.95);
  --nav-mobile-bg: rgba(10, 10, 15, 0.95);
  --grid-line: rgba(99, 102, 241, 0.04);
  --skill-bar-bg: #1e1e2e;
}

[data-theme="light"] {
  --bg: #f8f9fc;
  --surface: #eef0f5;
  --surface-hover: #e4e6ed;
  --border: #d4d7e0;
  --text: #18181b;
  --text-dim: #6b7280;
  --accent: #4f46e5;
  --accent-light: #6366f1;
  --accent-glow: rgba(79, 70, 229, 0.1);
  --nav-bg: rgba(248, 249, 252, 0.85);
  --nav-bg-scroll: rgba(248, 249, 252, 0.95);
  --nav-mobile-bg: rgba(248, 249, 252, 0.97);
  --grid-line: rgba(79, 70, 229, 0.06);
  --skill-bar-bg: #d4d7e0;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

/* ========== 导航栏 ========== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s;
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent-light);
}

.nav-links {
  display: flex; gap: 32px; list-style: none;
}

.nav-links a {
  font-size: 0.9rem;
  color: var(--text-dim);
  transition: color 0.2s;
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute; bottom: -4px; left: 0;
  width: 0; height: 2px;
  background: var(--accent);
  transition: width 0.3s;
}

.nav-links a:hover { color: var(--text); }
.nav-links a:hover::after { width: 100%; }

/* 主题切换 */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

.theme-toggle svg {
  width: 18px; height: 18px;
  position: absolute;
  transition: transform 0.4s, opacity 0.4s;
}

.icon-sun { transform: rotate(0) scale(1); opacity: 1; }
.icon-moon { transform: rotate(90deg) scale(0); opacity: 0; }

[data-theme="light"] .icon-sun { transform: rotate(90deg) scale(0); opacity: 0; }
[data-theme="light"] .icon-moon { transform: rotate(0) scale(1); opacity: 1; }

[data-theme="light"] .avatar { box-shadow: 0 0 40px rgba(79, 70, 229, 0.2); }
[data-theme="light"] .skill-card,
[data-theme="light"] .contact-card { background: #fff; }
[data-theme="light"] .project-card { background: #fff; }
[data-theme="light"] .btn-primary { color: #fff; }

.nav-toggle {
  display: none;
  flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer;
}

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

/* ========== 首屏 ========== */
.hero {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  padding: 120px 24px 80px;
  overflow: hidden;
}

.hero-content {
  text-align: center;
  position: relative; z-index: 2;
}

.avatar-wrapper { margin-bottom: 32px; }

.avatar {
  width: 96px; height: 96px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 50%;
  box-shadow: 0 0 40px var(--accent-glow);
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.highlight {
  background: linear-gradient(135deg, var(--accent-light), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.15rem;
  color: var(--text-dim);
  margin-top: 12px;
  letter-spacing: 0.06em;
}

.description {
  max-width: 540px;
  margin: 20px auto 0;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1.8;
}

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

.btn {
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.25s;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
}

.btn-primary:hover {
  background: var(--accent-light);
  box-shadow: 0 0 24px var(--accent-glow);
  transform: translateY(-1px);
}

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

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

/* 背景网格 */
.hero-bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}

/* ========== 通用 Section ========== */
.section {
  padding: 100px 0;
}

.section-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.02em;
}

.section-desc {
  text-align: center;
  color: var(--text-dim);
  margin-top: 8px;
  margin-bottom: 56px;
}

/* ========== 技能 ========== */
.skills-section {
  background: var(--surface);
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 20px;
}

.skill-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: all 0.3s;
}

.skill-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 32px var(--accent-glow);
  transform: translateY(-2px);
}

.skill-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-light);
  margin-bottom: 16px;
}

.skill-icon svg { width: 28px; height: 28px; }

.skill-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.skill-card p {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.skill-bar {
  height: 4px;
  background: var(--skill-bar-bg);
  border-radius: 4px;
  overflow: hidden;
}

.skill-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  border-radius: 4px;
  transition: width 1.2s ease;
}

.skill-fill.animate { width: var(--w); }

/* ========== 作品 ========== */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 20px;
}

.project-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: all 0.3s;
}

.project-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 32px var(--accent-glow);
  transform: translateY(-2px);
}

.project-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.project-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent-light);
}

.project-arrow {
  width: 20px; height: 20px;
  color: var(--text-dim);
  transition: all 0.3s;
}

.project-card:hover .project-arrow {
  color: var(--accent-light);
  transform: translate(2px, -2px);
}

.project-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.project-card p {
  color: var(--text-dim);
  font-size: 0.9rem;
  flex: 1;
}

.project-tech {
  margin-top: 16px;
  font-size: 0.78rem;
  color: var(--text-dim);
  opacity: 0.7;
}

/* ========== 联系 ========== */
.contact-section {
  background: var(--surface);
}

.contact-cards {
  display: flex; gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.contact-card {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.3s;
  cursor: default;
}

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

.contact-card svg {
  width: 22px; height: 22px;
  color: var(--accent-light);
  flex-shrink: 0;
}

.contact-card span {
  font-size: 0.95rem;
  color: var(--text-dim);
}

/* 微信二维码弹窗 */
.wechat-card {
  position: relative;
  cursor: pointer;
}

.wechat-qr {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.wechat-qr::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border);
}

.wechat-qr img {
  width: 160px;
  height: 160px;
  border-radius: 6px;
  display: block;
  object-fit: cover;
}

.wechat-qr p {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.wechat-card:hover .wechat-qr,
.wechat-card.active .wechat-qr {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

/* ========== 页脚 ========== */
.footer {
  text-align: center;
  padding: 32px;
  color: var(--text-dim);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

/* ========== 动画 ========== */
.fade-up {
  opacity: 0;
  transform: translateY(24px);
  animation: fadeUp 0.8s ease forwards;
}

.delay-1 { animation-delay: 0.15s; }
.delay-2 { animation-delay: 0.3s; }
.delay-3 { animation-delay: 0.45s; }

@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

/* 滚动显示 */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s, transform 0.7s;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-toggle { display: flex; }

  .nav-links.open {
    display: flex; flex-direction: column;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--nav-mobile-bg);
    backdrop-filter: blur(16px);
    padding: 20px 32px;
    gap: 16px;
    border-bottom: 1px solid var(--border);
  }

  .hero { padding: 100px 20px 60px; }
  .hero h1 { font-size: 1.8rem; }

  .skills-grid,
  .projects-grid {
    grid-template-columns: 1fr;
  }

  .contact-cards { flex-direction: column; align-items: stretch; }
}
