/*
 * Motion system minimalista para Gudfy
 * ------------------------------------
 * Tokens y clases reusables para mejorar perceived performance.
 * Cargado después de tailwind.css en _layout.ejs.
 *
 * Patrón de duraciones detectado en código existente:
 *   - 120-180ms fades
 *   - 200-250ms transforms con bounce
 * Easing: decelerate (out) para entradas, pop (overshoot) para FAB/CTA.
 */

:root {
  --gf-dur-fast: 120ms;
  --gf-dur-base: 180ms;
  --gf-dur-slow: 240ms;
  --gf-ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --gf-ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Spinner inline (currentColor, 14px default) ────────────────────────── */
@keyframes gf-spin { to { transform: rotate(360deg); } }
.gf-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: gf-spin 0.6s linear infinite;
  vertical-align: -2px;
  flex-shrink: 0;
}
.gf-spinner--sm { width: 12px; height: 12px; border-width: 1.5px; }
.gf-spinner--lg { width: 18px; height: 18px; }

/* ── HTMX swap cross-fade (sin View Transitions) ────────────────────────── */
/* HTMX agrega htmx-swapping al elemento que está siendo reemplazado, y
 * htmx-settling al recién insertado. Estas reglas evitan el flash blanco. */
.htmx-swapping {
  opacity: 0.4;
  transition: opacity var(--gf-dur-fast) var(--gf-ease-out);
}
.htmx-settling {
  opacity: 1;
}
.htmx-request .htmx-indicator,
.htmx-indicator.htmx-request {
  opacity: 1;
}
.htmx-indicator {
  opacity: 0;
  transition: opacity var(--gf-dur-fast) var(--gf-ease-out);
}

/* ── Optimistic chat message (pending/failed states) ────────────────────── */
.gf-msg-pending {
  opacity: 0.55;
  transition: opacity var(--gf-dur-base) var(--gf-ease-out);
}
.gf-msg-pending .gf-msg-meta::after {
  content: " · enviando…";
  font-style: italic;
  opacity: 0.7;
}
.gf-msg-failed {
  background: rgba(220, 38, 38, 0.06);
  border-left: 2px solid #DC2626;
  padding-left: 8px;
}
.gf-msg-failed .gf-msg-meta::after {
  content: " · error";
  color: #DC2626;
  font-weight: 600;
}

/* ── Buttons en loading state ───────────────────────────────────────────── */
.gf-btn-loading {
  cursor: wait !important;
  pointer-events: none;
}

/* ── Reduced motion: respetá la preferencia del usuario ─────────────────── */
@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;
  }
  /* Spinner es funcional (indica progreso), mantener su rotación pero acelerar */
  .gf-spinner { animation-duration: 0.6s !important; animation-iteration-count: infinite !important; }
}
