/* Tianyao Shi — homepage
   Two families: Archivo (variable width) for the name, numbers and interface;
   Literata for reading text. The four data colours encode the four dimensions
   of environmental impact and are not used for anything else. */

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo.woff2") format("woff2");
  font-weight: 400 750;
  font-stretch: 75% 118%;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("fonts/literata.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Name ZH";
  src: url("fonts/name-zh.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
  unicode-range: U+53F2, U+5929, U+5C27;
}

:root {
  --paper: #f3f4f6;
  --ink: #1a2030;
  --ink-2: #555d6e;
  --ink-3: #b3b8c3;
  --rule: #d9dce3;
  --hover: #e6e8ed;

  --energy: #bd8200;
  --carbon: #4a4f5a;
  --water: #2a6ab0;
  --bio: #c0213b;
  --bio-text: #b01c35;

  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --zh: "Name ZH", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;

  --wrap: 1200px;
  --gutter: clamp(20px, 5vw, 56px);
  --label-col: 9.5rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12151c;
    --ink: #e6e8ee;
    --ink-2: #9aa1b0;
    --ink-3: #3c4352;
    --rule: #272c38;
    --hover: #1c212b;

    --energy: #f0b23a;
    --carbon: #a3a9b5;
    --water: #5c9de6;
    --bio: #f0566e;
    --bio-text: #ff6f84;
    color-scheme: dark;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--serif);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol { margin: 0; }
h1, h2, h3, .lede, .pub-title, .map-paper a { text-wrap: balance; }
p, li { text-wrap: pretty; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
cite { font-style: normal; }
b, strong { font-weight: 600; }
sup, sub { position: relative; font-size: 0.72em; line-height: 0; vertical-align: baseline; }
sup { top: -0.48em; }
sub { top: 0.22em; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--ink-3);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-color: currentColor; }
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection { background: var(--ink); color: var(--paper); }

.wrap {
  max-width: calc(var(--wrap) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  font: 600 0.875rem/1 var(--sans);
  z-index: 10;
}
.skip:focus { top: 12px; }

/* ---------- top line ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  transition: box-shadow 0.2s ease;
}
.top.is-stuck { box-shadow: 0 1px 0 var(--rule); }
.top-inner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding-top: 18px;
  padding-bottom: 16px;
  font: 500 0.875rem/1.2 var(--sans);
}
.top nav { display: flex; flex-wrap: wrap; gap: 6px 26px; }
.top a { text-decoration: none; color: var(--ink-2); padding: 4px 0; }
.top a:hover { color: var(--ink); text-decoration: underline; }
.top nav a[aria-current="true"] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 0.45em; }

[id] { scroll-margin-top: 72px; }

.to-top {
  position: fixed;
  right: max(16px, calc((100vw - var(--wrap)) / 2 - 64px));
  bottom: 24px;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}
.to-top.is-shown { opacity: 1; visibility: visible; transform: none; transition: opacity 0.2s ease, transform 0.2s ease; }
.to-top .ic { width: 22px; height: 22px; }
.to-top:hover { background: var(--ink-2); }
.to-top:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  .top, .to-top, .to-top.is-shown { transition: none; }
}

/* ---------- intro ---------- */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px 64px;
  align-items: start;
  padding-top: clamp(28px, 4.5vw, 64px);
}

h1 {
  font-family: var(--sans);
  font-weight: 700;
  font-stretch: 100%;
  font-size: clamp(2.5rem, 5vw, 4.25rem);
  line-height: 1;
  letter-spacing: -0.02em;
}
h1 .zh {
  font-family: var(--zh);
  font-weight: 700;
  font-size: 0.72em;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  white-space: nowrap;
  vertical-align: 0.12em;
  margin-left: 0.1em;
}

.lede {
  margin-top: clamp(20px, 2.6vw, 30px);
  max-width: 52ch;
  font-size: clamp(1.25rem, 1.9vw, 1.625rem);
  line-height: 1.32;
  letter-spacing: -0.008em;
}

.bio {
  margin-top: 18px;
  max-width: 82ch;
  color: var(--ink-2);
}

.contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-top: 18px;
  margin-left: -8px;
  font: 500 0.9375rem/1.2 var(--sans);
}
.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  justify-content: center;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: 6px;
}
.icon-link .ic { width: 22px; height: 22px; }
.icon-link:hover { color: var(--ink); background: var(--hover); }
.icon-link.has-label { padding-right: 10px; }

.portrait {
  width: clamp(112px, 15vw, 180px);
  height: auto;
  aspect-ratio: 1;
  margin-top: 10px;
}

/* ---------- the meter ---------- */

.meter {
  margin-top: clamp(44px, 5.5vw, 72px);
  font-family: var(--sans);
}

.meter-title {
  font: 600 1rem/1.3 var(--sans);
  padding-top: 16px;
  border-top: 2px solid var(--ink);
}

.meter-grid {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  gap: 24px clamp(32px, 4vw, 56px);
  align-items: end;
  margin-top: 22px;
}

.readings { display: grid; gap: 12px; margin: 0; }

.reading {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.reading:last-child { border-bottom: 0; padding-bottom: 0; }
.reading dd { margin: 0; }

.dim {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 500 0.875rem/1.2 var(--sans);
  color: var(--ink-2);
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: currentColor;
}
.dim .ic { color: var(--c); width: 22px; height: 22px; }

[data-dim="energy"] { --c: var(--energy); }
[data-dim="carbon"] { --c: var(--carbon); }
[data-dim="water"]  { --c: var(--water); }
[data-dim="bio"]    { --c: var(--bio); }

.val {
  font-weight: 600;
  font-stretch: 85%;
  font-size: 1.625rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.01em;
}
.val small { font-size: 0.6em; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-left: 0.3em; }

.reading-bio { display: flex; flex-direction: column; min-width: 0; container-type: inline-size; }

.big {
  display: block;
  margin-top: 6px;
  font-weight: 600;
  font-stretch: 75%;
  font-size: clamp(1.5rem, 10.2cqi, 5.25rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
  color: var(--ink-3);
}
.big .sig { color: var(--bio-text); }

.unit {
  font: 400 0.9375rem/1.45 var(--sans);
  color: var(--ink-2);
  margin-top: 12px;
  max-width: 62ch;
}
.unit b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.meter-basis {
  margin-top: 24px;
  font: 400 0.9375rem/1.5 var(--sans);
  color: var(--ink-2);
}
.meter-basis [data-out] { color: var(--ink); font-variant-numeric: tabular-nums; }
.grid-pick select {
  font: 500 0.9375rem/1.2 var(--sans);
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ink-3);
  border-radius: 0;
  padding: 1px 2px;
  cursor: pointer;
}
.grid-pick select:hover { border-bottom-color: var(--ink); }
.grid-pick select:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.grid-pick option { color: #1a2030; background: #fff; }

.pathways { margin: 4px 0 16px; font: 400 0.9375rem/1.4 var(--sans); max-width: 640px; }
.pathways li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto 3.5rem;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--rule);
}
.pathways li:last-child { border-bottom: 1px solid var(--rule); }
.pathways .ic { width: 24px; height: 24px; color: var(--ink-2); }
.pathways .phi { color: var(--ink-2); font-size: 0.875rem; }
.pathways b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.method { margin-top: 10px; max-width: 86ch; }
.method summary {
  display: inline-block;
  cursor: pointer;
  font: 500 0.9375rem/1.5 var(--sans);
  text-decoration: underline;
  text-decoration-color: var(--ink-3);
  text-underline-offset: 0.2em;
  list-style: none;
}
.method summary::-webkit-details-marker { display: none; }
.method summary::after { content: " +"; }
.method[open] summary::after { content: " −"; }
.method-body {
  margin-top: 14px;
  font: 400 1rem/1.6 var(--serif);
}
.method-body p + p { margin-top: 10px; }
.method-body ol { list-style: decimal; padding-left: 1.3em; margin: 12px 0; }
.method-body li + li { margin-top: 8px; }
.method-body li::marker { font: 600 0.875rem var(--sans); color: var(--ink-2); }
.method-body strong { font-family: var(--sans); font-weight: 600; font-size: 0.9375rem; }

/* ---------- sections ---------- */

.block { margin-top: clamp(80px, 10vw, 128px); }

.block > h2 {
  font-family: var(--sans);
  font-weight: 700;
  font-stretch: 100%;
  font-size: clamp(1.625rem, 2.4vw, 2.125rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.block-intro {
  margin-top: 18px;
  font-size: 1.125rem;
  line-height: 1.6;
}

.block-note {
  margin-top: 24px;
  max-width: 96ch;
  font: 400 0.9375rem/1.55 var(--sans);
  color: var(--ink-2);
}

.list-title {
  font: 600 1rem/1.3 var(--sans);
  margin-top: 40px;
  margin-bottom: 4px;
}

/* ---------- research map ---------- */

.map {
  margin-top: 40px;
  font-family: var(--sans);
}

.map-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(4, minmax(56px, 112px));
  column-gap: 4px;
  align-items: center;
  border-top: 1px solid var(--rule);
  padding: 14px 0;
}
.map-row:last-child { border-bottom: 1px solid var(--rule); }

.map-head {
  border-top: 0;
  padding: 0 0 10px;
  font: 500 0.875rem/1.2 var(--sans);
  color: var(--ink-2);
}
.map-head .map-paper { visibility: hidden; }
.map-dim {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-dim .ic { color: var(--c); width: 24px; height: 24px; }

.map-paper {
  padding-right: 32px;
  font: 400 1.0625rem/1.4 var(--serif);
}
.map-paper a { text-decoration-color: transparent; }
.map-paper a:hover { text-decoration-color: currentColor; }
.venue {
  display: block;
  margin-top: 4px;
  font: 500 0.8125rem/1.3 var(--sans);
  color: var(--ink-2);
}

.cell { height: 12px; align-self: start; margin-top: 0.5rem; }
.cell.on { background: var(--c); }

/* ---------- dated lists ---------- */

.dated { margin-top: 20px; }
.dated li {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  gap: 16px;
  padding: 11px 0;
  border-top: 1px solid var(--rule);
}
.dated li:last-child { border-bottom: 1px solid var(--rule); }
.dated time {
  font: 500 0.875rem/1.75 var(--sans);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.dated p { max-width: 88ch; }

.plain { margin-top: 20px; }
.plain li { padding: 11px 0; border-top: 1px solid var(--rule); max-width: 96ch; }
.plain li:last-child { border-bottom: 1px solid var(--rule); }

/* ---------- papers ---------- */

.pubs li {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  gap: 16px;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
}
.pubs li:last-child { border-bottom: 1px solid var(--rule); }

.pub-venue {
  font: 600 0.875rem/1.85 var(--sans);
  font-stretch: 90%;
}
.pub-title {
  font: 500 1.125rem/1.4 var(--serif);
  text-decoration-color: transparent;
}
.pub-title:hover { text-decoration-color: currentColor; }
.pub-body { max-width: 88ch; }
.pub-authors, .pub-where, .pub-links {
  font: 400 0.9375rem/1.5 var(--sans);
  color: var(--ink-2);
}
.pub-authors { margin-top: 6px; }
.pub-authors b { color: var(--ink); font-weight: 600; }
.pub-links { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 18px; font-weight: 500; }
.pub-links a { color: var(--ink); }

/* ---------- background ---------- */

.cv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 56px;
}
.cv .dated li, .cv .plain li { font-size: 1rem; }
.cv .dated li { grid-template-columns: 4.75rem minmax(0, 1fr); }

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

.foot {
  margin-top: clamp(96px, 12vw, 160px);
  padding-top: 18px;
  padding-bottom: 48px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px 32px;
  background: linear-gradient(var(--ink), var(--ink)) center top / calc(100% - 2 * var(--gutter)) 2px no-repeat;
  font: 400 0.875rem/1.5 var(--sans);
  color: var(--ink-2);
}
.foot-note { max-width: 80ch; }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.foot-links a { color: var(--ink); }

/* ---------- smaller screens ---------- */

@media (max-width: 860px) {
  .cv { grid-template-columns: 1fr; }
  .meter-grid { grid-template-columns: 1fr; }
  .readings { max-width: 420px; }
  .reading-bio { order: -1; }
  :root { --label-col: 7.5rem; }
}

@media (max-width: 640px) {
  body { font-size: 1rem; }
  .top-inner { padding-top: 14px; padding-bottom: 12px; }
  .to-top { right: 16px; bottom: 16px; }
  .cv-pdf { display: none; }
  .top nav { gap: 6px 16px; }

  .intro { grid-template-columns: 1fr; padding-top: 28px; }
  .portrait { order: -1; width: 96px; margin-top: 0; }

  .val { font-size: 1.375rem; }
  .pathways li { grid-template-columns: 24px minmax(0, 1fr) 3rem; }
  .pathways .phi { display: none; }
  .big { letter-spacing: -0.02em; }

  .map-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    row-gap: 10px;
  }
  .map-paper { grid-column: 1 / -1; padding-right: 0; }
  .map-head .map-paper { display: none; }
  .map-head { font-size: 0.8125rem; }

  .dated li, .pubs li { grid-template-columns: 1fr; gap: 2px; }
  .cv .dated li { grid-template-columns: 4rem minmax(0, 1fr); gap: 12px; }
}

@media print {
  .top, .meter, .skip, .to-top { display: none; }
  body { background: #fff; color: #000; }
}
