/* Playful Geometric Design System */

/* ==============================
   Design Tokens
   ============================== */
:root {
  /* Colors */
  --bg: #FFFDF5;            /* 暖米色背景 */
  --foreground: #1E293B;    /* 深石板色 */
  --muted: #F1F5F9;         /* 浅石板色 */
  --muted-foreground: #64748B; /* 中石板色 */
  --accent: #8B5CF6;         /* 紫色强调色 */
  --accent-foreground: #FFFFFF; /* 白色 */
  --secondary: #F472B6;      /* 粉色 */
  --tertiary: #FBBF24;       /* 黄色 */
  --quaternary: #34D399;     /* 绿色 */
  --border: #E2E8F0;         /* 边框色 */
  --input: #FFFFFF;           /* 输入框背景 */
  --card: #FFFFFF;            /* 卡片背景 */
  --ring: #8B5CF6;           /* 焦点环 */
  
  /* Fonts */
  --font-heading: 'Outfit', system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  
  /* Radii */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-pop: 4px 4px 0px 0px var(--foreground);
  --shadow-pop-hover: 6px 6px 0px 0px var(--foreground);
  --shadow-pop-active: 2px 2px 0px 0px var(--foreground);
  
  /* Transitions */
  --transition-bounce: all 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-smooth: all 200ms ease;
}

/* ==============================
   Base Styles & Reset
   ============================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--foreground);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  position: relative;
}

/* ==============================
   Geometric Decorations
   ============================== */
.geometric-decorations {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

/* 圆形装饰 */
.decor-circle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.1;
  animation: float 8s ease-in-out infinite;
}

.decor-yellow {
  width: 300px;
  height: 300px;
  background-color: var(--tertiary);
  top: -100px;
  right: -100px;
}

.decor-pink {
  width: 200px;
  height: 200px;
  background-color: var(--secondary);
  bottom: -50px;
  left: -50px;
  animation-delay: 2s;
}

/* 三角形装饰 */
.decor-triangle {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 100px solid transparent;
  border-right: 100px solid transparent;
  border-bottom: 173px solid var(--accent);
  opacity: 0.1;
  top: 30%;
  left: -50px;
  animation: float 10s ease-in-out infinite;
  animation-delay: 1s;
}

/* 方形装饰 */
.decor-square {
  position: absolute;
  width: 150px;
  height: 150px;
  background-color: var(--quaternary);
  opacity: 0.1;
  bottom: 20%;
  right: -50px;
  transform: rotate(45deg);
  animation: float 12s ease-in-out infinite;
  animation-delay: 3s;
}

/* 点阵背景 */
.decor-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--foreground) 1px, transparent 1px);
  background-size: 30px 30px;
  opacity: 0.05;
}

/* ==============================
   Animations
   ============================== */
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

@keyframes bounce-in {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  70% {
    transform: translate(-50%, -50%) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(2deg); }
  75% { transform: rotate(-2deg); }
}

/* ==============================
   Container & Layout
   ============================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  position: relative;
  z-index: 1;
}

.hero-section {
  text-align: center;
  margin-bottom: 2rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.main-content {
  position: relative;
}

/* ==============================
   Typography
   ============================== */
h1 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: clamp(2.5rem, 6vw, 4rem);
  line-height: 1.1;
  margin-bottom: 1rem;
  color: var(--foreground);
  position: relative;
  display: inline-block;
}

h1::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 10%;
  right: 10%;
  height: 6px;
  background-color: var(--tertiary);
  border-radius: var(--radius-full);
  transform: rotate(-1deg);
}

.description {
  font-family: var(--font-body);
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--muted-foreground);
  max-width: 4xl;
  margin: 0 auto;
}

/* ============================== 
   API Configuration Button Container
   ============================== */
.api-config-btn-container {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 5;
}

.api-config-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
  background-color: var(--input);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-bounce);
  box-shadow: 3px 3px 0px transparent;
}

.api-config-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 3px 3px 0px 0px var(--accent);
  border-color: var(--accent);
}

/* ============================== 
   API Configuration Panel
   ============================== */
.api-config-panel {
  display: none;
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 500px;
  width: 90%;
  margin: 0;
  padding: 1.5rem;
  background-color: var(--card);
  border: 3px solid var(--foreground);
  border-radius: var(--radius-lg);
  box-shadow: 8px 8px 0px 0px var(--secondary);
  z-index: 100;
  animation: bounce-in 0.4s ease-out;
}

.api-input-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--foreground);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--input);
  outline: none;
  transition: var(--transition-bounce);
}

.api-input-group input:focus {
  border-color: var(--accent);
  box-shadow: 3px 3px 0px 0px var(--accent);
  transform: translate(-2px, -2px);
}

.cancel-api-btn, .save-api-btn {
  padding: 0.75rem 1.5rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  border: 2px solid var(--foreground);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-bounce);
  box-shadow: 3px 3px 0px 0px var(--foreground);
}

.cancel-api-btn {
  background-color: var(--input);
  color: var(--foreground);
  margin-right: 1rem;
}

.cancel-api-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0px 0px var(--foreground);
  background-color: var(--muted);
}

.save-api-btn {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.save-api-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0px 0px var(--foreground);
  background-color: var(--secondary);
}

.api-config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.api-config-header h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--foreground);
}

.close-api-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  color: var(--foreground);
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  transition: var(--transition-smooth);
}

.close-api-btn:hover {
  background-color: var(--muted);
  transform: scale(1.1);
}

.api-config-panel h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 0.75rem;
}

.api-config-panel p {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--muted-foreground);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.api-input-group {
  margin-bottom: 1.5rem;
}

.api-input-group label {
  display: block;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: 0.5rem;
}

.api-key-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--foreground);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--input);
  outline: none;
  transition: var(--transition-bounce);
}

.api-key-input:focus {
  border-color: var(--accent);
  box-shadow: 3px 3px 0px 0px var(--accent);
  transform: translate(-2px, -2px);
}

.api-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.save-api-btn, .clear-api-btn {
  padding: 0.75rem 1.5rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  border: 2px solid var(--foreground);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-bounce);
  box-shadow: 3px 3px 0px 0px var(--foreground);
}

.save-api-btn {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.save-api-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0px 0px var(--foreground);
  background-color: var(--secondary);
}

.clear-api-btn {
  background-color: var(--input);
  color: var(--foreground);
}

.clear-api-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0px 0px var(--foreground);
  background-color: var(--muted);
}

.api-status {
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
}

.api-status.success {
  background-color: rgba(52, 211, 153, 0.1);
  color: #059669;
  border: 1px solid #34D399;
}

.api-status.error {
  background-color: rgba(239, 68, 68, 0.1);
  color: #DC2626;
  border: 1px solid #F87171;
}

.api-status.info {
  background-color: rgba(59, 130, 246, 0.1);
  color: #2563EB;
  border: 1px solid #60A5FA;
}

/* ============================== 
   Input Section
   ============================== */
.input-section {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 3rem;
  flex-wrap: wrap;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 1rem;
}

.animal-input {
  flex: 1;
  min-width: 280px;
  max-width: 400px;
  height: 64px;
  padding: 0 1.5rem;
  font-family: var(--font-body);
  font-size: 1.125rem;
  color: var(--foreground);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--input);
  outline: none;
  transition: var(--transition-bounce);
  box-shadow: 4px 4px 0px transparent;
}

.animal-input::placeholder {
  color: var(--muted-foreground);
}

.animal-input:focus {
  border-color: var(--accent);
  box-shadow: 4px 4px 0px 0px var(--accent);
  transform: translate(-2px, -2px);
}

/* ==============================
   Buttons
   ============================== */
.search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  padding: 0 2rem;
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent-foreground);
  background-color: var(--accent);
  border: 2px solid var(--foreground);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-bounce);
  box-shadow: var(--shadow-pop);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.search-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-pop-hover);
  background-color: var(--secondary);
}

.search-btn:active {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-pop-active);
}

.search-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 1rem;
  width: 24px;
  height: 24px;
  background-color: var(--accent-foreground);
  border-radius: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--accent);
}

/* ==============================
   Result Section
   ============================== */
.result-section {
  min-height: 300px;
  position: relative;
  padding: 1rem 0;
}

/* ==============================
   SVG Card Container
   ============================== */
.svg-card-container {
  width: 100%;
  overflow-x: auto;
  padding: 1rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.svg-card-container svg {
  max-width: 100%;
  height: auto;
  border: 3px solid var(--foreground);
  border-radius: 28px;
  box-shadow: 10px 10px 0px 0px var(--secondary);
  transition: var(--transition-bounce);
}

.svg-card-container svg:hover {
  transform: translate(-4px, -4px) rotate(-1deg);
  box-shadow: 14px 14px 0px 0px var(--secondary);
}

/* ==============================
   Loading State
   ============================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 4rem 2rem;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.loading::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ==============================
   Error Message
   ============================== */
.error-message {
  padding: 2.5rem;
  background-color: var(--input);
  border: 2px solid var(--foreground);
  border-radius: var(--radius-lg);
  text-align: center;
  font-family: var(--font-body);
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--foreground);
  box-shadow: 6px 6px 0px 0px var(--tertiary);
  margin: 2rem auto;
  max-width: 700px;
  width: 90%;
}

/* ==============================
   Decorative Animal Icons
   ============================== */
.animal-icon {
  position: absolute;
  font-size: 3rem;
  opacity: 0.1;
  animation: wiggle 3s ease-in-out infinite;
  pointer-events: none;
}

.icon-1 {
  top: 10%;
  right: 5%;
  transform: rotate(15deg);
}

.icon-2 {
  bottom: 10%;
  left: 5%;
  transform: rotate(-15deg);
  animation-delay: 1.5s;
}

/* ==============================
   Responsive Design
   ============================== */
@media (max-width: 768px) {
  .container {
    padding: 1.5rem;
  }
  
  h1 {
    font-size: clamp(2rem, 8vw, 2.5rem);
  }
  
  .description {
    font-size: 1rem;
    margin-bottom: 2rem;
  }
  
  .input-section {
    flex-direction: column;
    align-items: center;
  }
  
  .animal-input {
    width: 100%;
    max-width: 100%;
  }
  
  .search-btn {
    width: 100%;
  }
  
  .svg-card-container {
    padding: 1rem 0;
  }
  
  .svg-card-container svg {
    box-shadow: 4px 4px 0px 0px var(--secondary);
  }
  
  .svg-card-container svg:hover {
    transform: translate(-2px, -2px) rotate(-1deg);
    box-shadow: 6px 6px 0px 0px var(--secondary);
  }
  
  .animal-icon {
    font-size: 2rem;
  }
  
  /* 调整装饰元素大小 */
  .decor-yellow {
    width: 200px;
    height: 200px;
  }
  
  .decor-pink {
    width: 150px;
    height: 150px;
  }
  
  .decor-triangle {
    border-left: 70px solid transparent;
    border-right: 70px solid transparent;
    border-bottom: 121px solid var(--accent);
  }
  
  .decor-square {
    width: 100px;
    height: 100px;
  }
}

/* ==============================
   Reduced Motion Accessibility
   ============================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .geometric-decorations {
    display: none;
  }
  
  .animal-icon {
    animation: none !important;
  }
}

/* ==============================
   Selection Styling
   ============================== */
::selection {
  background: rgba(139, 92, 246, 0.2);
  color: var(--foreground);
}
