/* Fields (brandbook "Inputs and selection controls", f1-f8), emitted by
   templates/form/. A field is the label, the control, then the error or the
   hint. Inputs 46 px tall, 4 px corners, field border; focus is a navy border
   with a navy-surface halo; an error adds a red border and a message with an
   icon, so it does not rely on colour. */

/* A form stacks its fields 16 px apart, and so does a wrapper inside it.
   :where() keeps this at zero specificity: any component class (the action
   row, an area's layout) overrides it. */
:where(.mm-form, .mm-form .form-wrapper, .mm-fieldset__body) {
  display: flex;
  flex-direction: column;
  gap: var(--mm-space-4);
}

.mm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.mm-label {
  font-size: 15px;
  font-weight: 600;
}

/* A required field's label, checkbox label or legend ends in a red asterisk
   (core's .form-required). The control carries `required` for assistive
   technology, so the asterisk has empty alternative text. */
.form-required::after {
  content: "*";
  content: "*" / "";
  margin-left: 2px;
  color: var(--mm-danger);
}

.mm-input {
  width: 100%;
  height: 46px;
  margin: 0;
  padding: 0 var(--mm-space-3);
  border: 1px solid var(--mm-field);
  border-radius: var(--mm-radius-field);
  background: var(--mm-surface);
  color: var(--mm-text);
  font: 400 16px var(--mm-sans);
}

/* base.css gives every :focus-visible a 4 px radius; the field keeps its own
   and draws the brandbook's halo instead of the focus ring. :focus, not
   :focus-visible: a text field shows focus on click as well. */
.mm-input:focus,
.mm-input:focus-visible {
  outline: none;
  border-color: var(--mm-primary);
  border-radius: var(--mm-radius-field);
  box-shadow: 0 0 0 1px var(--mm-primary), 0 0 0 4px var(--mm-primary-surface);
}

.mm-input.is-invalid {
  border-color: var(--mm-danger);
  box-shadow: inset 0 0 0 1px var(--mm-danger);
}

.mm-input.is-invalid:focus {
  border-color: var(--mm-danger);
  box-shadow: inset 0 0 0 1px var(--mm-danger), 0 0 0 4px var(--mm-danger-surface);
}

.mm-input--amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mm-input--multiline {
  height: auto;
  min-height: 120px;
  padding: 10px var(--mm-space-3);
  line-height: 1.5;
  resize: vertical;
}

/* An autocomplete field (the recipient's contact suggestions): core's idle
   throbber ring reads as a stray glyph in the field, so it shows only while
   suggestions load (core's .ui-autocomplete-loading). One class above
   core's autocomplete-loading.module.css. */
.js input.mm-input.form-autocomplete:not(.ui-autocomplete-loading) {
  background-image: none;
}

.mm-input[disabled] {
  background: var(--mm-disabled);
  color: var(--mm-disabled-text);
  border-color: var(--mm-line);
}

select.mm-input[multiple] {
  height: auto;
  padding: var(--mm-space-1);
}

.mm-select {
  position: relative;
}

.mm-select select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--mm-space-10);
}

.mm-select svg {
  position: absolute;
  top: 13px;
  right: var(--mm-space-3);
  width: 20px;
  height: 20px;
  color: var(--mm-muted);
  pointer-events: none;
}

.mm-hint {
  font-size: 14px;
  line-height: 1.45;
  color: var(--mm-muted);
}

.mm-hint a {
  color: var(--mm-primary);
  text-decoration-color: var(--mm-underline);
  text-underline-offset: 3px;
}

.mm-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--mm-danger);
}

.mm-error svg {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

/* A field prefix or suffix (a unit, a currency) sits on the control's line. */
.mm-field__affix {
  display: flex;
  align-items: center;
  gap: var(--mm-space-2);
}

.mm-field__affix > .mm-input {
  flex: 1 1 auto;
  min-width: 0;
}

/* Checkbox and radio: the native control, then its label, in one row. */
.mm-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 32px;
  padding-top: var(--mm-space-1);
  font-size: 16px;
  line-height: 1.35;
}

.mm-check input {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--mm-primary);
}

.mm-check__label {
  min-width: 0;
}

/* Under a checkbox the hint and the error line up with its label. */
.mm-field--check > .mm-hint,
.mm-field--check > .mm-error {
  padding-left: 30px;
}

/* A fieldset is a field: its legend is the label, its options follow. */
.mm-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.mm-fieldset__legend {
  float: left;
  width: 100%;
  margin-bottom: 6px;
  padding: 0;
}

.mm-fieldset__legend + * {
  clear: left;
}

:where(.mm-fieldset__body) {
  gap: 6px;
}

/* Details: a bordered group that opens. */
.mm-details {
  background: var(--mm-surface);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius-card);
}

.mm-details__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--mm-space-3);
  min-height: 48px;
  padding: var(--mm-space-3) var(--mm-space-4);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.mm-details__summary::-webkit-details-marker {
  display: none;
}

.mm-details__summary:focus-visible {
  border-radius: var(--mm-radius-card);
}

.mm-details__icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  color: var(--mm-muted);
  transition: transform .12s;
}

.mm-details[open] > .mm-details__summary .mm-details__icon {
  transform: rotate(180deg);
}

:where(.mm-details__body) {
  display: flex;
  flex-direction: column;
  gap: var(--mm-space-4);
  padding: 0 var(--mm-space-4) var(--mm-space-4);
}

.mm-details:not([open]) > .mm-details__body {
  display: none;
}
