HEX
Server: nginx/1.24.0
System: Linux 0c1023d6c65e 6.8.0-137-generic #137-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 17 20:28:23 UTC 2026 x86_64
User: root (0)
PHP: 8.3.33
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/ethnic-news-archive-enhancer.php
<?php
/**
 * Plugin Name: Ethnic News Archive Enhancer
 * Description: Refines the news archive with filter chips and cleaner blog cards.
 * Version: 1.0.0
 */

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

if ( ! function_exists( 'ethnic_news_archive_enhancer_is_news_page' ) ) {
	function ethnic_news_archive_enhancer_is_news_page() {
		return ! is_admin() && ( is_page( 575 ) || is_page( 'news' ) );
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_is_archive_page' ) ) {
	function ethnic_news_archive_enhancer_is_archive_page() {
		return ! is_admin() && ( is_tag() || is_category() || is_author() );
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_is_target' ) ) {
	function ethnic_news_archive_enhancer_is_target() {
		return ethnic_news_archive_enhancer_is_news_page() || ethnic_news_archive_enhancer_is_archive_page();
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_news_page_posts_per_page' ) ) {
	function ethnic_news_archive_enhancer_news_page_posts_per_page() {
		$published_posts   = wp_count_posts( 'post' );
		$published_count   = isset( $published_posts->publish ) ? (int) $published_posts->publish : 0;
		$default_per_page  = function_exists( 'thegem_get_option' ) ? (int) thegem_get_option( 'blog_layout_pagination_items_per_page' ) : 12;
		$default_per_page  = $default_per_page > 0 ? $default_per_page : 12;

		if ( $published_count > 0 && $published_count < $default_per_page ) {
			return $published_count;
		}

		return $default_per_page;
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_expand_news_grid' ) ) {
	function ethnic_news_archive_enhancer_expand_news_grid( $widget ) {
		if ( ! ethnic_news_archive_enhancer_is_news_page() || ! is_object( $widget ) || ! method_exists( $widget, 'get_name' ) ) {
			return;
		}

		if ( 'thegem-extended-blog-grid' !== $widget->get_name() ) {
			return;
		}

		if ( ! method_exists( $widget, 'set_settings' ) || ! method_exists( $widget, 'get_settings_for_display' ) ) {
			return;
		}

		$portfolio_uid   = method_exists( $widget, 'get_settings' ) ? (string) $widget->get_settings( 'portfolio_uid' ) : '';
		$widget_id       = method_exists( $widget, 'get_id' ) ? (string) $widget->get_id() : '';
		$published_posts = wp_count_posts( 'post' );
		$published_count = isset( $published_posts->publish ) ? (int) $published_posts->publish : 0;
		$items_per_page  = ethnic_news_archive_enhancer_news_page_posts_per_page();

		if ( ( '' !== $portfolio_uid || '' !== $widget_id ) && ! in_array( '08e1311', array( $portfolio_uid, $widget_id ), true ) ) {
			return;
		}

		$widget->set_settings( 'items_per_page', $items_per_page );
		$widget->set_settings( 'items_on_load', $items_per_page );
		$widget->set_settings( 'reduce_html_size', '' );

		if ( $published_count > $items_per_page ) {
			$widget->set_settings( 'show_pagination', 'yes' );
			$widget->set_settings( 'pagination_type', 'normal' );
		} else {
			$widget->set_settings( 'show_pagination', '' );
		}
	}
	add_action( 'elementor/frontend/widget/before_render', 'ethnic_news_archive_enhancer_expand_news_grid' );
	add_action( 'elementor/widget/before_render_content', 'ethnic_news_archive_enhancer_expand_news_grid' );
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_body_class' ) ) {
	function ethnic_news_archive_enhancer_body_class( $classes ) {
		if ( ethnic_news_archive_enhancer_is_target() ) {
			$classes[] = 'ethnic-news-target';
		}

		if ( ethnic_news_archive_enhancer_is_news_page() ) {
			$classes[] = 'ethnic-news-target--news';
		}

		if ( ethnic_news_archive_enhancer_is_archive_page() ) {
			$classes[] = 'ethnic-news-target--archive';
		}

		return $classes;
	}
	add_filter( 'body_class', 'ethnic_news_archive_enhancer_body_class' );
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_is_demo_term' ) ) {
	function ethnic_news_archive_enhancer_is_demo_term( $term ) {
		if ( ! $term || empty( $term->name ) || empty( $term->slug ) ) {
			return true;
		}

		$name = strtolower( wp_strip_all_tags( $term->name ) );
		$slug = strtolower( (string) $term->slug );

		if ( 'uncategorized' === $slug || false !== strpos( $name, 'demo' ) ) {
			return true;
		}

		return false;
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_human_list' ) ) {
	function ethnic_news_archive_enhancer_human_list( $items ) {
		$items = array_values( array_filter( array_map( 'strval', (array) $items ) ) );
		$count = count( $items );

		if ( 0 === $count ) {
			return '';
		}

		if ( 1 === $count ) {
			return $items[0];
		}

		if ( 2 === $count ) {
			return $items[0] . ' and ' . $items[1];
		}

		$last = array_pop( $items );

		return implode( ', ', $items ) . ', and ' . $last;
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_capped_srcset' ) ) {
	function ethnic_news_archive_enhancer_capped_srcset( $srcset, $max_width = 1024 ) {
		$srcset = trim( (string) $srcset );

		if ( '' === $srcset ) {
			return '';
		}

		$candidates = array_filter( array_map( 'trim', explode( ',', $srcset ) ) );
		$filtered   = array();

		foreach ( $candidates as $candidate ) {
			if ( preg_match( '/\s(\d+)w$/', $candidate, $matches ) && (int) $matches[1] > (int) $max_width ) {
				continue;
			}

			$filtered[] = $candidate;
		}

		return ! empty( $filtered ) ? implode( ', ', $filtered ) : $srcset;
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_placeholder_logo_payload' ) ) {
	function ethnic_news_archive_enhancer_placeholder_logo_payload() {
		$uploads = wp_get_upload_dir();

		if ( empty( $uploads['baseurl'] ) || empty( $uploads['basedir'] ) ) {
			return array(
				'url'    => '',
				'srcset' => '',
			);
		}

		$baseurl = trailingslashit( $uploads['baseurl'] );
		$basedir = trailingslashit( $uploads['basedir'] );
		$logos   = array(
			array(
				'1x' => '2026/03/main_logo_dark-256x85.png',
			),
			array(
				'1x' => '2026/03/main_logo_dark.png',
			),
			array(
				'1x' => 'thegem/logos/logo_e1057649409e5e93ffa2d960c8793f83_1x.png',
				'2x' => 'thegem/logos/logo_e1057649409e5e93ffa2d960c8793f83_2x.png',
			),
		);

		foreach ( $logos as $logo ) {
			if ( empty( $logo['1x'] ) || ! file_exists( $basedir . $logo['1x'] ) ) {
				continue;
			}

			$srcset = $baseurl . $logo['1x'] . ' 1x';

			if ( ! empty( $logo['2x'] ) && file_exists( $basedir . $logo['2x'] ) ) {
				$srcset .= ', ' . $baseurl . $logo['2x'] . ' 2x';
			}

			return array(
				'url'    => esc_url_raw( $baseurl . $logo['1x'] ),
				'srcset' => esc_attr( $srcset ),
			);
		}

		return array(
			'url'    => '',
			'srcset' => '',
		);
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_author_topics' ) ) {
	function ethnic_news_archive_enhancer_author_topics( $author_id ) {
		$post_ids = get_posts(
			array(
				'post_type'      => 'post',
				'post_status'    => 'publish',
				'author'         => (int) $author_id,
				'posts_per_page' => -1,
				'fields'         => 'ids',
			)
		);

		if ( empty( $post_ids ) ) {
			return array();
		}

		$terms = wp_get_object_terms(
			$post_ids,
			'category',
			array(
				'orderby' => 'count',
				'order'   => 'DESC',
			)
		);

		if ( empty( $terms ) || is_wp_error( $terms ) ) {
			return array();
		}

		$topics = array();

		foreach ( $terms as $term ) {
			if ( ethnic_news_archive_enhancer_is_demo_term( $term ) ) {
				continue;
			}

			$topics[] = html_entity_decode( wp_strip_all_tags( $term->name ), ENT_QUOTES, 'UTF-8' );

			if ( count( $topics ) >= 4 ) {
				break;
			}
		}

		return $topics;
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_author_role_label' ) ) {
	function ethnic_news_archive_enhancer_author_role_label( $user ) {
		if ( ! $user instanceof WP_User || empty( $user->roles ) || ! is_array( $user->roles ) ) {
			return '';
		}

		$role_key = (string) reset( $user->roles );

		if ( '' === $role_key ) {
			return '';
		}

		if ( function_exists( 'translate_user_role' ) ) {
			global $wp_roles;

			if ( $wp_roles instanceof WP_Roles && ! empty( $wp_roles->roles[ $role_key ]['name'] ) ) {
				return translate_user_role( $wp_roles->roles[ $role_key ]['name'] );
			}
		}

		return ucwords( str_replace( '_', ' ', $role_key ) );
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_post_payload' ) ) {
	function ethnic_news_archive_enhancer_post_payload() {
		$posts = get_posts(
			array(
				'post_type'      => 'post',
				'post_status'    => 'publish',
				'posts_per_page' => -1,
				'orderby'        => 'date',
				'order'          => 'DESC',
			)
		);

		$placeholder_logo = ethnic_news_archive_enhancer_placeholder_logo_payload();
		$payload          = array(
			'posts'                 => array(),
			'terms'                 => array(),
			'placeholderLogoUrl'    => $placeholder_logo['url'],
			'placeholderLogoSrcset' => $placeholder_logo['srcset'],
		);
		$term_index = array();

		foreach ( $posts as $post ) {
			$post_id          = (int) $post->ID;
			$term_items       = array();
			$term_slug_lookup = array();
			$primary_label    = '';
			$categories       = get_the_terms( $post_id, 'category' );
			$tags             = get_the_terms( $post_id, 'post_tag' );
				$excerpt          = get_the_excerpt( $post_id );
				$content          = wp_strip_all_tags( strip_shortcodes( (string) $post->post_content ) );
				$word_count       = str_word_count( $content );
				$reading_minutes  = max( 1, (int) ceil( $word_count / 200 ) );
				$reading_label    = 1 === $reading_minutes ? '1 Min To Read' : sprintf( '%d Mins To Read', $reading_minutes );
				$author_name      = get_the_author_meta( 'display_name', (int) $post->post_author );
				$thumbnail_id     = get_post_thumbnail_id( $post_id );
				$image_size       = 'large';
				$image_url        = '';
				$image_srcset     = '';
				$image_sizes      = '(max-width: 767px) calc(100vw - 40px), (max-width: 1024px) calc((100vw - 60px) / 2), calc((100vw - 132px) / 4)';
				$thumbnail_image  = $thumbnail_id ? wp_get_attachment_image_src( $thumbnail_id, $image_size ) : false;

				if ( $thumbnail_image && ! empty( $thumbnail_image[0] ) ) {
					$image_url    = $thumbnail_image[0];
					$image_srcset = ethnic_news_archive_enhancer_capped_srcset( wp_get_attachment_image_srcset( $thumbnail_id, $image_size ), 1024 );
				}

				$likes_count      = (int) get_post_meta( $post_id, '_zilla_likes', true );

			foreach ( array( $categories, $tags ) as $term_group ) {
				if ( empty( $term_group ) || is_wp_error( $term_group ) ) {
					continue;
				}

				foreach ( $term_group as $term ) {
					if ( ethnic_news_archive_enhancer_is_demo_term( $term ) ) {
						continue;
					}

					if ( isset( $term_slug_lookup[ $term->slug ] ) ) {
						continue;
					}

					$term_slug_lookup[ $term->slug ] = true;
					$term_items[]                    = array(
						'slug'     => (string) $term->slug,
						'name'     => html_entity_decode( wp_strip_all_tags( $term->name ), ENT_QUOTES, 'UTF-8' ),
						'taxonomy' => (string) $term->taxonomy,
					);

					if ( ! $primary_label && 'category' === $term->taxonomy ) {
						$primary_label = html_entity_decode( wp_strip_all_tags( $term->name ), ENT_QUOTES, 'UTF-8' );
					}
				}
			}

			if ( ! $primary_label && ! empty( $term_items[0]['name'] ) ) {
				$primary_label = $term_items[0]['name'];
			}

			foreach ( $term_items as $term_item ) {
				$slug = $term_item['slug'];

				if ( empty( $term_index[ $slug ] ) ) {
					$term_index[ $slug ] = array(
						'slug'     => $slug,
						'name'     => $term_item['name'],
						'taxonomy' => isset( $term_item['taxonomy'] ) ? (string) $term_item['taxonomy'] : '',
						'count'    => 0,
					);
				}

				$term_index[ $slug ]['count']++;
			}

			$payload['posts'][ (string) $post_id ] = array(
				'id'               => $post_id,
				'title'            => html_entity_decode( get_the_title( $post_id ), ENT_QUOTES, 'UTF-8' ),
				'url'              => get_permalink( $post_id ),
				'excerpt'          => html_entity_decode( wp_strip_all_tags( wp_trim_words( $excerpt, 22, '...' ) ), ENT_QUOTES, 'UTF-8' ),
				'author'           => html_entity_decode( wp_strip_all_tags( $author_name ), ENT_QUOTES, 'UTF-8' ),
					'readTimeLabel'    => $reading_label,
					'day'              => get_the_date( 'd', $post_id ),
					'month'            => strtoupper( get_the_date( 'F', $post_id ) ),
					'year'             => get_the_date( 'Y', $post_id ),
					'dateLabel'        => strtoupper( get_the_date( 'd M Y', $post_id ) ),
					'timestamp'        => (int) get_post_time( 'U', true, $post_id ),
					'hasFeaturedImage' => (bool) $thumbnail_id,
					'imageUrl'         => $image_url ? esc_url_raw( $image_url ) : '',
					'imageSrcset'      => $image_srcset ? esc_attr( $image_srcset ) : '',
					'imageSizes'       => $image_sizes,
					'likesCount'       => $likes_count,
					'primaryTermLabel' => $primary_label,
					'terms'            => $term_items,
					'termSlugs'        => array_values( array_map( 'strval', array_keys( $term_slug_lookup ) ) ),
				);
		}

		uasort(
			$term_index,
			static function ( $left, $right ) {
				if ( $left['count'] === $right['count'] ) {
					return strcasecmp( $left['name'], $right['name'] );
				}

				return $right['count'] <=> $left['count'];
			}
		);

		$payload['terms'] = array_values( $term_index );

		return $payload;
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_archive_heading_payload' ) ) {
	function ethnic_news_archive_enhancer_archive_heading_payload() {
		if ( ethnic_news_archive_enhancer_is_news_page() ) {
			$title = get_the_title( get_queried_object_id() );

			return array(
				'type'  => 'news',
				'title' => html_entity_decode( wp_strip_all_tags( $title ? $title : 'News' ), ENT_QUOTES, 'UTF-8' ),
			);
		}

		if ( ! ethnic_news_archive_enhancer_is_archive_page() ) {
			return array();
		}

		$object = get_queried_object();

		if ( is_tag() && $object instanceof WP_Term ) {
			return array(
				'eyebrow' => 'Tag',
				'type'    => 'tag',
				'title'   => html_entity_decode( wp_strip_all_tags( $object->name ), ENT_QUOTES, 'UTF-8' ),
			);
		}

		if ( is_category() && $object instanceof WP_Term ) {
			return array(
				'eyebrow' => 'Category',
				'type'    => 'category',
				'title'   => html_entity_decode( wp_strip_all_tags( $object->name ), ENT_QUOTES, 'UTF-8' ),
			);
		}

		if ( is_author() && $object instanceof WP_User ) {
			$topics           = ethnic_news_archive_enhancer_author_topics( $object->ID );
			$post_count       = (int) count_user_posts( $object->ID, 'post', true );
			$role_label       = ethnic_news_archive_enhancer_author_role_label( $object );
			$raw_description  = trim( wp_strip_all_tags( get_the_author_meta( 'description', $object->ID ) ) );
			$fallback_summary = sprintf(
				'%1$s shares insights on %2$s from the Ethnic Infotech team.',
				html_entity_decode( wp_strip_all_tags( $object->display_name ), ENT_QUOTES, 'UTF-8' ),
				ethnic_news_archive_enhancer_human_list( ! empty( $topics ) ? $topics : array( 'digital growth' ) )
			);

			return array(
				'eyebrow'       => 'Author',
				'type'          => 'author',
				'title'         => html_entity_decode( wp_strip_all_tags( $object->display_name ), ENT_QUOTES, 'UTF-8' ),
				'subtitle'      => $raw_description ? html_entity_decode( $raw_description, ENT_QUOTES, 'UTF-8' ) : $fallback_summary,
				'avatar'        => get_avatar_url( $object->ID, array( 'size' => 144 ) ),
				'role'          => $role_label ? $role_label : 'Ethnic Infotech Team',
				'postCountLabel'=> 1 === $post_count ? '1 article published' : sprintf( '%d articles published', $post_count ),
				'topics'        => $topics,
			);
		}

		return array();
	}
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_styles' ) ) {
	function ethnic_news_archive_enhancer_styles() {
		if ( ! ethnic_news_archive_enhancer_is_target() ) {
			return;
		}
		?>
		<style id="ethnic-news-archive-enhancer">
			body.ethnic-news-target {
				--ethnic-page-shell-padding: clamp(24px, 2.6vw, 48px);
			}

			body.ethnic-news-target--news .elementor-575 .elementor-element-c7d53b7 {
				display: none !important;
			}

			body.ethnic-news-target--news #page-title {
				display: none !important;
			}

			body.ethnic-news-target--news #main-content > .block-content {
				padding-bottom: 0 !important;
			}

			body.ethnic-news-target--archive #page-title {
				display: none !important;
			}

			body.ethnic-news-target--archive #main-content > .block-content > .container {
				width: 100% !important;
				max-width: none !important;
				padding-left: 0 !important;
				padding-right: 0 !important;
			}

			body.ethnic-news-target--archive #main-content > .block-content > .container > .panel {
				margin-left: 0 !important;
				margin-right: 0 !important;
			}

			body.ethnic-news-target--archive #main-content > .block-content > .container > .panel > .panel-center {
				padding-left: var(--ethnic-page-shell-padding, 40px) !important;
				padding-right: var(--ethnic-page-shell-padding, 40px) !important;
				box-sizing: border-box !important;
			}

			body.ethnic-news-target--news .elementor-575 .elementor-element-ecf96b6 {
				width: 100% !important;
				max-width: none !important;
				align-items: stretch !important;
				justify-content: flex-start !important;
				margin: 40px 0 0 !important;
				padding-left: 0 !important;
				padding-right: 0 !important;
				box-sizing: border-box !important;
			}

			body.ethnic-news-target--news .elementor-575 .elementor-element-08e1311,
			body.ethnic-news-target--news .elementor-575 .elementor-element-08e1311 > .elementor-widget-container {
				width: 100% !important;
				max-width: none !important;
			}

			body.ethnic-news-target--news .elementor-575 .elementor-element-08e1311 > .elementor-widget-container {
				padding-left: var(--ethnic-page-shell-padding, 40px) !important;
				padding-right: var(--ethnic-page-shell-padding, 40px) !important;
				box-sizing: border-box !important;
			}

			body.ethnic-news-target--archive .portfolio-preloader-wrapper {
				opacity: 0;
				visibility: hidden;
				transform: translateY(8px);
				transition: opacity 180ms ease, transform 180ms ease;
			}

			body.ethnic-news-target--news #style-08e1311:not([data-ethnic-news-enhanced="true"]) {
				opacity: 0;
				visibility: hidden;
				transform: translateY(8px);
				transition: opacity 180ms ease, transform 180ms ease;
			}

			body.ethnic-news-target--archive .portfolio-preloader-wrapper[data-ethnic-news-enhanced="true"] {
				opacity: 1;
				visibility: visible;
				transform: none;
			}

			body.ethnic-news-target--news #style-08e1311[data-ethnic-news-enhanced="true"] {
				opacity: 1;
				visibility: visible;
				transform: none;
			}

			body.ethnic-news-target .ethnic-news-archive-heading {
				margin: 0 0 28px;
			}

			body.ethnic-news-target .ethnic-news-archive-heading__eyebrow {
				display: inline-flex;
				align-items: center;
				min-height: 34px;
				padding: 8px 14px;
				border-radius: 999px;
				background: rgba(92, 81, 214, 0.08);
				color: #5c51d6;
				font-size: 13px;
				font-weight: 700;
				letter-spacing: 0.08em;
				line-height: 1;
				text-transform: uppercase;
			}

			body.ethnic-news-target .ethnic-news-archive-heading__title {
				margin: 14px 0 0;
				color: #0f172a;
				font-family: "Plus Jakarta Sans", "Figtree", sans-serif;
				font-size: clamp(44px, 6vw, 96px);
				font-weight: 700;
				line-height: 0.96;
				letter-spacing: -0.055em;
				text-wrap: balance;
			}

			body.ethnic-news-target--news .ethnic-news-archive-heading__title {
				margin-top: 0;
			}

			body.ethnic-news-target--archive .ethnic-news-author-profile {
				display: grid;
				grid-template-columns: 108px minmax(0, 1fr);
				gap: 24px;
				align-items: start;
				margin: 0 0 30px;
				padding: 28px;
				border: 1px solid rgba(15, 23, 42, 0.08);
				border-radius: 28px;
				background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 247, 255, 0.98));
				box-shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
			}

			body.ethnic-news-target--archive .ethnic-news-author-profile__avatar {
				width: 108px;
				height: 108px;
				border-radius: 999px;
				object-fit: cover;
				border: 6px solid rgba(92, 81, 214, 0.08);
				background: #ffffff;
			}

			body.ethnic-news-target--archive .ethnic-news-author-profile__role {
				display: inline-flex;
				align-items: center;
				min-height: 34px;
				padding: 8px 14px;
				border-radius: 999px;
				background: rgba(92, 81, 214, 0.08);
				color: #5c51d6;
				font-size: 13px;
				font-weight: 700;
				letter-spacing: 0.08em;
				line-height: 1;
				text-transform: uppercase;
			}

			body.ethnic-news-target--archive .ethnic-news-author-profile__summary {
				margin: 14px 0 0;
				color: #334155;
				font-size: 17px;
				line-height: 1.75;
				max-width: 760px;
			}

			body.ethnic-news-target--archive .ethnic-news-author-profile__meta {
				display: flex;
				flex-wrap: wrap;
				gap: 12px;
				margin-top: 18px;
			}

			body.ethnic-news-target--archive .ethnic-news-author-profile__badge {
				display: inline-flex;
				align-items: center;
				min-height: 38px;
				padding: 8px 16px;
				border: 1px solid rgba(15, 23, 42, 0.1);
				border-radius: 999px;
				background: #ffffff;
				color: #14213d;
				font-size: 14px;
				font-weight: 500;
				line-height: 1;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-set {
				gap: 12px !important;
				justify-items: stretch !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .wrap,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .wrap.clearfix {
				margin: 0 !important;
				max-width: none !important;
				border-radius: 6px !important;
				box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08) !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner {
				border-radius: 6px 6px 0 0 !important;
			}

			body.ethnic-news-target .ethnic-news-card__content {
				padding: 24px 22px 24px;
			}

			body.ethnic-news-target .ethnic-news-archive {
				width: 100%;
				max-width: none;
				padding-top: 16px;
				margin: 0 0 26px;
			}

			body.ethnic-news-target .ethnic-news-archive__topbar {
				display: grid;
				grid-template-columns: minmax(0, 1fr) minmax(320px, 49vw);
				gap: clamp(24px, 4vw, 64px);
				align-items: end;
				margin: 0 0 28px;
			}

			body.ethnic-news-target .ethnic-news-archive__topbar .ethnic-news-archive-heading {
				margin-bottom: 0;
			}

			body.ethnic-news-target .ethnic-news-search {
				position: relative;
				z-index: 5;
				width: 100%;
				max-width: 860px;
				justify-self: end;
			}

			body.ethnic-news-target .ethnic-news-search__field {
				position: relative;
				display: flex;
				align-items: center;
				min-height: 68px;
				border: 1px solid rgba(15, 23, 42, 0.12);
				border-radius: 14px;
				background: rgba(255, 255, 255, 0.9);
				box-shadow: 0 18px 46px rgba(15, 23, 42, 0.06);
				transition: border-color 180ms ease, box-shadow 180ms ease;
			}

			body.ethnic-news-target .ethnic-news-search__field:focus-within {
				border-color: rgba(92, 81, 214, 0.34);
				box-shadow: 0 22px 54px rgba(15, 23, 42, 0.1);
			}

			body.ethnic-news-target .ethnic-news-search__icon {
				display: inline-flex;
				align-items: center;
				justify-content: center;
				width: 66px;
				color: #5c51d6;
				line-height: 1;
				flex: none;
			}

			body.ethnic-news-target .ethnic-news-search__icon svg {
				display: block;
				width: 24px;
				height: 24px;
				fill: currentColor;
			}

			body.ethnic-news-target .ethnic-news-search__input {
				width: 100%;
				min-width: 0;
				height: 66px;
				padding: 0 54px 0 0;
				border: 0;
				background: transparent;
				color: #0f172a;
				font-size: clamp(18px, 1.25vw, 22px);
				font-weight: 500;
				letter-spacing: -0.02em;
				outline: none;
			}

			body.ethnic-news-target .ethnic-news-search__input::placeholder {
				color: rgba(64, 81, 107, 0.68);
			}

			body.ethnic-news-target .ethnic-news-search__clear {
				position: absolute;
				right: 14px;
				top: 50%;
				display: none;
				align-items: center;
				justify-content: center;
				width: 32px;
				height: 32px;
				padding: 0;
				border: 1px solid rgba(15, 23, 42, 0.1);
				border-radius: 50%;
				background: #ffffff;
				color: #40516b;
				cursor: pointer;
				transform: translateY(-50%);
			}

			body.ethnic-news-target .ethnic-news-search.has-value .ethnic-news-search__clear {
				display: inline-flex;
			}

			body.ethnic-news-target .ethnic-news-search__clear:hover,
			body.ethnic-news-target .ethnic-news-search__clear:focus-visible {
				border-color: rgba(92, 81, 214, 0.26);
				color: #5c51d6;
				outline: none;
			}

			body.ethnic-news-target .ethnic-news-archive__empty {
				display: none;
				margin: 18px 0 28px;
				padding: 28px;
				border: 1px solid rgba(15, 23, 42, 0.08);
				border-radius: 14px;
				background: #ffffff;
				color: #40516b;
				font-size: 18px;
				line-height: 1.55;
				text-align: center;
			}

			body.ethnic-news-target .ethnic-news-archive__empty.is-visible {
				display: block;
			}

			body.ethnic-news-target .ethnic-news-archive__filters-shell {
				display: grid;
				grid-template-columns: minmax(0, 1fr) 92px;
				align-items: start;
				gap: 12px;
				width: 100%;
				margin: 0 0 28px;
			}

			body.ethnic-news-target .ethnic-news-archive__filters {
				grid-column: 1;
				grid-row: 1;
				width: 100%;
				min-width: 0;
				margin: 0;
				padding: 4px 0 10px;
				overflow-x: auto;
				overflow-y: hidden;
				scrollbar-width: none;
				-ms-overflow-style: none;
				-webkit-overflow-scrolling: touch;
			}

			body.ethnic-news-target .ethnic-news-archive__filters::-webkit-scrollbar {
				display: none;
			}

			body.ethnic-news-target .ethnic-news-archive__filters-track {
				display: inline-flex;
				flex-wrap: nowrap;
				align-items: center;
				gap: 14px;
				min-width: max-content;
				will-change: transform;
			}

			body.ethnic-news-target .ethnic-news-archive__filters.is-bouncing .ethnic-news-archive__filters-track {
				animation: ethnic-news-filter-rail-hint 520ms ease-out 1;
			}

			body.ethnic-news-target .ethnic-news-archive__scroll-hint {
				grid-column: 2;
				grid-row: 1;
				display: inline-flex;
				align-items: center;
				justify-content: flex-end;
				gap: 12px;
				width: 92px;
				padding-top: 4px;
				color: #0f172a;
				z-index: 3;
				opacity: 0;
				pointer-events: none;
				transform: translateY(2px);
				transition: opacity 180ms ease, transform 180ms ease;
			}

			body.ethnic-news-target .ethnic-news-archive__filters-shell.is-scrollable .ethnic-news-archive__scroll-hint {
				opacity: 1;
				transform: translateY(0);
			}

			body.ethnic-news-target .ethnic-news-archive__scroll-button {
				appearance: none;
				-webkit-appearance: none;
				display: inline-flex;
				align-items: center;
				justify-content: center;
				width: 40px;
				height: 40px;
				padding: 0;
				border: 1px solid rgba(15, 23, 42, 0.06);
				border-radius: 50%;
				background: rgba(255, 255, 255, 0.92);
				color: inherit;
				box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
				cursor: pointer;
				pointer-events: auto;
				transition: border-color 180ms ease, box-shadow 180ms ease, opacity 180ms ease, transform 180ms ease;
			}

			body.ethnic-news-target .ethnic-news-archive__scroll-button:hover,
			body.ethnic-news-target .ethnic-news-archive__scroll-button:focus-visible {
				border-color: rgba(92, 81, 214, 0.2);
				box-shadow: 0 18px 32px rgba(15, 23, 42, 0.12);
				color: #5c51d6;
				transform: translateY(-1px);
				outline: none;
			}

			body.ethnic-news-target .ethnic-news-archive__scroll-button:focus-visible {
				border-radius: 4px;
				box-shadow: 0 0 0 2px rgba(92, 81, 214, 0.24);
			}

			body.ethnic-news-target .ethnic-news-archive__scroll-button:disabled {
				opacity: 0.45;
				cursor: default;
				transform: none;
			}

			body.ethnic-news-target .ethnic-news-archive__scroll-hint-arrow {
				position: relative;
				display: flex;
				align-items: center;
				justify-content: center;
				width: 16px;
				height: 16px;
				font-size: 14px;
				font-weight: 700;
				line-height: 1;
			}

			body.ethnic-news-target .ethnic-news-archive__filter {
				display: inline-flex;
				flex: 0 0 auto;
				align-items: center;
				justify-content: center;
				min-height: 44px;
				padding: 10px 18px;
				border: 1px solid rgba(15, 23, 42, 0.14);
				border-radius: 999px;
				background: #ffffff;
				color: #14213d;
				font-size: 15px;
				font-weight: 500;
				line-height: 1;
				white-space: nowrap;
				transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, transform 180ms ease;
				cursor: pointer;
			}

			body.ethnic-news-target .ethnic-news-archive__filter:hover,
			body.ethnic-news-target .ethnic-news-archive__filter:focus-visible {
				border-color: #5c51d6;
				color: #5c51d6;
				transform: translateY(-1px);
				outline: none;
			}

			body.ethnic-news-target .ethnic-news-archive__filter.is-active {
				background: #5c51d6;
				border-color: #5c51d6;
				color: #ffffff;
			}

			@keyframes ethnic-news-filter-rail-hint {
				0% {
					transform: translateX(0);
				}

				45% {
					transform: translateX(-5px);
				}

				100% {
					transform: translateX(0);
				}
			}

			body.ethnic-news-target .ethnic-news-archive-scope,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-preloader-wrapper,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-row-outer,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-row {
				overflow: visible !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-top-panel,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item-size-container {
				display: none !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-preloader-wrapper,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-row-outer,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-row {
				width: 100% !important;
				max-width: none !important;
				margin: 0 auto !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-row {
				display: block !important;
				height: auto !important;
				min-height: 0 !important;
				margin: 0 !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-set {
				display: grid !important;
				position: relative !important;
				grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
				justify-content: flex-start !important;
				justify-items: stretch !important;
				gap: 12px !important;
				align-content: start !important;
				align-items: stretch !important;
				height: auto !important;
				min-height: 0 !important;
				width: 100% !important;
				max-width: none !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-set::before,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-set::after {
				content: none !important;
				display: none !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:nth-child(1),
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:nth-child(2),
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:nth-child(3),
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:first-child:nth-last-child(2),
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:first-child:nth-last-child(2) + .portfolio-item,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:only-child {
				width: auto !important;
				max-width: none !important;
				display: flex !important;
				position: relative !important;
				top: auto !important;
				right: auto !important;
				bottom: auto !important;
				left: auto !important;
				visibility: visible !important;
				opacity: 1 !important;
				min-width: 0 !important;
				margin: 0 !important;
				padding: 0 !important;
				box-sizing: border-box !important;
				flex: initial !important;
				grid-column: auto !important;
				grid-row: auto !important;
				align-self: stretch !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item.is-filtered-out {
				display: none !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .wrap,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .wrap.clearfix {
				display: flex !important;
				flex-direction: column !important;
				height: 100% !important;
				width: 100% !important;
				max-width: none !important;
				margin: 0 !important;
				grid-template-columns: none !important;
				grid-template-rows: none !important;
				background: #ffffff !important;
				border: 1px solid rgba(15, 23, 42, 0.06) !important;
				box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08) !important;
				border-radius: 6px !important;
				overflow: hidden !important;
				transform: none !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .wrap::before,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .wrap::after,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .overlay,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .wrap > .caption,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:nth-child(1) .wrap > .caption,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:nth-child(2) .wrap > .caption,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:nth-child(3) .wrap > .caption,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:first-child:nth-last-child(2) .wrap > .caption,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:first-child:nth-last-child(2) + .portfolio-item .wrap > .caption,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item:only-child .wrap > .caption {
				display: none !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner {
				display: block !important;
				aspect-ratio: auto !important;
				height: auto !important;
				min-height: 0 !important;
				padding: 0 !important;
				width: 100% !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner {
				position: relative !important;
				height: auto !important;
				border-radius: 6px 6px 0 0 !important;
				background: #ffffff !important;
				overflow: hidden !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner::before,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner::after {
				content: none !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner > picture {
				display: none !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner .post-featured-content,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner .post-featured-content a,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner .post-featured-content picture,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner .post-featured-content img {
				display: block !important;
				width: 100% !important;
				height: auto !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner .post-featured-content {
				position: static !important;
				inset: auto !important;
				z-index: 1 !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner .post-featured-content img {
				object-fit: contain !important;
				object-position: center center !important;
				transform: none !important;
				opacity: 1 !important;
				filter: none !important;
			}

			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item.ethnic-news-card--placeholder-image .image,
			body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item.ethnic-news-card--placeholder-image .image-inner {
				aspect-ratio: 16 / 9 !important;
				height: auto !important;
			}

			body.ethnic-news-target .ethnic-news-card__placeholder {
				position: relative;
				display: flex;
				align-items: center;
				justify-content: center;
				width: 100%;
				aspect-ratio: 16 / 9;
				min-height: 184px;
				padding: 28px;
				overflow: hidden;
				background: #f4f8fc;
				box-sizing: border-box;
			}

			body.ethnic-news-target .ethnic-news-card__placeholder::after {
				content: none;
				position: absolute;
				inset: 18px;
				border: 1px solid rgba(15, 23, 42, 0.06);
				border-radius: 4px;
				pointer-events: none;
			}

			body.ethnic-news-target .ethnic-news-card__placeholder-logo {
				position: relative;
				z-index: 1;
				display: block !important;
				width: 128px !important;
				max-width: 42% !important;
				height: auto !important;
				min-height: 0 !important;
				aspect-ratio: auto !important;
				object-fit: contain !important;
				filter: grayscale(1) saturate(0) contrast(0.95) !important;
				opacity: 0.46 !important;
			}

			body.ethnic-news-target .ethnic-news-card__content {
				display: flex;
				flex: 1 1 auto;
				flex-direction: column;
				padding: 24px 22px 24px;
				min-height: 310px;
			}

			body.ethnic-news-target .ethnic-news-card__term {
				margin: 0 0 16px;
				color: #5c51d6;
				font-size: 13px;
				font-weight: 500;
				line-height: 1.2;
			}

			body.ethnic-news-target .ethnic-news-card__title {
				margin: 0;
				color: #0f172a;
				font-size: clamp(18px, 1.55vw, 22px);
				font-weight: 600;
				line-height: 1.16;
				letter-spacing: -0.025em;
			}

			body.ethnic-news-target .ethnic-news-card__title-link {
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 3;
				overflow: hidden;
				color: inherit;
				text-decoration: none;
			}

			body.ethnic-news-target .ethnic-news-card__title-link:hover {
				color: #213e73;
			}

			body.ethnic-news-target .ethnic-news-card__rule {
				width: 82px;
				height: 2px;
				margin: 18px 0 14px;
				background: #1f2a44;
			}

			body.ethnic-news-target .ethnic-news-card__excerpt {
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 3;
				overflow: hidden;
				margin: 0;
				color: #1f2937;
				font-size: 15px;
				line-height: 1.6;
				min-height: 4.8em;
			}

			body.ethnic-news-target .ethnic-news-card__footer {
				display: flex;
				justify-content: space-between;
				gap: 20px;
				align-items: flex-end;
				margin-top: auto;
				padding-top: 26px;
			}

			body.ethnic-news-target .ethnic-news-card__date {
				display: grid;
				grid-template-columns: auto auto;
				column-gap: 8px;
				row-gap: 3px;
				align-items: end;
				min-width: 112px;
			}

			body.ethnic-news-target .ethnic-news-card__date-day {
				grid-row: 1 / span 2;
				font-size: 46px;
				font-weight: 700;
				line-height: 0.92;
				letter-spacing: -0.04em;
				color: #0f172a;
			}

			body.ethnic-news-target .ethnic-news-card__date-month,
			body.ethnic-news-target .ethnic-news-card__date-year {
				color: #0f172a;
				font-size: 12px;
				font-weight: 600;
				line-height: 1.1;
				letter-spacing: 0.04em;
				text-transform: uppercase;
			}

			body.ethnic-news-target .ethnic-news-card__meta {
				display: flex;
				flex-direction: column;
				align-items: flex-end;
				gap: 4px;
				margin-left: auto;
				text-align: right;
			}

			body.ethnic-news-target .ethnic-news-card__meta-line {
				color: #0f172a;
				font-size: 14px;
				line-height: 1.25;
			}

			body.ethnic-news-target .ethnic-news-card__meta-line--secondary {
				display: none;
			}

			body.ethnic-news-target--news .ethnic-news-archive-scope .portfolio-navigator.gem-pagination {
				display: flex !important;
				align-items: center !important;
				justify-content: center !important;
				margin: 64px 0 0 !important;
				padding: 0 !important;
			}

			body.ethnic-news-target--news .ethnic-news-archive-scope.is-searching .portfolio-navigator.gem-pagination {
				display: none !important;
			}

			body.ethnic-news-target--news .ethnic-news-popular {
				width: 100vw;
				margin: 24px calc(50% - 50vw) 0;
				padding: 82px 0 70px;
				background: #eef4fb;
				overflow: hidden;
			}

			body.ethnic-news-target--news .ethnic-news-popular__inner {
				display: grid;
				grid-template-columns: minmax(260px, 29vw) minmax(0, 1fr);
				align-items: center;
				gap: clamp(28px, 3.2vw, 56px);
				width: 100%;
				max-width: 1840px;
				margin: 0 auto;
				padding: 0 clamp(24px, 7.5vw, 156px);
			}

			body.ethnic-news-target--news .ethnic-news-popular__intro {
				padding-right: clamp(18px, 3vw, 48px);
			}

			body.ethnic-news-target--news .ethnic-news-popular__title {
				margin: 0;
				color: #0f172a;
				font-size: clamp(42px, 4vw, 66px);
				font-weight: 400;
				line-height: 1.08;
				letter-spacing: -0.06em;
			}

			body.ethnic-news-target--news .ethnic-news-popular__rule {
				width: 122px;
				height: 2px;
				margin: 28px 0;
				background: rgba(15, 23, 42, 0.36);
			}

			body.ethnic-news-target--news .ethnic-news-popular__copy {
				max-width: 430px;
				margin: 0;
				color: #40516b;
				font-size: clamp(18px, 1.35vw, 24px);
				font-weight: 400;
				line-height: 1.7;
			}

			body.ethnic-news-target--news .ethnic-news-popular__link {
				display: inline-flex;
				align-items: center;
				gap: 16px;
				margin-top: 54px;
				color: #0f172a;
				font-size: clamp(18px, 1.6vw, 28px);
				font-weight: 700;
				line-height: 1;
				text-decoration: none;
			}

			body.ethnic-news-target--news .ethnic-news-popular__link-icon {
				display: inline-flex;
				align-items: center;
				justify-content: center;
				width: 54px;
				height: 54px;
				border: 2px solid currentColor;
				border-radius: 50%;
				font-size: 22px;
				line-height: 1;
				transition: transform 180ms ease;
			}

			body.ethnic-news-target--news .ethnic-news-popular__link:hover .ethnic-news-popular__link-icon,
			body.ethnic-news-target--news .ethnic-news-popular__link:focus-visible .ethnic-news-popular__link-icon {
				transform: translateX(3px);
			}

			body.ethnic-news-target--news .ethnic-news-popular__content {
				min-width: 0;
				padding-left: clamp(28px, 3vw, 46px);
				border-left: 1px solid rgba(64, 81, 107, 0.18);
			}

			body.ethnic-news-target--news .ethnic-news-popular__rail {
				display: flex;
				gap: 20px;
				overflow-x: auto;
				overflow-y: hidden;
				padding: 6px clamp(120px, 16vw, 300px) 12px 0;
				scroll-snap-type: none;
				scrollbar-width: none;
				-ms-overflow-style: none;
				-webkit-overflow-scrolling: touch;
				cursor: grab;
				overscroll-behavior-x: contain;
				touch-action: pan-y pinch-zoom;
			}

			body.ethnic-news-target--news .ethnic-news-popular__rail::-webkit-scrollbar {
				display: none;
			}

			body.ethnic-news-target--news .ethnic-news-popular__rail.is-dragging {
				cursor: grabbing;
				scroll-snap-type: none;
				user-select: none;
			}

			body.ethnic-news-target--news .ethnic-news-popular-card {
				display: flex;
				flex: 0 0 clamp(340px, 28vw, 460px);
				flex-direction: column;
				min-height: 548px;
				overflow: hidden;
				border: 1px solid rgba(15, 23, 42, 0.06);
				border-radius: 16px;
				background: #ffffff;
				color: #0f172a;
				text-decoration: none;
				box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
				scroll-snap-align: none;
				-webkit-user-drag: none;
				user-select: none;
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__media {
				position: relative;
				height: 256px;
				overflow: hidden;
				background:
					radial-gradient(circle at 18% 18%, rgba(190, 208, 255, 0.78), transparent 34%),
					linear-gradient(135deg, #dbe8ff 0%, #f6fbff 50%, #cfeef5 100%);
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__image {
				width: 100%;
				height: 100%;
				object-fit: cover;
				opacity: 0.72;
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__placeholder {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 100%;
				height: 100%;
				padding: 30px;
				background: #f4f8fc;
				box-sizing: border-box;
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__placeholder-logo {
				display: block !important;
				width: 132px !important;
				max-width: 46% !important;
				height: auto !important;
				min-height: 0 !important;
				aspect-ratio: auto !important;
				object-fit: contain !important;
				filter: grayscale(1) saturate(0) contrast(0.95) !important;
				opacity: 0.46 !important;
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__badge {
				position: absolute;
				top: 50%;
				left: 50%;
				z-index: 2;
				transform: translate(-50%, -50%);
				display: inline-flex;
				align-items: center;
				justify-content: center;
				min-height: 40px;
				padding: 0 24px;
				border-radius: 999px;
				background: rgba(255, 255, 255, 0.92);
				color: #1f2a44;
				font-size: 13px;
				font-weight: 700;
				letter-spacing: 0.12em;
				text-transform: uppercase;
				white-space: nowrap;
				box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__body {
				display: flex;
				flex: 1 1 auto;
				flex-direction: column;
				padding: 24px 28px 28px;
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__meta {
				display: flex;
				align-items: center;
				justify-content: space-between;
				gap: 18px;
				margin-bottom: 22px;
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__term {
				display: inline-flex;
				align-items: center;
				min-width: 0;
				min-height: 34px;
				padding: 0 14px;
				border: 1px solid rgba(50, 103, 206, 0.18);
				border-radius: 999px;
				background: #edf4ff;
				color: #31537d;
				font-size: 12px;
				font-weight: 700;
				letter-spacing: 0.08em;
				line-height: 1;
				text-transform: uppercase;
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__date {
				flex: 0 0 auto;
				color: #64748b;
				font-size: 13px;
				font-weight: 700;
				letter-spacing: 0.08em;
				text-transform: uppercase;
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__title {
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 3;
				overflow: hidden;
				margin: 0;
				color: #0f172a;
				font-size: clamp(26px, 2vw, 36px);
				font-weight: 500;
				line-height: 1.12;
				letter-spacing: -0.055em;
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__rule {
				width: 122px;
				height: 2px;
				margin: 22px 0 20px;
				background: rgba(15, 23, 42, 0.32);
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__excerpt {
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 4;
				overflow: hidden;
				margin: 0;
				color: #40516b;
				font-size: 17px;
				line-height: 1.62;
			}

			body.ethnic-news-target--news .ethnic-news-popular-card__read-time {
				margin-top: auto;
				padding-top: 32px;
				color: #516987;
				font-size: 15px;
				font-weight: 700;
				line-height: 1.2;
				text-align: right;
			}

			@media (max-width: 1024px) {
				body.ethnic-news-target .ethnic-news-archive-scope .portfolio-set {
					grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
				}

				body.ethnic-news-target--news .elementor-575 .elementor-element-ecf96b6 {
					margin-top: 30px !important;
					margin-bottom: 0 !important;
				}

				body.ethnic-news-target .ethnic-news-archive-heading {
					margin-bottom: 24px;
				}

				body.ethnic-news-target .ethnic-news-archive__topbar {
					grid-template-columns: 1fr;
					gap: 22px;
				}

				body.ethnic-news-target .ethnic-news-search {
					max-width: none;
					justify-self: stretch;
				}

				body.ethnic-news-target--archive .ethnic-news-author-profile {
					grid-template-columns: 88px minmax(0, 1fr);
					gap: 20px;
					padding: 24px;
				}

				body.ethnic-news-target--archive .ethnic-news-author-profile__avatar {
					width: 88px;
					height: 88px;
				}

				body.ethnic-news-target .ethnic-news-card__content {
					min-height: 0;
				}

				body.ethnic-news-target--news .ethnic-news-popular {
					margin-top: 24px;
					padding: 58px 0;
				}

				body.ethnic-news-target--news .ethnic-news-popular__inner {
					grid-template-columns: 1fr;
					gap: 34px;
				}

				body.ethnic-news-target--news .ethnic-news-popular__intro {
					max-width: 620px;
					padding-right: 0;
				}

				body.ethnic-news-target--news .ethnic-news-popular__content {
					padding-top: 30px;
					padding-left: 0;
					border-top: 1px solid rgba(64, 81, 107, 0.18);
					border-left: 0;
				}

				body.ethnic-news-target--news .ethnic-news-popular__link {
					margin-top: 34px;
				}
			}

			@media (max-width: 767px) {
				body.ethnic-news-target--news .elementor-575 .elementor-element-ecf96b6 {
					margin-top: 24px !important;
					margin-bottom: 56px !important;
				}

				body.ethnic-news-target .ethnic-news-archive-heading {
					margin-bottom: 20px;
				}

				body.ethnic-news-target .ethnic-news-archive-heading__title {
					font-size: 42px;
				}

				body.ethnic-news-target--archive .ethnic-news-author-profile {
					grid-template-columns: 1fr;
					padding: 20px;
					gap: 18px;
				}

				body.ethnic-news-target--archive .ethnic-news-author-profile__avatar {
					width: 80px;
					height: 80px;
				}

				body.ethnic-news-target--archive .ethnic-news-author-profile__summary {
					font-size: 16px;
					line-height: 1.7;
				}

				body.ethnic-news-target .ethnic-news-archive__filters-shell {
					margin-bottom: 20px;
				}

				body.ethnic-news-target .ethnic-news-archive__filters {
					padding: 4px 0 8px;
				}

				body.ethnic-news-target .ethnic-news-archive__filters-track {
					gap: 12px;
				}

				body.ethnic-news-target .ethnic-news-archive {
					padding-top: 12px;
				}

				body.ethnic-news-target .ethnic-news-archive__filter {
					min-height: 40px;
					padding: 9px 16px;
				}

				body.ethnic-news-target .ethnic-news-search__field {
					min-height: 56px;
				}

				body.ethnic-news-target .ethnic-news-search__icon {
					width: 48px;
				}

				body.ethnic-news-target .ethnic-news-search__input {
					height: 54px;
					font-size: 16px;
				}

				body.ethnic-news-target .ethnic-news-archive-scope .portfolio-set {
					grid-template-columns: 1fr !important;
				}

				body.ethnic-news-target .ethnic-news-card__content {
					padding: 20px 18px 22px;
					min-height: 0;
				}

				body.ethnic-news-target .ethnic-news-card__title {
					font-size: 26px;
				}

				body.ethnic-news-target .ethnic-news-card__footer {
					gap: 16px;
				}

				body.ethnic-news-target .ethnic-news-card__date-day {
					font-size: 42px;
				}

				body.ethnic-news-target .ethnic-news-card__meta-line {
					font-size: 14px;
				}

				body.ethnic-news-target .ethnic-news-archive-scope .portfolio-item .image-inner {
					height: auto !important;
				}

				body.ethnic-news-target--news .ethnic-news-popular {
					margin-top: 22px;
					padding: 44px 0 42px;
				}

				body.ethnic-news-target--news .ethnic-news-popular__inner {
					padding: 0 20px;
				}

				body.ethnic-news-target--news .ethnic-news-popular__title {
					font-size: 42px;
				}

				body.ethnic-news-target--news .ethnic-news-popular__copy {
					font-size: 17px;
					line-height: 1.55;
				}

				body.ethnic-news-target--news .ethnic-news-popular__link {
					gap: 12px;
					font-size: 20px;
				}

				body.ethnic-news-target--news .ethnic-news-popular__link-icon {
					width: 44px;
					height: 44px;
					font-size: 18px;
				}

				body.ethnic-news-target--news .ethnic-news-popular__rail {
					gap: 14px;
					padding-right: 54px;
				}

				body.ethnic-news-target--news .ethnic-news-popular-card {
					flex-basis: min(84vw, 340px);
					min-height: 500px;
					border-radius: 12px;
				}

				body.ethnic-news-target--news .ethnic-news-popular-card__media {
					height: 194px;
				}

				body.ethnic-news-target--news .ethnic-news-popular-card__body {
					padding: 20px;
				}

				body.ethnic-news-target--news .ethnic-news-popular-card__meta {
					align-items: flex-start;
					flex-direction: column;
					gap: 10px;
					margin-bottom: 18px;
				}

				body.ethnic-news-target--news .ethnic-news-popular-card__title {
					font-size: 26px;
				}

				body.ethnic-news-target--news .ethnic-news-popular-card__excerpt {
					font-size: 15px;
				}
			}
		</style>
		<?php
	}
	add_action( 'wp_head', 'ethnic_news_archive_enhancer_styles', 99 );
}

if ( ! function_exists( 'ethnic_news_archive_enhancer_script' ) ) {
	function ethnic_news_archive_enhancer_script() {
		if ( ! ethnic_news_archive_enhancer_is_target() ) {
			return;
		}

		$payload = ethnic_news_archive_enhancer_post_payload();
		$heading = ethnic_news_archive_enhancer_archive_heading_payload();
		?>
			<script id="ethnic-news-archive-enhancer-script">
				window.ethnicNewsArchiveData = <?php echo wp_json_encode( $payload ); ?>;
				window.ethnicNewsArchiveHeading = <?php echo wp_json_encode( $heading ); ?>;
				window.ethnicNewsArchiveIndexUrl = <?php echo wp_json_encode( get_permalink( 575 ) ); ?>;

			(function () {
				var initArchive = function () {
					var body = document.body;
					var isNewsPage = body.classList.contains('ethnic-news-target--news');
					var archiveGrid = isNewsPage
						? null
						: document.querySelector('body.ethnic-news-target--archive .portfolio.portfolio-grid.extended-portfolio-grid.news-grid.category-grid');
					var archive = isNewsPage
						? document.querySelector('#style-08e1311')
						: (archiveGrid ? archiveGrid.closest('.portfolio-preloader-wrapper') || archiveGrid : null);

					if (!archive || archive.dataset.ethnicNewsEnhanced === 'true') {
						return;
					}

					archive.classList.add('ethnic-news-archive-scope');

					var portfolioSet = archive.querySelector('.portfolio-set');

					if (!portfolioSet) {
						return;
					}

					var cards = [];
					var refreshCards = function () {
						portfolioSet = archive.querySelector('.portfolio-set');
						cards = portfolioSet
							? Array.from(portfolioSet.children).filter(function (card) {
								return card.classList.contains('portfolio-item') && card.querySelector('.wrap');
							})
							: [];

						return cards;
					};

					if (!refreshCards().length) {
						return;
					}

					var archiveData = window.ethnicNewsArchiveData || {};
					var postMap = archiveData.posts || {};
					var placeholderLogoUrl = archiveData.placeholderLogoUrl || '';
					var placeholderLogoSrcset = archiveData.placeholderLogoSrcset || '';
					var headingData = window.ethnicNewsArchiveHeading || {};
					var headingTitle = (headingData.title || '').trim();
					var termsFromCards = new Map();

					var extractPostId = function (card) {
						var match = card.className.match(/post-(\d+)/);
						return match ? match[1] : '';
					};

						var buildCard = function (card) {
							var postId = extractPostId(card);
							var existingContent = card.querySelector('.ethnic-news-card__content');

							if (card.dataset.ethnicNewsCard === 'true' && existingContent && card.dataset.ethnicNewsPostId === postId) {
								return;
							}

							if (existingContent) {
								existingContent.remove();
							}

							card.style.setProperty('padding', '0', 'important');
							card.style.setProperty('box-sizing', 'border-box', 'important');

							var postData = postMap[postId] || {};
							var wrap = card.querySelector('.wrap');

						if (!wrap) {
							return;
						}

						[wrap.querySelector('.image'), wrap.querySelector('.image-inner')].forEach(function (mediaNode) {
							if (!mediaNode) {
								return;
							}

							mediaNode.style.setProperty('height', 'auto', 'important');
							mediaNode.style.setProperty('min-height', '0', 'important');
							mediaNode.style.setProperty('aspect-ratio', 'auto', 'important');
						});

						var staticCaption = Array.from(wrap.children).find(function (child) {
							return child.classList && child.classList.contains('caption');
						}) || null;
						var titleLink = staticCaption ? staticCaption.querySelector('.title a') : null;
						var fallbackExcerpt = wrap.querySelector('.overlay .description .text-body, .overlay .description');
						var termSlugs = Array.isArray(postData.termSlugs) ? postData.termSlugs : [];
						var terms = Array.isArray(postData.terms) ? postData.terms : [];
						var primaryLabel = postData.primaryTermLabel || '';
						var excerpt = postData.excerpt || '';
						var author = postData.author || '';
						var title = postData.title || (titleLink ? titleLink.textContent.trim() : '');
						var url = postData.url || (titleLink ? titleLink.getAttribute('href') : '#');
						var imageUrl = postData.imageUrl || '';
						var imageSrcset = postData.imageSrcset || '';
						var imageSizes = postData.imageSizes || '100vw';
						var imageInner = wrap.querySelector('.image-inner');

						if (imageUrl) {
							card.classList.remove('ethnic-news-card--placeholder-image');

							if (imageInner) {
								var existingPlaceholder = imageInner.querySelector('.ethnic-news-card__placeholder');

								if (existingPlaceholder) {
									existingPlaceholder.remove();
								}
							}

							var cardImage = wrap.querySelector('.image-inner .post-featured-content img');

							if (cardImage) {
								var picture = cardImage.closest('picture');

								if (picture) {
									picture.querySelectorAll('source').forEach(function (source) {
										source.removeAttribute('srcset');
										source.removeAttribute('data-srcset');
									});
								}

								cardImage.removeAttribute('data-src');
								cardImage.removeAttribute('data-srcset');
								cardImage.src = imageUrl;

								if (imageSrcset) {
									cardImage.srcset = imageSrcset;
									cardImage.sizes = imageSizes;
								} else {
									cardImage.removeAttribute('srcset');
									cardImage.removeAttribute('sizes');
								}
							}
						} else if (imageInner && placeholderLogoUrl) {
							card.classList.add('ethnic-news-card--placeholder-image');

							[wrap.querySelector('.image'), imageInner].forEach(function (mediaNode) {
								if (!mediaNode) {
									return;
								}

								mediaNode.style.setProperty('height', 'auto', 'important');
								mediaNode.style.setProperty('aspect-ratio', '16 / 9', 'important');
							});

							var featuredContent = imageInner.querySelector('.post-featured-content');

							if (featuredContent) {
								featuredContent.remove();
							}

							if (!imageInner.querySelector('.ethnic-news-card__placeholder')) {
								var placeholder = document.createElement('div');
								placeholder.className = 'ethnic-news-card__placeholder';

								var placeholderLogo = document.createElement('img');
								placeholderLogo.className = 'ethnic-news-card__placeholder-logo';
								placeholderLogo.src = placeholderLogoUrl;
								if (placeholderLogoSrcset) {
									placeholderLogo.srcset = placeholderLogoSrcset;
								}
								placeholderLogo.alt = 'Ethnic Infotech';
								placeholderLogo.loading = 'lazy';
								placeholderLogo.decoding = 'async';

								placeholder.appendChild(placeholderLogo);
								imageInner.appendChild(placeholder);
							}
						}

						if (!excerpt && fallbackExcerpt) {
							excerpt = fallbackExcerpt.textContent.replace(/\s+/g, ' ').trim();
						}

						if (!primaryLabel) {
							var additionalMeta = staticCaption ? staticCaption.querySelector('.additional-meta') : null;
							primaryLabel = additionalMeta ? additionalMeta.textContent.trim() : 'Insight';
						}

						card.dataset.newsTerms = termSlugs.join(' ');

						terms.forEach(function (term) {
							if (!term || !term.slug || !term.name) {
								return;
							}

							if (!termsFromCards.has(term.slug)) {
								termsFromCards.set(term.slug, { slug: term.slug, name: term.name, taxonomy: term.taxonomy || '' });
							}
						});

						var content = document.createElement('div');
						content.className = 'ethnic-news-card__content';

						var term = document.createElement('div');
						term.className = 'ethnic-news-card__term';
						term.textContent = primaryLabel || 'Insight';

						var heading = document.createElement('h3');
						heading.className = 'ethnic-news-card__title';

						var link = document.createElement('a');
						link.className = 'ethnic-news-card__title-link';
						link.href = url || '#';
						link.textContent = title;
						heading.appendChild(link);

						var rule = document.createElement('div');
						rule.className = 'ethnic-news-card__rule';

						var footer = document.createElement('div');
						footer.className = 'ethnic-news-card__footer';

						var date = document.createElement('div');
						date.className = 'ethnic-news-card__date';
						date.innerHTML =
							'<span class="ethnic-news-card__date-day">' + (postData.day || '') + '</span>' +
							'<span class="ethnic-news-card__date-month">' + (postData.month || '') + '</span>' +
							'<span class="ethnic-news-card__date-year">' + (postData.year || '') + '</span>';

						var meta = document.createElement('div');
						meta.className = 'ethnic-news-card__meta';

						var readTime = document.createElement('div');
						readTime.className = 'ethnic-news-card__meta-line';
						readTime.textContent = postData.readTimeLabel || '1 Min Read';

						meta.appendChild(readTime);
						footer.appendChild(date);
						footer.appendChild(meta);

						content.appendChild(term);
						content.appendChild(heading);
						content.appendChild(rule);
						if (excerpt) {
							var excerptNode = document.createElement('p');
							excerptNode.className = 'ethnic-news-card__excerpt';
							excerptNode.textContent = excerpt;
							content.appendChild(excerptNode);
						}
						content.appendChild(footer);
						wrap.appendChild(content);

						card.dataset.ethnicNewsCard = 'true';
						card.dataset.ethnicNewsPostId = postId;
					};

					var enhanceCards = function () {
						refreshCards().forEach(buildCard);
					};

					enhanceCards();

						var buildArchiveHeading = function () {
							if (!headingTitle) {
								return null;
							}

						var heading = document.createElement('div');
						heading.className = 'ethnic-news-archive-heading';

						if (headingData.eyebrow) {
							var eyebrow = document.createElement('div');
							eyebrow.className = 'ethnic-news-archive-heading__eyebrow';
							eyebrow.textContent = headingData.eyebrow;
							heading.appendChild(eyebrow);
						}

						var titleNode = document.createElement('h1');
						titleNode.className = 'ethnic-news-archive-heading__title';
						titleNode.textContent = headingTitle;
						heading.appendChild(titleNode);

							return heading;
						};

						var buildPopularBlogs = function () {
							if (!isNewsPage || archive.querySelector('.ethnic-news-popular')) {
								return null;
							}

							var popularPosts = Object.keys(postMap).map(function (postId) {
								return postMap[postId];
							}).filter(function (post) {
								return post && post.title && post.url;
							});

							popularPosts.sort(function (left, right) {
								var leftLikes = Number(left.likesCount || 0);
								var rightLikes = Number(right.likesCount || 0);

								if (leftLikes !== rightLikes) {
									return rightLikes - leftLikes;
								}

								return Number(right.timestamp || 0) - Number(left.timestamp || 0);
							});

							popularPosts = popularPosts.slice(0, 6);

							if (!popularPosts.length) {
								return null;
							}

							var normalizeReadTime = function (label) {
								return String(label || '1 Min Read')
									.replace(/\s+To\s+Read$/i, ' Read')
									.replace(/\bMins\s+Read\b/i, 'Min Read');
							};

							var enablePopularRailDrag = function (railNode) {
								if (!railNode) {
									return;
								}

								var isDragging = false;
								var didMove = false;
								var suppressClick = false;
								var pointerId = null;
								var startX = 0;
								var startScrollLeft = 0;

								var finishDrag = function () {
									if (!isDragging) {
										return;
									}

									isDragging = false;
									railNode.classList.remove('is-dragging');

									if (didMove) {
										suppressClick = true;
										window.setTimeout(function () {
											suppressClick = false;
										}, 80);
									}

									didMove = false;
									pointerId = null;
								};

								railNode.addEventListener('pointerdown', function (event) {
									if (event.button !== undefined && event.button !== 0) {
										return;
									}

									if (railNode.scrollWidth <= railNode.clientWidth + 4) {
										return;
									}

									isDragging = true;
									didMove = false;
									pointerId = event.pointerId;
									startX = event.clientX;
									startScrollLeft = railNode.scrollLeft;
									railNode.classList.add('is-dragging');

									if (typeof railNode.setPointerCapture === 'function') {
										railNode.setPointerCapture(pointerId);
									}
								});

								railNode.addEventListener('pointermove', function (event) {
									if (!isDragging) {
										return;
									}

									var deltaX = event.clientX - startX;

									if (Math.abs(deltaX) > 4) {
										didMove = true;
									}

									if (didMove) {
										event.preventDefault();
										railNode.scrollLeft = startScrollLeft - deltaX;
									}
								});

								railNode.addEventListener('pointerup', function () {
									if (pointerId !== null && typeof railNode.releasePointerCapture === 'function') {
										try {
											railNode.releasePointerCapture(pointerId);
										} catch (error) {}
									}

									finishDrag();
								});

								railNode.addEventListener('pointercancel', finishDrag);

								railNode.addEventListener('click', function (event) {
									if (!suppressClick) {
										return;
									}

									event.preventDefault();
									event.stopPropagation();
								}, true);
							};

							var section = document.createElement('section');
							section.className = 'ethnic-news-popular';
							section.setAttribute('aria-labelledby', 'ethnic-news-popular-title');

							var inner = document.createElement('div');
							inner.className = 'ethnic-news-popular__inner';

							var intro = document.createElement('div');
							intro.className = 'ethnic-news-popular__intro';

							var title = document.createElement('h2');
							title.id = 'ethnic-news-popular-title';
							title.className = 'ethnic-news-popular__title';
							title.appendChild(document.createTextNode('Popular'));
							title.appendChild(document.createElement('br'));
							title.appendChild(document.createTextNode('Blogs'));

							var rule = document.createElement('div');
							rule.className = 'ethnic-news-popular__rule';

							var copy = document.createElement('p');
							copy.className = 'ethnic-news-popular__copy';
							copy.textContent = 'Reader-favorite guides on Magento, Adobe Commerce, Shopify, and practical ecommerce delivery decisions.';

							intro.appendChild(title);
							intro.appendChild(rule);
							intro.appendChild(copy);

							var content = document.createElement('div');
							content.className = 'ethnic-news-popular__content';

							var rail = document.createElement('div');
							rail.className = 'ethnic-news-popular__rail';
							rail.setAttribute('aria-label', 'Popular blog posts');

							popularPosts.forEach(function (post) {
								var card = document.createElement('a');
								card.className = 'ethnic-news-popular-card';
								card.href = post.url;
								card.draggable = false;
								var hasPopularImage = Boolean(post.imageUrl);

								var media = document.createElement('div');
								media.className = 'ethnic-news-popular-card__media';

								if (hasPopularImage) {
									var image = document.createElement('img');
									image.className = 'ethnic-news-popular-card__image';
									image.src = post.imageUrl;
									if (post.imageSrcset) {
										image.srcset = post.imageSrcset;
										image.sizes = post.imageSizes || '(max-width: 767px) 84vw, 460px';
									}
									image.alt = '';
									image.loading = 'lazy';
									image.decoding = 'async';
									image.draggable = false;
									media.appendChild(image);
								} else if (placeholderLogoUrl) {
									card.classList.add('ethnic-news-popular-card--placeholder-image');
									var popularPlaceholder = document.createElement('div');
									popularPlaceholder.className = 'ethnic-news-popular-card__placeholder';

									var popularLogo = document.createElement('img');
									popularLogo.className = 'ethnic-news-popular-card__placeholder-logo';
									popularLogo.src = placeholderLogoUrl;
									if (placeholderLogoSrcset) {
										popularLogo.srcset = placeholderLogoSrcset;
									}
									popularLogo.alt = 'Ethnic Infotech';
									popularLogo.loading = 'lazy';
									popularLogo.decoding = 'async';

									popularPlaceholder.appendChild(popularLogo);
									media.appendChild(popularPlaceholder);
								}

								if (hasPopularImage) {
									var badge = document.createElement('span');
									badge.className = 'ethnic-news-popular-card__badge';
									badge.textContent = 'Popular Blog';
									media.appendChild(badge);
								}

								var body = document.createElement('div');
								body.className = 'ethnic-news-popular-card__body';

								var meta = document.createElement('div');
								meta.className = 'ethnic-news-popular-card__meta';

								var term = document.createElement('span');
								term.className = 'ethnic-news-popular-card__term';
								term.textContent = post.primaryTermLabel || 'Insight';

								var date = document.createElement('span');
								date.className = 'ethnic-news-popular-card__date';
								date.textContent = post.dateLabel || [post.day, post.month, post.year].filter(Boolean).join(' ');

								meta.appendChild(term);
								meta.appendChild(date);

								var cardTitle = document.createElement('h3');
								cardTitle.className = 'ethnic-news-popular-card__title';
								cardTitle.textContent = post.title;

								var cardRule = document.createElement('div');
								cardRule.className = 'ethnic-news-popular-card__rule';

								var excerpt = document.createElement('p');
								excerpt.className = 'ethnic-news-popular-card__excerpt';
								excerpt.textContent = post.excerpt || '';

								var readTime = document.createElement('div');
								readTime.className = 'ethnic-news-popular-card__read-time';
								readTime.textContent = normalizeReadTime(post.readTimeLabel);

								body.appendChild(meta);
								body.appendChild(cardTitle);
								body.appendChild(cardRule);
								body.appendChild(excerpt);
								body.appendChild(readTime);

								card.appendChild(media);
								card.appendChild(body);
								rail.appendChild(card);
							});

							enablePopularRailDrag(rail);

							content.appendChild(rail);
							inner.appendChild(intro);
							inner.appendChild(content);
							section.appendChild(inner);

							return section;
						};

							var filterTerms = [];
							var orderedTerms = Array.isArray(archiveData.terms) ? archiveData.terms : [];

					orderedTerms.forEach(function (term) {
						if (term && term.slug && termsFromCards.has(term.slug)) {
							filterTerms.push({
								slug: term.slug,
								name: term.name || termsFromCards.get(term.slug).name,
								taxonomy: term.taxonomy || termsFromCards.get(term.slug).taxonomy || ''
							});
						}
					});

					if (!filterTerms.length) {
						termsFromCards.forEach(function (term) {
							filterTerms.push(term);
						});
					}

					filterTerms.sort(function (left, right) {
						var leftRank = left && left.taxonomy === 'category' ? 0 : 1;
						var rightRank = right && right.taxonomy === 'category' ? 0 : 1;

						if (leftRank !== rightRank) {
							return leftRank - rightRank;
						}

						return (left.name || '').localeCompare(right.name || '');
					});

						var wrapper = document.createElement('div');
						wrapper.className = 'ethnic-news-archive';
						var parent = archive.parentNode;

						if (headingTitle) {
							var newsHeading = buildArchiveHeading();

						if (newsHeading) {
							if (isNewsPage) {
								var topbar = document.createElement('div');
								topbar.className = 'ethnic-news-archive__topbar';
								topbar.appendChild(newsHeading);

								var search = document.createElement('div');
								search.className = 'ethnic-news-search';
								search.innerHTML =
									'<label class="screen-reader-text" for="ethnic-news-search-input">Search blogs</label>' +
									'<div class="ethnic-news-search__field">' +
									'<span class="ethnic-news-search__icon" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 50 50" focusable="false"><path d="M 21 3 C 11.621094 3 4 10.621094 4 20 C 4 29.378906 11.621094 37 21 37 C 24.710938 37 28.140625 35.804688 30.9375 33.78125 L 44.09375 46.90625 L 46.90625 44.09375 L 33.90625 31.0625 C 36.460938 28.085938 38 24.222656 38 20 C 38 10.621094 30.378906 3 21 3 Z M 21 5 C 29.296875 5 36 11.703125 36 20 C 36 28.296875 29.296875 35 21 35 C 12.703125 35 6 28.296875 6 20 C 6 11.703125 12.703125 5 21 5 Z"></path></svg></span>' +
									'<input id="ethnic-news-search-input" class="ethnic-news-search__input" type="search" autocomplete="off" placeholder="Search blog title or description">' +
									'<button type="button" class="ethnic-news-search__clear" aria-label="Clear blog search">×</button>' +
								'</div>';

								topbar.appendChild(search);
								wrapper.appendChild(topbar);
							} else {
								wrapper.appendChild(newsHeading);
							}
							}
						}

						if (!isNewsPage && headingData.type === 'author') {
							var authorProfile = document.createElement('div');
							authorProfile.className = 'ethnic-news-author-profile';

							if (headingData.avatar) {
								var avatar = document.createElement('img');
								avatar.className = 'ethnic-news-author-profile__avatar';
								avatar.src = headingData.avatar;
								avatar.alt = headingTitle || 'Author';
								authorProfile.appendChild(avatar);
							}

							var authorCopy = document.createElement('div');

							if (headingData.role) {
								var role = document.createElement('div');
								role.className = 'ethnic-news-author-profile__role';
								role.textContent = headingData.role;
								authorCopy.appendChild(role);
							}

							if (headingData.subtitle) {
								var summary = document.createElement('p');
								summary.className = 'ethnic-news-author-profile__summary';
								summary.textContent = headingData.subtitle;
								authorCopy.appendChild(summary);
							}

							var meta = document.createElement('div');
							meta.className = 'ethnic-news-author-profile__meta';

							if (headingData.postCountLabel) {
								var postCount = document.createElement('span');
								postCount.className = 'ethnic-news-author-profile__badge';
								postCount.textContent = headingData.postCountLabel;
								meta.appendChild(postCount);
							}

							if (Array.isArray(headingData.topics)) {
								headingData.topics.forEach(function (topic) {
									if (!topic) {
										return;
									}

									var topicBadge = document.createElement('span');
									topicBadge.className = 'ethnic-news-author-profile__badge';
									topicBadge.textContent = topic;
									meta.appendChild(topicBadge);
								});
							}

							if (meta.children.length) {
								authorCopy.appendChild(meta);
							}

							authorProfile.appendChild(authorCopy);
							wrapper.appendChild(authorProfile);
						}

						var filtersShell = document.createElement('div');
						filtersShell.className = 'ethnic-news-archive__filters-shell';

						var filtersHint = document.createElement('div');
						filtersHint.className = 'ethnic-news-archive__scroll-hint';
						filtersHint.innerHTML = '<button type="button" class="ethnic-news-archive__scroll-button" data-direction="-1" aria-label="Scroll filters left"><span aria-hidden="true" class="ethnic-news-archive__scroll-hint-arrow ethnic-news-archive__scroll-hint-arrow--left">←</span></button><button type="button" class="ethnic-news-archive__scroll-button" data-direction="1" aria-label="Scroll filters right"><span aria-hidden="true" class="ethnic-news-archive__scroll-hint-arrow ethnic-news-archive__scroll-hint-arrow--right">→</span></button>';
						var scrollLeftButton = filtersHint.querySelector('[data-direction="-1"]');
						var scrollRightButton = filtersHint.querySelector('[data-direction="1"]');

						var filters = document.createElement('div');
						filters.className = 'ethnic-news-archive__filters';
						filters.setAttribute('aria-label', 'Filter articles by topic');

						var filtersTrack = document.createElement('div');
						filtersTrack.className = 'ethnic-news-archive__filters-track';
						filters.appendChild(filtersTrack);

					var makeFilter = function (slug, label, active) {
						var button = document.createElement('button');
						button.type = 'button';
						button.className = 'ethnic-news-archive__filter' + (active ? ' is-active' : '');
						button.dataset.filter = slug;
						button.textContent = label;
						return button;
					};

					filtersTrack.appendChild(makeFilter('all', 'All', true));

					filterTerms.forEach(function (term) {
						filtersTrack.appendChild(makeFilter(term.slug, term.name, false));
					});

					var activeFilterSlug = 'all';
					var searchRoot = wrapper.querySelector('.ethnic-news-search');
					var searchInput = searchRoot ? searchRoot.querySelector('.ethnic-news-search__input') : null;
					var searchClear = searchRoot ? searchRoot.querySelector('.ethnic-news-search__clear') : null;
					var emptyState = document.createElement('div');
					var activeSearchQuery = '';
					var searchablePosts = Object.keys(postMap).map(function (postId) {
						var post = postMap[postId] || {};
						var title = String(post.title || '');
						var excerpt = String(post.excerpt || '');

						post.searchText = (title + ' ' + excerpt).toLowerCase();
						return post;
					}).filter(function (post) {
						return post && post.id && post.title && post.url;
					});

					emptyState.className = 'ethnic-news-archive__empty';
					emptyState.setAttribute('aria-live', 'polite');
					emptyState.textContent = 'No blogs matched your search. Try a different title or description keyword.';

					var ensureCardForPost = function (post) {
						if (!post || !post.id || !portfolioSet) {
							return null;
						}

						var postId = String(post.id);
						var existing = portfolioSet.querySelector('.portfolio-item.post-' + postId);

						if (existing) {
							buildCard(existing);
							return existing;
						}

						var item = document.createElement('div');
						item.className = 'portfolio-item post-' + postId;
						item.dataset.ethnicSearchGenerated = 'true';

						var wrap = document.createElement('div');
						wrap.className = 'wrap clearfix';

						var image = document.createElement('div');
						image.className = 'image';

						var imageInner = document.createElement('div');
						imageInner.className = 'image-inner';

						if (post.imageUrl) {
							var featured = document.createElement('div');
							featured.className = 'post-featured-content';

							var link = document.createElement('a');
							link.href = post.url;

							var img = document.createElement('img');
							img.src = post.imageUrl;
							if (post.imageSrcset) {
								img.srcset = post.imageSrcset;
								img.sizes = post.imageSizes || '100vw';
							}
							img.alt = '';
							img.loading = 'lazy';
							img.decoding = 'async';

							link.appendChild(img);
							featured.appendChild(link);
							imageInner.appendChild(featured);
						}

						image.appendChild(imageInner);
						wrap.appendChild(image);
						item.appendChild(wrap);
						portfolioSet.appendChild(item);
						buildCard(item);

						return item;
					};

					var normalizeSearchQuery = function () {
						return searchInput ? searchInput.value.replace(/\s+/g, ' ').trim() : '';
					};

					var getActiveSearchResults = function () {
						if (activeSearchQuery.length <= 3) {
							return [];
						}

						var query = activeSearchQuery.toLowerCase();

						return searchablePosts.filter(function (post) {
							return post.searchText.indexOf(query) >= 0;
						});
					};

					var applyArchiveControls = function () {
						enhanceCards();
						activeSearchQuery = normalizeSearchQuery();
						var isSearchActive = activeSearchQuery.length > 3;
						var searchResults = getActiveSearchResults();
						var searchResultIds = new Set(searchResults.map(function (post) {
							return String(post.id);
						}));

						if (searchRoot) {
							searchRoot.classList.toggle('has-value', activeSearchQuery.length > 0);
						}

						if (isSearchActive) {
							searchResults.forEach(ensureCardForPost);
						}

						refreshCards();

						if (!isSearchActive) {
							cards.forEach(function (card) {
								if (card.dataset.ethnicSearchGenerated === 'true') {
									card.remove();
								}
							});

							refreshCards();
						}

						cards.forEach(function (card) {
							var postId = extractPostId(card);
							var cardTerms = (card.dataset.newsTerms || '').split(/\s+/).filter(Boolean);
							var matchesFilter = activeFilterSlug === 'all' || cardTerms.indexOf(activeFilterSlug) >= 0;
							var matchesSearch = !isSearchActive || searchResultIds.has(postId);
							var matches = matchesFilter && matchesSearch;

							card.classList.toggle('is-filtered-out', !matches);
						});

						filtersTrack.querySelectorAll('.ethnic-news-archive__filter').forEach(function (button) {
							button.classList.toggle('is-active', button.dataset.filter === activeFilterSlug);
						});

						archive.classList.toggle('is-searching', isSearchActive);
						emptyState.classList.toggle('is-visible', isSearchActive && 0 === searchResults.length);
					};

					var applyFilter = function (slug) {
						activeFilterSlug = slug || 'all';
						applyArchiveControls();
					};

					var syncFilterRailState = function () {
						var isScrollable = filters.scrollWidth > filters.clientWidth + 4;
						var maxScroll = Math.max(0, filters.scrollWidth - filters.clientWidth);
						filters.classList.toggle('is-scrollable', isScrollable);
						filtersShell.classList.toggle('is-scrollable', isScrollable);

						if (scrollLeftButton) {
							scrollLeftButton.disabled = !isScrollable || filters.scrollLeft <= 2;
						}

						if (scrollRightButton) {
							scrollRightButton.disabled = !isScrollable || filters.scrollLeft >= maxScroll - 2;
						}

						if (!isScrollable || filters.dataset.ethnicScrollHintShown === 'true') {
							return;
						}

						if (window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
							filters.dataset.ethnicScrollHintShown = 'true';
							return;
						}

						filters.dataset.ethnicScrollHintShown = 'true';
						window.setTimeout(function () {
							filters.classList.add('is-bouncing');

							window.setTimeout(function () {
								filters.classList.remove('is-bouncing');
							}, 560);
						}, 180);
					};

					var scrollFilterRail = function (direction) {
						var distance = Math.max(180, Math.round(filters.clientWidth * 0.55));

						filters.scrollBy({
							left: distance * direction,
							behavior: 'smooth'
						});
					};

					var paginationPageKey = archive.id ? archive.id.replace(/^style-/, '') + '-page' : '08e1311-page';

					var getCurrentPaginationPage = function () {
						var params = new URLSearchParams(window.location.search);
						var pageFromUrl = Number(params.get(paginationPageKey) || 1);
						var currentLink = archive.querySelector('.portfolio-navigator.gem-pagination .pages a.current');
						var pageFromDom = currentLink ? Number(currentLink.dataset.page || currentLink.textContent || 1) : 1;
						var page = Math.max(1, pageFromUrl || pageFromDom || 1);

						return page;
					};

					var buildPaginationUrl = function (pageNumber) {
						var url = new URL(window.location.href);
						var page = Math.max(1, Number(pageNumber || 1));

						if (page <= 1) {
							url.searchParams.delete(paginationPageKey);
						} else {
							url.searchParams.set(paginationPageKey, String(page));
						}

						return url.toString();
					};

					var getPaginationTargetPage = function (link) {
						if (!link) {
							return 0;
						}

						if (link.dataset.page) {
							return Number(link.dataset.page || 0);
						}

						if (link.classList.contains('next')) {
							return getCurrentPaginationPage() + 1;
						}

						if (link.classList.contains('prev')) {
							return Math.max(1, getCurrentPaginationPage() - 1);
						}

						return 0;
					};

					var syncPaginationLinks = function () {
						archive.querySelectorAll('.portfolio-navigator.gem-pagination a').forEach(function (link) {
							var targetPage = getPaginationTargetPage(link);

							if (!targetPage) {
								return;
							}

							link.href = buildPaginationUrl(targetPage);
						});
					};

					filtersHint.addEventListener('click', function (event) {
						var button = event.target.closest('.ethnic-news-archive__scroll-button');

						if (!button || button.disabled) {
							return;
						}

						scrollFilterRail(Number(button.dataset.direction || 1));
					});

					filters.addEventListener('click', function (event) {
						var button = event.target.closest('.ethnic-news-archive__filter');

						if (!button) {
							return;
						}

						applyFilter(button.dataset.filter || 'all');
						button.scrollIntoView({
							behavior: 'smooth',
							block: 'nearest',
							inline: 'center'
						});
						window.setTimeout(syncFilterRailState, 260);
					});

					filters.addEventListener('scroll', syncFilterRailState, { passive: true });

					if (searchInput) {
						searchInput.addEventListener('input', function () {
							applyArchiveControls();
						});

						searchInput.addEventListener('focus', function () {
							applyArchiveControls();
						});

						searchInput.addEventListener('keydown', function (event) {
							if ('Escape' !== event.key) {
								return;
							}

							searchInput.value = '';
							applyArchiveControls();
						});
					}

					if (searchClear) {
						searchClear.addEventListener('click', function () {
							if (!searchInput) {
								return;
							}

							searchInput.value = '';
							searchInput.focus();
							applyArchiveControls();
						});
					}

					var refreshTimer = null;
					var scheduleArchiveRefresh = function (delay) {
						if (refreshTimer) {
							window.clearTimeout(refreshTimer);
						}

						refreshTimer = window.setTimeout(function () {
							refreshTimer = null;
							applyFilter(activeFilterSlug);
							syncPaginationLinks();
							syncFilterRailState();
						}, typeof delay === 'number' ? delay : 80);
					};

					if (window.MutationObserver) {
						var archiveObserver = new MutationObserver(function (mutations) {
							var shouldRefresh = mutations.some(function (mutation) {
								if (mutation.type !== 'childList') {
									return false;
								}

								var changedNodes = Array.from(mutation.addedNodes).concat(Array.from(mutation.removedNodes));

								return changedNodes.some(function (node) {
									if (!node || node.nodeType !== 1) {
										return false;
									}

									return (
										(node.classList && (node.classList.contains('portfolio-item') || node.classList.contains('portfolio-set'))) ||
										(typeof node.querySelector === 'function' && Boolean(node.querySelector('.portfolio-item, .portfolio-set')))
									);
								});
							});

							if (shouldRefresh) {
								scheduleArchiveRefresh();
							}
						});

						archiveObserver.observe(archive, {
							childList: true,
							subtree: true
						});
					}

					archive.addEventListener('click', function (event) {
						var paginationLink = event.target.closest('.portfolio-navigator a, .gem-pagination a');

						if (!paginationLink) {
							return;
						}

						var targetPage = getPaginationTargetPage(paginationLink);

						if (!targetPage || paginationLink.classList.contains('current')) {
							event.preventDefault();
							event.stopImmediatePropagation();
							return;
						}

						event.preventDefault();
						event.stopImmediatePropagation();
						window.location.assign(buildPaginationUrl(targetPage));
					}, true);

							filtersShell.appendChild(filters);
							filtersShell.appendChild(filtersHint);
							wrapper.appendChild(filtersShell);
							wrapper.appendChild(emptyState);
							parent.insertBefore(wrapper, archive);

							var popularBlogs = buildPopularBlogs();
							var pagination = archive.querySelector('.portfolio-navigator.gem-pagination');

							if (popularBlogs) {
								if (pagination && pagination.parentNode) {
									pagination.parentNode.insertBefore(popularBlogs, pagination.nextSibling);
								} else {
									archive.appendChild(popularBlogs);
								}
							}

							applyFilter('all');
							syncPaginationLinks();
							[200, 800, 1600].forEach(function (delay) {
								window.setTimeout(syncPaginationLinks, delay);
							});
							syncFilterRailState();

						var resizeTimer = null;
						window.addEventListener('resize', function () {
							if (resizeTimer) {
								window.clearTimeout(resizeTimer);
							}

							resizeTimer = window.setTimeout(syncFilterRailState, 120);
						});

						archive.dataset.ethnicNewsEnhanced = 'true';
				};

				if (document.readyState === 'loading') {
					document.addEventListener('DOMContentLoaded', initArchive);
				} else {
					initArchive();
				}
			})();
		</script>
		<?php
	}
	add_action( 'wp_footer', 'ethnic_news_archive_enhancer_script', 99 );
}