/* 141 — FLIP Reorder
   Liste verticale réordonnable. L'item saisi suit le pointeur (transform
   inline posé par anim.js) ; à chaque changement d'ordre, les autres items
   sont réordonnés dans le DOM puis animés en FLIP : transform inverse posé
   sans transition, puis transition vers 0 — aucun saut de layout. */

.flip-reorder {
  width: min(320px, 100%);
}

.flip-reorder__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flip-reorder__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--ml-surface, #151a24);
  border: 1px solid rgba(139, 145, 163, 0.16);
  border-radius: 12px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: grab;
  will-change: transform;
  /* transition FLIP des items qui font de la place */
  transition:
    transform 0.28s cubic-bezier(0.25, 0.8, 0.3, 1),
    box-shadow 0.28s ease,
    border-color 0.2s ease;
}

.flip-reorder__item:hover {
  border-color: rgba(124, 140, 255, 0.32);
}

/* — Item saisi : soulevé, transform piloté par le JS sans transition — */
.flip-reorder__item.is-dragging {
  transition: box-shadow 0.22s ease, border-color 0.22s ease;
  z-index: 2;
  cursor: grabbing;
  border-color: rgba(124, 140, 255, 0.45);
  box-shadow:
    0 16px 32px -14px rgba(4, 7, 16, 0.9),
    0 0 0 1px rgba(124, 140, 255, 0.22);
}

/* — Settle au drop : retour vers 0 avec léger overshoot élastique — */
.flip-reorder__item.is-settling {
  z-index: 2;
  transition:
    transform 0.45s cubic-bezier(0.28, 1.5, 0.35, 1),
    box-shadow 0.4s ease,
    border-color 0.35s ease;
}

/* — Poignée ⋮⋮ (focusable, cible clavier) — */
.flip-reorder__handle {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  flex: none;
  color: var(--ml-muted, #8b91a3);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: grab;
  touch-action: none;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.flip-reorder__handle:hover {
  color: var(--ml-fg, #e8eaf2);
  background: rgba(139, 145, 163, 0.14);
}

.flip-reorder__handle:focus-visible {
  outline: none;
  color: var(--ml-fg, #e8eaf2);
  box-shadow:
    0 0 0 2px var(--ml-bg, #0d1017),
    0 0 0 4px var(--ml-accent, #7c8cff);
}

.flip-reorder__handle svg {
  width: 10px;
  height: 14px;
}

/* — Contenu — */
.flip-reorder__dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 999px;
  background: var(--ml-accent, #7c8cff);
}

.flip-reorder__dot--teal { background: var(--ml-accent-2, #2dd4bf); }
.flip-reorder__dot--warm { background: #f2a65a; }
.flip-reorder__dot--rose { background: #f27da8; }

.flip-reorder__title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ml-fg, #e8eaf2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flip-reorder__badge {
  flex: none;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ml-muted, #8b91a3);
  background: rgba(139, 145, 163, 0.12);
  border-radius: 999px;
}

.flip-reorder__hint {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ml-muted, #8b91a3);
  opacity: 0.75;
  text-align: center;
}

/* — Région live pour lecteurs d'écran — */
.flip-reorder__live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* — Reduced motion : réordonnancement instantané, drag fonctionnel — */
@media (prefers-reduced-motion: reduce) {
  .flip-reorder__item,
  .flip-reorder__item.is-dragging,
  .flip-reorder__item.is-settling,
  .flip-reorder__handle {
    transition: none;
  }
}
