<?php
$collection = cms_collection($module['collection'] ?? 'rates');
$rows = $collection['items'] ?? [];
$grouped = [];
foreach ($rows as $row) {
  $grouped[$row['house'] ?? 'Без названия'][] = $row;
}
?>
<section class="section" id="<?= e($module['anchor'] ?? 'rates') ?>">
  <div class="container">
    <div class="section-heading">
      <div class="eyebrow"><?= e($module['eyebrow'] ?? '') ?></div>
      <h2><?= e($module['title'] ?? '') ?></h2>
      <p><?= e($module['text'] ?? '') ?></p>
    </div>
    <div class="cards cards--2 rate-groups">
      <?php foreach ($grouped as $house => $items): ?>
        <article class="card rate-group">
          <h3><?= e($house) ?></h3>
          <?php foreach ($items as $item): ?>
            <div class="rate-row">
              <div>
                <strong><?= e($item['season'] ?? 'Тариф') ?></strong>
                <div class="muted"><?= e($item['notes'] ?? '') ?></div>
              </div>
              <div class="rate-row__prices">
                <span>Будни: <?= e($item['weekday_price'] ?? '') ?></span>
                <span>Выходные: <?= e($item['weekend_price'] ?? '') ?></span>
              </div>
            </div>
          <?php endforeach; ?>
        </article>
      <?php endforeach; ?>
    </div>
  </div>
</section>
