/* Dark theme: Midnight. Previous Indigo dark palette:
  --bg: #15192b; --bg-soft: #1d2338; --bg-card: #202840; --text: #c9d3f6;
  --text-muted: #8d9bd6; --accent: #8ea4f7; --accent-light: #b7c5ff;
  --border: #3b4775; --gradient-start: #8ea4f7; --gradient-end: #c9d3f6;
  Other palettes are listed in palette-switcher.js. */
:root {
  --bg: #0b0d12;
  --bg-soft: #12151d;
  --bg-card: #171b25;
  --text: #dfe4ee;
  --text-muted: #8a93a8;
  --accent: #7aa2ff;
  --accent-light: #b3c8ff;
  --border: #2a3142;
  --shadow: rgba(0, 0, 0, 0.35);
  --gradient-start: #7aa2ff;
  --gradient-end: #dfe4ee;
}

/* Light theme: Terracotta. Previous Indigo light palette:
  --bg: #f5f7ff; --bg-soft: #e8ecf9; --bg-card: #ffffff; --text: #1d2338;
  --text-muted: #4d5878; --accent: #4a5fcb; --accent-light: #6b7fd6;
  --border: #b7c5ff; --gradient-start: #4a5fcb; --gradient-end: #8ea4f7;
  Other palettes are listed in palette-switcher.js. */
[data-theme="light"] {
  --bg: #fbf7f2;
  --bg-soft: #f2e9df;
  --bg-card: #ffffff;
  --text: #2b211b;
  --text-muted: #6b574a;
  --accent: #c0582c;
  --accent-light: #d97a4e;
  --border: #e8c7b0;
  --shadow: rgba(0, 0, 0, 0.1);
  --gradient-start: #c0582c;
  --gradient-end: #e08a5f;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: min(70%, 1400px);
  margin: 0 auto;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 1.25rem 0;
  background: rgba(11, 13, 18, 0.85);
  backdrop-filter: blur(12px);
  transition: background-color 0.3s ease;
}

[data-theme="light"] .header {
  background: rgba(251, 247, 242, 0.85);
}

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

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
}

.nav-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem 1.25rem;
  list-style: none;
}

.nav-link {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent-light);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle:hover {
  color: var(--accent-light);
  background-color: var(--bg-soft);
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
}

.hidden {
  display: none;
}

.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
}

.mobile-menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--text);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Hero */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8rem 0 4rem;
  text-align: left;
}

.hero-content {
  display: grid;
  grid-template-columns: 300px 1fr;
  align-items: flex-start;
  gap: 3rem;
  padding-top: 2rem;
}

.hero-image {
  justify-self: center;
  padding-top: 0.5rem;
}

.hero-image img {
  width: 300px;
  height: 300px;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 16px 40px var(--shadow);
}

.hero-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.25rem;
  /* Column is as wide as the title; the intro text fills that width. */
  justify-self: start;
  width: fit-content;
  max-width: 100%;
}

.hero-title {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-subtitle {
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--accent-light);
}

.hero-description {
  /* Don't widen the column; just fill the title's width. */
  width: 0;
  min-width: 100%;
  font-size: clamp(0.95rem, 1.4vw, 1.05rem);
  color: var(--text-muted);
  line-height: 1.7;
  text-align: left;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.btn-outline {
  border: 2px solid var(--accent);
  color: var(--accent);
  background-color: transparent;
}

.btn-outline:hover {
  background-color: var(--accent);
  color: var(--bg);
}

.icon-link {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s ease, transform 0.2s ease;
}

.icon-link:hover {
  color: var(--accent-light);
  transform: translateY(-2px);
}

.social-icon {
  width: 1.75rem;
  height: 1.75rem;
}

/* Sections */
.section {
  padding: 4.5rem 0;
}

.section-title {
  text-align: center;
  font-size: clamp(1.75rem, 4.5vw, 2.5rem);
  font-weight: 800;
  color: var(--accent-light);
  margin-bottom: 2.5rem;
  letter-spacing: -0.02em;
}

/* Research interests */
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.75rem;
}

.chip {
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  background-color: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 4px 12px var(--shadow);
}

/* Publications */
.publications-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.publication-card {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  background-color: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.publication-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px var(--shadow);
}

.publication-venue {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background-color: var(--accent);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 4px 12px var(--shadow);
}

.publication-image {
  flex: 0 0 220px;
  background-color: var(--bg-soft);
  overflow: hidden;
}

.publication-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.publication-image img.align-right {
  object-position: right center;
}

.publication-placeholder {
  width: 100%;
  height: 100%;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-muted);
}

.publication-info {
  flex: 1 1 auto;
  padding: 1.5rem;
  padding-right: 7rem;
  display: flex;
  flex-direction: column;
}

.publication-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--accent-light);
}

.publication-authors {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.publication-authors sup {
  font-size: 0.65rem;
  color: var(--accent);
  margin-left: 0.1rem;
}

.publication-affiliations {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.publication-affiliations sup {
  font-size: 0.6rem;
  color: var(--accent);
  margin-right: 0.1rem;
}

.publication-meta {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.publication-description {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  flex: 1 1 auto;
}

.publication-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.publication-links .link-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background-color: var(--bg-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.publication-links .link-chip:hover {
  background-color: var(--accent);
  color: var(--bg);
}

/* News grid */
.news-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.news-card {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.news-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px var(--shadow);
}

.news-card.hidden {
  display: none;
}

.news-image {
  width: 100%;
  height: 180px;
  background-color: var(--bg-soft);
  overflow: hidden;
}

.news-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.news-card:hover .news-image img {
  transform: scale(1.05);
}

.news-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
}

.news-body h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 0.5rem;
}

.news-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.news-meta-icon {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

.news-detail {
  flex: 1 1 auto;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.news-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.news-links a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

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

.news-no-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.news-load-more {
  display: block;
  width: max-content;
  margin: 2.5rem auto 0;
}

.news-load-more.hidden {
  display: none;
}

/* Blog */
.blog-overview-grid,
.blog-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.blog-overview-card,
.blog-card {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.blog-overview-card:hover,
.blog-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px var(--shadow);
}

.blog-overview-image,
.blog-image {
  width: 100%;
  height: 180px;
  background-color: var(--bg-soft);
  overflow: hidden;
}

.blog-overview-image img,
.blog-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.blog-overview-card:hover .blog-overview-image img,
.blog-card:hover .blog-image img {
  transform: scale(1.05);
}

.blog-overview-body,
.blog-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
}

.blog-overview-body h3,
.blog-body h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 0.5rem;
}

.blog-date {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.blog-excerpt {
  flex: 1 1 auto;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.blog-read-more {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
  align-self: flex-start;
}

.blog-read-more:hover {
  border-bottom-color: var(--accent);
}

.blog-loading,
.blog-error {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
}

.post-content {
  max-width: 720px;
  margin: 0 auto;
}

.post-header {
  margin: 2rem 0 1.5rem;
}

.post-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: var(--accent-light);
  margin: 0.5rem 0 1.5rem;
  line-height: 1.2;
}

.post-image {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 2rem;
  box-shadow: 0 8px 24px var(--shadow);
}

.post-image img {
  width: 100%;
  height: auto;
  display: block;
}

.post-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
}

.post-body h2,
.post-body h3 {
  color: var(--accent-light);
  margin: 1.5rem 0 0.75rem;
}

.post-body p {
  margin-bottom: 1rem;
}

.post-body ul,
.post-body ol {
  margin: 0 0 1rem 1.25rem;
}

.post-body li {
  margin-bottom: 0.5rem;
}

.post-body strong {
  color: var(--accent-light);
}

/* Timeline (education & experience) */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.timeline-item {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  background-color: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 8px 24px var(--shadow);
}

.timeline-date {
  flex: 0 0 130px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
}

.timeline-content {
  flex: 1 1 auto;
}

.timeline-content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 0.25rem;
}

.timeline-place {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.timeline-detail {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.timeline-detail a,
.hero-description a {
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.timeline-detail a:hover,
.hero-description a:hover {
  border-bottom-color: var(--accent);
}

/* Cards list (teaching & talks) */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.info-card {
  padding: 1.5rem;
  background-color: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 8px 24px var(--shadow);
}

.info-card h3 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 0.25rem;
}

.entry-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--accent);
}

.entry-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.info-meta {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.info-detail {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.info-links {
  display: flex;
  gap: 1.25rem;
}

.info-links a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

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

/* Contact */
.contact-content {
  text-align: center;
}

.contact-text {
  max-width: 480px;
  margin: 0 auto 1.75rem;
  color: var(--text-muted);
}

/* Footer */
.footer {
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
}

.footer-credit {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.footer-credit a {
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.footer-credit a:hover {
  border-bottom-color: var(--accent);
}

@media (max-width: 1000px) {
  .news-grid,
  .blog-overview-grid,
  .blog-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile nav */
@media (max-width: 700px) {
  .nav-list {
    position: fixed;
    top: 0;
    right: -100%;
    width: min(75%, 300px);
    height: 100vh;
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: nowrap;
    gap: 0;
    padding: 5rem 2rem 2rem;
    background-color: var(--bg-soft);
    box-shadow: -8px 0 24px var(--shadow);
    transition: right 0.3s ease;
    overflow-y: auto;
  }

  .nav-list.open {
    right: 0;
  }

  .nav-list li {
    width: 100%;
    border-bottom: 1px solid var(--border);
  }

  .nav-link,
  .theme-toggle {
    display: block;
    width: 100%;
    padding: 1rem 0;
    text-align: left;
  }

  .theme-toggle {
    border-radius: 0;
    height: auto;
    justify-content: flex-start;
  }

  .mobile-menu-toggle {
    display: flex;
    z-index: 110;
  }

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

  .mobile-menu-toggle.open span:nth-child(2) {
    opacity: 0;
  }

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

  .hero-content {
    grid-template-columns: 1fr;
    gap: 2rem;
    text-align: center;
  }

  .hero-text {
    align-items: center;
  }

  .hero-title,
  .hero-subtitle,
  .hero-description {
    width: 100%;
    text-align: center;
  }

  .chips,
  .hero-actions {
    width: 100%;
    justify-content: center;
  }

  .hero-image img {
    width: 220px;
    height: 220px;
  }

  .hero-content {
    padding-top: 0;
  }

  .hero-description {
    text-align: center;
  }

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

  .publication-image {
    flex: 0 0 auto;
    height: 140px;
  }

  .publication-info {
    padding-right: 5rem;
  }

  .timeline-item {
    flex-direction: column;
    gap: 0.5rem;
  }

  .timeline-date {
    flex: 0 0 auto;
  }

  .news-grid,
  .blog-overview-grid,
  .blog-list {
    grid-template-columns: 1fr;
  }
}
