/* =========================================================
   Zhengjian Li — personal site
   Modern-nerdy, Futura-flavoured (Jost) with mono accents.
   ========================================================= */

:root {
  --font-sans: "Jost", "Futura", "Century Gothic", system-ui, sans-serif;
  --font-mono: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --maxw: 760px;
  --pad: 1.5rem;
  --radius: 4px;

  /* light theme — neutrals carry a faint cool/violet tint to match the accent */
  --bg:        #f6f5f9;
  --bg-soft:   #ecebf3;
  --fg:        #16141b;
  --fg-soft:   #57525f;
  --line:      #dad7e4;
  --accent:    #6d28d9;        /* royal purple (was orange #ff4b1f) */
  --accent-fg: #ffffff;
}

html[data-theme="dark"] {
  --bg:        #100f15;
  --bg-soft:   #1a1822;
  --fg:        #eeedf3;
  --fg-soft:   #9c97a8;
  --line:      #2b2935;
  --accent:    #a78bfa;        /* lighter purple to pop on dark (was #ff5e3a) */
  --accent-fg: #100f15;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 1em;
  line-height: 1.7;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}
a:hover { border-bottom-color: var(--accent); }

.mono { font-family: var(--font-mono); }

/* ---------- Header / nav ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.6rem var(--pad) 1rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--fg);
  border: none;
  font-weight: 500;
  font-size: 1.3rem;
}
.brand:hover { color: var(--fg); }
.brand-logo {
  height: 3rem;
  width: auto;
  display: block;
  flex: 0 0 auto;
}
.brand-name { letter-spacing: 0.04em; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  color: var(--fg-soft);
  font-size: 1rem;
  text-transform: lowercase;
  letter-spacing: 0.05em;
  border: none;
  padding: 0.35rem 0;
}
.nav-link:hover { color: var(--fg); }
.nav-link.is-active { color: var(--accent); }

/* toggle buttons */
.toggle {
  font-family: var(--font-mono);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg-soft);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.toggle:hover { border-color: var(--accent); color: var(--fg); }

.lang-toggle .lang-sep { opacity: 0.4; margin: 0 0.15rem; }
.lang-toggle .lang-opt { transition: color 0.15s ease, opacity 0.15s ease; }
.lang-toggle .lang-opt.is-active { color: var(--accent); }
.lang-toggle .lang-opt:not(.is-active) { opacity: 0.5; }

.theme-toggle { display: inline-grid; place-items: center; }
.theme-icon { grid-area: 1 / 1; font-size: 1.15rem; }
html[data-theme="light"] .theme-icon--sun { display: none; }
html[data-theme="dark"]  .theme-icon--moon { display: none; }

/* ---------- Layout ---------- */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem var(--pad) 4rem;
}

.section-tag {
  color: var(--accent);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  margin: 0 0 0.6rem;
}

/* ---------- Hero ---------- */
.hero {
  display: flex;
  align-items: center;
  gap: 2.2rem;
  padding: 2.5rem 0 3rem;
  border-bottom: 1px solid var(--line);
}
.hero--compact { display: block; padding-bottom: 1.5rem; }
.hero-photo {
  flex: 0 0 auto;
  order: 2;            /* sit to the right of the text on desktop */
  width: 170px;
  height: 170px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-soft);
}
/* glitch-reveal only on a page switch (.is-switching), not on a hard refresh */
.is-switching .hero-photo { animation: photo-glitch 0.55s steps(1, end) both; }
/* glitch-out when leaving a page (plays the reveal in reverse) */
.is-leaving   .hero-photo { animation: photo-glitch 0.42s steps(1, end) reverse both; }
@keyframes photo-glitch {
  0%   { clip-path: inset(12% 0 58% 0); transform: translate(-5px, 1px); filter: saturate(1.7) hue-rotate(40deg); }
  18%  { clip-path: inset(55% 0 18% 0); transform: translate(5px, -1px);  filter: saturate(1.4) hue-rotate(-30deg); }
  34%  { clip-path: inset(30% 0 40% 0); transform: translate(-3px, 0);    filter: none; }
  50%  { clip-path: inset(68% 0 8% 0);  transform: translate(3px, 0); }
  66%  { clip-path: inset(8% 0 70% 0);  transform: translate(-2px, 0); }
  82%  { clip-path: inset(40% 0 30% 0); transform: translate(1px, 0); }
  100% { clip-path: inset(0 0 0 0);     transform: none; filter: none; }
}
/* graceful placeholder if no photo file is present yet */
.hero-photo.is-missing {
  position: relative;
}
.hero-photo.is-missing::after {
  content: "your photo →\Aassets/img/profile.jpg";
  white-space: pre;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-soft);
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 0.5rem;
}
.hero-text { min-width: 0; flex: 1; }
.hero-name {
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.01em;
  margin: 0 0 0.5rem;
}
.hero-role { font-size: 1.25rem; font-weight: 500; margin: 0; }
.hero-affil { color: var(--fg-soft); margin: 0.1rem 0 0; }
.hero-tagline { max-width: 48ch; margin: 0; }

/* ---------- Content blocks ---------- */
.block { padding: 2.2rem 0; border-bottom: 1px solid var(--line); }
.block-title {
  font-size: 1.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 0 0 1.1rem;
}
.block-body p { margin: 0 0 1.1rem; }
.block-body p:last-child { margin-bottom: 0; }

/* news */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-item {
  display: flex;
  gap: 1.1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}
.news-item:first-child { border-top: none; padding-top: 0; }
.news-date {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 0.95rem;
  padding-top: 0.15rem;
  white-space: nowrap;
}
.news-text { margin: 0; }

/* link list */
.link-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.6rem;
  margin: 0;
  padding: 0;
}
.link-list { font-size: 1rem; }
.link-list li::before { content: "→ "; color: var(--accent); }

.email-plain {
  margin: 1rem 0 0;
  font-size: 0.95rem;
  color: var(--fg-soft);
  user-select: none; /* nudge people to type it rather than copy-paste */
}

/* ---------- Publications ---------- */
.pub-year { padding: 2rem 0 0.5rem; }
.year-label {
  color: var(--fg-soft);
  font-size: 1rem;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.4rem;
  margin: 0 0 1.4rem;
}
.pub {
  margin: 0 0 1.8rem;
  padding-left: 1rem;
  border-left: 2px solid var(--line);
  transition: border-color 0.2s ease;
}
.pub:hover { border-left-color: var(--accent); }
.pub-type {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  margin: 0 0 0.5rem;
  border-radius: var(--radius);
  border: 1px solid currentColor;
  --pub-tone: var(--fg-soft);   /* default tone, overridden per type */
  color: var(--pub-tone);
}
/* per-type accent tones */
.pub--journal    .pub-type { --pub-tone: #2563eb; }  /* blue   */
.pub--preprint   .pub-type { --pub-tone: #d97706; }  /* amber  */
.pub--conference .pub-type { --pub-tone: #16a34a; }  /* green  */
html[data-theme="dark"] .pub--journal    .pub-type { --pub-tone: #60a5fa; }
html[data-theme="dark"] .pub--preprint   .pub-type { --pub-tone: #fbbf24; }
html[data-theme="dark"] .pub--conference .pub-type { --pub-tone: #4ade80; }
/* the left border of each entry picks up its type tone on hover */
.pub--journal:hover    { border-left-color: #2563eb; }
.pub--preprint:hover   { border-left-color: #d97706; }
.pub--conference:hover  { border-left-color: #16a34a; }

.pub-title { font-size: 1.3rem; font-weight: 500; margin: 0 0 0.3rem; line-height: 1.3; }
.pub-authors { margin: 0 0 0.2rem; color: var(--fg); }
.pub-authors strong { color: var(--accent); font-weight: 700; }
.pub-venue { color: var(--fg-soft); font-size: 0.95rem; margin: 0 0 0.4rem; font-style: italic; }
.pub-links { font-size: 0.95rem; margin: 0; display: flex; flex-wrap: wrap; gap: 0.9rem; }

/* ---------- Language scramble effect ---------- */
.i18n-glitch .dud { color: var(--accent); opacity: 0.85; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  :root { --pad: 1.15rem; }

  .site-header {
    padding-top: 1.1rem;
    padding-bottom: 1rem;
    row-gap: 1.1rem;
  }
  /* brand on its own row, nav wraps below full-width with a divider above it */
  .brand { flex: 1 0 100%; }
  .site-nav {
    flex: 1 0 100%;
    gap: 1rem 1.4rem;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
  }
  .nav-link { font-size: 1.25rem; }
  /* push the toggles to the right edge of the nav row */
  .lang-toggle { margin-left: auto; }

  /* stack the hero: photo above text */
  .hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.3rem;
    padding: 1.8rem 0 2.2rem;
  }
  .hero-photo { order: 0; width: 130px; height: 130px; }

  .block { padding: 1.8rem 0; }
  .news-item { gap: 0.85rem; }
}
