html { background-color: #ffffff; }
/* Prevent flash of light mode */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-color: #ffffff;
  --text-color: #333;
  --link-color: #1772d0;
  --link-hover: #f09228;
  --border-color: #f0f0f0;
  --news-bg: #f9f9f9;
  --gray-text: #666;
  background-color: #ffffff;
}

body.dark-mode-loading {
  visibility: hidden;
}

html.dark-mode,
body.dark-mode {
  --bg-color: #1a1a1a;
  --text-color: #e0e0e0;
  --link-color: #6bb6ff;
  --link-hover: #ffa940;
  --border-color: #333;
  --news-bg: #252525;
  --gray-text: #999;
  background-color: #1a1a1a; /* This line is critical */
}
body {
  font-family: 'Lato', Verdana, Helvetica, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  background-color: var(--bg-color);
  color: var(--text-color);
  padding: 20px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding-top: 20px;
}

/* Sticky Navigation */
.sticky-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-color);
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 1000;
  transform: translateY(0);
  transition: transform 0.3s ease, background-color 0.3s ease;
  padding: 12px 20px;
}

body.dark-mode .sticky-nav {
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.sticky-nav.visible {
  transform: translateY(0);
}

.nav-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.nav-links a {
  font-size: 16px;
  font-weight: 500;
}

.nav-controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

/* Dark mode toggle */
.theme-toggle {
  background: none;
  border: 2px solid var(--text-color);
  border-radius: 20px;
  width: 50px;
  height: 28px;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  padding: 0;
}

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

.theme-toggle::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: var(--text-color);
  top: 2px;
  left: 2px;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

body.dark-mode .theme-toggle::after {
  transform: translateX(22px);
}

/* Mobile menu */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-color);
  padding: 0;
  line-height: 1;
}

/* Header */
.header-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
  gap: 40px;
}

.header-info {
  flex: 1;
}

h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  transition: color 0.3s ease;
}

h1:hover {
  color: var(--link-hover);
  cursor: default;
}

.email {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  margin-bottom: 20px;
  color: var(--gray-text);
}

.portrait img {
  max-width: 220px;
  border-radius: 50%;
  display: block;
}

/* Links */
a {
  color: var(--link-color);
  text-decoration: none;
  transition: all 0.3s ease;
}

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

/* Publication title links */
a.pub-link {
  color: inherit;
  background-color: transparent;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 3px;
  transition: all 0.2s ease;
}

a.pub-link:hover {
  background-color: #000;
  color: #fff;
}

body.dark-mode a.pub-link:hover {
  background-color: #fff;
  color: #000;
}

/* Social Icons */
.social-icons {
  display: flex;
  justify-content: center;
  gap: 100px;
  margin: 50px 0;
  flex-wrap: wrap;
}

.social-icons a img {
  width: 64px;
  height: 64px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.social-icons a:hover img {
  transform: translateY(-4px);
  opacity: 0.8;
}

/* Invert only black/dark icons in dark mode */
body.dark-mode .social-icons a img[src*="cv-icon"],
body.dark-mode .social-icons a img[src*="iconbluesky"],
body.dark-mode .social-icons a img[src*="icongithub"],
body.dark-mode .social-icons a img[src*="email-icon"],
body.dark-mode .social-icons a img[src*="google-scholar"],
body.dark-mode .social-icons a img[src*="hal-logo"],
body.dark-mode .social-icons a img[src*="hf_logo"] {
  filter: invert(1);
}
/* Sections */
h2 {
  font-size: 26px;
  font-weight: 700;
  margin-top: 48px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 8px;
  scroll-margin-top: 80px;
}

p {
  margin-bottom: 16px;
}

/* Date spans */
.datespan {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  margin-right: 8px;
  white-space: nowrap;
  color: var(--gray-text);
}

/* Publication entries */
.pub-entry {
  margin-bottom: 24px;
  padding-left: 0;
}

.pub-entry.first {
  margin-top: 16px;
}

.pub-title {
  font-weight: 700;
  font-size: 18px;
}

/* New badge */
.newgif {
  width: 56px;
  height: 56px;
  vertical-align: middle;
  margin-right: 12px;
}

/* News section */
.news-box {
  background-color: var(--news-bg);
  padding: 20px;
  border-radius: 8px;
  margin: 24px 0;
  transition: background-color 0.3s ease;
}

.news-item {
  margin-bottom: 12px;
}

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

/* Research interests */
.interests {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.interest-tag {
  background-color: var(--news-bg);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 16px;
  transition: all 0.3s ease;
}

.interest-tag:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

body.dark-mode .interest-tag:hover {
  box-shadow: 0 4px 8px rgba(255,255,255,0.1);
}

/* Download buttons */
.download-buttons {
  display: flex;
  gap: 16px;
  margin: 24px 0;
  flex-wrap: wrap;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background-color: var(--link-color);
  color: white;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.download-btn:hover {
  background-color: var(--link-hover);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Page headers for subpages */
.page-header {
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 3px solid var(--border-color);
}

.page-header h1 {
  font-size: 36px;
  margin-bottom: 12px;
}

.page-subtitle {
  font-size: 18px;
  color: var(--gray-text);
  margin: 0;
  line-height: 1.6;
}

/* Footer */
footer {
  margin-top: 60px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  text-align: right;
  font-size: 14px;
  color: var(--gray-text);
}

/* ADD THESE RULES HERE - BEFORE @media */

/* Wrapper for figures (images + iframes in publications) */
.pub-figure {
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

/* PNGs: constrain size on desktop, full width on mobile */
.pub-image {
  display: block;
  width: 100%;
  max-width: 700px;     /* Maximum width on desktop */
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body.dark-mode .pub-image {
  box-shadow: 0 2px 8px rgba(255,255,255,0.1);
}

/* Interactive iframe: responsive sizing */
.pub-iframe {
  display: block;
  width: 100%;
  max-width: 1200px;    /* Wider to fit all clusters horizontally */
  height: 800px;        /* INCREASE HEIGHT - much taller to show full viz */
  margin: 1.5rem auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body.dark-mode .pub-iframe {
  box-shadow: 0 2px 8px rgba(255,255,255,0.1);
}

/* NOW START THE @media SECTION */
/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .container {
    padding-top: 10px;
  }

  .header-section {
    flex-direction: column-reverse;
    align-items: center;
  }

  .portrait img {
    max-width: 180px;
    margin-bottom: 20px;
  }

  .social-icons {
    gap: 16px;
  }

  .social-icons a img {
    width: 40px;
    height: 40px;
  }

  .mobile-menu-btn {
    display: block;
  }

  .nav-links {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    background-color: var(--bg-color);
    padding: 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    flex-direction: column;
    gap: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .nav-links.active {
    max-height: 300px;
  }

  .nav-links a {
    padding: 16px 20px;
    width: 100%;
    display: block;
    border-bottom: 1px solid var(--border-color);
  }

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

  .download-buttons {
    flex-direction: column;
  }

  .download-btn {
    width: 100%;
    justify-content: center;
  }
  
  h2 {
    scroll-margin-top: 60px;
  }
  
  /* Mobile adjustments for images/iframes */
  .pub-image {
    max-width: 100%;    /* Full width on mobile */
  }
  
  .pub-iframe {
    max-width: 100%;
    height: 600px;      /* Taller on mobile too */
    margin: 1rem auto;
  }
}

/* For very small screens */
@media (max-width: 480px) {
  .pub-iframe {
    height: 500px;
  }
}
}
