/* =============================================================================
   ANIMATIONS, TRANSITIONS & INTERACTION COMPONENTS
   Tailwind base tokens + XGate animation library (xg-* classes).

   CSS only — for interactive JS (scroll-reveal, flashlight), load animations.js
   ============================================================================= */

/* =============================================================================
   PREFERS-REDUCED-MOTION — Respeito global à preferência do usuário
   =============================================================================
   Usuários que ativaram "Reduce Motion" no SO (acessibilidade — vestibular,
   foto-sensitividade, simulator-sickness) recebem todas as animações
   neutralizadas. Cobre keyframes, transitions, scroll behavior e iterações
   automáticas. Override pontual disponível via `:not(.allow-motion)` se um
   componente futuro precisar manter movimento essencial. */
@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;
  }
}


/* =============================================================================
   1. TOKENS (Custom Properties)
   ============================================================================= */

@layer theme {
  :root {
    /* ── Easing Functions ── */
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

    /* ── XGate Easing ── */
    --xg-ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --xg-ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* ── Tailwind Animation Shorthands ── */
    --animate-spin: spin 1s linear infinite;
    --animate-ping: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
    --animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    --animate-bounce: bounce 1s infinite;

    /* ── Transitions ── */
    --default-transition-duration: 150ms;
    --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  }
}


/* =============================================================================
   2. KEYFRAMES
   ============================================================================= */

/* ── Tailwind Base ── */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes ping {

  75%,
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }

  50% {
    transform: none;
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

/* ── XGate: Entrance ── */

@keyframes xg-fade-up {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.98);
    filter: blur(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes xg-fade-up-simple {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── XGate: Text ── */

@keyframes xg-text-slide {
  0% {
    transform: translateY(110%);
    opacity: 0;
  }

  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── XGate: Marquee ── */

@keyframes xg-marquee {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(-50%);
  }
}

/* ── XGate: Shimmer ── */

@keyframes xg-shimmer {
  0% {
    transform: translateX(-150%) skewX(-15deg);
  }

  100% {
    transform: translateX(200%) skewX(-15deg);
  }
}

/* ── XGate: Beam Spin ── */

@keyframes xg-beam-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ── XGate: Spin (alias) ── */

@keyframes xg-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ── XGate: Float ── */

@keyframes xg-float {

  0%,
  100% {
    transform: translate(0, 0);
  }

  33% {
    transform: translate(30px, -50px);
  }

  66% {
    transform: translate(-20px, 20px);
  }
}

/* ── XGate: Pulse ── */

@keyframes xg-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* ── XGate: Bounce ── */

@keyframes xg-bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-25%);
  }
}


/* =============================================================================
   3. SCROLL REVEAL
   Elements animate when scrolling into view.
   Requires JS: animations.js (auto-initializes)
   ============================================================================= */

/* .xg-reveal — adds "active" class when in view */
.xg-reveal {
  opacity: 0;
  animation-fill-mode: forwards;
}

.xg-reveal.active {
  animation: xg-fade-up 1s var(--xg-ease-out-expo) forwards;
}

/* .xg-scroll-reveal — unpauses animation when in view */
.xg-scroll-reveal {
  animation-play-state: paused !important;
}

.xg-scroll-reveal.animate {
  animation-play-state: running !important;
}

/* ── Stagger Delays ── */
.xg-delay-100 {
  animation-delay: 0.1s;
}

.xg-delay-200 {
  animation-delay: 0.2s;
}

.xg-delay-300 {
  animation-delay: 0.3s;
}

.xg-delay-400 {
  animation-delay: 0.4s;
}

.xg-delay-500 {
  animation-delay: 0.5s;
}

.xg-delay-600 {
  animation-delay: 0.6s;
}

.xg-delay-700 {
  animation-delay: 0.7s;
}

.xg-delay-800 {
  animation-delay: 0.8s;
}

.xg-delay-1000 {
  animation-delay: 1s;
}


/* =============================================================================
   4. BUTTONS
   Beam borders, shimmer effects, hover states.
   ============================================================================= */

/* ── Base Button ── */
.xg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s var(--xg-ease-out-expo);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  border: none;
}

.xg-btn-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.2);
}

.xg-btn-outline {
  background: transparent;
  border: 1px solid currentColor;
  opacity: 0.6;
}

.xg-btn-outline:hover {
  opacity: 1;
}

/* ── Beam Button ── */
.xg-beam-wrapper {
  position: relative;
  display: inline-flex;
  padding: 2px;
  border-radius: 9999px;
  overflow: hidden;
  cursor: pointer;
  transform: translateZ(0);
  transition: transform 0.3s;
}

.xg-beam-wrapper:hover {
  transform: scale(1.02);
}

.xg-beam-border {
  position: absolute;
  inset: -200%;
  background: conic-gradient(from 0deg, transparent 0 320deg, currentColor 360deg);
  animation: xg-beam-spin 3s linear infinite;
}

.xg-beam-inner {
  position: relative;
  background: inherit;
  border-radius: 9999px;
  padding: 0.75rem 2rem;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 1;
}

/* ── Shimmer Button ── */
.xg-shimmer-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 2.5rem;
  border-radius: 9999px;
  cursor: pointer;
  border: none;
}

.xg-shimmer-effect {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

.xg-shimmer-effect::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  transform: translateX(-150%) skewX(-15deg);
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.xg-shimmer-btn:hover .xg-shimmer-effect::after {
  animation: xg-shimmer 1.5s infinite;
  opacity: 1;
}

.xg-shimmer-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Beam + Shimmer Combo ── */
.xg-beam-shimmer-btn {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.xg-beam-shimmer-border {
  position: absolute;
  inset: -1px;
  border-radius: 9999px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}

.xg-beam-shimmer-btn:hover .xg-beam-shimmer-border {
  opacity: 1;
}

.xg-beam-shimmer-border::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300%;
  height: 300%;
  background: conic-gradient(from 0deg, transparent 0 340deg, white 360deg);
  animation: xg-spin 2s linear infinite;
}

.xg-beam-shimmer-glow {
  position: absolute;
  inset: -2px;
  border-radius: 9999px;
  opacity: 0;
  filter: blur(16px);
  transition: opacity 0.5s;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.15);
}

.xg-beam-shimmer-btn:hover .xg-beam-shimmer-glow {
  opacity: 1;
}

.xg-beam-shimmer-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 9999px;
  padding: 1px;
  border: none;
  cursor: pointer;
  background: transparent;
}

.xg-beam-shimmer-inner>span:first-child {
  position: absolute;
  inset: -1000%;
  animation: xg-spin 2s linear infinite;
  background: conic-gradient(from 0deg, transparent 0 340deg, white 360deg);
}

/* ── Arrow Hover Shifts ── */
.xg-hover-arrow-shift {
  transition: transform 0.2s;
}

.xg-beam-shimmer-btn:hover .xg-hover-arrow-shift,
.xg-shimmer-btn:hover .xg-hover-arrow-shift,
.xg-btn:hover .xg-hover-arrow-shift {
  transform: translateX(4px);
}

.xg-hover-arrow-diagonal {
  transition: transform 0.2s;
}

*:hover>.xg-hover-arrow-diagonal {
  transform: translateX(2px) translateY(-2px);
}


/* =============================================================================
   5. CARDS
   Flashlight effect, hover lifts, 3D tilts.
   Flashlight requires JS: animations.js
   ============================================================================= */

/* ── Flashlight Card ── */
.xg-flashlight-card {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.xg-flashlight-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
      rgba(255, 255, 255, 0.06),
      transparent 40%);
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
  z-index: 2;
}

.xg-flashlight-card:hover::before {
  opacity: 1;
}

.xg-flashlight-card--light::before {
  background: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
      rgba(0, 0, 0, 0.04),
      transparent 40%);
}

/* ── Card Hover Lift ── */
.xg-card-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.xg-card-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1);
}

/* ── Card Hover Scale ── */
.xg-card-scale {
  transition: transform 0.3s ease;
}

.xg-card-scale:hover {
  transform: scale(1.05);
}

/* ── Card Hover Tilt ── */
.xg-card-tilt {
  transition: transform 0.3s ease;
}

.xg-card-tilt:hover {
  transform: rotate(1deg);
}

.xg-card-tilt-reverse:hover {
  transform: rotate(-1deg);
}

/* ── Card Stack ── */
.xg-card-stack {
  position: relative;
  perspective: 1000px;
}

.xg-card-stack-bg {
  position: absolute;
  width: 80%;
  height: 80%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 24px)) scale(0.95);
  opacity: 0.4;
  border-radius: inherit;
}

.xg-card-stack-front {
  position: relative;
  z-index: 1;
  transition: all 0.5s;
}

.xg-card-stack:hover .xg-card-stack-front {
  transform: scale(1.02);
}

/* ── Image Grayscale to Color ── */
.xg-img-grayscale {
  filter: grayscale(1);
  transition: filter 0.7s ease;
}

.xg-img-grayscale:hover,
*:hover>.xg-img-grayscale {
  filter: grayscale(0);
}


/* =============================================================================
   6. TEXT ANIMATIONS
   Clip-path reveals, stroke fills, gradients, stagger.
   ============================================================================= */

/* ── Text Clip Slide ── */
.xg-text-clip {
  overflow: hidden;
}

.xg-text-clip span {
  display: inline-block;
  opacity: 0;
  animation: xg-text-slide 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.xg-text-clip span:nth-child(1) {
  animation-delay: 0s;
}

.xg-text-clip span:nth-child(2) {
  animation-delay: 0.05s;
}

.xg-text-clip span:nth-child(3) {
  animation-delay: 0.1s;
}

.xg-text-clip span:nth-child(4) {
  animation-delay: 0.15s;
}

.xg-text-clip span:nth-child(5) {
  animation-delay: 0.2s;
}

.xg-text-clip span:nth-child(6) {
  animation-delay: 0.25s;
}

.xg-text-clip span:nth-child(7) {
  animation-delay: 0.3s;
}

.xg-text-clip span:nth-child(8) {
  animation-delay: 0.35s;
}

/* ── Text Stroke ── */
.xg-text-stroke {
  color: transparent;
  -webkit-text-stroke: 1px rgba(128, 128, 128, 0.3);
  transition: all 0.5s ease;
}

.xg-hover-stroke-fill:hover .xg-text-stroke {
  -webkit-text-stroke: 1px currentColor;
  color: transparent;
}

/* ── Text Gradient ── */
.xg-text-gradient {
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  background-image: var(--xg-text-gradient, linear-gradient(to right, #000, #666));
}

/* ── Stagger Children ── */
.xg-stagger-children>*:nth-child(1) {
  animation-delay: 0.1s;
}

.xg-stagger-children>*:nth-child(2) {
  animation-delay: 0.2s;
}

.xg-stagger-children>*:nth-child(3) {
  animation-delay: 0.3s;
}

.xg-stagger-children>*:nth-child(4) {
  animation-delay: 0.4s;
}

.xg-stagger-children>*:nth-child(5) {
  animation-delay: 0.5s;
}

.xg-stagger-children>*:nth-child(6) {
  animation-delay: 0.6s;
}

.xg-stagger-children>*:nth-child(7) {
  animation-delay: 0.7s;
}

.xg-stagger-children>*:nth-child(8) {
  animation-delay: 0.8s;
}


/* =============================================================================
   7. MARQUEE
   Infinite horizontal scroll with fade edges.
   ============================================================================= */

.xg-marquee-container {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.xg-marquee-track {
  display: flex;
  overflow: hidden;
  width: 100%;
}

.xg-marquee-content {
  display: flex;
  white-space: nowrap;
  gap: 4rem;
  align-items: center;
  animation: xg-marquee 40s linear infinite;
}

.xg-marquee-content--fast {
  animation-duration: 20s;
}

.xg-marquee-content--slow {
  animation-duration: 60s;
}

.xg-marquee-container:hover .xg-marquee-content {
  animation-play-state: paused;
}

.xg-marquee-fade-left {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6rem;
  z-index: 10;
  background: linear-gradient(to right, var(--xg-marquee-bg, #000), transparent);
  pointer-events: none;
}

.xg-marquee-fade-right {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6rem;
  z-index: 10;
  background: linear-gradient(to left, var(--xg-marquee-bg, #000), transparent);
  pointer-events: none;
}

.xg-marquee-bg-text {
  position: absolute;
  white-space: nowrap;
  font-weight: bold;
  opacity: 0.03;
  pointer-events: none;
  user-select: none;
  overflow: hidden;
  width: 100%;
}

.xg-marquee-bg-text>span {
  display: inline-block;
  animation: xg-marquee 20s linear infinite;
}


/* =============================================================================
   8. INPUTS
   Animated borders, focus states.
   ============================================================================= */

.xg-input-group {
  position: relative;
}

.xg-input {
  width: 100%;
  padding: 1rem;
  background: rgba(128, 128, 128, 0.05);
  border: none;
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
  border-radius: 0.5rem 0.5rem 0 0;
  outline: none;
  transition: background 0.3s;
  font: inherit;
  color: inherit;
}

.xg-input:focus {
  background: rgba(128, 128, 128, 0.02);
}

.xg-input-border {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 1px;
  width: 0%;
  background: var(--xg-input-accent, currentColor);
  transition: width 0.4s var(--xg-ease-out-expo);
}

/* =============================================================================
   9. RING BEAM ANIMATIONS (Shared between CTA & Produtos)
   ============================================================================= */

@property --xg-ring-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

@property --xg-ring-angle-rev {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

@keyframes xg-ring-rotate {
  from { --xg-ring-angle: 0deg; }
  to { --xg-ring-angle: 360deg; }
}

@keyframes xg-ring-rotate-rev {
  from { --xg-ring-angle-rev: 360deg; }
  to { --xg-ring-angle-rev: 0deg; }
}

@keyframes xg-ring-breathe-1 {
  0%, 100% { border-color: rgba(47, 244, 211, 0.12); }
  50% { border-color: rgba(47, 244, 211, 0.22); }
}

@keyframes xg-ring-breathe-2 {
  0%, 100% { border-color: rgba(47, 244, 211, 0.18); }
  50% { border-color: rgba(47, 244, 211, 0.28); }
}

@keyframes xg-ring-breathe-3 {
  0%, 100% { border-color: rgba(47, 244, 211, 0.25); }
  50% { border-color: rgba(47, 244, 211, 0.35); }
}

.xg-animated-ring {
  position: relative;
}

.xg-animated-ring::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(
    from var(--xg-ring-angle),
    transparent 0deg,
    transparent 300deg,
    rgba(47, 244, 211, 0.4) 340deg,
    rgba(47, 244, 211, 0.6) 350deg,
    transparent 360deg
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: xg-ring-rotate 6s linear infinite;
  pointer-events: none;
  z-index: 1;
}

.xg-animated-ring-rev::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(
    from var(--xg-ring-angle-rev),
    transparent 0deg,
    transparent 310deg,
    rgba(47, 244, 211, 0.3) 340deg,
    rgba(47, 244, 211, 0.5) 355deg,
    transparent 360deg
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: xg-ring-rotate-rev 8s linear infinite;
  pointer-events: none;
  z-index: 1;
}

.xg-input:focus+.xg-input-border {
  width: 100%;
}


/* =============================================================================
   9. VISUAL EFFECTS
   Glass, floating blobs, border gradients, masks.
   ============================================================================= */

/* ── Glassmorphism ── */
.xg-glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.xg-glass--dark {
  background: rgba(23, 23, 23, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* ── Float Blob ── */
.xg-float-blob {
  border-radius: 9999px;
  filter: blur(48px);
  animation: xg-float 10s ease-in-out infinite;
  pointer-events: none;
}

.xg-float-blob--reverse {
  animation-direction: reverse;
  animation-duration: 12s;
}

/* ── Border Gradient ── */
.xg-border-gradient {
  position: relative;
}

.xg-border-gradient::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  background: var(--xg-border-gradient, linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent));
  pointer-events: none;
}

/* ── Vertical Fade Mask ── */
.xg-mask-fade-vertical {
  mask-image: linear-gradient(180deg, transparent, black 20%, black 80%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, black 20%, black 80%, transparent);
}

/* ── Pulse Dot ── */
.xg-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  animation: xg-pulse 2s ease-in-out infinite;
}

/* ── Bounce ── */
.xg-bounce {
  animation: xg-bounce 1s ease-in-out infinite;
}

/* ── Hover Helpers ── */
.xg-hover-color {
  transition: color 0.5s ease;
}

.xg-hover-icon-color {
  transition: color 0.5s ease;
  opacity: 0.5;
}

*:hover>.xg-hover-icon-color {
  opacity: 1;
}