/* =============================================================================
   susjunyou.github.io — academic serif, single column, no external requests.
   Colour tokens (--bg --fg --muted --rule --soft --accent --accent-line
   --accent-wash --measure) are injected per page by build.py from theme.accent.
   ========================================================================== */

:root {
  /* Latin faces first so a CJK font never takes over the Latin glyphs. */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
    "Source Serif 4", Georgia, "Source Han Serif SC", "Songti SC",
    "Noto Serif CJK SC", serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", sans-serif;
  --step: 2.6rem;      /* vertical rhythm between sections */
}

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

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

/* The wash fades to the page colour by the time the nav bar arrives: masthead
   depth with no image, and `background-color` still carries --bg on its own. */
body {
  margin: 0;
  background: linear-gradient(180deg, var(--accent-wash) 0, var(--bg) 360px) no-repeat;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: 1.0625rem;          /* 17px */
  line-height: 1.62;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Page-top accent line. Fixed, so it stays as a constant edge while the content
   scrolls under it; above the sticky nav, clear of the skip link at 0.75rem. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-line) 55%, transparent);
  z-index: 30;
}

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem;
}

p { margin: 0 0 0.7em; }
p:last-child { margin-bottom: 0; }
b, strong { font-weight: 650; }
sup { font-size: 0.7em; line-height: 0; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  text-decoration-color: var(--accent-line);
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}
a:hover { text-decoration-color: var(--accent); }

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--accent);
  z-index: 20;
}
.skip:focus { left: 0.75rem; top: 0.75rem; }

/* Middle dot between two facts. It must never start a wrapped line, so a word
   joiner glues it to the text before it — Chinese breaks between any two
   characters otherwise — and a zero-width space puts the one break opportunity
   on the far side. Doing it here fixes every separator on the page at once. */
.mid { padding: 0 0.5em; color: var(--muted); opacity: 0.6; }
.mid::before { content: "\2060"; }
.mid::after { content: "\200B"; }

/* ------------------------------------------------------------- masthead --- */
.masthead {
  position: relative;                /* anchors .controls to the top-right */
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.6rem;
  align-items: start;
  padding-top: 4.4rem;
}

.portrait {
  display: block;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--soft);
  box-shadow: 0 0 0 1px var(--rule), 0 6px 18px rgb(0 0 0 / 9%);
}

h1 {
  margin: 0.1rem 0 0;
  font-size: clamp(1.85rem, 1.5rem + 1.6vw, 2.35rem);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.012em;
}
h1 .alt {
  display: inline-block;
  margin-left: 0.55rem;
  font-size: 0.56em;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  vertical-align: 0.1em;
}

.role {
  margin: 0.55rem 0 0;
  font-size: 1rem;
  color: var(--fg);
}
.role .where { color: var(--muted); }
.role .seg { white-space: nowrap; }
.where {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.015em;
}
.tagline {
  margin: 0.28rem 0 0;
  font-style: italic;
  font-size: 0.98rem;
  color: var(--muted);
}

/* Quiet pills: the wash flattens plain underlined text, and a bordered target is
   easier to hit. Separated by gap alone — a drawn divider would dangle at the
   start of a wrapped line, and this list wraps on narrow screens. */
.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.45rem;
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.92rem;
}
.contact a {
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
  text-decoration-color: transparent;
}
.contact a:hover {
  border-color: var(--accent-line);
  background: var(--accent-wash);
  text-decoration-color: var(--accent);
}

/* ------------------------------------------------------------------ nav --- */
.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-top: 2.4rem;
  background: var(--bg);
  border-block: 1px solid var(--rule);
}
.tabs-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.1rem 0.95rem;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}
.tabs a {
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.04em;
}
.tabs a:hover { color: var(--accent); }
:lang(en) .tabs a { font-variant: small-caps; letter-spacing: 0.06em; }

/* Language + theme switches. In the masthead corner rather than the nav bar:
   the nav needs its whole line for section links on a 47rem measure. */
.controls {
  position: absolute;
  top: 1.15rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.controls .lang {
  font-size: 0.85rem;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.controls .lang:hover { border-color: var(--accent-line); background: var(--accent-wash); }
.theme {
  font: inherit;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.15rem 0.4rem 0.2rem;
  color: var(--muted);
  background: none;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
}
.theme:hover { color: var(--accent); border-color: var(--rule); }

/* -------------------------------------------------------------- sections --- */
.sec {
  padding-top: var(--step);
  scroll-margin-top: 3.4rem;
}

h2 {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 1.15rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.1em;
}
/* A mark to start the line; the rule fades out instead of stopping dead at the
   measure, where the hard stop read like a truncated table. */
h2::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: var(--accent);
}
h2::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, var(--rule), transparent);
}
:lang(en) h2 { font-variant: small-caps; letter-spacing: 0.09em; font-size: 1.05rem; }
:lang(zh-Hans) h2 { font-size: 0.95rem; letter-spacing: 0.16em; }

h3 {
  margin: 0;
  font-size: 1.045rem;
  font-weight: 600;
  line-height: 1.38;
}
h3 a { text-decoration-color: transparent; }
h3 a:hover { text-decoration-color: var(--accent-line); }

.entry-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 1.25rem;
  align-items: baseline;
}
.date, .venue {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* An accepted venue gets a plate — the box is what makes it read as a
   credential. The two exceptions below are the whole point of it. */
.venue {
  color: var(--accent);
  letter-spacing: 0.03em;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--accent-line);
  border-radius: 2px;
  background: var(--accent-wash);
}
:lang(en) .venue { font-variant: small-caps; font-size: 0.95rem; }
/* "arXiv:2408.01323" is an identifier, not an acronym: keep it as typed. */
:lang(en) .venue-preprint {
  font-variant: normal;
  font-size: 0.86rem;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
/* Work under review is not a venue. Grey and lower case, so it never reads as
   an acceptance at a glance the way an accent-coloured acronym does. */
.venue-review {
  color: var(--muted);
  font-style: italic;
  letter-spacing: 0;
}
:lang(en) .venue-review { font-variant: normal; font-size: 0.88rem; }
html[lang^="zh"] .venue-review { font-style: normal; }
/* Neither a preprint identifier nor "under review" may wear the plate — that is
   exactly the claim they must not make. Placed after both blocks above. */
.venue-review,
.venue-preprint {
  padding: 0;
  border-color: transparent;
  background: none;
}

.sub {
  margin: 0.2rem 0 0;
  font-size: 0.92rem;
  font-style: italic;
  color: var(--muted);
}
.authors {
  margin: 0.28rem 0 0;
  font-size: 0.94rem;
  color: var(--muted);
  line-height: 1.5;
}
.me {
  color: var(--fg);
  font-weight: 650;
  border-bottom: 1px solid var(--accent-line);
}

.bullets {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}
.bullets li {
  position: relative;
  margin: 0.3rem 0;
  padding-left: 1.05rem;
  font-size: 0.98rem;
}
.bullets li::before {
  content: "";
  position: absolute;
  left: 0.1rem;
  top: 0.72em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.75;
}

.record { padding-bottom: 1.35rem; }   /* .pub sets its own padding, below */
/* A publication row answers the pointer. The 2px border is always there in
   transparent and the left margin accounts for it, so hovering never nudges the
   text; the 0.9rem bleed stays inside the 1.5rem gutter down to 320px. */
.pub {
  margin: 0 -0.9rem 0 calc(-0.9rem - 2px);
  padding: 0.55rem 0.9rem 1.1rem;
  border-left: 2px solid transparent;
  border-radius: 0 4px 4px 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.pub:hover { background: var(--soft); border-left-color: var(--accent-line); }
.sec > :last-child { padding-bottom: 0; }

/* An entry with a `logo:` slug gets a gutter for the mark; entries without one
   keep the full measure, so a section with no logos is not indented for nothing. */
.record.has-logo {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 0 0.8rem;
  align-items: start;
}
/* The plate stays light in both themes on purpose. These marks are drawn for a
   white field: composited straight onto the dark background the seal reads at
   1.98:1 and the network mark at 2.62:1, so a constant tile is what keeps every
   brand colour as issued instead of filtering it. Costs one hairline. */
.logo {
  width: 30px;
  height: 30px;
  padding: 2px;
  object-fit: contain;
  background: #f4f1ea;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--rule);
  /* Sits on the title's cap height rather than the top of its line box. */
  margin-top: 0.1rem;
}

/* One hairline down the middle of the logo gutter (30px plate → 15px centre), so
   a run of posts reads as one timeline. Not after the last entry: a thread
   hanging off the bottom of a section implies an entry that is not there. */
:is(.sec-experience, .sec-education) .record.has-logo { position: relative; }
:is(.sec-experience, .sec-education) .record.has-logo:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 40px;
  bottom: 0.15rem;
  width: 1px;
  background: var(--rule);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0 0;
}
.chip {
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  padding: 0.1rem 0.5rem;
  color: var(--accent);
  background: var(--soft);
  border: 1px solid var(--rule);
  border-radius: 2px;
  text-decoration: none;
}
.chip:hover { border-color: var(--accent-line); background: var(--accent-wash); }

.note {
  margin: 0.9rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.year {
  margin: 1.1rem 0 0.6rem;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* about */
.interests {
  margin-top: 0.9rem;
  font-size: 0.94rem;
  color: var(--muted);
}
.interests .tag {
  margin-right: 0.7rem;
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}
:lang(en) .interests .tag { font-variant: small-caps; font-size: 0.95rem; }

/* date / text pairs: news, honours, skills */
.dated {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.45rem 1.25rem;
  margin: 0;
}
.dated dt {
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  padding-top: 0.08em;
}
.dated dd { margin: 0; }
.skills { grid-template-columns: 7.5rem 1fr; }
.skills dt { color: var(--fg); font-weight: 650; font-size: 0.94rem; }
.skills dd { font-size: 0.97rem; }

/* ---------------------------------------------------------------- footer --- */
/* `footer.wrap`, not `footer`: the element carries .wrap, whose margin/padding
   shorthands outrank a bare element selector no matter what order they sit in. */
footer.wrap {
  position: relative;
  margin-top: 3.4rem;
  padding-top: 1.15rem;
  padding-bottom: 3rem;
  font-size: 0.88rem;
  color: var(--muted);
}
/* Inset to the text column so this rule lines up with the ones after each h2,
   which a border on .wrap would overhang by the gutter. */
footer.wrap::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1.5rem;
  right: 1.5rem;
  height: 1px;
  background: var(--rule);
}
footer .fine { font-size: 0.84rem; }
footer a { color: inherit; text-decoration-color: var(--rule); }
footer a:hover { color: var(--accent); }

/* ----------------------------------------------- Chinese typography tweaks --- */
:lang(zh-Hans) body,
html[lang^="zh"] body { line-height: 1.85; letter-spacing: 0; }
html[lang^="zh"] { line-break: strict; word-break: normal; }
/* Songti/PingFang have no true bold or italic at small sizes; the browser fakes
   both. Lean on colour and weight instead of a mechanically slanted face. */
html[lang^="zh"] b,
html[lang^="zh"] strong { font-weight: 700; }
html[lang^="zh"] .tagline,
html[lang^="zh"] .sub { font-style: normal; }
html[lang^="zh"] .bullets li,
html[lang^="zh"] .dated dd,
html[lang^="zh"] .skills dd { line-height: 1.8; }

/* ------------------------------------------------------------- responsive --- */
/* Honours are one short line each; at 56rem two date/text pairs fit on a row,
   which halves a list that ran longer than the section it sits in. `dl` auto-flow
   does the pairing — no markup change. */
@media (min-width: 46rem) {
  .sec-honors .dated {
    grid-template-columns: 4.6rem 1fr 4.6rem 1fr;
    gap: 0.5rem 1.2rem;
  }
}

@media (max-width: 34rem) {
  .masthead {
    grid-template-columns: 1fr;
    gap: 1.1rem;
    padding-top: 3.1rem;
  }
  .controls { top: 0.8rem; }
  /* Narrow screens: prefer an awkward break over a horizontal scrollbar. */
  .role .seg { white-space: normal; }
  .portrait { width: 92px; height: 92px; }
  .entry-head { grid-template-columns: 1fr; gap: 0.1rem; }
  .date, .venue { text-align: left; white-space: normal; }
  /* The venue moves above the title here. `justify-self` is what keeps the plate
     hugging its text: as a full-width grid item it read as a section bar. */
  .venue { order: -1; justify-self: start; margin-bottom: 0.1rem; }
  .dated, .skills { grid-template-columns: 1fr; gap: 0.15rem; }
  .dated dt { padding-top: 0.35rem; }
  .tabs { position: static; }
  body { font-size: 1.02rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  a { transition: none; }
}

/* ------------------------------------------------------------------ print --- */
@media print {
  :root { --bg: #fff; --fg: #000; --muted: #333; --rule: #999; --soft: #fff;
          --accent: #1f3864; --accent-line: #999; --accent-wash: #fff; }
  .tabs, .skip, .controls { display: none !important; }
  body::before { display: none; }
  body { font-size: 10.5pt; background: #fff; }
  .masthead { padding-top: 0; }
  .sec { padding-top: 1.2rem; break-inside: avoid; }
  .pub, .record { break-inside: avoid; }
  /* Screen affordances, not paper: a border round every contact and venue is
     ink spent to say nothing. */
  .contact a, .venue { padding: 0; border-color: transparent; background: none; }
  .pub { margin-left: 0; border-left: 0; }
  a { text-decoration: none; }
}
