/* AI:DA — движение точек знака (предложение, 2.1)
 *
 * Две точки двоеточия (sun сверху, mane снизу) показывают состояние системы:
 * думает, загружает, отвечает, слушает, ждёт, готово, ошибка, появление.
 *
 * Разметка:
 *   <span class="aida-dots aida-dots--think" aria-hidden="true"><i></i><i></i></span>
 *   <span>Думаем над ответом</span>        ← слово обязательно (правило 4)
 * Внутри знака: к `.aida-colon` добавляется `aida-dots` и модификатор —
 *   AI<span class="aida-colon aida-dots aida-dots--think"><i></i><i></i></span>DA
 *
 * Размер задаёт font-size: геометрия та же, что у двоеточия в logo/logo.css
 * (точка 0.19em, зазор 0.055em, высота 0.70em). Меньше 18px точки сливаются —
 * там точки не анимируют, а ставят слово.
 *
 * Кривые. Однократное движение — `--ease` без перелёта. Петли — ease-in-out,
 * как у символов курсов в marks/*.svg: у петли нет «прихода», ей нужна
 * симметричная кривая.
 *
 * Всё выключается по prefers-reduced-motion: точки стоят на местах, слово
 * остаётся.
 */

.aida-dots {
  --dot: 0.19em;
  --gap: 0.055em;
  display: inline-block;
  position: relative;
  vertical-align: baseline;
  width: var(--dot);
  height: 0.70em;
  overflow: visible;           /* в .aida-colon стоит hidden — снимаем для движения */
}
.aida-dots i {
  position: absolute;
  left: 0;
  width: var(--dot);
  height: var(--dot);
  border-radius: var(--radius-pill, 999px);
  background: var(--mane);
  transform-origin: 50% 50%;
}
.aida-dots i:first-child {
  bottom: calc(50% + var(--gap) / 2);
  background: var(--sun);
  z-index: 1;                  /* при слиянии солнце сверху */
}
.aida-dots i:last-child { top: calc(50% + var(--gap) / 2); }

@media (prefers-reduced-motion: no-preference) {

  /* Думает — точки по очереди затихают. Петля 1,6 с. */
  .aida-dots--think i { animation: aida-dots-think 1.6s ease-in-out infinite; }
  .aida-dots--think i:last-child { animation-delay: -0.8s; }

  /* Загружает — пара проворачивается на пол-оборота и замирает. Петля 1,4 с. */
  .aida-dots--load { animation: aida-dots-orbit 1.4s infinite; }

  /* Отвечает (пишет) — точки по очереди приподнимаются. Петля 1,1 с. */
  .aida-dots--type i { animation: aida-dots-type 1.1s ease-in-out infinite; }
  .aida-dots--type i:last-child { animation-delay: 0.16s; }

  /* Ждёт действия человека — дышит только солнце. Петля 2,4 с. */
  .aida-dots--wait i:first-child { animation: aida-dots-wait 2.4s ease-in-out infinite; }

  /* Слушает — размер точек идёт за уровнем звука: --l1, --l2 от 0 до 1
     выставляет скрипт. Предел 1,25: дальше точки заходят друг на друга. */
  .aida-dots--listen i {
    transform: scale(calc(1 + var(--l1, 0) * 0.25));
    transition: transform var(--motion-fast, 120ms) linear;
  }
  .aida-dots--listen i:last-child { transform: scale(calc(1 + var(--l2, 0) * 0.25)); }

  /* Однократные: запускаются добавлением класса, 1 раз. */

  /* Готово — точки сходятся в одну и расходятся обратно. 0,9 с. */
  .aida-dots--done i:first-child { animation: aida-dots-merge-top 0.9s both; }
  .aida-dots--done i:last-child { animation: aida-dots-merge-bottom 0.9s both; }

  /* Ошибка — пара качает «нет» с затуханием. 0,6 с. */
  .aida-dots--error { animation: aida-dots-shake 0.6s both; }

  /* Появление — точки возникают по очереди, шаг --stagger. 0,4 с. */
  .aida-dots--enter i { animation: aida-dots-enter var(--motion-slow, 400ms) var(--ease, cubic-bezier(0.2, 0, 0, 1)) both; }
  .aida-dots--enter i:last-child { animation-delay: var(--stagger, 60ms); }
}

@keyframes aida-dots-think {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(0.62); opacity: 0.45; }
}
@keyframes aida-dots-orbit {
  0%   { transform: rotate(0deg);   animation-timing-function: var(--ease, cubic-bezier(0.2, 0, 0, 1)); }
  45%  { transform: rotate(180deg); }
  50%  { transform: rotate(180deg); animation-timing-function: var(--ease, cubic-bezier(0.2, 0, 0, 1)); }
  95%  { transform: rotate(360deg); }
  100% { transform: rotate(360deg); }
}
@keyframes aida-dots-type {
  0%, 50%, 100% { transform: translateY(0); }
  22%           { transform: translateY(-0.05em); }
}
@keyframes aida-dots-wait {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
@keyframes aida-dots-merge-top {
  0%   { transform: translateY(0);        animation-timing-function: var(--ease, cubic-bezier(0.2, 0, 0, 1)); }
  35%  { transform: translateY(0.1225em); }
  65%  { transform: translateY(0.1225em); animation-timing-function: var(--ease, cubic-bezier(0.2, 0, 0, 1)); }
  100% { transform: translateY(0); }
}
@keyframes aida-dots-merge-bottom {
  0%   { transform: translateY(0);         animation-timing-function: var(--ease, cubic-bezier(0.2, 0, 0, 1)); }
  35%  { transform: translateY(-0.1225em); }
  65%  { transform: translateY(-0.1225em); animation-timing-function: var(--ease, cubic-bezier(0.2, 0, 0, 1)); }
  100% { transform: translateY(0); }
}
@keyframes aida-dots-shake {
  0%, 75%, 100% { transform: translateX(0); }
  15% { transform: translateX(0.06em); }
  30% { transform: translateX(-0.05em); }
  45% { transform: translateX(0.035em); }
  60% { transform: translateX(-0.02em); }
}
@keyframes aida-dots-enter {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

@media (forced-colors: active) {
  .aida-dots i { background: CanvasText; forced-color-adjust: none; }
}
