/* CommandMenu — organism. Spec: component-specs/command-menu.md */

.command-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-settings-modal) - 1);
    background: #000000d9;
    animation: command-menu-fade-in 0.175s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

[data-theme='light'] .command-menu-overlay {
    background: #ffffffa6;
}

@keyframes command-menu-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.command-menu-dialog {
    position: fixed;
    top: 13vh;
    left: 50%;
    width: min(720px, calc(100vw - 32px));
    max-height: min(73vh, 500px);
    z-index: var(--z-settings-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: var(--border-hairline) solid #ffffff12;
    border-radius: 12px;
    /* The page background — border + shadow define it against the dim. */
    background: var(--surface-canvas);
    box-shadow: var(--shadow-elevated);
    transform: translateX(-50%);
    transform-origin: top center;
    animation: command-menu-scale-in 0.175s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

[data-theme='light'] .command-menu-dialog {
    border-color: #0000000f;
}

@keyframes command-menu-scale-in {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

/* < 640px: full-screen takeover, slide-up entrance, close button appears. */
@media (width <= 640px) {
    .command-menu-dialog {
        top: 0;
        left: 0;
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border: none;
        border-radius: 0;
        transform: none;
        transform-origin: center;
        animation-name: command-menu-slide-up;
    }
}

@keyframes command-menu-slide-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.command-menu-combobox {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.command-menu-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    height: 46px;
    padding-inline: 18px;
    border-bottom: var(--border-hairline) solid #ffffff12;
    color: var(--text-quaternary);
}

[data-theme='light'] .command-menu-input-wrap {
    border-bottom-color: #0000000f;
}

.command-menu-input {
    flex: 1;
    height: 100%;
    border: none;
    background: none;
    font-size: 15px;
    color: var(--text-secondary);
    caret-color: var(--action-accent-bg);
}

/* The dialog is already a focus trap — a ring around the always-focused
 * input reads as noise. The library's one sanctioned suppression. */
.command-menu-input:focus-visible {
    outline: none;
}

.command-menu-input::placeholder {
    color: var(--text-quaternary);
}

.command-menu-close {
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    margin-right: -6px;
    border: none;
    background: none;
    color: var(--text-tertiary);
    cursor: pointer;
}

@media (any-hover: hover) {
    .command-menu-close:hover {
        color: var(--text-primary);
    }
}

@media (width <= 640px) {
    .command-menu-close {
        display: inline-flex;
    }
}

.command-menu-list {
    overflow-y: auto;
    padding: 6px;
}

.command-menu-group + .command-menu-group {
    margin-top: 4px;
}

.command-menu-group-heading {
    display: flex;
    align-items: center;
    height: 30px;
    padding-inline: 8px;
    font-size: var(--text-mini-size);
    font-weight: var(--font-weight-medium);
    color: var(--text-tertiary);
}

/* Result rows: the left-nav rhythm; selection/hover changes text color only. */
.command-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: var(--text-mini-size);
    font-weight: var(--font-weight-medium);
    line-height: 1.2;
    color: var(--text-tertiary);
    cursor: pointer;
}

.command-menu-item[aria-selected='true'] {
    color: var(--text-primary);
}

.command-menu-item-nested {
    padding-left: 26px;
    font-weight: var(--font-weight-normal);
}

.command-menu-empty {
    padding-block: 20px;
    text-align: center;
    font-size: 14px;
    color: var(--text-tertiary);
}
