{% extends "base.html" %}

{#
  Documentation List Template

  Three-column layout optimized for documentation section index pages:
  - Left sidebar: Navigation tree
  - Center: Content + Child page tiles
  - Right sidebar: TOC + metadata

  Usage: Set `template: doc/list.html` in frontmatter
  Or set `type: doc` to auto-select this template

  Features:
  - Automatically displays child pages and subsections as tiles
  - Disable with `show_children: false` in frontmatter
#}

{% from 'partials/navigation-components.html' import breadcrumbs, page_navigation, toc with context %}
{% from 'partials/content-components.html' import tag_list, child_page_tiles with context %}

{% block content %}
{# Three-column documentation layout #}
<div class="docs-layout">
  {# Left Sidebar: Navigation #}
  <aside class="docs-sidebar" id="docs-sidebar" role="navigation" aria-label="Documentation navigation">
    {% include 'partials/docs-nav.html' %}
  </aside>

  {# Main Content #}
  <div class="docs-main">
    {# Breadcrumbs #}
    {{ breadcrumbs(page) }}

    {# Article Content #}
    <article class="prose {% if page.metadata.get('css_class') %}{{ page.metadata.get('css_class') }}{% endif %}">
      <header class="docs-header">
        <h1>{{ page.title }}</h1>

        {% if page.metadata.get('description', '') %}
        <p class="lead">{{ page.metadata.get('description', '') }}</p>
        {% endif %}

        {# Document metadata #}
        {% include 'partials/docs-meta.html' %}
      </header>

      {# Main content #}
      <div class="docs-content">
        {{ content | safe }}
      </div>

      {# Child page tiles - can be disabled via frontmatter: show_children: false #}
      {% set show_children = page.metadata.get('show_children', true) if page else true %}
      {% if show_children and (posts or subsections) %}
      <div class="docs-children">
        {{ child_page_tiles(posts=posts, subsections=subsections) }}
      </div>
      {% endif %}

      {# Tags #}
      {% if page.tags %}
      <footer class="docs-footer">
        {{ tag_list(page.tags) }}
      </footer>
      {% endif %}
    </article>

    {# Page navigation (prev/next) at bottom #}
    {{ page_navigation(page) }}
  </div>

  {# Right Sidebar: TOC + Metadata #}
  {% if toc_items %}
  <aside class="docs-toc" role="complementary" aria-label="Table of contents">
    {{ toc(toc_items=toc_items, toc=toc, page=page) }}
  </aside>
  {% endif %}
</div>

{# Mobile sidebar toggle button #}
<button
  class="docs-sidebar-toggle"
  aria-label="Toggle navigation sidebar"
  aria-expanded="false"
  aria-controls="docs-sidebar">
  <svg viewBox="0 0 24 24">
    <line x1="3" y1="12" x2="21" y2="12"></line>
    <line x1="3" y1="6" x2="21" y2="6"></line>
    <line x1="3" y1="18" x2="21" y2="18"></line>
  </svg>
</button>

{# Sidebar overlay for mobile #}
<div class="docs-sidebar-overlay" aria-hidden="true"></div>
{% endblock %}

{# Sidebar toggle functionality is handled by interactive.js #}
