/* ═══════════════════════════════════════════════════════════
   Pulse AI — Login Screen
   Glassmorphism card with composer-matched glow.
   Standalone — does NOT touch components.css or hacker.css.
   ═══════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/pulse/assets/fonts/InstrumentSerif-Regular.woff2') format('woff2');
}

/* ── Layout ── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* ── Card ── */
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2.25rem 2rem;
  background: rgba(10, 12, 18, 0.72);
  backdrop-filter: blur(var(--glass-blur, 18px)) saturate(1.35);
  -webkit-backdrop-filter: blur(var(--glass-blur, 18px)) saturate(1.35);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius, 8px);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 158, 44, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  position: relative;

  /* Entry animation */
  animation: loginReveal 0.5s ease-out both;
}

@keyframes loginReveal {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ── Nucleus (mini logo) ── */
.login-nucleus {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  position: relative;
}

.login-nucleus__svg {
  width: 100%;
  height: 100%;
}

.login-nucleus__ring {
  stroke: rgba(255, 158, 44, 0.25);
}

.login-nucleus__ring--outer {
  animation: loginRingSpin 48s linear infinite;
}

.login-nucleus__ring--mid {
  stroke: rgba(255, 158, 44, 0.18);
  animation: loginRingSpin 64s linear infinite reverse;
}

.login-nucleus__ring--inner {
  stroke: rgba(255, 158, 44, 0.3);
}

.login-nucleus__signal {
  stroke: var(--accent-cyan, var(--accent-cyan));
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: loginSignalDraw 2.6s ease-in-out infinite;
}

@keyframes loginRingSpin {
  to { transform: rotate(360deg); transform-origin: 40px 40px; }
}

@keyframes loginSignalDraw {
  0% { stroke-dashoffset: 100; opacity: 0.3; }
  40% { stroke-dashoffset: 0; opacity: 1; }
  60% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: -100; opacity: 0.3; }
}

/* ── Brand text ── */
.login-brand {
  font-family: var(--font-display, 'Instrument Serif', Georgia, serif);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-editorial, #f0ece4);
  margin: 0 0 1.5rem;
  line-height: 1.3;
}

/* ── Form ── */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

/* ── Field wrapper (glow target) ── */
.login-field {
  position: relative;
  border-radius: var(--radius, 8px);
  padding: 1px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 158, 44, 0.08),
    rgba(255, 255, 255, 0.04)
  );
  transition: box-shadow 0.35s ease, background 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Focus: EXACT composer glow */
.login-field:focus-within {
  box-shadow:
    0 0 0 1px rgba(255, 158, 44, 0.28),
    0 0 40px rgba(255, 158, 44, 0.28),
    0 0 72px rgba(255, 158, 44, 0.1),
    0 14px 48px rgba(0, 0, 0, 0.55);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 158, 44, 0.14),
    rgba(255, 255, 255, 0.05)
  );
}

/* Typing pulse */
.login-field.is-typing:focus-within {
  animation: loginTypingPulse 1.5s ease infinite;
}

@keyframes loginTypingPulse {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(255, 158, 44, 0.28),
      0 0 40px rgba(255, 158, 44, 0.28),
      0 0 72px rgba(255, 158, 44, 0.1),
      0 14px 48px rgba(0, 0, 0, 0.55);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(255, 158, 44, 0.45),
      0 0 48px rgba(255, 158, 44, 0.38),
      0 0 80px rgba(255, 158, 44, 0.16),
      0 14px 48px rgba(0, 0, 0, 0.55);
  }
}

/* ── Label ── */
.login-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #9ca3af);
  padding: 0.55rem 0.85rem 0;
  text-align: left;
}

/* ── Input ── */
.login-field input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.85rem 0.65rem;
  background: rgba(10, 12, 18, 0.72);
  border: none;
  border-radius: calc(var(--radius, 8px) - 1px);
  color: var(--text-strong, #e8eaed);
  font-family: var(--font-sans);
  font-size: calc(0.95rem * var(--font-scale, 1));
  line-height: 1.5;
  outline: none;
  transition: background 0.28s ease;
}

.login-field:focus-within input {
  background: rgba(16, 20, 28, 0.88);
}

.login-field input::placeholder {
  color: var(--faint, #6b7280);
}

/* ── Error state ── */
.login-card.has-error .login-field {
  background: linear-gradient(
    135deg,
    rgba(248, 113, 113, 0.1),
    rgba(248, 113, 113, 0.06),
    rgba(248, 113, 113, 0.08)
  );
}

.login-card.has-error .login-field:not(:focus-within) {
  box-shadow:
    0 0 0 1px rgba(248, 113, 113, 0.4),
    0 0 32px rgba(248, 113, 113, 0.2),
    0 8px 24px rgba(0, 0, 0, 0.4);
}

.login-error {
  font-size: 0.82rem;
  color: var(--danger, #f87171);
  margin: 0;
  min-height: 1.2em;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.login-error.visible {
  opacity: 1;
  transform: translateY(0);
}

.login-notice {
  font-size: 0.84rem;
  color: var(--accent-cyan, #FF9E2C);
  background: rgba(255, 158, 44, 0.08);
  border: 1px solid rgba(255, 158, 44, 0.25);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 0 0 0.5rem;
  display: none;
  line-height: 1.4;
  text-align: left;
}

.login-notice.visible {
  display: block;
}

/* ── Shake animation ── */
.login-card.shake {
  animation: loginShake 0.4s ease-in-out;
}

@keyframes loginShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

/* ── Submit button ── */
.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1.5rem;
  margin-top: 0.5rem;
  border: 1px solid rgba(255, 158, 44, 0.25);
  border-radius: var(--radius, 8px);
  background: linear-gradient(145deg,
    rgba(255, 158, 44, 0.12) 0%,
    rgba(255, 158, 44, 0.06) 100%
  );
  color: var(--accent-cyan, var(--accent-cyan));
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background 0.3s ease,
    box-shadow 0.3s ease,
    border-color 0.3s ease,
    transform 0.15s ease;
}

.login-btn:hover:not(:disabled) {
  background: linear-gradient(145deg,
    rgba(255, 158, 44, 0.2) 0%,
    rgba(255, 158, 44, 0.1) 100%
  );
  border-color: rgba(255, 158, 44, 0.45);
  box-shadow:
    0 0 20px rgba(255, 158, 44, 0.25),
    0 0 40px rgba(255, 158, 44, 0.1);
  transform: translateY(-1px);
}

.login-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.login-btn.is-loading .login-btn__text::after {
  content: '…';
  animation: loginDots 1s steps(3, end) infinite;
}

@keyframes loginDots {
  0% { content: ''; }
  33% { content: '.'; }
  66% { content: '..'; }
  100% { content: '...'; }
}

/* ── Success flash ── */
.login-card.login-success {
  animation: loginSuccessFlash 0.6s ease-out forwards;
}

@keyframes loginSuccessFlash {
  0% {
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.45),
      0 0 0 1px rgba(255, 158, 44, 0.04),
      inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transform: scale(1);
    opacity: 1;
  }
  40% {
    box-shadow:
      0 0 0 2px rgba(255, 158, 44, 0.6),
      0 0 60px rgba(255, 158, 44, 0.5),
      0 0 120px rgba(255, 158, 44, 0.2),
      0 14px 48px rgba(0, 0, 0, 0.55);
    transform: scale(1.01);
    opacity: 1;
  }
  100% {
    box-shadow:
      0 0 0 2px rgba(255, 158, 44, 0),
      0 0 80px rgba(255, 158, 44, 0),
      0 0 120px rgba(255, 158, 44, 0);
    transform: scale(0.98);
    opacity: 0;
  }
}

/* ═══ HACK Theme Overrides ═══ */
html[data-theme="hacker"] .login-card {
  border-radius: 5px;
  background: rgba(4, 10, 12, 0.78);
  border-color: rgba(255, 158, 44, 0.1);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 158, 44, 0.06),
    inset 0 1px 0 rgba(255, 158, 44, 0.05);
}

html[data-theme="hacker"] .login-brand {
  font-family: var(--font-mono);
  color: rgba(255, 158, 44, 0.45);
}

html[data-theme="hacker"] .login-field {
  border-radius: 4px;
  background: linear-gradient(
    135deg,
    rgba(255, 158, 44, 0.12),
    rgba(0, 40, 50, 0.3),
    rgba(255, 158, 44, 0.08)
  );
}

html[data-theme="hacker"] .login-field:focus-within {
  box-shadow:
    0 0 0 1px rgba(255, 158, 44, 0.28),
    0 0 40px rgba(255, 158, 44, 0.32),
    0 0 72px rgba(255, 158, 44, 0.12),
    0 14px 48px rgba(0, 0, 0, 0.6);
  background: linear-gradient(
    135deg,
    rgba(255, 158, 44, 0.2),
    rgba(0, 40, 50, 0.45),
    rgba(255, 158, 44, 0.14)
  );
}

html[data-theme="hacker"] .login-field input {
  background: rgba(4, 10, 12, 0.78);
  font-family: var(--font-mono);
}

html[data-theme="hacker"] .login-field:focus-within input {
  background: rgba(6, 14, 16, 0.88);
}

html[data-theme="hacker"] .login-field input::placeholder {
  color: rgba(255, 158, 44, 0.35);
  letter-spacing: 0.04em;
}

html[data-theme="hacker"] .login-label {
  font-family: var(--font-mono);
  color: rgba(255, 158, 44, 0.5);
}

html[data-theme="hacker"] .login-btn {
  border-radius: 4px;
  font-family: var(--font-mono);
  border-color: rgba(255, 158, 44, 0.3);
}

html[data-theme="hacker"] .login-btn:hover:not(:disabled) {
  border-color: var(--accent-cyan);
  box-shadow:
    0 0 20px rgba(255, 158, 44, 0.35),
    inset 0 0 14px rgba(255, 158, 44, 0.1);
  text-shadow: 0 0 8px rgba(255, 158, 44, 0.5);
}

html[data-theme="hacker"] .login-nucleus__ring {
  stroke: rgba(255, 158, 44, 0.3);
}

html[data-theme="hacker"] .login-nucleus__signal {
  stroke: var(--accent-cyan);
}

/* ═══ Responsive ═══ */
@media (max-width: 480px) {
  .login-card {
    max-width: 92vw;
    padding: 2rem 1.5rem 1.5rem;
  }
}

@media (max-width: 360px) {
  .login-card {
    max-width: 94vw;
    padding: 1.75rem 1.25rem 1.25rem;
    padding-left: 16px;
    padding-right: 16px;
    margin-left: 8px;
    margin-right: 8px;
  }
  .auth-card {
    padding-left: 16px;
    padding-right: 16px;
    margin-left: 8px;
    margin-right: 8px;
  }
  .login-brand {
    font-size: 0.72rem;
  }
}

@media (max-width: 320px) {
  .login-card {
    max-width: 96vw;
    padding: 1.5rem 1rem 1rem;
  }
  .login-brand {
    font-size: 0.68rem;
    letter-spacing: 0.08em;
  }
  .login-field input {
    font-size: calc(0.88rem * var(--font-scale, 1));
  }
  .login-nucleus {
    width: 52px;
    height: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-card {
    animation: none;
  }
  .login-card.shake {
    animation: none;
  }
  .login-card.login-success {
    animation: none;
    opacity: 0;
  }
  .login-field.is-typing:focus-within {
    animation: none;
  }
  .login-nucleus__ring--outer,
  .login-nucleus__ring--mid {
    animation: none;
  }
}

.lgpd-wrapper,
.checkbox-wrapper,
.login-checkbox-wrap {
  min-height: 44px;
  display: flex;
  align-items: center;
}
