/* ============================================================
   PGX Framework — Animations
   @keyframes · Fade-in · Transitions · Shimmer · Line-draw
   ============================================================ */

/* --- Keyframes --- */
@keyframes gridPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

@keyframes badgeGlow {
  0%, 100% { box-shadow: 0 0 12px color-mix(in srgb, var(--fw-primary) 20%, transparent); }
  50% { box-shadow: 0 0 24px color-mix(in srgb, var(--fw-primary) 40%, transparent); }
}

@keyframes coreGlow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(127, 0, 255, 0.4)); }
  50% { filter: drop-shadow(0 0 20px rgba(127, 0, 255, 0.7)); }
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes placeholderShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--fw-primary) 30%, transparent); }
  70% { box-shadow: 0 0 0 12px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* --- Fade-in on Scroll --- */
.fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Staggered Word Animation (Hero) --- */
.fade-in-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-in-word.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- SVG Line Draw (Architecture) --- */
.arch-svg-wrap svg .line-draw {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  transition: stroke-dashoffset 1.2s ease;
}

.arch-svg-wrap.visible svg .line-draw {
  stroke-dashoffset: 0;
}

/* --- Core Glow (Architecture SVG) --- */
.arch-svg-wrap svg .core-glow {
  animation: coreGlow 3s ease-in-out infinite;
}

/* --- Hover Lift (generic) --- */
.hover-lift {
  transition: transform 0.3s, box-shadow 0.3s;
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

/* --- Stagger Children --- */
.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0ms; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(2) { transition-delay: 80ms; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(3) { transition-delay: 160ms; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(4) { transition-delay: 240ms; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(5) { transition-delay: 320ms; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(6) { transition-delay: 400ms; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(7) { transition-delay: 480ms; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(8) { transition-delay: 560ms; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(9) { transition-delay: 640ms; opacity: 1; transform: translateY(0); }

/* ===== INTRO ORIGIN ANIMATION ===== */

#pgx-intro {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  opacity: 1;
  transition: opacity 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

#pgx-intro.dissolve {
  opacity: 0;
  pointer-events: none;
}

#pgx-intro.gone {
  display: none;
}

/* Subtle background glow */
.intro-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 45%, rgba(127, 0, 255, 0.1) 0%, transparent 70%),
    radial-gradient(ellipse 40% 35% at 55% 55%, rgba(0, 188, 212, 0.06) 0%, transparent 60%);
  z-index: 0;
}

.intro-content {
  position: relative;
  z-index: 1;
  text-align: center;
  font-family: var(--font-body);
}

/* Brand icon in intro */
.intro-icon-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 0 auto 24px;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.8s ease, transform 0.9s cubic-bezier(0.22, 1, 0.36, 1), filter 0.7s ease;
}

.intro-icon-wrap.visible {
  opacity: 1;
  transform: scale(1);
}

.intro-icon-wrap.transformed {
  opacity: 1;
  transform: scale(0.85);
  filter: drop-shadow(0 0 30px rgba(127, 0, 255, 0.5)) drop-shadow(0 0 60px rgba(0, 188, 212, 0.3));
}

.intro-icon {
  width: clamp(80px, 14vw, 120px);
  height: clamp(80px, 14vw, 120px);
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(127, 0, 255, 0.35));
  transition: filter 0.6s ease;
}

/* Word swap area — both words occupy the same grid cell */
.intro-swap-line {
  display: grid;
  place-items: center;
  font-size: clamp(2.6rem, 6vw, 4.5rem);
  font-weight: 900;
  line-height: 1.15;
  color: var(--text-primary);
  overflow: visible;
}

.intro-swap-line > span {
  grid-area: 1 / 1;
}

.intro-platano {
  opacity: 0;
  transform: translateY(0) scaleY(1);
  transition: opacity 0.6s ease, transform 0.7s cubic-bezier(0.4, 0, 1, 1);
}

.intro-platano.visible {
  opacity: 1;
}

.intro-platano.crushed {
  opacity: 0;
  transform: translateY(60px) scaleY(0.4);
  filter: blur(3px);
}

.intro-professional {
  opacity: 0;
  transform: translateY(-100px);
  transition: opacity 0.3s ease, transform 0.7s cubic-bezier(0.22, 1.3, 0.36, 1);
}

.intro-professional.drop {
  opacity: 1;
  transform: translateY(0);
}

/* "Games eXtended" line */
.intro-games-line {
  font-size: clamp(2rem, 5vw, 3.6rem);
  font-weight: 300;
  color: var(--text-secondary);
  margin-top: 2px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.intro-games-line.visible {
  opacity: 1;
  transform: translateY(0);
}

/* The X in eXtended — gradient highlight */
.intro-x {
  font-weight: 900;
  background: linear-gradient(135deg, #7f00ff, #00bcd4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.1em;
}

/* "for Unreal Engine 5" */
.intro-engine {
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  font-weight: 300;
  color: var(--text-muted);
  margin-top: 24px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.intro-engine.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Subtle divider line between brand and engine */
.intro-divider {
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(127, 0, 255, 0.5), rgba(0, 188, 212, 0.5), transparent);
  margin: 20px auto 0;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.intro-divider.visible {
  opacity: 1;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .fade-in { opacity: 1; transform: none; }
  .fade-in-word { opacity: 1; transform: none; }
  .stagger-children > * { opacity: 1; transform: none; }
  #pgx-intro { display: none; }
}
