{source}
<?php
$legalStats = [['number' => 25, 'suffix' => '', 'label' => 'anni di esperienza'],
['number' => 100, 'suffix' => '%', 'label' => 'risoluzione di<br>controversie giuridiche'],
['number' => 100, 'suffix' => '%', 'label' => 'cause ereditarie'],
['number' => 100, 'suffix' => '%', 'label' => 'recupero crediti'],
];
?>
<section class="az-legal-stats"><div class="az-legal-stats-heading">
<h2>Assistenza legale nei casi di diritto</h2>
<p>Uno studio legale composto da avvocati dalla comprovata fama ed esperienza.</p>
</div>
<div class="az-legal-stats-box">
<?php foreach ($legalStats as $stat) : ?>
<div class="az-legal-stat-item">
<div class="az-legal-stat-number">
<span class="az-legal-counter" data-target="<?php echo $stat['number']; ?>">0</span><?php echo $stat['suffix']; ?>
</div>
<div class="az-legal-stat-label">
<?php echo $stat['label']; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</section>
<style>
.az-legal-stats {width: 100%;
padding: 30px 20px;
background: transparent;
text-align: center;
box-sizing: border-box;
}
.az-legal-stats-heading {margin-bottom: 25px;
}
.az-legal-stats-heading h2 {margin: 0;
color: #1f5fa7;
font-size: 32px;
font-weight: 500;
line-height: 1.15;
}
.az-legal-stats-heading p {margin: 5px 0 0;
color: #1f5fa7;
font-size: 16px;
font-weight: 500;
}
.az-legal-stats-box {max-width: 1400px;
margin: 0 auto;
background: #2f6fb0;
padding: 30px 20px;
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 20px;
box-sizing: border-box;
}
.az-legal-stat-item {padding: 5px;
color: #ffffff;
}
.az-legal-stat-number {font-family: Georgia, "Times New Roman", serif;
font-size: 52px;
font-weight: 700;
line-height: 1;
color: #ffffff;
}
.az-legal-stat-label {margin-top: 10px;
font-size: 15px;
font-weight: 700;
line-height: 1.25;
color: #ffffff;
}
@media (max-width: 991px) {.az-legal-stats-heading h2 {
font-size: 28px;
}
.az-legal-stats-heading p {
font-size: 15px;
}
.az-legal-stats-box {
grid-template-columns: repeat(2, 1fr);
padding: 25px 15px;
gap: 25px;
}
.az-legal-stat-number {
font-size: 44px;
}
}
@media (max-width: 575px) {.az-legal-stats {
padding: 20px 15px;
}
.az-legal-stats-heading {
margin-bottom: 20px;
}
.az-legal-stats-heading h2 {
font-size: 24px;
}
.az-legal-stats-heading p {
font-size: 14px;
}
.az-legal-stats-box {
grid-template-columns: 1fr;
padding: 25px 15px;
gap: 20px;
}
.az-legal-stat-number {
font-size: 42px;
}
.az-legal-stat-label {
font-size: 14px;
}
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function () {const statsSection = document.querySelector('.az-legal-stats');
if (!statsSection) return;
const counters = statsSection.querySelectorAll('.az-legal-counter');
let hasStarted = false;
function animateCounter(counter) {
const target = parseInt(counter.getAttribute('data-target'), 10);
if (isNaN(target)) return;
const duration = 1600;
const startTime = performance.now();
function updateCounter(currentTime) {
const elapsed = currentTime - startTime;
const progress = Math.min(elapsed / duration, 1);
counter.textContent = Math.floor(progress * target);
if (progress < 1) {
requestAnimationFrame(updateCounter);
} else {
counter.textContent = target;
}
}
requestAnimationFrame(updateCounter);
}
function startCounters() {
if (hasStarted) return;
hasStarted = true;
counters.forEach(function (counter) {
animateCounter(counter);
});
}
if ('IntersectionObserver' in window) {
const observer = new IntersectionObserver(function (entries) {
if (entries[0].isIntersecting) {
startCounters();
observer.disconnect();
}
}, {
threshold: 0.3
});
observer.observe(statsSection);
} else {
startCounters();
}
});
</script>
{/source}