<section class="little-picks" data-reveal>
  <div class="container">
    {%- if section.settings.eyebrow != blank -%}
      <span class="section-eyebrow">{{ section.settings.eyebrow }}</span>
    {%- endif -%}
    {%- if section.settings.heading != blank -%}
      <h2 class="section-heading">{{ section.settings.heading }}</h2>
    {%- endif -%}

    <div class="little-picks__grid">
      {%- if section.settings.collection != blank -%}
        {%- for product in section.settings.collection.products limit: section.settings.products_to_show -%}
          <div class="little-picks__card" data-reveal style="--index: {{ forloop.index }}">
            <a href="{{ product.url }}" class="little-picks__link" aria-label="{{ product.title }}">
              <div class="little-picks__media">
                {%- if product.featured_image != blank -%}
                  <img src="{{ product.featured_image | image_url: width: 600 }}" srcset="{{ product.featured_image | image_url: width: 300 }} 300w, {{ product.featured_image | image_url: width: 450 }} 450w, {{ product.featured_image | image_url: width: 600 }} 600w" sizes="(max-width: 768px) 50vw, 33vw" alt="{{ product.featured_image.alt | escape }}" loading="lazy" class="little-picks__image">
                {%- else -%}
                  {%- assign product_img = 'product-' | append: forloop.index | append: '.png' -%}
                  <img src="{{ product_img | asset_url }}" alt="{{ product.title }}" loading="lazy" class="little-picks__image" onerror="this.style.display='none';this.nextElementSibling.style.display='flex';">
                  <div class="little-picks__placeholder" style="display:none;">
                    <svg viewBox="0 0 400 400" fill="none" stroke="currentColor" stroke-width="1" opacity="0.12" aria-hidden="true"><rect x="40" y="40" width="320" height="320" rx="24"/><circle cx="200" cy="180" r="50"/><path d="M120 280 h160"/></svg>
                  </div>
                {%- endif -%}
              </div>
              <div class="little-picks__info">
                <h3 class="little-picks__title">{{ product.title }}</h3>
                <span class="little-picks__price">{{ product.price | money }}</span>
              </div>
            </a>
          </div>
        {%- endfor -%}
      {%- else -%}
        {%- assign placeholder_names = 'Organic Cotton Romper,Wooden Stacking Rings,Muslin Swaddle Set,Knit Bear Rattle,Linen Bloomers,First Puzzle Board' | split: ',' -%}
        {%- assign placeholder_prices = '$32,$28,$24,$18,$26,$34' | split: ',' -%}
        {%- for i in (1..6) -%}
          {%- assign idx = forloop.index0 -%}
          {%- assign product_img = 'product-' | append: forloop.index | append: '.png' -%}
          <div class="little-picks__card" data-reveal style="--index: {{ forloop.index }}">
            <div class="little-picks__link">
              <div class="little-picks__media">
                <img src="{{ product_img | asset_url }}" alt="{{ placeholder_names[idx] }}" loading="lazy" class="little-picks__image" onerror="this.style.display='none';this.nextElementSibling.style.display='flex';">
                <div class="little-picks__placeholder" style="display:none;">
                  <svg viewBox="0 0 400 400" fill="none" stroke="currentColor" stroke-width="1" opacity="0.12" aria-hidden="true"><rect x="40" y="40" width="320" height="320" rx="24"/><circle cx="200" cy="180" r="50"/><path d="M120 280 h160"/></svg>
                </div>
              </div>
              <div class="little-picks__info">
                <h3 class="little-picks__title">{{ placeholder_names[idx] }}</h3>
                <span class="little-picks__price">{{ placeholder_prices[idx] }}</span>
              </div>
            </div>
          </div>
        {%- endfor -%}
      {%- endif -%}
    </div>
  </div>
</section>

{% schema %}
{
  "name": "Little Picks",
  "class": "section-little-picks",
  "settings": [
    { "type": "text", "id": "eyebrow", "label": "Eyebrow" },
    { "type": "text", "id": "heading", "label": "Heading", "default": "Little Picks" },
    { "type": "collection", "id": "collection", "label": "Collection" },
    { "type": "range", "id": "products_to_show", "label": "Products to show", "min": 3, "max": 9, "step": 1, "default": 6 }
  ],
  "presets": [{ "name": "Little Picks" }]
}
{% endschema %}