/* ============================================
   Academic Homepage — Clean & Minimal Theme
   Teal accent · Light/Dark mode
   ============================================ */

/* --- CSS Variables --- */
:root,
[data-theme="light"] {
  --bg: #ffffff;
  --bg-alt: #f7fafa;
  --text: #1a2a2a;
  --text-secondary: #4a5e5e;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --border: #e0e7e7;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06);
  --nav-bg: rgba(255,255,255,0.92);
  --code-bg: #f0f5f5;
}

[data-theme="dark"] {
  --bg: #0f1a1a;
  --bg-alt: #162222;
  --text: #e0ecec;
  --text-secondary: #94b0b0;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --border: #243636;
  --card-bg: #1a2c2c;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
  --nav-bg: rgba(15,26,26,0.92);
  --code-bg: #1a2c2c;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  transition: background 0.3s, color 0.3s;
}

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

h1, h2, h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  line-height: 1.3;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- Navigation --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
}

.nav-logo {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
}
.nav-logo:hover {
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 400;
  transition: color 0.2s;
}
.nav-links a.active {
  color: var(--accent);
  font-weight: 500;
}
.nav-links a:hover {
  color: var(--accent);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: color 0.2s, border-color 0.2s;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

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

/* Mobile menu button */
.nav-menu-btn {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.nav-menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  transition: transform 0.3s, opacity 0.3s;
}
.nav-menu-btn.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-menu-btn.open span:nth-child(2) { opacity: 0; }
.nav-menu-btn.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* --- Hero --- */
.hero {
  padding: 7rem 0 4rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 2.5rem;
  align-items: start;
}

.photo-placeholder {
  width: 180px;
  height: 180px;
  border-radius: 12px;
  background: var(--bg-alt);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  overflow: hidden;
}

.photo-placeholder img,
.hero-photo img {
  width: 180px;
  height: 180px;
  border-radius: 12px;
  object-fit: cover;
}

.hero-text h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 0.15rem;
}

.affiliation {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.bio {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
}

.hero-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

/* --- Email Dropdown --- */
.email-dropdown {
  position: relative;
}

.email-btn {
  cursor: pointer;
  font-family: inherit;
}

.email-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 220px;
  z-index: 50;
  overflow: hidden;
}

.email-menu.open {
  display: flex;
  flex-direction: column;
}

.email-menu a {
  display: block;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  color: var(--text);
  transition: background 0.15s;
}

.email-menu a:hover {
  background: var(--bg-alt);
  color: var(--accent);
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  transition: all 0.2s;
  background: var(--accent);
  color: #fff;
  box-sizing: border-box;
}
.btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
}
.btn-outline:hover {
  background: var(--accent);
  color: #fff;
}

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

.section-alt {
  background: var(--bg-alt);
}

.section h2 {
  font-size: 1.6rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.section-intro {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  max-width: 640px;
}

/* --- Research Cards --- */
.research-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.research-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.research-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(13,148,136,0.1);
}

.research-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.research-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* --- Publications --- */
.pub-year {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.pub-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.pub-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  transition: border-color 0.2s;
}
.pub-item:hover {
  border-left-color: var(--accent);
}

.pub-title {
  font-weight: 500;
  font-size: 0.975rem;
}

.pub-legend {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 0.75rem;
}

.pub-authors {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.author-me {
  font-weight: 700;
  color: var(--accent);
}

.corresponding-mark {
  font-size: 0.7em;
  margin-left: 1px;
  vertical-align: super;
  line-height: 0;
}

.pub-legend .corresponding-mark {
  margin-right: 4px;
  margin-left: 0;
}

.pub-venue {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

.venue-top {
  color: var(--accent);
  font-weight: 700;
}

.pub-links {
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.pub-links a {
  font-weight: 500;
}

/* --- Teaching --- */
.teaching-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.teaching-item {
  display: flex;
  gap: 1.5rem;
  align-items: baseline;
}

.teaching-term {
  min-width: 110px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  flex-shrink: 0;
}

.teaching-detail h3 {
  font-size: 1rem;
  font-weight: 500;
}

.teaching-detail p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* --- CV --- */
.cv-section {
  margin-bottom: 2rem;
}

.cv-section h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.cv-item {
  display: flex;
  gap: 1.5rem;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.cv-date {
  min-width: 130px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.cv-detail {
  font-size: 0.95rem;
}

/* --- Services --- */
.service-group {
  margin-bottom: 1.5rem;
}

.service-category {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.service-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-left: 0;
}

.service-items li {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding-left: 1rem;
  position: relative;
  line-height: 1.6;
}

.service-items li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

/* --- Talks --- */
.talk-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 1rem;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  transition: border-color 0.2s;
}

.talk-item:hover {
  border-left-color: var(--accent);
}

.talk-title {
  font-weight: 500;
  font-size: 0.95rem;
}

.talk-detail {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* --- Back to Top --- */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, color 0.2s, border-color 0.2s;
  box-shadow: var(--card-shadow);
  z-index: 50;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
}

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

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 3.5rem;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
  }
  .nav-links.open {
    display: flex;
  }
  .nav-menu-btn {
    display: flex;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .hero-photo {
    justify-self: center;
  }

  .hero-text h1 {
    font-size: 1.6rem;
  }

  .teaching-item,
  .cv-item {
    flex-direction: column;
    gap: 0.25rem;
  }

  .teaching-term,
  .cv-date {
    min-width: auto;
  }
}
