/* ============================================================================
   Loom — дизайн-система
   Метафора: ткацкий станок. Защищённые каналы = переплетённые нити.
   Сигнатура: анимированная сеть нитей на фоне + индикатор-переплетение.
   ========================================================================== */

:root {
  /* Палитра — глубокий сине-чёрный, "нити" сине-фиолетовые, защита — мята */
  --bg-void: #0a0b0f;
  --bg-deep: #0e1016;
  --bg-panel: #13151d;
  --bg-panel-2: #181b25;
  --bg-elevated: #1e2230;

  --thread-1: #6366f1; /* индиго */
  --thread-2: #8b5cf6; /* фиолет */
  --thread-glow: rgba(99, 102, 241, 0.45);

  --secure: #34d399; /* мята — "защищено" */
  --secure-dim: rgba(52, 211, 153, 0.15);
  --warn: #fbbf24;
  --danger: #f87171;

  --text: #e6e8ef;
  --text-dim: #9094a6;
  --text-faint: #5b5f72;

  --border: rgba(255, 255, 255, 0.07);
  --border-bright: rgba(255, 255, 255, 0.14);

  --glass: rgba(22, 25, 35, 0.55);
  --glass-bright: rgba(30, 34, 48, 0.7);

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-deep: 0 24px 60px rgba(0, 0, 0, 0.55);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg-void);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Фоновое свечение нитей */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1100px 600px at 12% -5%, rgba(99, 102, 241, 0.14), transparent 60%),
    radial-gradient(900px 500px at 95% 110%, rgba(139, 92, 246, 0.12), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

::selection { background: var(--thread-glow); color: #fff; }

/* Скроллбары */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); background-clip: content-box; }

/* ── Утилиты ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.glass {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border);
}
.mono { font-family: var(--font-mono); }

/* Градиентный текст-нить */
.thread-text {
  background: linear-gradient(120deg, var(--thread-1), var(--thread-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Кнопки */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.25s var(--ease), background 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(120deg, var(--thread-1), var(--thread-2));
  box-shadow: 0 6px 20px var(--thread-glow);
}
.btn-primary:hover { box-shadow: 0 10px 30px var(--thread-glow); transform: translateY(-1px); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); }
.btn-icon {
  width: 40px; height: 40px; padding: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }

/* Поля ввода */
.field { position: relative; margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}
.input {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none;
}
.input::placeholder { color: var(--text-faint); }
.input:focus {
  border-color: var(--thread-1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
  background: rgba(0, 0, 0, 0.35);
}

/* Аватар-инициал с нитяным градиентом */
.avatar {
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}
.avatar[data-online="true"]::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 30%; height: 30%;
  background: var(--secure);
  border: 2px solid var(--bg-panel);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--secure);
}

/* Анимации появления */
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
.rise { animation: rise 0.5s var(--ease) both; }
.fade { animation: fade 0.3s var(--ease) both; }

/* Toast-уведомления */
#toasts {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-deep);
  animation: rise 0.3s var(--ease) both;
  max-width: 90vw;
}
.toast-err { background: #2a1316; border: 1px solid rgba(248, 113, 113, 0.4); color: #fca5a5; }
.toast-ok { background: #0f2018; border: 1px solid rgba(52, 211, 153, 0.4); color: #6ee7b7; }
.toast-info { background: var(--bg-elevated); border: 1px solid var(--border-bright); color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
