/* ==============================================================
   ANTAC - Custom styles
   Complementa Tailwind. Animaciones, a11y, reveal, header.
   Diseño: rojo primario + ámbar acento, zinc neutrals.
   Principios (emilkowalski):
   - Solo transform/opacity (perf)
   - ease-out para entrar/salir
   - Curvas fuertes (no easings built-in)
   - UI < 300ms
   - Animaciones interruptibles (CSS transitions, no @keyframes)
   - prefers-reduced-motion respetado
   ============================================================== */

/* ---------- Easings (curvas fuertes, no built-in) ---------- */
:root {
  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);  /* para microinteracciones del CTA */

  --dur-press:  120ms;
  --dur-pop:    220ms;
  --dur-modal:  300ms;
  --dur-reveal: 800ms;
  --dur-wobble: 700ms;
}

/* ---------- Tipografía base ---------- */
* { font-family: 'Manrope', system-ui, sans-serif; }
.font-serif { font-family: 'Bitter', Georgia, serif; }
html { scroll-behavior: smooth; }

/* ============================================================
   HEADER — slide up/down en scroll
   - translateY(-100%) al ocultar
   - 240ms ease-out (CSS transition = interruptible)
   - Header tiene transform, no display:none (mantiene layout)
   - Al volver a aparecer, micro-scale para que "llegue con peso"
   ============================================================ */
.site-header {
  transform: translateY(0) scale(1);
  transition:
    transform 240ms var(--ease-out),
    opacity   240ms var(--ease-out);
  opacity: 1;
}
.site-header.is-hidden {
  transform: translateY(-100%) scale(0.98);
  opacity: 0;
  pointer-events: none;
}

/* ============================================================
   FLOATING CTA — Pop in con scale + translateY
   - Empieza invisible (opacity 0, translateY 8px, scale 0.95)
   - Aparece con .is-visible
   - 250ms ease-out, interruptible
   ============================================================ */
.floating-cta {
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  pointer-events: none;
  transition:
    opacity 220ms var(--ease-out),
    transform 220ms var(--ease-out);
}
.floating-cta.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Pulse "breathing" sutil en el botón flotante (no molesto) */
.floating-cta::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 9999px;
  background: rgba(220, 38, 38, 0.3);
  z-index: -1;
  animation: cta-pulse 2.4s ease-in-out infinite;
  opacity: 0;
}
.floating-cta.is-visible::before {
  opacity: 1;
}
@keyframes cta-pulse {
  0%, 100% { transform: scale(1);    opacity: 0.4; }
  50%      { transform: scale(1.12); opacity: 0;   }
}

/* Wobble muy sutil cada ~7s (no mareante, solo da vida) */
@keyframes cta-wobble {
  0%, 88%, 100% { transform: translateY(0) scale(1)         rotate(0deg);   }
  90%           { transform: translateY(0) scale(1.04)      rotate(-2deg);  }
  93%           { transform: translateY(0) scale(1.04)      rotate(2deg);   }
  96%           { transform: translateY(0) scale(1.04)      rotate(-1deg);  }
}
.floating-cta.is-visible .btn-float {
  animation: cta-wobble 7s ease-in-out infinite;
  animation-delay: 2.5s;  /* arranca después de 2.5s, da respiro al usuario */
}

/* Press feedback en el botón (scale 0.97) + hover expand */
.floating-cta .btn-float {
  position: relative;
  overflow: hidden;
  gap: 0.625rem;  /* 10px entre texto y flecha, evita que quede pegada */
  padding-right: 1rem;  /* respiro derecho para la flecha */
  transition:
    transform 140ms var(--ease-out),
    padding   200ms var(--ease-out),
    background-color 140ms;
}
.floating-cta .btn-float > svg {
  margin-left: 0.25rem;  /* respiro extra entre el texto y la flecha */
  flex-shrink: 0;
}
.floating-cta .btn-float:hover {
  background-color: rgb(185 28 28);
  padding-right: 1.25rem;  /* crece un poco al hover */
}
.floating-cta .btn-float:active {
  transform: scale(0.97);
}

/* Texto secundario ("gratis") oculto, aparece al hover */
.floating-cta .btn-text-secondary {
  display: inline-block;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition:
    max-width 220ms var(--ease-out),
    opacity   180ms var(--ease-out);
}
.floating-cta .btn-float:hover .btn-text-secondary {
  max-width: 5.5rem;  /* " gratis" */
  opacity: 1;
}

/* Ripple effect al hacer click */
.floating-cta .btn-float .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  animation: ripple-expand 600ms var(--ease-out) forwards;
}
@keyframes ripple-expand {
  to {
    transform: translate(-50%, -50%) scale(4);
    opacity: 0;
  }
}

/* ============================================================
   REVEAL — IntersectionObserver (transform/opacity)
   - Stagger via delay
   - Una sola vez (unobserve tras disparar)
   - Más notorio: 800ms, translateY 24px, clip-path opcional
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 800ms var(--ease-out),
    transform 800ms var(--ease-out);
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger dentro de grids (más notorio: 120ms entre items) */
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 600ms var(--ease-out),
    transform 600ms var(--ease-out);
}
.reveal-stagger.is-visible > *:nth-child(1) { transition-delay: 0ms;    opacity: 1; transform: translateY(0); }
.reveal-stagger.is-visible > *:nth-child(2) { transition-delay: 120ms;  opacity: 1; transform: translateY(0); }
.reveal-stagger.is-visible > *:nth-child(3) { transition-delay: 240ms;  opacity: 1; transform: translateY(0); }
.reveal-stagger.is-visible > *:nth-child(4) { transition-delay: 360ms;  opacity: 1; transform: translateY(0); }
.reveal-stagger.is-visible > *:nth-child(5) { transition-delay: 480ms;  opacity: 1; transform: translateY(0); }
.reveal-stagger.is-visible > *:nth-child(6) { transition-delay: 600ms;  opacity: 1; transform: translateY(0); }

/* ============================================================
   REVEAL-ELEM — para unidades semánticas dentro de cada sección
   (h2, h3, p, article, fieldset, btn, nav link)
   Una sola vez. Sin re-animar al scroll reverso.
   ============================================================ */
.reveal-elem {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 700ms var(--ease-out),
    transform 700ms var(--ease-out);
  will-change: opacity, transform;
}
.reveal-elem.is-visible {
  opacity: 1;
  transform: translateY(0);
}
/* Header nav: solo aparece la primera vez (no re-animar entre páginas) */
header nav a.reveal-elem {
  transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
}

/* ============================================================
   HOVER/PRESS en cards — sutil, no exagerado
   - Elevación + sombra + shine que cruza
   ============================================================ */
.card-hover {
  position: relative;
  overflow: hidden;
  transition:
    transform 220ms var(--ease-out),
    box-shadow 220ms var(--ease-out);
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 32px -8px rgb(0 0 0 / 0.12);
}

/* Shine effect (pseudo-elemento que cruza en hover) */
.card-hover::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.45) 50%,
    transparent 100%
  );
  pointer-events: none;
  transition: left 700ms var(--ease-out);
}
.card-hover:hover::after {
  left: 130%;
}

/* Focus visible consistente (a11y) */
*:focus-visible {
  outline: 2px solid #DC2626;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Botón spinner */
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: -2px;
  margin-right: 4px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Upload zone focus */
.upload-zone:focus-visible {
  outline: 2px solid #DC2626;
  outline-offset: 2px;
}

/* ============================================================
   prefers-reduced-motion (a11y)
   Desactivamos TODO lo decorativo, mantenemos funcionalidad.
   ============================================================ */
@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;
  }
  .reveal,
  .reveal-elem,
  .reveal-stagger > * {
    opacity: 1 !important;
    transform: none !important;
  }
  .site-header {
    transform: none !important;
  }
  .floating-cta {
    opacity: 1 !important;
    transform: none !important;
  }
  .floating-cta::before {
    animation: none !important;
  }
  .card-hover:hover {
    transform: none;
  }
}

/* Tabla sin estilos (compat) */
table { border-collapse: collapse; width: 100%; }
