/* css/auth.css — SE-auth sign-in / sign-up page styling (owned by SE-auth).
 *
 * Moved here from SE_main (its css/auth.css + the auth section of
 * css/layout.css) because only this page uses it. Loads after SE_main's shared
 * design system (/css/tokens.css, base.css, components.css, layout.css).
 */

/* ── Auth pages (centred card, no shell) ────────────────────────────────── */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(166, 205, 62, 0.16), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(42, 83, 148, 0.35), transparent 60%),
    linear-gradient(160deg, var(--navy-900), var(--navy-950));
}

.auth-layout {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

/* Background motion (js/auth-motion.js): cricket ground + lime stripes. */
.auth-motion {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.auth-motion__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1200ms var(--ease-out);
}

.auth-motion.is-live .auth-motion__canvas {
  opacity: 0.75;
}

.auth-motion__stripes span {
  position: absolute;
  right: -12%;
  width: 52%;
  height: 24px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(166, 205, 62, 0), rgba(166, 205, 62, 0.62) 70%, rgba(166, 205, 62, 0.9));
  transform: rotate(-32deg);
  transform-origin: right center;
  animation: auth-drift 18s ease-in-out infinite alternate;
}

.auth-motion__stripes span:first-child {
  top: 8%;
}

.auth-motion__stripes span:last-child {
  top: calc(8% + 60px);
  right: -18%;
  opacity: 0.5;
  animation-delay: -6s;
}

/* Sign up: the wagon wheel is on the right, so the stripes mirror to the lower left. */
.auth-motion[data-scene='wagon'] .auth-motion__stripes span {
  right: auto;
  left: -12%;
  transform-origin: left center;
  background: linear-gradient(90deg, rgba(166, 205, 62, 0.9), rgba(166, 205, 62, 0.62) 30%, rgba(166, 205, 62, 0));
}

.auth-motion[data-scene='wagon'] .auth-motion__stripes span:first-child {
  top: auto;
  bottom: 14%;
}

.auth-motion[data-scene='wagon'] .auth-motion__stripes span:last-child {
  top: auto;
  bottom: calc(14% - 60px);
  left: -18%;
}

@keyframes auth-drift {
  to {
    translate: -22px 12px;
  }
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-xl);
  padding: var(--space-7) var(--space-6);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.5);
  animation: se-fade-up var(--dur-slow) var(--ease-out) both;
}

.auth-card__brand {
  display: block;
  text-align: center;
  font-size: var(--font-size-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
  color: var(--navy-900);
  text-decoration: none;
}

.auth-card__brand::before {
  content: '';
  display: block;
  width: 52px;
  height: 40px;
  margin: 0 auto var(--space-3);
  background: url('/brand/scoutedge-logo-ui.png') center / contain no-repeat;
}

.auth-card__brand:hover {
  text-decoration: none;
  color: var(--navy-900);
}

.auth-card__subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

.auth-card__footer {
  margin-top: var(--space-4);
  text-align: center;
  font-size: var(--font-size-sm);
}

@media (max-width: 480px) {
  .auth-card {
    padding: var(--space-6) var(--space-5);
  }

  .auth-motion__stripes span {
    width: 90%;
    height: 16px;
  }

  .auth-motion__stripes span:first-child {
    top: auto;
    bottom: 48px;
  }

  .auth-motion__stripes span:last-child {
    top: auto;
    bottom: 10px;
  }

  .auth-motion[data-scene='wagon'] .auth-motion__stripes span:first-child {
    bottom: 40px;
  }

  .auth-motion[data-scene='wagon'] .auth-motion__stripes span:last-child {
    bottom: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-motion__stripes span {
    animation: none;
  }
}

/* css/auth.css — sign in / sign up / reset / verify (auth pages only).
 *
 * Everything is scoped to `.auth-layout`, so the app's own forms and buttons
 * are untouched. Builds on tokens.css (navy/lime, Inter, Barlow Condensed)
 * and the existing auth shell in layout.css. Validation, loading and auth
 * behaviour are unchanged: these rules only style the states the existing
 * scripts already set (aria-invalid, .field__error, data-loading).
 */

/* ── Layout ─────────────────────────────────────────────────────────────── */
.auth-layout {
  padding: 4.5rem var(--space-5) var(--space-7);
}

/* A soft halo behind the card ties it to the scene without covering it. */
.auth-layout::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(520px 420px at 50% 50%, rgba(1, 21, 47, 0.55), rgba(1, 21, 47, 0) 70%);
}

.auth-back {
  position: absolute;
  top: 22px;
  left: 24px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border-radius: 8px;
  color: rgba(226, 235, 246, 0.72);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard);
}

.auth-back svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--dur) var(--ease-out);
}

.auth-back:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

.auth-back:hover svg {
  transform: translateX(-3px);
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.auth-layout .auth-card {
  max-width: 452px;
  padding: 2.5rem 2.5rem 2rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: linear-gradient(180deg, #ffffff 0%, #fcfdfe 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 2px 4px rgba(1, 21, 47, 0.08),
    0 24px 48px -20px rgba(1, 21, 47, 0.55),
    0 60px 120px -40px rgba(0, 0, 0, 0.6);
}

/* Lime hairline along the top edge. */
.auth-layout .auth-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 2.5rem;
  right: 2.5rem;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, rgba(166, 205, 62, 0), var(--lime-400) 30%, var(--lime-400) 70%, rgba(166, 205, 62, 0));
}

/* Two short diagonal strokes in the corner, echoing the logo's arrows. */
.auth-layout .auth-card::after {
  content: '';
  position: absolute;
  top: 26px;
  right: 22px;
  width: 30px;
  height: 4px;
  border-radius: 2px;
  background: var(--lime-400);
  box-shadow: 9px 9px 0 rgba(166, 205, 62, 0.45);
  transform: rotate(-32deg);
  opacity: 0.9;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.auth-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-head > * {
  animation: se-fade-up var(--dur-slow) var(--ease-out) both;
}
.auth-head > *:nth-child(2) { animation-delay: 60ms; }
.auth-head > *:nth-child(3) { animation-delay: 100ms; }
.auth-head > *:nth-child(4) { animation-delay: 140ms; }

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--navy-900);
}

.auth-brand:hover {
  text-decoration: none;
  color: var(--navy-900);
}

.auth-brand__mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: #fff;
  border: 1px solid var(--ink-200);
  box-shadow: 0 4px 10px -4px rgba(1, 35, 80, 0.25);
  transition: transform var(--dur) var(--ease-out);
}

.auth-brand:hover .auth-brand__mark {
  transform: rotate(-6deg) scale(1.04);
}

.auth-brand__mark img {
  width: 28px;
  height: auto;
  display: block;
}

.auth-brand__word {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 1.5rem 0 0.35rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lime-ink);
}

.auth-kicker::before {
  content: '';
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: var(--lime-400);
  transform: skewX(-32deg);
}

.auth-layout .auth-title {
  margin: 0;
  font-size: clamp(1.55rem, 1.35rem + 0.8vw, 1.85rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--navy-900);
}

.auth-layout .auth-lede {
  max-width: 32ch;
  margin: 0.5rem auto 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-500);
}

/* Older auth pages (reset / verify) keep their simpler header. */
.auth-layout .auth-card__subtitle {
  font-size: 0.95rem;
}

/* ── Fields ─────────────────────────────────────────────────────────────── */
.auth-layout .field {
  margin-bottom: 1.1rem;
}

.auth-layout .field__label {
  margin-bottom: 7px;
  font-size: 0.8125rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--ink-700);
}

.auth-layout .field__input {
  min-height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--color-border-field);
  border-radius: 10px;
  background-color: var(--ink-50);
  font-size: 0.97rem;
  color: var(--ink-900);
  box-shadow: none;
  transition: border-color 160ms var(--ease-standard), box-shadow 200ms var(--ease-standard),
    background-color 160ms var(--ease-standard);
}

.auth-layout .field__input:hover {
  border-color: var(--color-border-field-hover);
}

.auth-layout .field__input:focus {
  outline: none;
  background-color: #fff;
  border-color: var(--lime-500);
  box-shadow: 0 0 0 4px rgba(166, 205, 62, 0.18);
}

.auth-layout .field__input[aria-invalid='true'] {
  border-color: var(--color-error);
  background-color: #fffbfa;
}

.auth-layout .field__input[aria-invalid='true']:focus {
  box-shadow: 0 0 0 4px rgba(196, 50, 10, 0.12);
}

/* Leading icons (decorative, CSS only). */
.auth-field .field__input {
  padding-left: 44px;
  background-repeat: no-repeat;
  background-position: 14px center;
  background-size: 18px;
}

.auth-field--email .field__input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5h18v14H3z'/%3E%3Cpath d='m3 7 9 6 9-6'/%3E%3C/svg%3E");
}

.auth-field--email .field__input:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23012350' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5h18v14H3z'/%3E%3Cpath d='m3 7 9 6 9-6'/%3E%3C/svg%3E");
}

.auth-field--lock .field__input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='11' width='14' height='9' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E");
}

.auth-field--lock .field__input:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23012350' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='11' width='14' height='9' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E");
}

/* Keep autofilled fields on-brand (Chromium paints them yellow/blue). */
.auth-layout .field__input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink-900);
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
  caret-color: var(--ink-900);
}

.auth-layout .field__input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #fff inset, 0 0 0 4px rgba(166, 205, 62, 0.18);
}

.auth-layout .field__hint {
  margin-top: 6px;
  font-size: 0.75rem;
}

.auth-layout .field__error {
  margin-top: 7px;
}

.auth-aux {
  display: flex;
  justify-content: flex-end;
  margin: -0.7rem 0 0.9rem;
}

.auth-aux a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 4px;
  margin-right: -4px;
}

.auth-aux a,
.auth-layout .auth-card__footer a {
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--navy-700);
  text-underline-offset: 3px;
}

/* Alerts inside the card */
.auth-layout #form-alert .alert {
  border-radius: 10px;
  margin-bottom: 1.1rem;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.auth-layout .auth-submit {
  min-height: 52px;
  margin-top: 0.35rem;
  border-radius: 10px;
  font-size: 0.97rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, #b0d64b 0%, var(--lime-400) 100%);
  border-color: var(--lime-500);
  color: var(--navy-900);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 10px 22px -12px rgba(135, 173, 37, 0.85);
  transition: transform 160ms var(--ease-out), box-shadow 200ms var(--ease-out), background 160ms var(--ease-standard);
}

.auth-submit__icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 200ms var(--ease-out);
}

.auth-layout .auth-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #a9d042 0%, var(--lime-500) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 16px 28px -14px rgba(135, 173, 37, 0.95);
}

.auth-layout .auth-submit:hover:not(:disabled) .auth-submit__icon {
  transform: translateX(3px);
}

.auth-layout .auth-submit:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 4px 10px -6px rgba(135, 173, 37, 0.8);
}

.auth-layout .auth-submit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px rgba(166, 205, 62, 0.65);
}

/* Loading: the existing withButtonLoading() disables the button and sets
   data-loading="true" with a working label; add a small spinner. */
.auth-layout .btn[data-loading='true'] {
  opacity: 1;
  cursor: progress;
}

.auth-layout .btn[data-loading='true']::before {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(1, 35, 80, 0.25);
  border-top-color: var(--navy-900);
  animation: spin 0.7s linear infinite;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1.6rem 0 1rem;
  font-size: 0.8125rem;
  color: var(--ink-500);
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ink-200);
}

.auth-layout .auth-secondary {
  min-height: 48px;
  border-radius: 10px;
  border: 1.5px solid var(--ink-200);
  background: #fff;
  color: var(--navy-900);
  font-size: 0.92rem;
  font-weight: 650;
  box-shadow: none;
  transition: transform 160ms var(--ease-out), border-color 160ms var(--ease-standard),
    background 160ms var(--ease-standard);
}

.auth-layout .auth-secondary:hover {
  transform: translateY(-1px);
  border-color: var(--navy-700);
  background: var(--navy-50);
  text-decoration: none;
}

.auth-layout .auth-secondary:active {
  transform: translateY(1px);
}

.auth-layout .auth-secondary:focus-visible,
.auth-back:focus-visible,
.auth-brand:focus-visible,
.auth-aux a:focus-visible {
  outline: 2px solid var(--lime-500);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .auth-layout {
    padding: 4rem 16px 2rem;
    align-items: flex-start;
  }

  /* Keep the form dominant: the scene steps back on phones. */
  .auth-motion.is-live .auth-motion__canvas {
    opacity: 0.5;
  }

  .auth-layout .auth-card {
    padding: 2rem 1.35rem 1.6rem;
    border-radius: 18px;
  }

  .auth-layout .auth-card::before {
    left: 1.35rem;
    right: 1.35rem;
  }

  .auth-layout .auth-card::after {
    top: 22px;
    right: 18px;
    width: 24px;
  }

  .auth-kicker {
    margin-top: 1.2rem;
  }

  .auth-layout .field__input {
    font-size: 16px; /* prevents iOS zoom-on-focus */
  }

  .auth-back {
    top: 14px;
    left: 12px;
  }
}

@media (max-height: 700px) and (min-width: 601px) {
  .auth-layout {
    align-items: flex-start;
  }
}

/* Sign-up account-type selector (Athlete / Scout / Organisation) */
.auth-accounttype { border: 0; padding: 0; margin: 0 0 var(--space-4); }
.auth-accounttype__options { display: grid; gap: 8px; margin-top: 6px; }
.auth-accounttype__option { position: relative; display: block; cursor: pointer; }
.auth-accounttype__option input {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.auth-accounttype__card {
  display: block; border: 1.5px solid var(--color-border); border-radius: var(--radius);
  padding: 10px 14px; transition: border-color .15s ease, background .15s ease;
}
.auth-accounttype__card:hover { border-color: var(--navy-100); }
.auth-accounttype__option input:checked + .auth-accounttype__card {
  border-color: var(--navy-700); background: var(--navy-50);
}
.auth-accounttype__option input:focus-visible + .auth-accounttype__card {
  outline: 2px solid var(--navy-700); outline-offset: 2px;
}
.auth-accounttype__title { display: block; font-weight: 700; color: var(--navy-900); }
.auth-accounttype__desc { display: block; font-size: .82rem; color: var(--color-text-muted); margin-top: 2px; }
