/* ==========================================================================
   Знак ЛЭТО
   --------------------------------------------------------------------------
   Анимация собрана по макету из папки «для правок»: кольцо-меандр
   проявляется, из него вырастают листья, затем четыре слова складываются
   в диагональное «ЛЭТО». Финальный кадр — обычный логотип, поэтому
   статичная версия и конец анимации совпадают.

   Разметка — app/templates/_hub_leto_mark.html. Цвета — переменные
   --leto-ring / --leto-leaf / --leto-ink: знак стоит на тёмных медальонах
   в обеих темах POLIS, поэтому значения по умолчанию светлые.
   ========================================================================== */

.leto-mark {
  --leto-ring: #21f0a8;
  --leto-leaf: #f4fffb;
  --leto-ink: #f4fffb;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  user-select: none;
}

/* --- Кольцо-меандр: мягкое появление в конце сборки --- */
.leto-mark .meander-anim {
  opacity: 0;
  transform-origin: 10500px 10500px;
}

.leto-mark--animated .meander-anim {
  animation: leto-ring-fade 0.85s ease-out 3.6s both;
}

@keyframes leto-ring-fade {
  0% { opacity: 0; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}

/* --- Листья: маска-дуга прорисовывается и открывает зелень --- */
.leto-mark .vine-arc {
  fill: none;
  stroke: #fff;
  stroke-width: 5200;
  stroke-linecap: round;
  stroke-dasharray: 100 100;
  stroke-dashoffset: 100;
  opacity: 0;
}

.leto-mark--animated .vine-left {
  animation: leto-draw-vine 2.3s cubic-bezier(0.32, 0.72, 0.28, 1) 4s both;
}

.leto-mark--animated .vine-right {
  animation: leto-draw-vine 2.4s cubic-bezier(0.32, 0.72, 0.28, 1) 4.15s both;
}

@keyframes leto-draw-vine {
  0% { stroke-dashoffset: 100; opacity: 0; }
  3% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}

/* --- Четыре слова: буква остаётся, хвост уходит --- */
.leto-mark .word-group {
  opacity: 0;
}

.leto-mark--animated .w-logic { animation: leto-word-appear 0.45s ease-out 0.15s both; }
.leto-mark--animated .t-logic { animation: leto-tail-fade 0.45s ease-in 0.7s forwards; }
.leto-mark--animated .w-ethics { animation: leto-word-appear 0.45s ease-out 0.95s both; }
.leto-mark--animated .t-ethics { animation: leto-tail-fade 0.45s ease-in 1.5s forwards; }
.leto-mark--animated .w-creativity { animation: leto-word-appear 0.45s ease-out 1.75s both; }
.leto-mark--animated .t-creativity { animation: leto-tail-fade 0.45s ease-in 2.3s forwards; }
.leto-mark--animated .w-comm { animation: leto-word-appear 0.45s ease-out 2.55s both; }
.leto-mark--animated .t-comm { animation: leto-tail-fade 0.45s ease-in 3.1s forwards; }

@keyframes leto-word-appear {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes leto-tail-fade {
  0% { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(14px); }
}

/* --- Заглавные буквы встают по диагонали --- */
.leto-mark .cap-l,
.leto-mark .cap-e,
.leto-mark .cap-t,
.leto-mark .cap-o {
  transform-box: fill-box;
  transform-origin: center;
}

.leto-mark--animated .cap-l { animation: leto-move-l 0.85s cubic-bezier(0.22, 1, 0.36, 1) 3.45s forwards; }
.leto-mark--animated .cap-e { animation: leto-move-e 0.85s cubic-bezier(0.22, 1, 0.36, 1) 3.45s forwards; }
.leto-mark--animated .cap-t { animation: leto-move-t 0.85s cubic-bezier(0.22, 1, 0.36, 1) 3.45s forwards; }
.leto-mark--animated .cap-o { animation: leto-move-o 0.85s cubic-bezier(0.22, 1, 0.36, 1) 3.45s forwards; }

@keyframes leto-move-l { to { transform: translate(-25px, 74px) scale(2.2); } }
@keyframes leto-move-e { to { transform: translate(43px, 29px) scale(2.2); } }
@keyframes leto-move-t { to { transform: translate(111px, -16px) scale(2.2); } }
@keyframes leto-move-o { to { transform: translate(181px, -61px) scale(2.2); } }

/* --- Статичный финальный кадр --- */
.leto-mark--static .meander-anim {
  opacity: 1;
  transform: scale(1);
}

.leto-mark--static .vine-arc {
  opacity: 1;
  stroke-dashoffset: 0;
}

.leto-mark--static .word-group {
  opacity: 1;
}

.leto-mark--static .t-logic,
.leto-mark--static .t-ethics,
.leto-mark--static .t-creativity,
.leto-mark--static .t-comm {
  opacity: 0;
  transform: translateX(14px);
}

.leto-mark--static .cap-l { transform: translate(-25px, 74px) scale(2.2); }
.leto-mark--static .cap-e { transform: translate(43px, 29px) scale(2.2); }
.leto-mark--static .cap-t { transform: translate(111px, -16px) scale(2.2); }
.leto-mark--static .cap-o { transform: translate(181px, -61px) scale(2.2); }

/* --- Доступность: при отключённой анимации показываем финал --- */
@media (prefers-reduced-motion: reduce) {
  .leto-mark .meander-anim {
    animation: none;
    opacity: 1;
    transform: scale(1);
  }

  .leto-mark .vine-arc {
    animation: none;
    opacity: 1;
    stroke-dashoffset: 0;
  }

  .leto-mark .word-group {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .leto-mark .t-logic,
  .leto-mark .t-ethics,
  .leto-mark .t-creativity,
  .leto-mark .t-comm {
    animation: none;
    opacity: 0;
    transform: translateX(14px);
  }

  .leto-mark .cap-l { animation: none; transform: translate(-25px, 74px) scale(2.2); }
  .leto-mark .cap-e { animation: none; transform: translate(43px, 29px) scale(2.2); }
  .leto-mark .cap-t { animation: none; transform: translate(111px, -16px) scale(2.2); }
  .leto-mark .cap-o { animation: none; transform: translate(181px, -61px) scale(2.2); }
}

/* --- Посадка знака в медальонах --- */
.hub-brand__mark .leto-mark,
.hub-footer .hub-brand__mark .leto-mark {
  width: 100%;
  height: 100%;
}

.hub-hero__aside .leto-mark {
  width: 100%;
  height: 100%;
}

@media (max-width: 980px) {
  .hub-hero__mobile-seal .leto-mark {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
}
