/* ==========================================================================
   Interactions & state layer — MP Asistencias Legales
   Microinteracciones, estados y accesibilidad de movimiento.
   Solo anima transform / opacity / box-shadow (cero CLS).
   Se encola despues de style.css, gana en cascada.
   ========================================================================== */

/* ── 1. Respeto por prefers-reduced-motion (global) ───────────────────── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── 2. Foco visible coherente (solo teclado, no en click de raton) ───── */
.btn:focus-visible,
.wa-float:focus-visible,
.nav-toggle:focus-visible,
.nav-links a:focus-visible,
.nav-mobile a:focus-visible,
.mpal-text-link:focus-visible,
.mpal-contact-form :is(input, select, textarea):focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.btn:focus:not(:focus-visible) {
    outline: none;
}

/* ── 3. Feedback de pulsacion (imprescindible en touch, sin :hover) ───── */
.btn:active {
    transform: translateY(0) scale(.98);
}

.wa-float:active {
    transform: scale(.96);
}

/* ── 4. Estado loading dentro del boton de envio ──────────────────────── */
.btn.is-loading {
    pointer-events: none;
    opacity: .92;
}

@media (prefers-reduced-motion: no-preference) {
    .btn.is-loading {
        position: relative;
        color: transparent !important;
    }

    .btn.is-loading::after {
        content: "";
        position: absolute;
        inset: 0;
        margin: auto;
        width: 18px;
        height: 18px;
        border: 2px solid rgba(255, 255, 255, .4);
        border-top-color: #fff;
        border-radius: 50%;
        animation: mpal-spin .6s linear infinite;
    }
}

@keyframes mpal-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── 5. Validacion inline (progressive enhancement, tras interaccion) ─── */
.mpal-contact-form :is(input, select, textarea):user-invalid {
    border-color: #8c2727;
    box-shadow: 0 0 0 3px rgba(140, 39, 39, .12);
}

/* ── 6. Elevacion de cards de recurso (affordance hacia el CTA interno) ─ */
.post-card {
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.post-card:hover,
.post-card:focus-within {
    transform: translateY(-3px);
    box-shadow: 0 18px 40px rgba(15, 17, 40, .12);
}

/* ── 7. Scroll-reveal sutil (la clase .reveal solo la anade el JS; si el
       JS no corre o el usuario pide menos movimiento, el contenido queda
       visible sin animacion). La transicion vive en .is-revealed para que
       aplicar .reveal oculte al instante (sin fade-out inverso). ───────── */
.reveal {
    opacity: 0;
    transform: translateY(16px);
}

.reveal.is-revealed {
    opacity: 1;
    transform: none;
    transition: opacity .5s ease, transform .5s ease;
    will-change: opacity, transform;
}
