/* ---------- Custom dropdown (pages/shared/js/select.js), proposal B ----------
   The button keeps the pill of the select it replaces (page CSS styles both); the list is a
   square paper plate floating over the page, the chosen option ticked with the marker stroke. */

/* !important: page styles for the original select (e.g. .cmp__select width:100%) must not resize it. */
.dd-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-height: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    clip-path: inset(50%);
    opacity: 0;
    pointer-events: none;
}

.dd {
    position: relative;
    display: flex;
    align-items: center;
    text-align: left;
    white-space: nowrap;
    background-image: none !important;
}

.dd span {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chevron in currentColor, so it follows dark pills (compare) and light ones (filters). */
.dd::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 50%;
    width: 15px;
    height: 15px;
    margin-top: -7.5px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat center / contain;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat center / contain;
    transition: transform .3s var(--ease);
}

.dd[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

.dd__list {
    --ink: #0c0c0c;
    --accent: var(--orange-deep);
    position: fixed;
    z-index: 200;
    max-width: calc(100vw - 16px);
    max-height: 320px;
    margin: 0;
    padding: 8px;
    overflow-y: auto;
    list-style: none;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .6);
    scrollbar-width: thin;
    scrollbar-color: var(--ink) transparent;
    outline: 0;
    animation: dd-in .26s var(--ease);
}

.dd__list.is-up {
    animation-name: dd-in-up;
}

.dd__list li {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px 0 40px;
    border-radius: 999px;
    white-space: nowrap;
    cursor: pointer;
}

.dd__list li.is-active {
    background: rgba(12, 12, 12, .08);
}

/* Chosen option: the marker tick from the sprite, drawn in ink. */
.dd__list li[aria-selected="true"]::before {
    content: "";
    position: absolute;
    left: 14px;
    top: 50%;
    width: 18px;
    height: 15px;
    margin-top: -8px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 40' fill='none' stroke='%230c0c0c' stroke-width='7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 22l13 12L43 5'/%3E%3C/svg%3E") no-repeat center / contain;
}

@keyframes dd-in {
    from {
        opacity: 0;
        clip-path: inset(0 0 100% 0);
    }
    to {
        clip-path: inset(0 0 -40px 0);
    }
}

@keyframes dd-in-up {
    from {
        opacity: 0;
        clip-path: inset(100% 0 0 0);
    }
    to {
        clip-path: inset(-40px 0 0 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .dd__list {
        animation: none;
    }

    .dd::after {
        transition: none;
    }
}
