/**
 * Theme Name: Blocksy Child
 * Description: Blocksy Child theme
 * Author: Creative Themes
 * Template: blocksy
 * Text Domain: blocksy
 */
/* Simple, reliable responsive 4-column grid */
.sca-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
  align-items: start;
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: 830px;
}


/* Footer Column container */
.sca-col {
  min-width: 0;
}

.sca-heading {
  font-size: 1rem;
  margin: 0 0 10px 0;
  font-weight: 600;
  color: inherit;
}

.sca-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.sca-list li {
  margin: 6px 0;
}

.sca-list a {
  text-decoration: none;
  color: inherit;
}
.sca-list a:hover {
  text-decoration: underline;
}

/* Responsive breakpoints */
@media (max-width: 980px) {
  .sca-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .sca-grid {
    grid-template-columns: 1fr;
  }
  .sca-heading {
    margin-top: 8px;
  }
}

.ct-footer {
  padding-left: 25px!important;
  padding-right: 25px!important;
}

.wp-block-button__link {
  white-space: nowrap;
}

.sca-modal {
	display: none;
}
/**
 * Casino Games Section Shortcode
 */
function casino_games_section_shortcode() {
    // Get ACF fields
    $heading = get_field('casino_section_heading') ?: 'Popular Casino Games';
    $subheading = get_field('casino_section_subheading') ?: 'Thousands of slots & table games';
    $more_text = get_field('casino_more_text') ?: '+ MUCH MORE';
    $more_link = get_field('casino_more_link') ?: '#';
    
    // Build games array
    $games = array();
    for ($i = 1; $i <= 4; $i++) {
        $image = get_field('casino_game_' . $i . '_image');
        $name = get_field('casino_game_' . $i . '_name');
        $link = get_field('casino_game_' . $i . '_link');
        
        // Only add game if it has an image and name
        if ($image && $name) {
            $games[] = array(
                'image' => $image,
                'name' => $name,
                'link' => $link
            );
        }
    }
    
    // Don't output anything if no games
    if (empty($games)) {
        return '';
    }
    
    ob_start();
    ?>
    
    <section class="casino-games-section">
        <div class="casino-games-container">
            <!-- Section Header -->
            <div class="casino-games-header">
                <h2 class="casino-games-title"><?php echo esc_html($heading); ?></h2>
                <?php if ($subheading): ?>
                    <p class="casino-games-subtitle"><?php echo esc_html($subheading); ?></p>
                <?php endif; ?>
            </div>
            
            <!-- Games Grid -->
            <div class="casino-games-grid">
                <?php foreach ($games as $game): 
                    $has_link = !empty($game['link']);
                ?>
                    <div class="casino-game-card">
                        <?php if ($has_link): ?>
                            <a href="<?php echo esc_url($game['link']); ?>" class="game-card-link">
                        <?php endif; ?>
                        
                        <div class="game-card-image">
                            <img src="<?php echo esc_url($game['image']); ?>" 
                                 alt="<?php echo esc_attr($game['name']); ?>" 
                                 loading="lazy">
                        </div>
                        <div class="game-card-overlay">
                            <h3 class="game-card-title"><?php echo esc_html($game['name']); ?></h3>
                        </div>
                        
                        <?php if ($has_link): ?>
                            </a>
                        <?php endif; ?>
                    </div>
                <?php endforeach; ?>
            </div>
            
            <!-- More Link -->
            <?php if ($more_text): ?>
                <div class="casino-games-more">
                    <a href="<?php echo esc_url($more_link); ?>" class="casino-more-link">
                        <?php echo esc_html($more_text); ?>
                    </a>
                </div>
            <?php endif; ?>
        </div>
    </section>
    
    <?php
    return ob_get_clean();
}
add_shortcode('casino_games', 'casino_games_section_shortcode');