/**
 * @file
 * Form
 *
 * Contains styles for forms in main content region.
 */

 @use '_helper' as *;
 
.main .form {
  margin: calc($spacing-vertical-lg * 0.2) 0;
  display: flex;
  flex-direction: column;
  gap: 40px;

  @media screen and (min-width: $break-large) {
    margin: calc($spacing-vertical-lg * 0.3) 0;
  }

  &__item:not(.form--fieldset) {
    display: flex;
    flex-direction: column;
    gap: 10.5px;
    max-width: 284px;

    @media screen and (min-width: $break-medium) {
      max-width: 280px;
    }

    label {
      @include body(true);
    }

    input[type="text"], 
    input[type="email"],
    input[type="tel"],
    input[type="search"],
    input[type="number"],
    textarea {
      width: 100%;
    }
  }

  &--fieldset {
    margin: 0;
    padding: 0;
    border: 0;

    &__items {
      display: flex;
      flex-direction: column;
      gap: 11px;

      @media screen and (min-width: $break-large) {
        gap: 8px;
      }
    }

    legend {
      @include body(true);
      margin-bottom: 13px;

      @media screen and (min-width: $break-large) {
        margin-bottom: 12px;
      }
    }
  }

  &--actions {
    button {
      @include ctaButton;
      width: fit-content;
    }
  }
}

input[type="text"], 
input[type="email"],
input[type="tel"],
input[type="search"],
input[type="number"],
textarea {
  @include body;
  padding: 7px 13px 10px;
  background-color: $color-white;
  border: solid 1px $color-gray;
  border-radius: 5px;

  @media screen and (min-width: $break-large) {
    padding: 8px 13px 6px;
  }
}

textarea {
  min-width: 100%;
  max-width: 100%;
  min-height: 118px;
}

.form__checkbox,
.form__radio {
  display: flex;
  align-items: center;

  input {
    outline: 0;

    &:focus {
      + label::before {
        outline: solid 1px $color-black;
        outline-offset: 4px;
      }
    }

    &:checked {
      & + label::before {
        background-color: $color-blue-dark;
        border-color: $color-blue-dark;
      }
      
      & + label::after {
        opacity: 1;
      }
    }
  }

  input + label {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;

    @media screen and (min-width: $break-large) {
      gap: 10px;
    }

    &::before {
      content: '';
      display: block;
      width: 14px;
      height: 14px;
      border: solid 1px $color-black-50;
      border-radius: 2px;
      box-sizing: border-box;
    }

    &::after {
      content: '';
      display: block;
      position: absolute;
      opacity: 0;
    }
  }
}

.form__checkbox {
  input + label::after {
    width: 6px;
    height: 3px;
    top: 10.5px;
    left: 3px;
    border-bottom: 2px solid $color-white;
    border-left: 2px solid $color-white;
    transform: translateY(-50%) rotate(-45deg);

    @media screen and (min-width: $break-large) {
      top: 12.5px;
    }
  }
}

.form__radio {
  input + label {
    &::before {
      border-radius: 100%;
    }

    &::after {
      border: solid 3px $color-white;
      border-radius: 100%;
      top: 8.5px;
      left: 4px;
      box-sizing: content-box;

      @media screen and (min-width: $break-large) {
        top: 10.5px;
      }
    }
  }
}

.select {
  position: relative;

  &::after {
    content: '';
    width: 5px;
    height: 5px;
    position: absolute;
    top: calc(50% - 2px);
    right: 16.5px;
    transform: translateY(-50%) rotate(-45deg);
    border-bottom: 1.5px solid $color-black;
    border-left: 1.5px solid $color-black;
    pointer-events: none;
  }

  select {
    @include body;
    padding: 7.5px 39px 9.5px 13px;
    width: 100%;
    color: $color-black;
    background-color: $color-white;
    border: solid 1px $color-gray;
    border-radius: 5px;

    @media screen and (min-width: $break-large) {
      padding: 7px 39px 7px 13px;
    }
  }
}