/* CoEnv project page. Type and colour follow faceong.github.io. */

:root {
  --bg: #ffffff;
  --ink: #1c1b19;
  --ink-2: #45433f;
  --ink-3: #6f6c66;
  --rule: #e7e4df;
  --rule-strong: #d3cfc8;
  --accent-ink: #c2410c;
  --accent-rgb: 194, 65, 12;
  --code-bg: #f6f4f0;
  --ours-bg: #fbf6f0;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Figtree", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --w-text: 680px;
  --w-head: 780px;
  --w-table: 900px;
  --w-wide: 1060px;
  --w-hero: 1160px;
  --gutter: 20px;

  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

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

img, video { display: block; max-width: 100%; }

a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(var(--accent-rgb), 0.35);
}
a:hover { text-decoration-color: var(--accent-ink); }

sup, sub { font-size: 0.7em; line-height: 0; position: relative; vertical-align: baseline; }
sup { top: -0.5em; }
sub { bottom: -0.25em; }
.nw { white-space: nowrap; }

/* ---------- site header / footer ---------- */

.site { border-bottom: 1px solid var(--rule); }

.site-inner {
  max-width: var(--w-hero);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-name {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}

.site-links { display: flex; gap: 22px; font-size: 0.95rem; }
.site-links a { color: var(--ink-2); text-decoration: none; }
.site-links a:hover { color: var(--accent-ink); }

.site-foot {
  margin-top: 104px;
  border-top: 1px solid var(--rule);
  font-size: 0.88rem;
  color: var(--ink-3);
}
.site-foot .site-inner { height: auto; padding-top: 28px; padding-bottom: 44px; }
.site-foot a { color: var(--ink-3); }

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

.head {
  max-width: var(--w-head);
  margin: 76px auto 44px;
  padding: 0 var(--gutter);
}

.kicker {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
  color: var(--ink-3);
}
.kicker-cat { color: var(--ink); font-weight: 600; }
.kicker-cat::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 12px;
  border-radius: 50%;
  background: var(--rule-strong);
  vertical-align: middle;
}

h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.1rem, 1.25rem + 3.4vw, 3.45rem);
  line-height: 1.08;
  letter-spacing: -0.012em;
  margin: 0.38em 0 0.62em;
  text-wrap: balance;
}

.authors { margin: 0 0 10px; font-size: 1.02rem; line-height: 1.7; }
.authors a { color: var(--ink); text-decoration-color: var(--rule-strong); }
.authors sup { color: var(--ink-3); margin-left: 1px; }

.affils {
  margin: 0 0 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 18px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-3);
}
.notes { margin: 0; font-size: 0.86rem; color: var(--ink-3); }

.actions { margin: 30px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px 8px 13px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.btn:hover { border-color: var(--ink-2); background: #faf9f7; }
.btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

figure { margin: 0; }

figcaption {
  max-width: calc(var(--w-text) - 2 * var(--gutter));
  margin: 14px auto 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-3);
}
.fig-no { color: var(--ink); font-weight: 600; margin-right: 4px; }

.hero {
  max-width: var(--w-wide);
  margin: 0 auto 60px;
  padding: 0 var(--gutter);
}
.hero video {
  width: 100%;
  aspect-ratio: 854 / 480;
  object-fit: cover;
  border-radius: 10px;
  background: #e9e7e3;
  cursor: pointer;
}

.wide {
  max-width: var(--w-wide);
  margin: 48px auto 52px;
  padding: 0 var(--gutter);
}
.wide img { width: 100%; height: auto; cursor: zoom-in; }

/* ---------- body text ---------- */

.prose {
  max-width: var(--w-text);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.prose p { margin: 0 0 1.15em; }
.prose strong { font-weight: 600; }

.lead {
  font-family: var(--serif);
  font-size: 1.42rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 1.3em !important;
}

h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.85rem;
  line-height: 1.2;
  letter-spacing: -0.005em;
  margin: 2.3em 0 0.65em;
  scroll-margin-top: 24px;
}
.prose > h2:first-child { margin-top: 0.4em; }

.prose ul { margin: 0 0 1.2em; padding-left: 1.2em; }
.prose li { margin: 0.45em 0; padding-left: 0.2em; }
.prose li::marker { color: var(--accent-ink); }

/* code listing: a little wider than the text column on desktop */
.code {
  width: min(820px, calc(100vw - 2 * var(--gutter)));
  margin: 30px 0 32px 50%;
  transform: translateX(-50%);
}
.code figcaption { max-width: none; margin: 0 0 8px; }

pre {
  margin: 0;
  padding: 18px 20px;
  background: var(--code-bg);
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: #2b2a27;
  tab-size: 4;
}
pre .c { color: #8a867e; }
pre .s { color: #9a3412; }

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

.table {
  max-width: var(--w-table);
  margin: 44px auto 48px;
  padding: 0 var(--gutter);
}
.table figcaption { margin: 0 0 12px; max-width: none; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
th, td { padding: 9px 10px; text-align: center; }
th { font-size: 0.84rem; font-weight: 600; color: var(--ink-2); }
th.task, td.task { text-align: left; padding-left: 4px; }
td { color: var(--ink-2); border-bottom: 1px solid #efede9; }
td.ours { background: var(--ours-bg); color: var(--ink); }
td.best, tr.avg td.best { font-weight: 600; color: var(--ink); }

thead tr:last-child th { border-bottom: 1px solid var(--ink-2); }
tr.group th { padding-bottom: 4px; font-size: 0.86rem; }
tr.group th[colspan] { border-bottom: 1px solid var(--rule-strong); }
tr.group th.ours { color: var(--accent-ink); }

tr.section td {
  text-align: left;
  padding: 16px 4px 6px;
  font-size: 0.8rem;
  color: var(--ink-3);
  background: none;
  border-bottom: none;
}
tr.avg td { border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--ink-2); font-weight: 500; }

/* ---------- task explorer (Figure 3) ---------- */

.explorer {
  max-width: var(--w-wide);
  margin: 48px auto 52px;
  padding: 0 var(--gutter);
  --c-ours: #d9622b;
  --c-base: #b8b2a8;
}

.ex-tabs {
  display: flex;
  align-items: baseline;
  gap: 0 22px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.ex-tabs::-webkit-scrollbar { display: none; }
.ex-group { font-size: 0.78rem; color: var(--ink-3); margin-right: -10px; }
.ex-group + button { margin-left: 0; }
.ex-break { display: none; }
.ex-break + .ex-group { margin-left: 18px; padding-left: 22px; border-left: 1px solid var(--rule); }
.ex-tabs button {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 0 11px;
  font: 500 0.97rem/1.2 var(--sans);
  color: var(--ink-3);
  cursor: pointer;
}
.ex-tabs button:hover { color: var(--ink); }
.ex-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent-ink); }

.ex-body {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

.ex-views {
  display: inline-flex;
  margin-bottom: 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  overflow: hidden;
}
.ex-views button {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--rule-strong);
  background: #fff;
  padding: 6px 12px;
  font: 500 0.84rem/1.2 var(--sans);
  color: var(--ink-2);
  cursor: pointer;
}
.ex-views button:last-child { border-right: 0; }
.ex-views button:hover:not(:disabled) { background: #f7f6f3; }
.ex-views button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.ex-views button:disabled { color: #bdb8b0; cursor: not-allowed; }

.ex-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #ecebe7;
  border-radius: 6px;
  overflow: hidden;
}
.ex-frame img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.ex-tag {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  font: 500 0.75rem/1.2 var(--sans);
  color: var(--ink);
}

.ex-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.ex-strip button {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 4px;
  overflow: hidden;
  background: #ecebe7;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.ex-strip button:hover { opacity: 0.85; }
.ex-strip button[aria-current="true"] { opacity: 1; box-shadow: 0 0 0 2px var(--accent-ink); }
.ex-strip img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.ex-strip .n {
  position: absolute;
  left: 6px;
  bottom: 4px;
  font: 500 0.7rem/1 var(--mono);
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.ex-note { margin: 10px 0 0; min-height: 2.9em; font-size: 0.86rem; line-height: 1.5; color: var(--ink-3); }

.ex-info { padding-top: 2px; }
.ex-name { margin: 0 0 4px; font-family: var(--serif); font-weight: 500; font-size: 1.6rem; line-height: 1.2; }
.ex-setup { margin: 0 0 12px; font-size: 0.86rem; color: var(--ink-3); }
.ex-desc { margin: 0 0 22px; font-size: 1rem; line-height: 1.55; }

.ex-legend { display: flex; gap: 18px; margin-bottom: 10px; font-size: 0.8rem; color: var(--ink-2); }
.ex-legend .k::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: -1px;
}
.ex-legend .ours::before { background: var(--c-ours); }
.ex-legend .base::before { background: var(--c-base); }

.ex-row { padding: 12px 0 13px; border-top: 1px solid var(--rule); }
.ex-ms { margin-bottom: 8px; font-size: 0.87rem; line-height: 1.45; color: var(--ink-2); }
.ex-ms b { margin-right: 6px; font: 500 0.78rem var(--mono); color: var(--ink); }
.ex-ms em { font-style: normal; color: var(--ink-3); }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) 42px; align-items: center; gap: 10px; }
.bar + .bar { margin-top: 5px; }
.track { height: 8px; border-radius: 4px; background: #efece7; overflow: hidden; }
.track i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width 0.45s cubic-bezier(0.2, 0.7, 0.2, 1); }
.bar.ours i { background: var(--c-ours); }
.bar.base i { background: var(--c-base); }
.bar span { text-align: right; font: 500 0.8rem var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.bar.base span { color: var(--ink-3); }

.ex-chart-note { margin: 2px 0 0; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 0.84rem; line-height: 1.5; color: var(--ink-3); }
.explorer > figcaption { margin-top: 22px; }

/* ---------- citation ---------- */

.bib { position: relative; }
.bib pre { padding-right: 76px; }
.copy {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  font: 500 0.78rem/1.3 var(--sans);
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  cursor: pointer;
}
.copy:hover { border-color: var(--ink-2); color: var(--ink); }

/* ---------- zoomed figure ---------- */

dialog#zoom {
  padding: 0;
  border: 0;
  max-width: 96vw;
  max-height: 94vh;
  background: transparent;
  cursor: zoom-out;
}
dialog#zoom img { max-width: 96vw; max-height: 92vh; width: auto; height: auto; background: #fff; border-radius: 4px; }
dialog#zoom::backdrop { background: rgba(18, 18, 17, 0.86); }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  body { font-size: 17px; }
  .site-inner { height: 52px; }
  .site-links { gap: 16px; font-size: 0.9rem; }
  .head { margin: 40px auto 32px; }
  .authors { font-size: 0.98rem; }
  .affils { gap: 0 14px; font-size: 0.85rem; }
  .hero { padding: 0; margin-bottom: 44px; }
  .hero video { border-radius: 0; }
  .hero figcaption { padding: 0 var(--gutter); }
  .lead { font-size: 1.25rem; }
  h2 { font-size: 1.55rem; }
  .wide { margin: 36px auto 40px; }
  .explorer { margin: 36px auto 40px; }
  .ex-body { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .ex-tabs { gap: 0 20px; margin-bottom: 18px; }
  .ex-tabs { flex-wrap: wrap; white-space: normal; overflow: visible; }
  .ex-break { display: block; flex-basis: 100%; height: 0; }
  .ex-break + .ex-group { margin-left: 0; padding-left: 0; border-left: 0; }
  .ex-group { display: none; }
  .ex-tabs button { padding: 8px 0 9px; }
  .ex-strip { gap: 5px; }
  .ex-name { font-size: 1.4rem; }
  .code { margin: 24px 0 26px 50%; }
  pre { font-size: 0.74rem; padding: 14px 16px; }
  table { font-size: 0.86rem; }
  th, td { padding: 8px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .track i { transition: none; }
  .btn { transition: none; }
}

