/* ===================================================================
   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,        #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);
  --mf-accent:   var(--c-accent,     #6B1D2B);
  --mf-deep:     var(--c-accent-deep,#500F28);
  --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;

  --mf-font:     var(--font-body,    -apple-system, Inter, "Segoe UI", system-ui, sans-serif);
  --mf-display:  var(--font-display, Optima, "Segoe UI", system-ui, serif);

  font-family: var(--mf-font);
}

/* --- 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 {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: .5px solid var(--mf-line);
  border-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; right: 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-right: 40px;
}
.mifa-field.is-error textarea { padding-right: 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 34px 0 14px;
  border: .5px solid var(--mf-line);
  border-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;
}
.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-choice input { 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: 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: 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;
  left: -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: 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; }
}
