/* =============================================================
   Custom polish layer — loaded after style.css and publications.css.
   Keeps the upstream theme files untouched so it stays upgradable.
   ============================================================= */

:root {
  --accent: #330662;
  --accent-soft: rgba(51, 6, 98, 0.09);
  --accent-line: rgba(51, 6, 98, 0.18);
  --page-bg: #ffffff;
  --body-text: #1a1a1a;
  --muted: #6a6a72;
  --rule: rgba(0, 0, 0, 0.09);
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #ab82c5;
    --accent-soft: rgba(171, 130, 197, 0.16);
    --accent-line: rgba(171, 130, 197, 0.32);
    --page-bg: #404040;
    --body-text: #eee6f3;
    --muted: #c0b7c8;
    --rule: rgba(255, 255, 255, 0.14);
  }
}

/* ---------- Section rhythm ---------------------------------- */

section h2 {
  font-weight: 600;
  font-size: 1.42rem;
  letter-spacing: -0.01em;
  margin: 2.4rem 0 1.15rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}

section h2:first-child {
  margin-top: 0.6rem;
}

@media (prefers-color-scheme: dark) {
  section h2 {
    color: var(--body-text);
  }
}

/* Tighten the plain markdown lists (Education / Awards / Services) */
section > ul {
  margin-bottom: 1.2rem;
}

section > ul > li {
  margin-bottom: 0.45rem;
  line-height: 1.6;
}

/* ---------- Sidebar ----------------------------------------- */

header email {
  font-family: inherit;
  font-size: 0.9rem;
  word-break: break-word;
}

header .image.avatar img {
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

/* Calligraphic Chinese name — black ink on a transparent background,
   so it is inverted to white ink in dark mode. */
header .name-cn {
  display: block;
  height: 32px;          /* matches the 31px line box of the English <h1> */
  width: auto;
  max-width: 72%;
  margin: 0.2rem auto 0.5rem;
}

@media (prefers-color-scheme: dark) {
  header .name-cn {
    filter: invert(1);
  }
}

/* ---------- "On the job market" callout ---------------------- */

section blockquote {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  margin: 1.1rem 0 1.4rem;
  padding: 0.8rem 1rem;
  font-style: normal;
  font-size: 1rem;
  line-height: 1.6;
}

/* ---------- Publications ------------------------------------ */

.publications {
  margin-top: 0;
}

/* The markup separates entries with <br>; drop them and let margins do the work */
.publications ol.bibliography > br {
  display: none;
}

.publications ol.bibliography li {
  min-height: 0;
  margin-bottom: 0.15rem;
  padding: 0.3rem 0.4rem;
  border-radius: 10px;
  transition: background-color 0.16s ease;
}

.publications ol.bibliography li:hover {
  background-color: var(--accent-soft);
}

.publications ol.bibliography li .abbr {
  height: auto;
  margin-bottom: 0;
}

.publications ol.bibliography li .teaser {
  height: 118px;
  width: 258px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.13);
  margin: 0;
}

.publications ol.bibliography li .abbr abbr {
  top: 6px;
  left: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
}

.publications ol.bibliography li .title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.22rem;
}

.publications ol.bibliography li .author {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.publications ol.bibliography li .author strong {
  color: var(--body-text);
  font-weight: 700;
}

.publications ol.bibliography li .periodical {
  font-size: 0.87rem;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 0.1rem;
}

/* Equal-contribution / corresponding-author legend */
.pub-legend {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -0.7rem 0 0.9rem;
}

/* Collapse to the first 5 entries; the toggle is injected by JS */
.publications ol.bibliography.collapsed > li:nth-of-type(n + 6),
.publications ol.bibliography.collapsed > br:nth-of-type(n + 6) {
  display: none;
}

.pub-toggle {
  display: block;
  margin: 0.5rem auto 0;
  padding: 0.42rem 1.15rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.pub-toggle:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.pub-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Research experience timeline --------------------- */

.timeline-line {
  display: none;
}

.timeline-entry {
  position: relative;
  padding: 0 0 1.5rem 1.75rem;
  border-left: 2px solid var(--accent-line);
}

.timeline-entry:last-child {
  border-left-color: transparent;
  padding-bottom: 0.2rem;
}

.timeline-entry::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 0.3rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--page-bg);
}

.timeline-entry .year-circle {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.16rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}

.timeline-entry .entry-content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 0.4rem;
}

@media (prefers-color-scheme: dark) {
  .timeline-entry .entry-content h3 {
    color: var(--body-text);
  }
}

.timeline-entry .entry-content h3 i {
  color: var(--accent);
  font-size: 0.86em;
  margin-right: 0.45rem;
}

/* Company name leads; the role reads as a lighter suffix */
.timeline-entry .entry-content h3 .role {
  font-weight: 400;
  color: var(--muted);
}

/* Secondary line: advisors, GPA, and similar detail */
.timeline-entry .entry-content .entry-meta {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
}

.timeline-entry .entry-content ul {
  margin: 0;
  padding-left: 1.15rem;
}

.timeline-entry .entry-content li {
  margin-bottom: 0.3rem;
  line-height: 1.58;
}

/* ---------- Small screens ------------------------------------ */

@media screen and (max-width: 720px) {
  .pub-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .publications ol.bibliography li .abbr {
    padding-left: 0 !important;
    margin-bottom: 0.5rem;
  }

  .publications ol.bibliography li .teaser {
    width: 100%;
    max-width: 320px;
    height: auto;
    aspect-ratio: 258 / 118;
  }

  .publications ol.bibliography li .col-sm-9 {
    padding-left: 0 !important;
  }

  .publications ol.bibliography li .abbr abbr {
    position: static;
    display: inline-block;
    margin-bottom: 0.35rem;
  }
}
