/**
 * @file
 * Main form and form item styles.
 */

@import "../base/media-queries.pcss.css";

::placeholder {
  color: var(--color--gray-60);
}

/**
 * General form item.
 */
.form-item {
  margin-block: var(--sp1);
}

.form-item__label--multiple-value-form {
  margin-block: 0;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

/**
 * When a table row or a container-inline has a single form item, prevent it
 * from adding unnecessary extra spacing.
 * If it has multiple form items, allow spacing between them, overriding core.
 */
tr .form-item,
.container-inline .form-item {
  margin-block: var(--sp0-5);
}

/**
 * Form element label.
 */
.form-item__label {
  display: block;
  margin-block: var(--sp0-5);
}

.container-inline .form-item__label {
  margin-inline-end: 1em;
}

.form-item__label--multiple-value-form {
  margin-block: 0;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.form-item__label[for] {
  cursor: pointer;
}

.form-item__label.option {
  display: inline;
  font-weight: normal;
}

/* Label states. */
.form-item__label.is-disabled {
  cursor: default;
  color: var(--color--gray-70);
}

/* Form required star icon */
.form-item__label.form-required::after,
.fieldset__label.form-required::after,
.required-mark::after {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-inline: 0.3em;
  content: "";
  vertical-align: text-top;
  /* Use a background image to prevent screen readers from announcing the text. */
  background-image: url("data:image/svg+xml,%3Csvg height='16' width='16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m0 7.562 1.114-3.438c2.565.906 4.43 1.688 5.59 2.35-.306-2.921-.467-4.93-.484-6.027h3.511c-.05 1.597-.234 3.6-.558 6.003 1.664-.838 3.566-1.613 5.714-2.325l1.113 3.437c-2.05.678-4.06 1.131-6.028 1.356.984.856 2.372 2.381 4.166 4.575l-2.906 2.059c-.935-1.274-2.041-3.009-3.316-5.206-1.194 2.275-2.244 4.013-3.147 5.206l-2.856-2.059c1.872-2.307 3.211-3.832 4.017-4.575-2.081-.402-4.058-.856-5.93-1.356' fill='%232494DB'/%3E%3C/svg%3E%0A");
  background-repeat: no-repeat;
  background-size: 0.5rem 0.5rem;

  @media screen and (-ms-high-contrast: active) {
    background-image: url("data:image/svg+xml,%3Csvg height='16' width='16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m0 7.562 1.114-3.438c2.565.906 4.43 1.688 5.59 2.35-.306-2.921-.467-4.93-.484-6.027h3.511c-.05 1.597-.234 3.6-.558 6.003 1.664-.838 3.566-1.613 5.714-2.325l1.113 3.437c-2.05.678-4.06 1.131-6.028 1.356.984.856 2.372 2.381 4.166 4.575l-2.906 2.059c-.935-1.274-2.041-3.009-3.316-5.206-1.194 2.275-2.244 4.013-3.147 5.206l-2.856-2.059c1.872-2.307 3.211-3.832 4.017-4.575-2.081-.402-4.058-.856-5.93-1.356' fill='%23ffffff'/%3E%3C/svg%3E%0A");
  }
}

/**
 * Form item description.
 */
.form-item__description {
  margin-block: var(--sp0-5);
  max-width: 60ch;
  font-size: var(--font-size-s);
  line-height: var(--line-height-s);
}

.field-multiple-table + .form-item__description {
  margin-block-start: 0;
}

/**
 * Error message (Inline form errors).
 */
.form-item--error-message {
  margin-block: var(--sp0-5);
  padding-inline-start: var(--sp1-5);
  color: var(--color--red);
  background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23E33F1E' d='M9 0C4.03125 0 0 4.03125 0 9C0 13.9688 4.03125 18 9 18C13.9687 18 18 13.9688 18 9C18 4.03125 13.9687 0 9 0ZM10.5 14.6133C10.5 14.8242 10.3359 15 10.1367 15H7.88672C7.67578 15 7.5 14.8242 7.5 14.6133V12.3867C7.5 12.1758 7.67578 12 7.88672 12H10.1367C10.3359 12 10.5 12.1758 10.5 12.3867V14.6133ZM10.4766 10.582C10.4648 10.7461 10.2891 10.875 10.0781 10.875H7.91016C7.6875 10.875 7.51172 10.7461 7.51172 10.582L7.3125 3.30469C7.3125 3.22266 7.34766 3.14063 7.42969 3.09375C7.5 3.03516 7.60547 3 7.71094 3H10.2891C10.3945 3 10.5 3.03516 10.5703 3.09375C10.6523 3.14063 10.6875 3.22266 10.6875 3.30469L10.4766 10.582Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left top; /* LTR */
  background-size: var(--sp1) var(--sp1);
  font-size: var(--font-size-s);
  line-height: var(--line-height-s);

  @media screen and (-ms-high-contrast: active) {
    background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23ffffff' d='M9 0C4.03125 0 0 4.03125 0 9C0 13.9688 4.03125 18 9 18C13.9687 18 18 13.9688 18 9C18 4.03125 13.9687 0 9 0ZM10.5 14.6133C10.5 14.8242 10.3359 15 10.1367 15H7.88672C7.67578 15 7.5 14.8242 7.5 14.6133V12.3867C7.5 12.1758 7.67578 12 7.88672 12H10.1367C10.3359 12 10.5 12.1758 10.5 12.3867V14.6133ZM10.4766 10.582C10.4648 10.7461 10.2891 10.875 10.0781 10.875H7.91016C7.6875 10.875 7.51172 10.7461 7.51172 10.582L7.3125 3.30469C7.3125 3.22266 7.34766 3.14063 7.42969 3.09375C7.5 3.03516 7.60547 3 7.71094 3H10.2891C10.3945 3 10.5 3.03516 10.5703 3.09375C10.6523 3.14063 10.6875 3.22266 10.6875 3.30469L10.4766 10.582Z'/%3E%3C/svg%3E");
  }
}

[dir="rtl"] .form-item--error-message {
  background-position: right top;
}

/**
 * Form actions.
 */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-block: var(--sp0-5);
}

.form-actions .button,
.form-actions .action-link {
  margin-block: var(--sp0-5);
}

.form-actions .ajax-progress--throbber {
  align-self: center;
}

/**
 * Custom label placement for editor filter format select.
 */
.form-item--editor-format {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  max-width: 100%;
}

.form-item--editor-format .form-item__label,
.form-item--editor-format .form-item__prefix,
.form-item--editor-format .form-item__suffix,
.form-item--editor-format .form-element--editor-format {
  min-width: 1px;
}

.form-item--editor-format .form-item__label,
.form-item--editor-format .form-item__prefix,
.form-item--editor-format .form-item__suffix {
  margin-inline-end: var(--sp0-5);
}

.form-item--editor-format .form-item__description,
.form-item--editor-format .form-item--error-message {
  flex: 0 1 100%;
  min-width: 1px;
}

/**
 * Inline forms.
 */
.form--inline {
  & > * {
    display: inline-block;
    margin-top: var(--sp0-5);
    margin-bottom: 0;
    vertical-align: top; /* Ensure proper alignment if description is present. */
  }

  & .form-item__label {
    margin: 0;
  }

  & .form-actions {
    margin-top: var(--sp1-5);
  }
}

.layout-builder-form {
  & .form-actions {
    align-items: center;
  }
}
