/* Sign-in, sign-up and password pages. One job: the front door.
   Only loaded by _AuthLayout, so nothing here can reach the application shell. */

/* ── Brand panel ──────────────────────────────────────────────────────────────────────
   A fixed dark surface in BOTH themes, rather than a token-driven one. The tokens flip
   between light and dark, and a brand panel that flips with them stops being a brand:
   the mark, the colour and the first impression should be the same object whichever
   theme the visitor's machine happens to prefer. The form beside it themes normally. */
.auth-brand {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(120% 90% at 100% 0%, #4a4a72 0%, transparent 55%),
    radial-gradient(100% 80% at 0% 100%, #2b2b45 0%, transparent 60%),
    linear-gradient(160deg, #383857 0%, #23233a 100%);
}

/* A faint grid, fading out downward. Pure decoration: it gives the flat gradient something
   to catch, and it is drawn from a CSS gradient rather than an image so the page still has
   no network dependency on an isolated deployment. */
.auth-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
  pointer-events: none;
}

.auth-brand > * {
  position: relative;   /* above the grid */
}

/* ── Fields ───────────────────────────────────────────────────────────────────────────
   The shape lives here rather than in a repeated utility string. It was pasted into every
   input on every auth page, so any change meant finding all of them and one always got
   missed — the reset page's two fields already drifted from the sign-in page's. */
.auth-field {
  width: 100%;
  padding: .625rem .875rem;
  font-size: .875rem;
  color: rgb(var(--c-ink));
  background-color: rgb(var(--c-surface));
  border: 1px solid rgb(var(--c-line));
  border-radius: .75rem;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.auth-field::placeholder {
  color: rgb(var(--c-muted) / .8);
}

.auth-field:focus {
  border-color: rgb(var(--c-bar));
  box-shadow: 0 0 0 3px rgb(var(--c-track) / .9);
}

/* Invalid is announced by aria-invalid, so the colour follows the same attribute instead of
   a class the server has to remember to add in every branch. */
.auth-field[aria-invalid="true"] {
  border-color: #ef4444;
}

.auth-field[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgb(239 68 68 / .16);
}

/* Room for the show/hide button on the trailing edge — logical padding, so it moves to the
   left in Arabic without a second rule. */
.auth-field-password {
  padding-inline-end: 2.75rem;
}

.auth-reveal {
  position: absolute;
  inset-inline-end: .5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  padding: .375rem;
  border-radius: .5rem;
  color: rgb(var(--c-muted));
  transition: color .15s ease, background-color .15s ease;
}

.auth-reveal:hover {
  color: rgb(var(--c-ink));
  background-color: rgb(var(--c-track) / .7);
}

/* One icon shows at a time; auth-form.js flips the state on the button. */
.auth-reveal .icon-hide { display: none; }
.auth-reveal[data-visible="true"] .icon-hide { display: block; }
.auth-reveal[data-visible="true"] .icon-show { display: none; }

/* ── Password strength ────────────────────────────────────────────────────────────────
   Four segments rather than a percentage bar: a discrete score cannot imply a precision
   the rule does not have, and it reads at a glance without a number to interpret. */
.auth-strength {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .25rem;
}

.auth-strength span {
  height: 3px;
  border-radius: 999px;
  background-color: rgb(var(--c-track));
  transition: background-color .2s ease;
}

.auth-strength[data-score="1"] span:nth-child(-n+1) { background-color: #ef4444; }
.auth-strength[data-score="2"] span:nth-child(-n+2) { background-color: #f59e0b; }
.auth-strength[data-score="3"] span:nth-child(-n+3) { background-color: #eab308; }
.auth-strength[data-score="4"] span                 { background-color: #22c55e; }

/* ── Rule checklist ───────────────────────────────────────────────────────────────────
   Each rule carries data-met, set by auth-form.js from the SAME thresholds the server
   enforces. Unmet is muted rather than red: nothing is wrong yet while the user is still
   typing, and a form that shouts before the first submit teaches people to ignore it. */
.auth-rule {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .75rem;
  color: rgb(var(--c-muted));
  transition: color .15s ease;
}

.auth-rule[data-met="true"] {
  color: #16a34a;
}

.auth-rule .rule-dot { display: block; }
.auth-rule .rule-check { display: none; }
.auth-rule[data-met="true"] .rule-dot { display: none; }
.auth-rule[data-met="true"] .rule-check { display: block; }

html.dark .auth-rule[data-met="true"] { color: #4ade80; }

/* ── Provider buttons ─────────────────────────────────────────────────────────────── */
.auth-provider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .625rem;
  width: 100%;
  padding: .625rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  color: rgb(var(--c-ink));
  background-color: rgb(var(--c-surface));
  border: 1px solid rgb(var(--c-line));
  border-radius: .75rem;
  transition: border-color .15s ease, background-color .15s ease;
}

.auth-provider:hover {
  border-color: rgb(var(--c-bar));
  background-color: rgb(var(--c-canvas));
}

/* The vendor marks are full-colour SVGs and must stay so — Google and Microsoft brand
   guidelines both forbid recolouring them, and a monochrome mark reads as a fake. */
.auth-provider svg { flex-shrink: 0; }

/* ── "or" divider ─────────────────────────────────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .75rem;
  color: rgb(var(--c-muted));
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: rgb(var(--c-line));
}

/* ── Submitting state ─────────────────────────────────────────────────────────────────
   The button keeps its width while the label swaps for a spinner, so the form does not
   jump at the exact moment the user is watching it. */
.auth-submit[data-busy="true"] {
  opacity: .75;
  cursor: default;
}

.auth-submit .submit-spinner { display: none; }
.auth-submit[data-busy="true"] .submit-spinner { display: block; }
.auth-submit[data-busy="true"] .submit-label { display: none; }

@keyframes auth-spin { to { transform: rotate(360deg); } }

.submit-spinner {
  width: 1.05rem;
  height: 1.05rem;
  margin-inline: auto;
  border: 2px solid rgb(255 255 255 / .35);
  border-top-color: #fff;
  border-radius: 999px;
  animation: auth-spin .6s linear infinite;
}

/* Someone who asked for less motion gets a static ring rather than a spinner. */
@media (prefers-reduced-motion: reduce) {
  .submit-spinner { animation: none; }
}

/* ── Step indicator (sign-up is two screens) ──────────────────────────────────────── */
.auth-steps {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .75rem;
  color: rgb(var(--c-muted));
}

.auth-steps .step-bar {
  width: 1.75rem;
  height: 3px;
  border-radius: 999px;
  background-color: rgb(var(--c-track));
}

.auth-steps .step-bar[data-active="true"] {
  background-color: rgb(var(--c-ink));
}
