/* ==========================================================================
   qingxiamath.github.io: one stylesheet, no build step.
   Colours are custom properties; dark mode redefines them.
   Fonts are the reader's own (no web-font downloads), so pages load fast
   everywhere, including networks where Google Fonts is blocked.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f5f4f1;
  --text: #1c1b19;
  --text-2: #46423c;
  --muted: #6e6960;
  --rule: #e6e3dd;
  --rule-strong: #d3cec5;
  --accent: #8b1e2f;
  --accent-hover: #6b1220;
  --accent-line: rgba(139, 30, 47, .32);
  --accent-soft: rgba(139, 30, 47, .07);
  --focus: #1f5fbf;
  --shadow: rgba(60, 30, 15, .35);

  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Iowan Old Style", Georgia, "Noto Serif", "Songti SC", "SimSun", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --fs: 1.0625rem;              /* body size, 17px */
  --lh: 1.65;
  --line: calc(var(--fs) * var(--lh));
  --measure: 40rem;             /* comfortable text column */
  --wide: 58rem;                /* header, footer, home page */
  --pad: 1rem;                  /* side gutter; wider on larger screens */
}

@media (min-width: 40em) {
  :root { --pad: 2rem; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --bg-soft: #201e1b;
    --text: #ece8e1;
    --text-2: #cdc7bd;
    --muted: #9d978c;
    --rule: #302d28;
    --rule-strong: #46423b;
    --accent: #eba3aa;
    --accent-hover: #f6c9cd;
    --accent-line: rgba(235, 163, 170, .38);
    --accent-soft: rgba(235, 163, 170, .09);
    --focus: #8ab4f8;
    --shadow: rgba(0, 0, 0, .6);
  }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: light dark;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: var(--fs);
  line-height: var(--lh);
  font-kerning: normal;
  overflow-wrap: break-word;    /* long URLs wrap instead of widening the page */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main { flex: 1 0 auto; }

img, svg { max-width: 100%; }
img { height: auto; }

h1, h2, h3 { text-wrap: balance; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
  text-decoration-color: var(--accent-line);
  transition: color .15s ease, text-decoration-color .15s ease, border-color .15s ease, background-color .15s ease;
}
a:hover { color: var(--accent-hover); text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: .5rem;
  z-index: 10;
  padding: .5rem .8rem;
  background: var(--text);
  color: var(--bg);
  font-family: var(--sans);
  font-size: .9rem;
}
.skip-link:focus { left: .5rem; }

.wrap {
  width: 100%;
  max-width: calc(var(--wide) + 2 * var(--pad));
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.icon {
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  fill: currentColor;
  vertical-align: -.125em;
}

/* ---------- header ---------- */

.site-header { border-bottom: 1px solid var(--rule); }

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .35rem 2rem;
  padding-top: 1.1rem;
  padding-bottom: .9rem;
}

.site-title {
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: .005em;
  color: var(--text);
  text-decoration: none;
}
.site-title:hover { color: var(--accent); }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .1rem 1.4rem;
  font-family: var(--sans);
  font-size: .92rem;
}

.site-nav a {
  padding: .35rem 0 .3rem;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  text-decoration: none;
}
.site-nav a:hover { color: var(--text); border-bottom-color: var(--rule-strong); }
.site-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

@media (max-width: 30em) {
  .site-nav { gap: .1rem 1.15rem; }
}

/* ---------- page shell ---------- */

main {
  padding-top: clamp(2rem, 1.2rem + 3vw, 3.5rem);
  padding-bottom: 4.5rem;
}

.page { max-width: var(--measure); }
.page--publications { max-width: 46rem; }
.page--cv { max-width: 50rem; }

.page-header { margin-bottom: 2.25rem; }

.page-back {
  display: inline-block;
  margin-bottom: .9rem;
  font-family: var(--sans);
  font-size: .85rem;
  text-decoration: none;
}
.page-back:hover { text-decoration: underline; }

.page-title {
  margin: 0;
  font-size: clamp(1.9rem, 1.5rem + 1.6vw, 2.5rem);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -.012em;
}

.page-lede {
  margin: .65rem 0 0;
  font-size: 1.08rem;
  color: var(--text-2);
}

/* ---------- running text ---------- */

.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1rem; }

.prose h2 {
  margin: 2.6rem 0 .9rem;
  font-size: 1.3rem;
  line-height: 1.3;
  font-weight: 700;
}

.prose h3 {
  margin: 1.9rem 0 .55rem;
  font-family: var(--sans);
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

.prose ul:not([class]),
.prose ol:not([class]) { margin: 0 0 1.1rem; padding-left: 1.3rem; }
.prose li { margin: .3rem 0; }
.prose li::marker { color: var(--muted); }
.prose strong { font-weight: 700; }

.prose code {
  padding: .1em .3em;
  border-radius: 3px;
  background: var(--bg-soft);
  font-family: var(--mono);
  font-size: .86em;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--rule-strong);
  color: var(--text-2);
}

.prose hr { margin: 2.5rem 0; border: 0; border-top: 1px solid var(--rule); }

.prose table { width: 100%; margin: 0 0 1.2rem; border-collapse: collapse; font-size: .95rem; }
.prose th, .prose td { padding: .45rem .6rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.prose th { font-family: var(--sans); font-size: .8rem; font-weight: 600; color: var(--muted); }

/* Section labels (home page, publication years) */
.section-label {
  margin: 0 0 1.1rem;
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- home ---------- */

.hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: clamp(1.25rem, 4vw, 2.5rem);
  align-items: center;
}

.hero__photo {
  grid-row: span 2;
  width: clamp(140px, 17vw, 180px);
  aspect-ratio: 1;
  height: auto;
  object-fit: cover;
  border-radius: 16px;
  background: var(--bg-soft);
  box-shadow: 0 0 0 1px var(--rule), 0 14px 32px -20px var(--shadow);
}

.hero__text { align-self: end; }

.hero__name {
  margin: 0 0 .55rem;
  font-size: clamp(2.2rem, 1.6rem + 2.6vw, 3.2rem);
  line-height: 1.02;
  font-weight: 700;
  letter-spacing: -.02em;
}

.hero__role {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.45;
  color: var(--text-2);
}
.hero__affil { color: var(--muted); }

.hero__links {
  align-self: start;
  display: flex;
  flex-wrap: wrap;
  gap: .45rem 1.15rem;
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--sans);
  font-size: .88rem;
}

.hero__links a {
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  padding: .15rem 0;
  color: var(--text-2);
  text-decoration: none;
}
.hero__links a:hover { color: var(--accent); }
.hero__links .icon { width: 1.05rem; height: 1.05rem; }

@media (max-width: 36em) {
  .hero { grid-template-columns: 92px minmax(0, 1fr); column-gap: 1.1rem; }
  .hero__photo { grid-row: auto; width: 92px; border-radius: 12px; }
  .hero__text { align-self: center; }
  .hero__name { margin-bottom: .3rem; }
  .hero__role { font-size: 1rem; }
  .hero__links { grid-column: 1 / -1; margin-top: 1.25rem; gap: .55rem 1.1rem; }
}

.home-section { margin-top: clamp(2.6rem, 6vw, 3.75rem); }

.bio { max-width: var(--measure); font-size: 1.1rem; }
.bio p { margin-bottom: 1rem; }
.bio p:last-child { margin-bottom: 0; }

.research {
  display: grid;
  gap: 1.75rem 3rem;
  align-items: start;
}

@media (min-width: 46em) {
  .research { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
}

.interests { margin: 0; padding: 0; list-style: none; }

.interests li {
  display: flex;
  align-items: baseline;
  gap: .85rem;
  padding: .62rem 0;
  border-top: 1px solid var(--rule);
}
.interests li:last-child { border-bottom: 1px solid var(--rule); }

.interests li::before {
  content: "";
  flex: none;
  width: .38rem;
  height: .38rem;
  border-radius: 1px;
  background: var(--accent);
  transform: translateY(-.18em);
}

.research__figure { margin: 0; max-width: 30rem; }
.research__figure img { display: block; width: 100%; height: auto; }

/* Home figure: still image, with the animation (canvas), lens outline and pause button on top */
.wavefig { position: relative; }
.wavefig canvas,
.wavefig__lens { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.wavefig canvas { display: block; opacity: 0; transition: opacity .5s ease; }
.wavefig.is-live canvas { opacity: 1; }
.wavefig__lens { pointer-events: none; }
.wavefig__lens path {
  fill: none;
  stroke: var(--text);
  stroke-opacity: .6;
  stroke-width: 1.1;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.wavefig__toggle {
  position: absolute;
  right: .35rem;
  bottom: .35rem;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  opacity: .75;
  transition: opacity .15s ease, color .15s ease;
}
.wavefig__toggle[hidden] { display: none; }
.wavefig__toggle:hover,
.wavefig__toggle:focus-visible { opacity: 1; color: var(--text); }
.wavefig__toggle svg { width: .75rem; height: .75rem; fill: currentColor; }
.wavefig__toggle .i-play,
.wavefig__toggle[data-state="paused"] .i-pause { display: none; }
.wavefig__toggle[data-state="paused"] .i-play { display: block; }

.research__figure figcaption {
  margin-top: .55rem;
  font-family: var(--sans);
  font-size: .8rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Schematic figures on the research page (inline SVGs in _includes/fig-*.svg) */
.lattice { display: block; width: 100%; height: auto; }
.lattice .lt-grid { fill: none; stroke: var(--rule-strong); stroke-width: .6; }
.lattice .lt-out { fill: var(--muted); opacity: .45; }
.lattice .lt-domain { fill: var(--accent-soft); }
.lattice .lt-in { fill: var(--accent); opacity: .42; }
.lattice .lt-curve { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; }
.lattice .lt-gout { fill: var(--bg); stroke: var(--accent); stroke-width: 1.4; }
.lattice .lt-gin { fill: var(--accent); }
.lattice .lt-ghost { fill: none; stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 3 3; opacity: .6; }
.lattice .lt-wave { fill: none; stroke: var(--accent); stroke-width: 1.2; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.section-head .section-label { margin: 0; }

.more {
  font-family: var(--sans);
  font-size: .86rem;
  white-space: nowrap;
  text-decoration: none;
}
.more:hover { text-decoration: underline; }

.contact address { font-style: normal; }

/* ---------- research page ----------
   The figure row is wider than the text column; text keeps a comfortable measure. */

.page--research { max-width: 54rem; }
.page--research .page-header,
.page--research .prose > :not(.research-figs) { max-width: var(--measure); }

.research-figs {
  display: grid;
  gap: 1.1rem;
  margin: 0 0 2.4rem;
}

.research-figs figure {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  margin: 0;
}

.research-figs figcaption {
  font-family: var(--sans);
  font-size: .82rem;
  line-height: 1.5;
  color: var(--muted);
}

.research-figs figcaption strong {
  display: block;
  margin-bottom: .1rem;
  font-weight: 600;
  color: var(--text);
}

@media (min-width: 44em) {
  .research-figs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.75rem; }
  .research-figs figure { display: block; }
  .research-figs figcaption { margin-top: .55rem; }
}

.page--research .prose > p:first-of-type { font-size: 1.1rem; }
.page--research .prose ul:not([class]) > li { margin-bottom: .55rem; }

/* ---------- publications ---------- */

.pubs { margin: 0; padding: 0; list-style: none; }

.pub {
  margin: 0;
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}
.pub:first-child { padding-top: .15rem; border-top: 0; }
.pub p { margin: 0; }

.pub__title {
  font-size: 1.1rem;
  line-height: 1.4;
  font-weight: 400;
  text-wrap: pretty;
}
.pub__title a { color: var(--text); text-decoration: none; }
.pub__title a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
}

.pub__authors { margin-top: .25rem !important; color: var(--text-2); }
.pub__authors strong { font-weight: 700; color: var(--text); }

.pub__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem 1rem;
  margin-top: .3rem !important;
  color: var(--muted);
}
.pub__venue em { color: var(--text-2); }

.chips { display: inline-flex; flex-wrap: wrap; gap: .4rem; }

.chip {
  padding: .32rem .58rem .3rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: .74rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  text-decoration: none;
}
.chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- ruled lists: CV, teaching, misc, seminar archive ----------
   In Markdown, a CV entry starts with its dates in bold and a course starts
   with its number in `backticks`; both are moved into the left margin. */

.page--cv .prose > ul,
.page--teaching .prose > ul,
.page--links .prose > ul {
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.page--cv .prose > ul > li,
.page--teaching .prose > ul > li,
.page--links .prose > ul > li {
  position: relative;
  margin: 0;
  padding: .62rem 0;
  border-top: 1px solid var(--rule);
}

.page--cv .prose > ul > li:last-child,
.page--teaching .prose > ul > li:last-child,
.page--links .prose > ul > li:last-child { border-bottom: 1px solid var(--rule); }

.page--cv .prose > ul > li { padding-left: 8.25rem; }
.page--teaching .prose > ul > li { padding-left: 6.5rem; }

.page--cv .prose > ul > li > strong:first-child,
.page--cv .prose > ul > li > p:first-child > strong:first-child,
.page--teaching .prose > ul > li > code:first-child {
  position: absolute;
  left: 0;
  top: .62rem;
  padding: 0;
  background: none;
  font-family: var(--sans);
  font-size: .8rem;
  font-weight: 600;
  line-height: var(--line);
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.page--cv .prose li ul,
.page--links .prose li ul {
  margin: .2rem 0 0;
  padding: 0;
  list-style: none;
  font-size: .97rem;
  color: var(--text-2);
}
.page--cv .prose li li { margin: .12rem 0; }

.page--teaching .prose li > em {
  display: block;
  font-family: var(--sans);
  font-size: .84rem;
  font-style: normal;
  color: var(--muted);
}

@media (max-width: 34em) {
  .page--cv .prose > ul > li { padding-left: 0; }
  .page--cv .prose > ul > li > strong:first-child,
  .page--cv .prose > ul > li > p:first-child > strong:first-child {
    position: static;
    display: block;
    line-height: 1.5;
  }
  .page--teaching .prose > ul > li { padding-left: 5.4rem; }
}

/* Seminar pages: week headings become small labels */
.page--seminar .prose h2 {
  margin: 2.2rem 0 .7rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--accent);
}
.page--seminar .prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: .82rem;
  color: var(--muted);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem 2rem;
  padding-top: 1.4rem;
  padding-bottom: 2rem;
}

.site-footer p { margin: 0; }

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- motion & print ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

@media print {
  :root {
    --bg: #fff; --text: #000; --text-2: #222; --muted: #555;
    --rule: #ccc; --rule-strong: #999; --accent: #000; --accent-line: #999;
  }
  body { font-size: 11pt; }
  .site-nav, .site-footer, .skip-link, .hero__links, .research__figure, .more { display: none; }
  main { padding: 0; }
  a { text-decoration: none; }
  .chip { padding: 0; border: 0; }
}
