/* «Ночная степь»: фаза intro — заставка, фаза login — форма входа */
.night {
  --r: min(210px, 36vw);
  --orbit: 0deg;
  --dot: min(44px, 11.5vw);
  --step: min(56px, 13vw);
  --ease-move: cubic-bezier(0.7, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  min-height: 760px;
  background: #050b1a;
  color: #eaf1ff;
}

/* Сцена */
.scene {
  position: absolute;
  inset: 0;
  animation: scene-in 18s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  transform-origin: 50% 60%;
}

@keyframes scene-in {
  from { transform: scale(1.12) translateY(16px); }
}

.scene__defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Запас по краям, чтобы при смещении слоёв не открывался фон */
.scene__layer {
  position: absolute;
  inset: -4%;
  display: block;
  width: 108%;
  height: 108%;
  will-change: transform;
}

.s1 { animation: twinkle 4s ease-in-out infinite; }
.s2 { animation: twinkle 5.5s ease-in-out 1.6s infinite; }

@keyframes twinkle {
  50% { opacity: 0.4; }
}

.shoot {
  opacity: 0;
  animation: shoot 9s ease-in 2.4s infinite;
}

@keyframes shoot {
  0% { opacity: 0; transform: translate(0, 0); }
  2% { opacity: 1; }
  9%, 100% { opacity: 0; transform: translate(330px, 140px); }
}

.flame {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: flicker 0.45s ease-in-out infinite alternate;
}

@keyframes flicker {
  to { transform: scale(0.86, 1.14); }
}

.smoke { animation: smoke 7s ease-in-out infinite alternate; }

@keyframes smoke {
  from { opacity: 0.12; transform: translateX(0); }
  to { opacity: 0.35; transform: translateX(10px); }
}

.night__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(3 6 15 / 0.75), rgb(3 6 15 / 0) 32%);
}

.halo {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 560px;
  height: 560px;
  margin: -280px 0 0 -280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(120 170 255 / 0.24), rgb(120 170 255 / 0) 65%);
  transition: opacity 0.9s ease;
}

.night[data-phase="login"] .halo { opacity: 0; }

/* Логотип */
.brand {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  text-shadow: 0 0 40px rgb(130 190 255 / 0.6);
  white-space: nowrap;
  animation: glow-in 1.6s ease-out 0.2s both;
  transition:
    top 1.1s var(--ease-move),
    left 1.1s var(--ease-move),
    transform 1.1s var(--ease-move),
    font-size 1.1s var(--ease-move);
}

/* В заставке две строки внутри кольца, на форме одна строка в углу */
.brand__dash { display: none; }

.brand__product {
  color: #dce7ff;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

@keyframes glow-in {
  from { opacity: 0; filter: blur(12px); }
}

.night[data-phase="login"] .brand {
  top: 26px;
  left: 28px;
  flex-direction: row;
  align-items: baseline;
  transform: none;
  font-size: 24px;
  transition:
    top 1.1s var(--ease-move),
    left 1.1s var(--ease-move),
    transform 1.1s var(--ease-move),
    font-size 1.1s var(--ease-move),
    flex-direction 0s linear 1.1s allow-discrete,
    align-items 0s linear 1.1s allow-discrete;
}

/* Логотип перестраивается в одну строку, когда уже приехал в угол */
.night[data-phase="login"] .brand__dash {
  display: inline;
  transition: display 0s linear 1.1s allow-discrete;
}

.tagw {
  position: absolute;
  z-index: 5;
  top: calc(50% + 66px);
  right: 0;
  left: 0;
  padding: 0 16px;
  text-align: center;
  transition: opacity 0.5s ease, transform 0.8s ease;
}

.tag {
  margin: 0;
  color: #bfd6ff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  animation: fade-up 1s ease-out 0.8s both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
}

.night[data-phase="login"] .tagw {
  opacity: 0;
  transform: translateY(-20px);
}

/* На форме всё уже на месте: анимации появления нужны только в заставке */
.night[data-phase="login"] .brand,
.night[data-phase="login"] .tag,
.night[data-phase="login"] .pop { animation: none; }

/* Кольцо */
.ringw {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: calc(var(--r) * 2);
  height: calc(var(--r) * 2);
  margin-top: calc(var(--r) * -1);
  margin-left: calc(var(--r) * -1);
  transition: opacity 0.7s ease, transform 1.1s var(--ease-move);
}

.ring {
  width: 100%;
  height: 100%;
  border: 1.5px dashed rgb(170 205 255 / 0.5);
  border-radius: 50%;
  animation: ring-in 1.4s ease 0.4s both, spin 80s linear infinite;
}

@keyframes ring-in {
  from { opacity: 0; }
}

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

.night[data-phase="login"] .ringw {
  opacity: 0;
  transform: scale(1.7);
  pointer-events: none;
}

/* Флаги: по кольцу в заставке, в ряд внизу экрана на форме */
.orbs {
  display: contents;
  list-style: none;
}

.orb {
  --angle: calc(var(--orbit) + var(--i) * 51.4286deg);
  position: absolute;
  z-index: 3;
  top: calc(50% - var(--r) * cos(var(--angle)));
  left: calc(50% + var(--r) * sin(var(--angle)));
  width: 76px;
  height: 76px;
  margin: -38px 0 0 -38px;
}

.night[data-phase="login"] .orb {
  top: calc(100% - 52px);
  left: calc(50% + (var(--i) - 3) * var(--step));
  width: var(--dot);
  height: var(--dot);
  margin: calc(var(--dot) / -2) 0 0 calc(var(--dot) / -2);
  transition:
    top 1.1s var(--ease-move),
    left 1.1s var(--ease-move),
    width 1.1s var(--ease-move),
    height 1.1s var(--ease-move),
    margin 1.1s var(--ease-move);
  transition-delay: calc(var(--i) * 0.06s);
}

.orb__choice {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.flag__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.pop {
  display: block;
  width: 100%;
  height: 100%;
  animation: pop 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.35) both;
  animation-delay: calc(var(--i) * 0.2s + 0.9s);
}

@keyframes pop {
  0% { opacity: 0; transform: scale(0.2); }
  70% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 1; transform: scale(1); }
}

.disc {
  display: block;
  overflow: hidden;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgb(255 255 255 / 0.85), 0 6px 16px rgb(0 0 0 / 0.45);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.night[data-phase="intro"] .disc { animation: pulse 3.6s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgb(255 255 255 / 0.92), 0 0 18px rgb(140 200 255 / 0.4); }
  50% { box-shadow: 0 0 0 3px #fff, 0 0 34px rgb(140 200 255 / 0.85); }
}

.flag__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.orb:hover .disc { transform: translateY(-3px); }

.flag__input:checked + .pop .disc {
  box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgb(242 193 78 / 0.55);
}

.flag__input:focus-visible + .pop .disc {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

.oname {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  color: #dce7ff;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 8px rgb(0 0 0 / 0.7);
  white-space: nowrap;
  transition: opacity 0.4s ease;
}

.night[data-phase="login"] .oname {
  opacity: 0;
  pointer-events: none;
}

/* Подпись над рядом флагов: выбранная страна */
.country {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 84px;
  left: 0;
  margin: 0;
  padding: 0 16px;
  color: #c9d7f2;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.country [hidden] { display: none; }

.night[data-phase="login"] .country {
  opacity: 1;
  transition: opacity 0.7s ease 1s;
}

/* Карточка входа */
.center {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 84px 16px 118px;
  overflow-y: auto;
  perspective: 1400px;
  pointer-events: none;
}

.entrance {
  width: min(420px, 100%);
  opacity: 0;
  transform: translateY(30px) scale(0.96);
  visibility: hidden;
  transition: opacity 0.4s ease, transform 0.5s ease, visibility 0s linear 0.5s;
}

.night[data-phase="login"] .entrance {
  opacity: 1;
  transform: none;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 0.8s ease 0.55s,
    transform 1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.5s,
    visibility 0s;
}

.card {
  position: relative;
  border: 1px solid rgb(170 205 255 / 0.22);
  border-radius: 24px;
  background: rgb(10 18 40 / 0.78);
  box-shadow: 0 30px 90px rgb(0 0 0 / 0.55);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 32px;
}

.card__head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card__title {
  margin: 0;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
}

.card__lead {
  margin: 0;
  color: var(--card-text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.card__error {
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgb(255 157 143 / 0.12);
  color: var(--danger);
  font-size: 0.875rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  color: var(--card-text-soft);
  font-size: 0.8125rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid rgb(190 215 255 / 0.3);
  border-radius: 12px;
  outline: none;
  background: rgb(255 255 255 / 0.07);
  color: #fff;
  font: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder { color: #9db0d3; opacity: 1; }

.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgb(242 193 78 / 0.22);
}

.field input:-webkit-autofill {
  -webkit-text-fill-color: #fff;
  box-shadow: 0 0 0 40px #1a2540 inset;
}

.field__password { position: relative; }
.field__password input { padding-right: 52px; }

.field__eye {
  position: absolute;
  top: 2px;
  right: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--card-text-soft);
  cursor: pointer;
}

.field__eye:hover { background: rgb(255 255 255 / 0.08); }
.field__eye[aria-pressed="true"] { color: var(--gold); }

.card__options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--card-text-soft);
  font-size: 0.875rem;
  cursor: pointer;
}

.remember input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--gold);
}

.forgot {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}

.forgot:hover { color: #ffd97a; }

.card__hint {
  margin: -8px 0 0;
  color: var(--card-text-muted);
  font-size: 0.8125rem;
}

.card__hint[hidden] { display: none; }

.submit {
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--gold);
  color: #1b1405;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.submit:hover { background: #ffd46b; }

.field__eye:focus-visible,
.forgot:focus-visible,
.submit:focus-visible,
.ghost:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.card__note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--card-text-muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.card__note svg { flex: none; color: var(--gold); }

/* Кнопки заставки */
.ghost {
  position: absolute;
  z-index: 6;
  right: 24px;
  bottom: 20px;
  display: none;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid rgb(170 205 255 / 0.32);
  border-radius: 999px;
  background: rgb(10 18 40 / 0.5);
  color: #eaf1ff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.ghost:hover { background: rgb(10 18 40 / 0.75); }

.night[data-phase="login"] .ghost--replay { display: flex; }

.touch-hint {
  position: absolute;
  z-index: 6;
  right: 0;
  bottom: 56px;
  left: 0;
  display: none;
  margin: 0;
  padding: 0 16px;
  color: #eaf1ff;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 1px 10px rgb(0 0 0 / 0.8);
  animation: hint 2.4s ease-in-out infinite;
}

.night[data-phase="intro"] .touch-hint { display: block; }

@keyframes hint {
  50% { opacity: 0.45; }
}

.copyright {
  position: absolute;
  z-index: 6;
  bottom: 22px;
  left: 28px;
  margin: 0;
  color: rgb(234 241 255 / 0.7);
  font-size: 12px;
}

/* Телефон */
@media (max-width: 760px) {
  .brand { font-size: 44px; }
  .brand__product { font-size: 13px; }
  .night[data-phase="login"] .brand { top: 18px; left: 16px; gap: 6px; font-size: 18px; }
  .night[data-phase="login"] .ghost--replay { display: none; }
  .card__body { padding: 24px; }
  .orb { width: 60px; height: 60px; margin: -30px 0 0 -30px; }
  .oname { display: none; }
  .ghost { top: 16px; right: 16px; bottom: auto; }
  .copyright { display: none; }
  .country { bottom: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  .scene, .s1, .s2, .shoot, .flame, .smoke, .brand, .tag, .ring, .pop, .touch-hint { animation: none; }
  .shoot { opacity: 0; }
  .night *, .night[data-phase="login"] * { transition: none !important; }
}
