/*
 * Row states shared by every Next list row (AUDIT §6 point 20): `.dx-row` carries hover, highlight, selection,
 * current, disabled, drag and drop states, keyed on the attributes Ark's listbox and the reorder hook set; each row type
 * keeps its own class for layout. States take ui-theme's tokens as the current react-ui-list rows do.
 */

@layer dx-components {
  .dx-row {
    position: relative;
    /* Keeps the ring overlay's stacking inside the row, under sticky headers and popups. */
    isolation: isolate;
    border-radius: var(--radius-sm, 0.25rem);
    cursor: default;
  }
  /* Rows that run edge to edge would show their rounding against the container's own edges. */
  .dx-container[data-gutter='none'] > .dx-row {
    border-radius: 0;
  }
  .dx-row[data-selectable] {
    cursor: pointer;
  }
  /* A row is a large target, so it takes the subtle region hover rather than a control's. */
  .dx-row[data-selectable]:hover,
  .dx-row[data-highlighted] {
    background: var(--color-hover-surface-subtle);
  }
  /* `data-selected` too: a tree branch's `aria-selected` lands on its `display: contents` wrapper, not the row. */
  .dx-row:is([aria-selected='true'], [data-selected]) {
    background: var(--color-selected-surface);
  }
  .dx-row:is([aria-selected='true'], [data-selected]):hover {
    background: var(--color-selected-surface-hover);
  }
  .dx-row[aria-current='true'] {
    background: var(--color-current-surface);
  }
  .dx-row[data-disabled] {
    opacity: 0.5;
    cursor: default;
  }

  /*
   * The keyboard's row: ringed while it has visible focus itself (Tree), or while its list does (Listbox). The ring is
   * an overlay above the row's parts, since an inset shadow on the row is painted under them and an avatar or control
   * at the row's edge would hide that stretch of it.
   */
  .dx-row:focus-visible {
    outline: none;
  }
  .dx-row:focus-visible::before,
  [role='listbox']:focus-visible > .dx-row[data-highlighted]::before,
  [role='listbox']:focus-visible > * > .dx-row[data-highlighted]::before,
  /* The current row is the one the list's keys act on, so it is ringed whenever the list has focus, a click included. */
  [role='listbox']:focus-within > .dx-row[aria-current='true']::before,
  [role='listbox']:focus-within > * > .dx-row[aria-current='true']::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
    box-shadow: inset 0 0 0 var(--dx-focus-ring-width) var(--dx-focus-ring-color);
    pointer-events: none;
  }

  /* The source row stays in place, dimmed, while its preview is dragged. Not the parts of zag controls whose drag is a
     gesture rather than a moved row: zag marks every part `data-dragging` while a splitter seam or slider thumb is
     pulled, and they must stay as they are. */
  [data-dragging]:not([data-scope='splitter'], [data-scope='slider'], [data-scope='angle-slider']) {
    opacity: 0.5;
  }

  /* The edge a dragged row will land on, drawn by the target row itself from `data-drop-target` (useReorder). */
  [data-drop-target] {
    position: relative;
  }
  /* `inside` (a tree branch) is drawn by its own row type. */
  :is([data-drop-target='top'], [data-drop-target='bottom'])::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    height: var(--dx-drop-indicator-width);
    background: var(--dx-drop-indicator-color);
    pointer-events: none;
  }
  [data-drop-target='top']::after {
    top: calc(var(--dx-drop-indicator-width) / -2);
  }
  [data-drop-target='bottom']::after {
    bottom: calc(var(--dx-drop-indicator-width) / -2);
  }

  /* `virtual='variable'`: every row mounts, and the browser skips the layout of rows out of view. */
  [data-virtual='variable'] > :not([data-virtual-spacer]) {
    content-visibility: auto;
    contain-intrinsic-block-size: auto var(--dx-block-size);
  }
}
