/* DexRetargetBench project page.
 * Ink, muted and rule colours match the paper's figures; the four attribute
 * colours are the ones used in the paper's task-type charts. */

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-serif-4-latin-opsz-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-serif-4-latin-opsz-italic.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
}

:root {
  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --wrap: 1200px;
  --gutter: clamp(20px, 4vw, 40px);
  --nav-h: 56px;
  --radius: 3px;
}

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #1f1f1d;
  --muted: #6b6a66;
  --faint: #8f8d88;
  --line: #e6e4df;
  --line-strong: #c9c6bf;
  --surface: #f7f6f3;
  --scrim: rgba(255, 255, 255, 0.9);

  --attr-b: #2a78d6;
  --attr-m: #eb6834;
  --attr-a: #1baf7a;
  --attr-i: #eda100;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --ink: #ecebe7;
  --muted: #a3a29c;
  --faint: #7a7974;
  --line: #262625;
  --line-strong: #454442;
  --surface: #131313;
  --scrim: rgba(10, 10, 10, 0.92);

  --attr-b: #5b9ff0;
  --attr-m: #f28357;
  --attr-a: #35c690;
  --attr-i: #f4b62e;
}

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

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p,
dl,
dd,
ul,
figure,
pre {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration-color: var(--line-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover {
  text-decoration-color: currentColor;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: var(--radius);
}

code,
pre {
  font-family: var(--mono);
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  text-decoration: none;
}
.skip:focus {
  top: 10px;
}

/* ---------- Navigation ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 32px;
  height: var(--nav-h);
}

.wordmark {
  font: 600 1.0625rem/1 var(--serif);
  letter-spacing: -0.01em;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 28px;
  margin-left: auto;
  font-size: 0.875rem;
}
.nav-links a {
  color: var(--muted);
  text-decoration: none;
}
.nav-links a:hover {
  color: var(--ink);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
}
.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}
/* The button shows where it leads: a moon on white, a sun on black. */
:root[data-theme="light"] .icon-sun,
:root[data-theme="dark"] .icon-moon {
  display: none;
}

/* ---------- Hero ---------- */

.hero {
  padding-top: clamp(40px, 6vw, 60px);
  padding-bottom: 36px;
}

h1 {
  font: 560 clamp(2.5rem, 6.2vw, 4.75rem) / 1 var(--serif);
  letter-spacing: -0.028em;
  font-variation-settings: "opsz" 60;
}

.subtitle {
  max-width: 27em;
  margin-top: 18px;
  font: 400 clamp(1.125rem, 1.9vw, 1.4375rem) / 1.35 var(--serif);
  text-wrap: balance;
}

.affiliations {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 22px;
  margin-top: 26px;
}
.affiliations img {
  display: block;
  width: clamp(64px, 7vw, 76px);
  height: clamp(64px, 7vw, 76px);
  object-fit: contain;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.link-btn {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.link-btn:hover {
  border-color: var(--ink);
}
.link-btn[data-todo] {
  color: var(--muted);
  border-style: dashed;
  cursor: default;
}
.link-btn[data-todo]:hover {
  border-color: var(--line-strong);
}

/* ---------- Media frames ---------- */

.frame {
  display: block;
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* The demonstrations are rendered on white; keep the frame white while one loads. */
.frame:not(.ph) {
  background: #fff;
}

.frame video,
.frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* A card's poster lies over its video and steps aside while the clip plays. */
.frame .cover {
  position: absolute;
  inset: 0;
  transition: opacity 0.15s;
}
.frame.is-playing .cover {
  opacity: 0;
}

/* Empty frames carry crop marks so they read as reserved space, not a broken image. */
.frame.ph {
  --tick: var(--line-strong);
  --len: 12px;
  --inset: 12px;
  background:
    linear-gradient(var(--tick), var(--tick)) left var(--inset) top var(--inset) / var(--len) 1px,
    linear-gradient(var(--tick), var(--tick)) left var(--inset) top var(--inset) / 1px var(--len),
    linear-gradient(var(--tick), var(--tick)) right var(--inset) top var(--inset) / var(--len) 1px,
    linear-gradient(var(--tick), var(--tick)) right var(--inset) top var(--inset) / 1px var(--len),
    linear-gradient(var(--tick), var(--tick)) left var(--inset) bottom var(--inset) / var(--len) 1px,
    linear-gradient(var(--tick), var(--tick)) left var(--inset) bottom var(--inset) / 1px var(--len),
    linear-gradient(var(--tick), var(--tick)) right var(--inset) bottom var(--inset) / var(--len) 1px,
    linear-gradient(var(--tick), var(--tick)) right var(--inset) bottom var(--inset) / 1px var(--len),
    var(--surface);
  background-repeat: no-repeat;
}

.ph-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  font: 400 0.75rem/1.5 var(--mono);
  color: var(--faint);
  text-align: center;
}

/* ---------- Comparison stage ---------- */

.compare {
  padding-bottom: 8px;
}

.lede {
  max-width: 38em;
  margin-bottom: 18px;
  font-size: 1.0625rem;
  color: var(--muted);
  text-wrap: pretty;
}

.carousel {
  position: relative;
}

/* Slides share one grid cell; only the current one (and the one sliding out) is shown. */
.slides {
  display: grid;
  overflow: hidden;
  touch-action: pan-y;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.slide {
  grid-area: 1 / 1;
  visibility: hidden;
}
.slide.is-current,
.slide.is-leaving {
  visibility: visible;
}

/* Arrows sit on the outer edges, level with the middle of the frames (not the labels under them). */
.arrow {
  position: absolute;
  top: calc(50% - 15px);
  z-index: 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-top: -20px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}
.arrow.prev {
  left: -20px;
}
.arrow.next {
  right: -20px;
}
.arrow:hover {
  border-color: var(--ink);
}

.pane figcaption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.8125rem;
  color: var(--muted);
}
.pane-tag {
  font-weight: 600;
  color: var(--ink);
}

.transport {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}

.play {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}
.play:hover {
  border-color: var(--ink);
}
.play svg {
  fill: currentColor;
  stroke: none;
}
.play[aria-pressed="true"] .icon-play,
.play[aria-pressed="false"] .icon-pause {
  display: none;
}

.scrub {
  --p: 0%;
  flex: 1;
  height: 20px;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.scrub::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(to right, var(--ink) var(--p), var(--line-strong) var(--p));
}
.scrub::-moz-range-track {
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(to right, var(--ink) var(--p), var(--line-strong) var(--p));
}
.scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  margin-top: -4.5px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}
.scrub::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

.clock {
  flex: none;
  min-width: 9.5em;
  font: 400 0.75rem/1 var(--mono);
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stage-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 40px;
  margin-top: 22px;
}

.pager {
  display: flex;
  flex: none;
  margin: 2px -4px 0 0;
}
.dot {
  padding: 10px 4px;
}
.dot::before {
  content: "";
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 1px;
  background: var(--line-strong);
}
.dot:hover::before {
  background: var(--muted);
}
.dot[aria-current="true"]::before {
  background: var(--ink);
}

.caption {
  max-width: 46em;
  font: italic 400 1rem/1.5 var(--serif);
  color: var(--muted);
  text-wrap: pretty;
}
.caption .marks {
  margin-left: 0.4em;
  font-style: normal;
}

/* ---------- Attribute marks ---------- */

.mark {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--c);
}
.mark[data-attr="b"] { --c: var(--attr-b); }
.mark[data-attr="m"] { --c: var(--attr-m); }
.mark[data-attr="a"] { --c: var(--attr-a); }
.mark[data-attr="i"] { --c: var(--attr-i); }
.mark.off {
  background: none;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 400 0.8125rem/1 var(--sans);
  color: var(--muted);
  white-space: nowrap;
}
.tag + .tag {
  margin-left: 14px;
}

/* ---------- Sections ---------- */

.tasks {
  margin-top: clamp(72px, 9vw, 112px);
}

h2 {
  font: 560 1.75rem/1.15 var(--serif);
  letter-spacing: -0.015em;
}

/* ---------- Tasks ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.section-head p {
  color: var(--muted);
}

.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-top: 24px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  line-height: 1.4;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.chip:hover {
  border-color: var(--line-strong);
}
.chip[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--surface);
}
.chip .n {
  font: 400 0.75rem/1 var(--mono);
  color: var(--faint);
}

.count {
  font: 400 0.75rem/1.4 var(--mono);
  color: var(--muted);
}

.group {
  margin-top: 44px;
}

.group-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.group-head h3 {
  font: 560 1.25rem/1.2 var(--serif);
  letter-spacing: -0.01em;
}
.group-head p {
  font-size: 0.875rem;
  color: var(--muted);
}
.group-head .n {
  margin-left: auto;
  font: 400 0.75rem/1.4 var(--mono);
  color: var(--faint);
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 24px 16px;
  margin-top: 18px;
}

.card {
  display: block;
  width: 100%;
  text-align: left;
}
.card .frame.ph {
  --len: 8px;
  --inset: 8px;
}
.card:hover .frame,
.card:focus-visible .frame {
  border-color: var(--line-strong);
}

.card-id {
  display: block;
  margin-top: 9px;
  font: 400 0.75rem/1.4 var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}
.card-marks {
  display: flex;
  gap: 4px;
}
.card-dur {
  font: 400 0.75rem/1 var(--mono);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.empty {
  margin-top: 44px;
  color: var(--muted);
}

/* ---------- Footer ---------- */

.footer {
  margin-top: clamp(72px, 9vw, 112px);
  border-top: 1px solid var(--line);
}
.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 32px;
  padding-block: 28px 40px;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ---------- Task viewer ---------- */

.viewer {
  width: min(1080px, calc(100vw - 2 * var(--gutter)));
  max-width: none;
  padding: 0;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}
.viewer::backdrop {
  background: var(--scrim);
}
.viewer-body {
  padding: 16px;
}
.viewer-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-top: 14px;
}
.viewer-text {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  flex: 1 1 240px;
}
.viewer-dataset {
  font: 560 1.0625rem/1.2 var(--serif);
}
.viewer-text code {
  min-width: 0;
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.viewer-nav button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
}
.viewer-nav button:hover {
  border-color: var(--ink);
}
.viewer-pos {
  min-width: 4.5em;
  font: 400 0.75rem/1 var(--mono);
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
#viewer-close {
  margin-left: 10px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .nav-row {
    gap: 16px;
  }
  .nav-links {
    display: none;
  }
  .theme-toggle {
    margin-left: auto;
  }
  .pair {
    grid-template-columns: 1fr;
  }
  /* Panes stack here, so the arrows move to the middle of the upper frame. */
  .carousel {
    container-type: inline-size;
  }
  .arrow {
    top: calc(100cqw * 9 / 32);
    width: 36px;
    height: 36px;
    margin-top: -18px;
  }
  .arrow.prev {
    left: -14px;
  }
  .arrow.next {
    right: -14px;
  }
  .stage-foot {
    flex-direction: column-reverse;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .clock {
    min-width: 0;
  }
}

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