/* Custom dropdown — light storefront (ERR-82 / shop_design §6.5) */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.custom-dropdown {
  position: relative;
  z-index: 1;
  display: inline-block;
  min-width: 11rem;
  max-width: 100%;
}

.custom-dropdown--full {
  display: block;
  width: 100%;
  min-width: 0;
}

.custom-dropdown.is-open {
  z-index: 120;
}

.custom-dropdown__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.4rem 0.75rem 0.4rem 0.85rem;
  border: 1px solid rgb(108 86 133 / 0.15);
  border-radius: 0.5rem;
  background: #fff;
  color: var(--c-primary);
  font: inherit;
  font-size: 1rem;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    background-color var(--dur) var(--ease);
}

.custom-dropdown__trigger:hover {
  border-color: rgb(108 86 133 / 0.28);
}

.custom-dropdown__trigger:focus-visible,
.custom-dropdown.is-open .custom-dropdown__trigger {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 2px rgb(230 134 26 / 0.35);
  outline: none;
}

.custom-dropdown__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.custom-dropdown__chevron {
  flex: 0 0 auto;
  width: 0.7rem;
  height: 0.45rem;
  background-color: var(--c-primary);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23000' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23000' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  transition: transform var(--dur) var(--ease);
}

.custom-dropdown.is-open .custom-dropdown__chevron {
  transform: rotate(180deg);
}

.custom-dropdown__menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  z-index: 121;
  display: none;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  border: 1px solid rgb(108 86 133 / 0.12);
  border-radius: 0.65rem;
  background: #fff;
  box-shadow: var(--shadow-soft);
  max-height: min(16rem, 50vh);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.custom-dropdown.is-open .custom-dropdown__menu {
  display: block;
}

.custom-dropdown__option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 0.45rem;
  color: var(--c-primary);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}

.custom-dropdown__option:hover,
.custom-dropdown__option.is-active {
  background: rgb(214 228 235 / 0.55);
}

.custom-dropdown__option.is-selected {
  background: rgb(230 134 26 / 0.22);
  color: var(--c-primary);
  font-weight: 700;
}

.custom-dropdown__option.is-selected:hover,
.custom-dropdown__option.is-selected.is-active {
  background: rgb(230 134 26 / 0.34);
}

.custom-dropdown__check {
  flex: 0 0 auto;
  width: 0.85rem;
  height: 0.85rem;
  opacity: 0;
  background-color: var(--c-primary);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23000' d='M5.4 10.6L1.8 7l1.1-1.1 2.5 2.5 5.7-5.7L12.2 4 5.4 10.6z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23000' d='M5.4 10.6L1.8 7l1.1-1.1 2.5 2.5 5.7-5.7L12.2 4 5.4 10.6z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.custom-dropdown__option.is-selected .custom-dropdown__check {
  opacity: 1;
}

.catalog-filters__sort .custom-dropdown {
  width: min(100%, 16.5rem);
}

@media (max-width: 639px) {
  .catalog-filters__sort {
    flex: 1 1 100%;
  }

  .catalog-filters__sort .custom-dropdown {
    width: 100%;
  }

  .custom-dropdown__menu {
    max-height: min(14rem, 42vh);
  }
}

@supports (-webkit-touch-callout: none) {
  .custom-dropdown__trigger {
    min-height: 2.875rem;
  }

  .custom-dropdown__option {
    min-height: 2.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .custom-dropdown__trigger,
  .custom-dropdown__chevron,
  .custom-dropdown__option {
    transition: none;
  }
}
