/* AUTO-TOKYO — страница входа в админку */

body.login.at-login {
  --primary: var(--at-primary, #e11d2e);
  --header-bg: transparent;
  --body-bg: var(--at-bg, #f6f4f4);
  --body-fg: var(--at-ink, #141414);
  font-family: "Manrope", system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

body.login.at-login #container,
body.login.at-login .main,
body.login.at-login #content-start,
body.login.at-login #content {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  min-height: 100vh;
}

body.login.at-login #container {
  display: block;
}

body.login.at-login .skip-to-content-link {
  z-index: 100;
}

/* —— Полноэкранная сцена —— */
.at-login {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 32px;
  box-sizing: border-box;
}

.at-login__backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 70% at 15% 10%, color-mix(in srgb, var(--at-primary) 22%, transparent), transparent 55%),
    radial-gradient(ellipse 70% 60% at 88% 85%, color-mix(in srgb, var(--at-primary) 14%, transparent), transparent 50%),
    linear-gradient(165deg, var(--at-bg) 0%, color-mix(in srgb, var(--at-bg) 88%, var(--at-primary) 12%) 100%);
  animation: at-login-bg-shift 18s ease-in-out infinite alternate;
}

@keyframes at-login-bg-shift {
  0% { filter: hue-rotate(0deg) brightness(1); }
  100% { filter: hue-rotate(4deg) brightness(1.03); }
}

.at-login__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.55;
  pointer-events: none;
}

.at-login__orb--1 {
  width: min(420px, 55vw);
  height: min(420px, 55vw);
  top: -8%;
  left: -6%;
  background: color-mix(in srgb, var(--at-primary) 35%, transparent);
  animation: at-login-float-1 14s ease-in-out infinite;
}

.at-login__orb--2 {
  width: min(320px, 45vw);
  height: min(320px, 45vw);
  bottom: 8%;
  right: -4%;
  background: color-mix(in srgb, var(--at-primary) 28%, transparent);
  animation: at-login-float-2 11s ease-in-out infinite;
}

.at-login__orb--3 {
  width: 180px;
  height: 180px;
  top: 42%;
  left: 58%;
  background: color-mix(in srgb, var(--at-ink) 8%, var(--at-primary) 20%);
  animation: at-login-float-3 9s ease-in-out infinite;
}

@keyframes at-login-float-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(28px, 36px) scale(1.08); }
}

@keyframes at-login-float-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-32px, -24px) scale(1.06); }
}

@keyframes at-login-float-3 {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.4; }
  50% { transform: translate(calc(-50% + 20px), calc(-50% - 16px)) scale(1.12); opacity: 0.65; }
}

.at-login__grid {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(color-mix(in srgb, var(--at-primary) 8%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--at-primary) 8%, transparent) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
  animation: at-login-grid-drift 24s linear infinite;
}

@keyframes at-login-grid-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 48px 48px, 48px 48px; }
}

.at-login__noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 1;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.at-login__shell {
  position: relative;
  z-index: 2;
  width: min(420px, 100%);
}

/* —— Карточка —— */
.at-login__card {
  background: color-mix(in srgb, var(--at-surface) 96%, transparent);
  backdrop-filter: blur(16px);
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--at-ink) 8%, transparent);
  border-top: 4px solid var(--at-primary);
  box-shadow:
    0 4px 6px color-mix(in srgb, var(--at-ink) 6%, transparent),
    0 24px 48px color-mix(in srgb, var(--at-primary) 12%, transparent);
  padding: 28px 28px 22px;
  opacity: 0;
  transform: translateY(24px) scale(0.98);
  animation: at-login-card-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.1s forwards;
}

@keyframes at-login-card-in {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

body.at-login.is-ready .at-login__field {
  animation: at-login-field-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

body.at-login.is-ready .at-login__field:nth-child(1) { animation-delay: 0.35s; }
body.at-login.is-ready .at-login__field:nth-child(2) { animation-delay: 0.45s; }
body.at-login.is-ready .at-login__submit { animation-delay: 0.58s; }

@keyframes at-login-field-in {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

body.at-login.is-ready .at-login__submit {
  animation: at-login-field-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

/* —— Бренд —— */
.at-login__head {
  text-align: center;
  margin-bottom: 24px;
}

.at-login__brand {
  display: inline-flex;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.25s ease;
}

.at-login__brand:hover {
  transform: scale(1.02);
}

.at-login__logo {
  max-height: 52px;
  width: auto;
  margin: 0 auto;
}

.at-login__wordmark {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: -0.03em;
  color: var(--at-ink);
  line-height: 1;
}

.at-login__wordmark em {
  font-style: normal;
  color: var(--at-primary);
  animation: at-login-accent-pulse 3s ease-in-out infinite;
}

@keyframes at-login-accent-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.82; filter: brightness(1.1); }
}

.at-login__tagline {
  margin: 10px 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--at-muted);
  letter-spacing: 0.02em;
}

/* —— Алерты —— */
.at-login__alert {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  animation: at-login-shake 0.45s ease;
}

.at-login__alert--error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.at-login__alert--warn {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

@keyframes at-login-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* —— Форма —— */
.at-login__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.at-login__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.at-login__label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--at-ink);
  letter-spacing: 0.02em;
}

.at-login__input-wrap {
  position: relative;
}

.at-login__input-wrap input {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--at-ink);
  background: var(--at-surface);
  border: 2px solid color-mix(in srgb, var(--at-ink) 12%, transparent);
  border-radius: 12px;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.25s ease,
    transform 0.2s ease;
}

.at-login__input-wrap input:hover {
  border-color: color-mix(in srgb, var(--at-primary) 35%, transparent);
}

.at-login__input-wrap input:focus {
  border-color: var(--at-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--at-primary) 18%, transparent);
  transform: translateY(-1px);
}

.at-login__input-glow {
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  opacity: 0;
  background: linear-gradient(120deg, var(--at-primary), var(--at-primary-dark));
  z-index: -1;
  transition: opacity 0.3s ease;
  filter: blur(8px);
}

.at-login__input-wrap:focus-within .at-login__input-glow {
  opacity: 0.25;
  animation: at-login-glow-pulse 2s ease-in-out infinite;
}

@keyframes at-login-glow-pulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.35; }
}

.at-login__field--invalid .at-login__input-wrap input {
  border-color: #dc2626;
  animation: at-login-shake 0.4s ease;
}

.at-login__field-error {
  margin: 0;
  font-size: 0.8rem;
  color: #b91c1c;
  font-weight: 600;
}

.at-login__forgot {
  margin: -4px 0 0;
  text-align: center;
  font-size: 0.85rem;
}

.at-login__forgot a {
  color: var(--at-muted);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s ease;
}

.at-login__forgot a:hover {
  color: var(--at-primary);
}

/* —— Кнопка —— */
.at-login__submit {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-top: 4px;
  padding: 15px 20px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(145deg, var(--at-primary) 0%, var(--at-primary-dark) 100%);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--at-primary) 38%, transparent);
  transition:
    transform 0.2s ease,
    box-shadow 0.25s ease;
}

.at-login__submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px color-mix(in srgb, var(--at-primary) 45%, transparent);
}

.at-login__submit:active {
  transform: translateY(0) scale(0.98);
}

.at-login__submit:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--at-primary) 50%, transparent);
  outline-offset: 3px;
}

.at-login__submit-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.35) 45%,
    transparent 100%
  );
  transform: skewX(-18deg);
  animation: at-login-shine 4s ease-in-out infinite;
}

@keyframes at-login-shine {
  0% { left: -100%; }
  35%, 100% { left: 140%; }
}

.at-login__submit.is-loading {
  pointer-events: none;
  opacity: 0.88;
}

.at-login__submit.is-loading .at-login__submit-text::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 10px;
  vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: at-login-spin 0.7s linear infinite;
}

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

/* —— Подвал карточки —— */
.at-login__foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, var(--at-ink) 8%, transparent);
  text-align: center;
}

.at-login__site-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--at-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.at-login__site-link:hover {
  color: var(--at-primary);
}

/* Скрыть лишнее от Django admin на странице входа */
body.login.at-login #header,
body.login.at-login .breadcrumbs,
body.login.at-login #footer,
body.login.at-login .theme-toggle,
body.login.at-login #toggle-nav-sidebar {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .at-login__backdrop,
  .at-login__orb,
  .at-login__grid,
  .at-login__wordmark em,
  .at-login__submit-shine,
  .at-login__card,
  body.at-login.is-ready .at-login__field,
  body.at-login.is-ready .at-login__submit {
    animation: none !important;
  }

  .at-login__card {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 480px) {
  .at-login__card {
    padding: 22px 18px 18px;
    border-radius: 16px;
  }

  .at-login__wordmark {
    font-size: 1.65rem;
  }
}
