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

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

/**
 * OW-001 -- High-specificity link text-decoration override.
 * OceanWP forces text-decoration:underline on all .entry-content links via a
 * 0,5,1 selector. This inline block at priority 99 re-asserts text-decoration:none
 * for MBS retailer buttons and tab links at the same or higher specificity.
 */
add_action( 'wp_enqueue_scripts', static function () {

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

	$css = '
		/* OW-001: neutralise text-decoration:underline forced on all .entry-content links */

		/* Retailer buy buttons — inside .mbs-wrapper, reaches 0,5,1 to match OceanWP */
		.single-post:not(.elementor-page) .entry-content .mbs-wrapper a.mbs-retailer-btn,
		.page:not(.elementor-page):not(.woocommerce-page) .entry-content .mbs-wrapper a.mbs-retailer-btn {
			text-decoration: none;
			text-underline-offset: initial;
		}

		/* Format tabs rendered as anchors */
		.single-post:not(.elementor-page) .entry-content .mbs-wrapper a.mbs-format-tab,
		.page:not(.elementor-page):not(.woocommerce-page) .entry-content .mbs-wrapper a.mbs-format-tab {
			text-decoration: none;
		}

		/* Term-list items live outside .mbs-wrapper; !important required to
		   beat OceanWP\'s 0,5,1 selector without matching its page-context chain */
		a.mbs-term-list__item,
		a.mbs-term-list__item:hover,
		a.mbs-term-list__item:focus {
			text-decoration: none !important;
		}
	';

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

}, 99 );

/**
 * OW-002 note -- Font Awesome deregister (no current MBS conflict).
 * OceanWP unconditionally deregisters 'font-awesome' and 'fontawesome' handles.
 * MBS does not use either handle; if it ever enqueues FA, use 'mbs-font-awesome'.
 * Full analysis in PATCHES/COMPAT-WORKLOG.md -- OW-002.
 */
