/* ==========================================================================
   Yifan Lu · personal homepage
   Light, soft palette. Color tokens are at the top. No build step.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f4f8f6;         /* page background: soft mint, solid */
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --border: #e6e9f2;
  --border-strong: #d2d8e6;
  --text: #2c3552;       /* deep slate blue, used instead of black */
  --text-2: #525b76;
  --muted: #858da4;

  /* Accents: soft hues, dark enough to read as text on white */
  --a1: #5c62cf;         /* periwinkle */
  --a2: #23788f;         /* teal */
  --a3: #b0507f;         /* rose */
  --a1-soft: #eff0fd;
  --a2-soft: #e9f5f7;
  --a3-soft: #fbeff5;
  --ok: #3fb68b;

  --shadow-sm: 0 1px 2px rgba(60, 72, 120, .05), 0 6px 18px -10px rgba(60, 72, 120, .14);
  --shadow: 0 22px 48px -26px rgba(60, 72, 120, .30);
  --nav-bg: rgba(244, 248, 246, .85);

  --radius: 18px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --container: 1120px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
body {
  position: relative;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--text); text-decoration: none; background-image: linear-gradient(var(--a1), var(--a1)); background-size: 0 1px; background-position: 0 100%; background-repeat: no-repeat; transition: background-size .3s var(--ease), color .2s; }
a:hover { background-size: 100% 1px; }
p a, dd a, .news a, .role a { color: var(--text); background-size: 100% 1px; background-image: linear-gradient(var(--border-strong), var(--border-strong)); }
p a:hover, dd a:hover, .news a:hover, .role a:hover { color: var(--a1); background-image: linear-gradient(var(--a1), var(--a1)); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--a1); outline-offset: 3px; border-radius: 6px; }
::selection { background: #dfe1fb; color: var(--text); }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 24px; }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; padding: 8px 14px; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-sm); }
.skip-link:focus { left: 12px; }

/* ---------- Nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  transition: background-color .3s, border-color .3s, box-shadow .3s;
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: var(--nav-bg);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom-color: var(--border);
}
.nav-inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { font-size: 17px; font-weight: 700; letter-spacing: -.015em; color: var(--text); background: none; }
.nav-links { display: flex; gap: 2px; margin-left: auto; }
.nav-links a {
  padding: 6px 12px; border-radius: 999px; font-size: 14px; color: var(--text-2);
  background: none; transition: color .2s, background-color .2s;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a.active { color: var(--a1); background: var(--a1-soft); }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: border-color .2s, color .2s;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

/* ---------- Intro (first screen) ---------- */
.intro { padding: 120px 0 0; }
.intro-grid { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 56px; align-items: start; }
.intro-side { order: -1; }
.intro-main, .intro-side { animation: fade-up .8s var(--ease) both; }
.intro-main { animation-delay: .12s; }
.intro-side { display: grid; gap: 16px; }
.intro-side .card { padding: 22px; }
.intro-side .edu-item { gap: 12px; }
.intro-side .logo-tile { width: 38px; height: 38px; border-radius: 10px; }
.intro-side .logo-tile img { width: 28px; height: 28px; }
.intro-side .edu-school { font-size: 15px; }
.intro-side .edu-degree { font-size: 13.5px; }
.intro-side .news li { grid-template-columns: 56px 1fr; gap: 10px; font-size: 13.5px; }
.intro-side .news-date { font-size: 12px; }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.profile { display: flex; align-items: center; gap: 26px; margin-bottom: 30px; }
.avatar {
  flex: none; width: 132px; height: 132px; border-radius: 50%; padding: 4px;
  background: #fff; border: 2px solid #d6d8f6; box-shadow: var(--shadow-sm);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.name { margin: 0; font-size: clamp(2rem, 3.6vw, 2.6rem); line-height: 1.1; font-weight: 750; letter-spacing: -.03em; color: var(--text); }
.cn-name { display: inline-block; margin-left: 10px; font-size: .46em; font-weight: 500; letter-spacing: .22em; color: var(--muted); vertical-align: .22em; }
.role { margin: 8px 0 12px; font-size: 16px; color: var(--text-2); }
.status {
  display: inline-flex; align-items: center; gap: 9px; padding: 5px 13px 5px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: rgba(255, 255, 255, .75); font-size: 13px; color: var(--text-2);
}
.status:hover { border-color: var(--border-strong); color: var(--text); background-size: 0 0; }
.pulse { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; animation: ping 2.4s var(--ease) infinite; }
@keyframes ping { 0% { transform: scale(.5); opacity: .7; } 100% { transform: scale(1.8); opacity: 0; } }

.about-text p { margin: 0 0 16px; font-size: 17px; line-height: 1.7; color: var(--text-2); }
.about-text strong { color: var(--text); font-weight: 650; }
.about-text p:has(+ .about-points) { margin-bottom: 8px; }
.about-points { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 4px; }
.about-points li { position: relative; padding-left: 20px; font-size: 17px; line-height: 1.65; color: var(--text-2); }
.about-points li::before { content: ""; position: absolute; left: 4px; top: .68em; width: 6px; height: 6px; border-radius: 50%; background: var(--a1); opacity: .7; }

.cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 550;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), border-color .25s, box-shadow .25s, background-color .25s, color .25s;
}
.btn svg { width: 16px; height: 16px; flex: none; color: var(--text-2); }
.btn:hover { transform: translateY(-1px); border-color: var(--border-strong); background-size: 0 0; box-shadow: var(--shadow); }
.btn-primary { background: var(--a1-soft); border-color: color-mix(in srgb, var(--a1) 30%, transparent); color: var(--a1); }
.btn-primary svg { color: var(--a1); }
.btn-primary:hover { background: #e5e7fc; border-color: color-mix(in srgb, var(--a1) 45%, transparent); }

/* ---------- Cards ---------- */
.card {
  position: relative; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  padding: 26px; overflow: hidden; box-shadow: var(--shadow-sm);
  transition: border-color .3s, transform .4s var(--ease), box-shadow .4s;
}
.card:hover { border-color: var(--border-strong); }
.card > * { position: relative; }
.card-title { margin: 0 0 16px; font-size: 12.5px; font-family: var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }

/* Education and news in the intro side column */
.edu-item { display: flex; gap: 14px; align-items: flex-start; }
.edu-item + .edu-item { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.logo-tile { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px var(--border); overflow: hidden; }
.logo-tile img { width: 34px; height: 34px; object-fit: contain; }
.logo-mono { background: var(--a1-soft); color: var(--a1); font-weight: 800; font-size: 18px; }
.edu-school { font-weight: 650; font-size: 15.5px; }
.edu-degree { font-size: 14px; color: var(--text-2); }
.edu-meta { margin-top: 2px; font-size: 12.5px; color: var(--muted); font-family: var(--mono); }

.news-card { padding-bottom: 18px; }
.news { margin: 0; padding: 0; list-style: none; }
.news li { display: grid; grid-template-columns: 62px 1fr; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.55; color: var(--text-2); }
.news li:first-child { padding-top: 0; }
.news li:last-child { border-bottom: 0; }
.news li[hidden] { display: none; }
.news-date { font-family: var(--mono); font-size: 12.5px; color: var(--a2); padding-top: 1px; }
.news b { color: var(--text); font-weight: 650; }
.link-btn { margin-top: 6px; padding: 4px 0; border: 0; background: none; cursor: pointer; font-family: var(--mono); font-size: 12.5px; color: var(--a1); }
.link-btn:hover { text-decoration: underline; }

/* ---------- Sections ---------- */
.section { padding: 96px 0 0; }
.sec-title { display: flex; align-items: baseline; gap: 14px; margin: 0 0 28px; font-size: clamp(1.6rem, 2.8vw, 2rem); line-height: 1.2; font-weight: 750; letter-spacing: -.025em; color: var(--text); }
.sec-num { font-family: var(--mono); font-size: 14px; font-weight: 500; letter-spacing: .06em; color: var(--a2); }
.sub-head { margin: 48px 0 16px; font-size: 12.5px; font-family: var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }

/* ---------- Research ---------- */
.threads { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.thread { padding: 24px; }
.thread h3 { margin: 14px 0 6px; font-size: 18px; letter-spacing: -.02em; }
.thread p { color: var(--text-2); font-size: 15px; margin: 0; }
.thread-icon { color: var(--a1); width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); }
.thread-icon svg { width: 28px; height: 28px; }
.thread:hover, .feat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

/* Featured work: one row of cards with paper figures */
.featured { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.feat { padding: 0; display: flex; flex-direction: column; }
.feat-fig { display: block; aspect-ratio: 2 / 1; padding: 8px; background: #fff; border-bottom: 1px solid var(--border); overflow: hidden; }
.feat-fig:hover { background-size: 0 0; }
.feat-fig img { width: 100%; height: 100%; object-fit: contain; transition: transform .6s var(--ease); }
.feat:hover .feat-fig img { transform: scale(1.03); }
.feat-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.feat-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.feat h4 { margin: 12px 0 4px; font-size: 16.5px; line-height: 1.3; letter-spacing: -.015em; }
.feat p { margin: 0; font-size: 14px; color: var(--text-2); }
.feat-links { margin-top: auto; padding-top: 12px; font-family: var(--mono); font-size: 13px; }
.feat-links a { color: var(--a1); background: none; }
.feat-links a:hover { text-decoration: underline; }

/* Technical reports: plain list */
.reports { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.reports li { display: flex; align-items: center; justify-content: space-between; gap: 6px 20px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.report-title { font-weight: 650; font-size: 16px; }
.report-meta { font-size: 14px; color: var(--muted); }
.report-link { flex: none; font-family: var(--mono); font-size: 13px; color: var(--a1); background: none; }
.report-link:hover { text-decoration: underline; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px; font-size: 12.5px; font-weight: 600; font-family: var(--font); letter-spacing: 0; border: 1px solid var(--border); color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
.badge-conf { color: var(--a2); border-color: color-mix(in srgb, var(--a2) 22%, transparent); background: var(--a2-soft); }
.badge-journal { color: var(--a1); border-color: color-mix(in srgb, var(--a1) 22%, transparent); background: var(--a1-soft); }
.badge-review { color: var(--text-2); }
.badge-first { color: var(--a3); border-color: color-mix(in srgb, var(--a3) 22%, transparent); background: var(--a3-soft); }
.badge-oral { color: #fff; border-color: var(--a1); background: var(--a1); }

/* ---------- Experience ---------- */
.exp-head { display: flex; gap: 14px; align-items: center; }
.exp-title { flex: 1; min-width: 0; }
.exp-title h3 { margin: 0; font-size: 18px; letter-spacing: -.015em; }
.exp-role { font-size: 14.5px; color: var(--text-2); }
.exp-date { font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap; align-self: flex-start; padding-top: 4px; }
.exp > p { margin: 16px 0 0; color: var(--text-2); font-size: 15.5px; }
.exp + .exp { margin-top: 14px; }

/* ---------- Publications ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.filter { height: 36px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 14px; transition: all .25s var(--ease); }
.filter .count { margin-left: 4px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.filter:hover { border-color: var(--border-strong); color: var(--text); }
.filter.is-active { background: var(--a1-soft); color: var(--a1); border-color: color-mix(in srgb, var(--a1) 30%, transparent); font-weight: 600; }
.filter.is-active .count { color: inherit; opacity: .7; }
.pub-year { display: flex; align-items: center; gap: 14px; margin: 32px 0 10px; font-family: var(--mono); font-size: 14px; color: var(--muted); }
.pub-year:first-child { margin-top: 0; }
.pub-year::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.pub { display: grid; grid-template-columns: 170px 1fr; gap: 20px; padding: 16px 20px; border-radius: 14px; border: 1px solid transparent; transition: background-color .25s, border-color .25s, box-shadow .25s; }
.pub:hover { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
.pub-venue { display: flex; flex-wrap: wrap; align-content: flex-start; align-items: flex-start; gap: 6px; padding-top: 2px; }
.pub-title { margin: 0; font-size: 16px; line-height: 1.45; font-weight: 650; letter-spacing: -.01em; }
.pub-title a { color: var(--text); background-image: linear-gradient(var(--a1), var(--a1)); background-size: 0 1.5px; }
.pub-title a:hover { color: var(--a1); background-size: 100% 1.5px; }
.pub-authors { margin: 6px 0 0; font-size: 14.5px; color: var(--muted); }
.pub-authors .me { color: var(--text); font-weight: 650; text-decoration: underline; text-decoration-color: #a3a6f4; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.pub-links { display: flex; gap: 8px; margin-top: 10px; }
.pub-links a { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); font-family: var(--font); font-size: 12.5px; font-weight: 500; color: var(--text-2); background: var(--surface); transition: border-color .2s, color .2s; }
.pub-links a:hover { border-color: color-mix(in srgb, var(--a1) 40%, transparent); color: var(--a1); }
.pub.enter { animation: rise .5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Service: plain list, no card ---------- */
.kv { margin: 0; display: grid; grid-template-columns: 220px 1fr; border-top: 1px solid var(--border); }
.kv dt, .kv dd { margin: 0; padding: 14px 4px; border-bottom: 1px solid var(--border); font-size: 15px; }
.kv dt { font-weight: 650; }
.kv dd { color: var(--text-2); }

/* ---------- Footer ---------- */
.footer { margin-top: 96px; border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 24px; padding-bottom: 24px; font-size: 13px; color: var(--muted); font-family: var(--mono); }

/* ---------- WeChat dialog ---------- */
.wechat-dialog { border: 1px solid var(--border); border-radius: 20px; padding: 22px 22px 24px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); max-width: min(340px, 92vw); }
.wechat-dialog::backdrop { background: rgba(44, 53, 82, .22); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.wechat-dialog img { border-radius: 14px; width: 100%; height: auto; }
.dialog-title { margin: 0 0 14px; font-weight: 650; }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; }

/* ---------- Reveal on scroll ---------- */
.js .reveal { opacity: 0; transform: translateY(22px); transition: opacity .8s var(--ease), transform .8s var(--ease); transition-delay: var(--d, 0ms); }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .intro-grid { grid-template-columns: 1fr; gap: 28px; }
  .intro-side { order: 0; grid-template-columns: 1fr 1fr; align-items: start; }
  .threads { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .menu-btn { display: grid; margin-left: auto; }
  .nav-links {
    position: absolute; top: 64px; left: 12px; right: 12px; flex-direction: column; gap: 2px; padding: 10px;
    border-radius: 16px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
    opacity: 0; transform: translateY(-8px); pointer-events: none; transition: opacity .25s, transform .25s;
  }
  .nav-links.open { opacity: 1; transform: none; pointer-events: auto; }
  .nav-links a { padding: 11px 14px; font-size: 16px; }
  .featured { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .intro { padding-top: 96px; }
  .intro-side { grid-template-columns: 1fr; }
  .profile { gap: 18px; margin-bottom: 24px; }
  .avatar { width: 96px; height: 96px; }
  .about-text p, .about-points li { font-size: 16px; }
  .section { padding-top: 80px; }
  .card { padding: 20px; }
  .feat { padding: 0; }
  .pub { grid-template-columns: 1fr; gap: 10px; padding: 14px 4px; }
  .pub:hover { background: none; border-color: transparent; box-shadow: none; }
  .exp-head { flex-wrap: wrap; }
  .exp-date { width: 100%; padding: 0 0 0 60px; }
  .reports li { flex-direction: column; align-items: flex-start; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { border-bottom: 0; padding-bottom: 2px; }
  .kv dd { padding-top: 0; }
}
@media (max-width: 520px) {
  .profile { flex-direction: column; align-items: flex-start; gap: 16px; }
  .avatar { width: 88px; height: 88px; }
  .name { font-size: 2rem; }
  .featured { grid-template-columns: 1fr; }
  .btn { height: 40px; padding: 0 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; }
}
