/* hereinafter — окно входа. Слева действие, справа панель с цитатой и знаком «ворота». */

html, body { height: 100%; }

.e {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 46fr) minmax(0, 54fr);
}

.e__side {
  display: flex;
  flex-direction: column;
  padding: 20px clamp(20px, 5vw, 72px) 26px;
  transition: opacity 300ms ease;
}
.e__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
}
.e__tools { display: flex; align-items: center; gap: 10px; }
.e__logo { font-size: 23px; }
/* На самых узких экранах слово в строку с переключателями не помещается: логотип остаётся облаком. */
@media (max-width: 400px) {
  .e__logo .logo__w { display: none; }
  .e__logo .logo__b { margin-left: -0.738em; transform: none !important; }
}

.e__main {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 32px 0;
}
.e__state { width: min(100%, 400px); }

/* Смена состояния: новое содержимое проявляется и чуть поднимается. */
.anim .e__state.swap > * {
  animation: rise 520ms var(--ease-out) both;
  animation-delay: calc(var(--k, 0) * 60ms);
}
.e__state.swap > :nth-child(2) { --k: 1; }
.e__state.swap > :nth-child(3) { --k: 2; }
.e__state.swap > :nth-child(4) { --k: 3; }
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.e__h,
.e__clause {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(32px, 3.3vw, 46px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.e__name { overflow-wrap: anywhere; }
.e__nb { white-space: nowrap; }
.e__p {
  margin-top: 14px;
  font-size: 17.5px;
  line-height: 1.5;
  color: var(--ink-2);
  text-wrap: pretty;
  overflow-wrap: anywhere;
}
.e__hint { margin-top: 8px; font-size: 15px; color: var(--ink-3); }
.e__note {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--r-s);
  background: var(--tint);
  font-size: 15px;
  line-height: 1.45;
}
.e__act {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.e__form { margin-top: 24px; }
.e__wide { display: flex; width: 100%; min-height: 52px; }
.e__form .field__err { margin-bottom: 2px; }
.e__form [data-send] { margin-top: 12px; }
.e__form .field__help { margin-top: 10px; }

/* Код из письма: шесть цифр крупно и вразрядку. Поле одно, а не шесть клеток: так работают вставка
   и подстановка кода из почты на телефоне. */
.e__form--code { margin-top: 22px; }
.code {
  height: 68px;
  padding: 0 0 0 0.36em;                 /* разрядка оставляет пустоту после последней цифры — уравновешена слева */
  font-family: var(--serif);
  font-size: 34px;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0.36em;
  text-align: center;
}
.code::placeholder { color: var(--line); }
.code[readonly] { opacity: 0.55; }
.e__form--code + .e__hint { margin-top: 14px; }

/* Три точки-кляксы: идёт запрос. */
.dots { display: inline-flex; gap: 0.18em; margin-left: 0.22em; }
.dots i {
  width: 0.2em;
  height: 0.2em;
  border-radius: 50%;
  background: var(--m-lilac);
  animation: dot 900ms ease-in-out infinite alternate;
}
.dots i:nth-child(2) { background: var(--m-peri); animation-delay: 150ms; }
.dots i:nth-child(3) { background: var(--m-indigo); animation-delay: 300ms; }
@keyframes dot {
  from { transform: translateY(0.02em) scale(0.72); opacity: 0.55; }
  to { transform: translateY(-0.12em) scale(1); opacity: 1; }
}
.dots--btn { display: none; font-size: 26px; margin-left: 2px; }
.dots--btn i,
.dots--btn i:nth-child(2),
.dots--btn i:nth-child(3) { background: currentColor; }
.btn.is-busy .dots--btn { display: inline-flex; }
.btn.is-busy { pointer-events: none; }

/* Кавычки вокруг «Пользователь». */
.anim .e__clause .term__q {
  opacity: 0;
  transform: scale(0.6) rotate(-24deg);
  animation: pop 700ms var(--ease-spring) 380ms forwards;
}
.anim .e__clause .term__q--close { transform: scale(0.6) rotate(24deg); animation-delay: 520ms; }
@keyframes pop { to { opacity: 1; transform: none; } }

/* ── Панель: цитата и ворота ───────────────────────────────────────── */
/* Спокойная тонированная поверхность, а не заливка фирменным цветом: внимание остаётся на форме.
   Цитата стоит по центру свободной высоты, ворота — на нижней кромке панели, как на главной. */
.e__panel {
  --gw: min(50%, 40vh, 380px);          /* сторона рамки знака «ворота» */
  position: relative;
  z-index: 6;
  margin: 12px 12px 12px 0;
  padding: clamp(28px, 4vw, 60px) clamp(28px, 4vw, 60px) 0;
  display: grid;
  grid-template-rows: 1fr auto;
  border-radius: 32px;
  background: var(--tint);
  overflow: hidden;
}
.e__quote { align-self: center; margin: 0; padding: 24px 0; transition: opacity 200ms ease; }
/* Кавычки-кляксы: в рамке знака сверху и снизу по 20 % пустоты, слева 2,4 % — убраны отступами. */
.e__quote-m {
  --qw: clamp(84px, 8vw, 124px);
  display: block;
  width: var(--qw);
  aspect-ratio: 1;
  margin: calc(var(--qw) * -0.2) 0 calc(var(--qw) * -0.2) calc(var(--qw) * -0.024);
}
.e__quote-t {
  margin: clamp(14px, 1.6vw, 22px) 0 0;
  max-width: 13em;
  font-family: var(--serif);
  font-size: clamp(30px, 3.5vw, 54px);
  line-height: 1.1;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
/* Смена цитаты вместе с состоянием. */
.anim .e__quote-t.swap { animation: rise 560ms var(--ease-out) both; }
.anim .e__quote-m.swap .p0 { animation: pop 620ms var(--ease-spring) both; }
.anim .e__quote-m.swap .p1 { animation: pop 620ms var(--ease-spring) 90ms both; }
.e__quote-m .p { transform-box: fill-box; transform-origin: center; }
.anim .e__quote-m.swap .p { opacity: 0; transform: scale(0.6) rotate(-20deg); }

/* В рамке знака над воротами и под ними пусто (по 17,8 % стороны): эти поля убраны отступами,
   поэтому ворота стоят ровно на кромке панели. */
.gate {
  justify-self: end;
  width: var(--gw);
  aspect-ratio: 1;
  margin: calc(var(--gw) * -0.17) 3% calc(var(--gw) * -0.178) 0;
  transform-origin: 50% 82%;
  transition: transform 700ms var(--ease-spring);
}
.gate .m-peri { fill: var(--m-peri); transition: fill 500ms ease; }

/* Ожидание: ворота «дышат». */
[data-mood="wait"] .gate { animation: breathe 1100ms ease-in-out infinite alternate; }
@keyframes breathe {
  from { transform: scale(1, 1); }
  to { transform: scale(0.985, 1.04); }
}
/* Хорошая новость (письмо ушло, ссылка действительна): прыжок с приземлением. */
[data-mood="glad"] .gate { animation: hop 900ms var(--ease-out) both; }
[data-mood="glad"] .gate .m-peri { fill: var(--m-cobalt); }
@keyframes hop {
  0% { transform: scale(1.05, 0.93); }
  30% { transform: translateY(-9%) scale(0.96, 1.05); }
  62% { transform: translateY(0) scale(1.06, 0.94); }
  100% { transform: none; }
}
/* Отказ: ворота оседают и отворачиваются. */
[data-mood="sad"] .gate { transform: translateY(3%) rotate(-7deg) scale(0.95); }
/* Сервер молчит: покачиваются. */
[data-mood="off"] .gate { animation: sway 2600ms ease-in-out infinite alternate; }
@keyframes sway {
  from { transform: rotate(-4deg); }
  to { transform: rotate(4deg); }
}

/* Вход выполнен: проём ворот раскрывается на весь экран, и человек «проходит» в рабочее место. */
.e__veil {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: var(--tint);
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}
.entered,
.entered body { overflow: hidden; }
.entered .e__veil { opacity: 1; }
.entered .e__panel { overflow: visible; }
.entered .e__side { opacity: 0; }
.entered .gate {
  transform: scale(40);
  transition: transform 1100ms var(--ease-in-out) 160ms;
}
.entered .gate .m-peri { fill: var(--m-cobalt); }
.entered .e__quote { opacity: 0; }

@media (max-width: 860px) {
  /* Узкий экран: панель — полоса сверху, цитата слева, ворота справа на кромке. */
  .e { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .e__panel {
    --gw: clamp(112px, 32vw, 168px);
    order: -1;
    min-height: 136px;
    margin: 12px 12px 0;
    padding: 18px 0 0 22px;
    grid-template-rows: 1fr;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    align-items: end;
    border-radius: 24px;
  }
  .e__quote { align-self: center; padding: 0 0 18px; }
  .e__quote-m { --qw: 46px; }
  .e__quote-t { margin-top: 8px; font-size: clamp(18px, 5vw, 24px); line-height: 1.16; }
  .gate { margin-right: 10px; margin-top: 0; }
  .e__main { align-items: flex-start; padding: 28px 0 36px; }
  .e__side { padding-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .gate,
  [data-mood] .gate { animation: none; transition: none; }
  [data-mood="sad"] .gate { transform: rotate(-7deg); }
  .entered .gate { transform: none; }
  .dots i { animation: none; }
  .e__quote-t.swap, .e__quote-m.swap .p { animation: none; opacity: 1; transform: none; }
}
