/*
 * Dropdown pill: the site's standard dropdown. See assets/js/pill-select.js and
 * docs/DROPDOWN_PILL.md. The pill copies the GPU compare view pills (Table / Stacked):
 * 34px tall, fully rounded, 0.88rem/800 text, the same resting, hover and open colours.
 * Colours come only from the theme tokens, so html[data-theme="light"] restyles it.
 */

.pctv-pill-select {
    position: relative;
    display: inline-flex;
    max-width: 100%;
    min-width: 0;
    vertical-align: middle;
}

.pctv-pill-select--block {
    display: flex;
    width: 100%;
}

/* The native select stays in the form for submission and no-JS use, out of sight. */
.pctv-pill-select__native,
.pctv-pill-select__sr {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-height: 0 !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    border: 0 !important;
    white-space: nowrap !important;
    pointer-events: none;
}

body .pctv-pill-select__button {
    display: inline-flex;
    width: auto;
    max-width: 100%;
    min-width: 0;
    min-height: 34px;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    margin: 0;
    padding: 0.3rem 0.7rem 0.3rem 0.85rem;
    border: 1px solid rgba(232, 239, 234, 0.34);
    border-radius: 999px;
    background: var(--nc-surface-2);
    color: var(--nc-text-strong);
    font: 800 0.88rem/1.2 var(--nc-font-sans, inherit);
    letter-spacing: normal;
    text-align: start;
    text-transform: none;
    box-shadow: none;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.pctv-pill-select--block .pctv-pill-select__button {
    width: 100%;
    min-height: 40px;
}

.pctv-pill-select__value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pctv-pill-select.is-placeholder .pctv-pill-select__value {
    color: var(--nc-text-secondary);
}

.pctv-pill-select__chevron {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    opacity: 0.8;
    transition: transform 160ms ease;
}

.pctv-pill-select.is-open .pctv-pill-select__chevron {
    transform: rotate(180deg);
}

body .pctv-pill-select__button:hover,
.pctv-pill-select.is-open .pctv-pill-select__button {
    border-color: var(--nc-accent);
    background: var(--nc-surface-3);
    color: var(--nc-link-hover);
    box-shadow: 0 0 0 1px rgba(35, 136, 255, 0.22);
}

body .pctv-pill-select__button:focus {
    outline: none;
}

body .pctv-pill-select__button:focus-visible {
    border-color: var(--nc-accent);
    outline: 2px solid var(--nc-focus);
    outline-offset: 2px;
}

.pctv-pill-select.is-invalid .pctv-pill-select__button {
    border-color: var(--nc-danger);
}

body .pctv-pill-select__button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    border-color: var(--nc-border);
    background: var(--nc-surface-2);
    color: var(--nc-text-muted);
    box-shadow: none;
}

/* Menu */
.pctv-pill-select__menu {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100000;
    box-sizing: border-box;
    min-width: 12rem;
    margin: 0;
    padding: 0.3rem;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    list-style: none;
    border: 1px solid var(--nc-border);
    border-radius: 12px;
    background: var(--nc-bg-elevated);
    color: var(--nc-text);
    box-shadow: var(--nc-shadow-md);
    font: 600 0.9rem/1.3 var(--nc-font-sans, inherit);
    animation: pctv-pill-select-in 120ms ease-out;
}

.pctv-pill-select__menu[hidden] {
    display: none;
}

.pctv-pill-select__menu ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.pctv-pill-select__group {
    padding: 0.5rem 0.65rem 0.25rem;
    color: var(--nc-text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.pctv-pill-select__option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.55rem 0.75rem 0.55rem 0.5rem;
    border-radius: 8px;
    color: var(--nc-text);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.pctv-pill-select__option + .pctv-pill-select__option {
    margin-top: 1px;
}

.pctv-pill-select__check {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    visibility: hidden;
}

.pctv-pill-select__option.is-active {
    background: var(--nc-surface-3);
    color: var(--nc-text-strong);
}

.pctv-pill-select__option[aria-selected="true"] {
    color: var(--nc-link);
    font-weight: 800;
}

.pctv-pill-select__option[aria-selected="true"] .pctv-pill-select__check {
    visibility: visible;
}

.pctv-pill-select__option[aria-selected="true"].is-active {
    color: var(--nc-link-hover);
}

.pctv-pill-select__option[aria-disabled="true"] {
    color: var(--nc-text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

@media (hover: none) {
    .pctv-pill-select__option {
        padding-block: 0.7rem; /* 44px touch rows */
    }
}

@media (prefers-reduced-motion: reduce) {
    .pctv-pill-select__chevron,
    body .pctv-pill-select__button {
        transition: none;
    }

    .pctv-pill-select__menu {
        animation: none;
    }
}

@keyframes pctv-pill-select-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

.pctv-pill-select.is-above .pctv-pill-select__menu {
    animation-name: pctv-pill-select-in-up;
}

@keyframes pctv-pill-select-in-up {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* Light scheme: same rule the light view pills use. */
html[data-theme="light"] body .pctv-pill-select__button {
    border-color: var(--nc-border-strong);
}

html[data-theme="light"] body .pctv-pill-select__button:hover,
html[data-theme="light"] .pctv-pill-select.is-open .pctv-pill-select__button {
    border-color: var(--nc-accent);
    box-shadow: 0 0 0 1px rgba(22, 102, 209, 0.18);
}

html[data-theme="light"] .pctv-pill-select__option.is-active {
    background: #e8f0fb;
}

html[data-theme="light"] .pctv-pill-select__menu {
    background: #fff;
}

@media (forced-colors: active) {
    .pctv-pill-select__option.is-active {
        outline: 2px solid Highlight;
    }
}
