/* ============================================
   GLOBAL PARALLAX & SCROLL SYSTEM
   Split-Layer Architecture with Jitter Prevention
   ============================================ */

/* GLOBAL SCROLL FIXES */
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  /* Prevent momentum scrolling issues on iOS */
  -webkit-overflow-scrolling: auto;
}

body {
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent repainting during scroll */
* {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-perspective: 1000;
  perspective: 1000;
}

/* Hero section safe area (prevents address bar intrusion) */
.hero-section {
  min-height: 100svh; /* Use svh for mobile safety */
  padding-top: env(safe-area-inset-top);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Address bar intrusion fix for short viewports */
@media (max-height: 700px) {
  .hero-section {
    min-height: calc(100svh + 60px);
    padding-top: 60px;
  }
}

/* PARALLAX LAYERS - GPU ACCELERATION */
[data-parallax-bg],
.parallax-bg,
.background-layer,
.hero-background {
  will-change: transform;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

[data-parallax-content],
.parallax-content,
.section-container,
.card-grid {
  will-change: transform;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

[data-parallax-text],
.parallax-text,
.text-block {
  will-change: opacity;
}

/* SMOOTH TRANSITIONS FOR SECTIONS */
.section-transition {
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* FOOTER SMOOTH ARRIVAL */
.site-footer {
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.8s ease-out, opacity 0.8s ease-out;
}

.site-footer.visible {
  transform: translateY(0);
  opacity: 1;
}

/* PREVENT JITTER AT PAGE BOUNDARIES */
section {
  position: relative;
  overflow: hidden;
}

/* Scroll container stability */
main, .container {
  position: relative;
  z-index: 1;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  body {
    -webkit-overflow-scrolling: touch;
    overflow-y: scroll;
  }

  .parallax-bg,
  .parallax-content {
    transform: translateZ(0);
    will-change: auto;
  }

  /* Reduce parallax intensity on mobile */
  :root {
    --parallax-intensity: 0.5;
  }
}

/* PREVENT TEXT SELECTION DURING SCROLL */
.parallax-layer,
[data-parallax] {
  user-select: none;
  -webkit-user-select: none;
}

/* Fix for sticky positioning with parallax */
nav.sticky, 
.sticky {
  position: sticky;
  z-index: 900;
}

/* Prevent flickering on transform */
.parallax-layer,
[data-parallax],
section {
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: auto;
}

/* SCROLL PERFORMANCE MONITORING */
:root {
  --scroll-velocity: 0;
  --parallax-easing: 0.05;
}

/* Loading states */
.parallax-loading {
  opacity: 0.9;
}

.parallax-loaded {
  opacity: 1;
  transition: opacity 0.3s ease-out;
}
