/* Tailwind CSS Optimizations */

/* Remove unused utilities and focus on performance */
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

/* Critical CSS - Above the fold styles */
@layer base {
  html {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    scroll-behavior: smooth;
  }

  body {
    line-height: 1.6;
    color: #1f2937;
    background-color: #ffffff;
  }
}

/* Component optimizations */
@layer components {

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

  /* Optimized transitions */
  .transition-optimized {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Optimized hover effects */
  .hover-lift {
    transition: transform 0.2s ease-out;
  }

  .hover-lift:hover {
    transform: translateY(-2px);
  }

  /* Search highlight */
  .catalogue-highlight {
    background-color: #fef3c7;
    color: #92400e;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-weight: 600;
  }

  /* Optimized grid layouts - Force 2 columns on mobile */
  .products-grid,
  #products-grid {
    display: grid !important;
    gap: 1rem !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  @media (min-width: 640px) {

    .products-grid,
    #products-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
      gap: 1.5rem !important;
    }
  }

  @media (min-width: 1024px) {

    .products-grid,
    #products-grid {
      grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
      gap: 2rem !important;
    }
  }

  /* Ensure images fit properly in aspect ratio containers */
  .aspect-square {
    aspect-ratio: 1 / 1;
    width: 100%;
    position: relative;
  }

  .aspect-square>img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
  }

  /* Line clamping for performance */
  .line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* Utility optimizations */
@layer utilities {

  /* GPU acceleration for animations */
  .gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
  }

  /* Optimized aspect ratios */
  .aspect-square {
    aspect-ratio: 1 / 1;
  }

  .aspect-video {
    aspect-ratio: 16 / 9;
  }

  .aspect-photo {
    aspect-ratio: 4 / 3;
  }

  /* Performance-focused visibility */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Content visibility for performance */
  .content-visibility-auto {
    content-visibility: auto;
    contain-intrinsic-size: 1px 1000px;
  }
}

/* Animations */
@keyframes loading-shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print optimizations */
@media print {
  .no-print {
    display: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.4;
  }

  h1,
  h2,
  h3 {
    page-break-after: avoid;
  }

  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }
}

/* Dark mode optimizations (if needed) */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }
}

/* High contrast support */
@media (prefers-contrast: high) {
  .hover-lift:hover {
    outline: 2px solid currentColor;
  }

  .catalogue-highlight {
    background-color: yellow;
    color: black;
    outline: 1px solid black;
  }
}

/* Focus management for accessibility */
.focus-visible:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Mobile optimizations */
@media (max-width: 640px) {
  .products-grid {
    gap: 0.75rem;
  }

  /* Reduce motion on mobile for better performance */
  .transition-optimized {
    transition-duration: 0.15s;
  }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 2dppx) {
  .icon {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Container queries (modern browsers) */
@container (min-width: 640px) {
  .products-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@container (min-width: 1024px) {
  .products-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}