/* Charts and the live benchmark for the reverse-loop article. Scoped to .rl. */
.rl {
  --rl-fwd: #3987e5;
  --rl-rev: #d95926;
  --rl-other: rgb(242 241 238 / 0.38);
  margin: 1.5rem 0;
  padding: 1.25rem;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--ink);
  font-family: var(--font-body);
  position: relative;
}

.rl__title {
  margin: 0 0 1rem;
  font-family: var(--font-label);
  font-size: var(--fs-label);
  letter-spacing: var(--tracking-label, 0.08em);
  text-transform: uppercase;
  color: var(--muted);
}

.rl__plot {
  position: relative;
  width: 100%;
}

.rl__plot svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.rl__plot text {
  fill: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
}

.rl__plot .rl-label {
  fill: var(--ink);
  font-size: 13px;
}

.rl__plot .rl-value {
  fill: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.rl__plot .rl-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.rl__plot .rl-axis {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.rl__plot .rl-hit {
  fill: transparent;
  cursor: default;
}

.rl__plot .rl-row:hover .rl-bar,
.rl__plot .rl-row:focus .rl-bar {
  opacity: 0.8;
}

.rl__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0 0 0.75rem;
  font-size: var(--fs-small);
  color: var(--muted);
}

.rl__legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.rl__legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.rl__tip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  min-width: 9rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line-strong);
  background: var(--bg-sunken);
  color: var(--ink);
  font-size: var(--fs-small);
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--t-fast, 140ms);
}

.rl__tip.is-on {
  opacity: 1;
}

.rl__tip b {
  font-weight: 600;
}

.rl__tip .rl-sw {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 0.35rem;
  border-radius: 2px;
}

.rl__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 0 0 1rem;
  border: 1px solid var(--line);
  width: fit-content;
  max-width: 100%;
}

.rl__tabs button,
.rl__run {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-small);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}

.rl__tabs button + button {
  border-left: 1px solid var(--line);
}

.rl__tabs button[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--ink);
}

.rl__tabs button:focus-visible,
.rl__run:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rl__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.rl__run {
  border: 1px solid var(--accent);
  color: var(--ink);
}

.rl__run:hover:not(:disabled) {
  background: var(--accent-soft);
}

.rl__run:disabled {
  opacity: 0.5;
  cursor: progress;
}

.rl__status {
  font-size: var(--fs-small);
  color: var(--muted);
}
