/* ============================================
   Responsive Enhancements & Polish
   Additional responsive improvements and mobile optimizations
   ============================================ */

/* ============================================
   Mobile Navigation Improvements
   ============================================ */
@media (max-width: 768px) {
  /* Ensure navigation is touch-friendly */
  nav a, .navigation a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 12px 16px;
  }
  
  /* Improve spacing on mobile */
  body {
    font-size: 16px;
  }
  
  /* Stack elements vertically on mobile */
  .cta-buttons {
    width: 100%;
  }
  
  .btn-primary, .btn-secondary {
    width: 100%;
    text-align: center;
  }
}

/* ============================================
   Tablet Optimizations
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  .papers-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .hero-section {
    padding: 50px 30px;
  }
}

/* ============================================
   Large Screen Enhancements
   ============================================ */
@media (min-width: 1400px) {
  .papers-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  body {
    font-size: 19px;
  }
}

/* ============================================
   Touch Device Optimizations
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .paper-card:hover {
    transform: none;
  }
  
  /* Make buttons more prominent on touch */
  .btn-primary, .btn-secondary {
    padding: 16px 36px;
    font-size: 18px;
  }
  
  /* Larger touch targets */
  .filter-btn {
    padding: 12px 20px;
    font-size: 16px;
  }
}

/* ============================================
   Print Optimizations
   ============================================ */
@media print {
  .hero-section {
    background: white !important;
    color: black !important;
    border: 1px solid #ddd;
  }
  
  .cta-buttons,
  .filter-section,
  .btn-primary,
  .btn-secondary {
    display: none !important;
  }
  
  .paper-card {
    page-break-inside: avoid;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}

/* ============================================
   Reduced Motion Support
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .paper-card:hover,
  .team-member:hover,
  .theme-card:hover {
    transform: none;
  }
}

/* ============================================
   Dark Mode Support (if theme supports it)
   ============================================ */
@media (prefers-color-scheme: dark) {
  /* Keep the site in light mode for now, but prepare structure */
  /* Uncomment and customize when ready for dark mode:
  
  :root {
    --text-primary: #E0E0E0;
    --text-secondary: #B0B0B0;
    --bg-primary: #1A1A1A;
    --bg-secondary: #2A2A2A;
    --border-color: #404040;
  }
  */
}

/* ============================================
   High Contrast Mode Support
   ============================================ */
@media (prefers-contrast: high) {
  .venue-badge,
  .tag,
  .btn-primary,
  .btn-secondary {
    border: 2px solid currentColor;
  }
  
  .paper-card,
  .team-member,
  .theme-card {
    border: 2px solid #000;
  }
}

/* ============================================
   Loading States
   ============================================ */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #2196F3;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================
   Smooth Scroll Behavior
   ============================================ */
html {
  scroll-behavior: smooth;
}

/* Disable for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ============================================
   Focus Indicators for Accessibility
   ============================================ */
*:focus {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}

/* ============================================
   Image Loading Optimization
   ============================================ */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

img[loading="lazy"] {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

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

/* ============================================
   Viewport Height Fix for Mobile
   ============================================ */
.full-height-mobile {
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

/* ============================================
   Safe Area Support for Notched Devices
   ============================================ */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
}

/* ============================================
   Container Queries (Progressive Enhancement)
   ============================================ */
@supports (container-type: inline-size) {
  .paper-card-container {
    container-type: inline-size;
  }
  
  @container (max-width: 350px) {
    .paper-card-content {
      padding: 16px;
    }
    
    .paper-card-title {
      font-size: 1em;
    }
  }
}

/* ============================================
   Utility Classes for Responsive Design
   ============================================ */
.hide-mobile {
  display: block;
}

.show-mobile {
  display: none;
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
  
  .show-mobile {
    display: block !important;
  }
}

.hide-tablet {
  display: block;
}

@media (min-width: 769px) and (max-width: 1024px) {
  .hide-tablet {
    display: none !important;
  }
}

/* ============================================
   Overflow Handling
   ============================================ */
body {
  overflow-x: hidden;
}

pre, code {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   Performance Optimizations
   ============================================ */
.paper-card,
.team-member,
.theme-card,
.btn-primary,
.btn-secondary {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Only apply will-change on hover for better performance */
@media (hover: hover) {
  .paper-card:hover,
  .team-member:hover,
  .theme-card:hover {
    will-change: transform, box-shadow;
  }
}
