/* Xiao Liang homepage — soft rose & lavender theme */

:root {
  --bg: #fdf8f9;
  --bg-glow-1: rgba(244, 196, 214, 0.45);
  --bg-glow-2: rgba(214, 199, 240, 0.40);
  --surface: #ffffff;
  --surface-2: #fbf1f5;
  --text: #3d2f3a;
  --muted: #86727f;
  --heading: #2f2230;
  --accent: #b9517d;
  --accent-hover: #9c3c66;
  --accent-2: #8c6cc0;
  --border: #f0dee6;
  --chip-bg: #fbecf2;
  --chip-text: #9c3c66;
  --badge-bg: #b9517d;
  --badge-text: #ffffff;
  --thumb-bg: linear-gradient(140deg, #fdeef4 0%, #f3ecfb 100%);
  --thumb-line: #dcc3d0;
  --thumb-fill-1: #f7d9e5;
  --thumb-fill-2: #ead9f6;
  --thumb-fill-3: #f1c7d8;
  --shadow: 0 1px 2px rgba(120, 60, 90, 0.05), 0 8px 28px rgba(150, 80, 120, 0.08);
  --code-bg: #fbf3f6;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1519;
    --bg-glow-1: rgba(185, 81, 125, 0.16);
    --bg-glow-2: rgba(140, 108, 192, 0.14);
    --surface: #241c22;
    --surface-2: #2b2129;
    --text: #efe4ea;
    --muted: #b4a1ad;
    --heading: #fbf2f6;
    --accent: #f0a1c2;
    --accent-hover: #f7c0d7;
    --accent-2: #c4aaf0;
    --border: #3a2c36;
    --chip-bg: #3a2533;
    --chip-text: #f6c3d8;
    --badge-bg: #f0a1c2;
    --badge-text: #2a1622;
    --thumb-bg: linear-gradient(140deg, #2e2029 0%, #272237 100%);
    --thumb-line: #5a4453;
    --thumb-fill-1: #4a2e3e;
    --thumb-fill-2: #3c3156;
    --thumb-fill-3: #5a3249;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
    --code-bg: #1e171c;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1b1519;
  --bg-glow-1: rgba(185, 81, 125, 0.16);
  --bg-glow-2: rgba(140, 108, 192, 0.14);
  --surface: #241c22;
  --surface-2: #2b2129;
  --text: #efe4ea;
  --muted: #b4a1ad;
  --heading: #fbf2f6;
  --accent: #f0a1c2;
  --accent-hover: #f7c0d7;
  --accent-2: #c4aaf0;
  --border: #3a2c36;
  --chip-bg: #3a2533;
  --chip-text: #f6c3d8;
  --badge-bg: #f0a1c2;
  --badge-text: #2a1622;
  --thumb-bg: linear-gradient(140deg, #2e2029 0%, #272237 100%);
  --thumb-line: #5a4453;
  --thumb-fill-1: #4a2e3e;
  --thumb-fill-2: #3c3156;
  --thumb-fill-3: #5a3249;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
  --code-bg: #1e171c;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 520px at 8% -8%, var(--bg-glow-1), transparent 60%),
    radial-gradient(760px 520px at 100% 2%, var(--bg-glow-2), transparent 60%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16.5px;
  line-height: 1.7;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 72px 28px 40px;
}

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 44px;
  align-items: center;
  margin-bottom: 56px;
}

.portrait {
  position: relative;
  width: 220px;
}
.portrait::before {
  content: "";
  position: absolute;
  inset: -12px -12px 12px 12px;
  border-radius: 46% 54% 42% 58% / 55% 45% 55% 45%;
  background: linear-gradient(150deg, var(--thumb-fill-1), var(--thumb-fill-2));
  z-index: 0;
}
.portrait img {
  position: relative;
  z-index: 1;
  display: block;
  width: 220px;
  height: auto;
  aspect-ratio: 220 / 271;
  object-fit: cover;
  border-radius: 28px;
  box-shadow: var(--shadow);
  background: var(--surface-2);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, h3 {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  color: var(--heading);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(2.3rem, 5vw, 3.1rem);
  line-height: 1.1;
}

.tagline {
  margin: 0 0 14px;
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 1.12rem;
  color: var(--accent);
}

.lead { font-size: 1.08rem; }

.playground {
  margin: 28px 0 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.playground canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 880 / 260;
  border-radius: 12px;
  cursor: crosshair;
  touch-action: manipulation;
}
.playground figcaption {
  margin-top: 10px;
  font-size: .88rem;
  color: var(--muted);
  line-height: 1.55;
}
.pg-title {
  margin-right: 6px;
  color: var(--accent);
  font-weight: 700;
}

.affil { margin: 0 0 10px; color: var(--muted); line-height: 1.55; }
.affil a { color: var(--text); }
.affil a:hover { color: var(--accent); }

.email {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: .95rem;
}
.email i { color: var(--accent); }

.links { display: flex; flex-wrap: wrap; gap: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(120, 60, 90, 0.05);
  transition: transform .15s ease, border-color .15s ease, color .15s ease;
}
.pill i { color: var(--accent); font-size: 1rem; }
.pill:hover { text-decoration: none; color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }

/* ---------- sections ---------- */
.section { margin-bottom: 52px; }

h2 {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
  font-size: 1.65rem;
}
h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}
h2.sub { margin-top: 40px; font-size: 1.3rem; }

.section p { margin: 0 0 14px; }

.interests {
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.interests li {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: .88rem;
  font-weight: 600;
}

/* ---------- papers ---------- */
.papers { list-style: none; padding: 0; margin: 0; display: grid; gap: 22px; }

.paper {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 26px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.thumb {
  position: relative;
  align-self: start;
  border-radius: 16px;
  background: var(--thumb-bg);
  overflow: hidden;
  aspect-ratio: 240 / 150;
}
.thumb svg { display: block; width: 100%; height: 100%; font-family: "Fraunces", Georgia, serif; }
.badge {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.paper h3 { margin: 0 0 6px; font-size: 1.14rem; line-height: 1.35; }
.paper h3 a { color: var(--heading); }
.paper h3 a:hover { color: var(--accent); }
.authors { margin: 0 0 2px !important; font-size: .94rem; }
.authors b { color: var(--heading); font-weight: 700; }
.venue { margin: 0 0 10px !important; color: var(--muted); font-style: italic; font-size: .92rem; }
.note { font-style: normal; font-size: .85rem; }
.tldr { margin: 0 0 14px !important; font-size: .93rem; color: var(--text); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.chip {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 8px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.chip:hover { text-decoration: none; filter: brightness(.97); color: var(--accent-hover); }
details.bib[open] { flex-basis: 100%; }
details.bib summary { width: max-content; }
details.bib summary::-webkit-details-marker { display: none; }
.bib-box {
  position: relative;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--code-bg);
}
.bib-box pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: .78rem;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
}
.copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: .75rem;
  cursor: pointer;
}
.copy:hover { color: var(--accent); border-color: var(--accent); }

.others { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.others li {
  padding-left: 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  font-size: .95rem;
  line-height: 1.55;
}
.others li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: .62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--thumb-fill-3);
  border: 1.5px solid var(--accent);
}
.others a { color: var(--heading); font-weight: 600; }
.others a:hover { color: var(--accent); }
.others .authors { color: var(--text); font-size: .88rem; }
.others .venue { margin: 0 !important; font-size: .86rem; }

/* ---------- education ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  padding-bottom: 18px;
}
.timeline li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 18px;
  bottom: -2px;
  width: 2px;
  background: var(--border);
}
.timeline .dot {
  width: 14px;
  height: 14px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--accent);
}
.timeline p { margin: 0 !important; }
.degree { font-weight: 700; color: var(--heading); }
.school, .edu-note { color: var(--muted); font-size: .95rem; }

/* ---------- footer & toggle ---------- */
.footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
}

.top-controls {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}
.theme-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 1rem;
}
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
: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: inline; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* Grid items default to min-width:auto, so a long BibTeX line used to widen the card
   past the page; let the text column shrink and the code box scroll instead. */
.paper-body { min-width: 0; }

/* ---------- language switch ---------- */
.lang-switch {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: .9rem;
  line-height: 1;
  white-space: nowrap;
}
.lang-switch a,
.lang-switch .current { padding: 4px 2px; }
.lang-switch a { color: var(--accent); text-decoration: none; }
.lang-switch a:hover,
.lang-switch a:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
.lang-switch .current { color: var(--heading); font-weight: 700; }
.lang-switch .sep { color: var(--muted); padding: 0 6px; }

.alt-name {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 1rem;
}

/* ---------- Simplified Chinese typography ---------- */
/* Latin text keeps the web fonts; CJK falls back to system fonts (no web-font download). */
html[lang="zh-Hans"] body {
  font-family: "Nunito Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC",
    "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.85;
}
html[lang="zh-Hans"] h1,
html[lang="zh-Hans"] h2,
html[lang="zh-Hans"] .tagline {
  font-family: "Fraunces", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC",
    "Microsoft YaHei", serif;
}
html[lang="zh-Hans"] .tagline { font-style: normal; text-wrap: balance; }
/* CJK has no italic; emphasise with weight and colour instead of a synthetic slant. */
html[lang="zh-Hans"] #about em { font-style: normal; font-weight: 600; color: var(--heading); }
html[lang="zh-Hans"] .eyebrow { letter-spacing: .08em; }
/* Paper cards stay in English on the Chinese page. */
html[lang="zh-Hans"] [lang="en"] { line-height: 1.7; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .page { padding: 64px 16px 32px; }
  .hero { grid-template-columns: 1fr; gap: 28px; text-align: center; justify-items: center; margin-bottom: 44px; }
  .portrait, .portrait img { width: 180px; }
  .links { justify-content: center; }
  .paper { grid-template-columns: 1fr; gap: 16px; padding: 16px; }
  .thumb { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
