<?php
/**
 * Boxed ("box visning") event card. Expects $ev (see events.php) and $eventitStyle.
 * Placed inside .eventit-box-grid (CSS grid) - no Bootstrap columns needed.
 */
defined( 'ABSPATH' ) or die( 'I cannot do anything when called directly good sir' );

$acc = $ev['accent'];
?>
<div class="eventit-box-wrapper eventit-compact-wrap <?php echo esc_attr( $ev['classes'] ); ?>">
    <div class="eventit-inner cat-color-acc-<?php echo esc_attr( $acc[0] ); ?>">

        <div class="eventit-box-head">
<?php if ( trim( (string) $ev['day'] ) !== '' ) { /* no date badge when the API sent no start date */ ?>
            <div class="eventit-box-date cat-color-acc-<?php echo esc_attr( $acc[0] ); ?> cat-color-bg-<?php echo esc_attr( $acc[0] ); ?>">
                <em class="date"><?php echo esc_html( $ev['day'] ); ?><span class="eventit-date-dot">.</span></em>
                <em class="month"><?php echo esc_html( $ev['month_short'] ); ?></em>
            </div>
<?php } ?>
            <div class="eventit-box-body">
                <p class="eventit-title"><?php echo esc_html( $ev['title'] ); ?></p>
                <p class="eventit-description"><?php echo esc_html( $ev['description'] ); ?></p>
            </div>
        </div>

        <div class="eventit-box-foot">
            <div class="eventit-box-meta">
                <div class="eventit-box-tags">
<?php foreach ( $ev['categories'] as $category ) { ?>
                    <span class="cat-tag cat-color-span-<?php echo esc_attr( $category['color'] ); ?>"><?php echo esc_html( $category['name'] ); ?></span>
<?php } ?>
                </div>
<?php if ( $ev['location'] !== '' ) { ?>
                <p class="location"><i class="fa fa-map-marker fa-fw"></i><?php echo esc_html( $ev['location'] ); ?></p>
<?php } ?>
            </div>
            <div class="eventit-box-actions eventit-btn-row">
                <a href="<?php echo esc_url( $ev['info_url'] ); ?>" class="btn button-info" role="button"><?php echo esc_html( $ev['info_label'] ); ?></a>
                <a href="<?php echo esc_url( $ev['buy_url'] ); ?>" class="btn button-buy eventit-state-<?php echo esc_attr( $ev['buy_state'] ?? 'available' ); ?> <?php echo $ev['buy_disabled'] ? 'disabled' : ''; ?>" role="button"<?php echo $ev['buy_disabled'] ? ' aria-disabled="true" tabindex="-1"' : ''; ?>><?php echo esc_html( $ev['buy_label'] ); ?></a>
            </div>
        </div>

    </div>
</div>
