/*
 * Анимации по мотивам компонентов Magic UI с 21st.dev (лицензия MIT):
 *   Blur Fade      https://21st.dev/@magicui/components/blur-fade
 *   Shimmer Button https://21st.dev/@magicui/components/shimmer-button
 *   Border Beam    https://21st.dev/@magicui/components/border-beam
 *   Animated List  https://21st.dev/@magicui/components/animated-list
 *   Number Ticker  https://21st.dev/@magicui/components/number-ticker (js/animations.js)
 * Оригиналы на React + framer-motion, здесь те же эффекты на чистом CSS,
 * потому что сайт без сборки и без React.
 */

/* Blur Fade: появление из размытия со сдвигом */
@keyframes blur-fade-in {
    from {
        opacity: 0;
        filter: blur(6px);
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        /* none, а не blur(0): иначе элемент навсегда остаётся отдельным слоем
           и перекрывает выпадающие списки соседей */
        filter: none;
        transform: none;
    }
}

.blur-fade {
    animation: blur-fade-in 0.4s ease-out both;
    animation-delay: calc(0.04s + var(--i, 0) * 0.06s);
}

/* Animated List: элементы списка выпрыгивают по очереди с лёгкой пружиной */
@keyframes list-pop-in {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(10px);
    }
    60% {
        opacity: 1;
        transform: scale(1.015) translateY(-1px);
    }
    100% {
        opacity: 1;
        transform: none;
    }
}

.animated-list > * {
    animation: list-pop-in 0.5s cubic-bezier(.34, 1.3, .64, 1) both;
    animation-delay: calc(0.12s + var(--i, 0) * 0.09s);
}

/* Shimmer Button: искра бежит по краю кнопки, внутри мягкий блик */
.shimmer-btn {
    --spread: 90deg;
    --shimmer-color: #ffffff;
    --speed: 3s;
    --bg: linear-gradient(135deg, #4a7dff, #2a5dff);
    position: relative;
    z-index: 0;
    overflow: hidden;
    color: #fff;
    background: var(--bg);
    box-shadow: inset 0 -8px 10px rgba(255, 255, 255, 0.12), 0 6px 18px rgba(42, 93, 255, 0.35);
}

.shimmer-btn::before {
    content: "";
    position: absolute;
    z-index: -2;
    inset: -100%;
    background: conic-gradient(from 0deg, transparent 0, var(--shimmer-color) var(--spread), transparent var(--spread));
    animation: shimmer-spin var(--speed) linear infinite;
    opacity: 0.7;
}

.shimmer-btn::after {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 2px;
    border-radius: 10px;
    background: var(--bg);
}

.shimmer-btn:hover {
    box-shadow: inset 0 -6px 10px rgba(255, 255, 255, 0.25), 0 8px 22px rgba(42, 93, 255, 0.45);
}

.shimmer-btn:disabled::before {
    animation: none;
    opacity: 0;
}

@keyframes shimmer-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Border Beam: светящаяся точка обходит рамку карточки */
.border-beam {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    border: 1.5px solid transparent;
    -webkit-mask: linear-gradient(transparent, transparent), linear-gradient(#000, #000);
    -webkit-mask-clip: padding-box, border-box;
    -webkit-mask-composite: source-in, xor;
    mask: linear-gradient(transparent, transparent), linear-gradient(#000, #000);
    mask-clip: padding-box, border-box;
    mask-composite: intersect;
}

.border-beam::after {
    content: "";
    position: absolute;
    width: 90px;
    aspect-ratio: 1;
    background: linear-gradient(to left, #ffb347, #a46bff, transparent);
    offset-path: rect(0 auto auto 0 round 14px);
    offset-anchor: 90% 50%;
    animation: border-beam 7s linear infinite;
}

@keyframes border-beam {
    to {
        offset-distance: 100%;
    }
}

/* Маршрут на карте прорисовывается от A к B */
.route-draw {
    stroke-dasharray: var(--len, 4000);
    stroke-dashoffset: var(--len, 4000);
    animation: route-draw 1.1s cubic-bezier(.45, 0, .2, 1) forwards;
}

@keyframes route-draw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes pin-drop {
    from {
        opacity: 0;
        transform: translateY(-14px) scale(0.6);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 76, 91, 0.45);
        opacity: 1;
    }
    100% {
        box-shadow: 0 0 0 12px rgba(231, 76, 91, 0);
        opacity: 0;
    }
}

@keyframes skeleton {
    to {
        background-position: -200% 0;
    }
}

.card-enter {
    animation: blur-fade-in 0.3s ease-out both;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0s !important;
        transition-duration: 0.01ms !important;
    }

    .route-draw {
        stroke-dashoffset: 0;
    }
}
