/* MomWalk — стартовая заставка (вариант №04 «Мама рядом», v1.6).
   Тайминги и маска раскрытия — из согласованного прототипа; 26.10.2026 по просьбе Даши раскрытие логотипа
   удлинено 2,8 → 4,7 с; маска до 58% вместо 85% и кривая (.3,.2,.6,1) вместо (.2,.7,.25,1) — в прототипе
   логотип открывался почти целиком за 0,6 с, теперь равномерно ≈ за 3,3 с с мягкой остановкой;
   вся заставка 4,1 → 6 с (геопин и волны — как в прототипе).
   Базовый логотип .mw-splash__final виден по умолчанию: если скрипт не запустится,
   пользователь видит чистый утверждённый логотип, а не пустой экран. */
.mw-splash {
  --mw-coral: #f3796e;
  --mw-teal: #155e60;
  --mw-wave2: #168b85;
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height: 100vh;
  min-height: 100dvh;
  /* фон = background_color манифеста (#FFFDFC): системный экран Android переходит в заставку без смены цвета */
  background: radial-gradient(ellipse at center, #fff 4%, #fffdfc 75%), #fffdfc;
  color: var(--mw-teal);
  font: 16px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  opacity: 1;
  transition: opacity .35s ease;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}
.mw-splash--hide { opacity: 0; pointer-events: none; }

/* Квадратный контейнер: все слои в одной системе координат 900×900 */
.mw-splash__art {
  position: relative;
  width: min(86vw, 62vh, 460px);
  width: min(86vw, 62dvh, 460px);
  aspect-ratio: 1 / 1;
  isolation: isolate;
}
/* Телефон: квадрат 310 px — геопин совпадает по размеру и месту с геопином системного экрана
   (icons/icon-512.png рассчитан на этот размер — пересчитывать вместе). */
@media (max-width: 599px) {
  .mw-splash__art { width: min(310px, 86vw); }
}
.mw-splash__layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}
.mw-splash__final { z-index: 1; }
.mw-splash__reveal,
.mw-splash__pin,
.mw-splash__ring { display: none; }

/* Анимация включается только скриптом (класс --play) */
.mw-splash--play .mw-splash__final { visibility: hidden; }
.mw-splash--play .mw-splash__reveal {
  display: block;
  z-index: 2;
  clip-path: circle(0% at 49.5% 47%);
  -webkit-clip-path: circle(0% at 49.5% 47%);
  animation: mw-reveal 4.7s cubic-bezier(.3, .2, .6, 1) 1.02s both;
}
.mw-splash--play .mw-splash__pin {
  display: block;
  z-index: 3;
  opacity: 0;
  transform: scale(.7);
  transform-origin: 49.5% 47%;
  animation: mw-pin-in .6s cubic-bezier(.2, .85, .3, 1.2) .06s both, mw-pin-out .35s ease 5.4s forwards;
}
.mw-splash--play .mw-splash__ring {
  display: block;
  position: absolute;
  left: 49.5%;
  top: 47%;
  width: 14%;
  aspect-ratio: 1 / 1;
  border: 3px solid var(--mw-coral);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(.3);
  opacity: 0;
  z-index: 4;
  pointer-events: none;
  animation: mw-ring 1.05s ease-out .43s both;
}
.mw-splash--play .mw-splash__ring--two { border-color: var(--mw-wave2); animation-delay: .63s; }

/* Установленное приложение: системный экран Android уже показал геопин —
   он остаётся на месте с первого кадра (без проявления), дальше волны и раскрытие как обычно */
.mw-splash--from-system:not(.mw-splash--done) .mw-splash__final { visibility: hidden; }
.mw-splash--from-system:not(.mw-splash--done) .mw-splash__pin { display: block; z-index: 3; opacity: 1; transform: none; }
.mw-splash--from-system.mw-splash--play .mw-splash__pin { animation: mw-pin-out .35s ease 5.4s forwards; }

/* Финал: только чистый логотип, вспомогательные слои убраны */
.mw-splash--done .mw-splash__final { visibility: visible; }
.mw-splash--done .mw-splash__reveal,
.mw-splash--done .mw-splash__pin,
.mw-splash--done .mw-splash__ring { display: none; }

@keyframes mw-pin-in {
  0% { opacity: 0; transform: scale(.7); }
  65% { opacity: 1; transform: scale(1.045); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes mw-pin-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes mw-ring {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); }
  22% { opacity: .7; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(6); }
}
@keyframes mw-reveal {
  0% { clip-path: circle(0% at 49.5% 47%); -webkit-clip-path: circle(0% at 49.5% 47%); }
  /* 58%: логотип полностью открыт уже на 56% — раньше (85%) треть времени уходила на невидимый «хвост» */
  100% { clip-path: circle(58% at 49.5% 47%); -webkit-clip-path: circle(58% at 49.5% 47%); }
}

/* Долгая загрузка: ненавязчивый индикатор под логотипом */
.mw-splash__progress {
  position: absolute;
  left: 50%;
  bottom: calc(max(28px, env(safe-area-inset-bottom)) + 24px);
  width: 64px;
  height: 3px;
  margin-left: -32px;
  border-radius: 3px;
  background: rgba(21, 94, 96, .12);
  overflow: hidden;
  opacity: 0;
  transition: opacity .4s ease;
}
.mw-splash__progress::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: inherit;
  background: var(--mw-coral);
  animation: mw-progress 1.2s ease-in-out infinite;
}
.mw-splash--waiting .mw-splash__progress { opacity: 1; }
@keyframes mw-progress { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* Ошибка запуска */
.mw-splash__error {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 8px);
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
  line-height: 1.45;
}
.mw-splash__error[hidden] { display: none; }
.mw-splash__error p { margin: 0 0 14px; color: #4f6a6b; }
.mw-splash__error button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 13px;
  padding: 12px 22px;
  color: #fff;
  background: var(--mw-coral);
  cursor: pointer;
}
.mw-splash__error button:focus-visible { outline: 3px solid #288c8a; outline-offset: 3px; }
.mw-splash--error .mw-splash__progress { display: none; }

@media (prefers-reduced-motion: reduce) {
  .mw-splash { transition: none; }
  .mw-splash .mw-splash__final { visibility: visible; }
  .mw-splash .mw-splash__reveal,
  .mw-splash .mw-splash__pin,
  .mw-splash .mw-splash__ring { display: none; }
  .mw-splash__progress::after { animation-duration: 2.4s; }
}
