/* Performance Optimizations - GPU Acceleration */

/* Critical CSS - Inline in HTML */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Mobile-First Optimizations */
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Prevent horizontal scroll on mobile */
body, html {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Touch-friendly tap targets (minimum 48x48px) */
button, a, input, select, textarea {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}

/* Optimize touch scrolling */
.scroll-container {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}

/* Prevent text selection on mobile for UI elements */
.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
}

/* Force GPU acceleration for animated elements */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Optimize hover effects */
.hover-optimized {
  will-change: transform, opacity;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-optimized:hover {
  transform: translate3d(0, -8px, 0) scale(1.02);
}

/* Optimize group hover effects */
.group:hover .group-hover-optimized {
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

/* Optimize scale animations */
[class*="hover:scale"],
[class*="group-hover:scale"] {
  will-change: transform;
  transform: translateZ(0);
}

/* Optimize translate animations */
[class*="hover:translate"],
[class*="group-hover:translate"] {
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

/* Optimize opacity animations */
[class*="hover:opacity"],
[class*="group-hover:opacity"] {
  will-change: opacity;
}

/* Optimize rotating elements */
.animate-spin {
  will-change: transform;
  transform: translateZ(0);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg) translateZ(0);
  }
  to {
    transform: rotate(360deg) translateZ(0);
  }
}

/* Optimize bouncing elements */
.animate-bounce {
  will-change: transform;
  transform: translateZ(0);
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0) translateZ(0);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(-25%) translateZ(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

/* Optimize pulse animations */
.animate-pulse {
  will-change: opacity;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Optimize floating animations */
.animate-float {
  will-change: transform;
  transform: translateZ(0);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0) translateZ(0);
  }
  50% {
    transform: translateY(-10px) translateZ(0);
  }
}

/* Optimize marquee animations */
.animate-marquee-rtl,
.animate-marquee-ltr {
  will-change: transform;
  transform: translateZ(0);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    will-change: auto !important;
  }
}

/* Optimize card hover effects */
.card-hover-optimized {
  will-change: transform, box-shadow;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover-optimized:hover {
  transform: translate3d(0, -8px, 0) scale(1.02);
}

/* Optimize icon animations */
.icon-hover-optimized {
  will-change: transform;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.group:hover .icon-hover-optimized {
  transform: scale(1.1) translateZ(0);
}

/* Optimize text color transitions */
.text-hover-optimized {
  will-change: color;
  transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Lazy load optimization */
.lazy-load-fade {
  opacity: 0;
  transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.lazy-load-fade.visible {
  opacity: 1;
}

/* Optimize backdrop blur */
.backdrop-blur-optimized {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  will-change: backdrop-filter;
}

/* Content visibility for off-screen content */
.content-visibility-auto {
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}

/* Optimize images */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

img[loading="lazy"].loaded,
img.loaded {
  opacity: 1;
}

/* Optimize fonts */
@font-face {
  font-display: swap;
}


/* Mobile-Specific Optimizations */
@media (max-width: 768px) {
  /* Reduce animations on mobile for better performance */
  .animate-float,
  .animate-marquee-rtl,
  .animate-marquee-ltr {
    animation-duration: 6s;
  }
  
  /* Optimize hover effects for touch devices */
  @media (hover: none) {
    .hover-optimized:hover,
    .card-hover-optimized:hover {
      transform: none;
    }
    
    .hover-optimized:active,
    .card-hover-optimized:active {
      transform: scale(0.98);
    }
  }
  
  /* Optimize font sizes for mobile readability */
  body {
    font-size: 16px;
    line-height: 1.6;
  }
  
  /* Prevent zoom on input focus */
  input, select, textarea {
    font-size: 16px;
  }
  
  /* Optimize spacing for mobile */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Tablet Optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Landscape Mobile Optimization */
@media (max-width: 768px) and (orientation: landscape) {
  body {
    font-size: 14px;
  }
  
  /* Reduce vertical spacing in landscape */
  .py-16 {
    padding-top: 2rem;
    padding-bottom: 2rem;
  }
}

/* Print Optimization */
@media print {
  * {
    animation: none !important;
    transition: none !important;
  }
  
  .no-print {
    display: none !important;
  }
}

/* Mobile Touch Optimization for Interactive Elements */
button, a[role="button"], .btn {
  -webkit-tap-highlight-color: rgba(31, 24, 74, 0.1);
  cursor: pointer;
  user-select: none;
}

/* Improve button touch targets on mobile */
@media (max-width: 768px) {
  button, a[role="button"], .btn {
    min-height: 48px;
    padding: 12px 24px;
  }
  
  /* Ensure links are easily tappable */
  a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  
  /* Optimize form inputs for mobile */
  input, textarea, select {
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 8px;
  }
  
  /* Improve checkbox and radio button sizes */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 24px;
    min-height: 24px;
  }
}

/* Prevent double-tap zoom on buttons */
button, a[role="button"] {
  touch-action: manipulation;
}

/* Optimize focus states for mobile */
@media (max-width: 768px) {
  *:focus {
    outline: 2px solid #2874ae;
    outline-offset: 2px;
  }
  
  *:focus:not(:focus-visible) {
    outline: none;
  }
}

/* Mobile-friendly card layouts */
@media (max-width: 768px) {
  .grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .card {
    margin-bottom: 1rem;
  }
}

/* Optimize navigation for mobile */
@media (max-width: 768px) {
  nav a {
    padding: 12px 16px;
    display: block;
  }
}

/* Improve readability on small screens */
@media (max-width: 480px) {
  body {
    font-size: 14px;
    line-height: 1.5;
  }
  
  h1 {
    font-size: 1.75rem;
    line-height: 1.2;
  }
  
  h2 {
    font-size: 1.5rem;
    line-height: 1.3;
  }
  
  h3 {
    font-size: 1.25rem;
    line-height: 1.4;
  }
}
