<?php
/**
 * Block Patterns for AI Blog Theme
 *
 * @package Ai Blog
 */

/**
 * Register block patterns
 */
function ai_blog_register_block_patterns() {
    // Check if block patterns are supported
    if (function_exists('register_block_pattern')) {
        
        // Hero Section Pattern
       register_block_pattern(
    'ai-blog/hero-section',
    array(
        'title'       => __('Hero Section with CTA', 'ai-blog'),
        'description' => __('A hero section with heading, description and call-to-action buttons', 'ai-blog'),
        'content'     => '<!-- wp:group {"metadata":{"categories":["ai-blog-patterns"],"patternName":"ai-blog/hero-section","name":"Hero Section with CTA"},"style":{"color":{"background":"#2563eb"},"spacing":{"padding":{"top":"80px","bottom":"80px"}}},"layout":{"type":"default"}} -->
<div class="wp-block-group has-background" style="background-color:#2563eb;padding-top:80px;padding-bottom:80px"><!-- wp:heading {"textAlign":"center","style":{"elements":{"link":{"color":{"text":"var:preset|color|white"}}},"typography":{"fontStyle":"normal","fontWeight":"700"}},"textColor":"white","fontSize":"x-large"} -->
<h2 class="wp-block-heading has-text-align-center has-white-color has-text-color has-link-color has-x-large-font-size" style="font-style:normal;font-weight:700">' . __('Welcome To AI Blog', 'ai-blog') . '</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"align":"center","style":{"color":{"text":"#ffffff"}}} -->
<p class="has-text-align-center has-text-color" style="color:#ffffff">' . __('Discover the latest trends in artificial intelligence and technology', 'ai-blog') . '</p>
<!-- /wp:paragraph -->
<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
<div class="wp-block-buttons"><!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="#get-started">' . __('Get Started', 'ai-blog') . '</a></div>
<!-- /wp:button -->
<!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="#learn-more">' . __('Learn More', 'ai-blog') . '</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:group -->',
        'categories'  => array('ai-blog-patterns'),
        'keywords'    => array('hero', 'banner', 'header'),
        'viewportWidth' => 1200, // Optional: sets preview width
        'blockTypes'   => array('core/group'), // Optional: suggests where to use
    )
);

       

        // Featured Posts Pattern
        register_block_pattern(
            'ai-blog/featured-posts',
            array(
                'title'       => __('Featured Posts Grid', 'ai-blog'),
                'description' => __('A grid layout showing featured posts with images', 'ai-blog'),
                'content'     => '<!-- wp:heading {"textAlign":"center","level":2,"style":{"spacing":{"margin":{"bottom":"2rem"}}}} -->
<h2 class="wp-block-heading has-text-align-center" style="margin-bottom:2rem">Featured Posts</h2>
<!-- /wp:heading -->

<!-- wp:columns {"style":{"spacing":{"blockGap":{"top":"2rem","left":"2rem"}}}} -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:image {"aspectRatio":"16/9","scale":"cover","style":{"border":{"radius":"8px"}}} -->
<figure class="wp-block-image has-custom-border"><img alt="" style="border-radius:8px;aspect-ratio:16/9;object-fit:cover"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3,"style":{"spacing":{"margin":{"top":"1rem","bottom":"0.5rem"}}}} -->
<h3 class="wp-block-heading" style="margin-top:1rem;margin-bottom:0.5rem">AI in Healthcare</h3>
<!-- /wp:heading -->

<!-- wp:paragraph {"style":{"spacing":{"margin":{"top":"0.5rem","bottom":"1rem"}}}} -->
<p style="margin-top:0.5rem;margin-bottom:1rem">Exploring how artificial intelligence is revolutionizing healthcare and medical diagnostics.</p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"style":{"border":{"radius":"20px"},"spacing":{"padding":{"left":"1.5rem","right":"1.5rem","top":"0.5rem","bottom":"0.5rem"}}}} -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" style="border-radius:20px;padding-top:0.5rem;padding-right:1.5rem;padding-bottom:0.5rem;padding-left:1.5rem">Read More</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"><!-- wp:image {"aspectRatio":"16/9","scale":"cover","style":{"border":{"radius":"8px"}}} -->
<figure class="wp-block-image has-custom-border"><img alt="" style="border-radius:8px;aspect-ratio:16/9;object-fit:cover"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3,"style":{"spacing":{"margin":{"top":"1rem","bottom":"0.5rem"}}}} -->
<h3 class="wp-block-heading" style="margin-top:1rem;margin-bottom:0.5rem">Machine Learning Basics</h3>
<!-- /wp:heading -->

<!-- wp:paragraph {"style":{"spacing":{"margin":{"top":"0.5rem","bottom":"1rem"}}}} -->
<p style="margin-top:0.5rem;margin-bottom:1rem">Understanding the fundamentals of machine learning and its practical applications.</p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"style":{"border":{"radius":"20px"},"spacing":{"padding":{"left":"1.5rem","right":"1.5rem","top":"0.5rem","bottom":"0.5rem"}}}} -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" style="border-radius:20px;padding-top:0.5rem;padding-right:1.5rem;padding-bottom:0.5rem;padding-left:1.5rem">Read More</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"><!-- wp:image {"aspectRatio":"16/9","scale":"cover","style":{"border":{"radius":"8px"}}} -->
<figure class="wp-block-image has-custom-border"><img alt="" style="border-radius:8px;aspect-ratio:16/9;object-fit:cover"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3,"style":{"spacing":{"margin":{"top":"1rem","bottom":"0.5rem"}}}} -->
<h3 class="wp-block-heading" style="margin-top:1rem;margin-bottom:0.5rem">Future of AI</h3>
<!-- /wp:heading -->

<!-- wp:paragraph {"style":{"spacing":{"margin":{"top":"0.5rem","bottom":"1rem"}}}} -->
<p style="margin-top:0.5rem;margin-bottom:1rem">Predictions and insights into what the future holds for artificial intelligence technology.</p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"style":{"border":{"radius":"20px"},"spacing":{"padding":{"left":"1.5rem","right":"1.5rem","top":"0.5rem","bottom":"0.5rem"}}}} -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" style="border-radius:20px;padding-top:0.5rem;padding-right:1.5rem;padding-bottom:0.5rem;padding-left:1.5rem">Read More</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->',
                'categories'  => array('ai-blog-patterns'),
                'keywords'    => array('posts', 'grid', 'featured', 'blog'),
            )
        );

        // About Section Pattern
        register_block_pattern(
            'ai-blog/about-section',
            array(
                'title'       => __('About Section with Image', 'ai-blog'),
                'description' => __('An about section with image and text content', 'ai-blog'),
                'content'     => '<!-- wp:columns {"style":{"spacing":{"blockGap":{"top":"3rem","left":"3rem"},"margin":{"top":"3rem","bottom":"3rem"},"padding":{"top":"3rem","bottom":"3rem"}}}} -->
<div class="wp-block-columns" style="margin-top:3rem;margin-bottom:3rem;padding-top:3rem;padding-bottom:3rem"><!-- wp:column {"width":"40%"} -->
<div class="wp-block-column" style="flex-basis:40%"><!-- wp:image {"aspectRatio":"4/3","scale":"cover","style":{"border":{"radius":"12px"}}} -->
<figure class="wp-block-image has-custom-border"><img alt="" style="border-radius:12px;aspect-ratio:4/3;object-fit:cover"/></figure>
<!-- /wp:image --></div>
<!-- /wp:column -->

<!-- wp:column {"width":"60%","style":{"spacing":{"padding":{"left":"2rem"}}}} -->
<div class="wp-block-column" style="flex-basis:60%;padding-left:2rem"><!-- wp:heading {"level":2,"style":{"spacing":{"margin":{"bottom":"1.5rem"}}}} -->
<h2 class="wp-block-heading" style="margin-bottom:1.5rem">About AI Blog</h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"style":{"spacing":{"margin":{"bottom":"1.5rem"}},"typography":{"fontSize":"1.1rem","lineHeight":"1.6"}}} -->
<p style="margin-bottom:1.5rem;font-size:1.1rem;line-height:1.6">Welcome to AI Blog, your premier destination for cutting-edge insights into artificial intelligence and emerging technologies. Our mission is to make complex AI concepts accessible to everyone.</p>
<!-- /wp:paragraph -->

<!-- wp:list {"style":{"spacing":{"margin":{"bottom":"2rem"}}}} -->
<ul style="margin-bottom:2rem"><!-- wp:list-item -->
<li>Expert analysis of AI trends and developments</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Practical guides for implementing AI solutions</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Interviews with industry leaders and researchers</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Reviews of the latest AI tools and platforms</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"style":{"border":{"radius":"25px"},"spacing":{"padding":{"left":"2rem","right":"2rem","top":"0.75rem","bottom":"0.75rem"}}}} -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" style="border-radius:25px;padding-top:0.75rem;padding-right:2rem;padding-bottom:0.75rem;padding-left:2rem">Learn More About Us</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->',
                'categories'  => array('ai-blog-patterns'),
                'keywords'    => array('about', 'team', 'company', 'image'),
            )
        );

        // Newsletter Signup Pattern
        register_block_pattern(
            'ai-blog/newsletter-signup',
            array(
                'title'       => __('Newsletter Signup Section', 'ai-blog'),
                'description' => __('A newsletter signup section', 'ai-blog'),
                'content'     => '<!-- wp:group {"style":{"color":{"background":"#f3f4f6"},"spacing":{"padding":{"top":"60px","bottom":"60px"}}},"layout":{"type":"default"}} -->
<div class="wp-block-group has-background" style="background-color:#f3f4f6;padding-top:60px;padding-bottom:60px"><!-- wp:heading {"textAlign":"center"} -->
<h2 class="wp-block-heading has-text-align-center">' . __('Stay Updated with AI News', 'ai-blog') . '</h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center">' . __('Get the latest AI insights delivered to your inbox.', 'ai-blog') . '</p>
<!-- /wp:paragraph -->

<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:paragraph {"style":{"color":{"background":"#ffffff"},"spacing":{"padding":{"top":"15px","bottom":"15px","left":"20px","right":"20px"}}}} -->
<p class="has-background" style="background-color:#ffffff;padding-top:15px;padding-right:20px;padding-bottom:15px;padding-left:20px">' . __('Enter your email...', 'ai-blog') . '</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"><!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button">' . __('Subscribe', 'ai-blog') . '</a></div>
<!-- /wp:button --></div>
<!-- /wp:column --></div>
<!-- /wp:columns --></div>
<!-- /wp:group -->',
                'categories'  => array('ai-blog-patterns'),
                'keywords'    => array('newsletter', 'signup', 'email'),
            )
        );

        // Call to Action Pattern
        register_block_pattern(
            'ai-blog/call-to-action',
            array(
                'title'       => __('Call to Action Banner', 'ai-blog'),
                'description' => __('A simple call to action banner', 'ai-blog'),
                'content'     => '<!-- wp:group {"style":{"spacing":{"padding":{"top":"40px","bottom":"40px","left":"20px","right":"20px"}},"color":{"background":"#4f46e5","text":"#ffffff"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group has-text-color has-background" style="color:#ffffff;background-color:#4f46e5;padding-top:40px;padding-right:20px;padding-bottom:40px;padding-left:20px"><!-- wp:heading {"textAlign":"center","level":2} -->
<h2 class="wp-block-heading has-text-align-center">' . __('Ready to Explore AI?', 'ai-blog') . '</h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center">' . __('Join thousands of readers who trust AI Blog for the latest insights and tutorials.', 'ai-blog') . '</p>
<!-- /wp:paragraph -->

<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
<div class="wp-block-buttons"><!-- wp:button {"style":{"color":{"background":"#ffffff","text":"#4f46e5"}}} -->
<div class="wp-block-button"><a class="wp-block-button__link has-text-color has-background wp-element-button" style="color:#4f46e5;background-color:#ffffff">' . __('Start Reading', 'ai-blog') . '</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:group -->',
                'categories'  => array('ai-blog-patterns'),
                'keywords'    => array('call-to-action', 'cta', 'banner'),
            )
        );
    }
}

/**
 * Register block pattern category
 */
function ai_blog_register_pattern_category() {
    if (function_exists('register_block_pattern_category')) {
        register_block_pattern_category(
            'ai-blog-patterns',
            array(
                'label' => __('AI Blog Patterns', 'ai-blog'),
            )
        );
    }
}

// Hook into init
add_action('init', 'ai_blog_register_pattern_category');
add_action('init', 'ai_blog_register_block_patterns');
