{#- progressive.j2 - Progressive disclosure patterns -#}
{%- extends "python/_base/foundation.j2" -%}

{#- Macro for creating progressive disclosure sections -#}
{%- macro progressive_section(title, content, options={}) -%}
{%- set open_by_default = options.get('open', false) -%}
{%- set css_class = options.get('class', '') -%}
{%- set icon = options.get('icon', '') -%}

{%- if has_toggles %}
.. dropdown:: {{ icon }} {{ title }}
   :animate: fade-in-slide-down
   {%- if open_by_default %}
   :open:
   {%- endif %}
   {%- if css_class %}
   :class: {{ css_class }}
   {%- endif %}

   {{ content|indent(3) }}
{%- elif has_design %}
.. admonition:: {{ icon }} {{ title }}
   :class: dropdown {{ css_class }}

   {{ content|indent(3) }}
{%- else %}
{{ title }}
{{ "-" * title|length }}

{{ content }}
{%- endif %}
{%- endmacro -%}

{#- Macro for creating tabbed content -#}
{%- macro tabbed_content(tabs) -%}
{%- if has_tabs %}
.. tab-set::

   {%- for tab in tabs %}
   .. tab-item:: {{ tab.title }}
      {%- if tab.icon and has_emoji %}
      :sync: {{ tab.id|default(tab.title|lower|replace(' ', '-')) }}
      {%- endif %}

      {{ tab.content|indent(6) }}
   {%- endfor %}
{%- elif has_design %}
.. grid:: 1
   :gutter: 2

   {%- for tab in tabs %}
   .. grid-item-card:: {{ tab.title }}

      {{ tab.content|indent(6) }}
   {%- endfor %}
{%- else %}
{%- for tab in tabs %}
{{ tab.title }}
{{ "~" * tab.title|length }}

{{ tab.content }}
{%- endfor %}
{%- endif %}
{%- endmacro -%}

{#- Macro for creating info cards -#}
{%- macro info_card(title, content, options={}) -%}
{%- set columns = options.get('columns', '12 12 6 6') -%}
{%- set color = options.get('color', '') -%}
{%- set icon = options.get('icon', '') -%}

{%- if has_design %}
.. grid-item-card:: {{ icon }} {{ title }}
   :columns: {{ columns }}
   {%- if color %}
   :class-header: bg-{{ color }} text-white
   {%- endif %}

   {{ content|indent(3) }}
{%- elif has_panels %}
.. panels::
   :header: bg-{{ color|default('light') }}

   {{ icon }} {{ title }}
   ^^^
   {{ content|indent(3) }}
{%- else %}
**{{ icon }} {{ title }}**

{{ content }}
{%- endif %}
{%- endmacro -%}

{#- Macro for creating button/badge elements -#}
{%- macro badge(text, type='info') -%}
{%- if has_design %}
.. button-ref::
   :color: {{ type }}
   :outline:

   {{ text }}
{%- else %}
**[{{ text }}]**
{%- endif %}
{%- endmacro -%}

{#- Macro for method/attribute counts -#}
{%- macro object_stats(obj) -%}
{%- set stats = [] -%}
{%- if obj.all_methods %}{% set _ = stats.append(obj.all_methods|length ~ ' methods') %}{% endif -%}
{%- if obj.all_attributes %}{% set _ = stats.append(obj.all_attributes|length ~ ' attributes') %}{% endif -%}
{%- if obj.properties %}{% set _ = stats.append(obj.properties|length ~ ' properties') %}{% endif -%}
{%- if stats %}({{ stats|join(', ') }}){% endif -%}
{%- endmacro -%}