:root {
  color-scheme: light;
  --blue: #276fb4;
  --blue-dark: #174f83;
  --text: #171717;
  --muted: #666b73;
  --faint: #8a9098;
  --line: #e4e7eb;
  --line-strong: #cfd5dc;
  --surface: #f6f7f8;
  --paper: #ffffff;
  --yellow: #d49a25;
  --font: "Lato", Verdana, Helvetica, "PingFang SC", "Noto Sans CJK SC",
    sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--paper);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.35;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover, a:focus-visible { color: var(--blue-dark); text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, [tabindex="0"]:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 8px 12px;
  color: #fff;
  background: var(--blue-dark);
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

.skip-link:focus { transform: translateY(0); }

.page-shell, .site-footer { width: min(920px, calc(100% - 40px)); margin: 0 auto; }
.page-shell { padding: 32px 0 64px; }
.main-column, main { min-width: 0; }

.site-nav {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  margin-bottom: 46px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.site-nav a { color: var(--muted); }
.site-nav a:hover, .site-nav a:focus-visible, .site-nav a.active { color: var(--text); text-decoration: none; }
.site-nav a.active { font-weight: 700; }

.panel { margin: 0; padding: 0; background: transparent; border: 0; box-shadow: none; }
.panel + .panel, .post-section { margin-top: 54px; }

.section-label, .filter-eyebrow, .post-kicker {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-title, .panel-title, .filter-heading h1 {
  margin: 0 0 20px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.hero-title { font-size: 32px; }
.panel-title, .filter-heading h1 { font-size: 22px; }

.about-copy p, .research-origin, .research-intro, .news-item p { margin: 0 0 14px; }
.about-copy .intro-line { font-size: 14px; }
.person-name, .chinese-name { font-weight: 700; }
.person-link { color: var(--blue); font-weight: 600; }
.institution-link, .lab-link { color: var(--blue); }
.lab-name { color: var(--text); }

/* Home */
.home-page .page-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 245px;
  grid-template-rows: auto auto;
  gap: 0 52px;
}

.home-page .main-column { display: contents; }
.home-page .site-nav { grid-column: 1 / -1; grid-row: 1; }
.home-page main { grid-column: 1; grid-row: 2; }
.home-page .profile-column { grid-column: 2; grid-row: 2; }
.profile-card { text-align: center; }

.portrait-frame {
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--surface);
  border-radius: 8px;
}

.portrait-frame img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: 50% 43%; }
.portrait-caption { margin: 10px 0 0; color: var(--muted); font-size: 0.72rem; line-height: 1.45; text-align: left; }

.profile-quote {
  margin: 18px 0 12px;
  color: #3f4349;
  font-family: var(--serif);
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.5;
}

.profile-links { display: flex; justify-content: center; gap: 12px; }
.profile-icon-link { width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 50%; }
.profile-icon-link:hover, .profile-icon-link:focus-visible { color: var(--blue); border-color: var(--blue); text-decoration: none; }

.profile-icon {
  width: 14px;
  height: 14px;
  display: block;
  background: currentColor;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

.profile-icon-github { mask-image: url("assets/mark-github-16.svg"); -webkit-mask-image: url("assets/mark-github-16.svg"); }
.profile-icon-mail { mask-image: url("assets/mail-16.svg"); -webkit-mask-image: url("assets/mail-16.svg"); }
.news-panel { padding-top: 4px; }
.news-panel .panel-title { margin-bottom: 12px; }

.news-item {
  display: flex;
  gap: 14px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.news-label { flex: 0 0 auto; color: var(--muted); font-size: 0.78rem; }
.news-item p { margin: 0; }
.research-origin { max-width: 64ch; }
.research-intro { color: var(--muted); }

.research-list {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.research-list li { position: relative; padding: 17px 38px 17px 0; border-bottom: 1px solid var(--line); }
.research-list h3 { margin: 0; font-size: 1rem; font-weight: 600; }

/* Secondary pages */
.posts-page .page-shell, .publications-page .page-shell { width: min(900px, calc(100% - 40px)); }
.posts-page .profile-column, .publications-page .profile-column { display: none; }

.filter-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 44px;
}

.filter-heading h1 { margin-bottom: 0; font-size: 32px; }
.filter-controls { display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: 6px; overflow-x: auto; }

.filter-button, .pagination-button {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.filter-button { flex: 0 0 auto; padding: 6px 10px; border-radius: 999px; font-size: 0.75rem; }
.filter-button:hover, .filter-button:focus-visible, .filter-button.is-active { color: #fff; background: var(--blue); border-color: var(--blue); }
.projects-section-bare { margin-top: 0; }
.section-heading { position: relative; margin-bottom: 4px; }
.section-heading .panel-title { margin-bottom: 0; }
.post-list { display: grid; }
.post-card { position: relative; padding: 28px 0; border-top: 1px solid var(--line); }
.post-card[hidden], .filter-empty[hidden] { display: none; }

.project-feature-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  grid-template-areas: "title visual" "copy visual";
  gap: 12px 34px;
  align-items: start;
}

.project-feature-title, .project-card > h3 {
  grid-area: title;
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

.project-feature-copy { grid-area: copy; min-width: 0; }
.project-category-labels { display: flex; flex-wrap: wrap; gap: 6px; }

.project-category-label {
  width: fit-content;
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.project-category-labels .project-category-label { margin-bottom: 0; }
.project-sublist { margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; list-style: none; }
.project-sublist li { position: relative; }
.project-sublist h4 { margin: 0; font-size: 0.82rem; font-weight: 500; }
.project-link, .project-title-link { color: var(--blue); }

.project-visual {
  grid-area: visual;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #07101d;
}

.project-visual, .project-visual img, .project-visual-animated { width: 100%; aspect-ratio: 3 / 2; }
.project-visual img { height: 100%; display: block; object-fit: cover; }

.project-compact-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; }
.project-compact-card > h3 { grid-area: auto; font-size: 1.02rem; }

.project-pagination { margin-top: 24px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.project-pagination[hidden] { display: none; }
.pagination-pages { display: flex; gap: 6px; }
.pagination-button { min-width: 34px; min-height: 34px; padding: 5px 10px; border-radius: 4px; font-size: 0.75rem; }
.pagination-button:hover:not(:disabled), .pagination-button:focus-visible, .pagination-button.is-active { color: #fff; background: var(--blue); border-color: var(--blue); }
.pagination-button:disabled { opacity: 0.38; cursor: default; }
.filter-empty { padding: 28px 0; color: var(--muted); border-top: 1px solid var(--line); }
.post-card-empty { color: var(--muted); }
.post-card-empty h3 { color: var(--text); }

/* Lightweight hover descriptions */
.hover-dialog-card { position: relative; }

.hover-dialog-card::after {
  content: "i";
  position: absolute;
  top: 17px;
  right: 4px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: var(--faint);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 0.72rem;
  font-style: italic;
}

.section-heading.hover-dialog-card::after { top: 4px; }
.project-sublist .hover-dialog-card::after { display: none; }

.hover-dialog {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  padding: 12px 14px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  box-shadow: 0 10px 28px rgba(20, 32, 45, 0.12);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-5px);
  transition: opacity 220ms ease, transform 260ms var(--ease-out), visibility 0s linear 260ms;
}

.hover-dialog p { margin: 0; font-size: 0.8rem; line-height: 1.5; }
.section-heading > .hover-dialog { top: auto; right: auto; bottom: calc(100% + 8px); width: min(520px, 100%); }

.hover-dialog-card:hover > .hover-dialog,
.hover-dialog-card:focus > .hover-dialog,
.hover-dialog-card:focus-within > .hover-dialog {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 80ms, 80ms, 0s;
}

/* Project animation layers */
.project-animation { position: relative; width: 100%; height: 100%; overflow: hidden; isolation: isolate; background: #07101d; }

.project-animation .animation-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: transparent;
  will-change: opacity, transform, clip-path;
}

.geodesic-landscape-base { z-index: 1; clip-path: inset(0 50% 0 0); }
.geodesic-manifold-base { z-index: 2; opacity: 0; clip-path: inset(0 48% 0 52%); }
.geodesic-motion-layer { position: absolute; z-index: 3; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.geodesic-drawn-path, .geodesic-map-arrow path {
  fill: none;
  stroke: #07101b;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.geodesic-drawn-path { stroke-width: 5; stroke-dasharray: 1; stroke-dashoffset: 1; }
.geodesic-point { fill: #07101b; opacity: 0; transform-box: fill-box; transform-origin: center; }
.geodesic-map-arrow { color: #f4c94c; opacity: 0; transform-box: fill-box; transform-origin: center; }
.geodesic-map-arrow path { stroke: currentColor; stroke-width: 6; }

.project-card.is-animating .geodesic-landscape-path { animation: geodesic-left-path 7.2s linear infinite both; }
.project-card.is-animating .geodesic-landscape-start { animation: geodesic-left-start 7.2s ease infinite both; }
.project-card.is-animating .geodesic-landscape-end { animation: geodesic-left-end 7.2s ease infinite both; }
.project-card.is-animating .geodesic-map-arrow { animation: geodesic-arrow-sequence 7.2s var(--ease-out) infinite both; }
.project-card.is-animating .geodesic-manifold-base { animation: geodesic-manifold-reveal 7.2s var(--ease-out) infinite both; }
.project-card.is-animating .geodesic-manifold-path { animation: geodesic-right-path 7.2s linear infinite both; }
.project-card.is-animating .geodesic-manifold-start { animation: geodesic-right-start 7.2s ease infinite both; }
.project-card.is-animating .geodesic-manifold-end { animation: geodesic-right-end 7.2s ease infinite both; }

@keyframes geodesic-left-path {
  0%, 2% { opacity: 0; stroke-dashoffset: 1; }
  4% { opacity: 1; stroke-dashoffset: 1; }
  29%, 95% { opacity: 1; stroke-dashoffset: 0; }
  100% { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes geodesic-left-start {
  0%, 2% { opacity: 0; transform: scale(0.5); }
  4%, 95% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

@keyframes geodesic-left-end {
  0%, 27% { opacity: 0; transform: scale(0.5); }
  30%, 95% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

@keyframes geodesic-arrow-sequence {
  0%, 33% { opacity: 0; transform: translateX(-12px) scale(0.9); }
  41%, 95% { opacity: 1; transform: translateX(0) scale(1); }
  100% { opacity: 0; transform: translateX(0) scale(1); }
}

@keyframes geodesic-manifold-reveal {
  0%, 43% { opacity: 0; clip-path: inset(0 48% 0 52%); }
  63%, 95% { opacity: 1; clip-path: inset(0 0 0 52%); }
  100% { opacity: 0; clip-path: inset(0 0 0 52%); }
}

@keyframes geodesic-right-path {
  0%, 65% { opacity: 0; stroke-dashoffset: 1; }
  67% { opacity: 1; stroke-dashoffset: 1; }
  91%, 95% { opacity: 1; stroke-dashoffset: 0; }
  100% { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes geodesic-right-start {
  0%, 65% { opacity: 0; transform: scale(0.5); }
  67%, 95% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

@keyframes geodesic-right-end {
  0%, 89% { opacity: 0; transform: scale(0.5); }
  92%, 95% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

.lowdim-data-layer { z-index: 1; }
.lowdim-people-layer { z-index: 2; opacity: 0; }
.lowdim-pulled-layer { z-index: 3; opacity: 0; }
.lowdim-arrow-layer { z-index: 4; opacity: 0; }
.lowdim-manifold-layer { z-index: 5; opacity: 0; }
.project-card.is-animating .lowdim-people-layer { animation: lowdim-people-sequence 9s var(--ease-out) infinite both; }
.project-card.is-animating .lowdim-pulled-layer { animation: lowdim-pulled-sequence 9s var(--ease-out) infinite both; }
.project-card.is-animating .lowdim-arrow-layer { animation: lowdim-arrow-sequence 9s var(--ease-out) infinite both; }
.project-card.is-animating .lowdim-manifold-layer { animation: lowdim-manifold-sequence 9s var(--ease-out) infinite both; }

@keyframes lowdim-people-sequence {
  0% { opacity: 0; }
  2% { opacity: 0.2; }
  12%, 91% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes lowdim-pulled-sequence {
  0%, 22% { opacity: 0; }
  40%, 91% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes lowdim-arrow-sequence {
  0%, 44% { opacity: 0; }
  58%, 91% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes lowdim-manifold-sequence {
  0%, 60% { opacity: 0; }
  74%, 91% { opacity: 1; }
  100% { opacity: 0; }
}

.site-footer {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--faint);
  border-top: 1px solid var(--line);
  font-size: 0.76rem;
}

.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); }

@media (max-width: 760px) {
  .page-shell, .posts-page .page-shell, .publications-page .page-shell, .site-footer { width: min(100% - 28px, 620px); }
  .page-shell { padding-top: 20px; }
  .site-nav { justify-content: flex-start; margin-bottom: 34px; overflow-x: auto; }
  .home-page .page-shell { display: flex; flex-direction: column; }
  .home-page .main-column { display: contents; }
  .home-page .site-nav { order: 1; }
  .home-page .profile-column { order: 2; width: min(100%, 300px); margin: 0 auto 40px; }
  .home-page main { order: 3; }
  .filter-panel { display: block; }
  .filter-controls { justify-content: flex-start; margin-top: 20px; padding-bottom: 4px; }
  .project-feature-card { grid-template-columns: 1fr; grid-template-areas: "title" "copy" "visual"; }
  .project-visual { width: min(100%, 420px); margin-top: 8px; }
  .project-compact-card { grid-template-columns: 1fr; gap: 9px; }
}

@media (hover: none) {
  .geodesic-manifold-base { opacity: 1; clip-path: inset(0 0 0 52%); }
  .geodesic-drawn-path { opacity: 1; stroke-dashoffset: 0; }
  .geodesic-point, .geodesic-map-arrow, .lowdim-manifold-layer { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
  .geodesic-manifold-base { opacity: 1 !important; clip-path: inset(0 0 0 52%) !important; }
  .geodesic-drawn-path { opacity: 1 !important; stroke-dashoffset: 0 !important; }
  .geodesic-point, .geodesic-map-arrow, .lowdim-manifold-layer { opacity: 1 !important; transform: none !important; }
}
