/* Layout & typography adapted from Jon Barron's template
   (https://github.com/jonbarron/website); palette is our own. */

/* ===== Base ===== */
:root {
  --text: #212121;
  --muted: #6e7174;
  --link: #1772d0;
  --link-hover: #0b4f99;
  --rule: #e6e6e6;
  --bg: #ffffff;
  --code-bg: #f8f8f8;
  --highlight: #f5f5f2;
  --sans: "Lato", Verdana, Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", monospace;
  --maxw: 800px;
}

/* Neutral dark palette, toggled from the top bar. */
:root[data-theme="dark"] {
  --text: #e5e5e5;
  --muted: #aaaaaa;
  --link: #6ab0ff;
  --link-hover: #a6d0ff;
  --rule: #3b3c3f;
  --bg: #222222;
  --code-bg: #292929;
  --highlight: #2a2a2a;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 24px 40px;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--link-hover); text-decoration: underline; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--text); outline-offset: 4px; }
.intro-bio p a, .post-body a, .section > p a { text-decoration: underline; text-underline-offset: 3px; }

p { margin: 0 0 1em; }
strong, b { font-weight: 700; }

/* ===== Top bar (shared by homepage and blog) ===== */
.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.nav .brand { font-size: 17px; font-weight: 700; color: var(--text); }
.nav .brand:hover { text-decoration: none; color: var(--link); }
.nav-links { margin-left: auto; display: flex; gap: 18px; }
.nav-links a { color: var(--muted); }
.nav-links a:hover { color: var(--link-hover); text-decoration: none; }
.nav-links a.active { color: var(--text); font-weight: 700; }

/* zh / EN switch (blog) */
.lang-switch { color: var(--muted); font-size: 14px; }
.lang-switch a, .lang-switch button {
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
  color: var(--muted);
}
.lang-switch a:hover, .lang-switch button:hover { color: var(--link-hover); text-decoration: none; }
.lang-switch a.active,
html[data-lang="zh"] .lang-switch button[data-l="zh"],
html[data-lang="en"] .lang-switch button[data-l="en"] { color: var(--text); font-weight: 700; }

/* translated posts on the blog index: show only the preferred language */
html[data-lang="en"] .i18n[data-l="zh"],
html:not([data-lang="en"]) .i18n[data-l="en"] { display: none; }

.theme-toggle {
  background: none;
  border: 1px solid var(--rule);
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--link); border-color: var(--link); }

/* ===== Intro: text left, photo right ===== */
.intro {
  display: flex;
  gap: 32px;
  align-items: center;
  padding: 12px 0 8px;
}
.intro-bio { flex: 0 1 63%; min-width: 0; }
.intro-photo { flex: 0 1 37%; max-width: 37%; }
.intro-photo img {
  width: 100%;
  max-width: 260px;
  height: auto;            /* keep the photo's full aspect ratio — no cropping */
  display: block;
  margin: 0 auto;
}

.intro-bio h1 {
  font-weight: 400;
  font-size: 32px;
  line-height: 1.2;
  text-align: center;
  margin: 0 0 6px;
}
.intro-bio h1 .zh { font-size: 22px; color: var(--muted); margin-left: 6px; }

.affil { color: var(--muted); text-align: center; margin-bottom: 18px; }

.links { text-align: center; margin: 4px 0 0; }
.intro-bio .links a { text-decoration: none; }
.intro-bio .links a:hover { text-decoration: underline; }

/* ===== Sections ===== */
.section { margin-top: 36px; overflow-wrap: break-word; }
.section > :last-child { margin-bottom: 0; }

.section h2 {
  font-weight: 400;
  font-size: 22px;
  margin: 0 0 14px;
}

.note { color: var(--muted); font-size: 13px; margin-top: -6px; }

/* ===== News / timeline lists ===== */
.news, .timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.news li, .timeline li {
  display: flex;
  gap: 16px;
  padding: 4px 0;
  align-items: baseline;
}
.news .date, .timeline .date {
  flex: 0 0 110px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.news .item, .timeline .item { flex: 1 1 auto; }
.experience li { padding: 8px 0; }
.experience .date { flex-basis: 150px; }

/* ===== Publications: thumbnail left, text right ===== */
.pub {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 16px 0;
}
.pub.highlight { background: var(--highlight); padding: 16px 12px; margin: 0 -12px; }
.pub-thumb { flex: 0 0 25%; display: block; }
.pub-thumb img { width: 100%; display: block; background: #ffffff; }  /* transparent figures stay legible in dark mode */

.pub-info { flex: 1 1 auto; min-width: 0; }
.pub-info p { margin: 0 0 3px; }
.pub-title { font-weight: 700; }
.pub-title a { color: var(--link); }
.pub-title a:hover { color: var(--link-hover); }
.pub-venue { font-style: italic; }
.pub-desc { margin-top: 8px !important; }

sup { font-size: 0.7em; }

/* ===== Footer ===== */
.footer {
  margin-top: 48px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

/* ===== Blog index ===== */
.blog-list { list-style: none; margin: 0; padding: 0; }
.blog-list li {
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}
.blog-list li:last-child { border-bottom: none; }
.blog-list .post-link {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}
.blog-list .post-link:hover { color: var(--link); text-decoration: none; }
.blog-list .post-date { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.blog-list .post-summary { margin: 6px 0 0; }
.blog-empty { color: var(--muted); }

/* ===== Single post ===== */
.post header { margin-bottom: 28px; }
.post h1 {
  font-weight: 700;
  font-size: 30px;
  line-height: 1.25;
  margin: 0 0 6px;
}
.post .post-date { color: var(--muted); font-size: 15px; margin: 0; }
.post-body { font-size: 17px; line-height: 1.75; overflow-wrap: break-word; }
.post-body h2 { font-size: 22px; margin: 1.6em 0 0.5em; }
.post-body h3 { font-size: 19px; margin: 1.4em 0 0.4em; }
.post h1, .intro-bio h1, .pub-title { overflow-wrap: anywhere; }
.post-body img { max-width: 100%; height: auto; border-radius: 4px; }

/* keep over-wide content inside the column instead of stretching the page */
.post-body a { overflow-wrap: anywhere; }                 /* long URLs wrap */
.post-body table {                                        /* wide tables scroll locally */
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}
.post-body th, .post-body td { border: 1px solid var(--rule); padding: 6px 12px; }
.post-body mjx-container { max-width: 100%; }
.post-body mjx-container[display="true"] {                /* long display equations scroll locally */
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}
.post-body pre, .post-body .codehilite {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 14px;
}
.post-body .codehilite pre {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
}
.post-body code {
  font-family: var(--mono);
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}
.post-body pre code { background: none; padding: 0; }
.post-body blockquote {
  margin: 1em 0;
  padding: 2px 16px;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}
.post-back { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--rule); }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .container { padding: 16px 18px 32px; }
  .intro { flex-direction: column-reverse; gap: 20px; }
  .intro-bio, .intro-photo { flex-basis: auto; max-width: 100%; }
  .intro-photo img { max-width: 180px; }
  .news li, .timeline li { flex-direction: column; gap: 0; }
  .news .date, .timeline .date { flex-basis: auto; }
  .pub { flex-direction: column; align-items: flex-start; }
  .pub-thumb { flex-basis: auto; width: 100%; max-width: 320px; }
  .footer { text-align: center; }
}
