/* FUMA project page. Layout, type and tokens follow the DAVIAN Robotics project pages (e.g. DiscoDemo). */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #1f2937;
  --muted: #5b6472;
  --rule: #dadde3;
  --accent: #e67e22;
  --accent-ink: #b35a0e;
  --accent-wash: #fdf1e4;
  --surface: #ffffff;
  --shadow: rgba(31, 41, 55, 0.12);
  --soft: #f3f4f6;
  --ph-ink: #8a93a0;
  --btn-bg: #1f2937;
  --btn-ink: #ffffff;
  --btn-hover: #e67e22;
  --ours: #e67e22;
  --other: #b9bec7;
  --other-2: #9aa1ac;
  --best-bg: #fdefdf;
  --paper: #ffffff;

  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;

  --col: 840px;
  --gutter: clamp(16px, 4vw, 40px);
  --wrap: calc(var(--col) + 2 * var(--gutter));
}

/* Dark theme: follows the system unless the reader picks one with the header toggle (data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14161b;
    --ink: #e4e6ea;
    --muted: #9aa2ae;
    --rule: #2e323a;
    --accent: #f0a04b;
    --accent-ink: #f5b874;
    --accent-wash: #2b2117;
    --surface: #1d2027;
    --shadow: rgba(0, 0, 0, 0.5);
    --soft: #1d2027;
    --ph-ink: #6b7380;
    --btn-bg: #e4e6ea;
    --btn-ink: #14161b;
    --btn-hover: #f0a04b;
    --ours: #f0a04b;
    --other: #4a505b;
    --other-2: #626976;
    --best-bg: #33261a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161b;
  --ink: #e4e6ea;
  --muted: #9aa2ae;
  --rule: #2e323a;
  --accent: #f0a04b;
  --accent-ink: #f5b874;
  --accent-wash: #2b2117;
  --surface: #1d2027;
  --shadow: rgba(0, 0, 0, 0.5);
  --soft: #1d2027;
  --ph-ink: #6b7380;
  --btn-bg: #e4e6ea;
  --btn-ink: #14161b;
  --btn-hover: #f0a04b;
  --ours: #f0a04b;
  --other: #4a505b;
  --other-2: #626976;
  --best-bg: #33261a;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.125rem/1.65 var(--serif);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent-ink); text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
sub, sup { line-height: 0; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
}
.head-row { display: flex; align-items: center; gap: 24px; height: 52px; }
.wordmark-sm { font-size: 1.5rem; font-weight: 700; color: var(--accent); text-decoration: none; letter-spacing: -0.01em; }
.wordmark-sm:hover { color: var(--accent); }
.site-head nav { display: flex; gap: 20px; overflow-x: auto; scrollbar-width: none; }
.site-head nav a { color: var(--muted); text-decoration: none; font-size: 0.9rem; white-space: nowrap; }
.site-head nav a:hover { color: var(--ink); }
.lab-nav { margin-left: auto; display: flex; align-items: center; gap: 14px; flex: none; }
.home-link { display: inline-flex; }
.home-link img { height: 22px; width: auto; display: block; }
.home-link .on-dark { display: none; }
:root[data-theme="dark"] .home-link .on-light { display: none; }
:root[data-theme="dark"] .home-link .on-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .home-link .on-light { display: none; }
  :root:not([data-theme="light"]) .home-link .on-dark { display: block; }
}
.theme-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); cursor: pointer; }
.theme-btn:hover { color: var(--ink); background: var(--soft); }
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: none; }
}
.more { position: relative; }
.more summary { list-style: none; cursor: pointer; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: ""; display: inline-block; margin-left: 6px; border: 4px solid transparent; border-top-color: currentColor; transform: translateY(2px); }
.more[open] summary, .more summary:hover { color: var(--ink); }
.more-menu {
  position: absolute; right: 0; top: calc(100% + 12px); width: min(380px, 86vw); max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 6px;
  box-shadow: 0 8px 24px var(--shadow); z-index: 20;
}
.more-menu a { display: grid; grid-template-columns: 1fr auto; column-gap: 10px; padding: 8px 10px; border-radius: 7px; text-decoration: none; color: var(--ink); }
.more-menu a:hover { background: var(--soft); }
.more-head { margin: 8px 10px 4px; font: 600 0.72rem/1 var(--sans); color: var(--accent-ink); }
.more-menu b { font-weight: 600; font-size: 0.9rem; }
.more-menu span { grid-column: 1; font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
.more-menu small { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
/* Narrow screens: two header rows --- name and lab links on top, section links below (scrolls sideways). */
@media (max-width: 1239px) {
  html { scroll-padding-top: 96px; }
  .head-row { flex-wrap: wrap; height: auto; padding-top: 8px; row-gap: 2px; }
  .site-head nav { order: 3; width: 100%; padding: 4px 0 10px; }
}
@media (max-width: 420px) {
  .head-row { column-gap: 10px; }
  .wordmark-sm { font-size: 1.25rem; }
  .lab-nav { gap: 4px; }
  .theme-btn { width: 28px; height: 28px; }
  .home-link img { height: 18px; }
  .more summary { font-size: 0.82rem; }
}

/* Left-hand contents on wide screens (built by main.js from the header links); the current section is marked. */
.toc { display: none; }
@media (min-width: 1240px) {
  .site-head nav { display: none; }
  .toc {
    display: flex; flex-direction: column; gap: 2px;
    position: fixed; top: 50%; transform: translateY(-50%); z-index: 5;
    left: max(20px, calc((100vw - var(--col)) / 2 - 210px)); width: 170px;
    font-family: var(--sans);
  }
  .toc a {
    color: var(--muted); text-decoration: none; font-size: 0.9rem; line-height: 1.2;
    padding: 6px 0 6px 12px; border-left: 2px solid var(--rule);
    transition: color 0.2s ease, border-color 0.2s ease;
  }
  .toc a:hover { color: var(--ink); }
  .toc a.on { color: var(--accent-ink); border-left-color: var(--accent); font-weight: 600; }
}

/* ---------- hero ---------- */
.hero { padding-top: clamp(40px, 8vw, 88px); padding-bottom: 32px; }
.wordmark {
  font: 700 clamp(3rem, 9vw, 6.5rem)/0.95 var(--sans);
  color: var(--accent);
  letter-spacing: -0.035em;
  margin: 0;
}
.subtitle {
  font: 500 clamp(1.2rem, 2.4vw, 1.6rem)/1.3 var(--sans);
  letter-spacing: -0.01em;
  margin: 18px 0 0;
}
@media (min-width: 761px) { .subtitle { font-size: min(1.36rem, 2.3vw); white-space: nowrap; } }
/* The name is built from these letters; the underline shows where it comes from. */
.acro { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: 0.16em; }
.authors { font: 500 1rem/1.5 var(--sans); margin: 28px 0 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.authors .line-break { flex-basis: 100%; height: 0; }
.authors a { color: inherit; text-decoration: none; }
.authors a:hover { color: var(--accent-ink); text-decoration: underline; }
.affil { font: 400 0.9rem/1.4 var(--sans); color: var(--muted); margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.affil-note { margin-top: 2px; }

.links { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 0; }
.btn {
  display: inline-flex; align-items: center;
  font: 600 0.95rem/1 var(--sans);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-ink); text-decoration: none;
}
a.btn:hover { background: var(--btn-hover); color: var(--btn-ink); }
.btn .ico { width: 0.95em; height: 0.95em; vertical-align: -0.13em; margin-right: 0.4em; flex: none; }
.btn-off { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--rule); cursor: default; }
.btn-off::after { content: "soon"; font-weight: 500; font-size: 0.75rem; margin-left: 6px; }

/* ---------- sections ---------- */
/* Sections are separated by a hairline above their heading; nothing else is boxed. */
.prose-block { padding-top: 64px; margin-top: 56px; border-top: 1px solid var(--rule); }
.prose-block h2 {
  font: 700 clamp(1.5rem, 3vw, 2rem)/1.15 var(--sans);
  letter-spacing: -0.02em;
  margin: 0 0 16px;
}
@media (max-width: 760px) { .prose-block { padding-top: 40px; margin-top: 40px; } }

.tba { font: 500 1rem var(--sans); color: var(--muted); margin: 0; }

.site-foot { padding-top: 64px; padding-bottom: 48px; font: 400 0.85rem/1.5 var(--sans); color: var(--muted); }

/* ---------- TL;DR block under the title ---------- */
.tldr-block { margin: 28px 0 0; padding: 18px 22px; border-left: 4px solid var(--accent); background: var(--accent-wash);
              border-radius: 0 10px 10px 0; }
.tldr-block .lede { margin: 0 0 12px; font: 400 1.08rem/1.6 var(--serif); }
.tldr-block .lede b { font-family: var(--sans); color: var(--accent-ink); margin-right: 6px; }
.tldr-block .fig { margin: 16px 0 4px; }
.fig { margin: 24px 0 0; }
.fig figcaption { font: 400 0.92rem/1.5 var(--sans); color: var(--muted); margin-top: 10px; }
/* Paper figures are drawn for white paper: on the dark page they sit on a white sheet. */
.paper { background: var(--paper); border-radius: 8px; padding: 6px; }
.paper img, .traj img { display: block; width: 100%; height: auto; }
.fig-legend { display: flex; flex-wrap: wrap; gap: 6px 22px; font: 0.82rem var(--sans); color: var(--muted); margin-bottom: 8px; }
.fig-legend span { display: inline-flex; align-items: center; gap: 6px; }
.fig-legend img { background: #fff; border-radius: 3px; }
.fig-cols { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; font: 0.88rem var(--sans); margin-top: 6px; }

/* Prose */
.prose p { margin: 0 0 1em; }
.sub { font: 600 1.2rem/1.3 var(--sans); margin: 48px 0 8px; }
.m .katex { font-size: 1.02em; }
.eq { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* Method diagram */
.diagram svg { width: 100%; height: auto; display: block; }
.dg-lbl { font: 600 14px var(--sans); fill: var(--ink); }
.dg-sub { font: 12.5px var(--sans); fill: var(--muted); }
.dg-q { font: 600 13px var(--sans); fill: var(--ours); }
.dg-anchor { fill: var(--ink); }
.dg-end { fill: var(--ours); }
.dg-path { fill: none; stroke: var(--other-2); stroke-width: 1.6; stroke-dasharray: 4 3; }
.dg-link { stroke: var(--muted); stroke-width: 1.6; }
.dg-arrowhead { fill: var(--muted); }
.dg-box { fill: var(--bg); stroke: var(--rule); stroke-width: 1.5; }
.dg-ours { stroke: var(--ours); }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 32px 0 0; display: grid; gap: 28px; }
.steps li { counter-increment: step; border-top: 2px solid var(--ink); padding-top: 14px; min-width: 0; }
.steps li::before { content: counter(step); font: 700 0.95rem/1 var(--sans); color: var(--accent-ink); }
.steps h3 { font: 600 1.1rem/1.3 var(--sans); margin: 8px 0 8px; }
.steps p { margin: 0 0 8px; font-size: 1rem; }
.callout { border-left: 4px solid var(--accent); background: var(--accent-wash); padding: 14px 18px; border-radius: 0 10px 10px 0; font-size: 1rem; margin-top: 28px; }

/* Bar charts */
.chart { margin: 16px 0 8px; }
.chart-title { font: 600 14px var(--sans); margin: 0 0 8px; }
.chart-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.bars { display: grid; gap: 5px; font: 13px var(--sans); }
.bar-row { display: grid; grid-template-columns: 9.5em 1fr 3em; align-items: center; gap: 8px; }
.bar-label { color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 14px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--other); border-radius: 3px; }
.bar-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.is-ours .bar-label, .is-ours .bar-val { color: var(--ink); font-weight: 700; }
.is-ours .bar-fill { background: var(--ours); }
[data-chart="temp"] .bar-row { grid-template-columns: 13em 1fr 3em; }

/* Grouped chart (real robot) */
.g-legend { margin-bottom: 26px !important; display: flex; flex-wrap: wrap; gap: 4px 16px; font: 13px var(--sans); color: var(--muted); margin-bottom: 10px; }
.g-legend span { display: inline-flex; align-items: center; gap: 6px; }
.g-sw { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.g-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.g-group { display: flex; flex-direction: column; }
.g-avg { border-left: 1px solid var(--rule); padding-left: 14px; }
.g-bars { height: 170px; display: flex; align-items: flex-end; gap: 4px; border-bottom: 1px solid var(--rule); }
.g-bar { flex: 1; position: relative; min-height: 1px; border-radius: 2px 2px 0 0; }
.g-val { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font: 11px var(--sans); color: var(--muted); padding-bottom: 2px; }
.g-c3 .g-val { color: var(--ink); font-weight: 700; }
.g-name { font: 13px/1.3 var(--sans); text-align: center; margin-top: 6px; }
.g-c0 { background: #e2e4e8; } .g-c1 { background: #c6cad1; } .g-c2 { background: #9aa1ac; } .g-c3 { background: var(--ours); }
:root[data-theme="dark"] .g-c0 { background: #3a3f48; } :root[data-theme="dark"] .g-c1 { background: #4f5562; } :root[data-theme="dark"] .g-c2 { background: #6b7280; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .g-c0 { background: #3a3f48; }
  :root:not([data-theme="light"]) .g-c1 { background: #4f5562; }
  :root:not([data-theme="light"]) .g-c2 { background: #6b7280; }
}

/* Tables */
.table-details { margin: 10px 0; font-family: var(--sans); }
.table-details summary { cursor: pointer; font-size: 0.9rem; font-weight: 600; color: var(--accent-ink); padding: 4px 0; }
.table-wrap { overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; width: 100%; font: 13px/1.3 var(--sans); font-variant-numeric: tabular-nums; }
th, td { padding: 6px 7px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--rule); }
tbody th, tfoot th, tr.sec th { text-align: left; font-weight: 500; }
thead th { font-weight: 600; }
th.grp { color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--rule); }
th.ours { color: var(--ours); }
td small { color: var(--muted); font-size: 10px; margin-left: 1px; }
td.best { font-weight: 700; background: var(--best-bg); }
tfoot th, tfoot td, tr.avg th, tr.avg td { border-top: 1.5px solid var(--ink); }
tr.sec th { font-style: italic; color: var(--muted); padding-top: 12px; }
.table-note { font: 13px var(--sans); color: var(--muted); margin: 6px 0 0; }

/* Trajectories */
.traj-legend { display: flex; align-items: center; gap: 8px; font: 13px var(--sans); color: var(--muted); margin-bottom: 8px; }
.sw { width: 18px; height: 3px; display: inline-block; border-radius: 2px; }
.sw-bc { background: #9a9a9a; } .sw-ours { background: #6fbef7; margin-left: 10px; }
.traj-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.traj-task h4 { font: 600 14px var(--sans); margin: 0 0 6px; }
.traj-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.traj-pair figure { margin: 0; }
.traj-pair img { border-radius: 6px; }
.traj-pair figcaption { margin-top: 3px !important; text-align: center; font-size: 12px !important; }

.tbtn { font: 500 0.88rem/1 var(--sans); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.tbtn:hover { border-color: var(--ink); }

@media (max-width: 720px) {
  .chart-pair, .traj-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 7.5em 1fr 2.6em; }
  [data-chart="temp"] .bar-row { grid-template-columns: 10em 1fr 2.6em; }
  .g-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .g-avg { padding-left: 6px; }
  .g-name { font-size: 11px; }
  .g-val { font-size: 9px; }
  .fig-cols { font-size: 12px; }
  .lede { font-size: 17px; }
}

/* ---------- FUMA additions ---------- */
/* Two-line title: the break is kept on wide screens only. */
@media (min-width: 761px) { .subtitle-2 { white-space: normal; font-size: min(1.36rem, 2.3vw); } }
@media (max-width: 760px) { .br-wide { display: none; } }
/* Change relative to Vanilla, coloured as in the paper (gain red, drop blue). */
td i { font-style: normal; font-size: 10.5px; margin-left: 4px; }
td i.up { color: #c81e1e; } td i.dn { color: #1e5ac8; } td i.zr { color: var(--muted); }
:root[data-theme="dark"] td i.up { color: #f07a7a; } :root[data-theme="dark"] td i.dn { color: #7aa6f0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) td i.up { color: #f07a7a; }
  :root:not([data-theme="light"]) td i.dn { color: #7aa6f0; }
}
tr.ours-row th { color: var(--accent-ink); font-weight: 700; }
td.fixed { color: var(--muted); }
tbody th[rowspan] { vertical-align: middle; }
.steps .eq { margin: 4px 0 8px; }
.callout .eq { margin: 6px 0; }
.split { display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; align-items: start; }
.split .fig { margin-top: 4px; }
@media (max-width: 720px) { .split { grid-template-columns: 1fr; } }
.fig + .prose { margin-top: 24px; }
