/* Drag-and-drop reorder — shadcn-token aligned (load themes.css / page tokens first) */

.pls-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: var(--radius, 0.5rem);
  background: rgb(var(--muted) / 0.35);
  color: rgb(var(--muted-foreground));
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.pls-drag-handle:hover {
  background: rgb(var(--accent));
  color: rgb(var(--foreground));
}

.pls-drag-handle:active,
.pls-drag-handle--grabbing,
.pls-drag-handle[aria-grabbed='true'] {
  cursor: grabbing;
  background: rgb(var(--accent));
  color: rgb(var(--foreground));
}

.pls-drag-handle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgb(var(--ring, 24 24 27) / 0.25);
}

.pls-drag-handle__icon {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  pointer-events: none;
  opacity: 0.88;
}

.pls-drag-handle:hover .pls-drag-handle__icon,
.pls-drag-handle--grabbing .pls-drag-handle__icon,
.pls-drag-handle[aria-grabbed='true'] .pls-drag-handle__icon {
  opacity: 1;
}

.pls-sortable-ghost {
  opacity: 0.45;
  background: rgb(var(--muted) / 0.35);
  border: 1px dashed rgb(var(--border));
  border-radius: var(--radius, 0.5rem);
}

.pls-sortable-ghost > * {
  visibility: hidden;
}

.pls-sortable-chosen {
  z-index: 2;
  background: rgb(var(--card));
  border-radius: var(--radius, 0.5rem);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.06);
}

.dark .pls-sortable-chosen {
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.2);
}

.pls-sortable-drag {
  opacity: 1;
}

/* Profile preference rows (media types, public sections) — full-size grip */
.profile-pref-row__grip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.75rem;
  min-width: 2.75rem;
}

.profile-pref-row__grip .pls-drag-handle {
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
}

.profile-pref-row__grip .pls-drag-handle__icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* List editor — grip + position stacked in lead column (matches profile / ATL placement) */
.cml-selected-lead {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.125rem;
  flex-shrink: 0;
  width: 1.75rem;
  min-width: 1.75rem;
  padding-top: 0.35rem;
}

.cml-selected-lead .cml-selected-pos {
  width: auto;
  min-width: 0;
  justify-content: center;
  text-align: center;
  font-size: 1.25rem;
}

.cml-selected-lead .cml-selected-grip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  align-self: center;
}

.cml-selected-lead .cml-selected-grip .pls-drag-handle {
  width: 1.375rem;
  height: 1.25rem;
  min-width: 1.375rem;
  min-height: 1.25rem;
  border-radius: calc(var(--radius, 0.5rem) - 4px);
  background: transparent;
}

.cml-selected-lead .cml-selected-grip .pls-drag-handle:hover,
.cml-selected-lead .cml-selected-grip .pls-drag-handle--grabbing,
.cml-selected-lead .cml-selected-grip .pls-drag-handle[aria-grabbed='true'] {
  background: rgb(var(--muted) / 0.4);
}

.cml-selected-lead .cml-selected-grip .pls-drag-handle__icon {
  width: 0.8125rem;
  height: 0.8125rem;
  opacity: 0.72;
}

.cml-selected-lead .cml-selected-grip .pls-drag-handle:hover .pls-drag-handle__icon,
.cml-selected-lead .cml-selected-grip .pls-drag-handle--grabbing .pls-drag-handle__icon,
.cml-selected-lead .cml-selected-grip .pls-drag-handle[aria-grabbed='true'] .pls-drag-handle__icon {
  opacity: 1;
}

.cml-selected-row {
  min-width: 0;
}

.cml-selected-meta {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* List editor — grip leading (legacy / fallback if outside lead) */
.cml-selected-grip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: stretch;
  width: 2.25rem;
  min-width: 2.25rem;
}

.cml-selected-grip .pls-drag-handle {
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  min-height: 2.25rem;
  border-radius: calc(var(--radius, 0.5rem) - 2px);
  background: rgb(var(--muted) / 0.28);
}

.cml-selected-grip .pls-drag-handle__icon {
  width: 1.0625rem;
  height: 1.0625rem;
}

.cml-selected-row.pls-sortable-chosen {
  border-radius: calc(var(--radius, 0.5rem) - 2px);
  transform: none;
}

/* Profile collection table — grip + # stacked in lead column (4-col grid, iOS-safe) */
.profile-collection-row--sortable {
  grid-template-columns: 1.75rem 4.5rem minmax(0, 1fr) 4.75rem;
  column-gap: 0.625rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.profile-collection-row__lead {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.125rem;
  min-width: 0;
  width: 1.75rem;
  padding-top: 0.35rem;
}

.profile-collection-row__lead--head {
  align-items: center;
  justify-content: flex-end;
  padding-top: 0;
  padding-bottom: 0.125rem;
}

.profile-collection-row__lead .profile-collection-row__grip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-collection-row__lead .profile-collection-row__grip .pls-drag-handle {
  width: 1.375rem;
  height: 1.25rem;
  min-width: 1.375rem;
  min-height: 1.25rem;
  border-radius: calc(var(--radius, 0.5rem) - 4px);
  background: transparent;
}

.profile-collection-row__lead .profile-collection-row__grip .pls-drag-handle:hover,
.profile-collection-row__lead .profile-collection-row__grip .pls-drag-handle--grabbing,
.profile-collection-row__lead
  .profile-collection-row__grip
  .pls-drag-handle[aria-grabbed='true'] {
  background: rgb(var(--muted) / 0.4);
}

.profile-collection-row__lead .profile-collection-row__grip .pls-drag-handle__icon {
  width: 0.8125rem;
  height: 0.8125rem;
  opacity: 0.72;
}

.profile-collection-row__lead .profile-collection-row__grip .pls-drag-handle:hover .pls-drag-handle__icon,
.profile-collection-row__lead
  .profile-collection-row__grip
  .pls-drag-handle--grabbing
  .pls-drag-handle__icon,
.profile-collection-row__lead
  .profile-collection-row__grip
  .pls-drag-handle[aria-grabbed='true']
  .pls-drag-handle__icon {
  opacity: 1;
}

.profile-collection-row--sortable .profile-collection-row__num-value {
  flex-shrink: 0;
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: -0.04em;
  text-align: center;
}

.profile-collection-row--sortable .profile-collection-row__cover {
  grid-column: 2;
}

.profile-collection-row--sortable .profile-collection-row__title {
  grid-column: 3;
  min-width: 0;
}

.profile-collection-row--sortable .profile-collection-row__title-text {
  overflow-wrap: break-word;
  word-break: normal;
}

.profile-collection-row--sortable .profile-collection-row__actions {
  grid-column: 4;
  min-width: 0;
  overflow: visible;
}

.profile-collection-row--sortable.pls-sortable-chosen,
.profile-collection-row--sortable.pls-sortable-ghost {
  border-radius: var(--radius, 0.5rem);
  transform: none;
}

@media (min-width: 640px) {
  .cml-selected-lead {
    width: 2rem;
    min-width: 2rem;
  }

  .cml-selected-lead .cml-selected-pos {
    font-size: 1.5rem;
  }

  .profile-collection-row--sortable {
    grid-template-columns: 1.75rem 5.25rem minmax(0, 1fr) 4.75rem;
    column-gap: 0.75rem;
  }

  .profile-collection-row--sortable .profile-collection-row__num-value {
    font-size: 1.5rem;
  }

  .profile-collection-row__lead .profile-collection-row__grip .pls-drag-handle {
    width: 1.5rem;
    height: 1.375rem;
    min-width: 1.5rem;
    min-height: 1.375rem;
  }

  .profile-collection-row__lead .profile-collection-row__grip .pls-drag-handle__icon {
    width: 0.875rem;
    height: 0.875rem;
  }
}

@media (min-width: 640px) {
  .cml-selected-grip {
    width: 2.5rem;
    min-width: 2.5rem;
  }

  .cml-selected-grip .pls-drag-handle {
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    min-height: 2.5rem;
  }

  .cml-selected-grip .pls-drag-handle__icon {
    width: 1.125rem;
    height: 1.125rem;
  }
}

.pls-reorder-fallback {
  display: flex;
  gap: 0.25rem;
}

.pls-reorder-fallback.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Owner quick-edit overlay on list cover */
.pls-owner-quick-edit {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.375rem;
  margin: 0;
  border-radius: var(--radius, 0.5rem);
  border: 1px solid rgb(var(--border) / 0.65);
  background: rgb(var(--card) / 0.92);
  color: rgb(var(--foreground));
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.pls-owner-quick-edit:hover {
  background: rgb(var(--accent));
  color: rgb(var(--accent-foreground, var(--foreground)));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.pls-owner-quick-edit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgb(var(--ring, 24 24 27) / 0.35);
}

.pls-owner-quick-edit .pls-lucide-icon {
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}

/* Profile owned catalog list rows — grip + thumb + body */
.profile-catalog-list-row--sortable {
  display: flex;
  gap: 0.625rem;
  align-items: flex-start;
  min-width: 0;
  width: 100%;
}

.profile-catalog-list-row__grip {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-shrink: 0;
  padding-top: 0.35rem;
}

.profile-catalog-list-row__grip .pls-drag-handle {
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
}

.profile-catalog-list-row__main {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
}

.profile-catalog-list-row--sortable.pls-sortable-chosen,
.profile-catalog-list-row--sortable.pls-sortable-ghost {
  border-radius: var(--radius, 0.5rem);
}

/* Feed list-view owner rows */
.mpl-owned-list-row--sortable {
  position: relative;
}

.mpl-owned-list-row__grip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: stretch;
  padding-left: 0.25rem;
}

.mpl-owned-list-row__grip .pls-drag-handle {
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
}
