/* Performance Optimizations for AI Blog */

/* Critical CSS - Above the fold styles */
.site-header {
  will-change: transform;
  transform: translateZ(0);
}

/* GPU acceleration for smooth animations */
.menu-item a,
.post-thumbnail img,
.wp-block-button__link {
  will-change: transform;
  transform: translateZ(0);
}

/* Optimize font loading */
@font-face {
  font-family: 'Rubik';
  font-display: swap;
  src: local('Rubik'), url('https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;700&display=swap');
}

/* Lazy loading placeholder */
.lazy-loading {
  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;
  }
}

/* Optimize images */
img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

/* WebP support detection */
.webp img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: optimizeSpeed;
}

/* Smooth scrolling optimization */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Container queries for modern browsers */
@supports (container-type: inline-size) {
  .container {
    container-type: inline-size;
  }
  
  @container (min-width: 768px) {
    .responsive-text {
      font-size: 1.2rem;
    }
  }
}

/* CSS Grid fallback for older browsers */
@supports not (display: grid) {
  .grid-container {
    display: flex;
    flex-wrap: wrap;
  }
  
  .grid-item {
    flex: 1 1 300px;
  }
}

/* Preload critical resources */
.preload-critical {
  font-family: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Optimize animations */
.animate-fade-in {
  opacity: 0;
  animation: fadeIn 0.6s ease-in-out forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* Intersection Observer loading states */
.lazy-load {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.lazy-load.loaded {
  opacity: 1;
}

/* Critical path CSS for above-the-fold content */
.hero-section {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

@media (max-width: 768px) {
  .hero-section {
    background-attachment: scroll;
    min-height: 50vh;
  }
}

/* Optimize button interactions */
.wp-block-button__link,
.button,
.btn {
  cursor: pointer;
  transition: all 0.3s ease;
  touch-action: manipulation;
}

.wp-block-button__link:hover,
.button:hover,
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Optimize form elements */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
textarea {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 4px;
  border: 1px solid #ddd;
  padding: 12px 16px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(199, 0, 0, 0.1);
}

/* Optimize table styles */
.wp-block-table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
}

.wp-block-table th,
.wp-block-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.wp-block-table th {
  background-color: #f9f9f9;
  font-weight: 600;
}

/* Optimize quote blocks */
.wp-block-quote {
  border-left: 4px solid var(--color-primary);
  padding-left: 20px;
  margin: 1.5rem 0;
  font-style: italic;
}

.wp-block-quote cite {
  display: block;
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--color-gray);
  font-style: normal;
}

/* Optimize code blocks */
.wp-block-code {
  background-color: #f4f4f4;
  border-radius: 4px;
  padding: 16px;
  overflow-x: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Optimize gallery blocks */
.wp-block-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin: 1.5rem 0;
}

.wp-block-gallery .wp-block-image {
  margin: 0;
}

.wp-block-gallery img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 8px;
  transition: transform 0.3s ease;
}

.wp-block-gallery img:hover {
  transform: scale(1.05);
}

/* Print styles */
@media print {
  .site-header,
  .site-footer,
  .mobile-menu-bar,
  .wp-block-button,
  .navigation {
    display: none !important;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.4;
    color: #000;
    background: #fff;
  }
  
  a {
    color: #000;
    text-decoration: underline;
  }
  
  .entry-content {
    margin: 0;
    padding: 0;
  }
}
