/* ============================================================
   animations.css — Micro-animaciones y transiciones
   ============================================================ */

/* ── Entrada de elementos al DOM ──────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Clases de animación de entrada */
.anim-fade-in     { animation: fadeIn 0.25s ease forwards; }
.anim-fade-in-up  { animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.anim-scale-in    { animation: scaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.anim-slide-right { animation: slideInRight 0.3s ease forwards; }

/* Delays escalonados para grids */
.stagger-1  { animation-delay: 0.04s; }
.stagger-2  { animation-delay: 0.08s; }
.stagger-3  { animation-delay: 0.12s; }
.stagger-4  { animation-delay: 0.16s; }
.stagger-5  { animation-delay: 0.20s; }
.stagger-6  { animation-delay: 0.24s; }
.stagger-7  { animation-delay: 0.28s; }
.stagger-8  { animation-delay: 0.32s; }

/* ── Pulso (para indicadores de carga / notificaciones) ──────── */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}
.anim-pulse { animation: pulse 2s ease-in-out infinite; }

/* ── Spin (cargando) ──────────────────────────────────────────── */
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.anim-spin { animation: spin 0.8s linear infinite; }

/* ── Bounce suave (confirmación) ──────────────────────────────── */
@keyframes bounce-sm {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-4px); }
}
.anim-bounce { animation: bounce-sm 0.5s ease; }

/* ── Sacudida (error) ─────────────────────────────────────────── */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}
.anim-shake { animation: shake 0.4s ease; }

/* ── Efecto de click en bookmark ──────────────────────────────── */
@keyframes cardClick {
    0%   { transform: scale(1); }
    40%  { transform: scale(0.94) translateY(2px); }
    100% { transform: scale(1); }
}
.bookmark-card:active { animation: cardClick 0.2s ease forwards; }

/* ── Transición del tema (evitar flash) ───────────────────────── */
.theme-transitioning * {
    transition: background-color var(--t-base),
                border-color var(--t-base),
                color var(--t-base),
                box-shadow var(--t-base) !important;
}

/* ── Highlight de búsqueda ────────────────────────────────────── */
mark.search-highlight {
    background: var(--accent-light);
    color: var(--accent-text);
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 600;
}

/* ── Drag placeholder ─────────────────────────────────────────── */
.bookmark-card.dragging {
    opacity: 0.4;
    cursor: grabbing;
    box-shadow: var(--shadow-xl);
    scale: 1.05;
}
.drop-zone-active {
    border: 2px dashed var(--accent) !important;
    background: var(--accent-light) !important;
}

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