/* ==========================================================================
   Parva Mehta — Research Portfolio
   A research-paper layout: title page that zooms into the document,
   numbered sections, margin figures, booktabs tables.
   Palette: paper white, ink black, greys + one steel-blue accent.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --rail: 248px;
  --bar: 56px;
  --measure: 670px;
  --margin-col: 252px;
  --gutter: clamp(18px, 4.2vw, 52px);
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* light */
  --paper: #efeee9;      /* "White Dove": soft, neutral off-white */
  --card: #f4f3ef;       /* raised surfaces, a touch lighter than the page */
  --desk: #dde1e5;
  --desk-dot: #c7cfd8;
  --ink: #1a1a19;
  --ink-2: #45433e;
  --ink-3: #74716a;
  --rule: #d4d2ca;
  --rule-2: #e2e0da;
  --faux: #dbd9d2;

  /* steel-blue accent */
  --acc: #2f5b86;        /* text-safe (6.8:1 on paper) */
  --acc-2: #4a7fb0;      /* strokes, marks */
  --acc-soft: #b5c8dc;   /* borders, hovers */
  --tint: #e1e8f0;       /* fills */
  --tint-2: #e8ecf0;

  --sheet-shadow: 0 1px 2px rgba(22, 36, 54, .06), 0 2px 8px rgba(22, 36, 54, .05), 0 40px 90px -30px rgba(22, 40, 64, .30);
  --card-shadow: 0 1px 2px rgba(22, 36, 54, .04), 0 18px 40px -22px rgba(22, 40, 64, .28);
}

:root[data-theme="dark"] {
  --paper: #141413;
  --card: #181817;
  --desk: #0a0c0e;
  --desk-dot: #1b222b;
  --ink: #ebe8e1;
  --ink-2: #bdb9b0;
  --ink-3: #87847c;
  --rule: #2d2c29;
  --rule-2: #201f1d;
  --faux: #282826;

  --acc: #a5c3e3;
  --acc-2: #7ea6d0;
  --acc-soft: #34495f;
  --tint: rgba(126, 166, 208, .12);
  --tint-2: rgba(126, 166, 208, .05);

  --sheet-shadow: 0 0 0 1px rgba(255, 255, 255, .05), 0 40px 90px -30px rgba(0, 0, 0, .9);
  --card-shadow: 0 0 0 1px rgba(126, 166, 208, .08), 0 18px 40px -22px rgba(0, 0, 0, .8);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 24px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.62;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
  transition: background-color .3s ease, color .3s ease;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; }
a { color: inherit; }
sup { font-size: .68em; line-height: 0; }
::selection { background: var(--acc-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--acc-2); outline-offset: 3px; }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip {
  position: fixed; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 8px 12px;
  font: 500 12px/1 var(--mono); text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- Theme toggle: bordered, mono, small caps ---------- */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  font: 600 9.5px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color .18s, color .18s, background-color .18s;
}
.theme-toggle:hover { border-color: var(--acc-2); color: var(--ink); }
.theme-toggle svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.theme-toggle .i-moon { fill: currentColor; stroke: none; }
:root[data-theme="dark"] .theme-toggle .i-moon,
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }

::view-transition-old(root),
::view-transition-new(root) { animation-duration: .45s; animation-timing-function: cubic-bezier(.4, 0, .2, 1); }

/* ---------- Desktop rail ---------- */
.rail {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  width: var(--rail);
  display: flex; flex-direction: column; justify-content: space-between; gap: 24px;
  padding: 30px 26px 26px;
  background: var(--paper);
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  transition: background-color .3s ease, border-color .3s ease;
}
.mark { text-decoration: none; display: block; }
.mark-name { display: block; font-size: 25px; font-weight: 500; letter-spacing: -.01em; line-height: 1.1; }
.mark-sub {
  display: block; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule);
  font: 500 9.5px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3);
}

.toc { position: relative; padding-left: 16px; }
.toc-label { font: 600 9.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 14px; }
.toc ol { list-style: none; display: grid; gap: 1px; }
.toc a {
  display: flex; align-items: baseline; gap: 10px;
  padding: 4px 0;
  text-decoration: none;
  font-size: 15px; line-height: 1.3;
  color: var(--ink-3);
  transition: color .2s, transform .3s var(--ease);
}
.toc a .n { width: 14px; flex: none; font: 500 10.5px/1 var(--mono); color: var(--ink-3); transition: color .2s; }
.toc a:hover { color: var(--ink); }
.toc a.is-active { color: var(--ink); transform: translateX(3px); }
.toc a.is-active .n { color: var(--acc-2); }
.toc-track { position: absolute; left: 0; top: 26px; bottom: 4px; width: 1px; background: var(--rule); }
.toc-fill { position: absolute; inset: 0; background: var(--acc-2); transform-origin: top; transform: scaleY(0); }

.rail-foot { display: grid; gap: 12px; justify-items: start; }
.pdf-btn {
  display: block; width: 100%; text-align: center;
  padding: 12px 10px;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink);
  font: 600 10px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  text-decoration: none;
  transition: background-color .2s, color .2s, border-color .2s;
}
.pdf-btn:hover { background: var(--tint); color: var(--acc); border-color: var(--acc-2); }
.rev { font: 400 9.5px/1 var(--mono); letter-spacing: .08em; color: var(--ink-3); }

/* ---------- Mobile / tablet bar (shown below 1061px) ---------- */
.bar { display: none; }

/* ---------- Layout ---------- */
main { margin-left: var(--rail); }

/* ==========================================================================
   Title page / zoom intro
   ========================================================================== */
.intro { position: relative; height: calc(100vh + 118vh); }
.stage {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
  background-color: var(--desk);
  background-image: radial-gradient(var(--desk-dot) 1px, transparent 1.2px);
  background-size: 22px 22px;
  transition: background-color .3s ease;
}
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.js .world, .js .cue { opacity: 0; transition: opacity .7s ease; }
.js .intro.is-ready .world, .js .intro.is-ready .cue { opacity: 1; }
.sheet { position: relative; width: 100vw; height: 100vh; background: var(--paper); transition: background-color .3s ease; }
.sheet-shadow { position: absolute; inset: 0; box-shadow: var(--sheet-shadow); pointer-events: none; }

.sheet-head, .stamp, .faux-page {
  position: absolute; margin: 0;
  font: 500 13px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3);
}
.sheet-head { left: 0; right: 0; text-align: center; }
.stamp {
  transform-origin: 0 0; transform: rotate(-90deg);
  letter-spacing: .1em; font-size: 15px; color: var(--acc-2); white-space: nowrap;
}

/* Title block (real hero content) */
.title-block {
  position: absolute; left: 50%; top: 0;
  width: min(900px, 90%);
  transform: translateX(-50%);
  text-align: center;
}
.tb-kicker { font: 500 12px/1.4 var(--mono); letter-spacing: .26em; text-transform: uppercase; color: var(--acc); }
.tb-name {
  margin-top: clamp(16px, 2.6vh, 30px);
  font-size: clamp(50px, 7.4vw, 108px);
  font-weight: 500; letter-spacing: -.025em; line-height: .98;
  font-variation-settings: "opsz" 60;
}
.tb-sub {
  margin: clamp(20px, 3.2vh, 36px) auto 0; max-width: 44ch;
  font-size: clamp(18px, 1.75vw, 23px); font-style: italic; font-weight: 400; line-height: 1.5; color: var(--ink-2);
  text-wrap: balance;
}
.tb-rule { display: block; width: 36px; height: 1px; margin: clamp(22px, 3.4vh, 38px) auto 0; background: var(--acc-2); }
.tb-aff { margin-top: clamp(16px, 2.6vh, 28px); font-size: 17px; color: var(--ink); text-wrap: balance; }
.tb-deg { margin-top: 8px; font: 400 11px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.tb-links {
  list-style: none; margin-top: clamp(22px, 3.4vh, 38px);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0;
  font: 500 11.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
}
.tb-links li + li::before { content: "/"; margin: 0 18px; color: var(--rule); }
.tb-links a { text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--acc-soft); padding-bottom: 3px; transition: border-color .2s, color .2s; }
.tb-links a:hover { border-color: var(--acc-2); color: var(--acc); }
.tb-stats {
  margin: clamp(30px, 5.4vh, 60px) auto 0; max-width: 700px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink);
}
.tb-stats div { padding: clamp(12px, 2vh, 18px) 10px clamp(13px, 2.1vh, 19px); }
.tb-stats div + div { border-left: 1px solid var(--rule); }
.tb-stats dt { font-size: 30px; font-weight: 500; line-height: 1; font-variant-numeric: lining-nums; }
.tb-stats dd { margin-top: 9px; font: 400 10px/1.5 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }

/* Faux paper body */
.faux { position: absolute; left: 50%; transform: translateX(-50%); }
.faux i { display: block; height: 11px; margin-bottom: 11px; background: var(--faux); border-radius: 1px; }
.faux-h { text-align: center; font-weight: 600; font-size: 22px; margin-bottom: 18px; color: var(--ink-2); }
.faux-abs { width: 82%; margin: 0 auto 46px; }
.faux-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 54px; }
.faux-sec { font-weight: 600; font-size: 21px; margin: 6px 0 16px; color: var(--ink-2); }
.faux-sec:not(:first-child) { margin-top: 30px; }
.faux-fig { border: 1.5px solid var(--faux); height: 190px; padding: 22px; margin-bottom: 12px; background: var(--tint-2); }
.faux-fig svg { width: 100%; height: 100%; fill: none; stroke: var(--ink-3); stroke-width: 1.4; }
.faux-fig svg path { vector-effect: non-scaling-stroke; }
.faux-fig svg .faux-acc { stroke: var(--acc-2); stroke-width: 2; }
.faux-cap { height: 9px; width: 70%; margin: 0 auto 26px; background: var(--faux); }
.faux-page { position: static; text-align: center; margin-top: 40px; font-size: 14px; }
.faux-more { display: none; }
/* tall screens: clip the faux text to the page and pin the page number to the bottom */
.intro.is-portrait .sheet { overflow: hidden; }
.intro.is-portrait .faux { display: flex; flex-direction: column; }
.intro.is-portrait .faux-body { flex: 1; min-height: 0; overflow: hidden; }
.intro.is-portrait .faux-more { display: block; margin-top: 34px; }
.intro.is-portrait .faux-page { margin-top: 18px; flex: none; }

/* Scroll cue */
.cue {
  position: absolute; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font: 500 10px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3);
  pointer-events: none;
}
.cue i { width: 1px; height: 34px; background: linear-gradient(var(--acc-2), transparent); transform-origin: top; animation: cue 2.2s var(--ease) infinite; }
@keyframes cue { 0% { transform: scaleY(0); opacity: 1; } 60% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }

/* Loading hint: a faint page outline pulses on the desk until the title page is ready.
   It only starts after .5s, so on a normal connection it is never seen. */
.js .stage::before {
  content: ""; position: absolute; left: 50%; top: 47%;
  height: min(80%, calc((100vw - var(--rail)) * 1.118)); aspect-ratio: 1 / 1.3;
  transform: translate(-50%, -50%);
  border: 1px solid var(--rule); background: var(--paper);
  opacity: 0; pointer-events: none;
  animation: page-wait 1.8s ease-in-out .5s infinite;
}
.js .stage::after {
  content: "Loading"; position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  font: 500 10px/1 var(--mono); letter-spacing: .24em; text-transform: uppercase; color: var(--ink-3);
  opacity: 0; pointer-events: none;
  animation: page-wait 1.8s ease-in-out .5s infinite;
}
.js .intro.is-ready .stage::before, .js .intro.is-ready .stage::after { animation: none; opacity: 0; transition: opacity .3s ease; }
@keyframes page-wait { 0%, 100% { opacity: .25; } 50% { opacity: .75; } }
@media (prefers-reduced-motion: reduce) {
  .js .stage::before, .js .stage::after { animation: none; opacity: .5; }
}

/* Fallback (script too slow or blocked): the static title page fades in */
.fallback .title-block { animation: fallback-in .6s ease both; }
@keyframes fallback-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Without JS: plain static title page */
.no-js .intro { height: auto; }
.no-js .stage { position: relative; height: auto; background: var(--paper); }
.no-js .world, .no-js .sheet { position: relative; width: auto; height: auto; }
.no-js .title-block { position: relative; transform: none; left: auto; margin: 0 auto; padding: 18vh 0 12vh; }
.no-js .faux, .no-js .sheet-head, .no-js .stamp, .no-js .sheet-shadow, .no-js .cue { display: none; }

/* ==========================================================================
   Document
   ========================================================================== */
.doc {
  container: doc / inline-size;
  max-width: calc(var(--measure) + var(--margin-col) + 56px + 2 * var(--gutter));
  margin: 0 auto;
  padding: clamp(64px, 12vh, 140px) var(--gutter) 0;
}
section { padding-bottom: clamp(56px, 9vh, 100px); }

/* Abstract (paper-style, first person) */
.abstract { max-width: 660px; margin: 0 auto; }
.abs-h {
  text-align: center; font-size: 14px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  margin-bottom: 18px;
}
.abs-h::after { content: ""; display: block; width: 28px; height: 2px; margin: 12px auto 0; background: var(--acc-2); }
.abstract p { font-size: 18.5px; line-height: 1.7; color: var(--ink-2); }
.abstract p + p { margin-top: 14px; }
.abstract .lede { font-size: 21px; line-height: 1.55; color: var(--ink); }
.abstract .sign { text-align: right; font-style: italic; color: var(--ink-3); }
.inline { color: var(--acc); text-decoration: underline; text-decoration-color: var(--acc-soft); text-underline-offset: 3px; transition: text-decoration-color .2s; }
.inline:hover { text-decoration-color: var(--acc-2); }

/* Section heads */
.sec-head {
  display: flex; align-items: flex-start; gap: 20px;
  padding-bottom: 16px; margin-bottom: 34px;
  border-bottom: 1px solid var(--rule);
}
.sec-num {
  position: relative; flex: none; align-self: stretch;
  min-width: .62em; text-align: left;
  font-size: clamp(26px, 2.6vw, 34px); line-height: 1.15; font-weight: 400; color: var(--acc-2);
  font-variant-numeric: lining-nums tabular-nums;
}
/* accent rule under the number only: number width + ~2.5mm, sitting exactly on the section rule */
.sec-num::after { content: ""; position: absolute; left: 0; right: -10px; bottom: -17px; height: 2px; background: var(--acc-2); }
.sec-head h2 { font-size: clamp(26px, 2.6vw, 34px); font-weight: 500; letter-spacing: -.012em; line-height: 1.15; }
.sec-intro { max-width: var(--measure); font-size: 17px; font-style: italic; color: var(--ink-2); margin-bottom: 26px; }

/* Citations */
.cite { font-family: var(--serif); color: var(--acc); text-decoration: none; white-space: nowrap; position: relative; }
.cite:hover { text-decoration: underline; text-underline-offset: 3px; }
@media (hover: hover) {
  .cite::after {
    content: attr(data-ref);
    position: absolute; left: 50%; bottom: calc(100% + 8px);
    transform: translate(-50%, 4px);
    width: max-content; max-width: 240px; white-space: normal;
    padding: 7px 10px;
    background: var(--ink); color: var(--paper);
    font: 400 11px/1.4 var(--mono); letter-spacing: .02em; text-align: left;
    opacity: 0; pointer-events: none;
    transition: opacity .18s, transform .18s var(--ease);
    z-index: 5;
  }
  .cite:hover::after { opacity: 1; transform: translate(-50%, 0); }
}

/* Research interests */
.threads { list-style: none; max-width: calc(var(--measure) + 60px); border-top: 1px solid var(--rule-2); }
.threads li { display: grid; grid-template-columns: 52px 1fr; align-items: baseline; padding: 16px 0; border-bottom: 1px solid var(--rule-2); }
.th-k { font-style: italic; color: var(--acc-2); font-size: 17px; }
.threads h3 { font-size: 18.5px; font-weight: 600; line-height: 1.35; }
.threads p { margin-top: 4px; font-size: 16.5px; color: var(--ink-2); }
.methods { max-width: calc(var(--measure) + 60px); margin-top: 22px; font-size: 15.5px; color: var(--ink-2); font-style: italic; }
.methods span { font-style: normal; font: 600 10px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--acc); margin-right: 10px; }

/* Entries: main column + margin column */
.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--margin-col);
  gap: 56px;
  align-items: start;
}
.aside { padding-top: 4px; }
/* every margin figure sits in the same frame: hairline on top, figure, caption */
.aside.fig { border-top: 1px solid var(--rule); padding-top: 16px; }

/* Publications */
.legend { font: 400 11.5px/1.5 var(--mono); color: var(--ink-3); letter-spacing: .04em; margin: -12px 0 30px; }
.legend sup { font-size: 1em; }
.group {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font: 600 11px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-2);
  margin: 6px 0 22px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; border: 1.4px solid var(--acc-2); flex: none; }
.dot-full { background: var(--acc-2); }
.dot-half { background: linear-gradient(90deg, var(--acc-2) 50%, transparent 50%); }

.pub { padding: 0 0 44px; }
.pub + .group { margin-top: 10px; }
.pub-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.pub-id { font: 500 12px/1 var(--mono); color: var(--ink-3); }
.chip {
  font: 500 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  padding: 5px 8px; border: 1px solid var(--rule); color: var(--ink-2);
}
.chip-acc { background: var(--tint); border-color: var(--acc-soft); color: var(--acc); }
.pub-title { font-size: 22px; font-weight: 600; line-height: 1.3; letter-spacing: -.005em; max-width: 36em; text-wrap: pretty; }
.authors { margin-top: 10px; font-size: 16px; color: var(--ink-2); line-height: 1.55; }
.me { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--acc-soft); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.venue { margin-top: 6px; font-size: 16px; font-style: italic; color: var(--ink-2); }
.summary { margin-top: 12px; font-size: 16.5px; color: var(--ink-2); }
.role {
  margin-top: 14px; padding: 12px 16px;
  border-left: 2px solid var(--acc-2); background: var(--tint-2);
  font-size: 16px; color: var(--ink-2);
}
.role span { display: block; font: 600 9.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--acc); margin-bottom: 8px; }

.pub-links { margin-top: 16px; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 10px; }
.btn-link {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px;
  font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink); text-decoration: none;
  padding: 7px 11px; border: 1px solid var(--rule); background: transparent;
  cursor: pointer;
  transition: border-color .2s, background-color .2s, color .2s;
}
.btn-link:hover { border-color: var(--acc-2); background: var(--tint-2); color: var(--acc); }
.proj .btn-link { margin-top: 18px; }

.bib { flex-basis: 100%; display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s var(--ease); }
.bib.is-open { grid-template-rows: 1fr; }
.bib-inner { overflow: hidden; min-height: 0; }
.bib-btn[aria-expanded="true"] { border-color: var(--acc-2); background: var(--tint); color: var(--acc); }
.bib-body { position: relative; padding-top: 10px; }
.bib pre {
  margin: 0; padding: 16px 18px; overflow-x: auto;
  background: var(--tint-2); border: 1px solid var(--rule);
  font: 400 12px/1.6 var(--mono); color: var(--ink-2);
}
.copy {
  position: absolute; top: 18px; right: 8px;
  font: 500 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  padding: 6px 8px; background: var(--paper); color: var(--ink-2); border: 1px solid var(--rule); cursor: pointer;
}
.copy:hover { color: var(--acc); border-color: var(--acc-2); }

/* ---------- Work in progress ---------- */
.wip-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 40px; align-items: start; margin-bottom: 22px; }
.wip-head .sec-intro { margin-bottom: 0; }
.wip-venues {
  display: grid; grid-auto-flow: column; gap: 0;
  border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink);
}
.wip-venues div { padding: 9px 14px 10px; text-align: center; }
.wip-venues div + div { border-left: 1px solid var(--rule); }
.wip-venues dt { font: 500 9.5px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
.wip-venues dd { font-size: 24px; font-weight: 500; line-height: 1.1; margin-top: 4px; color: var(--ink); }

.wip-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.wip-filter button {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 34px; padding: 7px 12px;
  border: 1px solid var(--rule); background: transparent; color: var(--ink-2);
  font: 500 10.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer;
  transition: border-color .2s, background-color .2s, color .2s;
}
.wip-filter button span { color: var(--ink-3); font-weight: 400; }
.wip-filter button:hover { border-color: var(--acc-2); color: var(--ink); }
.wip-filter button.is-on { background: var(--tint); border-color: var(--acc-2); color: var(--acc); }
.wip-filter button.is-on span { color: var(--acc); }

.wip-grid { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.wip {
  position: relative;
  display: flex; flex-direction: column;
  padding: 20px 22px 18px;
  background: var(--card);
  border: 1px solid var(--rule);
  transition: border-color .3s, box-shadow .35s var(--ease), transform .35s var(--ease), opacity .3s ease;
}
.wip::before {
  content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 2px;
  background: var(--acc-2); transform: scaleX(0); transform-origin: left;
  transition: transform .5s var(--ease);
}
@media (hover: hover) {
  .wip:hover { border-color: var(--acc-soft); box-shadow: var(--card-shadow); transform: translateY(-3px); }
  .wip:hover::before { transform: scaleX(1); }
}
.wip:target { border-color: var(--acc-2); }
.wip:target::before { transform: scaleX(1); }
.wip.is-hidden { display: none; }
.wip.is-fading { opacity: 0; }

.wip-top { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.glyph { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--acc-2); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.wip-tag { font: 500 10px/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.wip-venue {
  margin-left: auto; white-space: nowrap;
  font: 600 9.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  padding: 5px 7px; background: var(--tint); color: var(--acc); border: 1px solid var(--acc-soft);
}
.wip-ongoing { background: transparent; color: var(--ink-2); border-style: dashed; border-color: var(--ink-3); }
.wip-title { font-size: 18.5px; font-weight: 600; line-height: 1.32; text-wrap: pretty; }
.wip-sub { font-weight: 400; font-style: italic; color: var(--ink-3); }
.wip-q { margin-top: 10px; font-size: 16px; line-height: 1.55; color: var(--ink-2); font-style: italic; flex: 1; }
.wip-a {
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--rule);
  font-size: 14.5px; color: var(--ink-3); padding-right: 40px;
}
.wip-a .me { font-weight: 600; }
.wip-role {
  display: inline-block; margin-left: 6px;
  font: 500 9.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--acc);
}
.wip-id { position: absolute; right: 20px; bottom: 18px; font: 500 11px/1 var(--mono); color: var(--ink-3); }

/* Experience / generic entries */
.xp, .proj { padding-bottom: 44px; }
.xp + .xp, .proj + .proj { padding-top: 40px; border-top: 1px solid var(--rule-2); }
.when { font: 500 11px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.xp-role { font-size: 22px; font-weight: 600; line-height: 1.3; }
.xp-org { margin-top: 4px; font-size: 17px; font-style: italic; color: var(--ink-2); }
.xp-org a, .bul a { color: var(--acc); text-decoration: none; }
.xp-org a:hover, .bul a:hover { text-decoration: underline; text-underline-offset: 3px; }
.bul { list-style: none; margin-top: 14px; display: grid; gap: 9px; }
.bul li { position: relative; padding-left: 22px; font-size: 17px; color: var(--ink-2); }
.bul li::before { content: ""; position: absolute; left: 3px; top: .78em; width: 8px; height: 1.5px; background: var(--acc-2); }
.bul b { color: var(--ink); font-weight: 600; }


/* Projects */
.proj-t { font-size: 22px; font-weight: 600; line-height: 1.3; }
.stack { margin-top: 6px; font: 400 11.5px/1.5 var(--mono); letter-spacing: .06em; color: var(--ink-3); }
.metrics {
  margin-top: 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink);
}
.metrics div { padding: 12px 14px 12px 0; }
.metrics div + div { padding-left: 16px; border-left: 1px solid var(--rule); }
.metrics dt { font-size: 24px; font-weight: 500; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.metrics dd { margin-top: 5px; font-size: 14px; line-height: 1.4; color: var(--ink-3); }

/* Figures */
.fig { color: var(--ink); }
.fig svg { display: block; width: 100%; height: auto; overflow: visible; }
.fig figcaption { margin-top: 12px; font-size: 13.5px; line-height: 1.5; color: var(--ink-3); }
.fig figcaption b { color: var(--acc); font-weight: 600; }

.ln { fill: none; stroke: currentColor; stroke-width: 1.15; stroke-linecap: round; stroke-linejoin: round; }
.ln-strong { stroke-width: 1.8; }
.ln-soft { opacity: .45; }
.ln.acc, .key-solid.acc { stroke: var(--acc-2); }
.box { fill: var(--paper); }
.box.acc { fill: var(--tint-2); }
.box-strong { stroke-width: 1.9; }
.fl { fill: currentColor; }
.acc-fill { fill: var(--acc-2); }
.node { fill: var(--paper); stroke: currentColor; stroke-width: 1.2; }
.ft text { font-family: var(--mono); font-size: 9.6px; fill: var(--ink-2); letter-spacing: .02em; }
.ft-c text { text-anchor: middle; }
.ft .val { fill: var(--ink); font-weight: 600; }
.ft .dim { fill: var(--ink-3); }
.ft .acc-text { fill: var(--acc); }
.key-solid, .key-dash { stroke: currentColor; fill: none; stroke-width: 1.6; }
.key-dash { opacity: .5; stroke-width: 1.2; }
.grid rect { fill: var(--ink); fill-opacity: var(--o); stroke: var(--ink); stroke-opacity: .35; stroke-width: .6; }
.ticks path { stroke: var(--rule); stroke-width: 1; fill: none; }
.seed { fill: var(--ink-3); opacity: .5; }
.seed-acc { fill: var(--acc-2); opacity: 1; }
.hbar { fill: var(--ink); }
.hbar-soft { fill: var(--ink-3); opacity: .5; }
.hbar-acc { fill: var(--acc-2); }

/* Booktabs table */
.tbl { max-width: calc(var(--measure) + var(--margin-col) + 56px); }
.tbl figcaption { font-size: 15px; color: var(--ink-2); margin-bottom: 12px; }
.tbl figcaption b { color: var(--acc); }
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.booktabs { width: 100%; border-collapse: collapse; font-size: 16.5px; border-top: 1.6px solid var(--ink); border-bottom: 1.6px solid var(--ink); }
.booktabs thead th { font: 600 10px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; text-align: left; padding: 12px 16px 11px 0; border-bottom: 1px solid var(--ink); color: var(--ink-2); }
.booktabs tbody th { text-align: left; font-weight: 600; padding: 13px 24px 13px 0; vertical-align: top; white-space: nowrap; width: 1%; }
.booktabs td { padding: 13px 0; color: var(--ink-2); }
.booktabs tbody tr + tr > * { border-top: 1px solid var(--rule-2); }

/* Contact */
.contact {
  max-width: calc(var(--measure) + 60px);
  padding: 26px 28px; margin-bottom: 26px;
  background: var(--card); border: 1px solid var(--rule); border-left: 2px solid var(--acc-2);
}
.contact-lead { font-size: 19px; line-height: 1.55; color: var(--ink-2); }
.mail {
  display: inline-flex; align-items: center; gap: 14px; margin-top: 18px; max-width: 100%;
  font-size: clamp(19px, 2.4vw, 26px); font-weight: 500; color: var(--ink); text-decoration: none;
  border-bottom: 2px solid var(--acc-soft); padding-bottom: 4px;
  transition: border-color .2s, color .2s;
}
.mail span:first-child { overflow-wrap: anywhere; }
.mail span:last-child { color: var(--acc-2); transition: transform .3s var(--ease); }
.mail:hover { color: var(--acc); border-color: var(--acc-2); }
.mail:hover span:last-child { transform: translateX(4px); }
.refs { list-style: none; display: grid; gap: 12px; max-width: var(--measure); }
.refs li { display: grid; grid-template-columns: 48px 92px minmax(0, 1fr); align-items: baseline; font-size: 17px; }
.ref-k { font: 500 12px/1 var(--mono); color: var(--ink-3); }
.refs li > span:nth-child(2) { color: var(--ink-2); }
.refs a { color: var(--acc); text-decoration: none; overflow-wrap: anywhere; }
.refs a:hover { text-decoration: underline; text-underline-offset: 3px; }

.colophon {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  padding: 26px 0 max(40px, env(safe-area-inset-bottom)); border-top: 1px solid var(--rule);
  font: 400 11px/1.6 var(--mono); letter-spacing: .04em; color: var(--ink-3);
}
.totop { color: var(--ink-2); text-decoration: none; text-transform: uppercase; letter-spacing: .14em; }
.totop:hover { color: var(--acc); }

/* ==========================================================================
   Scroll reveals + figure drawing (only when JS is running)
   ========================================================================== */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }
.js .wip.reveal.is-in { transition: opacity .5s ease, transform .9s var(--ease), border-color .3s, box-shadow .35s var(--ease); }
@media (hover: hover) { .js .wip.reveal.is-in:hover { transform: translateY(-3px); transition-duration: .35s; } }
.js .wip.reveal.is-in.is-fading { opacity: 0; transition: opacity .2s ease; }

/* solid strokes draw themselves (pathLength=1 is set from JS); dashed strokes fade in */
.js .fig .ln[pathLength] { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.5s cubic-bezier(.55, .1, .25, 1) var(--d, 0s); }
.js .is-in .fig .ln[pathLength] { stroke-dashoffset: 0; }
.js .fig .ln.dashed { opacity: 0; transition: opacity 1s ease var(--d, 0s); }
.js .is-in .fig .ln.dashed { opacity: 1; }
.js .is-in .fig .ln-soft.dashed { opacity: .45; }
.js .fig .ft, .js .fig .fl, .js .fig .acc-fill, .js .fig .node, .js .fig .grid, .js .fig .key-solid, .js .fig .key-dash, .js .fig .seed { opacity: 0; transition: opacity .9s ease .6s; }
.js .is-in .fig .ft, .js .is-in .fig .fl, .js .is-in .fig .acc-fill, .js .is-in .fig .node, .js .is-in .fig .grid, .js .is-in .fig .key-solid, .js .is-in .fig .seed-acc { opacity: 1; }
.js .is-in .fig .seed:not(.seed-acc) { opacity: .5; }
.js .is-in .fig .key-dash { opacity: .5; }
.js .fig .hbar { transform: scaleX(0); transform-box: fill-box; transform-origin: left; transition: transform 1.3s var(--ease) var(--d, 0s); }
.js .is-in .fig .hbar { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .js .reveal, .js .wip.reveal.is-in { opacity: 1; transform: none; transition: none; }
  .js .fig .ln[pathLength] { stroke-dasharray: none; stroke-dashoffset: 0; transition: none; }
  .js .fig .ln.dashed { opacity: 1; transition: none; }
  .js .fig .ln-soft.dashed { opacity: .45; }
  .js .fig .ft, .js .fig .fl, .js .fig .acc-fill, .js .fig .node, .js .fig .grid, .js .fig .key-solid, .js .fig .seed-acc { opacity: 1; transition: none; }
  .js .fig .seed:not(.seed-acc) { opacity: .5; transition: none; }
  .js .fig .hbar { transform: none; transition: none; }
  .cue i { animation: none; }
  body, .rail, .stage, .sheet, .wip { transition: none; }
}

/* ==========================================================================
   Responsive
   Laptop/desktop is the primary target; everything below adapts down.
   Content blocks respond to the width of the document column (container
   queries), so they behave the same with or without the side rail.
   ========================================================================== */

/* Large monitors */
@media (min-width: 1600px) {
  :root { --rail: 268px; --measure: 720px; --margin-col: 276px; }
  body { font-size: 19px; }
}

/* Document column too narrow for text + margin column: figures move under the text */
@container doc (max-width: 860px) {
  .entry { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .aside { padding-top: 0; }
  /* figure beside its caption, like a wide figure in a paper */
  .aside.fig { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 22px; align-items: center; max-width: 620px; }
  .aside.fig figcaption { margin-top: 0; }
  .wip-head { grid-template-columns: minmax(0, 1fr); }
  .wip-venues { justify-self: start; }
}
@container doc (max-width: 680px) {
  .wip-grid { grid-template-columns: minmax(0, 1fr); }
}
@container doc (max-width: 520px) {
  .aside.fig { grid-template-columns: minmax(0, 1fr); gap: 0; max-width: 400px; }
  .aside.fig figcaption { margin-top: 10px; }
  .wip-venues { width: 100%; grid-auto-columns: 1fr; }
  .wip-venues div { padding: 8px 4px 9px; display: flex; flex-direction: column; justify-content: space-between; }
  .wip-venues dt { white-space: normal; font-size: 8.5px; letter-spacing: .06em; }
  .wip-venues dd { font-size: 21px; }
  /* topic filter becomes one swipeable row */
  .wip-filter {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter);
    scroll-padding-inline: var(--gutter);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
            mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
  }
  .wip-filter::-webkit-scrollbar { display: none; }
  .wip-filter button { flex: none; }
  .threads li { grid-template-columns: 38px 1fr; }
  .refs li { grid-template-columns: 36px 76px minmax(0, 1fr); font-size: 16px; }
  .wip { padding: 18px 18px 16px; }
  .wip-id { right: 16px; bottom: 16px; }
  .contact { padding: 22px 20px; }
}

/* Small laptops: keep the rail but tighten it */
@media (max-width: 1240px) and (min-width: 1061px) {
  :root { --rail: 224px; --margin-col: 224px; }
  .rail { padding: 26px 20px 22px; }
  .entry { gap: 40px; }
}

/* Tablets and phones: top bar instead of rail */
@media (max-width: 1060px) {
  :root { --rail: 0px; }
  .rail { display: none; }
  main { margin-left: 0; padding-top: var(--bar); }
  html { scroll-padding-top: calc(var(--bar) + 16px); }

  .bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: fixed; inset: 0 0 auto 0; z-index: 40;
    height: var(--bar); padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    background: var(--paper); border-bottom: 1px solid var(--rule);
    transition: background-color .3s ease;
  }
  .bar-name { font-size: 19px; font-weight: 500; text-decoration: none; letter-spacing: -.01em; white-space: nowrap; }
  .bar-actions { display: flex; align-items: center; gap: 8px; }
  .menu-btn, .bar-pdf, .bar .theme-toggle {
    min-height: 36px; padding: 0 12px;
    display: inline-flex; align-items: center;
    border: 1px solid var(--rule); background: transparent; color: var(--ink-2);
    font: 600 9.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; text-decoration: none; cursor: pointer;
  }
  .bar-pdf { background: var(--ink); color: var(--paper); border-color: var(--ink); }
  .menu-btn[aria-expanded="true"] { border-color: var(--acc-2); color: var(--acc); background: var(--tint); }
  .bar-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--acc-2); transform-origin: left; transform: scaleX(0); }
  .mnav {
    position: absolute; top: var(--bar); left: 0; right: 0;
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px;
    padding: 10px var(--gutter) 18px;
    max-height: calc(100svh - var(--bar)); overflow-y: auto;
    background: var(--paper); border-bottom: 1px solid var(--rule);
    box-shadow: 0 24px 40px -24px rgba(0, 0, 0, .25);
  }
  .mnav[hidden] { display: none; }
  .mnav a { display: flex; gap: 14px; align-items: baseline; padding: 12px 0; text-decoration: none; font-size: 17px; border-bottom: 1px solid var(--rule-2); }
  .mnav a:hover { color: var(--acc); }
  .mnav .n { width: 16px; font: 500 11px/1 var(--mono); color: var(--acc-2); }
  .mnav-pdf { grid-column: 1 / -1; font: 600 11px/1 var(--mono) !important; letter-spacing: .14em; text-transform: uppercase; border-bottom: 0 !important; padding-top: 16px !important; color: var(--acc); }

  .intro { height: calc(100vh - var(--bar) + 96vh); }
  .stage { top: var(--bar); height: calc(100vh - var(--bar)); height: calc(100svh - var(--bar)); }
}

/* Phones */
@media (max-width: 640px) {
  body { font-size: 17px; }
  .bar-pdf { display: none; }
  .mnav { grid-template-columns: 1fr; }
  .tb-stats { grid-template-columns: repeat(2, 1fr); }
  .tb-stats div:nth-child(3) { border-left: 0; }
  .tb-stats div:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .tb-links { font-size: 10.5px; row-gap: 12px; }
  .tb-links li + li::before { margin: 0 9px; }
  .tb-aff { font-size: 15.5px; }
  .tb-deg { font-size: 10px; }
  .tb-links li + li::before { margin: 0 9px; }
  .abstract p { font-size: 17.5px; }
  .abstract .lede { font-size: 19.5px; }
  .pub-title, .xp-role, .proj-t { font-size: 20px; }
  .wip-title { font-size: 17.5px; }
  .booktabs { font-size: 15.5px; }
  .booktabs tbody th { white-space: normal; width: 34%; padding-right: 14px; }
  .theme-toggle .tt-label { display: none; }
  .bar .theme-toggle { padding: 0 11px; }
  .contact-lead { font-size: 17.5px; }
}
@media (max-width: 360px) {
  .bar-name { font-size: 17px; }
  .menu-btn { padding: 0 9px; }
  .tb-links li + li::before { margin: 0 6px; }
}

/* Short screens (landscape phones, small laptop windows): compress the title page */
@media (max-height: 680px) {
  .tb-name { font-size: clamp(42px, 11vh, 84px); margin-top: 10px; }
  .tb-sub { font-size: clamp(16px, 2.8vh, 20px); margin-top: 12px; }
  .tb-rule { margin-top: 14px; }
  .tb-aff { margin-top: 10px; font-size: 15px; }
  .tb-links { margin-top: 14px; }
  .tb-stats { margin-top: 18px; }
  .tb-stats div { padding: 8px 6px 9px; }
  .tb-stats dt { font-size: 22px; }
}
@media (max-height: 480px) {
  .tb-rule, .tb-aff, .tb-deg, .tb-stats, .cue { display: none; }
}

/* ---------- Print: it is a paper, after all ---------- */
@media print {
  .rail, .bar, .cue, .faux, .sheet-head, .stamp, .sheet-shadow, .copy, .skip, .wip-filter { display: none !important; }
  main { margin: 0; padding: 0; }
  .intro, .stage, .world, .sheet { position: static !important; height: auto !important; width: auto !important; transform: none !important; background: none !important; opacity: 1 !important; }
  .title-block { position: static; transform: none; margin: 0 auto; padding: 0 0 24px; }
  .js .reveal { opacity: 1 !important; transform: none !important; }
  .js .fig .ln { stroke-dashoffset: 0 !important; }
  .js .fig .ln.dashed { opacity: 1 !important; }
  .js .fig .ft, .js .fig .fl, .js .fig .node, .js .fig .grid { opacity: 1 !important; }
  .js .fig .hbar { transform: none !important; }
  .wip.is-hidden { display: flex !important; }
  .bib { display: none !important; }
}
