/* Mobile CSS Fixes for Android Compatibility */
/* Specific fixes for image display and Android WebView issues */

/* Base image fixes for Android */
img {
  max-width: 100%;
  height: auto;
  display: block;
  /* Prevent layout shifts while loading */
  background-color: rgba(240, 241, 240, 0.1);
  /* Hardware acceleration for smoother rendering on Android */
  transform: translateZ(0);
  backface-visibility: hidden;
  /* Smooth loading transition */
  transition: opacity 0.3s ease;
}

/* Initial state for images loading - EXCEPT footer icons and hero card icons */
img:not([loading="eager"]):not(.footer-card-icon img):not(.footer-smile-icon img):not(.footer-diamond-icon img):not(.icon-container img):not(.flip-card-front img) {
  opacity: 0;
}

img.loaded,
img[loading="eager"],
.footer-card-icon img,
.footer-smile-icon img,
.icon-container img,
.flip-card-front img {
  opacity: 1;
}

/* Team carousel image fixes for Android */
.full-team-card img,
.member-avatar img,
.full-member-avatar img {
  object-fit: cover;
  object-position: center;
  /* Ensure consistent dimensions */
  min-height: 200px;
  width: 100%;
  /* Prevent image distortion on Android */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Fix for Android WebView rendering issues */
@supports (-webkit-appearance: none) {
  .full-team-card img,
  .member-avatar img {
    /* Force GPU acceleration on iOS/Android WebKit */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }
}

/* Placeholder styles for broken/loading images */
img[src*="placeholder"] {
  background: repeating-linear-gradient(
    45deg,
    #f0f1f0,
    #f0f1f0 10px,
    #e0e0e0 10px,
    #e0e0e0 20px
  );
  opacity: 0.7;
  border: 1px solid #ddd;
}

/* Error state for images */
img.error {
  background-color: #f5f5f5;
  border: 2px dashed #ccc;
  opacity: 0.6;
  position: relative;
}

/* Loading state */
img.loading {
  background: linear-gradient(-90deg, #f0f0f0 0%, #e0e0e0 50%, #f0f0f0 100%);
  background-size: 400% 400%;
  animation: loading-shimmer 1.5s ease-in-out infinite;
}

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

/* Android-specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  /* Android Chrome specific fixes */
  .full-team-carousel img {
    /* Prevent pixelation on Android */
    image-rendering: -webkit-optimize-contrast;
  }
  
  /* Fix for carousel drag performance on Android */
  .full-team-track {
    /* Improve scrolling performance */
    -webkit-overflow-scrolling: touch;
    will-change: transform;
  }
}

/* Mobile viewport fixes */
@media (max-width: 768px) {
  /* Ensure images scale properly on small screens */
  .full-team-card img,
  .member-avatar img {
    max-width: 100%;
    height: auto;
    object-fit: cover;
  }
  
  /* Fix for mobile carousel images */
  .full-member-avatar {
    overflow: hidden;
    border-radius: 8px;
  }
  
  .full-member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
  }
}

/* Extra small screens (Android phones) */
@media (max-width: 375px) {
  .full-team-card {
    /* Ensure cards don't break layout on small Android screens */
    min-width: 250px;
    max-width: 280px;
  }
  
  .full-member-avatar img {
    /* Ensure proper aspect ratio on small screens */
    aspect-ratio: 2/3;
    object-fit: cover;
  }
}

/* Retina/High-DPI display support for Android */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  img {
    /* Better rendering for high-DPI Android screens */
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Network-aware loading for slow connections */
@media (prefers-reduced-data: reduce) {
  /* For users with slow connections, show loading indicator */
  img:not([loading="eager"]) {
    opacity: 0.8;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  img {
    transition: none;
  }
  
  .loading {
    animation: none;
  }
}

/* Dark mode considerations for Android */
@media (prefers-color-scheme: dark) {
  img.error {
    background-color: #2a2a2a;
    border-color: #444;
  }
  
  img[src*="placeholder"] {
    background: repeating-linear-gradient(
      45deg,
      #2a2a2a,
      #2a2a2a 10px,
      #333 10px,
      #333 20px
    );
  }
}

/* Footer icon fixes - ensure they always display */
.footer-card-icon img:not(.footer-diamond-icon img),
.footer-smile-icon img {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  opacity: 1 !important;
  visibility: visible !important;
  /* Remove background for all footer icons */
  background: none !important;
  background-color: transparent !important;
  /* Force image to load and display immediately */
  transform: translateZ(0);
}

/* Specific fix for stalk us diamond icon - preserve original styling */
.footer-diamond-icon img {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  /* Don't force width/height for diamond icon - let CSS handle it */
  background: none !important;
  background-color: transparent !important;
}

/* Ensure footer icons have proper dimensions */
.footer-card-icon:not(.footer-diamond-icon) {
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
}

/* Firefox-specific fixes for flip cards and SVG images */
@-moz-document url-prefix() {
  /* Fix SVG rendering in flip cards for Firefox */
  .flip-card-front img,
  .icon-container img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    /* Force Firefox to render SVGs properly */
    image-rendering: auto !important;
    image-rendering: -moz-crisp-edges;
    /* Remove any background that might hide the image */
    background: none !important;
    background-color: transparent !important;
    opacity: 1 !important;
    visibility: visible !important;
    /* Force hardware acceleration */
    will-change: transform;
  }
  
  /* Ensure flip card containers have proper dimensions */
  .icon-container {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: visible !important;
    min-height: 80px !important;
    min-width: 80px !important;
    position: relative;
    /* Ensure container is visible */
    background: transparent !important;
  }
  
  /* Fix flip card transformation in Firefox */
  .flip-card-inner {
    transform-style: preserve-3d !important;
    -moz-transform-style: preserve-3d !important;
  }
  
  /* Force reflow for Firefox SVG loading */
  .flip-card .icon-container img,
  .flip-card:hover .icon-container img {
    transform: translateZ(0) !important;
    will-change: transform;
    backface-visibility: visible !important;
  }
  
  /* Specific fixes for hero section cards in Firefox desktop */
  .about-hero-cards .flip-card-front img {
    position: relative !important;
    z-index: 1 !important;
    display: block !important;
  }
  
  /* Force Firefox desktop to show the images */
  .eye-card img[src*="eye.svg"],
  .smile-card img[src*="smile.svg"], 
  .heart-card img[src*="heart.svg"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    height: auto !important;
  }
}