{# `nvm_url` lets a caller redirect NVM elsewhere (the room gate-view passes #}
{# the table-hex URL so NVM returns to the hex, not out to /gameboard/).     #}
{# Defaults to the gameboard listing — room.html's own gear menu is unchanged.#}
{% if not nvm_url %}{% url 'gameboard' as nvm_url %}{% endif %}
{# `scroll_filter` (passed only from room.html's table phase, where the scroll #}
{# pane exists) adds a 2nd gear pane: room-scroll.js swaps the visible pane by #}
{# scroll position — the hex view keeps the default NVM/DEL/BYE; scrolling to  #}
{# the Scroll swaps in the Frame/Redact log filter (mirrors the Billscroll     #}
{# gear). `.room-menu-default` is `display:contents` so wrapping the existing  #}
{# controls doesn't change their layout. #}
<div id="id_room_menu" style="display:none">
    <div class="room-menu-default">
        <a href="{{ nvm_url }}" class="btn btn-cancel">NVM</a>
        {% if request.user == room.owner %}
        <form method="POST" action="{% url 'epic:delete_room' room.id %}">
            {% csrf_token %}
            <button type="submit" class="btn btn-danger" data-confirm="Delete this room?">DEL</button>
        </form>
        {% else %}
        <form method="POST" action="{% url 'epic:abandon_room' room.id %}">
            {% csrf_token %}
            <button type="submit" class="btn btn-abandon" data-confirm="Leave this room?">BYE</button>
        </form>
        {% endif %}
    </div>
    {% if scroll_filter %}
    {# Sky pane — shown by room-views.js (updateGear) while the CAST SKY felt is #}
    {# open (html.sky-open). NVM returns to the table-hex: epic:room re-renders   #}
    {# the hex with DRAW SEA if the sky was saved (confirmed), else CAST SKY.     #}
    <div class="room-menu-sky" style="display:none">
        <a href="{% url 'epic:room' room.id %}" class="btn btn-cancel">NVM</a>
    </div>
    {# Sea pane — shown by room-views.js (updateGear) while the DRAW SEA felt is #}
    {# open (html.sea-open). NVM returns to the table-hex (epic:room re-renders   #}
    {# the hex w. DRAW SEA, the sky already confirmed).                           #}
    <div class="room-menu-sea" style="display:none">
        <a href="{% url 'epic:room' room.id %}" class="btn btn-cancel">NVM</a>
    </div>
    <div class="room-menu-scroll" style="display:none">
        <form id="id_scroll_filter_form">
            <label><input type="checkbox" name="labels" value="frame" checked> Frame</label>
            <label><input type="checkbox" name="labels" value="redact" checked> Redact</label>
            <div class="menu-btns">
                <button type="submit" class="btn btn-confirm">OK</button>
                <button type="button" class="btn btn-cancel applet-menu-cancel">NVM</button>
            </div>
        </form>
    </div>
    {# ATLAS view's own gear: which reelhouse sources merge into the feed. Only #}
    {# scroll + post are wired sources; yarn + pulse have no model yet, so their #}
    {# checkboxes are disabled (struck label, an ✗ in the box). Starting-        #}
    {# majuscule labels (like Frame/Redact) — only the banner reel is capslock. #}
    <div class="room-menu-atlas" style="display:none">
        <form id="id_atlas_source_form" class="atlas-source-form">
            <label class="atlas-source"><input type="checkbox" name="views" value="scroll" checked> <span class="atlas-source-name">Scroll</span></label>
            <label class="atlas-source"><input type="checkbox" name="views" value="yarn" disabled> <span class="atlas-source-name">Yarn</span></label>
            <label class="atlas-source"><input type="checkbox" name="views" value="post" checked> <span class="atlas-source-name">Post</span></label>
            <label class="atlas-source"><input type="checkbox" name="views" value="pulse" disabled> <span class="atlas-source-name">Pulse</span></label>
            <div class="menu-btns">
                <button type="submit" class="btn btn-confirm">OK</button>
                <button type="button" class="btn btn-cancel applet-menu-cancel">NVM</button>
            </div>
        </form>
    </div>
    {% endif %}
</div>
{% include "apps/applets/_partials/_gear.html" with menu_id="id_room_menu" %}
