/* Optimized CSS for Wplace Color Converter */
/* Performance improvements and compatibility fixes */

/* Critical CSS for above-the-fold content */
:root {
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --accent-500: #f59e0b;
  --accent-600: #d97706;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  --transition-base: 200ms ease-out;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
}

/* Performance optimizations */
* {
  box-sizing: border-box;
}

/* Optimized range input styles with better browser support */
.range-input {
  flex: 1;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  position: relative;
}

/* Webkit browsers */
.range-input::-webkit-slider-track {
  background: var(--bg-tertiary);
  height: 8px;
  border-radius: 4px;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
  border: 2px solid white;
}

.range-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: var(--shadow-lg);
}

/* Firefox */
.range-input::-moz-range-track {
  background: var(--bg-tertiary);
  height: 8px;
  border-radius: 4px;
  border: none;
}

.range-input::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: var(--shadow-md);
}

/* Enhanced mobile navigation */
.mobile-nav {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  transform: translateY(-10px);
  opacity: 0;
  transition: all 0.3s ease-out;
}

.mobile-nav.open {
  display: block;
  transform: translateY(0);
  opacity: 1;
}

/* Improved accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-600);
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: var(--radius-md);
  z-index: 1000;
  font-weight: 500;
  transition: all var(--transition-base);
}

.skip-link:focus {
  top: 6px;
}

/* Focus indicators for better accessibility */
.nav-link:focus,
.mobile-nav-link:focus,
.upload-button:focus,
.cta-primary:focus,
.cta-secondary:focus {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* Loading animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* Error and success message styles */
.error-message,
.success-message {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 24px;
  border-radius: 12px;
  z-index: 10000;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  max-width: 400px;
  animation: slideInRight 0.3s ease-out;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.error-message {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.3);
}

.success-message {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.3);
}

/* Responsive optimizations */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2rem;
  }
  
  .hero-description {
    font-size: 1.125rem;
  }
  
  .section-title {
    font-size: 1.75rem;
  }
  
  .feature-card,
  .step-card,
  .community-card {
    padding: var(--space-6);
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 1.75rem;
  }
  
  .hero-description {
    font-size: 1rem;
  }
  
  .section-title {
    font-size: 1.5rem;
  }
  
  .cta-buttons {
    flex-direction: column;
    gap: var(--space-3);
  }
}

/* Print styles */
@media print {
  .site-header,
  .mobile-nav,
  .loading-overlay,
  .error-message,
  .success-message {
    display: none !important;
  }
  
  .hero-section {
    padding: 2rem 0;
  }
  
  .converter-section {
    page-break-before: always;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-light: #000000;
    --border-medium: #000000;
    --text-secondary: #000000;
  }
  
  .nav-link:hover,
  .mobile-nav-link:hover {
    background: #000000;
    color: #ffffff;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .loading-spinner {
    animation: none;
  }
}
