/* Shared theme for every page: white paper, typewriter type, lowercase labels,
   wide margins and a small name/menu "lockup" in the bottom-right corner.
   (Layout idea borrowed from andreeesty.com.) */

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

:root {
  --ink:   #111;
  --mid:   #6b6b68;
  --faint: #a4a4a0;
  --line:  #dcdcd8;
  --bg:    #fff;
  --type:  'Courier Prime', 'Courier New', Courier, monospace;
  --cjk:   'Songti SC', 'STSong', 'Noto Serif SC', 'SimSun', serif;
  --margin: clamp(1.25rem, 8vw, 8rem);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--type);
  font-size: 15px; line-height: 1.75;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: underline; text-decoration-thickness: 1px;
  text-underline-offset: 0.22em; text-decoration-color: var(--faint);
  transition: text-decoration-color 0.2s;
}
a:hover { text-decoration-color: var(--ink); }

/* ---- PAGE FRAME ---- */
.wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  max-width: 1800px; margin: 0 auto;
  padding: 0 var(--margin);
}
.wrap.wide { --margin: clamp(1.25rem, 4vw, 4rem); }

.topbar {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding-top: 2rem;
  font-size: 0.8rem; letter-spacing: 0.2em;
}
.topbar a { text-decoration: none; }
.topbar a:hover { text-decoration: underline; text-underline-offset: 0.3em; }
.topbar span { color: var(--mid); }

.page { width: 100%; max-width: 64rem; padding-bottom: 2rem; }
.wrap.wide .page { max-width: none; }

.page-title {
  margin: clamp(2.5rem, 7vw, 5rem) 0 1.25rem;
  font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 400;
  letter-spacing: 0.22em; line-height: 1.2;
}
.page-title::after { content: '_'; margin-left: 0.05em; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .page-title::after { animation: none; } }

.prose { max-width: 62ch; }
.prose p { margin-bottom: 1.15rem; }
.mid { color: var(--mid); }

/* ---- LOCKUP (name + menu), bottom-right of every page ---- */
.lockup {
  margin: auto 0 0 auto; width: 100%; max-width: 230px;
  padding: clamp(3rem, 8vw, 6rem) 0 2rem;
  text-align: center;
}
.lockup a { text-decoration: none; }
.lockup .name { display: block; }
.lockup .zh {
  display: block; font-family: var(--cjk);
  font-size: 1.5rem; line-height: 1.3; letter-spacing: 0.35em; text-indent: 0.35em;
}
.lockup .en { display: block; margin-top: 0.1rem; font-size: 1.05rem; letter-spacing: 0.14em; }
.lockup ul { list-style: none; margin: 1rem 0 0.6rem; font-size: 1rem; letter-spacing: 0.2em; line-height: 1.7; }
.lockup li a::before { content: '•'; margin-right: 0.55em; display: inline-block; }
.lockup li a:hover, .lockup li a[aria-current="page"] {
  text-decoration: underline; text-underline-offset: 0.3em; text-decoration-color: var(--ink);
}

/* ---- HOME ---- */
.wrap.home { position: relative; }
.stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding-top: 2.5rem;
}
.slides {
  position: relative; display: block; aspect-ratio: 0.82;
  width: min(calc(min(46vh, 520px) * 0.82), 100%);
}
.home .lockup { padding-top: 1.5rem; }
/* wide screens: photo centred in the window, name + menu pinned bottom-right (as on andreeesty.com) */
@media (min-width: 1200px) {
  .stage { padding-top: 0; }
  .slides { width: min(calc(min(70vh, 760px) * 0.82), calc(100vw - 2 * var(--margin) - 520px)); }
  .home .lockup { position: absolute; right: var(--margin); bottom: 0; padding-top: 0; }
}
.slides img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  opacity: 0; transition: opacity 1.4s ease;
}
.slides img.on { opacity: 1; }

/* ---- ABOUT ---- */
.about-grid {
  display: grid; grid-template-columns: minmax(170px, 300px) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 4.5rem); align-items: start;
}
.portrait { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.about .role { margin-bottom: 1.6rem; color: var(--mid); font-size: 0.9rem; }
.links { list-style: none; margin-top: 2rem; letter-spacing: 0.12em; }
.links li::before { content: '•'; margin-right: 0.7em; }

/* ---- SCIENCE (typed CV) ---- */
.index { margin: 0 0 1rem; font-size: 0.85rem; letter-spacing: 0.12em; color: var(--mid); }
.index a { text-decoration: none; }
.index a:hover { text-decoration: underline; text-underline-offset: 0.3em; }
.index a:not(:last-child)::after { content: '/'; margin: 0 0.1em 0 0.8em; color: var(--faint); display: inline-block; }

.section { margin-top: 2.5rem; padding-top: 2.25rem; border-top: 1px solid var(--line); }
.section > h2 {
  margin-bottom: 1.5rem;
  font-size: 0.85rem; font-weight: 400; letter-spacing: 0.22em;
}
.section > h2::before { content: '•'; margin-right: 0.7em; }

.entry {
  display: grid; grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 0.25rem 2rem; padding: 0.7rem 0;
}
.entry .when { color: var(--mid); font-size: 0.85rem; line-height: 1.6; padding-top: 0.15rem; }
.entry .when small { display: block; font-size: 0.78rem; color: var(--faint); }
.entry h3 { font-size: 1rem; font-weight: 700; line-height: 1.5; }
.entry p { margin-top: 0.3rem; max-width: 62ch; }
.entry .authors, .entry .venue { color: var(--mid); font-size: 0.88rem; }
.entry .authors b { color: var(--ink); }
.entry .journal { font-style: italic; color: var(--mid); font-size: 0.88rem; }
.tags { margin-top: 0.4rem; font-size: 0.8rem; color: var(--mid); }
.tag { margin-right: 0.7rem; }
.tag::before { content: '['; } .tag::after { content: ']'; }

/* ---- PHOTOGRAPHY ---- */
.gallery {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: clamp(1.25rem, 2.6vw, 2.5rem) clamp(1rem, 2.4vw, 2.25rem);
  margin-top: 2.5rem;
}
.gallery a { display: block; text-decoration: none; cursor: zoom-in; }
.gallery img { width: 100%; height: auto; display: block; transition: opacity 0.25s; }
.gallery a:hover img, .gallery a:focus-visible img { opacity: 0.75; }
.gallery a:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }
.gallery .no { display: block; margin-top: 0.4rem; font-size: 0.72rem; letter-spacing: 0.22em; color: var(--mid); }

/* ---- LIGHTBOX ---- */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 100;
  align-items: center; justify-content: center;
  background: #fff;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: min(92vw, 1100px); max-height: 88vh;
  width: auto; height: auto; object-fit: contain;
}
.lightbox button {
  position: absolute; background: none; border: 0; cursor: pointer;
  color: var(--ink); opacity: 0.5; transition: opacity 0.2s;
  width: 3.25rem; height: 3.25rem;
  display: flex; align-items: center; justify-content: center;
}
.lightbox button:hover, .lightbox button:focus-visible { opacity: 1; }
.lightbox svg { width: 1.6rem; height: 1.6rem; stroke: currentColor; fill: none; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.lb-close { top: 0.75rem; right: 0.75rem; }
.lb-prev  { left: 0.75rem;  top: 50%; transform: translateY(-50%); }
.lb-next  { right: 0.75rem; top: 50%; transform: translateY(-50%); }
.lb-count {
  position: absolute; bottom: 1rem; left: 50%; transform: translateX(-50%);
  font-size: 0.75rem; letter-spacing: 0.2em; color: var(--mid);
}

/* ---- RESPONSIVE ---- */
@media (min-width: 1700px) { .gallery { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 1100px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px) {
  .lockup { margin-inline: auto; }
  .about-grid { grid-template-columns: 1fr; }
  .portrait { max-width: 220px; }
  .entry { grid-template-columns: 1fr; gap: 0.1rem; padding: 0.9rem 0; }
  .entry .when small { display: inline; margin-left: 0.6rem; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 1.25rem 1rem; }
  .lb-prev, .lb-next { top: auto; bottom: 0.75rem; transform: none; }
  .lb-prev { left: 1rem; } .lb-next { right: 1rem; }
}
