/* ==========================================================================
   NexGen Portable Staging — interaction & motion layer
   Plain CSS only. The design/utility layer is in styles.css.
   ========================================================================== */

/* ---------- Scroll reveal (removed after it finishes so card hovers stay snappy) ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Hero entrance ---------- */
[data-hero-in] {
  opacity: 0;
  transform: translateY(24px);
  animation: nx-hero-in 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
@keyframes nx-hero-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Hero: 60 second build bar (2.4s fill + 1.2s pause) ---------- */
.nx-build-bar {
  width: 0%;
  animation: nx-build 3.6s ease-in-out infinite;
}
@keyframes nx-build {
  0% {
    width: 0%;
  }
  66.666%,
  100% {
    width: 100%;
  }
}

/* ---------- Hero: crossfade text ---------- */
#hero-slide-text {
  transition: opacity 0.2s ease;
}
#hero-slide-text.is-fading {
  opacity: 0;
}

/* ---------- Search combobox ---------- */
.nx-search-shell.is-open {
  border-color: #155433;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(163, 230, 53, 0.35);
}

/* ---------- Small pop-in used by menus / search results ---------- */
.nx-pop {
  animation: nx-pop 0.15s ease-out both;
}
@keyframes nx-pop {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---------- Overlay dialogs ---------- */
.nx-overlay .nx-overlay-backdrop {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.nx-overlay.is-open .nx-overlay-backdrop {
  opacity: 1;
}

.nx-dialog {
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
}
.nx-dialog-right {
  transform: translateX(100%);
}
.nx-dialog-left {
  transform: translateX(-100%);
}
.nx-dialog-center {
  opacity: 0;
  transform: translateY(16px) scale(0.97);
}
.nx-overlay.is-open .nx-dialog-right,
.nx-overlay.is-open .nx-dialog-left {
  transform: translateX(0);
}
.nx-overlay.is-open .nx-dialog-center {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ---------- Promo details / mobile accordions ---------- */
.nx-collapse {
  overflow: hidden;
  transition: height 0.3s ease, opacity 0.3s ease;
}

/* ---------- Back to top ---------- */
#back-to-top.nx-visible {
  animation: nx-pop-soft 0.28s ease-out both;
}
@keyframes nx-pop-soft {
  from {
    opacity: 0;
    transform: scale(0.6) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ---------- Performance: content-visibility for offscreen sections ---------- */
#shop,
#video-showcase,
#case-studies,
#why-nexgen,
#faq {
  content-visibility: auto;
  contain-intrinsic-size: auto 900px;
}
footer {
  content-visibility: auto;
  contain-intrinsic-size: auto 600px;
}

/* Hero image performance — promote to own layer, reduce layout thrash */
[data-hero-img] {
  will-change: transform;
  content-visibility: auto;
}
[data-hero-geo] {
  will-change: transform;
}
/* Marquee animation — use GPU layer */
.animate-marquee {
  will-change: transform;
  transform: translateZ(0);
}

/* Lazy images — prevent layout shift with aspect placeholders where missing */
img[loading="lazy"] {
  content-visibility: auto;
}

/* ---------- Focus / motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  [data-hero-in] {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }
  .nx-build-bar {
    width: 100% !important;
    animation: none !important;
  }
}

/* ---------- FAQ + footer: prevent narrow-screen overflow ---------- */
#faq .relative.mx-auto.grid,
#contact .relative.mx-auto.grid,
#faq .relative.mx-auto.grid > *,
#contact .relative.mx-auto.grid > *,
#contact nav > div,
#contact address p,
#contact address a[href^="mailto:"],
#faq [data-faq-item],
#faq [data-faq-toggle],
#faq [data-faq-toggle] > span:nth-child(2),
#faq [data-faq-panel] > div,
#faq .rounded-3xl a,
#contact #newsletter-form,
#contact #newsletter-form > div,
#contact #newsletter-email {
  min-width: 0;
}

#faq [data-faq-panel] p,
#faq [data-faq-panel] button,
#faq .rounded-3xl a[href^="mailto:"],
#contact a[href^="mailto:"],
#contact nav a,
#contact .border-t p {
  overflow-wrap: anywhere;
}

#faq [data-faq-panel] button {
  max-width: 100%;
  white-space: normal;
}

#faq .rounded-3xl a svg {
  flex: 0 0 auto;
}

#contact #newsletter-form button {
  flex-shrink: 0;
  white-space: nowrap;
}

#contact .border-t p {
  max-width: 100%;
}

@media (max-width: 639px) {
  #faq .relative.mx-auto.grid {
    row-gap: 2.5rem;
  }
  #faq [data-faq-toggle] {
    gap: 0.75rem;
    padding-inline: 1rem;
  }
  #faq [data-faq-panel] p {
    padding-right: 1rem;
    padding-left: 1rem;
  }
  #contact .relative.mx-auto.grid {
    row-gap: 2.5rem;
    padding-block: 3rem;
  }
  #contact nav {
    column-gap: 1.5rem;
    row-gap: 1.5rem;
  }
  #contact .border-t > .mx-auto {
    align-items: stretch;
  }
  #contact .border-t > .mx-auto > p {
    text-align: center;
  }
}

/* ---------- Navbar dropdown panels & missing responsive utilities ---------- */
.w-\[min\(42rem\,calc\(100vw-2rem\)\)\] {
  width: min(42rem, calc(100vw - 2rem));
}
.w-\[min\(46rem\,calc\(100vw-3rem\)\)\] {
  width: min(46rem, calc(100vw - 3rem));
}
.hover\:text-forest-700:hover {
  color: #155433;
}
.hover\:bg-electric\/20:hover {
  background-color: rgba(163, 230, 53, 0.2);
}
.nx-mega-scroll {
  max-height: calc(100vh - 8.5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 359px) {
  #faq [data-faq-toggle] {
    gap: 0.625rem;
    padding-inline: 0.75rem;
  }
  #contact #newsletter-form button {
    gap: 0.375rem;
    padding-inline: 0.75rem;
    font-size: 0.8125rem;
  }
  #contact nav {
    column-gap: 1rem;
  }
}
