<section class="section" id="<?= e($module['anchor'] ?? 'contacts') ?>">
  <div class="container split split--contacts-enhanced">
    <div>
      <div class="eyebrow"><?= e($module['eyebrow'] ?? '') ?></div>
      <h2><?= e($module['title'] ?? '') ?></h2>
      <p><?= e($module['text'] ?? '') ?></p>
      <div class="contact-stack">
        <a href="tel:<?= e($settings['contacts']['phone_raw'] ?? '') ?>"><?= e($settings['contacts']['phone_display'] ?? '') ?></a>
        <a href="mailto:<?= e($settings['contacts']['email'] ?? '') ?>"><?= e($settings['contacts']['email'] ?? '') ?></a>
        <?php if (!empty($settings['contacts']['telegram'])): ?><a href="<?= e($settings['contacts']['telegram']) ?>" target="_blank" rel="noopener">Telegram</a><?php endif; ?>
        <?php if (!empty($settings['contacts']['max'])): ?><a href="<?= e($settings['contacts']['max']) ?>" target="_blank" rel="noopener">MAX</a><?php endif; ?>
      </div>

      <?php
      $locationModule = cms_module('complex-map-home');
      $locationAddress = trim((string)($locationModule['address_label'] ?? ($locationModule['address'] ?? ($settings['contacts']['address'] ?? ''))));
      $locationLat = trim((string)($locationModule['map_lat'] ?? ''));
      $locationLon = trim((string)($locationModule['map_lon'] ?? ''));
      $locationZoom = (int)($locationModule['map_zoom'] ?? 16);
      if ($locationZoom < 3 || $locationZoom > 20) { $locationZoom = 16; }
      $contactRouteParams = ($locationLat !== '' && $locationLon !== '')
          ? ['ll' => $locationLon . ',' . $locationLat, 'z' => $locationZoom, 'pt' => $locationLon . ',' . $locationLat . ',pm2rdl']
          : ['mode' => 'search', 'text' => ($locationAddress !== '' ? $locationAddress : ($settings['contacts']['address'] ?? '')), 'z' => $locationZoom];
      $contactRouteUrl = 'https://yandex.ru/maps/?' . http_build_query($contactRouteParams);
      ?>

      <?php if ($locationAddress !== ''): ?>
      <div class="contacts-location-card">
        <div class="contacts-location-card__icon">⌖</div>
        <div class="contacts-location-card__body">
          <div class="contacts-location-card__eyebrow">Адрес комплекса</div>
          <p><?= e($locationAddress) ?></p>
        </div>
        <a class="button button--primary contacts-location-card__action" href="<?= e($contactRouteUrl) ?>" target="_blank" rel="noopener">Построить маршрут</a>
      </div>
      <?php endif; ?>
    </div>
    <div class="split__media">
      <img src="<?= e($module['image'] ?? '') ?>" alt="<?= e($module['title'] ?? '') ?>" loading="lazy">
    </div>
  </div>
</section>
