<?php
/**
 * Testimonials / Team template.
 *
 * @package Rsmspark_Content_Widgets
 */

defined( 'ABSPATH' ) || exit;

if ( empty( $profiles ) ) {
	return;
}
?>
<section id="<?php echo esc_attr( $widget_uid ); ?>" class="rsmspark-cw rsmspark-cw-team rsmspark-cw-team--<?php echo esc_attr( $layout ); ?>" style="<?php echo esc_attr( $style_vars ); ?>" data-rsmspark-cw-team>
	<?php if ( ! empty( $title ) ) : ?>
		<h2 class="rsmspark-cw-team__title"><?php echo esc_html( $title ); ?></h2>
	<?php endif; ?>

	<div class="rsmspark-cw-team__grid" <?php echo 'carousel' === $layout ? 'data-rsmspark-cw-carousel' : ''; ?>>
		<?php foreach ( $profiles as $index => $profile ) : ?>
			<article class="rsmspark-cw-team__card">
				<?php if ( ! empty( $profile['photo'] ) ) : ?>
					<div class="rsmspark-cw-team__photo" style="background-image:url(<?php echo esc_url( $profile['photo'] ); ?>);"></div>
				<?php endif; ?>
				<h3><?php echo esc_html( $profile['name'] ); ?></h3>
				<?php if ( ! empty( $profile['role'] ) ) : ?>
					<p class="rsmspark-cw-team__role"><?php echo esc_html( $profile['role'] ); ?></p>
				<?php endif; ?>
				<?php if ( ! empty( $profile['quote'] ) ) : ?>
					<p class="rsmspark-cw-team__quote"><?php echo esc_html( $profile['quote'] ); ?></p>
				<?php endif; ?>
				<?php if ( ! empty( $profile['bio'] ) ) : ?>
					<div class="rsmspark-cw-team__bio-source" id="<?php echo esc_attr( $profile['id'] ); ?>-bio" hidden>
						<?php echo wp_kses_post( $profile['bio'] ); ?>
					</div>
					<button
						type="button"
						class="rsmspark-cw-team__more"
						data-rsmspark-cw-team-open
						data-name="<?php echo esc_attr( $profile['name'] ); ?>"
						data-bio-target="<?php echo esc_attr( $profile['id'] ); ?>-bio"
					>
						<?php esc_html_e( 'View bio', 'rsm-content-widgets' ); ?>
					</button>
				<?php endif; ?>
			</article>
		<?php endforeach; ?>
	</div>

	<div class="rsmspark-cw-team__modal" data-rsmspark-cw-team-modal hidden>
		<div class="rsmspark-cw-team__modal-backdrop" data-rsmspark-cw-team-close></div>
		<div class="rsmspark-cw-team__modal-panel" role="dialog" aria-modal="true">
			<button type="button" class="rsmspark-cw-team__modal-close" data-rsmspark-cw-team-close aria-label="<?php esc_attr_e( 'Close', 'rsm-content-widgets' ); ?>">×</button>
			<h3 data-rsmspark-cw-team-modal-name></h3>
			<div data-rsmspark-cw-team-modal-bio></div>
		</div>
	</div>
</section>
