/* Quiet academic — typography-led, content-first */

:root {
  --bg: #f3f5f7;
  --ink: #14171c;
  --ink-soft: #4d5560;
  --ink-faint: #7e8794;
  --line: rgba(28, 40, 56, 0.12);
  --accent: #2a4a5e;
  --accent-hover: #163445;
  --max: 54rem;
  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --sans: "Source Sans 3", "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.65;
  font-weight: 400;
  background-color: var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/*
  Background themes — set on <body class="bg-…">
  Default: ink wash (quiet cool depth, no pattern)
  Also: bg-porcelain | bg-hairline | bg-draft
*/

/* A — ink wash (default): soft cool depth only */
body,
body.bg-wash {
  background-image:
    radial-gradient(ellipse 95% 65% at 8% -10%, rgba(42, 74, 94, 0.04), transparent 55%),
    radial-gradient(ellipse 70% 45% at 100% 105%, rgba(42, 74, 94, 0.028), transparent 50%),
    linear-gradient(180deg, #f7f8fa 0%, var(--bg) 48%, #eef1f4 100%);
}

/* B — porcelain: near-flat cool white, soft edge vignette */
body.bg-porcelain {
  --bg: #f6f7f9;
  background-image:
    radial-gradient(ellipse 120% 90% at 50% 40%, transparent 55%, rgba(28, 40, 56, 0.035) 100%),
    linear-gradient(180deg, #fafbfc 0%, #f4f6f8 100%);
}

/* C — hairline: extremely faint major graph only */
body.bg-hairline {
  --bg: #f2f4f6;
  background-image:
    radial-gradient(ellipse 90% 60% at 10% -8%, rgba(42, 74, 94, 0.035), transparent 55%),
    linear-gradient(rgba(42, 74, 94, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 74, 94, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, #f7f8fa 0%, var(--bg) 100%);
  background-size: auto, 72px 72px, 72px 72px, auto;
}

/* D — draft: quieter version of the previous graph + lattice */
body.bg-draft {
  --bg: #eef1f5;
  background-image:
    radial-gradient(ellipse 85% 55% at 6% -6%, rgba(42, 74, 94, 0.05), transparent 58%),
    radial-gradient(ellipse 60% 40% at 98% 0%, rgba(20, 36, 52, 0.03), transparent 52%),
    linear-gradient(rgba(42, 74, 94, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 74, 94, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(42, 74, 94, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 74, 94, 0.05) 1px, transparent 1px),
    linear-gradient(165deg, #f6f8fb 0%, var(--bg) 42%, #e8edf2 100%);
  background-size:
    auto, auto,
    20px 20px, 20px 20px,
    100px 100px, 100px 100px,
    auto;
}

body.bg-draft::before {
  content: "";
  opacity: 0.28;
  background:
    repeating-linear-gradient(
      60deg,
      transparent 0,
      transparent 47px,
      rgba(42, 74, 94, 0.03) 47px,
      rgba(42, 74, 94, 0.03) 48px
    ),
    repeating-linear-gradient(
      -60deg,
      transparent 0,
      transparent 47px,
      rgba(42, 74, 94, 0.03) 47px,
      rgba(42, 74, 94, 0.03) 48px
    );
}

::selection {
  background: rgba(42, 74, 92, 0.18);
}

.page {
  position: relative;
  z-index: 1;
  width: min(100% - 2.5rem, var(--max));
  margin: 0 auto;
  padding: 3.5rem 0 4rem;
}

/* —— Hero —— */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.75rem 2rem;
  align-items: end;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--line);
  opacity: 0;
  transform: translateY(10px);
  animation: rise 0.7s ease forwards;
}

.hero-text {
  min-width: 0;
}

.hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.6rem, 7vw, 3.4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.hero .zh {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.hero .role {
  margin: 1.1rem 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.45;
}

.hero .role strong {
  color: var(--ink);
  font-weight: 500;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin: 1.15rem 0 0;
  padding: 0;
  list-style: none;
}

.links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0 1px;
  transition: background-size 0.25s ease, color 0.2s ease;
}

.links a:hover,
.links a:focus-visible {
  color: var(--accent-hover);
  background-size: 100% 1px;
}

.portrait {
  width: 7.5rem;
  height: 7.5rem;
  object-fit: cover;
  border-radius: 50%;
  filter: grayscale(18%) contrast(1.02);
  box-shadow: 0 0 0 1px var(--line);
  opacity: 0;
  transform: scale(0.96);
  animation: fade-scale 0.8s ease 0.15s forwards;
}

/* —— Nav —— */
.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.35rem;
  margin: 1.35rem 0 2.75rem;
  opacity: 0;
  animation: rise 0.7s ease 0.12s forwards;
}

.toc a {
  color: var(--ink-faint);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.2s ease;
}

.toc a:hover,
.toc a:focus-visible {
  color: var(--ink);
}

/* —— Sections —— */
.section {
  margin-bottom: 2.75rem;
  opacity: 0;
  transform: translateY(8px);
  animation: rise 0.65s ease forwards;
}

.section:nth-of-type(1) { animation-delay: 0.18s; }
.section:nth-of-type(2) { animation-delay: 0.26s; }
.section:nth-of-type(3) { animation-delay: 0.34s; }
.section:nth-of-type(4) { animation-delay: 0.42s; }
.section:nth-of-type(5) { animation-delay: 0.5s; }

.section h2 {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.section p {
  margin: 0 0 1rem;
  color: var(--ink);
}

.interests {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.85rem;
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.interests li::before {
  content: "·";
  margin-right: 0.55rem;
  color: var(--ink-faint);
}

.interests li:first-child::before {
  content: none;
  margin: 0;
}

/* —— Publications —— */
.pub-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: pub;
}

.pub-list > li {
  position: relative;
  display: grid;
  grid-template-columns: 11.5rem minmax(0, 1fr);
  gap: 0.95rem 1.25rem;
  align-items: start;
  padding: 1.15rem 0 1.15rem 1.85rem;
  border-top: 1px solid var(--line);
  counter-increment: pub;
}

.pub-list > li:last-child {
  border-bottom: 1px solid var(--line);
}

.pub-list > li::before {
  content: counter(pub);
  position: absolute;
  left: 0;
  top: 1.25rem;
  color: var(--ink-faint);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.pub-thumb {
  width: 11.5rem;
  aspect-ratio: 16 / 10;
  height: auto;
  object-fit: cover;
  object-position: center;
  border-radius: 2px;
  background: #eef0f3;
}

.pub-thumb--empty {
  display: block;
  width: 11.5rem;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #e8eaee 0%, #dfe3e8 100%);
}

.pub-body {
  min-width: 0;
}

.pub-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
}

.pub-meta {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}

.pub-meta .me {
  font-weight: 600;
  color: var(--ink);
}

.pub-meta .venue {
  font-style: italic;
}

.pub-meta .badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: 0.08em;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  margin: 0.45rem 0 0;
  padding: 0;
  list-style: none;
}

.pub-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
}

.pub-links a:hover,
.pub-links a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.inline-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.inline-link:hover,
.inline-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.pub-note {
  color: var(--ink-faint);
  font-size: 0.9em;
  font-weight: 400;
}

/* —— Plain lists (projects / awards / experience) —— */
.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain-list > li {
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}

.plain-list > li:last-child {
  border-bottom: 1px solid var(--line);
}

#project-list > li {
  padding: 1.05rem 0;
}

.project-item {
  display: grid;
  grid-template-columns: 16.5rem minmax(0, 1fr);
  gap: 1rem 1.35rem;
  align-items: center;
}

.project-thumb {
  width: 16.5rem;
  aspect-ratio: 16 / 10;
  height: auto;
  object-fit: cover;
  object-position: center;
  border-radius: 2px;
  background: #eef0f3;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.project-item:hover .project-thumb {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(23, 24, 26, 0.08);
}

.project-thumb--empty {
  display: block;
  width: 16.5rem;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #e8eaee 0%, #dfe3e8 100%);
}

.project-body {
  min-width: 0;
}

.item-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  align-items: baseline;
}

.item-head a,
.item-title {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}

.item-head a:hover,
.item-head a:focus-visible {
  color: var(--accent);
}

.item-time {
  color: var(--ink-faint);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.item-sub {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.item-note {
  margin: 0.25rem 0 0;
  color: var(--ink-faint);
  font-size: 0.9rem;
}

.exp-block + .exp-block {
  margin-top: 1.75rem;
}

.exp-block h3 {
  margin: 0 0 0.65rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* —— Footer —— */
.footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.footer p {
  margin: 0;
}

/* —— Motion —— */
@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-scale {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .hero,
  .toc,
  .section,
  .portrait {
    opacity: 1;
    transform: none;
  }
}

/* —— Responsive —— */
@media (max-width: 560px) {
  .page {
    width: min(100% - 1.75rem, var(--max));
    padding-top: 2.25rem;
  }

  .hero {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .portrait {
    order: -1;
    width: 5.75rem;
    height: 5.75rem;
  }

  .pub-list > li {
    grid-template-columns: 7.5rem minmax(0, 1fr);
    gap: 0.75rem;
    padding-left: 1.5rem;
  }

  .pub-thumb,
  .pub-thumb--empty {
    width: 7.5rem;
  }

  .project-item {
    grid-template-columns: 1fr;
  }

  .project-thumb,
  .project-thumb--empty {
    width: 100%;
  }
}
