<% var detailAllowed = typeof successStoryDetailAllowed !== 'undefined' ? successStoryDetailAllowed : true; %>
<% var _cover = story.coverImageUrl && String(story.coverImageUrl).trim(); %>
<% var _detailHref = (story.submissionId) ? ("/ai-cases/submit/" + encodeURIComponent(String(story.submissionId))) : ("/ai-cases/" + encodeURIComponent(String(story.slug || ""))); %>
<% var _isSubmission = !!story.submissionId || story._source === "submission"; %>
<% var _viewCount = typeof story.viewCount !== "undefined" ? story.viewCount : 0; %>
<% var _likeCount = typeof story.likeCount !== "undefined" ? story.likeCount : 0; %>
<article class="success-story-card<%= detailAllowed ? '' : ' success-story-card--locked' %>">
  <% if (detailAllowed) { %>
  <a class="success-story-link" href="<%= _detailHref %>">
    <div class="success-thumb<%= _cover ? ' success-thumb--cover' : ' success-thumb--gradient' %>" aria-hidden="true">
      <% if (_cover) { %>
      <div class="success-thumb-media">
        <img src="<%= _cover %>" alt="" loading="lazy" decoding="async" width="560" height="315" />
      </div>
      <div class="success-thumb-scrim"></div>
      <% } %>
      <div class="success-thumb-inner">
        <span class="success-thumb-icon">✦</span>
        <span class="success-thumb-kicker"><%= story.department || "사내 사례" %></span>
      </div>
    </div>
    <div class="success-story-link-body">
      <div class="success-badge"><%= story.department || "사내" %> · <%= story.author || "" %></div>
      <h3><%= story.title %></h3>
      <p class="success-excerpt"><%= story.excerpt || "" %></p>
      <div class="tag-row">
        <% (story.tags || []).forEach((oneTag) => { %>
        <span class="tag-chip">#<%= oneTag %></span>
        <% }) %>
      </div>
      <small class="success-meta">
        <% if (_isSubmission) { %>조회 <%= _viewCount %> · ♥ <%= _likeCount %><% if (story.publishedAt) { %> · <% } %><% } %><% if (story.publishedAt) { %><%= story.publishedAt %><% } %>
      </small>
    </div>
  </a>
  <% } else { %>
  <div
    class="success-story-link"
    title="로그인 후 이용 가능합니다."
  >
    <div class="success-thumb<%= _cover ? ' success-thumb--cover' : ' success-thumb--gradient' %>" aria-hidden="true">
      <% if (_cover) { %>
      <div class="success-thumb-media">
        <img src="<%= _cover %>" alt="" loading="lazy" decoding="async" width="560" height="315" />
      </div>
      <div class="success-thumb-scrim"></div>
      <% } %>
      <div class="success-thumb-inner">
        <span class="success-thumb-icon">✦</span>
        <span class="success-thumb-kicker"><%= story.department || "사내 사례" %></span>
      </div>
    </div>
    <div class="success-story-link-body">
      <div class="success-badge"><%= story.department || "사내" %> · <%= story.author || "" %></div>
      <h3><%= story.title %></h3>
      <p class="success-excerpt"><%= story.excerpt || "" %></p>
      <div class="tag-row">
        <% (story.tags || []).forEach((oneTag) => { %>
        <span class="tag-chip">#<%= oneTag %></span>
        <% }) %>
      </div>
      <small class="success-meta">
        <% if (_isSubmission) { %>조회 <%= _viewCount %> · ♥ <%= _likeCount %><% if (story.publishedAt) { %> · <% } %><% } %><% if (story.publishedAt) { %><%= story.publishedAt %><% } %>
      </small>
    </div>
  </div>
  <% } %>
</article>
