/* commands.css — searchable, scannable catalog of every TobyBot slash
   command. Hero + sticky search/filter strip + per-category card grid.
   Reuses base.css design tokens; no new colour variables. */

.commands-page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

/* ---- Hero ---- */
.commands-hero {
    margin-bottom: 28px;
    max-width: 760px;
}
.commands-hero h1 {
    font-size: 2rem;
    color: var(--heading);
    margin: 6px 0 12px;
    line-height: 1.15;
}
.commands-hero .lede {
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 60ch;
    margin-bottom: 18px;
}
.commands-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.meta-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid rgba(88, 101, 242, 0.35);
    color: var(--text);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}
.meta-chip strong {
    color: var(--accent-light);
    margin-right: 4px;
}

/* ---- Sticky toolbar (search + category chips) ---- */
.commands-toolbar {
    position: sticky;
    top: 0;
    /* Stay below `body > nav { z-index: 10 }` (nav.css) so the sticky
       toolbar doesn't punch through the open mobile drawer. Same
       pattern as `.config-search-bar` on the moderation settings page
       (moderation.css). */
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: 14px 0;
    margin-bottom: 28px;
    background: rgba(26, 26, 46, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.commands-search {
    position: relative;
    flex: 1 1 320px;
    min-width: 240px;
}
.commands-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}
/* `input.` prefix bumps specificity to (0,1,1) so this beats the
   shared `input[type=search] { padding: 10px 12px }` rule in base.css
   on source order. Without it the input's left padding stays at 12px
   and the absolutely-positioned search icon at left:14px collides
   with the first character of the placeholder. */
input.commands-search-input {
    width: 100%;
    padding: 11px 44px 11px 40px;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
}
input.commands-search-input::placeholder { color: var(--text-muted); }
input.commands-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.commands-search-kbd {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 1px 7px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    pointer-events: none;
}
.commands-search-input:focus ~ .commands-search-kbd { opacity: 0; }

.commands-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out),
                border-color var(--dur-fast) var(--ease-out);
}
.cat-chip:hover {
    color: var(--text);
    border-color: var(--accent);
}
.cat-chip.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--on-accent);
}
.cat-chip-icon { font-size: 0.95rem; line-height: 1; }

/* ---- Category sections ---- */
.commands-stream {
    display: flex;
    flex-direction: column;
    gap: 56px;
}
.cat-section { scroll-margin-top: 80px; }

/* Category visibility is driven by `[hidden]` on each .cat-section,
   set in commands.js based on the active filter chip and search query.
   The `.cat-section[hidden]` rule lower in this file does the actual
   hide. */

.cat-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.cat-icon {
    font-size: 1.7rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}
.cat-heading { flex: 1; min-width: 0; }
.cat-heading h2 {
    font-size: 1.25rem;
    color: var(--heading);
    margin-bottom: 4px;
    text-transform: none;
    letter-spacing: 0;
}
.cat-blurb {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}
.cat-count {
    flex-shrink: 0;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---- Command cards ---- */
.cmd-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.cmd-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 18px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--dur-base) var(--ease-out),
                transform var(--dur-base) var(--ease-out),
                box-shadow var(--dur-base) var(--ease-out);
}
.cmd-card::before {
    content: "";
    position: absolute;
    left: 0; top: 12px; bottom: 12px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-out);
}
.cmd-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.cmd-card:hover::before { opacity: 1; }
.cmd-card:focus-within {
    border-color: var(--accent);
}

.cmd-card-top {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}
.cmd-pill {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--accent-light);
    background: var(--accent-soft);
    border: 1px solid rgba(88, 101, 242, 0.35);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.cmd-sub-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    white-space: nowrap;
}
.cmd-copy {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out),
                border-color var(--dur-fast) var(--ease-out);
}
.cmd-copy:hover {
    color: var(--accent-light);
    background: var(--accent-soft);
    border-color: rgba(88, 101, 242, 0.35);
}
.cmd-copy.is-copied { color: var(--success); border-color: var(--success); }

.cmd-desc {
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.5;
    margin: 0;
}

/* ---- Option / subcommand lists ---- */
.opt-list, .sub-list {
    list-style: none;
    margin: 4px 0 0;
    padding: 12px 0 0;
    border-top: 1px dashed var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.opt-row { display: flex; flex-direction: column; gap: 3px; }
.opt-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.opt-name {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 500;
}
.opt-type {
    display: inline-block;
    font-size: 0.7rem;
    line-height: 1.4;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-light);
    font-weight: 500;
    letter-spacing: 0.01em;
}
.opt-req {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    padding: 0 6px;
    border-radius: 3px;
    font-weight: 600;
}
.opt-desc {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.45;
    margin: 0;
}
.opt-choices {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.opt-choices li {
    font-size: 0.72rem;
    padding: 1px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
}

/* Subcommand rows look like nested mini-cards */
.sub-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.sub-pill {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
    color: var(--accent-light);
    font-weight: 500;
}
.sub-desc {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.45;
    margin: 0;
}
.sub-opts {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 4px 0 0;
    padding: 0;
}
.sub-opts li {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.sub-opts .opt-type { font-size: 0.65rem; }

/* ---- Empty state ---- */
.commands-empty {
    margin: 0 0 32px;
}
.commands-empty[hidden] { display: none; }
.link-button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
}
.link-button:hover { color: var(--accent-hover); }

/* ---- Cards / sections hidden by search filter ----
   `!important` because the category-show rules above have higher
   specificity than `[hidden]` alone would, and the [hidden] attribute
   here is the JS hatch for "this section/card has nothing visible". */
.cmd-card[hidden],
.cat-section[hidden] { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .commands-page { padding: 28px 16px 60px; }
    .commands-hero h1 { font-size: 1.6rem; }
    .commands-stream { gap: 44px; }
}

@media (max-width: 600px) {
    .commands-page { padding: 20px 14px 60px; }
    .commands-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 0 10px;
        gap: 10px;
    }
    /* `.commands-search` carries `flex: 1 1 320px` for desktop sizing.
       In a column-direction flex container that 320px basis becomes the
       *vertical* basis and `flex-grow: 1` stretches the search div to
       fill the toolbar's main axis — producing a giant gap between the
       input and the chips. Reset to natural height on mobile. */
    .commands-search { flex: 0 0 auto; width: 100%; }
    /* Wrap chips onto multiple rows rather than horizontal-scrolling —
       all six categories fit comfortably in two rows on a phone, and
       the horizontal-scroll strip was also leaking past the viewport
       and letting the whole page pan sideways. */
    .commands-chips {
        flex-wrap: wrap;
        gap: 6px;
    }

    .cmd-grid { grid-template-columns: 1fr; gap: 12px; }
    .cat-header {
        flex-wrap: wrap;
        gap: 10px;
    }
    .cat-count { order: 3; }
    .commands-hero h1 { font-size: 1.45rem; }
    .commands-search-kbd { display: none; }
}

@media (max-width: 480px) {
    .commands-hero h1 { font-size: 1.3rem; }
    .meta-chip { font-size: 0.8rem; }
    .cat-icon { font-size: 1.4rem; }
    .cat-heading h2 { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .cmd-card,
    .cmd-card::before,
    .cmd-copy,
    .cat-chip,
    .commands-search-input {
        transition: none;
    }
    .cmd-card:hover { transform: none; }
}
