/* ==========================================================================
   Academic Homepage — Junyi Li (https://junyi-24.github.io)
   --------------------------------------------------------------------------
   Table of contents
   1. CSS variables & base
   2. Layout
   3. Profile header
   4. Sections (shared)
   5. News
   6. Publications
   7. Research experience
   8. Honors & Awards
   9. Education
   10. Footer
   11. Theme toggle button
   12. Responsive (mobile)
   ========================================================================== */

/* 1. CSS variables & base ------------------------------------------------- */
:root {
  color-scheme: light;
  --color-bg: #fafafc;
  --color-surface: #ffffff;
  --color-text: #1d1d1f;
  --color-text-secondary: #57575e;
  --color-accent: #660874;                      /* Tsinghua purple */
  --color-accent-soft: rgba(102, 8, 116, 0.08);
  --color-border: #e4e4ea;
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #111114;
  --color-surface: #1b1b21;
  --color-text: #e9e9ec;
  --color-text-secondary: #a3a3ae;
  --color-accent: #c084fc;
  --color-accent-soft: rgba(192, 132, 252, 0.14);
  --color-border: #2b2b33;
  --shadow-card: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei",
               sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--color-accent); color: #ffffff; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* 2. Layout --------------------------------------------------------------- */
html { scroll-behavior: smooth; }

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 36px 24px 48px;
}

/* Top navigation (fixed). Sections need scroll-margin-top so anchors are
   not hidden behind it; see section 4. */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 52px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;   /* center the links on wide screens */
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;          /* scrolls horizontally on small screens */
  scrollbar-width: none;     /* Firefox: hide the scrollbar */
}
.nav-links::-webkit-scrollbar { display: none; }  /* WebKit: hide it */

.nav-links a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--color-text);
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover { background: var(--color-accent-soft); }
.nav-links a.active { background: var(--color-accent); color: #ffffff; }

/* 3. Profile header ------------------------------------------------------- */
.profile {
  display: flex;
  align-items: center;
  gap: 28px;
  padding-bottom: 8px;
}

.avatar {
  flex: 0 0 120px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;                /* crops the photo to fill the circle */
  background: var(--color-accent-soft);   /* shown while the photo loads */
  border: 1px solid var(--color-border);
}

.name { margin: 0 0 4px; font-size: 1.9rem; font-weight: 700; line-height: 1.25; }
.name-zh {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-left: 8px;
}

.affiliation { margin: 0 0 10px; color: var(--color-text-secondary); }

.contact {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
}
.contact li + li::before { content: "·"; margin: 0 10px; color: var(--color-text-secondary); }

/* 4. Sections (shared) ---------------------------------------------------- */
section { margin-top: 44px; scroll-margin-top: 70px; }  /* clear fixed nav */

h2 {
  margin: 0 0 16px;
  padding-left: 12px;
  border-left: 4px solid var(--color-accent);
  font-size: 1.35rem;
  line-height: 1.3;
}

section p { margin: 0 0 12px; }
section p:last-child { margin-bottom: 0; }

.interest-list { margin: 0; padding-left: 20px; }
.interest-list li { margin: 6px 0; }

.load-error { font-style: italic; color: var(--color-text-secondary); }

/* Language switching: English is the default; Chinese shows when
   <html data-lang="zh"> is set by the toggle button. */
.zh { display: none; }
[data-lang="zh"] .zh { display: inline; }
[data-lang="zh"] .en { display: none; }

/* .any — content shown in BOTH languages (e.g. paper titles and venues
   that stay in English). Without .en/.zh a span would already show in
   both modes; this class makes the intent explicit. */
.any { display: inline; }

/* 5. News ----------------------------------------------------------------- */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li { display: flex; gap: 14px; padding: 5px 0; }
.news-list time {
  flex: 0 0 88px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
}

/* 6. Publications --------------------------------------------------------- */
.publication-list { list-style: none; margin: 0; padding: 0; }
.publication { padding: 10px 0 14px; border-bottom: 1px dashed var(--color-border); }
.publication:last-child { border-bottom: none; }

.pub-title { margin: 0 0 4px; font-size: 1.05rem; font-weight: 600; line-height: 1.45; }
.pub-authors { margin: 0 0 2px; font-size: 0.95rem; color: var(--color-text-secondary); }
.pub-authors strong { color: var(--color-text); }
.pub-venue { margin: 0; font-size: 0.92rem; font-style: italic; color: var(--color-text-secondary); }

.pub-note {
  display: inline-block;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-style: normal;
  font-size: 0.8em;
  font-weight: 600;
  vertical-align: 1px;
}

.pub-link { font-style: normal; font-weight: 600; }

/* 7. Research experience --------------------------------------------------- */
.exp-item { padding: 10px 0; }
.exp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.exp-head h3 { margin: 0; font-size: 1.05rem; }
.exp-date { font-size: 0.92rem; font-weight: 600; color: var(--color-accent); }
.exp-role { margin: 2px 0 6px; color: var(--color-text-secondary); }
.exp-item ul { margin: 0; padding-left: 20px; }

/* 8. Honors & Awards ------------------------------------------------------ */
.honor-list { list-style: none; margin: 0; padding: 0; }
.honor-list li {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 7px 0;
  border-bottom: 1px dashed var(--color-border);
}
.honor-list li:last-child { border-bottom: none; }
.honor-name { font-weight: 600; }
.honor-grantor { flex: 1; min-width: 200px; color: var(--color-text-secondary); }
.honor-date {
  font-size: 0.92rem;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

/* 9. Education ------------------------------------------------------------ */
.edu-list { list-style: none; margin: 0; padding: 0; }
.edu-list li { padding: 8px 0; }
.edu-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.edu-head h3 { margin: 0; font-size: 1.05rem; }
.edu-date { font-size: 0.92rem; font-weight: 600; color: var(--color-accent); }
.edu-list p { margin: 2px 0 0; color: var(--color-text-secondary); }

/* 10. Footer -------------------------------------------------------------- */
footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}
footer p { margin: 0; }

/* 11. Corner controls (language & theme buttons, inside the top nav) ------- */
.corner-controls { display: flex; gap: 6px; flex: 0 0 auto; }

.icon-button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: border-color 0.15s, color 0.15s;
}
.icon-button:hover { border-color: var(--color-accent); color: var(--color-accent); }
.icon-button svg { width: 18px; height: 18px; }

/* Theme icons: sun only in dark mode, moon only in light mode */
#theme-toggle .icon-sun { display: none; }
[data-theme="dark"] #theme-toggle .icon-sun { display: block; }
[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

/* Language button shows the language it switches TO */
#lang-toggle .lang-en { display: none; }
[data-lang="zh"] #lang-toggle .lang-zh { display: none; }
[data-lang="zh"] #lang-toggle .lang-en { display: inline; }

/* 12. Responsive (mobile) ------------------------------------------------- */
@media (max-width: 640px) {
  .container { padding: 20px 16px 40px; }

  .topnav { padding: 0 8px; height: 48px; }
  /* On mobile the links scroll horizontally; left-align so the first
     links are reachable (centered overflow clips the start of the list). */
  .nav-links { justify-content: flex-start; }
  .nav-links a { padding: 6px 10px; font-size: 0.9rem; }
  .icon-button { width: 32px; height: 32px; }

  .profile {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
  .avatar { flex-basis: auto; width: 104px; height: 104px; }
  .contact { justify-content: center; }

  section { margin-top: 36px; }

  .news-list li { flex-direction: column; gap: 2px; }
  .news-list time { flex-basis: auto; }

  .honor-list li { flex-direction: column; gap: 2px; }
  .honor-grantor { min-width: 0; }

}
