/* SESSION TESTS — анимации (scripts/anim.js). Только transform/opacity. */

/* ── Тест: ответ ── */
@keyframes stPop { 0% { transform: scale(1); } 40% { transform: scale(1.045); } 100% { transform: scale(1); } }
@keyframes stShake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
@keyframes stGlow { 0% { box-shadow: 0 0 0 0 rgba(61,220,132,.55); } 100% { box-shadow: 0 0 0 12px rgba(61,220,132,0); } }
.st-pop { animation: stPop .32s cubic-bezier(.2,.9,.3,1.3); }
.st-shake { animation: stShake .42s ease; }
.st-aglow { animation: stGlow .9s ease-out; }

/* ── Тест: переход между вопросами ── */
@keyframes stQNext { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes stQPrev { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
.st-q-next { animation: stQNext .28s cubic-bezier(.2,.8,.2,1); }
.st-q-prev { animation: stQPrev .28s cubic-bezier(.2,.8,.2,1); }
#answers.st-q-next > button, #answers.st-q-prev > button { animation: stQNext .3s cubic-bezier(.2,.8,.2,1) both; }
#answers.st-q-prev > button { animation-name: stQPrev; }
#answers.st-q-next > button:nth-child(2), #answers.st-q-prev > button:nth-child(2) { animation-delay: .03s; }
#answers.st-q-next > button:nth-child(3), #answers.st-q-prev > button:nth-child(3) { animation-delay: .06s; }
#answers.st-q-next > button:nth-child(4), #answers.st-q-prev > button:nth-child(4) { animation-delay: .09s; }
#answers.st-q-next > button:nth-child(5), #answers.st-q-prev > button:nth-child(5) { animation-delay: .12s; }

/* ── Прогресс теста плавно ── */
.st-quiz-progress-fill { transition: width .45s cubic-bezier(.2,.8,.2,1) !important; }

/* ── Итог теста: круг с процентом ── */
.st-result-ring { position: relative; width: 132px; height: 132px; margin: 6px auto 10px; }
.st-result-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.st-rr-bg { fill: none; stroke: rgba(255,255,255,.1); stroke-width: 10; }
.st-rr-fg { fill: none; stroke: #8b7bff; stroke-width: 10; stroke-linecap: round; }
.st-result-ring[data-level="top"] .st-rr-fg { stroke: #3ddc84; }
.st-result-ring[data-level="low"] .st-rr-fg { stroke: #f5b14c; }
.st-rr-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.st-confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 6000; pointer-events: none; }

/* ── Чат ── */
@keyframes stMsgIn { 0% { opacity: 0; transform: translateY(14px) scale(.96); } 70% { transform: translateY(-2px) scale(1.01); } 100% { opacity: 1; transform: none; } }
.chat-msg.st-msg-in, .chat-msg.is-pending { animation: stMsgIn .32s cubic-bezier(.2,.8,.2,1); }
.chat-msg.is-me.st-msg-in, .chat-msg.is-me.is-pending { transform-origin: bottom right; }
.chat-msg.is-other.st-msg-in { transform-origin: bottom left; }
.ig-react-pill.st-pop { animation: stPop .35s cubic-bezier(.2,.9,.3,1.6); }
.st-dots { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle; }
.st-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: stDot 1.1s ease-in-out infinite; }
.st-dots i:nth-child(2) { animation-delay: .15s; }
.st-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes stDot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ── Списки каскадом ── */
@keyframes stRowIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.st-cascade > * { animation: stRowIn .32s cubic-bezier(.2,.8,.2,1) both; }
.st-cascade > .mx-grid > *, .st-cascade > .mx-tracks > * { animation: stRowIn .32s cubic-bezier(.2,.8,.2,1) both; }
.st-cascade > :nth-child(2) { animation-delay: .03s; } .st-cascade > :nth-child(3) { animation-delay: .06s; }
.st-cascade > :nth-child(4) { animation-delay: .09s; } .st-cascade > :nth-child(5) { animation-delay: .12s; }
.st-cascade > :nth-child(6) { animation-delay: .15s; } .st-cascade > :nth-child(7) { animation-delay: .18s; }
.st-cascade > :nth-child(8) { animation-delay: .21s; } .st-cascade > :nth-child(n+9) { animation-delay: .24s; }

/* ── Скелетоны ── */
@keyframes stShimmer { from { background-position: -200px 0; } to { background-position: 200px 0; } }
.st-skel { display: block; border-radius: 8px; background: linear-gradient(90deg, rgba(255,255,255,.05) 0, rgba(255,255,255,.11) 40px, rgba(255,255,255,.05) 80px) 0 0 / 400px 100% repeat-x, rgba(255,255,255,.04); animation: stShimmer 1.2s linear infinite; }
.st-skel-list { display: flex; flex-direction: column; gap: 6px; padding: 6px 4px; }
.st-skel-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; }
.st-skel-ava { flex: 0 0 48px; width: 48px; height: 48px; border-radius: 50%; }
.st-skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.st-skel-l1 { height: 12px; width: 55%; }
.st-skel-l2 { height: 10px; width: 80%; }
.st-skel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.st-skel-card { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.st-skel-sq { aspect-ratio: 1; width: 100%; border-radius: 10px; }
@media (max-width: 767px) { .st-skel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ── Переход страниц ── */
@keyframes stPageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.st-page-in { animation: stPageIn .26s cubic-bezier(.2,.8,.2,1); }

/* ── Нижнее меню: активная вкладка ── */
.st-tabbar a { position: relative; }
.st-tabbar a .st-tab-icon, .st-tabbar a svg { transition: transform .22s cubic-bezier(.2,.9,.3,1.4); }
.st-tabbar a.is-active .st-tab-icon, .st-tabbar a.is-active > svg { transform: translateY(-2px) scale(1.12); }
.st-tabbar a::after { content: ""; position: absolute; left: 50%; top: 3px; width: 18px; height: 3px; margin-left: -9px; border-radius: 2px; background: currentColor; opacity: 0; transform: scaleX(.2); transition: transform .25s cubic-bezier(.2,.8,.2,1), opacity .2s; }
.st-tabbar a.is-active::after { opacity: .9; transform: scaleX(1); }

/* ── Окна снизу: пружина ── */
@keyframes stSheetSpring { 0% { transform: translateY(60px); opacity: 0; } 70% { transform: translateY(-4px); opacity: 1; } 100% { transform: none; } }
@media (max-width: 767px) {
  .st-modal.is-open .st-modal-card, #profileModal .modal-content, .mx-menu.is-sheet { animation: stSheetSpring .34s cubic-bezier(.2,.8,.2,1) !important; }
}

/* ── «Вместе» ── */
@keyframes stFlash { 0% { box-shadow: 0 0 0 0 rgba(139,123,255,.8); transform: scale(1); } 40% { transform: scale(1.12); } 100% { box-shadow: 0 0 0 12px rgba(139,123,255,0); transform: scale(1); } }
.room-member.just-answered .room-ava { animation: stFlash .8s ease-out; }
@keyframes stBarGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.room-opt-bar { transform-origin: left center; animation: stBarGrow .55s cubic-bezier(.2,.8,.2,1) both; }
.room-opt:nth-child(2) .room-opt-bar { animation-delay: .06s; }
.room-opt:nth-child(3) .room-opt-bar { animation-delay: .12s; }
.room-opt:nth-child(4) .room-opt-bar { animation-delay: .18s; }
.room-opt:nth-child(5) .room-opt-bar { animation-delay: .24s; }

/* Кто попросил систему меньше анимаций — выключаем всё это. */
@media (prefers-reduced-motion: reduce) {
  .st-pop, .st-shake, .st-aglow, .st-q-next, .st-q-prev, #answers > button, .st-msg-in, .chat-msg.is-pending,
  .st-cascade > *, .st-page-in, .st-skel, .room-opt-bar, .room-member.just-answered .room-ava, .st-dots i { animation: none !important; }
  .st-tabbar a .st-tab-icon, .st-tabbar a svg, .st-quiz-progress-fill { transition: none !important; }
}
