.search-modal,
.cart-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
}

.cart-modal {
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-modal[hidden],
.cart-modal[hidden] {
  display: none;
}

.search-modal__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgb(10, 10, 10);
}

.cart-modal__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.8);
}

.search-modal__lift {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  padding-top: 20vh;
  pointer-events: none;
}

.search-modal__dialog {
  pointer-events: auto;
  width: 500px;
  max-width: 100%;
  max-height: min(496px, calc(100vh - 30px));
  background: #ffffff;
  color: rgb(10, 10, 10);
  box-shadow: rgba(0, 0, 0, 0.2) 0 20px 40px 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.search-modal__bar {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 12px;
  min-height: 55px;
  padding: 12px 20px;
}

.search-modal__icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: rgb(10, 10, 10);
}

.search-modal__input {
  flex: 1;
  min-width: 0;
  height: 32px;
  border: 0;
  outline: none;
  background: transparent;
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 500;
  line-height: 32px;
  color: rgb(10, 10, 10);
  text-transform: none;
}

.search-modal__input::placeholder {
  color: rgb(10, 10, 10);
  text-transform: uppercase;
}

.search-modal__clear {
  flex-shrink: 0;
  border: 0;
  background: none;
  padding: 0;
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 500;
  line-height: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgb(10, 10, 10);
  cursor: pointer;
}

.search-modal__results {
  overflow-y: auto;
  flex: 1;
}

.search-modal__result {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 75px;
  padding: 16px 20px;
  color: rgb(10, 10, 10);
  text-decoration: none;
}

.search-modal__result:hover,
.search-modal__result.is-active {
  background-color: #f5f5f5;
}

.search-modal__result-title {
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 500;
  line-height: 19px;
  color: rgb(10, 10, 10);
}

.search-modal__result-path {
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
  color: #888888;
}

.search-modal__empty {
  padding: 20px;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  color: #888888;
}

.cart-modal__dialog {
  position: relative;
  z-index: 1;
  width: 400px;
  max-width: calc(100% - 32px);
  max-height: min(80vh, 640px);
  background: #ffffff;
  display: flex;
  flex-direction: column;
}

.cart-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 16px 20px;
}

.cart-modal__title {
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  line-height: 17px;
  text-transform: uppercase;
  color: rgb(10, 10, 10);
}

.cart-modal__close {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  color: rgb(10, 10, 10);
  cursor: pointer;
}

.cart-modal__close .icon {
  width: 16px;
  height: 16px;
}

.cart-modal__items {
  overflow-y: auto;
  max-height: 320px;
}

.cart-modal__item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid #eeeeee;
}

.cart-modal__item-img {
  width: 64px;
  height: 80px;
  object-fit: cover;
  background: #f5f5f5;
}

.cart-modal__item-name {
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  line-height: 17px;
  text-transform: uppercase;
}

.cart-modal__item-meta {
  margin-top: 4px;
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
  color: #888888;
}

.cart-modal__item-price {
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
}

.cart-modal__foot {
  padding: 16px 20px 20px;
  border-top: 1px solid #eeeeee;
}

.cart-modal__subtotal {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
}

.cart-modal__checkout {
  width: 100%;
}

.cart-modal__clear-all {
  display: block;
  width: 100%;
  margin-top: 12px;
  border: 0;
  background: none;
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 500;
  line-height: 14px;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 2px;
  color: rgb(10, 10, 10);
  cursor: pointer;
}

body.is-search-open,
body.is-cart-open {
  overflow: hidden;
}

@media (max-width: 809px) {
  .search-modal,
  .search-modal__lift {
    height: 100dvh;
    min-height: 100dvh;
  }

  .search-modal__lift {
    padding-top: 0;
    align-items: stretch;
    justify-content: flex-start;
  }

  .search-modal__dialog {
    width: 100%;
    max-width: none;
    max-height: 100dvh;
    box-shadow: none;
  }

  .search-modal__bar {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .search-modal__results {
    max-height: calc(100dvh - 55px - env(safe-area-inset-top, 0px));
  }
}
