use crate::page::Page;

pub fn for_page(page: Page) -> &'static [(&'static str, &'static [(&'static str, &'static str)])] {
    match page {
        Page::Main => &[
            (
                "The step sequencer grid. Each cell is a Forth script that produces sound when evaluated. During playback, active steps run left-to-right, top-to-bottom. Toggle steps on/off with t to build your pattern. The left panel shows playing patterns, the right side shows VU meters.",
                &[
                    ("Arrows", "navigate grid"),
                    ("Space", "play / stop"),
                    ("Enter", "edit step script"),
                    ("t", "toggle step on/off"),
                    ("p", "preview script"),
                    ("Tab", "sample browser"),
                    ("?", "all keybindings"),
                ],
            ),
            (
                "Enter opens the script editor (Esc saves and closes). Select ranges with Shift+arrows for bulk operations. Linked steps share one script: edit the source and all links update. Adjust pattern length/speed directly, or use euclidean distribution to spread a step rhythmically.",
                &[
                    ("Shift+Arrows", "select range"),
                    ("Ctrl+C / V", "copy / paste steps"),
                    ("Ctrl+D", "duplicate steps"),
                    ("Ctrl+B", "paste as linked copies"),
                    ("< > / [ ]", "length / speed"),
                    ("e", "euclidean distribution"),
                    ("+ - / T", "tempo adjust / set"),
                ],
            ),
        ],
        Page::Patterns => &[
            (
                "Organize your project into banks and patterns. The left column lists 32 banks, the right shows patterns in the selected bank. The bottom strip previews steps and pattern properties. Stage patterns to play or stop, then commit to apply all changes at once.",
                &[
                    ("Arrows", "navigate"),
                    ("Enter", "open in sequencer"),
                    ("Space", "stage play/stop"),
                    ("c", "commit changes"),
                    ("r", "rename"),
                    ("e", "properties"),
                    ("?", "all keys"),
                ],
            ),
            (
                "Mute and solo patterns to control the mix. Use euclidean distribution to generate rhythmic patterns from a single step. Select multiple patterns with Shift for bulk operations.",
                &[
                    ("m", "stage mute"),
                    ("s", "stage solo"),
                    ("E", "euclidean"),
                    ("Shift+↑↓", "select range"),
                    ("y", "copy"),
                    ("P", "paste"),
                ],
            ),
        ],
        Page::Engine => &[(
            "Audio engine configuration. Select output and input devices, adjust buffer size and polyphony, and manage sample directories. The right side shows a live scope and spectrum analyzer.",
            &[
                ("Tab", "switch section"),
                ("↑↓", "navigate"),
                ("←→", "adjust"),
                ("R", "restart engine"),
                ("A", "add samples"),
                ("?", "all keys"),
            ],
        )],
        Page::Options => &[(
            "Global settings for display, UI, Link sync, MIDI, etc. All changes save automatically. Tutorial can be reset from here!",
            &[
                ("↑↓", "navigate"),
                ("←→", "change value"),
                ("?", "all keys"),
            ],
        )],
        Page::Help => &[(
            "Interactive documentation with executable Forth examples. Browse topics on the left, read content on the right. Code blocks can be run directly and evaluated by the sequencer engine.",
            &[
                ("Tab", "switch panels"),
                ("↑↓", "navigate"),
                ("Enter", "run code block"),
                ("n/p", "next/prev example"),
                ("/", "search"),
                ("?", "all keys"),
            ],
        )],
        Page::Dict => &[(
            "Complete reference of all Forth words by category. Each entry shows the word name, stack effect signature, description, and a usage example. Search filters across all categories.",
            &[
                ("Tab", "switch panels"),
                ("↑↓", "navigate"),
                ("/", "search"),
                ("?", "all keys"),
            ],
        )],
        Page::Script => &[(
            "Write a Forth script that runs periodically during playback, independent of the step sequencer. Use this for autonomous sound generation, drones, generative sequences, or anything that doesn't fit a fixed step grid.",
            &[
                ("Esc", "save & back"),
                ("Ctrl+E", "evaluate script"),
                ("[ ]", "adjust speed"),
                ("Ctrl+S", "toggle stack preview"),
            ],
        )],
    }
}
