/* Всплывающее уведомление (тост) — общее для редактора (/create) и студии
   (/projects). В редакторе разметка в create.html, мобильная раскладка над
   нижней панелью — в creator.css (поэтому этот файл подключается раньше него).
   В студии разметку вставляет scripts/toast.js. Светлая тема — в theme.css. */

.toast[hidden] {
  display: none !important;
}

/* ───────── Тост ─────────
   Внешний радиус 20px при padding 12px даёт концентричные 8px внутри.
   z-index 55 — выше слоя гайда (50): под затемнением с вырезом тост был бы
   не виден, а он объясняет, почему кнопка не сработала. Ниже входа (60). */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(460px, calc(100vw - 48px));
  border: 1px solid rgba(83, 144, 255, 0.22);
  border-radius: 20px;
  padding: 12px;
  color: #f5f6ff;
  background: rgba(9, 16, 30, 0.94);
  backdrop-filter: blur(14px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 2px 6px rgba(0, 0, 0, 0.24),
    0 12px 28px rgba(0, 0, 0, 0.32),
    0 28px 64px rgba(4, 10, 22, 0.44);
  font-size: 13px;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 200ms ease,
    transform 200ms ease;
}

/* Ошибка генерации — тёплая подсветка рамки, чтобы тост читался как проблема. */
.toast.toast--error {
  border-color: rgba(255, 148, 120, 0.28);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 2px 6px rgba(0, 0, 0, 0.24),
    0 12px 28px rgba(0, 0, 0, 0.32),
    0 28px 64px rgba(30, 8, 10, 0.42);
}

.toast.is-hiding {
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  pointer-events: none;
  animation: none;
}

.toast.is-hiding .toast-mascot,
.toast.is-hiding .toast-text,
.toast.is-hiding .toast-help {
  animation: none;
}

/* У .toast-help/.toast-mascot задан свой display — без этого правила
   атрибут hidden перестаёт их прятать, и обычный тост распухает. */
.toast-mascot[hidden],
.toast-help[hidden] {
  display: none !important;
}

.toast-mascot {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  align-self: center;
  object-fit: contain;
  /* Маскот белый по контуру — на тёмной панели ему нужна лёгкая тень, а не обводка. */
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.42));
  pointer-events: none;
}

.toast-body {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
}

.toast-text {
  margin: 0;
  line-height: 1.45;
  text-wrap: pretty;
}

.toast-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(87, 155, 255, 0.38);
  border-radius: 10px;
  color: #b5d4ff;
  background: rgba(20, 52, 96, 0.44);
  text-decoration: none;
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.toast-help:hover {
  border-color: rgba(87, 155, 255, 0.72);
  color: #ffffff;
  background: rgba(24, 62, 112, 0.68);
}

.toast-help:active {
  transform: scale(0.96);
}

.toast-help:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.toast-help svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 200ms cubic-bezier(0.2, 0, 0, 1);
}

.toast-help:hover svg {
  transform: translateX(2px);
}

.toast-close {
  position: relative;
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  align-self: flex-start;
  place-items: center;
  border: 1px solid rgba(83, 144, 255, 0.18);
  border-radius: 8px;
  color: #93a5c4;
  background: rgba(14, 24, 44, 0.7);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

/* Видимая кнопка 30px, зона нажатия — 40×40. */
.toast-close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
}

.toast-close:hover {
  border-color: rgba(87, 155, 255, 0.5);
  color: #ffffff;
  background: rgba(20, 40, 72, 0.82);
}

.toast-close:active {
  transform: scale(0.96);
}

.toast-close:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.toast-close svg {
  width: 13px;
  height: 13px;
}

/* Вход разбит на части: панель, маскот, текст, кнопка — со сдвигом по времени. */
.toast.is-entering {
  animation: toast-enter 300ms cubic-bezier(0.2, 0, 0, 1) backwards;
}

/* Маскот сознательно без собственной анимации: отдельный keyframe на изображении
   промотирует его в свой слой, и картинка перестаёт отрисовываться.
   Он въезжает вместе с панелью через toast-enter. */
.toast.is-entering .toast-text {
  animation: toast-part-in 300ms cubic-bezier(0.2, 0, 0, 1) 60ms backwards;
}

.toast.is-entering .toast-help {
  animation: toast-part-in 300ms cubic-bezier(0.2, 0, 0, 1) 150ms backwards;
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-part-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast.is-entering,
  .toast.is-entering .toast-text,
  .toast.is-entering .toast-help {
    animation-duration: 1ms;
    animation-delay: 0ms;
  }
}

@media (max-width: 720px) {
  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: auto;
    gap: 10px;
    border-radius: 18px;
    padding: 11px;
  }

  .toast-mascot {
    display: none;
  }
}
