/* Haihong Hao — one stylesheet for the page. The rooftop switch lives in rooftop.css.
   No build step, no external assets. Colours are CSS variables that rooftop.js
   moves along the dawn; the values below are the no-JavaScript defaults. */

@font-face {
  font-family: "Rooftop Pixel";
  src: url("rooftop-pixel.woff") format("woff");
  font-display: swap;
}

:root {
  --paper: #e8eef5;
  --ink: #18202a;
  --muted: #4f6076;
  --line: #c1cfe0;
  --blue: #1a4fd6;
  --tag: #dbe6f7;
  --hex: 62, 104, 214;
  --pixel: "Rooftop Pixel", ui-monospace, Menlo, Consolas, monospace;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Sitka Text", Cambria, "Noto Serif",
    "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif;
  --page: 1120px;
  --gutter: clamp(20px, 5vw, 56px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1422;
    --ink: #e9eef7;
    --muted: #a7b5c9;
    --line: #2a3a56;
    --blue: #a3bfff;
    --tag: #1b2a45;
    --hex: 120, 165, 255;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-decoration-thickness: 1px; text-underline-offset: 4px; }
a:hover { color: var(--blue); text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
::selection { background: var(--tag); color: var(--ink); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: fixed; top: -100px; left: 16px; z-index: 100; padding: 10px 18px; background: var(--paper); color: var(--ink); }
.skip:focus { top: 10px; }
.muted { color: var(--muted); }

/* One short, shared fade when the page crosses from night to day. */
html.theme-flip, html.theme-flip body, html.theme-flip body * {
  transition: color .45s ease, background-color .45s ease, border-color .45s ease, text-decoration-color .45s ease;
}

/* The honeycomb sits behind everything and is drawn by site.js. */
#hex-field { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

/* Pixel headings: sizes are multiples of 10px so every pixel lands on the grid. */
h1, h2, .journey-grid h3, #journey > h3, .brand-name, .roof-readouts, .filters button, .news-toggle {
  font-family: var(--pixel);
  font-weight: 400;
  -webkit-font-smoothing: none;
  font-smooth: never;
}
h1 { font-size: 50px; line-height: 1.2; letter-spacing: 0; }
h2 { font-size: 30px; line-height: 1.3; margin-bottom: 28px; }
h2::before {
  content: "";
  display: inline-block;
  width: 15px; height: 17px; margin-right: 14px;
  background: var(--blue);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
h1 [lang="zh"], .brand-name [lang="zh"], .footer-name [lang="zh"] { font-family: var(--serif); -webkit-font-smoothing: antialiased; }
h1 [lang="zh"] { font-size: 28px; margin-left: 10px; color: var(--muted); white-space: nowrap; }

/* Header */
.header {
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 22px var(--gutter) 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px 32px; flex-wrap: wrap;
}
.brand { min-width: 0; display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand img { width: 96px; }
.brand-name { min-width: 0; font-size: 20px; line-height: 1.2; }
.brand-name [lang="zh"] { font-size: 15px; margin-left: 6px; color: var(--muted); }
.header nav { display: flex; flex-wrap: wrap; gap: 6px 26px; font-size: 16px; }
.header nav a { text-decoration: none; padding: 4px 0; }
.header nav a[aria-current="location"] { color: var(--blue); box-shadow: 0 2px 0 currentColor; }
[data-theme="dark"] .brand img, [data-theme="dark"] .footer-name img {
  filter: brightness(0) saturate(100%) invert(75%) sepia(45%) saturate(610%) hue-rotate(183deg) brightness(105%) contrast(101%);
}

/* Intro */
.intro, .section, footer {
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .95fr); align-items: center; gap: 24px; padding-top: 28px; padding-bottom: 24px; }
.intro-lead { font-size: 21px; line-height: 1.6; max-width: 31em; margin-top: 22px; }
.links { display: flex; flex-wrap: wrap; gap: 8px 26px; margin-top: 22px; }
.links a { color: var(--blue); text-decoration-color: currentColor; }
.intelligence-sketch { position: relative; justify-self: end; width: 100%; max-width: 560px; min-width: 0; }
.sketch-stage { position: relative; aspect-ratio: 560 / 500; width: 100%; }
#intelligence-canvas { position: absolute; inset: 0; display: none; width: 100%; height: 100%; pointer-events: none; }
.sketch-fallback { display: block; width: 100%; height: 100%; }
.intelligence-sketch.enhanced #intelligence-canvas { display: block; }
.intelligence-sketch.enhanced .sketch-fallback { display: none; }

/* Sections share one rhythm; nothing else sets vertical padding on them. */
.section { padding-top: 72px; padding-bottom: 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.section-note { color: var(--muted); max-width: 44em; margin: -12px 0 12px; }

.about-grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
.portrait img { width: 100%; border-radius: 3px; }
.prose { max-width: 40em; }
.prose p + p { margin-top: 1.1em; }
.prose strong { font-weight: 600; }

/* News */
.news-list { max-width: 46em; }
.news-list li { display: grid; grid-template-columns: 6.2em 1fr; gap: 20px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.news-list time { color: var(--muted); font-variant-numeric: tabular-nums; }
.news-list li:first-child time { color: var(--blue); }
.news-toggle, .filters button {
  font-size: 20px; line-height: 1.2;
  border: 0; background: none; padding: 4px 0;
}
.news-toggle { margin-top: 18px; color: var(--blue); border-bottom: 2px solid currentColor; }

/* Publications */
.filters { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-bottom: 28px; }
.filters button { color: var(--muted); border-bottom: 2px solid transparent; }
.filters button:hover { color: var(--ink); }
.filters button.active { color: var(--blue); border-bottom-color: currentColor; }
.paper { display: grid; grid-template-columns: 6.2em minmax(0, 1fr); gap: 20px; padding: 22px 0; border-bottom: 1px solid var(--line); position: relative; }
.paper::before {
  content: ""; position: absolute; left: -20px; top: 29px; width: 9px; height: 10px;
  background: var(--blue); opacity: 0;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.paper:hover::before, .paper:focus-within::before { opacity: 1; }
.paper-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
.venue { color: var(--blue); font-weight: 600; }
.paper h3 { font-size: 20px; line-height: 1.4; font-weight: 600; max-width: 34em; }
.authors { color: var(--muted); font-size: 16px; line-height: 1.6; margin-top: 6px; max-width: 46em; }
.authors strong { color: var(--ink); font-weight: 600; }
.journal { font-size: 16px; font-style: italic; color: var(--muted); }
.paper-links { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-top: 8px; font-size: 16px; }
.paper-links a { color: var(--blue); text-decoration-color: currentColor; }

/* Background */
.journey-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 6vw, 80px); }
.journey-grid h3, #journey > h3 { font-size: 20px; line-height: 1.3; color: var(--muted); margin-bottom: 18px; }
.timeline + h3, #journey > h3 { margin-top: 34px; }
.timeline article { position: relative; padding: 0 0 22px 24px; border-left: 1px solid var(--line); }
.timeline article:last-child { padding-bottom: 4px; }
.timeline article::before {
  content: ""; position: absolute; left: -5px; top: 9px; width: 9px; height: 10px; background: var(--muted);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.timeline article:first-child::before { background: var(--blue); }
.when { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.timeline h4, .honors h4 { font-size: 19px; line-height: 1.4; font-weight: 600; }
.timeline p, .honors p { font-size: 16px; line-height: 1.6; }
.toolbox li { font-size: 16px; line-height: 1.6; color: var(--muted); padding: 6px 0; border-bottom: 1px solid var(--line); }
.honors { max-width: 46em; }
.honors li { display: grid; grid-template-columns: 6.2em 1fr; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.honors .when { font-size: 17px; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 34px 28px; }
.photo a { display: block; overflow: hidden; border-radius: 3px; background: var(--tag); }
.photo img { width: 100%; aspect-ratio: 1.45; object-fit: cover; }
.photo figcaption { margin-top: 10px; }
.photo h3 { font-size: 18px; font-weight: 600; line-height: 1.4; }
.photo p { font-size: 15px; color: var(--muted); }

/* Contact */
.contact { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); gap: 32px; align-items: center; padding-bottom: 40px; }
.contact-copy > p { max-width: 32em; }
.contact-email { display: inline-block; margin-top: 14px; font-size: clamp(22px, 3vw, 30px); color: var(--blue); text-decoration-color: currentColor; }
.contact-model { aspect-ratio: 560 / 500; }
.constellation-echo { display: block; width: 100%; height: 100%; }

footer { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding-top: 22px; padding-bottom: 28px; border-top: 1px solid var(--line); font-size: 15px; color: var(--muted); }
.footer-name { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.footer-name img { width: 70px; }
.footer-meta { display: flex; align-items: center; gap: 22px; }
#motion-preference { border: 0; background: none; padding: 2px 0; border-bottom: 1px solid currentColor; }
#motion-preference:hover { color: var(--blue); }

/* Small pixel travellers between chapters. */
.pixel-lane { height: 64px; position: relative; display: flex; justify-content: flex-end; align-items: center; margin-top: 26px; overflow: hidden; pointer-events: none; color: var(--muted); }
.pixel-trail { position: absolute; right: 0; bottom: 9px; width: 180px; border-bottom: 1px dashed var(--line); }
.pixel-companion { overflow: visible; image-rendering: pixelated; shape-rendering: crispEdges; }
.pixel-orbit { animation: pixel-drift 9s ease-in-out infinite; transform-origin: center; }
.pixel-bob { animation: pixel-bob 2.7s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.pixel-wave { animation: pixel-wave 1.6s steps(3, end) infinite; transform-box: fill-box; transform-origin: left bottom; }
.pixel-tentacles { animation: pixel-sway 1.1s steps(3, end) infinite; transform-box: fill-box; transform-origin: center top; }
.pixel-beam, .pixel-twinkle { animation: pixel-glow 2.4s steps(4, end) infinite; }
.pixel-squid .pixel-orbit { animation-duration: 11s; animation-delay: -3s; }
.pixel-cat .pixel-orbit { animation-duration: 13s; }
.pixel-alien .pixel-bob { animation-duration: 1.9s; }
@keyframes pixel-drift { 0%, 100% { transform: translateX(-18px); } 50% { transform: translateX(8px); } }
@keyframes pixel-bob { 0%, 100% { translate: 0 -3px; } 50% { translate: 0 3px; } }
@keyframes pixel-wave { 50% { rotate: -20deg; } }
@keyframes pixel-sway { 50% { transform: skewX(12deg) scaleY(.8); } }
@keyframes pixel-glow { 50% { opacity: .25; } }
.pixel-lane:not(.is-visible) *, .roof-static .pixel-lane * { animation-play-state: paused !important; }

@media (max-width: 860px) {
  h1 { font-size: 40px; }
  .intro { grid-template-columns: 1fr; padding-top: 12px; }
  .intelligence-sketch { justify-self: center; max-width: 440px; }
  .journey-grid { grid-template-columns: 1fr; gap: 34px; }
  .contact { grid-template-columns: 1fr; }
  .contact-model { max-width: 260px; justify-self: center; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  h1 { font-size: 30px; }
  h1 [lang="zh"] { font-size: 20px; }
  h2 { font-size: 20px; margin-bottom: 20px; }
  h2::before { width: 11px; height: 13px; margin-right: 10px; }
  .header { padding-top: 16px; }
  .brand img { width: 72px; }
  .header nav { gap: 2px 18px; font-size: 15px; }
  .intro-lead { font-size: 18px; }
  .section { padding-top: 52px; }
  .about-grid { grid-template-columns: 1fr; }
  .portrait { max-width: 220px; }
  .news-list li, .honors li { grid-template-columns: 1fr; gap: 0; }
  .paper { grid-template-columns: 1fr; gap: 6px; }
  .paper-meta { flex-direction: row; gap: 12px; }
  .paper h3 { font-size: 18px; }
  .photo-grid { grid-template-columns: 1fr; }
  .photo img { aspect-ratio: auto; }
  .pixel-lane { margin-top: 18px; height: 54px; }
  .pixel-companion { width: 120px; height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  #hex-field, .roof, .header nav, .filters, .news-toggle, .pixel-lane, .intelligence-sketch, .contact-model, #motion-preference { display: none !important; }
  html { background: #fff; }
  body { color: #000; }
  .paper[hidden], .news-list li[hidden] { display: grid !important; }
  .paper, .photo, .timeline article { break-inside: avoid; }
}

/* Let narrow columns shrink around long research titles and contact links. */
.intro-copy, .prose, .contact-copy, .journey-grid > div, .paper > div { min-width: 0; }
.prose, .authors, .paper h3, .contact-email { overflow-wrap: anywhere; }

/* Live pixel strips (pixel-friends.js) replace the small static companions. */
.pixel-lane.live { height: 104px; pointer-events: auto; overflow: visible; }
.pixel-lane.live > svg, .pixel-lane.live > .pixel-trail { display: none; }
.pixel-stage { display: block; width: 100%; height: 100%; image-rendering: pixelated; cursor: pointer; touch-action: pan-y; }
.pixel-pal { position: fixed; right: 14px; bottom: 12px; z-index: 6; width: 45px; height: 48px; image-rendering: pixelated; cursor: pointer; }
@media (max-width: 640px) { .pixel-lane.live { height: 78px; } .pixel-pal { width: 30px; height: 32px; right: 8px; bottom: 8px; } }
@media print { .pixel-pal { display: none; } }

/* The orbiting hexagon model returns at the head of every section. */
.section { position: relative; }
.section-model { position: absolute; right: var(--gutter); top: -44px; width: 236px; height: 209px; pointer-events: none; }
.section-head { padding-right: 240px; }
@media (max-width: 640px) { .section-model { width: 104px; height: 92px; top: 0; } .section-head { padding-right: 0; } }
@media print { .section-model { display: none; } }
