/* Interactive companions to the paper figures. */
:is(#results-explorer, #selection-explorer) {
  color: var(--ink, #15273e);
}

.rx {
  --rx-border: var(--line, #d8e0ea);
  --rx-paper: var(--surface, #fff);
  --rx-muted: var(--muted, #4f6075);
  --rx-blue: var(--blue, #283593);
  --rx-wash: var(--wash, #f3f6fa);
  --rx-mono: var(--mono, "Roboto Mono", monospace);
  background: var(--rx-paper);
  border: 1px solid var(--rx-border);
  border-radius: 24px;
  overflow: hidden;
}

.rx button,
.rx select {
  font: inherit;
  cursor: pointer;
}

.rx button:focus-visible,
.rx select:focus-visible {
  outline: 2px solid var(--rx-blue);
  outline-offset: 3px;
}

.rx-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
  background: var(--rx-wash);
  border-bottom: 1px solid var(--rx-border);
  padding: .75rem clamp(.65rem, 2.4vw, 1.5rem);
}

.rx-tabs button,
.rx-switches button {
  appearance: none;
  color: var(--rx-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .55rem .85rem;
  font-weight: 650;
  font-size: .9rem;
  line-height: 1.25;
}

.rx-tabs button:hover,
.rx-switches button:hover {
  color: var(--rx-blue);
  border-color: var(--rx-border);
  background: var(--rx-paper);
}

.rx-tabs button[aria-pressed="true"] {
  color: white;
  background: var(--rx-blue);
}

.rx-layout {
  display: grid;
  grid-template-columns: minmax(220px, .75fr) minmax(0, 1.6fr);
}

.rx-reading,
.rx-chart {
  min-width: 0;
  padding: clamp(1rem, 3.2vw, 2.2rem);
}

.rx-reading {
  border-right: 1px solid var(--rx-border);
}

.rx-reading h3 {
  margin: 0 0 .65rem;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  letter-spacing: -.035em;
  line-height: 1.12;
}

.rx-reading > p,
.rx-chart-head p {
  margin: 0;
  color: var(--rx-muted);
  font-size: .96rem;
  line-height: 1.48;
}

.rx-controls {
  display: grid;
  gap: .9rem;
  margin-top: 1.35rem;
}

.rx-field {
  display: grid;
  gap: .4rem;
  min-width: 0;
}

.rx-field > span {
  font-size: .875rem;
  font-weight: 650;
}

.rx-field select {
  width: 100%;
  min-width: 0;
  appearance: none;
  color: inherit;
  border: 1px solid var(--rx-border);
  border-radius: 8px;
  background-color: var(--rx-paper);
  background-image:
    linear-gradient(45deg, transparent 50%, #4f6075 50%),
    linear-gradient(135deg, #4f6075 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding: .56rem 1.7rem .56rem .64rem;
  font-size: .9rem;
}

.rx-switches {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.rx-switches button {
  border-color: var(--rx-border);
}

.rx-switches button[aria-pressed="true"] {
  border-color: #aebbe7;
  background: #eef1fc;
  color: #29378e;
}

.rx-chart {
  display: flex;
  flex-direction: column;
  container: rx-chart / inline-size;
}

.rx-chart-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .2rem .75rem;
  align-items: baseline;
  margin-bottom: .95rem;
}

.rx-chart-head h4 {
  margin: 0;
  font-size: clamp(1.12rem, 1.95vw, 1.39rem);
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.2;
}

.rx-chart-head > span {
  color: var(--rx-blue);
  background: #eef1fc;
  border-radius: 6px;
  padding: .2rem .5rem;
  font-size: .8rem;
  font-family: var(--rx-mono);
  font-weight: 650;
}

.rx-chart-head p {
  grid-column: 1 / -1;
}

.rx-bars {
  --rx-label-width: clamp(7.2rem, 14vw, 10.6rem);
  --rx-value-width: 3.5rem;
  --rx-row-gap: .55rem;
  --rx-bracket-width: clamp(4.6rem, 7vw, 6.25rem);
  margin-bottom: 1rem;
}

/* Keep the bracket gutter outside the common score scale. */
.rx-forecast-bars .rx-bar-axis {
  margin-left: var(--rx-bracket-width);
}

.rx-methods {
  display: grid;
  grid-template-columns: var(--rx-bracket-width) minmax(0, 1fr);
  margin-block: .2rem;
}

.rx-bracket {
  display: flex;
  align-items: center;
  position: relative;
  color: var(--rx-muted);
  padding: .2rem 1.18rem .2rem 0;
  font-size: .78rem;
  font-weight: 640;
  line-height: 1.2;
}

.rx-bracket::after {
  content: "";
  position: absolute;
  inset: .18rem .38rem .18rem auto;
  width: .43rem;
  border: solid #8498b0;
  border-width: 1px 0 1px 1px;
}

.rx-bar-axis,
.rx-bar-row {
  display: grid;
  grid-template-columns: minmax(0, var(--rx-label-width)) minmax(0, 1fr) var(--rx-value-width);
  align-items: center;
  gap: var(--rx-row-gap);
  padding-inline: .18rem;
}

.rx-bar-axis > div {
  grid-column: 2;
  position: relative;
  height: 1.2rem;
}

.rx-bar-axis > .rx-narrow-axis {
  display: none;
}

.rx-bar-axis span,
.rx-x-axis span {
  position: absolute;
  left: var(--tick);
  top: 0;
  transform: translateX(-50%);
  color: var(--rx-muted);
  font: .72rem var(--rx-mono);
  white-space: nowrap;
}

.rx-bar-axis span:first-child {
  transform: none;
}

.rx-bar-axis span:last-child {
  transform: translateX(-100%);
}

.rx-bar-row {
  box-sizing: border-box;
  width: 100%;
  min-height: 2.15rem;
  color: inherit;
  background: transparent;
  border: none;
  border-radius: 6px;
  text-align: left;
}

.rx-bar-row:hover,
.rx-bar-row:focus-visible,
.rx-bar-row[aria-pressed="true"] {
  background: var(--rx-wash);
}

.rx-bar-label {
  font-size: .9rem;
  font-weight: 580;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.rx-bar-row[aria-pressed="true"] .rx-bar-label {
  font-weight: 700;
}

.rx-bar-value {
  text-align: right;
  font: .78rem var(--rx-mono);
  font-variant-numeric: tabular-nums;
}

.rx-bar-track {
  display: flex;
  align-items: center;
  height: 100%;
  min-height: 2.15rem;
  border-inline: 1px solid var(--rx-border);
  background-image: linear-gradient(to right, transparent calc(100% - 1px), var(--rx-border) 0);
  background-size: 20% 100%;
}

.rx-bar {
  box-sizing: border-box;
  width: var(--value);
  height: 1rem;
  border-radius: 0 3px 3px 0;
  background: var(--series);
}

.rx-bar.rx-muted,
.rx-bar.rx-hatched,
.rx-bar.rx-hatched-reverse {
  border: 1px solid var(--series);
  background-color: color-mix(in srgb, var(--series) 42%, white);
}

.rx-bar.rx-hatched,
.rx-bar.rx-hatched-reverse {
  background-image: repeating-linear-gradient(135deg, transparent 0 5px, var(--series) 5px 6px);
}

.rx-bar.rx-hatched-reverse {
  background-image: repeating-linear-gradient(45deg, transparent 0 5px, var(--series) 5px 6px);
}

.rx-group-plot {
  margin-bottom: 1rem;
}

.rx-legend,
.rx-curve-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem 1rem;
}

.rx-legend {
  margin-bottom: 1.15rem;
}

.rx-legend > span {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  color: var(--rx-muted);
}

.rx-legend .rx-bar {
  width: 1.05rem;
  height: .75rem;
  border-radius: 2px;
}

.rx-group-frame {
  --rx-label-height: 2.8rem;
  --rx-group-height: clamp(11rem, 19vw, 14rem);
  position: relative;
  margin-left: 2.5rem;
}

.rx-group-columns {
  display: grid;
  grid-template-columns: repeat(var(--group-count), minmax(0, 1fr));
  gap: clamp(.24rem, .65vw, .62rem);
  position: relative;
}

.rx-category {
  display: grid;
  grid-template-rows: var(--rx-group-height) var(--rx-label-height);
  min-width: 0;
}

.rx-category-bars {
  display: flex;
  justify-content: center;
  gap: 2px;
}

.rx-category-bars button {
  appearance: none;
  display: flex;
  align-items: end;
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 2rem;
  padding: 0;
  border: 0;
  border-radius: 4px 4px 0 0;
  background: transparent;
}

.rx-category-bars button:hover,
.rx-category-bars button:focus-visible {
  background: color-mix(in srgb, var(--rx-wash) 80%, transparent);
  z-index: 1;
}

.rx-category-bars button[aria-pressed="true"] .rx-bar {
  outline: 1px solid var(--series);
  outline-offset: 1px;
}

.rx-category-bars .rx-bar {
  width: 100%;
  height: var(--value);
  min-height: 1px;
  border-radius: 3px 3px 0 0;
}

.rx-category-label {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-width: 0;
  color: var(--rx-muted);
  text-align: center;
  font-size: .75rem;
  font-weight: 620;
  line-height: 1.18;
  padding-top: .48rem;
}
.rx-category-label .predicate-pill { flex: 0 0 auto; padding-inline: .3em; font-size: .69rem; white-space: nowrap; }
.rx-category-label [data-predicate="on_road_high_vel"] { max-width: 100%; white-space: normal; text-wrap: balance; }

.rx-group-grid {
  position: absolute;
  inset: 0 0 var(--rx-label-height);
  border-left: 1px solid var(--rx-border);
}

.rx-group-grid > span {
  position: absolute;
  top: var(--tick);
  width: 100%;
  border-top: 1px solid var(--rx-border);
}

.rx-group-grid > span > span {
  position: absolute;
  right: calc(100% + .4rem);
  top: 0;
  transform: translateY(-50%);
  color: var(--rx-muted);
  font: .72rem var(--rx-mono);
}

.rx-group-axis {
  display: none;
}

.rx-detail {
  min-height: 5.15rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .12rem .6rem;
  align-content: start;
  align-items: baseline;
  background: var(--rx-wash);
  border: 1px solid var(--rx-border);
  border-radius: 10px;
  padding: .65rem .82rem;
}

.rx-detail > span {
  font-size: .96rem;
  font-weight: 680;
  line-height: 1.2;
}

.rx-detail strong {
  color: var(--rx-blue);
  font: 650 .93rem var(--rx-mono);
}

.rx-detail p,
.rx-note {
  color: var(--rx-muted);
  font-size: .86rem;
  line-height: 1.4;
}

.rx-detail p {
  grid-column: 1 / -1;
  margin: .1rem 0 0;
}

.rx-note {
  margin: .7rem 0 0;
}

.rx-curve {
  margin-bottom: .25rem;
}

.rx-curve-legend {
  gap: .32rem;
  margin: 0 0 .65rem;
}

.rx-curve-legend button {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  color: var(--rx-muted);
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  padding: .35rem .52rem;
  font-size: .84rem;
}

.rx-curve-legend button:hover,
.rx-curve-legend button[aria-pressed="true"] {
  color: var(--ink, #15273e);
  border-color: var(--rx-border);
  background: var(--rx-wash);
}

.rx-curve-legend .rx-joint {
  color: var(--ink, #15273e);
  font-weight: 720;
}

.rx-curve-legend i {
  width: 1.15rem;
  border-top: 2px solid var(--series);
  opacity: .64;
}

.rx-curve-legend .rx-joint i,
.rx-curve-legend button[aria-pressed="true"] i {
  opacity: 1;
  border-width: 3px;
}

.rx-curve-area {
  padding: .5rem .85rem .9rem 2.6rem;
}

.rx-curve-plot {
  height: clamp(12rem, 26vw, 17rem);
  position: relative;
}

.rx-curve-plot > svg,
.rx-y-grid,
.rx-x-axis {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.rx-curve polygon {
  fill: #151e2d;
  opacity: .045;
}

.rx-curve polyline {
  fill: none;
  stroke: var(--series);
  stroke-width: 2px;
  opacity: .55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rx-curve polyline.rx-active-series {
  opacity: .86;
  stroke-width: 2.5px;
}

.rx-curve polyline.rx-joint {
  opacity: 1;
  stroke-width: 3.4px;
}

.rx-y-grid > span {
  position: absolute;
  top: var(--tick);
  width: 100%;
  border-top: 1px solid var(--rx-border);
}

.rx-y-grid > span > span {
  position: absolute;
  right: calc(100% + .5rem);
  top: 0;
  transform: translateY(-50%);
  color: var(--rx-muted);
  font: .72rem var(--rx-mono);
}

.rx-x-axis {
  top: calc(100% + .55rem);
  bottom: auto;
  height: .95rem;
}

.rx-curve-plot > button {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
}

.rx-curve-plot > button > span {
  display: block;
  width: .75rem;
  height: .75rem;
  border-radius: 50%;
  border: 2px solid white;
  background: var(--series);
  box-shadow: 0 0 0 1px var(--series);
}

.rx-curve-plot > button:hover > span,
.rx-curve-plot > button:focus-visible > span,
.rx-curve-plot > button[aria-pressed="true"] > span {
  background: var(--gold, #ffca37);
  box-shadow: 0 0 0 2px #15273e;
}

.rx-curve-area > p {
  margin: 1.95rem 0 0;
  text-align: center;
  color: var(--rx-muted);
  font-size: .9rem;
}

@media (max-width: 750px) {
  .rx-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .rx-reading {
    border-right: 0;
    border-bottom: 1px solid var(--rx-border);
  }

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

@media (max-width: 520px) {
  .rx-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .rx-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .rx-tabs button {
    padding-inline: .35rem;
    text-align: center;
  }
}

@container rx-chart (max-width: 40rem) {
  .rx-group-frame {
    --rx-group-label: 6.3rem;
    margin-left: 0;
  }

  .rx-group-grid {
    display: none;
  }

  .rx-group-axis {
    display: block;
    position: relative;
    margin-left: calc(var(--rx-group-label) + .45rem);
    height: 1.1rem;
  }

  .rx-group-axis span {
    position: absolute;
    left: var(--tick);
    transform: translateX(-50%);
    color: var(--rx-muted);
    font: .72rem var(--rx-mono);
  }

  .rx-group-axis span:first-child {
    transform: none;
  }

  .rx-group-axis span:last-child {
    transform: translateX(-100%);
  }

  .rx-group-columns {
    display: flex;
    flex-direction: column;
    gap: .38rem;
  }

  .rx-category {
    grid-template: auto / var(--rx-group-label) minmax(0, 1fr);
    gap: .45rem;
    align-items: center;
  }

  .rx-category-label {
    grid-area: 1 / 1;
    justify-content: flex-start;
    text-align: left;
    padding: 0;
  }

  .rx-category-bars {
    grid-column: 2;
    flex-direction: column;
    gap: 0;
    border-inline: 1px solid var(--rx-border);
    background-image: linear-gradient(to right, transparent calc(100% - 1px), var(--rx-border) 0);
    background-size: 50% 100%;
  }

  .rx-category-bars button {
    width: 100%;
    max-width: none;
    min-height: 1.22rem;
    align-items: center;
  }

  .rx-category-bars .rx-bar {
    width: var(--value);
    min-width: 1px;
    height: .74rem;
    border-radius: 0 3px 3px 0;
  }
}

@container rx-chart (max-width: 29rem) {
  .rx-bars {
    --rx-bracket-width: 3.35rem;
    --rx-label-width: clamp(4.2rem, 22cqw, 6.15rem);
    --rx-value-width: 2.75rem;
    --rx-row-gap: .22rem;
  }

  .rx-bracket {
    padding-right: .68rem;
    font-size: .67rem;
  }

  .rx-bracket::after {
    width: .28rem;
    right: .23rem;
  }

  .rx-bar-label {
    font-size: .81rem;
  }

  .rx-bar-axis > .rx-wide-axis {
    display: none;
  }

  .rx-bar-axis > .rx-narrow-axis {
    display: block;
  }

  .rx-bar-track {
    background-size: 50% 100%;
  }
}
