

<style>


  .category-header {
    text-align: center;
    margin-bottom: 48px;
  }

  .category-header h2 {
    font-size: 32px;
    font-family: Georgia;
    font-weight: 400;
    font-size: 36px;
    line-height: 40px;
    text-align: center;

  }

  .category-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
  }

  .category-card {
    position: relative;
    border-radius: 12px; 
    overflow: hidden;
    aspect-ratio: 1 / 1.2;
    display: block;
    text-decoration: none;
  }

  .category-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
  }

  .category-card:hover .category-image {
    transform: scale(1.05);
  }

  .category-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    display: flex;
    align-items: flex-end;
  }

  .category-title {
    color: #ffffff;
    margin: 0;
    font-family: Georgia;
    font-weight: 400;
    font-size: 24px;
    line-height: 32px;
    letter-spacing: 0px;
  }
  .category-image{
    box-shadow: 0px 4px 6px -4px #0000001A;
    box-shadow: 0px 10px 15px -3px #0000001A;

}

  /* Responsive Design */
  @media screen and (max-width: 990px) {
    .category-container {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  @media screen and (max-width: 480px) {
    .category-header h2 { font-size:30px; }
    .category-container {
      grid-template-columns: 1fr;
    }
  }
</style>

<div class="category-grid-{{ section.id }}">
  <div class="category-header">
    <h2>{{ section.settings.heading }}</h2>
  </div>

  <div class="category-container">
    {% for block in section.blocks %}
      <a href="{{ block.settings.link }}" class="category-card" {{ block.shopify_attributes }}>
        {% if block.settings.image != blank %}
          <img src="{{ block.settings.image | img_url: '600x' }}" 
               alt="{{ block.settings.title }}" 
               class="category-image"
               loading="lazy">
        {% else %}
          {{ 'collection-1' | placeholder_svg_tag: 'category-image' }}
        {% endif %}
        
        <div class="category-overlay">
          <h3 class="category-title">{{ block.settings.title }}</h3>
        </div>
      </a>
    {% endfor %}
  </div>
</div>

{% schema %}
{
  "name": "Custom Category Grid",
  "settings": [
    {
      "type": "text",
      "id": "heading",
      "label": "Heading",
      "default": "Shop by Category"
    },
    {
      "type": "color",
      "id": "bg_color",
      "label": "Background Color",
      "default": "#ffffff"
    },
    {
      "type": "range",
      "id": "padding_top",
      "min": 0,
      "max": 100,
      "step": 5,
      "unit": "px",
      "label": "Padding Top",
      "default": 50
    },
    {
      "type": "range",
      "id": "padding_bottom",
      "min": 0,
      "max": 100,
      "step": 5,
      "unit": "px",
      "label": "Padding Bottom",
      "default": 50
    }
  ],
  "blocks": [
    {
      "type": "category_item",
      "name": "Category Card",
      "limit": 4,
      "settings": [
        {
          "type": "image_picker",
          "id": "image",
          "label": "Category Image"
        },
        {
          "type": "text",
          "id": "title",
          "label": "Category Title",
          "default": "Category Name"
        },
        {
          "type": "url",
          "id": "link",
          "label": "Category Link"
        }
      ]
    }
  ],
  "presets": [
    {
      "name": "Custom Category Grid",
      "blocks": [
        { "type": "category_item", "settings": { "title": "Rings" } },
        { "type": "category_item", "settings": { "title": "Necklaces" } },
        { "type": "category_item", "settings": { "title": "Earrings" } },
        { "type": "category_item", "settings": { "title": "Bracelets" } }
      ]
    }
  ]
}
{% endschema %}