/* ==========================================================
   Xin Zhang — personal site
   Plain CSS, light + dark. Edit the tokens below to restyle.
   ========================================================== */

:root {
  /* palette: "Cool spectrum" (Nov 2026) */
  --bg: #f7f9fc;
  --surface: #ffffff;
  --text: #141a26;
  --muted: #566173;
  --faint: #8691a3;
  --line: #e2e7ef;
  --accent: #2b59c3;
  --accent-soft: #e8eefb;

  /* one color per research theme / publication category (also used in the headline) */
  --c-ai: #6b4fd8;        /* theme 01: AI for circuits */
  --c-circuits: #1f6fd1;  /* theme 02: chips and circuits */
  --c-systems: #0e8a80;   /* theme 03: cooling, packaging and systems */

  --serif: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 1040px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c;
    --surface: #161c26;
    --text: #e6eaf2;
    --muted: #a2adbf;
    --faint: #7a8599;
    --line: #263041;
    --accent: #8fb1ff;
    --accent-soft: #1b2638;
    --c-ai: #b3a1ff;
    --c-circuits: #7fb2ff;
    --c-systems: #5fd3c7;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--sans);
  overflow-x: clip; /* the hero wash extends past the edges */
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding-inline: 24px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--surface); padding: 6px 10px; z-index: 10; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { font: 600 1.05rem var(--serif); color: var(--text); white-space: nowrap; }
.topbar nav { display: flex; gap: 20px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.topbar nav a:hover { color: var(--text); text-decoration: none; }

/* ---------- hero ---------- */
.hero { padding-block: 18px 40px; position: relative; }
/* soft blue/violet wash behind the opening section */
.hero::before {
  content: ""; position: absolute; inset: 0 -40vw; z-index: -1; pointer-events: none;
  background: radial-gradient(60% 80% at 78% 30%, color-mix(in srgb, var(--c-circuits) 9%, transparent), transparent 70%),
              radial-gradient(40% 60% at 20% 90%, color-mix(in srgb, var(--c-ai) 6%, transparent), transparent 70%);
}
/* photo on the right of name + headline; stacks on top on phones */
.hero-grid { display: grid; grid-template-columns: 1fr auto; gap: 48px; align-items: center; }
.hero-text { grid-column: 1; grid-row: 1; min-width: 0; }
.portrait {
  grid-column: 2; grid-row: 1;
  width: clamp(200px, 24vw, 300px); height: auto; aspect-ratio: 1; max-width: 100%;
  object-fit: cover; border-radius: 22px;
  border: 1px solid var(--line);
  box-shadow: 0 0 0 6px var(--surface), 0 0 0 7px color-mix(in srgb, var(--c-circuits) 35%, var(--line));
}
.eyebrow { margin: 0 0 12px; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.hero h1 { margin: 0; font: 600 clamp(2.2rem, 6vw, 3.0rem)/1.05 var(--serif); letter-spacing: -.01em; }
.roles { margin: 18px 0 0; color: var(--muted); font-size: 1.02rem; }
.focus { margin: 22px 0 0; max-width: none; font: 400 clamp(1.2rem, 2.4vw, 1.4rem)/1.4 var(--serif); }
.focus-ai { display: block; margin-top: 2px; }
/* headline key phrases in the research-theme colors */
.k-chips { color: var(--c-circuits); }
.k-quantum { color: var(--c-systems); }
.k-ai { color: var(--c-ai); }

/* headline layout: one row per stream (verb, then its text; a wrapped line lines up
   under the text), with a small "and" on its own tight line between them */
.focus-grid .stream { display: flex; align-items: baseline; column-gap: .3em; }
.focus-grid .verb { flex: none; font-weight: 600; }
.focus-grid .joiner { color: var(--faint); font-size: .82em; line-height: 1.15; margin: -.05em 0; }
/* underline drawn on the word itself, just below the letters */
.u { background-repeat: no-repeat; background-size: 100% 2px; background-position: left 0 bottom .02em; padding-bottom: .06em; }
.u-chips { background-image: linear-gradient(90deg, var(--c-circuits), var(--c-systems)); }
.u-ai { background-image: linear-gradient(90deg, var(--c-ai), var(--c-ai)); }
@media (max-width: 640px) {
  /* phones: no columns, so the text isn't squeezed */
  .focus-grid .stream { display: block; }
}
.links { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 26px 0 0; }
.links a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: .9rem;
}
.links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
/* small monochrome icons: gray at rest, accent blue on hover (follows the text color) */
.links .ic { width: 15px; height: 15px; flex: none; color: var(--muted); }
.links a:hover .ic { color: inherit; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 40px 0 0; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stats > div { background: var(--surface); padding: 16px 18px; }
.stats dt { font: 600 1.5rem/1.1 var(--serif); color: var(--accent); }
.stats dd { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }

.bio { margin-top: 36px; color: var(--muted); }  /* full content width, lines up with the stats box */
.bio p { margin: 0 0 12px; }

/* ---------- sections ---------- */
.section { padding-block: 44px; border-top: 1px solid var(--line); }
.section h2 { margin: 0 0 22px; font: 600 1.6rem/1.2 var(--serif); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.more { font-size: .92rem; white-space: nowrap; }
.lede { margin: -10px 0 20px; color: var(--muted); }

/* ---------- research themes ---------- */
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.theme {
  --c: var(--accent);
  background: var(--surface); border: 1px solid var(--line); border-top: 6px solid var(--c);
  border-radius: 10px; padding: 19px 22px 18px; display: flex; flex-direction: column;
}
.theme[data-cat="ai"] { --c: var(--c-ai); }
.theme[data-cat="circuits"] { --c: var(--c-circuits); }
.theme[data-cat="systems"] { --c: var(--c-systems); }
.theme-num { margin: 0; font: 600 1rem var(--sans); color: var(--c); letter-spacing: .05em; }
.theme h3 { margin: 4px 0 10px; font: 600 1.22rem/1.25 var(--serif); color: var(--c); }
.theme > p:not(.theme-num) { margin: 0 0 16px; color: var(--muted); font-size: .95rem; }
/* theme descriptions: the intro up to the colon on its own line, then a quarter-line gap before the list */
.theme > p.tight { margin-bottom: 6px; }  /* theme 2: smaller gap before "Most recently" */
.theme .lead { display: block; margin-bottom: .4em; margin-bottom: .25lh; }  /* .4em fallback for older browsers */
.reps { list-style: none; padding: 14px 0 0; margin: auto 0 0; border-top: 1px solid var(--line); font-size: .84rem; }
.reps li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.reps span { color: var(--faint); white-space: nowrap; font-size: .78rem; }

/* ---------- highlights ---------- */
.highlights { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 32px; }
.highlights li { padding-left: 16px; position: relative; color: var(--muted); }
.highlights li::before { content: ""; position: absolute; left: 0; top: .7em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.highlights strong { color: var(--text); font-weight: 600; }

/* ---------- publications ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 26px; }
.filters button {
  font: inherit; font-size: .88rem; cursor: pointer;
  padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted);
}
.filters button .n { color: var(--faint); margin-left: 4px; }
.filters button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.filters button[aria-pressed="true"] .n { color: inherit; opacity: .7; }

.pub-group { margin: 0 0 36px; }
.pub-group[data-cat="ai"] { --c: var(--c-ai); }
.pub-group[data-cat="circuits"] { --c: var(--c-circuits); }
.pub-group[data-cat="systems"] { --c: var(--c-systems); }
.pub-group > h3 {
  margin: 0 0 6px; padding-bottom: 8px; border-bottom: 3px solid var(--c); color: var(--c);
  font: 600 1.15rem var(--serif); display: flex; justify-content: space-between; align-items: baseline;
}
.pub-group > h3 small { font: 400 .85rem var(--sans); color: var(--faint); }

.year-block { display: grid; grid-template-columns: 64px 1fr; gap: 0 16px; padding-top: 14px; }
.year-block > .yr { font: 600 .95rem var(--serif); color: var(--faint); padding-top: 2px; }
.pubs { list-style: none; margin: 0; padding: 0; }
.pub { padding: 0 0 14px; }
.pub:target { background: var(--accent-soft); border-radius: 6px; box-shadow: 0 0 0 6px var(--accent-soft); }
.pub-title { font-weight: 600; color: var(--text); }
a.pub-title:hover { color: var(--accent); }
.pub-authors { color: var(--muted); font-size: .92rem; }
.pub-authors strong { color: var(--text); font-weight: 600; }
.pub-venue { font-size: .9rem; color: var(--muted); }
.pub-venue i { font-style: italic; }
.tag {
  display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  padding: 1px 7px; border-radius: 4px; margin-right: 6px; vertical-align: 1px;
  color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 12%, transparent);
}
.award { display: inline-block; font-size: .78rem; font-weight: 600; color: #8a5a00; background: #fbefd2; padding: 1px 7px; border-radius: 4px; margin-left: 6px; }
@media (prefers-color-scheme: dark) { .award { color: #f3cf7a; background: #3a2f14; } }

/* ---------- patents ---------- */
.patents { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.patent-col { background: var(--surface); border: 1px solid var(--line); border-top: 6px solid var(--c); border-radius: 10px; padding: 18px 18px 8px; }
.patent-col[data-cat="ai"] { --c: var(--c-ai); }
.patent-col[data-cat="circuits"] { --c: var(--c-circuits); }
.patent-col[data-cat="systems"] { --c: var(--c-systems); }
.patent-col h3 { margin: 4px 0 10px; font: 600 1.05rem var(--serif); color: var(--c); display: flex; justify-content: space-between; align-items: baseline; }
.patent-col h3 small { font: 400 .82rem var(--sans); color: var(--faint); }
.patent-col ul { list-style: none; margin: 0; padding: 0; }
.patent-col li { padding: 8px 0; border-top: 1px solid var(--line); font-size: .84rem; }
.patent-col li:first-child { border-top: 0; }
.pat-no { display: block; font-size: .78rem; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------- teaching / talks / contact ---------- */
.course { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; }
.course-code { margin: 0; font-size: .82rem; color: var(--faint); letter-spacing: .02em; }
.course h3 { margin: 4px 0 8px; font: 600 1.2rem var(--serif); }
.course p:last-child { margin: 0; color: var(--muted); }
.sub-h { margin: 32px 0 6px; font: 600 1.2rem var(--serif); }
.mentoring { color: var(--muted); margin: 0 0 14px; }
.table-scroll { overflow-x: auto; }
.mentees { width: 100%; border-collapse: collapse; font-size: .88rem; }
.mentees th { text-align: left; font-weight: 600; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--faint); padding: 0 12px 8px 0; border-bottom: 1px solid var(--line); }
.mentees td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); color: var(--muted); vertical-align: top; }
.mentees td.m-name { color: var(--text); font-weight: 600; white-space: nowrap; }
.mentees td.m-yrs { white-space: nowrap; font-variant-numeric: tabular-nums; }
.mentees .todo { color: var(--faint); font-style: italic; }
.mentees .unknown { color: var(--faint); }
.js .mentees-wrap:not(.open) tr.extra { display: none; }
@media (max-width: 640px) {
  /* phones: each person becomes a small stacked block */
  .mentees thead { display: none; }
  .mentees, .mentees tbody, .mentees tr, .mentees td { display: block; }
  .mentees tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .js .mentees-wrap:not(.open) .mentees tr.extra { display: none; }
  .mentees td { border: 0; padding: 1px 0; }
}

.talks { list-style: none; margin: 0; padding: 0; }
.talks li { display: grid; grid-template-columns: 64px 1fr; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.talks li:first-child { border-top: 0; }
.t-year { font: 600 .95rem var(--serif); color: var(--faint); }
.t-title { font-weight: 600; }
.t-where { display: block; color: var(--muted); font-size: .9rem; }

.contact-line { margin: 0; font-size: 1.05rem; }

.footer { border-top: 1px solid var(--line); padding-block: 28px 40px; color: var(--faint); font-size: .85rem; }
.footer p { margin: 0 0 4px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .portrait { width: 200px; }
  .hero-grid { gap: 28px; }
}
@media (max-width: 640px) {
  .hero-grid { grid-template-columns: 1fr; gap: 20px; }
  .portrait { grid-column: 1; grid-row: 1; width: 136px; }
  .hero-text { grid-row: 2; }
  /* phones: slightly more compact buttons so the five fit in two rows */
  .links { gap: 6px; }
  .links a { padding: 6px 10px; gap: 5px; font-size: .84rem; }
  .links .ic { width: 14px; height: 14px; }
}
@media (max-width: 860px) {
  .themes, .patents { grid-template-columns: 1fr; }
  .highlights { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .wrap { padding-inline: 16px; }
  .hero { padding-block: 11px 28px; }
  .brand { display: none; }
  .topbar nav { margin-left: 0; gap: 16px; }
  .year-block { grid-template-columns: 1fr; }
  .year-block > .yr { padding: 0 0 4px; }
  .talks li { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- patents: collapsed list (only when JS can expand it) ---------- */
.js .patents:not(.open) li.extra { display: none; }
/* publications: each category shows its newest papers; "Show all" expands that category */
.js .pub-group:not(.open) .extra { display: none; }
.patents-toggle, .pubs-toggle, .mentees-toggle {
  display: block; margin: 18px auto 0; cursor: pointer;
  font: inherit; font-size: .9rem; color: var(--accent);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 7px 18px;
}
.patents-toggle:hover, .pubs-toggle:hover, .mentees-toggle:hover { border-color: var(--accent); }
html:not(.js) .patents-toggle, html:not(.js) .pubs-toggle, html:not(.js) .mentees-toggle { display: none; }

/* ---------- top nav: fade at the right edge when it scrolls sideways ---------- */
@media (max-width: 860px) {
  .topbar nav {
    padding-right: 36px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
  }
}

/* keep organization names on one line */
.nw { white-space: nowrap; }
