@font-face {
  font-family: "Ma Shan Zheng";
  src: url("../assets/fonts/ma-shan-zheng/MaShanZheng-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #121722;
  --muted: #667085;
  --line: #dce1e8;
  --accent: #2459d3;
  --accent-dark: #1743a5;
  --radius: 14px;
  --wrap: 1120px;
  --sans: "Segoe UI Variable Display", "Aptos Display", "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --art: "STKaiti", "KaiTi", "KaiTi_GB2312", "FangSong", "Noto Serif SC", Georgia, serif;
  --hand: "Ma Shan Zheng", "STXingkai", "KaiTi", cursive;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

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

button {
  font: inherit;
}

:focus-visible {
  outline: 3px solid rgba(36, 89, 211, 0.35);
  outline-offset: 3px;
}

.wrap,
.nav-shell {
  width: min(calc(100% - 48px), var(--wrap));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  top: -80px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: #ffffff;
}

.skip-link:focus {
  top: 16px;
}

/* Language */
.en {
  display: none;
}

body.english .zh {
  display: none;
}

body.english .en {
  display: revert;
}

/* Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 248, 250, 0.9);
  border-bottom: 1px solid rgba(220, 225, 232, 0.8);
  backdrop-filter: blur(14px);
}

.nav-shell {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand span {
  color: var(--muted);
  font-weight: 500;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 26px;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.site-header nav a:hover {
  color: var(--accent);
}

.language-button {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.menu-button {
  display: none;
  padding: 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.menu-button span {
  display: block;
  width: 22px;
  height: 2px;
  margin: 5px;
  background: var(--ink);
}

/* Hero */
.hero {
  min-height: calc(100dvh - 68px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 72px;
  align-items: center;
  padding-block: 72px;
}

.kicker,
.section-label {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.kicker {
  margin: 0 0 24px;
}

.hero h1,
.about h2,
.blog-heading h2,
.blog-entry-content h3,
.footer-title,
.article-header h1 {
  font-family: var(--art);
  font-weight: 500;
  text-wrap: balance;
}

.hero h1 {
  max-width: 780px;
  margin: 0 0 28px;
  font-size: clamp(48px, 6.4vw, 82px);
  line-height: 1.12;
  letter-spacing: -0.025em;
}

body.english .hero h1,
body.english .about h2,
body.english .blog-heading h2,
body.english .blog-entry-content h3,
body.english .footer-title {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.035em;
}

.hero-intro {
  max-width: 590px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 36px;
}

.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.button.primary {
  padding-inline: 22px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.portrait {
  width: 260px;
  margin: 0;
  justify-self: end;
}

.portrait img {
  width: 260px;
  height: 260px;
  object-fit: cover;
  object-position: 58% 48%;
  border: 6px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 18px 50px rgba(23, 40, 70, 0.12);
  filter: saturate(0.82) contrast(1.03);
}

/* Shared sections */
.section {
  padding-block: 112px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 68px;
}

.section-label {
  margin-bottom: 42px;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10vw;
}

.about h2,
.blog-heading h2 {
  margin: 0;
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.prose {
  color: var(--muted);
  font-size: 17px;
}

.prose p:first-child {
  margin-top: 0;
}

.inline-links {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 30px;
}

.inline-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

/* Research */
.research-list,
.timeline {
  border-top: 1px solid var(--ink);
}

.research-item {
  position: relative;
  display: grid;
  grid-template-columns: 180px 1fr 40px;
  gap: 28px;
  padding: 34px 0;
  border-bottom: 1px solid var(--line);
}

.research-meta {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-weight: 700;
}

.status {
  margin-top: 5px;
  color: var(--accent);
  font-weight: 600;
}

.research-item h3 {
  margin: 0 0 5px;
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -0.03em;
}

.research-item p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
}

.tags,
.paper-actions,
.blog-tags,
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tags {
  margin-top: 16px;
}

.tags span {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.paper-actions {
  margin-top: 18px;
}

.paper-actions a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-inline: 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.paper-actions a:hover {
  background: var(--accent);
  color: #ffffff;
  transform: translateY(-1px);
}

.paper-actions a:active {
  transform: none;
}

.item-index {
  color: #aab2bf;
  font-variant-numeric: tabular-nums;
}

/* Blog timeline */
.blog-section {
  background: #eef1f5;
}

.blog-heading {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 10vw;
  align-items: end;
  margin-bottom: 56px;
}

.blog-heading .section-label {
  margin-bottom: 24px;
}

.blog-heading > p {
  margin: 0;
  color: var(--muted);
}

.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 40px;
}

.blog-filter {
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.blog-filter:hover,
.blog-filter.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.blog-timeline {
  position: relative;
}

.blog-timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 114px;
  width: 1px;
  background: var(--line);
}

.blog-entry {
  position: relative;
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 48px;
  padding-bottom: 54px;
}

.blog-entry::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 108px;
  z-index: 1;
  width: 11px;
  height: 11px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #eef1f5;
}

.blog-entry[hidden] {
  display: none;
}

.blog-entry time {
  display: flex;
  flex-direction: column;
  color: var(--ink);
  text-align: right;
  font-size: 20px;
  font-weight: 750;
  line-height: 1.1;
}

.blog-entry time small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.blog-entry-content {
  position: relative;
  display: block;
  padding: 0 52px 32px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.blog-tags > span,
.article-tags span {
  padding: 4px 10px;
  border: 1px solid #b9c8ec;
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.blog-entry-content h3 {
  margin: 12px 0 10px;
  font-size: clamp(25px, 3vw, 36px);
  line-height: 1.28;
  letter-spacing: -0.025em;
}

.blog-entry-content p {
  margin: 0;
  color: var(--muted);
}

.blog-arrow {
  position: absolute;
  top: 2px;
  right: 4px;
  color: var(--accent);
  font-size: 22px;
  transition: transform 0.2s ease;
}

.blog-entry-content:hover .blog-arrow {
  transform: translate(3px, -3px);
}

/* Education */
.timeline-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-row time {
  color: var(--accent);
  font-weight: 700;
}

.timeline-row h3 {
  margin: 0 0 4px;
  font-size: 20px;
}

.timeline-row p {
  margin: 0;
  color: var(--muted);
}

/* Footer */
.site-footer {
  padding: 70px 0;
  background: var(--ink);
  color: #ffffff;
}

.footer-grid {
  display: flex;
  justify-content: space-between;
  gap: 40px;
}

.footer-contact-block {
  max-width: 620px;
}

.footer-title {
  margin: 0 0 20px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.footer-contact {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  color: #ffffff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
}

.footer-contact-arrow {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #596170;
  border-radius: 50%;
  color: #a9c1ff;
  font-size: 18px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.footer-contact:hover .footer-contact-arrow {
  background: #ffffff;
  color: var(--ink);
  transform: translate(2px, -2px);
}

.footer-meta {
  color: #aeb5c2;
  text-align: right;
}

/* Article pages */
.article-main {
  padding: 80px 0 120px;
}

.article-shell {
  width: min(calc(100% - 48px), 760px);
  margin-inline: auto;
}

.article-back {
  display: inline-block;
  margin-bottom: 64px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.article-header {
  margin-bottom: 48px;
  padding-bottom: 42px;
  border-bottom: 1px solid var(--line);
}

.article-header time {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.article-tags {
  margin-top: 18px;
}

.article-header h1 {
  margin: 18px 0 22px;
  font-size: clamp(42px, 7vw, 72px);
  line-height: 1.22;
  letter-spacing: -0.015em;
}

.article-lead,
.article-body {
  font-family: var(--hand);
  font-weight: 400;
}

.article-lead {
  margin: 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1.8;
  letter-spacing: 0.025em;
}

.article-body {
  font-size: 21px;
  line-height: 2.12;
  letter-spacing: 0.025em;
}

.article-body p {
  margin: 0 0 1.55em;
  text-align: justify;
  text-justify: inter-ideograph;
}

.article-body strong {
  color: var(--accent);
  font-weight: 400;
}

.article-body .standalone {
  margin: 2.2em 0;
  font-size: 30px;
  line-height: 1.5;
  letter-spacing: 0.035em;
  text-align: left;
}

.article-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 72px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

/* Motion */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

/* Responsive */
@media (max-width: 800px) {
  .wrap,
  .nav-shell {
    width: min(calc(100% - 32px), var(--wrap));
  }

  .menu-button {
    display: block;
  }

  .site-header nav {
    position: absolute;
    top: 68px;
    right: 0;
    left: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    padding: 22px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
  }

  .site-header nav.open {
    display: flex;
  }

  .article-page .site-header nav {
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 36px;
    padding-block: 54px;
  }

  .portrait {
    width: 190px;
    grid-row: 1;
    justify-self: start;
  }

  .portrait img {
    width: 190px;
    height: 190px;
  }

  .hero h1 {
    font-size: clamp(43px, 13vw, 64px);
  }

  .section {
    padding-block: 78px;
  }

  .about-grid,
  .blog-heading {
    grid-template-columns: 1fr;
    gap: 34px;
  }

  .research-item {
    grid-template-columns: 1fr;
    padding: 28px 0;
  }

  .item-index {
    position: absolute;
    top: 30px;
    right: 0;
  }

  .blog-timeline::before {
    left: 15px;
  }

  .blog-entry {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-left: 42px;
  }

  .blog-entry::before {
    top: 7px;
    left: 9px;
  }

  .blog-entry time {
    display: block;
    text-align: left;
    font-size: 15px;
  }

  .blog-entry time span,
  .blog-entry time small {
    display: inline;
    font-size: 13px;
  }

  .blog-entry time small::before {
    content: " · ";
  }

  .blog-entry-content {
    padding-right: 34px;
  }

  .timeline-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .footer-grid {
    flex-direction: column;
  }

  .footer-meta {
    text-align: left;
  }

  .article-main {
    padding: 50px 0 80px;
  }

  .article-shell {
    width: min(calc(100% - 32px), 760px);
  }

  .article-back {
    margin-bottom: 44px;
  }

  .article-header h1 {
    font-size: clamp(38px, 11vw, 54px);
  }

  .article-lead {
    font-size: 20px;
  }

  .article-body {
    font-size: 19px;
    line-height: 2;
  }

  .article-body p {
    text-align: left;
  }

  .article-body .standalone {
    font-size: 27px;
  }

  .article-footer {
    flex-direction: column;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
