{% extends "base.html" %}

{% block title %}{{ t(key="audio-title", lang=lang | default(value='sk')) }}{% endblock title %}
{% block crumb %}audio{% endblock crumb %}

{% block content %}
{% if logged_in_admin %}
<header class="term-cmd">
  <div>
    <h1 class="term-title">{{ t(key="audio-title", lang=lang | default(value='sk')) }}</h1>
    <p class="term-sub">// {{ albums | length }} {{ t(key="audio-sub", lang=lang | default(value='sk')) }}</p>
  </div>
  <div class="term-cmd-actions">
    <a href="/audio/tracks" class="btn btn-outline btn-sm">[ {{ t(key="audio-all-songs", lang=lang | default(value='sk')) }} ]</a>
  </div>
</header>

{% if albums | length > 0 %}
  <div class="term-grid">
    {% for album in albums %}
      <article class="card">
        <div class="term-head">
          <span class="term-head-name">~/audio/{{ album.slug }}/</span>
          <span class="term-head-meta term-tag is-purple">{{ t(key="album", lang=lang | default(value='sk')) }}</span>
        </div>
        <div class="card-body">
          {% if album.cover_image_id %}
          <img src="/images/{{ album.cover_image_id }}" alt="" class="mb-3">
          {% endif %}
          <h2 class="card-title text-base">{{ album.title }}</h2>
          {% if album.artist %}
          <p class="text-sm t-aqua">{{ album.artist }}</p>
          {% endif %}
          {% if album.description %}
          <p class="term-prose text-sm opacity-80">{{ album.description }}</p>
          {% endif %}
          <div class="flex flex-wrap gap-2 pt-2">
            <button type="button" class="uw-play-album-remote btn btn-primary btn-sm"
              data-album-tracks-url="/audio/albums/{{ album.slug }}/tracks">{{ t(key="audio-play", lang=lang | default(value='sk')) }}</button>
            <a href="/audio/albums/{{ album.slug }}" class="btn btn-outline btn-sm">{{ t(key="audio-open", lang=lang | default(value='sk')) }}</a>
          </div>
        </div>
      </article>
    {% endfor %}
  </div>
{% else %}
  <div class="term-empty">
    <p class="font-medium">{{ t(key="audio-no-albums", lang=lang | default(value='sk')) }}</p>
  </div>
{% endif %}
{% else %}
<header class="term-cmd">
  <div>
    <h1 class="term-title">{{ t(key="audio-title", lang=lang | default(value='sk')) }}</h1>
    <p class="term-sub">{{ albums | length }} {{ t(key="audio-sub", lang=lang | default(value='sk')) }}</p>
  </div>
  <div class="term-cmd-actions">
    <a href="/audio/tracks" class="btn btn-outline btn-sm">[ {{ t(key="audio-all-songs", lang=lang | default(value='sk')) }} ]</a>
  </div>
</header>

{% if albums | length > 0 %}
  <div class="term-grid">
    {% for album in albums %}
      <article class="card">
        <div class="term-head">
          <span class="term-head-name">~/audio/{{ album.slug }}/</span>
          <span class="term-head-meta term-tag is-purple">{{ t(key="album", lang=lang | default(value='sk')) }}</span>
        </div>
        <div class="card-body">
          {% if album.cover_image_id %}
          <img src="/images/{{ album.cover_image_id }}" alt="" class="mb-3">
          {% endif %}
          <h2 class="card-title text-base">{{ album.title }}</h2>
          {% if album.artist %}
          <p class="text-sm t-aqua">{{ album.artist }}</p>
          {% endif %}
          {% if album.description %}
          <p class="term-prose text-sm opacity-80">{{ album.description }}</p>
          {% endif %}
          <div class="flex flex-wrap gap-2 pt-2">
            <button type="button" class="uw-play-album-remote btn btn-primary btn-sm"
              data-album-tracks-url="/audio/albums/{{ album.slug }}/tracks">{{ t(key="audio-play", lang=lang | default(value='sk')) }}</button>
            <a href="/audio/albums/{{ album.slug }}" class="btn btn-outline btn-sm">{{ t(key="audio-open", lang=lang | default(value='sk')) }}</a>
          </div>
        </div>
      </article>
    {% endfor %}
  </div>
{% else %}
  <div class="term-empty">
    <p class="font-medium">{{ t(key="audio-no-albums", lang=lang | default(value='sk')) }}</p>
  </div>
{% endif %}
{% endif %}
{% endblock content %}
