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

/**
 * Password confirm widget styles.
 */
.password-confirm {
  width: 100%;
  max-inline-size: var(--admin-max-line-length);

  & 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(--admin-duration-fast) ease-in-out,
      margin var(--admin-duration-fast) 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(--admin-color-error);
  --password-strength-bar-weak-border-color: var(--admin-color-error);
  /* Fair */
  --password-strength-bar-fair-bg-color: #ffd23f;
  --password-strength-bar-fair-border-color: #977405;
  /* Good */
  --password-strength-bar-good-bg-color: #26a769;
  --password-strength-bar-good-border-color: #26a769;
  /* Strong */
  --password-strength-bar-strong-bg-color: #26a769;
  --password-strength-bar-strong-border-color: #26a769;

  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(--admin-color-text-soft);
  font-size: var(--progress-bar-description-font-size);
  line-height: var(--admin-space-m);

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

.password-strength__text {
  color: var(--admin-color-text-loud);
  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(--admin-space-xs);
  padding: var(--admin-space-m);
  color: var(--admin-color-text-soft);
  border: 1px solid var(--admin-color-border);
  border-radius: var(--admin-radius-2xs);
  background-color: transparent;
  box-shadow: var(--details-box-shadow);
  font-size: var(--progress-bar-description-font-size);
}

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

.subfield-option {
  border: 1px solid var(--admin-color-border);
  border-radius: var(--admin-radius-m);
}
