/* ==========================================================================
   ETC-MEDMED Animations
   Scroll-triggered and interactive animations
   ========================================================================== */

/* ========================================
   Keyframes - Reveal Animations
   ======================================== */

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

/* ========================================
   Keyframes - Continuous Animations
   ======================================== */

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

@keyframes floatSlow {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(2deg);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.9;
  }
}

@keyframes pulseSoft {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

@keyframes gradientFlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-15px);
  }
  60% {
    transform: translateY(-8px);
  }
}

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

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(42, 78, 153, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(42, 78, 153, 0.6), 0 0 30px rgba(42, 78, 153, 0.3);
  }
}

/* Dot pattern animation */
@keyframes dotPulse {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.1);
  }
}

/* Hero diagonal slide */
@keyframes diagonalSlide {
  from {
    clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
  }
  to {
    clip-path: polygon(25% 0, 100% 0, 100% 100%, 0 100%);
  }
}

/* Underline grow */
@keyframes underlineGrow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* Counter number */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   Animation Base Classes
   ======================================== */

/* All animated elements start hidden */
[data-animate] {
  opacity: 0;
}

/* When visible, apply animation */
[data-animate].is-visible {
  opacity: 1;
}

/* ========================================
   Fade Animations
   ======================================== */

[data-animate="fade-up"].is-visible {
  animation: fadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

[data-animate="fade-in"].is-visible {
  animation: fadeIn 0.6s ease-out forwards;
}

[data-animate="fade-down"].is-visible {
  animation: fadeDown 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ========================================
   Slide Animations
   ======================================== */

[data-animate="slide-left"].is-visible {
  animation: slideLeft 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

[data-animate="slide-right"].is-visible {
  animation: slideRight 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ========================================
   Scale Animations
   ======================================== */

[data-animate="scale-in"].is-visible {
  animation: scaleIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

[data-animate="scale-up"].is-visible {
  animation: scaleUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ========================================
   Animation Delays
   ======================================== */

[data-delay="100"] { animation-delay: 100ms !important; }
[data-delay="200"] { animation-delay: 200ms !important; }
[data-delay="300"] { animation-delay: 300ms !important; }
[data-delay="400"] { animation-delay: 400ms !important; }
[data-delay="500"] { animation-delay: 500ms !important; }
[data-delay="600"] { animation-delay: 600ms !important; }
[data-delay="700"] { animation-delay: 700ms !important; }
[data-delay="800"] { animation-delay: 800ms !important; }

/* ========================================
   Stagger Animation (for grids/lists)
   ======================================== */

[data-animate="stagger"].is-visible > *:nth-child(1) { animation-delay: 0ms; }
[data-animate="stagger"].is-visible > *:nth-child(2) { animation-delay: 100ms; }
[data-animate="stagger"].is-visible > *:nth-child(3) { animation-delay: 200ms; }
[data-animate="stagger"].is-visible > *:nth-child(4) { animation-delay: 300ms; }
[data-animate="stagger"].is-visible > *:nth-child(5) { animation-delay: 400ms; }
[data-animate="stagger"].is-visible > *:nth-child(6) { animation-delay: 500ms; }
[data-animate="stagger"].is-visible > *:nth-child(7) { animation-delay: 600ms; }
[data-animate="stagger"].is-visible > *:nth-child(8) { animation-delay: 700ms; }
[data-animate="stagger"].is-visible > *:nth-child(9) { animation-delay: 800ms; }
[data-animate="stagger"].is-visible > *:nth-child(10) { animation-delay: 900ms; }
[data-animate="stagger"].is-visible > *:nth-child(11) { animation-delay: 1000ms; }
[data-animate="stagger"].is-visible > *:nth-child(12) { animation-delay: 1100ms; }

[data-animate="stagger"] > * {
  opacity: 0;
}

[data-animate="stagger"].is-visible > * {
  animation: fadeUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ========================================
   Continuous Animation Classes
   ======================================== */

.animate-float {
  animation: float 4s ease-in-out infinite;
}

.animate-float-slow {
  animation: floatSlow 6s ease-in-out infinite;
}

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

.animate-pulse-soft {
  animation: pulseSoft 3s ease-in-out infinite;
}

.animate-bounce {
  animation: bounce 2s ease infinite;
}

.animate-wiggle {
  animation: wiggle 1s ease-in-out infinite;
}

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

.animate-shimmer {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

.animate-gradient {
  background-size: 200% 200%;
  animation: gradientFlow 4s ease infinite;
}

/* ========================================
   Hover Trigger Animations
   ======================================== */

.hover-float {
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.hover-float:hover {
  transform: translateY(-8px);
}

.hover-scale {
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.hover-lift {
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.hover-lift:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 40px rgba(11, 20, 40, 0.15);
}

.hover-glow:hover {
  box-shadow: 0 0 30px rgba(42, 78, 153, 0.4);
}

/* ========================================
   Icon Animations
   ======================================== */

.icon-animate {
  transition: transform 0.3s ease;
}

.icon-animate:hover {
  transform: scale(1.15) rotate(5deg);
}

.icon-bounce:hover {
  animation: bounce 0.6s ease;
}

/* ========================================
   Text Animations
   ======================================== */

.text-reveal {
  overflow: hidden;
}

.text-reveal span {
  display: inline-block;
  transform: translateY(100%);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.text-reveal.is-visible span {
  transform: translateY(0);
}

/* ========================================
   Link Underline Animation
   ======================================== */

.link-underline {
  position: relative;
  text-decoration: none;
}

.link-underline::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.link-underline:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ========================================
   Button Animations
   ======================================== */

.btn-animated {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn-animated::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.btn-animated:hover::before {
  width: 300px;
  height: 300px;
}

.btn-animated:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(42, 78, 153, 0.3);
}

.btn-animated:active {
  transform: translateY(-1px);
}

/* ========================================
   Card Animations
   ======================================== */

.card-animated {
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.card-animated:hover {
  transform: translateY(-10px);
  box-shadow: 0 25px 50px rgba(11, 20, 40, 0.15);
}

/* Card icon animation */
.card-animated:hover .card__icon,
.card-animated:hover .feature-card__icon {
  transform: scale(1.1);
  background-color: var(--blue-500);
}

/* Card image zoom */
.card-image-zoom {
  overflow: hidden;
}

.card-image-zoom img {
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* ========================================
   Partner Logo Animations
   ======================================== */

.partner-logo-animated {
  filter: grayscale(100%);
  opacity: 0.7;
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.partner-logo-animated:hover {
  filter: grayscale(0%);
  opacity: 1;
  transform: scale(1.08);
}

/* ========================================
   Section Reveal
   ======================================== */

.section-reveal {
  position: relative;
}

.section-reveal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--surface);
  transform-origin: right;
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.section-reveal.is-visible::before {
  transform: scaleX(0);
}

/* ========================================
   Loading Skeleton Animation
   ======================================== */

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ========================================
   Accessibility - 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;
  }

  [data-animate] {
    opacity: 1 !important;
    transform: none !important;
  }

  [data-animate="stagger"] > * {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Reduce motion class (JS-applied) */
.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
}
