<?php
/** @var array $settings */
/** @var array $page */
/** @var array $modules */
/** @var string $content */
$housesCollection = cms_collection('houses');
$ratesCollection = cms_collection('rates');
$ui = $settings['ui'] ?? [];
$socials = $settings['socials'] ?? ['show_whatsapp' => true, 'show_telegram' => true, 'show_instagram' => false, 'show_max' => false];
$bookingMobilePosition = (string)($ui['booking_mobile_position'] ?? 'header');
$socialMobilePosition = (string)($ui['social_mobile_position'] ?? 'bottom');
$headerLayout = (string)($ui['header_layout'] ?? 'split');
$headerTheme = (string)($ui['header_theme'] ?? 'glass');
$desktopBookingLabel = (string)($ui['desktop_booking_label'] ?? 'Забронировать');
$mobileBookingLabel = (string)($ui['mobile_booking_label'] ?? $desktopBookingLabel);
$showPhoneDesktop = array_key_exists('show_phone_desktop', $ui) ? !empty($ui['show_phone_desktop']) : true;
$showBrandTaglineHeader = !empty($ui['show_brand_tagline_header']);
$socialDesktopPosition = (string)($ui['social_desktop_position'] ?? 'floating');
$headerSticky = array_key_exists('header_sticky', $ui) ? !empty($ui['header_sticky']) : true;
$showHeaderBookingMobile = in_array($bookingMobilePosition, ['header', 'both'], true);
$showFloatingBookingMobile = in_array($bookingMobilePosition, ['floating', 'both'], true);
$showHeaderSocialsMobile = in_array($socialMobilePosition, ['header', 'both'], true);
$showFloatingSocialsMobile = in_array($socialMobilePosition, ['bottom', 'both'], true);
$showInlineSocialsDesktop = in_array($socialDesktopPosition, ['inline', 'both'], true);
$showFloatingSocialsDesktop = in_array($socialDesktopPosition, ['floating', 'both'], true);
$hideFloatingMobileBar = !$showFloatingBookingMobile && !$showFloatingSocialsMobile;
$galleryUi = array_merge([
  'details_thumb_limit' => 8,
  'booking_thumb_limit' => 6,
], $settings['gallery_ui'] ?? []);

$maxUrl = trim((string)($settings['contacts']['max'] ?? ''));
if (!function_exists('normalize_social_url')) {
  function normalize_social_url(string $url, string $base): string
  {
    $url = trim($url);
    if ($url === '') return '';
    if (preg_match('~^https?://~i', $url)) return $url;
    return rtrim($base, '/') . '/' . ltrim($url, '/');
  }
}
$maxUrl = !empty($socials['show_max']) ? normalize_social_url($maxUrl, 'https://max.ru/') : '';

$animalsPopup = cms_animals_popup_settings($settings);
$bookingSuccess = array_merge([
  'enabled' => true,
  'title' => 'Спасибо за заявку',
  'text' => 'Мы скоро с вами свяжемся.',
  'details_template' => "Ваша бронь: {house}\nДаты: {checkin_ru} – {checkout_ru}\nМы свяжемся с вами.",
  'duration_ms' => 10000,
], $settings['booking_success'] ?? []);
$bookingForm = cms_booking_form_settings($settings);
$bookingGuard = booking_form_guard_fields();
$bookingFields = $bookingForm['fields'] ?? [];
$bookingFieldOrder = $bookingForm['field_order'] ?? array_keys($bookingFields);
$renderBookingField = static function (string $fieldKey, array $field) use ($housesCollection, $bookingForm): string {
    if (empty($field['enabled'])) {
        return '';
    }
    $label = e((string)($field['label'] ?? $fieldKey));
    $placeholder = e((string)($field['placeholder'] ?? ''));
    $required = !empty($field['required']) ? ' required' : '';
    $widthClass = (($field['width'] ?? 'half') === 'full') ? ' booking-form__wide' : '';
    $fieldClass = trim('booking-field' . $widthClass);
    $errorId = 'booking-error-' . preg_replace('/[^a-z0-9_-]+/i', '-', $fieldKey);
    ob_start();
    switch ((string)($field['type'] ?? 'text')) {
        case 'house_select': ?>
            <label class="<?= e($fieldClass) ?>" data-booking-field="house"><span><?= $label ?></span>
              <select name="house" data-house-select aria-describedby="<?= e($errorId) ?>"<?= $required ?>>
                <option value=""><?= e((string)($field['placeholder'] ?? $bookingForm['fields']['house']['placeholder'] ?? 'Выберите домик')) ?></option>
                <?php foreach (($housesCollection['items'] ?? []) as $house): ?>
                  <?php $title = (string)($house['title'] ?? ''); if ($title === '') continue; ?>
                  <option value="<?= e($title) ?>"><?= e($title) ?></option>
                <?php endforeach; ?>
              </select>
              <small class="booking-field-error" id="<?= e($errorId) ?>" data-booking-field-error="house" role="alert" hidden></small>
            </label>
            <?php
            break;
        case 'date_text':
            $dataAttr = $fieldKey === 'checkin' ? ' data-checkin' : ' data-checkout'; ?>
            <label class="<?= e($fieldClass) ?>" data-booking-field="<?= e($fieldKey) ?>"><span><?= $label ?></span><input name="<?= e($fieldKey) ?>" readonly aria-describedby="<?= e($errorId) ?>"<?= $required ?><?= $dataAttr ?> placeholder="<?= $placeholder ?>"><small class="booking-field-error" id="<?= e($errorId) ?>" data-booking-field-error="<?= e($fieldKey) ?>" role="alert" hidden></small></label>
            <?php
            break;
        case 'calendar': ?>
            <div class="booking-field booking-form__wide booking-form__wide--calendar" data-booking-field="dates"><span><?= e((string)($bookingForm['calendar_label'] ?? $field['label'] ?? 'Календарь бронирования')) ?></span>
              <small class="booking-field-error booking-field-error--calendar" id="booking-error-dates" data-booking-field-error="dates" role="alert" hidden></small>
              <div class="calendar-picker" data-calendar-picker tabindex="-1" aria-describedby="booking-error-dates"></div>
              <input type="hidden" name="dates" data-dates-range>
            </div>
            <?php
            break;
        case 'number': ?>
            <label class="<?= e($fieldClass) ?>" data-booking-field="<?= e($fieldKey) ?>"><span><?= $label ?></span><input name="<?= e($fieldKey) ?>" type="number" min="<?= e((string)($field['min'] ?? 1)) ?>" max="<?= e((string)($field['max'] ?? 20)) ?>" value="<?= e((string)($field['value'] ?? '')) ?>" aria-describedby="<?= e($errorId) ?>"<?= $required ?>><small class="booking-field-error" id="<?= e($errorId) ?>" data-booking-field-error="<?= e($fieldKey) ?>" role="alert" hidden></small></label>
            <?php
            break;
        case 'select': ?>
            <label class="<?= e($fieldClass) ?>" data-booking-field="<?= e($fieldKey) ?>"><span><?= $label ?></span>
              <select name="<?= e($fieldKey) ?>" aria-describedby="<?= e($errorId) ?>"<?= $required ?>>
                <?php foreach ((array)($field['options'] ?? []) as $option): ?>
                  <?php $optionValue = (string)($option['value'] ?? ''); $optionLabel = (string)($option['label'] ?? $optionValue); ?>
                  <option value="<?= e($optionValue) ?>"><?= e($optionLabel) ?></option>
                <?php endforeach; ?>
              </select>
              <small class="booking-field-error" id="<?= e($errorId) ?>" data-booking-field-error="<?= e($fieldKey) ?>" role="alert" hidden></small>
            </label>
            <?php
            break;
        case 'textarea': ?>
            <label class="<?= e($fieldClass) ?>" data-booking-field="<?= e($fieldKey) ?>"><span><?= $label ?></span><textarea name="<?= e($fieldKey) ?>" rows="<?= e((string)($field['rows'] ?? 4)) ?>" placeholder="<?= $placeholder ?>" aria-describedby="<?= e($errorId) ?>"<?= $required ?>></textarea><small class="booking-field-error" id="<?= e($errorId) ?>" data-booking-field-error="<?= e($fieldKey) ?>" role="alert" hidden></small></label>
            <?php
            break;
        default:
            $inputType = $fieldKey === 'phone' ? 'tel' : 'text';
            $inputMode = $fieldKey === 'phone' ? ' inputmode="tel"' : '';
            $autoComplete = $fieldKey === 'name' ? ' autocomplete="name"' : ($fieldKey === 'phone' ? ' autocomplete="tel"' : ' autocomplete="off"');
            $limits = $fieldKey === 'name' ? ' minlength="2" maxlength="80"' : ($fieldKey === 'phone' ? ' minlength="10" maxlength="25"' : ' maxlength="160"'); ?>
            <label class="<?= e($fieldClass) ?>" data-booking-field="<?= e($fieldKey) ?>"><span><?= $label ?></span><input name="<?= e($fieldKey) ?>" type="<?= e($inputType) ?>"<?= $inputMode ?><?= $autoComplete ?><?= $limits ?> placeholder="<?= $placeholder ?>" aria-describedby="<?= e($errorId) ?>"<?= $required ?>><small class="booking-field-error" id="<?= e($errorId) ?>" data-booking-field-error="<?= e($fieldKey) ?>" role="alert" hidden></small></label>
            <?php
            break;
    }
    return (string)ob_get_clean();
};
$seo = $settings['seo'] ?? [];
$seoTitle = $page['seo']['title'] ?? $settings['branding']['browser_title'] ?? $settings['site_name'] ?? SITE_NAME;
$seoDescription = $page['seo']['description'] ?? ($seo['default_og_description'] ?? '');
$slug = (string)($page['slug'] ?? 'home');
$canonicalPath = $slug === 'home' ? '/' : ($slug === 'policy' ? '/politica.php' : '/rools.php');
$canonical = (seo_site_url() ?: rtrim(base_url(''), '/')) . $canonicalPath;
$seoImage = '';
foreach (($housesCollection['items'] ?? []) as $houseItem) { if (!empty($houseItem['image'])) { $seoImage = (string)$houseItem['image']; break; } }
if ($seoImage !== '' && !preg_match('~^https?://~', $seoImage)) { $seoImage = (seo_site_url() ?: rtrim(base_url(''), '/')) . '/' . ltrim($seoImage, '/'); }
if (!function_exists('render_social_icon')) {
  function render_social_icon(string $kind): string
  {
      switch ($kind) {
          case 'whatsapp':
              return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M16.6 14.3c-.2-.1-1.4-.7-1.6-.8-.2-.1-.4-.1-.5.1-.1.2-.6.8-.8 1-.1.1-.3.2-.5.1-1.5-.8-2.5-1.5-3.5-3.4-.1-.2 0-.4.1-.5l.3-.4.2-.4v-.4c-.1-.1-.5-1.3-.7-1.8-.2-.4-.4-.4-.5-.4h-.5c-.2 0-.4.1-.6.3-.2.2-.8.8-.8 1.9s.8 2.1.9 2.3c.1.2 1.7 2.7 4.2 3.8 2.5 1.1 2.5.7 3 .7s1.5-.6 1.7-1.2c.2-.6.2-1.1.1-1.2-.1-.1-.3-.2-.5-.3Z" fill="currentColor"/><path d="M20 11.9A8 8 0 0 0 6.4 6.2a7.9 7.9 0 0 0-1.1 9.3L4 20l4.6-1.2A8 8 0 1 0 20 11.9Zm-8 6.5c-1.2 0-2.4-.3-3.4-1l-.2-.1-2.7.7.7-2.6-.2-.2A6.3 6.3 0 1 1 12 18.4Z" fill="currentColor"/></svg>';
          case 'telegram':
              return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9.5 15.8 9.3 19c.4 0 .6-.2.8-.4l1.6-1.5 3.2 2.4c.6.3 1 .2 1.2-.6l2.2-10.2c.2-.9-.3-1.2-.9-1l-12 4.6c-.8.3-.8.8-.1 1l3.1 1 7.3-4.6c.3-.2.6 0 .4.2l-6 5.4Z" fill="currentColor"/></svg>';
          case 'instagram':
              return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 7.6A4.4 4.4 0 1 0 12 16.4 4.4 4.4 0 0 0 12 7.6Zm0 7.2A2.8 2.8 0 1 1 12 9.2a2.8 2.8 0 0 1 0 5.6Z" fill="currentColor"/><path d="M17 3.8H7A3.2 3.2 0 0 0 3.8 7v10A3.2 3.2 0 0 0 7 20.2h10a3.2 3.2 0 0 0 3.2-3.2V7A3.2 3.2 0 0 0 17 3.8Zm1.6 13.1a1.6 1.6 0 0 1-1.6 1.6H7a1.6 1.6 0 0 1-1.6-1.6V7A1.6 1.6 0 0 1 7 5.4h10A1.6 1.6 0 0 1 18.6 7v9.9Z" fill="currentColor"/><circle cx="17.2" cy="6.9" r="1" fill="currentColor"/></svg>';
          default:
              return '';
      }
  }
}
track_activity('pageview', ['page' => (string)($page['slug'] ?? 'home')]);
?><!DOCTYPE html>
<html lang="ru">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title><?= e($seoTitle) ?></title>
  <meta name="description" content="<?= e($seoDescription) ?>">
  <meta name="keywords" content="<?= e($page['seo']['keywords'] ?? '') ?>">
  <meta name="theme-color" content="#111111">
  <meta name="robots" content="index,follow,noimageindex">
  <meta name="googlebot" content="index,follow,noimageindex">
  <meta name="yandex" content="index,follow,noimageindex">
  <meta property="og:type" content="website">
  <meta property="og:title" content="<?= e($seo['default_og_title'] ?? $seoTitle) ?>">
  <meta property="og:description" content="<?= e($seoDescription) ?>">
  <meta property="og:url" content="<?= e($canonical) ?>">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:title" content="<?= e($seoTitle) ?>">
  <meta name="twitter:description" content="<?= e($seoDescription) ?>">
  <link rel="canonical" href="<?= e($canonical) ?>">
  <link rel="icon" href="<?= e($settings['branding']['favicon'] ?? '/tild6138-3238-4136-b139-333839626664/favicon.ico') ?>">
  <link rel="stylesheet" href="/assets/app.css?v=102">
  <?php $headAnalyticsCode = cms_render_head_analytics($settings); $bodyAnalyticsCode = cms_render_body_open_analytics($settings); ?>
  <script type="application/ld+json"><?= json_encode([
    '@context' => 'https://schema.org',
    '@type' => 'LodgingBusiness',
    'name' => $settings['brand']['name'] ?? SITE_NAME,
    'description' => $seoDescription,
    'url' => $canonical,
    'telephone' => $settings['contacts']['phone_raw'] ?? '',
    'address' => ['@type' => 'PostalAddress', 'streetAddress' => $settings['contacts']['address'] ?? ''],
  ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></script>
  <?php if ($headAnalyticsCode !== ''): ?>
  <?= $headAnalyticsCode ?>
  <?php endif; ?>
</head>
<body class="<?= e($headerLayout === 'compact' ? 'header-compact' : 'header-split') ?> <?= $headerSticky ? 'has-sticky-header' : '' ?> header-theme-<?= e($headerTheme) ?>" data-details-thumb-limit="<?= e((string)max(2, min(24, (int)($galleryUi['details_thumb_limit'] ?? 8)))) ?>" data-booking-thumb-limit="<?= e((string)max(2, min(24, (int)($galleryUi['booking_thumb_limit'] ?? 6)))) ?>">
  <?php if ($bodyAnalyticsCode !== ''): ?>
  <?= $bodyAnalyticsCode ?>
  <?php endif; ?>
  <div class="site-shell">
    <header class="topbar topbar--theme-<?= e($headerTheme) ?> <?= $headerSticky ? 'topbar--sticky' : 'topbar--static' ?>">
      <div class="container topbar__inner">
        <a class="brand" href="/"><span><?= e($settings['brand']['name'] ?? 'feyaframe.com') ?></span><?php if ($showBrandTaglineHeader && !empty($settings['brand']['tagline'])): ?><small><?= e($settings['brand']['tagline']) ?></small><?php endif; ?></a>
        <nav class="nav">
          <?php foreach (($settings['navigation'] ?? []) as $item): ?>
            <a href="<?= e($item['url'] ?? '#') ?>"><?= e($item['label'] ?? '') ?></a>
          <?php endforeach; ?>
        </nav>
        <div class="topbar__actions">
          <?php if ($showPhoneDesktop): ?><a class="phone-link" href="tel:<?= e($settings['contacts']['phone_raw'] ?? '') ?>"><?= e($settings['contacts']['phone_display'] ?? '') ?></a><?php endif; ?>
          <?php if ($showInlineSocialsDesktop): ?>
            <div class="topbar__desktop-socials">
              <?php if (!empty($socials['show_whatsapp']) && !empty($settings['contacts']['whatsapp'])): ?><a class="social-pill social-pill--whatsapp" href="<?= e($settings['contacts']['whatsapp']) ?>" target="_blank" rel="noopener" aria-label="WhatsApp"><svg viewBox="0 0 32 32" aria-hidden="true"><path d="M19.1 17.5c-.3-.2-1.9-.9-2.2-1s-.5-.2-.8.2-.9 1-1.1 1.2-.4.2-.7 0c-.3-.2-1.4-.5-2.6-1.6-1-1-1.6-2.1-1.8-2.5-.2-.3 0-.5.1-.7.1-.1.3-.4.5-.5.2-.2.2-.3.3-.5.1-.2 0-.4 0-.5 0-.1-.8-2-1.1-2.7-.3-.7-.6-.6-.8-.6h-.7c-.2 0-.5.1-.8.4-.3.3-1 1-1 2.4s1 2.8 1.1 3c.1.2 2 3.2 4.9 4.5.7.3 1.3.5 1.7.7.7.2 1.4.2 1.9.1.6-.1 1.9-.8 2.2-1.6.3-.8.3-1.4.2-1.6-.1-.1-.3-.2-.6-.4Z" fill="currentColor"/><path d="M16.1 4.1a11.8 11.8 0 0 0-10.2 17.7L4 28l6.5-1.7a11.8 11.8 0 1 0 5.6-22.2Zm0 21.4c-1.8 0-3.6-.5-5.1-1.5l-.4-.2-3.9 1 1-3.8-.3-.4a9.6 9.6 0 1 1 8.7 4.9Z" fill="currentColor"/></svg></a><?php endif; ?>
              <?php if (!empty($socials['show_telegram']) && !empty($settings['contacts']['telegram'])): ?><a class="social-pill social-pill--telegram" href="<?= e($settings['contacts']['telegram']) ?>" target="_blank" rel="noopener" aria-label="Telegram"><svg viewBox="0 0 32 32" aria-hidden="true"><path d="M28.4 6.3 4.8 15.4c-1.6.6-1.6 1.5-.3 1.9l6 1.9 2.3 7.3c.3.8.1 1.1 1 .8.7-.3 1-.6 1.3-.9l3.1-3 6.4 4.7c1.2.7 2 .4 2.3-1.1l4-18.9c.4-1.8-.7-2.6-1.8-2Z" fill="currentColor"/></svg></a><?php endif; ?>
              <?php if (!empty($socials['show_instagram']) && !empty($settings['contacts']['instagram'])): ?><a class="social-pill social-pill--instagram" href="<?= e($settings['contacts']['instagram']) ?>" target="_blank" rel="noopener" aria-label="Instagram"><svg viewBox="0 0 32 32" aria-hidden="true"><path d="M16 10.2A5.8 5.8 0 1 0 16 21.8 5.8 5.8 0 0 0 16 10.2Zm0 9.5A3.7 3.7 0 1 1 16 12.3a3.7 3.7 0 0 1 0 7.4Z" fill="currentColor"/><path d="M23.4 9.9a1.4 1.4 0 1 0 0-2.8 1.4 1.4 0 0 0 0 2.8Z" fill="currentColor"/></svg></a><?php endif; ?>
              <?php if (!empty($socials['show_max']) && $maxUrl !== ''): ?><a class="social-pill social-pill--max" href="<?= e($maxUrl) ?>" target="_blank" rel="noopener" aria-label="MAX"><svg viewBox="0 0 32 32" aria-hidden="true"><path d="M16 3.5C9.1 3.5 3.5 8.8 3.5 15.4c0 3.5 1.5 6.7 4.1 8.9l-1.2 4.2c-.1.5.3.9.8.8l4.6-1.1c1.3.4 2.7.6 4.2.6 6.9 0 12.5-5.3 12.5-11.9S22.9 3.5 16 3.5Z" fill="currentColor"/><path d="M9.4 21V10.8h2.1l4.5 5.7 4.5-5.7h2.1V21h-2.4v-6.4l-3.4 4.2h-.8l-3.4-4.2V21H9.4Z" fill="#fff"/></svg></a><?php endif; ?>
            </div>
          <?php endif; ?>
          <button class="button button--primary" type="button" data-open-booking data-house=""><?= e($desktopBookingLabel) ?></button>
        </div>
        <button class="burger" type="button" data-burger aria-label="Открыть меню">☰</button>
        <div class="topbar__mobile-cta">
          <?php if ($showHeaderBookingMobile): ?>
            <button class="button button--primary button--mobile-booking" type="button" data-open-booking data-house=""><?= e($mobileBookingLabel) ?></button>
          <?php endif; ?>
          <?php if ($showHeaderSocialsMobile): ?>
            <div class="topbar__mobile-socials">
              <?php if (!empty($socials['show_whatsapp']) && !empty($settings['contacts']['whatsapp'])): ?>
                <a class="social-pill social-pill--whatsapp" href="<?= e($settings['contacts']['whatsapp']) ?>" target="_blank" rel="noopener" aria-label="WhatsApp"><svg viewBox="0 0 32 32" aria-hidden="true"><path d="M19.1 17.5c-.3-.2-1.9-.9-2.2-1s-.5-.2-.8.2-.9 1-1.1 1.2-.4.2-.7 0c-.3-.2-1.4-.5-2.6-1.6-1-1-1.6-2.1-1.8-2.5-.2-.3 0-.5.1-.7.1-.1.3-.4.5-.5.2-.2.2-.3.3-.5.1-.2 0-.4 0-.5 0-.1-.8-2-1.1-2.7-.3-.7-.6-.6-.8-.6h-.7c-.2 0-.5.1-.8.4-.3.3-1 1-1 2.4s1 2.8 1.1 3c.1.2 2 3.2 4.9 4.5.7.3 1.3.5 1.7.7.7.2 1.4.2 1.9.1.6-.1 1.9-.8 2.2-1.6.3-.8.3-1.4.2-1.6-.1-.1-.3-.2-.6-.4Z" fill="currentColor"/><path d="M16.1 4.1a11.8 11.8 0 0 0-10.2 17.7L4 28l6.5-1.7a11.8 11.8 0 1 0 5.6-22.2Zm0 21.4c-1.8 0-3.6-.5-5.1-1.5l-.4-.2-3.9 1 1-3.8-.3-.4a9.6 9.6 0 1 1 8.7 4.9Z" fill="currentColor"/></svg></a>
              <?php endif; ?>
              <?php if (!empty($socials['show_telegram']) && !empty($settings['contacts']['telegram'])): ?>
                <a class="social-pill social-pill--telegram" href="<?= e($settings['contacts']['telegram']) ?>" target="_blank" rel="noopener" aria-label="Telegram"><svg viewBox="0 0 32 32" aria-hidden="true"><path d="M28.4 6.3 4.8 15.4c-1.6.6-1.6 1.5-.3 1.9l6 1.9 2.3 7.3c.3.8.1 1.1 1 .8.7-.3 1-.6 1.3-.9l3.1-3 6.4 4.7c1.2.7 2 .4 2.3-1.1l4-18.9c.4-1.8-.7-2.6-1.8-2Z" fill="currentColor"/></svg></a>
              <?php endif; ?>
              <?php if (!empty($socials['show_instagram']) && !empty($settings['contacts']['instagram'])): ?>
                <a class="social-pill social-pill--instagram" href="<?= e($settings['contacts']['instagram']) ?>" target="_blank" rel="noopener" aria-label="Instagram"><svg viewBox="0 0 32 32" aria-hidden="true"><path d="M16 10.2A5.8 5.8 0 1 0 16 21.8 5.8 5.8 0 0 0 16 10.2Zm0 9.5A3.7 3.7 0 1 1 16 12.3a3.7 3.7 0 0 1 0 7.4Z" fill="currentColor"/><path d="M23.4 9.9a1.4 1.4 0 1 0 0-2.8 1.4 1.4 0 0 0 0 2.8Z" fill="currentColor"/></svg></a>
              <?php endif; ?>
              <?php if (!empty($socials['show_max']) && $maxUrl !== ''): ?>
                <a class="social-pill social-pill--max" href="<?= e($maxUrl) ?>" target="_blank" rel="noopener" aria-label="MAX"><svg viewBox="0 0 32 32" aria-hidden="true"><path d="M16 3.5C9.1 3.5 3.5 8.8 3.5 15.4c0 3.5 1.5 6.7 4.1 8.9l-1.2 4.2c-.1.5.3.9.8.8l4.6-1.1c1.3.4 2.7.6 4.2.6 6.9 0 12.5-5.3 12.5-11.9S22.9 3.5 16 3.5Z" fill="currentColor"/><path d="M9.4 21V10.8h2.1l4.5 5.7 4.5-5.7h2.1V21h-2.4v-6.4l-3.4 4.2h-.8l-3.4-4.2V21H9.4Z" fill="#fff"/></svg></a>
              <?php endif; ?>
            </div>
          <?php endif; ?>
        </div>
      </div>
      <div class="mobile-nav" data-mobile-nav>
        <?php foreach (($settings['navigation'] ?? []) as $item): ?>
          <a href="<?= e($item['url'] ?? '#') ?>"><?= e($item['label'] ?? '') ?></a>
        <?php endforeach; ?>
        <?php if (!$showHeaderBookingMobile): ?>
          <button class="button button--primary button--full" type="button" data-open-booking data-house=""><?= e($mobileBookingLabel) ?></button>
        <?php endif; ?>
      </div>
    </header>
    <main>
      <?= $content ?>
    </main>
    <footer class="footer">
      <div class="container footer__grid">
        <div>
          <div class="footer__brand"><?= e($settings['brand']['name'] ?? 'feyaframe.com') ?></div>
          <p><?= e($settings['brand']['tagline'] ?? '') ?></p>
        </div>
        <div>
          <div class="footer__title">Контакты</div>
          <a href="tel:<?= e($settings['contacts']['phone_raw'] ?? '') ?>"><?= e($settings['contacts']['phone_display'] ?? '') ?></a><br>
          <a href="mailto:<?= e($settings['contacts']['email'] ?? '') ?>"><?= e($settings['contacts']['email'] ?? '') ?></a><br>
          <span><?= e($settings['contacts']['address'] ?? '') ?></span>
        </div>
        <div>
          <div class="footer__title">Документы</div>
          <a href="/politica.php">Политика конфиденциальности</a><br>
          <a href="/rools.php">Правила проживания</a>
        </div>
      </div>
    </footer>
  </div>

    <div class="floating-actions <?= $showFloatingBookingMobile ? '' : 'floating-actions--hide-mobile-booking' ?> <?= $showFloatingSocialsMobile ? '' : 'floating-actions--hide-mobile-socials' ?> <?= $showFloatingSocialsDesktop ? '' : 'floating-actions--hide-desktop-socials' ?> <?= $hideFloatingMobileBar ? 'floating-actions--hide-on-mobile' : '' ?>">
      <div class="floating-actions__row">
        <button class="floating-booking" type="button" data-open-booking data-house=""><?= e($desktopBookingLabel) ?></button>
        <?php if (!empty($socials['show_whatsapp']) && !empty($settings['contacts']['whatsapp'])): ?>
          <a class="social-pill social-pill--whatsapp" href="<?= e($settings['contacts']['whatsapp']) ?>" target="_blank" rel="noopener" aria-label="WhatsApp">
            <svg viewBox="0 0 32 32" aria-hidden="true"><path d="M19.1 17.5c-.3-.2-1.9-.9-2.2-1s-.5-.2-.8.2-.9 1-1.1 1.2-.4.2-.7 0c-.3-.2-1.4-.5-2.6-1.6-1-1-1.6-2.1-1.8-2.5-.2-.3 0-.5.1-.7.1-.1.3-.4.5-.5.2-.2.2-.3.3-.5.1-.2 0-.4 0-.5 0-.1-.8-2-1.1-2.7-.3-.7-.6-.6-.8-.6h-.7c-.2 0-.5.1-.8.4-.3.3-1 1-1 2.4s1 2.8 1.1 3c.1.2 2 3.2 4.9 4.5.7.3 1.3.5 1.7.7.7.2 1.4.2 1.9.1.6-.1 1.9-.8 2.2-1.6.3-.8.3-1.4.2-1.6-.1-.1-.3-.2-.6-.4Z" fill="currentColor"/><path d="M16.1 4.1a11.8 11.8 0 0 0-10.2 17.7L4 28l6.5-1.7a11.8 11.8 0 1 0 5.6-22.2Zm0 21.4c-1.8 0-3.6-.5-5.1-1.5l-.4-.2-3.9 1 1-3.8-.3-.4a9.6 9.6 0 1 1 8.7 4.9Z" fill="currentColor"/></svg>
          </a>
        <?php endif; ?>
        <?php if (!empty($socials['show_telegram']) && !empty($settings['contacts']['telegram'])): ?>
          <a class="social-pill social-pill--telegram" href="<?= e($settings['contacts']['telegram']) ?>" target="_blank" rel="noopener" aria-label="Telegram">
            <svg viewBox="0 0 32 32" aria-hidden="true"><path d="M28.4 6.3 4.8 15.4c-1.6.6-1.6 1.5-.3 1.9l6 1.9 2.3 7.3c.3.8.1 1.1 1 .8.7-.3 1-.6 1.3-.9l3.1-3 6.4 4.7c1.2.7 2 .4 2.3-1.1l4-18.9c.4-1.8-.7-2.6-1.8-2Z" fill="currentColor"/><path d="m13.2 25.8.5-5.5 10-9.1c.4-.4-.1-.6-.6-.3L10.8 18.7l-5.3-1.7c-1.1-.4-1.1-1.1.2-1.6l20.9-8.1c1-.4 1.9.2 1.6 1.6l-3.6 17.1c-.3 1.2-.9 1.5-1.8.9l-6.1-4.5-2.9 2.8c-.3.3-.6.6-1.1.6-.3 0-.4-.1-.5-.6Z" fill="#fff" fill-opacity=".15"/></svg>
          </a>
        <?php endif; ?>
        <?php if (!empty($socials['show_instagram']) && !empty($settings['contacts']['instagram'])): ?>
          <a class="social-pill social-pill--instagram" href="<?= e($settings['contacts']['instagram']) ?>" target="_blank" rel="noopener" aria-label="Instagram">
            <svg viewBox="0 0 32 32" aria-hidden="true"><path d="M16 10.2A5.8 5.8 0 1 0 16 21.8 5.8 5.8 0 0 0 16 10.2Zm0 9.5A3.7 3.7 0 1 1 16 12.3a3.7 3.7 0 0 1 0 7.4Z" fill="currentColor"/><path d="M23.4 9.9a1.4 1.4 0 1 0 0-2.8 1.4 1.4 0 0 0 0 2.8Z" fill="currentColor"/><path d="M16 4.8c3.6 0 4 .1 5.4.1 1.3.1 2 .3 2.5.5.6.2 1 .5 1.4.9.4.4.7.8.9 1.4.2.5.4 1.2.5 2.5.1 1.4.1 1.8.1 5.4s0 4-.1 5.4c-.1 1.3-.3 2-.5 2.5-.2.6-.5 1-.9 1.4-.4.4-.8.7-1.4.9-.5.2-1.2.4-2.5.5-1.4.1-1.8.1-5.4.1s-4 0-5.4-.1c-1.3-.1-2-.3-2.5-.5-.6-.2-1-.5-1.4-.9-.4-.4-.7-.8-.9-1.4-.2-.5-.4-1.2-.5-2.5-.1-1.4-.1-1.8-.1-5.4s0-4 .1-5.4c.1-1.3.3-2 .5-2.5.2-.6.5-1 .9-1.4.4-.4.8-.7 1.4-.9.5-.2 1.2-.4 2.5-.5 1.4-.1 1.8-.1 5.4-.1Zm0-2.1c-3.7 0-4.2 0-5.5.1-1.4.1-2.4.3-3.2.6-.8.3-1.5.7-2.1 1.3-.6.6-1 1.3-1.3 2.1-.3.8-.5 1.8-.6 3.2C2.7 11.3 2.7 11.8 2.7 15.5s0 4.2.1 5.5c.1 1.4.3 2.4.6 3.2.3.8.7 1.5 1.3 2.1.6.6 1.3 1 2.1 1.3.8.3 1.8.5 3.2.6 1.3.1 1.8.1 5.5.1s4.2 0 5.5-.1c1.4-.1 2.4-.3 3.2-.6.8-.3 1.5-.7 2.1-1.3.6-.6 1-1.3 1.3-2.1.3-.8.5-1.8.6-3.2.1-1.3.1-1.8.1-5.5s0-4.2-.1-5.5c-.1-1.4-.3-2.4-.6-3.2-.3-.8-.7-1.5-1.3-2.1-.6-.6-1.3-1-2.1-1.3-.8-.3-1.8-.5-3.2-.6-1.3-.1-1.8-.1-5.5-.1Z" fill="currentColor"/></svg>
          </a>
        <?php endif; ?>
        <?php if (!empty($socials['show_max']) && $maxUrl !== ''): ?>
          <a class="social-pill social-pill--max" href="<?= e($maxUrl) ?>" target="_blank" rel="noopener" aria-label="MAX"><svg viewBox="0 0 32 32" aria-hidden="true"><path d="M16 3.5C9.1 3.5 3.5 8.8 3.5 15.4c0 3.5 1.5 6.7 4.1 8.9l-1.2 4.2c-.1.5.3.9.8.8l4.6-1.1c1.3.4 2.7.6 4.2.6 6.9 0 12.5-5.3 12.5-11.9S22.9 3.5 16 3.5Z" fill="currentColor"/><path d="M9.4 21V10.8h2.1l4.5 5.7 4.5-5.7h2.1V21h-2.4v-6.4l-3.4 4.2h-.8l-3.4-4.2V21H9.4Z" fill="#fff"/></svg></a>
        <?php endif; ?>
      </div>
    </div>

  <div class="modal" data-booking-modal hidden>
    <div class="modal__backdrop" data-close-booking></div>
    <div class="modal__dialog modal__dialog--booking" role="dialog" aria-modal="true" aria-labelledby="booking-title">
      <button class="modal__close" type="button" data-close-booking>×</button>
      <div class="booking-layout">
        <aside class="booking-aside">
          <div class="booking-aside__media" data-booking-house-gallery></div>
          <div class="booking-aside__body booking-aside__body--premium">
            <div class="booking-panel">
              <div class="eyebrow"><?= e($bookingForm['eyebrow'] ?? 'Выбранный вариант') ?></div>
              <h2 id="booking-title" data-booking-house-title><?= e($bookingForm['title'] ?? 'Забронировать отдых') ?></h2>
              <p class="muted" data-booking-house-description><?= e($bookingForm['house_description'] ?? 'Выберите домик и даты — мы сразу отправим заявку администратору в Telegram.') ?></p>
              <div class="house-badges" data-booking-house-meta></div>
              <div class="booking-staytimes" data-booking-house-times></div>
              <div class="booking-amenities" data-booking-house-features></div>
              <div class="booking-note" data-booking-house-note hidden></div>
            </div>
            <div class="booking-summary card booking-summary--premium">
              <div class="booking-summary__row"><span><?= e($bookingForm['summary_nights_label'] ?? 'Ночей') ?></span><strong data-summary-nights>—</strong></div>
              <div class="booking-summary__row"><span><?= e($bookingForm['summary_total_label'] ?? 'Стоимость от') ?></span><strong data-summary-total><?= e($bookingForm['summary_total_empty'] ?? 'Выберите даты') ?></strong></div>
              <p class="booking-summary__hint"><?= e($bookingForm['summary_hint'] ?? 'Итоговую стоимость подтверждает администратор с учётом выбранного дома, дат, сезона и дополнительных услуг.') ?></p>
            </div>
          </div>
        </aside>
        <section class="booking-main">
          <p class="muted booking-main__lead"><?= e($bookingForm['lead_text'] ?? 'Выберите домик, отметьте даты заезда и выезда в календаре и оставьте контакты — мы быстро подтвердим бронь в Telegram.') ?></p><div class="booking-main__caption"><?= e($bookingForm['caption'] ?? 'Удобный премиальный формат бронирования: главное о домике слева, контакты и календарь справа.') ?></div>
          <form class="booking-form" data-booking-form data-token-endpoint="/form-token.php" action="/send.php" method="post" novalidate>
            <input type="hidden" name="csrf_token" value="<?= e(csrf_token()) ?>">
            <input type="hidden" name="form_issued_at" value="<?= e($bookingGuard['issued_at']) ?>">
            <input type="hidden" name="form_token" value="<?= e($bookingGuard['token']) ?>">
            <input type="hidden" name="form_signature" value="<?= e($bookingGuard['signature']) ?>">
            <input type="hidden" name="js_enabled" value="0" data-js-enabled>
            <input type="hidden" name="interaction_started_at" value="0" data-interaction-started>
            <input type="hidden" name="page_slug" value="<?= e($page['slug'] ?? 'home') ?>">
            <input type="hidden" name="source" value="modal">
            <input type="hidden" name="estimated_total" data-estimated-total>
            <div class="booking-form__grid">
              <?php foreach ($bookingFieldOrder as $bookingFieldKey): ?>
                <?php if (!isset($bookingFields[$bookingFieldKey])) continue; ?>
                <?= $renderBookingField((string)$bookingFieldKey, (array)$bookingFields[$bookingFieldKey]) ?>
              <?php endforeach; ?>
            </div>
            <label class="consent booking-field" data-booking-field="privacy">
              <input type="checkbox" name="privacy" value="1" aria-describedby="booking-error-privacy" required>
              <span><?= e(rtrim((string)($bookingForm['consent_prefix'] ?? 'Согласен на обработку персональных данных и принимаю'))) ?> <a href="<?= e($bookingForm['privacy_link_url'] ?? '/politica.php') ?>" target="_blank" rel="noopener"><?= e($bookingForm['privacy_link_label'] ?? 'политику конфиденциальности') ?></a> <?= e(trim((string)($bookingForm['consent_middle'] ?? 'и'))) ?> <a href="<?= e($bookingForm['rules_link_url'] ?? '/rools.php') ?>" target="_blank" rel="noopener"><?= e($bookingForm['rules_link_label'] ?? 'правила проживания') ?></a><?= e($bookingForm['consent_suffix'] ?? '.') ?></span>
              <small class="booking-field-error" id="booking-error-privacy" data-booking-field-error="privacy" role="alert" hidden></small>
            </label>
            <label class="hp-field" aria-hidden="true">Сайт<input type="text" name="company" tabindex="-1" autocomplete="new-password"></label>
            <label class="hp-field" aria-hidden="true">Факс<input type="text" name="fax_number" tabindex="-1" autocomplete="new-password"></label>
            <button class="button button--primary button--full" type="button" data-booking-submit><?= e($bookingForm['submit_label'] ?? 'Отправить заявку') ?></button>
            <div class="form-status" data-form-status role="status" aria-live="assertive" aria-atomic="true"></div>
          </form>
        </section>
      </div>
    </div>
  </div>

  <script id="availability-data" type="application/json"><?= json_encode(cms_availability(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></script>
  <script id="houses-data" type="application/json"><?= json_encode($housesCollection, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></script>
  <script id="rates-data" type="application/json"><?= json_encode($ratesCollection, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></script>
  <div class="modal" data-details-modal hidden>
    <div class="modal__backdrop" data-close-details></div>
    <div class="modal__dialog modal__dialog--details" role="dialog" aria-modal="true" aria-labelledby="details-title">
      <button class="modal__close" type="button" data-close-details>×</button>
      <div class="details-layout details-layout--premium">
        <div class="details-layout__gallery" data-details-gallery></div>
        <div class="details-layout__content details-layout__content--premium">
          <div class="details-hero">
            <div class="eyebrow">Подробнее о домике</div>
            <h2 id="details-title" data-details-title>Домик</h2>
            <div class="house-badges" data-details-meta></div>
            <div class="details-staytimes" data-details-times></div>
            <p class="details-description" data-details-description></p>
          </div>
          <div class="details-grid">
            <div class="details-section details-section--card">
              <h3>Что есть в домике</h3>
              <div class="details-richtext" data-details-inside></div>
            </div>
            <div class="details-section details-section--card">
              <h3>Что есть на территории</h3>
              <div class="details-richtext" data-details-territory></div>
            </div>
          </div>
          <div class="details-section details-section--card">
            <h3>Преимущества и особенности</h3>
            <div class="details-features" data-details-features></div>
            <div class="details-pros" data-details-pros></div>
          </div>
          <div class="module-actions module-actions--premium">
            <button class="button button--primary" type="button" data-details-booking>Забронировать этот домик</button>
            <button class="button button--ghost" type="button" data-close-details>Закрыть</button>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div class="modal lightbox-modal" data-lightbox-modal hidden>
    <div class="modal__backdrop" data-close-lightbox></div>
    <div class="modal__dialog modal__dialog--lightbox" role="dialog" aria-modal="true" aria-label="Просмотр фотографии">
      <button class="modal__close" type="button" data-close-lightbox>×</button>
      <button class="lightbox-nav lightbox-nav--prev" type="button" data-lightbox-prev aria-label="Предыдущее фото">‹</button>
      <div class="lightbox-stage">
        <img src="" alt="Увеличенное фото" data-lightbox-image>
      </div>
      <button class="lightbox-nav lightbox-nav--next" type="button" data-lightbox-next aria-label="Следующее фото">›</button>
      <div class="lightbox-counter" data-lightbox-counter></div>
    </div>
  </div>
  <div class="modal booking-success-modal" data-booking-success-modal hidden>
    <div class="modal__backdrop booking-success-modal__backdrop" data-close-booking-success></div>
    <div class="booking-success-card" role="status" aria-live="polite" aria-modal="true" aria-label="Сообщение об успешной отправке">
      <button class="modal__close booking-success-card__close" type="button" data-close-booking-success>×</button>
      <div class="booking-success-card__icon">✓</div>
      <h3 class="booking-success-card__title" data-booking-success-title><?= e($bookingSuccess['title']) ?></h3>
      <p class="booking-success-card__text" data-booking-success-text><?= e($bookingSuccess['text']) ?></p>
      <p class="booking-success-card__hint">Окно закроется автоматически через <span data-booking-success-seconds><?= max(1, (int)ceil(((int)$bookingSuccess['duration_ms']) / 1000)) ?></span> сек.</p>
      <button class="button button--primary button--full" type="button" data-close-booking-success>Закрыть</button>
    </div>
  </div>
  <script id="booking-success-settings" type="application/json"><?= json_encode($bookingSuccess, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></script>

  <script>window.TRACK_PAGE=<?= json_encode((string)($page['slug'] ?? 'home'), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>;</script>
  <div class="modal" data-animals-modal hidden aria-hidden="true">
  <div class="modal__backdrop" data-close-animals></div>
  <div class="modal__dialog modal__dialog--animals">
    <button class="modal__close" type="button" data-close-animals aria-label="Закрыть">×</button>
    <div class="animals-modal__hero">
      <div class="eyebrow"><?= e($animalsPopup['eyebrow'] ?? 'Загородный отдых') ?></div>
      <h2 data-animals-title><?= e($animalsPopup['title'] ?? 'Про наших животных') ?></h2>
    </div>
    <div class="animals-modal__content" data-animals-text><?= nl2br(e($animalsPopup['text'] ?? '')) ?></div>
  </div>
</div>

  <script src="/assets/app.js?v=105"></script>
</body>
</html>
