/**
 * Pokemon-Style Battle CSS
 * Additional custom styles and animations
 */

/* Grass animation for battle field */
@keyframes grassSway {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(-2px) rotate(-1deg); }
  75% { transform: translateX(2px) rotate(1deg); }
}

.grass-blade {
  animation: grassSway 3s ease-in-out infinite;
}

/* HP Bar critical flash */
@keyframes hpCritical {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.hp-critical {
  animation: hpCritical 0.5s infinite;
}

/* Sprite entrance animations */
@keyframes spriteEnterLeft {
  0% {
    transform: translateX(-200px) scale(0.5);
    opacity: 0;
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

@keyframes spriteEnterRight {
  0% {
    transform: translateX(200px) scale(0.5);
    opacity: 0;
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

.sprite-enter-left {
  animation: spriteEnterLeft 0.8s ease-out;
}

.sprite-enter-right {
  animation: spriteEnterRight 0.8s ease-out;
}

/* Info box slide animations */
@keyframes infoBoxSlideLeft {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes infoBoxSlideRight {
  0% {
    transform: translateX(100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Battle message typing cursor */
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.typing-cursor::after {
  content: '▼';
  animation: blink 1s infinite;
  margin-left: 4px;
}

/* Action button press effect */
.action-btn:active:not(:disabled) {
  transform: scale(0.95) translateY(2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Selected action highlight */
.action-selected {
  position: relative;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.8);
}

.action-selected::before {
  content: '✓';
  position: absolute;
  top: -10px;
  right: -10px;
  background: #10B981;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Damage number animation */
@keyframes damageFloat {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-100px) scale(1.5);
    opacity: 0;
  }
}

.damage-number {
  animation: damageFloat 1.5s ease-out forwards;
  pointer-events: none;
}

/* Critical hit effect */
@keyframes criticalHit {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.2);
    filter: brightness(2);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.critical-hit {
  animation: criticalHit 0.5s ease-out;
}

/* Status effect icons */
@keyframes statusFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.status-icon {
  animation: statusFloat 2s ease-in-out infinite;
}

/* Victory sparkle effect */
@keyframes sparkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1) rotate(180deg);
  }
}

.sparkle {
  animation: sparkle 1s ease-in-out infinite;
}

/* Faint animation */
@keyframes faint {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100px) rotate(90deg);
    opacity: 0;
  }
}

.faint {
  animation: faint 1s ease-out forwards;
}

/* Screen flash for super effective hits */
@keyframes screenFlash {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(255, 255, 255, 0.8); }
}

.screen-flash {
  animation: screenFlash 0.3s;
}

/* Bullet trail effect */
@keyframes bulletTrail {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 165, 0, 0.7);
  }
  100% {
    box-shadow: 0 0 20px 10px rgba(255, 165, 0, 0);
  }
}

.bullet-trail {
  animation: bulletTrail 0.5s ease-out;
}

/* Shield barrier effect */
@keyframes shieldBarrier {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.8;
  }
}

.shield-barrier {
  animation: shieldBarrier 0.6s ease-out;
}

/* Loading bullet spin */
@keyframes bulletLoad {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.3);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

.bullet-load {
  animation: bulletLoad 0.8s ease-in-out;
}

/* Round transition */
@keyframes roundTransition {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.5);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.round-transition {
  animation: roundTransition 0.5s ease-out;
}

/* Chat bubble bounce in */
@keyframes bubbleBounce {
  0% {
    transform: scale(0) translateY(-50px);
    opacity: 0;
  }
  60% {
    transform: scale(1.1) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.chat-bubble {
  animation: bubbleBounce 0.5s ease-out;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .action-btn {
    font-size: 14px;
    padding: 12px 16px;
  }
  
  .action-selected::before {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }
}

/* Touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {
  .action-btn:active:not(:disabled) {
    background-color: rgba(16, 185, 129, 0.2);
  }
}

/* Prevent text selection during battle */
.battle-arena * {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Smooth transitions for all interactive elements */
button, .transition-element {
  transition: all 0.3s ease-out;
}

/* Accessibility - focus states */
button:focus-visible {
  outline: 3px solid #10B981;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .action-btn {
    border-width: 3px;
  }
  
  .hp-bar {
    border-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Custom scrollbar for multiplayer status */
.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: #475569 #1e293b;
}

.scrollbar-thin::-webkit-scrollbar {
  width: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: #1e293b;
  border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 3px;
  transition: background 0.3s ease-out;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Loading state */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Victory/Defeat overlay */
.result-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 1000;
}

@keyframes resultFadeIn {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.result-text {
  animation: resultFadeIn 0.5s ease-out;
}
