/**
 * HERO ANIMATIONS - Sistema de animaciones para sección hero
 * ========================================================
 * Depende de: design-system.css (cargado por styles.css)
 * Este archivo NO debe importar design-system.css independientemente
 */

/* ===== VARIABLES ESPECÍFICAS ===== */
:root {
  --hero-animation-duration: 0.8s;
  --hero-animation-delay-base: 0.1s;
  --hero-animation-delay-increment: 0.15s;
  --hero-hover-lift: -2px;
  --hero-parallax-distance: 8px;
  --hero-image-filter-opacity: 0.2;
}

/* ===== ANIMACIONES HERO PRINCIPALES ===== */
@keyframes heroFadeInUp {
  from {
    opacity: 0;
    transform: translateY(var(--space-6));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes heroFadeInScale {
  from {
    opacity: 0;
    transform: translateY(var(--space-4)) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes heroImageFloat {
  from {
    opacity: 0;
    transform: translateY(var(--space-3)) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes heroCountUp {
  from {
    opacity: 0;
    transform: translateY(var(--space-3));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes heroBackgroundShift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(var(--space-2));
  }
}

/* ===== CLASES PRINCIPALES DE ANIMACIÓN ===== */
.hero-section {
  contain: layout style;
  transform: translateZ(0);
}

.hero-animated {
  animation: heroFadeInUp var(--hero-animation-duration)
    var(--easing-emphasized) forwards;
  opacity: 0;
}

.hero-animated.hero-title {
  animation-delay: var(--hero-animation-delay-base);
}

.hero-animated.hero-subtitle {
  animation-delay: calc(
    var(--hero-animation-delay-base) + var(--hero-animation-delay-increment)
  );
}

.hero-animated.hero-content {
  animation-delay: calc(
    var(--hero-animation-delay-base) + var(--hero-animation-delay-increment) * 2
  );
}

.hero-animated.hero-actions {
  animation: heroFadeInScale var(--hero-animation-duration)
    var(--easing-emphasized) forwards;
  animation-delay: calc(
    var(--hero-animation-delay-base) + var(--hero-animation-delay-increment) * 3
  );
  opacity: 0;
}

.hero-image {
  animation: heroImageFloat var(--hero-animation-duration)
    var(--easing-emphasized) forwards;
  animation-delay: calc(
    var(--hero-animation-delay-base) + var(--hero-animation-delay-increment) *
      0.5
  );
  opacity: 0;
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* ===== HERO STATS/COUNTERS ===== */
.hero-stats {
  display: flex;
  gap: var(--space-8);
  justify-content: center;
  margin-top: var(--space-8);
}

.hero-stat {
  text-align: center;
  animation: heroCountUp var(--hero-animation-duration) var(--easing-emphasized)
    forwards;
  opacity: 0;
}

.hero-stat:nth-child(1) {
  animation-delay: 0.2s;
}
.hero-stat:nth-child(2) {
  animation-delay: 0.35s;
}
.hero-stat:nth-child(3) {
  animation-delay: 0.5s;
}
.hero-stat:nth-child(4) {
  animation-delay: 0.65s;
}

.hero-stat-number {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary-600);
  margin-bottom: var(--space-2);
}

.hero-stat-label {
  font-size: var(--font-size-sm);
  color: var(--color-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

/* ===== HERO VARIANTS ===== */
.hero-primary {
  background: linear-gradient(
    135deg,
    var(--color-primary-500),
    var(--color-primary-600)
  );
  color: var(--color-on-primary);
  padding: var(--space-16) 0;
  position: relative;
  overflow: hidden;
}

.hero-primary::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: url("/static/images/hero-pattern.svg") repeat;
  opacity: 0.05;
  animation: heroBackgroundShift 20s ease-in-out infinite;
}

.hero-primary > * {
  position: relative;
  z-index: 2;
}

.hero-compact {
  background: linear-gradient(
    135deg,
    var(--color-surface),
    var(--color-surface-variant)
  );
  color: var(--color-on-surface);
  padding: var(--space-12) 0;
  position: relative;
  overflow: hidden;
}

.hero-minimal {
  background: var(--color-surface);
  color: var(--color-on-surface);
  padding: var(--space-8) 0;
  border-bottom: 1px solid var(--color-outline-variant);
}

/* ===== HERO CONTENT ===== */
.hero-title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-6);
}

.hero-subtitle {
  font-size: var(--font-size-xl);
  line-height: var(--line-height-relaxed);
  opacity: 0.9;
  margin-bottom: var(--space-8);
}

.hero-description {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-8);
}

.hero-actions {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  justify-content: center;
}

.hero-cta {
  background: var(--color-primary-600);
  color: var(--color-on-primary);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-lg);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  transition:
    background-color var(--duration-fast) var(--easing-standard),
    transform var(--duration-fast) var(--easing-standard),
    box-shadow var(--duration-fast) var(--easing-standard);
  position: relative;
  overflow: hidden;
}

.hero-cta::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left var(--duration-slow) var(--easing-standard);
}

.hero-cta:hover::before {
  left: 100%;
}

.hero-cta:hover {
  background: var(--color-primary-700);
  transform: translateY(var(--hero-hover-lift));
  box-shadow: var(--shadow-lg);
}

.hero-cta:focus-visible {
  outline: 3px solid
    color-mix(in srgb, var(--color-primary-600) 40%, transparent);
  outline-offset: 2px;
}

.hero-cta:active {
  transform: translateY(0);
}

.hero-cta-secondary {
  background: transparent;
  color: var(--color-on-surface);
  border: 2px solid var(--color-outline);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-lg);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  transition:
    background-color var(--duration-fast) var(--easing-standard),
    border-color var(--duration-fast) var(--easing-standard),
    color var(--duration-fast) var(--easing-standard),
    transform var(--duration-fast) var(--easing-standard);
}

.hero-cta-secondary:hover {
  background: var(--color-primary-50);
  border-color: var(--color-primary-600);
  color: var(--color-primary-600);
  transform: translateY(calc(var(--hero-hover-lift) / 2));
}

.hero-cta-secondary:focus-visible {
  outline: 3px solid
    color-mix(in srgb, var(--color-primary-600) 40%, transparent);
  outline-offset: 2px;
}

/* ===== HERO IMAGES ===== */
.hero-image-container {
  position: relative;
  max-width: 100%;
  height: auto;
}

.hero-image-main {
  width: 100%;
  height: auto;
  max-width: 500px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  transition:
    transform var(--duration-normal) var(--easing-standard),
    filter var(--duration-normal) var(--easing-standard);
}

.hero-image-compact {
  width: 100%;
  height: auto;
  max-width: 300px;
  max-height: 200px;
  object-fit: contain;
  transition:
    transform var(--duration-normal) var(--easing-standard),
    filter var(--duration-normal) var(--easing-standard);
}

/* ===== EFECTOS HOVER E INTERACTIVOS ===== */
@media (hover: hover) and (pointer: fine) {
  .hero-image-main:hover {
    transform: scale(1.02) translateY(-4px);
    filter: drop-shadow(0 0 var(--space-6) rgba(0, 0, 0, 0.1));
  }

  .hero-image-compact:hover {
    transform: scale(1.05);
    filter: drop-shadow(
      0 0 var(--space-4)
        color-mix(in srgb, var(--color-primary-500) 30%, transparent)
    );
  }
}

/* ===== EFECTOS PARALLAX ===== */
@media (min-width: 992px) {
  .hero-parallax {
    transition: transform var(--duration-normal) var(--easing-standard);
    will-change: transform;
  }

  .hero-section:hover .hero-parallax {
    transform: translateY(calc(var(--hero-parallax-distance) * -1));
  }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 991.98px) {
  .hero-title {
    font-size: var(--font-size-3xl);
  }

  .hero-subtitle {
    font-size: var(--font-size-lg);
  }

  .hero-description {
    font-size: var(--font-size-base);
  }

  .hero-actions {
    justify-content: stretch;
  }

  .hero-cta,
  .hero-cta-secondary {
    flex: 1;
    text-align: center;
  }

  .hero-stats {
    flex-direction: column;
    gap: var(--space-4);
  }

  .hero-image-main {
    max-width: 400px;
  }
}

@media (max-width: 767.98px) {
  .hero-primary {
    padding: var(--space-12) 0;
  }

  .hero-compact {
    padding: var(--space-8) 0;
  }

  .hero-minimal {
    padding: var(--space-6) 0;
  }

  .hero-title {
    font-size: var(--font-size-2xl);
  }

  .hero-subtitle {
    font-size: var(--font-size-base);
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-image-compact {
    max-width: 250px;
    max-height: 150px;
  }

  .hero-image-main {
    max-width: 300px;
  }

  /* Reducir delays en móviles */
  .hero-animated.hero-title {
    animation-delay: 0.05s;
  }

  .hero-animated.hero-subtitle {
    animation-delay: 0.15s;
  }

  .hero-animated.hero-content {
    animation-delay: 0.25s;
  }

  .hero-animated.hero-actions {
    animation-delay: 0.35s;
  }

  .hero-image {
    animation-delay: 0.1s;
  }

  /* Eliminar efectos parallax en móviles */
  .hero-parallax {
    display: none;
  }
}

@media (max-width: 576px) {
  .hero-title {
    font-size: var(--font-size-xl);
  }

  .hero-cta,
  .hero-cta-secondary {
    padding: var(--space-3) var(--space-6);
  }

  .hero-image-compact {
    max-width: 200px;
    max-height: 120px;
  }

  .hero-image-main {
    max-width: 250px;
  }
}

/* ===== OPTIMIZACIONES PARA PANTALLAS DE ALTA DENSIDAD ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .hero-image-main,
  .hero-image-compact {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* ===== INTERSECTION OBSERVER SUPPORT ===== */
.hero-section.aos-animate .hero-animated,
.hero-section.aos-animate .hero-image {
  animation-play-state: running;
}

.hero-section:not(.aos-animate) .hero-animated,
.hero-section:not(.aos-animate) .hero-image {
  animation-play-state: paused;
}

/* ===== LOADING STATES ===== */
.hero-image.loading {
  opacity: 0;
  animation: none;
}

.hero-image.loaded {
  animation: heroImageFloat var(--hero-animation-duration)
    var(--easing-emphasized) forwards;
  animation-delay: calc(
    var(--hero-animation-delay-base) + var(--hero-animation-delay-increment) *
      0.5
  );
}

/* ===== PROGRESSIVE ENHANCEMENT ===== */
.js-enabled .hero-animated,
.js-enabled .hero-image {
  /* Animaciones solo con JavaScript habilitado */
}

.no-js .hero-animated,
.no-js .hero-image {
  animation: none;
  opacity: 1;
  transform: none;
}

/* ===== ACCESSIBILITY - REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  .hero-animated,
  .hero-image,
  .hero-stat {
    animation: none;
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hero-cta:hover,
  .hero-cta-secondary:hover {
    transform: none;
  }

  .hero-image-main:hover,
  .hero-image-compact:hover {
    transform: none;
    filter: none;
  }

  .hero-section:hover .hero-parallax {
    transform: none;
  }

  .hero-primary::before {
    animation: none;
  }

  .hero-cta::before {
    display: none;
  }

  /* Alternativas visuales sin animación */
  .hero-cta:hover {
    border-width: 3px;
  }

  .hero-image-main:hover {
    opacity: 0.9;
  }
}

@media (forced-colors: active) {
  .hero-primary,
  .hero-compact,
  .hero-minimal {
    background: Canvas;
    color: CanvasText;
    border: 2px solid;
  }

  .hero-cta,
  .hero-cta-secondary {
    background: ButtonFace;
    color: ButtonText;
    border: 2px solid ButtonText;
  }

  .hero-image-main,
  .hero-image-compact {
    filter: none;
  }
}

@media (pointer: coarse) {
  .hero-cta,
  .hero-cta-secondary {
    min-height: 44px;
    padding: var(--space-4) var(--space-8);
  }

  .hero-image-main,
  .hero-image-compact {
    min-height: 44px;
  }
}

/* ===== DARK MODE ===== */
[data-bs-theme="dark"] {
  --hero-image-filter-opacity: 0.3;
}

[data-bs-theme="dark"] .hero-primary {
  background: linear-gradient(
    135deg,
    var(--color-primary-600),
    var(--color-primary-700)
  );
}

[data-bs-theme="dark"] .hero-compact {
  background: linear-gradient(
    135deg,
    var(--color-surface),
    var(--color-surface-variant)
  );
}

[data-bs-theme="dark"] .hero-image-main,
[data-bs-theme="dark"] .hero-image-compact {
  filter: drop-shadow(0 0 var(--space-3) rgba(255, 255, 255, 0.1));
}

[data-bs-theme="dark"] .hero-image-main:hover,
[data-bs-theme="dark"] .hero-image-compact:hover {
  filter: drop-shadow(
    0 0 var(--space-4) rgba(255, 255, 255, var(--hero-image-filter-opacity))
  );
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.hero-section,
.hero-primary,
.hero-compact,
.hero-minimal {
  contain: layout style;
  transform: translateZ(0);
}

.hero-image-main,
.hero-image-compact,
.hero-cta,
.hero-cta-secondary {
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* ===== PRINT STYLES ===== */
@media print {
  .hero-section,
  .hero-primary,
  .hero-compact,
  .hero-minimal {
    background: white;
    color: black;
    padding: var(--space-4) 0;
  }

  .hero-primary::before {
    display: none;
  }

  .hero-image-main,
  .hero-image-compact {
    max-width: 300px;
    max-height: 200px;
    filter: none;
    animation: none;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .hero-parallax {
    display: none;
  }

  .hero-cta,
  .hero-cta-secondary {
    background: white;
    color: black;
    border: 1px solid black;
    print-color-adjust: exact;
  }

  .hero-animated,
  .hero-image,
  .hero-stat {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ===== DEBUGGING ===== */
@media screen and (max-width: 0px) {
  .debug-hero-animations::before {
    content: "🎬 Hero ELITE";
    position: fixed;
    top: 170px;
    right: 10px;
    background: var(--color-warning-500);
    color: var(--color-on-warning);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    z-index: var(--z-debug);
    opacity: 0.8;
  }
}
