<% @page_title = "Notifications" %>
<% @hide_footer_frames = true %>

<% content_for :header do %>
  <h1 class="header__title"><%= @page_title %></h1>

  <div class="header__actions header__actions--end">
    <%= link_to notifications_settings_path, class: "btn" do %>
      <%= icon_tag "settings" %> <span class="for-screen-reader">Notification settings</span>
    <% end %>
  </div>
<% end %>

<div data-controller="badge navigable-list" data-badge-unread-class="unread" data-action="keydown@document->navigable-list#navigate" data-navigable-list-actionable-items-value="true"
      data-navigable-list-focus-on-selection-value="false">
  <section class="notifications-list panel center borderless unpad flex flex-column gap-half">
    <% if @unread.any? %>
      <div class="flex align-center justify-space-between margin-block-start margin-block-end-half">
        <h2 class="txt-medium txt-uppercase txt-alert">New for you</h2>
        <%= button_to "Mark all as read", bulk_reading_path, class: "btn txt-small", form: { data: { turbo: false } }, data: { action: "badge#clear" } %>
      </div>
    <% else %>
      <div class="notifications-list__empty-message pad border-radius border translucent" style="--border-style: dashed; --border-color: var(--color-ink); --border-radius: 0.2em;">
        <strong>Nothing new for you.</strong>
      </div>
    <% end %>

    <div id="notifications_list" contents>
      <%= render partial: "notifications/notification", collection: @unread, cached: true %>
    </div>
  </section>

  <section class="notifications-list notifications-list--read panel center borderless unpad flex flex-column gap-half margin-block-start">
    <h2 class="txt-medium margin-block-start-double margin-block-end-half txt-uppercase translucent">Previously seen</h2>

    <div id="notifications_list_read" contents>
      <%= render partial: "notifications/notification", collection: @page.records, cached: true %>
    </div>
  </section>
</div>

<%= notifications_next_page_link(@page) if @page.records.any? %>
