/**
 * Command Palette + Context Menu overlays.
 */

body.katabam-overlay-open {
    overflow: hidden;
}

/* —— Command Palette —— */
.katabam-cmd {
    position: fixed;
    inset: 0;
    z-index: 320;
    display: grid;
    place-items: start center;
    padding: min(18vh, 7.5rem) 1rem 1.5rem;
}

.katabam-cmd__backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
    background: rgba(8, 24, 42, 0.28);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: katabam-overlay-fade 0.22s ease;
}

html.dark .katabam-cmd__backdrop {
    background: rgba(4, 12, 24, 0.55);
}

.katabam-cmd__panel {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid rgba(8, 24, 42, 0.1);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(244, 247, 251, 0.96));
    box-shadow:
        0 0 0 1px rgba(110, 190, 69, 0.08),
        0 24px 64px rgba(8, 24, 42, 0.18);
    animation: katabam-cmd-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    color: var(--katabam-text, #1a1a1a);
}

html.dark .katabam-cmd__panel {
    border-color: rgba(255, 255, 255, 0.1);
    background:
        linear-gradient(180deg, rgba(14, 32, 54, 0.96), rgba(8, 24, 42, 0.98));
    box-shadow:
        0 0 0 1px rgba(110, 190, 69, 0.12),
        0 28px 70px rgba(0, 0, 0, 0.45);
    color: #e8eef4;
}

.katabam-cmd__search {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.95rem 1rem;
    border-bottom: 1px solid rgba(8, 24, 42, 0.08);
}

html.dark .katabam-cmd__search {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.katabam-cmd__search-icon {
    flex-shrink: 0;
    color: var(--katabam-primary);
}

.katabam-cmd__search-icon svg,
.katabam-cmd__close svg {
    display: block;
    stroke: currentColor;
}

.katabam-cmd__input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--katabam-text);
    font: inherit;
    font-size: 1rem;
}

.katabam-cmd__input::placeholder {
    color: var(--katabam-text-muted);
}

.katabam-cmd__kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.7rem;
    height: 1.45rem;
    padding: 0 0.35rem;
    border-radius: 6px;
    border: 1px solid rgba(8, 24, 42, 0.12);
    background: rgba(8, 24, 42, 0.04);
    color: var(--katabam-text-muted);
    font-family: inherit;
    font-size: 0.68rem;
    line-height: 1;
}

html.dark .katabam-cmd__kbd {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
}

.katabam-cmd__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--katabam-text-muted);
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.katabam-cmd__close:hover,
.katabam-cmd__close:focus-visible {
    background: rgba(110, 190, 69, 0.14);
    color: var(--katabam-secondary);
}

html.dark .katabam-cmd__close:hover,
html.dark .katabam-cmd__close:focus-visible {
    color: #fff;
}

.katabam-cmd__list {
    max-height: min(46vh, 360px);
    overflow: auto;
    padding: 0.55rem;
    scrollbar-width: thin;
}

.katabam-cmd__group {
    padding: 0.55rem 0.7rem 0.3rem;
    color: var(--katabam-text-muted);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.katabam-cmd__item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    margin: 0;
    padding: 0.7rem 0.75rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--katabam-text);
    font: inherit;
    text-align: right;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.katabam-cmd__item:hover,
.katabam-cmd__item.is-active {
    background: rgba(110, 190, 69, 0.16);
    color: var(--katabam-secondary);
}

html.dark .katabam-cmd__item:hover,
html.dark .katabam-cmd__item.is-active {
    background: rgba(110, 190, 69, 0.2);
    color: #f8fafc;
}

.katabam-cmd__item-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(8, 24, 42, 0.05);
    color: var(--katabam-secondary);
}

html.dark .katabam-cmd__item-icon {
    background: rgba(255, 255, 255, 0.06);
    color: #e8eef4;
}

.katabam-cmd__item.is-active .katabam-cmd__item-icon,
.katabam-cmd__item:hover .katabam-cmd__item-icon {
    background: rgba(110, 190, 69, 0.22);
    color: var(--katabam-primary-dark, #5aab38);
}

.katabam-cmd__item-label {
    flex: 1;
    min-width: 0;
    color: inherit;
}

.katabam-cmd__item-icon .katabam-icon,
.katabam-cmd__item-icon svg {
    display: block;
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.katabam-cmd__item-keys {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    flex-shrink: 0;
}

.katabam-cmd__item-keys kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.25rem;
    padding: 0 0.28rem;
    border-radius: 5px;
    border: 1px solid rgba(8, 24, 42, 0.12);
    background: rgba(8, 24, 42, 0.04);
    font-family: inherit;
    font-size: 0.65rem;
    line-height: 1;
}

html.dark .katabam-cmd__item-keys kbd {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
}

.katabam-cmd__empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--katabam-text-muted);
    font-size: 0.92rem;
}

.katabam-cmd__footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 1.15rem;
    padding: 0.7rem 1rem;
    border-top: 1px solid rgba(8, 24, 42, 0.08);
    color: var(--katabam-text-muted);
    font-size: 0.72rem;
}

html.dark .katabam-cmd__footer {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.katabam-cmd__footer span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.katabam-cmd__footer kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.25rem;
    padding: 0 0.28rem;
    border-radius: 5px;
    border: 1px solid rgba(8, 24, 42, 0.12);
    background: rgba(8, 24, 42, 0.04);
    font-family: inherit;
    font-size: 0.65rem;
}

html.dark .katabam-cmd__footer kbd {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
}

/* —— Context Menu —— */
.katabam-ctx {
    position: fixed;
    z-index: 330;
    width: max-content;
    min-width: 220px;
    max-width: min(280px, calc(100vw - 20px));
    padding: 0.4rem;
    border-radius: 12px;
    border: 1px solid rgba(8, 24, 42, 0.1);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(244, 247, 251, 0.98));
    box-shadow:
        0 0 0 1px rgba(110, 190, 69, 0.06),
        0 18px 42px rgba(8, 24, 42, 0.16);
    animation: katabam-ctx-in 0.16s ease;
}

html.dark .katabam-ctx {
    border-color: rgba(255, 255, 255, 0.1);
    background:
        linear-gradient(180deg, rgba(16, 34, 56, 0.98), rgba(8, 24, 42, 0.99));
    box-shadow:
        0 0 0 1px rgba(110, 190, 69, 0.1),
        0 20px 48px rgba(0, 0, 0, 0.42);
}

.katabam-ctx__item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    margin: 0;
    padding: 0.58rem 0.7rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--katabam-text);
    font: inherit;
    font-size: 0.88rem;
    text-align: right;
    cursor: pointer;
    transition: background-color 0.14s ease, color 0.14s ease;
}

.katabam-ctx__item:hover,
.katabam-ctx__item:focus-visible {
    background: rgba(110, 190, 69, 0.16);
    color: var(--katabam-secondary);
    outline: none;
}

html.dark .katabam-ctx__item:hover,
html.dark .katabam-ctx__item:focus-visible {
    color: #f8fafc;
}

.katabam-ctx__icon {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    color: var(--katabam-primary);
    flex-shrink: 0;
}

.katabam-ctx__icon .katabam-icon,
.katabam-ctx__icon svg {
    display: block;
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.katabam-ctx__label {
    flex: 1;
    min-width: 0;
}

.katabam-ctx__sep {
    height: 1px;
    margin: 0.35rem 0.45rem;
    background: rgba(8, 24, 42, 0.08);
}

html.dark .katabam-ctx__sep {
    background: rgba(255, 255, 255, 0.08);
}

@keyframes katabam-overlay-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes katabam-cmd-in {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes katabam-ctx-in {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .katabam-cmd__backdrop,
    .katabam-cmd__panel,
    .katabam-ctx {
        animation: none;
    }
}

/* Zen / motion tools */
html.katabam-reduce-motion * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
}

html.katabam-reduce-motion .katabam-cmd__backdrop,
html.katabam-reduce-motion .katabam-cmd__panel,
html.katabam-reduce-motion .katabam-ctx,
html.katabam-reduce-motion .katabam-overlay-toast {
    transition-duration: 0.01ms !important;
}

body.katabam-zen-mode .site-header,
body.katabam-zen-mode .site-footer,
body.katabam-zen-mode .site-mobile-nav {
    display: none !important;
}

body.katabam-zen-mode #content,
body.katabam-zen-mode .site-content {
    padding-top: 0.5rem;
}

.katabam-overlay-toast {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    z-index: 340;
    max-width: min(92vw, 360px);
    padding: 0.65rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(110, 190, 69, 0.35);
    background: rgba(8, 24, 42, 0.92);
    color: #f8fafc;
    font-size: 0.88rem;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 8px);
    transition:
        opacity 0.22s ease,
        visibility 0.22s ease,
        transform 0.22s ease;
    pointer-events: none;
}

.katabam-overlay-toast.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

html.dark .katabam-overlay-toast {
    background: rgba(14, 32, 54, 0.96);
}
