/* ============================================================
   LOGIN SCREEN - Cinematic intro feel
   ============================================================ */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  padding: 24px;
  /* Respect iOS notch/home-indicator on PWA + Safari */
  padding-top: max(24px, env(safe-area-inset-top, 0px));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  text-align: center;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: center center / cover no-repeat;
  background-color: var(--bg-void);
  /* Visible by default; animation only enhances entrance.
     Avoids stuck opacity: 0 if animation event never fires (WebKit headless,
     reduced-motion, slow JS init). */
  opacity: 1;
  animation: hero-fade-in 2s ease-out 0.3s both;
}

@keyframes hero-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Dark overlay + UI layer - present from the start so the background
   art (combat scene, alert HUD, explosions) does not bleed into the form
   and hurt readability. The fade animation only smooths the entry. */
.login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center 40%, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.85) 100%);
  pointer-events: none;
  z-index: 0;
  opacity: 1;
  animation: login-fade-in 1.5s ease-out 2.5s both;
}

.login-logo-img {
  width: min(420px, 80vw);
  height: auto;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
  opacity: 1;
  filter: drop-shadow(0 0 30px rgba(var(--accent-rgb), 0.4));
  animation: login-fade-in 1.5s ease-out 2.5s both, logo-glow 4s ease-in-out 4s infinite;
}

@keyframes logo-glow {
  0%, 100% {
    filter: drop-shadow(0 0 30px rgba(var(--accent-rgb), 0.4));
  }
  50% {
    filter: drop-shadow(0 0 50px rgba(var(--accent-rgb), 0.6));
  }
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 40px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
  opacity: 1;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8), 0 0 12px var(--scrim-50);
  animation: login-fade-in 1.5s ease-out 2.5s both;
}

.login-panel {
  width: 100%;
  max-width: 380px;
  position: relative;
  z-index: 1;
  /* Force visible by default. The fade-in animation is a nice-to-have, but
     the panel must remain readable even if the animation never fires
     (WebKit headless / reduced-motion / blocked CSS animations). */
  opacity: 1;
  animation: login-fade-in 1.5s ease-out 2.5s both;
}

@keyframes login-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Holographic terminal effect - animated border */
.login-panel.panel {
  background: rgba(6, 6, 18, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  box-shadow:
    0 0 30px rgba(var(--accent-rgb), 0.08),
    0 8px 32px var(--scrim-60),
    inset 0 1px 0 rgba(var(--accent-rgb), 0.1);
  animation: login-fade-in 1.5s ease-out 2.5s both, panel-border-glow 3s ease-in-out 4s infinite;
}

/* Reduced motion / no-animation fallback: skip entrance and keep visible. */
@media (prefers-reduced-motion: reduce) {
  .login-screen,
  .login-screen::before,
  .login-logo-img,
  .login-subtitle,
  .login-panel,
  .login-panel.panel {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

@keyframes panel-border-glow {
  0%, 100% {
    border-color: rgba(var(--accent-rgb), 0.25);
    box-shadow:
      0 0 30px rgba(var(--accent-rgb), 0.08),
      0 8px 32px var(--scrim-60),
      inset 0 1px 0 rgba(var(--accent-rgb), 0.1);
  }
  50% {
    border-color: rgba(var(--accent-rgb), 0.4);
    box-shadow:
      0 0 40px rgba(var(--accent-rgb), 0.12),
      0 8px 32px var(--scrim-60),
      inset 0 1px 0 rgba(var(--accent-rgb), 0.15);
  }
}

/* Scan line effect on login panel */
.login-panel.panel::after {
  content: '';
  position: absolute;
  top: -100%;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(var(--accent-rgb), 0.03) 50%,
    transparent 100%
  );
  animation: scan-line 4s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes scan-line {
  0% { top: -100%; }
  100% { top: 200%; }
}

.login-panel .panel-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 28px 28px;
  position: relative;
  z-index: 1;
}

#login-fields {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

#login-fields .login-remember {
  margin-top: -6px;
}

#reset-flow {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#reset-step-request,
#reset-step-code {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Login star decoration */
.login-stars {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.login-star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: white;
  border-radius: 50%;
  animation: twinkle var(--duration, 3s) infinite alternate;
  opacity: var(--opacity, 0.5);
}

/* Some login stars are brighter/larger */
.login-star.bright {
  width: 3px;
  height: 3px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
}

@keyframes twinkle {
  from { opacity: 0.2; }
  to { opacity: var(--opacity, 0.8); }
}

/* --- Error display --- */
.login-error {
  font-size: 0.8rem;
  color: var(--red);
  text-align: center;
  min-height: 20px;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
  cursor: pointer;
}

/* ─── Mobile adjustments ─── */
@media (max-width: 600px) {
  .login-screen {
    padding: 12px 16px;
    justify-content: flex-start;
    /* 12vh baseline, but never less than safe-area-inset-top + 24px so the
       logo never sits under the iOS notch / status bar. */
    padding-top: max(12vh, calc(env(safe-area-inset-top, 0px) + 24px));
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    touch-action: none;
    overscroll-behavior: none;
  }
  .login-logo-img {
    width: min(240px, 55vw);
  }
  .login-subtitle {
    margin-bottom: 12px;
    font-size: 0.6rem;
    letter-spacing: 0.25em;
  }
  .login-panel {
    max-width: 340px;
  }
  .login-panel .panel-body {
    padding: 12px 16px 16px;
    gap: 10px;
  }
  #login-fields {
    gap: 8px;
  }
  .login-panel.panel {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(6, 6, 18, 0.8);
  }
  .login-error {
    min-height: 14px;
    font-size: 0.7rem;
  }
  .login-remember {
    font-size: 0.65rem;
  }
}
