{% extends "base.html" %}
{% import "partials/detail_cards.html" as detail %}
{% import "partials/icons.html" as icons %}
{% import "partials/image_section.html" as img %}
{% block title %}Brewlog · {{ roaster.name }}{% endblock %}
{% block og_title %}{{ roaster.name }} — Brewlog{% endblock %}
{% block og_description %}
  {{ roaster.name }}
  — {{ roaster.country_flag }}
  {{ roaster.country }}{% if let Some(c) = roaster.city %}, {{ c }}{% endif %}
{% endblock %}
{% block head %}
  <meta property="og:image" content="{{ base_url }}/static/og-image.png" />
{% endblock %}
{% block content %}
  <header class="flex items-start justify-between gap-4">
    <div class="flex items-center gap-4 min-w-0">
      {{ img::image_thumbnail("roaster", roaster.id, image_url, is_authenticated) }}
      <div class="flex flex-col gap-1 min-w-0">
        <h1 class="text-2xl font-semibold truncate">{{ roaster.name }}</h1>
        <p class="text-sm text-text-secondary">
          <a
            href="/data?type=roasters"
            class="text-accent hover:text-accent-hover transition"
            >Roasters</a
          >
          · {{ roaster.created_date }}
        </p>
      </div>
    </div>
  </header>
  {{ img::lightbox_script() }}

  <div class="grid gap-6 md:grid-cols-2">
    <div class="rounded-lg border bg-surface p-5">
      <h2 class="text-lg font-semibold text-text mb-4">Details</h2>
      <dl class="grid grid-cols-2 gap-x-4 gap-y-3 text-sm">
        <div>
          <dt class="text-text-muted">Country</dt>
          <dd class="font-medium text-text">
            <span
              >{% if !roaster.country_flag.is_empty() %}
                <span class="mr-1">{{ roaster.country_flag }}</span>
              {% endif %}{{ roaster.country }}</span
            >
          </dd>
        </div>
        {% if let Some(c) = roaster.city %}
          <div>
            <dt class="text-text-muted">City</dt>
            <dd class="font-medium text-text">{{ c }}</dd>
          </div>
        {% endif %}
        {% if let Some(url) = roaster.homepage %}
          <div>
            <dt class="text-text-muted">Website</dt>
            <dd class="font-medium">
              <a
                href="{{ url }}"
                target="_blank"
                rel="noreferrer noopener"
                class="text-accent hover:text-accent-hover transition"
                >Visit Website</a
              >
            </dd>
          </div>
        {% endif %}
      </dl>
    </div>

    {{ detail::map_with_legend(roaster.map_countries, roaster.map_max, roaster.legend_entries) }}
  </div>

  {% if is_authenticated %}
    {{ detail::edit_delete_buttons(edit_url, "roaster", "/api/v1/roasters", roaster.id) }}
  {% endif %}
{% endblock %}
