/* ==========================================================================
   Swipe actions — swipe a row to show its buttons, like in mail apps.

   <div class="swipe-item" data-moey-swipe>
     <div class="swipe-content">…the row…</div>
     <div class="swipe-start"><button class="swipe-action theme-blue"><i class="mi mi-mail-open"></i>Read</button></div>
     <div class="swipe-end">
       <button class="swipe-action theme-amber"><i class="mi mi-archive"></i>Archive</button>
       <button class="swipe-action theme-red" data-moey-swipe-full><i class="mi mi-trash-2"></i>Delete</button>
     </div>
   </div>

   .swipe-start shows when the row is swiped toward the end (→ in left-to-right), .swipe-end the
   other way. data-moey-swipe-full on an action: a long swipe presses it. Tabbing to an action
   opens its side, so everything works without swiping too.
   ========================================================================== */

.swipe-item {
  --mo-swipe-bg: var(--mo-bg-surface);
  position: relative;
  overflow: hidden;
  touch-action: pan-y;                       /* up/down still scrolls the page */
  user-select: none;
  -webkit-user-select: none;
}
.swipe-content :is(a, img) { -webkit-user-drag: none; }
.swipe-content {
  position: relative;
  z-index: 1;
  background: var(--mo-swipe-bg);
  transition: translate .28s cubic-bezier(.2, 0, 0, 1);
}
.swipe-item.is-dragging .swipe-content { transition: none; }
.swipe-item.is-open .swipe-content { box-shadow: 0 0 0 1px var(--mo-border-color); }
.swipe-start,
.swipe-end {
  position: absolute;
  inset-block: 0;
  z-index: 0;
  display: flex;
  overflow: hidden;
}
.swipe-start { inset-inline-start: 0; }
.swipe-end { inset-inline-end: 0; justify-content: flex-end; }
.swipe-action {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: .25rem;
  align-items: center;
  justify-content: center;
  min-width: 4.75rem;
  padding: 0 .75rem;
  font: inherit;
  font-size: .75rem;
  font-weight: var(--mo-font-weight-semibold);
  color: var(--mo-theme-strong-contrast, var(--mo-white));
  white-space: nowrap;
  cursor: pointer;
  background: var(--mo-theme-strong, var(--mo-gray-600));
  border: 0;
  outline: none;
  transition: flex-grow .2s var(--mo-ease), min-width .2s var(--mo-ease);
}
.swipe-action > .mi { font-size: 1.25rem; }
.swipe-action:focus-visible { box-shadow: inset 0 0 0 3px var(--mo-theme-strong-contrast, var(--mo-white)); }
.swipe-action:active { filter: brightness(.92); }
/* A long swipe: the full-swipe action takes all the room it is given */
.swipe-item.is-full :is(.swipe-start, .swipe-end) > [data-moey-swipe-full] { flex-grow: 1; }
.swipe-item.is-full :is(.swipe-start, .swipe-end) > :not([data-moey-swipe-full]) { min-width: 0; padding: 0; overflow: hidden; flex-basis: 0; }
/* Gone after a full swipe (until the app removes the row or puts it back) */
.swipe-item.is-leaving { transition: height .25s var(--mo-ease), opacity .25s var(--mo-ease); }
@media (prefers-reduced-motion: reduce) {
  .swipe-content, .swipe-action, .swipe-item.is-leaving { transition: none; }
}
/* In a list group: rows keep their dividers */
.list-group > .swipe-item:not(:last-child) { border-bottom: var(--mo-border-width, 1px) solid var(--mo-border-color); }
.list-group > .swipe-item > .swipe-content > .list-group-item { border: 0; }
