/* ===========================================================
   Zhengyuan Liu — academic homepage
   Self-contained stylesheet (no framework)
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,500;0,8..60,600;0,8..60,700;1,8..60,400;1,8..60,500&display=swap');

:root {
  --bg:        #ffffff;
  --ink:       #16181d;
  --ink-soft:  #454851;
  --ink-faint: #7a7e88;
  --line:      #eae9e6;
  --line-soft: #f1f0ed;

  --accent:    #3a5a8c;   /* blue  */
  --accent-dk: #2c4468;
  --accent-bg: #eef2f8;

  --teal:      #1d8f78;
  --teal-bg:   #e6f4f0;
  --pink:      #c94f7c;
  --pink-bg:   #fbeef2;
  --pink-line: #f1d3de;

  --grad: linear-gradient(100deg, #3a5a8c 0%, #6a5ea8 42%, #c94f7c 100%);
  --max:  1000px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Source Serif 4', Charter, Georgia, 'Times New Roman', serif;
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "liga", "onum";
  overflow-x: hidden;
}

::selection { background: #e4d9ee; }

/* ---------- scroll progress ---------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: 60;
}
.scroll-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--grad);
  transition: width .1s linear;
}

/* ---------- sticky glass nav ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(20px, 5vw, 60px);
  background: rgba(255,255,255,.72);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, box-shadow .3s ease, background .3s ease;
}
.topnav.scrolled {
  border-bottom-color: var(--line);
  box-shadow: 0 6px 24px rgba(30,45,75,.06);
}
.topnav .brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  background-image: none;
}
.topnav .brand:hover { color: var(--accent); }
.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nav-links a {
  position: relative;
  color: var(--ink-soft);
  font-size: 0.96rem;
  padding: 6px 12px;
  border-radius: 8px;
  background-image: none;
  transition: color .2s ease, background-color .2s ease;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .28s cubic-bezier(.22,.61,.36,1);
}
.nav-links a:hover { color: var(--ink); }
.nav-links a:hover::after { transform: scaleX(1); }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 56px 32px 48px;
  counter-reset: section;
  position: relative;
}

/* ---------- links ---------- */
a {
  color: var(--accent);
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0% 1px;
  transition: background-size .25s ease, color .2s ease;
}
a:hover {
  color: var(--accent-dk);
  background-size: 100% 1px;
}

/* ---------- reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity .8s cubic-bezier(.22,.61,.36,1),
              transform .8s cubic-bezier(.22,.61,.36,1);
  will-change: opacity, transform;
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- header / intro ---------- */
.hero {
  position: relative;
  display: flex;
  gap: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 8px;
}
.hero-text { flex: 1 1 auto; min-width: 0; position: relative; z-index: 1; }

/* floating decorative orbs */
.orbs {
  position: absolute;
  inset: -60px -40px;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  opacity: .55;
}
.orb-1 {
  width: 260px; height: 260px;
  left: -60px; top: -40px;
  background: radial-gradient(circle at 30% 30%, #7f9bd0, #3a5a8c);
  animation: float1 14s ease-in-out infinite;
}
.orb-2 {
  width: 220px; height: 220px;
  right: 12%; top: -30px;
  background: radial-gradient(circle at 30% 30%, #f0a9c4, #c94f7c);
  opacity: .42;
  animation: float2 17s ease-in-out infinite;
}
.orb-3 {
  width: 200px; height: 200px;
  right: 4%; bottom: -60px;
  background: radial-gradient(circle at 30% 30%, #8fd6c5, #1d8f78);
  opacity: .40;
  animation: float3 20s ease-in-out infinite;
}
@keyframes float1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(24px,18px)} }
@keyframes float2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-22px,14px)} }
@keyframes float3 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-14px,-20px)} }

h1 {
  font-weight: 700;
  font-size: 3.2rem;
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0 0 14px;
  position: relative;
  padding-bottom: 12px;
}
.grad {
  background: var(--grad);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: hue 8s ease-in-out infinite;
}
@keyframes hue {
  0%,100% { background-position: 0% 0; }
  50%     { background-position: 100% 0; }
}
h1::after {
  content: "";
  position: absolute;
  left: 2px;
  bottom: 0;
  width: 70px;
  height: 4px;
  border-radius: 4px;
  background: var(--grad);
  background-size: 200% 100%;
  animation: hue 8s ease-in-out infinite;
}

.roles {
  color: var(--ink-soft);
  font-size: 1.0rem;
  line-height: 1.45;
  margin: 0 0 14px;
}
.roles span { display: block; }
.roles .senior { color: var(--ink-faint); font-size: 0.95rem; margin-top: 4px; }

.social {
  font-size: 0.8rem;
  margin: 0 0 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.social a {
  white-space: nowrap;
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background-image: none;
  color: var(--ink-soft);
  transition: border-color .2s ease, background-color .2s ease, color .2s ease, transform .2s ease;
}
.social a:hover {
  border-color: transparent;
  background: var(--accent-bg);
  color: var(--accent-dk);
  transform: translateY(-2px);
}

.quote {
  margin: 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--accent-bg);
  color: var(--ink-faint);
  font-style: italic;
  font-size: 1.0rem;
}

/* portrait */
.portrait {
  flex: 0 0 auto;
  width: 200px;
  height: 200px;
  position: relative;
  z-index: 1;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 14px 38px rgba(30,45,75,.20);
}
.portrait img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 0%;
  transform: scale(1.1);
  display: block;
  transition: transform .35s cubic-bezier(.22,.61,.36,1);
}

/* ---------- section rhythm ---------- */
section { margin-top: 46px; counter-increment: section; }

h2 {
  font-weight: 600;
  font-size: 1.55rem;
  letter-spacing: -0.015em;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
}
h2::before {
  content: counter(section, decimal-leading-zero);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--grad);
  padding: 4px 9px;
  border-radius: 7px;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

p { margin: 0 0 14px; }
p:last-child { margin-bottom: 0; }

/* ---------- research direction cards ---------- */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
  transition: border-color .25s ease, box-shadow .35s ease, transform .35s cubic-bezier(.22,.61,.36,1);
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--card-accent, var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .4s cubic-bezier(.22,.61,.36,1);
}
.card::after {
  content: "";
  position: absolute;
  right: -40px; top: -40px;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: var(--card-tint, var(--accent-bg));
  opacity: 0;
  transition: opacity .4s ease;
  z-index: 0;
}
.card > * { position: relative; z-index: 1; }
.card:hover {
  border-color: transparent;
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(30,45,75,.12);
}
.card:hover::before { transform: scaleX(1); }
.card:hover::after { opacity: .5; }

.card-blue { --card-accent: var(--accent); --card-tint: var(--accent-bg); }
.card-teal { --card-accent: var(--teal);   --card-tint: var(--teal-bg); }
.card-pink { --card-accent: var(--pink);   --card-tint: var(--pink-bg); }

.card-title {
  font-weight: 600;
  color: var(--ink);
  font-size: 1.16rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.card-title .emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin: 0 12px 8px 0;
  font-size: 1.2rem;
  border-radius: 12px;
  background: var(--card-tint, var(--accent-bg));
  vertical-align: middle;
  transition: transform .35s cubic-bezier(.22,.61,.36,1);
}
.card:hover .card-title .emoji { transform: translateY(-3px) rotate(-5deg) scale(1.05); }
.card p {
  color: var(--ink-soft);
  font-size: 0.96rem;
  line-height: 1.55;
  margin: 0 0 10px;
}
.card-topic { color: var(--ink-soft); }

.openings {
  position: relative;
  margin-top: 18px;
  padding: 16px 22px;
  background: linear-gradient(120deg, #fbeef2, #f4eefb);
  border: 1px solid var(--pink-line);
  border-radius: 16px;
  overflow: hidden;
}
.openings::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(var(--pink), #6a5ea8);
}
.openings p {
  color: var(--ink-soft);
  font-size: 0.99rem;
  line-height: 1.7;
  margin: 0 0 8px;
}
.openings p:last-child { margin-bottom: 0; }
.openings strong { color: var(--ink); font-weight: 600; }

/* ---------- tags / labels ---------- */
.tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 2px 9px;
  border-radius: 5px;
  vertical-align: middle;
  margin-right: 2px;
}

/* ---------- news ---------- */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li {
  position: relative;
  padding: 9px 14px 9px 16px;
  margin: 0 -14px;
  border-radius: 10px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.99rem;
  color: var(--ink-soft);
  transition: background-color .2s ease, transform .2s ease;
}
.news-list li:hover { background: #faf9fc; transform: translateX(3px); }
.news-list li:last-child { border-bottom: none; }
.news-date {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  margin-right: 2px;
}
.news-list li.hidden-news { display: none; }
.news-list.expanded li.hidden-news { display: block; }

.toggle-news {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 18px;
  cursor: pointer;
  color: var(--accent);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color .2s ease, background-color .2s ease, transform .2s ease;
}
.toggle-news:hover {
  border-color: transparent;
  background: var(--accent-bg);
  transform: translateY(-2px);
}

/* ---------- simple lists (awards) ---------- */
.plain { list-style: none; margin: 0; padding: 0; }
.plain li {
  padding: 3px 0 3px 22px;
  color: var(--ink-soft);
  font-size: 0.99rem;
  position: relative;
}
.plain li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 0.7em;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--grad);
  transform: rotate(45deg);
}

/* ---------- grants & projects ---------- */
.proj-list { list-style: none; margin: 0; padding: 0; }
.proj-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}
.proj-list li:last-child { border-bottom: none; }
.proj-main { min-width: 0; }
.proj-title {
  color: var(--ink);
  font-weight: 600;
}
.proj-role {
  display: inline-block;
  margin-left: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 1px 9px;
  border-radius: 999px;
  vertical-align: middle;
  white-space: nowrap;
}
.proj-year {
  flex: 0 0 auto;
  color: var(--ink-faint);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- academic service ---------- */
.service-block p {
  color: var(--ink-soft);
  font-size: 0.99rem;
  line-height: 1.6;
  margin-bottom: 6px;
}
.service-block .lbl { color: var(--ink); font-weight: 600; }

/* ---------- footer ---------- */
footer {
  margin-top: 72px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.88rem;
  letter-spacing: 0.01em;
}

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .cards { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  html { scroll-padding-top: 70px; }
  .wrap { padding: 40px 22px 36px; }
  h1 { font-size: 2.5rem; }
  .hero {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 28px;
  }
  .portrait { width: 150px; height: 150px; }
  .nav-links { gap: 0; }
  .nav-links a { padding: 6px 9px; font-size: 0.9rem; }
  .topnav .brand { font-size: 0.98rem; }
}

/* ---------- accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  .orb { opacity: .3; }
}
