/* ---------- tokens ---------- */
:root {
  color-scheme: dark;

  --bg:      #131211;
  --surface: #1d1b19;
  --text:    #e9e6e0;
  --muted:   #a39e96;
  --faint:   #827d75;
  --rule:    #2f2c28;

  /* 深色背景上的链接色：偏暖的浅红，保证对比度 */
  --accent:   #e2908a;
  --accent-2: #f1aaa4;
  --accent-line: rgba(226, 144, 138, 0.34);

  /* 压在浅色地图截图上的按钮，和页面主题无关，固定用深红配白字 */
  --cta:   #8c1d1d;
  --cta-2: #a82626;

  --serif: "Source Serif 4", Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;

  --page: 64rem;      /* 1024px：左栏 236 + 间距 56 + 正文 732 */
  --sidebar: 236px;
  --gutter: 20px;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* 顶部 tab 是 sticky 的，锚点跳转要留出它的高度 */
  scroll-padding-top: 72px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 18.5px;
  line-height: 1.7;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-line); }
a:hover { color: var(--accent-2); border-bottom-color: var(--accent-2); }

.skip {
  position: absolute; left: -9999px;
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border: 0; border-radius: 4px;
}
.skip:focus { left: 12px; top: 12px; z-index: 20; }

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

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

.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  gap: 0 56px;
  align-items: start;
  padding-top: 56px;
}

.content { min-width: 0; }

/* ---------- 左侧栏 ---------- */
/* 跟随滚动停在原处，这样正文滚很长时左边也不会空一大片；
   它比视口矮，所以不会出现"侧栏自己还要滚"的问题。 */
.sidebar { position: sticky; top: 36px; }

.portrait {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface);
  display: block;
}

.name {
  font-size: 2.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin: 22px 0 8px;
}

.role {
  font-size: 1rem;
  line-height: 1.45;
  margin: 0 0 4px;
}

.affil {
  font-size: 0.93rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.links {
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
  font-size: 0.95rem;
  line-height: 1.5;
}
.links li { margin-bottom: 7px; }
.links a { color: var(--text); border-bottom-color: var(--rule); }
.links a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- top tabs ---------- */
.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 19px;
  margin-top: 0;
  padding: 0 0 13px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  font-size: 0.93rem;
}
.tabs a { color: var(--text); border-bottom: 0; }
.tabs a:hover { color: var(--accent); }

/* ---------- sections ---------- */
.section { margin-top: 56px; }
.about { margin-top: 34px; }

h2 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

/* Research 下面的 Working Papers / Publications / Research Assistantships */
.subhead {
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 36px 0 14px;
}
h2 + .subhead { margin-top: 0; }

.section p { margin: 0 0 18px; }
.section p:last-child { margin-bottom: 0; }

.lede { color: var(--muted); margin-bottom: 28px !important; }

/* ---------- papers ---------- */
.paper {
  border-left: 2px solid var(--rule);
  padding-left: 18px;
  margin-bottom: 24px;
}
.paper[open] { border-left-color: var(--accent); }

.paper-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  cursor: pointer;
  list-style: none;
}
.paper-flat .paper-head { cursor: default; }
.paper-head::-webkit-details-marker { display: none; }

.paper-text { display: block; min-width: 0; }

.paper-title {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 4px;
}

.meta { display: block; font-size: 0.93rem; color: var(--muted); line-height: 1.55; }

.toggle { flex: none; padding-top: 4px; }

.toggle-label {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 3px;
  padding: 1px 10px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.toggle-label::after { content: " +"; }
.paper[open] .toggle-label::after { content: " \2212"; }
.paper-head:hover .toggle-label { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.abstract { padding-top: 14px; }
.abstract p { font-size: 0.97rem; line-height: 1.7; }

.keywords { font-size: 0.92rem; color: var(--muted); }
.keywords span { font-style: italic; color: var(--faint); margin-right: 6px; }

/* ---------- lists ---------- */
.worklist, .rows, .citations { list-style: none; padding: 0; margin: 0; }

.worklist li { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.worklist li:last-child { border-bottom: 0; padding-bottom: 0; }

/* 按 CV 的引文格式排，悬挂缩进 */
.citations li {
  padding-left: 1.6em;
  text-indent: -1.6em;
  margin-bottom: 14px;
  font-size: 0.99rem;
  line-height: 1.6;
}
.citations li:last-child { margin-bottom: 0; }
.citations a { word-break: break-word; }

.rows li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 24px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.rows li:last-child { border-bottom: 0; padding-bottom: 0; }

.t { font-weight: 600; font-size: 1.02rem; line-height: 1.45; }
.t a { color: var(--text); border-bottom-color: var(--rule); }
.t a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.c { display: block; font-size: 0.95rem; color: var(--muted); line-height: 1.55; }
.rows .c { grid-column: 1; }

.d {
  grid-row: 1;
  grid-column: 2;
  font-size: 0.93rem;
  color: var(--faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-top: 3px;
}

/* ---------- visualizations ---------- */
/* 三个项目之间拉开，并用分隔线断开，避免滚起来是一整坨 */
.project {
  padding-bottom: 64px;
  margin-bottom: 64px;
  border-bottom: 1px solid var(--rule);
}
.project:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }

.shot {
  display: block;
  position: relative;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
  line-height: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.shot:hover { border-color: var(--accent-line); box-shadow: 0 4px 22px rgba(0, 0, 0, 0.45); }
.shot img {
  width: 100%; height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover; object-position: top center;
  display: block;
  transition: filter 0.2s ease;
}

/* 打开应用的按钮压在截图中央：整张图都是链接，按钮只是明确告诉人可以点 */
.shot-cta {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--cta);
  color: #fff;
  font-size: 0.97rem;
  line-height: 1.25;
  white-space: nowrap;
  padding: 8px 22px;
  border-radius: 3px;
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
  transition: background 0.15s ease, transform 0.15s ease;
}
.shot-cta::after { content: " \2192"; }

.shot:hover img { filter: brightness(0.86); }
.shot:hover .shot-cta {
  background: var(--cta-2);
  transform: translate(-50%, -50%) scale(1.05);
}

/* 不喜欢动效的人就别动 */
@media (prefers-reduced-motion: reduce) {
  .shot img, .shot-cta { transition: none; }
  .shot:hover .shot-cta { transform: translate(-50%, -50%); }
}

/* 没有公开托管的那个：不要做成可点的样子 */
figure.shot { margin: 0; }
.shot-static { cursor: default; }
.shot-static:hover { border-color: var(--rule); box-shadow: none; }
.shot-static:hover img { filter: none; }

.project-body { padding-top: 20px; }

.project-kicker {
  font-size: 0.86rem;
  font-style: italic;
  color: var(--faint);
  margin: 0 0 4px !important;
}

.project-title {
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0 0 12px;
}

.note {
  font-size: 0.93rem;
  color: var(--muted);
  border-left: 2px solid var(--rule);
  padding-left: 14px;
}

.caption { font-size: 0.93rem; color: var(--muted); }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 16px 0 0; }
.tags li {
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1px 9px;
}

.actions { margin: 20px 0 0 !important; }

.btn {
  display: inline-block;
  font-size: 0.97rem;
  color: #fff;
  background: var(--cta);
  border: 1px solid var(--cta);
  border-radius: 3px;
  padding: 5px 18px;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--cta-2); border-color: var(--cta-2); color: #fff; }
.btn::after { content: " \2192"; }

/* ---------- footer ---------- */
.footer {
  margin-top: 64px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
  color: var(--muted);
}
.footer p { margin: 0 0 4px; }
.updated { color: var(--faint); font-size: 0.88rem; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  body { font-size: 17px; }
  html { scroll-padding-top: 108px; }

  .layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: 34px;
  }
  .sidebar { position: static; }
  .portrait { width: 132px; }
  .name { font-size: 2.1rem; }
  .links { margin-bottom: 30px; }

  .tabs { gap: 2px 20px; }

  .section { margin-top: 44px; }

  .paper-head { flex-direction: column; gap: 10px; }

  .citations li { padding-left: 1.2em; text-indent: -1.2em; }

  .rows li { grid-template-columns: 1fr; }
  .d { grid-row: auto; grid-column: 1; }

  .project { padding-bottom: 48px; margin-bottom: 48px; }
  .shot-cta { font-size: 0.9rem; padding: 7px 16px; }
}

@media print {
  .tabs, .toggle, .btn, .shot-cta, .skip { display: none; }
  body { font-size: 11pt; background: #fff; color: #000; }
  .page { max-width: none; }
  a { color: #000; border: 0; }
  .abstract { display: block !important; }
}
