<% person = local_assigns[:person] %>
<% team = local_assigns[:team] %>
<% editable = local_assigns.fetch(:editable, false) %>
<% compact = local_assigns.fetch(:compact, false) %>

<article class="roster-card<%= " roster-card--compact" if compact %>">
  <div class="roster-card__avatar">
    <%= roster_person_avatar(person, team, size: 72) %>
  </div>
  <div class="roster-card__body">
    <h3 class="roster-card__name">
      <%= person.full_name %>
      <% if person.category == "player" && person.jersey_number.present? %>
        <span class="roster-card__number">#<%= person.jersey_number %></span>
      <% end %>
    </h3>
    <p class="roster-card__role"><%= person.display_role %></p>
    <% if person.bio.present? %>
      <p class="roster-card__bio"><%= person.bio %></p>
    <% end %>
  </div>
  <% if editable %>
    <div class="roster-card__actions">
      <%= link_to "Modifica", edit_public_team_roster_member_path(team, person), class: "roster-card__btn" %>
      <%= button_to "Rimuovi", public_team_roster_member_path(team, person), method: :delete, class: "roster-card__btn roster-card__btn--danger",
            form: { data: { turbo_confirm: "Rimuovere #{person.full_name} dall'organico?" } } %>
    </div>
  <% end %>
</article>
