/* ===== Переменные ===== */
:root {
  --bg: #080610;
  --white: #ffffff;
  --text-muted: #b3b3b3;
  --label: #67656f;
  --placeholder: #37363e;
  --line: #2b2a33;
  --line-focus: #67656f;
  --green: #2ed477;
  --green-hover: #4be08d;
  --btn-disabled-bg: #1c1a24;
  --btn-disabled-text: #37363e;
  --btn-gradient: radial-gradient(100% 2339.91% at 0% 0%, #e571ff 9.59%, #ff8933);
  --error: #f97052;
  --font: "Nunito Sans", "Nunito", "Avenir Next", "Segoe UI", Arial, sans-serif;
}

/* ===== Сброс ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  position: relative;
  min-height: 100vh;
  background: var(--bg);
  color: var(--white);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  outline: none;
}

/* ===== Размытый фон ===== */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
}

.blob--1 {
  top: -90px;
  left: 54%;
  width: 46%;
  height: 210px;
  background: rgba(80, 82, 88, 0.55);
  transform: rotate(6deg);
}

.blob--2 {
  top: -60px;
  left: 76%;
  width: 26%;
  height: 160px;
  background: rgba(110, 104, 92, 0.6);
}

.blob--3 {
  top: 40px;
  left: 50%;
  width: 22%;
  height: 130px;
  background: rgba(40, 42, 50, 0.65);
  transform: rotate(18deg);
}

.blob--4 {
  top: 10px;
  left: 66%;
  width: 18%;
  height: 120px;
  background: rgba(60, 64, 72, 0.5);
}

.blob--5 {
  top: 60px;
  left: 82%;
  width: 22%;
  height: 120px;
  background: rgba(36, 40, 46, 0.6);
}

/* ===== Заглушки логотипов ===== */
.logo-placeholder {
  display: block;
}



.logo-placeholder--main {
  margin: 0 auto;
}

.logo-placeholder--inline {
  display: inline-block;
  width: 130px;
  height: 19px;
  vertical-align: middle;
}

/* ===== Шапка ===== */
.header {
  position: absolute;
  top: 16px;
  left: 35px;
  z-index: 2;
}

/* ===== Страница ===== */
.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 261px 16px 80px;
}

.auth {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.auth__title {
  font-size: 31px;
  line-height: 43px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.auth__subtitle {
  margin-top: 20px;
  font-size: 15px;
  line-height: 20px;
  font-weight: 400;
}

/* ===== Форма ===== */
.form {
  margin-top: 34px;
  text-align: left;
}

.field + .field {
  margin-top: 42px;
}

.field__label {
  display: block;
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
  color: var(--label);
}

.field__control {
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.2s ease;
}

.field__control:focus-within {
  border-color: var(--line-focus);
}

.field--invalid .field__control {
  border-color: var(--error);
}

.field__input {
  width: 100%;
  height: 57px;
  padding: 6px 0 0;
  font-size: 25.5px;
  font-weight: 800;
  color: var(--white);
  caret-color: var(--green);
}

.field__input::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

.field__input--password {
  padding-right: 36px;
}

/* автозаполнение браузера — сохранить тёмный фон */
.field__input:-webkit-autofill,
.field__input:-webkit-autofill:hover,
.field__input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--white);
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  transition: background-color 9999s ease-in-out 0s;
}

.field__toggle {
  position: absolute;
  right: 0;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-top: 0;
  transform: translateY(-50%);
  color: var(--white);
  cursor: pointer;
  border-radius: 6px;
  transition: opacity 0.2s ease;
}

.field__toggle:hover {
  opacity: 0.75;
}

.field__toggle:focus-visible {
  box-shadow: 0 0 0 2px var(--green);
}

.field__toggle .icon-eye-off {
  display: none;
}

.field__toggle.is-visible .icon-eye {
  display: none;
}

.field__toggle.is-visible .icon-eye-off {
  display: block;
}

.field__error {
  font-size: 14.5px;
  line-height: 20px;
  color: var(--error);
}

.field__error:not(:empty) {
  margin-top: 8px;
  animation: error-in 0.2s ease;
}

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

/* ===== Ссылки ===== */
.link {
  color: var(--green);
  transition: color 0.2s ease;
}

.link:hover {
  color: var(--green-hover);
}

.link:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 2px;
}

.form__forgot {
  display: inline-block;
  margin-top: 16px;
  font-size: 14.5px;
  line-height: 20px;
}

/* ===== Кнопка ===== */
.btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: block;
  width: 100%;
  height: 43px;
  margin-top: 22px;
  border-radius: 8px;
  background: var(--btn-disabled-bg);
  color: var(--white);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.3s ease, box-shadow 0.3s ease, filter 0.2s ease, transform 0.1s ease;
}

/* активное состояние: градиент на отдельном слое, чтобы плавно проявлялся */
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--btn-gradient);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 8px 24px rgba(242, 123, 164, 0.3);
}

.btn:active:not(:disabled) {
  transform: scale(0.99);
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #e571ff;
}

.btn:disabled {
  color: var(--btn-disabled-text);
  cursor: not-allowed;
}

.btn:disabled::before {
  opacity: 0;
}

.btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

/* ===== Низ формы ===== */
.form__footer {
  margin-top: 32px;
  text-align: center;
  font-size: 14.5px;
  line-height: 20px;
  color: var(--text-muted);
}

/* ===== Кнопка чат-бота ===== */
.chat-bot {
  position: fixed;
  right: 25px;
  bottom: 121px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(160deg, #e66de0 0%, #f27ba4 50%, #f9874f 100%);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-bot:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 20px rgba(242, 123, 164, 0.35);
}

.chat-bot:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #f27ba4;
}

.link--btn {
  display: inline;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
  cursor: pointer;
}

.link--back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.link--back svg {
  transition: transform 0.2s ease;
}

.link--back:hover svg {
  transform: translateX(-3px);
}

/* ===== Переворот карточки ===== */
.flip {
  --flip-duration: 1s;
  position: relative;
  perspective: 1800px;
}

/* мягкое зелёное свечение за карточкой во время переворота */
.flip::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 45%;
  width: 140%;
  height: 90%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(46, 212, 119, 0.22), rgba(46, 212, 119, 0) 70%);
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.flip.is-animating::before {
  animation: flip-glow var(--flip-duration) ease-in-out;
}

/* «отъезд» карточки вглубь в середине переворота */
.flip.is-animating {
  animation: flip-depth var(--flip-duration) ease-in-out;
}

.flip__inner {
  position: relative;
  display: grid;
  transform-style: preserve-3d;
  transition: transform var(--flip-duration) cubic-bezier(0.6, -0.15, 0.25, 1.15);
  will-change: transform;
}

.flip__inner.is-flipped {
  transform: rotateY(180deg);
}

.face {
  position: relative;
  grid-area: 1 / 1;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.face--back {
  transform: rotateY(180deg);
}

/* поверхность «карточки» — видна только во время переворота */
.face::before,
.face::after {
  content: "";
  position: absolute;
  inset: -36px -40px;
  border-radius: 28px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.face::before {
  z-index: -1;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

/* блик, пробегающий по карточке */
.face::after {
  background: linear-gradient(105deg,
      transparent 30%,
      rgba(255, 255, 255, 0.12) 45%,
      rgba(255, 255, 255, 0.02) 55%,
      transparent 70%);
  background-size: 250% 100%;
  background-position: 100% 0;
}

.flip.is-animating .face::before,
.flip.is-animating .face::after {
  opacity: 1;
}

.flip.is-animating .face::after {
  animation: flip-sheen var(--flip-duration) ease-in-out;
}

@keyframes flip-depth {
  0%   { transform: scale(1) translateY(0); }
  50%  { transform: scale(0.86) translateY(10px); }
  100% { transform: scale(1) translateY(0); }
}

@keyframes flip-glow {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  50%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.15); }
}

@keyframes flip-sheen {
  0%   { background-position: 100% 0; }
  100% { background-position: -50% 0; }
}

/* ===== OTP ===== */
.auth__subtitle--otp {
  color: var(--text-muted);
  line-height: 22px;
}

.otp-email {
  color: var(--white);
  font-weight: 700;
  word-break: break-all;
}

.otp {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.otp__cell {
  width: 100%;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  color: var(--white);
  caret-color: var(--green);
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.otp__cell:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 212, 119, 0.15);
}

.otp__cell.is-filled {
  border-color: var(--line-focus);
  animation: otp-tap 0.18s ease;
}

/* ячейки «выпрыгивают» по очереди после переворота */
.otp.is-intro .otp__cell {
  animation: otp-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(var(--flip-duration) * 0.55 + var(--i, 0) * 60ms);
}

.otp.is-error .otp__cell {
  border-color: var(--error);
}

.otp.is-shake {
  animation: otp-shake 0.45s ease;
}

.otp.is-success .otp__cell,
.otp.is-success .otp__cell.is-filled {
  border-color: var(--green);
  background: rgba(46, 212, 119, 0.08);
  animation: otp-success 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}

.otp__error {
  text-align: center;
}

.otp__resend {
  margin-top: 20px;
  text-align: center;
  font-size: 14.5px;
  line-height: 20px;
  color: var(--label);
}

.otp__resend b {
  color: var(--text-muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.form--otp .btn {
  margin-top: 24px;
}

@keyframes otp-pop {
  0%   { opacity: 0; transform: translateY(14px) scale(0.6); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes otp-tap {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes otp-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

@keyframes otp-success {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12) translateY(-4px); }
  100% { transform: scale(1); }
}

/* ===== Спиннер в кнопке ===== */
.btn__spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: -3px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ===== Адаптив ===== */
@media (max-height: 900px) {
  .page {
    padding-top: 140px;
  }
}

@media (max-width: 600px) {
  .header {
    top: 16px;
    left: 16px;
  }

  .logo-placeholder--header {
    width: 110px;
    height: 26px;
  }

  .page {
    padding-top: 110px;
  }

  .logo-placeholder--main {
    width: 86px;
    height: 77px;
  }

  .auth__title {
    font-size: 30px;
    line-height: 38px;
  }

  .field__input {
    font-size: 22px;
    height: 52px;
  }

  .otp {
    gap: 8px;
  }

  .otp__cell {
    height: 56px;
    font-size: 24px;
    border-radius: 10px;
  }

  .face::before,
  .face::after {
    inset: -24px -12px;
  }

  .chat-bot {
    right: 16px;
    bottom: 24px;
  }
}

/* без анимаций — простая смена сторон */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .flip__inner.is-flipped,
  .face--back {
    transform: none;
  }

  .face--back,
  .flip__inner.is-flipped .face--front {
    visibility: hidden;
  }

  .flip__inner.is-flipped .face--back {
    visibility: visible;
  }
}
