# Feature: Menu Runtime

## Intent

Problem: menus need trigger state, keyboard navigation, item activation, disabled handling, and dismissal behavior that CSS cannot provide.
Users or stakeholders: application teams, QA, keyboard users, screen reader users, and framework package maintainers.
Desired outcome: implement accessible Menu behavior as a lightweight controller over Seventh UI markup.
Non-goals: implement a full command palette, virtualized menu, or application command registry.

## Scope

In scope: trigger open/close, roving focus, item activation, disabled items, Escape dismissal, outside dismissal, ARIA state, and cleanup.
Out of scope: positioning engine, CSS animations, remote menu loading, and business command execution.

## Markup Hooks

- Root: `[data-sui-menu]` or `[data-sui-component="menu"]`.
- Trigger: `[data-sui-trigger="menu"]` with `data-sui-target`.
- Menu surface: `[role="menu"]` or `[data-sui-menu-content]`.
- Item: `[role="menuitem"]`, `[role="menuitemcheckbox"]`, `[role="menuitemradio"]`, or `[data-sui-menu-item]`.
- Value: optional `data-sui-value`.

## Behavior

1. Opening dispatches `sui:menu:before-open`; cancellation blocks the open.
2. Closing dispatches `sui:menu:before-close`; cancellation blocks the close.
3. Activation dispatches `sui:menu:select` for enabled items only.
4. Arrow keys move focus among enabled items.
5. Escape and outside pointer close the menu.
6. Trigger state updates `aria-expanded`, content hidden state, and `data-sui-state`.
7. Cleanup removes trigger, item, document, and outside listeners.

## Accessibility

Align with WAI-ARIA Menu Button guidance for application menus. Do not convert simple navigation lists into application menus unless hooks opt in.

## Acceptance Examples

Scenario: disabled item
Given a disabled menu item
When the user presses Enter on it
Then no `sui:menu:select` event is emitted.

Scenario: Escape dismissal
Given a menu is open
When Escape is pressed
Then the menu closes and focus returns to the trigger.
