@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 {
  margin: 0;
  @include govuk-font(19);
}

.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;
  flex-shrink: 0;
  width: 30px;
  height: 40px;
  margin-inline: 10px 4px;
  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 {
  background: url("option-select/input-icon.svg") govuk-colour("white") no-repeat -5px -3px;
  @include govuk-font(19);

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

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

.govuk-frontend-supported {
  .gem-c-option-select__heading {
    position: relative;
    margin: 0 0 govuk-spacing(1);
  }

  .gem-c-option-select__toggle {
    display: flex;
    flex-direction: row-reverse;
    justify-content: start;
    align-items: center;
  }

  [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 {
  margin-left: 44px;
  color: $govuk-text-colour;
  @include govuk-font($size: 16, $line-height: 1);
}

.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;
  }
}
