/* ==========================================================
   Zanxi Ruan — personal homepage
   Quiet, Google Sans, light blue · light / dark
   ========================================================== */

:root {
  --bg: #fcfdff;
  --card: #f4f7fb;
  --ink: #222a36;
  --ink-2: #434b58;
  --muted: #6c7583;
  --faint: #9ba3ae;
  --hairline: #e4e9f0;
  --link: #3d7cc0;

  --accent: #7fb6ea;
  --accent-ink: #3d7cc0;
  --accent-soft: #edf5fd;

  --header-bg: rgba(252, 253, 255, 0.8);
  --badge-bg: rgba(255, 255, 255, 0.88);
  --badge-ink: #222a36;
  --shadow: 0 8px 28px rgba(34, 42, 54, 0.07);

  --font: "Google Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 20px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10141a;
    --card: #1a2029;
    --ink: #eef2f7;
    --ink-2: #cfd6df;
    --muted: #9ea7b3;
    --faint: #6f7884;
    --hairline: #28303b;
    --link: #9ccbf5;
    --accent-ink: #9ccbf5;
    --accent-soft: rgba(127, 182, 234, 0.12);
    --header-bg: rgba(16, 20, 26, 0.8);
    --badge-bg: rgba(26, 32, 41, 0.85);
    --badge-ink: #eef2f7;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #10141a;
  --card: #1a2029;
  --ink: #eef2f7;
  --ink-2: #cfd6df;
  --muted: #9ea7b3;
  --faint: #6f7884;
  --hairline: #28303b;
  --link: #9ccbf5;
  --accent-ink: #9ccbf5;
  --accent-soft: rgba(127, 182, 234, 0.12);
  --header-bg: rgba(16, 20, 26, 0.8);
  --badge-bg: rgba(26, 32, 41, 0.85);
  --badge-ink: #eef2f7;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

/* ---------- Base ---------- */

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

::selection {
  background: rgba(127, 182, 234, 0.3);
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

strong {
  color: var(--ink);
  font-weight: 700;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}

.site-header nav {
  width: min(1080px, calc(100% - 44px));
  height: 54px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 28px;
}

.site-header .site-name {
  margin-right: auto;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.site-header .site-name:hover {
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-links a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: color 0.2s var(--ease);
}

.nav-links a:hover {
  color: var(--ink);
  text-decoration: none;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.theme-toggle:hover {
  background: var(--card);
  color: var(--ink);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Layout ---------- */

.page-shell {
  width: min(1080px, calc(100% - 44px));
  margin: 0 auto;
  padding: 72px 0 96px;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 72px;
  align-items: start;
}

/* ---------- Profile ---------- */

.profile {
  position: sticky;
  top: 100px;
  min-width: 0;
}

.profile .avatar {
  display: block;
  width: 160px;
  height: 160px;
  margin: 0 0 24px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow);
}

.profile-name {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.profile-name h1 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.profile-name .chinese {
  margin: 0;
  color: var(--faint);
  font-size: 15px;
}

.profile-role,
.profile-affiliation,
.profile-location {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.profile-role {
  margin-top: 10px;
  color: var(--ink);
  font-weight: 700;
}

.profile-affiliation,
.profile-location {
  color: var(--muted);
}

.location-note {
  display: block;
  color: var(--faint);
  font-size: 13px;
}

.profile-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.profile-links {
  display: grid;
  gap: 6px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
}

.profile-links a {
  width: max-content;
  font-size: 15px;
  font-weight: 600;
}

/* visitor globe */

.visitor-card {
  margin-top: 28px;
  padding: 16px 16px 14px;
  border-radius: var(--radius);
  background: var(--card);
}

.visitor-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.visitor-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.visitor-heading span {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.visitor-map {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.globe-ocean {
  fill: var(--bg);
  stroke: none;
}

.globe-grid {
  fill: none;
  stroke: var(--hairline);
  stroke-width: 0.6;
}

.globe-land {
  fill: var(--accent);
  opacity: 0.3;
}

.visitor-marker {
  fill: var(--accent-ink);
  stroke: var(--bg);
  stroke-width: 1.2;
}

.visitor-note {
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.45;
}

/* ---------- Content & headings ---------- */

.content {
  min-width: 0;
  max-width: 760px;
}

.content > section,
.content > .sec {
  margin: 0 0 88px;
  scroll-margin-top: 72px;
}

.sec-hd {
  margin: 0;
}

.section-title,
.sec-hd h2 {
  margin: 0 0 26px;
  color: var(--ink);
  font-size: 32px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

/* ---------- About ---------- */

.about-section p {
  margin: 0 0 18px;
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1.65;
}

.about-section .visit-opportunity {
  margin: 0 0 32px;
  padding: 20px 24px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 16.5px;
  line-height: 1.55;
}

.visit-opportunity .visit-label {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
}

.research-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 26px;
}

.research-tags span {
  padding: 6px 14px;
  border-radius: 980px;
  background: var(--card);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.about-personal {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(200px, 0.8fr);
  gap: 16px;
  margin-top: 30px;
}

.about-section .about-personal p {
  margin: 0;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.about-note-title {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

/* ---------- News ---------- */

.news-list {
  max-height: 440px;
  margin: 0;
  padding: 0 12px 0 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: var(--hairline) transparent;
  scrollbar-width: thin;
}

.news-item {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 24px;
  align-items: baseline;
  margin: 0;
  padding: 15px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 16px;
}

.news-item:first-child {
  padding-top: 0;
}

.news-item:last-child {
  border-bottom: 0;
}

.news-date {
  color: var(--faint);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.news-content {
  color: var(--ink-2);
  line-height: 1.55;
}

.brand-name span {
  color: var(--accent-ink);
}

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

.pub-list {
  display: grid;
  gap: 14px;
}

.pub-item {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
  margin: 0;
  padding: 22px;
  border-radius: 24px;
  background: var(--card);
  transition: background-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.pub-item:hover {
  background: var(--bg);
  box-shadow: var(--shadow);
}

.pub-thumb {
  position: relative;
  width: 210px;
  height: 132px;
  margin: 0;
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
}

.pub-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.venue-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 3px 3px 10px;
  border-radius: 980px;
  background: var(--badge-bg);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  box-shadow: 0 0 0 0.5px rgba(34, 42, 54, 0.08), 0 2px 8px rgba(34, 42, 54, 0.12);
  color: var(--badge-ink);
  line-height: 1;
  pointer-events: none;
}

.venue-badge strong,
.venue-badge span {
  white-space: nowrap;
}

.venue-badge strong {
  color: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.venue-badge span {
  padding: 3px 7px;
  border-radius: 980px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

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

.pub-title {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.015em;
}

.pub-authors {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.pub-authors strong {
  color: var(--accent-ink);
  font-weight: 700;
}

.author-note {
  margin: 0 0 4px;
  color: var(--faint);
  font-size: 12px;
}

.pub-venue {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.pub-venue .conf {
  color: var(--ink);
  font-weight: 700;
}

.pub-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
}

.ptag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  background: var(--bg);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.ptag-accept,
.ptag-q1 {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.pub-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn,
.pbtn {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 14px;
  border: 1px solid var(--hairline);
  border-radius: 980px;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 700;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.btn:hover,
.pbtn:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
}

.btn.active,
.pbtn.active {
  border-color: var(--accent-ink);
  background: var(--accent-ink);
  color: #fff;
}

.pub-expand {
  display: none;
  margin-top: 16px;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.65;
  animation: fade-in 0.25s var(--ease);
}

.pub-item:hover .pub-expand {
  background: var(--card);
}

.pub-expand p {
  margin: 0;
}

.pub-expand .expand-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.pub-expand pre {
  margin: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
}

/* ---------- Service ---------- */

.service-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.service-item {
  margin: 0;
  padding: 24px 26px;
  border-radius: var(--radius);
  background: var(--card);
}

.service-icon {
  display: none;
}

.service-body h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}

.service-body p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.service-item-recognition {
  grid-column: 1 / -1;
}

.recognition-list {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 48px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.recognition-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0;
}

.recognition-year {
  color: var(--faint);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.recognition-list strong,
.recognition-list small {
  display: block;
}

.recognition-list strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
}

.recognition-list small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

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

footer {
  margin: 0;
  padding: 22px 0 0;
  border-top: 1px solid var(--hairline);
  color: var(--faint);
  font-size: 13px;
}

footer p {
  margin: 0;
}

/* ---------- Image modal ---------- */

.image-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(34, 42, 54, 0.55);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.image-modal img {
  max-width: 92%;
  max-height: 90%;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
  cursor: zoom-out;
  animation: fade-in 0.3s var(--ease);
}

/* ---------- Reveal ---------- */

.reveal-item {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}

.reveal-item.is-visible {
  opacity: 1;
  transform: none;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@media (max-width: 960px) {
  .page-shell {
    grid-template-columns: 196px minmax(0, 1fr);
    gap: 48px;
  }

  .profile .avatar {
    width: 136px;
    height: 136px;
  }

  .pub-item {
    grid-template-columns: 176px minmax(0, 1fr);
    gap: 20px;
    padding: 18px;
  }

  .pub-thumb {
    width: 176px;
    height: 112px;
  }
}

@media (max-width: 700px) {
  body {
    font-size: 16px;
  }

  html {
    scroll-padding-top: 60px;
  }

  .site-header nav,
  .page-shell {
    width: calc(100% - 32px);
  }

  .site-header nav {
    height: 50px;
    gap: 12px;
  }

  .site-header .site-name {
    display: none;
  }

  .nav-links {
    flex: 1;
    justify-content: space-between;
    gap: 0;
  }

  .nav-links a {
    font-size: 13px;
  }

  .page-shell {
    display: block;
    padding: 36px 0 56px;
  }

  .profile {
    position: static;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 0 20px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--hairline);
  }

  .profile .avatar {
    grid-row: 1 / span 6;
    width: 96px;
    height: 96px;
    margin: 0;
  }

  .profile-name,
  .profile-role,
  .profile-affiliation,
  .profile-location,
  .profile-status,
  .profile-links {
    grid-column: 2;
  }

  .profile-name h1 {
    font-size: 24px;
  }

  .profile-role {
    margin-top: 6px;
  }

  .profile-status {
    margin-top: 10px;
  }

  .profile-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: 14px;
    padding-top: 12px;
  }

  .visitor-card {
    grid-column: 1 / -1;
    margin-top: 26px;
  }

  .visitor-map {
    max-width: 280px;
    margin: 0 auto;
  }

  .content {
    padding-top: 44px;
  }

  .content > section,
  .content > .sec {
    margin-bottom: 64px;
  }

  .section-title,
  .sec-hd h2 {
    font-size: 28px;
    margin-bottom: 22px;
  }

  .about-section p {
    font-size: 16.5px;
  }

  .about-section .visit-opportunity {
    padding: 18px 20px;
    font-size: 16px;
  }

  .about-personal {
    grid-template-columns: 1fr;
  }

  .news-list {
    max-height: none;
    padding-right: 0;
    overflow: visible;
  }

  .news-item {
    grid-template-columns: 1fr;
    gap: 4px;
    font-size: 15px;
  }

  .pub-item {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px 16px 20px;
  }

  .pub-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .pub-title {
    font-size: 17px;
  }

  .service-list {
    grid-template-columns: 1fr;
  }

  .service-item {
    padding: 22px;
  }

  .service-item-recognition {
    grid-column: auto;
  }

  .recognition-list {
    display: grid;
    gap: 12px;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
