/* ═══ PASSWORD STRENGTH ═════════════════════════════════════════════════════
   The meter under every sign-up password field (shared/_password_strength.html.erb):
   four segments, a one-word verdict, and the rules that move it.

   🚨 ITS OWN PROPSHAFT SHEET, like shared/invite_identity, because the screens that
   render it do not share a layout: the email-then-password sign-up, the buyer form and
   the account invitation are `auth`, the broker and teammate invitations are
   `onboarding`, and the buyer sign-up on Explore is `explore`. Each of those layouts
   links this file. It is NOT @imported into the Tailwind bundle: the tokens below are
   marketing-bundle tokens and would resolve to nothing there.

   Colour carries the score on the segments, and the verdict word says the same thing in
   text, so nothing depends on telling the hues apart. A met rule changes its icon tint
   AND its text colour.
   ═════════════════════════════════════════════════════════════════════════ */
.pw-strength {
  margin-top: var(--sp-2);
}

.pw-strength__meter {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.pw-strength__seg {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--gray-200);
  transition: background-color 0.16s ease;
}

/* Score 1 is Weak, 2 Fair, 3 Good, 4 Strong: the first N segments fill in the score's
   colour. Score 0 leaves them all empty. */
.pw-strength__meter[data-score="1"] .pw-strength__seg:nth-child(-n + 1) { background: var(--text-danger); }
.pw-strength__meter[data-score="2"] .pw-strength__seg:nth-child(-n + 2) { background: var(--color-orange-700); }
.pw-strength__meter[data-score="3"] .pw-strength__seg:nth-child(-n + 3) { background: var(--brand-500); }
.pw-strength__meter[data-score="4"] .pw-strength__seg:nth-child(-n + 4) { background: var(--brand-700); }

.pw-strength__verdict {
  margin: var(--sp-2) 0 0;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.pw-strength__verdict strong {
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}

.pw-strength__rules {
  display: grid;
  gap: 2px 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: var(--sp-2) 0 0;
  padding: 0;
  list-style: none;
}

.pw-strength__rule {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-tertiary);
}

.pw-strength__rule[hidden] { display: none; }

.pw-strength__tick {
  display: inline-flex;
  flex: none;
  margin-top: 2px;
  color: var(--gray-300);
}

.pw-strength__rule.is-met { color: var(--text-secondary); }
.pw-strength__rule.is-met .pw-strength__tick { color: var(--brand-700); }

/* The common-password warning spans the row: it is the one line that is a refusal
   rather than a rule. */
.pw-strength__rule--warn {
  grid-column: 1 / -1;
  color: var(--text-danger);
}

.pw-strength__rule--warn .pw-strength__tick { color: var(--text-danger); }

@media (max-width: 420px) {
  .pw-strength__rules { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .pw-strength__seg { transition: none; }
}

/* ═══ PASSWORD MATCH ════════════════════════════════════════════════════════
   The line under every Confirm password field (shared/_password_match.html.erb). It lives
   in this sheet because every screen with a confirmation also has the meter, so the same
   three layouts already link it.

   An icon AND a word carry the state, in the meter's colours: the brand green of a met
   rule, the danger red of the common-password warning. The line keeps its height while
   `data-state="empty"`, so "Passwords match" appearing does not push the terms checkbox
   (or anything else below) down as the person types. */
.pw-match {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: var(--sp-2) 0 0;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.pw-match { min-height: 1.5em; }

.pw-match__icon {
  display: none;
  flex: none;
  margin-top: 2px;
}

.pw-match[data-state="match"] { color: var(--brand-700); }
.pw-match[data-state="match"] .pw-match__icon--match { display: inline-flex; }

.pw-match[data-state="mismatch"] { color: var(--text-danger); }
.pw-match[data-state="mismatch"] .pw-match__icon--mismatch { display: inline-flex; }
