/*
  SIGNAL SWAP - TYPOGRAPHY & SPACING FIXES
  Fixes for glitchy text and spacing issues during scrolling
*/

/* ================================== */
/* CRITICAL TYPOGRAPHY FIXES          */
/* ================================== */

/* Fix font loading and rendering issues */
html {
  /* Improve text rendering on all platforms */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1;
  
  /* Prevent text selection glitches */
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  
  /* Stable scrolling behavior */
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  /* Fix base font rendering */
  font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6; /* More readable line height */
  letter-spacing: -0.01em; /* Subtle kerning improvement */
  
  /* Prevent layout shifts */
  font-display: swap;
  
  /* Stable text color transitions */
  color: var(--text-primary, #f8fafc);
  transition: color 0.3s ease;
}

/* ================================== */
/* HERO SECTION TEXT FIXES            */
/* ================================== */

.hero-title {
  /* Fix hero title responsiveness and readability */
  font-size: clamp(2.25rem, 4vw + 1rem, 4rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
  
  /* Prevent text overflow on small screens */
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  
  /* Stable gradient text */
  background: linear-gradient(135deg, #ffffff 0%, #00ff88 30%, #377dff 60%, #ffffff 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  
  /* Fix animation performance */
  will-change: background-position;
  transform: translateZ(0);
}

.hero-description {
  /* Fix description text readability */
  font-size: clamp(1rem, 2vw + 0.5rem, 1.25rem);
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 2rem;
  max-width: 100%;
  
  /* Prevent text overflow */
  word-wrap: break-word;
  overflow-wrap: break-word;
  
  /* Improve readability */
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* ================================== */
/* SECTION HEADERS & CONTENT FIXES    */
/* ================================== */

.section-header h2,
.gradient-text {
  /* Fix section heading responsiveness */
  font-size: clamp(1.875rem, 3vw + 1rem, 2.5rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-bottom: 1rem;
  
  /* Prevent text overflow */
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  
  /* Stable gradient rendering */
  background: linear-gradient(135deg, #ffffff 0%, #00ff88 30%, #377dff 60%, #ffffff 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  
  /* Prevent animation glitches */
  will-change: background-position;
  transform: translateZ(0);
}

.section-description,
.feature-content p {
  /* Fix body text readability */
  font-size: clamp(0.875rem, 1.5vw + 0.5rem, 1.125rem);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 1.5rem;
  
  /* Prevent text overflow */
  word-wrap: break-word;
  overflow-wrap: break-word;
  
  /* Improve readability */
  font-weight: 400;
  letter-spacing: 0.005em;
}

/* ================================== */
/* BUTTON TEXT FIXES                  */
/* ================================== */

.btn {
  /* Fix button text rendering */
  font-family: inherit;
  font-size: clamp(0.875rem, 1vw + 0.5rem, 1rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.025em;
  
  /* Prevent text selection and overflow */
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  
  /* Stable animations */
  will-change: transform;
  transform: translateZ(0);
}

/* ================================== */
/* NAVIGATION TEXT FIXES              */
/* ================================== */

.nav-link {
  /* Fix navigation text */
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.01em;
  
  /* Prevent text overflow */
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  
  /* Stable hover states */
  transition: color 0.25s ease, opacity 0.25s ease;
}

.brand {
  /* Fix brand text */
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.025em;
  
  /* Prevent text selection */
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* ================================== */
/* RESPONSIVE TEXT SPACING FIXES      */
/* ================================== */

/* Fix spacing hierarchy */
h1, .hero-title {
  margin-top: 0;
  margin-bottom: clamp(1rem, 2vw, 2rem);
}

h2, .section-header h2 {
  margin-top: 0;
  margin-bottom: clamp(0.75rem, 1.5vw, 1.5rem);
}

h3, .feature-content h3 {
  margin-top: 0;
  margin-bottom: clamp(0.5rem, 1vw, 1rem);
  font-size: clamp(1.125rem, 2vw + 0.5rem, 1.5rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

p {
  margin-top: 0;
  margin-bottom: clamp(0.75rem, 1.5vw, 1.25rem);
}

/* ================================== */
/* MOBILE TEXT FIXES                  */
/* ================================== */

@media (max-width: 768px) {
  .hero-title {
    font-size: clamp(1.875rem, 6vw, 2.5rem);
    line-height: 1.15;
    margin-bottom: 1rem;
  }
  
  .hero-description {
    font-size: clamp(0.9375rem, 3vw, 1.125rem);
    line-height: 1.6;
    margin-bottom: 1.5rem;
  }
  
  .section-header h2 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    line-height: 1.25;
    margin-bottom: 0.75rem;
  }
  
  .btn {
    font-size: clamp(0.875rem, 2vw, 1rem);
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1.5rem, 4vw, 2rem);
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: clamp(1.625rem, 7vw, 2.25rem);
    line-height: 1.2;
  }
  
  .hero-description {
    font-size: clamp(0.875rem, 3.5vw, 1rem);
    line-height: 1.55;
  }
  
  .section-header h2 {
    font-size: clamp(1.375rem, 6vw, 1.75rem);
    line-height: 1.3;
  }
}

/* ================================== */
/* ANIMATION PERFORMANCE FIXES        */
/* ================================== */

/* Prevent text animation glitches */
.scroll-reveal,
.animate-fade-in,
.animate-slide-in-left,
.animate-scale-in {
  /* GPU acceleration for smooth animations */
  will-change: transform, opacity;
  transform: translateZ(0);
  
  /* Prevent subpixel rendering issues */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Fix text during animations */
.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0) translateZ(0);
}

/* ================================== */
/* ACCESSIBILITY IMPROVEMENTS         */
/* ================================== */

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  html {
    scroll-behavior: auto;
  }
  
  .gradient-text,
  .hero-title {
    animation: none;
    background-position: 0% 0%;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .gradient-text,
  .hero-title {
    background: none;
    -webkit-text-fill-color: unset;
    color: white;
  }
  
  .hero-description {
    color: rgba(255, 255, 255, 0.95);
  }
}

/* ================================== */
/* PRINT STYLES                       */
/* ================================== */

@media print {
  .gradient-text,
  .hero-title {
    background: none;
    -webkit-text-fill-color: unset;
    color: black;
  }
  
  body {
    color: black;
    background: white;
  }
}

/* ================================== */
/* LOADING STATE FIXES               */
/* ================================== */

/* Prevent FOUT (Flash of Unstyled Text) */
.font-loading {
  visibility: hidden;
}

.font-loaded {
  visibility: visible;
}

/* Skeleton loading for better UX */
.text-skeleton {
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.1) 25%, 
    rgba(255, 255, 255, 0.2) 50%, 
    rgba(255, 255, 255, 0.1) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
  height: 1.2em;
}

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

/* ================================== */
/* CRITICAL RENDERING PATH FIXES      */
/* ================================== */

/* Optimize font loading */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Inter'), local('Inter-Regular'),
       url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfAZ9hiJ-Ek-_EeA.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: local('Inter SemiBold'), local('Inter-SemiBold'),
       url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuGKYAZ9hiJ-Ek-_EeA.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local('Inter Bold'), local('Inter-Bold'),
       url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuFuYAZ9hiJ-Ek-_EeA.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: local('Inter Black'), local('Inter-Black'),
       url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuDyYAZ9hiJ-Ek-_EeA.woff2') format('woff2');
}