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

:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-text-muted: #666666;
  --color-border: #d4d3cb;
  --color-border-light: #e8e7e3;
  --color-accent: #c0bdad;
  --color-highlight: #fffde7;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --max-width: 780px;
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  --spacing-3xl: 4rem;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

/* Typography */
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: 1.3;
}

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: text-decoration-thickness 0.15s ease;
}

a:hover {
  text-decoration-thickness: 2px;
}

.text-underline {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Header & Navigation */
.header {
  position: sticky;
  top: 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-light);
  z-index: 100;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--spacing-md);
  padding-bottom: var(--spacing-md);
}

.logo {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

.nav-link {
  text-decoration: none;
  color: var(--color-text-muted);
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.125rem;
  line-height: 1;
  color: var(--color-text-muted);
  transition: color 0.15s ease;
}

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

.theme-icon {
  display: none;
}

/* Light mode: show sun icon */
:root[data-theme="light"] .theme-icon--light,
:root:not([data-theme]) .theme-icon--light {
  display: block;
}

/* Dark mode: show moon icon */
:root[data-theme="dark"] .theme-icon--dark {
  display: block;
}

:root[data-theme="dark"] .theme-icon--light {
  display: none;
}

/* Profile Section */
.profile-section {
  padding: var(--spacing-3xl) 0 var(--spacing-2xl);
}

.profile-layout {
  display: flex;
  gap: var(--spacing-xl);
  align-items: flex-start;
  margin-bottom: var(--spacing-xl);
}

.profile-image-wrapper {
  flex-shrink: 0;
}

.profile-image {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  object-fit: cover;
}

.profile-content {
  flex: 1;
}

.profile-name {
  font-size: 2rem;
  margin-bottom: var(--spacing-xs);
  letter-spacing: -0.02em;
}

.profile-title {
  font-size: 1rem;
  color: var(--color-text);
  margin-bottom: var(--spacing-xs);
}

.profile-affiliation {
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-md);
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm) var(--spacing-md);
}

.profile-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--spacing-xs);
  transition: color 0.15s ease;
}

.profile-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.profile-link:hover {
  color: var(--color-text);
  text-decoration: none;
}

.bio {
  border-top: 1px solid var(--color-border-light);
  padding-top: var(--spacing-xl);
}

.bio p {
  margin-bottom: var(--spacing-md);
}

.bio p:last-child {
  margin-bottom: 0;
}

/* Section Titles */
.section-title {
  font-size: 1.25rem;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--color-border-light);
}

.section-subtitle {
  color: var(--color-text-muted);
  margin-top: calc(-1 * var(--spacing-md));
  margin-bottom: var(--spacing-xl);
}

/* News Section */
.news-section {
  padding: var(--spacing-2xl) 0;
  border-top: 1px solid var(--color-border-light);
}

.timeline {
  position: relative;
  padding-left: var(--spacing-xl);
  border-left: 1px solid var(--color-border);
}

.timeline-gradient-top,
.timeline-gradient-bottom {
  position: absolute;
  left: -1px;
  width: 1px;
  height: 40px;
  pointer-events: none;
}

.timeline-gradient-top {
  top: 0;
  background: linear-gradient(to bottom, var(--color-bg), transparent);
}

.timeline-gradient-bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--color-bg), transparent);
}

.timeline-item {
  position: relative;
  padding-bottom: var(--spacing-lg);
}

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

.timeline-dot {
  position: absolute;
  left: calc(-1 * var(--spacing-xl) - 4px);
  top: 4px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-bg);
}

.timeline-content {
  padding-left: var(--spacing-md);
}

.timeline-date {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-right: var(--spacing-sm);
  min-width: 70px;
}

.timeline-text {
  display: inline;
  font-size: 0.875rem;
}

/* Research Interests */
.interests-section {
  padding: var(--spacing-2xl) 0;
  border-top: 1px solid var(--color-border-light);
}

.interests-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-lg);
}

.interest-item {
  padding: var(--spacing-md);
  border: 1px solid var(--color-border-light);
}

.interest-title {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
}

.interest-description {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* Publications Section */
.publications-section {
  padding: var(--spacing-2xl) 0;
  border-top: 1px solid var(--color-border-light);
}

.publication {
  display: flex;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg) 0;
  border-bottom: 1px solid var(--color-border-light);
}

.publication:last-child {
  border-bottom: none;
}

.publication-image {
  flex-shrink: 0;
  width: 180px;
}

.publication-image a {
  display: block;
  text-decoration: none;
}

.publication-image img {
  width: 180px;
  height: 110px;
  object-fit: cover;
  border: 1px solid var(--color-border);
  transition: border-color 0.15s ease;
}

.publication-image a:hover img {
  border-color: var(--color-text);
}

.publication-image-placeholder {
  width: 180px;
  height: 110px;
  background: var(--color-border-light);
  border: 1px solid var(--color-border);
}

.publication-content {
  flex: 1;
  min-width: 0;
}

.publication-title {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
  line-height: 1.4;
}

.publication-title a {
  text-decoration: none;
}

.publication-title a:hover {
  text-decoration: underline;
}

.publication-authors {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-xs);
}

.publication-venue {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
}

.publication-award {
  display: inline-block;
  background: var(--color-highlight);
  padding: 0 var(--spacing-xs);
  font-size: 0.75rem;
  color: #856404;
  border: 1px solid #ffeeba;
}

.publication-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

.pub-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 2px var(--spacing-sm);
  border: 1px solid var(--color-border);
  transition: all 0.15s ease;
}

.pub-link svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.pub-link:hover {
  color: var(--color-text);
  border-color: var(--color-text);
  text-decoration: none;
}

.pub-link.disabled {
  opacity: 0.6;
  cursor: default;
}

.pub-link.disabled:hover {
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

/* Teaching Section */
.teaching-section {
  padding: var(--spacing-2xl) 0;
  border-top: 1px solid var(--color-border-light);
}

.teaching-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.teaching-item {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: var(--spacing-md);
  align-items: baseline;
  padding: var(--spacing-sm) 0;
}

.teaching-role {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.teaching-course {
  font-size: 0.875rem;
}

.teaching-course a {
  text-decoration: none;
}

.teaching-course a:hover {
  text-decoration: underline;
}

.teaching-term {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  text-align: right;
}

/* Services Section */
.services-section {
  padding: var(--spacing-2xl) 0;
  border-top: 1px solid var(--color-border-light);
}

.services-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.service-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--spacing-md);
  align-items: baseline;
}

.service-role {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.service-detail {
  font-size: 0.875rem;
}

/* Education Section */
.education-section {
  padding: var(--spacing-2xl) 0;
  border-top: 1px solid var(--color-border-light);
}

.education-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
}

.education-item {
  padding-bottom: var(--spacing-md);
}

.education-degree {
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
}

.education-school {
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-xs);
}

.education-details {
  display: flex;
  gap: var(--spacing-md);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.education-date {
  min-width: 180px;
}

/* Misc Section (Awards) */
.misc-section {
  padding: var(--spacing-2xl) 0;
  border-top: 1px solid var(--color-border-light);
}

.awards-list {
  list-style: none;
  padding: 0;
}

.awards-list li {
  position: relative;
  padding-left: var(--spacing-lg);
  margin-bottom: var(--spacing-sm);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.awards-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--color-border);
}

/* Footer */
.footer {
  border-top: 1px solid var(--color-border-light);
  padding: var(--spacing-lg) 0;
  margin-top: var(--spacing-xl);
}

.footer-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.footer-name {
  font-weight: 500;
}

.footer-sep {
  color: var(--color-text-muted);
}

.footer-email {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.footer-right {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .profile-layout {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

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

  .bio {
    text-align: left;
  }

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

  .publication {
    flex-direction: column;
  }

  .publication-image {
    width: 100%;
  }

  .publication-image img,
  .publication-image-placeholder {
    width: 100%;
    height: 160px;
  }

  .teaching-item {
    grid-template-columns: 1fr;
    gap: var(--spacing-xs);
  }

  .teaching-term {
    text-align: left;
  }

  .service-item {
    grid-template-columns: 1fr;
    gap: var(--spacing-xs);
  }

  .education-details {
    flex-direction: column;
    gap: var(--spacing-xs);
  }
}

@media (max-width: 640px) {
  .profile-name {
    font-size: 1.75rem;
  }

  .profile-image {
    width: 120px;
    height: 120px;
  }

  .nav-links {
    gap: var(--spacing-md);
    font-size: 0.8125rem;
  }

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

/* Dark Mode Support */
:root[data-theme="dark"] {
  --color-bg: #111111;
  --color-text: #f0f0f0;
  --color-text-muted: #888888;
  --color-border: #333333;
  --color-border-light: #222222;
  --color-highlight: #3d3d00;
}

:root[data-theme="dark"] .publication-award {
  background: var(--color-highlight);
  color: #ffd700;
  border-color: #665c00;
}
