/* ------------------------------------------------------------------
   Xi Xia — personal page
   One column of text, one accent colour, no frameworks.
------------------------------------------------------------------- */

:root {
  --bg: #fafaf8;
  --fg: #15171b;
  --fg-2: #3b3f47;
  --muted: #6d727b;
  --faint: #a2a6ad;
  --rule: #e4e4df;
  --rule-2: #cdcec8;
  --accent: #23477b;
  --accent-soft: rgba(35, 71, 123, 0.12);

  --serif: "Newsreader", "Noto Serif SC", "Iowan Old Style", "Palatino Linotype", Georgia, "Songti SC", serif;
  --sans: "IBM Plex Sans", "Noto Sans SC", -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, "Noto Sans SC", monospace;

  --wrap: 1080px;
  --gutter: 40px;
  --label: 184px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --fg: #e8e6e1;
    --fg-2: #c2c1bc;
    --muted: #8b9099;
    --faint: #5c6169;
    --rule: #212429;
    --rule-2: #33373e;
    --accent: #94b5e4;
    --accent-soft: rgba(148, 181, 228, 0.16);
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16.5px/1.65 var(--sans);
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

html[data-lang="zh"] body {
  font-size: 15.5px;
  line-height: 1.85;
  letter-spacing: 0.01em;
}

::selection { background: var(--accent-soft); }

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul { list-style: none; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule-2);
  text-underline-offset: 0.22em;
  transition: color 0.18s ease, text-decoration-color 0.18s ease;
}
a:hover { color: var(--accent); text-decoration-color: currentColor; }
a:focus-visible,
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* language visibility ------------------------------------------------ */
html[data-lang="en"] body [lang="zh-CN"]:not(.keep) { display: none !important; }
html[data-lang="zh"] body [lang="en"]:not(.keep) { display: none !important; }

main, .hero { transition: opacity 0.14s ease; }
html.switching main,
html.switching .hero { opacity: 0; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* top bar ------------------------------------------------------------ */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
}

.wordmark {
  font: 500 15px/1 var(--serif);
  letter-spacing: 0.01em;
  text-decoration: none;
}
.wordmark:hover { color: var(--fg); }

.lang {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 400 12.5px/1 var(--mono);
  letter-spacing: 0.04em;
  color: var(--faint);
}
.lang button {
  font: inherit;
  letter-spacing: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 6px 2px;
  cursor: pointer;
  transition: color 0.18s ease;
}
.lang button:hover { color: var(--fg); }
.lang button[aria-pressed="true"] {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

/* hero --------------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 72px;
  align-items: end;
  padding-top: clamp(48px, 11vh, 128px);
  padding-bottom: 72px;
  border-bottom: 1px solid var(--rule);
}

.name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(52px, 8.4vw, 96px);
  line-height: 0.92;
  letter-spacing: -0.025em;
  font-optical-sizing: auto;
}
.name .alt {
  display: inline-block;
  margin-left: 0.32em;
  font-size: 0.34em;
  letter-spacing: 0.08em;
  color: var(--muted);
  vertical-align: 0.12em;
}
html[data-lang="zh"] .name { letter-spacing: 0.04em; font-weight: 500; }
html[data-lang="zh"] .name .alt { letter-spacing: 0; font-weight: 400; }

.lede {
  max-width: 31em;
  margin-top: 32px;
  font: 400 clamp(19px, 2vw, 22px)/1.48 var(--serif);
  color: var(--fg);
}
html[data-lang="zh"] .lede {
  font-size: clamp(17px, 1.7vw, 19px);
  line-height: 1.8;
  letter-spacing: 0.02em;
}

.facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px 24px;
  margin-top: 40px;
  max-width: 31em;
}
.facts > div { display: contents; }
.facts dt {
  padding-top: 3px;
  font: 500 11px/1.4 var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}
html[data-lang="zh"] .facts dt { letter-spacing: 0.2em; padding-top: 2px; }
.facts dd {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--fg-2);
}
.facts .coord {
  margin-left: 10px;
  font: 400 12px/1.6 var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* hero portrait */
.portrait { margin: 0; }
.portrait img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 2px;
  background: var(--rule);
}

/* animated figures (sea chart, campus, arm) ------------------------- */
.chart { width: 100%; }
.chart canvas {
  display: block;
  width: 100%;
  aspect-ratio: var(--chart-aspect, 1.8);
}
.readout {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  font: 400 11.5px/1.4 var(--mono);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.readout b { font-weight: 500; color: var(--fg-2); }
.chart figcaption {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}
.chart figcaption a { white-space: nowrap; margin-left: 4px; }

/* campus flow: canvas over the base map */
.flow .stage { position: relative; background: #0f1216; border-radius: 2px; overflow: hidden; }
.flow .stage img { display: block; width: 100%; height: auto; }
.flow .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
@media (prefers-color-scheme: dark) {
  .flow .stage { box-shadow: 0 0 0 1px var(--rule); }
}

/* arm: photo and kinematic sketch side by side, equal heights
   (column ratio = photo 700x875 : sketch 216x172 mm window) */
.arm .pair {
  display: grid;
  grid-template-columns: minmax(0, 800fr) minmax(0, 1256fr);
  gap: 12px;
}
.arm .pair img { display: block; width: 100%; height: auto; border-radius: 2px; }
.arm .pair canvas { border: 1px solid var(--rule); border-radius: 2px; }

/* figures inside entries */
.media { margin-top: 20px; }
.media img,
.media video { display: block; width: 100%; height: auto; }
.media video { aspect-ratio: 16 / 9; background: #0d1520; border-radius: 2px; }
.media.framed img { border: 1px solid var(--rule); }
.media.narrow { max-width: 320px; }
.media.narrow img { border-radius: 2px; }
.media figcaption {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}
html[data-lang="zh"] .media figcaption,
html[data-lang="zh"] .chart figcaption { font-size: 12.5px; letter-spacing: 0.02em; }

/* sections ----------------------------------------------------------- */
.block {
  display: grid;
  grid-template-columns: var(--label) minmax(0, 1fr);
  gap: 48px;
  padding: 64px 0;
  border-bottom: 1px solid var(--rule);
}
.block > header {
  position: sticky;
  top: 28px;
  align-self: start;
}
.block h2 {
  font: 500 11.5px/1.5 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
html[data-lang="zh"] .block h2 { letter-spacing: 0.2em; font-size: 12.5px; }
.block .sub {
  margin-top: 4px;
  font: 400 11.5px/1.5 var(--mono);
  color: var(--faint);
}
.body { max-width: 680px; }

.prose p + p { margin-top: 1.05em; }
.prose p { color: var(--fg-2); }
.prose strong { font-weight: 500; color: var(--fg); }

/* "now" list */
.now li {
  position: relative;
  padding-left: 22px;
  color: var(--fg-2);
}
.now li + li { margin-top: 10px; }
.now li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.82em;
  width: 10px;
  height: 1px;
  background: var(--accent);
}

/* entries (research, work) */
.entry {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 28px;
  padding: 26px 0;
  border-top: 1px solid var(--rule);
}
.entry:first-child { border-top: 0; padding-top: 0; }
.entry:last-child { padding-bottom: 0; }

.when {
  padding-top: 3px;
  font: 400 12px/1.5 var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entry h3 {
  font: 500 17px/1.4 var(--sans);
  letter-spacing: -0.005em;
  color: var(--fg);
}
html[data-lang="zh"] .entry h3 { font-size: 16.5px; letter-spacing: 0.02em; }
.entry h3 a { text-decoration: none; }
.entry h3 a .arrow {
  display: inline-block;
  margin-left: 4px;
  font-weight: 400;
  color: var(--faint);
  transition: transform 0.2s ease, color 0.2s ease;
}
.entry h3 a:hover .arrow { transform: translate(2px, -2px); color: var(--accent); }

.role {
  margin-top: 3px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}
.entry .desc {
  margin-top: 10px;
  color: var(--fg-2);
}
.math { font-family: var(--serif); font-size: 1.08em; white-space: nowrap; color: var(--fg); }
.math i { font-style: italic; }

/* honors table */
.honors li {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 28px;
  padding: 13px 0;
  border-top: 1px solid var(--rule);
}
.honors li:first-child { border-top: 0; padding-top: 0; }
.honors .what { color: var(--fg); }
.honors .what small {
  display: block;
  font-size: 13.5px;
  color: var(--muted);
}

/* elsewhere */
.plain li {
  color: var(--fg-2);
  padding: 9px 0;
  border-top: 1px solid var(--rule);
}
.plain li:first-child { border-top: 0; padding-top: 0; }
.plain .logo {
  display: block;
  width: 240px;
  max-width: 70%;
  height: auto;
  margin: 14px 0 6px;
}
@media (prefers-color-scheme: dark) {
  .plain .logo { filter: brightness(0) invert(0.86); }
}

/* contact */
.email {
  display: inline-block;
  font: 400 clamp(26px, 3.4vw, 36px)/1.2 var(--serif);
  letter-spacing: -0.01em;
  text-decoration-color: var(--rule-2);
  text-underline-offset: 0.18em;
}
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 40px;
  margin-top: 24px;
}
.links li { display: flex; gap: 12px; align-items: baseline; }
.links .k {
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}

/* footer */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 32px;
  padding-bottom: 48px;
  font: 400 12px/1.6 var(--mono);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.foot .clock { color: var(--muted); }

/* responsive --------------------------------------------------------- */
@media (max-width: 900px) {
  :root { --label: 120px; }
  .hero { grid-template-columns: 1fr; gap: 48px; align-items: start; }
  .portrait { max-width: 420px; }
}

@media (max-width: 680px) {
  :root { --gutter: 20px; }
  body { font-size: 16px; }
  .top { height: 64px; }
  .hero { padding-top: 40px; padding-bottom: 52px; gap: 40px; }
  .facts { margin-top: 32px; gap: 8px 16px; }
  .facts .coord { display: block; margin-left: 0; }
  .block { grid-template-columns: 1fr; gap: 20px; padding: 48px 0; }
  .block > header { position: static; }
  .entry,
  .honors li { grid-template-columns: 1fr; gap: 4px; }
  .entry { padding: 22px 0; }
  .when { padding-top: 0; }
  .foot { flex-direction: column; }
  .readout { flex-wrap: wrap; row-gap: 4px; }
  .media.narrow { max-width: 240px; }
  .arm .pair { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  main, .hero { transition: none; }
}

@media print {
  :root { --bg: #fff; --fg: #000; --fg-2: #222; --muted: #555; --faint: #777; --rule: #ddd; }
  .lang, .chart, .media video, .foot .clock { display: none; }
  .portrait { max-width: 160px; }
  .hero { grid-template-columns: 1fr; padding-top: 0; }
  .block { padding: 28px 0; break-inside: avoid; }
  .block > header { position: static; }
  a { text-decoration: none; }
}
