/**
 * Animal Sorter Styles
 * Interactive drag-and-drop classification game UI
 */

:root {
  --accent: #2f7d32;
  --accent2: #7cb342;
  --line: #d7e3d2;
  --soft: #eef6ea;
  --ink: #1f2a1f;
  --card: #ffffff;
  --success-color: #4caf50;
  --error-color: #f44336;
  --info-color: #2196f3;
}

/* ============================================
   ANIMAL SORTER CONTAINER
   ============================================ */

.animal-sorter-container {
  margin-top: 20px;
  padding: 0;
}

.animal-sorter-container.completion-celebration {
  animation: celebrationPulse 0.6s ease-in-out;
}

@keyframes celebrationPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* ============================================
   ANIMAL POOL (Draggable Cards)
   ============================================ */

.animal-pool {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px;
  background: #f9fdf8;
  border: 2px dashed var(--line);
  border-radius: 12px;
  margin-bottom: 24px;
  min-height: 120px;
}

.animal-card {
  background: var(--card);
  border: 2px solid var(--accent2);
  border-radius: 10px;
  padding: 12px;
  cursor: grab;
  transition: all 0.2s ease;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.animal-card:hover:not(.placed) {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(47, 125, 50, 0.15);
  transform: translateY(-2px);
}

.animal-card:active:not(.placed) {
  cursor: grabbing;
}

.animal-card.dragging {
  opacity: 0.6;
  cursor: grabbing;
}

.animal-card.placed {
  opacity: 0.3;
  border-color: #ccc;
  cursor: not-allowed;
  background: #f5f5f5;
}

.animal-card-name {
  font-weight: 600;
  color: var(--accent);
  font-size: 1rem;
  margin-bottom: 4px;
}

.animal-card-desc {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.4;
}

/* ============================================
   DROP ZONES
   ============================================ */

.drop-zones-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 20px;
}

.drop-zones-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.drop-zones-row.habitat-row {
  margin-top: 12px;
}

.drop-zone {
  background: linear-gradient(135deg, #f0f8f0 0%, #fafef9 100%);
  border: 3px dashed var(--accent2);
  border-radius: 12px;
  padding: 16px;
  min-height: 150px;
  transition: all 0.2s ease;
  position: relative;
}

.drop-zone:hover {
  background: linear-gradient(135deg, #e8f5e9 0%, #f1fdf0 100%);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(47, 125, 50, 0.1);
}

.drop-zone.drag-over {
  background: linear-gradient(135deg, #e8f5e9 0%, #f1fdf0 100%);
  border-color: var(--accent);
  border-width: 3px;
  box-shadow: 0 6px 16px rgba(47, 125, 50, 0.2);
  transform: scale(1.02);
}

.drop-zone.correct-placement {
  background: #e8f5e9;
  border-color: var(--success-color);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.drop-zone-label {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.drop-zone-sublabel {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 12px;
}

.drop-zone-content {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 8px;
}

.drop-zone-content:empty::after {
  content: 'Drop animals here';
  display: block;
  width: 100%;
  color: #aaa;
  font-style: italic;
  font-size: 0.9rem;
  padding: 8px;
  text-align: center;
}

/* ============================================
   ZONED ANIMAL CARDS (In Drop Zones)
   ============================================ */

.zoned-animal-card {
  background: var(--card);
  border: 2px solid var(--success-color);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--success-color);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(76, 175, 80, 0.15);
  animation: slideInCard 0.3s ease-out;
}

.zoned-animal-card:hover {
  background: #f0f8f0;
  box-shadow: 0 4px 8px rgba(76, 175, 80, 0.2);
  transform: scale(1.05);
}

@keyframes slideInCard {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================
   FEEDBACK MESSAGES
   ============================================ */

.sorter-feedback {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  text-align: center;
  min-height: 1.2em;
  transition: all 0.3s ease;
  animation: fadeInFeedback 0.3s ease-out;
}

@keyframes fadeInFeedback {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sorter-feedback-correct {
  background: #c8e6c9;
  color: #2e7d32;
  border-left: 4px solid var(--success-color);
}

.sorter-feedback-incorrect {
  background: #ffcdd2;
  color: #c62828;
  border-left: 4px solid var(--error-color);
  animation: bounceInFeedback 0.4s ease-out;
}

.sorter-feedback-info {
  background: #bbdefb;
  color: #1565c0;
  border-left: 4px solid var(--info-color);
}

.sorter-feedback-celebration {
  background: linear-gradient(135deg, #c8e6c9 0%, #bbdefb 100%);
  color: var(--accent);
  border-left: 4px solid var(--success-color);
  font-size: 1.1rem;
  padding: 16px;
  animation: celebrationFade 1.5s ease-in-out;
}

@keyframes bounceInFeedback {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

@keyframes celebrationFade {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.sorter-feedback strong {
  display: inline;
  font-weight: 700;
}

/* ============================================
   BOUNCE BACK ANIMATION (Incorrect Placement)
   ============================================ */

.animal-card.bounce-back {
  animation: bounceBack 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceBack {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(20px);
  }
  75% {
    transform: translateX(-20px);
  }
  100% {
    transform: translateX(0);
  }
}

/* ============================================
   RESET BUTTON
   ============================================ */

.sorter-reset-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 16px;
  box-shadow: 0 2px 6px rgba(47, 125, 50, 0.2);
}

.sorter-reset-btn:hover {
  background: #1b5e20;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(47, 125, 50, 0.3);
}

.sorter-reset-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(47, 125, 50, 0.2);
}

/* ============================================
   HABITAT SECTION LABEL
   ============================================ */

.habitat-section-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 20px;
  margin-bottom: 12px;
  padding: 12px;
  background: #fff9e6;
  border-left: 4px solid #c9a227;
  border-radius: 6px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
  .animal-pool {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    padding: 12px;
  }

  .drop-zones-row {
    grid-template-columns: 1fr;
  }

  .drop-zones-row.habitat-row {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .drop-zone {
    min-height: 120px;
    padding: 12px;
  }

  .drop-zone-label {
    font-size: 1rem;
  }

  .animal-card {
    padding: 10px;
  }

  .animal-card-name {
    font-size: 0.95rem;
  }

  .animal-card-desc {
    font-size: 0.8rem;
  }

  .sorter-reset-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .animal-pool {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .drop-zone {
    padding: 10px;
    min-height: 100px;
  }

  .drop-zone-label {
    font-size: 0.95rem;
  }

  .drop-zone-sublabel {
    font-size: 0.8rem;
    margin-bottom: 8px;
  }

  .drop-zone-content:empty::after {
    font-size: 0.8rem;
  }

  .animal-card {
    padding: 8px;
  }

  .animal-card-name {
    font-size: 0.9rem;
  }

  .animal-card-desc {
    font-size: 0.75rem;
  }

  .zoned-animal-card {
    font-size: 0.85rem;
    padding: 6px 10px;
  }

  .sorter-feedback {
    font-size: 0.9rem;
    padding: 10px 12px;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.animal-card:focus-visible,
.sorter-reset-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.drop-zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
