/* keybind_editor.css (2026-10-17) - the Keybind Editor page
   (keybind_editor.php). Cards, buttons, fields and the pop-up come from
   supply_chain.css (.sc-card, .sc-btn, .sc-notify-overlay ...); this adds
   the drop box, the control tables, the key chips and the "press a key" box. */

.kb-page h2,
.kb-page h3 {
    text-align: left;
}

.kb-page .sc-card {
    margin-bottom: 1rem;
}

/* ---------------- Start / drop box ---------------- */
.kb-start {
    border: 2px dashed var(--border-colour);
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kb-start.is-hot {
    border-color: var(--highlight-colour);
    box-shadow: 0 0 18px rgba(92, 212, 255, 0.35);
}

.kb-start h2 {
    margin: 0 0 0.5rem;
    font-size: 1.35rem;
}

.kb-page .kb-start p {
    margin: 0 0 0.7rem;
    text-align: left;
}

.kb-page p.kb-private {
    padding: 0.6rem 0.8rem;
    border: 1px solid rgba(87, 214, 141, 0.55);
    border-radius: var(--radius1, 8px);
    background: rgba(87, 214, 141, 0.08);
    font-size: 0.92rem;
}

.kb-private .fa {
    color: #57d68d;
    margin-right: 0.25rem;
}

.kb-where {
    margin: 0 0 0.9rem;
    font-size: 0.92rem;
}

.kb-where summary,
.kb-type summary {
    cursor: pointer;
    color: var(--highlight-colour);
}

.kb-where ol,
.kb-install ol {
    margin: 0.5rem 0 0;
    padding-left: 1.3rem;
    text-align: left;
}

.kb-where li,
.kb-install li {
    margin-bottom: 0.3rem;
}

.kb-page code {
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.35);
    color: var(--highlight-colour);
    font-size: 0.85em;
    overflow-wrap: anywhere;
}

.kb-start-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.kb-page p.kb-drop-hint {
    margin: 0.6rem 0 0;
    font-size: 0.82rem;
    color: var(--muted, #9ec8e8);
}

.kb-page p.kb-status {
    margin: 0.4rem 0 0;
    font-size: 0.85rem;
    color: var(--muted, #9ec8e8);
}

.kb-page p.kb-status.is-bad {
    color: #ffb36b;
}

/* ---------------- Toolbar ---------------- */
.kb-bar {
    position: sticky;
    top: 0.5rem;
    z-index: 5;
}

.kb-bar-top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
}

.kb-name-field {
    flex: 1 1 14rem;
    max-width: 22rem;
}

.kb-name-field input {
    width: 100%;
}

.kb-bar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.kb-page p.kb-summary {
    margin: 0.7rem 0 0.6rem;
    font-size: 0.88rem;
    color: var(--muted, #9ec8e8);
    text-align: left;
}

.kb-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.kb-filters .sc-filter-pills {
    margin: 0;
}

.kb-cols {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1rem;
    margin-top: 0.6rem;
    font-size: 0.88rem;
}

.kb-cols-lbl {
    color: var(--muted, #9ec8e8);
}

.kb-cols label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
}

.kb-page .kb-cols input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
}

/* ---------------- Groups and tables ---------------- */
.kb-page h2.kb-sec-title {
    margin: 1.4rem 0 0.6rem;
    font-size: 1.2rem;
    letter-spacing: 0.04em;
}

.kb-page .kb-group {
    padding: 0;
    margin-bottom: 0.6rem;
    overflow: hidden;
}

.kb-group-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    list-style: none;
}

.kb-group-head::-webkit-details-marker {
    display: none;
}

.kb-group-head:hover .kb-group-name,
.kb-group-head:focus-visible .kb-group-name {
    color: var(--highlight-colour);
}

.kb-group-name {
    font-weight: bold;
}

.kb-group-count {
    margin-left: auto;
    font-size: 0.82rem;
    color: var(--muted, #9ec8e8);
}

.kb-chev {
    transition: transform 0.15s ease;
}

.kb-group[open] .kb-chev {
    transform: rotate(180deg);
}

.kb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.kb-table th {
    padding: 0.45rem 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    color: var(--highlight-colour);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
}

.kb-table td {
    padding: 0.5rem 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    vertical-align: top;
    text-align: left;
}

.kb-row.is-changed td:first-child {
    box-shadow: inset 3px 0 0 var(--highlight-colour);
}

.kb-c-name {
    width: 40%;
}

.kb-groups.no-km .kb-c-km,
.kb-groups.no-js .kb-c-js,
.kb-groups.no-gp .kb-c-gp {
    display: none;
}

.kb-label {
    font-weight: bold;
}

.kb-tag {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0 0.4rem;
    border: 1px solid var(--highlight-colour);
    border-radius: 999px;
    color: var(--highlight-colour);
    font-size: 0.7rem;
    font-weight: normal;
    vertical-align: middle;
}

.kb-tag.kb-tag-axis {
    border-color: var(--muted, #9ec8e8);
    color: var(--muted, #9ec8e8);
}

.kb-desc {
    margin-top: 0.15rem;
    font-size: 0.82rem;
    color: var(--muted, #9ec8e8);
}

.kb-code {
    margin-top: 0.15rem;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.45);
    overflow-wrap: anywhere;
}

.kb-clash {
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: #ffc46b;
}

/* The key buttons: one per device column, holding a chip per input. */
.kb-bind {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    width: 100%;
    min-height: 34px;
    padding: 0.25rem;
    background: transparent;
    border: 1px dashed transparent;
    border-radius: var(--radius1, 8px);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.kb-bind:hover,
.kb-bind:focus-visible {
    border-color: var(--highlight-colour);
    background: rgba(61, 187, 255, 0.08);
    outline: none;
}

.kb-key {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--border-colour);
    border-bottom-width: 3px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.35);
    font-size: 0.82rem;
    white-space: nowrap;
}

.kb-key.is-default {
    color: rgba(255, 255, 255, 0.78);
}

.kb-key.is-file {
    border-color: var(--highlight-colour);
}

.kb-key.is-edit {
    border-color: var(--highlight-colour);
    background: color-mix(in srgb, var(--highlight-colour) 25%, transparent);
    color: #fff;
}

.kb-bind-empty {
    padding: 0.15rem 0.2rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
}

.kb-page p.kb-none {
    padding: 1.5rem;
    text-align: center;
    color: var(--muted, #9ec8e8);
}

.kb-install.is-hot {
    border-color: var(--highlight-colour);
    box-shadow: 0 0 14px rgba(92, 212, 255, 0.3);
}

.kb-page p.kb-disclaimer {
    margin-top: 1.2rem;
    font-size: 0.8rem;
    color: var(--muted, #9ec8e8);
    text-align: center;
}

/* ---------------- The change box ---------------- */
.kb-modal-card {
    position: relative;
    width: min(560px, 100%);
}

.supply-chain-page .kb-modal-card p.kb-modal-sub {
    margin: -0.4rem 0 0.8rem;
    font-size: 0.85rem;
    color: var(--muted, #9ec8e8);
}

.kb-dev-tabs {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 0.7rem;
    border-bottom: 1px solid var(--border-colour);
}

.kb-dev-tabs button {
    padding: 0.45rem 0.8rem;
    background: transparent;
    border: 0;
    border-bottom: 3px solid transparent;
    color: var(--muted, #9ec8e8);
    font: inherit;
    font-size: 0.88rem;
    cursor: pointer;
}

.kb-dev-tabs button.active {
    border-bottom-color: var(--highlight-colour);
    color: #fff;
}

.supply-chain-page .kb-modal-card p.kb-now {
    margin: 0 0 0.7rem;
    font-size: 0.95rem;
}

.kb-now span {
    font-weight: bold;
    color: var(--highlight-colour);
}

.kb-js-pick {
    margin-bottom: 0.7rem;
}

.kb-js-pick select {
    width: auto;
    min-width: 12rem;
}

.kb-listen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 2px dashed var(--highlight-colour);
    border-radius: var(--radius1, 8px);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font: inherit;
    text-align: center;
    cursor: crosshair;
    user-select: none;
}

.kb-listen:focus-visible,
.kb-listen:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(92, 212, 255, 0.35), 0 0 16px var(--glow-colour);
    animation: kb-pulse 1.6s ease-in-out infinite;
}

.kb-listen.is-got {
    animation: kb-got 0.6s ease;
}

.kb-listen-big {
    font-size: 1.1rem;
    font-weight: bold;
}

.kb-listen-small {
    font-size: 0.8rem;
    color: var(--muted, #9ec8e8);
}

@keyframes kb-pulse {
    50% { border-color: var(--glow-colour); }
}

@keyframes kb-got {
    0% { background: rgba(87, 214, 141, 0.45); }
    100% { background: rgba(0, 0, 0, 0.3); }
}

@media (prefers-reduced-motion: reduce) {
    .kb-listen:focus,
    .kb-listen.is-got {
        animation: none;
    }
}

.kb-type {
    margin: 0.8rem 0 0;
    font-size: 0.9rem;
}

.kb-type-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.kb-type-row input {
    flex: 1;
    min-width: 0;
}

.supply-chain-page .kb-modal-card p.kb-clash {
    margin: 0.7rem 0 0;
    padding: 0.5rem 0.7rem;
    border: 1px solid rgba(255, 196, 107, 0.6);
    border-radius: var(--radius1, 8px);
    background: rgba(255, 196, 107, 0.1);
    color: #ffd79a;
    font-size: 0.85rem;
}

/* ---------------- Phones ---------------- */
@media (max-width: 700px) {
    .kb-bar {
        position: static;
    }

    .kb-table thead {
        display: none;
    }

    .kb-table,
    .kb-table tbody,
    .kb-table tr,
    .kb-table td {
        display: block;
        width: 100%;
    }

    .kb-table tr {
        padding: 0.4rem 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .kb-table td {
        border: 0;
        padding: 0.25rem 0.8rem;
    }

    .kb-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.72rem;
        color: var(--muted, #9ec8e8);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .kb-groups.no-km .kb-c-km,
    .kb-groups.no-js .kb-c-js,
    .kb-groups.no-gp .kb-c-gp {
        display: none;
    }

    .kb-filters .sc-search,
    .kb-filters select {
        flex: 1 1 100%;
        max-width: none;
    }
}

/* High contrast theme: plain borders. */
.theme-contrast .kb-key.is-edit {
    background: #000;
    border-color: #ffe000;
}
