/* === Reset === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === Custom Properties === */
:root {
  --color-bg: #FFFFFF;
  --color-text: #1a1a1a;
  --color-text-secondary: #666666;
  --color-accent: #2563EB;
  --color-accent-hover: #1d4ed8;
  --color-border: #E5E7EB;
  --color-card-bg: #F9FAFB;

  --font-en: 'Inter', sans-serif;
  --font-zh: 'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --max-width: 800px;
  --nav-height: 64px;
  --section-padding: 64px 24px;
}

/* === Base === */
html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-height);
}

body {
  font-family: var(--font-en), var(--font-zh);
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Typography === */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.3;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; margin-bottom: 48px; display: flex; align-items: center; gap: 12px; }
h3 { font-size: 1.25rem; }

.section-icon {
  color: var(--color-accent);
  flex-shrink: 0;
}

p {
  margin-bottom: 16px;
  color: var(--color-text-secondary);
}

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

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

/* === Layout === */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

section {
  padding: var(--section-padding);
}

section .container > *:last-child {
  margin-bottom: 0;
}

section .container > *:last-child > *:last-child {
  margin-bottom: 0;
}

/* === Utilities === */
.section-fade {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.section-fade.visible {
  opacity: 1;
  transform: translateY(0);
}

/* === Navigation === */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  transition: box-shadow 0.3s ease;
}

.nav.scrolled {
  box-shadow: 0 1px 0 var(--color-border);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--color-text);
}

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-links a {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: var(--color-text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  width: 28px;
  height: 28px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
}

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

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

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

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

.lang-toggle {
  font-family: var(--font-en);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-toggle:hover {
  border-color: var(--color-text);
  color: var(--color-text);
}

/* === Hero === */
.hero {
  padding-top: calc(var(--nav-height) + 80px);
  padding-bottom: 80px;
}

.hero-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 48px;
}

.hero-content {
  flex: 1;
}

.hero-content h1 {
  margin-bottom: 8px;
}

.hero-tagline {
  font-size: 1.125rem;
  color: var(--color-text-secondary);
  margin-bottom: 24px;
}

.hero-links {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}

.hero-links a {
  color: var(--color-text-secondary);
  transition: color 0.2s ease;
}

.hero-links a:hover {
  color: var(--color-accent);
}

.hero-photo {
  flex-shrink: 0;
}

.hero-photo img {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
}

.hero-photo-placeholder {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--color-card-bg);
  border: 2px dashed var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.btn {
  display: inline-block;
  padding: 10px 24px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--color-accent);
  color: #FFFFFF;
}

/* === About === */
.about-content {
  max-width: 640px;
}

.about-content p {
  font-size: 1.0625rem;
  line-height: 1.8;
  text-align: justify;
  word-break: break-word;
}

/* === Projects === */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.project-card {
  padding: 24px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  transition: box-shadow 0.2s ease;
}

.project-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.project-card h3 {
  margin-bottom: 8px;
}

.project-card p {
  font-size: 0.9375rem;
  margin-bottom: 16px;
}

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

.tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 10px;
  background: var(--color-card-bg);
  border-radius: 4px;
  color: var(--color-text-secondary);
}

.project-links {
  display: flex;
  gap: 16px;
}

.project-links a {
  font-size: 0.875rem;
  font-weight: 500;
}

/* === Publications === */
.pub-list {
  list-style: none;
}

.pub-item {
  padding: 24px 0;
  border-bottom: 1px solid var(--color-border);
}

.pub-item:first-child {
  padding-top: 0;
}

.pub-item:last-child {
  border-bottom: none;
}

.pub-featured {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.pub-figure {
  flex-shrink: 0;
  width: 280px;
}

.pub-figure img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

.pub-info {
  flex: 1;
  min-width: 0;
}

.pub-title {
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.pub-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  font-style: normal;
  padding: 1px 8px;
  background: var(--color-accent);
  color: #FFFFFF;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 6px;
}

.pub-authors {
  font-size: 0.9375rem;
  margin-bottom: 2px;
}

.pub-authors strong {
  color: var(--color-accent);
}

.pub-venue {
  font-size: 0.875rem;
  font-style: italic;
  margin-bottom: 8px;
}

.pub-links {
  display: flex;
  gap: 16px;
}

.pub-links a {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 2px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-secondary);
  transition: all 0.2s ease;
}

.pub-links a:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* === Publication toggle === */
.pub-toggle {
  display: block;
  margin: 24px auto 0;
  padding: 8px 24px;
  font-family: var(--font-en), var(--font-zh);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* === Timeline === */

.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--color-border);
}

.timeline-item {
  position: relative;
  padding-bottom: 40px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
}

.timeline-date {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.timeline-content h3 {
  margin-bottom: 2px;
}

.timeline-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  user-select: none;
}

.timeline-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
}

.timeline-org {
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 4px;
}

.timeline-content > p:last-child {
  font-size: 0.9375rem;
}

.expand-icon {
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  color: var(--color-text-secondary);
}

.timeline-item.expanded .expand-icon {
  transform: rotate(180deg);
}

.timeline-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.timeline-item.expanded .timeline-details {
  max-height: 2000px;
  opacity: 1;
}

.timeline-details > p {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
  margin-top: 8px;
  line-height: 1.6;
}

.timeline-category {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 12px 0 4px 0;
}

.timeline-category:first-child {
  margin-top: 8px;
}

.timeline-category + .timeline-highlights {
  margin-top: 0;
}

.timeline-highlights {
  margin: 8px 0 0 0;
  padding-left: 1.25em;
  list-style: disc;
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.timeline-highlights li + li {
  margin-top: 4px;
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.skill-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

/* === Lightbox === */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* === Footer === */
.footer {
  padding: 48px 24px;
  text-align: center;
  border-top: 1px solid var(--color-border);
}

.footer p {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

/* === Responsive === */
@media (max-width: 768px) {
  :root {
    --section-padding: 48px 20px;
  }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; margin-bottom: 32px; }

  .nav-inner {
    padding: 0 20px;
  }

  .nav-links {
    gap: 20px;
  }

  .nav-links a {
    font-size: 0.8125rem;
  }

  .hero-grid {
    flex-direction: column-reverse;
    text-align: center;
  }

  .hero-links {
    justify-content: center;
  }

  .hero-photo-placeholder,
  .hero-photo img {
    width: 150px;
    height: 150px;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .pub-featured {
    flex-direction: column;
  }

  .pub-figure {
    width: 100%;
  }

  .timeline-logo {
    display: none;
  }

  .timeline-item {
    padding-bottom: 28px;
  }
}

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

  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    flex-direction: column;
    padding: 16px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  }

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

  .nav-links a {
    padding: 12px 24px;
    text-align: center;
    font-size: 0.9375rem;
  }

  .nav-links a:hover {
    background: var(--color-card-bg);
  }

  .about-content p {
    text-align: left;
  }

  h1 { font-size: 1.75rem; }
}
