/**
 * @file
 * Checkbox and radio input elements.
 */

@import "../base/media-queries.pcss.css";

input[type="checkbox"],
input[type="radio"] {
  display: inline-block;
  width: var(--sp1-5);
  height: var(--sp1-5);
  margin: 0;
  vertical-align: middle;
  border: 1px solid var(--color--gray-60);
  border-radius: 3px;
  background-color: var(--color--white);
  background-repeat: no-repeat;
  background-position: 50% 50%;
  background-size: var(--sp1) var(--sp1);
  appearance: none;

  &:focus {
    border: solid 2px var(--color--primary-50);
    outline: solid 2px var(--color--primary-50);

    @supports (outline-style: double) {
      border-width: 1px;
      outline-width: 6px;
      outline-style: double;
      outline-offset: -1px;
    }
  }

  &:hover {
    border-color: var(--color--primary-60);
  }

  &[disabled] {
    background-color: var(--color--gray-100);

    &:hover {
      border-color: var(--color--gray-60);
    }

    &:checked {
      border-width: 1px;
    }
  }

  &:checked {
    border-width: 2px;
  }

  &.error {
    border: solid 2px var(--color--red);

    &:focus {
      outline-color: var(--color--red);
      outline-offset: -2px;
    }
  }

  & + label {
    display: inline-block;
    padding-inline-start: var(--sp0-5);
  }
}

input[type="checkbox"] {
  &:checked {
    background-image: url("data:image/svg+xml,%3Csvg width='17px' height='13px' viewBox='0 0 17 13' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cpath d='M14.8232,0.176777 C14.9209,0.0791457 15.0791,0.0791455 15.1768,0.176777 L16.9445,1.94454 C17.0422,2.04217 17.0422,2.20047 16.9445,2.2981 L6.23744,13.0052 C6.13981,13.1028 5.98151,13.1028 5.88388,13.0052 L0.176777,7.2981 C0.0791456,7.20047 0.0791456,7.04218 0.176777,6.94454 L1.94454,5.17678 C2.04217,5.07915 2.20047,5.07915 2.2981,5.17678 L5.88388,8.76256 C5.98151,8.86019 6.13981,8.86019 6.23744,8.76256 L14.8232,0.176777 Z' id='Path' fill='%232494DB' fill-rule='nonzero'%3E%3C/path%3E%3C/svg%3E");
  }
}

input[type="radio"] {
  border-radius: 50%;

  &:checked {
    background-image: url("data:image/svg+xml,%3Csvg width='17' height='17' viewBox='0 0 17 17' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='8.5' cy='8.5' r='8.5' fill='%232494DB'/%3E%3C/svg%3E%0A");
    background-size: 17px;
  }

  &:focus {
    border-width: 2px;
    border-color: var(--color--primary-50);
    outline-color: transparent;
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--color--primary-50);
  }

  &.error:focus {
    outline-color: transparent;
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--color--red);
  }
}

.form-type-boolean {
  margin-block: var(--sp1);
}