<?php
/**
 * List ("fuld bredde") event card. Expects $ev (see events.php) and $eventitStyle.
 * Colours/spacing are driven by CSS variables on #eventdetaillist - see flex.css.
 */
defined( 'ABSPATH' ) or die( 'I cannot do anything when called directly good sir' );

$acc = $ev['accent'];
$dateStyle = $eventitStyle['date-style'];
/* An event without a usable start date drops the date column entirely rather than
   showing an empty block - the content then uses the full width. */
$hasDate = ( trim( (string) $ev['day'] ) !== '' );
?>
<div class="eventit-compact-wrap row eventdetailpanel compact <?php echo esc_attr( $ev['classes'] ); ?>">
<?php if ( $hasDate ) { ?>
    <div class="col-lg-2 eventit-date-col">
<?php if ( $dateStyle === 'circle' ) { ?>
        <div class="eventit-date-circle-wrap">
            <div class="eventit-date-circle cat-color-acc-<?php echo esc_attr( $acc[0] ); ?>">
                <span class="eventit-dc-day"><?php echo esc_html( $ev['day'] ); ?></span>
                <span class="eventit-dc-month"><?php echo esc_html( $ev['month_short'] ); ?></span>
            </div>
            <div class="eventit-date-sub">
                <span class="eventit-ds-weekday"><?php echo esc_html( $ev['weekday'] ); ?></span>
                <?php if ( $ev['time'] !== '' ) { ?><span class="eventit-ds-time"><i class="fa fa-clock fa-fw"></i><?php echo esc_html( $ev['time'] ); ?></span><?php } ?>
            </div>
        </div>
<?php } else { ?>
        <div class="row date-wrapper compact">
            <div class="col col-lg-12 weekday compact cat-color-acc-<?php echo esc_attr( $acc[0] ); ?> cat-color-bg-<?php echo esc_attr( $acc[0] ); ?>"><?php echo esc_html( $ev['weekday'] ); ?></div>
            <div class="col col-lg-12 date compact cat-color-acc-<?php echo esc_attr( $acc[1] ); ?> cat-color-bg-<?php echo esc_attr( $acc[0] ); ?>"><?php echo esc_html( $ev['day'] . '. ' . $ev['month'] ); ?></div>
            <div class="col col-lg-12 time compact cat-color-acc-<?php echo esc_attr( $acc[2] ); ?> cat-color-bg-<?php echo esc_attr( $acc[0] ); ?>"><?php if ( $ev['time'] !== '' ) { ?><i class="fa fa-clock fa-fw"></i><?php echo esc_html( $ev['time'] ); } ?></div>
        </div>
<?php } ?>
    </div>
<?php } ?>

    <div class="<?php echo $hasDate ? 'col-lg-10' : 'col-lg-12'; ?> right-event-wrapper border-acc-<?php echo esc_attr( $acc[0] ); ?> compact eventit-main-col<?php echo $hasDate ? '' : ' eventit-no-date'; ?>">
        <div class="row">
            <div class="col-md-12 event-title-wrap compact">
                <?php echo esc_html( $ev['title'] ); ?>
                <p class="eventit-description"><?php echo esc_html( $ev['description'] ); ?></p>
            </div>

            <div class="col-md-6 lower-event-blocks eventit-meta-col">
                <div class="category-wrap compact">
<?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>
                <div class="location-wrap compact">
<?php if ( $ev['location'] !== '' ) { ?>
                    <i class="fa fa-map-marker fa-fw site-event-details-icon align-middle"></i><p class="align-middle"><?php echo esc_html( $ev['location'] ); ?></p>
<?php } ?>
                </div>
            </div>
            <div class="col-md-6 lower-event-blocks text-right 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 mr-0 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>
