/* ==========================================================================
   Yi Wei — personal site
   Layout after Jon Barron's academic template: one centered column, section
   headings above their content. Navy ink on white with one accent color
   (change --accent to re-theme the whole site). Three typefaces:
     Lato            — everything on the homepage
     LXGW WenKai     — Chinese name (Kai style; only its characters are loaded)
     Noto Serif SC   — any other Chinese text
     Source Serif 4  — blog post body text
   ========================================================================== */

:root {
  --paper:    #ffffff;
  --ink:      #16213a;   /* body text: deep navy instead of pure black */
  --ink-soft: #3a4560;
  --muted:    #5f6a7f;
  --hair:     #e1e5ee;
  --wash:     #f4f6fb;

  /* Theme color. Everything colored on the site derives from these two. */
  --accent:      #6d28d9;
  --accent-wash: #f5f1fe;

  --ui:   "Lato", "Noto Serif SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --cn:   "LXGW WenKai TC", "Kaiti SC", STKaiti, KaiTi, serif;
  --read: "Source Serif 4", "Noto Serif SC", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --max: 880px;

  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
main.wrap { padding-top: 40px; padding-bottom: 72px; }

/* ---------- links: accent color, no underline until hover ---------- */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ==========================================================================
   Masthead / nav (only rendered while the blog is on)
   ========================================================================== */
.masthead { border-bottom: 1px solid var(--hair); }
.masthead .wrap {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; padding-top: 18px; padding-bottom: 16px;
}
.masthead .wordmark { font-weight: 700; color: var(--ink); }
.masthead nav { display: flex; gap: 22px; }
.masthead nav a { color: var(--ink-soft); }
.masthead nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* ==========================================================================
   Sections: heading on top, content below
   ========================================================================== */
.section { padding: 18px 0; }
.section > h2 {
  margin: 0 0 12px;
  font-size: 22px; font-weight: 400;
  color: var(--ink);
}
.section > .body { min-width: 0; }

/* ==========================================================================
   Intro: name + bio on the left, photo on the right
   ========================================================================== */
.intro {
  display: grid; grid-template-columns: 210px 1fr; gap: 36px;
  align-items: start; padding-bottom: 18px;
}
.intro h1 {
  margin: 0 0 14px;
  font-size: 32px; font-weight: 400; line-height: 1.2;
}
.intro h1 .cn { font-family: var(--cn); font-weight: 400; color: var(--muted); font-size: 0.7em; letter-spacing: normal; margin-left: 8px; }
.intro p { margin: 0 0 12px; }
.intro p.muted { color: var(--muted); }
.intro p b { font-weight: 700; }
.intro p a b { color: var(--accent); }
.intro .contact { margin-top: 16px; }
.intro .contact .sep { color: var(--muted); margin: 0 2px; }
.intro .portrait { order: -1; }
.intro .portrait img {
  width: 100%; aspect-ratio: 4/5; object-fit: cover; object-position: 50% 30%;
  display: block; border-radius: 6px; background: var(--wash);
}

/* ==========================================================================
   News
   ========================================================================== */
.news { margin: 0; padding-left: 20px; }
.news li { margin-bottom: 4px; }
.news li::marker { color: var(--accent); }
.news .when { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.viewmore {
  font: inherit; color: var(--accent); background: none; border: 0;
  padding: 2px 0 0 20px; cursor: pointer;
}
.viewmore:hover { text-decoration: underline; }

/* ==========================================================================
   Publications & projects
   ========================================================================== */
.entry { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; padding: 16px 0; }
.entry.no-media { grid-template-columns: 1fr; }
.entry.highlight {
  background: var(--accent-wash); border-radius: 8px;
  padding: 16px; margin: 0 -16px;
}

.entry .media { margin: 0; }
.entry .media img, .entry .media video { width: 100%; display: block; border-radius: 4px; background: var(--wash); }
.entry .media figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

.entry .title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; line-height: 1.4; }
.entry .byline { font-size: 14px; margin: 0 0 2px; color: var(--ink-soft); }
.entry .byline .me { font-weight: 700; color: var(--ink); }
.entry .where { font-size: 14px; margin: 0; }
.entry .where b { font-weight: 700; }
.entry .where .status { font-style: italic; color: var(--muted); }
.entry .tldr { margin: 10px 0 0; font-size: 14.5px; }

.entry .prose { font-size: 15px; line-height: 1.62; margin: 0 0 10px; }
.entry .prose sup { font-size: 0.72em; }
.entry .contribution {
  font-size: 15px; line-height: 1.62;
  margin: 0 0 10px; padding-left: 14px; border-left: 2px solid var(--accent);
}
.entry .contribution b { font-weight: 700; }

.entry .tags { font-size: 13.5px; color: var(--muted); margin-top: 8px; }
.entry .rowlinks { font-size: 14.5px; margin-top: 9px; display: flex; flex-wrap: wrap; gap: 0 12px; }

/* abs / arXiv / pdf / video / bib */
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill {
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1;
  padding: 5px 10px; border-radius: 4px; cursor: pointer;
  color: var(--accent); background: var(--paper);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  text-decoration: none;
}
.pill:hover, .pill[aria-expanded="true"] {
  color: #fff; background: var(--accent); border-color: var(--accent); text-decoration: none;
}
.panel {
  margin-top: 12px; padding: 14px 16px;
  background: var(--paper); border: 1px solid var(--hair); border-radius: 6px;
}
.panel .prose:last-child, .panel .contribution:last-child { margin-bottom: 0; }
.panel pre {
  margin: 0; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
}

/* ==========================================================================
   CV-style lists (experience, teaching, service, education, awards)
   ========================================================================== */
.cvlist { margin: 0; }
.cvlist .item + .item { margin-top: 16px; }
.cvlist .head, .cvlist .subhead {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  align-items: baseline;
}
.cvlist .what { font-weight: 700; }
.cvlist .when { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cvlist .org { color: var(--ink-soft); }
.cvlist .detail { font-size: 14.5px; color: var(--muted); margin: 4px 0 0; }

/* optional logo (lab, school, conference) to the left of an entry */
.cvlist .item.has-logo {
  display: grid; grid-template-columns: 64px 1fr; gap: 18px; align-items: center;
}
.cvlist .item.has-logo + .item { margin-top: 22px; }
.cvlist .logo { display: flex; justify-content: center; }
.cvlist .logo img { max-width: 60px; max-height: 36px; object-fit: contain; display: block; }

/* ==========================================================================
   Blog
   ========================================================================== */

/* blog index header */
.pagehead { margin-bottom: 34px; padding-bottom: 22px; border-bottom: 1px solid var(--hair); }
.pagehead h1 { margin: 0 0 6px; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.pagehead p { margin: 0; color: var(--muted); font-family: var(--read); font-size: 16px; max-width: 60ch; }

.postlist { margin: 0; }
.postlist .item { padding: 22px 0; border-top: 1px solid var(--hair); }
.postlist .item:first-child { border-top: 0; padding-top: 0; }
.postlist .when { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.postlist h3 { margin: 3px 0 5px; font-size: 19px; font-weight: 600; letter-spacing: -0.012em; }
.postlist h3 a { text-decoration: none; }
.postlist h3 a:hover { text-decoration: underline; text-underline-offset: 3px; }
.postlist .blurb { font-family: var(--read); font-size: 15.5px; color: var(--ink-soft); margin: 0; max-width: 64ch; }
.postlist .empty { color: var(--muted); }

.post { max-width: 68ch; }
.post .when { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.post h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin: 6px 0 22px; text-wrap: balance; }
.post .content { font-family: var(--read); font-size: 17px; line-height: 1.7; }
.post .content p { margin: 0 0 18px; }
.post .content h2 { font-family: var(--ui); font-size: 19px; font-weight: 600; margin: 34px 0 10px; letter-spacing: -0.01em; }
.post .content h3 { font-family: var(--ui); font-size: 16px; font-weight: 600; margin: 26px 0 8px; }
.post .content ul, .post .content ol { margin: 0 0 18px; padding-left: 22px; }
.post .content li { margin-bottom: 6px; }
.post .content img { max-width: 100%; height: auto; display: block; margin: 22px 0; }
.post .content blockquote {
  margin: 22px 0; padding-left: 18px; border-left: 2px solid var(--hair); color: var(--ink-soft);
}
.post .content code {
  font-family: var(--mono); font-size: 0.85em; background: var(--wash); padding: 1px 5px;
}
.post .content pre {
  background: var(--wash); padding: 15px 17px; overflow-x: auto;
  font-family: var(--mono); font-size: 13px; line-height: 1.6; margin: 0 0 20px;
}
.post .content pre code { background: none; padding: 0; font-size: inherit; }
.post .content table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-family: var(--ui); font-size: 14.5px; }
.post .content th, .post .content td { text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--hair); }
.post .backlink { margin-top: 46px; padding-top: 18px; border-top: 1px solid var(--hair); font-size: 14.5px; }

/* wide content never pushes the page sideways */
.scroll-x { overflow-x: auto; }

/* ==========================================================================
   Narrow screens: photo moves above the text
   ========================================================================== */
@media (max-width: 720px) {
  .intro { grid-template-columns: 1fr; gap: 16px; }
  .intro .portrait { width: 160px; margin: 0 auto; }
  .intro h1, .intro .contact { text-align: center; }
  .entry { grid-template-columns: 1fr; gap: 14px; }
  .entry .media { max-width: 420px; }
  .cvlist .item.has-logo { grid-template-columns: 48px 1fr; gap: 14px; }
  .cvlist .logo img { max-width: 48px; max-height: 30px; }
  .post h1, .intro h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .masthead nav { display: none; }
  body { font-size: 11pt; }
}
