/* -------------------------------- 

File#: _2_autocomplete
Title: Autocomplete
Descr: Autocomplete plugin for input elements
Usage: codyhouse.co/license

-------------------------------- */
/* reset */
*, *::after, *::before {
  box-sizing: border-box;
}

* {
  font: inherit;
  margin: 0;
  padding: 0;
  border: 0;
}

body {
  background-color: hsl(0, 0%, 100%);
  font-family: system-ui, sans-serif;
  color: hsl(230, 7%, 23%);
  font-size: 1rem;
}

h1, h2, h3, h4 {
  line-height: 1.2;
  color: hsl(230, 13%, 9%);
  font-weight: 700;
}

h1 {
  font-size: 2.0736rem;
}

h2 {
  font-size: 1.728rem;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1.2rem;
}

ol, ul, menu {
  list-style: none;
}

button, input, textarea, select {
  background-color: transparent;
  border-radius: 0;
  color: inherit;
  line-height: inherit;
  appearance: none;
}

textarea {
  resize: vertical;
  overflow: auto;
  vertical-align: top;
}

a {
  color: hsl(250, 84%, 54%);
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

img, video, svg {
  display: block;
  max-width: 100%;
}

@media (min-width: 64rem) {
  body {
    font-size: 1.25rem;
  }

  h1 {
    font-size: 3.051rem;
  }

    h2 {
    font-size: 2.44rem;
  }

    h3 {
    font-size: 1.75rem;
  }

    h4 {
    font-size: 1.5625rem;
  }
}

/* variables */
:root {
  /* colors */
  --am2-color-primary-hsl: 250, 84%, 54%;
  --am2-color-bg-hsl: 0, 0%, 100%;
  --am2-color-contrast-high-hsl: 230, 7%, 23%;
  --am2-color-contrast-higher-hsl: 230, 13%, 9%;
  --am2-color-bg-light-hsl: 0, 0%, 100%;
  --am2-color-bg-dark-hsl: 240, 4%, 95%;
  --am2-color-contrast-lower-hsl: 240, 4%, 85%;
  --am2-color-contrast-low-hsl: 240, 4%, 65%;

  /* spacing */
  --am2-space-2xs: 0.375rem;
  --am2-space-xs: 0.5rem;
  --am2-space-sm: 0.75rem;

  /* typography */
  --am2-text-sm: 0.833rem;
}

@media(min-width: 64rem){
  :root {
    /* spacing */
    --am2-space-2xs: 0.5625rem;
    --am2-space-xs: 0.75rem;
    --am2-space-sm: 1.125rem;

    /* typography */
    --am2-text-sm: 1rem;
  }
}

/* form elements */
.am2-form-control {
  font-size: 1em;
  padding: var(--am2-space-2xs) var(--am2-space-xs);
  background: hsl(var(--am2-color-bg-dark-hsl));
  line-height: 1.2;
  box-shadow: inset 0px 0px 0px 1px hsl(var(--am2-color-contrast-lower-hsl));
  transition: all 0.2s ease;
  border-radius: 0.25em;
}

.am2-form-control::placeholder {
  opacity: 1;
  color: hsl(var(--am2-color-contrast-low-hsl));
}

.am2-form-control:focus, .am2-form-control:focus-within {
  background: hsl(var(--am2-color-bg-hsl));
  box-shadow: inset 0px 0px 0px 1px hsla(var(--am2-color-contrast-lower-hsl), 0), 0px 0px 0px 2px hsl(var(--am2-color-primary-hsl)), 0 0.3px 0.4px rgba(0, 0, 0, 0.025),0 0.9px 1.5px rgba(0, 0, 0, 0.05), 0 3.5px 6px rgba(0, 0, 0, 0.1);
  outline: none;
}

.am2-form-label {
  display: inline-block;
  font-size: var(--am2-text-sm);
}

/* component */
:root {
  --autocomplete-dropdown-vertical-gap: 4px;
  /* gap between input and results list */
  --autocomplete-dropdown-max-height: 150px;
  --autocomplete-dropdown-scrollbar-width: 6px;
  /* custom scrollbar width - webkit browsers */
}

.autocomplete__loader {
  /* loader visible while searching */
  /* CSS variables inherited from the circle-loader component */
  --circle-loader-v1-size: 1em;
  --circle-loader-v1-stroke-width: 2px;
}

.autocomplete:not(.autocomplete--searching) .autocomplete__loader {
  /* .autocomplete--searching is used to show the loader element - added in JS */
  display: none;
}

/* results dropdown  */
.autocomplete__results {
  position: absolute;
  z-index: 5;
  width: 100%;
  left: 0;
  top: calc(100% + var(--autocomplete-dropdown-vertical-gap));
  -webkit-transform: translateY(4px);
          transform: translateY(4px);
  /* slide in animation */
  background-color: hsl(var(--am2-color-bg-light-hsl));
  box-shadow: inset 0 0 0.5px 1px hsla(0, 0%, 100%, 0.075), 0 0.9px 1.5px rgba(0, 0, 0, 0.03),0 3.1px 5.5px rgba(0, 0, 0, 0.08),0 14px 25px rgba(0, 0, 0, 0.12);
  border-radius: 0.25em;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0s 0.3s, -webkit-transform 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19);
  transition: opacity 0.3s, visibility 0s 0.3s, transform 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19);
  transition: opacity 0.3s, visibility 0s 0.3s, transform 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19), -webkit-transform 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19);
  overflow: hidden;
}
.autocomplete--results-visible .autocomplete__results {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s, -webkit-transform 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.215, 0.61, 0.355, 1), -webkit-transform 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
  -webkit-transform: translateY(0);
          transform: translateY(0);
}

.autocomplete__list {
  max-height: var(--autocomplete-dropdown-max-height);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  /* custom scrollbar */
}
.autocomplete__list::-webkit-scrollbar {
  /* scrollbar width */
  width: var(--autocomplete-dropdown-scrollbar-width);
}
.autocomplete__list::-webkit-scrollbar-track {
  /* progress bar */
  background-color: hsla(var(--am2-color-contrast-higher-hsl), 0.08);
  border-radius: 0;
}
.autocomplete__list::-webkit-scrollbar-thumb {
  /* handle */
  background-color: hsla(var(--am2-color-contrast-higher-hsl), 0.12);
  border-radius: 0;
}
.autocomplete__list::-webkit-scrollbar-thumb:hover {
  background-color: hsla(var(--am2-color-contrast-higher-hsl), 0.2);
}

/* single result item */
.autocomplete__item {
  cursor: pointer;
  transition: 0.2s;
}
.autocomplete__item:hover {
  background-color: hsla(var(--am2-color-contrast-higher-hsl), 0.075);
}
.autocomplete__item:focus {
  outline: none;
  background-color: hsla(var(--am2-color-primary-hsl), 0.15);
}
.autocomplete__item--is-hidden {
  display: none;
}

/* utility classes */
.am2-sr-only {
  position: absolute;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

.am2-text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.am2-padding-x-sm {
  padding-left: var(--am2-space-sm);
  padding-right: var(--am2-space-sm);
}

.am2-padding-y-xs {
  padding-top: var(--am2-space-xs);
  padding-bottom: var(--am2-space-xs);
}

.am2-items-center {
  align-items: center;
}

.am2-flex {
  display: flex;
}

.am2-height-100\% {
  height: 100%;
}

.am2-padding-right-sm {
  padding-right: var(--am2-space-sm);
}

.am2-right-0 {
  right: 0;
}

.am2-top-0 {
  top: 0;
}

.am2-position-absolute {
  position: absolute;
}

.am2-width-100\% {
  width: 100%;
}

.am2-position-relative {
  position: relative;
}

.am2-margin-bottom-2xs {
  margin-bottom: var(--am2-space-2xs);
}