/* ==========================================================================
   xuefenghu.me — site styles
   Two families: Newsreader (display / titles) and Inter (text / UI).
   ========================================================================== */

:root {
  --bg: #fbfaf7;
  --surface: #f4f1eb;
  --ink: #1d1c1a;
  --ink-2: #47443f;
  --muted: #7d786f;
  --rule: #e6e1d8;
  --accent: #a3451d;
  --accent-ink: #8a3815;
  --accent-soft: #f5e8df;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --wrap: 1040px;
  --gutter: 24px;
  --label-col: 176px;
  --col-gap: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131211;
    --surface: #1c1b19;
    --ink: #ece8e1;
    --ink-2: #c5c0b7;
    --muted: #8e897f;
    --rule: #2a2825;
    --accent: #e8925f;
    --accent-ink: #f0a578;
    --accent-soft: #2b1e16;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; display: block; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color .15s ease, text-decoration-color .15s ease;
}
a:hover { color: var(--accent-ink); text-decoration-color: var(--accent); }

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

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

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

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.topbar.is-scrolled { border-bottom-color: var(--rule); }

.topbar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 24px;
}

.brand {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--ink); }

.nav {
  display: flex;
  gap: 26px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--ink-2);
}
.nav a { text-decoration: none; }
.nav a:hover { color: var(--accent-ink); }

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  column-gap: var(--col-gap);
  align-items: start;
  padding: 72px 0 64px;
}

.portrait {
  width: 100%;
  aspect-ratio: 4 / 5;
  margin: 0;
  overflow: hidden;
  border-radius: 4px;
  background: #e8863c;
}
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 49% 62%;
  transform: scale(1.9);
  transform-origin: 49% 62%;
}

.hero h1 {
  margin: -6px 0 6px;
  font-family: var(--serif);
  font-size: clamp(40px, 6vw, 58px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.022em;
}

.role {
  margin: 0 0 28px;
  font-size: 16px;
  color: var(--ink-2);
}
.role .sep { color: var(--muted); padding: 0 6px; }

.lede {
  margin: 0 0 16px;
  max-width: 64ch;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.5;
  letter-spacing: -0.003em;
  color: var(--ink);
}

.bio p {
  margin: 0 0 14px;
  max-width: 66ch;
  color: var(--ink-2);
}

.topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}
.topics li {
  font-size: 13px;
  line-height: 1;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
  font-size: 14.5px;
  font-weight: 500;
}
.links a { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.links a::after {
  content: "↗";
  font-size: 12px;
  color: var(--muted);
  transition: transform .15s ease, color .15s ease;
}
.links a:hover::after { color: var(--accent); transform: translate(1px, -1px); }

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

.section {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  column-gap: var(--col-gap);
  padding: 48px 0 52px;
  border-top: 1px solid var(--rule);
}

.section-label {
  margin: 4px 0 20px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-label a { text-decoration: none; }

.section-body > :first-child { margin-top: 0; }
.section-body > :last-child { margin-bottom: 0; }

.note {
  margin: 20px 0 0;
  font-size: 14px;
  color: var(--muted);
}

/* Generic dated list (news, experience, education, honors) */

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}
.timeline > li {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  column-gap: 20px;
  padding: 10px 0;
}
.timeline .when {
  font-size: 14px;
  line-height: 1.85;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.timeline .what { margin: 0; }

.news .what { color: var(--ink-2); }
.news .what strong { color: var(--ink); font-weight: 600; }

.roles > li { padding: 14px 0; }
.org {
  font-weight: 600;
  color: var(--ink);
}
.org-role { color: var(--ink-2); }
.org-meta {
  display: block;
  font-size: 14px;
  color: var(--muted);
}
.org-desc {
  margin: 6px 0 0;
  font-size: 15px;
  color: var(--ink-2);
  max-width: 62ch;
}

/* Role progression within one company */
.steps {
  margin: 12px 0 0;
  padding: 0 0 0 18px;
  list-style: none;
  border-left: 1px solid var(--rule);
}
.steps > li {
  position: relative;
  padding: 0 0 14px;
}
.steps > li:last-child { padding-bottom: 2px; }
.steps > li::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--muted);
}
.steps > li:first-child::before { background: var(--accent); border-color: var(--accent); }
.step-role { font-weight: 500; color: var(--ink); margin-right: 10px; }
.step-when { font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.steps .org-desc { margin-top: 2px; }

.subhead {
  margin: 40px 0 6px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.subhead:first-child { margin-top: 0; }

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

.pubs {
  margin: 0;
  padding: 0;
  list-style: none;
}
.pub {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  column-gap: 20px;
  padding: 14px 0;
}
.pub + .pub { border-top: 1px dashed var(--rule); }

.venue {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
  padding-top: 5px;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}
.venue.is-pending { color: var(--muted); }

.pub-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.005em;
}
.pub-title a { text-decoration: none; }
.pub-title a:hover { text-decoration: underline; text-decoration-color: var(--accent); }

.pub-authors {
  margin: 4px 0 0;
  font-size: 14.5px;
  color: var(--ink-2);
}
.pub-authors .me {
  color: var(--ink);
  font-weight: 600;
}

.pub-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 8px;
  font-size: 13.5px;
}
.pub-meta a {
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.pub-meta a:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.tag.is-quiet { background: var(--surface); color: var(--ink-2); }

/* ---------- Photography ---------- */

.prose-lite-intro {
  margin: 0 0 20px;
  max-width: 66ch;
  color: var(--ink-2);
}

.photos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.photos a {
  display: block;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface);
  aspect-ratio: 4 / 5;
}
.photos img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s cubic-bezier(.2, .7, .2, 1), filter .3s ease;
}
.photos a:hover img { transform: scale(1.03); filter: brightness(1.04); }

/* ---------- Beyond research / writing ---------- */

.prose-lite p {
  margin: 0 0 14px;
  max-width: 66ch;
  color: var(--ink-2);
}

.nb { white-space: nowrap; }

.epigraph {
  margin: 28px 0 8px;
  padding: 0 0 0 18px;
  border-left: 2px solid var(--accent);
  max-width: 60ch;
}
.epigraph p {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  font-style: italic;
  line-height: 1.45;
  color: var(--ink);
}
.epigraph cite {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  font-style: normal;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.epigraph cite::before { content: "— "; }

.essays {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.essays li {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  column-gap: 20px;
  padding: 8px 0;
}
.essays .when { font-size: 14px; color: var(--muted); line-height: 1.9; font-variant-numeric: tabular-nums; }
.essays a {
  font-family: var(--serif);
  font-size: 17.5px;
  text-decoration: none;
}
.essays a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.essays .cat { display: block; font-size: 13px; color: var(--muted); }

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

.site-footer {
  margin-top: 24px;
  border-top: 1px solid var(--rule);
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  padding-top: 28px;
  padding-bottom: 48px;
  font-size: 13.5px;
  color: var(--muted);
}
.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--accent-ink); }

/* ---------- Article pages (essays, misc) ---------- */

.article {
  max-width: 700px;
  margin: 0 auto;
  padding: 64px 0 72px;
}
.back {
  display: inline-block;
  margin-bottom: 40px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
}
.back:hover { color: var(--accent-ink); }

.eyebrow {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.article h1 {
  margin: 0 0 40px;
  font-family: var(--serif);
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.018em;
}

.prose {
  font-family: var(--serif);
  font-size: 19.5px;
  line-height: 1.7;
  color: var(--ink);
}
.prose p { margin: 0 0 1.1em; }
.prose h2, .prose h3 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.25;
  margin: 1.8em 0 .6em;
}
.prose ul { padding-left: 1.2em; }
.prose li { margin: .3em 0; }
.prose blockquote {
  margin: 1.4em 0;
  padding-left: 1em;
  border-left: 2px solid var(--accent);
  color: var(--ink-2);
  font-style: italic;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
}
.pager a { text-decoration: none; display: block; }
.pager .eyebrow { margin-bottom: 4px; }
.pager .t { font-family: var(--serif); font-size: 18px; line-height: 1.35; }
.pager a:hover .t { color: var(--accent-ink); }
.pager .next { text-align: right; }

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

@media (max-width: 860px) {
  :root { --label-col: 140px; --col-gap: 36px; }
  .nav { gap: 18px; }
}

@media (max-width: 720px) {
  :root { --gutter: 16px; }
  body { font-size: 15.5px; }

  .nav { display: none; }

  .hero {
    grid-template-columns: 1fr;
    padding: 36px 0 44px;
  }
  .portrait {
    width: 112px;
    aspect-ratio: 1;
    border-radius: 50%;
    margin-bottom: 24px;
  }
  .portrait img {
    object-position: 49% 51%;
    transform: scale(2.6);
    transform-origin: 49% 51%;
  }
  .lede { font-size: 19px; }

  .section {
    grid-template-columns: 1fr;
    padding: 36px 0 40px;
  }

  .timeline > li,
  .pub,
  .essays li {
    grid-template-columns: 1fr;
    row-gap: 2px;
  }
  .timeline .when,
  .essays .when { line-height: 1.5; }
  .venue { padding-top: 0; }

  .article { padding: 40px 0 56px; }
  .prose { font-size: 18px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

@media print {
  .topbar, .site-footer, .nav { display: none; }
  body { background: #fff; color: #000; }
  .section { break-inside: avoid; }
}
