<% if card.published? && !params[:focus_on_title]%>
  <%= turbo_frame_tag card, :edit do %>
    <div class="card__content">
      <h1 class="card__title flex align-start gap-half">
        <%= link_to card.title, edit_collection_card_path(card.collection, card), class: "card__title-link" %>
      </h1>
      <div class="card__description rich-text-content margin-block-half rich-text-content" data-controller="syntax-highlight retarget-links">
        <%= card.description %>
      </div>
    </div>
  <% end %>
<% else %>
  <%= form_with model: card, url: collection_card_path(card.collection, card), id: "card_form", class: "card__content", data: { controller: "autoresize auto-save" } do |form| %>
    <h1 class="card__title autoresize__wrapper" data-autoresize-target="wrapper" data-autoresize-clone-value="">
      <%= form.text_area :title, placeholder: "Name it…",
            class: "input input--textarea full-width borderless txt-align-start autoresize__textarea",
            autofocus: card.title.blank? || params[:focus_on_title], rows: 1,
            data: { autoresize_target: "textarea", action: "input->autoresize#resize auto-save#change blur->auto-save#submit keydown.enter->auto-save#submit:prevent keydown.ctrl+enter->auto-save#submit:prevent" } %>
    </h1>
    <div class="card__description rich-text-content margin-block-start-half margin-block-end">
      <%= form.rich_textarea :description, class: "card-field__description",
            placeholder: "Add some notes, context, pictures, or video about this…",
            data: { action: "actiontext:change->auto-save#change focusout->auto-save#submit keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do %>
        <%= mentions_prompt(card.collection) %>
        <%= cards_prompt %>
    <% end %>
    </div>
  <% end %>
<% end %>
