:root {
  --primary: #2563eb;
  --accent: #f59e42;
  --fg: #22223b;
  --bg: #f8f9fa;
  --muted: #6c757d;
}

body[data-theme="dark"] {
  --primary: #1e293b;
  --accent: #fbbf24;
  --fg: #f8fafc;
  --bg: #101522;
  --muted: #a0aec0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--fg); line-height: 1.6; }

/* Top nav styling */
nav, .main-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100vw;
  left: 0;
  right: auto;
  box-sizing: border-box;
  position: fixed;
  top: 0;
  z-index: 1000;
  background: transparent;
  padding: 1rem 2rem;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-links a,
.nav-links span {
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
}
.search-toggle,
.theme-toggle {
  background: none;
  border: none;
  color: var(--fg);
  margin-left: 1rem;
  cursor: pointer;
  font-size: 1.2rem;
}
body[data-theme="dark"] .theme-toggle,
body[data-theme="dark"] .search-toggle {
  color: var(--fg);
}

/* Home page */
main.home {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  padding-top: 10rem;
  text-align: center;
}
.avatar {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.social {
  margin: 1rem 0;
  display: flex;
  gap: 1.25rem;
}
.social a {
  color: var(--fg);
  font-size: 1.75rem;
  transition: color 0.2s;
}
.social a:hover {
  color: var(--accent);
}
.bio {
  max-width: 600px;
  color: var(--muted);
  margin-top: 1rem;
}
.name {
  position: absolute;
  top: 0.2rem;
  left: 2rem;
  margin: 0;
  text-align: left;
}
.affiliation {
  position: absolute;
  top: 2.7rem;
  left: 2rem;
  margin: 0;
  text-align: left;
}
.tagline {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Content pages */
main.content {
  padding: 6rem 2rem 2rem;
  max-width: 800px;
  margin: 0 auto;
  text-align: left;
  overflow: visible !important;
}

/* Research & Contact pages reuse these styles */
.publications { list-style: none; margin-top: 2rem; }
.publications li { margin-bottom: 2rem; }
.contact-form { display: flex; flex-direction: column; gap: 1rem; margin-top: 2rem; }
.contact-form input, .contact-form textarea { padding: 0.75rem; border: 1px solid #d1d5db; border-radius: 0.5rem; }

.lab-link {
  background: none;
  color: #111;
  font-weight: bold;
  text-decoration: none;
  border-radius: 0.25rem;
  transition: none;
}
.lab-link:hover {
  text-decoration: underline;
  background: none;
}
body[data-theme="dark"] .lab-link {
  background: none;
  color: #fff;
  font-weight: bold;
}

/* Section headings */
.intro-section h1 {
  text-align: center;
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 2rem;
  line-height: 1.2;
}

/* Cloud and parallax backgrounds */
#cloud {
  background-color: var(--bg);
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  margin-bottom: 2rem;
}
.parallax-container {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}
.parallax-bg {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 100%;
  z-index: -1;
  background-color: var(--bg);
  will-change: transform;
  display: flex;
  align-items: center;
  justify-content: center;
}
.intro-section {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 8rem 5vw 6rem;
  background: var(--bg);
  color: var(--fg);
  text-align: left;
  font-size: 1.1rem;
  line-height: 1.8;
}
body.research-page[data-theme="dark"] .intro-section {
  background: var(--primary);
  color: var(--fg);
}
body.research-page[data-theme="dark"] .parallax-bg,
body.research-page[data-theme="dark"] #cloud {
  background-color: var(--primary);
}
body.research-page .intro-section p + p {
  margin-top: 2rem;
}
.projects-section {
  padding: 4rem 2rem;
  background: var(--bg);
  overflow: visible !important;
}

/* Project Card Styles (used only on research page) */
.project-card {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  background: #d1d5db;
  border: 1px solid #e0e0e0;
  border-radius: 0.75rem;
  box-shadow: 0 4px 24px 0 rgba(31, 41, 55, 0.18);
  color: #222;
}
body[data-theme="dark"] .project-card {
  background: var(--primary);
  border-color: var(--muted);
  box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}
.project-card h3 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
  color: #2563eb;
  font-weight: 600;
}
.project-card a {
  display: inline-block;
  margin-right: 1rem;
  color: #2563eb;
  font-weight: bold;
  text-decoration: none;
}
.project-card a:hover {
  text-decoration: underline;
  color: #f59e42;
}
.project-thumb {
  flex-shrink: 0;
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.project-info {
  flex: 1;
}
.project-info h3 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
  color: #2563eb;
  font-weight: 600;
}
.project-info h3 a {
  color: var(--primary);
  text-decoration: none;
}
.project-info h3 a:hover {
  text-decoration: underline;
}
.project-info p {
  margin-bottom: 1rem;
  color: var(--muted);
  line-height: 1.5;
}
.project-links a {
  display: inline-block;
  margin-right: 1rem;
  color: #2563eb;
  font-weight: bold;
  text-decoration: none;
}
.project-links a:hover {
  text-decoration: underline;
  color: #f59e42;
}
.project-links .btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  margin-right: 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.btn-paper {
  background-color: transparent;
  color: #2563eb;
  border: 2px solid #2563eb;
}
.btn-paper:hover {
  background-color: #2563eb;
  color: #fff;
  border: 2px solid #2563eb;
}
.btn-code {
  background-color: transparent;
  color: #2563eb;
  border: 2px solid #2563eb;
}
.btn-code:hover {
  background-color: #2563eb;
  color: #fff;
  border: 2px solid #2563eb;
}
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 0.375rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  list-style: none;
  padding: 0.5rem 0;
  min-width: 12rem;
  z-index: 2000;
}
.dropdown-menu li + li {
  margin-top: 0.25rem;
}
.dropdown-menu a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--fg);
  text-decoration: none;
}
.dropdown-menu a:hover {
  background: var(--accent);
  color: var(--bg);
}
.dropdown.open .dropdown-menu {
  display: block;
}
.dropdown-toggle .caret {
  margin-left: 0.5em;
  font-size: 0.8em;
  transition: transform 0.2s;
}
.dropdown.open .caret {
  transform: rotate(180deg);
}

/* Dark theme overrides */
body[data-theme="dark"] {
  --fg: #f8fafc;
  --bg: #1e293b;
  --muted: #a0aec0;
}
body[data-theme="dark"] .lab-link {
  color: var(--accent);
}
body[data-theme="dark"] .project-info h3 a {
  color: var(--fg);
}
body[data-theme="dark"] .project-info h3 a:hover {
  color: var(--accent);
}
body[data-theme="dark"] .dropdown-menu {
  background: var(--primary);
  border: 1px solid var(--muted);
}
body[data-theme="dark"] .dropdown-menu a {
  color: var(--fg);
}
body[data-theme="dark"] .dropdown-menu a:hover {
  background-color: rgba(255,255,255,0.1);
}

/* Timeline layout */
.timeline-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 1rem;
  overflow: visible !important;
}
.timeline {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background-color: var(--muted);
  z-index: 0;
}
.timeline-left,
.timeline-right {
  width: 48%;
  box-sizing: border-box;
  padding: 0 1rem;
}

/* Timeline card style */
.timeline-content,
.project-card {
  background: #f3f6fd;
  border: 2px solid #2563eb;
  border-radius: 1rem;
  box-shadow: 0 4px 24px 0 rgba(31, 41, 55, 0.10);
  color: #22223b;
  padding: 2rem 2rem 1.5rem 2rem;
  margin-bottom: 2.5rem;
  transition: box-shadow 0.2s, background 0.2s, border 0.2s;
  position: relative;
  z-index: 1;
}
.timeline-content h3,
.project-card h3 {
  color: #2563eb;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.timeline-content ul li a,
.project-card a {
  color: #2563eb;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s, text-decoration 0.2s;
}
.timeline-content ul li a:hover,
.project-card a:hover {
  color: #f59e42;
  text-decoration: underline;
}
.timeline-content p,
.project-card p {
  color: #374151;
  font-size: 1.05rem;
  margin-bottom: 1rem;
}
@media (max-width: 600px) {
  .timeline-content,
  .project-card {
    padding: 1.2rem 0.8rem 1rem 0.8rem;
    border-radius: 0.7rem;
  }
}

/* Timeline list style */
.timeline-content ul {
  margin: 0.5rem 0 0.5rem 0;
  padding-left: 2em;
  list-style-position: outside;
}
.timeline-content ul li {
  margin-bottom: 0.5rem;
  padding-left: 0;
}

/* Dark mode tweaks for timeline */
body[data-theme="dark"] .timeline-content {
  background: #22315a;
  border: 2px solid #38bdf8;
  color: #f8fafc;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}
body[data-theme="dark"] .timeline::before {
  background-color: var(--muted);
}
body[data-theme="dark"] .timeline-content p {
  color: #cbd5e1;
}
body[data-theme="dark"] .timeline-container {
  color: #e2e8f0;
}
body[data-theme="dark"] .timeline-content h3 {
  color: #38bdf8;
}
body[data-theme="dark"] .timeline-content ul li a {
  color: #7dd3fc;
}
body[data-theme="dark"] .timeline-content ul li a:hover {
  color: #bae6fd;
}
body[data-theme="dark"] .timeline-content p {
  color: #cbd5e1;
}
@media (max-width: 768px) {
  .timeline {
    flex-direction: column;
  }
  .timeline-left, .timeline-right {
    width: 100%;
  }
  .timeline::before {
    left: 20px;
  }
  .timeline-content {
    margin-left: 40px;
    margin-bottom: 20px;
  }
  main.home {
    padding-top: 7.5rem;
    padding-bottom: 4.5rem;
  }
  .name, .affiliation {
    position: static;
    display: block;
    width: 100%;
    text-align: center;
    left: auto;
    top: auto;
    margin-left: 0;
    margin-right: 0;
  }
  .name {
    margin-top: 1.5rem;
  }
  .tagline {
    position: static;
    left: auto;
    bottom: auto;
    width: 100%;
    margin-top: 2rem;
    text-align: center;
    font-size: 1rem;
    color: var(--muted);
    transform: none;
  }
}
@media (min-width: 769px) {
  .timeline-content {
    margin-left: 1.5rem;
    margin-right: 1.5rem;
  }
}

/* Navigation scroll effect for research page */
body.research-page .main-nav {
  background: transparent;
  transition: background 0.3s, color 0.3s;
  width: 100vw;
  left: 0;
  right: auto;
  box-sizing: border-box;
}
body.research-page .main-nav .nav-links {
  justify-content: flex-end;
}
body.research-page .main-nav .nav-links a,
body.research-page .main-nav .nav-links span,
body.research-page .main-nav .search-toggle,
body.research-page .main-nav .theme-toggle {
  color: #111;
  transition: color 0.3s;
}
body.research-page .main-nav.scrolled .nav-links a,
body.research-page .main-nav.scrolled .nav-links span,
body.research-page .main-nav.scrolled .search-toggle,
body.research-page .main-nav.scrolled .theme-toggle {
  color: #fff;
}
body.research-page[data-theme="dark"] .main-nav .nav-links a,
body.research-page[data-theme="dark"] .main-nav .nav-links span,
body.research-page[data-theme="dark"] .main-nav .search-toggle,
body.research-page[data-theme="dark"] .main-nav .theme-toggle {
  color: #fff;
}
body.research-page[data-theme="dark"] .main-nav.scrolled .nav-links a,
body.research-page[data-theme="dark"] .main-nav.scrolled .nav-links span,
body.research-page[data-theme="dark"] .main-nav.scrolled .search-toggle,
body.research-page[data-theme="dark"] .main-nav.scrolled .theme-toggle {
  color: #111;
}
body[data-theme="dark"] nav:not(.main-nav) {
  background: var(--primary);
}

/* Link styles */
a {
  color: #111;
  font-weight: bold;
  text-decoration: none;
  background: none;
}
a:hover {
  text-decoration: underline;
  background: none;
}
body[data-theme="dark"] a {
  color: #fff;
  font-weight: bold;
  background: none;
}
body[data-theme="dark"] a:hover {
  text-decoration: underline;
  background: none;
}

.bg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('assets/Control_Map.png');
  background-repeat: repeat;
  background-position: center center;
  background-size: contain;
  opacity: 0.2;
  pointer-events: none;
  z-index: 0;
}

.page-wrapper {
  position: relative;
  min-height: 100vh;
}

body.research-page[data-theme="dark"] .project-desc {
  color: #fff !important;
  font-weight: bold !important;
}
body.research-page[data-theme="dark"] .tech-badge,
body.research-page[data-theme="dark"] .lang-badge,
body.research-page[data-theme="dark"] .lib-badge {
  color: #fff !important;
  background: none !important;
  font-weight: bold !important;
}

.tech-badge,
.lang-badge,
.lib-badge {
  font-weight: bold;
}

/* Hamburger menu styles */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 2.5rem;
  height: 2.5rem;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1100;
}
.hamburger span {
  display: block;
  width: 2rem;
  height: 0.25rem;
  margin: 0.3rem 0;
  background: var(--fg);
  border-radius: 2px;
  transition: all 0.3s;
}

@media (max-width: 768px) {
  nav, .main-nav {
    flex-direction: row;
    padding: 0.5rem 1rem;
    height: auto;
    justify-content: flex-end;
    align-items: center;
  }
  .main-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100vw;
    z-index: 1000;
    background: var(--bg);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  }
  .main-nav .theme-toggle {
    margin-left: 0.5rem;
    order: 2;
  }
  .hamburger {
    display: flex;
    margin-left: 0.5rem;
    margin-right: 0;
    order: 3;
    align-self: center;
    justify-self: flex-end;
  }
  .main-nav .nav-links {
    display: none;
  }
  .main-nav.nav-open .nav-links {
    display: flex;
  }
  .nav-links {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 70vw;
    max-width: 320px;
    background: var(--bg);
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 4.5rem 1.5rem 2rem 1.5rem;
    gap: 0.2rem;
    box-shadow: -2px 0 16px rgba(0,0,0,0.10);
    border-left: 1px solid var(--muted);
    transform: translateX(100%);
    transition: transform 0.3s;
    z-index: 1050;
  }
  .main-nav.nav-open .nav-links {
    transform: translateX(0);
  }
  .nav-links a, .nav-links span {
    font-size: 1.1rem;
    color: var(--fg);
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.25rem;
    border-radius: 0.3rem;
    transition: background 0.2s, color 0.2s;
  }
  .nav-links a:hover {
    background: var(--primary);
    color: #fff;
  }
  /* Main content and cards responsive */
  main.home, main.content, .projects-section, .timeline-container {
    padding-left: 1rem;
    padding-right: 1rem;
    max-width: 100vw;
  }
  .project-card, .timeline-content {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100%;
    min-width: 0;
    margin-left: 0;
    margin-right: 0;
  }
  .project-thumb {
    width: 100%;
    max-width: 320px;
    height: auto;
    margin: 0 auto 1rem auto;
    display: block;
  }
  .timeline {
    flex-direction: column;
    align-items: stretch;
  }
  .timeline-left, .timeline-right {
    width: 100%;
    padding: 0;
  }
  .timeline::before {
    left: 20px;
    height: 100%;
  }
  .main-nav,
  .nav-links {
    background: #f8f9fa;
  }
  .nav-links a,
  .nav-links span {
    color: #22223b !important;
  }
  .nav-links a:hover {
    background: #2563eb;
    color: #fff !important;
  }
  body[data-theme="dark"] .main-nav,
  body[data-theme="dark"] .nav-links {
    background: #101522;
  }
  body[data-theme="dark"] .nav-links a,
  body[data-theme="dark"] .nav-links span {
    color: #fff !important;
  }
  body[data-theme="dark"] .nav-links a:hover {
    background: #2563eb;
    color: #fff !important;
  }
}