@use 'sass:math';
@use 'vars' as *;
@use 'mixins' as *;

form {
  @include background;

  padding: math.div($small-padding, 2) $small-padding $small-padding $small-padding;
  border-radius: $border-radius;

  input:-webkit-autofill,
  input:-webkit-autofill:hover,
  input:-webkit-autofill:focus {
    -webkit-text-fill-color: white;
    transition: background-color 5000s ease-in-out 0s;
  }

  input,
  label {
    font-size: 1.5rem;
  }

  fieldset {
    border: $border;
    padding: 0 $medium-padding $medium-padding $medium-padding;
    border-radius: $border-radius;

    div {
      // disable margin collapse
      overflow: auto;
    }

    legend {
      font-family: 'Comfortaa', sans-serif;
      font-size: 2rem;
    }

    .name-group {
      position: relative;
      padding: 15px 0 0;
      margin-top: 10px;
      margin: 10px math.div($small-padding, 2) $small-padding math.div($small-padding, 2);

      input {
        font-family: inherit;
        border: none;
        border-bottom: $border;
        color: white;
        padding: 10px 0 0px 0;
        background: transparent;
        margin-bottom: $border-width-focused - $border-width;
        width: 100%;

        &::placeholder {
          color: transparent;
        }

        &:placeholder-shown ~ label {
          font-size: 1.3rem;
          cursor: text;
          top: 20px;
        }
      }

      label {
        position: absolute;
        top: 0;
        display: block;
        transition: $animation-time;
        color: $bright-neutral;
        font-size: 1.1rem;
      }

      input:focus,
      input:not(:placeholder-shown) {
        outline: none;
        margin-bottom: 0;
        border-width: $border-width-focused;
        border-color: $accent;

        ~ label {
          position: absolute;
          top: 0;
          display: block;
          transition: $animation-time;
        }
      }
    }

    input[type='radio'] {
      width: 0;
      height: 0;
      appearance: none;

      + label {
        display: block;
        border-radius: $border-radius;
        padding: $small-padding;
        border: $border;

        cursor: pointer;
        margin: $border-width-focused - $border-width $border-width-focused -
          $border-width + math.div($small-padding, 2);

        .completion {
          font-size: 0.7em;
          color: $bright-neutral;
        }
      }

      &:focus {
        outline: none;
      }

      &:focus + label,
      &:checked + label {
        border-color: $accent;
        border-width: $border-width-focused;
        margin: 0 math.div($small-padding, 2);
      }
    }
  }
}
