/* ------------------------------------------------------------------
   Junfei Zhou — personal homepage
   Editorial layout: hanging section labels, ledger rows, one accent.
   ------------------------------------------------------------------ */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/newsreader-latin-wght-normal.woff2") format("woff2-variations"),
       url("fonts/newsreader-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
}

:root {
  --bg: #fcfcfa;
  --ink: #1b1b1b;
  --ink-2: #474746;
  --ink-3: #7b7b78;
  --rule: #e6e5e0;
  --rule-strong: #cfcec8;
  --accent: #1f3a5f;
  --accent-ul: #a9b8cc;
  --panel: #f5f5f2;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --measure: 40.5rem; /* ~648px */
}

* { 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(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "kern" 1, "liga" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-ul);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  transition: text-decoration-color 120ms ease;
}
a:hover { text-decoration-color: var(--accent); }

p { margin: 0 0 0.9em; }
p:last-child { margin-bottom: 0; }

strong { font-weight: 600; }

.page {
  max-width: 62rem; /* 992px */
  margin: 0 auto;
  padding: 4.5rem 2rem 3rem;
}

/* ---------- Rail navigation (wide screens only) ----------
   A column of short bars floating at the left edge, vertically centred.
   The current section's bar is long and navy. Hovering a bar stretches it
   and springs its label out; leaving lets it settle back. */

.railnav {
  display: none;
  position: fixed;
  left: 1.75rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
}
@media (min-width: 1080px) {
  .railnav { display: block; }
}

.railnav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.railnav__link {
  position: relative;
  display: flex;
  align-items: center;
  width: 3rem;
  height: 1.5rem;
  text-decoration: none;
  outline: none;
}

.railnav__bar {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: var(--rule-strong);
  transition: width 300ms cubic-bezier(0.4, 0, 0.6, 1),
              background-color 220ms ease;
}

.railnav__label {
  position: absolute;
  left: 2.75rem;
  top: 50%;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(27, 27, 27, 0.06);
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-10px, -50%) scale(0.96);
  transform-origin: left center;
  transition: opacity 140ms ease,
              transform 260ms cubic-bezier(0.4, 0, 0.6, 1);
}

.railnav__link:hover .railnav__bar,
.railnav__link:focus-visible .railnav__bar {
  width: 32px;
  background: var(--ink);
  transition: width 420ms cubic-bezier(0.34, 1.45, 0.64, 1),
              background-color 160ms ease;
}
.railnav__link:hover .railnav__label,
.railnav__link:focus-visible .railnav__label {
  opacity: 1;
  transform: translate(0, -50%) scale(1);
  transition: opacity 120ms ease,
              transform 460ms cubic-bezier(0.34, 1.45, 0.64, 1);
}

.railnav__link.is-active .railnav__bar {
  width: 32px;
  background: var(--accent);
}
.railnav__link.is-active:hover .railnav__bar { background: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .railnav__bar,
  .railnav__label,
  .railnav__link:hover .railnav__bar,
  .railnav__link:hover .railnav__label { transition: none; }
}

main section[id] { scroll-margin-top: 1.5rem; }

/* ---------- Header ---------- */

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--rule-strong);
}

.masthead__name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2.85rem;
  line-height: 1.05;
  letter-spacing: -0.012em;
  margin: 0 0 0.75rem;
}

.masthead__role {
  font-size: 1.0625rem;
  color: var(--ink-2);
  margin: 0 0 0.25rem;
  max-width: 34rem;
}

.masthead__place {
  font-size: 0.9375rem;
  color: var(--ink-3);
  margin: 0 0 1.25rem;
}

.masthead__portrait {
  flex: none;
  width: 104px;
  height: 130px;
  object-fit: cover;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  background: #fff;
}

/* Inline link rows separated by middle dots */
.inline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  font-size: 0.9375rem;
}
.inline-list > li { white-space: nowrap; }
.inline-list > li + li::before {
  content: "\00B7";
  color: var(--ink-3);
  margin: 0 0.6em;
}
.inline-list [hidden] { display: none; }

.muted { color: var(--ink-3); }

/* ---------- Sections ---------- */

.section {
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr);
  column-gap: 2rem;
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.section:last-of-type { border-bottom: 0; }

.section__label {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.375rem;
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin: 0;
  padding-top: 0.1rem;
  color: var(--ink);
}

.section__body { min-width: 0; }
.section__body > p { max-width: var(--measure); }

/* Notice */
.notice {
  margin-top: 1.5rem;
  padding: 0.15rem 0 0.15rem 1.1rem;
  border-left: 2px solid var(--accent);
  color: var(--ink-2);
  font-size: 0.96rem;
  max-width: var(--measure);
}
.notice a { white-space: nowrap; }

/* Ledger rows: date | text */
.ledger {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ledger > li {
  display: grid;
  grid-template-columns: 8.25rem minmax(0, 1fr);
  column-gap: 1rem;
  padding: 0.45rem 0;
  max-width: 47rem;
}
.ledger__date {
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  font-size: 0.9rem;
  line-height: 1.6;
  padding-top: 0.05rem;
}
.ledger__text { color: var(--ink); }
.ledger__text .sub {
  display: block;
  color: var(--ink-3);
  font-size: 0.9rem;
}

/* ---------- Publications ---------- */

.pubs {
  list-style: none;
  margin: 0;
  padding: 0;
}
.pub {
  display: grid;
  grid-template-columns: 4.25rem 160px minmax(0, 1fr);
  column-gap: 1.25rem;
  padding: 0.3rem 0 1.85rem;
}
.pub:last-child { padding-bottom: 0.25rem; }

.pub__year {
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  font-size: 0.9rem;
  padding-top: 0.2rem;
}
.pub.same-year .pub__year { visibility: hidden; }

.pub__figure {
  margin: 0;
  width: 160px;
  height: 100px;
  border: 1px solid var(--rule);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.pub__figure img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  padding: 4px;
}

.pub__venue {
  font-size: 0.84rem;
  color: var(--ink-3);
  letter-spacing: 0.01em;
  margin: 0.2rem 0 0.3rem;
}
.pub__venue .hl { color: var(--accent); font-weight: 500; }

.pub__title {
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.4;
  margin: 0 0 0.35rem;
  color: var(--ink);
}

.pub__authors {
  font-size: 0.94rem;
  color: var(--ink-2);
  margin: 0 0 0.45rem;
}
.pub__authors strong { font-weight: 600; color: var(--ink); }
.pub__authors .fn { color: var(--ink-3); font-size: 0.86rem; }

.pub__links { font-size: 0.9rem; }

/* ---------- Footer ---------- */

.footer {
  margin-top: 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule-strong);
  color: var(--ink-3);
  font-size: 0.86rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
}

.visitor-map { max-width: 300px; }
.visitor-map:empty { display: none; }
.visitor-map img { display: block; max-width: 100%; height: auto; }

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .page { padding: 2.5rem 1.25rem 2.5rem; }

  .masthead {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 1.5rem;
    padding-bottom: 2rem;
  }
  .masthead__name { font-size: 2.25rem; }
  .masthead__portrait { width: 88px; height: 110px; }

  .section {
    grid-template-columns: 1fr;
    row-gap: 1rem;
    padding: 2rem 0;
  }
  .section__label { font-size: 1.3rem; }

  .ledger > li { grid-template-columns: 5.75rem minmax(0, 1fr); }
  .ledger__date { font-size: 0.86rem; }

  .pub {
    grid-template-columns: 1fr;
    row-gap: 0.75rem;
    padding-bottom: 2rem;
  }
  .pub__year { display: none; }
  .pub__figure { width: 160px; height: 100px; }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
  }
}

@media print {
  body { background: #fff; }
  .page { padding: 0; max-width: none; }
  .visitor-map { display: none; }
  a { color: inherit; text-decoration: none; }
}
