/* Project pages, typeset like the CodeTriage paper companion: centered title block,
   serif reading column, numbered sections, captioned figures, hairline tables.
   Each page sets its own accent (--accent, --accent-ink, --accent-line, --accent-pale). */

:root {
  --paper: #fff;
  --ink: #222;
  --text: #333;
  --soft: #444;
  --muted: #62665f;
  --faint: #7a8073;
  --line: #e1e3dc;
  --rule: #cfd6c8;
  --surface: #fafbf8;
  --figure-bg: #fff;
  --accent: #76b900;
  --accent-ink: #477300;
  --accent-line: #c9d7b6;
  --accent-pale: #f5faec;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Helvetica Neue', Arial, sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #131512;
  --ink: #ecede8;
  --text: #d3d6ce;
  --soft: #c0c4ba;
  --muted: #9ba193;
  --faint: #868c7f;
  --line: #2a2e27;
  --rule: #3d4438;
  --surface: #1a1d18;
  --figure-bg: #fff;
  color-scheme: dark;
}

/* Base */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 32px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure { margin: 0; }
a { color: inherit; text-decoration: none; }
img, video, svg { display: block; }
button, select { font: inherit; color: inherit; }
::selection { background: var(--accent-line); }

a:focus-visible,
button:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 16px;
  z-index: 10;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  pointer-events: none;
}

.skip-link:focus { opacity: 1; pointer-events: auto; }

.page-width {
  width: min(1040px, calc(100% - 96px));
  margin-inline: auto;
}

/* Header */
.site-header {
  width: min(1160px, calc(100% - 96px));
  height: 68px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.paper-home { font: 15px var(--serif); color: var(--soft); }

/* Header breadcrumb: the site monogram links home, then the paper's short title */
.site-crumbs { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.site-home { font: 600 20px var(--serif); letter-spacing: -0.5px; color: var(--ink); }
.crumb-sep { font: 15px var(--serif); color: var(--rule); }
.paper-home { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.site-header nav {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 11px;
  color: var(--muted);
}

.site-header nav a:hover { color: var(--ink); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: -6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover { color: var(--ink); }

.theme-toggle svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

:root[data-theme="dark"] .icon-moon,
:root:not([data-theme="dark"]) .icon-sun { display: none; }

/* Title block */
.paper-title {
  max-width: 960px;
  margin: 58px auto 43px;
  padding-inline: 28px;
  text-align: center;
}

.paper-title h1 {
  font: 400 47px/1.2 var(--serif);
  letter-spacing: -1.1px;
}

.paper-title h1 > span {
  display: block;
  margin-top: 13px;
  font: 400 31px/1.3 var(--serif);
  letter-spacing: -0.45px;
}

.paper-authors {
  margin-top: 24px;
  font: 18px/1.5 var(--serif);
  color: var(--ink);
}

.paper-authors sup,
.paper-affiliations sup {
  font-size: 60%;
  color: var(--faint);
  margin-left: 1px;
}

.paper-affiliations {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin-top: 8px;
  font: 14px var(--serif);
  color: var(--muted);
}

.paper-venue {
  margin-top: 10px;
  font: italic 15px var(--serif);
  color: var(--accent-ink);
}

.paper-buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.paper-buttons a,
.paper-buttons span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font: 12.5px var(--sans);
  color: var(--ink);
  transition: border-color 0.2s, color 0.2s;
}

.paper-buttons a:hover { border-color: var(--accent); color: var(--accent-ink); }
.paper-buttons svg { width: auto; height: 14px; }
.paper-buttons .icon-arxiv { height: 15px; }
.paper-buttons .icon-mark { fill: currentColor; }

.paper-buttons .icon-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.paper-buttons .pending { color: var(--faint); border-style: dashed; cursor: default; }
.paper-buttons .pending svg { opacity: 0.7; }
.paper-buttons .pending small { font-size: 10.5px; color: var(--faint); }

/* Reading text */
.paper-text {
  width: min(780px, 100%);
  margin-inline: auto;
  font: 16px/1.8 var(--serif);
  color: var(--text);
  text-align: justify;
  hyphens: auto;
}

.paper-text p + p,
.paper-text p + ul,
.paper-text ul + p { margin-top: 15px; }

.paper-text strong { font-weight: 600; color: var(--ink); }
.paper-text ul { margin: 12px 0 0; padding-left: 22px; }
.paper-text li + li { margin-top: 6px; }
.paper-text li::marker { color: var(--faint); }

.paper-text a,
.paper-caption a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
  text-underline-offset: 4px;
}

.paper-text a:hover,
.paper-caption a:hover { text-decoration-color: var(--accent); }

.method-name { color: var(--accent-ink); font-weight: 600; }

.abstract.paper-text { width: min(780px, calc(100% - 64px)); }

.abstract h2 {
  margin-bottom: 17px;
  text-align: center;
  font: 400 23px var(--serif);
  color: var(--ink);
}

/* Sections */
.section { padding-top: 51px; }

.section-heading {
  width: min(780px, 100%);
  margin: 0 auto 24px;
}

.section-heading h2 {
  margin-bottom: 18px;
  font: 400 29px/1.3 var(--serif);
  letter-spacing: -0.4px;
  color: var(--ink);
}

.section-number {
  padding-right: 11px;
  font-size: 23px;
  color: var(--faint);
}

.paper-text h3 {
  margin: 30px 0 12px;
  font: 400 21px/1.35 var(--serif);
  color: var(--ink);
}

.paper-text h4 {
  margin: 22px 0 8px;
  font: italic 400 17px/1.4 var(--serif);
  color: var(--ink);
}

/* A quiet aside: hairline in the accent, no fill */
.note {
  margin: 22px 0;
  padding: 2px 0 2px 18px;
  border-left: 2px solid var(--accent);
}

.note-label {
  display: block;
  margin-bottom: 4px;
  font: 11px var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

/* Display math */
.paper-equation {
  margin: 18px 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}

/* Figures */
.paper-figure { margin: 29px auto 0; }
.paper-figure img,
.paper-figure video { width: 100%; height: auto; margin-inline: auto; background: var(--figure-bg); }
.paper-figure.narrow { width: min(620px, 100%); }
.paper-figure.medium { width: min(780px, 100%); }
.paper-figure.compact { width: min(520px, 100%); }

.paper-caption {
  margin: 17px 0 0;
  font: 14px/1.65 var(--serif);
  color: var(--soft);
  text-align: left;
}

.paper-caption b { font-weight: 600; color: var(--ink); }

/* Side-by-side panels with (a), (b) subcaptions */
.figure-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: 28px;
  align-items: start;
}

.figure-row img,
.figure-row video { width: 100%; height: auto; background: var(--figure-bg); }

.subcaption {
  margin-top: 10px;
  font: 14px/1.55 var(--serif);
  color: var(--soft);
  text-align: center;
}

.subcaption b { font-weight: 600; color: var(--ink); }
.subcaption small { display: block; font: 12px/1.6 var(--sans); color: var(--muted); }

.video-dark { display: none !important; }
:root[data-theme="dark"] .video-light { display: none !important; }
:root[data-theme="dark"] .video-dark { display: block !important; }
.paper-figure .video-dark { background: transparent; }

/* Quiet figure controls, as in the paper figures */
.figure-tools {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding-top: 13px;
  margin-bottom: 14px;
  border-top: 1px solid var(--line);
  font: 12px var(--sans);
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 2px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.figure-tools select {
  padding: 3px 0;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  font: 12.5px var(--mono);
  color: var(--ink);
  cursor: pointer;
}

.figure-tools select:focus { outline: none; border-bottom-color: var(--ink); }

/* Tables: booktabs rules, no fills */
.table-wrap { width: min(780px, 100%); margin: 24px auto 0; overflow-x: auto; }

.paper-table {
  width: 100%;
  border-collapse: collapse;
  font: 14.5px/1.6 var(--serif);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* On narrow screens the table scrolls sideways; the caption stays put and wraps to the screen */
.paper-table caption {
  position: sticky;
  left: 0;
  max-width: calc(100vw - 40px);
  caption-side: top;
  padding-bottom: 12px;
  text-align: left;
  font-size: 14px;
  color: var(--soft);
}

.paper-table caption b { font-weight: 600; color: var(--ink); }

.paper-table th,
.paper-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  font-weight: 400;
  white-space: nowrap;
}

/* Row labels sit flush left; later header rows (under a rowspan) keep numeric alignment */
.paper-table thead tr:where(:first-child) th:where(:first-child),
.paper-table tbody td:where(:first-child) { text-align: left; padding-left: 0; }

.paper-table thead { border-top: 1px solid var(--soft); }
.paper-table thead tr:last-child th { border-bottom: 1px solid var(--faint); }
.paper-table thead th { font-size: 13.5px; font-weight: 500; color: var(--ink); vertical-align: bottom; }
.paper-table thead th[colspan] { text-align: center; }
.paper-table tbody tr:last-child td { border-bottom: 1px solid var(--soft); }
.paper-table tbody { transition: opacity 0.15s; }
.paper-table tbody tr { transition: opacity 0.15s; }
.paper-table tbody:hover tr:not(:hover) { opacity: 0.5; }
.paper-table .best { font-weight: 600; color: var(--accent-ink); }
.paper-table .second { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.paper-table .gain { color: var(--accent-ink); }
.paper-table .flat { color: var(--faint); }

/* References and citation */
.cite {
  margin-left: 2px;
  font-size: 78%;
  color: var(--accent-ink) !important;
  text-decoration: none !important;
  letter-spacing: 0.2px;
}

.cite:hover { color: var(--accent) !important; }

.reference-list {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  counter-reset: ref;
  font: 15px/1.65 var(--serif);
  color: var(--text);
  text-align: left;
}

.reference-list li {
  position: relative;
  padding-left: 38px;
  margin-bottom: 9px;
  counter-increment: ref;
}

.reference-list li::before {
  content: "[" counter(ref) "]";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.reference-list li:target { background: var(--accent-pale); outline: 6px solid var(--accent-pale); }
.reference-list li > a { font-size: 13px; white-space: nowrap; }

.citation-box {
  position: relative;
  width: min(780px, 100%);
  margin-inline: auto;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
}

/* Long BibTeX lines wrap in place; the copied text keeps the original line breaks */
.citation-box pre {
  margin: 0;
  padding-right: 56px;
  font: 12.5px/1.65 var(--mono);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.copy-button {
  position: absolute;
  top: 10px;
  right: 12px;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
}

.copy-button:hover { color: var(--accent-ink); border-color: var(--accent); }
.copy-button.copied { color: var(--accent-ink); border-color: var(--accent); }

/* Footer */
.paper-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 54px;
  padding: 22px 0 29px;
  border-top: 1px solid var(--line);
  font: 12px var(--serif);
  color: var(--faint);
}

.paper-footer div { display: flex; gap: 22px; }
.paper-footer a:hover { color: var(--ink); }

/* ---------- Native figures (projects/figures.js) ----------
   Plot type matches the CodeTriage page; controls stay quiet: text toggles
   underlined when active, hairline tooltips, no fills or shadows. */
:root { --plot: 'Times New Roman', Georgia, serif; }

.fig-plot { display: block; width: 100%; height: auto; overflow: visible; }
.fig-plot text { font-family: var(--plot); fill: var(--ink); font-variant-numeric: tabular-nums; }
.fig-grid { stroke: var(--line); stroke-width: 0.8; }
.fig-axis { fill: none; stroke: var(--soft); stroke-width: 1.1; }
.fig-tick { font-size: 15px; }
.fig-axis-label { font-size: 17px; }
.fig-plot.compact .fig-tick { font-size: 13px; }
.fig-plot.compact .fig-axis-label { font-size: 15px; }
.fig-curve { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.fig-band { fill-opacity: 0.12; stroke: none; }
.fig-end-label { font-size: 14px; }
.fig-point { cursor: crosshair; }
.fig-point:focus { outline: none; }
.fig-point:focus-visible circle, .fig-point:focus-visible rect, .fig-point:focus-visible path { stroke: var(--ink); stroke-width: 1.5; }
.fig-series { transition: opacity 0.15s; }
.fig-plot.focusing .fig-series:not(.hl) { opacity: 0.28; }

/* Legend: buttons toggle series */
.fig-legend { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 22px; margin-bottom: 12px; }
.fig-legend > button,
.fig-legend > span { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 2px 0; border: 0; background: none; font: 16px var(--plot); color: var(--soft); cursor: pointer; transition: opacity 0.15s; }
.fig-legend > span { cursor: default; }
.fig-legend > .lead { color: var(--series-color, var(--accent-ink)); font-weight: 600; }
.fig-legend > button:hover { opacity: 0.7; }
.fig-legend > button[aria-pressed="false"] { opacity: 0.3; text-decoration: line-through; }
.fig-swatch { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 12px; }
.fig-swatch::before { content: ""; position: absolute; inset: 5px 0 auto; border-top: 1.7px solid var(--series-color); }
.fig-swatch.dashed::before { border-top-style: dashed; }
.fig-swatch.band::before { inset: 1px 0; border: 0; background: var(--series-color); opacity: 0.18; }
.fig-swatch i { position: relative; width: 7px; height: 7px; background: var(--series-color); border: 1px solid var(--paper); border-radius: 50%; }
.fig-swatch.square i { border-radius: 0; }
.fig-swatch.diamond i { border-radius: 0; transform: rotate(45deg); }
.fig-swatch.triangle i { border: 0; border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.fig-swatch.down i { border: 0; border-radius: 0; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.fig-swatch.cross i { border: 0; border-radius: 0; clip-path: polygon(38% 0, 62% 0, 62% 38%, 100% 38%, 100% 62%, 62% 62%, 62% 100%, 38% 100%, 38% 62%, 0 62%, 0 38%, 38% 38%); }
.fig-swatch.hollow i { background: var(--paper); border: 1.5px solid var(--series-color); }

/* Tooltip: inspection only */
.fig-tooltip {
  position: fixed;
  z-index: 50;
  max-width: 300px;
  padding: 8px 11px 9px;
  background: var(--paper);
  border: 1px solid var(--faint);
  font: 12px/1.5 var(--sans);
  color: var(--text);
  pointer-events: none;
}
.fig-tooltip strong { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.fig-tooltip span { display: block; color: var(--muted); }
.fig-tooltip small { display: block; margin-top: 2px; font: 11px/1.45 var(--mono); color: var(--muted); }

/* Quiet controls */
.fig-choice { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 16px; }
.fig-field { display: block; width: 100%; margin-bottom: 1px; font: 10.5px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.fig-choice button {
  padding: 3px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  font: 12.5px var(--sans);
  color: var(--muted);
  cursor: pointer;
}
.fig-choice button:hover { color: var(--ink); }
.fig-choice button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.fig-tabs { display: flex; gap: 28px; overflow-x: auto; overflow-y: hidden; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.fig-tabs button {
  margin-bottom: -1px;
  padding: 12px 0 11px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  font: 12px var(--sans);
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}
.fig-tabs button:hover { color: var(--ink); }
.fig-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.figure-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 4px 0;
  border: 0;
  background: none;
  font: 11.5px var(--sans);
  color: var(--muted);
  cursor: pointer;
}
.figure-action:hover { color: var(--accent-ink); }
.figure-action svg { width: 12px; height: 12px; fill: currentColor; }
.figure-action[data-playing="true"] .play,
.figure-action:not([data-playing="true"]) .pause { display: none; }

/* Range inputs: hairline track filled to --range-fill, small square thumb */
.paper-figure input[type="range"] { appearance: none; -webkit-appearance: none; height: 24px; margin: 0; background: transparent; cursor: ew-resize; }
.paper-figure input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(to right, var(--accent) var(--range-fill, 100%), var(--rule) var(--range-fill, 100%)); }
.paper-figure input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 11px; margin-top: -4.5px; background: var(--paper); border: 1.5px solid var(--accent); }
.paper-figure input[type="range"]::-moz-range-track { height: 2px; background: var(--rule); }
.paper-figure input[type="range"]::-moz-range-progress { height: 2px; background: var(--accent); }
.paper-figure input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 0; background: var(--paper); border: 1.5px solid var(--accent); }

/* A figure built from several panels: tools row, plots, caption */
.fig-panels { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 28px; }
.fig-panel-title { margin: 0 0 6px; text-align: center; font: 17px var(--plot); color: var(--ink); }
.fig-panel-sub { margin-top: 6px; text-align: center; font: 16px var(--plot); color: var(--ink); }
.fig-readout { min-height: 22px; margin-top: 8px; font: 12.5px/1.6 var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
.fig-readout b { font-weight: 600; color: var(--ink); }
@media (max-width: 600px) {
  .fig-panels { grid-template-columns: 1fr; gap: 22px; }
  .fig-legend > button, .fig-legend > span { font-size: 14px; }
}

/* Responsive */
@media (max-width: 850px) {
  .page-width,
  .site-header { width: calc(100% - 64px); }

  .paper-home { font-size: 13px; }
  .site-header nav { gap: 17px; }
  .paper-title { margin-top: 44px; }
  .paper-title h1 { font-size: 41px; }
  .paper-title h1 > span { font-size: 27px; }
}

@media (max-width: 600px) {
  .page-width,
  .site-header { width: calc(100% - 40px); }

  .site-header { height: 57px; gap: 14px; }
  .site-header nav a { display: none; }
  .paper-home { font-size: 12px; }

  .paper-title { margin: 35px auto 31px; padding-inline: 21px; }
  .paper-title h1 { font-size: 33px; letter-spacing: -0.65px; }
  .paper-title h1 > span { font-size: 22px; line-height: 1.35; letter-spacing: 0; }
  .paper-authors { font-size: 15.5px; }
  .paper-affiliations { font-size: 12.5px; }
  .paper-buttons a, .paper-buttons span { padding: 6px 12px; font-size: 12px; }

  .abstract.paper-text { width: calc(100% - 48px); }
  .paper-text { font-size: 15px; text-align: left; }
  .abstract h2 { font-size: 21px; margin-bottom: 15px; }
  .section { padding-top: 40px; }
  .section-heading { margin-bottom: 21px; }
  .section-heading h2 { font-size: 26px; letter-spacing: 0; margin-bottom: 16px; }
  .section-number { font-size: 21px; padding-right: 8px; }
  .paper-caption { font-size: 13px; line-height: 1.7; }
  .figure-row { grid-template-columns: 1fr; gap: 20px; }
  .reference-list { font-size: 13.5px; }
  .reference-list li { padding-left: 32px; }
  .citation-box { padding: 14px 12px; }
  .citation-box pre { font-size: 11px; }
  .paper-footer { flex-direction: column; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
