/*
 * Contact page postcard form (Ninja Forms 3 markup).
 * The theme's style.css targets the old Ninja Forms 2 IDs, and NF3 adds its own
 * field backgrounds, widths and validation icons, so restyle the form here.
 */

#contact #contact-form #postcard .nf-form-fields-required {
  font-size: 0.75em;
  text-align: left;
  margin-bottom: 8px;
}

#contact #contact-form #postcard .nf-row,
#contact #contact-form #postcard .nf-cell {
  margin: 0;
  padding: 0;
}

#contact #contact-form #postcard .nf-field-container {
  margin-bottom: 14px;
}

/* Strip the per-field colours, borders and widths Ninja Forms injects */
#contact #contact-form #postcard .field-wrap,
#contact #contact-form #postcard .field-wrap .nf-field-label label,
#contact #contact-form #postcard .field-wrap .nf-field-element .ninja-forms-field {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: 0;
  float: none;
  margin: 0;
  padding: 0;
  text-align: left;
}

#contact #contact-form #postcard .field-wrap,
#contact #contact-form #postcard .field-wrap .nf-field-element .ninja-forms-field {
  width: 100% !important;
}

#contact #contact-form #postcard .field-wrap .nf-field-label {
  margin: 0;
}

#contact #contact-form #postcard .field-wrap .nf-field-label label {
  width: auto !important;
  font-size: 0.875em;
  font-weight: 400;
}

/* Leftover empty "submit_button" field from the NF2 -> NF3 migration */
#contact #contact-form #postcard .unknown-container {
  display: none;
}

/* Name / email / phone: label and input on one underlined "address line" */
#contact #contact-form #postcard .textbox-wrap,
#contact #contact-form #postcard .email-wrap {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  border-bottom: 1px solid #aaaaa0 !important;
}

#contact #contact-form #postcard .textbox-wrap .nf-field-label,
#contact #contact-form #postcard .email-wrap .nf-field-label {
  flex: 0 0 auto;
  width: auto;
  padding-right: 8px;
  white-space: nowrap;
}

#contact #contact-form #postcard .textbox-wrap .nf-field-element,
#contact #contact-form #postcard .email-wrap .nf-field-element {
  flex: 1 1 auto;
  min-width: 0;
}

#contact #contact-form #postcard .textbox-wrap .ninja-forms-field,
#contact #contact-form #postcard .email-wrap .ninja-forms-field {
  height: auto;
  padding: 8px 0 4px !important;
  font-size: 0.875em;
  color: #525349;
}

/* Message: ruled lines like the back of a postcard */
#contact #contact-form #postcard .textarea-wrap .nf-field-label {
  margin-bottom: 4px;
}

#contact #contact-form #postcard .textarea-wrap .nf-field-element .ninja-forms-field {
  height: 168px;
  resize: none;
  font-size: 0.875em;
  line-height: 24px;
  color: #525349;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 23px, #aaaaa0 23px, #aaaaa0 24px) !important;
  background-attachment: local !important;
}

/* Hide NF's green tick / red cross; errors still show as text and a red line */
#contact #contact-form #postcard .nf-field-element::after,
#contact #contact-form #postcard .nf-pass .nf-field-element::after,
#contact #contact-form #postcard .nf-error .nf-field-element::after {
  display: none !important;
  content: none !important;
}

#contact #contact-form #postcard .nf-error .textbox-wrap,
#contact #contact-form #postcard .nf-error .email-wrap {
  border-bottom-color: #d95e01 !important;
}

#contact #contact-form #postcard .nf-error-wrap {
  font-size: 0.75em;
  text-align: left;
  color: #d95e01;
}

#contact #contact-form #postcard .nf-error-wrap .nf-error-msg {
  color: #d95e01;
}

#contact #contact-form #postcard .submit-container {
  margin: 8px 0 0;
}

#contact #contact-form #postcard .submit-container .field-wrap {
  border: 0 !important;
}

#contact #contact-form #postcard .submit-container .nf-field-element input[type="submit"] {
  position: static;
  width: 190px !important;
  margin: 0 auto;
  display: block;
  padding: 12px !important;
  background: #333 !important;
  color: #fff;
  font-size: 1em;
  text-align: center;
  cursor: pointer;
}

#contact #contact-form #postcard .submit-container .nf-field-element input[type="submit"]:hover {
  background: #525349 !important;
}

@media (min-width: 40em) {
  /* Line up with the message column rather than the envelope border */
  #contact #contact-form #postcard .nf-form-fields-required {
    width: 48%;
    padding-left: 24px;
  }

  /* Two halves of the postcard, split by a vertical rule */
  #contact #contact-form #postcard .nf-row:first-child {
    display: flex;
  }

  #contact #contact-form #postcard .nf-row:first-child .nf-cell {
    width: 50% !important;
    padding: 0 3%;
  }

  #contact #contact-form #postcard .nf-row:first-child .nf-cell:first-child {
    border-right: 1px solid #cfcfc0;
  }

  /* Leave room for the whippet stamp above the address lines */
  #contact #contact-form #postcard .namecont {
    margin-top: 100px;
  }

  #contact #contact-form #postcard .phcont {
    margin-bottom: 0;
  }

  /* Errors sit just under their line so they don't push fields off the card */
  #contact #contact-form #postcard .nf-field-container {
    position: relative;
  }

  #contact #contact-form #postcard .nf-field-container .nf-error-wrap {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 1px;
    line-height: 1.2;
  }

  /* The form-wide error would land on the envelope border; the field errors
     already say what's wrong, so keep it for screen readers only */
  #contact #contact-form #postcard .nf-form-errors {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  /* Send button below the card on the right, opposite the social icons */
  #contact #contact-form #postcard .submit-container {
    position: absolute;
    right: 0;
    bottom: 0;
    margin: 0;
  }
}
