/* Mobile Performance Optimizations for BBOnWeb */

/* Critical rendering path optimizations */
.main-content {
  contain: layout style paint;
}

.article {
  contain: layout style;
}

/* Reduce repaints and reflows */
.houseguest-img-container,
.breaking-news-headline,
.bbonweb-article {
  will-change: transform;
}

.houseguest-img-container:hover,
.article:hover {
  will-change: auto;
}

/* Optimize animations for mobile */
@media (max-width: 900px) {
  /* Reduce motion for users who prefer it */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
  
  /* Optimize scroll performance */
  .main-content,
  .houseguest-container {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  /* Optimize font loading */
  body {
    font-display: swap;
  }
  
  /* Reduce layout shifts */
  .houseguest-img-container {
    aspect-ratio: 1;
  }
  
  .article img {
    aspect-ratio: 16/9;
    object-fit: cover;
  }
  
  /* Optimize touch scrolling */
  .houseguest-container {
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .houseguest-container::-webkit-scrollbar {
    display: none;
  }
  
  .houseguest-img-container {
    scroll-snap-align: start;
  }
  
  /* Optimize tab switching */
  .articles-column,
  .bbonweb-column {
    transform: translateZ(0);
  }
  
  .articles-column.active,
  .bbonweb-column.active {
    transform: translateZ(0);
  }
  
  /* Optimize mobile menu */
  .main-nav {
    transform: translateZ(0);
    backface-visibility: hidden;
  }
  
  /* Reduce paint complexity */
  .tab-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    z-index: -1;
  }
  
  /* Optimize glassmorphism effects */
  .mobile-tabs,
  .main-header {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  
  /* Optimize gradients */
  .tab-button.active {
    background: #FF8C00;
    background: linear-gradient(135deg, #993300 0%, #FF8C00 100%);
  }
  
  /* Optimize shadows */
  .article {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  }
  
  .article:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  }
}

/* Very small screens optimization */
@media (max-width: 400px) {
  /* Reduce complexity for very small screens */
  .mobile-tabs {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255, 255, 255, 0.95);
  }
  
  .main-header {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
  }
  
  /* Simplify animations */
  .tab-button,
  .main-nav a {
    transition: background-color 0.2s ease;
  }
  
  /* Optimize typography */
  .headline {
    line-height: 1.2;
  }
  
  .content {
    line-height: 1.5;
  }
}

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

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
  .main-header {
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
  }
  
  .mobile-tabs {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .tab-button {
    color: #fff;
  }
  
  .tab-button:not(.active):hover {
    background: rgba(255, 140, 0, 0.2);
    color: #FF8C00;
  }
}

/* Landscape orientation optimizations */
@media (max-width: 900px) and (orientation: landscape) {
  .main-header {
    padding: 0.5rem 0;
  }
  
  .header-container {
    padding: 0.5rem 1rem;
  }
  
  .logo img {
    max-width: 100px !important;
  }
  
  .main-nav {
    width: 320px;
  }
  
  .houseguest-container {
    padding: 0.75rem;
  }
  
  .houseguest-img-container {
    min-width: 60px;
    width: 60px;
    height: 60px;
  }
}

/* Print styles for mobile */
@media print {
  .main-header,
  .mobile-tabs,
  .header-social,
  .mobile-menu-btn,
  .mobile-nav-overlay {
    display: none !important;
  }
  
  .main-content {
    padding: 0;
    margin: 0;
  }
  
  .article {
    break-inside: avoid;
    margin-bottom: 1rem;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* Accessibility improvements */
@media (max-width: 900px) {
  /* Focus indicators */
  .tab-button:focus,
  .main-nav a:focus,
  .mobile-menu-btn:focus {
    outline: 3px solid #FF8C00;
    outline-offset: 2px;
  }
  
  /* High contrast mode */
  @media (prefers-contrast: high) {
    .tab-button.active {
      background: #000;
      color: #fff;
      border: 2px solid #fff;
    }
    
    .main-nav a:hover,
    .main-nav a.active {
      background: #000;
      color: #fff;
      border: 2px solid #fff;
    }
  }
  
  /* Reduced transparency for better readability */
  @media (prefers-reduced-transparency: reduce) {
    .mobile-tabs,
    .main-header {
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      background: rgba(255, 255, 255, 0.98);
    }
  }
}
