.ca-search {
  $search-width: 290px !default;

  @include bp(tablet-down) {
    transform: translateY(-100%);
    transition: transform 200ms ease;
    width: 100%;
    position: fixed;
    z-index: $z-index-search;
  }

  @include bp(laptop) {
    margin-top: calc(-#{$search-input-height} / 2);
    position: absolute;
    top: 50%;
    left: 0;
    z-index: $z-index-search-computer;
  }

  &__bar {
    @include bp(tablet-down) {
      @include flex-calign;

      height: $search-height;
      background-color: $c-search-bg;
    }
  }

  &__input-wrap {
    @include flex-valign;

    position: relative;
    height: $search-input-height;
    width: calc(100% - #{$default-spacing});
    border: $border-light;
    background-color: $c-white;
    border-radius: $default-radius;

    @include bp(laptop) {
      width: $search-width;
    }
  }

  &__input {
    flex: 1;
    height: 100%;
    padding: 0 $px16;
    outline: none;

    @include bp(phone-only) {
      font-size: $font-size-m;
    }

    &:focus-visible {
      box-shadow: none;
    }
  }

  &__button {
    @include flex-calign;

    height: 100%;
    width: 40px;
    font-size: 20px;
  }

  &__remove {
    @include flex-calign;

    height: 100%;
    width: 40px;
    font-size: 15px;
    background-color: $c-white;
    position: absolute;
    right: 40px;
  }

  &__title {
    text-transform: uppercase;
    font-weight: $font-weight-bold;

    &--suggestion {
      margin: 0 0 $px8;
    }
  }

  &__suggestions {
    position: fixed;
    background-color: $c-white;
    width: 100%;
    padding: $px16 $px20;
    line-height: 1.6;
    border-radius: $default-radius;

    @include bp(laptop) {
      margin: rem-calc(6px) 0 0;
      width: $search-width;
    }
  }

  &__no-suggestions {
    font-size: $font-size-xs;
    color: $c-text-secondary;
  }

  &__spinner.ca-spinner {
    border-color: var(--accent-color, $c-accent-color);
    width: 30px;
    height: 30px;
    position: absolute;
    top: 40%;
    left: 50%;
    margin: 0 -15px;

    @include bp(laptop) {
      top: 50%;

      &.empty {
        margin: 20px auto;
        position: static;
      }
    }
  }

  &__results-box {
    padding: $px16 $px20 rem-calc(66px);
    overflow: hidden auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;

    @include bp(laptop) {
      overflow-y: hidden;
      padding: $px16 $px20;
    }
  }

  &__no-results {
    color: $c-text-secondary;
    margin: $px10 0;
    font-size: $font-size-l;
    text-align: center;
    width: 100%;
  }

  &__results-wrap {
    display: flex;
    place-content: flex-start space-between;
    flex-wrap: wrap;

    @include bp(laptop) {
      flex-wrap: nowrap;
      justify-content: flex-start;
    }
  }

  &__close-button {
    height: 50px;
    background-color: $c-white;
    width: 100%;
    text-transform: uppercase;
    border-top: $border-light;
    position: fixed;
    bottom: 0;
    left: 0;
  }

  &__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0 0 $px16;
    transition: opacity 200ms ease;
  }

  &__see-all {
    text-decoration: underline;
  }

  &__result {
    width: 320px;
    margin: 0 0 0 $px32;
    transition: opacity 200ms ease;

    @include bp(desktop-down) {
      width: 25vw;
    }

    @include bp(tablet-down) {
      width: 48%;
      margin: 0;
    }

    &--products {
      width: 420px;
      margin: 0;

      @include bp(desktop-down) {
        width: 33vw;
      }

      @include bp(tablet-down) {
        width: 100%;
        margin: 0 0 $px16;
      }
    }
  }

  &__results {
    $vh: calc(var(--vh, 1vh) * 100);

    position: relative;
    background-color: $c-white;
    border-radius: $default-radius;
    height: calc(
      100vh - #{$top-bar-height + $header-bar-height + $search-height}
    );
    height: calc(
      #{$vh} - #{$top-bar-height + $header-bar-height + $search-height}
    );

    @include bp(laptop) {
      position: fixed;
      margin: rem-calc(6px) 0 0;
      height: auto;
      width: auto;
      max-width: 100%;
      transition: max-width 200ms ease;

      &--loading-empty,
      &--no-results {
        width: $search-width;
        max-width: $search-width;
      }
    }

    &--loading:not(&--loading-empty) {
      .ca-search {
        &__top,
        &__result {
          opacity: 0.5;
        }
      }
    }
  }

  &__list-title {
    font-weight: $font-weight-bold;
    margin: 0 0 $px8;
  }

  &__list {
    @include bp(laptop) {
      display: flex;
      flex-flow: column wrap;
      align-content: space-between;
      height: 265px;
    }
  }

  &__item {
    @include bp(laptop) {
      width: 49%;
    }

    &--product {
      margin: 0 0 $px4;

      @include bp(tablet-down) {
        margin: 0;

        &:not(:first-child) {
          margin: rem-calc(6px) 0 0;
        }
      }
    }

    &--tag {
      &:not(:last-child) {
        margin: 0 0 $px8;
      }
    }
  }

  &__item-link {
    &--product {
      display: flex;
      align-items: flex-start;
    }

    &--tag {
      @include ellipsis;

      background-color: $c-light-gray;
      padding: rem-calc(6px) rem-calc(10px);
      display: inline-block;
      width: auto;
      max-width: 100%;
    }
  }

  &__item-image {
    width: rem-calc(40px);
    margin: 0 $px12 0 0;

    @include bp(laptop) {
      width: auto;
      height: rem-calc(49px);
      flex-grow: 1;

      .ca-image {
        &__img {
          width: auto;
          height: 100%;
        }
      }
    }
  }

  &__item-info {
    width: calc(100% - #{rem-calc(52px)});
  }

  &__item-name {
    @include ellipsis;
  }

  &__item-price.ca-price {
    @include ellipsis;

    font-size: 0.8em;
  }

  &__overlay.ca-overlay {
    @include bp(tablet-down) {
      z-index: $z-index-search-overlay;
    }
  }

  &--visible {
    @include bp(tablet-down) {
      transform: translateY(0);
    }
  }
}
