/* =========================================================================
   Minxue Pan — Academic Homepage
   Refined minimal style. Self-contained, GitHub Pages friendly (static only).
   ========================================================================= */

/* ----- Design tokens ----------------------------------------------------- */
:root {
  --ink:        #1a1a1a;   /* primary text            */
  --ink-soft:   #44474d;   /* secondary text          */
  --ink-faint:  #767b85;   /* meta / muted            */
  --line:       #e6e6e6;   /* hairlines               */
  --line-soft:  #f0f0f0;   /* very light dividers     */
  --paper:      #ffffff;   /* card / content surface  */
  --bg:         #f6f6f4;   /* page background         */
  --accent:     #8a1f2b;   /* deep academic crimson   */
  --accent-2:   #1f6f8b;   /* link / interactive teal */
  --accent-2d:  #134c5f;   /* link hover              */
  --tag-bg:     #f2efe9;   /* venue tag background     */
  --highlight:  #fcf6dc;   /* "Minxue Pan" name marker */
  --radius:     12px;
  --maxw:       980px;
  --serif: "Spectral", Georgia, "Songti SC", "SimSun", serif;
  --sans:  "Inter Tight", "Helvetica Neue", Arial, "PingFang SC",
           "Microsoft YaHei", sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* subtle paper grain on the page background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
  background-image: radial-gradient(var(--line) 0.5px, transparent 0.5px);
  background-size: 22px 22px;
}

a {
  color: var(--accent-2);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-2d); text-decoration: underline; text-underline-offset: 2px; }

img { max-width: 100%; height: auto; }

/* ----- Navigation -------------------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav__inner {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}
.nav__brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
  color: var(--ink);
  text-decoration: none;
}
.nav__brand:hover { color: var(--ink); text-decoration: none; }
.nav__brand span { color: var(--accent); }

/* mobile hamburger — hidden on desktop */
.nav__toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  cursor: pointer;
}
.nav__toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  background: var(--ink-soft);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.nav__toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle.is-open span:nth-child(2) { opacity: 0; }
.nav__toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.nav__links { display: flex; gap: 4px; flex-wrap: wrap; }
.nav__links a {
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  padding: 6px 10px;
  border-radius: 7px;
}
.nav__links a:hover {
  color: var(--accent);
  background: var(--line-soft);
  text-decoration: none;
}

/* ----- Layout shell ------------------------------------------------------ */
.wrap {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 28px 90px;
}

.section { padding-top: 56px; scroll-margin-top: 74px; }

.section__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--ink);
  margin: 0 0 22px;
  padding-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.section__title::before {
  content: "";
  width: 22px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  transform: translateY(-5px);
}
.section__title small {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--ink-faint);
  letter-spacing: 0.2px;
}

/* ----- Hero -------------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  align-items: center;
  padding: 64px 0 14px;
}
.hero__name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 2.6rem;
  line-height: 1.1;
  margin: 0 0 4px;
  letter-spacing: -0.5px;
}
.hero__name .zh { font-size: 1.5rem; color: var(--ink-faint); font-weight: 500; margin-left: 8px; }
.hero__role {
  font-size: 1.02rem;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 16px;
  letter-spacing: 0.2px;
}
.hero__affil {
  color: var(--ink-soft);
  font-size: 0.96rem;
  line-height: 1.85;
  margin: 0 0 16px;
}
.hero__affil strong { color: var(--ink); font-weight: 600; }
.hero__contact { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 6px 13px;
  border-radius: 999px;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.chip:hover { color: var(--accent-2d); border-color: var(--accent-2); text-decoration: none; transform: translateY(-1px); }
.hero__photo {
  width: 188px;
  height: 250px;          /* 3:4 width-to-height ratio */
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.10);
}

/* ----- Bio --------------------------------------------------------------- */
.bio {
  margin-top: 26px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 24px 28px;
}
.bio strong { color: var(--ink); font-weight: 600; }

.bio__quote {
  margin: 0 0 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.32rem;
  line-height: 1.42;
  color: var(--accent);
  letter-spacing: 0.1px;
  text-wrap: balance;
}
.bio__lede {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.06rem;
  line-height: 1.78;
  color: var(--ink-soft);
}
.bio__lede em { font-style: italic; color: var(--ink); }
.bio__edu {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink-faint);
}

/* ----- News -------------------------------------------------------------- */
.news { list-style: none; margin: 0; padding: 0; }
.news li {
  position: relative;
  padding: 12px 0 12px 22px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-soft);
  font-size: 0.96rem;
}
.news li:last-child { border-bottom: 0; }
.news li::before {
  content: "";
  position: absolute;
  left: 0; top: 20px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.news li strong { color: var(--ink); font-weight: 600; }
.news .tag-a {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--accent);
  background: #f7ebec;
  border-radius: 5px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
}
.news--callout {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  color: var(--ink-soft);
  font-size: 0.97rem;
}
.news--callout strong { color: var(--accent); }

/* ----- Publications ------------------------------------------------------ */
.pub-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.pub-filter {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pub-filter:hover { border-color: var(--accent-2); color: var(--accent-2d); }
.pub-filter.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.pub-list { list-style: none; margin: 0; padding: 0; counter-reset: pub; }
.pub {
  counter-increment: pub;
  position: relative;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line-soft);
}
.pub:last-child { border-bottom: 0; }
.pub__venue {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-align: center;
  align-self: start;
}
.pub__venue a {
  display: block;
  color: var(--accent);
  background: var(--tag-bg);
  border: 1px solid #e7e0d4;
  border-radius: 7px;
  padding: 5px 2px;
  line-height: 1.25;
  white-space: nowrap;
}
.pub__venue a:hover { background: #ece4d6; text-decoration: none; }
.pub__tier {
  display: block;
  margin-top: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--ink-faint);
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 0;
  line-height: 1.2;
}
.pub__tier--a {            /* top tier — subtle accent weight */
  color: var(--accent);
  background: var(--tag-bg);
  border-color: #e7e0d4;
}
.pub__tier--b { color: var(--ink-soft); }   /* mid — default neutral, a touch darker text */
.pub__tier--c { color: var(--ink-faint); opacity: 0.85; }  /* lowest — faintest */
.pub__body { font-size: 0.95rem; color: var(--ink-soft); }
.pub__title {
  display: block;
  color: var(--ink);
  font-weight: 600;
  margin: 2px 0 4px;
}
.pub__authors u { text-decoration: none; }
.pub__authors u {                      /* highlight the host author */
  font-weight: 700;
  color: var(--ink);
}
.pub__meta { color: var(--ink-faint); font-style: italic; }
.pub__award {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #8a6d1f;
  background: #fbf3d8;
  border: 1px solid #ecdfae;
  border-radius: 5px;
  padding: 1px 7px;
  margin-left: 4px;
  font-style: normal;
}
.pub__link { font-weight: 600; white-space: nowrap; }
.pub.is-hidden { display: none; }

/* ----- Generic content cards (teaching / tools) -------------------------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 26px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.list-clean { list-style: none; margin: 0; padding: 0; }
.list-clean > li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-soft);
  font-size: 0.96rem;
}
.list-clean > li:last-child { border-bottom: 0; }
.list-clean strong { color: var(--ink); }
.list-clean em { color: var(--ink-faint); }

.teaching-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.course {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}
.course b { display: block; color: var(--ink); font-size: 0.98rem; margin-bottom: 3px; }
.course span { font-size: 0.84rem; color: var(--ink-faint); }
.course--note {
  grid-column: 1 / -1;
  background: var(--line-soft);
  border-style: dashed;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.tool { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.tool:last-child { border-bottom: 0; }
.tool b { color: var(--ink); font-size: 0.98rem; }
.tool a b { color: var(--accent-2d); }
.tool p { margin: 4px 0 0; color: var(--ink-soft); font-size: 0.94rem; }

/* ----- Footer ------------------------------------------------------------ */
.foot {
  position: relative;
  z-index: 1;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.82rem;
  padding: 40px 20px 50px;
  border-top: 1px solid var(--line);
  margin-top: 40px;
}

/* ----- Reveal-on-load animation ------------------------------------------ */
.reveal { opacity: 0; transform: translateY(14px); animation: rise 0.6s ease forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

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

/* Tablet — narrower gutters, tighter hero, two-up teaching stays */
@media (max-width: 900px) {
  .hero { gap: 28px; }
  .hero__name { font-size: 2.35rem; }
  .hero__photo { width: 168px; height: 224px; }
  .wrap { padding: 0 24px 80px; }
  .nav__inner { padding: 0 24px; }
}

/* Mobile / small tablet portrait — stacked layout + drawer nav */
@media (max-width: 720px) {
  .nav__inner { height: 54px; padding: 0 18px; }
  .nav__toggle { display: flex; }

  /* links collapse into a dropdown drawer under the bar */
  .nav__links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    padding: 6px 12px 12px;
    box-shadow: 0 12px 24px rgba(0,0,0,0.06);
    display: none;
  }
  .nav__links.is-open { display: flex; }
  .nav__links a {
    font-size: 0.95rem;
    padding: 11px 12px;
    border-radius: 8px;
  }

  .hero {
    grid-template-columns: 1fr;
    text-align: left;
    gap: 22px;
    padding: 40px 0 8px;
  }
  .hero__photo { width: 150px; height: 200px; order: -1; }
  .hero__name { font-size: 2.1rem; }
  .hero__name .zh { display: inline-block; font-size: 1.3rem; }

  .section { padding-top: 44px; }
  .section__title { font-size: 1.35rem; }

  .teaching-grid { grid-template-columns: 1fr; }

  .pub { grid-template-columns: 1fr; gap: 6px; padding: 16px 0; }
  .pub__venue { text-align: left; }
  .pub__venue a { display: inline-block; }

  .wrap { padding: 0 18px 70px; }
  .bio { padding: 20px 20px; }
  .bio__quote { font-size: 1.18rem; }
  .card { padding: 18px 18px; }
}

/* Very small phones — keep the year filter from overflowing */
@media (max-width: 420px) {
  .hero__name { font-size: 1.85rem; }
  .pub-toolbar { gap: 6px; }
  .pub-filter { padding: 5px 11px; font-size: 0.78rem; }
  .hero__contact { gap: 6px; }
}

/* ----- Dark mode --------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --ink:        #ececec;
    --ink-soft:   #c2c5cc;
    --ink-faint:  #8b909a;
    --line:       #2c2e34;
    --line-soft:  #24262b;
    --paper:      #1c1d22;
    --bg:         #16161a;
    --accent:     #e0838d;   /* lifted crimson for contrast on dark */
    --accent-2:   #5bb6cf;
    --accent-2d:  #86cfe2;
    --tag-bg:     #26241f;
    --highlight:  #3a3320;
  }
  body::before { opacity: 0.18; }
  .nav { background: rgba(28, 29, 34, 0.86); }
  @media (max-width: 720px) {
    .nav__links { background: rgba(28, 29, 34, 0.97); }
  }
  .hero__photo { box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5); }
  .pub-filter.is-active { background: var(--accent-2); border-color: var(--accent-2); color: #0d1417; }
  .pub__venue a { border-color: #3a352c; }
  .news .tag-a { background: #3a2a2c; }
  .pub__award { color: #e8cd84; background: #332c16; border-color: #4a3f1f; }
}

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