/* drag-sort.css - Styling for drag-and-drop sorting questions */

.drag-sort-container {
  width: 100%;
  margin: 1rem 0;
}

/* Items pool (source area) */
.drag-sort-items-pool {
  background-color: #f8f9fa;
  border: 2px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 1rem;
}

.drag-sort-pool-label {
  color: #495057;
  margin-bottom: 0.5rem;
}

.drag-sort-items {
  min-height: 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.25rem;
  justify-content: start;
}

@media (min-width: 768px) {
  .drag-sort-items {
    grid-template-columns: repeat(auto-fill, minmax(156px, calc(25% - 0.375rem)));
    max-width: calc(4 * 156px + 3 * 0.5rem + 1rem);
  }
}

.drag-sort-items:has(.drag-sort-item:nth-child(10)) {
  max-width: none !important;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)) !important;
}

/* Individual draggable items */
.drag-sort-item {
  background-color: white;
  border: 2px solid var(--scandi-6);
  border-radius: 0.375rem;
  padding: 0.5rem;
  cursor: move;
  user-select: none;
  touch-action: none; /* Prevent default touch behaviors like scrolling */
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 156px;
  max-height: 130px;
  overflow: visible;
  position: relative;
  z-index: 1;
}

.drag-sort-item:hover {
  background-color: #e7f3ff;
  transform: translateY(-2px) scale(1.5);
  box-shadow: 0 4px 16px rgba(0, 123, 255, 0.3);
  z-index: 100;
  max-width: 180px;
  max-height: 150px;
}

.drag-sort-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

/* Items with images */
.drag-sort-image {
  max-width: 130px !important;
  max-height: 104px !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  display: block !important;
  pointer-events: none; /* Prevent the image from being the drag target */
}

/* Items with audio */
.drag-sort-item .drag-sort-audio {
  max-width: 200px;
  height: 32px;
  touch-action: auto; /* Allow touch interactions for audio controls */
}

/* Text inside items should not be draggable */
.drag-sort-item span {
  pointer-events: none;
}

/* Categories area */
.drag-sort-categories {
  margin-top: 1rem;
}

.drag-sort-category {
  background-color: #ffffff;
  border: 2px solid #6c757d;
  border-radius: 0.5rem;
  padding: 1rem;
}

.drag-sort-category-label {
  color: #212529;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

/* Drop zones */
.drag-sort-dropzone {
  min-height: 80px;
  background-color: #f8f9fa;
  border: 2px dashed #adb5bd;
  border-radius: 0.375rem;
  padding: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-content: flex-start;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.drag-sort-dropzone.drag-over {
  background-color: #e7f3ff;
  border-color: #007bff;
  border-style: solid;
}

/* Empty state for drop zones */
.drag-sort-dropzone:empty::before {
  content: 'Drop items here';
  color: #adb5bd;
  font-style: italic;
  display: block;
  text-align: center;
  padding: 1.5rem;
  width: 100%;
}

.drag-sort-dropzone.drag-over:empty::before {
  content: 'Release to drop';
  color: #007bff;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .drag-sort-item {
    font-size: 0.875rem;
    padding: 0.4rem 0.8rem;
  }

  .drag-sort-item .drag-sort-image {
    max-width: 80px;
    max-height: 60px;
  }

  .drag-sort-category-label {
    font-size: 0.9rem;
  }
}
