.uniform__potty {
  position: absolute;
  left: -9999px;
}

.uniform-contact {
  width: 100%;
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;

  --cf-default-color-success: #2f9f35;
  --cf-default-color-warning: #c87911;
  --cf-default-color-error: #b5414b;
  --cf-default-color-accent: #4d74bc;
  --cf-default-color-background: #fff;
  --cf-default-color-spinner: #fff;

  --cf-default-border-radius: 0.5rem;
  --cf-default-gap: 1rem;
  --cf-default-padding: 0.5rem;

  --cf-padding-1: var(--cf-padding, var(--cf-default-padding));
  --cf-padding-2: calc(var(--cf-padding, var(--cf-default-padding)) * 1.5);
  --cf-padding-3: calc(var(--cf-padding, var(--cf-default-padding)) * 3);

  --grid-layout-gap: var(--cf-gap, var(--cf-default-gap));
  --grid-column-count: 2;
  --grid-item--min-width: 250px;

  .uniform-contact__form.uniform-contact__layout--one-column {
    --grid-column-count: 1;
  }

  .uniform-contact__form.uniform-contact__layout--two-column {
    --grid-column-count: 2;

    .uniform-contact__message, .uniform-contact__last_block {
      grid-column: unset;
    }

    .uniform-contact__message textarea {
      min-height: 150px;
    }
  }

  button {
    /* prevent buttons to stay while transitioning between confirmation and form */
    transition: none;
  }
}

.uniform-contact__confirmation, .uniform-contact__form {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  transition: visibility 0s, opacity 0.3s ease-out;
  opacity: 1;
}

.uniform-contact__confirmation[aria-hidden="true"],
.uniform-contact__form[aria-hidden="true"],
.uniform-contact__result[aria-hidden="true"] {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.uniform-contact__confirmation {
  display: grid;
  place-items: center;
  text-align: center;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.uniform-contact__theme--basic {
  label, .uniform-contact__privacy {
    display: block;
    margin-inline-start: var(--cf-padding-1);
  }

  input,
  textarea,
  button {
    border: 1px solid var(--cf-color-accent, var(--cf-default-color-accent));
    padding: var(--cf-padding-1) var(--cf-padding-2);

    &:focus {
      border-color: var(--cf-color-accent, var(--cf-default-color-accent));
    }
  }

  input,
  textarea {
    border-radius: var(--cf-border-radius, var(--cf-default-border-radius));
  }

  textarea {
    min-height: 120px;
    resize: vertical;
  }

  button {
    background-color: var(--cf-color-accent, var(--cf-default-color-accent));
    color: var(--cf-color-background, var(--cf-default-color-background));
    border-radius: calc(var(--cf-border-radius, var(--cf-default-border-radius)) * 2);
    transition: all 0.5s;
  }

  button:hover {
    color: var(--cf-color-accent, var(--cf-default-color-accent));
    background-color: var(--cf-color-background, var(--cf-default-color-background));
    border: 1px solid var(--cf-color-accent, var(--cf-default-color-accent));
  }
}

.uniform-contact__form {

  --cf-gap-count: calc(var(--grid-column-count) - 1);
  --total-gap-width: calc(var(--cf-gap-count) * var(--grid-layout-gap));
  --grid-item--max-width: calc((100% - var(--total-gap-width)) / var(--grid-column-count));

  width: 100%;

  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(max(var(--grid-item--min-width), var(--grid-item--max-width)), 1fr));
  grid-gap: var(--grid-layout-gap);

  .uniform-contact__message, .uniform-contact__last_block {
    grid-column: 1 / -1;
  }

  label {
    text-align: left;
  }

  .uniform-contact__input-group {
    display: flex;
    flex-direction: column;
    height: fit-content;
  }

  .uniform-contact__title {
    margin-bottom: calc(var(--cf-gap, var(--cf-default-gap)) * 2);
  }

  .uniform-contact__input {
    height: 100%;
    font: inherit;
    color: inherit;
    width: 100%;
    margin: 0;
  }

  .uniform-contact__message textarea {
    width: auto;
    resize: block;
    height: 4lh;
    box-sizing: content-box;
  }

  .uniform-contact__input:focus {
    outline-color: var(--cf-color-accent, var(--cf-default-color-accent));
    border-color: var(--cf-color-accent, var(--cf-default-color-accent));
  }

  .uniform-contact__input:valid:not(:placeholder-shown):focus {
    outline-color: var(--cf-color-success, var(--cf-default-color-success));
    border-color: var(--cf-color-success, var(--cf-default-color-success));
  }

  .uniform-contact__input:invalid:not(:placeholder-shown):focus {
    outline-color: var(--cf-color-warning, var(--cf-default-color-warning));
    border-color: var(--cf-color-warning, var(--cf-default-color-warning));
  }

  .uniform-contact__input.error {
    outline-color: var(--cf-color-error, var(--cf-default-color-error)) !important;
    border-color: var(--cf-color-error, var(--cf-default-color-error)) !important;
  }

  .uniform-contact__error-message {
    text-align: start;
    font-size: 80%;
    color: var(--cf-color-error, var(--cf-default-color-error));
    margin-top: calc(var(--cf-border-radius, var(--cf-default-border-radius)) * 0.3);
    margin-inline-start: calc(var(--cf-border-radius, var(--cf-default-border-radius)) * 0.3);
  }

  .uniform-contact__general-errors {
    margin-top: var(--cf-padding-1);
    width: 100%;
  }

  .uniform-contact__last_block {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: var(--cf-gap, var(--cf-default-gap));
  }

  .uniform-contact__captcha {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
    gap: var(--cf-gap, var(--cf-default-gap));

    @media (max-width: 575px) {
      flex-direction: column;
      align-items: flex-start;
    }
  }

  .uniform-contact__captcha-answer {
    width: 100%;
    height: fit-content;
  }

  .uniform-contact__captcha-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--cf-gap, var(--cf-default-gap));
  }

  .uniform-contact__captcha-image {
    height: 100%;
  }

  .uniform-contact__captcha-image img {
    height: 100%;
    object-fit: cover;
    border-radius: var(--cf-border-radius, var(--cf-default-border-radius));
  }

  .uniform-contact__captcha-reload {
    cursor: pointer;
  }

  .uniform-contact__captcha-input {
    flex-grow: 1;
  }

  .uniform-contact__privacy {
    margin-top: calc(var(--cf-gap, var(--cf-default-gap)) * 0.3);
    margin-bottom: calc(var(--cf-gap, var(--cf-default-gap)) * 0.3);
    text-align: left;
    font-size: 90%;
  }

  .uniform-contact__submit-btn {
    width: 100%;
  }

  .uniform-contact__submit-btn.is-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
  }

  .uniform-contact__submit-btn.is-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-top: -10px;
    margin-left: -10px;
    border-radius: 50%;
    border: 2px solid var(--cf-color-spinner, var(--cf-default-color-spinner));
    border-top-color: transparent;
    animation: spinner 1s linear infinite;
  }

  .uniform-contact__result {
    grid-column: 1/-1;
    width: 100%;
    text-align: center;
    margin-top: var(--cf-padding-1);

    .uniform-contact__result--success {
      color: inherit;
      text-align: center;
    }

    .uniform-contact__result--error {
      display: inline-block;
      color: white;
      background: var(--cf-color-error, var(--cf-default-color-error));
      border-radius: var(--cf-border-radius, var(--cf-default-border-radius));
      text-align: center;
      padding: max(var(--cf-padding-1), 10px) max(var(--cf-padding-2), 20px);
    }
  }
}

@keyframes spinner {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
