/* ===== CSS Variables & Dark Mode ===== */
:root {
  --bg: white;
  --bg-alt: #f7f7f7;
  --text: black;
  --text-secondary: #333;
  --text-muted: #666;
  --text-faint: #999;
  --accent: black;
  --accent-hover: #444;
  --border: #e0e0e0;
  --border-light: #ccc;
  --border-pub: #ddd;
  --chip-bg: #f0f0f0;
  --chip-text: #333;
  --card-bg: white;
  --card-shadow: rgba(0, 0, 0, 0.06);
  --nav-bg: rgba(255, 255, 255, 0.95);
  --footer-bg: black;
  --footer-text: #aaa;
  --footer-link: white;
  --footer-link-hover: #ccc;
  --footer-muted: #666;
  --timeline-dot-border: white;
  --thumb-bg: #f5f5f5;
}

[data-theme="dark"] {
  --bg: black;
  --bg-alt: #0a0a0a;
  --text: white;
  --text-secondary: #ccc;
  --text-muted: #999;
  --text-faint: #666;
  --accent: white;
  --accent-hover: #bbb;
  --border: #222;
  --border-light: #333;
  --border-pub: #333;
  --chip-bg: #1a1a1a;
  --chip-text: #ccc;
  --card-bg: #0a0a0a;
  --card-shadow: rgba(0, 0, 0, 0.4);
  --nav-bg: rgba(0, 0, 0, 0.95);
  --footer-bg: #0a0a0a;
  --footer-text: #666;
  --footer-link: white;
  --footer-link-hover: #aaa;
  --footer-muted: #444;
  --timeline-dot-border: black;
  --thumb-bg: #111;
}

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

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

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

h1, h2, h3,
nav ul a {
  font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;
}


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

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

img {
  max-width: 100%;
}

/* ===== Fade-in Animations ===== */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

/* ===== Layout ===== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 5.5rem 0;
}

section > .container {
  width: 100%;
}

.section-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--text);
  position: relative;
  display: inline-block;
}

.section-title::after {
  content: "";
  display: block;
  width: 40px;
  height: 3px;
  background: var(--text);
  margin-top: 0.4rem;
  border-radius: 2px;
}

nav,
section,
footer {
  position: relative;
  z-index: 1;
}

/* ===== Nav ===== */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  padding: 0.8rem 0;
  transition: background 0.3s;
}

nav .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

nav ul a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: font-variation-settings 0.2s ease, color 0.2s;
}

nav ul a:hover,
nav ul a.active {
  color: var(--text);
  font-weight: 700;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: color 0.2s;
  margin-left: auto;
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-moon {
  display: none;
}

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

[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
}

/* ===== Content Card ===== */
.content-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
}

/* ===== Timeline (Experience & Education) ===== */
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: var(--border-light);
}

.timeline-item {
  position: relative;
  margin-bottom: 2.5rem;
}

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

.timeline-item::before {
  content: "";
  position: absolute;
  left: -2rem;
  top: 0.55rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--timeline-dot-border);
  transform: translateX(-4px);
}

.timeline-item h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.timeline-item .meta {
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-bottom: 0.5rem;
}

.timeline-item ul {
  padding-left: 1.2rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.timeline-item ul li {
  margin-bottom: 0.3rem;
}

/* ===== Projects ===== */
.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.project-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  display: flex;
  transition: box-shadow 0.3s, transform 0.3s;
}

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

.project-thumb {
  width: 180px;
  min-height: 100%;
  background: var(--thumb-bg);
  flex-shrink: 0;
  overflow: hidden;
  transition: background 0.3s;
}

.project-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-body {
  padding: 1.5rem 1.8rem;
  flex: 1;
}

.project-body h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.project-body p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  line-height: 1.6;
}

.project-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.project-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: underline;
}

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

.project-links svg {
  width: 14px;
  height: 14px;
}

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

.pub-list li {
  margin-bottom: 1.5rem;
  padding-left: 1rem;
  border-left: 3px solid var(--border-pub);
  transition: border-color 0.2s;
}

.pub-list li:hover {
  border-left-color: var(--text);
}

.pub-list .pub-title {
  font-weight: 600;
  font-size: 1rem;
  display: block;
  margin-bottom: 0.25rem;
}

.pub-list .pub-desc {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 0.3rem;
}

.pub-list .pub-venue {
  font-size: 0.85rem;
  color: var(--text-faint);
}

.pub-list .pub-venue a {
  font-weight: 500;
}

/* ===== Skills ===== */
.skills-group {
  margin-bottom: 1.5rem;
}

.skills-group h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  background: var(--chip-bg);
  color: var(--chip-text);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.3s;
}

/* ===== Footer ===== */
footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: 3rem 0;
  text-align: center;
  transition: background 0.3s;
}

footer a {
  color: var(--footer-link);
}

footer a:hover {
  color: var(--footer-link-hover);
}

footer .footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

footer .footer-links a {
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

footer .footer-links a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.footer-email {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--footer-text);
}

footer p {
  font-size: 0.8rem;
  color: var(--footer-muted);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  section {
    min-height: auto;
    padding: 4rem 0;
  }

  .project-card {
    flex-direction: column;
  }

  .project-thumb {
    width: 100%;
    min-height: auto;
    height: 160px;
  }

  nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-alt);
    flex-direction: column;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
  }

  nav ul.open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

}

@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }
}

/* ===== Home (single-screen layout) ===== */
.home {
  position: relative;
  z-index: 1;
  padding: 6.5rem 0 3rem;
}

.home-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 3rem;
  align-items: start;
}

.home-side {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.home-photo {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  display: block;
}

.home-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.home-links li,
.home-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.home-links a {
  color: var(--text-muted);
}

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

.home-links svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.home-main h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.home-main p {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 1rem;
  max-width: 62ch;
}

.home-main p a,
.work-title a {
  text-decoration: underline;
  text-decoration-color: var(--border-light);
  text-underline-offset: 3px;
}

.home-main p a:hover,
.work-title a:hover {
  text-decoration-color: currentColor;
}

.home-subhead {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.75rem 0 0.75rem;
}

/* Recent work */
.home-work {
  min-height: 0;
  display: block;
  padding: 1.5rem 0 0;
  margin-top: 1.75rem;
  border-top: 1px solid var(--border);
  max-width: 62ch;
}

.home-work .home-subhead {
  margin-top: 0;
}

.work-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.work-title {
  display: block;
  font-weight: 600;
  font-size: 1rem;
}

.work-meta {
  display: block;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.work-links {
  display: block;
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-top: 0.1rem;
}

.work-links a {
  font-weight: 500;
  color: var(--text-muted);
}

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

.work-more {
  margin-top: 1.25rem;
  font-size: 0.9rem;
}

.work-more a {
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
}

.work-more a:hover {
  color: var(--text);
}

/* Minimal footer (home) */
footer.footer-min {
  background: transparent;
  color: var(--text-faint);
  padding: 1.5rem 0 2rem;
  text-align: left;
}

footer.footer-min p {
  color: var(--text-faint);
}

@media (max-width: 768px) {
  .home {
    padding-top: 5.5rem;
  }

  .home-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .home-side {
    align-items: center;
  }

  .home-photo {
    width: 150px;
    height: 150px;
  }

  .home-links {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.1rem;
  }

  .home-main h1 {
    font-size: 1.7rem;
    text-align: center;
  }

}
