/* ==========================================================================
   Xiang Li — personal homepage
   Plain CSS, no build step. Light/dark via `color-scheme` + light-dark().
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Fallback values first (older browsers), then light-dark() overrides. */
  --bg: #ffffff;           --bg: light-dark(#ffffff, #0b0d12);
  --bg-elev: #f5f6f8;      --bg-elev: light-dark(#f5f6f8, #12151c);
  --text: #15181e;         --text: light-dark(#15181e, #e7e9ee);
  --text-2: #4a5160;       --text-2: light-dark(#4a5160, #a6aebc);
  --muted: #6f7787;        --muted: light-dark(#6f7787, #7d8696);
  --line: #e6e8ec;         --line: light-dark(#e6e8ec, #232936);
  --accent: #1f5fd8;       --accent: light-dark(#1f5fd8, #8ab4ff);
  --accent-soft: #e9f0ff;  --accent-soft: light-dark(#e9f0ff, #172443);
  --chip: #eef0f3;         --chip: light-dark(#eef0f3, #1a1f29);
  --award: #b7791f;        --award: light-dark(#b7791f, #f2c063);
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 10px 30px -14px rgba(0, 0, 0, .25);

  --maxw: 900px;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

img { max-width: 100%; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

.skip-link {
  position: absolute; left: 8px; top: -100px;
  padding: 8px 12px; background: var(--accent); color: #fff; border-radius: 8px; z-index: 100;
}
.skip-link:focus { top: 8px; }

/* --------------------------------------------------------------------------
   Top navigation
   -------------------------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { font-weight: 650; letter-spacing: -0.01em; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 6px; }
.nav-links { display: flex; gap: 2px; }
.nav-links a {
  padding: 6px 10px; border-radius: 8px; color: var(--text-2); font-size: 14.5px; font-weight: 500;
}
.nav-links a:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin-left: 6px;
  border: 1px solid var(--line); border-radius: 9px; background: transparent; cursor: pointer;
  color: var(--text-2);
}
.theme-toggle:hover { background: var(--bg-elev); color: var(--text); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* --------------------------------------------------------------------------
   Hero / about
   -------------------------------------------------------------------------- */
.hero {
  display: grid; grid-template-columns: 1fr 224px; gap: 44px; align-items: start;
  padding: 52px 0 0;
}
.hero h1 {
  margin: 0; font-size: 42px; line-height: 1.1; font-weight: 750; letter-spacing: -0.025em;
}
.hero h1 .zh { font-weight: 500; color: var(--text-2); font-size: 0.66em; margin-left: 10px; letter-spacing: 0; }
.role { margin: 12px 0 0; font-size: 17.5px; color: var(--text-2); }
.role strong { color: var(--text); font-weight: 600; }
.prev { margin: 4px 0 0; font-size: 15px; color: var(--muted); }
.prev a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.prev a:hover { color: var(--accent); text-decoration-color: currentColor; }

.contacts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font-size: 14px; font-weight: 500; line-height: 1.2;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

.portrait {
  width: 224px; height: 224px; object-fit: cover; display: block;
  border-radius: 22px; box-shadow: var(--shadow);
}

.bio { margin: 26px 0 0; font-size: 17px; line-height: 1.75; max-width: 70ch; }

/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */
.section { padding-top: 46px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-bottom: 10px; margin-bottom: 18px; border-bottom: 1px solid var(--line);
}
.section h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.015em; }
.section-note { color: var(--muted); font-size: 13.5px; }

/* --------------------------------------------------------------------------
   Highlight cards (Grok Imagine / Veo)
   -------------------------------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.card {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: var(--bg-elev); color: inherit;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.card-body { padding: 14px 16px 16px; }
.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card-title { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.card-org { color: var(--muted); font-size: 13px; white-space: nowrap; }
.card-role { margin: 3px 0 6px; color: var(--accent); font-size: 13px; font-weight: 600; }
.card p { margin: 0; color: var(--text-2); font-size: 14.5px; line-height: 1.55; }
.card-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 13.5px; font-weight: 500; }
.card-link svg { width: 14px; height: 14px; }
.card:hover .card-link { text-decoration: underline; text-underline-offset: 3px; }

/* --------------------------------------------------------------------------
   News
   -------------------------------------------------------------------------- */
.news { list-style: none; margin: 0; padding: 0; }
.news li {
  display: grid; grid-template-columns: 82px 1fr; gap: 14px;
  padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 15.5px;
}
.news li:last-child { border-bottom: 0; }
.news time { color: var(--muted); font-size: 13.5px; padding-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.news strong { font-weight: 600; }
.news-more { margin-top: 12px; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--text-2); font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.btn-ghost:hover { background: var(--bg-elev); color: var(--text); }

/* --------------------------------------------------------------------------
   Publications
   -------------------------------------------------------------------------- */
.pub-filters { display: flex; gap: 6px; }
.pub-filter {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--text-2); font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.pub-filter:hover { background: var(--bg-elev); color: var(--text); }
.pub-filter[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.pub-filter .count { opacity: .7; font-weight: 400; margin-left: 3px; }

.pub-year { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 20px; }
.pub-year + .pub-year { margin-top: 8px; }
.year-label {
  position: sticky; top: 70px; align-self: start;
  margin: 0; padding-top: 16px;
  font-size: 15px; font-weight: 700; color: var(--muted); letter-spacing: .02em;
}
.pub-list { list-style: none; margin: 0; padding: 0; }

.pub {
  display: grid; grid-template-columns: 184px minmax(0, 1fr); gap: 20px;
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.pub-thumb {
  display: block; width: 184px; height: 98px;
  border-radius: 10px; overflow: hidden;
  background: var(--bg-elev); border: 1px solid var(--line);
}
.pub-thumb img {
  width: 100%; height: 100%; object-fit: contain; display: block; padding: 4px;
  transition: transform .2s ease;
}
.pub:hover .pub-thumb img { transform: scale(1.03); }

.pub-title { margin: 0 0 4px; font-size: 16.5px; font-weight: 650; line-height: 1.35; letter-spacing: -0.005em; }
.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--accent); text-decoration: none; }
.pub-authors { margin: 0 0 7px; color: var(--text-2); font-size: 14.5px; line-height: 1.5; }
.pub-authors .me {
  color: var(--text); font-weight: 600;
  text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 3px;
}
.pub-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.venue {
  display: inline-block; padding: 2px 9px; border-radius: 6px;
  background: var(--chip); color: var(--text-2); font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
}
.venue.preprint { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.award { color: var(--award); font-size: 12.5px; font-weight: 600; }
.pub-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0 0; }
.pub-links a {
  font-size: 13px; font-weight: 500; padding: 3px 9px; border-radius: 6px;
  border: 1px solid var(--line); color: var(--accent); line-height: 1.4;
  transition: background .15s, border-color .15s;
}
.pub-links a:hover { background: var(--accent-soft); border-color: transparent; text-decoration: none; }
.pub-foot { margin: 14px 0 0; color: var(--muted); font-size: 13px; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.footer { margin-top: 64px; padding: 26px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 4px; }
.footer-links a { display: inline-flex; padding: 6px; border-radius: 8px; color: var(--muted); }
.footer-links a:hover { color: var(--accent); background: var(--bg-elev); }
.footer-links svg { width: 18px; height: 18px; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 760px) {
  .wrap { padding: 0 18px; }
  .nav-links a { padding: 6px 8px; font-size: 13.5px; }

  .hero { grid-template-columns: 1fr; gap: 22px; padding-top: 32px; }
  .portrait { order: -1; width: 148px; height: 148px; border-radius: 18px; }
  .hero h1 { font-size: 34px; }
  .hero h1 .zh { display: block; margin: 6px 0 0; font-size: 0.6em; }
  .bio { font-size: 16.5px; }

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

  .news li { grid-template-columns: 1fr; gap: 0; padding: 10px 0; }
  .news time { padding-top: 0; }

  .pub-year { grid-template-columns: 1fr; gap: 0; }
  .year-label { position: static; padding: 18px 0 0; }
  .pub { grid-template-columns: 1fr; gap: 12px; }
  .pub-thumb { width: 100%; height: 150px; }
}

@media (max-width: 420px) {
  .brand { display: none; }
  .nav-right { width: 100%; justify-content: space-between; }
  .nav-links a { padding: 6px 7px; font-size: 13px; }
}

@media print {
  .nav, .theme-toggle, .news-more, .pub-filters, .footer-links { display: none !important; }
  .pub { break-inside: avoid; }
  a { color: inherit; }
}
