/* ==========================================================================
   avinashkarkada.github.io
   1. Fonts  2. Tokens  3. Base  4. Layout  5. Nav  6. Hero  7. Sections
   8. Figures  9. Work  10. Software  11. Experience  12. Publications
   13. Skills  14. Background  15. Contact + footer  16. Quick navigation
   17. Motion + print
   ========================================================================== */

/* 1. Fonts --------------------------------------------------------------- */
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/IBMPlexSans-var.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/IBMPlexSans-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/IBMPlexMono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/IBMPlexMono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/IBMPlexMono-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

/* 2. Tokens -------------------------------------------------------------- */
:root {
  color-scheme: light;
  --page: #f6f4ee;
  --surface: #fcfbf8;
  --surface-2: #efece4;
  --ink: #14171a;
  --ink-2: #474b51;
  --muted: #6a6d71;
  --line: #dfdcd2;
  --line-2: #c6c3b8;
  --accent: #1c5fb4;

  /* data colours: categorical slots 1-3, then the residue classes */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --mute-mark: #c6c3b8;
  --c-hydrophobic: #2a78d6;
  --c-polar: #1baf7a;
  --c-basic: #eb6834;
  --c-acidic: #4a3aa7;
  --c-special: #e87ba4;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --wrap: 1140px;
  --gutter: clamp(16px, 4vw, 40px);
  --nav-h: 60px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 23, 26, .04), 0 8px 24px rgba(20, 23, 26, .05);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e1011;
  --surface: #17191b;
  --surface-2: #1f2224;
  --ink: #f3f1ea;
  --ink-2: #c5c4bb;
  --muted: #98978f;
  --line: #2a2c2e;
  --line-2: #404345;
  --accent: #74adf0;

  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --mute-mark: #404345;
  --c-hydrophobic: #3987e5;
  --c-polar: #199e70;
  --c-basic: #d95926;
  --c-acidic: #9085e9;
  --c-special: #d55181;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
}

/* 3. Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, canvas { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
sup { font-size: .7em; line-height: 0; }

a { color: inherit; text-decoration-color: var(--line-2); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--s1); color: #fff; }

.nw { white-space: nowrap; }
.vh {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 1em; height: 1em; flex: none; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 10px 14px; background: var(--ink); color: var(--page);
  border-radius: 8px; text-decoration: none; font-size: 14px;
}
.skip:focus { top: 12px; color: var(--page); }

kbd {
  font-family: var(--mono); font-size: 11px; line-height: 1;
  padding: 3px 5px; border: 1px solid var(--line-2); border-radius: 4px;
  color: var(--muted); background: var(--surface);
}

/* 4. Layout + shared pieces --------------------------------------------- */
.wrap { width: 100%; max-width: calc(var(--wrap) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }

.eyebrow, .work-meta, .sec-num, .fig-num, .lang, .private, .pub-year, .filter-count {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .01em;
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--surface); color: var(--ink);
  font-size: 15px; font-weight: 500; line-height: 1.2; text-decoration: none;
  transition: border-color .15s, background-color .15s, color .15s, transform .15s;
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--ink); border-color: var(--ink); color: var(--page); }
.btn--primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn--primary:hover { color: #0e1011; }
.btn--sm { padding: 6px 10px; font-size: 13px; border-radius: 7px; gap: 6px; }
.btn--lg { padding: 13px 20px; font-size: 16px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}

.repo {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 14px; font-weight: 500; text-decoration: none; color: var(--accent);
}
.repo:hover { text-decoration: underline; }
.repo .ico { font-size: 12px; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg button {
  padding: 6px 10px; border: 0; border-left: 1px solid var(--line-2); background: none;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.seg button:first-child { border-left: 0; }
.seg button:hover { color: var(--ink); background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--page); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 999px;
  background: none; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  transition: background-color .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--page); }

.search {
  display: inline-flex; align-items: center; gap: 8px;
  min-width: min(100%, 300px); padding: 8px 12px;
  border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface);
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search input {
  flex: 1; min-width: 0; border: 0; background: none; outline: 0;
  font-size: 15px; color: var(--ink);
}
.search input::placeholder { color: var(--muted); opacity: 1; }

.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 24px; }
.filter-count { margin-left: auto; color: var(--muted); }
.empty { padding: 24px 0; color: var(--muted); }
[hidden] { display: none !important; }

.tip {
  position: fixed; z-index: 60; left: 0; top: 0; pointer-events: none;
  max-width: 260px; padding: 6px 9px; border-radius: 7px;
  background: var(--ink); color: var(--page);
  font-size: 12.5px; line-height: 1.35; box-shadow: var(--shadow);
}
.tip b { font-weight: 600; }
.tip span { display: block; opacity: .75; }

/* 5. Nav ----------------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  background: color-mix(in srgb, var(--page) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.nav.is-stuck { border-bottom-color: var(--line); }
.nav-in { height: 100%; display: flex; align-items: center; gap: 24px; }

.brand { display: inline-flex; gap: 3px; text-decoration: none; }
.brand .res { width: 24px; height: 27px; font-size: 14px; border-bottom-width: 2px; border-radius: 4px 4px 2px 2px; animation: none; }

.nav nav { margin-left: auto; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  display: block; padding: 8px 10px; border-radius: 7px;
  font-size: 14.5px; color: var(--ink-2); text-decoration: none;
}
.nav-links a:hover { color: var(--ink); background: var(--surface-2); }
.nav-links a[aria-current="true"] { color: var(--ink); font-weight: 500; box-shadow: inset 0 -2px 0 var(--s1); border-radius: 7px 7px 0 0; }

.nav-tools { display: flex; align-items: center; gap: 6px; }
.kbtn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 10px;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface);
  font-size: 13.5px; color: var(--muted);
}
.kbtn:hover { border-color: var(--ink); color: var(--ink); }
.iconbtn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid transparent; border-radius: 8px; background: none; font-size: 17px; color: var(--ink-2);
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.ico-moon, :root[data-theme="dark"] .ico-sun { display: none; }
:root[data-theme="dark"] .ico-moon { display: block; }
.nav-menu { display: none; }
.burger, .burger::before, .burger::after { display: block; width: 16px; height: 1.5px; background: currentColor; border-radius: 2px; transition: transform .2s; }
.burger { position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -5px; }
.burger::after { top: 5px; }
[aria-expanded="true"] > .burger { background: transparent; }
[aria-expanded="true"] > .burger::before { transform: translateY(5px) rotate(45deg); }
[aria-expanded="true"] > .burger::after { transform: translateY(-5px) rotate(-45deg); }

.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; }
.progress span { display: block; height: 100%; width: 100%; background: var(--s1); transform-origin: 0 50%; transform: scaleX(0); }

@media (max-width: 900px) {
  .nav-menu { display: inline-grid; }
  .kbtn-label, .kbtn kbd { display: none; }
  .kbtn { width: 36px; padding: 0; justify-content: center; border-color: transparent; background: none; font-size: 17px; color: var(--ink-2); }
  .nav nav { margin-left: auto; }
  .nav-links {
    position: absolute; left: 0; right: 0; top: var(--nav-h);
    flex-direction: column; gap: 0; padding: 8px var(--gutter) 16px;
    background: var(--page); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  .js .nav-links { display: none; }
  .js .nav-links.is-open { display: flex; }
  html:not(.js) .nav-links { position: static; flex-direction: row; flex-wrap: wrap; padding: 0; box-shadow: none; border: 0; }
  .nav-links a { padding: 12px 4px; font-size: 16px; border-bottom: 1px solid var(--line); border-radius: 0; }
  .nav-links a[aria-current="true"] { box-shadow: none; }
}

/* 6. Hero ---------------------------------------------------------------- */
.hero { position: relative; padding: clamp(32px, 5vw, 64px) 0 clamp(40px, 6vw, 72px); }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: .55;
  -webkit-mask-image: radial-gradient(ellipse 60% 70% at 78% 45%, #000 0%, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 70% at 78% 45%, #000 0%, transparent 75%);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: clamp(24px, 5vw, 72px); align-items: center; }

.eyebrow { color: var(--muted); margin-bottom: 22px; }

.seqname { font: inherit; }
.seq { display: grid; gap: clamp(5px, .8vw, 9px); --tile: clamp(34px, 5.1vw, 66px); }
.seq-word { display: flex; gap: clamp(3px, .5vw, 6px); position: relative; padding-left: 34px; }
.seq-word::before {
  content: attr(data-pos); position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 24px; text-align: right;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
}

.res {
  --res: var(--c-hydrophobic);
  display: inline-grid; place-items: center;
  width: var(--tile); height: calc(var(--tile) * 1.12);
  font-family: var(--mono); font-weight: 600; font-size: calc(var(--tile) * .56); line-height: 1;
  color: var(--ink);
  background: var(--surface);
  background: color-mix(in oklab, var(--res) 15%, var(--surface));
  border-bottom: 3px solid var(--res);
  border-radius: 7px 7px 3px 3px;
  cursor: default; user-select: none;
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), background-color .18s;
}
.res[data-aa="N"], .res[data-aa="S"] { --res: var(--c-polar); }
.res[data-aa="H"], .res[data-aa="K"], .res[data-aa="R"] { --res: var(--c-basic); }
.res[data-aa="D"] { --res: var(--c-acidic); }
.res[data-aa="O"] { --res: var(--c-special); }
.seq .res:hover, .seq .res.is-on { transform: translateY(-4px); background: color-mix(in oklab, var(--res) 32%, var(--surface)); }
.seq.has-class .res:not(.is-class) { background: var(--surface); border-bottom-color: var(--line-2); color: var(--muted); }

.js .seq .res { animation: res-in .5s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 38ms + 80ms); }
@keyframes res-in { from { opacity: 0; transform: translateY(10px) scale(.92); } }

.seq-readout { margin-top: 18px; min-height: 1.5em; padding-left: 34px; font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.seq-readout b { font-weight: 600; color: var(--ink); }
.seq-legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 8px; padding-left: 28px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.seq-legend li { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px; border-radius: 5px; cursor: default; }
.seq-legend li:hover { background: var(--surface-2); color: var(--ink); }
.swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--c-hydrophobic); }
.swatch[data-class="polar"] { background: var(--c-polar); }
.swatch[data-class="basic"] { background: var(--c-basic); }
.swatch[data-class="acidic"] { background: var(--c-acidic); }
.swatch[data-class="special"] { background: var(--c-special); }

.lead { margin-top: 28px; max-width: 30ch; font-size: clamp(20px, 2.3vw, 26px); line-height: 1.35; letter-spacing: -.01em; color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.links { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 22px; font-size: 14.5px; }
.links a { color: var(--ink-2); }
.links a:hover { color: var(--accent); }

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .seq { --tile: clamp(32px, 10.4vw, 58px); }
  .seq-word, .seq-readout { padding-left: 26px; }
  .seq-word::before { width: 18px; font-size: 10.5px; }
  .seq-legend { padding-left: 20px; }
}

/* 7. Sections ------------------------------------------------------------ */
.section { padding: clamp(36px, 5vw, 64px) 0; }
.sec-head { display: flex; align-items: baseline; gap: 16px; padding-top: 20px; margin-bottom: 28px; border-top: 1px solid var(--line-2); }
.sec-num { color: var(--muted); }
.sec-head h2 { font-size: clamp(28px, 3.6vw, 42px); font-weight: 500; line-height: 1.1; letter-spacing: -.025em; }
.sec-intro { max-width: 62ch; margin: -8px 0 40px; color: var(--ink-2); }
.sub { margin: 40px 0 16px; font-family: var(--mono); font-size: 12.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.prose p { max-width: 66ch; }
.prose p + p { margin-top: 1em; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

.about-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 64px); align-items: start; }
.about-grid .prose { font-size: 18px; }
.about-card { padding: 22px; }
.portrait { width: 120px; height: 120px; border-radius: 10px; object-fit: cover; }
.facts { margin-top: 18px; display: grid; gap: 12px; font-size: 14.5px; line-height: 1.45; }
.facts > div { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.facts dt { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 2px; }
@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; }
  .portrait { width: 96px; height: 96px; }
}

/* 8. Figures ------------------------------------------------------------- */
.fig { min-width: 0; padding: 16px 18px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.fig--bare { padding: 0; background: none; border: 0; box-shadow: none; }

.fig-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.fig-title { font-size: 15px; font-weight: 600; line-height: 1.3; }
.fig-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.range { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.range input { width: 110px; accent-color: var(--s1); }
.range output { font-family: var(--mono); font-size: 12px; min-width: 4ch; }

.fig-stage { position: relative; }
.fig-noscript { padding: 24px 0; color: var(--muted); font-size: 14px; }
.plot { width: 100%; height: auto; overflow: visible; touch-action: pan-y; }

.fig-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin-top: 10px; min-height: 22px; }
.fig-readout { font-family: var(--mono); font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.fig-readout b { font-weight: 600; color: var(--ink); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.key { --k: var(--s1); display: inline-block; flex: none; background: var(--k); }
.key[data-series="2"] { --k: var(--s2); }
.key[data-series="3"] { --k: var(--s3); }
.key[data-series="4"] { --k: var(--s4); }
.key[data-series="5"] { --k: var(--s5); }
.key[data-series="mute"] { --k: var(--mute-mark); }
.key--line { width: 14px; height: 2px; border-radius: 2px; }
.key--bar { width: 10px; height: 10px; border-radius: 2px; }
.key--dot { width: 9px; height: 9px; border-radius: 50%; }
.key--ring { width: 10px; height: 10px; border-radius: 50%; background: none; border: 1.5px solid var(--ink); }
.key--tri { width: 0; height: 0; background: none; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid var(--ink); }

figcaption { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.fig--bare figcaption { border-top: 0; padding-top: 0; }
.fig-num { margin-right: 6px; font-weight: 500; color: var(--ink); }

/* SVG chart parts */
.plot text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.plot .lbl { fill: var(--ink-2); }
.plot .lbl-strong { fill: var(--ink); font-weight: 500; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.plot .grid line { stroke: var(--line); stroke-width: 1; }
.plot .axis line, .plot .axis path { stroke: var(--line-2); stroke-width: 1; fill: none; }
.plot .s1 { fill: var(--s1); }
.plot .s2 { fill: var(--s2); }
.plot .s3 { fill: var(--s3); }
.plot .ring { stroke: var(--surface); stroke-width: 2; }
.plot .line-s1 { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.plot .rule { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 4 3; }
.plot .hair { stroke: var(--ink-2); stroke-width: 1; }

/* Fig 1: structure */
.ha-stage { aspect-ratio: 4 / 5; max-height: 580px; margin-inline: auto; }
#fig-ha .fig-foot { margin-top: 6px; }
/* The readout grows when the hovered residue belongs to an antigenic site. Give it a
   row of its own so a longer label can never reflow the figure under the pointer. */
#fig-ha .fig-foot .fig-readout {
  flex-basis: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#fig-ha .legend { margin-top: 10px; }
.ha-stage canvas { width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
.ha-stage canvas.is-drag { cursor: grabbing; }
.fig-pause {
  position: absolute; right: 4px; bottom: 4px; display: grid; place-items: center;
  width: 30px; height: 30px; border: 1px solid var(--line-2); border-radius: 50%;
  background: var(--surface); color: var(--ink-2); font-size: 12px;
}
.fig-pause:hover { color: var(--ink); border-color: var(--ink); }

/* Fig 2: two levels of analysis */
#levels-plot .dot { fill: var(--mute-mark); stroke: var(--surface); stroke-width: 1; }
#levels-plot .dot.is-on { fill: var(--s1); }
#levels-plot .dot.is-planted { stroke: var(--ink); stroke-width: 1.3; }
#levels-plot .dot.is-hover { stroke: var(--accent); stroke-width: 2.2; }
#levels-plot .hit { fill: transparent; }

/* Fig 3: rule graph */
.dag-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.dag-node { cursor: pointer; }
.dag-node rect { fill: var(--surface); stroke: var(--line-2); stroke-width: 1.25; transition: fill .25s, stroke .25s; }
.dag-node text { fill: var(--ink-2); font-size: 13px; transition: fill .25s; pointer-events: none; }
.dag-node:hover rect, .dag-node:focus-visible rect { stroke: var(--ink); }
.dag-node:focus { outline: none; }
.dag-node.is-active rect { stroke: var(--ink); stroke-width: 2; }
.dag-node.is-active text { fill: var(--ink); font-weight: 500; }
.dag-node.is-running rect { stroke: var(--s1); stroke-width: 2; fill: color-mix(in oklab, var(--s1) 14%, var(--surface)); }
.dag-node.is-done rect { fill: var(--ink); stroke: var(--ink); }
.dag-node.is-done text { fill: var(--page); }
.dag-node .count { fill: var(--muted); font-size: 11px; }
.dag-node.is-done .count { fill: var(--page); opacity: .7; }
.dag-edge { fill: none; stroke: var(--line-2); stroke-width: 1.25; transition: stroke .25s; }
.dag-edge.is-done { stroke: var(--ink-2); }
.dag-arrow { fill: var(--line-2); }
.dag-side { display: grid; gap: 12px; min-width: 0; }
.dag-info { min-height: 132px; }
.dag-rule { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.dag-desc { margin-top: 6px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.dag-log {
  height: 220px; overflow: auto; padding: 10px 12px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55; color: var(--ink-2);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.dag-log:empty::before { content: "Press “Replay run” to step through the rules in order."; color: var(--muted); font-family: var(--sans); font-size: 13px; }
@media (max-width: 560px) { .dag-layout { grid-template-columns: 1fr; } .dag-info { min-height: 0; } }

/* Fig 4: 4PL */
#fourpl-plot .pt { cursor: ns-resize; }
#fourpl-plot .pt circle { fill: var(--s1); stroke: var(--surface); stroke-width: 2; transition: r .12s; }
#fourpl-plot .pt .halo { fill: transparent; stroke: none; }
#fourpl-plot .pt:hover circle.dot, #fourpl-plot .pt:focus-visible circle.dot, #fourpl-plot .pt.is-drag circle.dot { r: 6.5; }
#fourpl-plot .pt:focus { outline: none; }
#fourpl-plot .pt:focus-visible .halo { stroke: var(--accent); stroke-width: 2; }
#fourpl-plot .nt-dot { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
#fourpl-plot .ci { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }

/* Fig 5: MDS */
#mds-plot .strain { cursor: grab; }
#mds-plot .strain.is-drag { cursor: grabbing; }
#mds-plot .strain circle.dot { stroke: var(--surface); stroke-width: 2; }
#mds-plot .strain .halo { fill: transparent; }
#mds-plot .strain:focus { outline: none; }
#mds-plot .strain:focus-visible .halo { stroke: var(--accent); stroke-width: 2; }
#mds-plot .strain.is-panel .dot { stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
#mds-plot .drift { fill: none; stroke: var(--line-2); stroke-width: 1; stroke-linejoin: round; }
#mds-plot .frame { fill: none; stroke: var(--line-2); }
.ramp.ramp--time i { width: 72px; background: linear-gradient(90deg, #86b6ef, #3987e5, #1c5cab, #0d366b); }
:root[data-theme="dark"] .ramp.ramp--time i { background: linear-gradient(90deg, #184f95, #3987e5, #86b6ef, #cde2fb); }

/* Fig 6: free-energy landscape */
.fel-stage { aspect-ratio: 1.42; }
.fel-stage canvas { width: 100%; height: 100%; }
.ramp { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.ramp i { width: 110px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #0d366b, #1c5cab, #3987e5, #86b6ef, #cde2fb); }
:root[data-theme="dark"] .ramp i { background: linear-gradient(90deg, #cde2fb, #86b6ef, #3987e5, #1c5cab, #0d366b); }

/* Code listing */
.fig--code { padding-bottom: 6px; }
.code {
  overflow-x: auto; padding: 14px 16px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65; color: var(--ink);
  tab-size: 2;
}
.code .c { color: var(--muted); }

/* Work section arcs */
.arc {
  margin: clamp(36px, 5vw, 60px) 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line-2);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}
.arc:first-of-type { margin-top: 0; }
.arc + .work { border-top: 0; padding-top: 20px; }

/* Fig: platform flow */
.plat-node { cursor: pointer; }
.plat-node rect { fill: var(--surface); stroke: var(--line-2); stroke-width: 1.25; transition: fill .2s, stroke .2s; }
.plat-node text { fill: var(--ink-2); font-size: 12px; pointer-events: none; transition: fill .2s; }
.plat-node.is-store rect { fill: var(--surface-2); stroke-dasharray: 3 2; }
.plat-node:hover rect, .plat-node:focus-visible rect { stroke: var(--ink); }
.plat-node:focus { outline: none; }
.plat-node.is-active rect { fill: var(--ink); stroke: var(--ink); stroke-dasharray: none; }
.plat-node.is-active text { fill: var(--page); font-weight: 500; }
.stage-info { min-height: 84px; margin-top: 12px; }
.stage-name { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink); }
.stage-desc { margin-top: 5px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }

/* Fig: HAScan reactivity across strains */
#hascan-plot .cell { shape-rendering: crispEdges; }
#hascan-plot .rowbar { fill: var(--s1); opacity: .55; }
#hascan-plot .rowbar.is-on { opacity: 1; }
#hascan-plot .hit { fill: transparent; cursor: crosshair; }
#fig-hascan .ramp i { background: linear-gradient(90deg, #f8f7f2, #cde2fb, #86b6ef, #3987e5, #184f95); }
:root[data-theme="dark"] #fig-hascan .ramp i { background: linear-gradient(90deg, #1a1d1f, #1c5cab, #3987e5, #86b6ef, #cde2fb); }

/* Fig: epitopes on the structure */
.epitope-stage { aspect-ratio: 1.45; }
.epitope-stage canvas { width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
.epitope-stage canvas.is-drag { cursor: grabbing; }
#epitope-ruler { width: 100%; height: auto; margin-top: 6px; overflow: visible; }
#epitope-ruler text { font-family: var(--mono); font-size: 10.5px; fill: var(--muted); }
#epitope-ruler .lbl-strong { fill: var(--ink); font-weight: 500; }
#epitope-ruler .ruler-track { fill: var(--surface-2); stroke: var(--line); }
#epitope-ruler .ruler-seg { fill: var(--s1); }
#epitope-ruler .ruler-seg.s2 { fill: var(--s2); }
#epitope-ruler .ruler-gap { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 3 3; }

/* 9. Work ---------------------------------------------------------------- */
.work { padding: clamp(32px, 5vw, 56px) 0; border-top: 1px solid var(--line); }
.work:first-of-type { border-top: 0; padding-top: 0; }
.work:last-child { padding-bottom: 0; }
.work--split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(24px, 4vw, 56px); align-items: start; }
.work--flip .work-text { order: 2; }
.work--flip { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.fig-stack { display: grid; gap: 20px; min-width: 0; }

.work-meta { color: var(--muted); margin-bottom: 10px; }
.work h3 { font-size: clamp(22px, 2.4vw, 28px); font-weight: 500; line-height: 1.2; letter-spacing: -.015em; margin-bottom: 14px; }
.work-text p:not(.work-meta) { color: var(--ink-2); font-size: 16.5px; }
.work-text p + p { margin-top: .8em; }
.work-text .tags { margin-top: 18px; }
.work-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 18px; }
.work-foot .tags { margin-top: 0; }
@media (min-width: 981px) { .work--split .work-text { position: sticky; top: calc(var(--nav-h) + 24px); } }
@media (max-width: 980px) {
  .work--split, .work--flip { grid-template-columns: 1fr; }
  .work--flip .work-text { order: 0; }
}

/* 10. Software ----------------------------------------------------------- */
.sw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.sw-grid > .sw {
  display: flex; flex-direction: column; gap: 10px; padding: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, transform .15s;
}
.sw-grid > .sw:hover { border-color: var(--line-2); transform: translateY(-2px); }
.sw h3 { font-size: 17px; font-weight: 600; line-height: 1.3; }
.sw p { font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }
.sw-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 8px; }
.lang, .private { color: var(--muted); font-size: 12px; }

.tools { display: grid; gap: 0; border-top: 1px solid var(--line); }
.tools li { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); gap: 4px 24px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.tools a { font-weight: 500; }
.tools span { color: var(--ink-2); }
@media (max-width: 640px) { .tools li { grid-template-columns: 1fr; } }

/* 11. Experience --------------------------------------------------------- */
.xp-list { --info: 320px; }
.xp-axis { display: grid; grid-template-columns: var(--info) 1fr 28px; gap: 20px; margin-bottom: 4px; }
.xp-axis ol { display: flex; }
.xp-axis li { flex: 1; padding: 0 0 6px 6px; border-left: 1px solid var(--line-2); font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

.xp { border-top: 1px solid var(--line); }
.xp:last-child { border-bottom: 1px solid var(--line); }
.xp summary { display: grid; grid-template-columns: var(--info) 1fr 28px; gap: 20px; align-items: center; padding: 14px 0; cursor: pointer; list-style: none; }
.xp summary::-webkit-details-marker { display: none; }
.xp-info { display: grid; gap: 1px; min-width: 0; }
.xp-info strong { font-size: 16.5px; font-weight: 600; line-height: 1.3; }
.xp-info span { font-size: 14.5px; color: var(--ink-2); }
.xp-info time { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.xp-track {
  position: relative; height: 28px;
  background-image: linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: calc(100% / 7) 100%;
}
.xp-bar {
  position: absolute; top: 9px; height: 10px; min-width: 6px; border-radius: 5px;
  left: calc(var(--s) / var(--months) * 100%);
  width: calc((var(--e) - var(--s)) / var(--months) * 100%);
  background: var(--line-2);
  transition: background-color .15s;
}
.xp-bar--now { background: var(--s1); border-radius: 5px 0 0 5px; }
.xp-bar--now::after { content: ""; position: absolute; right: -7px; top: -2px; border: 7px solid transparent; border-right: 0; border-left-color: var(--s1); }
.xp summary:hover .xp-bar:not(.xp-bar--now), .xp[open] .xp-bar:not(.xp-bar--now) { background: var(--ink-2); }
.xp-chev { font-size: 16px; color: var(--muted); transition: transform .2s; justify-self: end; }
.xp[open] .xp-chev { transform: rotate(180deg); }
.xp-body { display: grid; grid-template-columns: var(--info) 1fr 28px; gap: 20px; padding: 2px 0 22px; }
.xp-body p { grid-column: 2; max-width: 70ch; font-size: 15.5px; color: var(--ink-2); }
@media (max-width: 860px) {
  .xp-axis { display: none; }
  .xp summary { grid-template-columns: 1fr 28px; gap: 6px 12px; }
  .xp-track { grid-column: 1 / -1; grid-row: 2; height: 18px; }
  .xp-bar { top: 4px; }
  .xp-body { grid-template-columns: 1fr; }
  .xp-body p { grid-column: 1; }
}

/* 12. Publications ------------------------------------------------------- */
.pubs { border-top: 1px solid var(--line); }
.pub { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.pub-year { color: var(--muted); padding-top: 3px; }
.pub h3 { font-size: 17px; font-weight: 500; line-height: 1.4; max-width: 80ch; }
.pub h3 a { text-decoration: none; }
.pub h3 a:hover { text-decoration: underline; }
.pub-authors { margin-top: 6px; font-size: 14px; line-height: 1.5; color: var(--muted); max-width: 90ch; }
.pub-authors strong { font-weight: 600; color: var(--ink); }
.pub-venue { margin-top: 4px; font-size: 14px; color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
@media (max-width: 560px) { .pub { grid-template-columns: 1fr; gap: 4px; } }

/* 13. Skills ------------------------------------------------------------- */
.skill-groups { border-top: 1px solid var(--line); }
.skill-group { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 12px 32px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.skill-group h3 { font-size: 15.5px; font-weight: 600; line-height: 1.35; }
.skill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.skill-list li {
  padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-2);
}
.skill-list li.is-match { border-color: var(--s1); color: var(--ink); }
@media (max-width: 760px) { .skill-group { grid-template-columns: 1fr; } }

/* 14. Background --------------------------------------------------------- */
.bg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 64px); }
.bg-grid .sub { margin-top: 0; }
.edu li { display: grid; gap: 2px; padding: 14px 0; border-top: 1px solid var(--line); }
.edu strong { font-weight: 600; }
.edu span { color: var(--ink-2); font-size: 15px; }
.edu time { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.awards li { padding: 12px 0; border-top: 1px solid var(--line); font-size: 15.5px; color: var(--ink-2); }
.awards strong { color: var(--ink); font-weight: 600; }
@media (max-width: 860px) { .bg-grid { grid-template-columns: 1fr; } }

.fold { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.bg-grid + .fold { margin-top: 40px; }
.fold summary { display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; list-style: none; font-weight: 500; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary .ico { margin-left: auto; color: var(--muted); transition: transform .2s; }
.fold[open] summary .ico { transform: rotate(180deg); }
.fold-n { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.certs { padding: 0 18px 12px; }
.certs li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px; }
.certs span { color: var(--muted); font-size: 14px; }
.courses { padding: 4px 18px 18px; }

/* 15. Contact + footer --------------------------------------------------- */
.section--contact { padding-bottom: clamp(64px, 9vw, 120px); }
.contact-lead { max-width: 28ch; font-size: clamp(24px, 3.2vw, 36px); line-height: 1.25; letter-spacing: -.02em; }
.contact-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.links--lg { margin-top: 28px; font-size: 15.5px; gap: 8px 24px; }
.links--lg a { display: inline-flex; align-items: center; gap: 5px; }
.links--lg .ico { font-size: 12px; }

.footer { border-top: 1px solid var(--line); padding: 22px 0 32px; font-size: 13.5px; color: var(--muted); }
.footer-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }

/* 16. Quick navigation --------------------------------------------------- */
.palette {
  width: min(560px, calc(100vw - 24px)); margin: 14vh auto auto; padding: 0;
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}
.palette::backdrop { background: rgba(14, 16, 17, .45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.palette .search { display: flex; margin: 10px; border-color: var(--line); }
.palette .search:focus-within { box-shadow: none; border-color: var(--line-2); }
.palette-list { max-height: min(50vh, 380px); overflow: auto; padding: 0 6px; }
.palette-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border-radius: 8px; font-size: 15px; cursor: pointer;
}
.palette-list li small { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.palette-list li[aria-selected="true"] { background: var(--surface-2); }
.palette-list .none { color: var(--muted); cursor: default; }
.palette-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 10px 16px 12px; border-top: 1px solid var(--line); margin-top: 6px; font-size: 12px; color: var(--muted); }

/* Without JavaScript the interactive figures and controls have nothing to do,
   so they step aside and the text stands on its own. */
html:not(.js) .work .fig:not(.fig--code),
html:not(.js) .filterbar,
html:not(.js) .nav-tools,
html:not(.js) #fig-ha canvas,
html:not(.js) #fig-ha .fig-foot,
html:not(.js) .fig-pause,
html:not(.js) [data-copy],
html:not(.js) [data-copy-text] { display: none; }
html:not(.js) .ha-stage { aspect-ratio: auto; }

/* 17. Motion + print ----------------------------------------------------- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s cubic-bezier(.2, .8, .2, 1); }
.js .reveal.is-in { opacity: 1; transform: none; }

@media (max-width: 640px) {
  /* On a narrow screen these two readouts run to a second line as their content
     changes. Reserve both lines so the figure cannot resize under the reader. */
  #fig-levels .fig-readout,
  #fig-4pl .fig-readout { min-height: 3.2em; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
  .js .reveal { opacity: 1; transform: none; }
}

@media print {
  .nav, .fig-controls, .fig-pause, .filterbar, .palette, .skip, .actions, .contact-row { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .section { padding: 18pt 0; }
  .fig, .card, .sw { box-shadow: none; break-inside: avoid; }
  .js .reveal { opacity: 1; transform: none; }
  details > *:not(summary) { display: block; }
}
