.predictive-search {
  border-width: var(--style-border-width-popover);
  border-style: solid;
  border-color: var(--color-foreground);
  background: var(--color-background);
  z-index: 3;
  border-radius: var(--style-border-radius-popover);
  box-shadow: var(--style-shadow-popover);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--padding-2xl);
  @media screen and (max-width: 749px){
    max-height: 70dvh !important;
  }
}


.predictive-search--search-template {
  z-index: 2;
  width: calc(100% + 0.2rem);
  position: absolute;
  top: 100%;
  left: -0.1rem;
  display: none;
  padding: var(--padding-xl);
}

.predictive-search__results-groups-wrapper {
  border-bottom: 0.1rem solid
    rgb(var(--color-foreground-rgb) / var(--opacity-8));
  padding-bottom: 1rem;
}

@media screen and (max-width: 749px) {
  .predictive-search--header {
    right: 0;
    left: 0;
    top: 100%;
  }

  .predictive-search__results-groups-wrapper {
    flex-direction: column;
  }

  .predictive-search__results-groups-wrapper:not(
      .predictive-search__results-groups-wrapper--no-suggestions
    ) {
    gap: 2rem;
  }
}

@media screen and (min-width: 750px) {
  .predictive-search {
    width: calc(100% + 0.2rem);
  }

  .header predictive-search {
    position: relative;
  }
}

predictive-search[open] .predictive-search,
predictive-search[loading] .predictive-search {
  display: block;
}

.predictive-search__result-group {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 2rem;
}

.predictive-search__result-group:first-child .predictive-search__pages-wrapper {
  display: none;
}

@media screen and (min-width: 750px) {
  .predictive-search__results-groups-wrapper--no-products
    .predictive-search__result-group:nth-child(2),
  .predictive-search__result-group:last-child
    .predictive-search__pages-wrapper {
    display: none;
  }
  .predictive-search__result-group:first-child
    .predictive-search__pages-wrapper {
    display: initial;
  }
}

.predictive-search__heading {
  margin: 0;
  padding: 1.5rem 0 0.75rem;
  color: rgb(var(--color-foreground-rgb) / var(--opacity-70));
  border-bottom: 0.1rem solid rgb(var(--color-foreground-rgb) / var(--opacity-10));
}

predictive-search .spinner {
  width: 1.5rem;
  height: 1.5rem;
  line-height: 0;
}

predictive-search:not([loading]) .predictive-search__loading-state,
predictive-search:not([loading]) .predictive-search-status__loading {
  display: none;
}

predictive-search[loading] .predictive-search__loading-state {
  display: flex;
  justify-content: center;
  padding: 1rem;
}

predictive-search[loading] .predictive-search__search-for-button {
  display: none;
}

predictive-search[loading]
  .predictive-search__results-groups-wrapper
  ~ .predictive-search__loading-state {
  display: none;
}

predictive-search[loading]
  .predictive-search__results-groups-wrapper
  ~ .predictive-search__search-for-button {
  display: initial;
}

.predictive-search__list-item[aria-selected="true"] > *,
.predictive-search__list-item:hover > *,
.predictive-search__item[aria-selected="true"],
.predictive-search__item:hover {
  color: var(--color-foreground);
  background-color: rgb(var(--color-foreground-rgb) / var(--opacity-4));
}

.predictive-search__item {
  display: flex;
  padding: 1.2rem 2rem;
  text-align: left;
  text-decoration: none;
  width: 100%;

  &.link {
    text-transform: initial;
  }

  &:not(.predictive-search__item--term).link {
    display: inline-flex;
    width: initial;
  }
}

.predictive-search__item--link-with-thumbnail {
  display: grid;
  grid-template-columns: 5rem 1fr;
  grid-column-gap: 2rem;
  grid-template-areas: "product-image product-content";
}

.predictive-search__item-content {
  grid-area: product-content;
  display: flex;
  flex-direction: column;
}

.link .predictive-search__item-content {
  display: inline;
}

.predictive-search__item-content--centered {
  justify-content: center;
}

.predictive-search__item-vendor {
  font-size: 0.9rem;
}

.predictive-search__item-heading {
  margin: 0;
}

.predictive-search__item-query-result *:not(mark) {
  font-weight: bolder;
}

.predictive-search__item-query-result mark {
  color: rgb(var(--color-foreground-rgb) / var(--opacity-75));
}

.predictive-search__item-query-result mark {
  background-color: transparent;
}

.predictive-search__item .price {
  color: rgb(var(--color-foreground-rgb) / var(--opacity-70));
  font-size: 1.2rem;
}

.predictive-search__item-vendor + .predictive-search__item-heading,
.predictive-search .price {
  margin-top: 0.5rem;
}

.predictive-search__item--term {
  justify-content: space-between;
  align-items: center;
  word-break: break-all;
}

@media screen and (min-width: 750px) {
  .predictive-search__item--term {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
}

.predictive-search__item--term .icon-arrow {
  width: 1.4rem;
  height: 1.4rem;
  flex-shrink: 0;
  color: var(--color-primary);
}

.predictive-search__image {
  grid-area: product-image;
  object-fit: contain;
  font-family: "object-fit: contain";
}

/* header search */
.search-modal.search-modal--full {
  --style-shadow-popover: none;
  inset: 0;
  position: fixed;
  background: transparent;
  display: block;

  .modal-overlay::after {
    top: 0;
    background: rgba(var(--color-foreground-rgb) / var(--opacity-70));
  }

  .search-modal__content {
    align-items: flex-start;
    padding: 0;
    padding-top: 4.4rem;
    background: var(--color-white);
    height: auto;
  }

  .predictive-search--center {
    display: grid;
    grid-template-columns: minmax(1.6rem, 1fr) min(calc((150rem + 1.6rem * 2) - 1.6rem * 2), calc(100% - 1.6rem * 2)) minmax(1.6rem, 1fr);
    max-height: 80dvh;
    > *{
      grid-column: 2;
    }
  }

  @media screen and (min-width: 1025px) {
    .search-modal__form {
      max-width: 100%;
    }
  }
}

.search-modal:has(predictive-search),
.search-drawer:has(predictive-search) {

  .predictive-search {
    margin-top: var(--padding-2xl);
    border: none;
  }
  .search__button {
    z-index: 1;
  }

  .search__button:not(:focus-visible):not(.focused),
  .reset__button:not(:focus-visible):not(.focused),
  .search__button,
  .reset__button {
    background-color: var(--color-primary-button-background);
  }

  .search__input.field__input {
    box-shadow: none;
  }

  .field:after {
    box-shadow: none;
    height: 1px;
    top: auto;
    bottom: 0;
    background-color: rgba(var(--color-foreground-rgb) / var(--opacity-100));
    transform: scaleX(0);
    transition: transform var(--duration-extra-long) var(--ease-out-smooth);
    transform-origin: left;
  }

  .field:hover .field:after {
    box-shadow: none;
  }

  .predictive-search--center .field__label {
    left: calc(var(--inputs-border-width) + var(--minimum-touch-target));
  }

  .reset__button {
    top: 0;
    &::after{
      border: none;
    }
  }
}

.search-modal:has(predictive-search) {
  .predictive-search {
    border-top: 0.1rem solid rgb(var(--color-foreground-rgb) / var(--opacity-8));
  }
  .search__button {
    left: var(--inputs-border-width);
    right: auto;
  }

  .search__input.field__input {
    padding-left: calc(var(--minimum-touch-target) + var(--margin-xs));
  }

  .predictive-search--center .field__label {
    left: calc(var(--inputs-border-width) + calc(var(--minimum-touch-target) + 1rem));
  }
}

.search-drawer:has(predictive-search) {
  .search__button {
    top: -.1rem;
    right: -.1rem;
    left: unset;
  }

  .search__input.field__input {
    border-radius: unset;
    padding-left: 0;
  }

  .predictive-search--center .field__label {
    left: 0;
  }
}

details[open] > .search-modal.search-modal--full,
.search-drawer.active {
  .field:after {
    transform: scaleX(1);
  }
}

.predictive-search-results__wrapper {
  padding-block-end: var(--padding-sm);
  padding-inline: 0;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 var(--padding-xl);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.predictive-search-results__wrapper.predictive-search-results__wrapper-queries {
  margin-block: var(--margin-lg);
  gap: var(--gap-lg);
}

.predictive-search-results__pill {
  font-weight: 500;
  white-space: nowrap;
  color: var(--color-foreground);
  transition: background-color var(--animation-speed-medium)
      var(--animation-timing-hover),
    box-shadow var(--animation-speed-medium) var(--animation-timing-bounce),
    transform var(--animation-speed-medium) var(--animation-timing-bounce);
  background: rgba(var(--color-foreground-rgb) / .1);
  padding: 6px 8px;
  &.link {
    text-transform: initial;
  }

  @media (hover: hover) {
    &:hover {
      background-color: var(--pills-pill-background-color);
    }
  }
}
