/* A small addition to the original header. The hero and its animation stay intact. */
.header-telegram {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 4px 0 16px;
  border: 1px solid rgba(132, 181, 255, 0.3);
  border-radius: 14px;
  background: linear-gradient(115deg, rgba(52, 92, 153, 0.23), rgba(59, 47, 114, 0.27));
  box-shadow: inset 0 1px 0 rgba(197, 220, 255, 0.06), 0 0 22px rgba(90, 126, 233, 0.06);
  color: #deedff;
  text-decoration: none;
  white-space: nowrap;
  isolation: isolate;
  transition: border-color 200ms ease, background 200ms ease, box-shadow 200ms ease;
}

.header-telegram:hover,
.header-telegram:focus-visible {
  border-color: rgba(160, 204, 255, 0.65);
  background: linear-gradient(115deg, rgba(60, 111, 187, 0.32), rgba(91, 66, 155, 0.32));
  box-shadow: inset 0 1px 0 rgba(214, 229, 255, 0.1), 0 0 28px rgba(104, 132, 249, 0.17);
  color: #fff;
}

.header-telegram:focus-visible {
  outline: 2px solid #b7ceff;
  outline-offset: 4px;
}

.header-telegram__label {
  font-size: 0.79rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.header-telegram__space {
  position: relative;
  flex: 0 0 54px;
  width: 54px;
  height: 40px;
  overflow: hidden;
  border-radius: 10px;
  background: radial-gradient(ellipse at 70% 25%, rgba(141, 124, 238, 0.2), transparent 72%);
  pointer-events: none;
}

.header-telegram__stars {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #aecfff;
  opacity: 0.65;
  box-shadow: 23px -3px 0 #d9d1ff, 37px 14px 0 #b7d0fc, -3px 19px 0 #a5b8ed, 23px 24px 0 #a4a5e2;
}

.header-telegram__planet {
  position: absolute;
  width: 10px;
  height: 10px;
  top: 4px;
  right: 3px;
  border-radius: 50%;
  background: linear-gradient(135deg, #b2a0e3, #554481 70%);
  box-shadow: 0 0 9px rgba(163, 139, 243, 0.28);
  opacity: 0.65;
}

.header-telegram__plane {
  position: absolute;
  top: 10px;
  left: 12px;
  width: 24px;
  height: 24px;
  color: #e1f3ff;
  filter: drop-shadow(0 0 5px rgba(118, 191, 255, 0.5));
  transform-origin: 65% 40%;
}

.header-telegram__trail {
  position: absolute;
  top: 30px;
  left: 2px;
  width: 29px;
  height: 2px;
  border-radius: 50%;
  background: linear-gradient(90deg, transparent, #9c9cff 55%, #bdedff);
  box-shadow: 0 0 7px #9194ff;
  opacity: 0;
  transform: rotate(-39deg) scaleX(0.1);
  transform-origin: right center;
}

.header-telegram.is-launching .header-telegram__plane {
  animation: telegram-space-flight 2200ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.header-telegram.is-launching .header-telegram__trail {
  animation: telegram-space-trail 2200ms ease-out both;
}

.header-telegram.is-launching .header-telegram__stars {
  animation: telegram-space-stars 2200ms ease-out both;
}

@keyframes telegram-space-flight {
  0% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
  17% { transform: translate(-4px, 3px) rotate(-9deg) scale(1.04); opacity: 1; }
  46% { transform: translate(23px, -19px) rotate(7deg) scale(0.5); opacity: 1; }
  57% { transform: translate(39px, -33px) rotate(12deg) scale(0.15); opacity: 0; }
  63% { transform: translate(-24px, 24px) rotate(-7deg) scale(0.6); opacity: 0; }
  85% { transform: translate(1px, -1px) rotate(1deg) scale(1); opacity: 1; }
  100% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
}

@keyframes telegram-space-trail {
  0%, 15% { opacity: 0; transform: rotate(-39deg) scaleX(0.1); }
  28% { opacity: 0.85; transform: rotate(-39deg) scaleX(0.75); }
  48% { opacity: 0.35; transform: translate(17px, -14px) rotate(-39deg) scaleX(1.1); }
  61%, 100% { opacity: 0; transform: translate(34px, -30px) rotate(-39deg) scaleX(0.2); }
}

@keyframes telegram-space-stars {
  0%, 100% { opacity: 0.65; }
  40% { opacity: 1; filter: drop-shadow(0 0 3px #c1d4ff); }
  65% { opacity: 0.4; }
}

/* Keep both Telegram and the menu reachable without changing mobile hero sizing. */
@media (max-width: 680px) {
  .site-header__inner {
    grid-template-columns: minmax(0, 1fr) 46px 44px;
    gap: 8px;
  }

  .header-actions {
    display: flex;
    grid-column: 2;
    grid-row: 1;
    margin: 0;
  }

  .menu-button { grid-column: 3; }

  .header-telegram {
    width: 46px;
    min-height: 44px;
    justify-content: center;
    padding: 0;
    border-radius: 13px;
  }

  .header-telegram__label { display: none; }
  .header-telegram__space { width: 44px; flex-basis: 44px; }
  .header-telegram__plane { left: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .header-telegram { transition: none; }
  .header-telegram.is-launching .header-telegram__plane,
  .header-telegram.is-launching .header-telegram__trail,
  .header-telegram.is-launching .header-telegram__stars { animation: none; }
}
