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/mu-plugins/ethnic-shared-case-study-showcase.php
<?php
/**
 * Plugin Name: Ethnic Shared Case Study Showcase
 * Description: Shared case study slider component used across service pages.
 * Version: 1.0.0
 */

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

if ( ! function_exists( 'ethnic_shared_case_study_showcase_enqueue_assets' ) ) {
	function ethnic_shared_case_study_showcase_enqueue_assets() {
		if ( is_admin() ) {
			return;
		}

		$css_relative_path = '/css/ethnic-shared-case-study-showcase.css';
		$js_relative_path  = '/js/ethnic-shared-case-study-showcase.js';
		$css_path          = defined( 'THEGEM_THEME_PATH' ) ? THEGEM_THEME_PATH . $css_relative_path : '';
		$js_path           = defined( 'THEGEM_THEME_PATH' ) ? THEGEM_THEME_PATH . $js_relative_path : '';

		if ( defined( 'THEGEM_THEME_URI' ) ) {
			wp_enqueue_style(
				'ethnic-shared-case-study-showcase',
				THEGEM_THEME_URI . $css_relative_path,
				array(),
				$css_path && file_exists( $css_path ) ? filemtime( $css_path ) : null
			);

			wp_enqueue_script(
				'ethnic-shared-case-study-showcase',
				THEGEM_THEME_URI . $js_relative_path,
				array(),
				$js_path && file_exists( $js_path ) ? filemtime( $js_path ) : null,
				true
			);
		}
	}
	add_action( 'wp_enqueue_scripts', 'ethnic_shared_case_study_showcase_enqueue_assets', 36 );
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_works_url' ) ) {
	function ethnic_shared_case_study_showcase_works_url() {
		return function_exists( 'ethnic_case_studies_archive_url' ) ? ethnic_case_studies_archive_url() : home_url( '/case-studies/' );
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_placeholder_image_url' ) ) {
	function ethnic_shared_case_study_showcase_placeholder_image_url() {
		return content_url( 'uploads/2026/03/placeholder-1-768x512.png' );
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_palette' ) ) {
	function ethnic_shared_case_study_showcase_palette() {
		return array( '#ff6b6b', '#0ea5a4', '#2f6bff', '#7c3aed', '#f59e0b', '#0f766e', '#1d4ed8' );
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_text' ) ) {
	function ethnic_shared_case_study_showcase_text( $text, $fallback = '' ) {
		$text = is_scalar( $text ) ? trim( wp_strip_all_tags( (string) $text ) ) : '';

		return '' !== $text ? $text : $fallback;
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_is_placeholder' ) ) {
	function ethnic_shared_case_study_showcase_is_placeholder( $text ) {
		$text = strtolower( ethnic_shared_case_study_showcase_text( $text ) );

		if ( '' === $text ) {
			return true;
		}

		$placeholder_tokens = array(
			'(demo)',
			'demo project',
			'demo portfolio',
			'lorem ipsum',
			'placeholder',
			'sample project',
		);

		foreach ( $placeholder_tokens as $token ) {
			if ( false !== strpos( $text, $token ) ) {
				return true;
			}
		}

		return false;
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_first_meta' ) ) {
	function ethnic_shared_case_study_showcase_first_meta( $post_id, $meta_keys ) {
		foreach ( (array) $meta_keys as $meta_key ) {
			$value = get_post_meta( $post_id, $meta_key, true );
			$value = ethnic_shared_case_study_showcase_text( $value );

			if ( '' !== $value && ! ethnic_shared_case_study_showcase_is_placeholder( $value ) ) {
				return $value;
			}
		}

		return '';
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_initials' ) ) {
	function ethnic_shared_case_study_showcase_initials( $title ) {
		$title    = ethnic_shared_case_study_showcase_text( $title, 'Case Study' );
		$segments = preg_split( '/[\s\-_&]+/u', $title );
		$initials = '';

		if ( is_array( $segments ) ) {
			foreach ( $segments as $segment ) {
				$segment = trim( (string) $segment );

				if ( '' === $segment ) {
					continue;
				}

				$letter = function_exists( 'mb_substr' ) ? mb_substr( $segment, 0, 1 ) : substr( $segment, 0, 1 );
				$letter = function_exists( 'mb_strtoupper' ) ? mb_strtoupper( $letter ) : strtoupper( $letter );

				$initials .= $letter;

				$length = function_exists( 'mb_strlen' ) ? mb_strlen( $initials ) : strlen( $initials );

				if ( $length >= 2 ) {
					break;
				}
			}
		}

		return '' !== $initials ? $initials : 'CS';
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_split_list' ) ) {
	function ethnic_shared_case_study_showcase_split_list( $text, $limit = 3 ) {
		$text = ethnic_shared_case_study_showcase_text( $text );

		if ( '' === $text || ethnic_shared_case_study_showcase_is_placeholder( $text ) ) {
			return array();
		}

		$values = preg_split( '/\s*[,;|]\s*/', $text );
		$values = is_array( $values ) ? $values : array();
		$values = array_values(
			array_filter(
				array_map( 'trim', $values ),
				static function ( $value ) {
					return '' !== $value;
				}
			)
		);

		return array_slice( array_unique( $values ), 0, max( 1, (int) $limit ) );
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_summary' ) ) {
	function ethnic_shared_case_study_showcase_summary( $text, $fallback = '' ) {
		$text = ethnic_shared_case_study_showcase_text( $text, $fallback );

		if ( '' === $text ) {
			$text = 'Selected example of digital delivery focused on clearer workflows, better user experience, and stronger business outcomes.';
		}

		return wp_trim_words( $text, 24, '…' );
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_detail' ) ) {
	function ethnic_shared_case_study_showcase_detail( $text, $fallback = '' ) {
		$text = ethnic_shared_case_study_showcase_text( $text, $fallback );

		if ( '' === $text || ethnic_shared_case_study_showcase_is_placeholder( $text ) ) {
			return '';
		}

		return wp_trim_words( $text, 28, '…' );
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_normalize_item' ) ) {
	function ethnic_shared_case_study_showcase_normalize_item( $item, $index = 0 ) {
		if ( ! is_array( $item ) ) {
			return array();
		}

		$title = isset( $item['title'] ) ? ethnic_shared_case_study_showcase_text( $item['title'] ) : '';

		if ( '' === $title || ethnic_shared_case_study_showcase_is_placeholder( $title ) ) {
			return array();
		}

		$industry  = isset( $item['industry'] ) ? ethnic_shared_case_study_showcase_text( $item['industry'], 'Case Study' ) : 'Case Study';
		$service   = isset( $item['service'] ) ? ethnic_shared_case_study_showcase_text( $item['service'] ) : '';
		$platform  = isset( $item['platform'] ) ? ethnic_shared_case_study_showcase_text( $item['platform'] ) : '';
		$summary   = isset( $item['summary'] ) ? ethnic_shared_case_study_showcase_summary( $item['summary'] ) : '';
		$url       = isset( $item['url'] ) && $item['url'] ? esc_url_raw( $item['url'] ) : ethnic_shared_case_study_showcase_works_url();
		$image     = isset( $item['image'] ) ? esc_url_raw( $item['image'] ) : '';
		$image_alt = isset( $item['image_alt'] ) ? ethnic_shared_case_study_showcase_text( $item['image_alt'], $title ) : $title;
		$palette   = ethnic_shared_case_study_showcase_palette();
		$accent    = isset( $item['accent'] ) ? ethnic_shared_case_study_showcase_text( $item['accent'] ) : $palette[ $index % count( $palette ) ];
		$position  = isset( $item['position'] ) ? ethnic_shared_case_study_showcase_text( $item['position'] ) : '50% 0%';
		$challenge = isset( $item['challenge'] ) ? ethnic_shared_case_study_showcase_detail( $item['challenge'] ) : '';
		$solution  = isset( $item['solution'] ) ? ethnic_shared_case_study_showcase_detail( $item['solution'] ) : '';
		$outcome   = isset( $item['outcome'] ) ? ethnic_shared_case_study_showcase_detail( $item['outcome'] ) : '';

		if ( '' === $summary ) {
			$summary = ethnic_shared_case_study_showcase_summary(
				$outcome,
				$challenge
			);
		}

		$technologies = array();

		if ( ! empty( $item['technologies'] ) && is_array( $item['technologies'] ) ) {
			$technologies = array_values(
				array_filter(
					array_map(
						static function ( $technology ) {
							return ethnic_shared_case_study_showcase_text( $technology );
						},
						$item['technologies']
					)
				)
			);
		}

		if ( empty( $technologies ) && isset( $item['services'] ) ) {
			$technologies = ethnic_shared_case_study_showcase_split_list( $item['services'] );
		}

		if ( empty( $technologies ) ) {
			$technologies = array_values(
				array_unique(
					array_filter(
						array(
							$platform,
							$industry,
							$service,
						)
					)
				)
			);
		}

		if ( empty( $technologies ) ) {
			$technologies = array_filter(
				array(
					$industry,
					'Project Delivery',
				)
			);
		}

		$technologies = array_slice( array_values( array_unique( $technologies ) ), 0, 3 );
		$service      = '' !== $service ? $service : ( isset( $technologies[0] ) ? $technologies[0] : $industry );
		$platform     = '' !== $platform ? $platform : ( isset( $technologies[1] ) ? $technologies[1] : $industry );
		$meta_items   = array_slice(
			array_values(
				array_unique(
					array_filter(
						array(
							$platform,
							$industry,
							$service,
						)
					)
				)
			),
			0,
			3
		);
		$insights     = array();

		foreach (
			array(
				'Challenge' => $challenge,
				'Solution'  => $solution,
				'Outcome'   => $outcome,
			) as $label => $copy
		) {
			if ( '' === $copy ) {
				continue;
			}

			$insights[] = array(
				'label' => $label,
				'copy'  => $copy,
			);
		}

		if ( empty( $insights ) ) {
			$insights[] = array(
				'label' => 'Overview',
				'copy'  => ethnic_shared_case_study_showcase_detail( $summary ),
			);
		}

		$visual_stats = array();
		$stat_keys    = array();

		foreach (
			array(
				array(
					'label' => 'Service',
					'value' => $service,
				),
				array(
					'label' => 'Platform',
					'value' => $platform,
				),
				array(
					'label' => 'Industry',
					'value' => $industry,
				),
			) as $stat
		) {
			$stat_value = ethnic_shared_case_study_showcase_text( $stat['value'] );
			$stat_key   = sanitize_title( $stat_value );

			if ( '' === $stat_value || isset( $stat_keys[ $stat_key ] ) ) {
				continue;
			}

			$visual_stats[]       = array(
				'label' => $stat['label'],
				'value' => $stat_value,
			);
			$stat_keys[ $stat_key ] = true;

			if ( count( $visual_stats ) >= 2 ) {
				break;
			}
		}

		if ( ! $image ) {
			$image = ethnic_shared_case_study_showcase_placeholder_image_url();
		}

		return array(
			'industry'       => $industry,
			'service'        => $service,
			'platform'       => $platform,
			'title'          => $title,
			'summary'        => $summary,
			'challenge'      => $challenge,
			'solution'       => $solution,
			'outcome'        => $outcome,
			'insights'       => $insights,
			'url'            => $url,
			'image'          => $image,
			'image_alt'      => $image_alt,
			'brand_mark'     => isset( $item['brand_mark'] ) ? ethnic_shared_case_study_showcase_text( $item['brand_mark'] ) : ethnic_shared_case_study_showcase_initials( $title ),
			'accent'         => $accent,
			'position'       => $position,
			'technologies'   => $technologies,
			'meta_items'     => $meta_items,
			'visual_note_a'  => isset( $item['visual_note_a'] ) ? ethnic_shared_case_study_showcase_text( $item['visual_note_a'] ) : $service,
			'visual_note_b'  => isset( $item['visual_note_b'] ) ? ethnic_shared_case_study_showcase_text( $item['visual_note_b'] ) : $platform,
			'visual_label'   => '' !== $outcome ? 'Outcome' : 'Project Snapshot',
			'visual_caption' => '' !== $outcome ? $outcome : ethnic_shared_case_study_showcase_detail( $summary ),
			'visual_stats'   => $visual_stats,
		);
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_from_post' ) ) {
	function ethnic_shared_case_study_showcase_from_post( $post, $taxonomy, $index = 0 ) {
		$post = get_post( $post );

		if ( ! ( $post instanceof WP_Post ) ) {
			return array();
		}

		$post_id = (int) $post->ID;
		$payload = function_exists( 'ethnic_case_studies_build_post_payload' ) ? ethnic_case_studies_build_post_payload( $post ) : array();
		$title   = ! empty( $payload['title'] ) ? ethnic_shared_case_study_showcase_text( $payload['title'] ) : ethnic_shared_case_study_showcase_text( get_the_title( $post_id ) );

		if ( '' === $title || ethnic_shared_case_study_showcase_is_placeholder( $title ) ) {
			return array();
		}

		$excerpt_source = has_excerpt( $post_id ) ? get_the_excerpt( $post_id ) : get_post_field( 'post_content', $post_id );
		$summary        = ! empty( $payload['summary'] ) ? ethnic_shared_case_study_showcase_text( $payload['summary'] ) : ethnic_shared_case_study_showcase_text( $excerpt_source );

		if ( '' === $summary || ethnic_shared_case_study_showcase_is_placeholder( $summary ) ) {
			$summary = ethnic_shared_case_study_showcase_first_meta(
				$post_id,
				array(
					'outcome',
					'_outcome',
					'project_outcome',
					'_project_outcome',
					'case_study_outcome',
					'_case_study_outcome',
					'solution',
					'_solution',
					'project_solution',
					'_project_solution',
					'challenge',
					'_challenge',
					'project_challenge',
					'_project_challenge',
				)
			);
		}

		$terms = get_the_terms( $post_id, $taxonomy );
		$terms = is_wp_error( $terms ) || ! is_array( $terms ) ? array() : $terms;

		$industry = ! empty( $payload['industries'] ) && function_exists( 'ethnic_case_studies_first_value' )
			? ethnic_case_studies_first_value( $payload['industries'], 'Case Study' )
			: 'Case Study';

		if ( 'Case Study' === $industry ) {
			foreach ( $terms as $term ) {
				$term_name = isset( $term->name ) ? ethnic_shared_case_study_showcase_text( $term->name ) : '';

				if ( '' === $term_name || ethnic_shared_case_study_showcase_is_placeholder( $term_name ) ) {
					continue;
				}

				$industry = $term_name;
				break;
			}
		}

		$service = ! empty( $payload['services'] ) && function_exists( 'ethnic_case_studies_first_value' )
			? ethnic_case_studies_first_value( $payload['services'], '' )
			: '';
		$platform = ! empty( $payload['platforms'] ) && function_exists( 'ethnic_case_studies_first_value' )
			? ethnic_case_studies_first_value( $payload['platforms'], '' )
			: '';
		$services = ethnic_shared_case_study_showcase_first_meta(
			$post_id,
			array(
				'_thegem_cf_services',
				'services',
				'_services',
				'project_services',
				'_project_services',
			)
		);

		$technologies = ethnic_shared_case_study_showcase_split_list( $services );

		if ( empty( $technologies ) ) {
			$technologies = array_slice(
				array_values(
					array_filter(
						array_map(
							static function ( $term ) {
								return isset( $term->name ) ? ethnic_shared_case_study_showcase_text( $term->name ) : '';
							},
							$terms
						)
					)
				),
				0,
				3
			);
		}

		if ( empty( $technologies ) ) {
			$technologies = array_values(
				array_unique(
					array_filter(
						array(
							$platform,
							$industry,
							$service,
						)
					)
				)
			);
		}

		if ( empty( $technologies ) ) {
			$technologies = array( $industry, 'Project Delivery' );
		}

		$challenge = function_exists( 'ethnic_case_studies_service_page_card_copy' )
			? ethnic_case_studies_service_page_card_copy( $post_id, 'challenge' )
			: ethnic_shared_case_study_showcase_first_meta( $post_id, array( 'challenge', '_challenge', 'project_challenge', '_project_challenge', 'brief', '_brief' ) );
		$solution  = function_exists( 'ethnic_case_studies_service_page_card_copy' )
			? ethnic_case_studies_service_page_card_copy( $post_id, 'solution' )
			: ethnic_shared_case_study_showcase_first_meta( $post_id, array( 'solution', '_solution', 'project_solution', '_project_solution' ) );
		$outcome   = function_exists( 'ethnic_case_studies_service_page_card_copy' )
			? ethnic_case_studies_service_page_card_copy( $post_id, 'outcome' )
			: ethnic_shared_case_study_showcase_first_meta( $post_id, array( 'outcome', '_outcome', 'project_outcome', '_project_outcome', 'result', '_result' ) );

		return ethnic_shared_case_study_showcase_normalize_item(
			array(
				'industry'      => $industry,
				'service'       => $service,
				'platform'      => $platform,
				'title'         => $title,
				'summary'       => ethnic_shared_case_study_showcase_summary( $summary ),
				'challenge'     => $challenge,
				'solution'      => $solution,
				'outcome'       => $outcome,
				'url'           => ! empty( $payload['url'] ) ? $payload['url'] : ( get_permalink( $post_id ) ? get_permalink( $post_id ) : ethnic_shared_case_study_showcase_works_url() ),
				'image'         => ! empty( $payload['image_url'] ) ? $payload['image_url'] : get_the_post_thumbnail_url( $post_id, 'large' ),
				'image_alt'     => ! empty( $payload['image_alt'] ) ? $payload['image_alt'] : $title,
				'technologies'  => $technologies,
				'visual_note_a' => '' !== $service ? $service : $industry,
				'visual_note_b' => '' !== $platform ? $platform : ( isset( $technologies[1] ) ? $technologies[1] : 'Project Delivery' ),
			),
			$index
		);
	}
}

if ( ! function_exists( 'ethnic_shared_service_case_studies' ) ) {
	function ethnic_shared_service_case_studies( $fallback_case_studies = array(), $limit = 3, $page_id = 0 ) {
		static $cache = array();

		$limit      = max( 1, (int) $limit );
		$page_id    = (int) $page_id;
		$works_url  = ethnic_shared_case_study_showcase_works_url();
		$post_type  = post_type_exists( 'thegem_pf_item' ) ? 'thegem_pf_item' : 'post';
		$taxonomy   = 'thegem_pf_item' === $post_type ? 'thegem_portfolios' : 'category';
		$case_items = array();
		$seen       = array();

		if ( $page_id < 1 && function_exists( 'get_queried_object_id' ) ) {
			$page_id = (int) get_queried_object_id();
		}

		$cache_key = md5( wp_json_encode( array( $fallback_case_studies, $limit, $page_id ) ) );

		if ( isset( $cache[ $cache_key ] ) ) {
			return $cache[ $cache_key ];
		}

		$is_service_page = $page_id > 0 && function_exists( 'ethnic_case_studies_is_service_page' ) && ethnic_case_studies_is_service_page( $page_id );
		$selected_ids    = $page_id > 0 && function_exists( 'ethnic_case_studies_service_page_selected_ids' ) ? ethnic_case_studies_service_page_selected_ids( $page_id, $limit ) : array();

		if ( $is_service_page && empty( $selected_ids ) ) {
			$cache[ $cache_key ] = array();

			return $cache[ $cache_key ];
		}

		if ( ! empty( $selected_ids ) ) {
			foreach ( $selected_ids as $selected_id ) {
				$item = ethnic_shared_case_study_showcase_from_post( get_post( $selected_id ), $taxonomy, count( $case_items ) );

				if ( empty( $item ) ) {
					continue;
				}

				$item_key = sanitize_title( $item['title'] );

				if ( isset( $seen[ $item_key ] ) ) {
					continue;
				}

				$case_items[]      = $item;
				$seen[ $item_key ] = true;
			}
		}

		if ( $is_service_page ) {
			$cache[ $cache_key ] = array_slice( $case_items, 0, $limit );

			return $cache[ $cache_key ];
		}

		$query_args = apply_filters(
			'ethnic_shared_case_studies_query_args',
			array(
				'post_type'           => $post_type,
				'post_status'         => 'publish',
				'posts_per_page'      => max( $limit * 4, 6 ),
				'orderby'             => 'date',
				'order'               => 'DESC',
				'ignore_sticky_posts' => true,
				'no_found_rows'       => true,
				'post__not_in'        => $selected_ids,
			),
			$limit,
			$post_type,
			$taxonomy
		);

		$case_query = new WP_Query( $query_args );

		if ( $case_query->have_posts() ) {
			while ( $case_query->have_posts() ) {
				$case_query->the_post();

				$item = ethnic_shared_case_study_showcase_from_post( get_post(), $taxonomy, count( $case_items ) );

				if ( empty( $item ) ) {
					continue;
				}

				$item_key = sanitize_title( $item['title'] );

				if ( isset( $seen[ $item_key ] ) ) {
					continue;
				}

				$case_items[]       = $item;
				$seen[ $item_key ]  = true;

				if ( count( $case_items ) >= $limit ) {
					break;
				}
			}

			wp_reset_postdata();
		}

		foreach ( (array) $fallback_case_studies as $fallback_index => $fallback_case_study ) {
			$item = ethnic_shared_case_study_showcase_normalize_item( $fallback_case_study, count( $case_items ) + (int) $fallback_index );

			if ( empty( $item ) ) {
				continue;
			}

			$item_key = sanitize_title( $item['title'] );

			if ( isset( $seen[ $item_key ] ) ) {
				continue;
			}

			if ( empty( $item['url'] ) ) {
				$item['url'] = $works_url;
			}

			$case_items[]      = $item;
			$seen[ $item_key ] = true;

			if ( count( $case_items ) >= $limit ) {
				break;
			}
		}

		$cache[ $cache_key ] = array_slice( $case_items, 0, $limit );

		return $cache[ $cache_key ];
	}
}

if ( ! function_exists( 'ethnic_shared_case_study_showcase_render' ) ) {
	function ethnic_shared_case_study_showcase_render( $case_studies, $args = array() ) {
		$defaults = array(
			'carousel_label'   => 'Case studies and our work',
			'cta_label'        => 'View Case Study',
			'technology_label' => 'Project Scope',
		);
		$args     = wp_parse_args( $args, $defaults );
		$items    = array_values(
			array_filter(
				array_map(
					'ethnic_shared_case_study_showcase_normalize_item',
					is_array( $case_studies ) ? $case_studies : array(),
					array_keys( is_array( $case_studies ) ? $case_studies : array() )
				)
			)
		);

		if ( empty( $items ) ) {
			return '';
		}

		$count    = count( $items );
		$slider_id = function_exists( 'wp_unique_id' ) ? wp_unique_id( 'ethnic-case-showcase-track-' ) : uniqid( 'ethnic-case-showcase-track-' );

		ob_start();
		?>
		<div class="ethnic-case-showcase" data-ethnic-case-showcase data-loop-slider data-loop-clones="1">
			<div class="ethnic-case-showcase__frame">
				<div
					class="ethnic-case-showcase__track"
					id="<?php echo esc_attr( $slider_id ); ?>"
					data-loop-track
					tabindex="0"
					role="region"
					aria-roledescription="carousel"
					aria-label="<?php echo esc_attr( $args['carousel_label'] ); ?>"
				>
					<?php foreach ( $items as $index => $item ) : ?>
						<article
							class="ethnic-case-showcase__slide"
							data-loop-slide
							role="group"
							aria-roledescription="slide"
							aria-label="<?php echo esc_attr( sprintf( '%s, slide %d of %d', $item['title'], $index + 1, $count ) ); ?>"
							style="--ethnic-case-accent: <?php echo esc_attr( $item['accent'] ); ?>; --ethnic-case-image: url('<?php echo esc_url( $item['image'] ); ?>'); --ethnic-case-position: <?php echo esc_attr( $item['position'] ); ?>;"
						>
							<div class="ethnic-case-showcase__copy">
								<div class="ethnic-case-showcase__eyebrow-row">
									<span class="ethnic-case-showcase__eyebrow">Case Study</span>
									<?php if ( ! empty( $item['meta_items'] ) ) : ?>
										<div class="ethnic-case-showcase__meta-pills" aria-label="<?php echo esc_attr( $item['title'] . ' overview' ); ?>">
											<?php foreach ( $item['meta_items'] as $meta_item ) : ?>
												<span class="ethnic-case-showcase__meta-pill"><?php echo esc_html( $meta_item ); ?></span>
											<?php endforeach; ?>
										</div>
									<?php endif; ?>
								</div>

								<div class="ethnic-case-showcase__brand">
									<div class="ethnic-case-showcase__brand-copy">
										<span class="ethnic-case-showcase__brand-kicker"><?php echo esc_html( $item['industry'] ); ?></span>
										<strong><?php echo esc_html( $item['title'] ); ?></strong>
									</div>
								</div>

								<div class="ethnic-case-showcase__text">
									<h3><?php echo esc_html( $item['title'] ); ?></h3>
									<p><?php echo esc_html( $item['summary'] ); ?></p>
								</div>

								<?php if ( ! empty( $item['insights'] ) ) : ?>
									<div class="ethnic-case-showcase__insights" aria-label="<?php echo esc_attr( $item['title'] . ' highlights' ); ?>">
										<?php foreach ( $item['insights'] as $insight ) : ?>
											<article class="ethnic-case-showcase__insight">
												<span class="ethnic-case-showcase__insight-label"><?php echo esc_html( $insight['label'] ); ?></span>
												<p><?php echo esc_html( $insight['copy'] ); ?></p>
											</article>
										<?php endforeach; ?>
									</div>
								<?php endif; ?>

								<div class="ethnic-case-showcase__footer">
									<div class="ethnic-case-showcase__technologies" aria-label="<?php echo esc_attr( $item['title'] . ' technologies' ); ?>">
										<span class="ethnic-case-showcase__technologies-label"><?php echo esc_html( $args['technology_label'] ); ?></span>
										<div class="ethnic-case-showcase__technologies-list">
											<?php foreach ( $item['technologies'] as $technology ) : ?>
												<span class="ethnic-case-showcase__technologies-pill"><?php echo esc_html( $technology ); ?></span>
											<?php endforeach; ?>
										</div>
									</div>

									<a
										class="ethnic-case-showcase__cta"
										href="<?php echo esc_url( $item['url'] ); ?>"
										data-loop-primary-link
										tabindex="<?php echo 0 === $index ? '0' : '-1'; ?>"
									><?php echo esc_html( $args['cta_label'] ); ?></a>
								</div>
							</div>

							<div class="ethnic-case-showcase__visual">
								<div class="ethnic-case-showcase__visual-stage">
									<div class="ethnic-case-showcase__visual-badges" aria-hidden="true">
										<?php if ( ! empty( $item['visual_note_a'] ) ) : ?>
											<div class="ethnic-case-showcase__visual-badge"><?php echo esc_html( $item['visual_note_a'] ); ?></div>
										<?php endif; ?>
										<?php if ( ! empty( $item['visual_note_b'] ) ) : ?>
											<div class="ethnic-case-showcase__visual-badge ethnic-case-showcase__visual-badge--secondary"><?php echo esc_html( $item['visual_note_b'] ); ?></div>
										<?php endif; ?>
									</div>

									<div class="ethnic-case-showcase__visual-frame">
										<img class="ethnic-case-showcase__device-image" src="<?php echo esc_url( $item['image'] ); ?>" alt="<?php echo esc_attr( $item['image_alt'] ); ?>" loading="lazy" decoding="async" />
										<div class="ethnic-case-showcase__visual-caption">
											<span class="ethnic-case-showcase__visual-caption-label"><?php echo esc_html( $item['visual_label'] ); ?></span>
											<p><?php echo esc_html( $item['visual_caption'] ); ?></p>
										</div>
									</div>

									<?php if ( ! empty( $item['visual_stats'] ) ) : ?>
										<div class="ethnic-case-showcase__visual-footer">
											<?php foreach ( $item['visual_stats'] as $visual_stat ) : ?>
												<div class="ethnic-case-showcase__visual-stat">
													<span><?php echo esc_html( $visual_stat['label'] ); ?></span>
													<strong><?php echo esc_html( $visual_stat['value'] ); ?></strong>
												</div>
											<?php endforeach; ?>
										</div>
									<?php endif; ?>
								</div>
							</div>
						</article>
					<?php endforeach; ?>
				</div>
			</div>

			<?php if ( $count > 1 ) : ?>
				<div class="ethnic-case-showcase__nav" aria-label="Case study slider navigation">
					<div class="ethnic-case-showcase__progress">
						<div class="ethnic-case-showcase__count">
							<span class="ethnic-case-showcase__current" data-loop-current>01</span>
							<span class="ethnic-case-showcase__divider">/</span>
							<span class="ethnic-case-showcase__total"><?php echo esc_html( sprintf( '%02d', $count ) ); ?></span>
						</div>

						<div class="ethnic-case-showcase__dots" role="tablist" aria-label="Case study slides">
							<?php foreach ( $items as $index => $item ) : ?>
								<button
									type="button"
									class="ethnic-case-showcase__dot<?php echo 0 === $index ? ' is-active' : ''; ?>"
									data-loop-dot="<?php echo esc_attr( $index ); ?>"
									aria-label="<?php echo esc_attr( sprintf( 'Show slide %d: %s', $index + 1, $item['title'] ) ); ?>"
									aria-selected="<?php echo 0 === $index ? 'true' : 'false'; ?>"
									tabindex="<?php echo 0 === $index ? '0' : '-1'; ?>"
								></button>
							<?php endforeach; ?>
						</div>
					</div>

					<div class="ethnic-case-showcase__controls">
						<button type="button" class="ethnic-case-showcase__arrow ethnic-case-showcase__arrow--prev" data-loop-prev aria-controls="<?php echo esc_attr( $slider_id ); ?>" aria-label="Show previous case study">
							<span aria-hidden="true">←</span>
						</button>
						<button type="button" class="ethnic-case-showcase__arrow ethnic-case-showcase__arrow--next" data-loop-next aria-controls="<?php echo esc_attr( $slider_id ); ?>" aria-label="Show next case study">
							<span aria-hidden="true">→</span>
						</button>
					</div>
				</div>
			<?php endif; ?>
		</div>
		<?php

		return ob_get_clean();
	}
}