/* ============================================
   ANIMATIONS.CSS - Keyframes y Animaciones CSS
   WebDev & Marketing - Animation System
   ============================================ */

/* ============================================
   VARIABLES GLOBALES
   ============================================ */
:root {
  --animation-duration: 0.8s;
  --animation-timing: cubic-bezier(0.4, 0, 0.2, 1);
  --animation-delay: 0.1s;
  --primary-color: #00B36A;
  --primary-light: #21C87A;
}

/* ============================================
   KEYFRAMES - FADE ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================
   KEYFRAMES - SCALE ANIMATIONS
   ============================================ */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleInUp {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale3d(0.3, 0.3, 0.3);
  }
  50% {
    opacity: 1;
  }
  to {
    transform: scale3d(1, 1, 1);
  }
}

/* ============================================
   KEYFRAMES - ROTATION ANIMATIONS
   ============================================ */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-200deg);
  }
  to {
    opacity: 1;
    transform: rotate(0);
  }
}

/* ============================================
   KEYFRAMES - SLIDE ANIMATIONS
   ============================================ */
@keyframes slideInLeft {
  from {
    transform: translate3d(-100%, 0, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes slideInRight {
  from {
    transform: translate3d(100%, 0, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes slideInUp {
  from {
    transform: translate3d(0, 100%, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes slideInDown {
  from {
    transform: translate3d(0, -100%, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

/* ============================================
   KEYFRAMES - BOUNCE ANIMATIONS
   ============================================ */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-15px);
  }
  60% {
    transform: translateY(-7px);
  }
}

@keyframes bounceIn {
  from,
  20%,
  40%,
  60%,
  80%,
  to {
    animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
  }
  0% {
    opacity: 0;
    transform: scale3d(0.3, 0.3, 0.3);
  }
  20% {
    transform: scale3d(1.1, 1.1, 1.1);
  }
  40% {
    transform: scale3d(0.9, 0.9, 0.9);
  }
  60% {
    opacity: 1;
    transform: scale3d(1.03, 1.03, 1.03);
  }
  80% {
    transform: scale3d(0.97, 0.97, 0.97);
  }
  to {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }
}

/* ============================================
   KEYFRAMES - SPECIAL EFFECTS
   ============================================ */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-10px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(10px);
  }
}

@keyframes flip {
  from {
    transform: perspective(400px) rotateY(0);
  }
  40% {
    transform: perspective(400px) rotateY(-10deg);
  }
  to {
    transform: perspective(400px) rotateY(360deg);
  }
}

/* ============================================
   KEYFRAMES - BUTTON EFFECTS
   ============================================ */
@keyframes ripple-effect {
  to {
    transform: scale(2);
    opacity: 0;
  }
}

@keyframes button-shine {
  0% {
    left: -100%;
  }
  20% {
    left: 100%;
  }
  100% {
    left: 100%;
  }
}

/* ============================================
   KEYFRAMES - LOADING ANIMATIONS
   ============================================ */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes dots-loading {
  0%, 20% {
    color: transparent;
  }
  40% {
    color: var(--primary-color);
  }
  100% {
    color: transparent;
  }
}

@keyframes skeleton-loading {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.animate-fade-in {
  animation: fadeIn var(--animation-duration) var(--animation-timing) forwards;
}

.animate-fade-in-up {
  animation: fadeInUp var(--animation-duration) var(--animation-timing) forwards;
}

.animate-fade-in-down {
  animation: fadeInDown var(--animation-duration) var(--animation-timing) forwards;
}

.animate-fade-in-left {
  animation: fadeInLeft var(--animation-duration) var(--animation-timing) forwards;
}

.animate-fade-in-right {
  animation: fadeInRight var(--animation-duration) var(--animation-timing) forwards;
}

.animate-scale-in {
  animation: scaleIn var(--animation-duration) var(--animation-timing) forwards;
}

.animate-bounce-in {
  animation: bounceIn var(--animation-duration) var(--animation-timing) forwards;
}

.animate-rotate {
  animation: rotate 2s linear infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Delays */
.animation-delay-100 {
  animation-delay: 100ms;
}

.animation-delay-200 {
  animation-delay: 200ms;
}

.animation-delay-300 {
  animation-delay: 300ms;
}

.animation-delay-500 {
  animation-delay: 500ms;
}

/* ============================================
   SCROLL ANIMATIONS
   ============================================ */
.will-animate {
  opacity: 0;
}

.animated {
  opacity: 1;
}

/* ============================================
   HOVER EFFECTS
   ============================================ */
.hover-lift {
  transition: transform 0.3s var(--animation-timing), box-shadow 0.3s var(--animation-timing);
}

.hover-lift:hover {
  transform: translateY(-8px);
  box-shadow: 0 10px 30px rgba(0, 149, 85, 0.2);
}

.hover-grow {
  transition: transform 0.3s var(--animation-timing);
}

.hover-grow:hover {
  transform: scale(1.05);
}

.hover-glow {
  transition: box-shadow 0.3s var(--animation-timing);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(0, 149, 85, 0.5);
}

.hover-brightness {
  transition: filter 0.3s var(--animation-timing);
}

.hover-brightness:hover {
  filter: brightness(1.1);
}

/* ============================================
   IMAGE EFFECTS
   ============================================ */
.image-zoom {
  overflow: hidden;
}

.image-zoom img {
  transition: transform 0.5s var(--animation-timing);
}

.image-zoom:hover img {
  transform: scale(1.1);
}

.image-parallax {
  position: relative;
  overflow: hidden;
}

.image-parallax img {
  position: absolute;
  width: 100%;
  height: 120%;
  object-fit: cover;
}

/* ============================================
   GRADIENT ANIMATIONS
   ============================================ */
@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.gradient-animated {
  background-size: 200% 200%;
  animation: gradient-shift 3s ease infinite;
}

/* ============================================
   TEXT EFFECTS
   ============================================ */
@keyframes text-shimmer {
  0% {
    background-position: -500%;
  }
  100% {
    background-position: 500%;
  }
}

.text-shimmer {
  background: linear-gradient(90deg,
    #00B36A 0%,
    #21C87A 50%,
    #00B36A 100%);
  background-size: 200% auto;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: text-shimmer 3s linear infinite;
}

/* ============================================
   LOADING STATES
   ============================================ */
.skeleton {
  background: linear-gradient(90deg,
    rgba(0, 179, 106, 0.1) 0%,
    rgba(0, 179, 106, 0.2) 50%,
    rgba(0, 179, 106, 0.1) 100%);
  background-size: 200px 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

/* ============================================
   PREFERS REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================
   RESPONSIVE ANIMATIONS
   ============================================ */
@media (max-width: 768px) {
  :root {
    --animation-duration: 0.5s;
  }

  /* Deshabilitar algunas animaciones complejas en móvil */
  .device-low .animate-rotate,
  .device-low .animate-pulse,
  .is-mobile .gradient-animated {
    animation: none;
  }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */
.dark .hover-lift:hover {
  box-shadow: 0 10px 30px rgba(0, 198, 110, 0.3);
}

.dark .hover-glow:hover {
  box-shadow: 0 0 20px rgba(0, 198, 110, 0.6);
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */
.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

/* Forzar aceleración por hardware */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* ============================================
   CUSTOM SCROLL BAR (opcional)
   ============================================ */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-light);
}

/* Dark mode scrollbar */
.dark ::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

/* ============================================
   THREE.JS CONTAINERS
   ============================================ */

/* Logo 3D Container */
#logo-3d {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ocultar fallback SVG cuando Three.js está activo */
#logo-3d canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#logo-3d canvas + .threejs-fallback {
  display: none;
}

/* Global Particles Container */
#global-particles {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: -1;
}

#global-particles canvas,
#hero-particles canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Legacy hero particles support (in case anchors remain) */
#hero-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Asegurar que los contenedores Three.js no afecten el layout */
[data-threejs] {
  overflow: hidden;
}

[data-threejs] canvas {
  display: block;
}

/* Loading state para Three.js */
[data-threejs]:not(.threejs-loaded) .threejs-fallback {
  display: block;
}

[data-threejs].threejs-loaded .threejs-fallback {
  display: none !important;
}
