{#
  CV Skills Section - skills grouped by category
  Data fetched from /cv/data.json via homepage plugin
  Each family gets a distinct color via cycling palette
#}

{% if cv and cv.skills and (cv.skills | dictsort | length) %}
<section class="mb-8 sm:mb-12" id="skills">
  <h2 class="text-xl sm:text-2xl font-bold text-surface-900 dark:text-surface-100 mb-4 sm:mb-6">
    {{ section.config.title or "Skills" }}
  </h2>

  <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
    {% for category, items in cv.skills %}
    {% if not filterType or (cv.skillTypes and cv.skillTypes[category] == filterType) or not cv.skillTypes or not cv.skillTypes[category] %}
    {# Cycle through 8 distinct colors per family using loop.index0 #}
    {% set ci = loop.index0 % 8 %}
    <div class="p-4 bg-surface-50 dark:bg-surface-800 rounded-lg border border-surface-200 dark:border-surface-700 shadow-sm">
      <h3 class="font-semibold text-sm uppercase tracking-wide text-surface-600 dark:text-surface-400 mb-2">
        {{ category }}
      </h3>
      <div class="flex flex-wrap gap-1.5">
        {% for skill in items %}
        {% if ci == 0 %}
        <span class="text-xs px-2 py-1 bg-amber-50 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300 rounded-full">
        {% elif ci == 1 %}
        <span class="text-xs px-2 py-1 bg-emerald-50 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-300 rounded-full">
        {% elif ci == 2 %}
        <span class="text-xs px-2 py-1 bg-sky-50 dark:bg-sky-900/30 text-sky-700 dark:text-sky-300 rounded-full">
        {% elif ci == 3 %}
        <span class="text-xs px-2 py-1 bg-rose-50 dark:bg-rose-900/30 text-rose-700 dark:text-rose-300 rounded-full">
        {% elif ci == 4 %}
        <span class="text-xs px-2 py-1 bg-purple-50 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 rounded-full">
        {% elif ci == 5 %}
        <span class="text-xs px-2 py-1 bg-orange-50 dark:bg-orange-900/30 text-orange-700 dark:text-orange-300 rounded-full">
        {% elif ci == 6 %}
        <span class="text-xs px-2 py-1 bg-teal-50 dark:bg-teal-900/30 text-teal-700 dark:text-teal-300 rounded-full">
        {% elif ci == 7 %}
        <span class="text-xs px-2 py-1 bg-indigo-50 dark:bg-indigo-900/30 text-indigo-700 dark:text-indigo-300 rounded-full">
        {% endif %}
          {{ skill }}
        </span>
        {% endfor %}
      </div>
    </div>
    {% endif %}
    {% endfor %}
  </div>
</section>
{% endif %}
