/* Academic typography adapted from https://luchengthu.github.io/files/jemdoc.css:
   serif text, blue headings over hairline rules, and compact spacing.
   The link accent, line colors, and content width come from site-theme.css. */
:root {
  --home-text: #1a1a1a;
  --home-heading: #4a72b5;
  --home-rule: #c5cad3;
  --section-gap: 40px;
  --entry-gap: 24px;
  --portrait-width: 220px;
  --profile-gap: 56px;
}

html {
  background-color: #ffffff;
}

body {
  box-sizing: border-box;
  font-family: var(--site-font-serif);
  font-size: 16px;
  color: var(--home-text);
  background-color: #ffffff;
  text-align: left;
  margin: 0;
  padding: 0;
}

.home-shell {
  box-sizing: border-box;
  width: min(var(--site-width), calc(100% - 80px));
  margin: 0 auto;
  padding: 48px 0 32px;
}

#layout-content {
  margin: 0;
  padding: 0;
  border: none;
  text-align: left;
  vertical-align: top;
}

/* Hero: name and bio on the left; photo, motto, and contacts in a narrow right column. */
.profile-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--portrait-width);
  gap: 24px var(--profile-gap);
  align-items: start;
}

.profile-main {
  min-width: 0;
}

.profile-intro {
  margin-bottom: 22px;
}

#toptitle {
  margin-bottom: 0;
}

.profile-affiliation {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin: 10px 0 0;
  font-size: 17px;
  line-height: 1.5;
}

.profile-role {
  color: var(--home-heading);
  font-weight: bold;
}

.profile-university {
  color: #000000;
  font-weight: bold;
}

.profile-university::before {
  content: "·";
  margin-right: 10px;
  color: var(--site-muted);
}

.profile-bio p:last-child {
  margin-bottom: 0;
}

.profile-aside {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.portrait-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(37, 38, 43, 0.1);
}

.portrait {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 57% 50%;
  transform: scale(1.5);
  transform-origin: 50% 66%;
  border: none;
}

.portrait-illustration {
  object-fit: contain;
  object-position: center;
  transform: none;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) and (pointer: fine) {
  .portrait-frame.is-illustration-ready:hover .portrait-illustration {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portrait-illustration { transition: none; }
}

.portrait-caption {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: #666666;
}

.portrait-caption strong {
  display: block;
  margin-bottom: 2px;
  color: var(--home-heading);
  font-size: 15px;
  font-weight: normal;
}

.profile-contact {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
}

.profile-email {
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 8px;
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.profile-links a,
.profile-links button {
  white-space: nowrap;
}

h1, h2, h3 {
  color: var(--home-heading);
  margin-top: 0.7em;
  margin-bottom: 0.5em;
  padding-top: 0.5em;
  padding-bottom: 0.2em;
  line-height: 1;
}

h1 {
  font-size: 34px;
  font-weight: bold;
}

#toptitle h1 {
  margin: 0;
  padding: 0;
  line-height: 1.25;
}

#toptitle h1 span {
  white-space: nowrap;
}

h2 {
  padding-top: 0.8em;
  font-size: 22px;
  font-weight: bold;
}

/* Section headings sit on a hairline rule, as in the original academic layout. */
#layout-content > h2 {
  margin: var(--section-gap) 0 16px;
  padding: 0 0 6px;
  line-height: 1.3;
  border-bottom: 1px solid var(--home-rule);
}

h3 {
  font-size: 17px;
  font-weight: bold;
}

h2 + h3 {
  padding-top: 0.2em;
}

p {
  margin-top: 0;
  margin-bottom: 0.8em;
  padding: 0;
  line-height: 1.6;
}

strong {
  color: #000000;
  font-weight: bold;
}

a, .contact-button {
  color: var(--site-accent);
  text-decoration: none;
}

a:hover, .contact-button:hover {
  text-decoration: underline dotted gray;
  text-underline-offset: 3px;
}

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--site-accent);
  outline-offset: 3px;
}

.contact-button {
  border: none;
  padding: 0;
  background: none;
  font: inherit;
  cursor: pointer;
}

.wechat-contact {
  width: 340px;
  max-width: calc(100vw - 64px);
  padding: 20px;
  border: 1px solid var(--site-line);
  border-radius: 10px;
  background: var(--site-surface);
  color: var(--home-text);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.wechat-contact::backdrop {
  background: rgba(0, 0, 0, 0.18);
}

.wechat-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wechat-heading h3 {
  margin: 0;
  padding: 0;
  line-height: 1.3;
}

.wechat-qr {
  display: block;
  width: 100%;
  height: auto;
  max-height: 65vh;
  object-fit: contain;
}

.wechat-contact p {
  margin-bottom: 0;
  font-size: 0.9em;
  color: var(--site-muted);
}

ul {
  margin-top: 0.2em;
  margin-bottom: 0.8em;
  padding-top: 0;
  list-style-position: outside;
  list-style-type: square;
}

p + ul {
  margin-top: -0.5em;
}

li {
  margin-top: 0.9em;
}

li p {
  margin-bottom: 0.3em;
}

/* News timeline structure adapted from Ziyang Gong's homepage.
   See THIRD_PARTY_NOTICES.txt; node and line colors use the site palette. */
.news-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.news-list > li {
  position: relative;
  margin: 0;
  padding: 0 0 1.25em 24px;
  line-height: 1.5;
}

.news-list > li::before {
  content: "";
  position: absolute;
  top: 0.65em;
  bottom: -0.65em;
  left: 5px;
  width: 2px;
  border-radius: 1px;
  background: var(--site-line);
}

.news-list > li::after {
  content: "";
  position: absolute;
  top: calc(0.65em - 6px);
  left: 0;
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  border: 2px solid var(--site-accent);
  border-radius: 50%;
  background: var(--site-bg);
}

.news-list > li:last-child {
  padding-bottom: 0;
}

.news-list > li:last-child::before {
  display: none;
}

.news-list time {
  display: block;
  margin-bottom: 0.25em;
  color: var(--site-muted);
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.news-list .news-description {
  margin: 0;
  line-height: inherit;
  overflow-wrap: anywhere;
}

.news-emoji {
  display: inline-block;
  margin-right: 0.4em;
}

.honors-list {
  display: grid;
  row-gap: 12px;
  margin: 0;
  padding-left: 24px;
  list-style: none;
}

.honors-list > li {
  position: relative;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: baseline;
  column-gap: 16px;
  margin: 0;
  line-height: 1.5;
}

.honors-list > li::before {
  content: "";
  position: absolute;
  top: calc(0.75em - 2px);
  left: -20px;
  width: 4px;
  height: 4px;
  background: currentColor;
}

.honors-list time {
  color: var(--site-muted);
  font-size: 0.85em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.publication-list,
.experience-list,
.education-list {
  display: grid;
  gap: var(--entry-gap);
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.publication-entry {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: start;
  column-gap: var(--entry-gap);
  margin: 0;
}

.publication-figure {
  position: relative;
  display: block;
  box-sizing: border-box;
  padding: 7px;
  border: 1px solid var(--site-line);
  border-radius: 10px;
  background: var(--site-surface);
  box-shadow: 0 1px 3px rgba(37, 38, 43, 0.05);
  cursor: zoom-in;
}

.publication-figure:hover,
.publication-figure:focus-visible {
  border: 1px solid var(--site-line-strong);
  box-shadow: 0 4px 14px rgba(37, 38, 43, 0.09);
  text-decoration: none;
}

.publication-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
}

.figure-zoom-hint {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--site-line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: var(--site-ink);
  font: 20px/1 var(--site-font);
  opacity: 0;
}

.publication-figure:hover .figure-zoom-hint,
.publication-figure:focus-visible .figure-zoom-hint {
  opacity: 1;
}

.figure-viewer-open {
  overflow: hidden;
}

.figure-viewer {
  box-sizing: border-box;
  width: min(1100px, calc(100vw - 48px));
  max-width: none;
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--site-line);
  border-radius: 12px;
  background: var(--site-surface);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.25);
  color: var(--home-text);
}

.figure-viewer[open] {
  display: flex;
  flex-direction: column;
}

.figure-viewer::backdrop {
  background: rgba(20, 29, 43, 0.65);
}

.figure-viewer-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--site-line);
}

.figure-viewer-header h2 {
  margin: 0;
  padding: 0;
  border: none;
  font-size: 20px;
  line-height: 1.3;
  color: var(--site-accent);
}

.figure-viewer-header p {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--site-muted);
}

.figure-viewer-controls {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.figure-viewer-controls button,
.figure-viewer-controls a {
  box-sizing: border-box;
  border: 1px solid var(--site-line);
  border-radius: 6px;
  padding: 7px 10px;
  background: var(--site-surface);
  color: var(--site-accent);
  font: inherit;
  font-size: 14px;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
}

.figure-viewer-controls button:hover,
.figure-viewer-controls a:hover {
  border-color: var(--site-line-strong);
  background: var(--site-accent-soft);
  text-decoration: none;
}

.figure-viewer-stage {
  min-height: 0;
  padding: 20px;
  overflow: auto;
  background: var(--site-bg);
}

#figure-viewer-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(88dvh - 140px);
  margin: 0 auto;
  object-fit: contain;
  background: #ffffff;
}

.figure-viewer.is-zoomed #figure-viewer-image {
  max-width: none;
  max-height: none;
}

@media (max-width: 620px) {
  .figure-viewer-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px;
  }

  .figure-viewer-stage {
    padding: 12px;
  }

  #figure-viewer-image {
    max-height: calc(88dvh - 180px);
  }
}

.publication-details {
  min-width: 0;
  line-height: 1.5;
}

.publication-title {
  display: block;
  font-size: 1.05em;
  font-weight: bold;
  line-height: 1.4;
  margin-bottom: 0.55em;
}

.publication-details .publication-authors {
  font-size: 0.95em;
  line-height: 1.55;
  margin-bottom: 0.6em;
}

.publication-venue {
  white-space: nowrap;
}

.publication-links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

.publication-details .publication-summary {
  padding-left: 20px;
  margin-top: 0.75em;
  margin-bottom: 0;
}

.publication-summary > li {
  margin-top: 0;
}

/* Writing: posts listed like publications, with a small cover beside each title. */
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: var(--section-gap) 0 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--home-rule);
}

.section-heading h2 {
  margin: 0;
  padding: 0;
  line-height: 1.3;
}

.section-heading a {
  font-size: 15px;
  white-space: nowrap;
}

.writing-list {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.writing-list > li {
  margin: 0;
}

.writing-card {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: center;
  gap: var(--entry-gap);
  color: var(--home-text);
}

.writing-card:hover {
  text-decoration: none;
}

.writing-cover {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--site-line);
  border-radius: 6px;
}

.writing-text {
  display: grid;
  gap: 3px;
  min-width: 0;
  line-height: 1.5;
}

.writing-title {
  color: var(--site-accent);
  font-size: 1.05em;
  font-weight: bold;
  line-height: 1.4;
}

.writing-card:hover .writing-title {
  text-decoration: underline dotted gray;
  text-underline-offset: 3px;
}

.writing-meta {
  color: #666666;
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}

.institution-entry {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  align-items: start;
  column-gap: var(--entry-gap);
  margin: 0;
}

.institution-logo {
  display: block;
}

.institution-logo img {
  display: block;
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.institution-details {
  min-width: 0;
}

.institution-details h3 {
  margin: 0 0 0.4em;
  padding: 0;
  line-height: 1.4;
}

.institution-details h3 a {
  color: inherit;
}

.institution-details p {
  margin-bottom: 0.3em;
  line-height: 1.6;
}

.institution-details p:last-child {
  margin-bottom: 0;
}

.wechat-contact a:hover,
.institution-logo:hover {
  border-bottom: none;
  text-decoration: none;
}

#footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 20px 32px;
  border-top: 1px solid #c0c0c0;
  padding-top: 16px;
  margin-top: 48px;
}

.footer-info {
  display: grid;
  align-content: center;
  min-height: 85px;
  gap: 6px;
}
.footer-copyright { margin: 0; font-size: 14px; color: var(--site-muted); }
.footer-credit { margin: 0; color: #666666; font-size: small; }

.visitor-map {
  box-sizing: border-box;
  width: 170px;
  max-width: 100%;
  justify-self: end;
  font-family: var(--site-font);
  color: var(--site-muted);
  font-size: 14px;
  line-height: 1.6;
}

.visitor-map-accessible {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.visitor-map p { margin: 0; }
.visitor-map [hidden] { display: none; }
.visitor-map-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: stretch;
  box-sizing: border-box;
  height: 85px;
  padding: 3px;
  list-style: none;
  background: #eaf1fc;
  border: 1px solid #dce6f5;
  border-radius: 9px;
  box-shadow: inset 0 1px 0 #ffffffb3;
  cursor: pointer;
  transition: transform 160ms ease;
}

.visitor-map-card::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  box-shadow: 0 4px 12px rgb(44 81 145 / 10%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.visitor-map-card::-webkit-details-marker { display: none; }
.visitor-map-card::marker { content: ''; }
.visitor-map-card:focus-visible,
.visitor-map-retry:focus-visible {
  outline: 2px solid var(--site-accent);
  outline-offset: 4px;
}

.visitor-map-card:active { background: #dee9fa; }
.visitor-map-details[open] .visitor-map-card { border-color: #a8bfdf; }
@media (hover: hover) and (pointer: fine) {
  .visitor-map-card:hover {
    border-color: #a8bfdf;
    transform: translateY(-1px);
  }
  .visitor-map-card:hover::after { opacity: 1; }
  .visitor-map-card:active { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .visitor-map-card,
  .visitor-map-card::after { transition: none; }
  .visitor-map-card:hover { transform: none; }
}

.visitor-map-world { display: block; width: 100%; height: 100%; }
.visitor-map-halo { fill: var(--site-accent); opacity: .12; }
.visitor-map-ring { fill: none; stroke: var(--site-accent); stroke-width: 1.5; opacity: .65; }
.visitor-map-dot { fill: var(--site-accent); stroke: #fff; stroke-width: 1.5; }

.visitor-map-counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 5px 2px;
  border: 1px solid #fff;
  border-radius: 7px;
  background: #f8fbff;
  color: var(--site-accent);
  box-shadow: 0 1px 3px #2c51911a, 0 3px 8px #2c519108;
  line-height: 1.2;
}

.visitor-map-beacon {
  box-sizing: border-box;
  width: 8px;
  height: 8px;
  margin-bottom: 5px;
  border: 1.5px solid #c6d7ef;
  border-radius: 50%;
  background: var(--site-accent);
  box-shadow: 0 0 0 2px #e7effb;
}

.visitor-map-beacon:not([data-state="ready"]) { background: #9baac0; }
.visitor-map-counter strong { color: var(--site-accent); font-size: 14px; font-weight: 600; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.visitor-map-unit { margin-top: 2px; font-size: 6px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.visitor-map-period { width: 100%; margin-top: 5px; padding-top: 4px; border-top: 1px solid #dce6f5; font-size: 6px; font-weight: 500; letter-spacing: .03em; white-space: nowrap; text-align: center; text-transform: uppercase; }

.visitor-map-panel { padding: 14px 2px 0; }
.visitor-map-totals { color: var(--site-accent); font-weight: 500; font-variant-numeric: tabular-nums; }
.visitor-map-since { font-size: 12px; }
.visitor-map-status:empty { display: none; }
.visitor-map-retry {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--site-accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.visitor-map-countries { margin: 8px 0 12px; padding: 0; list-style: none; }
.visitor-map-countries:empty { display: none; }
.visitor-map-countries li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--site-line); }
.visitor-map-countries span { overflow-wrap: anywhere; }
.visitor-map-countries strong { font-weight: 500; font-variant-numeric: tabular-nums; }
.visitor-map-note { font-size: 12px; }

@media (max-width: 600px) {
  #footer { grid-template-columns: minmax(0, 1fr); }
  .footer-info { min-height: 0; text-align: center; }
  .visitor-map { justify-self: center; }
}

.skip-link {
  position: absolute;
  top: -100px;
}

.skip-link:focus {
  top: 0;
  background: white;
}

@media (max-width: 840px) {
  :root {
    --portrait-width: 200px;
    --profile-gap: 40px;
  }

  .profile-email {
    font-size: 12px;
  }

  .publication-entry {
    grid-template-columns: 220px minmax(0, 1fr);
    column-gap: 24px;
  }

  .home-shell {
    width: min(720px, calc(100% - 48px));
  }
}

@media (max-width: 760px) {
  :root {
    --section-gap: 36px;
    --portrait-width: 180px;
    --profile-gap: 32px;
  }

  h1 {
    font-size: 30px;
  }

  .home-shell {
    padding-top: 32px;
  }
}

@media (max-width: 620px) {
  :root {
    --portrait-width: 120px;
  }

  /* Phones: name beside a small photo, then contacts, then the bio. */
  .profile-header {
    grid-template-areas:
      "intro photo"
      "contact contact"
      "bio bio";
    gap: 22px 20px;
  }

  .profile-main,
  .profile-aside {
    display: contents;
  }

  .profile-intro {
    grid-area: intro;
    align-self: center;
    margin: 0;
  }

  .profile-photo {
    grid-area: photo;
  }

  .profile-contact {
    grid-area: contact;
    justify-items: start;
    text-align: left;
  }

  .profile-email {
    font-size: 14px;
  }

  .profile-links {
    justify-content: flex-start;
  }

  .profile-bio {
    grid-area: bio;
  }

  .profile-affiliation {
    flex-direction: column;
    gap: 2px;
    font-size: 16px;
  }

  .profile-university::before {
    content: none;
  }

  #toptitle h1 {
    font-size: 26px;
  }

  #layout-content > h2,
  .section-heading h2 {
    font-size: 20px;
  }

  .writing-card {
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: start;
    gap: 14px;
  }

  .portrait-caption {
    font-size: 11px;
  }

  .portrait-caption strong {
    font-size: 12px;
  }

  .publication-entry {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 16px;
  }

  .publication-figure {
    width: min(100%, 320px);
  }

  .institution-entry {
    grid-template-columns: 64px minmax(0, 1fr);
    column-gap: 16px;
  }

  .institution-logo img {
    width: 64px;
    height: 64px;
  }

}

@media (max-width: 480px) {
  .home-shell {
    width: calc(100% - 40px);
  }
}
