/* DUEL project page — minimal, framework-free.
   Two semantic colours run through the page: --duel (exact, ours) and --elbo (bound, baseline). */

:root {
  --bg: #FAF8F4;
  --surface: #F2EEE6;
  --ink: #1E2125;
  --muted: #6B6F76;
  --rule: #E4DED3;
  --duel: #2F7A6E;
  --duel-tint: rgba(47, 122, 110, 0.11);
  --elbo: #BC6440;
  --elbo-tint: rgba(188, 100, 64, 0.12);

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --col: 800px;
  --wide: 1020px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--duel); text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { border-bottom-color: currentColor; }

strong { font-weight: 600; }

/* KaTeX defaults to 1.21em, too large beside the serif body. */
.katex { font-size: 1.07em; }
.katex-display > .katex { font-size: 1.12em; }
.algo .katex, .tbl .katex, figcaption .katex { font-size: 1em; }

.duel-c { color: var(--duel); }
.elbo-c { color: var(--elbo); }
.sc { font-variant: small-caps; letter-spacing: 0.03em; }

/* ---------- layout ---------- */

main { padding: 0 1.25rem 4rem; }

.col { max-width: var(--col); margin: 0 auto; }
.wide {
  /* break out of the reading column, centred on it */
  width: min(var(--wide), calc(100vw - 2.5rem));
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

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

.masthead {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 4.5rem 1.25rem 2rem;
  text-align: center;
}

.masthead .venue {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.1rem;
}

.masthead h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.9rem, 3.6vw, 2.7rem);
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 0 auto 1.4rem;
  max-width: none;
}
@media (max-width: 900px) { .masthead h1 { max-width: 22ch; } .br-wide { display: none; } }
.masthead h1 .name { color: var(--duel); font-variant: small-caps; letter-spacing: 0.02em; }

.authors {
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.8;
}
.authors a { color: var(--ink); }
.authors a:hover { color: var(--duel); border-bottom-color: transparent; }
.authors .author { white-space: nowrap; margin: 0 0.55rem; }
.authors sup { color: var(--muted); font-size: 0.7em; }

.affil {
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.6rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.45rem 1.05rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn svg { width: 1rem; height: 1rem; fill: currentColor; }

/* ---------- table of contents (wide screens only) ---------- */

.toc {
  display: none;
  position: fixed;
  top: 6rem;
  left: max(1.5rem, calc(50vw - var(--col) / 2 - 15rem));
  width: 11.5rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.5;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0.35rem 0; }
.toc a { color: var(--muted); border: none; display: flex; gap: 0.55rem; }
.toc a .n { font-variant-numeric: tabular-nums; opacity: 0.7; }
.toc a:hover, .toc a.active { color: var(--duel); }
.toc .toc-title {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.7rem;
  opacity: 0.8;
}
@media (min-width: 1270px) { .toc { display: block; } }

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

section { padding-top: 3.2rem; }

h2 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.55rem;
  letter-spacing: -0.012em;
  line-height: 1.3;
  margin: 0 0 1.1rem;
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
}
h2 .n {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--duel);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

h3 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1.4;
  margin: 2.6rem 0 0.8rem;
}
h3 .n { color: var(--duel); font-weight: 500; margin-right: 0.5rem; font-variant-numeric: tabular-nums; }
h3 .claim { font-weight: 400; color: var(--muted); }

p { margin: 0 0 1.05rem; }

.lead-label {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.4rem;
}

/* ---------- abstract ---------- */

.abstract {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: inset 3px 0 0 var(--duel);
  padding: 1.4rem 1.7rem 0.6rem;
}
.abstract-label {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--duel);
  margin-bottom: 0.6rem;
}
.abstract p { text-align: justify; hyphens: auto; font-size: 0.97em; }
@media (max-width: 640px) { .abstract { padding: 1.1rem 1.1rem 0.4rem; } }

/* ---------- equations ---------- */

.eq {
  background: var(--surface);
  border-radius: 12px;
  padding: 0.9rem 1.2rem;
  margin: 1.2rem 0 1.4rem;
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
}
.eq .katex-display { margin: 0.35rem 0; }
.eq .tag {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
}
.eq.key {
  background: var(--duel-tint);
  box-shadow: inset 3px 0 0 var(--duel);
}
.eq .eq-label {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--duel);
  margin-bottom: 0.2rem;
}

.callout {
  border-left: 3px solid var(--elbo);
  padding: 0.2rem 0 0.2rem 1.1rem;
  margin: 1.4rem 0;
}
.callout.good { border-left-color: var(--duel); }
.callout ol, .callout ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.callout li { margin: 0.2rem 0; }

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

figure { margin: 2rem auto; }
figure img { display: block; width: 100%; height: auto; border-radius: 6px; }
figure.hero { margin: 1.6rem 0 1.4rem; }
figure.hero img { background: #fff; padding: 0.8rem; border-radius: 12px; }
figcaption {
  font-family: var(--sans);
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 0.8rem;
  max-width: var(--col);
  margin-left: auto;
  margin-right: auto;
}
figcaption strong { color: var(--ink); font-weight: 600; }

/* ---------- tables (booktabs) ---------- */

.tables { display: grid; gap: 1.6rem 2.4rem; margin: 1.6rem 0 1.8rem; }
.tables.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.tbl { overflow-x: auto; }
.tbl.narrow { max-width: calc((var(--wide) - 2.4rem) / 2); margin-left: auto; margin-right: auto; }
.tbl .cap {
  font-family: var(--sans);
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.tbl .cap strong { color: var(--ink); }

table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
}
th, td { padding: 0.42rem 0.6rem; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-weight: 600; border-bottom: 1px solid var(--ink); vertical-align: bottom; }
thead tr.group th { border-bottom: none; padding-bottom: 0; }
thead tr.group th.span { text-align: center; }
thead tr.group th.span > span { display: block; border-bottom: 1px solid var(--rule); padding-bottom: 0.25rem; }
tbody tr + tr td { border-top: 1px solid var(--rule); }
tbody tr.sep td { border-top: 1px solid var(--ink); }
tbody tr.avg td { font-style: italic; }
th.duel, td.duel { color: var(--duel); }
th.elbo { color: var(--elbo); }
td.elbo { color: var(--muted); }
td.win { font-weight: 650; }
td.big { font-weight: 650; color: var(--duel); }
.d { font-size: 0.78em; color: var(--duel); margin-left: 0.2rem; opacity: 0.9; }
.le { color: var(--muted); font-size: 0.85em; margin-right: 0.08rem; }
.arrow { color: var(--muted); font-weight: 400; font-size: 0.85em; }

details.more { margin: 0.6rem 0 1.4rem; }
details.more summary {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--duel);
  list-style: none;
}
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+ "; }
details.more[open] summary::before { content: "− "; }
details.more > *:not(summary) { margin-top: 1rem; }

/* ---------- algorithms ---------- */

.algos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.2rem;
  margin: 1.6rem auto 0.4rem;
}
.algo {
  background: var(--surface);
  border-radius: 12px;
  padding: 1rem 1.1rem 0.9rem;
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.55;
}
.algo .algo-title {
  font-weight: 600;
  padding-bottom: 0.45rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}
.algo .algo-title .n { color: var(--muted); font-weight: 500; margin-right: 0.35rem; }
.algo ol { list-style: none; margin: 0; padding: 0; counter-reset: line; }
.algo li {
  counter-increment: line;
  display: grid;
  grid-template-columns: 1.4rem 1fr auto;
  align-items: baseline;
  column-gap: 0.4rem;
  padding: 0.08rem 0.4rem;
  border-radius: 6px;
}
.algo li::before {
  content: counter(line);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.7;
}
.algo li.req { counter-increment: none; }
.algo li.req::before { content: ""; }
.algo li .c { color: var(--muted); font-style: italic; font-size: 0.82rem; text-align: right; padding-left: 0.6rem; }
.algo .kw { font-weight: 600; }
.algo .i1 { padding-left: 1.1rem; }
.algo .i2 { padding-left: 2.2rem; }
.algo li.hl-sample { background: var(--elbo-tint); }
.algo li.hl-sample .c { color: var(--elbo); }
.algo li.hl-score { background: var(--duel-tint); }
.algo li.hl-score .c { color: var(--duel); }

/* ---------- rule table ---------- */
table.rules td { white-space: normal; }
table.rules td:nth-child(2) { text-align: left; }
table.rules td:last-child { text-align: left; color: var(--muted); }

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

.bib {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}
.copy {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  cursor: pointer;
}
.copy:hover { color: var(--ink); border-color: var(--ink); }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--rule);
  margin-top: 4rem;
  padding: 1.6rem 1.25rem 2.4rem;
  text-align: center;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
}
footer a { color: var(--muted); }

@media (max-width: 640px) {
  body { font-size: 17px; }
  .masthead { padding-top: 2.8rem; }
  .eq { padding: 0.7rem 0.8rem; }
  .eq .katex-display > .katex { font-size: 0.86em; }
  .eq .tag { position: static; transform: none; display: block; text-align: right; }
  .abstract p { text-align: left; }
}

h2 + h3 { margin-top: 0.3rem; }

.callout ol.problems { padding-left: 1.3rem; margin: 0; }
.callout ol.problems li { margin: 0.25rem 0 0.6rem; padding-left: 0.2rem; }
.callout ol.problems li::marker { font-family: var(--sans); font-weight: 600; color: var(--elbo); }

/* ---------- inline citations ---------- */

a.cite { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
a.cite:hover { color: var(--duel); border-bottom-color: var(--duel); }
table.rules { font-size: 0.85rem; }
table.rules td:first-child, table.rules td:last-child, table.rules td:nth-child(2) { white-space: nowrap; }
