/* Dr. Nianzu Xiong — site design
   Concept: two scripts, one voice. Oxford ink for structure, a brush-written Chinese
   name beneath the portrait, cinnabar reserved for small accents and audience figures. */

/* Newsreader is self-hosted (Latin subset, SIL Open Font License) so it also loads in mainland China */
@font-face { font-family: "Newsreader"; src: url("/assets/fonts/newsreader.woff") format("woff"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("/assets/fonts/newsreader-italic.woff") format("woff"); font-weight: 200 800; font-style: italic; font-display: swap; }

:root {
  --paper: #f4f5f2;
  --paper-2: #e9ebe6;
  --ink: #14243b;
  --text: #28323f;
  --slate: #5d6773;
  --rule: #d6d9d3;
  --seal: #a3302a;
  --serif: "Newsreader", Georgia, "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC", "STSong", "SimSun", serif;
  --cjk: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC", "STSong", "SimSun", serif;
  --wrap: 1180px;
  --gut: clamp(16px, 4vw, 48px);
  --ease: cubic-bezier(.7, 0, .2, 1);
  --ease-out: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.lang-zh { line-height: 1.85; }
img { max-width: 100%; height: auto; display: block; }
picture { display: block; }
h1, h2, h3 { color: var(--ink); font-weight: 500; margin: 0; line-height: 1.15; }
.lang-zh h1, .lang-zh h2, .lang-zh h3 { font-family: var(--cjk); font-weight: 600; line-height: 1.3; }
p { margin: 0 0 1em; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--seal); outline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: .5em 1em; z-index: 20; }
.skip:focus { left: 8px; }

/* Links and buttons */
.link {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--seal);
  text-decoration-thickness: 1px;
  text-underline-offset: .25em;
  transition: text-decoration-thickness .2s;
}
.link:hover { text-decoration-thickness: 2px; }
.prose a, .interest__text a, .event__body a { color: var(--ink); text-decoration-color: var(--seal); text-underline-offset: .2em; }
.btn {
  display: inline-block;
  padding: .7em 1.25em;
  border: 1px solid var(--ink);
  border-radius: 2px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1.2;
  transition: background-color .2s, color .2s, border-color .2s;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--solid:hover { background: var(--seal); border-color: var(--seal); }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(244, 245, 242, .92);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.bar.is-scrolled { border-bottom-color: var(--rule); }
.bar__inner {
  max-width: var(--wrap); margin: 0 auto; padding: .9rem var(--gut);
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1.5rem;
}
.bar__name { color: var(--ink); text-decoration: none; font-size: 1.2rem; font-weight: 600; }
.lang-zh .bar__name { font-family: var(--cjk); }
.bar__nav { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; align-items: baseline; font-size: 1rem; }
.bar__nav a { color: var(--slate); text-decoration: none; padding: .2em 0; border-bottom: 1px solid transparent; }
.bar__nav a:hover { color: var(--ink); }
.bar__nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--seal); }
.bar__lang { color: var(--ink); text-decoration: none; font-size: 1rem; border: 1px solid var(--rule); border-radius: 2px; padding: .1em .55em; }
.bar__lang:hover { border-color: var(--ink); }
.bar__nav { margin-left: auto; }

/* ---------- Homepage hero ---------- */
.hero {
  max-width: var(--wrap); margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 6rem) var(--gut) clamp(3rem, 7vw, 6rem);
  display: grid; grid-template-columns: 1fr; gap: 2.5rem; align-items: center;
}
.hero__name {
  font-size: clamp(2.1rem, 6.4vw, 4.6rem);
  line-height: 1.05;
  white-space: nowrap;
  letter-spacing: -.02em;
  font-weight: 500;
}
.lang-zh .hero__name { font-weight: 900; letter-spacing: .02em; line-height: 1.1; }
.hero__roles {
  margin: 1.1rem 0 0;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-style: italic;
  color: var(--ink);
}
.lang-zh .hero__roles { font-style: normal; font-family: var(--cjk); letter-spacing: .08em; }
.hero__intro { margin: 1.5rem 0 2rem; max-width: 34em; color: var(--text); }
.hero__actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0; }

.hero__portrait { display: flex; flex-direction: column; width: min(100%, 420px); justify-self: start; }
.hero__photo { overflow: hidden; border-radius: 2px; }
.hero__photo img { width: 100%; aspect-ratio: 625 / 781; object-fit: cover; }
.hero__sign { color: #161616; margin-top: 1.1rem; align-self: center; width: 78%; }
.hero__sign .callig { display: block; width: 100%; height: auto; }

@media (min-width: 900px) {
  .hero { grid-template-columns: 7fr 5fr; gap: 3rem; }
  .hero__portrait { justify-self: end; width: clamp(280px, 28vw, 380px); }
}

/* Hero entrance: the one orchestrated moment on load */
.js .hero__name, .js .hero__roles, .js .hero__intro, .js .hero__actions {
  opacity: 0; transform: translateY(.35em);
  animation: rise .9s var(--ease-out) forwards;
}
.js .hero__name { animation-delay: .05s; }
.js .hero__roles { animation-delay: .2s; }
.js .hero__intro { animation-delay: .32s; }
.js .hero__actions { animation-delay: .44s; }
.js .hero__sign { clip-path: inset(0 100% 0 0); animation: write 1.6s cubic-bezier(.45, 0, .25, 1) 1.1s forwards; }
@keyframes write { to { clip-path: inset(0 0 0 0); } }
.js .hero__photo img { clip-path: inset(100% 0 0 0); transform: scale(1.12); animation: unveil 1.4s var(--ease) .25s forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes unveil { to { clip-path: inset(0 0 0 0); transform: scale(1); } }

/* ---------- Homepage sections ---------- */
.block {
  max-width: var(--wrap); margin: 0 auto; padding: clamp(2.75rem, 6vw, 4.5rem) var(--gut);
  display: grid; grid-template-columns: 1fr; gap: 1.25rem;
  border-top: 1px solid var(--rule);
}
.block__title { font-size: 1.5rem; }
.block__body { max-width: 46rem; }
@media (min-width: 900px) {
  .block { grid-template-columns: 3fr 9fr; gap: 3rem; }
  .block__title { position: sticky; top: 5.5rem; align-self: start; }
}
.prose p:last-child { margin-bottom: 0; }

.interests { display: grid; grid-template-columns: 1fr; gap: 2rem 3rem; max-width: none; }
@media (min-width: 700px) { .interests { grid-template-columns: 1fr 1fr; } }
.interest h3 { font-size: 1.4rem; margin-bottom: .5rem; }
.interest h3::before { content: ""; display: block; width: 1.5rem; height: 2px; background: var(--seal); margin-bottom: .9rem; }
.interest__text p { margin: 0; }

.degrees { list-style: none; margin: 0; padding: 0; }
.degree { padding: 1.25rem 0; border-bottom: 1px solid var(--rule); }
.degree:first-child { padding-top: 0; }
.degree:last-child { border-bottom: 0; padding-bottom: 0; }
.degree__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.degree h3 { font-size: 1.3rem; }
.degree__year { color: var(--slate); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.degree__school { margin: .2rem 0 0; color: var(--ink); font-style: italic; }
.lang-zh .degree__school { font-style: normal; }
.degree__note { color: var(--slate); font-size: 1rem; margin-top: .4rem; }
.degree__note p { margin: 0; }

.strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 1.75rem 0 1.25rem; }
.strip img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; filter: saturate(.9); transition: filter .3s; }
.strip:hover img { filter: saturate(1.05); }

.contact { background: var(--ink); color: var(--paper); margin-top: clamp(2rem, 5vw, 3rem); }
.contact__inner { max-width: var(--wrap); margin: 0 auto; padding: clamp(3rem, 7vw, 5.5rem) var(--gut); }
.contact__lead { color: #c9d0da; font-size: 1.15rem; margin-bottom: .6rem; }
.contact__email {
  color: var(--paper);
  font-size: clamp(1.6rem, 4.6vw, 3.25rem);
  line-height: 1.15;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  word-break: break-word;
}
.contact__email:hover { text-decoration-thickness: 2px; }

/* ---------- Public engagement ---------- */
.pagehead { max-width: var(--wrap); margin: 0 auto; padding: clamp(2.5rem, 7vw, 5.5rem) var(--gut) clamp(1.5rem, 4vw, 3rem); }
.pagehead h1 { font-size: clamp(2.5rem, 6.2vw, 4.75rem); line-height: 1.02; letter-spacing: -.015em; max-width: 14em; }
.lang-zh .pagehead h1 { font-weight: 900; letter-spacing: .02em; }
.pagehead__lead { margin: 1.25rem 0 0; font-size: 1.25rem; color: var(--slate); max-width: 32em; }

.event {
  max-width: var(--wrap); margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) var(--gut);
  display: grid; grid-template-columns: 1fr; gap: 1.75rem; align-items: center;
}
.event + .event { border-top: 1px solid var(--rule); }
@media (min-width: 900px) {
  .event { grid-template-columns: 7fr 5fr; gap: 3.5rem; }
  .event--flip { grid-template-columns: 5fr 7fr; }
  .event--flip .event__media { order: 2; }
  .event--gallery { grid-template-columns: 1fr; }
  .event--gallery .event__text { order: -1; max-width: 40rem; }
}
.event__media { display: grid; gap: 8px; }
.event--gallery .event__media { grid-template-columns: 1fr 1fr; }
.event--gallery .shot:first-child { grid-column: 1 / -1; }
.event__title { font-size: clamp(1.6rem, 3vw, 2.25rem); }
.event__place { margin: .5rem 0 0; color: var(--slate); font-style: italic; }
.lang-zh .event__place { font-style: normal; }
.event__reach {
  margin: 1.1rem 0 0;
  color: var(--seal);
  font-size: clamp(1.3rem, 2.3vw, 1.6rem);
  line-height: 1.25;
  font-weight: 500;
}
.lang-zh .event__reach { font-family: var(--cjk); font-weight: 600; }
.event__body { margin-top: 1.1rem; }
.event__body p:last-child { margin-bottom: .75rem; }

.shot {
  display: block; width: 100%; padding: 0; margin: 0; border: 0; background: var(--paper-2);
  cursor: zoom-in; overflow: hidden; border-radius: 2px;
}
.shot img { width: 100%; transition: transform .6s var(--ease-out); }
.shot:hover img { transform: scale(1.025); }

/* Scroll reveal: each photo is unveiled with a wipe as it enters the screen */
.js .reveal img {
  clip-path: inset(0 0 0 100%);
  transform: scale(1.14);
  transition: clip-path 1.15s var(--ease), transform 1.6s var(--ease-out);
}
.js .event--flip .reveal img { clip-path: inset(0 100% 0 0); }
.js .event--gallery .reveal img { clip-path: inset(100% 0 0 0); }
.js .reveal.is-in img { clip-path: inset(0 0 0 0); transform: scale(1); }
.js .reveal.is-in:hover img { transform: scale(1.025); }
.js .event--gallery .shot:nth-child(2) img { transition-delay: .15s; }
.js .event--gallery .shot:nth-child(3) img { transition-delay: .3s; }
.js .event__text { opacity: 0; transform: translateY(14px); transition: opacity .8s var(--ease-out) .3s, transform .8s var(--ease-out) .3s; }
.js .event__text.is-in { opacity: 1; transform: none; }

.others { max-width: var(--wrap); margin: 0 auto; padding: clamp(2.5rem, 6vw, 4rem) var(--gut) clamp(3rem, 7vw, 5rem); border-top: 1px solid var(--rule); }
.others h2 { font-size: 1.5rem; margin-bottom: 1rem; }
.others ul { margin: 0; padding-left: 1.1em; max-width: 46rem; }
.others li { margin-bottom: .6rem; }
.others li::marker { color: var(--seal); }

/* ---------- Speech ---------- */
.speech { max-width: var(--wrap); margin: 0 auto; padding: clamp(2.5rem, 7vw, 5rem) var(--gut) clamp(3rem, 7vw, 5rem); }
.speech__head h1 { font-size: clamp(2.6rem, 6.5vw, 5rem); line-height: 1; letter-spacing: -.015em; }
.lang-zh .speech__head h1 { font-weight: 900; }
.speech__context { margin: 1rem 0 0; color: var(--slate); font-size: 1.2rem; max-width: 36em; }
.speech__photo { margin: 2.25rem 0 2.75rem; max-width: 560px; }
.speech__photo img { width: 100%; border-radius: 2px; }

.speech__switch { display: inline-flex; border: 1px solid var(--ink); border-radius: 2px; margin-bottom: 1.75rem; }
.speech__switch button {
  font: inherit; font-size: 1rem; padding: .45em 1em; border: 0; background: transparent; color: var(--ink); cursor: pointer;
}
.speech__switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.parallel { display: grid; grid-template-columns: 1fr; column-gap: 3.5rem; }
.parallel p { max-width: 40rem; }
.parallel__label { color: var(--slate); font-style: italic; border-bottom: 1px solid var(--rule); padding-bottom: .5rem; margin-bottom: 1.5rem; }
.parallel__zh, .parallel__label:lang(zh-CN) { font-family: var(--cjk); line-height: 1.95; font-style: normal; }
.parallel__en { line-height: 1.65; }
@media (max-width: 899px) {
  .parallel[data-show="en"] .parallel__zh, .parallel[data-show="en"] .parallel__label:lang(zh-CN),
  .parallel[data-show="zh"] .parallel__en, .parallel[data-show="zh"] .parallel__label:lang(en) { display: none; }
}
@media (min-width: 900px) {
  .speech__switch { display: none; }
  .parallel { grid-template-columns: 1fr 1fr; }
}
.speech__back { margin-top: 2.5rem; }

/* ---------- Footer ---------- */
.foot { border-top: 1px solid var(--rule); }
.contact + .foot, .sc--home .foot { border-top: 0; }
.foot__inner {
  max-width: var(--wrap); margin: 0 auto; padding: 1.5rem var(--gut);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem;
  color: var(--slate); font-size: .95rem;
}
.foot__inner a { color: var(--slate); }

/* ---------- Lightbox ---------- */
.lightbox { border: 0; padding: 0; background: transparent; max-width: 94vw; max-height: 94vh; overflow: visible; }
.lightbox::backdrop { background: rgba(20, 36, 59, .9); }
.lightbox img { max-width: 94vw; max-height: 84vh; width: auto; margin: 0 auto; border-radius: 2px; }
.lightbox__cap { color: #dfe4ea; text-align: center; margin: .75rem auto 0; max-width: 40em; font-size: 1rem; }
.lightbox__close {
  position: fixed; top: 12px; right: 16px; width: 44px; height: 44px;
  font: 400 2rem/1 var(--serif); color: var(--paper); background: transparent; border: 0; cursor: pointer;
}
.lightbox[open] { animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .js .hero__name, .js .hero__roles, .js .hero__intro, .js .hero__actions,
  .js .event__text { opacity: 1; transform: none; }
  .js .hero__photo img, .js .reveal img, .js .hero__sign { clip-path: none; transform: none; }
}

/* Keep tall photos from dominating an entry */
.event:not(.event--gallery) .shot img { max-height: 78vh; object-fit: cover; object-position: 50% 30%; }

/* Phones: name and language switch on the first row, page links on the second */
@media (max-width: 640px) {
  .bar__inner { display: grid; grid-template-columns: 1fr auto; align-items: center; row-gap: .35rem; }
  .bar__nav { grid-column: 1 / -1; grid-row: 2; margin-left: 0; }
  .bar__lang { grid-column: 2; grid-row: 1; }
}

/* Working papers */
.paper__title { font-size: 1.4rem; line-height: 1.3; }
.paper__title a { color: var(--ink); text-decoration: none; }
.paper__title a:hover { text-decoration: underline; text-decoration-color: var(--seal); text-underline-offset: .2em; }
.paper__original { margin: .4rem 0 0; font-style: italic; color: var(--ink); }
.paper__meta { margin: .5rem 0 0; color: var(--slate); }
.paper__abstract { margin-top: 1rem; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.paper__abstract summary { cursor: pointer; padding: .6rem 0; color: var(--ink); list-style: none; display: flex; justify-content: space-between; align-items: center; }
.paper__abstract summary::-webkit-details-marker { display: none; }
.paper__abstract summary::after { content: "+"; font-size: 1.25rem; color: var(--slate); }
.paper__abstract[open] summary::after { content: "−"; }
.paper__abstract p { margin: 0 0 1rem; font-size: 1rem; color: var(--text); }
.paper__links { margin: 1rem 0 0; }
html { scroll-padding-top: 5rem; }
.paper + .paper { margin-top: 3rem; }
