/* ── Variables globales del proyecto ──────────────────────────────────────── */
:root {
  --color-brand:      #16a34a;
  --color-brand-dark: #15803d;
  --color-brand-light:#f0fdf4;
  --color-text:       #111827;
  --color-muted:      #6b7280;
  --color-border:     #e5e7eb;
  --font-body:        'Inter', system-ui, sans-serif;
  --font-heading:     'Poppins', system-ui, sans-serif;
  --transition:       0.2s ease;
  --radius:           0.75rem;
  --shadow-sm:        0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:        0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:        0 8px 32px rgba(0,0,0,0.12);
}

/* ── Reset y base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  /* Offset para el header fijo al navegar por anchor links */
  scroll-padding-top: 72px;
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a { text-decoration: none; color: inherit; }

/* ── Header con sombra al hacer scroll ───────────────────────────────────── */
#header.scrolled {
  box-shadow: var(--shadow-md);
}

/* ── Secciones: espaciado consistente ────────────────────────────────────── */
section {
  padding: 5rem 1rem;
}

@media (min-width: 768px) {
  section { padding: 6rem 1.5rem; }
}

/* ── Contenedor máximo centrado ──────────────────────────────────────────── */
.container {
  max-width: 72rem;   /* 1152px */
  margin-inline: auto;
  width: 100%;
}

/* ── Tipografía de secciones ─────────────────────────────────────────────── */
.section-title {
  font-family: var(--font-heading);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
}

.section-subtitle {
  font-size: 1rem;
  color: var(--color-muted);
  max-width: 42rem;
  margin-inline: auto;
  line-height: 1.7;
}

/* ── Badge de sección ────────────────────────────────────────────────────── */
.section-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-brand);
  background: var(--color-brand-light);
  border: 1px solid #bbf7d0;
  padding: 0.25rem 0.875rem;
  border-radius: 9999px;
  margin-bottom: 1rem;
}

/* ── Botones reutilizables ───────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-brand);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.875rem 2rem;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
}

.btn-primary:hover {
  background: var(--color-brand-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(22, 163, 74, 0.35);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  color: var(--color-brand);
  font-weight: 600;
  font-size: 1rem;
  padding: 0.875rem 2rem;
  border-radius: 9999px;
  border: 2px solid var(--color-brand);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-secondary:hover {
  background: var(--color-brand-light);
  transform: translateY(-2px);
}

/* ── Animación de entrada (scroll reveal) ────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ════════════════════════════════════════════════════════════════
   ANIMACIONES
════════════════════════════════════════════════════════════════ */

/* ── 1. Hero: entrada de elementos ───────────────────────────────────────── */
@keyframes heroFadeUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes heroFadeLeft {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes heroFloat {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-12px); }
}

@keyframes heroPulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
  50%       { box-shadow: 0 0 32px 8px rgba(22, 163, 74, 0.15); }
}

/* Clases de entrada del Hero — se aplican en cascada con delay */
.hero-animate-1 {
  opacity: 0;
  animation: heroFadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.1s forwards;
}
.hero-animate-2 {
  opacity: 0;
  animation: heroFadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.25s forwards;
}
.hero-animate-3 {
  opacity: 0;
  animation: heroFadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.4s forwards;
}
.hero-animate-4 {
  opacity: 0;
  animation: heroFadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.55s forwards;
}
.hero-animate-5 {
  opacity: 0;
  animation: heroFadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.7s forwards;
}

/* Foto del Hero: entra desde la derecha y flota */
.hero-photo {
  opacity: 0;
  animation:
    heroFadeLeft 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.3s forwards,
    heroFloat 6s ease-in-out 1.2s infinite;
}

/* Marco verde detrás de la foto — entra con delay */
.hero-photo-frame {
  opacity: 0;
  animation:
    heroFadeLeft 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.15s forwards,
    heroPulseGlow 4s ease-in-out 1.5s infinite;
}

/* Badge flotante sobre la foto */
.hero-badge-float {
  opacity: 0;
  animation: heroFadeUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.9s forwards;
}

/* ── 2. WhatsApp FAB: pulso de atención ──────────────────────────────────── */
@keyframes waPulse {
  0%   { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7); }
  50%  { box-shadow: 0 0 0 14px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

@keyframes waBounce {
  0%, 100% { transform: scale(1); }
  25%       { transform: scale(1.12); }
  50%       { transform: scale(1.06); }
  75%       { transform: scale(1.1); }
}

#whatsapp-fab {
  animation: waPulse 2.5s ease-out 3s infinite;
}

/* Cada 8 segundos hace un pequeño bounce para llamar la atención */
#whatsapp-fab:not(:hover) {
  animation: waPulse 2.5s ease-out 3s infinite;
}

/* Pseudo-elemento: onda expansiva detrás del botón */
#whatsapp-fab::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #25D366;
  opacity: 0;
  animation: waPulse 2.5s ease-out 3s infinite;
  z-index: -1;
}

/* ── 3. Tarjetas de servicios: hover avanzado ────────────────────────────── */
@keyframes cardShine {
  from { left: -100%; }
  to   { left: 200%; }
}

/* Contenedor necesita position relative para el shine */
#servicios article {
  position: relative;
  overflow: hidden;
}

/* Efecto shine al hacer hover */
#servicios article::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  transform: skewX(-15deg);
  transition: none;
  pointer-events: none;
}

#servicios article:hover::after {
  animation: cardShine 0.6s ease forwards;
}

/* Ícono de la tarjeta: escala y rota levemente al hover */
#servicios article:hover .w-12 {
  transform: scale(1.15) rotate(-5deg);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#servicios article .w-12 {
  transition: transform 0.3s ease;
}

/* Tarjeta destacada verde: brillo propio al hover */
#servicios article.bg-brand-600:hover {
  background-color: #15803d;
  box-shadow: 0 12px 40px rgba(22, 163, 74, 0.4);
}

/* ── 4. Transiciones entre secciones: gradiente ondulado ─────────────────── */
.section-wave {
  position: relative;
  z-index: 1;
}

.section-wave::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 60px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 60'%3E%3Cpath fill='%23f9fafb' d='M0,30 C360,60 1080,0 1440,30 L1440,60 L0,60 Z'/%3E%3C/svg%3E");
  background-size: cover;
  background-repeat: no-repeat;
  pointer-events: none;
}

/* Ola invertida para secciones grises a blancas */
.section-wave-white::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 60'%3E%3Cpath fill='%23ffffff' d='M0,30 C360,60 1080,0 1440,30 L1440,60 L0,60 Z'/%3E%3C/svg%3E");
}

/* ── 5. Scroll reveal mejorado: diferentes direcciones ───────────────────── */
.reveal-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal-right {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal-left.visible,
.reveal-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Delay escalonado para grids (hijos directos) */
.reveal-stagger > *:nth-child(1) { transition-delay: 0s;    }
.reveal-stagger > *:nth-child(2) { transition-delay: 0.1s;  }
.reveal-stagger > *:nth-child(3) { transition-delay: 0.2s;  }
.reveal-stagger > *:nth-child(4) { transition-delay: 0.3s;  }

/* ── 6. Stats del Hero: contador animado (controlado desde JS) ───────────── */
@keyframes statPop {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.stat-number.animated {
  animation: statPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ── 7. Botón primario: shimmer en loop ──────────────────────────────────── */
@keyframes btnShimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.btn-primary {
  background-size: 200% auto;
  background-image: linear-gradient(
    90deg,
    #16a34a 0%,
    #22c55e 40%,
    #16a34a 60%,
    #15803d 100%
  );
  animation: btnShimmer 3s linear 2s infinite;
}

.btn-primary:hover {
  animation: none;
  background-image: none;
  background-color: #15803d;
}

/* ── 8. Respeto por preferencias de movimiento reducido ─────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .hero-photo { opacity: 1; transform: none; }
  .hero-photo-frame { opacity: 1; }
  .hero-badge-float { opacity: 1; }
  .hero-animate-1, .hero-animate-2, .hero-animate-3,
  .hero-animate-4, .hero-animate-5 { opacity: 1; transform: none; }
}