<% provide :title do %><%= t('debates.index.title') %><% end %>
<% content_for :header_addon do %>
  <%= render "shared/search_form",
             search_path: debates_path(page: 1),
             i18n_namespace: "debates.index.search_form" %>
<% end %>

<main>
  <div class="wrap row">
    <div id="debates" class="debates-list small-12 medium-9 column">

      <div class="small-12 search-results">
        <% if @search_terms || @advanced_search_terms %>
          <h2>
            <%= page_entries_info @debates %>
            <% if !@advanced_search_terms %>
              <%= t("debates.index.search_results", count: @debates.size, search_term: @search_terms) %>
            <% end %>
          </h2>
        <% elsif @tag_filter %>
          <h2>
            <%= page_entries_info @debates %>
            <%= t("debates.index.filter_topic", count: @debates.size, topic: @tag_filter) %>
          </h2>
        <% end %>
      </div>

      <% if has_banners %>
        <%= render "shared/banner" %>
      <% end %>

      <% unless @tag_filter || @search_terms || !has_featured? %>
        <%= render "featured_debates" %>
      <% end %>

      <%= render "shared/advanced_search", search_path: debates_path(page: 1) %>

      <%= render 'shared/order_links', i18n_namespace: "debates.index" %>

      <div class="show-for-small-only">
        <%= link_to t("debates.index.start_debate"), new_debate_path, class: 'button expanded' %>
      </div>

      <%= render @debates %>
      <%= paginate @debates %>
    </div>

    <div class="small-12 medium-3 column">

      <aside class="margin-bottom">
        <%= link_to t("debates.index.start_debate"), new_debate_path, class: 'button expanded' %>
        <%= render "shared/tag_cloud", taggable: 'debate' %>
      </aside>
    </div>

  </div>
</main>
