/* ==========================================================================
   Nord palette
   ========================================================================== */
:root {
  --nord0: #2e3440;
  --nord1: #3b4252;
  --nord2: #434c5e;
  --nord3: #4c566a;
  --nord4: #d8dee9;
  --nord5: #e5e9f0;
  --nord6: #eceff4;
  --nord7: #8fbcbb;
  --nord8: #88c0d0;
  --nord9: #81a1c1;
  --nord10: #5e81ac;
  --nord11: #bf616a;
  --nord12: #d08770;
  --nord13: #ebcb8b;
  --nord14: #a3be8c;
  --nord15: #b48ead;

  --bg: var(--nord0);
  --surface: rgba(59, 66, 82, 0.55);
  --surface-strong: rgba(67, 76, 94, 0.72);
  --border: rgba(216, 222, 233, 0.12);
  --border-strong: rgba(136, 192, 208, 0.45);
  --text: var(--nord6);
  --text-muted: var(--nord4);
  --text-dim: var(--nord9);

  --radius-lg: 22px;
  --radius-md: 12px;
  --shadow-card: 0 30px 70px -30px rgba(0, 0, 0, 0.75),
                 0 2px 8px rgba(0, 0, 0, 0.25);
  --ring: 0 0 0 4px rgba(136, 192, 208, 0.18);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==========================================================================
   Base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.auth-body {
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(94, 129, 172, 0.28), transparent 60%),
    linear-gradient(180deg, #343b49 0%, var(--nord0) 55%, #292f3a 100%);
  overflow-x: hidden;
  position: relative;
  isolation: isolate;
}

/* Faint grid texture */
.auth-body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(216, 222, 233, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(216, 222, 233, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(70% 60% at 50% 40%, #000 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(70% 60% at 50% 40%, #000 0%, transparent 100%);
  pointer-events: none;
  z-index: -2;
}

/* ==========================================================================
   Aurora background
   ========================================================================== */
.aurora {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.aurora__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
}

.aurora__blob--blue {
  width: 42vmax;
  height: 42vmax;
  top: -12vmax;
  left: -10vmax;
  background: radial-gradient(circle, rgba(129, 161, 193, 0.9), transparent 65%);
  animation: drift-a 24s var(--ease) infinite alternate;
}

.aurora__blob--purple {
  width: 38vmax;
  height: 38vmax;
  right: -10vmax;
  top: 8vmax;
  background: radial-gradient(circle, rgba(180, 142, 173, 0.75), transparent 65%);
  animation: drift-b 28s var(--ease) infinite alternate;
}

.aurora__blob--teal {
  width: 34vmax;
  height: 34vmax;
  bottom: -14vmax;
  left: 28vw;
  background: radial-gradient(circle, rgba(143, 188, 187, 0.6), transparent 65%);
  animation: drift-c 32s var(--ease) infinite alternate;
}

@keyframes drift-a {
  to { transform: translate3d(6vw, 5vh, 0) scale(1.12); }
}
@keyframes drift-b {
  to { transform: translate3d(-7vw, 8vh, 0) scale(1.08); }
}
@keyframes drift-c {
  to { transform: translate3d(4vw, -6vh, 0) scale(1.15); }
}

/* ==========================================================================
   Card
   ========================================================================== */
.card {
  position: relative;
  width: min(100%, 410px);
  padding: 2.4rem 2.2rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(160deg, rgba(76, 86, 106, 0.35), rgba(46, 52, 64, 0.2)),
    var(--surface);
  backdrop-filter: blur(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  box-shadow: var(--shadow-card);
  animation: card-in 0.7s var(--ease) both;
}

/* Subtle top highlight */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    160deg,
    rgba(216, 222, 233, 0.35),
    rgba(216, 222, 233, 0.02) 40%,
    transparent 70%
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card__header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.brand {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 1.15rem;
  border: 1px solid rgba(136, 192, 208, 0.3);
  border-radius: 16px;
  background: linear-gradient(145deg, var(--nord2), var(--nord0));
  box-shadow:
    0 12px 28px -12px rgba(0, 0, 0, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand img {
  display: block;
  width: 42px;
  height: 42px;
}

h1 {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--nord6);
}

.muted {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-dim);
}

/* ==========================================================================
   Alert
   ========================================================================== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 1.15rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(191, 97, 106, 0.45);
  border-radius: var(--radius-md);
  background: rgba(191, 97, 106, 0.14);
  color: #e3a1a7;
  font-size: 0.85rem;
  line-height: 1.45;
  animation: shake 0.4s var(--ease);
}

.alert svg {
  flex: none;
  width: 17px;
  height: 17px;
  margin-top: 1px;
  color: var(--nord11);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ==========================================================================
   Form
   ========================================================================== */
.form {
  display: grid;
  gap: 1.05rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.field__control {
  position: relative;
  display: flex;
  align-items: center;
}

.field__icon {
  position: absolute;
  left: 14px;
  width: 19px;
  height: 19px;
  color: var(--nord3);
  pointer-events: none;
  transition: color 0.2s ease;
}

.field__control input {
  width: 100%;
  height: 48px;
  padding: 0 3rem 0 2.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(46, 52, 64, 0.55);
  color: var(--nord6);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease,
    box-shadow 0.2s ease;
}

.field__control input::placeholder {
  color: var(--nord3);
}

.field__control input:hover {
  border-color: rgba(216, 222, 233, 0.22);
}

.field__control input:focus {
  border-color: var(--border-strong);
  background: rgba(46, 52, 64, 0.85);
  box-shadow: var(--ring);
}

.field__control:focus-within .field__icon {
  color: var(--nord8);
}

/* Autofill keeps the dark surface */
.field__control input:-webkit-autofill,
.field__control input:-webkit-autofill:hover,
.field__control input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--nord6);
  -webkit-box-shadow: 0 0 0 100px var(--nord2) inset;
  caret-color: var(--nord6);
  transition: background-color 5000s ease-in-out 0s;
}

.field__toggle {
  position: absolute;
  right: 8px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--nord3);
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.field__toggle:hover {
  color: var(--nord8);
  background: rgba(136, 192, 208, 0.1);
}

.field__toggle:focus-visible {
  outline: none;
  color: var(--nord8);
  box-shadow: var(--ring);
}

.field__toggle svg {
  width: 19px;
  height: 19px;
}

.field__toggle .icon-eye-off {
  display: none;
}

.field__toggle[aria-pressed="true"] .icon-eye {
  display: none;
}

.field__toggle[aria-pressed="true"] .icon-eye-off {
  display: block;
}

/* ==========================================================================
   Button
   ========================================================================== */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  height: 48px;
  margin-top: 0.35rem;
  padding: 0 1.25rem;
  border: 1px solid rgba(136, 192, 208, 0.35);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--nord9), var(--nord10));
  color: var(--nord6);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  box-shadow:
    0 12px 26px -12px rgba(94, 129, 172, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition:
    transform 0.18s var(--ease),
    box-shadow 0.2s ease,
    filter 0.2s ease;
}

.btn svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s var(--ease);
}

.btn:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
  box-shadow:
    0 18px 32px -12px rgba(94, 129, 172, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn:hover svg {
  transform: translateX(3px);
}

.btn:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring), 0 12px 26px -12px rgba(94, 129, 172, 0.9);
}

.btn--ghost {
  margin-top: 1.4rem;
  background: rgba(76, 86, 106, 0.35);
  border-color: var(--border);
  box-shadow: none;
  color: var(--nord5);
}

.btn--ghost:hover {
  background: rgba(76, 86, 106, 0.55);
  box-shadow: none;
  filter: none;
}

.btn--ghost:hover svg {
  transform: translateX(-3px);
}

/* ==========================================================================
   Footer / panel / misc
   ========================================================================== */
.card__footer {
  margin-top: 1.5rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
}

.card--panel {
  text-align: center;
}

.card--panel h1 {
  margin-top: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(163, 190, 140, 0.35);
  border-radius: 999px;
  background: rgba(163, 190, 140, 0.12);
  color: var(--nord14);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge svg {
  width: 15px;
  height: 15px;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--nord8);
}

/* ==========================================================================
   Responsive & motion preferences
   ========================================================================== */
@media (max-width: 440px) {
  .auth-body {
    padding: 1.25rem 1rem;
  }

  .card {
    padding: 2rem 1.4rem 1.4rem;
    border-radius: 18px;
  }

  h1 {
    font-size: 1.35rem;
  }
}

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