/* ==========================================================================
   Sortable — drag items of any list to reorder them (data-moey-sortable).

   <ul class="list-group" data-moey-sortable>
     <li class="list-group-item" data-id="a"><span class="sort-handle"></span>Write the brief</li> …
   </ul>

   With a .sort-handle in the items only the handle drags (and starts at once on touch);
   without, the whole item drags (press and hold on touch).
   ========================================================================== */

.is-sortable > * { -webkit-touch-callout: none; }
.is-sortable:not(:has(.sort-handle)) > * { cursor: grab; user-select: none; -webkit-user-select: none; }
.sort-handle {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  margin-inline: -.375rem .125rem;
  color: var(--mo-fg-3);
  cursor: grab;
  touch-action: none;                        /* a drag on the handle never scrolls */
  user-select: none;
  border-radius: var(--mo-radius-control);
  outline: none;
}
.sort-handle:empty::before {
  width: .75rem;
  height: 1.125rem;
  content: "";
  /* six dots */
  background: radial-gradient(circle, currentcolor 1.5px, transparent 1.6px) 0 0 / 6px 6px;
}
.sort-handle:hover { color: var(--mo-fg-body); background: color-mix(in oklab, var(--mo-fg-body) 6%, transparent); }
.sort-handle:focus-visible { box-shadow: 0 0 0 var(--mo-focus-ring-width) var(--mo-theme-focus-ring); }
.is-sortable > :focus-visible { outline: var(--mo-focus-ring-width) solid var(--mo-theme-focus-ring); outline-offset: -2px; }

/* The item's place while it is dragged, picked up with the keyboard, or pressed (touch) */
.is-sortable > .is-sorting { background: color-mix(in oklab, var(--mo-fg-body) 5%, transparent) !important; box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--mo-fg-body) 14%, transparent); }
.is-sortable > .is-sorting > *,
tr.is-sorting > td > * { visibility: hidden; }
.is-sortable > .is-grabbed { position: relative; z-index: 1; box-shadow: 0 0 0 2px var(--mo-default-base), var(--mo-shadow-overlay); }
.is-sortable > .is-pressing { scale: .985; transition: scale .2s var(--mo-ease); }

/* Under the pointer */
.sort-ghost {
  position: fixed;
  z-index: var(--mo-z-tooltip, 1080);
  margin: 0;
  pointer-events: none;
  background: var(--mo-bg-raised);
  border-radius: var(--mo-radius-control);
  box-shadow: var(--mo-shadow-overlay);
  list-style: none;
  scale: 1.02;
}
table.sort-ghost { border-collapse: collapse; }
html.mo-sorting, html.mo-sorting * { cursor: grabbing !important; user-select: none !important; }
@media (prefers-reduced-motion: reduce) { .is-sortable > .is-pressing, .sort-ghost { scale: none; transition: none; } }
/* An emptied list keeps a drop area (lists that share items) */
.is-sortable:not(:has(> :not(.sort-ghost, template, script, .visually-hidden))) {
  min-height: 3rem;
  border-radius: var(--mo-radius-control);
  box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--mo-fg-body) 14%, transparent);
}
