:root {
  /* The solver page's palette and type, so the two pages read as one site.
     The blue and the amber are the logo's. Both palettes are defined below,
     so the browser does not invert the page for a reader who asks for
     dark. */
  color-scheme: light dark;
  --bg: #f5f5f2;
  --card: #ffffff;
  --line: #e0e0d9;
  --line-strong: #c9c9c0;
  --ink: #1d1f21;
  --muted: #6c7075;
  --accent: #2070a8;
  --accent-fill: #dbe9f6;
  --amber: #d99a2b;
  --amber-fill: #fbeed0;
  --code: #f2f2ed;
  --warning: #6b5200;
  --warning-fill: #fff8d8;
  --danger: #8a352a;
  --danger-fill: #fbece8;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;
    --card: #1d2024;
    --line: #2e333a;
    --line-strong: #3d434b;
    --ink: #e5e8ea;
    --muted: #9aa1a9;
    --accent: #6fb3e6;
    --accent-fill: #1e3448;
    --amber: #e8a830;
    --amber-fill: #46381a;
    --code: #15181b;
    --warning: #e8c85a;
    --warning-fill: #3a3212;
    --danger: #f08a7a;
    --danger-fill: #3d1f1a;
  }
}

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

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

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

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

code,
.visible-count,
.solver-version,
.instance-source,
.instance-dimensions,
.alias-count,
.result-cell,
.kind-tag,
.group-tag,
.aggregate-primary,
.aggregate-secondary,
.profile-legend-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.55rem 0.75rem;
  transform: translateY(-180%);
  border: 1px solid var(--accent);
  background: var(--card);
  color: var(--accent);
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.metric-help {
  position: relative;
  width: fit-content;
  border-bottom: 1px dotted currentColor;
  cursor: help;
}

.metric-help::after {
  position: absolute;
  z-index: 30;
  bottom: calc(100% + 0.55rem);
  left: 0;
  width: min(280px, 78vw);
  padding: 0.55rem 0.65rem;
  border-radius: 5px;
  background: var(--ink);
  box-shadow: 0 3px 12px rgb(0 0 0 / 18%);
  color: var(--bg);
  content: attr(data-tooltip);
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 400;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transform: translateY(0.2rem);
  transition: opacity 100ms ease, transform 100ms ease;
  white-space: normal;
}

.metric-help:hover::after,
.metric-help:focus::after {
  opacity: 1;
  transform: translateY(0);
}

.scope-grid label:last-child .metric-help::after,
.aggregate-score:nth-child(n + 4) .metric-help::after,
.detail-metric:last-child .metric-help::after {
  right: 0;
  left: auto;
}

/* The page takes the whole window, like the solver page. */
.report-header,
main,
footer,
.fixture-notice {
  margin-inline: 2rem;
}

/* The header is the solver page's: the logo, the title and the lede, with
   the run's facts in a row beneath. */
.report-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.1rem;
  margin-top: 1.5rem;
}

.logo-link {
  flex: none;
  line-height: 0;
  text-decoration: none;
}

.logo {
  display: block;
  width: 6rem;
  height: 6rem;
}

.title-block {
  flex: 1 1 30rem;
  min-width: 0;
}

h1 {
  margin-bottom: 0.35rem;
  font-size: 1.35rem;
}

.lede {
  color: var(--muted);
}

.run-record {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 2rem;
  flex: 1 1 100%;
}

.run-record div {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.run-record dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.run-record dd {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.fixture-notice {
  padding: 0.7rem 1rem;
  border-right: 1px solid var(--amber);
  border-bottom: 1px solid var(--amber);
  border-left: 3px solid var(--amber);
  background: var(--warning-fill);
  color: var(--warning);
  font-size: 0.84rem;
}

main {
  padding: 1.5rem 0 4rem;
}

main > section {
  margin-top: 1.75rem;
}

main > .scope {
  margin-top: 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1rem;
}

.section-heading.compact {
  align-items: center;
  margin-bottom: 0.8rem;
}

.section-heading h2 {
  font-size: 1.05rem;
}

.section-heading h2 + p,
.subsection-heading p {
  max-width: 760px;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.visible-count {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.scope {
  padding: 1.1rem 1.25rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.scope-grid {
  display: grid;
  grid-template-columns: minmax(250px, 1.5fr) repeat(3, minmax(155px, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.scope-grid label,
.table-controls label {
  display: grid;
  gap: 0.3rem;
}

.scope-grid label > span,
.table-controls label > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.scope-grid input,
.scope-grid select,
.table-controls select,
.direction-button {
  width: 100%;
  min-height: 2.45rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
}

.scope-grid input:hover,
.scope-grid select:hover,
.table-controls select:hover,
.direction-button:hover {
  border-color: var(--accent);
}

.aggregate-quality-key,
.quality-key {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.aggregate-quality-key i,
.quality-gradient {
  width: 6.5rem;
  height: 0.58rem;
  border: 1px solid var(--line-strong);
  background: linear-gradient(90deg, hsl(136 62% 84%), hsl(48 72% 86%), hsl(5 62% 87%));
}

.methodology-note {
  margin: -0.15rem 0 0.8rem;
  color: var(--muted);
  font-size: 13px;
}

.aggregate-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}

.aggregate-header,
.aggregate-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.3fr) repeat(4, minmax(120px, 1fr));
}

.aggregate-header {
  border-bottom: 1px solid var(--line-strong);
  background: var(--accent-fill);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 650;
}

.aggregate-header > span {
  justify-self: center;
  margin: 0.55rem 0;
}

.aggregate-header .aggregate-header-solver {
  justify-self: start;
  margin-left: 0.8rem;
  border-bottom: 0;
  cursor: default;
}

.aggregate-header .metric-help::after {
  top: calc(100% + 0.55rem);
  bottom: auto;
}

.aggregate-header .metric-help:nth-child(n + 4)::after {
  right: 0;
  left: auto;
}

.aggregate-row + .aggregate-row {
  border-top: 1px solid var(--line);
}

.aggregate-solver,
.aggregate-score {
  min-width: 0;
  padding: 0.72rem 0.8rem;
}

.aggregate-solver {
  display: grid;
  align-content: center;
  border-right: 1px solid var(--line);
  font-weight: 600;
}

.aggregate-solver-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.solver-marker {
  flex: 0 0 auto;
  width: 0.25rem;
  height: 1.35rem;
  background: var(--solver-color);
}

.aggregate-solver .solver-version {
  margin: 0.15rem 0 0 0.8rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.56rem;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aggregate-score {
  display: grid;
  align-content: center;
  justify-items: center;
  border-right: 1px solid var(--line);
  text-align: center;
}

.aggregate-score:last-child {
  border-right: 0;
}

.aggregate-score.has-relative-quality {
  background: var(--summary-quality);
  box-shadow: inset 0 -3px 0 var(--summary-accent);
}

.aggregate-primary,
.aggregate-secondary {
  display: block;
}

.aggregate-primary {
  font-size: 0.88rem;
  font-weight: 700;
}

.aggregate-secondary {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.58rem;
}

.profile-block {
  margin-top: 2.2rem;
}

.subsection-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 0.75rem;
}

.subsection-heading h3 {
  font-size: 1.05rem;
}

.subsection-heading p {
  margin-top: 0;
  text-align: right;
}

.profile-figure {
  padding: 0.9rem 1rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

#width-profile-chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.profile-grid-line,
.profile-axis-line {
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.profile-grid-line {
  stroke: var(--line);
}

.profile-axis-line {
  stroke: var(--line-strong);
}

.profile-axis-label,
.profile-axis-title,
.profile-empty-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.profile-axis-title {
  font-family: var(--sans);
  font-size: 13px;
}

.profile-series {
  fill: none;
  pointer-events: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.profile-series-hit {
  fill: none;
  pointer-events: stroke;
  stroke: transparent;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 14;
  vector-effect: non-scaling-stroke;
}

.profile-series-hit:hover + .profile-series,
.profile-series-hit:focus + .profile-series {
  filter: drop-shadow(0 0 2px rgb(23 35 45 / 45%));
  stroke-width: 4;
}

.profile-series-hit:focus {
  outline: none;
}

.profile-series.is-goatd {
  stroke-width: 3;
}

.profile-point {
  fill: var(--card);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.profile-point:focus {
  fill: var(--amber);
  outline: none;
}

.profile-figure figcaption {
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.67rem;
}

.profile-legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem 1.2rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.profile-legend-item {
  display: grid;
  grid-template-columns: 1.8rem minmax(0, 1fr);
  align-items: center;
  gap: 0.1rem 0.45rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.69rem;
}

.profile-legend-item svg {
  display: block;
  width: 1.8rem;
  height: 0.5rem;
  overflow: visible;
}

.profile-legend-name {
  overflow: hidden;
  color: var(--ink);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-legend-value {
  grid-column: 2;
  font-size: 0.58rem;
}

.matrix-heading-row {
  align-items: end;
}

.quality-key {
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.9rem;
}

.quality-gradient {
  display: inline-block;
  width: 5rem;
  height: 0.45rem;
}

.table-controls {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(110px, 150px) 9rem;
  gap: 0.7rem;
  align-items: end;
  width: fit-content;
  margin: 0 0 0.75rem auto;
}

.direction-button {
  background: var(--accent-fill);
  color: var(--accent);
  font-weight: 600;
}

.result-list {
  display: grid;
  gap: 0.9rem;
}

.graph-row {
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}

.instance-cell {
  min-width: 0;
  padding: 0.9rem 1rem;
  border-right: 1px solid var(--line);
}

.instance-label,
.instance-source,
.instance-dimensions,
.alias-count {
  display: block;
}

.instance-label {
  overflow-wrap: anywhere;
  font-size: 0.86rem;
  font-weight: 650;
}

.instance-source {
  margin-top: 0.28rem;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.61rem;
  line-height: 1.35;
}

.instance-dimensions {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.63rem;
}

.alias-count {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.59rem;
}

.instance-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.48rem;
}

.kind-tag,
.group-tag {
  color: var(--muted);
  font-size: 0.57rem;
}

.kind-tag::before {
  content: "kind: ";
}

.group-tag::before {
  content: "group: ";
}

.solver-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  align-content: stretch;
}

.result-cell {
  min-width: 0;
  padding: 0.65rem 0.75rem 0.7rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-cell.has-width-quality {
  background: var(--quality-background);
  box-shadow: inset 0 3px 0 var(--quality-accent);
}

.result-solver {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 650;
}

.result-solver .solver-marker {
  height: 0.85rem;
}

.result-solver .solver-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-status {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  margin-top: 0.35rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.59rem;
  font-weight: 600;
}

.status-dot {
  width: 0.38rem;
  height: 0.38rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--accent);
}

.status-timeout .status-dot {
  background: var(--amber);
}

.status-error .status-dot,
.status-invalid .status-dot {
  background: var(--danger);
}

.status-skipped .status-dot,
.status-unavailable .status-dot {
  background: transparent;
}

.status-unavailable .status-dot {
  border-style: dashed;
}

.status-timeout .result-status {
  color: var(--warning);
}

.status-error .result-status,
.status-invalid .result-status {
  color: var(--danger);
}

.width-result {
  display: flex;
  align-items: baseline;
  gap: 0.42rem;
  margin-top: 0.26rem;
}

.width-label {
  color: var(--muted);
  font-size: 0.62rem;
}

.width-result strong {
  font-size: 1.12rem;
  line-height: 1;
}

.quality-badge {
  align-self: center;
  padding: 0.06rem 0.22rem;
  border-top: 2px solid var(--quality-accent);
  background: color-mix(in srgb, var(--card) 70%, transparent);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.53rem;
  font-weight: 650;
}

.result-details {
  display: grid;
  grid-template-columns: 1.1fr 0.7fr 0.9fr;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.detail-metric {
  min-width: 0;
  padding-top: 0.24rem;
  border-top: 1px solid var(--line);
}

.detail-metric dt {
  color: var(--muted);
  font-size: 0.5rem;
  white-space: nowrap;
}

.detail-metric dd {
  margin-top: 0.08rem;
  overflow: hidden;
  font-size: 0.61rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-metric.is-best {
  border-top: 2px solid var(--amber);
  padding-top: calc(0.24rem - 1px);
}

.failed-result {
  display: grid;
  align-content: start;
  min-height: 2.8rem;
  margin-top: 0.4rem;
  color: var(--muted);
}

.failed-time {
  font-size: 0.7rem;
  font-weight: 600;
}

.failed-message {
  margin-top: 0.2rem;
  font-family: var(--sans);
  font-size: 0.6rem;
  line-height: 1.3;
}

.empty-result {
  padding: 2.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--muted);
  text-align: center;
}

.matrix-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.7rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.67rem;
}

.pagination button {
  min-height: 2.1rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.72rem;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.definitions {
  padding: 1.4rem 1.5rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.definitions dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.3rem 1.6rem;
}

.definitions dt {
  font-size: 0.78rem;
  font-weight: 650;
}

.definitions dd {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.ranking-note {
  margin-top: 1.25rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.74rem;
}

.load-error {
  margin: 2rem auto;
  padding: 0.9rem 1rem;
  border: 1px solid var(--danger);
  border-left: 3px solid var(--danger);
  background: var(--danger-fill);
  color: var(--danger);
}

footer {
  padding: 1.4rem 0 3rem;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.72rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 980px) {
  .scope-grid {
    grid-template-columns: 1fr 1fr;
  }

  .search-control {
    grid-column: 1 / -1;
  }

  .aggregate-row {
    grid-template-columns: repeat(4, 1fr);
  }

  .aggregate-header {
    grid-template-columns: repeat(4, 1fr);
  }

  .aggregate-solver,
  .aggregate-header-solver {
    grid-column: 1 / -1;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .definitions dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .graph-row {
    grid-template-columns: 1fr;
  }

  .instance-cell {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 680px) {
  .report-header,
  main,
  footer,
  .fixture-notice {
    margin-inline: 1rem;
  }

  .section-heading,
  .subsection-heading {
    display: grid;
    gap: 0.5rem;
  }

  .subsection-heading p {
    text-align: left;
  }

  .scope-grid,
  .aggregate-row {
    grid-template-columns: 1fr;
  }

  .aggregate-header {
    display: none;
  }

  .search-control,
  .aggregate-solver {
    grid-column: auto;
  }

  .aggregate-score,
  .aggregate-solver {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .aggregate-score:last-child {
    border-bottom: 0;
  }

  .aggregate-score::before {
    margin-bottom: 0.2rem;
    color: var(--muted);
    content: attr(data-metric);
    font-family: var(--sans);
    font-size: 0.62rem;
    font-weight: 600;
  }

  .matrix-heading-row {
    align-items: start;
  }

  .quality-key {
    justify-content: start;
  }

  .table-controls {
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .direction-button {
    grid-column: 1 / -1;
  }

  .solver-results,
  .definitions dl,
  .profile-legend {
    grid-template-columns: 1fr;
  }

  .result-cell {
    border-right: 0;
  }
}

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

  .metric-help::after {
    transition: none;
  }
}

@media print {
  body {
    background: white;
  }

  .scope,
  .table-controls {
    display: none;
  }

  .graph-row {
    break-inside: avoid;
  }
}

/* Dark palette only: the quality tints are pale colours the script picks for
   a white cell; on a dark card they are mixed in rather than painted over
   it. This comes last so it wins over the rules above. */
@media (prefers-color-scheme: dark) {
  .aggregate-score.has-relative-quality {
    background: color-mix(in srgb, var(--summary-quality) 30%, var(--card));
  }

  .result-cell.has-width-quality {
    background: color-mix(in srgb, var(--quality-background) 30%, var(--card));
  }

  .aggregate-quality-key i,
  .quality-gradient {
    opacity: 0.75;
  }
}
