/* Enhanced Performance and Optimization Styles */

/* Critical CSS for above-the-fold content */
@media (prefers-reduced-motion: no-preference) {
  .hero {
    background-attachment: fixed;
  }
  
  .parallax-element {
    will-change: transform;
  }
}

@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;
  }
  
  .hero {
    background-attachment: scroll;
  }
}

/* Performance optimizations */
.hero-content,
.glass-card,
.feature-item {
  contain: layout style paint;
}

/* Lazy loading optimization */
.hero {
  background-image: 
    linear-gradient(135deg, 
      rgba(26, 32, 44, 0.95) 0%, 
      rgba(45, 55, 72, 0.9) 50%, 
      rgba(0, 217, 255, 0.1) 100%
    );
}

.hero.loaded {
  background-image: 
    linear-gradient(135deg, 
      rgba(26, 32, 44, 0.95) 0%, 
      rgba(45, 55, 72, 0.9) 50%, 
      rgba(0, 217, 255, 0.1) 100%
    ), 
    url('images/temple-696x522.jpg');
}

/* Efficient GPU acceleration */
.btn,
.glass-card,
.nav-links a::after,
.feature-item {
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Optimize font loading */
@font-display: swap;

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a202c;
    --color-surface: rgba(45, 55, 72, 0.85);
    --color-text: #e2e8f0;
    --color-text-light: #a0aec0;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }
  
  .glass-card {
    border: 2px solid var(--color-primary);
  }
}

/* Print styles */
@media print {
  .nav, .footer, .cta-buttons, .mobile-menu {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .hero {
    background: none;
    color: black;
  }
}

/* Focus management for accessibility */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--color-primary);
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  opacity: 0;
  z-index: 9999;
}

.skip-to-content:focus {
  top: 6px;
  opacity: 1;
}

/* Enhanced loading states */
.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

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

/* Intersection Observer fallbacks */
.no-js .animate-on-scroll {
  opacity: 1;
  transform: translateY(0);
}

/* Connection-aware features */
@media (max-width: 768px) and (max-resolution: 1dppx) {
  .hero {
    background-image: none;
  }
  
  .glass-card {
    backdrop-filter: none;
    background: rgba(255, 255, 255, 0.95);
  }
}

/* Enhanced micro-interactions */
.btn:active {
  transform: translateY(-2px) scale(0.98);
}

.glass-card:active {
  transform: translateY(-5px) scale(0.99);
}

/* Improved error states */
.error-message {
  background: linear-gradient(135deg, #fed7d7, #feb2b2);
  color: #742a2a;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #fc8181;
  margin: 1rem 0;
}

/* Success states */
.success-message {
  background: linear-gradient(135deg, #c6f6d5, #9ae6b4);
  color: #276749;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #68d391;
  margin: 1rem 0;
}

/* Content loading optimization */
.content-loader {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Enhanced scroll indicators */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--gradient-accent);
  transform-origin: 0%;
  z-index: 9999;
}

/* Better focus indicators */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Enhanced card states */
.glass-card[aria-expanded="true"] {
  transform: scale(1.02);
  box-shadow: 0 25px 50px rgba(31, 38, 135, 0.6);
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .btn:hover,
  .glass-card:hover,
  .feature-item:hover {
    transform: none;
  }
  
  .btn:active {
    transform: scale(0.95);
  }
}

/* Reduced data mode */
.data-saver .hero {
  background-image: none;
  background: var(--gradient-primary);
}

.data-saver .glass-card {
  backdrop-filter: none;
  background: white;
}

/* Improved contrast ratios */
.card-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.footer-section ul li a:hover {
  color: white;
  text-decoration: underline;
}