/* 04_VISUAL/xwui/xwui-lib/xwui-lib-basic/src/action/XWUISwipeRow/XWUISwipeRow.css */
/*
 * Tokens only. Sizes come from the Mobile artboard (row 1): a 76 wide action, glyph 17, caption 11/600, 4 between
 * them, flush to the row with no border and no radius, hairline under the row. Every px value lives in a custom-property
 * definition. Direction: logical properties and flex order only, so RTL mirrors with no extra rule (a start strip
 * sits at the inline start, and the JS converts the pointer into inline px).
 *
 * How the reveal is drawn: the strips are flex siblings of the content and their width IS the revealed amount, driven
 * by ONE custom property (--xwui-swipe-row-offset, a signed unitless number the adapter writes per frame while
 * dragging and at rest). Open therefore gives the artboard's exact box (content 314 + action 76 = 390), not a
 * translated row with its start cut off; the buttons stay anchored to the outer edge and the content edge sweeps over
 * them. A drag costs layout of one row only.
 */

/* WHY :where(): zero specificity for the structural rules, so a page utility on the same element wins. */
:where(.xwui-swipe-row) {
  --xwui-swipe-row-icon: calc(var(--spacing-unit) * 4.25);
  --xwui-swipe-row-gap: var(--spacing-unit);
  --xwui-swipe-row-font: calc(var(--font-size-base) * 0.6875);
  --xwui-swipe-row-weight: var(--font-weight-semibold);
  --xwui-swipe-row-pad: calc(var(--spacing-unit) * 1.5);
  --xwui-swipe-row-divider-w: calc(var(--spacing-unit) * 0.25);
  --xwui-swipe-row-divider-color: var(--border-color, transparent);
  --xwui-swipe-row-focus-w: calc(var(--spacing-unit) * 0.5);
  --xwui-swipe-row-ease: var(--motion-easing-decelerate);
  /* The offset and the button width are unitless numbers; this is the one place they get a unit. */
  --xwui-swipe-row-unit: 1px;
  /* The touch-target floor (DESIGN.md): the buttons need a glyph, a caption and room around them even for a one-line row. */
  --xwui-swipe-row-min-height: calc(var(--spacing-unit) * 11);

  position: relative;
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  inline-size: 100%;
  min-inline-size: 0;
  min-block-size: var(--xwui-swipe-row-min-height);
  /* clip, not hidden: hidden is still scrollable by a focus() on a clipped button, which would shift the row. */
  overflow: hidden;
  overflow: clip;
  /* pan-y: the browser keeps vertical scrolling and hands every horizontal move to the row. */
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}
.xwui-swipe-row--divider {
  border-block-end: var(--xwui-swipe-row-divider-w) solid
    var(--xwui-swipe-row-divider-color);
}
.xwui-swipe-row:focus {
  outline: none;
}
/* A disabled row has no horizontal gesture to protect, so the browser may pan it any way. */
.xwui-swipe-row--disabled {
  touch-action: auto;
}
.xwui-swipe-row[data-dragging="true"] {
  -webkit-user-select: none;
          user-select: none;
}

/* ---------- content: the host-owned slot ---------- */
.xwui-swipe-row__content {
  order: 0;
  display: flex;
  flex: 1 1 0;
  align-items: stretch;
  min-inline-size: 0;
}
.xwui-swipe-row__content > * {
  flex: 1 1 auto;
  min-inline-size: 0;
}

/* ---------- strips: width is the revealed amount ---------- */
.xwui-swipe-row__strip {
  display: flex;
  flex: none;
  align-self: stretch;
  box-sizing: border-box;
  overflow: hidden;
  overflow: clip;
  inline-size: 0;
  transition: inline-size var(--motion-duration-fast) var(--xwui-swipe-row-ease);
}
.xwui-swipe-row__strip--start {
  order: -1;
  justify-content: flex-start;
  inline-size: calc(
    max(var(--xwui-swipe-row-offset, 0), 0) * var(--xwui-swipe-row-unit)
  );
}
.xwui-swipe-row__strip--end {
  order: 1;
  justify-content: flex-end;
  inline-size: calc(
    max(var(--xwui-swipe-row-offset, 0) * -1, 0) * var(--xwui-swipe-row-unit)
  );
}
/* The finger drives the width while dragging: no transition, or the row would lag behind it. */
.xwui-swipe-row[data-dragging="true"] .xwui-swipe-row__strip {
  transition: none;
}
@media (prefers-reduced-motion: reduce) {
  .xwui-swipe-row__strip {
    transition: none;
  }
}

/* ---------- actions: a column of glyph over caption ---------- */
.xwui-swipe-row .xwui-swipe-row__action {
  --xwui-swipe-row-action-bg: var(--accent-primary, currentcolor);
  --xwui-swipe-row-action-ink: var(--accent-primary-ink, inherit);

  box-sizing: border-box;
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--xwui-swipe-row-gap);
  inline-size: calc(
    var(--xwui-swipe-row-action-w, 76) * var(--xwui-swipe-row-unit)
  );
  margin: 0;
  padding: 0 var(--xwui-swipe-row-pad);
  border: 0;
  border-radius: 0;
  background-color: var(--xwui-swipe-row-action-bg);
  color: var(--xwui-swipe-row-action-ink);
  font-family: inherit;
  font-size: var(--xwui-swipe-row-font);
  font-weight: var(--xwui-swipe-row-weight);
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.xwui-swipe-row .xwui-swipe-row__action--neutral {
  --xwui-swipe-row-action-bg: var(--bg-active, transparent);
  --xwui-swipe-row-action-ink: var(--text-primary, inherit);
}
.xwui-swipe-row .xwui-swipe-row__action--danger {
  --xwui-swipe-row-action-bg: var(--accent-error, currentcolor);
  --xwui-swipe-row-action-ink: var(--accent-primary-ink, inherit);
}
/* success and warning use the theme's readable tag pairs: white on the solid green or amber fails contrast at this size. */
.xwui-swipe-row .xwui-swipe-row__action--success {
  --xwui-swipe-row-action-bg: var(--color-tag-green-bg, transparent);
  --xwui-swipe-row-action-ink: var(--color-tag-green-text, inherit);
}
.xwui-swipe-row .xwui-swipe-row__action--warning {
  --xwui-swipe-row-action-bg: var(--color-tag-orange-bg, transparent);
  --xwui-swipe-row-action-ink: var(--color-tag-orange-text, inherit);
}
@supports (color: color-mix(in srgb, red 50%, transparent)) {
  .xwui-swipe-row .xwui-swipe-row__action:not(:disabled):hover,
  .xwui-swipe-row .xwui-swipe-row__action:not(:disabled):active {
    background-image: linear-gradient(
      color-mix(in srgb, var(--xwui-swipe-row-action-ink) 14%, transparent),
      color-mix(in srgb, var(--xwui-swipe-row-action-ink) 14%, transparent)
    );
  }
}
/* Inset: the strip clips, so an outside outline would be cut off on three sides. */
.xwui-swipe-row .xwui-swipe-row__action:focus-visible {
  outline: var(--xwui-swipe-row-focus-w) solid
    var(--control-active, currentcolor);
  outline-offset: calc(var(--xwui-swipe-row-focus-w) * -1);
}
.xwui-swipe-row .xwui-swipe-row__action:disabled {
  cursor: not-allowed;
}

.xwui-swipe-row .xwui-swipe-row__icon {
  display: inline-grid;
  flex: none;
  place-items: center;
  inline-size: var(--xwui-swipe-row-icon);
  block-size: var(--xwui-swipe-row-icon);
  pointer-events: none;
}
.xwui-swipe-row .xwui-swipe-row__icon > xwui-icon {
  display: block;
  inline-size: 100%;
  block-size: 100%;
}
.xwui-swipe-row .xwui-swipe-row__label {
  max-inline-size: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

/* ---------- polite status line: out of sight, in the accessibility tree ---------- */
.xwui-swipe-row__live {
  position: absolute;
  inline-size: calc(var(--spacing-unit) * 0.25);
  block-size: calc(var(--spacing-unit) * 0.25);
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* High-contrast mode drops author fills: keep the actions visibly delimited. */
@media (forced-colors: active) {
  .xwui-swipe-row .xwui-swipe-row__action {
    border: var(--xwui-swipe-row-divider-w) solid ButtonText;
  }
}
