/* ============================================================================
   MAMYPOKO PERFORMANCE CSS - Critical Optimizations
   This file contains performance enhancements that should be injected into all pages
   ============================================================================ */

/* Reset and normalize for optimal rendering */
* {
  box-sizing: border-box;
}

/* Critical CSS Reset Optimizations */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  padding: 0;
}

/* Font Display Optimization - Swap fonts without blocking render */
@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/figtree/v4/w-0cwyrzQTAf-m6jDSwPcw.woff2') format('woff2');
}

@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/figtree/v4/w-0cyrzQTAf-m6jDSwPcw.woff2') format('woff2');
}

@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/figtree/v4/w-0byrzQTAf-m6jDSwPcw.woff2') format('woff2');
}

/* Content Visibility for below-fold sections - prevents unnecessary rendering */
.hp-footer,
.faq-section,
.testimonials-section,
.related-products,
[data-below-fold] {
  content-visibility: auto;
  contain-intrinsic-size: auto 500px;
}

/* Will-change hints for animated elements - use sparingly */
.hp-nav-links a:hover,
.btn-submit:hover,
.hp-mobile-menu,
.carousel-item.active,
[data-animated] {
  will-change: transform, opacity;
}

/* Optimize images and media */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Lazy-loaded images styling */
img[loading="lazy"] {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: pulse 1.5s infinite;
}

img[loading="lazy"].loaded {
  background: none;
  animation: none;
}

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

/* Reduce repaints and reflows */
.top-navbar,
.hp-nav-links {
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* GPU acceleration for smooth scrolling */
body {
  scroll-behavior: smooth;
}

/* Optimize transitions and animations */
* {
  transition-duration: 0.2s;
}

a:hover,
button:hover {
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Loading states - minimal reflow */
.loading::after {
  content: '';
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-left: 0.5em;
  vertical-align: -0.125em;
  border: 0.25em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: loading 0.6s linear infinite;
}

@keyframes loading {
  to {
    transform: rotate(360deg);
  }
}

/* Optimize form rendering */
input,
textarea,
select {
  font-family: inherit;
  font-size: 16px;
}

/* Media queries for performance - serve different assets */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #e0e0e0;
  }
}

/* Critical viewport optimizations */
@media (max-width: 768px) {
  /* Disable GPU acceleration on mobile for memory conservation */
  .top-navbar,
  .hp-nav-links {
    transform: none;
  }

  /* Optimize touch targets */
  button,
  a,
  input {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Print styles for performance */
@media print {
  * {
    animation: none !important;
    transition: none !important;
    box-shadow: none !important;
  }

  body {
    background: white;
    color: black;
  }

  a {
    text-decoration: underline;
  }
}
