/* ========================================
   CSS Variables & Theme (Professional & Clean)
   ======================================== */
:root {
  --primary: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --primary-bg: #dbeafe;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --bg-white: #ffffff;
  --bg-alt: #f3f7ff;
  --bg-card: #ffffff;
  --bg-hero: #eef4ff;

  --border: #c7d2e8;
  --border-light: #dce4f5;

  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08);
  --shadow-md: 0 4px 8px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 20px -3px rgb(0 0 0 / 0.08), 0 4px 8px -4px rgb(0 0 0 / 0.06);
  --shadow-hover: 0 20px 40px -5px rgba(15, 23, 42, 0.12), 0 10px 20px -5px rgba(15, 23, 42, 0.08);

  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;

  /* 优化缓动函数，使其具有高级的弹性阻尼感 */
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);

  --font-en: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-zh: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --max-width: 1000px;
}
/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
}
body {
  font-family: var(--font-en);
  color: var(--text-secondary);
  background: var(--bg-white);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.lang-zh { font-family: var(--font-zh); }
::selection { background-color: var(--primary-light); color: var(--bg-white); }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
ul { list-style: none; }
img { max-width: 100%; display: block; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
/* ========================================
   [Req 7] Language Text Fade Transition
   ======================================== */
[data-en][data-zh] {
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: inline-block; /* 确保 transform 生效 */
}
.lang-switching [data-en][data-zh] {
  opacity: 0 !important;
  transform: translateY(4px);
}
/* ========================================
   [Req 6] Navigation (Enhanced Glassmorphism)
   ======================================== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0); /* 初始透明 */
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  border-bottom: 1px solid transparent;
  transition: background-color 0.5s ease, backdrop-filter 0.5s ease, box-shadow 0.5s ease, padding 0.3s ease;
  padding: 10px 0;
}
.navbar.scrolled {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
  padding: 0; /* 滚动时导航栏收缩 */
}
.nav-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}
.nav-logo { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.nav-logo:hover { color: var(--primary); }
.nav-menu { display: flex; gap: 24px; }
.nav-link { display: inline-block; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); position: relative; padding: 4px 0; }
.nav-link::after {
  content: ''; position: absolute; bottom: 0; left: 0; width: 0; height: 2px;
  background: var(--primary); transition: width var(--transition); border-radius: 2px;
}
.nav-link:hover, .nav-link.active { color: var(--text-primary); }
.nav-link:hover::after, .nav-link.active::after { width: 100%; }
.nav-right { display: flex; align-items: center; gap: 16px; }
.lang-toggle {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 30px; background: var(--bg-white);
  cursor: pointer; font-size: 0.75rem; font-weight: 600; transition: all var(--transition);
}
.lang-toggle:hover { border-color: var(--primary-light); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.lang-option { color: var(--text-muted); transition: color var(--transition); }
.lang-option.active { color: var(--primary); }
.lang-divider { color: var(--border); font-weight: 300; }
.hamburger { display: none; flex-direction: column; gap: 6px; padding: 4px; background: none; border: none; cursor: pointer; }
.hamburger span { display: block; width: 24px; height: 2px; background: var(--text-primary); border-radius: 2px; transition: all var(--transition); }
.hamburger.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
/* ========================================
   Hero
   ======================================== */
.hero { padding: 180px 0 100px; background: linear-gradient(180deg, var(--bg-hero) 0%, #f7f9ff 60%, var(--bg-white) 100%); }
.hero-content { text-align: left; max-width: 800px; }
.hero-name { font-size: 3.5rem; font-weight: 800; letter-spacing: -0.04em; color: var(--text-primary); margin-bottom: 8px; line-height: 1.2; }
.hero-name-zh { font-size: 1.5rem; font-weight: 500; color: var(--text-muted); margin-bottom: 16px; display: none; }
body.lang-zh .hero-name-zh { display: block; }
/* [Req 1] Typewriter specific CSS */
.hero-title {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 32px;
  position: relative;
  display: inline-block;
  min-height: 1.75rem; /* 防止高度塌陷 */
}
/* 打字机光标闪烁 */
.hero-title::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 10%;
  bottom: 10%;
  width: 2px;
  background-color: var(--primary);
  animation: blink 0.8s step-end infinite;
  opacity: 1;
  transition: opacity 0.3s;
}
@keyframes blink {
  50% { opacity: 0; }
}
.hero-contact { display: flex; flex-wrap: wrap; gap: 24px; font-size: 0.9rem; color: var(--text-secondary); }
.hero-contact a, .hero-contact span { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); transition: color var(--transition); }
.hero-contact a:hover { color: var(--primary); }
.hero-contact i { color: var(--text-muted); font-size: 1rem; transition: transform var(--transition-spring), color var(--transition); }
.hero-contact a:hover i { color: var(--primary); transform: scale(1.1); }
/* ========================================
   Sections & Scroll Reveal Animation
   ======================================== */
.section { padding: 100px 0; overflow-x: hidden; /* 防止从左侧滑入时出现横向滚动条 */ position: relative; }
.section-alt { background: var(--bg-alt); }
/* 渐变过渡：section-alt 顶部和底部使用伪元素实现白色到蓝色的柔和过渡 */
.section-alt::before,
.section-alt::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 80px;
  pointer-events: none;
  z-index: 0;
}
.section-alt::before {
  top: 0;
  background: linear-gradient(180deg, var(--bg-white), var(--bg-alt));
}
.section-alt::after {
  bottom: 0;
  background: linear-gradient(180deg, var(--bg-alt), var(--bg-white));
}
.section-title {
  display: flex; align-items: center; font-size: 1.75rem; font-weight: 700;
  color: var(--text-primary); margin-bottom: 64px; white-space: nowrap; letter-spacing: -0.02em;
}
.section-title::after {
  content: ''; display: block; flex: 1; height: 2px;
  background: linear-gradient(90deg, var(--primary-light), transparent); margin-left: 24px; max-width: 300px;
}
/* [Req 2] Scroll Reveal Base Styles */
.timeline-item {
  opacity: 0;
  transform: translateX(-40px); /* 从左侧进入 */
  transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.project-card, .publication-item, .cert-card, .interest-tag {
  opacity: 0;
  transform: translateY(30px); /* 默认从底部向上进入 */
  transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Revealed States */
.timeline-item.revealed,
.project-card.revealed,
.publication-item.revealed,
.cert-card.revealed,
.interest-tag.revealed {
  opacity: 1;
  transform: translate(0, 0);
}
/* Staggering Delays */
.project-card:nth-child(2) { transition-delay: 0.1s; }
.project-card:nth-child(3) { transition-delay: 0.2s; }
.project-card:nth-child(4) { transition-delay: 0.3s; }
.cert-card:nth-child(2) { transition-delay: 0.1s; }
.cert-card:nth-child(3) { transition-delay: 0.2s; }
.cert-card:nth-child(4) { transition-delay: 0.3s; }
.interest-tag:nth-child(2) { transition-delay: 0.1s; }
.interest-tag:nth-child(3) { transition-delay: 0.2s; }
/* ========================================
   Timeline (Education & Experience)
   ======================================== */
.timeline { position: relative; max-width: 850px; margin: 0; padding-left: 40px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(180deg, var(--primary-light), var(--border)); }
.timeline-item { position: relative; margin-bottom: 48px; }
.timeline-item:last-child { margin-bottom: 0; }
.timeline-dot {
  position: absolute; left: -40px; top: 8px; width: 19px; height: 19px;
  border-radius: 50%; background: var(--bg-white); border: 4px solid var(--border);
  z-index: 1; transition: all var(--transition);
}
.timeline-item:hover .timeline-dot { border-color: var(--primary-light); background: var(--primary-bg); transform: scale(1.2); }
.timeline-item:first-child .timeline-dot { border-color: var(--primary); background: var(--bg-white); }
.timeline-content { background: transparent; padding: 0; transition: all var(--transition); }
.timeline-body { display: flex; align-items: flex-start; gap: 24px; }
.school-logo { width: 64px; height: 64px; flex-shrink: 0; margin-top: 4px; }
.school-logo img { width: 100%; height: 100%; border-radius: var(--radius-sm); object-fit: contain; background: var(--bg-white); padding: 8px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.school-logo-fallback { width: 100%; height: 100%; border-radius: var(--radius-sm); background: var(--bg-white); border: 1px solid var(--border); display: none; align-items: center; justify-content: center; color: var(--text-muted); font-size: 1.5rem; }
.timeline-text { flex: 1; min-width: 0; }
.timeline-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 12px; margin-bottom: 6px; }
.timeline-header h3 { font-size: 1.25rem; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.timeline-date { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); font-family: var(--font-en); }
.timeline-subtitle { font-size: 1rem; color: var(--text-primary); font-weight: 500; margin-bottom: 12px; }
.timeline-details { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.timeline-details li { position: relative; padding-left: 20px; font-size: 0.95rem; color: var(--text-secondary); }
.timeline-details li::before { content: '▹'; position: absolute; left: 0; top: 0; color: var(--primary); font-size: 1rem; line-height: inherit; }
/* ========================================
   Projects
   ======================================== */
.project-company { margin-bottom: 80px; }
.project-company:last-child { margin-bottom: 0; }
.company-header { display: flex; align-items: center; gap: 20px; margin-bottom: 32px; }
.company-logo-placeholder { width: 100px; height: 100px; flex-shrink: 0; }
.company-logo-placeholder img { width: 100%; height: 100%; border-radius: var(--radius-xs); object-fit: contain; }
.company-logo-fallback { width: 100%; height: 100%; border-radius: var(--radius-xs); background: var(--bg-alt); display: none; align-items: center; justify-content: center; color: var(--text-muted); font-size: 1.5rem; }
.company-header h3 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.project-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
/* [Req 3] Project Card Hover Effect */
.project-card {
  display: flex; flex-direction: column; padding: 32px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform var(--transition-spring), box-shadow 0.4s ease, border-color 0.4s ease;
  position: relative; z-index: 1; box-shadow: var(--shadow-sm);
}
.project-card:hover {
  border-color: transparent;
  box-shadow: var(--shadow-hover);
  transform: translateY(-8px); /* 轻微上移 */
  z-index: 2;
}
.project-icon { margin-bottom: 24px; color: var(--primary); font-size: 1.5rem; transition: transform var(--transition-spring); }
.project-card:hover .project-icon { transform: scale(1.1) translateX(4px); } /* 图标联动微动 */
.project-info { flex: 1; display: flex; flex-direction: column; }
.project-date { font-size: 0.8rem; font-family: var(--font-en); font-weight: 500; color: var(--text-muted); margin-bottom: 8px; }
.project-info h4 { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 12px; line-height: 1.4; }
.project-info p { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.6; flex-grow: 1; }
.project-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 20px; font-size: 0.85rem; font-weight: 600; color: var(--text-primary); transition: all var(--transition); align-self: flex-start; }
.project-link:hover { color: var(--primary); gap: 12px; }
/* ========================================
   Publications
   ======================================== */
.publications-list { display: flex; flex-direction: column; gap: 64px; max-width: 850px; margin: 0 auto; }
.publication-item { display: grid; grid-template-columns: 200px 1fr; gap: 40px; align-items: center; }
.publication-item:nth-child(even) { grid-template-columns: 1fr 200px; }
.publication-item:nth-child(even) .publication-image { grid-column: 2; grid-row: 1; }
.publication-item:nth-child(even) .publication-info { grid-column: 1; grid-row: 1; text-align: right; }
.publication-item:nth-child(even) .publication-link { align-self: flex-end; }
/* [Req 4] Publication Image 3D Tilt */
.publication-image {
  width: 100%; aspect-ratio: 3 / 4;
  position: relative;
  perspective: 1200px; /* 开启 3D 空间 */
}
.publication-image img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-spring), box-shadow 0.5s ease;
  transform-origin: center center;
  transform-style: preserve-3d;
}
/* 奇数项：向右倾斜 */
.publication-item:hover .publication-image img {
  transform: rotateX(8deg) rotateY(-8deg) scale(1.03);
  box-shadow: -15px 15px 25px rgba(0, 0, 0, 0.1);
}
/* 偶数项：向左倾斜 */
.publication-item:nth-child(even):hover .publication-image img {
  transform: rotateX(8deg) rotateY(8deg) scale(1.03);
  box-shadow: 15px 15px 25px rgba(0, 0, 0, 0.1);
}
.publication-image-fallback { width: 100%; height: 100%; background: var(--bg-alt); display: none; align-items: center; justify-content: center; color: var(--text-muted); font-size: 2.5rem; }
.publication-info { display: flex; flex-direction: column; }
.publication-tag { display: inline-block; align-self: flex-start; padding: 4px 12px; font-size: 0.75rem; font-weight: 600; color: var(--primary); background: var(--primary-bg); border-radius: 20px; margin-bottom: 16px; letter-spacing: 0.02em; }
.publication-item:nth-child(even) .publication-tag { align-self: flex-end; }
.publication-info h4 { font-size: 1.2rem; font-weight: 600; color: var(--text-primary); margin-bottom: 12px; line-height: 1.5; }
.publication-meta { font-size: 0.9rem; color: var(--text-secondary); }
.publication-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 20px; font-size: 0.85rem; font-weight: 600; color: var(--text-primary); transition: all var(--transition); align-self: flex-start; }
.publication-link:hover { color: var(--primary); gap: 12px; }
/* ========================================
   Certifications
   ======================================== */
.cert-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; max-width: 900px; margin: 0 auto; }
.cert-card { text-align: center; padding: 32px 24px; background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius); transition: all var(--transition); box-shadow: var(--shadow-sm); }
.cert-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow-md); transform: translateY(-4px); }
.cert-icon { width: 48px; height: 48px; border-radius: var(--radius-xs); background: var(--primary-bg); display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; color: var(--primary-dark); font-size: 1.25rem; transition: all var(--transition); }
/* [Req 5] Certification Icon Pulse Animation */
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(29, 78, 216, 0.4); transform: scale(1); }
  70% { box-shadow: 0 0 0 12px rgba(29, 78, 216, 0); transform: scale(1.05); }
  100% { box-shadow: 0 0 0 0 rgba(29, 78, 216, 0); transform: scale(1); }
}
.cert-card:hover .cert-icon {
  background: var(--primary-bg);
  color: var(--primary);
  animation: pulse-ring 1.5s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}
.cert-card h4 { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; line-height: 1.5; }
.cert-date { font-size: 0.85rem; font-family: var(--font-en); color: var(--text-muted); }
/* ========================================
   Interests
   ======================================== */
.interests-tags { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; max-width: 800px; margin: 0 auto; }
.interest-tag { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: var(--bg-white); border: 1px solid var(--border); border-radius: 30px; font-size: 0.9rem; font-weight: 500; color: var(--text-secondary); transition: all var(--transition); }
.interest-tag:hover { border-color: var(--primary); color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.interest-tag i { color: var(--text-muted); transition: color var(--transition); }
.interest-tag:hover i { color: var(--primary); }
/* ========================================
   Footer
   ======================================== */
.footer { padding: 40px 0; background: var(--bg-alt); position: relative; }
/* 当 section-alt 紧接 footer 时，去掉中间多余的白色过渡 */
.section-alt:has(+ .footer)::after { display: none; }
.section-alt + .footer::before { display: none; }
.footer-content { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--text-muted); }
.footer-links { display: flex; gap: 20px; }
.footer-links a { color: var(--text-muted); font-size: 1.1rem; transition: all var(--transition); }
.footer-links a:hover { color: var(--primary); transform: translateY(-2px); }
/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .hero { padding: 140px 0 60px; text-align: center; }
  .hero-content { margin: 0 auto; }
  .hero-contact { justify-content: center; }
  .nav-menu { position: fixed; top: 72px; left: 0; right: 0; background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); flex-direction: column; padding: 24px; border-bottom: 1px solid var(--border); transform: translateY(-100%); opacity: 0; pointer-events: none; transition: all var(--transition); box-shadow: var(--shadow-md); }
  .nav-menu.open { transform: translateY(0); opacity: 1; pointer-events: all; }
  .nav-link::after { display: none; }
  .hamburger { display: flex; }
  .section { padding: 80px 0; }
  .section-title::after { max-width: none; }
  .timeline { padding-left: 24px; }
  .timeline::before { left: 8px; }
  .timeline-dot { left: -24px; width: 17px; height: 17px; border-width: 3px; }
  .timeline-body { flex-direction: column; gap: 16px; }
  .project-grid { grid-template-columns: 1fr; }
  .publication-item, .publication-item:nth-child(even) { grid-template-columns: 1fr; gap: 24px; text-align: left; }
  .publication-item:nth-child(even) .publication-image { grid-column: 1; grid-row: 1; }
  .publication-item:nth-child(even) .publication-info { grid-column: 1; grid-row: 2; text-align: left; }
  .publication-item:nth-child(even) .publication-tag, .publication-item:nth-child(even) .publication-link { align-self: flex-start; }
  .publication-image { max-width: 240px; margin: 0 auto; }
  .cert-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-content { flex-direction: column; gap: 16px; text-align: center; }
}
@media (max-width: 480px) {
  .hero-name { font-size: 2.5rem; }
  .section-title { font-size: 1.5rem; }
  .cert-grid { grid-template-columns: 1fr; }
}
/* ========================================
   Chinese language overrides
   ======================================== */
body.lang-zh .nav-link, body.lang-zh .hero-title, body.lang-zh .section-title, body.lang-zh .timeline-header h3, body.lang-zh .timeline-subtitle, body.lang-zh .timeline-details li, body.lang-zh .company-header h3, body.lang-zh .project-info h4, body.lang-zh .project-info p, body.lang-zh .publication-tag, body.lang-zh .publication-info h4, body.lang-zh .publication-meta, body.lang-zh .cert-card h4 { font-family: var(--font-zh); }
[data-zh-only] { display: none; }
body.lang-zh [data-zh-only] { display: block; }
