/* ==========================================================================
   GambaCodes Login - Midnight Observatory
   A single focused login card floating in a cosmic void.
   ========================================================================== */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Outfit:wght@400;700&display=swap');

/* --- Custom Properties --- */
@property --border-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@property --glow-opacity {
  syntax: '<number>';
  initial-value: 0;
  inherits: false;
}

:root {
  --void: #09090b;
  --void-surface: #0c0c0f;
  --violet-electric: #7c3aed;
  --cyan-bright: #22d3ee;
  --rose-vivid: #f43f5e;
  --violet-soft: #a78bfa;
  --rose-soft: #fb7185;
  --text-primary: #fafafa;
  --text-secondary: rgba(250, 250, 250, 0.5);
  --text-muted: rgba(250, 250, 250, 0.3);
  --glass-bg: rgba(255, 255, 255, 0.02);
  --glass-border: rgba(255, 255, 255, 0.06);
  --card-radius: 24px;
  --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */

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

/* Hide scrollbars */
html {
  overflow: hidden;
  scrollbar-width: none;
}

html::-webkit-scrollbar {
  display: none;
}

/* Custom selection color */
::selection {
  background: rgba(124, 58, 237, 0.4);
  color: #fafafa;
}

::-moz-selection {
  background: rgba(124, 58, 237, 0.4);
  color: #fafafa;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--void);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Background: Cosmic Void with Drifting Aurora Blobs
   ========================================================================== */

body::before {
  content: '';
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse 600px 400px at 20% 30%, rgba(124, 58, 237, 0.15) 0%, transparent 70%),
    radial-gradient(ellipse 500px 500px at 75% 70%, rgba(34, 211, 238, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 400px 600px at 60% 20%, rgba(244, 63, 94, 0.07) 0%, transparent 70%),
    radial-gradient(ellipse 700px 300px at 30% 80%, rgba(167, 139, 250, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 350px 350px at 85% 40%, rgba(124, 58, 237, 0.05) 0%, transparent 60%);
  animation: auroraDrift 25s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}

body::after {
  content: '';
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse 500px 350px at 80% 25%, rgba(34, 211, 238, 0.1) 0%, transparent 70%),
    radial-gradient(ellipse 600px 500px at 15% 65%, rgba(244, 63, 94, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 450px 450px at 50% 50%, rgba(124, 58, 237, 0.04) 0%, transparent 50%);
  animation: auroraDrift2 30s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}

@keyframes auroraDrift {
  0% {
    transform: translate(0%, 0%) rotate(0deg);
  }
  25% {
    transform: translate(5%, -3%) rotate(1deg);
  }
  50% {
    transform: translate(-3%, 5%) rotate(-0.5deg);
  }
  75% {
    transform: translate(4%, 2%) rotate(0.5deg);
  }
  100% {
    transform: translate(-2%, -4%) rotate(-1deg);
  }
}

@keyframes auroraDrift2 {
  0% {
    transform: translate(0%, 0%) rotate(0deg);
  }
  33% {
    transform: translate(-4%, 3%) rotate(-1deg);
  }
  66% {
    transform: translate(3%, -5%) rotate(0.8deg);
  }
  100% {
    transform: translate(5%, 2%) rotate(-0.5deg);
  }
}

/* ==========================================================================
   Background Elements: Stars & Aurora (HTML divs, styled as layers)
   ========================================================================== */

.bg-stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 15% 25%, rgba(255, 255, 255, 0.3) 50%, transparent 50%),
    radial-gradient(1.2px 1.2px at 50% 15%, rgba(255, 255, 255, 0.25) 50%, transparent 50%),
    radial-gradient(1px 1px at 80% 45%, rgba(255, 255, 255, 0.2) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 35% 70%, rgba(255, 255, 255, 0.35) 50%, transparent 50%),
    radial-gradient(1px 1px at 70% 80%, rgba(255, 255, 255, 0.15) 50%, transparent 50%);
  background-size: 200px 200px;
  animation: starTwinkle 8s ease-in-out infinite alternate;
  opacity: 0.6;
}

@keyframes starTwinkle {
  0% { opacity: 0.6; }
  50% { opacity: 0.4; }
  100% { opacity: 0.7; }
}

.bg-aurora {
  position: fixed;
  inset: -30%;
  width: 160%;
  height: 160%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 500px 350px at 25% 35%, rgba(124, 58, 237, 0.12) 0%, transparent 70%),
    radial-gradient(ellipse 400px 400px at 70% 65%, rgba(34, 211, 238, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 350px 500px at 55% 25%, rgba(244, 63, 94, 0.06) 0%, transparent 60%);
  animation: bgAuroraDrift 22s ease-in-out infinite alternate;
}

@keyframes bgAuroraDrift {
  0% { transform: translate(0%, 0%) rotate(0deg); }
  50% { transform: translate(3%, -2%) rotate(0.5deg); }
  100% { transform: translate(-2%, 3%) rotate(-0.5deg); }
}

/* ==========================================================================
   Star Field: Subtle dot pattern using pseudo-element (fallback overlay)
   ========================================================================== */

.login-container::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(255, 255, 255, 0.4) 50%, transparent 50%),
    radial-gradient(1px 1px at 25% 40%, rgba(255, 255, 255, 0.2) 50%, transparent 50%),
    radial-gradient(1.2px 1.2px at 45% 10%, rgba(255, 255, 255, 0.35) 50%, transparent 50%),
    radial-gradient(1px 1px at 60% 55%, rgba(255, 255, 255, 0.15) 50%, transparent 50%),
    radial-gradient(1px 1px at 80% 25%, rgba(255, 255, 255, 0.3) 50%, transparent 50%),
    radial-gradient(0.8px 0.8px at 92% 60%, rgba(255, 255, 255, 0.25) 50%, transparent 50%),
    radial-gradient(1px 1px at 15% 75%, rgba(255, 255, 255, 0.2) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 35% 85%, rgba(255, 255, 255, 0.15) 50%, transparent 50%),
    radial-gradient(1px 1px at 55% 70%, rgba(255, 255, 255, 0.3) 50%, transparent 50%),
    radial-gradient(0.8px 0.8px at 70% 90%, rgba(255, 255, 255, 0.2) 50%, transparent 50%),
    radial-gradient(1px 1px at 88% 80%, rgba(255, 255, 255, 0.25) 50%, transparent 50%),
    radial-gradient(1.2px 1.2px at 5% 50%, rgba(255, 255, 255, 0.15) 50%, transparent 50%),
    radial-gradient(1px 1px at 50% 35%, rgba(255, 255, 255, 0.2) 50%, transparent 50%),
    radial-gradient(0.8px 0.8px at 40% 60%, rgba(255, 255, 255, 0.1) 50%, transparent 50%),
    radial-gradient(1px 1px at 72% 45%, rgba(255, 255, 255, 0.3) 50%, transparent 50%),
    radial-gradient(1px 1px at 95% 10%, rgba(255, 255, 255, 0.2) 50%, transparent 50%),
    radial-gradient(0.8px 0.8px at 20% 92%, rgba(255, 255, 255, 0.15) 50%, transparent 50%),
    radial-gradient(1px 1px at 65% 8%, rgba(255, 255, 255, 0.25) 50%, transparent 50%),
    radial-gradient(1.2px 1.2px at 30% 22%, rgba(255, 255, 255, 0.12) 50%, transparent 50%),
    radial-gradient(1px 1px at 85% 72%, rgba(255, 255, 255, 0.18) 50%, transparent 50%);
  background-size: 200px 200px;
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
  animation: starTwinkle 20s ease-in-out infinite alternate;
}

@keyframes starTwinkle {
  0% { opacity: 0.5; }
  50% { opacity: 0.7; }
  100% { opacity: 0.5; }
}

/* ==========================================================================
   Login Container
   ========================================================================== */

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

/* ==========================================================================
   Login Card: Glassmorphism with Animated Gradient Border
   ========================================================================== */

.login-card {
  position: relative;
  background:
    /* Noise texture via fine gradient */
    repeating-conic-gradient(
      rgba(255, 255, 255, 0.008) 0% 25%,
      transparent 0% 50%
    ) 0 0 / 4px 4px,
    /* Glass surface */
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.03) 0%,
      rgba(255, 255, 255, 0.01) 100%
    );
  backdrop-filter: blur(40px) saturate(1.2);
  -webkit-backdrop-filter: blur(40px) saturate(1.2);
  border-radius: var(--card-radius);
  padding: 52px 44px;
  box-shadow:
    /* Outer shadow - depth */
    0 25px 60px -12px rgba(0, 0, 0, 0.6),
    0 8px 24px rgba(0, 0, 0, 0.3),
    /* Inner portal glow */
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 0 80px rgba(124, 58, 237, 0.03),
    inset 0 0 40px rgba(34, 211, 238, 0.02);
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

/* Animated rotating gradient border */
.login-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--card-radius);
  padding: 1.5px;
  background: conic-gradient(
    from var(--border-angle),
    var(--violet-electric),
    var(--cyan-bright),
    var(--rose-vivid),
    var(--violet-soft),
    var(--violet-electric)
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: borderRotate 6s linear infinite;
  pointer-events: none;
  opacity: 0.7;
}

/* Inner glow layer - portal effect */
.login-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--card-radius);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(124, 58, 237, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(34, 211, 238, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

@keyframes borderRotate {
  to {
    --border-angle: 360deg;
  }
}

/* Fallback for browsers without @property support */
@supports not (background: paint(something)) {
  .login-card::before {
    animation: borderRotateFallback 6s linear infinite;
  }

  @keyframes borderRotateFallback {
    0% {
      background: conic-gradient(from 0deg, #7c3aed, #22d3ee, #f43f5e, #a78bfa, #7c3aed);
    }
    25% {
      background: conic-gradient(from 90deg, #7c3aed, #22d3ee, #f43f5e, #a78bfa, #7c3aed);
    }
    50% {
      background: conic-gradient(from 180deg, #7c3aed, #22d3ee, #f43f5e, #a78bfa, #7c3aed);
    }
    75% {
      background: conic-gradient(from 270deg, #7c3aed, #22d3ee, #f43f5e, #a78bfa, #7c3aed);
    }
    100% {
      background: conic-gradient(from 360deg, #7c3aed, #22d3ee, #f43f5e, #a78bfa, #7c3aed);
    }
  }
}

/* ==========================================================================
   Title: Refined Soft Halo Glow
   ========================================================================== */

.login-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.85rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 36px;
  color: var(--text-primary);
  letter-spacing: 1.5px;
  position: relative;
  z-index: 1;
  text-shadow:
    0 0 20px rgba(124, 58, 237, 0.25),
    0 0 40px rgba(124, 58, 237, 0.12),
    0 0 80px rgba(124, 58, 237, 0.06);
}

.login-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 400;
  text-align: center;
  color: var(--text-secondary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: -24px;
  margin-bottom: 32px;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Form Layout
   ========================================================================== */

#login-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Password Input: Minimal, Bottom Border Glow on Focus
   ========================================================================== */

#password {
  width: 100%;
  padding: 14px 0;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0;
  outline: none;
  transition:
    border-color 0.4s var(--transition-smooth),
    box-shadow 0.4s var(--transition-smooth);
  position: relative;
  letter-spacing: 0.5px;
  /* For the expanding glow effect */
  background-image: linear-gradient(var(--cyan-bright), var(--cyan-bright));
  background-size: 0% 1px;
  background-position: center bottom;
  background-repeat: no-repeat;
  transition:
    background-size 0.4s var(--transition-smooth),
    border-color 0.4s var(--transition-smooth);
}

#password::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.3px;
  transition: color 0.3s var(--transition-smooth);
}

#password:focus {
  border-bottom-color: transparent;
  background-size: 100% 1.5px;
  box-shadow: 0 4px 16px -8px rgba(34, 211, 238, 0.3);
}

#password:focus::placeholder {
  color: var(--text-secondary);
}

#password:hover:not(:focus) {
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Submit Button: Violet-to-Rose Gradient with Shine Sweep
   ========================================================================== */

button[type="submit"] {
  width: 100%;
  padding: 14px 24px;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--violet-electric) 0%, var(--rose-vivid) 100%);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  position: relative;
  overflow: hidden;
  transition:
    transform 0.3s var(--transition-smooth),
    box-shadow 0.3s var(--transition-smooth);
  box-shadow:
    0 4px 20px -4px rgba(124, 58, 237, 0.4),
    0 2px 8px rgba(124, 58, 237, 0.15);
}

/* Shine sweep effect */
button[type="submit"]::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent 20%,
    rgba(255, 255, 255, 0.12) 40%,
    rgba(255, 255, 255, 0.18) 50%,
    rgba(255, 255, 255, 0.12) 60%,
    transparent 80%
  );
  transition: left 0.6s var(--transition-smooth);
}

button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 30px -4px rgba(124, 58, 237, 0.5),
    0 4px 12px rgba(244, 63, 94, 0.2),
    0 0 40px rgba(124, 58, 237, 0.15);
}

button[type="submit"]:hover::before {
  left: 120%;
}

button[type="submit"]:active {
  transform: translateY(0px);
  box-shadow:
    0 2px 10px -2px rgba(124, 58, 237, 0.4),
    0 1px 4px rgba(124, 58, 237, 0.1);
  transition-duration: 0.1s;
}

button[type="submit"]:focus-visible {
  outline: 2px solid var(--violet-soft);
  outline-offset: 3px;
}

/* ==========================================================================
   Error Message: Soft Red Glow, Slides in from Below
   ========================================================================== */

.error-message {
  min-height: 0;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--rose-soft);
  text-align: center;
  text-shadow: 0 0 12px rgba(244, 63, 94, 0.3);
  margin-top: 2px;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.4s var(--transition-smooth),
    transform 0.4s var(--transition-smooth);
  letter-spacing: 0.2px;
  line-height: 1.4;
}

/* When error message has content, slide it in */
.error-message:not(:empty) {
  opacity: 1;
  transform: translateY(0);
  min-height: 24px;
}

/* ==========================================================================
   Shake Animation on Failed Login
   ========================================================================== */

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 50%, 90% {
    transform: translateX(-6px);
  }
  30%, 70% {
    transform: translateX(6px);
  }
  20%, 60% {
    transform: translateX(4px);
  }
  40%, 80% {
    transform: translateX(-4px);
  }
}

.login-card.shake {
  animation: shake 0.45s var(--transition-smooth);
}

/* ==========================================================================
   Responsive: Mobile (max-width: 480px)
   ========================================================================== */

@media (max-width: 480px) {
  .login-container {
    padding: 16px;
    max-width: 100%;
  }

  .login-card {
    padding: 40px 28px;
    border-radius: 20px;
  }

  .login-title {
    font-size: 1.5rem;
    margin-bottom: 28px;
    letter-spacing: 1px;
  }

  #password {
    padding: 12px 0;
    font-size: 0.9rem;
  }

  button[type="submit"] {
    padding: 13px 20px;
    font-size: 0.825rem;
    letter-spacing: 2px;
  }

  body::before,
  body::after {
    inset: -30%;
    width: 160%;
    height: 160%;
  }
}

/* ==========================================================================
   prefers-reduced-motion: Disable All Animations
   ========================================================================== */

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

  body::before,
  body::after {
    animation: none;
  }

  .login-container::before {
    animation: none;
  }

  .login-card::before {
    animation: none;
    background: conic-gradient(from 135deg, #7c3aed, #22d3ee, #f43f5e, #a78bfa, #7c3aed);
  }

  button[type="submit"]::before {
    transition: none;
    display: none;
  }

  .login-card.shake {
    animation: none;
  }

  #password {
    transition: none;
    background-image: none;
  }

  #password:focus {
    border-bottom-color: var(--cyan-bright);
    background-image: none;
    background-size: auto;
  }
}

/* ==========================================================================
   prefers-contrast: high - Maximum Readability
   ========================================================================== */

@media (prefers-contrast: high) {
  :root {
    --glass-bg: rgba(0, 0, 0, 0.9);
    --glass-border: #fff;
    --text-primary: #fff;
    --text-secondary: #ccc;
    --text-muted: #aaa;
  }

  body {
    background-color: #000;
  }

  body::before,
  body::after,
  .login-container::before {
    display: none;
  }

  .login-card {
    background: #000;
    border: 2px solid #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
  }

  .login-card::before,
  .login-card::after {
    display: none;
  }

  .login-title {
    text-shadow: none;
    color: #fff;
  }

  #password {
    border-bottom: 2px solid #fff;
    color: #fff;
    background-image: none;
  }

  #password:focus {
    border-bottom-color: #0ff;
    background-image: none;
    background-size: auto;
    box-shadow: none;
  }

  #password::placeholder {
    color: #aaa;
  }

  button[type="submit"] {
    background: #fff;
    color: #000;
    font-weight: 700;
    border: 2px solid #fff;
  }

  button[type="submit"]::before {
    display: none;
  }

  button[type="submit"]:hover {
    background: #ddd;
    box-shadow: none;
  }

  button[type="submit"]:focus-visible {
    outline: 3px solid #0ff;
    outline-offset: 3px;
  }

  .error-message {
    color: #ff4444;
    text-shadow: none;
    font-weight: 700;
  }
}
