/* ============================================================
   AUTH PAGES
   Login • Register • Password Reset

   Фон намеренно не переопределяем: `.auth-page-wrap` прозрачен и снизу
   просвечивает общий сайтовый `.bg` (01-base/background.css) — те же
   медленные амбиентные пятна, что и на каждой другой странице. Раньше
   здесь жила отдельная анимированная сетка + два пульсирующих «орба» +
   плавающие частицы — параллельная, более резкая (8-10s) система,
   конфликтующая с общей (34-46s) и не переиспользующая ничего сайтового.
   ============================================================ */

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ============================================================
   PAGE
   ============================================================ */

.auth-page-wrap {
  position: relative;
  isolation: isolate;
  overflow: hidden;

  min-height: 100vh;
  min-height: 100dvh;
}

/* тонкий статичный узор печатной платы — фирменный мотив «железного»
   магазина (та же визуальная лексика, что у ic-circuit-break в спрайте:
   прямые дорожки + точки-переходы). Статика, не анимируем — достаточно
   движения даёт свечение ниже + дыхание карточки. */
.auth-page-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cg fill='none' stroke='var(--cyan-a30)' stroke-width='1'%3E%3Cpath d='M0 40H45V0'/%3E%3Cpath d='M140 90H95V140'/%3E%3Cpath d='M60 140V100H140'/%3E%3Cpath d='M0 110H30V140'/%3E%3C/g%3E%3Cg fill='var(--cyan-a45)'%3E%3Ccircle cx='45' cy='40' r='2'/%3E%3Ccircle cx='95' cy='90' r='2'/%3E%3Ccircle cx='60' cy='100' r='2'/%3E%3Ccircle cx='30' cy='110' r='2'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 140px 140px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, var(--black) 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, var(--black) 0%, transparent 75%);
}

/* одно медленное дрейфующее свечение позади карточки — в темпе сайтовых
   амбиентных огней (01-base/background.css, 34-46s), а не отдельная
   более резкая система: читается как продолжение ауры самой карточки */
.auth-page-wrap::after {
  content: '';
  position: absolute;
  z-index: 0;
  pointer-events: none;
  top: 50%;
  left: 50%;
  width: 900px;
  height: 900px;
  margin: -450px 0 0 -450px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--cyan-a12) 0%, transparent 65%);
  filter: blur(10px);
  animation: authAuraDrift 36s ease-in-out infinite;
}

@keyframes authAuraDrift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%       { transform: translate3d(30px, -20px, 0) scale(1.08); }
}

@media (max-width: 980px) {
  .auth-page-wrap::after {
    animation: none;
  }
}

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

.auth-wrap {
  position: relative;
  z-index: 1;

  display: flex;
  align-items: center;
  justify-content: center;

  min-height: inherit;

  padding: var(--sp-10) var(--page-x) var(--sp-7);
}

/* ============================================================
   CARD
   ============================================================ */

.auth-card {
  position: relative;

  width: 100%;
  max-width: 460px;

  padding: var(--sp-6);

  border-radius: var(--r-xl);

  background: var(--bg-a90);
  border: 1px solid var(--line);

  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);

  box-shadow:
    inset 0 1px 0 var(--line),
    0 0 40px var(--cyan-a05),
    0 40px 80px var(--black-a55);

  animation: authCardIn .6s cubic-bezier(.22, .68, 0, 1.2) both;
}

@keyframes authCardIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* дышащее свечение по контуру — только opacity (GPU-safe), карточка
   выглядит «живой» без пульсации размера/резких колец */
.auth-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  box-shadow: 0 0 60px var(--cyan-a22);
  opacity: .4;
  pointer-events: none;
  animation: authCardGlow 5s ease-in-out infinite;
}

@keyframes authCardGlow {
  0%, 100% { opacity: .3; }
  50%       { opacity: .7; }
}

/* ============================================================
   ENTRANCE — каскадное появление содержимого карточки (не сама карточка,
   она уже входит через authCardIn). Быстрые шаги (~50ms), суммарно
   укладываемся в те же ~400ms, что и сайтовый .anim-in (01-base/helpers.css).
   ============================================================ */

@keyframes authFieldIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-anim {
  animation: authFieldIn .35s cubic-bezier(.22, .68, 0, 1.2) both;
}

.auth-d1 { animation-delay: 0s; }
.auth-d2 { animation-delay: .03s; }
.auth-d3 { animation-delay: .06s; }
.auth-d4 { animation-delay: .09s; }
.auth-d5 { animation-delay: .12s; }
.auth-d6 { animation-delay: .15s; }
.auth-d7 { animation-delay: .18s; }
.auth-d8 { animation-delay: .18s; }
.auth-d9 { animation-delay: .18s; }

/* ============================================================
   HEADING
   ============================================================ */

.auth-card h1 {
  margin-bottom: var(--sp-1);

  font-family: var(--font-display), sans-serif;
  font-size: clamp(1.5rem, 1.15rem + 1vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.02em;

  text-wrap: balance;
  overflow-wrap: anywhere;

  color: var(--white);
}

/* ============================================================
   SUBTITLE
   ============================================================ */

.auth-card .sub {
  margin-bottom: var(--sp-4);
  max-width: 32ch;
  color: var(--text-soft);
  font-size: .875rem;
  line-height: 1.6;
  text-wrap: pretty;
}

/* ============================================================
   FORM
   ============================================================ */

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

.auth-form .form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

/* ============================================================
   LABEL
   ============================================================ */

.auth-form .form-group label {
  color: var(--text-dim);

  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;

  letter-spacing: .14em;
  text-transform: uppercase;

  user-select: none;
}

/* ============================================================
   INPUT
   ============================================================ */

.auth-form .form-group input {
  width: 100%;
  box-sizing: border-box;

  min-height: var(--h-input);

  padding-inline: var(--sp-2);

  color: var(--white);
  background: var(--pure-white-a04);

  border: 1px solid var(--field-border);
  border-radius: var(--r-sm);

  transition:
    border-color .25s ease,
    background-color .25s ease,
    box-shadow .25s ease;
}

.auth-form .form-group input::placeholder {
  color: var(--text-dim);
  opacity: .7;
}

.auth-form .form-group input:hover {
  border-color: var(--field-border-hover);
}

.auth-form .form-group input:focus {
  outline: none;
  border-color: var(--cyan);
  background: var(--pure-white-a05);
  box-shadow: 0 0 0 3px var(--cyan-a12);
}

/* Chrome красит автозаполненные поля в белый (внутренний UA-стиль,
   обычный background не перебивает) — гасим через инсет-тень фона
   и держим текст читаемым на тёмном. */
.auth-form .form-group input:-webkit-autofill,
.auth-form .form-group input:-webkit-autofill:hover,
.auth-form .form-group input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--white);
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2-a95) inset;
  box-shadow: 0 0 0 1000px var(--surface-2-a95) inset;
  caret-color: var(--white);
  transition: background-color 5000s ease-in-out 0s;
}

/* поле пароля + кнопка «показать/скрыть» внутри одной рамки */
.auth-input-wrap {
  position: relative;
  display: flex;
}

.auth-input-wrap input {
  padding-right: 44px;
}

.auth-eye {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 44px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: color .2s ease;
}

.auth-eye .ic {
  width: 18px;
  height: 18px;
}

/* два готовых состояния иконки в разметке — переключаем видимость классом,
   а не href (href-свап в JS не подхватывается сканером manage.py build_icon_sprite,
   который ищет литеральный href="#ic-…" в исходниках) */
.auth-eye-ic--hide {
  display: none;
}

.auth-eye.is-shown .auth-eye-ic--show {
  display: none;
}

.auth-eye.is-shown .auth-eye-ic--hide {
  display: block;
}

.auth-eye:hover {
  color: var(--text-hi);
}

.auth-eye:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: -2px;
  border-radius: var(--r-sm);
}

/* ============================================================
   PASSWORD STRENGTH — сегментный индикатор, один акцентный цвет
   (без цветофора красный/жёлтый/зелёный), надёжность = число сегментов
   ============================================================ */

.auth-strength {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 2px;
}

/* класс задаёт display:flex с той же специфичностью, что и атрибут [hidden] —
   без явного правила ниже браузер показывает блок даже с hidden в разметке */
.auth-strength[hidden],
.auth-hint[hidden] {
  display: none;
}

.auth-strength-bars {
  display: flex;
  gap: 4px;
  flex: 1;
}

.auth-strength-bars span {
  height: 3px;
  flex: 1;
  border-radius: 2px;
  background: var(--pure-white-a10);
  transition: background-color .3s ease;
}

.auth-strength-bars span.is-filled {
  background: var(--cyan);
}

.auth-strength-label {
  flex: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ============================================================
   MATCH HINT (пароли совпадают / не совпадают)
   ============================================================ */

.auth-hint {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.auth-hint.is-ok {
  color: var(--success);
}

.auth-hint.is-bad {
  color: var(--danger);
}

/* ============================================================
   BUTTON
   ============================================================ */

.auth-submit {
  position: relative;

  width: 100%;
  min-height: var(--h-btn);

  margin-top: var(--sp-2);
  padding-inline: var(--sp-3);

  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-family: var(--font-display), sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;

  color: var(--cta-ink);

  cursor: pointer;
  user-select: none;
  touch-action: manipulation;

  border: none;
  border-radius: var(--r-md);

  background: var(--cyan);

  box-shadow: 0 8px 28px var(--cyan-a25), var(--shadow-cta);

  transition:
    transform .3s ease,
    box-shadow .3s ease;
}

/* тонкий стеклянный блик — нейтральный (белый→прозрачный), не брендовый
   двухцветный градиент, поэтому остаётся в рамках «без градиентов» */
.auth-submit::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--pure-white-a14), transparent);
  pointer-events: none;
}

.auth-submit:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 48px var(--cyan-a38), var(--shadow-cta-hover);
}

.auth-submit:active {
  transform: translateY(-1px);
}

.auth-submit:disabled {
  cursor: not-allowed;
  opacity: .65;
  transform: none;
  box-shadow: none;
}

/* загрузка — прячем текст, крутим спиннер (тот же приём, что у .primary.is-loading) */
.auth-submit.is-loading {
  color: transparent !important;
  pointer-events: none;
}

.auth-submit.is-loading::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--cta-ink-a35);
  border-top-color: var(--cta-ink);
  border-radius: 50%;
  animation: authBtnSpin .6s linear infinite;
}

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

/* ============================================================
   LINK
   ============================================================ */

.auth-link {
  margin-top: var(--sp-4);
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}

.auth-link a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding-inline: 6px;
  color: var(--cyan);
  text-decoration: none;
  transition: color .25s ease;
}

.auth-link a:hover {
  color: var(--white);
}

.auth-link a:active {
  opacity: .85;
}

/* ============================================================
   ERROR
   ============================================================ */

.auth-error {
  margin-top: var(--sp-1);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--danger) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 20%, transparent);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .auth-card::before,
  .auth-anim,
  .auth-submit.is-loading::before {
    animation: none !important;
    opacity: 1;
    transform: none;
  }

  .auth-submit,
  .auth-form .form-group input {
    transition: none;
  }
}

/* ============================================================
   TABLET
   ============================================================ */

@media (max-width: 768px) {
  .auth-wrap {
    padding: var(--sp-8) var(--sp-4) var(--sp-6);
  }

  .auth-card {
    max-width: 100%;
    padding: 32px 24px;
  }
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 520px) {
  .auth-wrap {
    padding: var(--sp-6) 16px var(--sp-5);
  }

  .auth-card {
    max-width: 100%;
    padding: 37px 20px;
    border-radius: var(--r-lg);
  }

  .auth-card h1 {
    font-size: clamp(1.5rem, 5vw, 1.75rem);
  }

  .auth-card .sub {
    max-width: none;
    font-size: 13px;
  }

  .auth-submit {
    min-height: 52px;
  }
}

/* ============================================================
   SMALL MOBILE
   ============================================================ */

@media (max-width: 360px) {
  .auth-wrap {
    padding-inline: 12px;
  }

  .auth-card {
    padding: 24px 16px;
  }

  .auth-card h1 {
    font-size: 1.375rem;
  }
}

/* ============================================================
   LANDSCAPE
   ============================================================ */

@media (max-height: 520px) and (orientation: landscape) {
  .auth-wrap {
    min-height: auto;
    padding-top: 96px;
    padding-bottom: 48px;
    align-items: flex-start;
  }
}

/* ============================================================
   LARGE SCREENS
   ============================================================ */

@media (min-width: 1600px) {
  .auth-card {
    max-width: 500px;
  }
}

@media (min-width: 2560px) {
  .auth-card {
    max-width: 540px;
  }
}
