<?php
/**
 * Golpo: Block Patterns & Styles Registry
 *
 * @package Golpo
 */

/**
 * Register Block Styles/Patterns on init.
 */
function golpo_register_block_patterns() {

    // -------------------------------------------------------------------------
    // 1. REGISTER BLOCK STYLES
    // -------------------------------------------------------------------------
    if ( function_exists( 'register_block_style' ) ) {
        
        // Button Styles
        register_block_style(
            'core/button',
            array(
                'name'  => 'golpo-outline',
                'label' => __( 'Outline Pro', 'golpo' ),
            )
        );
        register_block_style(
            'core/button',
            array(
                'name'  => 'golpo-soft-shadow',
                'label' => __( 'Soft Shadow', 'golpo' ),
            )
        );

        // Quote Styles
        register_block_style(
            'core/quote',
            array(
                'name'  => 'golpo-modern-quote',
                'label' => __( 'Modern Left Border', 'golpo' ),
            )
        );
        register_block_style(
            'core/quote',
            array(
                'name'  => 'golpo-boxed-quote',
                'label' => __( 'Boxed Card', 'golpo' ),
            )
        );

        // Heading Styles
        register_block_style(
            'core/heading',
            array(
                'name'  => 'golpo-underline',
                'label' => __( 'Underline', 'golpo' ),
            )
        );
        register_block_style(
            'core/heading',
            array(
                'name'  => 'golpo-gradient-text',
                'label' => __( 'Gradient Text', 'golpo' ),
            )
        );

        // List Styles
        register_block_style(
            'core/list',
            array(
                'name'  => 'golpo-check-list',
                'label' => __( 'Checkmark List', 'golpo' ),
            )
        );

        // Image Styles
        register_block_style(
            'core/image',
            array(
                'name'  => 'golpo-shadow-rounded',
                'label' => __( 'Rounded Shadow', 'golpo' ),
            )
        );
        
        // Table Styles
        register_block_style(
            'core/table',
            array(
                'name'  => 'golpo-striped-modern',
                'label' => __( 'Striped Modern', 'golpo' ),
            )
        );

        // Separator
        register_block_style(
            'core/separator',
            array(
                'name'  => 'golpo-thick-accent',
                'label' => __( 'Thick Accent', 'golpo' ),
            )
        );
    }

    // -------------------------------------------------------------------------
    // 2. REGISTER BLOCK PATTERNS
    // -------------------------------------------------------------------------
    if ( function_exists( 'register_block_pattern' ) ) {

        // Register Category
        register_block_pattern_category(
            'golpo-general',
            array( 'label' => __( 'Golpo Theme', 'golpo' ) )
        );

        // 1. Hero Section
        register_block_pattern(
            'golpo/hero-section',
            array(
                'title'       => __( 'Hero Section', 'golpo' ),
                'description' => _x( 'A hero section with title and button.', 'Block pattern description', 'golpo' ),
                'categories'  => array( 'golpo-general', 'header' ),
                'content'     => '<!-- wp:cover {"url":"https://s.w.org/images/core/5.8/art-01.jpg","dimRatio":50,"overlayColor":"black","align":"full"} -->
                                <div class="wp-block-cover alignfull has-black-background-color has-background-dim"><div class="wp-block-cover__inner-container"><!-- wp:heading {"textAlign":"center","level":1,"style":{"typography":{"fontSize":"64px"}},"textColor":"white"} -->
                                <h1 class="has-white-color has-text-color has-text-align-center" style="font-size:64px">Welcome to Our Stories</h1>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph {"align":"center","textColor":"white","fontSize":"large"} -->
                                <p class="has-text-align-center has-white-color has-text-color has-large-font-size">Discover the world through our lens. Simplicity meets elegance.</p>
                                <!-- /wp:paragraph -->
                                <!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
                                <div class="wp-block-buttons"><!-- wp:button {"backgroundColor":"vivid-cyan-blue","textColor":"white"} -->
                                <div class="wp-block-button"><a class="wp-block-button__link has-white-color has-vivid-cyan-blue-background-color has-text-color has-background">Get Started</a></div>
                                <!-- /wp:button --></div>
                                <!-- /wp:buttons --></div></div>
                                <!-- /wp:cover -->',
            )
        );

        // 2. Call to Action (CTA)
        register_block_pattern(
            'golpo/cta-simple',
            array(
                'title'       => __( 'Simple CTA', 'golpo' ),
                'categories'  => array( 'golpo-general', 'buttons' ),
                'content'     => '<!-- wp:group {"backgroundColor":"light-grayish-magenta","layout":{"type":"constrained"}} -->
                                <div class="wp-block-group has-light-grayish-magenta-background-color has-background"><!-- wp:heading {"textAlign":"center"} -->
                                <h2 class="has-text-align-center">Ready to dive in?</h2>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph {"align":"center"} -->
                                <p class="has-text-align-center">Join our newsletter and never miss an update.</p>
                                <!-- /wp:paragraph -->
                                <!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
                                <div class="wp-block-buttons"><!-- wp:button {"style":{"border":{"radius":"50px"}},"className":"is-style-outline"} -->
                                <div class="wp-block-button is-style-outline"><a class="wp-block-button__link" style="border-radius:50px">Subscribe Now</a></div>
                                <!-- /wp:button --></div>
                                <!-- /wp:buttons --></div>
                                <!-- /wp:group -->',
            )
        );

        // 3. Features Grid (3 Columns)
        register_block_pattern(
            'golpo/features-grid-3',
            array(
                'title'       => __( 'Features Grid (3 Cols)', 'golpo' ),
                'categories'  => array( 'golpo-general', 'columns' ),
                'content'     => '<!-- wp:columns {"align":"wide"} -->
                                <div class="wp-block-columns alignwide"><!-- wp:column -->
                                <div class="wp-block-column"><!-- wp:heading {"level":3,"fontSize":"medium"} -->
                                <h3 class="has-medium-font-size">Fast Performance</h3>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph -->
                                <p>Optimized for speed and efficiency, ensuring your readers stay engaged.</p>
                                <!-- /wp:paragraph --></div>
                                <!-- /wp:column -->
                                <!-- wp:column -->
                                <div class="wp-block-column"><!-- wp:heading {"level":3,"fontSize":"medium"} -->
                                <h3 class="has-medium-font-size">Clean Design</h3>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph -->
                                <p>Minimalist aesthetics that focus purely on your content and typography.</p>
                                <!-- /wp:paragraph --></div>
                                <!-- /wp:column -->
                                <!-- wp:column -->
                                <div class="wp-block-column"><!-- wp:heading {"level":3,"fontSize":"medium"} -->
                                <h3 class="has-medium-font-size">SEO Friendly</h3>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph -->
                                <p>Built with best practices to help your content rank higher in search results.</p>
                                <!-- /wp:paragraph --></div>
                                <!-- /wp:column --></div>
                                <!-- /wp:columns -->',
            )
        );

        // 4. Testimonial Card
        register_block_pattern(
            'golpo/testimonial-card',
            array(
                'title'       => __( 'Testimonial Card', 'golpo' ),
                'categories'  => array( 'golpo-general', 'text' ),
                'content'     => '<!-- wp:group {"backgroundColor":"very-light-gray","style":{"spacing":{"padding":{"top":"2rem","right":"2rem","bottom":"2rem","left":"2rem"}}}} -->
                                <div class="wp-block-group has-very-light-gray-background-color has-background" style="padding-top:2rem;padding-right:2rem;padding-bottom:2rem;padding-left:2rem"><!-- wp:quote {"className":"is-style-large"} -->
                                <blockquote class="wp-block-quote is-style-large"><p>"Golpo has transformed the way I write. The clear typography and lack of distractions make it a joy to use."</p><cite>— Jane Doe, Blogger</cite></blockquote>
                                <!-- /wp:quote --></div>
                                <!-- /wp:group -->',
            )
        );

        // 5. Team Member
        register_block_pattern(
            'golpo/team-member',
            array(
                'title'       => __( 'Team Member Profile', 'golpo' ),
                'categories'  => array( 'golpo-general', 'columns' ),
                'content'     => '<!-- wp:media-text {"mediaPosition":"right","mediaType":"image"} -->
                                <div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile"><figure class="wp-block-media-text__media"><img src="https://s.w.org/images/core/5.8/art-02.jpg" alt=""/></figure><div class="wp-block-media-text__content"><!-- wp:heading -->
                                <h2>John Smith</h2>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph {"fontSize":"small"} -->
                                <p class="has-small-font-size">LEAD DEVELOPER</p>
                                <!-- /wp:paragraph -->
                                <!-- wp:paragraph -->
                                <p>John loves coding and coffee. He ensures the theme engine runs smoothly.</p>
                                <!-- /wp:paragraph -->
                                <!-- wp:social-links {"iconColor":"dark-gray","iconColorValue":"#444","className":"is-style-default"} -->
                                <ul class="wp-block-social-links is-style-default has-icon-color"><!-- wp:social-link {"url":"#","service":"twitter"} /-->
                                <!-- wp:social-link {"url":"#","service":"linkedin"} /--></ul>
                                <!-- /wp:social-links --></div></div>
                                <!-- /wp:media-text -->',
            )
        );

        // 6. Pricing Table (3 cols)
        register_block_pattern(
            'golpo/pricing-table',
            array(
                'title'       => __( 'Pricing Table', 'golpo' ),
                'categories'  => array( 'golpo-general', 'columns' ),
                'content'     => '<!-- wp:columns {"align":"wide"} -->
                                <div class="wp-block-columns alignwide"><!-- wp:column {"style":{"border":{"width":"1px"}},"borderColor":"very-light-gray"} -->
                                <div class="wp-block-column has-border-color has-very-light-gray-border-color" style="border-width:1px"><!-- wp:heading {"textAlign":"center","level":3} -->
                                <h3 class="has-text-align-center">Basic</h3>
                                <!-- /wp:heading -->
                                <!-- wp:heading {"textAlign":"center","level":4,"style":{"typography":{"fontSize":"40px"}}} -->
                                <h4 class="has-text-align-center" style="font-size:40px">$19</h4>
                                <!-- /wp:heading -->
                                <!-- wp:list -->
                                <ul><li>5 Projects</li><li>Basic Support</li></ul>
                                <!-- /wp:list -->
                                <!-- wp:button {"width":100,"className":"is-style-outline"} -->
                                <div class="wp-block-button has-custom-width wp-block-button__width-100 is-style-outline"><a class="wp-block-button__link">Select</a></div>
                                <!-- /wp:button --></div>
                                <!-- /wp:column -->
                                <!-- wp:column {"backgroundColor":"very-light-gray"} -->
                                <div class="wp-block-column has-very-light-gray-background-color has-background"><!-- wp:heading {"textAlign":"center","level":3} -->
                                <h3 class="has-text-align-center">Pro</h3>
                                <!-- /wp:heading -->
                                <!-- wp:heading {"textAlign":"center","level":4,"style":{"typography":{"fontSize":"40px"}}} -->
                                <h4 class="has-text-align-center" style="font-size:40px">$49</h4>
                                <!-- /wp:heading -->
                                <!-- wp:list -->
                                <ul><li>Unlimited Projects</li><li>Priority Support</li></ul>
                                <!-- /wp:list -->
                                <!-- wp:button {"width":100,"backgroundColor":"primary"} -->
                                <div class="wp-block-button has-custom-width wp-block-button__width-100"><a class="wp-block-button__link has-primary-background-color has-background">Select</a></div>
                                <!-- /wp:button --></div>
                                <!-- /wp:column -->
                                <!-- wp:column {"style":{"border":{"width":"1px"}},"borderColor":"very-light-gray"} -->
                                <div class="wp-block-column has-border-color has-very-light-gray-border-color" style="border-width:1px"><!-- wp:heading {"textAlign":"center","level":3} -->
                                <h3 class="has-text-align-center">Enterprise</h3>
                                <!-- /wp:heading -->
                                <!-- wp:heading {"textAlign":"center","level":4,"style":{"typography":{"fontSize":"40px"}}} -->
                                <h4 class="has-text-align-center" style="font-size:40px">$99</h4>
                                <!-- /wp:heading -->
                                <!-- wp:list -->
                                <ul><li>Custom Solutions</li><li>24/7 Support</li></ul>
                                <!-- /wp:list -->
                                <!-- wp:button {"width":100,"className":"is-style-outline"} -->
                                <div class="wp-block-button has-custom-width wp-block-button__width-100 is-style-outline"><a class="wp-block-button__link">Select</a></div>
                                <!-- /wp:button --></div>
                                <!-- /wp:column --></div>
                                <!-- /wp:columns -->',
            )
        );

        // 7. Contact Section
        register_block_pattern(
            'golpo/contact-split',
            array(
                'title'       => __( 'Contact Split Section', 'golpo' ),
                'categories'  => array( 'golpo-general', 'columns' ),
                'content'     => '<!-- wp:columns {"align":"wide"} -->
                                <div class="wp-block-columns alignwide"><!-- wp:column {"width":"40%"} -->
                                <div class="wp-block-column" style="flex-basis:40%"><!-- wp:heading -->
                                <h2>Get in touch</h2>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph -->
                                <p>We are here to help you. Send us a message and we will respond within 24 hours.</p>
                                <!-- /wp:paragraph -->
                                <!-- wp:paragraph -->
                                <p><strong>Email:</strong> info@golpotheme.com<br><strong>Phone:</strong> +1 234 567 890</p>
                                <!-- /wp:paragraph --></div>
                                <!-- /wp:column -->
                                <!-- wp:column {"width":"60%"} -->
                                <div class="wp-block-column" style="flex-basis:60%"><!-- wp:shortcode -->
                                [contact-form-7 id="1234" title="Contact form 1"]
                                <!-- /wp:shortcode -->
                                <!-- wp:paragraph {"fontSize":"small","style":{"color":{"text":"#999999"}}} -->
                                <p class="has-text-color has-small-font-size" style="color:#999999">Note: Install Contact Form 7 plugin to use this area.</p>
                                <!-- /wp:paragraph --></div>
                                <!-- /wp:column --></div>
                                <!-- /wp:columns -->',
            )
        );

        // 8. Newsletter Signup
        register_block_pattern(
            'golpo/newsletter-wide',
            array(
                'title'       => __( 'Newsletter Wide', 'golpo' ),
                'categories'  => array( 'golpo-general', 'buttons' ),
                'content'     => '<!-- wp:cover {"overlayColor":"strong-magenta","minHeight":250,"align":"full"} -->
                                <div class="wp-block-cover alignfull has-strong-magenta-background-color has-background-dim" style="min-height:250px"><div class="wp-block-cover__inner-container"><!-- wp:heading {"textAlign":"center","textColor":"white"} -->
                                <h2 class="has-text-align-center has-white-color has-text-color">Subscribe to the Newsletter</h2>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph {"align":"center","textColor":"white"} -->
                                <p class="has-text-align-center has-white-color has-text-color">Get the latest stories delivered to your inbox.</p>
                                <!-- /wp:paragraph -->
                                <!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
                                <div class="wp-block-buttons"><!-- wp:button {"backgroundColor":"white","textColor":"strong-magenta"} -->
                                <div class="wp-block-button"><a class="wp-block-button__link has-strong-magenta-color has-white-background-color has-text-color has-background">Sign Up</a></div>
                                <!-- /wp:button --></div>
                                <!-- /wp:buttons --></div></div>
                                <!-- /wp:cover -->',
            )
        );

        // 9. Two Image Columns
        register_block_pattern(
            'golpo/two-images',
            array(
                'title'       => __( 'Two Columns with Images', 'golpo' ),
                'categories'  => array( 'golpo-general', 'gallery' ),
                'content'     => '<!-- wp:columns -->
                                <div class="wp-block-columns"><!-- wp:column -->
                                <div class="wp-block-column"><!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->
                                <figure class="wp-block-image size-large"><img src="https://s.w.org/images/core/5.8/art-03.jpg" alt=""/></figure>
                                <!-- /wp:image -->
                                <!-- wp:heading {"level":3} -->
                                <h3>Nature</h3>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph -->
                                <p>Exploring the outdoors.</p>
                                <!-- /wp:paragraph --></div>
                                <!-- /wp:column -->
                                <!-- wp:column -->
                                <div class="wp-block-column"><!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->
                                <figure class="wp-block-image size-large"><img src="https://s.w.org/images/core/5.8/art-04.jpg" alt=""/></figure>
                                <!-- /wp:image -->
                                <!-- wp:heading {"level":3} -->
                                <h3>Architecture</h3>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph -->
                                <p>Building the future.</p>
                                <!-- /wp:paragraph --></div>
                                <!-- /wp:column --></div>
                                <!-- /wp:columns -->',
            )
        );

        // 10. FAQ / Accordion (Using Details Block if available in core, purely headings/paragraphs fallback for wide compat)
        register_block_pattern(
            'golpo/faq-simple',
            array(
                'title'       => __( 'FAQ Simple', 'golpo' ),
                'categories'  => array( 'golpo-general', 'text' ),
                'content'     => '<!-- wp:group {"backgroundColor":"very-light-gray","layout":{"type":"constrained"}} -->
                                <div class="wp-block-group has-very-light-gray-background-color has-background"><!-- wp:heading {"textAlign":"center"} -->
                                <h2 class="has-text-align-center">Frequently Asked Questions</h2>
                                <!-- /wp:heading -->
                                <!-- wp:separator {"className":"is-style-wide"} -->
                                <hr class="wp-block-separator is-style-wide"/>
                                <!-- /wp:separator -->
                                <!-- wp:heading {"level":4} -->
                                <h4>How do I customize the theme?</h4>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph -->
                                <p>Go to Appearance > Customize to access all theme options including colors, layout, and typography.</p>
                                <!-- /wp:paragraph -->
                                <!-- wp:heading {"level":4} -->
                                <h4>Is it SEO friendly?</h4>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph -->
                                <p>Yes, Golpo is built with semantic HTML5 and schema markup to ensure great SEO performance.</p>
                                <!-- /wp:paragraph -->
                                <!-- wp:heading {"level":4} -->
                                <h4>Can I use it for a portfolio?</h4>
                                <!-- /wp:heading -->
                                <!-- wp:paragraph -->
                                <p>Absolutely! The gallery features and clean layout make it perfect for showcasing work.</p>
                                <!-- /wp:paragraph --></div>
                                <!-- /wp:group -->',
            )
        );

    }
}
add_action( 'init', 'golpo_register_block_patterns' );
