/**
 * @file
 * Visual styles for the Password widgets.
 */

/**
 * Password confirm widget styles.
 */
.password-confirm {
  max-inline-size: 25rem;

  & input {
    width: 100%;
  }
}

.password-confirm__password {
  margin-block-end: 0;
}

.password-confirm__confirm {
  margin-block-end: 0;

  .js & {
    max-height: 10rem;
    transition:
      max-height var(--speed-transition) ease-in-out,
      margin var(--speed-transition) ease-in-out;
  }
}

@media screen and (prefers-reduced-motion: reduce) {
  .js .password-confirm__confirm {
    transition: none;
  }
}

/* Password confirm widget states. */
.js .is-initial:not(.form-item--error) .form-item__description {
  margin-block-start: 0;
}
.js .is-initial.is-password-empty.is-confirm-empty:not(.form-item--error) .password-confirm__confirm {
  display: none;
  max-block-size: 0;
  margin-block-start: 0;
}

/**
 * Password strength
 *
 * Description and strength indicator for the main input.
 */
.password-strength {
  /* Weak */
  --password-strength-bar-weak-bg-color: var(--color-maximumred);
  --password-strength-bar-weak-border-color: var(--color-maximumred);
  /* Fair */
  --password-strength-bar-fair-bg-color: var(--color-sunglow);
  --password-strength-bar-fair-border-color: #977405;
  /* Good */
  --password-strength-bar-good-bg-color: var(--color-lightninggreen);
  --password-strength-bar-good-border-color: var(--color-lightninggreen);
  /* Strong */
  --password-strength-bar-strong-bg-color: var(--color-lightninggreen);
  --password-strength-bar-strong-border-color: var(--color-lightninggreen);

  margin-block: var(--progress-bar-spacing-size);
}

.password-strength__track {
  height: var(--progress-bar-small-size);
  margin-block: var(--progress-bar-spacing-size);
  border: var(--progress-bar-border-size) solid var(--progress-track-border-color);
  border-radius: var(--progress-bar-small-size-radius);
  background-color: var(--progress-track-bg-color);
}

.password-strength__track::after {
  display: table;
  clear: both;
  content: "";
}

/* Password strength states */
.password-strength__bar {
  min-inline-size: var(--progress-bar-small-size);
  height: var(--progress-bar-small-size);
  margin: calc(var(--progress-bar-border-size) * -1);
  transition: var(--progress-bar-transition);
  border: var(--progress-bar-border-size) solid transparent;
  border-radius: var(--progress-bar-small-size-radius);
  background-color: transparent;

  &.is-weak {
    border-color: var(--password-strength-bar-weak-border-color);
    background-color: var(--password-strength-bar-weak-bg-color);
  }

  &.is-fair {
    border-color: var(--password-strength-bar-fair-border-color);
    background-color: var(--password-strength-bar-fair-bg-color);
  }

  &.is-good {
    border-color: var(--password-strength-bar-good-border-color);
    background-color: var(--password-strength-bar-good-bg-color);
  }

  &.is-strong {
    border-color: var(--password-strength-bar-strong-border-color);
    background-color: var(--password-strength-bar-strong-bg-color);
  }
}

@media screen and (prefers-reduced-motion: reduce) {
  .password-strength__bar {
    transition: none;
  }
}

.password-strength__title {
  overflow: hidden;
  margin-block: var(--progress-bar-spacing-size);
  color: var(--progress-bar-description-color);
  font-size: var(--progress-bar-description-font-size);
  line-height: var(--space-m);

  .is-initial.is-password-empty & {
    margin: 0;
    line-height: 0;
  }
}

.password-strength__text {
  color: var(--progress-bar-label-color);
  font-weight: bold;
}

@media (forced-colors: active) {
  .password-strength__bar {
    &.is-weak,
    &.is-fair,
    &.is-good,
    &.is-strong {
      background-color: canvastext;
    }
  }

  .is-initial .password-strength__bar {
    border-color: transparent;
    background-color: transparent;
  }
}

/**
 * Password match message.
 *
 * This is the description-like message on the bottom of the password confirm
 * input.
 */
.password-match-message {
  margin-block: var(--progress-bar-spacing-size);
  color: var(--progress-bar-description-color);
  font-size: var(--progress-bar-description-font-size);

  .is-confirm-empty & {
    visibility: hidden;
  }
}

.password-match-message__text {
  color: var(--progress-bar-label-color);
  font-weight: bold;
}

/**
 * Password suggestions.
 *
 * Tips for improving the password.
 */
.password-suggestions {
  margin-block: var(--progress-bar-spacing-size) var(--space-xs);
  padding: var(--space-m);
  color: var(--progress-bar-description-color);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--base-border-radius);
  background-color: var(--color-white);
  box-shadow: var(--details-box-shadow);
  font-size: var(--progress-bar-description-font-size);
}

.password-suggestions__tips {
  margin-block-start: var(--space-xs);
  margin-inline-start: var(--space-l);
}
