/*
  Страница входа (ui/login.html): неоновая сетка-пол едет на зрителя, по рамке карточки
  бежит свет, надпись MONTA.HUB коротко «глитчит». Только CSS: transform, opacity и угол градиента,
  без скриптов. При «уменьшить движение» base.css выключает анимации — страница остаётся целой и неподвижной.
  Цвета — токены обеих тем.
*/

@property --mh-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.mh-login {
  --mh-grid-line: color-mix(in srgb, var(--accent) 55%, transparent);
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--space-4);
  padding: calc(var(--space-6) * 2) var(--space-4) var(--space-6);
  overflow: hidden;
}

/* ---------- Фон: свечение, горизонт, пол-сетка, строки развёртки ---------- */
.mh-login__sky,
.mh-login__horizon,
.mh-login__floor,
.mh-login__scan { position: absolute; pointer-events: none; z-index: -1; }

.mh-login__sky {
  inset: 0;
  background:
    radial-gradient(55% 40% at 50% 62%, color-mix(in srgb, var(--brand-violet) 38%, transparent), transparent 70%),
    radial-gradient(28% 18% at 50% 62%, color-mix(in srgb, var(--brand-pink) 30%, transparent), transparent 70%);
  animation: mh-sky-breathe 7s ease-in-out infinite;
}

.mh-login__horizon {
  left: 0; right: 0; top: 62%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand-pink) 25%, var(--cyan) 50%, var(--brand-pink) 75%, transparent);
  box-shadow: 0 0 18px var(--brand-pink), 0 0 42px var(--brand-violet);
}

.mh-login__floor {
  left: 0; right: 0; top: 62%; bottom: 0;
  perspective: 300px;
  perspective-origin: 50% 0%;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 35%);
  mask-image: linear-gradient(to bottom, transparent, black 35%);
}
/* Пол: ближний край внизу экрана, дальний уходит к горизонту. Сдвиг на одну клетку — бесшовный цикл «на зрителя». */
.mh-login__floor::before {
  content: "";
  position: absolute; left: -100%; right: -100%; bottom: -60px; height: 2000px;
  background-image:
    linear-gradient(to right, var(--mh-grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--mh-grid-line) 1px, transparent 1px);
  background-size: 72px 72px;
  transform-origin: center bottom;
  transform: rotateX(72deg);
  animation: mh-floor-run 1.3s linear infinite;
}

.mh-login__scan {
  inset: 0;
  background: repeating-linear-gradient(to bottom, color-mix(in srgb, var(--ink) 3%, transparent) 0 1px, transparent 1px 4px);
}

/* ---------- Язык и тема в углу; на телефоне — строкой над карточкой ---------- */
.mh-login__controls {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + var(--space-4));
  right: var(--space-4);
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2);
}

/* ---------- Карточка с бегущим неоновым краем ---------- */
.mh-login__card {
  width: min(100%, 400px);
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    conic-gradient(from var(--mh-angle), var(--line) 0 50%, var(--brand-violet) 68%, var(--brand-pink) 80%, var(--cyan) 90%, var(--line) 100%) border-box;
  box-shadow: var(--shadow-glow);
  animation: mh-border-run 5s linear infinite, mh-card-in .7s ease-out;
}

.mh-login__brand { display: flex; align-items: center; gap: var(--space-3); }
.mh-login__mark { width: 44px; height: 44px; flex: none; }

/* Надпись с глитчем: две цветные копии из data-text вспыхивают со сдвигом и срезами. */
.mh-glitch {
  position: relative;
  display: inline-block;
  margin: 0;
  font: 800 26px/30px var(--font-display);
  letter-spacing: .04em;
  color: var(--ink);
  text-shadow: 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent);
  animation: mh-flicker 1.4s steps(1) 1;
}
.mh-glitch b { color: var(--accent); font-weight: 800; }
.mh-glitch::before,
.mh-glitch::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  opacity: 0;
  pointer-events: none;
}
.mh-glitch::before { color: var(--cyan); animation: mh-glitch-a 6s steps(1) infinite; }
.mh-glitch::after { color: var(--magenta); animation: mh-glitch-b 6s steps(1) infinite; }

.mh-login__lead { margin: 0; color: var(--ink-muted); font-size: 13px; }
.mh-login__lead::after { content: "_"; margin-left: 2px; color: var(--cyan); animation: mh-caret 1s steps(1) infinite; }

.mh-login__form { display: grid; gap: var(--space-3); }
.mh-login__submit { width: 100%; height: 44px; margin-top: var(--space-2); font-size: 14px; }
/* Подпись лежит на сетке пола: подложка, чтобы линии не мешали читать. */
.mh-login__foot {
  margin: 0; max-width: 400px; padding: 6px 12px; text-align: center; font-size: 12px; color: var(--ink-muted);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.mh-login__foot a { color: var(--accent); font-weight: 700; text-decoration: none; }
.mh-login__foot a:hover { text-decoration: underline; }

/* ---------- Движение ---------- */
@keyframes mh-floor-run { to { transform: rotateX(72deg) translateY(72px); } }
@keyframes mh-border-run { to { --mh-angle: 360deg; } }
@keyframes mh-sky-breathe { 50% { opacity: .7; } }
@keyframes mh-card-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes mh-caret { 50% { opacity: 0; } }
@keyframes mh-flicker {
  0% { opacity: .15; } 8% { opacity: 1; } 14% { opacity: .35; } 20% { opacity: 1; }
  52% { opacity: .6; } 56% { opacity: 1; }
}
@keyframes mh-glitch-a {
  0%, 5%, 58%, 100% { opacity: 0; transform: none; }
  1% { opacity: .9; transform: translate(-3px, -1px); clip-path: inset(8% 0 58% 0); }
  2% { opacity: .9; transform: translate(3px, 1px); clip-path: inset(62% 0 6% 0); }
  3% { opacity: .9; transform: translate(-2px, 0); clip-path: inset(30% 0 42% 0); }
  56% { opacity: .9; transform: translate(2px, -1px); clip-path: inset(44% 0 30% 0); }
}
@keyframes mh-glitch-b {
  0%, 5%, 58%, 100% { opacity: 0; transform: none; }
  1% { opacity: .85; transform: translate(3px, 1px); clip-path: inset(52% 0 20% 0); }
  2% { opacity: .85; transform: translate(-3px, 0); clip-path: inset(12% 0 64% 0); }
  4% { opacity: .85; transform: translate(2px, 1px); clip-path: inset(70% 0 4% 0); }
  57% { opacity: .85; transform: translate(-2px, 1px); clip-path: inset(18% 0 60% 0); }
}

@media (max-width: 640px) {
  .mh-login { padding-top: var(--space-4); }
  .mh-login__controls { position: static; justify-self: end; }
  .mh-login__card { padding: var(--space-5) var(--space-4); }
  .mh-glitch { font-size: 22px; line-height: 26px; }
}
