/*
 * context-menu.css — Base styles for the positioned context menu
 * (controls/context-menu.js).
 *
 * The control mounts its element on `document.body` and positions it with inline
 * left/top, so `position: fixed` and a stacking `z-index` are not cosmetic here —
 * without them the menu lays out statically at the end of the page, ignores its
 * coordinates, and renders behind the surface that opened it. Same failure mode,
 * and same fix, as the toast control: these rules were bundled inside
 * chaos-controls.css, which only the Chaos and Forge apps load, so any other app
 * calling contextMenu() got an invisible menu. Pulling them into a dedicated
 * control stylesheet loaded by index.html lets every app open one.
 *
 * Uses the project's theme tokens from shell.css (--bg-panel, --border,
 * --text-primary, --bg-hover, --radius). Light/dark themes swap automatically.
 */

.ch-context-menu {
    position: fixed;
    z-index: 1000;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 0;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* S-16(c): these rows are <button> now, so the agreements a button brings with
   it have to be undone - a button does not inherit font, and it arrives with a
   background, a border and centred text. Without these the menu keeps working
   and looks like a stack of form controls. */
.ch-context-item {
    appearance: none;
    background: none;
    border: 0;
    width: 100%;
    text-align: left;
    font: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.1s ease;
}

.ch-context-item:hover {
    background: var(--bg-hover);
}

.ch-context-danger {
    color: #f44336;
}

.ch-context-danger:hover {
    background: rgba(244, 67, 54, 0.1);
}

.ch-context-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ── One nested level ───────────────────────────────────────────────────
   A parent row holds its children inside itself, positioned beside the row.
   Inside rather than appended to the body so the two share one lifetime: the
   outer menu closing takes the nested one with it, and there is no second
   element to dismiss, clamp or leak. */
.ch-context-item--parent {
    position: relative;
}

.ch-context-item--parent > .ch-context-chevron {
    margin-left: auto;
    color: var(--text-muted);
}

.ch-context-submenu {
    position: absolute;
    top: -4px;
    left: 100%;
    display: none;
    margin-left: 2px;
}

.ch-context-item--parent:hover > .ch-context-submenu,
.ch-context-item--parent.ch-context-item--open > .ch-context-submenu {
    display: block;
}

/* The parent row stays highlighted while its children are open, or the eye
   loses which row they belong to. */
.ch-context-item--parent:hover,
.ch-context-item--parent.ch-context-item--open {
    background: var(--bg-hover);
}
