/* Окно входа и регистрации: одна карточка по центру поверх размытой главной страницы (assets/img/auth-bg.jpg).
   Вход и регистрация через Telegram — auth-telegram.js. */
.acct-auth {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 112px 16px 56px;
}

/* размытая главная: снимок уже размыт и затемнён, сверху — виньетка, чтобы карточка читалась */
.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 80% at 50% 40%, rgba(5, 5, 7, 0.05), rgba(5, 5, 7, 0.7) 100%),
    url("../img/auth-bg.jpg?v=corvus") center top / cover no-repeat,
    #060608;
}

.auth-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 7, 0.18);
}

.auth-card {
  position: relative;
  width: min(440px, 100%);
  padding: 40px 40px 30px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 70%),
    rgba(11, 11, 14, 0.86);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 30px 80px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: acct-pop 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.auth-main,
.tg-flow {
  width: 100%;
}

.auth-main {
  display: grid;
}

.auth-main[hidden],
.tg-flow[hidden],
.tg-step[hidden] {
  display: none;
}

.auth-mark {
  justify-self: center;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 22px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, #1c1c22, #111115);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.auth-mark img {
  display: block;
  border-radius: 50%;
}

.auth-title {
  margin: 0;
  text-align: center;
  font-family: var(--font-body);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.auth-switch {
  margin: 10px 0 28px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.auth-link,
.auth-legal a {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-primary);
  font: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.45);
  text-underline-offset: 4px;
  cursor: pointer;
  transition: text-decoration-color 0.2s;
}

.auth-link:hover,
.auth-legal a:hover {
  text-decoration-color: currentColor;
}

/* поля */
.auth-form {
  gap: 18px;
}

.auth-form label {
  gap: 9px;
}

.auth-form label > span {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.auth-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.auth-form .acct-forgot {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
}

.auth-form .acct-forgot:hover {
  color: var(--text-primary);
}

.auth-form input {
  height: 50px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(4, 4, 6, 0.7);
  font-size: 0.98rem;
}

.auth-form input::placeholder {
  color: #55555e;
}

.auth-form input:focus {
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.06);
}

/* кнопки */
.auth-primary,
.auth-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 52px;
  border-radius: 12px;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s, opacity 0.2s;
}

.auth-primary {
  margin-top: 6px;
  border: 0;
  background: #ededf0;
  color: #0b0b0e;
}

.auth-primary::after {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform 0.2s;
}

.auth-primary:hover:not(:disabled) {
  background: #fff;
}

.auth-primary:hover:not(:disabled)::after {
  transform: translateX(3px);
}

.auth-primary:disabled,
.auth-secondary:disabled {
  opacity: 0.55;
  cursor: progress;
}

.auth-secondary {
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(4, 4, 6, 0.55);
  color: var(--text-primary);
  font-weight: 500;
}

.auth-secondary svg {
  color: #5aa9e6;
}

.auth-secondary:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.04);
}

.auth-legal {
  margin: 20px 0 0;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.auth-legal a {
  color: var(--text-secondary);
}

.auth-form .captcha {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(4, 4, 6, 0.7);
}

/* виджет Cloudflare Turnstile на всю ширину формы */
.captcha-cf {
  min-height: 65px;
  border-radius: 12px;
  overflow: hidden;
}

.captcha-cf[hidden],
.captcha[hidden] {
  display: none !important;
}

.tg-flow .acct-submit,
.tg-flow .tg-start {
  margin-top: 4px;
}

/* ---------- кнопка Telegram ---------- */

.tg-start {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr 20px;
  align-items: center;
  gap: 14px;
  padding: 14px 18px 14px 14px;
  border-radius: 18px;
  border: 1px solid #2a4a66;
  background: linear-gradient(135deg, #15283a, #101c29);
  color: #eaf4ff;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.tg-start:hover {
  border-color: #3f7fb3;
  transform: translateY(-1px);
  box-shadow: 0 12px 34px rgba(42, 138, 214, 0.22);
}

.tg-start:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

.tg-start-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #2a8ad6;
  color: #fff;
}

.tg-start-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tg-start-text b {
  font-size: 0.98rem;
  font-weight: 600;
}

.tg-start-text span {
  font-size: 0.8rem;
  color: #a9c4de;
}

.tg-start-arrow {
  color: #a9c4de;
}

.tg-start-compact {
  grid-template-columns: 40px 1fr;
  padding: 10px 16px 10px 10px;
  text-decoration: none;
}

.tg-start-compact .tg-start-icon {
  width: 40px;
  height: 40px;
}

.tg-start-error {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--error);
}

.tg-start-error:empty {
  display: none;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0 18px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--stroke-strong);
}

.auth-divider span {
  text-transform: uppercase;
}

/* ---------- капча «Я не робот» ---------- */

.captcha {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 10px;
  border-radius: var(--radius-md);
  border: 1px dashed #3a3a44;
  background: rgba(26, 26, 31, 0.6);
}

.acct-form[data-mode="login"] .captcha {
  display: none;
}

.captcha-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
}

.captcha-box:focus-visible {
  outline: 2px solid var(--accent-soft);
}

.captcha-check {
  flex: none;
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid #5c5c66;
  background: #121216;
  transition: border-color 0.2s, background 0.2s;
}

.captcha[data-state="checking"] .captcha-check {
  border-color: #3a3a44;
  border-top-color: var(--accent-soft);
  border-radius: 50%;
  animation: captcha-spin 0.8s linear infinite;
}

.captcha[data-state="done"] .captcha-check {
  border-color: var(--ok);
  background: rgba(134, 239, 172, 0.14);
}

.captcha[data-state="done"] .captcha-check::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 7px;
  height: 12px;
  border: solid var(--ok);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

.captcha[data-state="error"] .captcha-check {
  border-color: var(--error);
}

.captcha-meta {
  font-size: 0.6rem;
  line-height: 1.3;
  text-align: right;
}

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

/* ---------- шаги Telegram ---------- */

.tg-step {
  display: grid;
  gap: 16px;
  animation: acct-fade 0.25s ease;
}

.tg-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1.2;
}

.tg-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.tg-text b {
  color: var(--text-primary);
  font-weight: 600;
}

.tg-wait {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.tg-wait[hidden] {
  display: none;
}

.tg-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ea6ef;
  box-shadow: 0 0 0 0 rgba(78, 166, 239, 0.6);
  animation: tg-pulse 1.6s ease-out infinite;
}

.tg-timer {
  margin-left: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

@keyframes tg-pulse {
  to { box-shadow: 0 0 0 10px rgba(78, 166, 239, 0); }
}

.tg-back {
  justify-self: start;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.tg-back:hover {
  color: var(--text-primary);
}

.tg-chip {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  border: 1px solid #2a4a66;
  background: rgba(42, 138, 214, 0.12);
  font-size: 0.86rem;
}

.tg-chip-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #2a8ad6;
  font-weight: 700;
  font-size: 0.8rem;
}

.tg-chip-name {
  color: #eaf4ff;
}

.tg-chip-ok {
  color: var(--ok);
  font-size: 0.78rem;
}

.tg-email {
  border: 1px dashed #3a3a44;
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.tg-email summary {
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.tg-email summary span {
  color: var(--text-secondary);
}

.tg-email[open] summary {
  margin-bottom: 12px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- узкие экраны ---------- */

@media (max-width: 560px) {
  .acct-auth {
    padding: 92px 12px 32px;
  }

  .auth-card {
    padding: 30px 20px 24px;
    border-radius: 20px;
  }

  .auth-title {
    font-size: 1.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .tg-step {
    animation: none;
  }

  .tg-dot,
  .captcha[data-state="checking"] .captcha-check {
    animation: none;
  }
}
