/* Copyright (c) 2022: jump-dev/benchmarks contributors
 *
 * Use of this source code is governed by an MIT-style license that can be found
 * in the LICENSE.md file or at https://opensource.org/licenses/MIT.
 *
 * Colours: the accent is Julia blue; the chart series use a categorical
 * palette validated for colour-vision deficiency on both surfaces. Dark mode
 * follows the OS unless <html data-theme="light|dark"> says otherwise.
 */
:root {
  color-scheme: light;
  --bg: #fcfcfb;
  --surface: #ffffff;
  --border: #e3e2dd;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #8a8984;
  --link: #4063d8;
  --accent: #4063d8;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --good: #008300;
  --critical: #d03b3b;
  --row-hover: #f3f2ee;
  --grid: #ecebe6;
  --baseline: #c8c7c0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1a19;
    --surface: #222221;
    --border: #383835;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --link: #8fa6f0;
    --accent: #6b8af0;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --good: #4cbf4c;
    --critical: #ef6b6b;
    --row-hover: #2a2a28;
    --grid: #2e2e2c;
    --baseline: #4a4a46;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1a19;
  --surface: #222221;
  --border: #383835;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #8f8e88;
  --link: #8fa6f0;
  --accent: #6b8af0;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --good: #4cbf4c;
  --critical: #ef6b6b;
  --row-hover: #2a2a28;
  --grid: #2e2e2c;
  --baseline: #4a4a46;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: 0 0 48px;
}
.container { max-width: 1400px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .container { padding: 0 16px; } }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .num, td.num, th.num, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
h1 { font-size: 22px; margin: 20px 0 8px; }
h2 { font-size: 17px; margin: 28px 0 8px; }
h3 { font-size: 14px; margin: 16px 0 6px; color: var(--text-2); }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--critical); }

.topbar { border-bottom: 1px solid var(--border); }
.topbar .container { display: flex; align-items: stretch; gap: 28px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; padding: 10px 0; font-weight: 600; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .logo { height: 26px; width: auto; display: block; }
.topbar nav { display: flex; gap: 20px; }
.topbar nav a { display: flex; align-items: center; padding: 12px 0 10px; margin-bottom: -1px; color: var(--text-2); border-bottom: 2px solid transparent; }
.topbar nav a:hover { color: var(--text); text-decoration: none; }
.topbar nav a.active { color: var(--text); border-bottom-color: var(--accent); }
footer { margin-top: 48px; border-top: 1px solid var(--border); font-size: 12px; }
footer .container { padding-top: 12px; }

/* Tables */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th { color: var(--text-2); font-weight: 600; position: sticky; top: 0; background: var(--bg); z-index: 1; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sorted { color: var(--text); }
th.sorted::after { content: " ▾"; color: var(--accent); }
th.sorted.asc::after { content: " ▴"; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--row-hover); }
.table-wrap { overflow-x: auto; margin: 8px 0 16px; }
td.wrap { white-space: normal; }
tr.current td { background: var(--row-hover); font-weight: 600; }

/* Relative changes: lower is better for every metric, so a rise is bad. */
.delta { font-variant-numeric: tabular-nums; }
.delta.worse { color: var(--critical); }
.delta.better { color: var(--good); }
.delta.flat { color: var(--muted); }

.chip { display: inline-block; padding: 0 6px; border-radius: 10px; font-size: 11px; background: var(--row-hover); color: var(--text-2); margin-left: 4px; vertical-align: 2px; }
.chip.group-micro { color: var(--text-2); }
.chip.group-latency { color: var(--text-2); }

.controls {
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; width: fit-content; max-width: 100%;
  padding: 10px 12px; margin: 12px 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
.controls label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-2); }
.controls .note { font-size: 12px; color: var(--muted); align-self: center; }
select, input[type=text], input[type=search] {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 6px; min-width: 120px;
}
select.wide { max-width: 100%; min-width: 260px; }
select:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 12px 0; }
.tile { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; background: var(--surface); min-width: 0; }
.tile .label { font-size: 12px; color: var(--text-2); }
.tile .value { font-size: 22px; font-weight: 500; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .value a { color: var(--text); }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 16px; margin: 8px 0; font-size: 13px; }
dl.kv dt { color: var(--text-2); }
dl.kv dd { margin: 0; }

pre.log {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px; font-size: 12px; line-height: 1.35; overflow: auto; max-height: 60vh; white-space: pre;
}
details { margin: 8px 0; }
details summary { cursor: pointer; color: var(--text-2); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
.cols > * { min-width: 0; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

/* Plot grid: each plot is a titled section with a short description. */
.plots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 32px; margin: 8px 0; }
@media (max-width: 900px) { .plots { grid-template-columns: 1fr; } }
.plots.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 1200px) { .plots.three { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) { .plots.three { grid-template-columns: 1fr; } }
.plot { min-width: 0; }
.plot h3 { font-size: 15px; font-weight: 600; margin: 12px 0 2px; color: var(--text); }
.plot h3 .delta { font-size: 13px; font-weight: 400; margin-left: 8px; }
.plot p { margin: 0 0 4px; }

/* SVG charts */
.chart-wrap { position: relative; margin: 4px 0; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-wrap .axis text { font-size: 11px; fill: var(--text-2); }
.chart-wrap .axis line { stroke: var(--grid); }
.chart-wrap .axis-title { font-size: 12px; fill: var(--text-2); }
.chart-wrap .baseline { stroke: var(--baseline); stroke-width: 1; }
.chart-wrap .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-wrap .pt { stroke: var(--bg); stroke-width: 2; }
.chart-wrap .crosshair line { stroke: var(--text-2); stroke-width: 1; }
.chart-wrap .crosshair .pt { stroke: var(--text); }
.chart-wrap .empty { font-size: 12px; fill: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12px; color: var(--text-2); margin: 4px 0 0; }
.legend .swatch { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: 2px; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 6px 8px; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.15); display: none; z-index: 2;
  min-width: 180px; max-width: 240px;
}
.tooltip .tip-head { margin: 0 0 4px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.tooltip .tip-row { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.tooltip .key { display: inline-block; width: 10px; height: 3px; border-radius: 2px; flex: none; }
.tooltip .small { font-size: 11px; margin-top: 3px; }

/* Sparklines in tables */
svg.spark { width: 120px; height: 24px; display: block; }
svg.spark path { fill: none; stroke: var(--series-1); stroke-width: 1.5; }
svg.spark circle { fill: var(--series-1); }

/* Plotly charts on the repository activity page */
.toc { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 16px 0 8px; padding: 8px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 13px; }
.plotly-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
@media (max-width: 1100px) { .plotly-grid { grid-template-columns: 1fr; } }
.plotly-grid > div { min-width: 0; }
.plotly-chart { width: 100%; height: 420px; margin: 4px 0 16px; }
@media (max-width: 600px) { .plotly-chart { height: 360px; } }
section { scroll-margin-top: 12px; }
