/* ---------------------------------------------------------------- */
/* Fonts                                                             */
/* ---------------------------------------------------------------- */
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Lato Regular'), local('Lato-Regular'), url(https://fonts.gstatic.com/s/lato/v15/S6uyw4BMUTPHjx4wXiWtFCc.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local('Lato Bold'), local('Lato-Bold'), url(https://fonts.gstatic.com/s/lato/v15/S6u9w4BMUTPHh6UVSwiPGQ3q5d0.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------------------------------------------------------------- */
/* Theme                                                              */
/* ---------------------------------------------------------------- */
:root {
  --bg: #ffffff;
  --bg-subtle: #f6f7f9;
  --text: #1c1e21;
  --text-muted: #5b6572;
  --border: #e4e7eb;
  --accent: #1772d0;
  --accent-hover: #f09228;
  --card-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --chip-bg: #eef2f7;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --bg-subtle: #1b1e24;
  --text: #e7e9ec;
  --text-muted: #9aa3af;
  --border: #2a2e35;
  --accent: #5ea1e6;
  --accent-hover: #f4a94f;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
  --chip-bg: #21252c;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --bg-subtle: #1b1e24;
    --text: #e7e9ec;
    --text-muted: #9aa3af;
    --border: #2a2e35;
    --accent: #5ea1e6;
    --accent-hover: #f4a94f;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
    --chip-bg: #21252c;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  transition: background-color 0.2s ease, color 0.2s ease;
}

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

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

/* ---------------------------------------------------------------- */
/* Layout                                                             */
/* ---------------------------------------------------------------- */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

.site-nav {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  padding: 20px 24px 0;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

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

/* ---------------------------------------------------------------- */
/* Intro                                                              */
/* ---------------------------------------------------------------- */
.intro {
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 32px 0 8px;
}

.intro-text {
  flex: 1 1 auto;
  min-width: 0;
}

.name {
  margin: 0 0 12px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.name .zh {
  font-weight: 400;
  color: var(--text-muted);
}

.bio {
  margin: 0 0 14px;
  color: var(--text);
}

.avatar {
  flex: 0 0 auto;
  width: 148px;
  height: 180px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

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

.links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 4px;
  margin: 4px 0 0;
  font-weight: 600;
}

.links .sep {
  color: var(--border);
  padding: 0 2px;
}

/* "More about me" */
details.more {
  margin: 4px 0 0;
}

details.more summary {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

details.more summary::-webkit-details-marker {
  display: none;
}

details.more summary::before {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}

details.more[open] summary::before {
  transform: rotate(45deg);
}

details.more p {
  margin: 10px 0 0;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------- */
/* Sections                                                           */
/* ---------------------------------------------------------------- */
.section {
  padding: 28px 0 0;
}

.section h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
}

.section .section-lede {
  margin: 0 0 16px;
  color: var(--text-muted);
}

/* Publications */
.pub-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pub-card {
  display: flex;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-subtle);
}

.pub-media {
  flex: 0 0 clamp(150px, 34%, 240px);
  align-self: flex-start;
  border-radius: 8px;
  overflow: hidden;
  background: var(--chip-bg);
}

.pub-media video,
.pub-media img {
  display: block;
  width: 100%;
  height: auto;
}

.pub-body {
  min-width: 0;
}

.pub-title {
  font-weight: 700;
  margin: 0 0 4px;
}

.pub-authors,
.pub-desc {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 14px;
}

.pub-authors .me {
  color: var(--text);
  font-weight: 700;
}

.pub-venue {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}

.pub-links a {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
}

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

/* Timeline */
.timeline {
  position: relative;
  margin: 0;
  padding: 0 0 0 20px;
  list-style: none;
  border-left: 2px solid var(--border);
}

.timeline li {
  position: relative;
  padding: 0 0 24px 20px;
}

.timeline li:last-child {
  padding-bottom: 0;
}

.timeline li::before {
  content: '';
  position: absolute;
  left: -27px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
}

.tl-when {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.tl-title {
  margin: 2px 0 2px;
  font-weight: 700;
}

.tl-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* Footer */
.footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------- */
/* Responsive                                                         */
/* ---------------------------------------------------------------- */
@media (max-width: 560px) {
  .intro {
    flex-direction: column-reverse;
    text-align: center;
    gap: 20px;
  }

  .links {
    justify-content: center;
  }

  /* Float the media so the text wraps under it instead of leaving a gap
     beside a short video in a tall, narrow text column. */
  .pub-card {
    display: block;
    padding: 12px;
  }

  .pub-media {
    float: left;
    width: 48%;
    margin: 0 12px 8px 0;
  }

  .pub-body::after {
    content: '';
    display: block;
    clear: both;
  }
}

/* ---------------------------------------------------------------- */
/* Footnote popover                                                   */
/* ---------------------------------------------------------------- */
.note {
  position: relative;
  display: inline-block;
  margin-left: 3px;
  vertical-align: super;
  line-height: 0;
}

.note-btn {
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 10px;
  font-style: italic;
  font-weight: 700;
  line-height: 13px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.note-btn:hover,
.note-btn:focus-visible,
.note.is-open .note-btn {
  background: var(--accent);
  color: var(--bg);
  outline: none;
}

.note-pop {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: max-content;
  max-width: min(22rem, calc(100vw - 48px));
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: var(--card-shadow), 0 8px 24px rgba(16, 24, 40, 0.12);
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  vertical-align: baseline;
}

.note-pop::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  background: var(--bg);
  transform: rotate(45deg);
}

.note.flip .note-pop {
  left: auto;
  right: 0;
}

.note.flip .note-pop::before {
  left: auto;
  right: 2px;
}

/* Invisible bridge so the pointer can travel from the badge into the card. */
.note-pop::after {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
}

.note.is-open .note-pop {
  display: block;
}

/* Hover-capable devices (desktop): show on hover; touch devices tap instead. */
@media (hover: hover) {
  .note:hover .note-pop {
    display: block;
  }
}
