/* Shared record-selection contract for every module at mind.arx.hk.
   Load after module CSS. Native controls, field origins, navigation and status
   badges retain their own colors. See docs/ARX_BRAND.md. */

/* Tables: whole row on the soft blue tint, strong blue edge on the first cell,
   thin connecting rules; never recolors input fills. Inset rules preserve row
   height and survive collapsed table borders. Selection wins over row tones
   (e.g. MIND .pcb-tone-*), which are written with :where() so this sheet's
   specificity is higher. */
table tbody tr:is(.row-selected, .is-selected, .tm-selected-row, [aria-selected="true"], [data-arx-selected="true"]) {
  --arx-record-identity-bg: var(--arx-selection-soft);
}
table tbody tr:is(.row-selected, .is-selected, .tm-selected-row, [aria-selected="true"], [data-arx-selected="true"]) > td {
  background-color: var(--arx-selection-soft);
  box-shadow: inset 0 1px 0 var(--arx-selection-border), inset 0 -1px 0 var(--arx-selection-border);
}
table tbody tr:is(.row-selected, .is-selected, .tm-selected-row, [aria-selected="true"], [data-arx-selected="true"]) > td:first-child {
  background-color: var(--arx-selection-soft);
  box-shadow: var(--arx-selection-edge);
}
table tbody tr:is(.row-selected, .is-selected, .tm-selected-row, [aria-selected="true"], [data-arx-selected="true"]) > td:last-child {
  border-right: 1px solid var(--arx-selection-border);
}

/* Record lists/cards and category selectors; not module navigation or tabs.
   Future Purchasing views opt in with arx-selection-item + data-arx-selected. */
:is(.arx-selection-item[data-arx-selected="true"], .og-category[aria-pressed="true"], .ow-card.is-selected,
    .cat-row.is-active, .tree-leaf.is-active, .round-row.is-active, .cust-row.is-active,
    .tree-node.is-selected > .tree-row, .ss-option.selected) {
  background-color: var(--arx-selection-soft);
  color: var(--arx-selection-text);
  box-shadow: var(--arx-selection-edge);
}
.ow-card.is-selected { border-color: var(--arx-selection-border); }
.ss-option.selected { color: var(--arx-selection-text); }

/* Existing Offers descendants used white on the old blue selection fill. */
:is(.cat-row.is-active, .tree-leaf.is-active, .round-row.is-active, .cust-row.is-active,
    .tree-node.is-selected > .tree-row) {
  --on-accent: var(--arx-selection-text);
  --on-accent-2: var(--arx-selection-secondary);
}
:is(.cat-row.is-active, .tree-leaf.is-active, .round-row.is-active, .cust-row.is-active):focus-visible {
  outline-color: var(--arx-blue-ink);
}
.round-row.is-active .rr-expiry .in.is-soon, .cust-row.is-active .cr-note .warn { color: var(--amber); }
.round-row.is-active .rr-expiry .in.is-past, .cust-row.is-active .cr-note .bad { color: var(--red); }
:is(.round-row.is-active, .cust-row.is-active) .status.st-green { color: var(--green); }
:is(.round-row.is-active, .cust-row.is-active) .status.st-amber { color: var(--amber); }
:is(.round-row.is-active, .cust-row.is-active) .status.st-red { color: var(--red); }
:is(.round-row.is-active, .cust-row.is-active) .status.st-accent { color: var(--accent-ink); }

/* A shape remains visible in forced-colors mode, independent of the tint. */
@media (forced-colors: active) {
  table tbody tr:is(.row-selected, .is-selected, .tm-selected-row, [aria-selected="true"], [data-arx-selected="true"]),
  :is(.arx-selection-item[data-arx-selected="true"], .og-category[aria-pressed="true"], .ow-card.is-selected,
      .cat-row.is-active, .tree-leaf.is-active, .round-row.is-active, .cust-row.is-active,
      .tree-node.is-selected > .tree-row, .ss-option.selected) {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}
