/* app/resources/css/motion.css
 * Liderra motion-инфраструктура. 7 паттернов + reduced-motion wrapper.
 * Spec: §9.
 */

/* === keyframes === */
@keyframes ld-fadeup {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

@keyframes ld-slideup {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

@keyframes ld-shimmer {
    0%   { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}

@keyframes ld-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.6); opacity: 0.4; }
}

@keyframes ld-dialog-in {
    0%   { opacity: 0; transform: scale(0.94) translateY(8px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* === Utilities === */

/* motion #4 — Hover lift */
.ld-hover-lift {
    transition:
        transform 200ms cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.ld-hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
}

/* motion #2 — Stagger list (применяется к строкам таблиц/списков; mount-only) */
.ld-stagger-row {
    animation: ld-slideup 400ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.ld-stagger-row:nth-child(1) { animation-delay: 0ms; }
.ld-stagger-row:nth-child(2) { animation-delay: 50ms; }
.ld-stagger-row:nth-child(3) { animation-delay: 100ms; }
.ld-stagger-row:nth-child(4) { animation-delay: 150ms; }
.ld-stagger-row:nth-child(5) { animation-delay: 200ms; }
.ld-stagger-row:nth-child(6) { animation-delay: 250ms; }
.ld-stagger-row:nth-child(7) { animation-delay: 300ms; }
.ld-stagger-row:nth-child(8) { animation-delay: 350ms; }
.ld-stagger-row:nth-child(9) { animation-delay: 400ms; }
.ld-stagger-row:nth-child(10) { animation-delay: 450ms; }

/* motion #5 — Skeleton shimmer */
.ld-skeleton {
    background: linear-gradient(
        90deg,
        rgba(1, 32, 25, 0.06) 0%,
        rgba(1, 32, 25, 0.12) 50%,
        rgba(1, 32, 25, 0.06) 100%
    );
    background-size: 400px 100%;
    animation: ld-shimmer 1400ms infinite linear;
    border-radius: var(--radius-6);
}

/* motion #10 (auxiliary) — Live pulse */
.ld-pulse {
    position: relative;
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--liderra-teal);
}

.ld-pulse::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    background: var(--liderra-teal);
    animation: ld-pulse 1800ms infinite cubic-bezier(0.4, 0, 0.6, 1);
}

/* motion #6 — Page transition (View Transitions API + CSS fallback) */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 280ms;
    animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

::view-transition-old(root) {
    animation-name: ld-fadeout-up;
}

::view-transition-new(root) {
    animation-name: ld-fadeup;
}

@keyframes ld-fadeout-up {
    from { opacity: 1; transform: none; }
    to   { opacity: 0; transform: translateY(-4px); }
}

/* CSS fallback для router transition */
.ld-route-fadeup-enter-active,
.ld-route-fadeup-leave-active {
    transition: opacity 280ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.ld-route-fadeup-enter-from { opacity: 0; transform: translateY(4px); }
.ld-route-fadeup-leave-to { opacity: 0; transform: translateY(-4px); }

/* === Reduced motion — отключаем всё === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
