/* ==========================================================================
   Puhua Jiang — personal academic homepage
   设计系统：所有颜色 / 间距 / 圆角都在这里改，改一处全站生效
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  --bg:            #f7f8fa;
  --surface:       #ffffff;
  --surface-2:     #f1f3f7;
  --surface-3:     #e9ecf2;
  --text:          #151821;
  --text-2:        #565d6b;
  --text-3:        #8b93a3;
  --line:          #e4e8ee;
  --line-2:        #d3d9e3;
  --accent:        #2b5bd7;
  --accent-ink:    #1e45a8;
  --accent-soft:   rgba(43, 91, 215, .09);
  --accent-ring:   rgba(43, 91, 215, .22);
  --ok:            #0f7a58;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .10), 0 2px 8px rgba(16, 24, 40, .04);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto,
               Helvetica, Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
                "Songti SC", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  --radius:    16px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --wrap:  1060px;
  --nav-h: 60px;

  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* 深色模式：手动切换（data-theme）或跟随系统（无 data-theme 时） */
:root[data-theme="dark"] {
  --bg:          #0d0f14;
  --surface:     #14181f;
  --surface-2:   #1a1f28;
  --surface-3:   #222834;
  --text:        #e7eaf0;
  --text-2:      #a3abb9;
  --text-3:      #79818f;
  --line:        #242a34;
  --line-2:      #333b47;
  --accent:      #7aa7ff;
  --accent-ink:  #a8c6ff;
  --accent-soft: rgba(122, 167, 255, .14);
  --accent-ring: rgba(122, 167, 255, .28);
  --ok:          #4bd0a0;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .30);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .34);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .48);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0d0f14;
    --surface:     #14181f;
    --surface-2:   #1a1f28;
    --surface-3:   #222834;
    --text:        #e7eaf0;
    --text-2:      #a3abb9;
    --text-3:      #79818f;
    --line:        #242a34;
    --line-2:      #333b47;
    --accent:      #7aa7ff;
    --accent-ink:  #a8c6ff;
    --accent-soft: rgba(122, 167, 255, .14);
    --accent-ring: rgba(122, 167, 255, .28);
    --ok:          #4bd0a0;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .30);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .34);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .48);
  }
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 20px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1;
}

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

a { color: var(--accent); text-decoration: none; transition: color .18s var(--ease); }
a:hover { color: var(--accent-ink); }

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }

::selection { background: var(--accent-ring); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

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

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 3. Top navigation ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}
.nav.is-stuck {
  border-bottom-color: var(--line);
  box-shadow: 0 1px 12px rgba(16, 24, 40, .05);
}
.nav__inner {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 20px;
}
.nav__brand {
  font-family: var(--font-serif);
  font-size: 1.06rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .01em;
  white-space: nowrap;
}
.nav__brand:hover { color: var(--accent); }

.nav__links {
  display: flex;
  gap: 2px;
  margin-left: auto;
  align-items: center;
}
.nav__link {
  position: relative;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-2);
  transition: color .18s var(--ease), background-color .18s var(--ease);
}
.nav__link:hover { color: var(--text); background: var(--surface-2); }
.nav__link.is-active { color: var(--accent); background: var(--accent-soft); }

.nav__tools { display: flex; align-items: center; gap: 8px; margin-left: 6px; }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all .18s var(--ease);
}
.icon-btn:hover { color: var(--accent); border-color: var(--line-2); transform: translateY(-1px); }
.icon-btn svg { width: 17px; height: 17px; }

/* 主题图标：亮色下显示月亮，深色下显示太阳 */
.icon-moon { display: block; }
.icon-sun  { display: none; }
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun  { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-moon { display: none; }
  :root:not([data-theme="light"]) .icon-sun  { display: block; }
}

/* ---------- 4. Hero ---------- */
.hero { padding: 52px 0 8px; }
.hero__inner {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 34px;
  align-items: start;
}
.hero__avatar {
  width: 148px; height: 148px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.hero__avatar img { width: 100%; height: 100%; object-fit: cover; }

.hero__name {
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 4.6vw, 3rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.12;
}
.hero__role {
  margin-top: 10px;
  font-size: 1.06rem;
  color: var(--text-2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.hero__role b { color: var(--text); font-weight: 600; }
.dot-sep { color: var(--line-2); }

.hero__chips {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 13px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  transition: all .18s var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.chip--badge {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 34%, transparent);
  background: color-mix(in srgb, var(--ok) 9%, transparent);
}
.chip--badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent);
}

.hero__contact {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.email-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: .84rem;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all .18s var(--ease);
}
.email-chip:hover { border-color: var(--accent); color: var(--accent); }
.email-chip svg { width: 15px; height: 15px; opacity: .75; }
.email-chip.copied { border-color: var(--ok); color: var(--ok); }

.social { display: flex; gap: 8px; }
.social a {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  transition: all .2s var(--ease);
}
.social a:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.social svg { width: 18px; height: 18px; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  font-size: .88rem; font-weight: 600;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 8px var(--accent-ring);
  transition: all .2s var(--ease);
}
.btn-primary:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 6px 18px var(--accent-ring); }
.btn-primary svg { width: 16px; height: 16px; }

/* ---------- 5. Section scaffolding ---------- */
.section { padding: 46px 0; scroll-margin-top: calc(var(--nav-h) + 24px); }
.section + .section { border-top: 1px solid var(--line); }

.section__head { margin-bottom: 26px; }
.section__title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -.015em;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section__title::before {
  content: "";
  width: 4px; height: 1.15em;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 30%, transparent));
}
.section__sub { margin: 8px 0 0 16px; color: var(--text-3); font-size: .9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ---------- 6. About ---------- */
.about__text p { margin: 0 0 14px; color: var(--text-2); font-size: 1.01rem; }
.about__text p:last-child { margin-bottom: 0; }
.about__text strong { color: var(--text); font-weight: 600; }
.about__text a {
  color: var(--text);
  border-bottom: 1px solid var(--accent-ring);
  padding-bottom: 1px;
}
.about__text a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.interests {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(238px, 1fr));
  gap: 14px;
}
.interest {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: all .22s var(--ease);
}
.interest:hover {
  transform: translateY(-3px);
  border-color: var(--line-2);
  box-shadow: var(--shadow-md);
}
.interest h3 { font-size: .98rem; margin-bottom: 7px; }
.interest p { margin: 0; font-size: .88rem; color: var(--text-3); line-height: 1.6; }

/* ---------- 7. News ---------- */
.news { list-style: none; margin: 0; padding: 0; }
.news li {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 20px;
  padding: 13px 0;
  border-bottom: 1px dashed var(--line);
  align-items: baseline;
}
.news li:first-child { padding-top: 0; }
.news li:last-child { border-bottom: 0; padding-bottom: 0; }
.news__date {
  font-family: var(--font-mono);
  font-size: .79rem;
  color: var(--text-3);
  letter-spacing: .02em;
  padding-top: 2px;
}
.news__body { color: var(--text-2); font-size: .96rem; }
.news__body strong { color: var(--text); font-weight: 600; }
.news__body a { border-bottom: 1px solid var(--accent-ring); }
.news__body a:hover { border-bottom-color: var(--accent); }
.news li.is-latest .news__body { color: var(--text); }
.tag {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  vertical-align: 1px;
}
.tag--service { color: var(--text-3); background: var(--surface-2); }
.tag--work    { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }

/* ---------- 8. Publications ---------- */
.pub-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 22px;
}
.filter {
  padding: 6px 14px;
  font: inherit;
  font-size: .84rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all .18s var(--ease);
}
.filter:hover { border-color: var(--line-2); color: var(--text); }
.filter.is-on {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-ring);
}
.pub-count { margin-left: auto; font-size: .82rem; color: var(--text-3); font-family: var(--font-mono); }

.pub-list { display: flex; flex-direction: column; gap: 16px; }

.pub {
  display: grid;
  grid-template-columns: 236px 1fr;
  gap: 24px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.pub:hover {
  transform: translateY(-3px);
  border-color: var(--line-2);
  box-shadow: var(--shadow-md);
}
.pub.is-hidden { display: none; }

.pub__media {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.pub__media img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform .5s var(--ease);
}
.pub__media img.is-contain { object-fit: contain; padding: 6px; }
.pub:hover .pub__media img { transform: scale(1.04); }
.pub__fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-3);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
}

.pub__body { min-width: 0; display: flex; flex-direction: column; }
.pub__title {
  font-size: 1.03rem;
  font-weight: 600;
  line-height: 1.42;
  margin-bottom: 6px;
}
.pub__title a { color: var(--text); }
.pub__title a:hover { color: var(--accent); }
.pub__authors {
  margin: 0 0 5px;
  font-size: .88rem;
  color: var(--text-3);
  line-height: 1.55;
}
.pub__authors strong { color: var(--accent); font-weight: 600; }
.pub__venue {
  margin: 0 0 12px;
  font-size: .86rem;
  color: var(--text-2);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.pub__venue em { font-style: italic; }
.badge {
  display: inline-block;
  padding: 2px 9px;
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--radius-pill);
}
.badge--preprint {
  color: var(--text-3);
  background: var(--surface-2);
  border-color: var(--line);
}

.pub__links { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }
.pub__link {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  font-size: .79rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  transition: all .18s var(--ease);
}
.pub__link:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.pub__link svg { width: 13px; height: 13px; }

.pub-note {
  margin: 8px 0 0;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ok);
}

/* ---------- 9. Education & Service ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  padding: 15px 0;
  border-bottom: 1px dashed var(--line);
}
.rows li:first-child { padding-top: 0; }
.rows li:last-child { border-bottom: 0; padding-bottom: 0; }
.rows__main { flex: 1 1 260px; min-width: 0; }
.rows__title { font-weight: 600; font-size: .98rem; }
.rows__title a { color: var(--text); }
.rows__title a:hover { color: var(--accent); }
.rows__note { margin-top: 3px; font-size: .86rem; color: var(--text-3); }
.rows__note a { border-bottom: 1px solid var(--accent-ring); }
.rows__note a:hover { border-bottom-color: var(--accent); }
.rows__period {
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--text-3);
  white-space: nowrap;
  margin-left: auto;
}

.service-group + .service-group { margin-top: 28px; }
.service-group h3 {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}

/* ---------- 10. Footer ---------- */
.footer {
  margin-top: 30px;
  padding: 26px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: .82rem;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: center;
}
.footer a { color: var(--text-3); }
.footer a:hover { color: var(--accent); }
.footer__spacer { margin-left: auto; }

.to-top {
  position: fixed;
  right: 26px; bottom: 26px;
  z-index: 40;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all .28s var(--ease);
}
.to-top.is-on { opacity: 1; pointer-events: auto; transform: none; }
.to-top:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }
.to-top svg { width: 17px; height: 17px; }

/* ---------- 11. Reveal animation ---------- */
/* 只有 JS 可用时才启用入场动画，否则内容必须始终可见 */
.reveal { opacity: 1; transform: none; }
.js .reveal { opacity: 0; transform: translateY(14px); }
.js .reveal.is-in {
  opacity: 1;
  transform: none;
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}

/* ---------- 12. Responsive ---------- */
@media (max-width: 880px) {
  .wrap { padding: 0 20px; }
  .hero { padding-top: 34px; }
  .hero__inner { grid-template-columns: 1fr; gap: 22px; justify-items: start; }
  .hero__avatar { width: 108px; height: 108px; }
  .pub { grid-template-columns: 1fr; gap: 16px; }
  .pub__media { aspect-ratio: 16 / 9; }
  .news li { grid-template-columns: 1fr; gap: 4px; }
  .news__date { padding-top: 0; }
  .section { padding: 34px 0; }
}

@media (max-width: 640px) {
  .nav__links {
    position: absolute;
    top: var(--nav-h); left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    display: none;
  }
  .nav__links.is-open { display: flex; }
  .nav__link { padding: 11px 14px; border-radius: var(--radius-sm); }
  .nav__toggle { display: inline-flex; }
  .nav__tools { margin-left: auto; }
  .rows__period { margin-left: 0; }
  .pub-count { margin-left: 0; width: 100%; }
}

.nav__toggle {
  display: none;
  margin-left: auto;
}

@media (max-width: 640px) {
  .nav__toggle { display: inline-flex; }

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

@media print {
  .nav, .to-top, .pub-toolbar, .pub__links { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .pub, .card, .interest { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
  .reveal, .js .reveal { opacity: 1 !important; transform: none !important; }
  a { color: #000; }
}
