{% set count_counters =
  craft.entries().section('countersBlock').level(1).count()
%}

<article data-co-59534 id="{{ id }}" class="py-5 countersBlockData bg-{{ index.index0 }} ">
	<section class="container countersBlock py-4">
		<div class="col-12 col-lg-8 mx-auto">
			<h2 class="countersBlock__title">
				{{ component.countersTitle }}
			</h2>
			{% if (component.subtitle|length) > 0 %}
				<h3 class="countersBlock__subtitle">
					{{ component.subtitle }}
				</h3>
			{% endif %}
			{% if (component.titleCounter|length) > 0 %}
				<h4 class="countersBlock__titleCounter counters" data-number="{{ component.titleCounter }}">
					{{ component.titleCounter }}
				</h4>
			{% endif %}
			{% if (component.titleCounterDescription|length) > 0 %}
				<section class="countersBlock__descriptionCounter">
					{{ component.titleCounterDescription }}
				</section>
			{% endif %}
		</div>
		{% if count_counters > 0 %}
			{% for item in craft.entries().section('countersBlock').level(1).all() %}
				{% if item.children.count() > 0 %}
					<p class="col-12 col-md-6 mx-auto text-center countersBlock__titleBlock">
						{{ item.title }}
					</p>
					<div class="row countersBlock__counters">
						{% for j in item.children.all() %}
							<section class="col-12 col-md-4 my-5 countersBlock__counters--item">
								<div class="title mb-0 col-12">
									{% if (j.fieldText|length) > 0 %}
										<span>{{ j.fieldText }}</span>
									{% endif %}
									<span class="counters" data-number="{{ j.title }}">
										{{ j.title }}
									</span>
									{% if (j.fieldText1|length) > 0 %}
										<span class="{{ (j.fieldText1|length) > 8 ? 'd-block' : null }}">
											{{ j.fieldText1 }}
										</span>
									{% endif %}
								</div>
								<div class="description mt-3">
									{{ j.fieldRedactor }}
								</div>
							</section>
						{% endfor %}
					</div>
				{% endif %}
			{% endfor %}
		{% endif %}
	</section>
</article>
