/* page2: results ("Score, Tokens and Cost").
   One instrument panel: task-set tabs on top, an axis toolbar, then the scatter chart and the readout table side
   by side, the model switches and the footnote underneath. Scoped to #results so the copy of the chart embedded
   in #analysis (.is-findings-sweep) keeps its own styling. Data colours (models, points) are untouched. */

/* ---------- frame: page wrap, left-aligned heading (the template centres both) ---------- */
body.p2 main > #results.section {
  padding: var(--p2-section-y) 0 !important;
  background: var(--p2-surface) !important;
}

body.p2 #results > .container {
  width: 100% !important;
  max-width: var(--p2-wrap) !important;
  padding: 0 var(--p2-gutter) !important;
}

body.p2 #results .section-heading > .column,
body.p2 #results .section-heading > .column.is-four-fifths {
  width: 100% !important;
  max-width: 900px !important;
  margin: 0 !important;
  padding: 0 !important;
}

body.p2 #results .section-heading .section-deck {
  max-width: 64ch !important;
  margin: 0 !important;
  text-align: left !important;
}

body.p2 #results .benchmark-sweep-container {
  display: block !important;
  width: 100% !important;
  max-width: var(--p2-wrap) !important;
  padding: 0 var(--p2-gutter) !important;
}

body.p2 #results .benchmark-sweep {
  --rs-table-w: 480px;
  --rs-bar-h: 52px;
  display: grid;
  /* one column: the chart keeps the full width so that every point label can be placed */
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "scope"
    "axes"
    "chart"
    "table"
    "models"
    "caption";
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  font-family: var(--p2-display);
  color: var(--p2-ink);
}

/* flatten the wrappers so the pieces can be placed on one grid */
body.p2 #results .benchmark-plot-row,
body.p2 #results .benchmark-plot-column,
body.p2 #results .benchmark-sweep-controls { display: contents !important; }

body.p2 #results .benchmark-chart-switches { grid-area: scope; }
body.p2 #results .benchmark-axis-controls { grid-area: axes; }
body.p2 #results .benchmark-chart-wrap { grid-area: chart; }
body.p2 #results .benchmark-table-section { grid-area: table; }
body.p2 #results .benchmark-model-panel { grid-area: models; }
body.p2 #results .benchmark-chart-caption { grid-area: caption; }

/* ---------- task-set tabs: underline tabs with mono counts ---------- */
body.p2 #results .benchmark-chart-switches {
  display: block !important;
  margin: 0 0 28px;
  border-bottom: 1px solid var(--p2-line);
}

body.p2 #results .benchmark-scope-switch.benchmark-segmented {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0 30px !important;
  width: 100%;
  min-width: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
}

body.p2 #results .benchmark-scope-switch .benchmark-metric-btn {
  flex: none !important;
  display: inline-flex !important;
  align-items: baseline !important;
  gap: 7px;
  min-width: 0 !important;
  height: auto !important;
  margin: 0 0 -1px;
  padding: 12px 0 13px !important;
  border: 0 !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--p2-muted) !important;
  font: 500 15px/1.2 var(--p2-display) !important;
  letter-spacing: -0.005em;
  transition: color 0.15s ease, border-color 0.15s ease;
}

body.p2 #results .benchmark-scope-switch .benchmark-metric-btn small {
  margin: 0;
  opacity: 1;
  font: 400 12px/1 var(--p2-mono);
  letter-spacing: 0.02em;
  color: var(--p2-muted);
  font-variant-numeric: tabular-nums;
}

body.p2 #results .benchmark-scope-switch .benchmark-metric-btn:hover { color: var(--p2-ink) !important; }

body.p2 #results .benchmark-scope-switch .benchmark-metric-btn[aria-pressed="true"] {
  border-bottom-color: var(--p2-ink) !important;
  background: transparent !important;
  color: var(--p2-ink) !important;
}

body.p2 #results .benchmark-scope-switch .benchmark-metric-btn[aria-pressed="true"] small { color: var(--p2-ink-2); }

/* ---------- axis toolbar: the head of the panel ---------- */
body.p2 #results .benchmark-axis-controls {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 28px !important;
  height: var(--rs-bar-h);
  padding: 0 16px;
  border: 1px solid var(--p2-line);
  border-bottom: 0;
  border-radius: var(--p2-radius-lg) var(--p2-radius-lg) 0 0;
  background: var(--p2-surface-2);
}

body.p2 #results .benchmark-control-group { gap: 10px !important; }

body.p2 #results .benchmark-control-label {
  font: 500 12px/1 var(--p2-mono);
  letter-spacing: 0.12em;
  color: var(--p2-muted);
}

body.p2 #results .benchmark-control-label::after { content: " axis"; }

/* square segmented control */
body.p2 #results .benchmark-axis-controls .benchmark-segmented {
  display: inline-flex !important;
  gap: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  border: 1px solid var(--p2-line-strong) !important;
  border-radius: var(--p2-radius) !important;
  background: var(--p2-surface) !important;
}

body.p2 #results .benchmark-axis-controls .benchmark-metric-btn:first-child { border-radius: 3px 0 0 3px !important; }
body.p2 #results .benchmark-axis-controls .benchmark-metric-btn:last-child { border-radius: 0 3px 3px 0 !important; }

body.p2 #results .benchmark-axis-controls .benchmark-metric-btn {
  min-width: 0 !important;
  height: 30px !important;
  padding: 0 13px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--p2-ink-2) !important;
  font: 500 13px/1 var(--p2-display) !important;
  transition: background-color 0.15s ease, color 0.15s ease;
}

body.p2 #results .benchmark-axis-controls .benchmark-metric-btn + .benchmark-metric-btn {
  border-left: 1px solid var(--p2-line-strong) !important;
}

body.p2 #results .benchmark-axis-controls .benchmark-metric-btn:hover { background: var(--p2-surface-2) !important; color: var(--p2-ink) !important; }

body.p2 #results .benchmark-axis-controls .benchmark-metric-btn[aria-pressed="true"] {
  background: var(--p2-ink) !important;
  color: #fff !important;
}

body.p2 #results .benchmark-metric-btn:disabled,
body.p2 #results .benchmark-metric-btn:disabled:hover {
  background: transparent !important;
  color: var(--p2-faint) !important;
  opacity: 1 !important;
  cursor: not-allowed !important;
}

/* ---------- chart: flat white plate ---------- */
body.p2 #results .benchmark-chart-wrap {
  min-width: 0;
  border: 1px solid var(--p2-line);
  border-radius: 0 0 0 var(--p2-radius-lg);
  background: var(--p2-surface);
  box-shadow: none;
}

body.p2 #results .benchmark-sweep {
  --bs-grid: rgba(16, 20, 25, 0.055);
  --bs-axis: var(--p2-ink);
}

body.p2 #results .benchmark-sweep .axis-line { stroke-width: 1; }

body.p2 #results .benchmark-sweep .tick-text,
body.p2 #results .benchmark-sweep .chart-note {
  fill: var(--p2-muted);
  font-family: var(--p2-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

body.p2 #results .benchmark-sweep .axis-label {
  fill: var(--p2-ink-2);
  font-family: var(--p2-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.p2 #results .benchmark-sweep .crosshair {
  stroke: var(--p2-faint);
  stroke-dasharray: 3 3;
  opacity: 0.9;
}

body.p2 #results .benchmark-sweep .axis-value-label rect {
  fill: var(--p2-ink);
  stroke: var(--p2-ink);
}

body.p2 #results .benchmark-sweep .axis-value-label text {
  fill: #fff;
  font-family: var(--p2-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

body.p2 #results .benchmark-label-note {
  margin: -4px 16px 12px;
  font: 400 12px/1.4 var(--p2-mono);
  color: var(--p2-muted);
  text-align: left;
}

/* tooltip */
body.p2 #results .benchmark-tooltip {
  min-width: 210px;
  max-width: min(290px, calc(100% - 24px));
  padding: 12px 14px;
  border: 1px solid var(--p2-line-strong);
  border-radius: var(--p2-radius);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 10px 28px -14px rgba(16, 20, 25, 0.28);
  color: var(--p2-ink-2);
  font: 400 12.5px/1.55 var(--p2-display);
}

body.p2 #results .benchmark-tooltip.is-pinned { border-color: var(--p2-ink); }

body.p2 #results .benchmark-tooltip-title {
  margin-bottom: 6px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--p2-line);
  font: 600 13.5px/1.3 var(--p2-display);
  color: var(--p2-ink);
}

body.p2 #results .benchmark-tooltip strong {
  font: 500 12px/1.55 var(--p2-mono);
  color: var(--p2-ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- readout table, right of the chart ---------- */
body.p2 #results .benchmark-table-section {
  display: flex !important;
  flex-direction: column;
  align-self: stretch;
  width: auto !important;
  height: auto !important;
  min-width: 0;
}

body.p2 #results .benchmark-data-table-wrap {
  flex: 1 1 auto;
  height: auto !important;
  overflow-x: auto;
  overflow-y: visible !important;
  border: 1px solid var(--p2-line);
  border-left: 0;
  border-radius: 0 0 var(--p2-radius-lg) 0;
  background: var(--p2-surface);
  box-shadow: none;
}

body.p2 #results .benchmark-data-table-wrap table {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
  border-collapse: collapse;
  font: 400 13px/1.3 var(--p2-display);
  color: var(--p2-ink);
}

body.p2 #results .benchmark-data-table-wrap th,
body.p2 #results .benchmark-data-table-wrap td {
  padding: 0 10px !important;
  border-bottom: 1px solid var(--p2-line);
  text-align: right !important;
  white-space: nowrap;
}

body.p2 #results .benchmark-data-table-wrap th:first-child,
body.p2 #results .benchmark-data-table-wrap td:first-child { width: 37% !important; text-align: left !important; padding-left: 18px !important; }

body.p2 #results .benchmark-data-table-wrap th:nth-child(2),
body.p2 #results .benchmark-data-table-wrap td:nth-child(2) { width: 25% !important; }

body.p2 #results .benchmark-data-table-wrap th:nth-child(3),
body.p2 #results .benchmark-data-table-wrap td:nth-child(3),
body.p2 #results .benchmark-data-table-wrap th:nth-child(4),
body.p2 #results .benchmark-data-table-wrap td:nth-child(4) { width: 19% !important; }

body.p2 #results .benchmark-data-table-wrap th:last-child,
body.p2 #results .benchmark-data-table-wrap td:last-child { padding-right: 18px !important; }

body.p2 #results .benchmark-data-table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 45px;
  border-bottom-color: var(--p2-line-strong);
  background: var(--p2-surface-2);
  color: var(--p2-muted);
  font: 600 12.5px/1.25 var(--p2-display) !important;
  letter-spacing: 0.005em;
  white-space: normal;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

body.p2 #results .benchmark-data-table-wrap th:hover { color: var(--p2-ink); }

body.p2 #results .benchmark-data-table-wrap td {
  height: 35px;
  vertical-align: middle;
  font: 400 13px/1 var(--p2-mono);
  color: var(--p2-ink-2);
  font-variant-numeric: tabular-nums;
}

body.p2 #results .benchmark-data-table-wrap td:nth-child(3) { color: var(--p2-ink); font-weight: 500; }

body.p2 #results .benchmark-data-table-wrap td:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  font: 500 13.5px/1 var(--p2-display);
  color: var(--p2-ink);
}

body.p2 #results .benchmark-data-table-wrap tbody tr { transition: background-color 0.12s ease; }

body.p2 #results .benchmark-data-table-wrap tbody tr:hover { background: var(--p2-surface-2); }

body.p2 #results .benchmark-data-table-wrap tbody tr.is-selected {
  background: var(--p2-accent-soft);
  box-shadow: inset 2px 0 0 var(--p2-accent);
}

body.p2 #results .benchmark-data-table-wrap tbody tr:last-child td { border-bottom: 0; }

body.p2 #results .benchmark-model-cell { gap: 9px; }
body.p2 #results .benchmark-model-cell .benchmark-swatch { width: 8px; height: 8px; }
body.p2 #results .benchmark-model-logo { width: 15px; height: 15px; flex: 0 0 15px; }

/* ---------- model switches ---------- */
body.p2 #results .benchmark-model-panel {
  display: grid !important;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  width: auto !important;
  margin: 24px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.p2 #results .benchmark-panel-title {
  padding-top: 11px;
  font: 500 12px/1 var(--p2-mono);
  letter-spacing: 0.12em;
  color: var(--p2-muted);
}

body.p2 #results .benchmark-model-toggles {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

body.p2 #results .benchmark-model-toggle {
  gap: 9px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--p2-line);
  border-radius: var(--p2-radius);
  background: var(--p2-surface);
  color: var(--p2-ink);
  font: 500 13px/1.2 var(--p2-display);
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

body.p2 #results .benchmark-model-toggle:hover,
body.p2 #results .benchmark-model-toggle:focus-visible {
  border-color: var(--p2-ink);
  background: var(--p2-surface);
}

body.p2 #results .benchmark-model-toggle .benchmark-swatch {
  width: 8px;
  height: 8px;
  border: 1.5px solid currentColor;
  box-sizing: border-box;
}

body.p2 #results .benchmark-model-toggle[aria-pressed="false"] {
  opacity: 1;
  border-style: dashed;
  background: var(--p2-surface-2);
  color: var(--p2-muted);
}

body.p2 #results .benchmark-model-toggle[aria-pressed="false"] .benchmark-swatch { background: transparent; }

body.p2 #results .benchmark-model-toggle[aria-pressed="false"] .benchmark-model-toggle-name {
  text-decoration: line-through;
  text-decoration-color: var(--p2-faint);
}

/* ---------- footnote: a labelled row under the model switches ---------- */
body.p2 #results .benchmark-chart-caption {
  display: grid;
  grid-template-columns: 112px minmax(0, 118ch);
  column-gap: 16px;
  margin: 28px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--p2-line);
  font: 400 13px/1.65 var(--p2-display);
  color: var(--p2-muted);
  text-align: left;
}

body.p2 #results .benchmark-chart-caption::before {
  content: "Notes";
  padding-top: 4px;
  font: 500 12px/1 var(--p2-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--p2-muted);
}
