/* ===== PAGE TRANSITIONS ===== */

/* ===== DESKTOP TRANSITIONS - SLIDE ANIMATIONS ===== */

/* Desktop slide transitions - default behavior */
@media (min-width: 1024px) {
  .page-enter-active {
    animation: slide-in-right 0.5s cubic-bezier(0.33, 1, 0.68, 1) forwards;
  }

  .page-leave-active {
    animation: slide-out-left 0.5s cubic-bezier(0.32, 0, 0.67, 0) forwards;
  }

  /* Desktop slide keyframes */
  @keyframes slide-in-right {
    0% {
      transform: translateX(100%);
      opacity: 0;
    }
    100% {
      transform: translateX(0);
      opacity: 1;
    }
  }

  @keyframes slide-out-left {
    0% {
      transform: translateX(0);
      opacity: 1;
    }
    100% {
      transform: translateX(-100%);
      opacity: 0;
    }
  }
}

/* ===== MOBILE & SMALL SCREEN TRANSITIONS - CROSS-FADE ===== */

/* Cross-fade transitions for mobile and smaller screens */
@media (max-width: 1023px) {
  .page-enter-active,
  .page-leave-active {
    transition-property: opacity;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 0.3s;
    will-change: opacity;
  }

  /* Page enter states */
  .page-enter-from {
    opacity: 0;
  }

  .page-enter-to {
    opacity: 1;
  }

  /* Page leave states */
  .page-leave-from {
    opacity: 1;
  }

  .page-leave-to {
    opacity: 0;
  }
}

/* Touch device optimization - even faster cross-fade */
@media (hover: none) and (pointer: coarse) {
  .page-enter-active,
  .page-leave-active {
    transition-duration: 0.25s;
  }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* GPU acceleration and performance optimizations */
.page-enter-active,
.page-leave-active {
  /* Prevent layout shifts */
  position: relative;
  z-index: 1;

  /* Smooth rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Desktop-specific performance optimizations */
@media (min-width: 768px) {
  .page-enter-active,
  .page-leave-active {
    /* Enable GPU acceleration for slide animations */
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;

    /* Improve rendering performance */
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
  }
}

/* Mobile-specific performance optimizations */
@media (max-width: 767px) {
  .page-enter-active,
  .page-leave-active {
    /* Optimize for mobile GPUs - only opacity changes */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
}

/* ===== ACCESSIBILITY OPTIMIZATIONS ===== */

/* Respect user's motion preferences - works for both desktop and mobile */
@media (prefers-reduced-motion: reduce) {
  .page-enter-active,
  .page-leave-active {
    /* Disable animations/transitions for users who prefer reduced motion */
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-property: opacity;
  }

  /* Provide subtle opacity fallback for accessibility */
  .page-enter-from,
  .page-leave-to {
    opacity: 0.1;
  }

  .page-enter-to,
  .page-leave-from {
    opacity: 1;
  }
}

/* ===== HIGH CONTRAST MODE SUPPORT ===== */

/* Ensure transitions work well in high contrast mode */
@media (prefers-contrast: high) {
  .page-enter-from,
  .page-leave-to {
    opacity: 0;
  }

  .page-enter-to,
  .page-leave-from {
    opacity: 1;
  }
}

/* ===== DARK MODE OPTIMIZATIONS ===== */

/* Optimize transitions for dark mode */
@media (prefers-color-scheme: dark) {
  .page-enter-active,
  .page-leave-active {
    /* Better rendering in dark mode */
    -webkit-font-smoothing: subpixel-antialiased;
  }
}

/* ===== MEMORY MANAGEMENT ===== */

/* Clean up will-change after animation/transition completes */
.page-enter-active.animation-complete,
.page-leave-active.animation-complete {
  will-change: auto;
}

/* ===== BROWSER COMPATIBILITY ===== */

/* Fallback for older browsers - desktop slide transitions */
@media (min-width: 1024px) {
  @supports not (animation: slide-in-right 0.5s) {
    .page-enter-active {
      transition: all 0.5s ease-in-out;
      transform: translateX(0);
      opacity: 1;
    }

    .page-leave-active {
      transition: all 0.5s ease-in-out;
      transform: translateX(-100%);
      opacity: 0;
    }
  }
}

/* Fallback for older browsers - mobile cross-fade transitions */
@media (max-width: 1023px) {
  @supports not (transition-property: opacity) {
    .page-enter-active {
      transition: opacity 0.3s ease-in-out;
      opacity: 1;
    }

    .page-leave-active {
      transition: opacity 0.3s ease-in-out;
      opacity: 0;
    }
  }
}

/* ===== PRINT STYLES ===== */

/* Disable transitions when printing */
@media print {
  .page-enter-active,
  .page-leave-active {
    animation: none !important;
    transition: none !important;
  }

  .page-enter-from,
  .page-enter-to,
  .page-leave-from,
  .page-leave-to {
    opacity: 1 !important;
  }
}
