<?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 Content Block
	register_block_pattern( 'fanspaysite/mode-text-block', array(
		'title'       => __( 'Light/Dark Mode Content Block', 'fanspaysite' ),
		'description' => __( 'A content block that adapts background, text, and link colors to the active light or dark theme mode via CSS variables.', 'fanspaysite' ),
		'categories'  => array( 'fanspaysite' ),
		'content'     => '<!-- wp:group {"className":"ui segment fps-mode-block","style":{"color":{"background":"var(--background-color)","text":"var(--text-color)"},"spacing":{"padding":{"top":"1.5rem","right":"1.5rem","bottom":"1.5rem","left":"1.5rem"}}}} -->
<div class="wp-block-group ui segment fps-mode-block" style="background-color:var(--background-color);color:var(--text-color)">

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">' . esc_html__( 'Mode-Aware Content', 'fanspaysite' ) . '</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>' . esc_html__( 'This block automatically adjusts its background, text, and link colors based on the active light or dark theme mode. Use it to ensure content always looks correct regardless of the visitor\'s preferred mode.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons">
<!-- wp:button {"style":{"color":{"background":"var(--link-color)","text":"#ffffff"}}} -->
<div class="wp-block-button"><a class="wp-block-button__link has-text-color has-background wp-element-button" style="color:#ffffff;background-color:var(--link-color)">' . esc_html__( 'Learn More', 'fanspaysite' ) . '</a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->

</div>
<!-- /wp:group -->',
	) );

	// FAQ Section
	register_block_pattern( 'fanspaysite/faq-section', array(
		'title'       => __( 'FAQ Section', 'fanspaysite' ),
		'description' => __( 'Frequently asked questions with expandable answers, styled as a Fomantic UI segment.', 'fanspaysite' ),
		'categories'  => array( 'fanspaysite' ),
		'content'     => '<!-- wp:group {"className":"ui segment fps-faq-section","layout":{"type":"constrained"}} -->
<div class="wp-block-group ui segment fps-faq-section">

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

<!-- wp:separator {"className":"ui divider"} -->
<hr class="wp-block-separator has-alpha-channel-opacity ui divider"/>
<!-- /wp:separator -->

<!-- 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 -->

<!-- wp:details -->
<details class="wp-block-details"><summary>' . esc_html__( 'Can I use multiple monetization options?', 'fanspaysite' ) . '</summary><!-- wp:paragraph -->
<p>' . esc_html__( 'Yes. You can combine subscriptions, pay-per-view content, tips, and premium downloads to maximize your revenue.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph --></details>
<!-- /wp:details -->

</div>
<!-- /wp:group -->',
	) );

	// Testimonials Section
	register_block_pattern( 'fanspaysite/testimonials-section', array(
		'title'       => __( 'Testimonials', 'fanspaysite' ),
		'description' => __( 'A three-column testimonial quotes section using Fomantic UI cards, adapts to light/dark mode.', 'fanspaysite' ),
		'categories'  => array( 'fanspaysite' ),
		'content'     => '<!-- wp:group {"className":"fps-testimonials","layout":{"type":"constrained"}} -->
<div class="wp-block-group fps-testimonials">

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

<!-- wp:columns {"className":"ui three stackable cards"} -->
<div class="wp-block-columns ui three stackable cards">

<!-- wp:column {"className":"ui card"} -->
<div class="wp-block-column ui card">
<!-- wp:group {"className":"content"} -->
<div class="wp-block-group content">
<!-- wp:paragraph {"className":"description"} -->
<p class="description">&ldquo;' . esc_html__( 'This platform transformed how I connect with my audience. The tools are intuitive and the monetization options are fantastic!', 'fanspaysite' ) . '&rdquo;</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
<!-- wp:group {"className":"extra content"} -->
<div class="wp-block-group extra content">
<!-- wp:paragraph -->
<p><strong>' . esc_html__( 'Alex', 'fanspaysite' ) . '</strong> &mdash; ' . esc_html__( 'Content Creator', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:column -->

<!-- wp:column {"className":"ui card"} -->
<div class="wp-block-column ui card">
<!-- wp:group {"className":"content"} -->
<div class="wp-block-group content">
<!-- wp:paragraph {"className":"description"} -->
<p class="description">&ldquo;' . esc_html__( 'Easy to set up and my fans love the exclusive content experience. Highly recommend for any digital creator.', 'fanspaysite' ) . '&rdquo;</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
<!-- wp:group {"className":"extra content"} -->
<div class="wp-block-group extra content">
<!-- wp:paragraph -->
<p><strong>' . esc_html__( 'Jordan', 'fanspaysite' ) . '</strong> &mdash; ' . esc_html__( 'Digital Artist', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:column -->

<!-- wp:column {"className":"ui card"} -->
<div class="wp-block-column ui card">
<!-- wp:group {"className":"content"} -->
<div class="wp-block-group content">
<!-- wp:paragraph {"className":"description"} -->
<p class="description">&ldquo;' . esc_html__( 'The best investment I made for my creative career. My subscribers get a seamless premium experience every time.', 'fanspaysite' ) . '&rdquo;</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
<!-- wp:group {"className":"extra content"} -->
<div class="wp-block-group extra content">
<!-- wp:paragraph -->
<p><strong>' . esc_html__( 'Sam', 'fanspaysite' ) . '</strong> &mdash; ' . esc_html__( 'Musician', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
</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, feature cards, testimonials, and call to action. Uses theme accent color and adapts to light/dark mode.', 'fanspaysite' ),
		'categories'  => array( 'fanspaysite' ),
		'blockTypes'  => array( 'core/post-content' ),
		'content'     => '<!-- wp:cover {"dimRatio":60,"minHeight":420,"isDark":true,"style":{"color":{"background":"var(--link-color)"}}} -->
<div class="wp-block-cover is-dark" style="min-height:420px"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-60 has-background-dim" style="background-color:var(--link-color)"></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 {"className":"ui large button","style":{"color":{"background":"#ffffff","text":"var(--link-color)"}}} -->
<div class="wp-block-button ui large button"><a class="wp-block-button__link has-text-color has-background wp-element-button" style="color:var(--link-color);background-color:#ffffff">' . esc_html__( 'Get Started', 'fanspaysite' ) . '</a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->

</div></div>
<!-- /wp:cover -->

<!-- wp:spacer {"height":"48px"} -->
<div style="height:48px" 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:spacer {"height":"24px"} -->
<div style="height:24px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:columns {"className":"ui three stackable cards"} -->
<div class="wp-block-columns ui three stackable cards">

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

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

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

</div>
<!-- /wp:columns -->

<!-- wp:spacer {"height":"48px"} -->
<div style="height:48px" 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":"24px"} -->
<div style="height:24px" 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 {"style":{"color":{"background":"var(--link-color)","text":"#ffffff"}}} -->
<div class="wp-block-button"><a class="wp-block-button__link has-text-color has-background wp-element-button" style="color:#ffffff;background-color:var(--link-color)">' . esc_html__( 'Create Your Account', 'fanspaysite' ) . '</a></div>
<!-- /wp:button -->
<!-- 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__( 'Learn More', '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 displayed as grid cards.', '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:query {"queryId":1,"query":{"perPage":6,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false},"className":"fps-posts-query"} -->
<div class="wp-block-query fps-posts-query">

<!-- wp:post-template {"layout":{"type":"grid","columnCount":3},"className":"fps-boxes-grid"} -->

<!-- wp:group {"className":"fps-box-card ui fluid card","layout":{"type":"constrained"}} -->
<div class="wp-block-group fps-box-card ui fluid card">

<!-- wp:post-featured-image {"isLink":true,"aspectRatio":"16/9","className":"fps-box-media image"} /-->

<!-- wp:group {"className":"fps-box-body content"} -->
<div class="wp-block-group fps-box-body content">

<!-- wp:post-title {"isLink":true,"level":3,"className":"fps-box-title header"} /-->

<!-- wp:post-excerpt {"moreText":"","excerptLength":15,"className":"fps-box-excerpt description"} /-->

</div>
<!-- /wp:group -->

<!-- wp:group {"className":"fps-card-meta extra content"} -->
<div class="wp-block-group fps-card-meta extra content">

<!-- wp:post-author {"showAvatar":true,"avatarSize":24,"showBio":false,"className":"fps-box-author"} /-->

<!-- wp:post-date {"className":"fps-box-date"} /-->

</div>
<!-- /wp:group -->

</div>
<!-- /wp:group -->

<!-- /wp:post-template -->

<!-- wp:query-no-results -->
<!-- wp:paragraph -->
<p>' . esc_html__( 'No posts found.', 'fanspaysite' ) . '</p>
<!-- /wp:paragraph -->
<!-- /wp:query-no-results -->

<!-- wp:query-pagination {"className":"ui pagination menu","layout":{"type":"flex","justifyContent":"center"}} -->
<!-- wp:query-pagination-previous /-->
<!-- wp:query-pagination-numbers /-->
<!-- wp:query-pagination-next /-->
<!-- /wp:query-pagination -->

</div>
<!-- /wp:query -->

<!-- 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.
 */
