/* liuwei.ai — no framework, no build step.
   Restrained on purpose: the credentials are the design. */

:root {
  --bg: #fdfdfc;
  --surface: #f6f6f3;
  --border: #e4e4de;
  --text: #17171a;
  --muted: #56565e;
  /* Tuned to clear WCAG AA 4.5:1 at small sizes. */
  --faint: #6b6b72;
  --accent: #1b4dd8;
  --accent-soft: #eef1fe;
  --max: 48rem;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Songti SC", "Noto Serif CJK SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121216;
    --surface: #1b1b21;
    --border: #2d2d36;
    --text: #e9e9e6;
    --muted: #a6a6ae;
    --faint: #9a9aa2;
    --accent: #8fb4ff;
    --accent-soft: #1b2338;
  }
}

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

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  /* --accent is light in dark mode, so white-on-accent fails there.
     Pin both colours instead of inheriting. */
  color: var(--bg);
  padding: 0.6rem 1rem;
  z-index: 100;
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

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

a:hover {
  border-bottom-color: currentColor;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.7rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  border: 0;
  letter-spacing: 0.02em;
}

.brand:hover {
  color: var(--text);
  border: 0;
}

nav.sections {
  margin-left: auto;
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
}

nav.sections a {
  font-size: 0.875rem;
  color: var(--muted);
  border: 0;
}

nav.sections a:hover {
  color: var(--accent);
  border: 0;
}

.lang-toggle {
  font-family: var(--sans);
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.lang-toggle:hover {
  color: var(--text);
  border-color: var(--faint);
}

/* ---------- hero ---------- */

.hero {
  padding: 4rem 0 2.25rem;
}

/* Theory · Method · Systems. Sits below the tagline: the institution,
   name and title lead, following the convention in academic homepages. */
.spine {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.spine li + li::before {
  content: "·";
  margin-right: 0.75rem;
  color: var(--border);
}

/* Name and portrait sit side by side; portrait yields first on narrow screens. */
.hero-main {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
}

.hero-text {
  flex: 1 1 auto;
  min-width: 0;
}

.portrait {
  flex: 0 0 auto;
  display: block;
  order: 2;
}

.portrait img {
  display: block;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--border);
}

/* Institution first, in the manner of a letterhead. */
.institution {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 0.9rem;
}

h1 {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 5.5vw, 3rem);
  line-height: 1.12;
  font-weight: 600;
  margin: 0 0 0.3rem;
  letter-spacing: -0.015em;
}

.role {
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 1.1rem;
}

.role .sep {
  color: var(--border);
  margin: 0 0.15rem;
}

.tagline {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 2.2vw, 1.3rem);
  line-height: 1.5;
  color: var(--text);
  margin: 0;
  max-width: 36rem;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.75rem;
  padding: 0;
  list-style: none;
}

.quick-links a {
  display: inline-block;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
}

.quick-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- sections ---------- */

main section {
  padding: 2.75rem 0;
  border-top: 1px solid var(--border);
}

main section:first-child {
  border-top: 0;
}

h2 {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
  margin: 0 0 1.5rem;
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  line-height: 1.4;
}

p {
  margin: 0 0 1rem;
}

p:last-child {
  margin-bottom: 0;
}

.lead {
  color: var(--muted);
  margin-bottom: 1.75rem;
}

/* ---------- research: three layers, each with its proof ---------- */

.areas {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 2rem;
  counter-reset: layer;
}

.area {
  counter-increment: layer;
  padding-left: 1.5rem;
  border-left: 2px solid var(--border);
  position: relative;
}

.area-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.area-body {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

/* The receipt for each claim. */
.area-proof {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--faint);
  margin: 0.5rem 0 0;
}

/* Key facts: collapsed by default so the prose reads cleanly, but present
   in the HTML and expandable — visible to readers, not crawler-only text. */
.facts {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.facts summary {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  cursor: pointer;
}

.facts summary:hover {
  color: var(--text);
}

.facts ul {
  margin: 1rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.6rem;
}

.facts li {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- publications ---------- */

/* The PRL stands alone. It is the strongest single credential on the page. */
.pub-featured {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 6px;
  padding: 1.4rem 1.5rem;
  margin-bottom: 2rem;
}

.pub-featured-venue {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin: 0 0 0.4rem;
}

.pub-featured-title {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 0.5rem;
}

.pub-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.6rem;
}

.pub {
  display: grid;
  gap: 0.25rem;
}

.pub-title {
  font-weight: 600;
  line-height: 1.45;
}

.pub-authors,
.pub-venue {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0;
}

.pub-authors strong {
  color: var(--text);
}

.pub-venue em {
  font-style: italic;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.2rem;
}

.pub-links a {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
}

.pub-more {
  margin: 2rem 0 0;
  font-size: 0.875rem;
}

/* Status badges: a preprint must never read as a published paper. */
.badge {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  vertical-align: 0.1em;
  margin-left: 0.4rem;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ---------- projects ---------- */

.proj-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.75rem;
}

.proj-site {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--faint);
  margin-left: 0.5rem;
}

/* Domain shown but not yet linkable: reads as a label, not a dead link. */
.proj-site-pending {
  opacity: 0.75;
}

.proj-role {
  font-size: 0.8rem;
  font-family: var(--mono);
  color: var(--faint);
  margin: 0 0 0.4rem;
}

.proj-body {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 0.4rem;
}

.proj-stat {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--faint);
  margin: 0 0 0.6rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.tags li {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 3px;
}

/* ---------- contact ---------- */

.email-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.email-row a {
  border: 0;
}

.email-row code {
  font-family: var(--mono);
  font-size: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  color: var(--text);
}

.email-row a:hover code {
  border-color: var(--accent);
  color: var(--accent);
}

.copy-btn {
  font-size: 0.78rem;
  font-family: var(--sans);
  padding: 0.25rem 0.6rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

.copy-btn:hover {
  color: var(--text);
  border-color: var(--faint);
}

footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0 3rem;
  font-size: 0.82rem;
  color: var(--faint);
}

.notice {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  margin: 1.5rem 0 0;
}

.notice code {
  font-family: var(--mono);
  font-size: 0.85em;
}

/* ---------- narrow screens ---------- */


@media (max-width: 34rem) {
  .hero {
    padding-top: 2.75rem;
  }
  nav.sections {
    display: none;
  }
  .topbar-inner {
    justify-content: space-between;
  }
  /* 44px minimum touch target. */
  .lang-toggle,
  .copy-btn {
    min-height: 44px;
    min-width: 44px;
    padding-inline: 0.9rem;
  }
  .quick-links a {
    padding: 0.65rem 0.95rem;
  }
  .area {
    padding-left: 1.1rem;
  }
  .pub-featured {
    padding: 1.2rem 1.1rem;
  }
  /* Portrait leads on mobile: smaller, above the name. */
  .hero-main {
    flex-direction: column;
    gap: 1.1rem;
  }
  .portrait {
    order: -1;
  }
  .portrait img {
    width: 96px;
    height: 96px;
  }
}

@media print {
  .topbar,
  .lang-toggle,
  .copy-btn,
  .skip-link,
  .quick-links {
    display: none;
  }
  body {
    color: #000;
    background: #fff;
  }
  a {
    color: #000;
  }
  .pub-featured {
    background: none;
    border-color: #ccc;
  }
  main section {
    padding: 1rem 0;
    break-inside: avoid;
  }
}
