/* ============================================================
   Движение. Только transform и opacity (не грузит телефон).
   Отключается целиком: настройка «Спокойное» (data-motion="calm") или системное «уменьшить движение».
   Длительности и кривые — токены --d1..--d3, --ease*, --stagger из tokens.css.
   ============================================================ */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 18px) scale(.94); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes mark-draw { from { opacity: 0; transform: translateY(8px) scale(.96); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }

/* Экран появляется, когда app.js снимает с него .hidden */
#app > section:not(.hidden) { animation: rise var(--d3) var(--ease-out) both; }
#screen-client:not(.hidden) > *, #screen-admin:not(.hidden) > .card { animation: rise var(--d3) var(--ease-out) both; }
#screen-client > *:nth-child(2), #screen-admin > *:nth-child(2) { animation-delay: calc(var(--stagger) * 2); }
#screen-client > *:nth-child(3) { animation-delay: calc(var(--stagger) * 4); }
.logo-lg { animation: mark-draw 1.1s var(--ease-out) both; }

/* Рабочая область админа: анимация только при смене вкладки (класс ставит ui/enhance.js),
   иначе каждый клик по фильтру таблицы дёргал бы карточку заново */
#adm-workspace.ws-enter > .card { animation: rise var(--d3) var(--ease-out) both; }
#adm-workspace.ws-enter > .card:nth-child(2) { animation-delay: calc(var(--stagger) * 1.5); }
#adm-workspace.ws-enter > .card:nth-child(3) { animation-delay: calc(var(--stagger) * 3); }
#adm-workspace.ws-enter > .card:nth-child(n+4) { animation-delay: calc(var(--stagger) * 4); }

/* Списки, которые подгружаются по выбору (ученики группы, абонементы) — лесенкой */
.list-item { animation: rise var(--d2) var(--ease-out) both; }
.list-item:nth-child(2) { animation-delay: calc(var(--stagger) * 1); }
.list-item:nth-child(3) { animation-delay: calc(var(--stagger) * 2); }
.list-item:nth-child(4) { animation-delay: calc(var(--stagger) * 3); }
.list-item:nth-child(5) { animation-delay: calc(var(--stagger) * 4); }
.list-item:nth-child(n+6) { animation-delay: calc(var(--stagger) * 5); }
[id^="grp-clients-"]:not(.hidden) > * { animation: rise var(--d2) var(--ease-out) both; }

#cl-info-panel:not(.hidden) { animation: rise var(--d2) var(--ease-out) both; }
.th-dropdown { animation: pop var(--d2) var(--ease-spring) both; }
.toast:not(.hidden) { animation: toast-in var(--d2) var(--ease-spring) both; }
#qr-result img { animation: pop var(--d3) var(--ease-spring) both; }

/* «Загрузка...» от app.js — мягкий перелив вместо мёртвого текста */
[id^="grp-clients-"] > .muted.small:only-child {
  background: linear-gradient(90deg, var(--muted) 0%, var(--text) 50%, var(--muted) 100%) 0 0 / 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.6s linear infinite;
}

/* Смена темы: круг раскрывается от нажатой карточки (View Transitions, где браузер умеет) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: vt-reveal .7s var(--ease-out) both; }
@keyframes vt-reveal { from { clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 50%)); } to { clip-path: circle(150vmax at var(--vt-x, 50%) var(--vt-y, 50%)); } }

/* ---- Спокойный режим ---- */
:root[data-motion="calm"] *, :root[data-motion="calm"] *::before, :root[data-motion="calm"] *::after {
  animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) *, :root:not([data-motion="full"]) *::before, :root:not([data-motion="full"]) *::after {
    animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
