/* Use CSS custom properties for repeated values */
:root {
  --brand-purple: #5a58c3;
  --brand-purple-light: #6b69d6;
  --bg-primary: #121019;
  --transition-fast: 0.2s ease;
  --transition-medium: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-light: 0 0 3px var(--brand-purple), 0 0 6px var(--brand-purple);
  --shadow-heavy: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Critical styles for immediate render */
html {
  scroll-behavior: smooth;
}

.animated-gradient {
  background: var(--bg-primary);
}

.aspect-video-reduced {
  aspect-ratio: 16 / 8.1;
}

/* Combine similar selectors for efficiency */
.liquid-button, 
.hover-lift, 
.footer-link {
  transition: var(--transition-medium);
  will-change: transform;
}

/* Optimized hover effects with GPU acceleration */
.hover-lift:hover {
  transform: translate3d(0, -8px, 0) scale(1.02);
  box-shadow: var(--shadow-heavy);
}

.footer-link:hover {
  color: var(--brand-purple);
  transform: translate3d(4px, 0, 0);
}

/* Optimize animations with containment */
.neon-glow {
  contain: layout style paint;
  box-shadow: var(--shadow-light);
  animation: neonPulse 2s ease-in-out infinite alternate;
}

/* Efficient keyframes using custom properties */
@keyframes neonPulse {
  0% { box-shadow: var(--shadow-light); }
  100% { box-shadow: 0 0 1px var(--brand-purple), 0 0 3px var(--brand-purple); }
}

/* Optimize carousel with better performance */
.logo-carousel {
  animation: logoScroll 22.5s linear infinite;
  contain: layout style paint;
  will-change: transform;
  transform: translateZ(0); /* Force GPU layer */
}

@keyframes logoScroll {
  to { transform: translate3d(-50%, 0, 0); }
}

/* Efficient pseudo-elements */
.liquid-button {
  position: relative;
  overflow: hidden;
}

.liquid-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: translate3d(-100%, 0, 0);
  transition: transform var(--transition-medium);
  will-change: transform;
  pointer-events: none;
}

.liquid-button:hover::before {
  transform: translate3d(100%, 0, 0);
}

/* Scroll animations with containment */
.animate-on-scroll {
  contain: layout style;
  will-change: opacity, transform;
}

/* Optimized image rendering */
img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: optimizeSpeed;
}

/* Performance optimizations for frequently used elements */
.backdrop-blur-reduced {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Additional performance helpers */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Text shimmer effect - only load if needed */
.text-shimmer {
  background: linear-gradient(90deg, #fff 0%, var(--brand-purple) 50%, #fff 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 3s ease-in-out infinite;
  contain: layout style paint;
}

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

/* ========================================
   POPUP FORM STYLES
   ======================================== */

/* Popup overlay with optimized backdrop */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-medium);
  contain: layout style paint;
}

.popup-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* Popup form container */
.popup-form {
  background: linear-gradient(135deg, #1a1825 0%, #1f1b2e 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-heavy);
  transform: translateY(20px) scale(0.95);
  transition: all var(--transition-medium);
  position: relative;
  contain: layout style paint;
}

.popup-overlay.show .popup-form {
  transform: translateY(0) scale(1);
}

/* Form inputs with consistent styling */
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  color: white;
  font-size: 1rem;
  font-family: inherit;
  transition: all var(--transition-medium);
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: var(--brand-purple);
  box-shadow: 0 0 0 3px rgba(90, 88, 195, 0.1);
  background: rgba(255, 255, 255, 0.08);
}

.form-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

/* Textarea specific styling */
.form-input[type="textarea"],
textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

/* Submit button with brand styling */
.submit-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, var(--brand-purple), var(--brand-purple-light));
  border: none;
  border-radius: 0.5rem;
  color: white;
  font-weight: 600;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-medium);
  position: relative;
  overflow: hidden;
}

.submit-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--brand-purple-light), #7c6ce8);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(90, 88, 195, 0.3);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Close button styling */
.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color var(--transition-fast);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
}

.close-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

/* Form labels */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.5rem;
}

/* Status messages */
.form-status {
  text-align: center;
  font-size: 0.875rem;
  padding: 0.5rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

.form-status.success {
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.form-status.error {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Form spacing utilities */
.form-group {
  margin-bottom: 1rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

/* Media queries for popup responsiveness */
@media (max-width: 768px) {
  .popup-form {
    padding: 1.5rem;
    margin: 1rem;
    max-width: calc(100% - 2rem);
  }
  
  .popup-overlay {
    padding: 1rem;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
}

@media (max-width: 480px) {
  .popup-form {
    padding: 1rem;
  }
  
  .form-input {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

/* Reduce motion for popup animations */
@media (prefers-reduced-motion: reduce) {
  .popup-overlay,
  .popup-form,
  .submit-btn {
    transition-duration: 0.01ms !important;
  }
  
  .popup-overlay.show .popup-form {
    transform: none;
  }
}

/* Media queries for performance on smaller devices */
@media (max-width: 768px) {
  .hover-lift:hover {
    transform: none; /* Disable expensive transforms on mobile */
  }
  
  .neon-glow {
    animation: none; /* Disable animations on mobile for battery life */
  }
}

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

/* Print styles */
@media print {
  .neon-glow,
  .liquid-button::before,
  .logo-carousel {
    animation: none;
  }
  
  .hover-lift:hover {
    transform: none;
  }
  
  .popup-overlay {
    display: none !important;
  }
}