<?php
/**
 * Block Name: Contact Block
 *
 * A full-width CTA banner with a background photo, decorative linework overlay,
 * body text, and a link button.
 *
 * @package CWC
 */

namespace CWC;

$bg_image = get_field( 'background_image' );
$text     = get_field( 'text' );
$button   = get_field( 'button_link' );

$classes = 'contact-block rounded-t-3xl pt-5 container';
$wrapper = blockWrapperAttributes( $classes, $is_preview );
?>

<section <?php echo wp_kses_post( $wrapper ); ?>>
	<div class="contact-block__media" aria-hidden="true">
		<?php if ( $bg_image ) : ?>
			<img
				class="contact-block__bg-image"
				src="<?php echo esc_url( $bg_image['url'] ); ?>"
				alt=""
				loading="lazy"
				role="presentation"
			/>
		<?php endif; ?>

        <?php get_template_part( '/views/blocks/contact-block/linework' ); ?>
	</div>

	<div class="contact-block__content container pt-12 pb-16 relative z-10">
		<?php if ( $text ) : ?>
			<h2 class="contact-block__text font-quincy font-normal leading-none text-white max-w-4/5 mb-8">
				<?php echo wp_kses_post( $text ); ?>
			</h2>
		<?php endif; ?>

		<?php if ( $button ) : ?>
            <a class="contact-block__cta button dark" href="<?php echo esc_url( $button['url'] ?? '#' ); ?>" title="<?php echo esc_attr( $button['title'] ?? '' ); ?>" aria-label="<?php echo esc_attr( $button['title'] ?? '' ); ?>" data-button-color="secondary" data-button-variant="outline"><?php echo esc_html( $button['title'] ); ?></a>
		<?php endif; ?>
	</div>
</section>
