/* ============================================
   SIMPLE PAGE TRANSITIONS - Safe & Native
   ============================================ */

/* Page content - always visible by default */
.main-content {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Fade in on page load */
.main-content.page-fade-in {
  animation: pageFadeIn 0.4s ease forwards;
}

@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px) translateZ(0); /* GPU acceleration */
  }
  to {
    opacity: 1;
    transform: translateY(0) translateZ(0);
  }
}

/* Fade out before navigation (fallback) */
.main-content.page-fade-out {
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* View Transitions API (Chrome 111+) */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.4s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth transitions for View Transitions API */
::view-transition-old(root) {
  animation: fadeOut 0.3s ease;
}

::view-transition-new(root) {
  animation: fadeIn 0.4s ease;
}

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

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

/* Loading overlay */
.page-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.95);
  /* backdrop-filter: blur(8px); REMOVED - causes severe lag in Safari */
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  overflow: hidden;
  will-change: opacity;
}

.page-loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Logo container */
.page-loading-logo-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Logo scale-up animation - optimized for Safari GPU acceleration */
.page-loading-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateZ(0); /* Force GPU acceleration */
  z-index: 2;
  animation: logoScaleUp 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  will-change: transform, opacity;
  backface-visibility: hidden; /* Safari optimization */
}

.loading-logo-image {
  height: 120px;
  width: auto;
  max-width: 400px;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(99, 102, 241, 0.5));
  transition: transform 0.3s ease;
}

.loading-logo-icon {
  font-size: 8rem;
  color: var(--primary);
  filter: drop-shadow(0 8px 24px rgba(99, 102, 241, 0.5));
  transition: transform 0.3s ease;
}

/* Slide track - removed for bounce animation */
.page-loading-slide-track {
  display: none;
}

/* Optimized scale animation for Safari - reduced complexity */
@keyframes logoScaleUp {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(3);
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .loading-logo-image {
    height: 100px;
    max-width: 320px;
  }
  
  .loading-logo-icon {
    font-size: 6rem;
  }
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Disable transitions on reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .main-content,
  .page-loading-overlay,
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
    transition: none !important;
  }
}
