<?php
/**
 * FansPaysite Block Editor integration.
 *
 * Pattern category, block patterns, block styles, and editor assets.
 *
 * @package FansPaysite
 * @since   2.2
 */

/**
 * Register the FansPaysite pattern category.
 */
function fanspaysite_register_pattern_categories() {
	register_block_pattern_category( 'fanspaysite', array(
		'label' => __( 'FansPaysite', 'fanspaysite' ),
	) );
}
add_action( 'init', 'fanspaysite_register_pattern_categories' );

/**
 * Register block patterns.
 */
function fanspaysite_register_block_patterns() {
	if ( ! function_exists( 'register_block_pattern' ) ) {
		return;
	}

	// Light/Dark Mode Text Block (existing)
	register_block_pattern( 'fanspaysite/mode-text-block', array(
		'title'       => __( 'Light/Dark Mode Text Block', 'fanspaysite' ),
		'description' => __( 'A text block that adapts to the theme mode.', 'fanspaysite' ),
		'categories'  => array( 'fanspaysite' ),
		'content'     => "<!-- wp:group {\"className\":\"mode-text-block\"} -->\n<div class=\"wp-block-group mode-text-block\"><!-- wp:paragraph -->\n<p>" . esc_html__( 'This text block automatically adjusts its colors based on the theme\'s light or dark mode.', 'fanspaysite' ) . "</p><!-- /wp:paragraph --></div><!-- /wp:group -->",
	) );

	// FAQ Section
	register_block_pattern( 'fanspaysite/faq-section', array(
		'title'       => __( 'FAQ Section', 'fanspaysite' ),
		'description' => __( 'Frequently asked questions with expandable answers.', 'fanspaysite' ),
		'categories'  => array( 'fanspaysite' ),
		'content'     => '<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group">
<!-- wp:heading {"level":2} -->
<h2>' . esc_html__( 'Frequently Asked Questions', 'fanspaysite' ) . '</h2>
<!-- /wp:heading -->

<!-- wp:details -->
<details class="wp-block-details"><summary>' . esc_html__( 'What is this platform about?', 'fanspaysite' ) . '</summary><!-- wp:paragraph -->
<p>' . esc_html__( 'Our platform helps digital content creators monetize their work and connect with fans directly.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph --></details>
<!-- /wp:details -->

<!-- wp:details -->
<details class="wp-block-details"><summary>' . esc_html__( 'How do I get started as a creator?', 'fanspaysite' ) . '</summary><!-- wp:paragraph -->
<p>' . esc_html__( 'Sign up for an account, set up your profile, and start publishing content. Your fans can subscribe to access your exclusive posts.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph --></details>
<!-- /wp:details -->

<!-- wp:details -->
<details class="wp-block-details"><summary>' . esc_html__( 'What payment methods are supported?', 'fanspaysite' ) . '</summary><!-- wp:paragraph -->
<p>' . esc_html__( 'We support various payment methods. Check your payment settings for the full list of available options.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph --></details>
<!-- /wp:details -->

<!-- wp:details -->
<details class="wp-block-details"><summary>' . esc_html__( 'How do subscriptions work?', 'fanspaysite' ) . '</summary><!-- wp:paragraph -->
<p>' . esc_html__( 'Fans can subscribe to creator profiles on a recurring basis. Creators set their own subscription pricing.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph --></details>
<!-- /wp:details -->
</div>
<!-- /wp:group -->',
	) );

	// Testimonials Section
	register_block_pattern( 'fanspaysite/testimonials-section', array(
		'title'       => __( 'Testimonials', 'fanspaysite' ),
		'description' => __( 'A two-column testimonial quotes section.', 'fanspaysite' ),
		'categories'  => array( 'fanspaysite' ),
		'content'     => '<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group">
<!-- wp:heading {"level":2} -->
<h2>' . esc_html__( 'What Our Creators Say', 'fanspaysite' ) . '</h2>
<!-- /wp:heading -->

<!-- wp:columns -->
<div class="wp-block-columns">
<!-- wp:column -->
<div class="wp-block-column">
<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>' . esc_html__( 'This platform transformed how I connect with my audience. The tools are intuitive and the monetization options are fantastic!', 'fanspaysite' ) . '</p><cite>' . esc_html__( 'Alex, Content Creator', 'fanspaysite' ) . '</cite></blockquote>
<!-- /wp:quote -->
</div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column">
<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>' . esc_html__( 'Easy to set up and my fans love the exclusive content experience. Highly recommend for any digital creator.', 'fanspaysite' ) . '</p><cite>' . esc_html__( 'Jordan, Digital Artist', 'fanspaysite' ) . '</cite></blockquote>
<!-- /wp:quote -->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
</div>
<!-- /wp:group -->',
	) );

	// Creator Landing Page
	register_block_pattern( 'fanspaysite/creator-landing', array(
		'title'       => __( 'Creator Landing Page', 'fanspaysite' ),
		'description' => __( 'A complete landing page for content creators with hero, features, testimonials, and call to action.', 'fanspaysite' ),
		'categories'  => array( 'fanspaysite' ),
		'blockTypes'  => array( 'core/post-content' ),
		'content'     => '<!-- wp:cover {"dimRatio":60,"minHeight":400,"isDark":true,"style":{"color":{"background":"#77145d"}}} -->
<div class="wp-block-cover is-dark" style="min-height:400px"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-60 has-background-dim" style="background-color:#77145d"></span><div class="wp-block-cover__inner-container">
<!-- wp:heading {"textAlign":"center","level":1,"style":{"color":{"text":"#ffffff"}}} -->
<h1 class="wp-block-heading has-text-align-center has-text-color" style="color:#ffffff">' . esc_html__( 'Welcome to Your Creator Platform', 'fanspaysite' ) . '</h1>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"center","style":{"color":{"text":"#ffffff"}}} -->
<p class="has-text-align-center has-text-color" style="color:#ffffff">' . esc_html__( 'Share exclusive content, connect with fans, and grow your community.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph -->

<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
<div class="wp-block-buttons">
<!-- wp:button {"style":{"color":{"background":"#ffffff","text":"#77145d"}}} -->
<div class="wp-block-button"><a class="wp-block-button__link has-text-color has-background wp-element-button" style="color:#77145d;background-color:#ffffff">' . esc_html__( 'Get Started', 'fanspaysite' ) . '</a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
</div></div>
<!-- /wp:cover -->

<!-- wp:spacer {"height":"40px"} -->
<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:heading {"textAlign":"center","level":2} -->
<h2 class="wp-block-heading has-text-align-center">' . esc_html__( 'Why Creators Choose Us', 'fanspaysite' ) . '</h2>
<!-- /wp:heading -->

<!-- wp:columns -->
<div class="wp-block-columns">
<!-- wp:column -->
<div class="wp-block-column">
<!-- wp:heading {"level":3,"textAlign":"center"} -->
<h3 class="wp-block-heading has-text-align-center">' . esc_html__( 'Monetize Your Content', 'fanspaysite' ) . '</h3>
<!-- /wp:heading -->
<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center">' . esc_html__( 'Set your own prices for subscriptions, pay-per-view content, and tips from your audience.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column">
<!-- wp:heading {"level":3,"textAlign":"center"} -->
<h3 class="wp-block-heading has-text-align-center">' . esc_html__( 'Engage Your Fans', 'fanspaysite' ) . '</h3>
<!-- /wp:heading -->
<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center">' . esc_html__( 'Live streaming, messaging, and interactive features keep your community engaged.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column">
<!-- wp:heading {"level":3,"textAlign":"center"} -->
<h3 class="wp-block-heading has-text-align-center">' . esc_html__( 'Own Your Platform', 'fanspaysite' ) . '</h3>
<!-- /wp:heading -->
<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center">' . esc_html__( 'Self-hosted on WordPress means you control your data, branding, and business rules.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->

<!-- wp:spacer {"height":"40px"} -->
<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:separator -->
<hr class="wp-block-separator has-alpha-channel-opacity"/>
<!-- /wp:separator -->

<!-- wp:spacer {"height":"20px"} -->
<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:heading {"textAlign":"center","level":2} -->
<h2 class="wp-block-heading has-text-align-center">' . esc_html__( 'Ready to Start?', 'fanspaysite' ) . '</h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"center"} -->
<p class="has-text-align-center">' . esc_html__( 'Join thousands of creators who are building their independent platforms.', 'fanspaysite' ) . '</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">' . esc_html__( 'Create Your Account', 'fanspaysite' ) . '</a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->',
	) );

	// Blog Home / Directory Page
	register_block_pattern( 'fanspaysite/blog-home', array(
		'title'       => __( 'Blog Home / Directory', 'fanspaysite' ),
		'description' => __( 'A homepage layout with welcome message and latest posts.', 'fanspaysite' ),
		'categories'  => array( 'fanspaysite' ),
		'blockTypes'  => array( 'core/post-content' ),
		'content'     => '<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group">
<!-- wp:heading {"level":1} -->
<h1 class="wp-block-heading">' . esc_html__( 'Discover Amazing Creators', 'fanspaysite' ) . '</h1>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>' . esc_html__( 'Browse our community of talented content creators. Subscribe to your favorites and enjoy exclusive content.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph -->

<!-- wp:separator -->
<hr class="wp-block-separator has-alpha-channel-opacity"/>
<!-- /wp:separator -->

<!-- wp:heading {"level":2} -->
<h2 class="wp-block-heading">' . esc_html__( 'Latest Posts', 'fanspaysite' ) . '</h2>
<!-- /wp:heading -->

<!-- wp:latest-posts {"postsToShow":6,"displayPostContent":true,"excerptLength":20,"displayPostDate":true,"columns":2,"displayFeaturedImage":true,"featuredImageSizeSlug":"medium"} /-->

<!-- wp:spacer {"height":"30px"} -->
<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
<div class="wp-block-buttons">
<!-- wp:button {"className":"is-style-outline"} -->
<div class="wp-block-button is-style-outline"><a class="wp-block-button__link wp-element-button">' . esc_html__( 'View All Posts', 'fanspaysite' ) . '</a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
</div>
<!-- /wp:group -->',
	) );
}
add_action( 'init', 'fanspaysite_register_block_patterns' );

/**
 * Register custom block styles.
 */
function fanspaysite_register_block_styles() {
	if ( ! function_exists( 'register_block_style' ) ) {
		return;
	}

	register_block_style( 'core/paragraph', array(
		'name'         => 'fanspaysite-custom-style',
		'label'        => __( 'Light/Dark Mode Style', 'fanspaysite' ),
		'inline_style' => '.is-style-fanspaysite-custom-style { padding: 20px; border-radius: 5px; background-color: var(--background-color); color: var(--text-color); }',
	) );
}
add_action( 'init', 'fanspaysite_register_block_styles' );

/**
 * Editor styles note: the block editor loads editor-style.css via
 * add_editor_style() in inc/enqueue.php. WordPress automatically scopes
 * those rules under .editor-styles-wrapper so they don't interfere with
 * the editor UI or pattern previews. Do NOT load the full style.css here
 * as its layout CSS (.site-wrapper, .site-sidebar, flex) would break
 * pattern previews and the editor layout.
 */
