/**
 * Form states of the contact form (components/zotek/contact/form.php) and the job application form
 * (components/zotek/career-single/body.php, #apply), script assets/js/contact-form.js.
 * The designs (template_html/contact.html, career-detail.html) have no error / captcha / sent state,
 * so the template classes stay as they are and these rules only apply while such a state is shown.
 */

/* hidden attribute also on elements whose classes set a display (flex, block…). */
[data-contact-form] [hidden] {
  display: none !important;
}

/* A field wrapper with a fixed design height (h-[89.2px], h-[161.2px], sm:h-[208.63px]…) grows while it
   shows an error. */
[data-contact-fields] > div:has(> [data-field-error]:not([hidden])) {
  height: auto;
}

/* Field area: its fixed desktop height (min-[1200px]:h-[854.43px]) becomes a minimum while
   error messages or the reCAPTCHA box add lines. */
@media (min-width: 1200px) {
  #contact-form [data-contact-fields]:has([data-field-error]:not([hidden]), [data-form-error]:not([hidden]), [data-recaptcha]) {
    height: auto;
    min-height: 854.43px;
  }
}

/* Invalid field: red border (text inputs carry the border, select / textarea sit in a bordered box). */
[data-contact-form] input[aria-invalid="true"]:not([type="radio"]):not([type="checkbox"]),
[data-contact-form] div:has(> select[aria-invalid="true"]),
[data-contact-form] div:has(> textarea[aria-invalid="true"]),
[data-contact-form] div:has(> input[type="url"][aria-invalid="true"]),
[data-contact-form] label:has(> input[type="file"][aria-invalid="true"]) {
  border-color: #dc2626;
}

/* File drop area (application form): the fixed design height (h-[167.43px]) becomes a minimum while the
   chosen file name is shown (on phones the hint text takes 2 lines); a file dragged over it; keyboard
   focus of its sr-only input. */
[data-contact-form] [data-file-drop]:has([data-file-name]:not([hidden])) {
  height: auto;
  min-height: 167.43px;
}
@media (max-width: 639px) {
  [data-contact-form] [data-file-drop]:has([data-file-name]:not([hidden])) {
    padding-bottom: 16px;
  }
}
@media (min-width: 640px) {
  [data-contact-fields] > div:has([data-file-name]:not([hidden])) {
    height: auto;
    min-height: 208.63px;
  }
}
[data-contact-form] [data-file-drop][data-dragover] {
  border-color: #0b75d5;
  background-color: #e6edf8;
}
[data-contact-form] label:has(> input[type="file"]:focus-visible),
[data-contact-form] label:has(> input[type="checkbox"].sr-only:focus-visible) {
  outline: 2px solid #0b75d5;
  outline-offset: 2px;
}

/* Topic cards: the design draws the first card as selected; the look follows the checked radio
   instead (same colours as the design's selected / unselected cards), plus a keyboard focus ring. */
[data-contact-form] fieldset label:has(> input[type="radio"]:checked) {
  border-color: #0b75d5;
  background-color: #eff4f8;
  box-shadow: 0 8px 20px #0b75d524;
}
[data-contact-form] fieldset label:has(> input[type="radio"]:not(:checked)) {
  border-color: #eff4f8;
  background-color: #ffffff;
  box-shadow: none;
}
[data-contact-form] fieldset label:has(> input[type="radio"]:checked) > span:last-child {
  color: #0b75d5;
}
[data-contact-form] fieldset label:has(> input[type="radio"]:not(:checked)) > span:last-child {
  color: #5b6478;
}
[data-contact-form] fieldset label:has(> input[type="radio"]:focus-visible) {
  outline: 2px solid #0b75d5;
  outline-offset: 2px;
}

/* Sending. */
[data-contact-form] [data-contact-submit]:disabled {
  cursor: wait;
  opacity: 0.6;
}

/* The anchors of the no-JS redirect (#contact-form, #apply) clear the fixed header. */
#contact-form,
#apply {
  scroll-margin-top: 120px;
}
