/* Shared presentation for the whole-documentation selector, above Search.
   Built from a button + listbox (no native <select>) so it looks identical
   on every OS and browser. */
.version-switcher {
    padding: 0 var(--sidebar-item-spacing-horizontal);
    margin-bottom: var(--sidebar-item-spacing-vertical);
}

.version-switcher-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: var(--sidebar-caption-font-size);
    font-weight: bold;
    color: var(--color-sidebar-caption-text);
}

.version-switcher-control {
    position: relative;
}

/* Trigger button */
.version-switcher-button {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    display: block;
    width: 100%;
    margin: 0;
    padding: 0.4rem 2rem 0.4rem 0.6rem;
    font: inherit;
    font-size: var(--sidebar-item-font-size);
    line-height: 1.4;
    text-align: left;
    color: var(--color-foreground-primary);
    background: var(--color-background-primary);
    border: 1px solid var(--color-background-border);
    border-radius: 0.25rem;
    box-shadow: none;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.version-switcher-button::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 0.6rem;
    width: 0.75rem;
    height: 0.75rem;
    transform: translateY(-50%);
    background-color: var(--color-foreground-secondary);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 6l4.5 4.5L12.5 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 6l4.5 4.5L12.5 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform 0.15s ease;
}

.version-switcher-button[aria-expanded="true"]::after {
    transform: translateY(-50%) rotate(180deg);
}

.version-switcher-button:hover {
    border-color: var(--color-foreground-border);
}

.version-switcher-button:focus {
    outline: none;
}

.version-switcher-button:focus-visible,
.version-switcher-button[aria-expanded="true"] {
    border-color: var(--color-brand-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-brand-primary) 30%, transparent);
}

/* Dropdown list */
.version-switcher-list {
    position: absolute;
    z-index: 100;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    max-height: 16rem;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-background-primary);
    border: 1px solid var(--color-background-border);
    border-radius: 0.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.version-switcher-list[hidden] {
    display: none;
}

.version-switcher-list:focus {
    outline: none;
}

.version-switcher-option {
    position: relative;
    margin: 0;
    padding: 0.35rem 0.5rem 0.35rem 1.6rem;
    font-size: var(--sidebar-item-font-size);
    line-height: 1.4;
    color: var(--color-foreground-primary);
    border-radius: 0.2rem;
    cursor: pointer;
    user-select: none;
}

.version-switcher-option.is-active {
    background: var(--color-background-hover);
}

.version-switcher-option[aria-selected="true"] {
    font-weight: 600;
    color: var(--color-brand-primary);
}

/* Checkmark on the current version */
.version-switcher-option[aria-selected="true"]::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0.45rem;
    width: 0.75rem;
    height: 0.75rem;
    transform: translateY(-50%);
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.5 3.5L13 4.5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.5 3.5L13 4.5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
