/* ============================================
   chatbot-effects.css — GAJ-DASTAK Chatbot Visual Effects
   Elephant walk animation, particle trails, pulse rings,
   gradient shimmer, floating particles, transition effects.
   ============================================ */

/* --- Effect Design Tokens --- */
:root {
  --chat-accent-amber: #F5A623;
  --chat-accent-green: #7BA68A;
  --chat-accent-forest: var(--accent-amber, #2D6B3F);
  --chat-accent-orange: var(--accent-orange, #F75E3E);
  --chat-bg-dark: #0a0a0a;
  --chat-bg-mid: #141414;
  --chat-particle-gold: #F5A623;
  --chat-particle-green: #7BA68A;
  --chat-shimmer-start: rgba(245, 166, 35, 0);
  --chat-shimmer-mid: rgba(245, 166, 35, 0.35);
  --chat-shimmer-end: rgba(245, 166, 35, 0);
}


/* ============================================
   1. ELEPHANT WALKING ANIMATION
   A small elephant silhouette walks across
   the bottom of the viewport every ~30s.
   ============================================ */

.elephant-walker {
  position: fixed;
  bottom: 12px;
  left: -80px;
  z-index: 9990;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
}

.elephant-walker.walking {
  animation: elephantWalk 8s linear forwards,
             elephantFadeInOut 8s ease forwards;
}

.elephant-walker__body {
  width: 52px;
  height: 36px;
  position: relative;
  animation: elephantBob 0.6s ease-in-out infinite;
}

/* Elephant SVG silhouette rendered inline via JS, but we style the container */
.elephant-walker__body svg {
  width: 52px;
  height: 36px;
  fill: var(--chat-accent-forest);
  filter: drop-shadow(0 2px 6px rgba(45, 107, 63, 0.3));
  opacity: 0.75;
}

/* Leg animation — alternating leg movement illusion */
.elephant-walker__legs {
  position: absolute;
  bottom: -4px;
  left: 8px;
  display: flex;
  gap: 6px;
}

.elephant-walker__leg {
  width: 3px;
  height: 10px;
  background: var(--chat-accent-forest);
  border-radius: 1px;
  transform-origin: top center;
  opacity: 0.6;
}

.elephant-walker__leg:nth-child(1) {
  animation: legSwing 0.5s ease-in-out infinite;
}
.elephant-walker__leg:nth-child(2) {
  animation: legSwing 0.5s ease-in-out infinite 0.25s;
}
.elephant-walker__leg:nth-child(3) {
  animation: legSwing 0.5s ease-in-out infinite 0.15s;
}
.elephant-walker__leg:nth-child(4) {
  animation: legSwing 0.5s ease-in-out infinite 0.4s;
}

@keyframes elephantWalk {
  0%   { left: -80px; }
  100% { left: calc(100vw + 80px); }
}

@keyframes elephantFadeInOut {
  0%   { opacity: 0; }
  5%   { opacity: 1; }
  90%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes elephantBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

@keyframes legSwing {
  0%, 100% { transform: rotate(-12deg); }
  50%      { transform: rotate(12deg); }
}


/* ============================================
   2. PARTICLE / GLITTER TRAIL
   Sparkles trail behind the walking elephant.
   Each particle is spawned by JS and animated via CSS.
   ============================================ */

.elephant-particle {
  position: fixed;
  bottom: 18px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9989;
  will-change: transform, opacity;
  animation: particleFadeUp 1.2s ease-out forwards;
}

.elephant-particle--gold {
  background: var(--chat-particle-gold);
  box-shadow: 0 0 6px var(--chat-particle-gold), 0 0 12px rgba(245, 166, 35, 0.3);
}

.elephant-particle--green {
  background: var(--chat-particle-green);
  box-shadow: 0 0 6px var(--chat-particle-green), 0 0 12px rgba(123, 166, 138, 0.3);
}

.elephant-particle--tiny {
  width: 3px;
  height: 3px;
}

.elephant-particle--large {
  width: 7px;
  height: 7px;
}

@keyframes particleFadeUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  40% {
    opacity: 0.8;
    transform: translateY(-15px) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translateY(-35px) scale(0.3);
  }
}

/* Variant: some particles drift sideways */
.elephant-particle--drift-left {
  animation: particleDriftLeft 1.4s ease-out forwards;
}

.elephant-particle--drift-right {
  animation: particleDriftRight 1.4s ease-out forwards;
}

@keyframes particleDriftLeft {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-12px, -30px) scale(0.2);
  }
}

@keyframes particleDriftRight {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(12px, -30px) scale(0.2);
  }
}


/* ============================================
   3. PULSE RING ANIMATION
   Pulsing ring on the chat button every 10s.
   ============================================ */

.chatbot-toggle {
  position: relative;
}

.chatbot-toggle::before,
.chatbot-toggle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: none;
  opacity: 0;
}

.chatbot-toggle::before {
  border: 2px solid var(--chat-accent-forest);
}

.chatbot-toggle::after {
  border: 1.5px solid var(--chat-accent-orange);
}

/* Pulse plays via class toggled by JS every 10s */
.chatbot-toggle.pulse-ring::before {
  animation: pulseRingExpand 1.5s ease-out forwards;
}

.chatbot-toggle.pulse-ring::after {
  animation: pulseRingExpand 1.5s ease-out 0.25s forwards;
}

@keyframes pulseRingExpand {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.7;
  }
  70% {
    opacity: 0.2;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.8);
    opacity: 0;
  }
}

/* Don't pulse when chat is open */
.chatbot-toggle.chatbot-active::before,
.chatbot-toggle.chatbot-active::after {
  animation: none !important;
  opacity: 0;
}


/* ============================================
   4. GRADIENT SHIMMER
   Sweeping gradient shine on the chat button.
   ============================================ */

.chatbot-toggle .shimmer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
}

.chatbot-toggle .shimmer-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--chat-shimmer-start) 0%,
    var(--chat-shimmer-mid) 50%,
    var(--chat-shimmer-end) 100%
  );
  opacity: 0;
}

.chatbot-toggle.shimmer-active .shimmer-overlay::after {
  animation: shimmerSweep 1s ease-in-out forwards;
}

@keyframes shimmerSweep {
  0% {
    left: -100%;
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    left: 100%;
    opacity: 0;
  }
}

/* Don't shimmer when chat is open */
.chatbot-toggle.chatbot-active .shimmer-overlay::after {
  animation: none !important;
  opacity: 0;
}


/* ============================================
   5. FLOATING PARTICLES IN CHAT HEADER
   Tiny sparkles float upward when chat is open.
   ============================================ */

.chatbot-header {
  position: relative;
  overflow: hidden;
}

.header-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
}

.header-particle--gold {
  background: rgba(245, 166, 35, 0.7);
  box-shadow: 0 0 4px rgba(245, 166, 35, 0.4);
}

.header-particle--white {
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.header-particle--green {
  background: rgba(123, 166, 138, 0.7);
  box-shadow: 0 0 4px rgba(123, 166, 138, 0.4);
}

.header-particle.floating {
  animation: headerParticleFloat var(--float-duration, 3s) ease-in-out infinite;
  animation-delay: var(--float-delay, 0s);
}

@keyframes headerParticleFloat {
  0% {
    opacity: 0;
    transform: translateY(0) translateX(0) scale(0.5);
  }
  15% {
    opacity: 0.8;
    transform: translateY(-5px) scale(1);
  }
  50% {
    opacity: 0.6;
    transform: translateY(-20px) translateX(var(--float-drift, 4px)) scale(0.9);
  }
  85% {
    opacity: 0.3;
    transform: translateY(-35px) translateX(calc(var(--float-drift, 4px) * -0.5)) scale(0.6);
  }
  100% {
    opacity: 0;
    transform: translateY(-45px) translateX(0) scale(0.3);
  }
}


/* ============================================
   6. TRANSITION EFFECTS
   Chat open/close, form focus, submit hover.
   ============================================ */

/* --- Chat Open: slide up + bounce --- */
.chatbot-panel {
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.3s ease;
}

.chatbot-panel.open {
  display: flex;
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* --- Chat Close: slide down + scale toward button --- */
.chatbot-panel.closing {
  animation: chatClose 0.35s ease-in forwards;
}

@keyframes chatClose {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  60% {
    transform: translateY(10px) scale(0.92);
    opacity: 0.6;
  }
  100% {
    transform: translateY(40px) scale(0.3);
    opacity: 0;
    /* Collapses toward bottom-right where the button sits */
    transform-origin: bottom right;
  }
}

/* --- Form Fields: amber border glow on focus --- */
.chatbot-input:focus,
.chatbot-panel input:focus,
.chatbot-panel textarea:focus,
.chatbot-panel select:focus {
  border-color: var(--chat-accent-amber) !important;
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.2),
              0 0 12px rgba(245, 166, 35, 0.1);
  outline: none;
}

/* --- Submit Button: gradient animation on hover --- */
.chatbot-submit,
.chatbot-panel button[type="submit"] {
  background-size: 200% 100%;
  background-image: linear-gradient(
    90deg,
    var(--chat-accent-forest) 0%,
    var(--chat-accent-orange) 50%,
    var(--chat-accent-forest) 100%
  );
  background-position: 0% center;
  transition: background-position 0.5s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

.chatbot-submit:hover,
.chatbot-panel button[type="submit"]:hover {
  background-position: 100% center;
  box-shadow: 0 4px 16px rgba(247, 94, 62, 0.3);
}

.chatbot-submit:active,
.chatbot-panel button[type="submit"]:active {
  transform: translateY(0) scale(0.97);
}


/* ============================================
   7. RESPONSIVE / REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .elephant-walker,
  .elephant-particle,
  .header-particle,
  .chatbot-toggle::before,
  .chatbot-toggle::after,
  .chatbot-toggle .shimmer-overlay::after {
    animation: none !important;
    opacity: 0 !important;
  }

  .chatbot-panel {
    transition: opacity 0.2s ease;
    transform: none;
  }

  .chatbot-panel.open {
    transform: none;
  }
}

/* On small screens, the walking elephant is less visible — keep it but shrink */
@media (max-width: 600px) {
  .elephant-walker__body {
    width: 36px;
    height: 24px;
  }

  .elephant-walker__body svg {
    width: 36px;
    height: 24px;
  }

  .elephant-walker__legs {
    gap: 4px;
  }

  .elephant-walker__leg {
    width: 2px;
    height: 7px;
  }

  .chatbot-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    bottom: 5rem;
  }
}
