<?php get_header(); ?>

  <section class="v2ray-vpn">
    <div class="container">
      <div class="intro-v2ray">
        <h1 class="title-h1-v2ray scroll-fade-in"><?php the_field( 'zagolovok_home' ); ?></h1>
        <p class="use-v2ray scroll-fade-in">
          <?php the_field( 'tekst_pod_zagolovkom_home' ); ?>
        </p>
        <div class="intro-buttons-vpn scroll-fade-in">
          <a href="#" class="nav-trigger intro-button-getkey">Получить ключ</a>
          <a href="#features" class="intro-button-moreinfo">Узнать больше</a>
        </div>
        <div class="features-v2rayvpn scroll-fade-in">
          <?php if ( have_rows( 'preimushhestva_home' ) ) : ?>
            <?php while ( have_rows( 'preimushhestva_home' ) ) : the_row(); ?>
              <div class="card-item">
                <span class="intro-numb"><?php the_sub_field( 'tekst_v_pervoj_stroke' ); ?></span>
                <span class="intro-txt"><?php the_sub_field( 'tekst_vo_vtoroj_stroke' ); ?></span>
              </div>
              <?php endwhile; ?>
                <?php else : ?>
                  <?php // No rows found ?>
                    <?php endif; ?>
        </div>
      </div>
    </div>
  </section>

  <section id="features" class="why">
    <div class="container">
      <h2 class="h2-v2ray-vpn"><?php the_field( 'zagolovok_bloka_pochemu_vybirayut' ); ?></h2>
      <div class="why-choose-v2ray">
        <?php if ( have_rows( 'kartochki_bloka_home' ) ) : ?>
          <?php while ( have_rows( 'kartochki_bloka_home' ) ) : the_row(); ?>
            <div class="choose-v2ray">
              <div class="why-icon">
                <?php the_sub_field( 'kod_ikonki_svg' ); ?>
              </div>
              <h3><?php the_sub_field( 'zagolovok_card_home' ); ?></h3>
              <p>
                <?php the_sub_field( 'tekst_card_home' ); ?>
              </p>
            </div>
            <?php endwhile; ?>
              <?php else : ?>
                <?php // No rows found ?>
                  <?php endif; ?>
      </div>
    </div>
  </section>

  <!-- Servers Section -->
  <section class="servers" id="servers">
    <div class="container">
      <div class="section-header">
        <h2 class="h2-v2ray-vpn" style="margin-bottom: 24px;">Серверы по всему миру</h2>
        <p>Высокоскоростные серверы для
          <?php the_field('brand1', 'option'); ?> в ключевых локациях для оптимального соединения</p>
      </div>

      <div class="servers-grid">
        <div class="server-card">
          <div class="server-header">
            <div class="server-flag">🇺🇸</div>
            <div class="server-info">
              <h3>США</h3>
              <p>Нью-Йорк, Лос-Анджелес</p>
            </div>
          </div>
          <div class="server-stats">
            <div class="server-stat">
              <span class="server-stat-value">15ms</span>
              <span class="server-stat-label">Пинг</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">25 Gbps</span>
              <span class="server-stat-label">Скорость</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">99.9%</span>
              <span class="server-stat-label">Аптайм</span>
            </div>
          </div>
          <div class="server-status">Онлайн</div>
        </div>

        <div class="server-card">
          <div class="server-header">
            <div class="server-flag">🇬🇧</div>
            <div class="server-info">
              <h3>Великобритания</h3>
              <p>Лондон, Манчестер</p>
            </div>
          </div>
          <div class="server-stats">
            <div class="server-stat">
              <span class="server-stat-value">12ms</span>
              <span class="server-stat-label">Пинг</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">25 Gbps</span>
              <span class="server-stat-label">Скорость</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">99.8%</span>
              <span class="server-stat-label">Аптайм</span>
            </div>
          </div>
          <div class="server-status">Онлайн</div>
        </div>

        <div class="server-card">
          <div class="server-header">
            <div class="server-flag">🇩🇪</div>
            <div class="server-info">
              <h3>Германия</h3>
              <p>Франкфурт, Берлин</p>
            </div>
          </div>
          <div class="server-stats">
            <div class="server-stat">
              <span class="server-stat-value">8ms</span>
              <span class="server-stat-label">Пинг</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">25 Gbps</span>
              <span class="server-stat-label">Скорость</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">99.9%</span>
              <span class="server-stat-label">Аптайм</span>
            </div>
          </div>
          <div class="server-status">Онлайн</div>
        </div>

        <div class="server-card">
          <div class="server-header">
            <div class="server-flag">🇷🇺</div>
            <div class="server-info">
              <h3>Россия</h3>
              <p>Москва, Санкт-Петербург</p>
            </div>
          </div>
          <div class="server-stats">
            <div class="server-stat">
              <span class="server-stat-value">25ms</span>
              <span class="server-stat-label">Пинг</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">25 Gbps</span>
              <span class="server-stat-label">Скорость</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">99.7%</span>
              <span class="server-stat-label">Аптайм</span>
            </div>
          </div>
          <div class="server-status">Онлайн</div>
        </div>

        <div class="server-card">
          <div class="server-header">
            <div class="server-flag">🇸🇬</div>
            <div class="server-info">
              <h3>Сингапур</h3>
              <p>Сингапур</p>
            </div>
          </div>
          <div class="server-stats">
            <div class="server-stat">
              <span class="server-stat-value">18ms</span>
              <span class="server-stat-label">Пинг</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">25 Gbps</span>
              <span class="server-stat-label">Скорость</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">99.9%</span>
              <span class="server-stat-label">Аптайм</span>
            </div>
          </div>
          <div class="server-status">Онлайн</div>
        </div>

        <div class="server-card">
          <div class="server-header">
            <div class="server-flag">🇨🇦</div>
            <div class="server-info">
              <h3>Канада</h3>
              <p>Торонто, Ванкувер</p>
            </div>
          </div>
          <div class="server-stats">
            <div class="server-stat">
              <span class="server-stat-value">20ms</span>
              <span class="server-stat-label">Пинг</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">25 Gbps</span>
              <span class="server-stat-label">Скорость</span>
            </div>
            <div class="server-stat">
              <span class="server-stat-value">99.8%</span>
              <span class="server-stat-label">Аптайм</span>
            </div>
          </div>
          <div class="server-status">Онлайн</div>
        </div>
      </div>
    </div>
  </section>

  <section class="faq">
    <div class="container">
      <div class="faq-block">
        <h2 class="h2-v2ray-vpn">Частые вопросы</h2>
        <?php if ( have_rows( 'faq-main-page' ) ) : ?>
          <div class="faq-main">
            <?php while ( have_rows( 'faq-main-page' ) ) : the_row(); ?>
              <details class="details" name="faq">
                <summary class="details__title">
                  <?php the_sub_field( 'question-faq' ); ?>
                </summary>
                <div class="details__content">
                  <p>
                    <?php the_sub_field( 'answer-faq' ); ?>
                  </p>
                </div>
              </details>
              <?php endwhile; ?>
                <?php else : ?>
                  <?php // No rows found ?>
          </div>
          <?php endif; ?>
      </div>
    </div>
  </section>

  <section class="now">
    <div class="container">

      <h2 class="h2-v2ray-vpn-test">Протестируйте <?php the_field('brand1', 'option'); ?> в течение 7 дней</h2>
      <p class="info-test">Присоединяйтесь к миллионам пользователей, которые уже защищают свой интернет</p>

      <a href="#" class="nav-trigger button-getkey-vpn">Получить ключ</a>

    </div>
  </section>

  <script>
    document.addEventListener('DOMContentLoaded', function() {
      let blocks = document.querySelectorAll('.choose-v2ray');

      function checkBlocksVisibility() {
        let windowHeight = window.innerHeight;
        blocks.forEach(block => {
          let blockPosition = block.getBoundingClientRect().top;
          if (blockPosition < windowHeight - 100) {
            block.style.opacity = "1";
            block.style.transform = "translateY(0)";
          } else {
            block.style.opacity = "0";
            block.style.transform = "translateY(50px)";
          }
        });
      }
      checkBlocksVisibility();
      window.addEventListener('scroll', checkBlocksVisibility);
    });
  </script>

  <?php get_footer(); ?>