/* Site stylesheet: academic CV homepage + blog pages.
   System fonts only (fast in every region, no external requests). */

:root {
  --ink: #1c2430;
  --body: #3a4656;
  --muted: #6b7684;
  --rule: #e3e6ea;
  --bg: #ffffff;
  --bg-soft: #f5f7f9;
  --accent: #1f4e8c;
  --accent-soft: #e9f0f9;
  --max: 900px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial,
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --serif: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  --mono: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--body);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover, a:focus { text-decoration: underline; }
img, video { max-width: 100%; }
strong { color: var(--ink); font-weight: 600; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0; }

.container { max-width: var(--max); margin: 0 auto; padding: 0 24px; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 6px 12px; z-index: 10; }
.skip-link:focus { left: 8px; }

/* ---------- Header & footer ---------- */
.site-header {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 16px; }
.site-name { font-weight: 650; font-size: 17px; color: var(--ink); white-space: nowrap; }
.site-name:hover { text-decoration: none; color: var(--accent); }
.site-name-zh { margin-left: 8px; font-weight: 400; color: var(--muted); }
.site-nav { display: flex; gap: 22px; font-size: 15px; overflow-x: auto; }
.site-nav a { color: var(--body); white-space: nowrap; }
.site-nav a:hover { color: var(--accent); text-decoration: none; }

.site-footer { border-top: 1px solid var(--rule); margin-top: 64px; padding: 24px 0 40px; font-size: 14px; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.footer-links a { margin-left: 18px; color: var(--muted); }
.footer-links a:hover { color: var(--accent); }

main.container { padding-top: 40px; }

/* ---------- Profile ---------- */
.profile { display: grid; grid-template-columns: 168px 1fr; gap: 36px; align-items: center; }
.avatar { width: 168px; height: 168px; border-radius: 50%; object-fit: cover; border: 1px solid var(--rule); }
.name { font-family: var(--serif); font-size: 40px; font-weight: 600; letter-spacing: -0.3px; }
.name-zh { font-family: var(--sans); font-size: 26px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.role { margin: 8px 0 0; font-size: 19px; color: var(--ink); font-weight: 500; }
.affiliation { margin: 2px 0 0; color: var(--muted); }
.profile-links { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 15px; }
.profile-links .fa { width: 16px; text-align: center; margin-right: 2px; }

.bio { margin-top: 28px; }
.bio p { margin: 0 0 14px; }
.tags { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li, a.tag {
  display: inline-block; font-size: 13.5px; padding: 3px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}

/* ---------- CV sections ---------- */
.cv-section { margin-top: 52px; }
.cv-section > h2 {
  font-family: var(--serif); font-size: 26px; font-weight: 600;
  padding-bottom: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--rule);
}

.news { list-style: none; padding: 0; margin: 0; }
.news li { display: grid; grid-template-columns: 96px 1fr; gap: 16px; padding: 5px 0; }
.news-date { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 15px; padding-top: 1px; }

.job { margin-bottom: 36px; }
.job-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.job-head h3 { font-size: 20px; font-weight: 600; }
.job-head h3 a { color: var(--ink); }
.org-zh { font-weight: 400; color: var(--muted); font-size: 0.85em; margin-left: 4px; }
.dates { color: var(--muted); font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.job-role { margin: 2px 0 0; font-style: italic; color: var(--ink); }
.job-note { margin: 2px 0 0; font-size: 14.5px; color: var(--muted); }
.job h4 { font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--accent); margin: 20px 0 6px; }
.bullets { margin: 8px 0 0; padding-left: 20px; }
.bullets li { margin-bottom: 6px; }
.bullets li::marker { color: var(--muted); }

/* projects */
.project { display: grid; grid-template-columns: 220px 1fr; gap: 28px; padding: 20px 0; border-bottom: 1px solid var(--rule); }
.project:last-child { border-bottom: none; }
.project-visual { align-self: start; }
.project-visual img, .project-visual video {
  width: 220px; height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--rule); background: var(--bg-soft); display: block;
}
.metric {
  width: 220px; height: 140px; border-radius: 8px; background: var(--bg-soft); border: 1px solid var(--rule);
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 12px;
}
.metric-value { font-family: var(--serif); font-size: 36px; font-weight: 600; color: var(--accent); line-height: 1.1; }
.metric-label { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.project-body h3 { font-size: 18px; font-weight: 600; }
.project-body h3 a { color: var(--ink); }
.project-body h3 a:hover { color: var(--accent); }
.project-where { margin: 2px 0 8px; font-size: 14.5px; color: var(--muted); }
.project-body p { margin: 0; }

/* skills */
.skills { display: grid; grid-template-columns: 150px 1fr; gap: 10px 24px; margin: 0; }
.skills dt { font-weight: 600; color: var(--ink); }
.skills dd { margin: 0; }

/* education */
.edu { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.edu strong { font-size: 17px; }
.edu-degree { font-style: italic; color: var(--ink); }

.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li { padding: 4px 0; }
.post-list-date, .post-date-list { color: var(--muted); font-size: 14px; margin-left: 8px; }
.more { margin-top: 10px; }
.updated { margin-top: 40px; font-size: 14px; color: var(--muted); }

/* ---------- Blog & pages ---------- */
.post, .page { max-width: 760px; }
.post-title, .page-title { font-family: var(--serif); font-size: 34px; font-weight: 600; margin: 4px 0 8px; }
.post-date { display: block; color: var(--muted); font-size: 15px; margin-bottom: 28px; }
.back { margin: 0; font-size: 14.5px; }
.post h1:not(.post-title), .page h1:not(.page-title) { font-size: 26px; margin: 36px 0 12px; }
.post h2, .page h2 { font-family: var(--serif); font-size: 24px; margin: 36px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.post h3, .page h3 { font-size: 19px; margin: 28px 0 10px; }
.post p, .page p { margin: 0 0 16px; }
.post ul, .post ol, .page ul, .page ol { padding-left: 22px; margin: 0 0 16px; }
.post li, .page li { margin-bottom: 6px; }
.page .lead { font-size: 17px; color: var(--muted); }
#list { list-style: none; padding: 0; }
#list li { padding: 4px 0; }
blockquote { margin: 0 0 16px; padding: 4px 18px; border-left: 3px solid var(--rule); color: var(--muted); }
code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; }
pre { font-family: var(--mono); font-size: 14px; background: var(--bg-soft); padding: 14px 16px; border-radius: 8px; overflow-x: auto; line-height: 1.5; }
pre code { background: none; padding: 0; }
table { border-collapse: collapse; width: 100%; margin: 0 0 16px; font-size: 15px; }
th, td { border-bottom: 1px solid var(--rule); padding: 8px 10px; text-align: left; }
.post-content img { border-radius: 6px; }
.post-meta { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--rule); }
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.post-nav { display: flex; justify-content: space-between; gap: 16px; font-size: 15px; }
.related { display: none; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .container { padding: 0 18px; }
  .site-name-zh { display: none; }
  .site-nav { gap: 16px; font-size: 15px; }
  .nav-anchor { display: none; }
  .profile { grid-template-columns: 1fr; gap: 18px; text-align: left; }
  .avatar { width: 112px; height: 112px; }
  .name { font-size: 32px; }
  .name-zh { font-size: 22px; }
  .news li { grid-template-columns: 1fr; gap: 0; }
  .project { grid-template-columns: 1fr; gap: 14px; }
  .project-visual img, .project-visual video, .metric { width: 100%; height: 160px; }
  .skills { grid-template-columns: 1fr; gap: 2px; }
  .skills dd { margin-bottom: 10px; }
  .post-title, .page-title { font-size: 28px; }
}

/* ---------- Print: the homepage prints as a clean CV ---------- */
@media print {
  @page { margin: 16mm 14mm; }
  body { font-size: 10.5pt; line-height: 1.45; color: #000; }
  .site-header, .site-footer, .skip-link, .no-print, .updated, .project-visual, #news, .tags { display: none !important; }
  main.container { padding: 0; max-width: none; }
  a { color: #000; }
  .profile { grid-template-columns: 90px 1fr; gap: 18px; }
  .avatar { width: 90px; height: 90px; }
  .name { font-size: 24pt; }
  .cv-section { margin-top: 18px; }
  .cv-section > h2 { font-size: 14pt; margin-bottom: 8px; }
  .project { grid-template-columns: 1fr; padding: 6px 0; border: none; }
  .bullets li, .project, .edu, .news li { break-inside: avoid; }
  .job-head, .job h4, .cv-section > h2 { break-after: avoid; }
  .job { margin-bottom: 14px; }
}

/* ---------- Project detail pages ---------- */
.crumbs { font-size: 14.5px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs span { margin: 0 8px; }

.project-page { max-width: 820px; }
.pp-title { font-family: var(--serif); font-size: 36px; font-weight: 600; letter-spacing: -0.3px; }
.pp-summary { font-size: 18px; color: var(--ink); margin: 12px 0 0; line-height: 1.55; }
.pp-meta { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 14px 0 0; font-size: 14.5px; color: var(--muted); }
.pp-meta .fa { margin-right: 4px; }
.pp-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 22px 0 0; }
.pp-metric { background: var(--bg-soft); border: 1px solid var(--rule); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; }
.pp-metric .metric-value { font-size: 28px; }
.pp-metric .metric-label { margin-top: 4px; }
.project-page .tags { margin-top: 18px; }
.pp-links { margin: 14px 0 0; display: flex; gap: 18px; flex-wrap: wrap; }

.toc { margin: 28px 0 8px; padding: 14px 18px; background: var(--bg-soft); border: 1px solid var(--rule); border-radius: 8px; font-size: 15px; }
.toc summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.toc ul { list-style: none; padding-left: 0; margin: 8px 0 0; }
.toc ul ul { padding-left: 18px; margin: 2px 0 4px; }
.toc li { margin: 3px 0; }

.pp-content { margin-top: 12px; }
.pp-content h2 { font-family: var(--serif); font-size: 25px; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.pp-content h3 { font-size: 19px; margin: 28px 0 10px; }
.pp-content p, .pp-content ul, .pp-content ol { margin: 0 0 16px; }
.pp-content ul, .pp-content ol { padding-left: 22px; }
.pp-content li { margin-bottom: 6px; }
.pp-content table { font-size: 14.5px; }
.pp-content th { background: var(--bg-soft); color: var(--ink); font-weight: 600; }
.pp-content td, .pp-content th { vertical-align: top; }
.pp-content figure { margin: 22px 0; }
.pp-content figure img, .pp-content figure video { display: block; width: 100%; border-radius: 8px; border: 1px solid var(--rule); }
.pp-content figcaption { font-size: 14px; color: var(--muted); margin-top: 6px; text-align: center; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 22px 0; }
.media-grid figure { margin: 0; }
.media-grid video, .media-grid img { aspect-ratio: 16 / 10; object-fit: cover; }

.pipeline { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 22px 0; }
.pipe-stage { display: flex; flex-direction: column; justify-content: center; padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); border: 1px solid #cfdcef; min-width: 96px; }
.pipe-name { font-weight: 600; color: var(--ink); font-size: 14.5px; line-height: 1.3; }
.pipe-note { font-size: 12.5px; color: var(--muted); line-height: 1.3; margin-top: 2px; }
.pipe-arrow { align-self: center; color: var(--accent); font-size: 18px; }

.callout { margin: 22px 0; padding: 14px 18px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; color: var(--ink); }
.callout p:last-child { margin-bottom: 0; }
.callout-result { border-left-color: #2f7d4f; background: #ecf6f0; }
.callout-caveat { border-left-color: #a86412; background: #fbf3e8; }

.back-links { margin-top: 14px; font-size: 14.5px; }
.read-more { margin-top: 6px !important; font-size: 14.5px; }
.projects-index .project-body h3 a { color: var(--ink); }
.project-actions { margin: 8px 0 0 !important; font-size: 14.5px; }
.project-actions a + a { margin-left: 16px; }

@media (max-width: 640px) {
  .pp-title { font-size: 28px; }
  .pp-summary { font-size: 16.5px; }
  .pp-content table { display: block; overflow-x: auto; }
  .pipe-arrow { transform: none; }
}
@media print {
  .crumbs, .toc, .post-nav, .back-links, .media-grid video { display: none !important; }
}
.section-intro { margin: -8px 0 8px; font-size: 15px; color: var(--muted); }

/* Chinese pages: no synthetic italics, slightly looser line height */
.lang-zh .job-role, .lang-zh .edu-degree { font-style: normal; }
.lang-zh { line-height: 1.75; }
.lang-zh .job h4 { letter-spacing: 0; }

/* =====================================================================
   Figures (inline SVG), demos and the homepage overview
   ===================================================================== */
.is-page { --max: 1040px; }
.project-page { max-width: none; }
.pp-header, .toc, .project-page .post-meta,
.pp-content > p, .pp-content > ul, .pp-content > ol, .pp-content > h2, .pp-content > h3,
.pp-content > pre, .pp-content > blockquote, .pp-content > .callout, .pp-content > .highlight { max-width: 800px; }

.figure { margin: 26px 0; }
.fig-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--rule); border-radius: 10px; background: #fff; padding: 14px 14px 10px; cursor: zoom-in; }
.fig-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.fig { display: block; width: 100%; height: auto; min-width: 760px; }
svg.fig text { font-family: var(--sans); }
.figure figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; text-align: center; }
.figure.zoomed { position: fixed; inset: 0; z-index: 50; margin: 0; padding: 20px; background: rgba(255, 255, 255, 0.97); display: flex; flex-direction: column; justify-content: center; opacity: 1 !important; transform: none !important; }
.figure.zoomed .fig-scroll { cursor: zoom-out; border: none; max-height: 100%; overflow: auto; }
.figure.zoomed svg.fig { width: min(1560px, 100%); min-width: 960px; margin: 0 auto; }
body.has-zoom { overflow: hidden; }

/* parity-chain demo states */
svg.fig .hop.fail .gate { fill: #fbe9e9; stroke: #d03b3b; }
svg.fig .hop.fail .tick { visibility: hidden; }
svg.fig .hop.fail .cross { visibility: visible; }
svg.fig .hop.blocked .gate { fill: #eef1f5; stroke: #a9b4c2; }
svg.fig .hop.blocked .tick { stroke: #a9b4c2; }
svg.fig .hop.fail .hopline, svg.fig .hop.blocked .hopline { stroke-dasharray: 4 5; }
svg.fig .pstage.suspect .pbox { stroke: #d03b3b; stroke-width: 2.5; }

@keyframes fig-flow { to { stroke-dashoffset: -14; } }
@keyframes fig-pulse { 0%, 9%, 100% { filter: none; } 4% { filter: brightness(0.94) saturate(1.4); } }
@media (prefers-reduced-motion: no-preference) {
  html.js .figure, html.js .kpis, html.js .demo { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease; }
  html.js .figure.in, html.js .kpis.in, html.js .demo.in { opacity: 1; transform: none; }
  svg.fig .flow { stroke-dasharray: 7 7; animation: fig-flow 1.1s linear infinite; }
  .figure.in svg.fig .stage, .figure.in svg.fig .pl-stage, .figure.in svg.fig .gen,
  .figure.in svg.fig .pstep, .figure.in svg.fig .mstage, .figure.in svg.fig .fam {
    animation: fig-pulse 7s ease-in-out infinite; animation-delay: calc(var(--i, 0) * 0.55s);
  }
}

/* demos */
.demo { margin: 18px 0 26px; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 10px; background: var(--bg-soft); }
.demo-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { font: inherit; font-size: 14.5px; font-weight: 600; line-height: 1.3; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
.btn:hover { filter: brightness(1.1); }
.btn-ghost { background: #fff; color: var(--accent); border-color: #c5d3e6; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.demo-status { margin: 10px 0 0 !important; font-size: 15px; color: var(--ink); min-height: 1.6em; max-width: none !important; }
.demo-note { margin: 10px 0 0 !important; font-size: 13.5px; color: var(--muted); line-height: 1.55; max-width: none !important; }
.demo canvas { display: block; width: 100%; background: #fff; border: 1px solid var(--rule); border-radius: 8px; margin-top: 12px; }
.demo-readout { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.7fr); gap: 10px; margin: 12px 0 0; }
.demo-readout div { background: #fff; border: 1px solid var(--rule); border-radius: 8px; padding: 8px 12px; }
.demo-readout dt { font-size: 12.5px; color: var(--muted); }
.demo-readout dd { margin: 0; font-size: 19px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.demo-readout dd.lut-verdict { font-size: 15px; line-height: 1.5; padding-top: 3px; }
.lut-verdict.ok { color: #006300; }
.lut-verdict.bad { color: #9a2323; }
.parity-demo { margin-top: -12px; }

/* homepage: bio + bit-width playground, KPI strip */
.bio { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.bio .quant-demo { margin: 0; padding: 12px 14px; }
.quant-demo canvas { margin-top: 0; }
.quant-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 10px; font-size: 14px; color: var(--ink); }
.quant-ctl input[type=range] { vertical-align: middle; width: 120px; accent-color: var(--accent); }
.quant-readout { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 30px; border: 1px solid var(--rule); border-radius: 10px; background: var(--bg-soft); overflow: hidden; }
.kpi { padding: 16px 18px 14px; border-left: 1px solid var(--rule); display: flex; flex-direction: column; }
.kpi:nth-child(3n + 1) { border-left: none; }
.kpi:nth-child(n + 4) { border-top: 1px solid var(--rule); }
.kpi-value { font-size: 27px; font-weight: 700; color: var(--accent); line-height: 1.15; white-space: nowrap; letter-spacing: -0.2px; }
.kpi-label { margin-top: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.kpi-detail { margin-top: 3px; font-size: 12.5px; color: var(--muted); line-height: 1.35; }

@media (max-width: 860px) {
  .bio { grid-template-columns: 1fr; }
  .demo-readout { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .demo-readout .wide { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi, .kpi:nth-child(3n + 1) { border-left: none; border-top: 1px solid var(--rule); padding: 12px 12px 10px; }
  .kpi:nth-child(2n) { border-left: 1px solid var(--rule); }
  .kpi:nth-child(-n + 2) { border-top: none; }
  .kpi-value { font-size: 21px; }
}
@media print {
  .figure, .demo { display: none !important; }
  .bio { display: block; }
  .kpis { opacity: 1 !important; transform: none !important; margin-top: 12px; grid-template-columns: repeat(6, minmax(0, 1fr)); break-inside: avoid; }
  .kpi, .kpi:nth-child(n) { padding: 6px 6px 6px 8px; border-top: none; border-left: 1px solid var(--rule); }
  .kpi:first-child { border-left: none; }
  .kpi-value { font-size: 12pt; }
  .kpi-label { font-size: 7.5pt; margin-top: 2px; }
  .kpi-detail { font-size: 7pt; }
}
