/* Critical Performance CSS - Load early to prevent CLS */

/* Font loading optimizations */
@font-face {
  font-family: 'Inter';
  font-display: swap;
  src: local('Inter'), url('/_next/static/media/inter-var.woff2') format('woff2');
  font-weight: 100 900;
}

/* Prevent layout shifts from font loading */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  font-display: swap;
}

/* Image optimization */
img {
  max-width: 100%;
  height: auto;
  font-size: 0; /* Prevent alt text from causing layout shifts */
}

/* Reserve space for images with aspect ratios */
.aspect-video { aspect-ratio: 16/9; }
.aspect-square { aspect-ratio: 1/1; }
.aspect-[4/3] { aspect-ratio: 4/3; }
.aspect-[16/10] { aspect-ratio: 16/10; }
.aspect-[3/2] { aspect-ratio: 3/2; }

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

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

/* Prevent button layout shifts */
button, .btn, input[type="button"], input[type="submit"] {
  min-height: 44px;
  box-sizing: border-box;
  contain: layout style paint;
}

/* Prevent form field layout shifts */
input, textarea, select {
  min-height: 44px;
  box-sizing: border-box;
  contain: layout style paint;
}

/* Prevent navigation layout shifts */
nav, header {
  contain: layout style paint;
}

/* Prevent footer layout shifts */
footer {
  contain: layout style;
}

/* Critical above-the-fold optimizations */
.above-fold {
  contain: layout style paint;
  content-visibility: visible;
}

.below-fold {
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}

/* Prevent carousel/slider layout shifts */
.carousel-container, .slider-container {
  min-height: 400px;
  contain: layout style paint;
}

/* Prevent modal/overlay layout shifts */
.modal, .dialog, .overlay {
  position: fixed;
  inset: 0;
  contain: layout style paint;
}

/* Prevent grid layout shifts */
.grid-container {
  contain: layout style;
}

/* Animation performance optimizations */
.animated {
  will-change: transform;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
  perspective: 1000px;
  contain: layout style paint;
}

/* Hover state optimizations */
.hover-optimized {
  transition: none;
}

.hover-optimized:hover {
  transition: all 0.2s ease;
}

/* Prevent text content layout shifts */
.text-container {
  word-wrap: break-word;
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
          hyphens: auto;
}

/* Loading state optimizations */
.loading-container {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  contain: layout style paint;
}

/* Video embed optimization */
.video-embed {
  aspect-ratio: 16/9;
  background: #000;
  position: relative;
  contain: layout style paint;
}

/* Map embed optimization */
.map-embed {
  min-height: 400px;
  background: #e5e7eb;
  contain: layout style paint;
}

/* Social media embed optimization */
.social-embed {
  min-height: 400px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  contain: layout style paint;
}

/* Table optimization */
table {
  table-layout: fixed;
  width: 100%;
  contain: layout style;
}

/* Accordion/collapsible optimization */
.accordion-content {
  overflow: hidden;
  transition: max-height 0.3s ease;
  contain: layout style;
}

/* Tab content optimization */
.tab-content {
  min-height: 200px;
  contain: layout style paint;
}

/* Card component optimization */
.card {
  contain: layout style paint;
}

/* List optimization */
.list-container {
  contain: layout style;
}

/* Prevent search result layout shifts */
.search-results {
  min-height: 300px;
  contain: layout style paint;
}

/* Prevent pagination layout shifts */
.pagination {
  min-height: 60px;
  contain: layout style paint;
}

/* Prevent breadcrumb layout shifts */
.breadcrumb {
  min-height: 40px;
  contain: layout style paint;
}

/* Critical utility classes */
.prevent-cls {
  contain: layout style paint;
}

.preserve-space {
  min-height: inherit;
}

.stable-height {
  height: auto;
  min-height: -webkit-fit-content;
  min-height: fit-content;
}

/* Responsive image containers */
@media (max-width: 768px) {
  .responsive-image-container {
    aspect-ratio: 4/3;
  }
}

@media (min-width: 769px) {
  .responsive-image-container {
    aspect-ratio: 16/9;
  }
}

/* Print optimizations */
@media print {
  .skeleton, .loading-container {
    display: none;
  }
  
  img {
    max-width: 100% !important;
    height: auto !important;
  }
}

/* Reduced motion optimizations */
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
  
  .animated {
    animation: none;
    transition: none;
  }
}
/* Critical Above-the-Fold CSS - Inline for fastest render */

/* Essential header styles */
.fixed.inset-x-0.top-0.z-50 {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 50;
  background-color: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Hero section critical styles */
.hero-section {
  min-height: 60vh;
  display: flex;
  align-items: center;
  padding: 2rem 1rem;
}

/* Button hover states for CTA optimization */
.btn-primary {
  background-color: #1e40af;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background-color: #1d4ed8;
  transform: translateY(-1px);
}

/* Critical grid layout */
.responsive-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .responsive-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .responsive-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Prevent layout shift for 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; }
}
