/* Auth modal — real email/password auth on the marketing origin.
 * Opened by any [data-auth-open="signup"|"signin"] trigger. Email sign-up,
 * log-in and reset run here against Supabase; Google keeps its hand-off to
 * app.careerbadger.io. Mirrors the homepage Google + email lock-up. */

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  background: rgba(13, 13, 15, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.auth-modal.is-open { opacity: 1; pointer-events: auto; }

.auth-modal__card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: var(--sp-7) var(--sp-6) var(--sp-6);
  position: relative;
  transform: translateY(8px);
  transition: transform 200ms ease;
}
.auth-modal.is-open .auth-modal__card { transform: translateY(0); }

.auth-modal__close {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 50%;
  color: var(--text);
  /* Hide the × glyph (sits high in its em-box) and draw a centred cross. */
  font-size: 0;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}
.auth-modal__close::before,
.auth-modal__close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.auth-modal__close::before { transform: translate(-50%, -50%) rotate(45deg); }
.auth-modal__close::after  { transform: translate(-50%, -50%) rotate(-45deg); }
.auth-modal__close:hover { border-color: var(--magenta); color: var(--magenta); }

.auth-modal__title {
  margin: 0 0 var(--sp-2) 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.auth-modal__subtitle {
  margin: 0 0 var(--sp-5) 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

/* Google = outlined/secondary, matching the homepage hero */
.auth-modal__google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  width: 100%;
  height: 48px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.auth-modal__google:hover {
  background: var(--surface-raised);
  border-color: rgba(245, 245, 245, 0.36);
}
.auth-modal__google svg { width: 18px; height: 18px; flex-shrink: 0; }

.auth-modal__divider {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.auth-modal__divider::before,
.auth-modal__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.auth-modal__form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.auth-modal__input {
  width: 100%;
  height: 48px;
  padding: 0 var(--sp-4);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}
.auth-modal__input::placeholder { color: var(--muted); }
/* Continue with email = solid/primary, matching the homepage hero */
.auth-modal__submit {
  width: 100%;
  height: 48px;
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
  border-radius: 6px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.auth-modal__submit:hover { background: #ffffff; border-color: #ffffff; }

.auth-modal__terms {
  margin: var(--sp-4) 0 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}
.auth-modal__terms a { color: var(--magenta); text-decoration: none; }

/* Inline error banner above the form. */
.auth-modal__error {
  margin: 0 0 var(--sp-4) 0;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid rgba(229, 72, 77, 0.4);
  border-radius: 6px;
  background: rgba(229, 72, 77, 0.08);
  color: #E5484D;
  font-size: 13px;
  line-height: 1.45;
}

/* "Forgot password?" — quiet text link, right-aligned under the inputs. */
.auth-modal__forgot {
  align-self: flex-end;
  margin: calc(-1 * var(--sp-1)) 0 var(--sp-1);
  padding: 0;
  background: none;
  border: 0;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.auth-modal__forgot:hover { color: var(--text); text-decoration: underline; }

/* Sign-up ⇄ sign-in toggle line. */
.auth-modal__toggle {
  margin: var(--sp-4) 0 0 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.auth-modal__toggle button {
  padding: 0;
  background: none;
  border: 0;
  color: var(--magenta);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.auth-modal__toggle button:hover { text-decoration: underline; }

/* Check-your-email success state. */
.auth-modal__success-msg {
  margin: 0 0 var(--sp-5) 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted);
}

/* Busy / disabled states during a request. */
.auth-modal__submit:disabled,
.auth-modal__input:disabled,
.auth-modal__forgot:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.auth-modal__submit.is-busy { color: transparent; position: relative; }
.auth-modal__submit.is-busy::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid var(--bg);
  border-top-color: transparent;
  border-radius: 50%;
  animation: auth-spin 600ms linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

body.auth-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .auth-modal,
  .auth-modal__card { transition: none; }
}
