/* Mind the Gap: Hi-LeWM project page
   Palette follows the UvA theme (uvared #C41E3A, ricegray #5E6062). */

:root {
  --bg: #fdfdfb;
  --surface: #ffffff;
  --panel: #f4f3ef;
  --ink: #16181a;
  --muted: #5e6062;
  --faint: #83858a;
  --line: #e3e1dc;
  --line-strong: #cfccc5;
  --red: #c41e3a;
  --red-soft: #f9e5e8;
  --red-hover: #9e1830;
  --orange: #e67e22;
  --orange-soft: #f6c496;
  --blue: #2e86de;
  --gray-series: #8d9096;
  --figure-bg: #ffffff;
  --shadow: none;

  --serif: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --measure: 68ch;
  --page: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121314;
    --surface: #191a1c;
    --panel: #1d1f21;
    --ink: #ecebe7;
    --muted: #a3a4a6;
    --faint: #8b8d90;
    --line: #2b2d30;
    --line-strong: #3a3d41;
    --red: #e2314b;
    --red-soft: #2a1417;
    --red-hover: #ff4d63;
    --orange-soft: #f2b177;
    --figure-bg: #f6f6f4;
  }
}

:root[data-theme="dark"] {
  --bg: #121314;
  --surface: #191a1c;
  --panel: #1d1f21;
  --ink: #ecebe7;
  --muted: #a3a4a6;
  --faint: #8b8d90;
  --line: #2b2d30;
  --line-strong: #3a3d41;
  --red: #e2314b;
  --red-soft: #2a1417;
  --red-hover: #ff4d63;
  --orange-soft: #f2b177;
  --figure-bg: #f6f6f4;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

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

a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
a:hover { color: var(--red); border-bottom-color: var(--red); }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.22; letter-spacing: -0.01em; }

code, .num, table, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.wrap { width: min(100% - 3rem, var(--page)); margin-inline: auto; }
.prose { max-width: var(--measure); }
.prose p { margin: 0 0 1.05em; }

/* ---------- navigation ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
  width: min(100% - 3rem, var(--page));
  margin-inline: auto;
}

.nav-mark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 0.98rem;
  border: none;
  white-space: nowrap;
}
.nav-mark span { color: var(--red); }

.nav-links { display: flex; gap: 1.15rem; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }

.nav-links a {
  border: none;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
  padding: 2px 0;
  border-bottom: 2px solid transparent;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a.active { color: var(--ink); border-bottom-color: var(--red); }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  flex: none;
}
.theme-toggle:hover { color: var(--red); border-color: var(--red); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

/* ---------- header ---------- */

.masthead { padding: 4.5rem 0 2.5rem; border-bottom: 1px solid var(--line); }

.uva-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1.4rem;
}

.uva-brand img { height: 34px; width: auto; }

.uva-brand span {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink, inherit);
}

.venue {
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
  font-weight: 600;
  margin-bottom: 1.1rem;
}

.masthead h1 {
  font-size: clamp(2.1rem, 4.6vw, 3.35rem);
  margin: 0 0 0.35rem;
  max-width: 20ch;
}

.subtitle {
  font-family: var(--serif);
  font-size: clamp(1.05rem, 1.8vw, 1.32rem);
  color: var(--muted);
  margin: 0 0 2rem;
}

.authors { max-width: 62ch; margin-bottom: 0.5rem; font-size: 0.98rem; }
.authors span { white-space: nowrap; }
.authors a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
.authors a:hover { color: var(--red); border-bottom-color: var(--red); }
.authors sup { color: var(--red); font-size: 0.72em; }
.affil { color: var(--muted); font-size: 0.88rem; margin-bottom: 0.35rem; }
.contact { color: var(--faint); font-size: 0.82rem; font-family: var(--mono); word-break: break-word; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 2rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 0.55rem 1rem;
  font-size: 0.86rem;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--sans);
}
.btn:hover { border-color: var(--red); color: var(--red); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); border-color: var(--red-hover); color: #fff; }
.btn small { color: inherit; opacity: 0.7; font-family: var(--mono); font-size: 0.72rem; }

/* ---------- headline numbers ---------- */

.headline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}
.headline > div { padding: 2rem 1.6rem 2rem 0; }
.headline > div + div { padding-left: 1.6rem; border-left: 1px solid var(--line); }
.headline .k { font-family: var(--mono); font-size: clamp(1.6rem, 3vw, 2.15rem); letter-spacing: -0.02em; }
.headline .k.down { color: var(--red); }
.headline .k.up { color: var(--orange); }
.headline .l { color: var(--muted); font-size: 0.88rem; margin-top: 0.3rem; max-width: 32ch; }

/* ---------- sections ---------- */

section { padding: 4.2rem 0; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: none; }

.sec-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.6rem; }
.sec-num { font-family: var(--mono); font-size: 0.8rem; color: var(--red); padding-top: 0.35rem; }
.sec-head h2 { font-size: clamp(1.45rem, 2.6vw, 1.95rem); margin: 0; }
.sec-lede { font-family: var(--serif); font-size: 1.14rem; color: var(--muted); margin: -0.5rem 0 2rem; }

h3 { font-size: 1.12rem; margin: 2.4rem 0 0.7rem; }
h3:first-child { margin-top: 0; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 2.6rem; align-items: start; }
.cols-13 { display: grid; grid-template-columns: 1fr 1.55fr; gap: 2.6rem; align-items: start; }
.cols-31 { display: grid; grid-template-columns: 1.45fr 1fr; gap: 2.6rem; align-items: start; }

figure + .cols, figure + .cols-13, figure + .cols-31 { margin-top: 2.6rem; }

/* grid children must be allowed to shrink, otherwise wide tables and equations
   widen the whole page instead of scrolling inside their own container */
.cols > *, .cols-13 > *, .cols-31 > *, .docs > * { min-width: 0; }

/* ---------- figures ---------- */

figure { margin: 1.8rem 0 0; }

.fig-frame {
  background: var(--figure-bg);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.9rem;
}
.fig-frame img, .fig-frame svg { display: block; width: 100%; height: auto; }

.fig-frame.flush { background: none; border: none; padding: 0; cursor: default; }

figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.7rem;
  line-height: 1.55;
}
figcaption b { color: var(--ink); font-weight: 600; }

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; max-width: 100%; margin: 1.4rem 0 0; }

table { border-collapse: collapse; width: 100%; font-size: 0.85rem; min-width: 460px; }
caption { text-align: left; font-size: 0.85rem; color: var(--muted); padding-bottom: 0.7rem; }
.tcap { font-size: 0.85rem; color: var(--muted); margin: 1.4rem 0 0.2rem; }
.tcap + .table-scroll { margin-top: 0.5rem; }
th, td { padding: 0.5rem 0.85rem; text-align: right; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
thead th {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
tbody tr:hover { background: var(--panel); }
td.best { color: var(--red); font-weight: 600; }
td.mark { color: var(--ink); font-weight: 600; }
tr.row-group td { background: var(--panel); font-family: var(--sans); font-weight: 600; color: var(--muted); font-size: 0.78rem; }
.sd { color: var(--faint); }

/* ---------- callouts, math, notes ---------- */

.callout {
  border-left: 2px solid var(--red);
  background: var(--red-soft);
  padding: 1rem 1.2rem;
  margin: 1.8rem 0 0;
  font-size: 0.94rem;
  max-width: 72ch;
}
.callout b { font-family: var(--serif); }

.note {
  border-left: 2px solid var(--line-strong);
  padding: 0.75rem 1.1rem;
  margin: 1.6rem 0 0;
  font-size: 0.87rem;
  color: var(--muted);
  max-width: 72ch;
}

.eq {
  font-family: var(--mono);
  font-size: 0.92rem;
  background: none;
  border: none;
  padding: 0.85rem 1.1rem;
  margin: 1.3rem 0;
  overflow-x: auto;
  white-space: nowrap;
}
.eq .lbl { float: right; color: var(--faint); font-size: 0.8rem; white-space: normal; max-width: 60%; text-align: right; }
.eq-img { display: flex; flex-direction: column; align-items: center; gap: 1.4rem; padding: 1.6rem 1.1rem; }
.eq-img .lbl { float: none; align-self: stretch; max-width: 100%; text-align: center; }

@media (max-width: 640px) {
  .eq .lbl { float: none; display: block; max-width: 100%; text-align: left; margin-bottom: 0.5rem; }
}

/* Equation glyphs are inline SVG with fill: var(--ink), so they pick up the
   right ink color under every theme/browser natively (no filter or mask
   trick, which proved unreliable for externally-referenced SVGs). Each has
   a viewBox but no width/height attribute, so the browser derives the
   intrinsic aspect ratio and width:auto keeps it proportional. */
.eq-svg, .ieq {
  display: inline-block;
  overflow: visible;
}
.eq-svg {
  height: 2.6rem;
  width: auto;
  max-width: 100%;
}
.ieq {
  height: 1.3em;
  width: auto;
  vertical-align: -0.3em;
  margin: 0 0.05em;
}

dl.spec { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.4rem; margin: 1.4rem 0 0; font-size: 0.88rem; }
dl.spec dt { color: var(--muted); }
dl.spec dd { margin: 0; font-family: var(--mono); }

ul.tight { margin: 0.8rem 0 0; padding-left: 1.1rem; }
ul.tight li { margin-bottom: 0.45rem; }
ul.tight li::marker { color: var(--red); }

/* ---------- chart ---------- */

.chart-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

.toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 2px; overflow: hidden; }
.toggle button {
  border: 0;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.82rem;
  padding: 0.4rem 0.95rem;
  cursor: pointer;
}
.toggle button + button { border-left: 1px solid var(--line-strong); }
.toggle button[aria-pressed="true"] { background: var(--red); color: #fff; }

.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.82rem; color: var(--muted); margin-top: 0.9rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend i { width: 12px; height: 12px; display: inline-block; border-radius: 1px; }

.chart-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 2px; padding: 1.2rem 1rem 0.6rem; }
#chart { width: 100%; height: auto; display: block; }
#chart .bar { transition: opacity 0.12s ease; cursor: default; }
#chart .grid { stroke: var(--line); stroke-width: 1; }
#chart .axis { stroke: var(--line-strong); stroke-width: 1; }
#chart text { font-family: var(--sans); fill: var(--muted); font-size: 12px; }
#chart text.val { font-family: var(--mono); fill: var(--ink); font-size: 11.5px; }
#chart text.tick-x { fill: var(--ink); font-size: 12.5px; }
#chart .whisker { stroke: var(--ink); stroke-width: 1.3; opacity: 0.55; }
.chart-readout { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); min-height: 1.4em; margin-top: 0.4rem; }
.chart-readout b { color: var(--ink); }

/* ---------- video figures ---------- */

.video-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.9rem; }
.video-grid > * { min-width: 0; }
.video-grid video { display: block; width: 100%; height: auto; }

/* label gutter + red midline separating model (top) from expert (bottom) */
.video-split { display: grid; grid-template-columns: auto 1fr; gap: 0.7rem; align-items: stretch; }
.video-stage { position: relative; min-width: 0; }

.video-labels {
  display: grid;
  grid-template-rows: 1fr 1fr;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--red);
}
.video-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  place-self: center;
  white-space: nowrap;
}

/* one segment per frame, anchored to each video's own vertical centre, so the
   line stays exactly mid-clip whatever the grid wraps to */
.video-grid .fig-frame { position: relative; }
.video-grid .fig-frame::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 2px solid var(--red);
  transform: translateY(-1px);
  pointer-events: none;
}
.video-midline { display: none; }

@media (max-width: 720px) {
  .video-grid { grid-template-columns: repeat(2, 1fr); }
  /* two rows: a single left gutter would no longer line up, so label each clip */
  .video-labels { display: none; }
  .video-split { grid-template-columns: 1fr; gap: 0; }
  /* horizontal corner labels: the vertical gutter labels have no room here */
  .video-grid .fig-frame::before,
  .video-grid .fig-frame::after {
    font-family: var(--mono);
    font-size: 0.55rem;
    letter-spacing: 0.08em;
    color: var(--red);
    pointer-events: none;
  }
  .video-grid .fig-frame::before {
    content: "MODEL";
    position: absolute;
    left: 0.3rem;
    top: 0.2rem;
    z-index: 1;
  }
  /* ::after keeps the midline from the base rule and carries the lower label
     just beneath it */
  .video-grid .fig-frame::after {
    content: "EXPERT";
    padding: 0.2rem 0 0 0.3rem;
    line-height: 1;
  }
}

/* ---------- placeholders ---------- */

.placeholder {
  border: 1px dashed var(--line-strong);
  border-radius: 2px;
  padding: 1.6rem;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 9px,
    color-mix(in srgb, var(--line) 45%, transparent) 9px,
    color-mix(in srgb, var(--line) 45%, transparent) 10px
  );
}
.placeholder .tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 2px;
  padding: 0.1rem 0.4rem;
  margin-bottom: 0.7rem;
}
.placeholder p { margin: 0; font-size: 0.9rem; color: var(--muted); max-width: 66ch; }
.placeholder .slot {
  margin-top: 1rem;
  height: 130px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.78rem;
}

/* ---------- documents ---------- */

.docs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.6rem; }
.doc-card { display: flex; gap: 1.1rem; border: 1px solid var(--line); background: var(--surface); padding: 1rem; border-radius: 2px; }
.doc-card img { width: 96px; height: auto; border: 1px solid var(--line); background: #fff; }
.doc-card h4 { margin: 0 0 0.3rem; font-size: 1rem; }
.doc-card p { margin: 0 0 0.6rem; font-size: 0.84rem; color: var(--muted); }

/* ---------- bibtex ---------- */

.bibtex-wrap { position: relative; margin-top: 1.2rem; }
pre.bibtex {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
  margin: 0;
}
.copy-btn { position: absolute; top: 0.6rem; right: 0.6rem; }

/* ---------- references, footer ---------- */

ol.refs { font-size: 0.86rem; color: var(--muted); padding-left: 1.3rem; max-width: 78ch; }
ol.refs li { margin-bottom: 0.5rem; }
ol.refs li::marker { color: var(--red); }
ol.refs i { color: var(--ink); font-style: italic; }
ol.refs .ref-authors { color: var(--red); }
ol.refs a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--faint); }
ol.refs a:hover { color: var(--red); border-bottom-color: var(--red); }

footer { padding: 2.6rem 0 4rem; color: var(--faint); font-size: 0.82rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: center; justify-content: space-between; }
footer img { height: 34px; width: auto; opacity: 0.8; }

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(12, 12, 13, 0.9);
  display: none;
  place-items: center;
  padding: 2.5rem;
  cursor: zoom-out;
}
.lightbox.open { display: grid; }
.lightbox img, .lightbox svg { max-width: 100%; max-height: 88vh; background: #fff; padding: 1rem; }
.lightbox .hint { position: absolute; bottom: 1.2rem; left: 0; right: 0; text-align: center; color: #cfcfcf; font-size: 0.78rem; font-family: var(--mono); }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .cols, .cols-13, .cols-31, .docs { grid-template-columns: 1fr; gap: 2rem; }
  .headline { grid-template-columns: 1fr; }
  .headline > div { padding: 1.4rem 0; }
  .headline > div + div { padding-left: 0; border-left: none; border-top: 1px solid var(--line); }
  .nav-mark { display: none; }
  .nav-links { margin-left: 0; }
}

@media (max-width: 760px) {
  .chart-wrap { overflow-x: auto; }
  #chart { min-width: 660px; }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .wrap { width: min(100% - 2rem, var(--page)); }
  .masthead { padding-top: 3rem; }
  section { padding: 3rem 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
