.legacy-button {
    display: inline-block;
    box-sizing: border-box;
    border: 1px solid var(--sammo-button-base1-border);
    border-radius: 3px;
    padding: 5px 10px;
    background: var(--sammo-button-base1-bg);
    color: #fff;
    font: inherit;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition:
        color 0.15s ease-in-out,
        background-color 0.15s ease-in-out,
        border-color 0.15s ease-in-out,
        box-shadow 0.15s ease-in-out;
}

.legacy-button:hover,
.legacy-button:focus,
.legacy-button:active {
    border-color: var(--sammo-button-base1-hover-border);
    background: var(--sammo-button-base1-hover-bg);
    color: #fff;
}

.legacy-button:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgb(85 115 146 / 50%);
}

.legacy-button:disabled,
.legacy-button[aria-disabled='true'] {
    cursor: default;
    opacity: 0.65;
}

/*
 * Compact sorting controls used by the Ref-style directory pages. Native
 * dark-mode selects vary by browser, so both the closed control and its option
 * popup own an explicit high-contrast palette. The submit control keeps a
 * raised face and pressed edge without increasing the legacy title row.
 */
.legacy-sort-form {
    min-height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 0;
}

.legacy-sort-select,
.legacy-sort-submit {
    box-sizing: border-box;
    height: 25px;
    font: inherit;
}

.legacy-sort-select {
    min-width: 78px;
    border: 1px solid #91a39a;
    border-radius: 3px;
    padding: 1px 24px 1px 6px;
    background-color: #18231d;
    color: #f7faf8;
    color-scheme: dark;
    cursor: pointer;
}

.legacy-sort-select option {
    background-color: #18231d;
    color: #f7faf8;
}

.legacy-sort-select option:checked {
    background-color: #375a7f;
    color: #fff;
}

.legacy-sort-submit {
    margin-top: 0;
    border-color: #27405a;
    border-style: solid;
    border-width: 0 1px 3px;
    border-radius: 3px;
    padding: 1px 9px;
    background: #375a7f;
    color: #fff;
    font-weight: 700;
    line-height: 21px;
    vertical-align: middle;
    cursor: pointer;
}

.legacy-sort-submit:hover {
    margin-top: 1px;
    border-bottom-width: 2px;
}

.legacy-sort-submit:active {
    margin-top: 2px;
    border-bottom-width: 1px;
}

.legacy-sort-select:focus-visible,
.legacy-sort-submit:focus-visible,
.legacy-sort-header:focus-visible {
    outline: 2px solid var(--sammo-color-accent);
    outline-offset: 1px;
}

.legacy-sort-header {
    width: 100%;
    min-height: 18px;
    margin: 0;
    border: 0;
    padding: 0 2px;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: inherit;
    cursor: pointer;
}

.legacy-sort-header:hover {
    background: rgb(255 255 255 / 12%);
}

.legacy-sort-indicator {
    margin-left: 2px;
    color: #9ee7ba;
    font-size: 0.75em;
    opacity: 0.65;
}

[aria-sort] .legacy-sort-indicator {
    opacity: 1;
}

/*
 * Ref Bootstrap 5.2 + Lumen button family. This class owns the common raised
 * edge and pressed movement. Semantic modifiers below only select face, edge,
 * and text colors; width and the optional fixed-height value stay with the owner.
 * Existing semantic modifiers also opt in for backward compatibility.
 */
.legacy-button:is(
    .legacy-button--lumen,
    .legacy-button--primary,
    .legacy-button--secondary,
    .legacy-button--danger,
    .legacy-button--info,
    .legacy-button--navigation,
    .legacy-button--dark
) {
    --legacy-button-bg: var(--sammo-button-primary-bg);
    --legacy-button-border: var(--sammo-button-primary-border);
    --legacy-button-color: #fff;
    margin-top: 0;
    border-color: var(--legacy-button-border);
    border-style: solid;
    border-width: 0 1px 4px;
    border-radius: 5.25px;
    padding: 5.25px 10.5px;
    background: var(--legacy-button-bg);
    color: var(--legacy-button-color);
    filter: none;
    line-height: 21px;
    /* Ref's framework baseline for these controls. */
    vertical-align: middle;
}

/*
 * Top bars and other fixed rows keep their owner-provided height while using
 * the same Lumen edge movement. Shrinking the box with the edge keeps its
 * bottom coordinate fixed instead of moving the whole control down.
 */
.legacy-button.legacy-button--fixed-height {
    height: var(--legacy-button-height);
}

.legacy-button.legacy-button--secondary {
    --legacy-button-bg: var(--sammo-button-secondary-bg);
    --legacy-button-border: var(--sammo-button-secondary-border);
}

.legacy-button.legacy-button--danger {
    --legacy-button-bg: var(--sammo-button-danger-bg);
    --legacy-button-border: var(--sammo-button-danger-border);
}

.legacy-button.legacy-button--info {
    --legacy-button-bg: var(--sammo-button-info-bg);
    --legacy-button-border: var(--sammo-button-info-border);
}

.legacy-button.legacy-button--navigation {
    --legacy-button-bg: var(--sammo-button-navigation-bg);
    --legacy-button-border: var(--sammo-button-navigation-border);
}

.legacy-button.legacy-button--dark {
    --legacy-button-bg: var(--sammo-button-dark-bg);
    --legacy-button-border: var(--sammo-button-dark-border);
}

.legacy-button:is(
        .legacy-button--lumen,
        .legacy-button--primary,
        .legacy-button--secondary,
        .legacy-button--danger,
        .legacy-button--info,
        .legacy-button--navigation,
        .legacy-button--dark
    ):not(:disabled, [aria-disabled='true']):hover {
    margin-top: 1px;
    border-color: var(--legacy-button-border);
    border-bottom-width: 3px;
    background: var(--legacy-button-bg);
}

.legacy-button.legacy-button--fixed-height:not(:disabled, [aria-disabled='true']):is(:hover, [aria-expanded='true']) {
    height: calc(var(--legacy-button-height) - 1px);
}

.legacy-button:is(
        .legacy-button--lumen,
        .legacy-button--primary,
        .legacy-button--secondary,
        .legacy-button--danger,
        .legacy-button--info,
        .legacy-button--navigation,
        .legacy-button--dark
    ):not(:disabled, [aria-disabled='true'])[aria-expanded='true'] {
    margin-top: 1px;
    border-color: var(--legacy-button-border);
    border-bottom-width: 3px;
    background: var(--legacy-button-bg);
}

.legacy-button:is(
        .legacy-button--lumen,
        .legacy-button--primary,
        .legacy-button--secondary,
        .legacy-button--danger,
        .legacy-button--info,
        .legacy-button--navigation,
        .legacy-button--dark
    ):not(:disabled, [aria-disabled='true']):active {
    margin-top: 2px;
    border-color: var(--legacy-button-border);
    border-bottom-width: 2px;
    background: var(--legacy-button-bg);
    box-shadow: none;
}

.legacy-button.legacy-button--fixed-height:not(:disabled, [aria-disabled='true']):active {
    height: calc(var(--legacy-button-height) - 2px);
}

.legacy-button:is(
        .legacy-button--lumen,
        .legacy-button--primary,
        .legacy-button--secondary,
        .legacy-button--danger,
        .legacy-button--info,
        .legacy-button--navigation,
        .legacy-button--dark
    ):focus {
    border-color: var(--legacy-button-border);
    background: var(--legacy-button-bg);
}

/*
 * Split controls share one outer silhouette. Keep the main control's right
 * border as the subtle divider while removing every inner corner and the
 * toggle's overlapping left border. These rules intentionally follow the
 * Lumen family so its border shorthand cannot restore the inner rounding.
 */
.legacy-split-button > :is(.main-menu-link, .legacy-split-button__main) {
    border-radius: 5.25px 0 0 5.25px;
}

.legacy-split-button > .legacy-split-button__toggle {
    border-left-width: 0;
    border-radius: 0 5.25px 5.25px 0;
}
