/* Оформление страницы проверки.

   Задача — чтобы человек не успел заскучать и не испугался. Отсюда всё
   остальное: тёмная спокойная подложка, один смысловой центр, движение
   вместо процентов и текста, и полное отсутствие кнопок в нормальном
   сценарии. Кнопка появляется только если что-то пошло не так.

   Цвета берутся из темы Telegram, когда клиент их даёт (переменные
   --tg-*), и подставляются собственные, когда не даёт. Так страница
   выглядит частью мессенджера, а не сайтом внутри него. */

:root {
  --bg: #0f1116;
  --bg-soft: #171a21;
  --card: #1b1f28;
  --line: #262b36;
  --text: #eef1f6;
  --muted: #8b93a4;
  --accent: #ffc84a;
  --accent-soft: rgba(255, 200, 74, .14);
  --ok: #4ade80;
  --err: #f87171;

  --radius: 22px;
  --ease: cubic-bezier(.22, .9, .3, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* --------------------------------------------------------------------- */
/*  Сцена                                                                 */
/* --------------------------------------------------------------------- */
.stage {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  gap: 18px;
}

/* Мягкое свечение за карточкой. Оно же меняет цвет на успехе и ошибке —
   самый быстрый способ сообщить исход до того, как прочитан текст. */
.halo {
  position: absolute;
  top: 32%;
  left: 50%;
  width: 340px;
  height: 340px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 68%);
  filter: blur(6px);
  transition: background .6s var(--ease), opacity .6s var(--ease);
  pointer-events: none;
}

.stage.done .halo { background: radial-gradient(circle, rgba(74,222,128,.18) 0%, transparent 68%); }
.stage.failed .halo { background: radial-gradient(circle, rgba(248,113,113,.16) 0%, transparent 68%); }

.card {
  position: relative;
  width: 100%;
  max-width: 360px;
  padding: 30px 26px 22px;
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  text-align: center;
  animation: rise .5s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------- */
/*  Эмблема: кольцо прогресса и щит, который превращается в галочку        */
/* --------------------------------------------------------------------- */
.emblem {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 0 auto 20px;
}

.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
}

.ring-track { stroke: var(--line); }

.ring-fill {
  stroke: var(--accent);
  /* 2πr при r=52 — длина окружности; ею же управляем заполнением. */
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset .55s var(--ease), stroke .45s var(--ease);
}

.stage.done .ring-fill { stroke: var(--ok); }
.stage.failed .ring-fill { stroke: var(--err); }

.glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.glyph svg {
  position: absolute;
  width: 42px;
  height: 42px;
  transition: opacity .35s var(--ease), transform .45s var(--ease);
}

.shield {
  fill: var(--accent);
  opacity: .95;
}

/* Пульс, пока идёт проверка: страница обязана выглядеть живой, даже если
   всё занимает полсекунды. */
.stage.working .shield { animation: breathe 1.6s ease-in-out infinite; }

@keyframes breathe {
  0%, 100% { transform: scale(1);    opacity: .95; }
  50%      { transform: scale(1.07); opacity: 1; }
}

.tick {
  fill: none;
  stroke: var(--ok);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(.6);
}

.stage.done .shield { opacity: 0; transform: scale(.7); }
.stage.done .tick   { opacity: 1; transform: scale(1); }
.stage.failed .shield { fill: var(--err); }

/* --------------------------------------------------------------------- */
/*  Текст                                                                 */
/* --------------------------------------------------------------------- */
h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}

/* --------------------------------------------------------------------- */
/*  Шаги                                                                  */
/* --------------------------------------------------------------------- */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 14px;
  transition: color .3s var(--ease), background .3s var(--ease);
}

.step.active {
  color: var(--text);
  background: rgba(255, 255, 255, .04);
}

.step.done { color: var(--text); }

.bullet {
  position: relative;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line);
  transition: border-color .3s var(--ease), background .3s var(--ease);
}

.step.active .bullet {
  border-color: var(--accent);
  animation: spin 1s linear infinite;
  border-right-color: transparent;
}

@keyframes spin { to { transform: rotate(360deg); } }

.step.done .bullet {
  border-color: var(--ok);
  background: var(--ok);
  animation: none;
}

/* Галочка внутри точки — псевдоэлементом, чтобы не плодить разметку. */
.step.done .bullet::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: .5px;
  width: 4px;
  height: 8px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.step.failed .bullet {
  border-color: var(--err);
  background: var(--err);
  animation: none;
}

/* --------------------------------------------------------------------- */
/*  Ошибка                                                                */
/* --------------------------------------------------------------------- */
.failure { margin-top: 16px; }

.failure-text {
  margin: 0 0 12px;
  color: var(--err);
  font-size: 14px;
}

.retry {
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-radius: 13px;
  background: var(--accent);
  color: #1a1405;
  font: inherit;
  font-weight: 620;
  cursor: pointer;
  transition: transform .15s var(--ease), filter .2s var(--ease);
}

.retry:active { transform: scale(.98); filter: brightness(.94); }

/* --------------------------------------------------------------------- */
/*  Раскрывающийся честный список                                         */
/* --------------------------------------------------------------------- */
.disclose {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.disclose summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  list-style: none;
  text-align: center;
  transition: color .2s var(--ease);
}

.disclose summary::-webkit-details-marker { display: none; }
.disclose summary:hover { color: var(--text); }

.facts {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.facts-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  opacity: .85;
}

.brand {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .5;
}

/* Плавность выключается, если человек просил систему её не показывать. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* --------------------------------------------------------------------- */
/*  Светлая тема                                                          */
/* --------------------------------------------------------------------- */
/* Класс ставит скрипт по tg.colorScheme. Если человек держит Telegram
   светлым, тёмная страница внутри выглядит чужой заплатой — а страница
   должна читаться как часть мессенджера. */
body.light {
  --bg: #f2f3f7;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --line: #e3e6ee;
  --text: #12141a;
  --muted: #7a8296;
  --accent: #e3a008;
  --accent-soft: rgba(227, 160, 8, .12);
  --ok: #16a34a;
  --err: #dc2626;
}

body.light .card { box-shadow: 0 16px 44px rgba(20, 24, 40, .12); }
body.light .step.active { background: rgba(20, 24, 40, .04); }
body.light .step.done .bullet::after { border-color: #fff; }
body.light .retry { color: #fff; }
