/* ═══════════════════════════════════════════════════════════════════════════
   RubiStories · Вход и регистрация · «Рубин в золе»
   Две колонки на широком экране: арт-панель (стол, свеча, два кресла) и
   форма. На телефоне арт сжимается в полосу сверху. Токены из ds/tokens.css,
   база из ds/base.css. Весь CSS висит под body.auth.
   Картинка необязательна: без неё панель остаётся тёплой тьмой с лужей света.
   ═══════════════════════════════════════════════════════════════════════════ */

.auth {
  --au-art-w: minmax(0, 1.12fr);
  --au-form-w: minmax(420px, .88fr);
  --au-card-w: 420px;
  min-height: 100vh; min-height: 100dvh;
  overflow-x: hidden;
}
.au-grain {
  position: fixed; inset: 0; z-index: var(--z-grain); pointer-events: none; opacity: .055;
  background-image: var(--tex-grain); mix-blend-mode: screen;
}
.auth h1, .auth p { margin: 0; }
.auth em { font-style: italic; }

.au-shell {
  display: grid; grid-template-columns: var(--au-art-w) var(--au-form-w);
  min-height: 100vh; min-height: 100dvh;
}

/* ── арт-панель ──────────────────────────────────────────────────────────── */
.au-art {
  position: relative; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(520px 420px at 62% 58%, rgba(242, 104, 42, .13), transparent 70%),
    linear-gradient(160deg, var(--ash-1), var(--ash-0));
}
.au-art-pic {
  position: absolute; inset: -4%; z-index: -2;
  background: url("/static/img/chat-hero.jpg") 76% 50% / cover no-repeat;
  opacity: 0; transition: opacity 1.4s var(--ease-inout) .1s;
  animation: au-drift 46s ease-in-out infinite alternate;
  will-change: transform;
}
.auth.pic-ok .au-art-pic { opacity: 1; }
@keyframes au-drift { from { transform: scale(1) translate3d(0, 0, 0); } to { transform: scale(1.07) translate3d(-1.2%, -.8%, 0); } }

/* скрим из пепла: слева под логотип, снизу под цитату, виньетка по краям */
.au-art-scrim {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(10, 8, 7, .7) 0%, rgba(10, 8, 7, 0) 24%, rgba(10, 8, 7, 0) 52%, rgba(10, 8, 7, .94) 100%),
    linear-gradient(90deg, rgba(10, 8, 7, .55), rgba(10, 8, 7, 0) 34%),
    radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(10, 8, 7, .6) 100%);
}
.au-art::after {
  content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 1px; pointer-events: none;
  background: linear-gradient(180deg, transparent, var(--brass-line) 24%, var(--brass-line) 76%, transparent);
}
.au-art-brand {
  position: absolute; top: clamp(24px, 4.5vh, 44px); left: clamp(28px, 4vw, 56px);
  display: flex; align-items: center; gap: 12px; user-select: none;
}
.au-art-quote {
  position: absolute; left: clamp(28px, 4vw, 56px); right: clamp(28px, 4vw, 56px);
  bottom: clamp(28px, 6vh, 64px); max-width: 30em;
  display: flex; flex-direction: column; gap: 18px;
}
.au-art-quote .orn { max-width: 260px; }
.au-quote {
  font-family: var(--display); font-style: italic; font-weight: 300;
  font-size: clamp(26px, 2.6vw, 40px); line-height: 1.16; letter-spacing: -.012em;
  color: var(--bone); text-wrap: balance;
}

/* ── бренд ───────────────────────────────────────────────────────────────── */
.au-gem { width: 30px; height: 30px; flex: none; filter: drop-shadow(0 4px 14px rgba(226, 72, 95, .55)); }
.au-wordmark { font-family: var(--display); font-size: 24px; line-height: 1; letter-spacing: -.01em; color: var(--bone); }
.au-wordmark em { color: var(--ember-hi); font-weight: 400; }
.au-brand-sm { display: none; align-items: center; gap: 11px; justify-content: center; margin-bottom: 22px; user-select: none; }

/* ── колонка формы ───────────────────────────────────────────────────────── */
.au-main {
  display: flex; align-items: center; justify-content: center;
  padding: clamp(24px, 5vh, 56px) clamp(16px, 3vw, 40px);
  background: linear-gradient(180deg, rgba(16, 13, 12, .55), rgba(10, 8, 7, .2));
}
.au-card {
  width: 100%; max-width: var(--au-card-w); position: relative;
  padding: 36px 34px 28px;
  background: linear-gradient(180deg, var(--ash-2), var(--ash-1));
  border: 1px solid var(--line-soft); border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  animation: au-in var(--dur-3) var(--ease) both;
}
@keyframes au-in { from { opacity: 0; transform: translateY(12px); } }
/* пока спрашиваем сервер, не вошли ли мы уже: карточка чуть притушена */
.auth.is-checking .au-card { opacity: .55; pointer-events: none; }
.au-card { transition: opacity var(--dur-3) var(--ease); }

/* ── вкладки: тот же вид, что у переключателя Мир/Чат ──────────────────── */
.au-tabs {
  display: flex; padding: 3px; gap: 2px; border-radius: var(--r-pill);
  border: 1px solid var(--line-soft); background: var(--ash-0);
  margin-bottom: 28px;
}
.auth .au-tabs button {
  flex: 1; height: 38px; padding: 0 14px; border: 0; border-radius: var(--r-pill);
  background: none; box-shadow: none; color: var(--text-dim);
  font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
}
.auth .au-tabs button:hover { color: var(--text); background: none; border: 0; }
.auth .au-tabs button:active { transform: none; box-shadow: none; }
.auth .au-tabs button[aria-selected="true"] {
  background: var(--ember-wash); color: var(--ember-hi); box-shadow: 0 0 0 1px var(--ember-line) inset;
}

/* ── заголовок панели ────────────────────────────────────────────────────── */
.au-panel { animation: au-rise var(--dur-3) var(--ease) both; }
@keyframes au-rise { from { opacity: 0; transform: translateY(8px); } }
.au-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.au-title { font-size: clamp(30px, 3.4vw, 38px); line-height: 1.04; font-weight: 400; letter-spacing: -.015em; }
.au-title em { color: var(--ember-hi); }
.au-sub { color: var(--text-dim); font-size: var(--fs-md); line-height: 1.5; text-wrap: pretty; }

/* ── поля ────────────────────────────────────────────────────────────────── */
.au-form { display: flex; flex-direction: column; gap: 16px; }
.au-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.au-field label {
  font-family: var(--mono); font-size: var(--fs-2xs); font-weight: 500;
  letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--brass);
}
.au-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.au-count { font-size: var(--fs-2xs); color: var(--text-far); letter-spacing: .06em; }
.au-count.is-full { color: var(--warn); }
.au-field input { height: 48px; padding: 0 14px; font-size: 16px; /* 16px: iOS не приближает страницу */ }
.au-pass { position: relative; }
.au-pass input { padding-right: 52px; }
.auth .au-eye {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; padding: 0; border: 0; border-radius: var(--r-pill);
  background: none; box-shadow: none; color: var(--text-far);
}
.auth .au-eye:hover { background: var(--ash-3); color: var(--text); border: 0; }
.auth .au-eye:active { transform: translateY(-50%); box-shadow: none; }
.auth .au-eye[aria-pressed="true"] { color: var(--ember-hi); }
.au-eye .ico { width: 20px; height: 20px; }
.au-hint { font-size: var(--fs-xs); color: var(--text-far); line-height: 1.4; }
.au-err { font-size: var(--fs-xs); color: var(--ruby-hi); line-height: 1.4; min-height: 0; }
.au-err:empty { display: none; }
.au-field input[aria-invalid="true"] { border-color: var(--ruby-lo); }
.au-field input[aria-invalid="true"]:focus { border-color: var(--ruby); box-shadow: 0 0 0 3px rgba(226, 72, 95, .16), 0 1px 0 rgba(0, 0, 0, .5) inset; }
/* автозаполнение браузера не должно красить поле в светлое */
.au-field input:-webkit-autofill {
  -webkit-text-fill-color: var(--text); caret-color: var(--ember-hi);
  box-shadow: 0 0 0 100px var(--ash-1) inset;
  transition: background-color 9999s;
}

/* ошибка над формой */
.au-alert {
  padding: 11px 14px; border-radius: var(--r-sm); font-size: var(--fs-sm); line-height: 1.45;
  background: var(--ruby-wash); border: 1px solid var(--ruby-lo); color: var(--ruby-hi);
  animation: au-rise var(--dur-2) var(--ease) both;
}

/* ── главная кнопка и «кольца слуха» вместо спиннера ──────────────────── */
.auth .au-submit { width: 100%; height: 50px; margin-top: 6px; font-size: 16px; border-radius: var(--r-md); position: relative; }
.au-rings { display: none; position: relative; width: 20px; height: 20px; flex: none; }
.au-rings::before, .au-rings::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid var(--ember-ink); opacity: 0;
  animation: au-ring 1.5s var(--ease) infinite;
}
.au-rings::after { animation-delay: .5s; }
.au-rings { background: radial-gradient(circle, var(--ember-ink) 0 2.5px, transparent 3px); }
@keyframes au-ring { 0% { transform: scale(.2); opacity: .9; } 100% { transform: scale(1.15); opacity: 0; } }
.au-form.is-busy .au-rings { display: inline-block; }
.au-form.is-busy .au-submit { cursor: progress; opacity: 1; }
.au-form.is-busy .au-submit:disabled { opacity: .88; }
.au-form.is-busy input { opacity: .7; }

/* ── переключатель внизу ─────────────────────────────────────────────────── */
.au-switch { margin-top: 20px; padding-top: 18px; text-align: center; font-size: var(--fs-sm); color: var(--text-far); position: relative; }
.au-switch::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--brass-line), transparent); }
.auth .au-link {
  display: inline; padding: 2px 3px; border: 0; background: none; box-shadow: none;
  font-size: inherit; font-weight: 600; color: var(--ember-hi); border-radius: var(--r-xs);
  text-decoration: underline; text-decoration-color: var(--ember-line); text-underline-offset: 3px;
}
.auth .au-link:hover { background: none; border: 0; text-decoration-color: var(--ember-hi); }
.auth .au-link:active { transform: none; box-shadow: none; }

/* метка режима проверки (только ?mock=1&noredirect=1) */
.au-mock {
  margin-top: 14px; padding: 8px 12px; border-radius: var(--r-sm);
  font-family: var(--mono); font-size: var(--fs-xs); color: var(--verd-hi);
  background: var(--verd-wash); border: 1px solid var(--verd-line); word-break: break-all;
}

/* ── планшет и телефон: арт сжимается в полосу сверху ──────────────────── */
@media (max-width: 900px) {
  .au-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .au-art { height: clamp(120px, 22vh, 190px); }
  .au-art::after { top: auto; right: 0; left: 0; bottom: 0; width: auto; height: 1px;
    background: linear-gradient(90deg, transparent, var(--brass-line) 24%, var(--brass-line) 76%, transparent); }
  .au-art-quote { display: none; }
  .au-art-brand { top: 50%; left: 50%; transform: translate(-50%, -50%); }
  .au-art-pic { background-position: 66% 42%; }
  .au-art-scrim {
    background:
      linear-gradient(180deg, rgba(10, 8, 7, .45), rgba(10, 8, 7, .18) 40%, rgba(10, 8, 7, .96) 100%),
      radial-gradient(100% 120% at 50% 50%, rgba(10, 8, 7, .35), rgba(10, 8, 7, .1) 60%);
  }
  .au-main { align-items: flex-start; padding: 8px 16px 32px; }
}
@media (max-width: 480px) {
  .au-card { padding: 26px 20px 22px; border-radius: var(--r-md); }
  .au-tabs { margin-bottom: 22px; }
  .au-head { margin-bottom: 20px; }
  .au-title { font-size: 30px; }
}
@media (max-width: 380px) {
  .au-main { padding-left: 12px; padding-right: 12px; }
  .auth .au-tabs button { padding: 0 8px; letter-spacing: .06em; }
}
@media (max-height: 640px) and (min-width: 901px) {
  .au-art-quote { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .au-art-pic { animation: none; }
  .au-card, .au-panel, .au-alert { animation: none; }
  .au-rings::before, .au-rings::after { animation: none; opacity: .6; transform: scale(.8); }
}
