/* ===========================================================================
   rank-explorer.css -- chapter 13's draggable scatterplot with preset
   patterns, covariance, Pearson's r and Spearman's r_s
   (assets/js/rank-explorer.js).

   The container carries `dx cx rkx`: the preset buttons come from the .dx
   rules in dist-explorer.css, the frame and text from the .cx rules in
   calc-explorer.css. Defined here: the small pictures on the preset
   buttons, the line of values (numbers in UW purple), the light grid, the
   points with their larger touch targets, their glide, and the focus ring.
   The point colour comes from R (RKDATA.colors) as a css variable on the
   svg; the static PDF figure uses the same one (chunk
   correlation-drag-static).

   Nothing here is needed by the PDF build; the LaTeX format never loads css.
   =========================================================================== */

/* The panel spans the text column, edge to edge; the script widens the svg's
   x axis to match, so its text keeps the static figures' sizes. */
.cx.rkx { max-width: none; }

/* preset buttons: one row, centred; small, with the pattern's points above
   the name. The points take the button's text colour, so they turn white on
   the selected one. A column too narrow for the row scrolls it sideways
   (the auto margins centre it without cutting off its left end). */
.rkx .rkx-tabs {
  flex-wrap: nowrap; gap: 0.2rem; margin-bottom: 0;
  overflow-x: auto; scrollbar-width: thin;
}
.rkx .rkx-tab:first-child { margin-left: auto; }
.rkx .rkx-tab:last-child  { margin-right: auto; }
.rkx .rkx-tab {
  flex: none; display: inline-flex; flex-direction: column; align-items: center;
  gap: 0.12rem; padding: 0.22rem 0.32rem 0.2rem;
  font-size: 0.72em; white-space: nowrap;
}
.rkx .rkx-thumb { display: block; }
.rkx .rkx-thumb circle { fill: currentColor; fill-opacity: 0.45; }
.rkx .rkx-tab.dx-on .rkx-thumb circle { fill-opacity: 0.8; }

/* the values, midway between the buttons and the plot's frame: the frame
   starts 6 px into the svg (geo.MT), so the bottom margin is 6 px less */
.rkx .rkx-read { margin: 0.5rem 0 calc(0.5rem - 6px); text-align: center; }
.rkx .rkx-read b { color: #32006e; font-weight: 600; font-variant-numeric: tabular-nums; }

/* the plot takes 90% of the panel, centred; the script reads this width */
.rkx .cx-plot { width: 90%; margin: 0 auto; }

/* the plot has no text: grid lines only, since the scale is made up */
.rkx svg .rkx-grid { stroke: #ebebeb; stroke-width: 1; }

/* a point: the dot, and a larger invisible circle that takes the pointer;
   placed by a css transform in svg units, which glides between presets */
.rkx svg .rkx-pt {
  cursor: grab; touch-action: none; outline: none;
  transform-box: view-box; transform-origin: 0 0;
  transition: transform 0.5s ease;
}
.rkx.rkx-drag svg .rkx-pt { transition: none; }
.rkx svg .rkx-pt.rkx-on { cursor: grabbing; }
.rkx svg .rkx-hit { fill: #fff; fill-opacity: 0; }
.rkx svg .rkx-dot { fill: var(--rkx-dot); stroke: #fff; stroke-width: 1; }
.rkx svg .rkx-pt.rkx-on .rkx-dot,
.rkx svg .rkx-pt:focus-visible .rkx-dot { stroke: #c9b6e6; stroke-width: 3; }

@media (prefers-reduced-motion: reduce) {
  .rkx svg .rkx-pt { transition: none; }
}

@media print { .rkx { display: none; } }
