/* ==========================================================================
   Sign-in screens: Google or phone + password, sign-up, Google sign-up, unlock, new password.  (views/auth.js)
   One narrow column; from 640px the step sits on a surface card.
   ========================================================================== */

.auth {
  position: relative;
  isolation: isolate;
  overflow-x: clip;
}

/* The listening rings of the brand, large and faint behind the logo. */
.auth-halo {
  position: absolute;
  z-index: -1;
  top: -250px;
  left: 50%;
  width: 620px;
  height: 620px;
  margin-left: -310px;
  border-radius: 50%;
  background: radial-gradient(
    circle closest-side,
    rgb(var(--accent-rgb) / 0.13) 0 34%,
    rgb(var(--accent-rgb) / 0.08) 34.4% 66%,
    rgb(var(--accent-rgb) / 0.04) 66.4% 100%
  );
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .auth-halo {
    animation: auth-breathe 7s var(--ease-in-out) infinite alternate;
  }
}

@keyframes auth-breathe {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.05);
  }
}

.auth-top,
.auth-main {
  width: 100%;
  max-width: calc(var(--w-narrow) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: max(var(--gutter), var(--safe-left)) max(var(--gutter), var(--safe-right));
}

.auth-top {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-height: calc(var(--topbar-h) + var(--space-2));
  padding-top: var(--safe-top);
}

.auth-back:empty {
  display: none;
}

.auth-back > .btn {
  margin-left: calc(var(--space-3) * -1);
}

.auth-logo {
  width: auto;
  height: 32px;
}

.auth-main {
  flex: 1 1 auto;
  padding-top: clamp(var(--space-6), 7vh, var(--space-16));
  padding-bottom: calc(var(--space-8) + var(--safe-bottom));
}

/* ---- Step ---------------------------------------------------------------- */

.auth-step {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  opacity: 1;
  transform: none;
}

.auth-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.auth-head h1:focus,
.auth-head h1:focus-visible {
  outline: none;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Steps slide in from the side they come from; nothing animates out. */
@media (prefers-reduced-motion: no-preference) {
  .auth-step {
    transition:
      opacity var(--dur-3) var(--ease-out),
      transform var(--dur-3) var(--ease-out);
  }

  @starting-style {
    .auth-step {
      opacity: 0;
      transform: translateX(18px);
    }

    .auth-step[data-dir="back"] {
      transform: translateX(-18px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-step {
    transition: opacity var(--dur-2) linear;
  }

  @starting-style {
    .auth-step {
      opacity: 0;
    }
  }
}

/* ---- Phone step ---------------------------------------------------------- */

.auth-trust {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-2);
  padding: 0;
  list-style: none;
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.auth-trust li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.auth-trust .icon {
  color: var(--success);
}

.auth-legal {
  color: var(--ink-3);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.auth-legal a {
  color: var(--ink-2);
}

/* ---- Links under a form ------------------------------------------------- */

.auth-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 var(--space-4);
  margin-inline: calc(var(--space-2) * -1);
}

.auth-links > :only-child {
  margin-inline: auto;
}

.auth-note {
  text-align: center;
}

/* ---- «Google-ээр нэвтрэх»: the neutral button with the four-colour G ------ */

.auth-google {
  gap: var(--space-3);
}

.auth-google .g-mark {
  flex: none;
}

/* ---- Recovery key -------------------------------------------------------- */

.auth-keycode {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 104px;
  white-space: nowrap;
}

/* Always two rows of three groups; the dash between the rows stays in the text for copy, not on screen. */
.auth-keycode-sep {
  position: absolute;
  opacity: 0;
}

.auth-keycode-skeleton {
  width: 78%;
}

.auth-key-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.auth-key-input {
  font-family: var(--font-mono);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.auth-key-input::placeholder {
  font-weight: var(--weight-regular);
}

.auth-shake {
  animation: shake 360ms var(--ease-in-out);
}

@media (prefers-reduced-motion: reduce) {
  .auth-shake {
    animation: none;
  }
}

/* ---- Wide screens: the step becomes a card ------------------------------- */

@media (min-width: 640px) {
  .auth-top {
    min-height: calc(var(--topbar-h) + var(--space-8));
  }

  .auth-main {
    padding-top: var(--space-6);
  }

  .auth-stage {
    padding: var(--space-8);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-2);
  }
}

/* ---- Password field with show/hide ----------------------------------------- */

.auth-password {
  position: relative;
}

.auth-password .input {
  width: 100%;
  padding-right: 88px;
}

.auth-eye {
  position: absolute;
  top: 50%;
  right: var(--space-1);
  transform: translateY(-50%);
}

.auth-eye:active {
  transform: translateY(-50%) scale(0.97);
}
