/* Контейнеры для анимаций */
.animation-invest-top {
    position: relative;
    width: 100%;
    max-width: 796px;
    aspect-ratio: 796 / 436;
    margin: 0 auto;
    overflow: hidden;
}

.animation-invest-bottom {
    position: relative;
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
}

.animation-zaem-top {
    position: relative;
    width: 100%;
    aspect-ratio: 650 / 444.117;
    overflow: visible;
}

.animation-zaem-bottom {
    position: relative;
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
}

/* Прогресс бары */

.animation-invest-top .progress-bar {
    top: 81.5%;
    left: 18%;
    height: 2.2%;
    width: 65%; /* Максимальня ширина */
}

.animation-zaem-top .progress-bar {
    top: 60.569624670976341819835763999126%;
    left: 31.846153846153846153846153846154%;
    height: 1.1%;
    width: 33.692307692307692307692307692308%; /* Максимальня ширина */
}

/* Контейнеры для анимации текста */

.animation-invest-top .animation-text {
    top: 13.5%;
    left: 12.5%;
    width: 72%;
    height: 65%;
}

.animation-zaem-top .animation-text {
    top: 13.5%;
    left: 20.5%;
    width: 63.3%;
    height: 46%;
}

/* Размеры текстов SVG */

.animation-invest-top text { font-size: 0.7em }
.animation-zaem-top text { font-size: 0.7em }

/* Контейнеры для кнопки Play */

.animation-invest-top .play-button {
    top: 50%;
    left: 49%;
    transform: translate(-50%, -50%); /* Используем translate для позиционирования */
    width: 30%;
    height: 30%;
}

.animation-invest-bottom .play-button {
    top: 57%;
    left: 50%;
    transform: translate(-50%, -50%); /* Используем translate для позиционирования */
    width: 40%;
    height: 40%;
}

.animation-zaem-top .play-button {
    top: 38.5%;
    left: 52.5%;
    transform: translate(-50%, -50%); /* Используем translate для позиционирования */
    width: 24%;
    height: 24%;
}

.animation-zaem-bottom .play-button {
    top: 57%;
    left: 50%;
    transform: translate(-50%, -50%); /* Используем translate для позиционирования */
    width: 40%;
    height: 40%;
}

/* Контейнеры для персонажей */
.animation-invest-top .character {
    position: absolute;
    bottom: 0;
    right: 0;
    transform: scale(1); /* Масштабирование с использованием transform */
    width: 40.5%;
    height: auto;
    z-index: 2;
}

.animation-invest-bottom .character {
    position: absolute;
    bottom: 0;
    right: 0;
    transform: scale(1); /* Масштабирование с использованием transform */
    width: 33%;
    height: auto;
    z-index: 2;
}

.animation-zaem-top .character {
    position: absolute;
    bottom: -2.4768248006718950186549940668788%;
    left: 0;
    transform: scale(1); /* Масштабирование с использованием transform */
    width: 100%;
    height: auto;
    z-index: 2;
}

.animation-zaem-bottom .character {
    position: absolute;
    bottom: 0;
    left: 0;
    transform: scale(1); /* Масштабирование с использованием transform */
    width: 55.5%;
    height: auto;
    z-index: 2;
}


/* УНИВЕРСАЛЬНЫЕ (прописать для каждого контейнера) */

.animation-invest-top .play-button,
.animation-invest-bottom .play-button,
.animation-zaem-top .play-button,
.animation-zaem-bottom .play-button {
    position: absolute;
    z-index: 3;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center;
    animation: playButtonAnimation 3s ease-in-out infinite;
    transition: transform 2.5s ease, animation 2.5s ease;
    will-change: transform; /* Оптимизация */
}

.animation-invest-top .play-circle,
.animation-invest-bottom .play-circle,
.animation-zaem-top .play-circle,
.animation-zaem-bottom .play-circle {
    position: absolute;
    width: 82%;
    height: 82%;
    animation: playCircleColorAnimation 3s ease-in-out infinite;
    will-change: fill; /* Оптимизация для изменения цвета */
}

.animation-invest-top .play-triangle,
.animation-invest-bottom .play-triangle,
.animation-zaem-top .play-triangle,
.animation-zaem-bottom .play-triangle {
    position: absolute;
    width: 40%;
    height: 40%;
    transform: translateX(5%);
}

/* Состояние паузы всех анимаций, когда контейнер вне зоны видимости */
.animation-invest-top:not(.animations-running) *,
.animation-invest-bottom:not(.animations-running) *,
.animation-zaem-top:not(.animations-running) *,
.animation-zaem-bottom:not(.animations-running) * {
    animation-play-state: paused !important;
}

/* Прямоугольник для прогресс-бара */
.animation-invest-top .progress-bar,
.animation-zaem-top .progress-bar {
    position: absolute;
    transform-origin: left; /* Преобразование начинается с левого края */
    background-color: #FF735D;
    z-index: 1;
    transform: scaleX(0); /* Начальное значение scale */
    animation: progressBarAnimation 3s linear infinite;
}

/* Контейнер для анимации текста */
.animation-invest-top .animation-text,
.animation-zaem-top .animation-text {
    position: absolute;
    overflow: hidden;
    user-select: none;
    z-index: 1;
}

.animation-invest-top text,
.animation-zaem-top text {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: middle;
    user-select: none;
}

.animation-invest-top svg,
.animation-zaem-top svg {
    width: 100%;
    height: 100%;
    user-select: none;
}


/* УНИВЕРСАЛЬНЫЕ */

/* Определяем переменную для скорости анимации */
:root {
    --rotate-speed: 6s;
}

/* Ссылка охватывает весь контейнер */
.animation-link {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    text-decoration: none;
    transition: fill 0.5s ease;
}

/* Контейнер для ноутбука */
.animation-invest-top .laptop,
.animation-zaem-top .laptop {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

/* Контейнер для ноутбука */
.animation-invest-bottom .laptop,
.animation-zaem-bottom .laptop {
    position: absolute;
    inset: 0; /* Используем inset для позиционирования */
    z-index: 0;
}

.play-lines {
    position: absolute;
    width: 100%;
    height: 100%;
    animation: rotate720 var(--rotate-speed) linear infinite;
    transition: all 1s ease-in-out;
    will-change: transform; /* Оптимизация для вращения */
}

/* Добавление плавного перехода для круга */
.play-circle circle {
    transition: fill 0.5s ease;
}

.svg-character {
    width: 100%;
    height: auto;
    display: block;
}

.svg-laptop {
    width: 100%;
    height: 100%;
    display: block;
}

.animate-text {
    animation: loopAnimation 6s infinite;
    transition: fill 0.5s ease;
}

/* Анимация пульсации (heartbeat) */
.heartbeat {
    -webkit-animation: heartbeat 1.5s ease-in-out infinite both;
    animation: heartbeat 1.5s ease-in-out infinite both;
}

/* АНИМАЦИИ (УНИВЕРСАЛЬНЫЕ) */

/* Анимация прогресс-бара с использованием scaleX */
@keyframes progressBarAnimation {
    0% { transform: scaleX(0); /* Прогресс бар скрыт */ }
    100% { transform: scaleX(1); /* Прогресс бар полностью заполнен */ }
}

/* Анимация всей кнопки play */
@keyframes playButtonAnimation {
    0% { transform: translate(-50%, -70%) scale(1); }
    15% { transform: translate(-50%, -70%) scale(0.67); }
    25% { transform: translate(-50%, -70%) scale(1.17); }
    35% { transform: translate(-50%, -70%) scale(0.91); }
    40% { transform: translate(-50%, -70%) scale(1); }
    100% { transform: translate(-50%, -70%) scale(1); }
}

/* Анимация при наведении */
@keyframes playButtonHover {
    0% { transform: translate(-50%, -70%) scale(1); }
    100% { transform: translate(-50%, -70%) scale(1.17); }
}

/* Анимация вращения с изменением прозрачности */
@keyframes rotate720 {
    0% {
        transform: rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: rotate(720deg);
        opacity: 1;
    }
}

/* Анимация текста */
@keyframes loopAnimation {
    0% {
        letter-spacing: -0.5em;
        opacity: 0;
        filter: blur(0px);
    }
    25% {
        letter-spacing: normal;
        opacity: 1;
    }
    50% {
        letter-spacing: normal;
        opacity: 1;
    }
    80% {
        filter: blur(0px);
        letter-spacing: normal;
        opacity: 1;
    }
    100% {
        letter-spacing: 1em;
        opacity: 0;
        filter: blur(5px);
    }
}

/* Анимация цвета круга */
@keyframes playCircleColorAnimation {
    0% { fill: #FF735D; }
    15% { fill: #FD8C7A; }
    25% { fill: #EC543C; }
    35% { fill: #FF735D; }
    100% { fill: #FF735D; }
}

/* Анимация heartbeat */
@keyframes heartbeat {
    from {
    -webkit-transform: translateX(5%) scale(1); /* Сохраняем translateX(5%) */
            transform: translateX(5%) scale(1);
    -webkit-transform-origin: center center;
            transform-origin: center center;
    -webkit-animation-timing-function: ease-out;
            animation-timing-function: ease-out;
    }
    10% {
    -webkit-transform: translateX(5%) scale(0.91); /* Пульсация + translateX(5%) */
            transform: translateX(5%) scale(0.91);
    -webkit-animation-timing-function: ease-in;
            animation-timing-function: ease-in;
    }
    17% {
    -webkit-transform: translateX(5%) scale(0.98);
            transform: translateX(5%) scale(0.98);
    -webkit-animation-timing-function: ease-out;
            animation-timing-function: ease-out;
    }
    33% {
    -webkit-transform: translateX(5%) scale(0.87);
            transform: translateX(5%) scale(0.87);
    -webkit-animation-timing-function: ease-in;
            animation-timing-function: ease-in;
    }
    45% {
    -webkit-transform: translateX(5%) scale(1);
            transform: translateX(5%) scale(1);
    -webkit-animation-timing-function: ease-out;
            animation-timing-function: ease-out;
    }
}

/* ИЗМЕНЕНИЕ СОСТОЯНИЙ */

.animation-invest-top:hover .play-button {
    animation: playButtonHover 0.5s forwards;
    transition: transform 0.5s ease, animation 0.5s ease;
}

.animation-invest-bottom:hover .play-button {
    animation: playButtonHover 0.5s forwards;
    transition: transform 0.5s ease, animation 0.5s ease;
}

.animation-zaem-top:hover .play-button {
    animation: playButtonHover 0.5s forwards;
    transition: transform 0.5s ease, animation 0.5s ease;
}

.animation-zaem-bottom:hover .play-button {
    animation: playButtonHover 0.5s forwards;
    transition: transform 0.5s ease, animation 0.5s ease;
}

.animation-invest-top:hover .play-circle circle { fill: #EC543C }
.animation-invest-bottom:hover .play-circle circle { fill: #EC543C }
.animation-zaem-top:hover .play-circle circle { fill: #EC543C }
.animation-zaem-bottom:hover .play-circle circle { fill: #EC543C }

.animation-invest-top:hover .play-lines { --rotate-speed: 3s }
.animation-invest-bottom:hover .play-lines { --rotate-speed: 3s }
.animation-zaem-top:hover .play-lines { --rotate-speed: 3s }
.animation-zaem-bottom:hover .play-lines { --rotate-speed: 3s }

.animation-invest-top:hover .animate-text {fill: #EC543C}
.animation-zaem-top:hover .animate-text {fill: #EC543C}

.animation-invest-top:hover .play-triangle { animation: heartbeat 1.5s ease-in-out infinite both }
.animation-invest-bottom:hover .play-triangle { animation: heartbeat 1.5s ease-in-out infinite both }
.animation-zaem-top:hover .play-triangle { animation: heartbeat 1.5s ease-in-out infinite both }
.animation-zaem-bottom:hover .play-triangle { animation: heartbeat 1.5s ease-in-out infinite both }

@media all and (max-width: 520px) {
    .animation-zaem-bottom {aspect-ratio: 200 / 135;}
    .animation-invest-bottom {aspect-ratio: 200 / 135;}
}