/* Mensthetic Animation Enhancement System */

/* Respect user's motion preferences */
@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;
  }
  
  /* Provide alternative feedback for reduced motion */
  .btn--menst-primary:focus,
  .btn--menst-quiet:focus {
    outline: 3px solid var(--menst-accent);
    outline-offset: 2px;
  }
}

/* Enhanced Button Animations - Clinical Precision */
.btn--menst-primary {
  position: relative;
  overflow: hidden;
  transform: translateZ(0); /* Force GPU layer */
  will-change: transform, box-shadow;
  transition: all var(--menst-motion-fast), 
              transform var(--menst-motion-fast),
              box-shadow var(--menst-motion);
}

.btn--menst-primary:hover {
  background: #0A5CE8;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(14, 107, 255, 0.25);
  will-change: auto;
}

.btn--menst-primary:active {
  transform: translateY(-1px) scale(1.01);
  transition-duration: 100ms;
}

/* Subtle shimmer effect for primary buttons */
.btn--menst-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn--menst-primary:hover::before {
  left: 100%;
}

/* Enhanced Quiet Button Animations */
.btn--menst-quiet {
  position: relative;
  transform: translateZ(0);
  transition: all var(--menst-motion-fast);
}

.btn--menst-quiet:hover {
  background: var(--menst-accent);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(14, 107, 255, 0.15);
}

.btn--menst-quiet:active {
  transform: translateY(0);
  transition-duration: 100ms;
}

/* Clinical Card Hover Effects */
.service-card,
.card--menst {
  position: relative;
  transform: translateZ(0);
  transition: all var(--menst-motion);
  will-change: transform, box-shadow;
}

.service-card:hover,
.card--menst:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(11, 14, 17, 0.12);
  will-change: auto;
}

/* Stabilize service icons - prevent jumping */
.service-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: var(--menst-s-4);
  transition: transform var(--menst-motion);
  transform: scale(1);
  will-change: auto;
}

/* Subtle border animation for cards */
.service-card::before,
.card--menst::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, transparent, rgba(14, 107, 255, 0.1), transparent);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--menst-motion);
}

.service-card:hover::before,
.card--menst:hover::before {
  opacity: 1;
}

/* Progressive Content Reveal Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

/* Hero Section Progressive Reveal */
.hero-content {
  animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-text h1 {
  animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.1s both;
}

.hero-text p {
  animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

.hero-actions {
  animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.3s both;
}

.hero-image {
  animation: scaleIn 1s cubic-bezier(0.4, 0, 0.2, 1) 0.4s both;
}

/* Navigation Dropdown Enhancement */
.dropdown {
  position: relative;
}

/* Create invisible bridge between nav item and dropdown */
.dropdown::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: var(--menst-s-2);
  background: transparent;
  z-index: 999;
}

.dropdown-menu {
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  transition: all var(--menst-motion-fast);
  pointer-events: none;
  z-index: 1000;
}

.dropdown:hover .dropdown-menu,
.dropdown-menu:hover {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Keep dropdown open when hovering over it */
.dropdown:hover .dropdown-menu,
.dropdown .dropdown-menu:hover {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Enhanced hover behavior with delay */
.dropdown {
  transition: all 0.1s ease;
}

.dropdown:hover {
  /* Keep hover state active */
}

.dropdown-content a {
  opacity: 0;
  transform: translateX(-8px);
  transition: all var(--menst-motion-fast);
}

.dropdown:hover .dropdown-content a {
  opacity: 1;
  transform: translateX(0);
}

.dropdown-content a:nth-child(1) { transition-delay: 50ms; }
.dropdown-content a:nth-child(2) { transition-delay: 100ms; }
.dropdown-content a:nth-child(3) { transition-delay: 150ms; }
.dropdown-content a:nth-child(4) { transition-delay: 200ms; }

/* Form Input Enhancements */
.form-input,
.input--menst {
  position: relative;
  transition: all var(--menst-motion-fast);
}

.form-input:focus,
.input--menst:focus {
  border-color: var(--menst-accent);
  transform: scale(1.02);
  box-shadow: 0 0 0 3px rgba(14, 107, 255, 0.1);
}

/* Loading States */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.loading {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Scroll-Driven Animation Classes */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(32px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger Animation for Multiple Elements */
.animate-on-scroll.stagger-1 { transition-delay: 0.1s; }
.animate-on-scroll.stagger-2 { transition-delay: 0.2s; }
.animate-on-scroll.stagger-3 { transition-delay: 0.3s; }
.animate-on-scroll.stagger-4 { transition-delay: 0.4s; }

/* Mobile Optimization */
@media (max-width: 768px) {
  /* Reduce animation intensity on mobile */
  .btn--menst-primary:hover,
  .btn--menst-quiet:hover {
    transform: translateY(-1px);
  }
  
  .service-card:hover,
  .card--menst:hover {
    transform: translateY(-2px);
  }
  
  .form-input:focus,
  .input--menst:focus {
    transform: scale(1.01);
  }
}

/* High Performance Scroll Animations (Modern Browsers) */
@supports (animation-timeline: scroll()) {
  .scroll-fade {
    animation: fadeIn linear;
    animation-timeline: view();
    animation-range: entry 0% entry 100%;
  }
  
  .scroll-slide {
    animation: fadeInUp linear;
    animation-timeline: view();
    animation-range: entry 0% entry 80%;
  }
}

/* Performance: Reduce animations on low-power devices */
@media (prefers-reduced-motion: no-preference) and (update: slow) {
  * {
    animation-duration: 0.1s !important;
    transition-duration: 0.1s !important;
  }
}

/* Enhanced form field styles */
.form-input.valid {
  border-color: var(--menst-success);
  background-image: linear-gradient(to right, transparent 90%, rgba(22, 163, 74, 0.1) 100%);
}

.form-input.invalid {
  border-color: var(--menst-danger);
  background-image: linear-gradient(to right, transparent 90%, rgba(217, 45, 32, 0.1) 100%);
}

/* Button press effect */
.btn--menst-primary:active,
.btn--menst-quiet:active {
  transform: scale(0.98);
}

/* Page transition preparation */
.page-transition-enter {
  opacity: 0;
  transform: translateX(20px);
}

.page-transition-enter-active {
  opacity: 1;
  transform: translateX(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-transition-exit {
  opacity: 1;
  transform: translateX(0);
}

.page-transition-exit-active {
  opacity: 0;
  transform: translateX(-20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}