<?php $slides = function_exists( 'kgv_classic_slider_items' ) ? kgv_classic_slider_items() : array(); if ( empty( $slides ) ) { return; } ?>
<section class="hero-slider" aria-label="Startseiten-Slideshow">
  <div class="slider-track">
    <?php foreach ( $slides as $index => $slide ) : ?>
      <article class="slide<?php echo 0 === $index ? ' is-active' : ''; ?>">
        <img src="<?php echo esc_url( $slide['image'] ); ?>" alt="<?php echo esc_attr( $slide['title'] ); ?>">
        <div class="slide-overlay">
          <div class="container slide-content">
            <h2><?php echo esc_html( $slide['title'] ); ?></h2>
            <p><?php echo esc_html( $slide['text'] ); ?></p>
            <?php if ( ! empty( $slide['button'] ) && ! empty( $slide['label'] ) ) : ?>
  <a class="button" href="<?php echo esc_url( $slide['button'] ); ?>">
    <?php echo esc_html( $slide['label'] ); ?>
  </a>
<?php endif; ?>
          </div>
        </div>
      </article>
    <?php endforeach; ?>
  </div>
  <?php if ( count( $slides ) > 1 ) : ?>
    <div class="slider-dots" aria-hidden="true">
      <?php foreach ( $slides as $index => $slide ) : ?>
        <button class="slider-dot<?php echo 0 === $index ? ' is-active' : ''; ?>" data-slide="<?php echo esc_attr( $index ); ?>"></button>
      <?php endforeach; ?>
    </div>
  <?php endif; ?>
</section>
