/* Performance optimizations for Best Property in Navi Mumbai */

/* Image lazy loading */
img[data-src] {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

img[data-src].loaded {
  opacity: 1;
}

/* Smooth scrolling improvements */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

/* Reduce paint on scroll */
.main {
  will-change: transform;
}

/* Optimize animations */
.btn, .card, .modal {
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Preload critical fonts - system fonts are already optimized */

/* Optimize images */
img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Reduce layout shifts */
.card {
  contain: layout style paint;
}

/* Better mobile performance */
@media (max-width: 768px) {
  .cards {
    contain: layout style;
  }
  
  img {
    contain: layout;
  }
}

/* Loading states */
.loading {
  pointer-events: none;
  opacity: 0.6;
}

.btn.loading::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Optimized modal transitions */
.modal {
  transform: scale(0.95);
  opacity: 0;
  transition: all 0.2s ease-out;
}

.modal.open {
  transform: scale(1);
  opacity: 1;
}

/* Better form focus states */
input:focus, textarea:focus, select:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  transform: scale(1.01);
  transition: all 0.2s ease;
}

/* Error states */
.field-error {
  animation: slideDown 0.2s ease-out;
}

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

/* Success messages */
.form-message-success {
  animation: fadeInScale 0.3s ease-out;
}

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

/* Enhanced mobile touch interactions */
@media (max-width: 768px) {
  .btn {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 20px;
    transition: transform 0.15s ease;
  }
  
  .btn:active {
    transform: scale(0.96);
  }
  
  .card {
    transition: transform 0.2s ease;
  }
  
  .card:active {
    transform: scale(0.98);
  }
  
  input, textarea, select {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Better touch targets */
  .navlinks a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 12px 16px;
  }
  
  /* Swipe gestures for cards */
  .cards {
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
  }
  
  .card {
    scroll-snap-align: start;
  }
  
  /* Improved modal on mobile */
  .modal .dialog {
    margin: 0;
    border-radius: 0;
    max-height: 100vh;
    overflow-y: auto;
  }
  
  /* Better form spacing on mobile */
  .field {
    margin-bottom: 20px;
  }
  
  .field input,
  .field select,
  .field textarea {
    margin-bottom: 8px;
  }
}

/* Touch feedback for all interactive elements */
.btn, .navlinks a, .card a, input[type="submit"], button {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  user-select: none;
  -webkit-user-select: none;
}

/* Smooth scrolling for mobile */
@media (pointer: coarse) {
  html {
    scroll-behavior: smooth;
  }
  
  /* Reduce motion for users who prefer it */
  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }
    
    .btn, .card, .modal {
      transition: none;
    }
  }
}
