/* Экран входа: всегда тёмный, тон в тон с тёмной темой сайта.
   Ввод кода — как разблокировка телефона: точки + цифровая клавиатура. */

*, *::before, *::after { box-sizing: border-box; }

html, body.auth {
  margin: 0;
  touch-action: manipulation;   /* двойной тап по цифрам больше не зумит страницу */
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  -webkit-font-smoothing: antialiased;
}

.auth-box {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom, 0px));
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
}

.auth-brand {
  margin: 0 0 28px;
  font-family: var(--font-display);
  font-weight: var(--fw-display-strong);
  font-size: 30px;
  letter-spacing: -.02em;
  color: var(--text);
}

.auth-sub {
  margin: -20px 0 24px;
  font-size: 14px;
  color: var(--text-muted);
}

.auth-form { width: 100%; display: flex; flex-direction: column; align-items: center; }

.auth-nick {
  width: 100%;
  max-width: 260px;
  height: 48px;
  padding: 0 16px;
  margin-bottom: 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-field);
  background: var(--surface);
  color: var(--text);
  font: 500 16px/1 var(--font-text);
  text-align: center;
  outline: none;
}
.auth-nick::placeholder { color: var(--text-faint); }
.auth-nick:focus-visible {
  border-color: var(--focus-line);
  box-shadow: 0 0 0 var(--focus-w) var(--focus-ring);
}

.auth-hint { margin: 0 0 14px; font-size: 13px; color: var(--text-muted); }

/* --- точки кода --- */
.dots { display: flex; gap: 18px; margin-bottom: 10px; }
.dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--text-muted);
  background: transparent;
  transition: background-color var(--dur-press) var(--ease),
              border-color var(--dur-press) var(--ease);
}
.dot.is-on {
  background: var(--accent);
  border-color: var(--accent);
}

.auth-err {
  margin: 8px 0 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--danger);
}

/* --- клавиатура --- */
.pad {
  display: grid;
  grid-template-columns: repeat(3, 74px);
  gap: 16px;
  margin-top: 26px;
  justify-content: center;
}
.key {
  width: 74px;
  height: 74px;
  border: 1px solid var(--line);
  border-top-color: var(--line-top);
  border-radius: 50%;
  background-color: var(--surface);
  background-image: var(--surface-grad);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: var(--fw-display);
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color var(--dur-press) var(--ease);
}
@media (hover: hover){.key:hover { background-color: var(--surface-raised); }}
[data-tap="on"] .key:active,
[data-tap="on"] .key.is-tap { background-color: var(--tap-bg); border-color: var(--accent); }
.key:focus-visible { outline: 2px solid var(--focus-line); outline-offset: 3px; }
.key--empty { border: 0; background: none; pointer-events: none; }
.key--back { border-color: transparent; background: none; }
.key--back svg { width: 26px; height: 26px; }

.auth-switch { margin: 26px 0 0; font-size: 14px; color: var(--text-muted); }
.auth-switch a { color: var(--accent-ink); text-decoration: none; font-weight: 500; }
@media (hover: hover){.auth-switch a:hover { text-decoration: underline; }}

/* Промах кода — короткая встряска, как на телефоне */
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(4px); }
  50%      { transform: translateX(-6px); }
}
.dots.is-wrong { animation: shake 420ms var(--ease); }

@media (max-height: 700px) {
  .auth-sub { margin-bottom: 16px; }
  .auth-nick { margin-bottom: 16px; }
  .pad { grid-template-columns: repeat(3, 66px); gap: 12px; margin-top: 18px; }
  .key { width: 66px; height: 66px; font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .dot, .key { transition-duration: 1ms; }
  .dots.is-wrong { animation: none; }
  .key:active { transform: none; }
}

/* Свободен ли ник — видно сразу при вводе */
.nick-state { margin: -16px 0 16px; min-height: 16px; font-size: 13px; color: var(--text-muted); }
.nick-state.is-free { color: var(--accent-ink); }
.nick-state.is-taken { color: var(--danger); }

@media (prefers-reduced-motion: reduce) { .key:active { transition: none; } }
