<?php
/**
 * File Path: includes/compat/compat-astra.php
 * Astra Theme Compatibility -- loaded when get_template() === 'astra'.
 * Findings reference: PATCHES/COMPAT-WORKLOG.md -- AS-001 through AS-004.
 * @package My_Book_Showroom
 * @since   1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * AS-001 -- Neutralise Astra's dynamic p margin-bottom inside .mbs-wrapper.
 * Astra injects an inline <style> on 'astra-theme-css' that may load after
 * mbs-compat.css; attaching at priority 99 guarantees our rule wins.
 */
add_action( 'wp_enqueue_scripts', static function () {

	if ( ! wp_style_is( 'mbs-front', 'enqueued' ) ) {
		return;
	}

	$css = '
		/* AS-001: neutralise Astra dynamic p margin-bottom inside .mbs-wrapper */
		.entry-content .mbs-wrapper p {
			margin: 0 0 0.75em;
		}
		.entry-content .mbs-wrapper p:last-child {
			margin-bottom: 0;
		}
	';

	wp_add_inline_style( 'mbs-front', $css );

}, 99 );
