/* Lab and Pharmacy: result animations, tutorial overlay, enhanced feedback */

/* ---------- Lab: Slime Synthesizer Enhancements ---------- */
.slime-synth-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.slime-synth-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 140px;
}

.slime-synth-controls select {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 2px solid var(--slime, #b7a4ce);
  background: var(--paper, #eef2ff);
  color: var(--ink, #16152a);
  font-size: 1em;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.slime-synth-controls select:focus {
  outline: none;
  border-color: var(--accent, #5865f2);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.3);
}

.slime-synth-controls select:hover {
  border-color: var(--accent, #5865f2);
}

#mutate-btn {
  min-height: 44px;
  padding: 12px 24px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent, #5865f2), var(--slime, #b7a4ce));
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

#mutate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(88, 101, 242, 0.5);
}

#mutate-btn:active {
  transform: translateY(0);
}

#mutate-btn.mutating {
  animation: mutate-pulse 0.6s ease-out;
}

@keyframes mutate-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); box-shadow: 0 0 24px rgba(88, 101, 242, 0.8); }
}

/* Hybrid name display with enhanced animation */
.hybrid-name {
  font-weight: 600;
  font-size: 1.1em;
  text-align: center;
  padding: 12px;
  min-height: 1.5em;
  transition: all 0.3s ease;
}

.hybrid-result {
  animation: hybrid-reveal 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: linear-gradient(135deg, rgba(183, 164, 206, 0.2), rgba(88, 101, 242, 0.2));
  border-radius: 8px;
  border: 2px solid var(--slime, #b7a4ce);
}

@keyframes hybrid-reveal {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(10px);
    filter: blur(4px);
  }
  40% {
    opacity: 1;
    transform: scale(1.05) translateY(0);
    filter: blur(0);
  }
  70% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1);
  }
}

/* Slime canvas with glow effect */
#slime-hybrid {
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(14, 13, 34, 0.8), rgba(22, 21, 42, 0.9));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 0 30px rgba(183, 164, 206, 0.1);
  border: 2px solid var(--slime, #b7a4ce);
}

/* Mutation log enhancements */
.mutation-log-item {
  position: relative;
  overflow: hidden;
}

.mutation-log-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.mutation-log-item:hover::before {
  transform: translateX(100%);
}

.mutation-log-item.new-mutation {
  animation: new-mutation-flash 1s ease-out;
}

@keyframes new-mutation-flash {
  0%, 100% { background: var(--paper, #eef2ff); }
  50% { background: rgba(88, 101, 242, 0.2); }
}

/* Pet breeder enhancements */
.breeder-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 16px 0;
}

#breed-btn {
  min-height: 44px;
  min-width: 100px;
  padding: 12px 20px;
  font-weight: 700;
  background: linear-gradient(135deg, #ff69b4, #ff8c42);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

#breed-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 105, 180, 0.5);
}

#breed-btn:active {
  transform: translateY(0) scale(1);
}

#breed-btn.breeding {
  animation: breed-pulse 0.8s ease-out;
}

@keyframes breed-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); box-shadow: 0 0 30px rgba(255, 105, 180, 0.8); }
}

.pet-card {
  flex: 1;
  min-width: 150px;
  max-width: 200px;
}

.pet-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--paper, #eef2ff);
  border-radius: 8px;
  border: 2px solid var(--slime, #b7a4ce);
}

.pet-emoji {
  font-size: 2.5em;
  line-height: 1;
}

.pet-type {
  font-weight: 600;
  text-transform: capitalize;
}

.pet-traits {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85em;
  text-align: center;
}

.pet-traits li {
  padding: 2px 0;
}

.pet-baby-wrap {
  margin: 16px 0;
  min-height: 120px;
}

.pet-baby-card {
  animation: baby-arrive 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-color: var(--accent, #5865f2);
  box-shadow: 0 4px 20px rgba(88, 101, 242, 0.3);
}

@keyframes baby-arrive {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-10deg);
  }
  60% {
    opacity: 1;
    transform: scale(1.1) rotate(5deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

.pet-baby-emoji {
  animation: baby-bounce 1s ease-out infinite;
}

@keyframes baby-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.pet-collection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.pet-collection-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pet-collection-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.pet-mutated {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.7em;
  background: #ff4444;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.pet-card {
  position: relative;
}

/* Tutorial overlay improvements */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  padding: 20px;
  animation: tutorial-fade-in 0.3s ease-out;
}

.tutorial-overlay.hidden {
  display: none;
}

.tutorial-card {
  background: var(--card, #d6daf0);
  color: var(--ink, #16152a);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: tutorial-slide-up 0.3s ease-out;
}

.tutorial-card h2 {
  margin: 0 0 8px;
  font-size: 1.3em;
  text-align: center;
}

.tutorial-card .tutorial-intro {
  text-align: center;
  color: var(--slime-dark, #5d4a74);
  font-style: italic;
  margin-bottom: 16px;
}

.tutorial-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
}

.tutorial-steps li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.tutorial-steps li:last-child {
  border-bottom: none;
}

.tutorial-step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent, #5865f2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.tutorial-step-text {
  flex: 1;
}

.tutorial-step-text b {
  display: block;
  margin-bottom: 2px;
}

.tutorial-step-text span {
  font-size: 0.9em;
  opacity: 0.8;
}

.tutorial-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.tutorial-actions button {
  min-height: 44px;
  min-width: 120px;
}

@keyframes tutorial-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tutorial-slide-up {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---------- Result flash animation (lab hybrid) ---------- */
.hybrid-result {
  animation: hybrid-flash 0.6s ease-out;
}

@keyframes hybrid-flash {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  75% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- Hybrid mutation history ---------- */
.mutation-history {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.mutation-history h3 {
  font-size: 0.9em;
  margin: 0 0 8px;
  color: var(--slime-dark, #5d4a74);
}

.mutation-log {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mutation-log-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8em;
  background: var(--paper, #eef2ff);
  border: 1px solid var(--slime, #b7a4ce);
  cursor: default;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mutation-log-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.mutation-log-item .mut-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mutation-log-item .mut-name {
  font-weight: 600;
}

/* ---------- Pharmacy result feedback ---------- */
.pharmacy-result {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  text-align: center;
  animation: result-pop 0.4s ease-out;
}

.pharmacy-result.success {
  background: #d4edda;
  color: #155724;
  border: 2px solid #28a745;
}

.pharmacy-result.failure {
  background: #f8d7da;
  color: #721c24;
  border: 2px solid #dc3545;
  animation: result-shake 0.4s ease-out;
}

.pharmacy-result.in-progress {
  background: var(--paper, #eef2ff);
  color: var(--ink, #16152a);
  border: 1px solid var(--slime, #b7a4ce);
}

@keyframes result-pop {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  60% {
    transform: scale(1.03);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes result-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ---------- Pharmacy ingredient progress ---------- */
.pharmacy-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.pharmacy-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--paper, #eef2ff);
  border-radius: 4px;
  overflow: hidden;
}

.pharmacy-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--slime, #b7a4ce), var(--accent, #5865f2));
  border-radius: 4px;
  transition: width 0.3s ease-out;
}

.pharmacy-progress-label {
  font-size: 0.8em;
  font-weight: 600;
  color: var(--slime-dark, #5d4a74);
  min-width: 50px;
  text-align: right;
}

/* ---------- Pharmacy hint system ---------- */
.pharmacy-hint {
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--mustard, #e2c7d5);
  border-left: 4px solid var(--accent, #5865f2);
  font-size: 0.9em;
  animation: hint-fade-in 0.3s ease-out;
}

.pharmacy-hint b {
  display: block;
  margin-bottom: 4px;
}

@keyframes hint-fade-in {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ---------- Pharmacy celebration particles ---------- */
.pharmacy-celebration {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
}

.pharmacy-celebration .particle {
  position: absolute;
  font-size: 24px;
  animation: celebration-fall 1.5s ease-out forwards;
  opacity: 0;
}

@keyframes celebration-fall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(200px) rotate(360deg) scale(0.5);
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .tutorial-overlay,
  .tutorial-card,
  .hybrid-result,
  .pharmacy-result,
  .pharmacy-result.success,
  .pharmacy-result.failure,
  .pharmacy-hint,
  .pharmacy-celebration .particle {
    animation: none;
    opacity: 1;
  }
}

/* ---------- Daily Challenge ---------- */
.challenge-target-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px;
  margin: 12px 0;
  border-radius: 12px;
  background: var(--paper, #eef2ff);
  border: 2px dashed var(--slime, #b7a4ce);
}

.challenge-target-card .pet-emoji {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.challenge-target-card .pet-type {
  font-size: 1.3em;
  font-weight: 600;
  color: var(--ink, #16152a);
  margin-bottom: 8px;
}

.challenge-target-card .pet-traits {
  list-style: none;
  padding: 0;
  margin: 8px 0 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, max-content);
  gap: 4px 12px;
  font-size: 0.9em;
}

.challenge-desc {
  font-size: 0.85em;
  color: var(--slime-dark, #5d4a74);
  margin: 0;
}

.challenge-progress {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.challenge-progress h3 {
  font-size: 0.9em;
  margin: 0 0 8px;
  color: var(--slime-dark, #5d4a74);
}

.challenge-best {
  font-size: 1em;
  margin-bottom: 8px;
}

.challenge-best b {
  color: var(--accent, #5865f2);
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .tutorial-card {
    padding: 16px;
  }

  .tutorial-steps li {
    padding: 6px 0;
  }

  .tutorial-actions {
    flex-direction: column;
  }

  .tutorial-actions button {
    width: 100%;
  }

  .mutation-log-item {
    font-size: 0.7em;
    padding: 3px 8px;
  }
}
