{{ $articleType := .Params.type | default "life" }}
{{ $typeConfig := .Site.Params.articleTypes }}
{{ $typeData := index $typeConfig $articleType }}
{{ $isDark := strings.Contains (os.Getenv "THEME") "dark" }}
{{ $color := cond $isDark $typeData.color_dark $typeData.color_light }}

<div class="mb-8 pb-8 border-b border-border">
  <!-- Type badge -->
  {{ if $typeData }}
  <span
    class="inline-flex items-center px-3 py-1 rounded text-sm font-semibold mb-4 transition-colors"
    style="color: {{ $color }}; background-color: {{ $color }}20;"
  >
    {{ i18n $articleType }}
  </span>
  {{ end }}

  <!-- Title -->
  <h1 class="text-4xl md:text-5xl font-bold text-accent mb-4">
    {{ .Title }}
  </h1>

  <!-- Metadata -->
  <div class="flex flex-wrap items-center gap-4 text-sm text-text-dim">
    <!-- Publish date -->
    {{ if .PublishDate }}
    <div class="flex items-center gap-1">
      <i data-feather="calendar" class="w-4 h-4"></i>
      <time datetime="{{ .PublishDate.Format "2006-01-02T15:04:05Z07:00" }}">
        {{ .PublishDate.Format "Jan 2, 2006" }}
      </time>
    </div>
    {{ end }}

    <!-- Update date if different -->
    {{ if and .LastMod (ne .LastMod.Format "2006-01-02" .PublishDate.Format "2006-01-02") }}
    <div class="flex items-center gap-1">
      <i data-feather="edit-2" class="w-4 h-4"></i>
      <time datetime="{{ .LastMod.Format "2006-01-02T15:04:05Z07:00" }}">
        {{ .LastMod.Format "Jan 2, 2006" }}
      </time>
    </div>
    {{ end }}

    <!-- Reading time -->
    {{ if .Site.Params.readingTime }}
    <div class="flex items-center gap-1">
      <i data-feather="clock" class="w-4 h-4"></i>
      <span>{{ .ReadingTime }} {{ i18n "min" }} {{ i18n "readingTime" }}</span>
    </div>
    {{ end }}
  </div>
</div>
