/* ===================================================================
   MIFA Forms

   Every colour and size below is a var() with a fallback. Drop the plugin
   into a theme that defines the MIFA tokens and it adopts that theme's
   palette and type; drop it into anything else and the fallbacks keep it
   presentable. Nothing here hard-codes a brand.
   =================================================================== */

.mifa-form,
.mifa-sent {
  --mf-ink:      var(--c-ink,        var(--e-global-color-text, #1E1F21));
  --mf-body:     var(--c-body,       #6B6E76);
  --mf-muted:    var(--c-muted,      #7D818A);
  --mf-line:     var(--c-field-line, #B7B9BE);
  --mf-line-soft:var(--c-line,       #DDDEE1);
  /* The site's own colour: the setting first, then a MIFA theme's token, then
     Elementor's primary. The last value is a plain dark - never somebody
     else's brand. */
  --mf-accent:   var(--mifa-accent, var(--c-accent, var(--e-global-color-primary, #1E1F21)));
  --mf-deep:     var(--mifa-accent, var(--c-accent-deep, var(--mf-accent)));
  --mf-radius:   var(--mifa-radius, 2px);
  --mf-surface:  var(--c-surface,    #FCFCFC);

  /* Taken from the designer's screenshots rather than the Figma file — the
     component set holding the real values could not be read. Change these
     two and every error and success state on the site follows. */
  --mf-error:    #B3261E;
  --mf-ok:       #2E9E6B;

  /* No font of its own: without a MIFA theme the form is set in whatever
     the page around it uses. */
  --mf-display:  var(--font-display, inherit);

  font-family: var(--font-body, inherit);
}

/* --- fields ------------------------------------------------------- */

/* Two columns so a field can sit at half width; a full-width one spans both.
   Below 560 everything is one column - two boxes side by side on a phone are
   too narrow to type in. */
.mifa-form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.mifa-field--full { grid-column: 1 / -1; }

@media (max-width: 560px) {
  .mifa-form__grid { grid-template-columns: 1fr; }
  .mifa-field--half { grid-column: 1 / -1; }
}

.mifa-field__label {
  display: block;
  margin: 0 0 4px;
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
  color: var(--mf-ink);
}

.mifa-field__control { position: relative; }

.mifa-field input,
.mifa-field textarea {
  /* not every theme resets this; without it the padding pushes the field
     past the edge of a narrow screen */
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: .5px solid var(--mf-line);
  border-radius: var(--mf-radius, 2px);
  background: transparent;
  color: var(--mf-ink);
  font-family: inherit;
  font-size: 12px;
  line-height: 18px;
  transition: border-color .25s ease, box-shadow .25s ease;
}
.mifa-field textarea {
  height: 100px;
  padding: 11px 14px;
  border-color: var(--mf-line-soft);
  resize: vertical;
  /* A textarea is inline-block by default, so it sits on a text baseline and
     leaves ~6px of descender space underneath. That gap is invisible until
     something below it has to land on an exact number. */
  display: block;
}
.mifa-field input::placeholder { color: var(--mf-body); font-weight: 500; }
.mifa-field textarea::placeholder { color: var(--mf-body); }

.mifa-field input:focus,
.mifa-field textarea:focus {
  outline: none;
  border-color: var(--mf-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mf-accent) 14%, transparent);
}

/* the warning mark lives inside the field, and only appears when it is wrong */
.mifa-field__mark {
  position: absolute;
  top: 10px; inset-inline-end: 12px;
  z-index: 1;
  display: none;
  color: var(--mf-error);
  pointer-events: none;
}
.mifa-field__hint {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin: 4px 0 0;
  color: var(--mf-error);
  font-size: 12px;
  line-height: 18px;
}
.mifa-field__hint[hidden] { display: none; }
.mifa-field__hint-icon { flex: 0 0 auto; margin-top: 1px; }

.mifa-field.is-error input,
.mifa-field.is-error textarea {
  border-color: var(--mf-error);
  padding-inline-end: 40px;
}
.mifa-field.is-error textarea { padding-inline-end: 40px; }
.mifa-field.is-error .mifa-field__mark { display: block; }
.mifa-field.is-error .mifa-field__choices ~ .mifa-field__mark,
.mifa-field.is-error .mifa-choice--single ~ .mifa-field__mark { display: none; }
.mifa-field.is-error input:focus,
.mifa-field.is-error textarea:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mf-error) 14%, transparent);
}

/* --- dropdowns and choices ---------------------------------------- */
.mifa-field select {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  padding-inline-end: 34px;
  border: .5px solid var(--mf-line);
  border-radius: var(--mf-radius, 2px);
  background: transparent;
  color: var(--mf-ink);
  font-family: inherit;
  font-size: 12px;
  line-height: 18px;
  appearance: none;
  /* the caret is drawn rather than fetched, so there is no extra request and
     it inherits the field's colour */
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
/* on a right-to-left site the caret sits at the left end */
.mifa-field select:dir(rtl) {
  background-position: 13px 18px, 18px 18px;
}
.mifa-field select:focus {
  outline: none;
  border-color: var(--mf-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mf-accent) 14%, transparent);
}
.mifa-field.is-error select { border-color: var(--mf-error); }

.mifa-field__choices { display: flex; flex-wrap: wrap; gap: 8px 20px; padding-top: 8px; }
.mifa-choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--mf-ink);
  font-size: 14px;
  line-height: 22px;
  cursor: pointer;
}
/* `.mifa-field input` above sizes text boxes — 100% wide, 40px tall, padded,
   bordered — and it reached checkboxes and radios too, stretching each one
   across the row and pushing its label to the far edge. A tick box is its own
   size. (Found building steps in 1.5; no live form had used a choice yet.) */
.mifa-choice input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  accent-color: var(--mf-accent);
}
.mifa-choice--single { padding-top: 4px; }

/* --- submit ------------------------------------------------------- */
.mifa-form__submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  margin-top: 24px;
  padding: 0 24px;
  border: 0;
  border-radius: var(--mf-radius, 2px);
  background: var(--mf-deep);
  color: var(--mf-surface);
  font-family: inherit;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .25s ease, transform .25s ease;
}
.mifa-form__submit:hover { opacity: .92; transform: translateY(-1px); }
.mifa-form__submit[disabled] { opacity: .6; cursor: default; transform: none; }

.mifa-form__note {
  margin: 8px 0 0;
  text-align: center;
  color: var(--mf-muted);
  font-size: 12px;
  line-height: 18px;
}
.mifa-form__notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: var(--mf-radius, 2px);
  background: color-mix(in srgb, var(--mf-error) 8%, transparent);
  color: var(--mf-error);
  font-size: 14px;
  line-height: 22px;
}

/* Off-screen rather than display:none — some bots skip hidden inputs, and a
   field they skip catches nothing. */
.mifa-form__trap {
  position: absolute;
  /* logical, not `left`: on a right-to-left page a box far to the left gives
     the whole page a 10,000px sideways scroll */
  inset-inline-start: -9999px;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* --- inline layout ------------------------------------------------
   One row: the fields, then the button beside them. Used for a single
   email box. The labels stay in the markup and are only moved out of
   sight - a field with no label at all is unusable with a screen reader,
   and the placeholder disappears the moment you start typing. */
.mifa-form--inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}
.mifa-form--inline .mifa-form__grid {
  display: block;
  flex: 1 1 195px;
  gap: 0;
}
.mifa-form--inline .mifa-field__label {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.mifa-form--inline .mifa-form__submit {
  flex: 0 0 auto;
  width: auto;
  min-width: 189px;
  margin-top: 0;
  font-size: 14px;
  line-height: 22px;
}
.mifa-form--inline .mifa-form__note,
.mifa-form--inline .mifa-form__notice { flex: 1 0 100%; }

@media (max-width: 520px) {
  .mifa-form--inline .mifa-form__grid,
  .mifa-form--inline .mifa-form__submit { flex: 1 0 100%; }
}

/* --- the panel that replaces the form ----------------------------- */
.mifa-sent { text-align: center; }

.mifa-sent__check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: 1px solid color-mix(in srgb, var(--mf-ok) 40%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--mf-ok) 10%, transparent);
  color: var(--mf-ok);
}

.mifa-sent__title {
  margin: 16px 0 0;
  font-family: var(--mf-display);
  font-size: 28px;
  line-height: 42px;
  font-weight: 700;
  color: var(--mf-ink);
}
.mifa-sent__text {
  max-width: 34em;
  margin: 4px auto 0;
  color: var(--mf-body);
  font-size: 14px;
  line-height: 22px;
}

.mifa-sent__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}
.mifa-sent__primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 174px;
  height: 40px;
  padding: 0 24px;
  border-radius: var(--mf-radius, 2px);
  background: var(--mf-deep);
  color: var(--mf-surface);
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
  text-decoration: none;
}
.mifa-sent__primary:hover { opacity: .92; }
.mifa-sent__secondary {
  color: var(--mf-ink);
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
  text-decoration: none;
}
.mifa-sent__secondary:hover { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .mifa-form__submit,
  .mifa-field input,
  .mifa-field textarea { transition: none; }
  .mifa-form__submit:hover { transform: none; }
}

/* --- steps -------------------------------------------------------- */

/* A theme's `fieldset {display:block}` or `button {display:inline-flex}`
   would beat the browser's own [hidden] rule and show a step or a Back
   button that should be gone. */
.mifa-form--steps [hidden] { display: none !important; }

.mifa-step {
  min-width: 0;          /* fieldsets refuse to shrink below their content otherwise */
  margin: 0;
  padding: 0;
  border: 0;
}

/* Without steps.js every step shows, one under another. */
.mifa-step + .mifa-step { margin-top: 40px; }
.mifa-form--steps.is-stepped .mifa-step + .mifa-step { margin-top: 0; }

.mifa-step__title {
  margin: 0 0 24px;
  font-family: var(--mf-display);
  font-size: 28px;
  line-height: 36px;
  font-weight: 400;
  color: var(--mf-ink);
}
.mifa-step__title:focus { outline: none; }   /* focused by script, not by a person */

/* The segmented bar in the design: one segment per step, filled up to here. */
.mifa-steps__progress {
  display: flex;
  gap: 8px;
  margin-top: 48px;
}
.mifa-steps__segment {
  flex: 1;
  height: 3px;
  border-radius: var(--mf-radius, 2px);
  background: var(--mf-line-soft);
  transition: background .25s ease;
}
.mifa-steps__segment.is-done { background: var(--mf-body); }

/* "Step 2 of 6" — for screen readers; the bar says it to everyone else. */
.mifa-steps__count {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.mifa-steps__nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
}

/* Next and Send sit at the end even when Back is gone on the first step. */
.mifa-steps__nav .mifa-steps__next,
.mifa-steps__nav .mifa-form__submit {
  margin-inline-start: auto;
}

.mifa-steps__nav .mifa-form__submit,
.mifa-steps__next {
  width: auto;
  min-width: 120px;
  margin-top: 0;
}

.mifa-steps__next {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 24px;
  border: 0;
  border-radius: var(--mf-radius, 2px);
  background: var(--mf-deep);
  color: var(--mf-surface);
  font-family: inherit;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .25s ease, transform .25s ease;
}
.mifa-steps__next:hover { opacity: .92; transform: translateY(-1px); }

.mifa-steps__back {
  padding: 8px 4px;
  border: 0;
  background: none;
  color: var(--mf-ink);
  font-family: inherit;
  font-size: 16px;
  line-height: 24px;
  cursor: pointer;
}
.mifa-steps__back:hover { text-decoration: underline; }

.mifa-steps__back:focus-visible,
.mifa-steps__next:focus-visible {
  outline: 2px solid var(--mf-accent);
  outline-offset: 2px;
}

/* Multiple choice and radio groups in a step read as a list, one per line,
   as in the design — long answers do not wrap into each other. */
.mifa-form--steps .mifa-field__choices {
  flex-direction: column;
  gap: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .mifa-steps__segment,
  .mifa-steps__next { transition: none; }
}

/* --- file upload --------------------------------------------------- */

/* The text-box rule gives every input a fixed 40px height; a file control
   needs room for its button. */
.mifa-field input.mifa-file {
  height: auto;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 22px;
  cursor: pointer;
}
.mifa-field input.mifa-file::file-selector-button {
  margin-inline-end: 12px;
  padding: 6px 14px;
  border: .5px solid var(--mf-line);
  border-radius: var(--mf-radius, 2px);
  background: transparent;
  color: var(--mf-ink);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.mifa-file__limits {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 18px;
  color: var(--mf-muted);
}
.mifa-file__list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  line-height: 20px;
  color: var(--mf-ink);
}
.mifa-file__list[hidden] { display: none; }
/* The warning mark is placed for a one-line text box; on a file control it
   lands on top of the chosen file's name. The message underneath is enough. */
.mifa-field.is-error input.mifa-file ~ .mifa-field__mark { display: none; }

/* --- a form placed automatically ---------------------------------- */

/* The wrapper sits outside .mifa-form, so it names its own colours — the
   same chain as the sheet: the MIFA theme, then Elementor's globals, then
   neutral. Nothing here hard-codes a brand. */
.mifa-auto {
  --ma-accent:  var(--mifa-sheet-accent, var(--c-accent, var(--e-global-color-primary, #1E1F21)));
  --ma-ink:     var(--c-ink, var(--e-global-color-text, #1E1F21));
  --ma-surface: var(--c-surface, #FFFFFF);
  margin: 32px 0;
  clear: both;
}
.mifa-auto__heading {
  margin: 0 0 16px;
  font-size: 20px;
  line-height: 1.4;
  color: var(--ma-ink);
}

/* Folded on phones. The button exists in the markup with [hidden]; fold.js
   reveals it and adds .is-ready. Every rule that hides the form is inside
   the phone query — on a desktop the form shows whatever the script did. */
.mifa-fold__toggle[hidden] { display: none; }

@media (min-width: 768px) {
  .mifa-fold__toggle { display: none !important; }
}

@media (max-width: 767px) {
  .mifa-fold.is-ready .mifa-fold__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    background: var(--ma-accent);
    color: var(--ma-surface);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    text-align: start;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mifa-fold.is-ready .mifa-fold__toggle:focus-visible {
    outline: 3px solid var(--ma-ink);
    outline-offset: 2px;
  }
  .mifa-fold__mark {
    flex: none;
    width: 9px;
    height: 9px;
    border-inline-end: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform .2s ease;
  }
  .mifa-fold.is-open .mifa-fold__mark { transform: rotate(-135deg) translateY(-2px); }

  .mifa-fold.is-ready:not(.is-open) .mifa-fold__body { display: none; }
  .mifa-fold.is-ready.is-open .mifa-fold__body { margin-top: 16px; }
  /* The button already carries the heading's words. */
  .mifa-fold.is-ready .mifa-auto__heading { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mifa-fold__mark { transition: none; }
}
