@import "govuk_publishing_components/individual_component_support";

.gem-c-option-select {
  position: relative;
  padding: 0 0 govuk-spacing(2);
  margin-bottom: govuk-spacing(2);
  border-bottom: 1px solid $govuk-border-colour;

  @include govuk-media-query($from: desktop) {
    // Redefine scrollbars on desktop where these lists are scrollable
    // so they are always visible in option lists
    ::-webkit-scrollbar {
      -webkit-appearance: none;
      width: 7px;
    }

    ::-webkit-scrollbar-thumb {
      border-radius: 4px;

      background-color: rgba(0, 0, 0, .5);
      -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .87);
    }
  }

  .gem-c-checkboxes {
    margin: 0;
  }
}

.gem-c-option-select__title {
  @include govuk-font(19);
  margin: 0;
}

.gem-c-option-select__button {
  z-index: 1;
  background: none;
  border: 0;
  text-align: left;
  padding: 0;
  cursor: pointer;
  color: $govuk-link-colour;

  &:hover {
    text-decoration: underline;
    text-underline-offset: .1em;
    @include govuk-link-hover-decoration;
  }

  &::-moz-focus-inner {
    border: 0;
  }

  &:focus {
    outline: none;
    text-decoration: none;
    @include govuk-focused-text;
  }

  &[disabled] {
    background-image: none;
    color: inherit;
  }

  // Extend the touch area of the button to span the heading
  &::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
  }
}

.gem-c-option-select__icon {
  display: none;
  position: absolute;
  top: 0;
  left: 9px;
  width: 30px;
  height: 40px;
  fill: govuk-colour("black");
}

.gem-c-option-select__container {
  position: relative;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: govuk-colour("white");

  &:focus {
    outline: 0;
  }
}

.gem-c-option-select__container--large {
  max-height: 600px;
}

.gem-c-option-select__container-inner {
  padding: govuk-spacing(1) 13px;
}

.gem-c-option-select__filter {
  position: relative;
  background: govuk-colour("white");
  padding: 13px 13px govuk-spacing(2) 13px;
}

.gem-c-option-select__filter-input {
  @include govuk-font(19);
  background: image-url("option-select/input-icon.svg") govuk-colour("white") no-repeat -5px -3px;

  @include govuk-media-query($from: tablet) {
    @include govuk-font(16);
  }
}

.gem-c-option-select__filter-input.govuk-input {
  padding-left: 33px;
}

.js-enabled {
  .gem-c-option-select__heading {
    position: relative;
    padding: 10px 8px 5px 43px;
    margin: 0;
  }

  [aria-expanded="true"] ~ .gem-c-option-select__icon--up {
    display: block;
  }

  [aria-expanded="false"] ~ .gem-c-option-select__icon--down {
    display: block;
  }

  .gem-c-option-select__container {
    height: 200px;
  }

  .gem-c-option-select__container--large {
    height: 600px;
  }

  [data-closed-on-load="true"] .gem-c-option-select__container {
    display: none;
  }
}

.gem-c-option-select__selected-counter {
  @include govuk-font($size: 14);
  color: $govuk-text-colour;
  margin-top: 3px;
}

.gem-c-option-select.js-closed {
  .gem-c-option-select__filter,
  .gem-c-option-select__container {
    display: none;
  }
}

.gem-c-option-select.js-opened {
  .gem-c-option-select__filter,
  .gem-c-option-select__container {
    display: block;
  }
}