// Forms and input fields
//
// All the forms on the site. General styles. Supports most of
// the Gravity Forms styles out of the box.

// Variables
$color-checkbox: $color-east-bay;
$border-width-inputs: 2px;

// CSS Variables for radios and checkboxes
:root {
  --color-background-inputs: var(--color-white);
  --color-checkbox: #{$color-checkbox};
  --color-checkbox-rgb: #{hextorgb($color-checkbox)};
  --checkbox-radio-size: 16px;
  --checkbox-radio-gap: 10px;
  --checkbox-radio-border-width: 2px;
  --checkbox-radio-line-height: var(--line-height-paragraphs);
  --radio-marker-size: 8px;
  --checkbox-marker-size: 12px;
  --checkbox-radius: 4px;
}

// Buttons
.button-wrapper {
  margin-bottom: 0;
}

// Buttons
.site-main,
.site-footer {
  button,
  .button,
  input[type="reset"],
  input[type="submit"],
  input[type="button"] {
    @include button();

    // Button styles
    &.button-ghost {
      @include button-style-ghost();
    }

    // Button sizes
    &.button-small {
      @include button-size-small();
    }

    &.button-medium {
      @include button-size-medium();
    }

    &.button-large {
      @include button-size-large();
    }
  }
}

// Select drop downs
select {
  background-image: url('../../svg/select.svg');
  background-position: right 0 center;
  background-repeat: no-repeat;
  background-size: 40px auto;
  border-color: var(--color-border-forms);
  border-radius: 0;
  border-style: solid;
  border-width: $border-width-inputs;
  color: var(--color-paragraphs);
  font-size: var(--font-size-medium);
  line-height: 24px;
  max-width: 100%;
  min-width: 0;
  padding: 15px;
  text-indent: 1px;
  transition: none;
  width: 100%;
}

// Form input elements and textareas
textarea,
select,
input[type="text"],
input[type="tel"],
input[type="url"],
input[type="password"],
input[type="number"],
input[type="month"],
input[type="week"],
input[type="email"],
input[type="search"] {
  @extend %default;
  background-color: var(--color-background-inputs);
  border-color: var(--color-border-forms);
  border-radius: 3px;
  border-style: solid;
  border-width: $border-width-inputs;
  box-sizing: border-box;
  font-family: $font-paragraphs;
  font-size: var(--font-size-medium);
  line-height: 24px;
  margin-bottom: 0;
  padding: 15px;
  position: relative;
  text-decoration: none;
  transition: background .55s;

  &::placeholder {
    color: var(--color-paragraphs);
    opacity: .4;
  }

  &:focus {
    background-color: var(--color-background-inputs);
    border-color: rgba(var(--color-valhalla-rgb), .3);

    &::placeholder {
      color: var(--color-black);
      opacity: .8;
    }
  }
}

// Radio buttons and checkboxes
input[type="radio"],
input[type="checkbox"] {
  height: var(--checkbox-radio-size);
  margin: 0;
  margin-top: calc((1em * var(--checkbox-radio-line-height) - var(--checkbox-radio-size)) / 2);
  opacity: 0;
  padding: 0;
  pointer-events: none;
  // Hide native buttons
  position: absolute;
  width: var(--checkbox-radio-size);
}

// Labels for radio buttons and checkboxes
input[type="radio"] + label,
input[type="checkbox"] + label {
  align-items: flex-start;
  cursor: pointer;
  display: inline-flex;
  line-height: var(--checkbox-radio-line-height);
}

// Custom buttons - basic style
input[type="radio"] + label::before,
input[type="checkbox"] + label::before {
  align-self: center;
  background-color: var(--color-white);
  background-position: center;
  background-repeat: no-repeat;
  border-color: var(--color-checkbox);
  border-style: solid;
  border-width: var(--checkbox-radio-border-width);
  content: '';
  display: inline-flex;
  flex-shrink: 0;
  height: var(--checkbox-radio-size);
  margin-right: var(--checkbox-radio-gap);
  position: relative;
  top: calc(var(--checkbox-radio-border-width) / 2);
  transition: transform .2s, border .2s;
  width: var(--checkbox-radio-size);
}

// Radio only style
input[type="radio"] + label::before {
  border-radius: 50%;
}

// Checkbox only style
input[type="checkbox"] + label::before {
  border-radius: var(--checkbox-radius);
}

// Radio button and checkbox checked states
input[type="radio"]:checked + label::before,
input[type="checkbox"]:checked + label::before {
  background-color: var(--color-checkbox);
  border-color: var(--color-checkbox);
  box-shadow: none;
  transition: transform .2s;
}

// Radio button and checkbox active states
input[type="radio"]:active + label::before,
input[type="checkbox"]:active + label::before {
  transform: scale(.8);
  transition: transform .2s;
}

// Radio button icon
input[type="radio"]:checked + label::before {
  background-image: url("data:image/svg+xml;charset=utf8, %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg class='nc-icon-wrapper' fill='%23ffffff'%3E%3Ccircle cx='8' cy='8' r='8' fill='%23ffffff'%3E%3C/circle%3E%3C/g%3E%3C/svg%3E");
  background-size: var(--radio-marker-size);
}

// Checkbox button icon
input[type="checkbox"]:checked + label::before {
  background-image: url("data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpolyline points='1 6.5 4 9.5 11 2.5' fill='none' stroke='%23FFFFFF' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'/%3E%3C/svg%3E");
  background-size: var(--checkbox-marker-size);
}

// Radio button and checkbox focus states
input[type="radio"]:focus + label::before,
input[type="checkbox"]:focus + label::before,
input[type="radio"]:checked:active + label::before,
input[type="checkbox"]:checked:active + label::before {
  border-color: var(--color-checkbox);
  box-shadow: 0 0 0 3px rgba(var(--color-checkbox-rgb), .2);
}

// Radio button and checkbox checked + active states
input[type="radio"]:checked:active + label::before,
input[type="checkbox"]:checked:active + label::before {
  transform: none;
  transition: none;
}

// Radio button and checkbox hovers
/* stylelint-disable sh-waqar/declaration-use-variable, selector-max-pseudo-class */
input[type="radio"]:not(:checked):not(:focus) + label:hover::before,
input[type="checkbox"]:not(:checked):not(:focus) + label:hover::before {
  border-color: lighten($color-checkbox, 15%);
}
/* stylelint-enable sh-waqar/declaration-use-variable, selector-max-pseudo-class */
