{% load markdownify %}
{% if depth == 0 %} {# Check if this is a packet-level section (no subsections) or category (has subsections) #} {% if not section_data.subsections %} {# Packet-level section (e.g., "Full Packet") - always visible #}

{{ section_data.section.name }}

{% if section_data.section.description %}
{{ section_data.section.description|markdownify }}
{% endif %} {# All files in packet-level section are always visible #} {% for packet_file in section_data.files %} {% include "hugopacket/bits/packet_file.html" with packet=packet_file %} {% if not forloop.last %}
{% endif %} {% endfor %}
{% else %} {# Category section (e.g., "Best Novel") with collapsible finalists #}

{{ section_data.section.name }}

{% if section_data.section.description %}
{{ section_data.section.description|markdownify }}
{% endif %} {# Category-level files (e.g., "Best Novel - Complete Packet") - always visible #} {% for packet_file in section_data.files %} {% include "hugopacket/bits/packet_file.html" with packet=packet_file %} {% if not forloop.last %}
{% endif %} {% endfor %}
{# Expand/Collapse button for all finalists in this category #}
{# Collapsible container for ALL finalists in this category #}
{% for subsection_data in section_data.subsections %} {% include "hugopacket/bits/section.html" with section_data=subsection_data depth=depth|add:1 %} {% endfor %}
{% endif %} {% elif depth == 1 %} {# Finalist subsection - rendered within category's collapsible container #}

{{ section_data.section.name }}

{% if section_data.section.description %}
{{ section_data.section.description|markdownify }}
{% endif %} {% for packet_file in section_data.files %} {% include "hugopacket/bits/packet_file.html" with packet=packet_file %} {% if not forloop.last %}
{% endif %} {% endfor %} {% for subsection_data in section_data.subsections %} {% include "hugopacket/bits/section.html" with section_data=subsection_data depth=depth|add:1 %} {% endfor %}
{% else %} {# Deeper nesting levels (depth >= 2) - not collapsible #} {% if depth == 2 %}

{{ section_data.section.name }}

{% else %}
{{ section_data.section.name }}
{% endif %} {% if section_data.section.description %}
{{ section_data.section.description|markdownify }}
{% endif %} {% for packet_file in section_data.files %} {% include "hugopacket/bits/packet_file.html" with packet=packet_file %} {% if not forloop.last %}
{% endif %} {% endfor %} {% for subsection_data in section_data.subsections %} {% include "hugopacket/bits/section.html" with section_data=subsection_data depth=depth|add:1 %} {% endfor %} {% endif %}