/* ================================================================
   JIAN GUAN — Personal Academic Website
   Pure CSS — no frameworks, no build step
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Light-mode tokens (default) ────────────────────────────────── */
:root {
  --navy:        #0f2441;
  --navy-2:      #1a3355;
  --teal:        #1b9aaa;
  --teal-dk:     #12737f;
  --teal-lt:     #e6f5f7;
  --blue:        #3b82f6;
  --blue-lt:     #eff6ff;
  --indigo:      #6366f1;
  --indigo-lt:   #eef2ff;
  --amber:       #d97706;
  --amber-lt:    #fffbeb;
  --rose:        #e11d48;
  --rose-lt:     #fff1f2;
  --emerald:     #059669;
  --emerald-lt:  #ecfdf5;
  --bg:          #ffffff;
  --bg-alt:      #f8fafc;
  --text:        #1e293b;
  --text-2:      #475569;
  --text-3:      #94a3b8;
  --border:      #e2e8f0;
  --card-bg:     #ffffff;
  --radius:      12px;
  --shadow-sm:   0 1px 3px rgba(15,36,65,.06), 0 1px 2px rgba(15,36,65,.04);
  --shadow-md:   0 4px 16px rgba(15,36,65,.08);
  --shadow-lg:   0 12px 40px rgba(15,36,65,.12);
  --max-w:       1060px;
  --nav-h:       64px;
}

/* ── Dark-mode tokens ───────────────────────────────────────────── */
[data-theme="dark"] {
  --navy:        #e2e8f0;
  --navy-2:      #cbd5e1;
  --teal:        #2dd4bf;
  --teal-dk:     #5eead4;
  --teal-lt:     rgba(45,212,191,.1);
  --indigo:      #a5b4fc;
  --indigo-lt:   rgba(165,180,252,.1);
  --amber:       #fbbf24;
  --amber-lt:    rgba(251,191,36,.1);
  --bg:          #0f172a;
  --bg-alt:      #1e293b;
  --text:        #e2e8f0;
  --text-2:      #cbd5e1;
  --text-3:      #64748b;
  --border:      #334155;
  --card-bg:     #1e293b;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.3);
  --shadow-md:   0 4px 16px rgba(0,0,0,.35);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.4);
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

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

a { color: var(--teal); text-decoration: none; transition: color .15s; }
a:hover { color: var(--teal-dk); }

/* ── Nav ────────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background .3s ease, border-color .3s ease;
}

.nav__inner {
  max-width: var(--max-w);
  margin: 0 auto; padding: 0 2rem;
  height: 100%;
  display: flex; align-items: center; justify-content: space-between;
}

.nav__brand { font-weight: 700; font-size: 1.15rem; color: var(--navy); letter-spacing: -.02em; }

.nav__right { display: flex; align-items: center; gap: .6rem; }
.nav__links { display: flex; gap: .25rem; list-style: none; }
.nav__links a {
  display: block; padding: .45rem 1rem;
  font-size: .95rem; font-weight: 500; color: var(--text-2);
  border-radius: 8px; transition: color .15s, background .15s;
}
.nav__links a:hover { color: var(--navy); background: var(--bg-alt); }
.nav__links a.active { color: var(--teal); font-weight: 600; }

/* Theme toggle button */
.theme-toggle {
  background: none; border: 1.5px solid var(--border);
  border-radius: 50%; width: 2.2rem; height: 2.2rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-2);
  transition: color .15s, border-color .15s, background .15s;
}
.theme-toggle:hover {
  color: var(--teal); border-color: var(--teal);
  background: var(--teal-lt);
}
.theme-toggle svg { width: 1rem; height: 1rem; }
.theme-toggle .icon-moon  { display: block; }
.theme-toggle .icon-sun   { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }

/* ── Layout ─────────────────────────────────────────────────────── */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 2rem; }
.section { padding: 4.5rem 0; }
.section--alt { background: var(--bg-alt); }

.page-title {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 800; color: var(--teal);
  letter-spacing: -.02em; margin-bottom: .5rem;
}

.page-desc {
  font-size: 1.1rem; color: var(--text-2);
  max-width: 42rem; margin-bottom: 2.5rem; line-height: 1.75;
}

/* ── Home: single-screen layout ─────────────────────────────────── */
.home-page {
  height: 100vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.home-page .nav { flex-shrink: 0; }
.home-page .footer--home {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 1rem 0; text-align: center;
  font-size: .82rem; color: var(--text-3);
}

/* ── Hero ────────────────────────────────────────────────────────── */
.hero { padding: 5rem 0 4rem; border-bottom: 1px solid var(--border); }

.hero--full {
  flex: 1;
  display: flex; align-items: center;
  padding: 0; border-bottom: none;
  position: relative;
  background:
    radial-gradient(ellipse at 75% 40%, rgba(27,154,170,.06) 0%, transparent 65%),
    radial-gradient(ellipse at 15% 80%, rgba(99,102,241,.04) 0%, transparent 55%);
}

[data-theme="dark"] .hero--full {
  background:
    radial-gradient(ellipse at 75% 40%, rgba(45,212,191,.06) 0%, transparent 65%),
    radial-gradient(ellipse at 15% 80%, rgba(165,180,252,.05) 0%, transparent 55%);
}

.hero--full::before {
  content: '';
  position: absolute;
  top: -80px; right: -120px;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(27,154,170,.07) 0%, transparent 70%);
  pointer-events: none;
}

.hero__row { display: flex; align-items: center; gap: 4.5rem; }
.hero__text { flex: 1; min-width: 0; }

.hero__greeting {
  display: inline-flex; align-items: center;
  font-size: .82rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--teal); margin-bottom: .6rem;
}
.hero__greeting::before {
  content: '';
  display: inline-block;
  width: 2rem; height: 2px;
  background: var(--teal);
  margin-right: .6rem;
  border-radius: 1px;
}

.hero__name {
  font-size: clamp(2.6rem, 5vw, 3.4rem);
  font-weight: 800; color: var(--navy);
  line-height: 1.08; letter-spacing: -.03em;
  margin-bottom: .6rem;
}

.hero__tagline {
  font-size: 1.12rem; color: var(--text-2);
  margin-bottom: 1.6rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem;
}
.hero__tagline strong { color: var(--text); font-weight: 600; }

.hero__bio {
  font-size: 1.08rem; color: var(--text-2);
  line-height: 1.78; max-width: 38rem; margin-bottom: 1.5rem;
}
.hero__bio a { font-weight: 500; }
.hero__bio a:hover { text-decoration: underline; }

.hero__icons { display: flex; gap: .6rem; align-items: center; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  border: 1.5px solid var(--border);
  color: var(--text-2); background: var(--card-bg);
  transition: color .15s, border-color .15s, background .15s, transform .1s;
}
.icon-btn svg { width: 1.1rem; height: 1.1rem; }
.icon-btn--cv svg { width: 1.15rem; height: 1.15rem; }
.icon-btn:hover {
  color: var(--teal); border-color: var(--teal);
  background: var(--teal-lt); transform: translateY(-2px);
}

.hero__photo { flex-shrink: 0; }
.hero__photo img {
  width: 240px; height: 240px;
  border-radius: 50%; object-fit: cover;
  box-shadow: var(--shadow-lg);
  border: 4px solid var(--card-bg);
  outline: 3px solid color-mix(in srgb, var(--teal) 25%, transparent);
}

/* ── Research cards (overview page) ─────────────────────────────── */
.research-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.6rem;
}

.rcard {
  display: flex; flex-direction: column;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  text-decoration: none !important; color: inherit !important;
}
.rcard:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--teal) 35%, transparent);
}

/* Color bands on top of research cards */
.rcard--teal   { border-top: 4px solid var(--teal); }
.rcard--amber  { border-top: 4px solid var(--amber); }
.rcard--indigo { border-top: 4px solid var(--indigo); }

.rcard__img {
  width: 100%; height: 180px;
  object-fit: cover; background: var(--bg-alt);
}

.rcard__body { padding: 1.3rem 1.5rem 1.5rem; flex: 1; }

.rcard__tag {
  display: inline-block;
  font-size: .72rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: .2rem .65rem; border-radius: 999px;
  margin-bottom: .7rem;
}
.rcard__tag--teal    { color: var(--teal-dk);  background: var(--teal-lt); }
.rcard__tag--amber   { color: var(--amber);    background: var(--amber-lt); }
.rcard__tag--indigo  { color: var(--indigo);   background: var(--indigo-lt); }

.rcard__title {
  font-size: 1.1rem; font-weight: 700; color: var(--navy);
  line-height: 1.35; margin-bottom: .55rem;
}

.rcard__excerpt {
  font-size: .98rem; color: var(--text-2); line-height: 1.65;
}

.rcard__arrow {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .88rem; font-weight: 600; color: var(--teal);
  margin-top: .85rem;
}
.rcard:hover .rcard__arrow { text-decoration: underline; }

/* ── Research detail page ───────────────────────────────────────── */
.research-detail { max-width: 780px; margin: 0 auto; }

.research-detail__hero-img {
  width: 85%; max-width: 620px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md); margin: 0 auto 2rem;
}

.research-detail__tag {
  display: inline-block;
  font-size: .75rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: .22rem .7rem; border-radius: 999px;
  margin-bottom: .8rem;
}

.research-detail__title {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 800; color: var(--navy);
  line-height: 1.25; margin-bottom: 1.2rem;
}

.research-detail__body {
  font-size: 1.08rem; color: var(--text-2); line-height: 1.85;
}
.research-detail__body p { margin-bottom: 1.2rem; }

.research-detail__tools {
  margin-top: 1.8rem; padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: .92rem; color: var(--text-3); font-style: italic;
}

.research-detail__back {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .95rem; font-weight: 600; color: var(--teal);
  margin-bottom: 2rem;
}
.research-detail__back:hover { text-decoration: underline; }

/* ── Publications ───────────────────────────────────────────────── */
.pub-year {
  font-size: 1.4rem; font-weight: 700; color: var(--navy);
  margin: 2.8rem 0 1rem; padding-bottom: .45rem;
  border-bottom: 2px solid var(--teal-lt);
}
.pub-year:first-child { margin-top: .5rem; }

.pub {
  padding: .65rem .85rem .65rem 1.1rem;
  margin-bottom: .6rem;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  transition: border-color .15s, background .15s;
}
.pub:hover { border-left-color: var(--teal); background: var(--teal-lt); }

.pub__title {
  font-weight: 600; font-size: 1.15rem; line-height: 1.45;
  color: var(--teal);
}
.pub__title:hover { color: var(--teal-dk); text-decoration: underline; }

.pub__meta {
  font-size: 1.05rem; color: var(--text-2);
  line-height: 1.65; margin-top: .25rem;
}

/* ── Footer ─────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0; text-align: center;
  font-size: .85rem; color: var(--text-3);
}

/* ── Scroll reveal animation ────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .6s ease, transform .6s ease;
}
.reveal--visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.reveal-stagger > .reveal:nth-child(1) { transition-delay: 0s; }
.reveal-stagger > .reveal:nth-child(2) { transition-delay: .12s; }
.reveal-stagger > .reveal:nth-child(3) { transition-delay: .24s; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .home-page { height: auto; overflow: auto; }
  .hero { padding: 3.5rem 0 3rem; }
  .hero--full { padding: 2.5rem 0; }
  .hero--full::before { display: none; }
  .hero__row { flex-direction: column-reverse; text-align: center; gap: 2rem; }
  .hero__tagline { justify-content: center; }
  .hero__bio { max-width: none; font-size: 1rem; }
  .hero__icons { justify-content: center; }
  .hero__photo img { width: 150px; height: 150px; }
  .research-grid { grid-template-columns: 1fr; }
  .section { padding: 3rem 0; }
  .container { padding: 0 1.25rem; }
}
