{% comment %}
  Custom Instagram/Image Gallery - Figma Style
  Features: Rounded corners, Center heading, Responsive grid
{% endcomment %}

<style>
  .instagram-gallery-{{ section.id }} {
    padding: {{ section.settings.padding_top }}px 20px {{ section.settings.padding_bottom }}px;
    background-color: {{ section.settings.bg_color }};
    text-align: center;
  }

  .gallery-header {
    margin-bottom: 40px;
  }



  .gallery-header p {
    font-size: 16px;
    color: #4A5565;
    margin: 0;
    line-height:24px;
    padding-top:16px;
  }

  .gallery-wrapper {
    max-width:1216px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
  }

  .gallery-card {
    flex: 0 0 calc(16.66% - 15px); /* Default 6 items per row */
    min-width: 180px;
    aspect-ratio: 1 / 1;
    border-radius: 15px; /* Exact rounded corners from Figma */
    overflow: hidden;
    position: relative;
  }

  .gallery-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
    display: block;
  }

  .gallery-card:hover img {
    transform: scale(1.1);
  }

  /* Tablet & Mobile Responsiveness */
  @media screen and (max-width: 1024px) {
    .gallery-card {
      flex: 0 0 calc(33.33% - 15px);
    }
  }

  @media screen and (max-width: 768px) {
    .gallery-wrapper {
      flex-wrap: nowrap;
      overflow-x: auto;
      justify-content: flex-start;
      padding-bottom: 15px;
      -webkit-overflow-scrolling: touch;
    }
    .gallery-card {
      flex: 0 0 200px; /* Mobile par swipeable cards */
    }
    .gallery-header h2 { font-size: 26px; }
  }
</style>

<div class="instagram-gallery-{{ section.id }}">
  <div class="gallery-header">
    <h2>{{ section.settings.title }}</h2>
    <p>{{ section.settings.subtitle }}</p>
  </div>

  <div class="gallery-wrapper">
    {% for block in section.blocks %}
      <div class="gallery-card" {{ block.shopify_attributes }}>
        {% if block.settings.image != blank %}
          <img src="{{ block.settings.image | img_url: '600x600', crop: 'center' }}" 
               alt="Gallery Image" 
               loading="lazy">
        {% else %}
          {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
        {% endif %}
      </div>
    {% endfor %}
  </div>
</div>

{% schema %}
{
  "name": "Custom Insta Gallery",
  "settings": [
    {
      "type": "text",
      "id": "title",
      "label": "Heading",
      "default": "Follow Us @Aurellia"
    },
    {
      "type": "text",
      "id": "subtitle",
      "label": "Sub-heading",
      "default": "Join our community and share your style"
    },
    {
      "type": "color",
      "id": "bg_color",
      "label": "Background Color",
      "default": "#ffffff"
    },
    {
      "type": "range",
      "id": "container_width",
      "min": 1000,
      "max": 1600,
      "step": 100,
      "unit": "px",
      "label": "Container Width",
      "default": 1400
    },
    {
      "type": "range",
      "id": "padding_top",
      "min": 0,
      "max": 100,
      "step": 5,
      "unit": "px",
      "label": "Padding Top",
      "default": 60
    },
    {
      "type": "range",
      "id": "padding_bottom",
      "min": 0,
      "max": 100,
      "step": 5,
      "unit": "px",
      "label": "Padding Bottom",
      "default": 40
    }
  ],
  "blocks": [
    {
      "type": "image_block",
      "name": "Gallery Image",
      "settings": [
        {
          "type": "image_picker",
          "id": "image",
          "label": "Select Image"
        }
      ]
    }
  ],
  "presets": [
    {
      "name": "Custom Insta Gallery",
      "blocks": [
        { "type": "image_block" },
        { "type": "image_block" },
        { "type": "image_block" },
        { "type": "image_block" },
        { "type": "image_block" },
        { "type": "image_block" }
      ]
    }
  ]
}
{% endschema %}