/**
 * Quomodo Core GSAP Animations — FULL CSS (refined)
 * - Safe pin behavior (no layout breakage)
 * - Scoped anti-FOUC
 * - ScrollSmoother shells (header gap via CSS var)
 * - Performance tweaks without overusing !important
 */

/* --- Global basics --- */
html {
  scroll-behavior: auto !important;
} /* avoid fighting Smoother */
html,
body {
  height: 100%;
}

/* --- Performance: be selective (avoid star-descendant rules) --- */
.quomodo-animating {
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  transform: translateZ(0);
}
.quomodo-animating .char,
.quomodo-animating .word,
.quomodo-animating .line,
.quomodo-animating img {
  will-change: transform, opacity;
  backface-visibility: hidden;
}

/* --- Anti-FOUC: only on nodes that declare animations --- */
.quomodo-animating[data-quomodo-animation="fade"]:not(.quomodo-pin-element),
.quomodo-animating[data-quomodo-animation="move"]:not(.quomodo-pin-element),
.quomodo-animating[data-quomodo-text-animation]:not(.quomodo-pin-element),
.quomodo-animating[data-quomodo-image-animation]:not(.quomodo-pin-element) {
  opacity: 0;
  visibility: visible;
}

/* --- Pin root (minimal; allow inner animations to control opacity) --- */
.quomodo-pin-element {
  position: relative;
  z-index: 1;
  min-height: 1px;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

/* Nested pins: light z-index bump to keep stacking sane */
.quomodo-pin-element .quomodo-pin-element {
  z-index: 2;
}

/* ScrollTrigger pin spacer tuning (local overflow relaxor) */
.pin-spacer {
  overflow: visible !important; /* avoid cropping during transform pin */
  contain: layout paint style; /* micro-optimization */
  will-change: contents;
}
.pin-spacer > .quomodo-pin-element {
  transform: translate3d(0, 0, 0);
}

/* --- ScrollSmoother shell (wrapper/content) --- */
#qmd-smooth-wrapper,
.ScrollSmoother-wrapper {
  position: relative; /* keep relative; fixed breaks sticky UI */
  width: 100%;
  min-height: 100%;
  isolation: isolate; /* prevent z-index clashes with headers/modals */
  overflow: hidden; /* wrapper may clip; content is transformed */
}
#qmd-smooth-content,
.ScrollSmoother-content {
  position: relative;
  width: 100%;
  min-height: 100%;
  will-change: transform;
  transform: translateZ(0);
  padding-top: var(--fixed-header-gap, 0px); /* JS sets header+adminbar gap */
}

/* (Optional) Admin bar tweaks are handled via the header gap var; no top shift needed here */

/* --- Mouse move effects --- */
.quomodo-mouse-move {
  transition: transform 0.1s ease-out;
  transform: translate3d(0, 0, 0);
}

/* --- Loading hook if you gate elements before JS runs --- */
.quomodo-gsap-loading {
  opacity: 0;
}

/* --- Text animation helpers --- */
.quomodo-text-animation .char,
.quomodo-text-animation .word {
  display: inline-block;
  will-change: transform;
}
.quomodo-text-animation .word {
  white-space: nowrap;
}
.quomodo-text-animation .line,
.anim-reveal-line {
  display: block;
  overflow: hidden;
}

/* --- text_invert helpers (HSL triplet stored in --text-color) --- */
.quomodo-t-animation-text_invert .elementor-widget-container {
  --text-color: 0, 0%, 0%;
}
.invert-line {
  background-image: linear-gradient(
    to right,
    hsla(var(--text-color), 1) 50%,
    hsla(var(--text-color), 0.3) 50%
  );
  background-size: 200% 100%;
  background-position-x: 100%;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  display: inline-block;
  padding: 0.02em 0;
}
/* Fallback when ScrollTrigger absent → reveal immediately */
html.no-scrolltrigger .invert-line {
  background-position-x: 0;
}

/* --- ScrollTrigger markers (debug only; safe to keep) --- */
.gsap-marker-start,
.gsap-marker-end,
.gsap-marker-scroller-start,
.gsap-marker-scroller-end {
  position: absolute;
  left: 0;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
}
.gsap-marker-start {
  color: green;
}
.gsap-marker-end {
  color: red;
}
.gsap-marker-scroller-start {
  color: blue;
}
.gsap-marker-scroller-end {
  color: purple;
}

/* --- DO NOT globally force overflow visible on Elementor containers ---
   If a specific section needs relaxed overflow for a clip issue, scope it:
   .qmd-pin-scope .elementor-widget-container { overflow: visible; }
*/

/* --- Mobile + Reduced motion --- */
@media (max-width: 768px) {
  .quomodo-animating {
    animation-duration: 0.5s !important;
    transition-duration: 0.5s !important;
  }
  .quomodo-mouse-move {
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .quomodo-animating {
    animation: none !important;
    transition: none !important;
  }
  [data-quomodo-animation] {
    opacity: 1 !important;
    transform: none !important;
  }
  .quomodo-mouse-move {
    transform: none !important;
  }
}

/* --- High contrast support (optional) --- */
@media (prefers-contrast: high) {
  .gsap-marker-start,
  .gsap-marker-end,
  .gsap-marker-scroller-start,
  .gsap-marker-scroller-end {
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 4px;
    border-radius: 2px;
  }
}
