/* TSU-178: password strength meter.
 *
 * A standalone stylesheet, not part of application.sass, because the same
 * partial renders on the Foundation-era signup and profile pages and inside the
 * Tailwind admin -- and the admin layout loads only tailwind.css. One file,
 * linked by both layouts, beats the same rules maintained twice.
 *
 * Plain CSS for the same reason: Tailwind utilities are not available on the
 * front-end pages. */

.ts-password-strength {
  margin: 6px 0 10px;
}

/* The meter is shown only once there is a score to show.
 *
 * Two reasons, and the second is the one that bit: a page where the controller
 * never runs (or where the selector matched nothing) must not leave a dead grey
 * track under the field -- and neither must a field the user has not typed in
 * yet. A 4px empty track reads as a horizontal divider, not as a meter, which
 * is exactly how it was first reported. `data-connected` stays on the element
 * as the wiring signal; visibility keys off the reading. The rules list beside
 * it (TSU-355) is the opposite: it is there to be read before typing. */
.ts-password-strength__meter {
  display: none;
}

.ts-password-strength[data-reading="true"] .ts-password-strength__meter {
  display: block;
  margin-bottom: 8px;
}

.ts-password-strength__track {
  background: #e6e6e6;
  border-radius: 2px;
  height: 4px;
  overflow: hidden;
  width: 100%;
}

.ts-password-strength__bar {
  background: #c0392b;
  border-radius: 2px;
  height: 100%;
  transition: width 150ms ease, background-color 150ms ease;
  width: 0;
}

/* weak (red) and fair (amber) are both refusals; the split is there so the bar
 * shows progress while the advice is being followed. */
.ts-password-strength__bar[data-strength="weak"] {
  background: #c0392b;
}

.ts-password-strength__bar[data-strength="fair"] {
  background: #e08b00;
}

.ts-password-strength__bar[data-strength="ok"] {
  background: #2e7d4f;
}

.ts-password-strength__readout {
  font-size: 12px;
  line-height: 1.4;
  margin: 4px 0 0;
}

.ts-password-strength__label {
  font-weight: 600;
}

.ts-password-strength__label:not(:empty) {
  margin-right: 4px;
}

.ts-password-strength__advice {
  color: #767676;
}

/* TSU-355: the rules, listed under the field from the start, each line ticked
 * or crossed off the reading as the user types. Neutral until then: a list of
 * four crosses under an empty field is a scolding, not a guide. */
.ts-password-rules {
  color: #555;
  font-size: 12px;
  line-height: 1.5;
}

.ts-password-rules__lead,
.ts-password-rules__tip {
  color: #767676;
  margin: 4px 0 0;
}

/* font-size and line-height are inherited explicitly: Foundation sizes bare
 * ul/li elements itself, which made the rules a size larger than the notes
 * around them. */
.ts-password-rules__list {
  font-size: inherit;
  line-height: inherit;
  list-style: none;
  margin: 0;
  padding: 0;
}

.ts-password-rules__list li {
  font-size: inherit;
  line-height: inherit;
  margin: 0;
  padding-left: 1.4em;
  position: relative;
  transition: color 150ms ease;
}

.ts-password-rules__list li::before {
  color: #999;
  content: "\2022";
  left: 0.35em;
  position: absolute;
}

.ts-password-rules__list li[data-met="true"] {
  color: #2e7d4f;
}

.ts-password-rules__list li[data-met="true"]::before {
  color: #2e7d4f;
  content: "\2713";
  left: 0.1em;
}

.ts-password-rules__list li[data-met="false"] {
  color: #c0392b;
}

.ts-password-rules__list li[data-met="false"]::before {
  color: #c0392b;
  content: "\2715";
  left: 0.15em;
}

/* TSU-355: the show/hide toggle, an eye button laid over the right end of a
 * password field. The wrapper is the field's parent (PasswordFormHelper); the
 * Stimulus controller sets the button's top and height from the input's own
 * box, and the height here is only the fallback until it does. Foundation
 * styles bare <button> elements as big orange blocks, hence every reset. */
.ts-password-field {
  position: relative;
}

.ts-password-field > input {
  padding-right: 2.6rem;
}

.ts-password-field__toggle {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: #767676;
  cursor: pointer;
  display: flex;
  height: 2.3rem;
  justify-content: center;
  line-height: 1;
  margin: 0;
  min-width: 0;
  padding: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: none;
  width: 2.4rem;
}

.ts-password-field__toggle:hover,
.ts-password-field__toggle:focus {
  background: none;
  color: #333;
}

.ts-password-field__toggle:focus-visible {
  outline: 2px solid #e08b00;
  outline-offset: -2px;
}

.ts-password-field__toggle svg {
  display: block;
  height: 18px;
  width: 18px;
}

.ts-password-field__toggle[aria-pressed="true"] .ts-password-field__eye,
.ts-password-field__toggle[aria-pressed="false"] .ts-password-field__eye-off {
  display: none;
}

/* The legacy dialogs park jQuery-validate's tick or cross in the same corner
 * (modals.sass). Move it left of the eye, and make room for both. Selectors
 * match that file's specificity; this sheet is linked after it, so it wins. */
form .ts-password-field > .fa-check,
form .ts-password-field > .fa-times {
  right: 2.6rem;
}

form .ts-password-field > input:not([type=submit]).error,
form .ts-password-field > input:not([type=submit]).valid {
  padding-right: 4.6rem;
}
