{% comment %}
  Custom Testimonials Section - With Image Picker for Stars
{% endcomment %}

<style>
  .testimonials-{{ section.id }} {
    background: linear-gradient(10deg,rgba(255, 255, 255, 1) 0%, rgba(255, 251, 235, 1) 56%);
    padding: 80px 20px;
  }
  .testimonial-header {
    text-align: center;
    margin-bottom: 50px;
  }
  .testimonial-header h2 {
    font-family: serif;
    font-size: 36px;
    color: #333;
    margin: 0;
  }
  .testimonial-grid {
    max-width: 1216px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap:32px;
  }
  .testimonial-card {
    background: #fff;
    padding: 30px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0px 2px 4px -2px #0000001A;
    box-shadow: 0px 4px 6px -1px #0000001A;

  }
  .star-image-wrapper {
    margin-bottom: 15px;
  }
  .star-custom-img {
    width:300px;
    height: auto;
    display: block;
  }
  .testimonial-text {
    color: #4A5565 !important;
    line-height:24px;
    margin-bottom: 20px;
    font-size: 16px;
    font-style:italic;
    font-weight:400;
  }
  .testimonial-author {
    font-weight: 600;
    font-family: 'Inter';
    font-size: 16px;
    line-height: 24px;
    letter-spacing: -0.31px;
    color:#101828;
    padding-top:16px;

  }
  @media (max-width: 990px) {
    .testimonial-grid { grid-template-columns: repeat(2, 1fr); }
  }
  @media (max-width: 600px) {
    .testimonial-grid { grid-template-columns: 1fr; }
  }
</style>

<div class="testimonials-{{ section.id }}">
  <div class="testimonial-header">
    <h2>{{ section.settings.title }}</h2>
  </div>
  <div class="testimonial-grid">
    {% for block in section.blocks %}
      <div class="testimonial-card" {{ block.shopify_attributes }}>
        <div class="star-image-wrapper">
          {% if block.settings.star_image != blank %}
            <img src="{{ block.settings.star_image | img_url: '200x' }}" class="star-custom-img" alt="Rating">
          {% else %}
            <div style="color: #ffb400;">★★★★★</div> {% comment %} Fallback stars {% endcomment %}
          {% endif %}
        </div>
        <p class="testimonial-text">{{ block.settings.text }}</p>
        <span class="testimonial-author">{{ block.settings.author }}</span>
      </div>
    {% endfor %}
  </div>
</div>

{% schema %}
{
  "name": "Testimonials Grid",
  "settings": [
    { "type": "text", "id": "title", "label": "Heading", "default": "What Our Customers Say" },
    { "type": "color", "id": "bg_color", "label": "Background Color", "default": "#fdfaf0" },
    { 
      "type": "range", 
      "id": "star_width", 
      "min": 50, 
      "max": 200, 
      "step": 5, 
      "unit": "px", 
      "label": "Star Image Width", 
      "default": 100 
    }
  ],
  "blocks": [
    {
      "type": "testimonial",
      "name": "Testimonial",
      "settings": [
        { "type": "image_picker", "id": "star_image", "label": "Star/Rating Image" },
        { "type": "textarea", "id": "text", "label": "Review", "default": "The quality and craftsmanship are absolutely outstanding." },
        { "type": "text", "id": "author", "label": "Author", "default": "Emma Richardson" }
      ]
    }
  ],
  "presets": [{ "name": "Testimonials Grid" }]
}
{% endschema %}