/* Benchmarks page, on top of the site's style.css. */
.bench { --grid: color-mix(in srgb, var(--line) 75%, transparent); }
.bench h2 { font-size: clamp(30px, 4vw, 40px); }
.bench .ct { font: 600 17px/1.3 var(--body); text-transform: none; letter-spacing: normal; color: var(--fg); margin: 2.2em 0 0.4em; }

/* bar charts: one row per change, bars from zero with the 95% interval as a line */
.chart { margin: 0.6em 0 1em; }
.headline + .chart { margin-top: 2.4em; }
.chart .row {
  display: grid; grid-template-columns: minmax(180px, 280px) 1fr 66px 66px; column-gap: 16px; align-items: center;
  min-height: 42px; margin: 0 -10px; padding: 0 10px; border-radius: 8px;
}
.chart .row[data-tip] { cursor: default; }
.chart .row[data-tip]:hover, .chart .row[data-tip]:focus-visible { background: var(--panel-2); }
.chart .row:focus-visible { outline-offset: 0; }
.row .name { font-weight: 600; font-size: 14.5px; line-height: 1.3; padding: 7px 0; }
.row .name small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.row .plot {
  position: relative; align-self: stretch;
  background: linear-gradient(to right, var(--grid) 1px, transparent 1px) 0 0 / calc(100% / var(--ticks)) 100%;
  box-shadow: inset -1px 0 var(--grid);
}
.row .plot::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: var(--muted); opacity: 0.6; }
.row .bar { position: absolute; left: 0; top: 50%; height: 12px; margin-top: -6px; border-radius: 0 4px 4px 0; background: var(--ok); }
.row.ns .bar { background: var(--muted); opacity: 0.45; }
.row .ci { position: absolute; top: 50%; height: 2px; margin-top: -1px; border-radius: 1px; background: var(--fg); opacity: 0.55; }
.row .v { text-align: right; font: 500 14px var(--mono); white-space: nowrap; }
.row .v.ns { color: var(--muted); }
.row.head { min-height: 26px; }
.row.head .plot { background: none; box-shadow: none; }
.row.head .plot::before { content: none; }
.row.head .v { font: 600 11.5px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.axis span { position: absolute; bottom: 5px; transform: translateX(-50%); font: 500 11.5px/1 var(--mono); color: var(--muted); }
.axis span:first-child { transform: none; }
.axis span:last-child { transform: translateX(-100%); }
.chart .sep {
  margin-top: 10px; padding: 12px 0 2px; border-top: 1px solid var(--line);
  font: 600 11.5px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
}

/* mods too small to measure */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0.4em 0 1em; padding: 0; list-style: none; }
.chips li { margin: 0; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; line-height: 1.35; }
.chips li:hover, .chips li:focus-visible { background: var(--panel-2); }
.chips small { color: var(--muted); font-size: 13px; margin-left: 2px; }

/* collapsed tables */
details.numbers { margin: 1.6em 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
details.numbers > summary { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; color: var(--muted); font-size: 14.5px; font-weight: 500; }
details.numbers > summary::-webkit-details-marker { display: none; }
details.numbers > summary::before { content: "\203A"; font-size: 20px; line-height: 1; transition: transform 0.15s; }
details.numbers > summary:hover { color: var(--fg); }
details.numbers[open] > summary { margin-bottom: 1em; }
details.numbers[open] > summary::before { transform: rotate(90deg); }
details.numbers table { font-size: 14px; }
details.numbers td.num, details.numbers th.num { text-align: right; white-space: nowrap; }
details.numbers td.num { font-family: var(--mono); font-size: 13.5px; }
details.numbers td { padding: 9px 12px; }
details.numbers td:first-child { min-width: 170px; }

/* method: a long-form write-up with figures */
.method { counter-reset: msec; }
.method > p, .method > ul, .method > ol, .method > h3 { max-width: 760px; }
.method .lede { font-size: 18px; line-height: 1.6; }
.method h3 { counter-increment: msec; display: flex; align-items: baseline; gap: 12px; font: 600 22px/1.3 var(--body); margin: 2.6em 0 0.7em; }
.method h3::before { content: counter(msec, decimal-leading-zero); font: 600 13px/1 var(--mono); color: var(--accent); letter-spacing: 0.04em; }
.method code { white-space: nowrap; }
.fig { margin: 1.6em 0 1.8em; }
.fig > img { display: block; width: 100%; border: 1px solid var(--line); }
.fig figcaption { margin-top: 10px; color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 760px; }
.steps { list-style: none; padding: 0; margin: 1.2em 0; counter-reset: step; }
.steps li { counter-increment: step; position: relative; display: grid; grid-template-columns: 96px 1fr; gap: 16px; margin: 0; padding: 0 0 14px 28px; }
.steps li::before { content: ""; position: absolute; left: 5px; top: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.steps li::after { content: ""; position: absolute; left: 9px; top: 21px; bottom: 0; width: 1px; background: var(--line); }
.steps li:last-child::after { content: none; }
.steps b { font: 600 13px/1.9 var(--mono); text-transform: uppercase; letter-spacing: 0.05em; }
.steps span { color: var(--fg); }
.steps code { white-space: normal; }
.codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 1.4em 0; }
.code { min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); overflow: hidden; }
.code-label { padding: 8px 14px; border-bottom: 1px solid var(--line); font: 500 12px/1.3 var(--mono); color: var(--muted); }
.code pre { margin: 0; border: 0; border-radius: 0; background: none; font-size: 13.5px; line-height: 1.6; }
.method .code code { white-space: pre; }
.legend i.base, .sched i.base, .legend i.dot { background: var(--teal); }
.legend i.dot { border-radius: 50%; }
.legend i.hl, .sched i.hl { background: var(--accent); }
.legend i.cfg, .sched i.cfg { background: color-mix(in srgb, var(--muted) 35%, transparent); }
.legend i.band { background: color-mix(in srgb, var(--teal) 16%, transparent); border: 1px solid color-mix(in srgb, var(--teal) 45%, transparent); }
.legend i.van, .legend i.cl { width: 16px; height: 2px; border-radius: 1px; background: var(--muted); }
.legend i.cl { background: var(--accent); }

/* run order: one row per round, one cell per launch, --cols cells per row (the longest round) */
.sched { display: grid; gap: 5px; }
.srow { display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 8px; }
.sr { font: 500 12px/1 var(--mono); color: var(--muted); text-align: right; }
.cells { display: grid; grid-template-columns: repeat(var(--cols, 15), minmax(0, 1fr)); gap: 3px; }
.cells i { display: block; height: 22px; border-radius: 3px; }
.cells i:hover { outline: 2px solid var(--fg); outline-offset: -2px; }

/* plot frames for the baseline dots and the frame-time trace */
.pchart { padding-left: 44px; }
.pchart .plot { position: relative; height: 260px; border-bottom: 1px solid var(--muted); }
.pchart .gy { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--grid); }
.pchart .gy em { position: absolute; right: calc(100% + 8px); top: -8px; font: 500 11.5px/1 var(--mono); font-style: normal; color: var(--muted); white-space: nowrap; }
.pchart .xt { position: relative; height: 24px; }
.pchart .xt span { position: absolute; top: 8px; transform: translateX(-50%); font: 500 11.5px/1 var(--mono); color: var(--muted); white-space: nowrap; }
.pchart .xt span:first-child { transform: none; }
.pchart .xt span:last-child { transform: translateX(-100%); }
.dots .band { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--teal) 10%, transparent); }
.dots .mean { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--fg); opacity: 0.6; }
.dots .mean em { position: absolute; right: 8px; top: -20px; font: 500 11.5px/1 var(--mono); font-style: normal; }
.dots i { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 2px var(--panel); }
.dots i::after { content: ""; position: absolute; inset: -7px; }
.dots i:hover { transform: scale(1.3); }
.trace svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.trace path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.trace path.van { stroke: var(--muted); }
.trace path.cl { stroke: var(--accent); }
.trace .plot { margin-right: 76px; cursor: crosshair; }
.trace .xt { margin-right: 76px; }
.trace .end { position: absolute; left: calc(100% + 8px); transform: translateY(-50%); font-size: 13px; font-weight: 600; white-space: nowrap; }
.trace .end.van { color: var(--muted); }
.trace .cross { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--fg); opacity: 0.5; display: none; pointer-events: none; }
.trace.hover .cross { display: block; }
.method .table-wrap { max-width: 760px; }
.method table td:first-child { color: var(--muted); font-weight: 500; white-space: nowrap; }
.method table td.num, .method table th.num { text-align: right; font-family: var(--mono); font-size: 13.5px; }
.method table td { padding: 10px 14px; }

/* tooltip (bench.js) */
.tip {
  position: fixed; z-index: 30; max-width: 300px; padding: 10px 12px; pointer-events: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 14px 36px -14px rgb(0 0 0 / 0.55); font-size: 13px; line-height: 1.5;
}
.tip-title { font-weight: 600; margin-bottom: 4px; }
.tip-row b { font: 600 13px var(--mono); margin-right: 8px; }
.tip-row span { color: var(--muted); }

@media (max-width: 760px) {
  .steps li { grid-template-columns: 1fr; gap: 2px; }
  .pchart .plot { height: 200px; }
  .cells { gap: 2px; }
  .cells i { height: 16px; }
  .hl-nums b { font-size: 44px; }
  .hl-row { grid-template-columns: 70px 1fr; gap: 10px; }
  .hl-row > span:empty { display: block; }
}
@media (max-width: 640px) {
  .chart .row { grid-template-columns: 1fr 58px 58px; grid-template-areas: "name name name" "plot avg low"; column-gap: 10px; padding-bottom: 8px; }
  .row .name { grid-area: name; padding-bottom: 4px; }
  .row .plot { grid-area: plot; height: 22px; }
  .row .v.avg { grid-area: avg; }
  .row .v.low { grid-area: low; }
  .row.head { grid-template-areas: "plot avg low"; padding-bottom: 0; }
  .row.head .name { display: none; }
  .row.head .plot { height: 26px; }
  .axis span:nth-child(even), .hl-axis span:nth-child(even) { display: none; }
}
