/* ═══════════════════════════════════════════════════════════════
   GHOSTLY VPN — Auth Page
   Design system: Void × Phantom Lime × Ghost Bone
   Fonts: Syne 800 / Space Grotesk 400–600 / DM Mono 300–400
═══════════════════════════════════════════════════════════════ */

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --void:         #09090B;
  --shadow-well:  #131316;
  --fog:          #52525B;
  --ghost-bone:   #E8E3D9;
  --ghost-dim:    #9B9690;
  --lime:     #4F8EFF;   /* было: #C8FF57 */
  --lime-dim: #3B7FEE;   /* было: #A8D93E */
  --border:       rgba(255, 255, 255, 0.06);
  --border-hover: rgba(200, 255, 87, 0.25);

  --font-display: 'Syne', sans-serif;
  --font-ui:      'Space Grotesk', sans-serif;
  --font-mono:    'DM Mono', monospace;

  --radius-card:  2px;
  --radius-btn:   2px;

  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:   cubic-bezier(0.7, 0, 0.84, 0);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  cursor: none;
}

body {
  min-height: 100dvh;
  background-color: var(--void);
  font-family: var(--font-ui);
  color: var(--ghost-bone);
  overflow: hidden;
}

/* ─── Custom Cursor ────────────────────────────────────────── */
.cursor,
.cursor-follower {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: difference;
  transition: opacity 0.3s;
}

.cursor {
  width: 16px;
  height: 16px;
  will-change: transform;
}

.cursor::before,
.cursor::after {
  content: '';
  position: absolute;
  background: var(--ghost-bone);
  transition: transform 0.15s var(--ease-out), background 0.2s;
}

/* Cross/plus shape */
.cursor::before {
  width: 1px;
  height: 16px;
  left: 50%;
  top: 0;
}

.cursor::after {
  width: 16px;
  height: 1px;
  top: 50%;
  left: 0;
}

.cursor-follower {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(232, 227, 217, 0.3);
  border-radius: 50%;
  will-change: transform;
  transition: width 0.3s var(--ease-out),
              height 0.3s var(--ease-out),
              border-color 0.3s,
              border-radius 0.3s;
}

.cursor.cursor-hover::before,
.cursor.cursor-hover::after {
  background: var(--lime);
}

.cursor-follower.cursor-hover {
  width: 50px;
  height: 50px;
  border-color: var(--lime);
  border-radius: 0;
}

/* ─── Preloader ────────────────────────────────────────────── */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--void);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.5s var(--ease-in), visibility 0.5s;
}

.preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-slash {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--lime);
  opacity: 0;
  animation: slash-blink 1.2s ease-in-out infinite;
}

.preloader-slash:nth-child(1) { animation-delay: 0s; }
.preloader-slash:nth-child(2) { animation-delay: 0.15s; }
.preloader-slash:nth-child(3) { animation-delay: 0.3s; }

@keyframes slash-blink {
  0%, 80%, 100% { opacity: 0; }
  40%            { opacity: 1; }
}

/* ─── Background Layer ─────────────────────────────────────── */
.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

/* Giant ghost letter — architectural scale */
.bg-ghost-letter {
  position: absolute;
  right: -8vw;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(40vw, 55vw, 700px);
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px rgba(232, 227, 217, 0.04);
  user-select: none;
  animation: ghost-breathe 8s ease-in-out infinite;
}

@keyframes ghost-breathe {
  0%, 100% { opacity: 0.7; transform: translateY(-50%) scale(1); }
  50%       { opacity: 1;   transform: translateY(-51%) scale(1.005); }
}

/* Grain overlay on entire page */
.bg-grain {
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.032;
  animation: grain-shift 0.5s steps(2) infinite;
}

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-2%, -1%); }
  50%  { transform: translate(1%, 2%); }
  75%  { transform: translate(-1%, 1%); }
  100% { transform: translate(2%, -2%); }
}

/* Ambient glow — extremely subtle */
.bg-glow {
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(ellipse at center,
    rgba(200, 87, 255, 0.04) 0%,
    transparent 70%);
  border-radius: 50%;
  animation: glow-pulse 6s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.1); }
}

/* System label — top left */
.sys-label {
  position: absolute;
  top: 24px;
  left: 32px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  color: var(--fog);
  letter-spacing: 0.12em;
  opacity: 0.6;
  animation: fade-in-label 2s var(--ease-out) 1s both;
}

@keyframes fade-in-label {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 0.6; transform: translateX(0); }
}

/* ─── Auth Wrapper ─────────────────────────────────────────── */
.auth-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  /* Intentionally off-center — asymmetric layout */
  justify-content: flex-start;
  padding: 24px 24px 24px clamp(24px, 8vw, 12vw);
  opacity: 0;
  transition: opacity 0.8s var(--ease-out);
}

.auth-wrapper.visible {
  opacity: 1;
}

/* ─── Card ─────────────────────────────────────────────────── */
.card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--shadow-well);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 40px;
  overflow: hidden;
  /* Subtle shadow with warm undertone */
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.02) inset,
    0 32px 80px rgba(0, 0, 0, 0.7),
    0 0 80px rgba(200, 255, 87, 0.03);
  animation: card-appear 0.8s var(--ease-out) 0.1s both;
}

@keyframes card-appear {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Card grain overlay */
.card-grain {
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.025;
  pointer-events: none;
  z-index: 0;
  animation: grain-shift 0.4s steps(2) infinite;
}

/* ─── Card Header ──────────────────────────────────────────── */
.card-header {
  position: relative;
  z-index: 1;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 2.6rem);
  line-height: 1;
  color: var(--ghost-bone);
  letter-spacing: -0.03em;
}

/* Living dot — pulses like a heartbeat */
.brand-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--lime);
  border-radius: 50%;
  animation: dot-pulse 2.4s ease-in-out infinite;
  align-self: flex-end;
  margin-bottom: 5px;
  flex-shrink: 0;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.6); }
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  color: var(--fog);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* ─── Divider ──────────────────────────────────────────────── */
.card-divider {
  position: relative;
  z-index: 1;
  height: 1px;
  background: var(--border);
  margin-bottom: 28px;
  overflow: visible;
}

.card-divider::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  height: 1px;
  background: var(--lime);
}

/* ─── Buttons ──────────────────────────────────────────────── */
.card-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--ghost-bone);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: none;
  overflow: hidden;
  transition:
    border-color 0.25s var(--ease-out),
    background   0.25s var(--ease-out),
    color        0.25s var(--ease-out),
    transform    0.15s var(--ease-out);
}

/* Hover fill animation */
.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--lime);
  transform: translateX(-101%);
  transition: transform 0.35s var(--ease-out);
  z-index: 0;
}

/* Grain texture on hover fill */
.btn::after {
  content: '';
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.35s;
}

.btn:hover::before { transform: translateX(0); }
.btn:hover::after  { opacity: 0.06; }

.btn:hover {
  border-color: var(--lime);
  color: var(--void);
}

.btn:hover .btn-icon,
.btn:hover .btn-arrow {
  color: var(--void);
}

.btn:active { transform: scale(0.99); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* All inner elements above the fill */
.btn-icon,
.btn-label,
.btn-arrow,
.btn-loader {
  position: relative;
  z-index: 2;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--fog);
  transition: color 0.25s;
  flex-shrink: 0;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-label {
  flex: 1;
  text-align: left;
}

.btn-arrow {
  font-size: 1rem;
  color: var(--fog);
  transition: color 0.25s, transform 0.25s var(--ease-out);
  opacity: 0;
}

.btn:hover .btn-arrow {
  opacity: 1;
  transform: translateX(3px);
}

/* ── Telegram button specific */
.btn-tg {
  background: rgba(255, 255, 255, 0.02);
}

/* ── Passkey button specific */
.btn-passkey { }

/* ── Loading state */
.btn-loader {
  display: none;
  gap: 3px;
  align-items: center;
}

.btn-loader span {
  display: block;
  width: 3px;
  height: 3px;
  background: currentColor;
  border-radius: 50%;
  animation: loader-dot 0.9s ease-in-out infinite both;
}

.btn-loader span:nth-child(1) { animation-delay: 0s; }
.btn-loader span:nth-child(2) { animation-delay: 0.15s; }
.btn-loader span:nth-child(3) { animation-delay: 0.3s; }

@keyframes loader-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1; }
}

.btn.loading .btn-loader { display: flex; }
.btn.loading .btn-label  { opacity: 0.5; }

/* ─── Status Badge ─────────────────────────────────────────── */
.status-wrap {
  position: relative;
  z-index: 1;
  min-height: 28px;
  margin-bottom: 24px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity   0.3s var(--ease-out),
    transform 0.3s var(--ease-out);
  pointer-events: none;
}

.status-badge.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Animated pulse dot */
.status-pulse {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--fog);
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-badge.info    .status-pulse { background: var(--ghost-dim); animation: pulse-ring 1.5s ease-out infinite; }
.status-badge.success .status-pulse { background: var(--lime); }
.status-badge.error   .status-pulse { background: #FF5757; }

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(232, 227, 217, 0.4); }
  70%  { box-shadow: 0 0 0 5px rgba(232, 227, 217, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 227, 217, 0); }
}

.status-icon {
  font-size: 0.7rem;
  color: var(--fog);
  line-height: 1;
  transition: color 0.3s;
}

.status-badge.success .status-icon { color: var(--lime); }
.status-badge.error   .status-icon { color: #FF5757; }

.status-text {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  color: var(--ghost-dim);
  letter-spacing: 0.08em;
  transition: color 0.3s;
}

.status-badge.success .status-text { color: var(--lime); }
.status-badge.error   .status-text { color: #FF5757; }

/* ─── Card Footer ──────────────────────────────────────────── */
.card-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.footer-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  color: var(--fog);
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ghost-bone);
  text-decoration: none;
  cursor: none;
  transition: color 0.2s, gap 0.2s var(--ease-out);
}

.footer-link svg {
  width: 14px;
  height: 14px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s var(--ease-out);
}

.footer-link:hover {
  color: var(--lime);
  gap: 8px;
}

.footer-link:hover svg {
  opacity: 1;
  transform: translateX(2px);
  stroke: var(--lime);
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  body {
    cursor: auto;
    overflow: auto;
  }

  .cursor,
  .cursor-follower {
    display: none;
  }

  .auth-wrapper {
    justify-content: center;
    padding: 20px;
    min-height: 100dvh;
    align-items: center;
  }

  .card {
    padding: 28px 24px;
  }

  .bg-ghost-letter {
    font-size: 80vw;
    right: -15vw;
    opacity: 0.6;
  }

  .sys-label {
    display: none;
  }
}

@media (max-width: 380px) {
  .card {
    padding: 24px 20px;
  }

  .btn {
    padding: 13px 14px;
  }
}

/* ─── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Focus visible (accessibility) ───────────────────────── */
.btn:focus-visible,
.footer-link:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}