$stacking-order: (
  backdrop: 10,
  content: 20,
  input: 30,
);

.Biblio-Select {
  position: relative;

  // IE 11 fix to remove default dropdown arrow
  select::-ms-expand {
    display: none;
  }
}

.Biblio-Select--disabled {
  .Biblio-Select__Content {
    color: color('ink', 'lightest');
  }

  .Biblio-Select__InlineLabel {
    color: inherit;
  }

  .Biblio-Select__Icon {
    opacity: 0.4;
  }

  .Biblio-Select__Backdrop {
    @include control-backdrop(disabled);
  }
}

.Biblio-Select--error {
  .Biblio-Select__Backdrop {
    @include control-backdrop(error);
  }

  // Need to override the higher specificity of the sibling selector
  // so that errors still have red borders.
  // stylelint-disable-next-line selector-max-specificity
  .Biblio-Select__Input:focus ~ .Biblio-Select__Backdrop {
    @include control-backdrop(focused-error);
  }
}

.Biblio-Select--placeholder {
  // stylelint-disable-next-line selector-max-class
  &.Biblio-Select--error .Biblio-Select__Input {
    // This is the only place this color is used.
    // stylelint-disable-next-line color-no-hex
    color: #9c9798;
  }

  // stylelint-disable-next-line selector-max-class, selector-max-specificity
  &.Biblio-Select--error .Biblio-Select__Input:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 color('ink', 'base');
  }
}

.Biblio-Select__Content {
  @include text-style-input;
  position: relative;
  z-index: z-index(content, $stacking-order);
  display: flex;
  align-items: center;
  width: 100%;
  min-height: control-height();
  padding: control-vertical-padding() rem(8px) control-vertical-padding()
    spacing(base-tight);
}

.Biblio-Select__InlineLabel {
  @include text-emphasis-subdued;
  margin-right: rem(4px);
  white-space: nowrap;
  overflow: hidden;
}

.Biblio-Select__SelectedOption {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
}

.Biblio-Select__Icon {
  @include recolor-icon(color('ink', 'lighter'));
}

.Biblio-Select__Backdrop {
  @include control-backdrop;
  position: absolute;
  z-index: z-index(backdrop, $stacking-order);
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

.Biblio-Select__Input {
  // Even though the input is invisible, text styles apply to the options menu
  @include text-style-input;
  position: absolute;
  top: 0;
  left: 0;
  z-index: z-index(input, $stacking-order);
  width: 100%;
  height: 100%;
  margin: 0;
  // ChromeVox may hide content set to opacity: 0
  opacity: 0.001;
  appearance: none;

  &:focus {
    ~ .Biblio-Select__Backdrop {
      @include control-backdrop(focused);
    }
  }
}

@media (-ms-high-contrast: active) {
  .Biblio-Select__Content {
    color: ms-high-contrast-color('text');
    -ms-high-contrast-adjust: none;
  }

  .Biblio-Select__InlineLabel {
    color: inherit;

    &::after {
      content: ':';
    }
  }

  .Biblio-Select__SelectedOption {
    color: inherit;
  }

  .Biblio-Select__Icon {
    @include recolor-icon(ms-high-contrast-color('button-text'));
  }

  .Biblio-Select__Backdrop {
    &::after {
      // Remove the dotted focus outline from the control-backdrop mixin.
      display: none;
    }
  }

  .Biblio-Select__Input:focus {
    ~ .Biblio-Select__Content {
      color: ms-high-contrast-color('selected-text');
    }

    ~ .Biblio-Select__Backdrop {
      // Align with the native styling for this element, which differs from
      // what the control-backdrop mixin provides.
      background-color: ms-high-contrast-color('selected-text-background');
    }
  }

  .Biblio-Select--disabled {
    .Biblio-Select__Content {
      color: ms-high-contrast-color('disabled-text');
    }

    .Biblio-Select__Icon {
      @include recolor-icon(ms-high-contrast-color('disabled-text'));
      opacity: 1;
    }
  }
}
