/*
 * Results explorer (static/js/explorer.js): quality or speed against cost, by method family.
 *
 * Colours, radius and widths are the shared tokens from index.css, and the button groups follow
 * the dark pressed state of the comparison player in compare.css; the "Compare with" toggles,
 * which add families rather than pick one option, are check boxes instead. Method colours come
 * from the data file and reach the legend and table through --ex-method. explorer.js sets
 * --ex-move (the time the points take to glide to a new selection), --ex-fade (the axis
 * cross-fade) and --ex-tip-columns (values per row of the compact tooltip), and adds .is-static
 * while it draws without animation.
 */

.ex {
  --ex-grid: #edf0f1;
  --ex-baseline: #c9ced1;
  --ex-leader: #b3bbbf;
  --ex-check: #9aa3a8;
  width: 100%;
  max-width: var(--hx-wide);
  margin: 0 auto;
  color: var(--hx-ink);
}

/* Controls ----------------------------------------------------------------------------------- */

.ex-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px 24px;
  margin: 0 0 14px;
}

.ex-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.ex-control-label {
  color: var(--hx-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ex-segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--hx-line);
  border-radius: 999px;
  background: var(--hx-line);
}

.ex-segmented button {
  min-height: 32px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  background: var(--hx-surface);
  color: var(--hx-ink);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

@media (hover: hover) {
  .ex-segmented button:hover {
    background: var(--hx-surface-2);
  }
}

.ex-segmented button[aria-pressed="true"] {
  background: var(--hx-dark);
  color: #fff;
}

.ex-segmented button:focus-visible {
  outline: 2px solid var(--hx-select);
  outline-offset: -4px;
}

.ex-segmented button[aria-pressed="true"]:focus-visible {
  outline-color: #fff;
}

.ex-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  color: var(--hx-ink);
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}

.ex-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--hx-dark);
  cursor: pointer;
}

/* "Compare with": a toggle per optional baseline family, a fixed chip per family always shown ---- */

.ex-families {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 16px;
}

.ex-family-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.ex-family {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0;
  padding: 5px 16px 5px 12px;
  border: 1px solid var(--hx-line);
  border-radius: var(--hx-radius);
  background: var(--hx-surface);
  color: var(--hx-ink);
  font: inherit;
  line-height: 1.25;
  text-align: left;
}

button.ex-family {
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

@media (hover: hover) {
  button.ex-family:hover {
    background: var(--hx-surface-2);
  }
}

button.ex-family[aria-pressed="true"] {
  border-color: var(--hx-dark);
  box-shadow: inset 0 0 0 1px var(--hx-dark);
}

button.ex-family:focus-visible {
  outline: 2px solid var(--hx-select);
  outline-offset: 2px;
}

.ex-family.is-fixed {
  background: var(--hx-surface-2);
}

.ex-family-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ex-family-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.ex-family-members {
  color: var(--hx-muted);
  font-size: 0.75rem;
}

.ex-family-check {
  display: block;
  flex: none;
}

.ex-family-box {
  fill: var(--hx-surface);
  stroke: var(--ex-check);
  stroke-width: 1.5;
}

.ex-family-tick {
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

button.ex-family[aria-pressed="true"] .ex-family-box {
  fill: var(--hx-dark);
  stroke: var(--hx-dark);
}

.ex-family.is-fixed .ex-family-box {
  fill: var(--ex-check);
}

button.ex-family[aria-pressed="true"] .ex-family-tick,
.ex-family.is-fixed .ex-family-tick {
  opacity: 1;
}

.ex-family-note {
  flex-basis: 100%;
  margin: 0;
  color: var(--hx-muted);
  font-size: 0.75rem;
  line-height: 1.45;
  text-align: center;
}

/* Chart card: the plot and its legend --------------------------------------------------------- */

.ex-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: center;
  gap: 12px 28px;
  padding: 18px 20px 16px;
  border: 1px solid var(--hx-line);
  border-radius: var(--hx-radius);
  background: var(--hx-surface);
}

.ex-plot {
  position: relative;
  min-width: 0;
}

.ex-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  font-family: var(--hx-font-body);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.ex-grid {
  stroke: var(--ex-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.ex-baseline {
  stroke: var(--ex-baseline);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.ex-tick {
  fill: var(--hx-muted);
  font-variant-numeric: tabular-nums;
}

.ex-axis-title {
  fill: var(--hx-ink);
  font-weight: 600;
}

.ex-cue-text {
  fill: var(--hx-muted);
}

.ex-cue-arrow {
  fill: none;
  stroke: var(--hx-muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ex-axis {
  transition: opacity var(--ex-fade, 300ms) ease;
}

.ex-axis.is-entering,
.ex-axis.is-leaving {
  opacity: 0;
}

/* Points: the hit area is the nearest point within 24 px (explorer.js), not the painted marker.
   Hexels halos sit in their own layer under every marker, so they never hide a baseline. */
.ex-point,
.ex-halo {
  transition: transform var(--ex-move, 600ms) cubic-bezier(0.33, 0, 0.2, 1), opacity 0.2s ease;
}

.ex-point {
  cursor: pointer;
  outline: none;
}

.ex-mark {
  stroke: var(--hx-surface);
  stroke-width: 2;
  stroke-linejoin: round;
}

.ex-halo {
  opacity: 0.18;
  pointer-events: none;
}

.ex-halo.is-dim {
  opacity: 0.04;
}

.ex-ring {
  fill: none;
  stroke: var(--hx-ink);
  stroke-width: 1.5;
  opacity: 0;
  transition: opacity 0.15s;
}

.ex-point.is-target .ex-ring {
  opacity: 0.6;
}

.ex-point:focus-visible .ex-ring {
  stroke: var(--hx-select);
  stroke-width: 2.5;
  opacity: 1;
}

.ex-point.is-dim {
  opacity: 0.2;
}

.ex-point.is-absent,
.ex-halo.is-absent {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ex-point.is-jump,
.ex-halo.is-jump {
  transition: none;
}

/* Direct labels and their leader lines fade out while the points move. */
.ex-labels {
  transition: opacity 0.2s ease;
}

.ex-labels.is-hidden {
  opacity: 0;
  transition-duration: 0.12s;
}

.ex-label {
  display: none;
  fill: var(--hx-muted);
  paint-order: stroke;
  stroke: var(--hx-surface);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.ex-label.is-ours {
  fill: var(--hx-ink);
  font-weight: 600;
}

.ex-leader {
  display: none;
  stroke: var(--ex-leader);
  stroke-width: 1;
  transition: opacity 0.2s ease;
}

.ex-label.is-placed,
.ex-leader.is-placed {
  display: inline;
}

.ex-label.is-dim,
.ex-leader.is-dim {
  opacity: 0.2;
}

.ex.is-static :is(.ex-point, .ex-halo, .ex-axis, .ex-labels, .ex-label, .ex-leader, .ex-ring) {
  transition: none;
}

/* Tooltip ------------------------------------------------------------------------------------ */

.ex-tip {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: max-content;
  min-width: 196px;
  max-width: 264px;
  padding: 9px 12px 8px;
  border: 1px solid var(--hx-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 6px 18px rgba(31, 43, 48, 0.14);
  color: var(--hx-ink);
  font-size: 0.8rem;
  line-height: 1.45;
  pointer-events: none;
}

.ex-tip-name {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 6px;
  font-family: var(--hx-font-title);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}

.ex-tip-values {
  display: grid;
  grid-template-columns: auto auto;
  gap: 1px 16px;
  margin: 0;
}

.ex-tip-values div {
  display: contents;
}

.ex-tip-values dt {
  color: var(--hx-muted);
}

.ex-tip-values dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}

.ex-tip-values .is-plotted dt {
  color: var(--hx-ink);
  font-weight: 600;
}

.ex-tip-meta {
  margin: 6px 0 0;
  padding-top: 5px;
  border-top: 1px solid var(--hx-line);
  color: var(--hx-muted);
  font-size: 0.75rem;
}

/* Compact charts (explorer.js sets .is-compact): a shorter tooltip with the y metrics in one row
   and the x metrics in the next, so it always fits above or below the point. */
.ex.is-compact .ex-tip {
  min-width: 0;
  max-width: calc(100% - 8px);
  padding: 7px 10px 6px;
  font-size: 0.75rem;
  line-height: 1.35;
}

.ex.is-compact .ex-tip-name {
  margin-bottom: 4px;
  font-size: 0.85rem;
}

.ex.is-compact .ex-tip-values {
  grid-template-columns: repeat(var(--ex-tip-columns, 3), auto);
  gap: 4px 12px;
}

.ex.is-compact .ex-tip-values div {
  display: block;
}

.ex.is-compact .ex-tip-values .is-y {
  grid-row: 1;
}

.ex.is-compact .ex-tip-values .is-x {
  grid-row: 2;
}

.ex.is-compact .ex-tip-values dd {
  text-align: left;
}

.ex.is-compact .ex-tip-meta {
  margin-top: 5px;
  padding-top: 4px;
  font-size: 0.7rem;
}

.ex-empty,
.ex-error {
  color: var(--hx-muted);
  font-size: 0.95rem;
  text-align: center;
}

.ex-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: 0;
  transform: translate(-50%, -50%);
}

.ex-error {
  padding: 1.5rem 1rem;
}

/* Legend ------------------------------------------------------------------------------------- */

.ex-legend-group + .ex-legend-group {
  margin-top: 12px;
}

.ex-legend-title {
  margin: 0 0 4px 10px;
  color: var(--hx-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ex-legend-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ex-legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 30px;
  margin: 0;
  padding: 3px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--hx-ink);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

@media (hover: hover) {
  .ex-legend-item:hover {
    background: var(--hx-surface-2);
  }
}

.ex-legend-item[aria-pressed="true"] {
  border-color: var(--ex-method);
  background: color-mix(in srgb, var(--ex-method) 10%, var(--hx-surface));
  font-weight: 600;
}

.ex-legend-item:focus-visible {
  outline: 2px solid var(--hx-select);
  outline-offset: 0;
}

.ex-legend-item.is-absent {
  color: var(--hx-muted);
}

.ex-legend-item.is-absent .ex-swatch {
  opacity: 0.35;
}

.ex-legend-hint {
  margin: 12px 0 0 10px;
  color: var(--hx-muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.ex-swatch {
  display: block;
  flex: none;
}

/* Table -------------------------------------------------------------------------------------- */

.ex-table-block {
  max-width: 1000px;
  margin: 24px auto 0;
}

.ex-table-title {
  margin: 0 0 8px;
  font-family: var(--hx-font-title);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
}

/* Positioned, so the absolutely positioned screen-reader text in the header cells (Bulma .is-sr-only)
   is clipped by this scroller instead of widening the page on phones. */
.ex-table-scroll {
  position: relative;
  overflow-x: auto;
}

.table.ex-table {
  width: 100%;
  margin: 0;
  color: var(--hx-ink);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.table.ex-table th,
.table.ex-table td {
  padding: 6px 12px;
  border-color: var(--hx-line);
  vertical-align: middle;
  white-space: nowrap;
}

.table.ex-table thead th {
  color: var(--hx-muted);
  font-weight: 600;
  line-height: 1.25;
  text-align: right;
  vertical-align: bottom;
}

.table.ex-table thead th:first-child {
  text-align: left;
}

.table.ex-table thead th.is-plotted {
  color: var(--hx-ink);
  box-shadow: inset 0 -2px 0 var(--hx-dark);
}

.ex-th-name,
.ex-th-detail {
  display: block;
}

.ex-th-detail {
  font-size: 0.75rem;
  font-weight: 400;
}

.table.ex-table td {
  position: relative;
  text-align: right;
}

.table.ex-table tbody th {
  font-weight: 400;
}

.table.ex-table .is-best {
  font-weight: 700;
}

.table.ex-table tbody tr.is-ours {
  background: color-mix(in srgb, var(--ex-method) 8%, var(--hx-surface));
}

.table.ex-table tbody tr.is-ours th {
  box-shadow: inset 3px 0 0 var(--ex-method);
  font-weight: 600;
}

.table.ex-table tbody tr.is-active th {
  text-decoration: underline;
  text-decoration-color: var(--ex-method);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* Family heading rows: each baseline family's name in small uppercase letters, kept at the left
   edge while the table scrolls sideways on phones. */
.table.ex-table tbody tr.ex-family-row th {
  padding-top: 14px;
  color: var(--hx-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}

.table.ex-table.is-hoverable tbody tr.ex-family-row:hover {
  background-color: transparent;
}

.ex-family-row span {
  position: sticky;
  left: 7px;
}

.ex-method {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ex-partial,
.ex-dagger {
  color: var(--hx-muted);
  font-weight: 400;
}

.ex-partial {
  margin-left: -7px;
}

/* The dagger hangs in the cell padding, so marked numbers stay aligned with the others. */
.ex-dagger {
  position: absolute;
  top: 4px;
  margin-left: 1px;
}

/* Table notes, footnotes and the disclosure with every definition and note -------------------- */

.ex-table-notes,
.ex-notes {
  color: var(--hx-muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.ex-table-notes {
  margin-top: 8px;
}

.ex-notes {
  max-width: 1000px;
  margin: 10px auto 0;
  text-wrap: pretty;
}

.ex-notes p + p,
.ex-table-notes p + p {
  margin-top: 4px;
}

.ex-notes strong {
  color: var(--hx-ink);
  font-weight: 600;
}

.ex-details {
  margin-top: 8px;
}

.ex-details summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  color: var(--hx-link);
  cursor: pointer;
  list-style: none;
}

.ex-details summary::-webkit-details-marker {
  display: none;
}

.ex-details summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.ex-details[open] summary::before {
  transform: rotate(45deg);
}

.ex-details summary:focus-visible {
  outline: 2px solid var(--hx-select);
  outline-offset: 2px;
  border-radius: 4px;
}

.ex-details-body {
  margin-top: 6px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--hx-surface-2);
}

/* Narrower screens: the legend moves under the plot ------------------------------------------ */

@media (max-width: 1087px) {
  .ex-body {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The legend flows like text under the plot, so entries wrap one by one after their group title. */
  .ex-legend {
    text-align: center;
  }

  .ex-legend-group {
    text-wrap: balance;
  }

  .ex-legend-group + .ex-legend-group {
    margin-top: 2px;
  }

  .ex-legend-title {
    display: inline-block;
    margin: 0 4px 0 0;
    vertical-align: middle;
  }

  .ex-legend-list,
  .ex-legend-list li {
    display: inline;
  }

  .ex-legend-item {
    display: inline-flex;
    width: auto;
    vertical-align: middle;
  }

  .ex-legend-hint {
    margin: 6px 0 0;
  }
}

/* Phones: compact stacked controls, each group's options in one row of equal cells, so that the plot
   starts on the first screen under the section heading; a taller plot and a two-column legend ---- */

@media (max-width: 600px) {
  .ex-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 10px;
  }

  .ex-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
  }

  .ex-control .ex-segmented {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  /* Long names (Tanks and Temples) wrap inside their cell instead of adding a row of cells. */
  .ex-segmented {
    display: grid;
    grid-auto-flow: row;
    grid-template-columns: repeat(var(--ex-count, 3), minmax(0, 1fr));
    border-radius: var(--hx-radius);
  }

  /* Compact cells and checks; touch screens keep 40 px targets (the (pointer: coarse) rules further down). */
  .ex-control .ex-segmented button {
    min-height: 32px;
    padding: 2px 4px;
    font-size: 0.8rem;
    line-height: 1.15;
    white-space: normal;
  }

  .ex-control .ex-check {
    min-height: 24px;
  }

  /* One family per row, so each name and its members get the full width. */
  .ex-families {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    margin-bottom: 10px;
  }

  .ex-family-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .ex-family {
    gap: 8px;
    min-height: 34px;
    padding: 3px 10px 3px 8px;
    line-height: 1.15;
  }

  .ex-family-name {
    font-size: 0.8rem;
  }

  .ex-family-members {
    font-size: 0.72rem;
  }

  .ex-family-note {
    line-height: 1.35;
    text-align: left;
  }

  .ex-body {
    padding: 10px 10px 12px;
  }

  .ex-legend {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    text-align: left;
  }

  .ex-legend-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .ex-legend-title {
    margin: 0 0 0 4px;
  }

  .ex-legend-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 6px;
  }

  .ex-legend-item {
    width: 100%;
    min-height: 36px;
    padding: 3px 6px;
    font-size: 0.8rem;
  }

  .ex-legend-hint {
    text-align: left;
    margin-left: 4px;
  }

  .table.ex-table {
    font-size: 0.8rem;
  }

  .table.ex-table th,
  .table.ex-table td {
    padding: 5px 7px;
  }

  .table.ex-table thead th:first-child,
  .table.ex-table tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--hx-surface);
  }

  .table.ex-table tbody tr.is-ours th {
    background: color-mix(in srgb, var(--ex-method) 8%, var(--hx-surface));
  }
}

/* Touch screens: tap targets of at least 40 px, also over the compact phone sizes above (same specificity, later). */
@media (pointer: coarse) {
  .ex-control .ex-segmented button {
    min-height: 40px;
  }

  .ex-control .ex-check {
    min-height: 40px;
  }

  .ex-check input {
    width: 20px;
    height: 20px;
  }

  .ex-legend-item,
  .ex-details summary {
    min-height: 40px;
  }
}

/* Phones with touch: the compact "Compare with" rows also keep 40 px (wider screens have 44 px). */
@media (max-width: 600px) and (pointer: coarse) {
  .ex-family {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ex-segmented button,
  button.ex-family,
  .ex-point,
  .ex-halo,
  .ex-ring,
  .ex-axis,
  .ex-labels,
  .ex-label,
  .ex-leader,
  .ex-legend-item,
  .ex-details summary::before {
    transition: none;
  }
}
