/* ===========================================================================
   Contact Form 7
   ---------------------------------------------------------------------------
   The generated forms are wrapped in the theme's own .fbh-form markup, so most
   styling already applies. What is left is CF7's own wrappers, which are inline
   by default, and the states it adds on validation.
   =========================================================================== */

.fbh-form .wpcf7-form { margin: 0; }

/* CF7 wraps every control in an inline span; the fields need to be block for
   the width and the grid to behave. */
.fbh-form .wpcf7-form-control-wrap { display: block; }

.fbh-form .wpcf7-form-control:not([type="checkbox"]):not([type="radio"]):not([type="submit"]) { width: 100%; }

.fbh-form input[type="file"].wpcf7-form-control {
  padding: 0.6rem;
  background: var(--fbh-surface);
  border: 1px dashed var(--fbh-line-strong);
  border-radius: var(--fbh-radius);
}

/* -- Checkbox and radio sets ---------------------------------------------- */

.fbh-form .wpcf7-checkbox,
.fbh-form .wpcf7-radio { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }

.fbh-form .wpcf7-list-item { margin: 0; }

.fbh-form .wpcf7-list-item label {
  display: inline-flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: var(--fbh-step--1);
  cursor: pointer;
}

.fbh-form .wpcf7-list-item-label { line-height: 1.4; }

/* The topic chooser keeps the chip treatment the hand-built form had. */
.fbh-topics .wpcf7-radio { gap: 0.4rem; }

.fbh-topics .wpcf7-list-item label {
  padding: 0.45rem 1rem;
  border: 1px solid var(--fbh-line-strong);
  border-radius: var(--fbh-radius-pill);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fbh-topics .wpcf7-list-item input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.fbh-topics .wpcf7-list-item label:has(input:checked) {
  background: var(--fbh-ink);
  color: var(--fbh-ground);
  border-color: var(--fbh-ink);
}

.fbh-topics .wpcf7-list-item label:has(input:focus-visible) {
  outline: 3px solid var(--fbh-focus);
  outline-offset: 2px;
}

/* -- Validation and response ---------------------------------------------- */

.fbh-form .wpcf7-not-valid-tip {
  display: block;
  margin-top: 0.3rem;
  font-size: var(--fbh-step--1);
  font-weight: 600;
  color: var(--fbh-brand);
}

.fbh-form .wpcf7-form-control.wpcf7-not-valid {
  border-color: var(--fbh-brand);
  box-shadow: 0 0 0 1px var(--fbh-brand);
}

.fbh-form .wpcf7-response-output {
  margin: var(--fbh-space-m) 0 0;
  padding: var(--fbh-space-s) var(--fbh-space-m);
  border: 0;
  border-left: 3px solid var(--fbh-line-strong);
  border-radius: var(--fbh-radius);
  background: var(--fbh-ground-2);
  font-size: var(--fbh-step--1);
}

.fbh-form .sent .wpcf7-response-output { border-left-color: var(--fbh-accent-2); }

.fbh-form .invalid .wpcf7-response-output,
.fbh-form .unaccepted .wpcf7-response-output,
.fbh-form .failed .wpcf7-response-output,
.fbh-form .spam .wpcf7-response-output { border-left-color: var(--fbh-brand); }

/* -- Submit --------------------------------------------------------------- */

.fbh-form .wpcf7-submit { width: auto; }

.fbh-form .wpcf7-spinner {
  margin: 0 0 0 0.75rem;
  background-color: var(--fbh-ink-3);
}

/* The field and its button share a line. "!important" is not decoration
   here: the Contact Form 7 Multi-Step plugin ships
     .wpcf7-form { position: relative; overflow: hidden; display: block !important }
   in cf7mls.css, which beat this rule and dropped the button onto its own
   line under a full-width field, left aligned and half the width of the box
   above it. An important declaration can only be answered by another one. */
.fbh-form.fbh-form--newsletter .wpcf7-form,
.fbh-newsletter .wpcf7-form {
  display: flex !important;
  flex-wrap: wrap;
  gap: var(--fbh-space-2xs);
  /* stretch, so the button is exactly as tall as the field beside it rather
     than two pixels shorter, which is what flex-start gave: the input carries
     a border the button's own min-height does not account for. */
  align-items: stretch;
}

.fbh-newsletter .wpcf7-form .fbh-form__grid { flex: 1 1 10rem; min-width: 0; display: block; }
.fbh-newsletter .wpcf7-form .fbh-form__submit { margin: 0; }
.fbh-newsletter .wpcf7-response-output { flex: 0 0 100%; }
/* The spinner is a 24px dot and must not be stretched to the row's height. */
.fbh-newsletter .wpcf7-form .wpcf7-spinner { align-self: center; }

/* Once the pair no longer fits on one line, the button takes the full width
   under the field instead of sitting stubby and left aligned, which is the
   shape the broken desktop layout had. */
@media (max-width: 30rem) {
  .fbh-newsletter .wpcf7-form .fbh-form__submit { width: 100%; }
}
