/* ============================================
   NEXUS DIGITAL — Animations & Transitions
   Smooth, performant, GPU-accelerated
   ============================================ */

/* ── Keyframes ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translate3d(0, 40px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes fadeDown {
  from { opacity: 0; transform: translate3d(0, -30px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes fadeLeft {
  from { opacity: 0; transform: translate3d(30px, 0, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes fadeRight {
  from { opacity: 0; transform: translate3d(-30px, 0, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideUp {
  from { transform: translate3d(0, 100%, 0); }
  to { transform: translate3d(0, 0, 0); }
}
@keyframes ping {
  0% { transform: scale(1); opacity: 0.8; }
  75%, 100% { transform: scale(2.2); opacity: 0; }
}
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(0, -10px, 0); }
}
@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1); opacity: 0.3; }
  100% { transform: scale(0.9); opacity: 0.6; }
}
@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes draw-line {
  from { stroke-dashoffset: 1000; }
  to { stroke-dashoffset: 0; }
}
@keyframes count-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes blob {
  0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
  25% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
  50% { border-radius: 50% 60% 30% 60% / 30% 50% 70% 60%; }
  75% { border-radius: 60% 40% 60% 40% / 70% 40% 50% 60%; }
}
@keyframes typewriter {
  from { width: 0; }
  to { width: 100%; }
}

/* ── Scroll Reveal System ── */
/* Base - all elements start hidden */
[data-reveal] {
  opacity: 0;
  will-change: opacity, transform;
  transition-property: opacity, transform;
  transition-duration: 0.7s;
  transition-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Direction variants */
[data-reveal="up"] { transform: translate3d(0, 50px, 0); }
[data-reveal="down"] { transform: translate3d(0, -30px, 0); }
[data-reveal="left"] { transform: translate3d(40px, 0, 0); }
[data-reveal="right"] { transform: translate3d(-40px, 0, 0); }
[data-reveal="scale"] { transform: scale(0.9); }
[data-reveal="fade"] { transform: none; }

/* Revealed state — will-change removed after animation to free GPU memory */
[data-reveal].is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  will-change: auto;
}

/* Stagger delays via data-delay attribute */
[data-delay="1"] { transition-delay: 0.1s; }
[data-delay="2"] { transition-delay: 0.2s; }
[data-delay="3"] { transition-delay: 0.3s; }
[data-delay="4"] { transition-delay: 0.4s; }
[data-delay="5"] { transition-delay: 0.5s; }
[data-delay="6"] { transition-delay: 0.6s; }

/* ── Hero Entrance Animations (fast: ~0.8s total) ── */
.hero__badge { animation: fadeUp 0.55s 0.05s cubic-bezier(0.25,0.46,0.45,0.94) both; }
.hero h1 { animation: fadeUp 0.55s 0.1s cubic-bezier(0.25,0.46,0.45,0.94) both; }
.hero__subtitle { animation: fadeUp 0.55s 0.18s cubic-bezier(0.25,0.46,0.45,0.94) both; }
.hero .btn-group { animation: fadeUp 0.55s 0.25s cubic-bezier(0.25,0.46,0.45,0.94) both; }
.hero__stats { animation: fadeUp 0.55s 0.32s cubic-bezier(0.25,0.46,0.45,0.94) both; }
.hero__tech { animation: fadeUp 0.55s 0.38s cubic-bezier(0.25,0.46,0.45,0.94) both; }
.hero__mockups { animation: fadeLeft 0.7s 0.2s cubic-bezier(0.25,0.46,0.45,0.94) both; }

/* ── Card Hover Micro-Interactions ── */
/* will-change removed from permanent state — applied only on hover for perf */
.service-card:hover,
.portfolio-card:hover,
.process-card:hover,
.why-card:hover,
.pricing-card:hover {
  will-change: transform;
}

/* Smooth border-top reveal on service cards */
.service-card::before {
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.service-card:hover::before { transform: scaleX(1); }

/* Portfolio card overlay shift */
.portfolio-card__desc {
  opacity: 0; transform: translate3d(0, 8px, 0);
  transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.portfolio-card:hover .portfolio-card__desc {
  opacity: 1; transform: translate3d(0, 0, 0);
}

/* Link arrow animation */
.service-card__link svg,
.btn--ghost svg {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.service-card__link:hover svg,
.btn--ghost:hover svg {
  transform: translateX(4px);
}

/* ── Button Press Effect ── */
.btn:active {
  transform: translateY(0) scale(0.97) !important;
  transition-duration: 0.1s;
}

/* ── FAQ Accordion Animation ── */
.faq-item__answer {
  max-height: 0; overflow: hidden;
  transition: max-height 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              padding 0.35s ease;
}
.faq-item.is-open .faq-item__answer {
  max-height: 600px; /* Generous height for longer FAQ answers */
}
.faq-item__icon {
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.faq-item.is-open .faq-item__icon {
  transform: rotate(45deg);
}

/* ── Contact Form Step Transitions ── */
.form-step {
  display: none;
}
.form-step.is-active {
  display: block;
  animation: fadeUp 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
.form-success.is-visible {
  animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── Form Option Selection ── */
.form-option {
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.form-option.is-selected {
  transform: scale(1.02);
}

/* ── Floating Elements ── */
.fab-whatsapp {
  animation: float 3.5s ease-in-out infinite;
}

/* ── Orb Ambient Animation ── */
.hero__orb--1 { animation: blob 12s ease-in-out infinite; }
.hero__orb--2 { animation: blob 15s ease-in-out infinite reverse; }
/* Disable expensive blob + blur animations on mobile */
@media (max-width: 768px) {
  .hero__orb--1, .hero__orb--2 {
    animation: none;
    filter: blur(60px); /* Reduced blur for mobile perf */
  }
}

/* ── Counter Animation ── */
.counter-animated {
  animation: count-up 0.5s ease both;
}

/* ── Image/Mockup Subtle Hover ── */
.mockup {
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.portfolio-card:hover .mockup {
  transform: scale(1.03);
}

/* ── Smooth Scroll Progress Bar ── */
.scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; z-index: 200;
  background: linear-gradient(90deg, var(--blue), var(--cyan), var(--orange));
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.1s linear;
}

/* ── Page Transition ── */
.page-transition {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--navy);
  transform: translate3d(0, 100%, 0);
  transition: transform 0.5s cubic-bezier(0.76, 0, 0.24, 1);
}
.page-transition.is-active {
  transform: translate3d(0, 0, 0);
}

/* ── Loading Skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--bg) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
}

/* ── Form Step Slide Transitions ── */
@keyframes stepSlideIn {
  from { opacity: 0; transform: translate3d(30px, 0, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes stepSlideOut {
  from { opacity: 1; transform: translate3d(0, 0, 0); }
  to { opacity: 0; transform: translate3d(-30px, 0, 0); }
}
.form-step.slide-in { animation: stepSlideIn 0.35s var(--ease) both; }
.form-step.slide-out { animation: stepSlideOut 0.25s var(--ease) both; }

/* ── Form Error States ── */
.field__error {
  border-color: #EF4444 !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.15) !important;
}
.field__error-text {
  color: #EF4444; font-size: 0.78rem; font-weight: 500;
  margin-top: 4px;
}

/* ── Dark Mode Toggle Transition ── */
@keyframes themeSwitch {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}
[data-theme-transitioning] {
  animation: themeSwitch 0.3s ease;
}

/* ── Accessibility: Reduce Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
