/* FAME: живой первый экран (шапка + hero).
   Классы на <html> ставит motion/hero.js (hm-wait - ещё и строка в <head>):
   hm-wait  - ждём шрифт, элементы первого экрана скрыты (с запасным показом через 2.5 с);
   hm-intro - идёт заставка (у всех анимаций fill both, последний кадр = обычный вид);
   hm       - движение разрешено, скрипт работает;
   hm-idle  - заставка закончилась.
   .hm-off на .hero и .site-header - первый экран за краем, бесконечные анимации на паузе.
   Двигаем только transform / opacity / clip-path. */

@keyframes hm-failsafe {
  to { opacity: 1; }
}

@keyframes hm-failsafe-mark {
  to { opacity: .64; }
}

/* Буквы FAME: существуют только во время заставки, потом h1 возвращается к обычному тексту.
   nowrap: между inline-block появляются места переноса, а слово целиком переноситься не должно. */
.hero-title.hm-split {
  white-space: nowrap;
}

.hm-l {
  display: inline-block;
  clip-path: inset(-.3em -.3em 0 -.3em);
}

.hm-li {
  display: inline-block;
}

/* Точка «набор идёт» перед строкой в шапке: ширина 0, вёрстку не двигает. */
.hm-live {
  position: relative;
  display: inline-block;
  width: 0;
  height: 0;
  vertical-align: middle;
}

.hm-live::before,
.hm-live::after {
  content: "";
  position: absolute;
  top: -3px;
  right: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.hm-live::before {
  background: var(--foreground);
}

.hm-live::after {
  border: 1px solid var(--foreground);
  opacity: 0;
}

/* Бегущая строка под первым экраном. */
.hm-band {
  display: flex;
  align-items: center;
  height: 52px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  color: var(--foreground);
  font-family: var(--display);
  font-size: clamp(1.15rem, 1.7vw, 1.6rem);
  font-weight: 750;
  font-stretch: 44%;
  font-optical-sizing: none;
  font-variation-settings: "opsz" 36, "wdth" 44;
  line-height: 1;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
}

.hm-band-track {
  display: flex;
  flex: none;
  width: max-content;
}

.hm-band-group {
  display: flex;
  flex: none;
  align-items: center;
  gap: .9em;
  padding-right: .9em;
}

.hm-band-item {
  flex: none;
}

.hm-band-pixel {
  font-family: "Pixelify Sans", monospace;
  font-size: 1.1em; /* высота заглавных как у Roboto Flex в строке */
  font-weight: 700;
  letter-spacing: .04em;
  translate: 0 -.055em; /* и на одной линии с ними: крупный Pixelify иначе сидит на 1-1.5 px ниже */
}

.hm-band-star {
  flex: none;
  width: .62em;
  height: .62em;
  background: currentColor;
  clip-path: polygon(50% 5%, 61% 36%, 94% 36%, 67% 55%, 78% 88%, 50% 68%, 22% 88%, 33% 55%, 6% 36%, 39% 36%);
}

@media (max-width: 440px) {
  .hm-band {
    height: 44px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html.hm {
    --hm-ease: cubic-bezier(.16, 1, .3, 1);
    --hm-cut: cubic-bezier(.7, 0, .2, 1);
  }

  /* Пока ждём шрифт: первый экран скрыт. Если скрипт так и не запустился - всё само появится через 2.5 с. */
  html.hm-wait :is(.site-nav, .header-launch, .hero-title, .hero-subtitle, .hero-description, .hero-action .cta, .hm-band) {
    opacity: 0;
    animation: hm-failsafe .01s linear 2.5s forwards;
  }

  html.hm-wait .hero-mark,
  html.hm-intro .hero-mark:not(.hm-go) {
    opacity: 0;
    animation: hm-failsafe-mark .01s linear 2.5s forwards;
  }

  /* Шапка. */
  html.hm-intro :is(.site-nav, .header-launch) {
    animation: hm-drop .6s var(--hm-ease) both;
  }

  /* FAME: буквы по одной поднимаются из-под маски. */
  html.hm-intro .hm-li {
    animation: hm-rise .76s var(--hm-ease) both;
    animation-delay: calc(var(--i, 0) * 70ms);
  }

  html.hm-intro .hero-title:not(.hm-split) {
    animation: hm-fade .7s var(--hm-ease) both;
  }

  /* МЫШЛЕНИЕ МЕДИАБОГОВ: сплошная плашка вырастает слева и уезжает вправо, открывая текст. */
  html.hm-intro .hero-subtitle {
    position: relative;
    animation: hm-wipe-clip .86s .3s var(--hm-cut) both;
  }

  html.hm-intro .hero-subtitle::after {
    content: "";
    position: absolute;
    inset: -.04em -.07em -.12em;
    background: var(--foreground);
    transform-origin: right;
    animation: hm-wipe-bar .86s .3s var(--hm-cut) both;
  }

  html.hm-intro .hm-band {
    animation: hm-fade .8s .9s ease-out both;
  }

  html.hm-intro .hero-description {
    animation: hm-up .7s .56s var(--hm-ease) both;
  }

  /* Кнопка открывается шторкой, стрелка подъезжает следом. */
  html.hm-intro .hero-action .cta {
    animation: hm-cta-in .66s .64s var(--hm-cut) both;
  }

  html.hm-intro .hero-action .cta::after {
    animation: hm-arrow-in .42s 1.06s var(--hm-ease) both;
  }

  /* Знаки SS и FLEX: влетают с поворотом, потом медленно покачиваются. */
  html.hm .hero-mark-ss.hm-go {
    animation: hm-ss-in 1s var(--hm-delay, 0ms) cubic-bezier(.34, 1.3, .5, 1) both;
  }

  html.hm .hero-mark-flex.hm-go {
    animation: hm-flex-in 1s var(--hm-delay, 0ms) cubic-bezier(.3, 1.25, .5, 1) both;
  }

  html.hm .hero-mark-ss.hm-float {
    animation: hm-ss-float 8s linear infinite;
  }

  html.hm .hero-mark-flex.hm-float {
    animation: hm-flex-float 11s linear infinite;
  }

  /* Стрелка кнопки время от времени толкается вправо. */
  html.hm-idle .hero-action .cta::after {
    animation: hm-nudge 3.2s .6s cubic-bezier(.3, 0, .2, 1) infinite;
  }

  /* Под мышью и в фокусе стрелку ведёт обычный ховер кнопки, толчки не мешают. */
  html.hm-idle .hero-action .cta:is(:hover, :focus-visible)::after {
    animation: none;
  }

  .hm-live::before {
    animation: hm-blink 1.8s ease-in-out infinite;
  }

  .hm-live::after {
    animation: hm-ping 1.8s cubic-bezier(0, 0, .2, 1) infinite;
  }

  .hm-band-track {
    animation: hm-marquee var(--hm-band-time, 40s) linear infinite;
    animation-play-state: paused;
  }

  .hm-band.hm-run .hm-band-track {
    animation-play-state: running;
  }

  /* html.hm и .hero-action: правило должно быть сильнее html.hm .hero-mark-ss.hm-float
     и html.hm-idle .hero-action .cta::after, иначе их shorthand animation снова ставит running. */
  html.hm .hero.hm-off .hero-mark,
  html.hm .hero.hm-off .hero-action .cta::after,
  .site-header.hm-off .hm-live::before,
  .site-header.hm-off .hm-live::after {
    animation-play-state: paused;
  }
}

@keyframes hm-drop {
  from { opacity: 0; transform: translateY(-8px); }
}

@keyframes hm-rise {
  from { transform: translateY(112%); }
}

@keyframes hm-fade {
  from { opacity: 0; }
}

@keyframes hm-up {
  from { opacity: 0; transform: translateY(18px); }
}

@keyframes hm-wipe-clip {
  /* Первый кадр закрыт полностью: слева не торчит полоска плашки. */
  0% { clip-path: inset(-.2em calc(100% + .2em) -.2em -.2em); }
  50%, 100% { clip-path: inset(-.2em -.2em -.2em -.2em); }
}

@keyframes hm-wipe-bar {
  0%, 50% { transform: scaleX(1); }
  100% { transform: scaleX(0); }
}

@keyframes hm-cta-in {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes hm-arrow-in {
  from { opacity: 0; transform: translateX(-16px); }
}

/* У знаков одинаковый список функций во всех кадрах: так поворот идёт по кругу, а не через матрицу.
   Последний кадр совпадает с исходным transform из styles.css. */
@keyframes hm-ss-in {
  from {
    opacity: 0;
    transform: translate(50%, -43%) translate(0, -55%) rotate(23deg) rotate(-210deg) scale(.45);
  }
  to {
    opacity: .64;
    transform: translate(50%, -43%) translate(0, 0) rotate(23deg) rotate(0deg) scale(1);
  }
}

@keyframes hm-flex-in {
  from {
    opacity: 0;
    transform: translate(50%, -34%) translate(-70%, 10%) rotate(-30deg) rotate(-120deg) scale(.6);
  }
  to {
    opacity: .64;
    transform: translate(50%, -34%) translate(0, 0) rotate(-30deg) rotate(0deg) scale(1);
  }
}

/* Покачивание похоже на синус: скорость без рывков на стыках кадров. */
@keyframes hm-ss-float {
  0%, 100% {
    transform: translate(50%, -43%) translate(0, 0) rotate(23deg) rotate(0deg);
    animation-timing-function: cubic-bezier(.39, .575, .565, 1);
  }
  25% {
    transform: translate(50%, -43%) translate(0, -3%) rotate(23deg) rotate(5deg);
    animation-timing-function: cubic-bezier(.445, .05, .55, .95);
  }
  75% {
    transform: translate(50%, -43%) translate(0, 2%) rotate(23deg) rotate(-4deg);
    animation-timing-function: cubic-bezier(.47, 0, .745, .715);
  }
}

@keyframes hm-flex-float {
  0%, 100% {
    transform: translate(50%, -34%) translate(0, 0) rotate(-30deg) rotate(0deg);
    animation-timing-function: cubic-bezier(.39, .575, .565, 1);
  }
  25% {
    transform: translate(50%, -34%) translate(0, 2%) rotate(-30deg) rotate(-3deg);
    animation-timing-function: cubic-bezier(.445, .05, .55, .95);
  }
  75% {
    transform: translate(50%, -34%) translate(0, -2%) rotate(-30deg) rotate(3deg);
    animation-timing-function: cubic-bezier(.47, 0, .745, .715);
  }
}

@keyframes hm-nudge {
  0%, 62%, 100% { transform: none; }
  72% { transform: translateX(7px); }
  82% { transform: none; }
  90% { transform: translateX(4px); }
}

@keyframes hm-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

@keyframes hm-ping {
  0% { opacity: .7; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(3); }
}

@keyframes hm-marquee {
  to { transform: translateX(-50%); }
}
