/* Fluent Forms' markup in the site's form look (site/src/styles/form.css). The fields already carry
   the site's own classes where Fluent Forms allows them (.field, .choices, .form__row, .form__send,
   .btn), so form.css does most of the work; this fills the gaps Fluent Forms' wrappers leave.
   Fluent Forms' own stylesheets are switched off (inc/forms.php). Tokens only. */

/* The form, as .form: one column with the site's spacing between fields */
.frm-fluent-form fieldset {
  display: grid;
  gap: var(--primitive-spacing-6);
  min-width: 0;
}

.frm-fluent-form .ff-el-group {
  margin: 0;
}

/* Two fields side by side, as .form__row */
.frm-fluent-form .ff-t-cell {
  min-width: 0;
}

/* The audit form's phone row has an empty second column; on phones it would add a gap */
.frm-fluent-form .ff-t-cell:empty {
  display: none;
}

/* The label's wrapper steps aside, so the label sits in the field's grid as on the site */
.frm-fluent-form .ff-el-input--label {
  display: contents;
}

/* Label, hint and box with the site's small gap between them */
.frm-fluent-form .field .ff-el-input--content {
  display: grid;
  gap: var(--primitive-spacing-2);
}

/* The hint, as .field__hint */
.frm-fluent-form .ff-el-help-message {
  margin-top: calc(-1 * var(--primitive-spacing-1));
  font-size: var(--primitive-fontSize-small);
  color: var(--muted);
}

/* A field with an error, as .field--error and .field__error */
.frm-fluent-form .ff-el-is-error :is(input, textarea) {
  border-color: var(--error);
  border-width: 2px;
}

.frm-fluent-form .ff-el-is-error .error,
.frm-fluent-form .text-danger {
  font-size: var(--primitive-fontSize-small);
  font-weight: 600;
  color: var(--error);
}

/* The topic choices as pills, as .choices and .choice: the selected one fills with juice. The site's
   question is a <legend>, which sits outside the grid's gap, so only the gap spaces these. */
.frm-fluent-form .choices .ff-el-input--content {
  display: flex;
  flex-wrap: wrap;
  gap: var(--primitive-spacing-2);
}

.frm-fluent-form .ff-el-form-check {
  position: relative;
}

.frm-fluent-form .choices .ff-el-form-check-label {
  display: block;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.frm-fluent-form .ff-el-form-check-input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.frm-fluent-form .ff-el-form-check-label span {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
  padding: 0 var(--primitive-spacing-4);
  border: 1.5px solid var(--field-border);
  border-radius: var(--primitive-radius-full);
  font-size: var(--primitive-fontSize-sm);
  font-weight: 600;
  background-color: var(--surface);
  transition:
    background-color var(--primitive-duration-fast) ease,
    border-color var(--primitive-duration-fast) ease;
}

.frm-fluent-form .ff-el-form-check-input:hover + span {
  border-color: var(--text);
}

.frm-fluent-form .ff-el-form-check-input:checked + span {
  border-color: var(--text);
  background-color: var(--ground-juice);
  color: var(--ground-on-juice);
}

.frm-fluent-form .ff-el-form-check-input:focus-visible + span {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: var(--focus-offset);
}

/* While it sends: the button waits, as the site's does */
.frm-fluent-form .ff-btn-submit[disabled],
.frm-fluent-form.ff_submitting .ff-btn-submit {
  cursor: progress;
  opacity: 0.75;
}

/* Fluent Forms' own message if a send fails on the server */
.ff-errors-in-stack {
  margin-top: var(--primitive-spacing-4);
  padding: var(--primitive-spacing-5);
  border: 2px solid var(--error);
  border-radius: var(--primitive-radius-md);
  background-color: var(--surface);
  color: var(--error);
  font-weight: 600;
}

.ff-errors-in-stack:empty {
  display: none;
}
