/* ============================================================
   Rui Xiao — personal site
   Plain CSS, no build step. Colours live in the :root blocks
   below; change those and the whole page follows.
   ============================================================ */

/* ---------- Palette: light is the base ---------- */
:root {
  --bg:         #ffffff;
  --text:       #1b1b1d;
  --muted:      #6a6f76;
  --faint:      #8b9098;
  --accent:     #2f6fd0;
  --rule:       #e6e8eb;
  --card:       #f6f7f9;
  --badge-bg:   #fdf0d5;
  --badge-text: #8a5a00;
  --award-bg:   #fde7ec;
  --award-text: #a2123f;

  --maxw:       46rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
          Helvetica, Arial, "Noto Sans", sans-serif;
}

/* ---------- Dark: follow the OS unless the user picked light ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:         #121316;
    --text:       #e7e8ea;
    --muted:      #9ba1a9;
    --faint:      #7d838b;
    --accent:     #7fa9ea;
    --rule:       #26282d;
    --card:       #1a1c20;
    --badge-bg:   #3a2f14;
    --badge-text: #e9c46a;
    --award-bg:   #3d1f2a;
    --award-text: #f7a8c0;
  }
}

/* ---------- Dark: the explicit toggle wins in both directions ---------- */
:root[data-theme="dark"] {
  --bg:         #121316;
  --text:       #e7e8ea;
  --muted:      #9ba1a9;
  --faint:      #7d838b;
  --accent:     #7fa9ea;
  --rule:       #26282d;
  --card:       #1a1c20;
  --badge-bg:   #3a2f14;
  --badge-text: #e9c46a;
  --award-bg:   #3d1f2a;
  --award-text: #f7a8c0;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 4.5rem 1.5rem 3rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s ease;
}
a:hover { border-bottom-color: var(--accent); }

p { margin: 0 0 1rem; }

strong { font-weight: 600; }

section { margin-top: 3.25rem; }

h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 0 0 .4rem;
}

h2 {
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.35rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--rule);
}

h3.sub {
  font-size: .95rem;
  font-weight: 600;
  margin: 1.75rem 0 .6rem;
}
h3.sub:first-of-type { margin-top: 0; }

.muted { color: var(--faint); }

/* ---------- Header ---------- */
.profile {
  display: flex;
  gap: 1.9rem;
  align-items: flex-start;
}

.avatar {
  width: 148px;
  height: 148px;
  flex: 0 0 148px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--card);
}

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

.tagline {
  color: var(--muted);
  font-size: .95rem;
  margin: 0 0 .45rem;
  line-height: 1.55;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem .9rem;
  margin-top: .95rem;
  font-size: .92rem;
}

.links a {
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: .22rem .8rem;
  color: var(--text);
  transition: border-color .15s ease, color .15s ease;
}
.links a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- News ---------- */
.news-list, .plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: .95rem;
}

.news-list li, .plain-list li {
  display: flex;
  gap: 1rem;
  padding: .42rem 0;
}

.date {
  flex: 0 0 5.4rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  font-size: .88rem;
  padding-top: .06rem;
}

/* ---------- Publications ---------- */
.section-note {
  font-size: .9rem;
  color: var(--muted);
  margin-top: -.5rem;
  margin-bottom: 1.6rem;
}

.pub {
  display: flex;
  gap: 1.4rem;
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--rule);
}
.pub:last-child { border-bottom: 0; }

.pub > img {
  width: 190px;
  height: 108px;
  flex: 0 0 190px;
  /* Teaser figures range from 1.5:1 to 3.4:1. 'contain' shows each one
     whole; 'cover' silently cropped the wide ones down the middle. */
  object-fit: contain;
  border-radius: 5px;
  background: #fff;
  padding: 5px;
  border: 1px solid var(--rule);
}

.pub-body { min-width: 0; }

.pub h3 {
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 .3rem;
}

.authors {
  font-size: .9rem;
  color: var(--muted);
  margin: 0 0 .22rem;
}

.me { font-weight: 600; color: var(--text); }

.eqnote {
  font-size: .82rem;
  color: var(--faint);
  margin: -.08rem 0 .34rem;
}

.venue {
  font-size: .9rem;
  color: var(--faint);
  margin: 0 0 .5rem;
}

.badge {
  display: inline-block;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: .08rem .42rem;
  margin-left: .3rem;
  vertical-align: 1px;
}

.badge-award {
  background: var(--award-bg);
  color: var(--award-text);
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .85rem;
  font-size: .89rem;
  margin: 0;
}
.pub-links:empty { display: none; }

/* ---------- Footer ---------- */
footer {
  margin-top: 3.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: .85rem;
  color: var(--faint);
}
footer p { margin: 0; }

/* ---------- Theme toggle ---------- */
#theme-toggle {
  position: fixed;
  top: 1.1rem;
  right: 1.1rem;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  z-index: 10;
  transition: color .15s ease, border-color .15s ease;
}
#theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

#theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Show the icon for the theme you would switch TO. */
.icon-moon { display: block; }
.icon-sun  { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-moon { display: none; }
  :root:not([data-theme="light"]) .icon-sun  { display: block; }
}
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun  { display: block; }
:root[data-theme="light"] .icon-moon { display: block; }
:root[data-theme="light"] .icon-sun  { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 620px) {
  main { padding: 3.25rem 1.15rem 2.5rem; }

  .profile {
    flex-direction: column;
    gap: 1.15rem;
  }

  .avatar {
    width: 118px;
    height: 118px;
    flex-basis: 118px;
  }

  h1 { font-size: 1.72rem; }

  .pub {
    flex-direction: column;
    gap: .85rem;
  }
  .pub > img {
    width: 100%;
    height: 170px;
    flex-basis: auto;
  }

  .news-list li, .plain-list li {
    flex-direction: column;
    gap: .1rem;
  }
  .date { flex-basis: auto; }
}

/* ---------- Print (handy for a quick PDF of the page) ---------- */
@media print {
  #theme-toggle { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}
