/* Page wrapper - keeps content centered with consistent max width */
.container {
  max-width: 560px;
  margin: 0 auto;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.header {
  text-align: center !important;
  margin-bottom: 28px !important;
  background: linear-gradient(219deg, #fb0e76 0%, #910694 100%) !important;
  border-radius: 12px !important;
  padding: 24px !important;
  box-shadow: 0 10px 30px rgba(145, 6, 148, 0.22) !important;
}

.header-title {
  margin: 0 0 8px !important;
  font-size: clamp(28px, 4vw, 40px) !important;
  font-weight: 700 !important;
  letter-spacing: -0.03em !important;
  line-height: 1.15 !important;
  color: #ffffff !important;
}

.header-subtitle {
  color: rgba(255, 255, 255, 0.92) !important;
  font-size: 16px !important;
  line-height: 1.6 !important;
  margin: 0 !important;
  max-width: 460px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* ==========================================================================
   RESULT SECTION (hidden until first generation)
   ========================================================================== */
.result-section {
  margin-bottom: 25px;
  animation: fadeInUp 0.5s ease forwards;
}

.result-card {
  background: #ffffff;
  border: 1px solid #f3c9e4;
  border-radius: 18px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(145, 6, 148, 0.12);
  margin-bottom: 25px;
  text-align: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Subtle hover lift on the result card */
.result-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(145, 6, 148, 0.18);
}

/* Image container - stable layout for the three image states */
.animal-image-container {
  width: 100%;
  max-width: 320px;
  margin: 0 auto 20px;
  border-radius: 16px;
  overflow: hidden;
  background-color: #f3eef7;
}

/* State 1: Loading indicator (inside the image container) */
.animal-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 260px;
  padding: 20px 0;
}

/* State 2: Animal image (success) */
.animal-image {
  display: none;
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: 16px;
  transition: opacity 0.4s ease, transform 0.5s ease;
  opacity: 0;
  transform: scale(0.92);
}

/* When the image has loaded, the JS adds .loaded to trigger the animation */
.animal-image.loaded {
  opacity: 1;
  transform: scale(1);
}

/* State 3: Fallback (error) */
.animal-image-fallback {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 260px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f3c9e4 0%, #e8d5ef 100%);
  color: #910694;
  font-size: 15px;
  font-weight: 600;
}

/* Animal name */
.animal-name {
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 700;
  color: #2a1a2f;
  margin-bottom: 12px;
  line-height: 1.2;
  animation: fadeInUp 0.5s ease 0.1s both;
}

/* Category badge under the name */
.category-badge {
  display: inline-block;
  background: rgba(145, 6, 148, 0.08);
  color: #910694;
  border: 1px solid rgba(145, 6, 148, 0.18);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  animation: fadeInUp 0.5s ease 0.18s both;
}

/* Optional animal fact text */
.animal-fact {
  font-size: 15px;
  color: #555555;
  line-height: 1.6;
  max-width: 440px;
  margin: 0 auto;
  animation: fadeInUp 0.5s ease 0.26s both;
}

/* ==========================================================================
   LOADING STATE (spinner used inside .animal-loading)
   ========================================================================== */
.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #f3c9e4;
  border-top-color: #fb0e76;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: 15px;
  color: #910694;
  font-weight: 600;
}

/* ==========================================================================
   CONTROLS CARD (category select + generate button)
   ========================================================================== */
.controls-card {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 18px !important;
  padding: 30px !important;
  box-shadow: 0 10px 30px rgba(145, 6, 148, 0.1) !important;
  margin-bottom: 25px !important;
}

.control-label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #2a1a2f;
  margin-bottom: 10px;
}

/* Select dropdown */
.category-select {
  background: #ffffff;
  border: 1px solid #d8c5df;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 16px;
  color: #222222;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23910694' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 14px;
  padding-right: 42px;
}

.category-select:focus {
  border-color: #910694 !important;
  box-shadow: 0 0 0 4px rgba(251, 14, 118, 0.1) !important;
  outline: none !important;
}

/* Generate button - gradient theme */
.generate-btn {
  background: linear-gradient(219deg, #fb0e76 0%, #910694 100%) !important;
  color: #ffffff!important;
  border: none!important;
  border-radius: 12px !important;
  padding: 14px 26px !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease !important;
  width: 100% !important;
  margin-top: 18px !important;
  font-family: inherit !important;
}

.generate-btn:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 10px 24px rgba(145, 6, 148, 0.28) !important;
}

.generate-btn:focus {
  outline: none !important;
  box-shadow: 0 0 0 4px rgba(251, 14, 118, 0.18) !important;
}

.generate-btn:active {
  transform: translateY(0) !important;
}

/* Disabled state while loading */
.generate-btn:disabled {
  opacity: 0.65 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   RESPONSIVE - TABLET
   ========================================================================== */
@media (max-width: 768px) {
  body {
    padding: 20px 14px 40px;
  }

  .header {
    padding: 22px 20px;
    margin-bottom: 24px;
  }

  .header-subtitle {
    font-size: 15px;
  }

  .result-card,
  .controls-card {
    padding: 24px 20px;
  }

  .animal-image-container {
    max-width: 300px;
  }

  .animal-image,
  .animal-loading,
  .animal-image-fallback {
    height: 240px;
  }
}

/* ==========================================================================
   RESPONSIVE - MOBILE
   ========================================================================== */
@media (max-width: 480px) {
  body {
    padding: 16px 12px 32px;
  }

  .header {
    padding: 20px 16px;
    margin-bottom: 20px;
    border-radius: 10px;
  }

  .header-title {
    font-size: clamp(24px, 6vw, 32px);
  }

  .header-subtitle {
    font-size: 14px;
  }

  .result-card,
  .controls-card {
    padding: 20px 16px;
    border-radius: 14px;
  }

  /* Image fills width on mobile, capped at 320px */
  .animal-image-container {
    max-width: 320px;
  }

  .animal-image,
  .animal-loading,
  .animal-image-fallback {
    height: 220px;
    border-radius: 14px;
  }

  .animal-name {
    font-size: clamp(22px, 5.5vw, 30px);
  }

  .animal-fact {
    font-size: 14px;
  }

  /* Buttons and select are full width on mobile */
  .category-select,
  .generate-btn {
    width: 100%;
  }
}
