/*
Theme Name: Bigwave Media
Theme URI: https://bigwavemedia.co.uk
Description:
Author: Bigwave Media
Author URI: https://bigwavemedia.co.uk
Template: Total
Version: 1.0
*/

/* This theme uses Sass ye know */

@font-face {
    font-family: "Handmade Bugler Solid W00 Rg";
    src: url("fonts/29277eefcb2d6cc2f152bcf1f17f9b1e.eot"); /* IE9*/
    src: url("fonts/29277eefcb2d6cc2f152bcf1f17f9b1e.eot?#iefix") format("embedded-opentype"), /* IE6-IE8 */
    url("fonts/29277eefcb2d6cc2f152bcf1f17f9b1e.woff2") format("woff2"), /* chrome、firefox */
    url("fonts/29277eefcb2d6cc2f152bcf1f17f9b1e.woff") format("woff"), /* chrome、firefox */
    url("fonts/29277eefcb2d6cc2f152bcf1f17f9b1e.ttf") format("truetype"), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
    url("fonts/29277eefcb2d6cc2f152bcf1f17f9b1e.svg#Handmade Bugler Solid W00 Rg") format("svg"); /* iOS 4.1- */
}


.wp-block { margin:0 auto!important; }

.latest-posts-list .post-item:nth-child(odd) {
    background-color: #fff;
    color: #000;
}

.latest-posts-list .post-item:nth-child(even) {
    background-color: #004053; /* Petrol blue */
    color: #fff;
    padding: 20px; /* Add padding for block shape */
    border-radius: 5px; /* Optional: Add rounded corners */
}

.latest-posts-list .post-item:nth-child(even) .post-title a,
.latest-posts-list .post-item:nth-child(even) .post-date,
.latest-posts-list .post-item:nth-child(even) .post-category,
.latest-posts-list .post-item:nth-child(even) .post-excerpt,
.latest-posts-list .post-item:nth-child(even) .read-more {
    color: #fff; /* Ensure text is white on dark background */
}

.latest-posts-list .post-item:nth-child(even) .post-category a {
    color: #fff; /* Ensure category links are white */
}

.latest-posts-list .post-item:nth-child(even) .post-category a:hover {
    text-decoration: underline;
}

.post-thumbnail img {
    max-width: 100%; /* Ensure the image fits within its container */
    height: auto;
}

.post-title {
    font-family: 'YourThemeFont', sans-serif; /* Replace with your theme's font */
    font-size: 100%; /* Revert to original size */
    margin: 10px 0;
}

.post-date, .post-category, .post-excerpt {
    margin: 5px 0;
}

.post-category a {
    color: #0073aa; /* Adjust color as needed */
    text-decoration: none;
}

.post-category a:hover {
    text-decoration: underline;
}

.read-more {
    display: inline-block;
    margin-top: 10px;
    padding: 5px 10px;
    background-color: #0073aa; /* Adjust color as needed */
    color: #fff;
    text-decoration: none;
    border-radius: 3px;
    font-weight: bold; /* Make the button text bold */
}

.read-more:hover {
    background-color: #005177; /* Adjust color as needed */
}

.post-thumbnail img {
    width: 100%; /* Ensure the image fits within its container */
    height: auto;
    object-fit: cover; /* Crop the image to fit the container */
    aspect-ratio: 1 / 1; /* Maintain a square aspect ratio */
}

.post-title {
    font-family: 'YourThemeFont', sans-serif; /* Replace with your theme's font */
    font-size: 100%; /* Revert to original size */
    margin: 10px 0;
}

.post-date, .post-excerpt {
    margin: 5px 0;
}

.read-more {
    display: inline-block;
    margin-top: 10px;
    padding: 5px 10px;
    background-color: #0073aa; /* Adjust color as needed */
    color: #fff;
    text-decoration: none;
    border-radius: 3px;
    font-weight: bold; /* Make the button text bold */
}

.read-more:hover {
    background-color: #005177; /* Adjust color as needed */
}

.align-left .post-thumbnail {
    float: left;
    margin-right: 15px;
}

.align-right .post-thumbnail {
    float: right;
    margin-left: 15px;
}

.sidebar { /* Hide the sidebar */
    display: none;
}
.content-area { /* Display content as full width */
    width: 100%;
}

<?php


add_shortcode('post-archive', 'postArchiveListings');
function postArchiveListings($atts) {
    $atts = shortcode_atts(array(
        'post_type' => 'post',
    ), $atts );

    $args = array(
        'post_type' => $atts['post_type'],
        'posts_per_page' => -1 // Display all posts
    );

    if ($atts['post_type'] == 'events') {
        $args['meta_query'] = array(
            array(
                'key' => 'event_date',
                'value' => date("Y-m-d"),
                'compare' => '>=',
                'type' => 'DATE'
            )
        );
    }

    $the_query = new WP_Query($args);

    $html = '';
    if ($the_query->have_posts()) {
        $alternateLayoutSwitch = false;
        $sequentialColour = 0;
        $html .= '<div class="text_image_alternate_block listings"><div class="text_image_grid">';
        while ($the_query->have_posts()) {
            $the_query->the_post();
            $img = get_the_post_thumbnail_url(get_the_ID(), 'full');
            $eventDate = get_field('event_date', get_the_ID());
            $additionalContent = get_field('additional_content', get_the_ID());
            $html .= returnListingsHTML($img, $alternateLayoutSwitch, $sequentialColour, $additionalContent, $eventDate);
            $alternateLayoutSwitch = !$alternateLayoutSwitch;
            $sequentialColour++;
            if ($sequentialColour > 3) {
                $sequentialColour = 0;
            }
        }
        $html .= '</div></div>';
    } else {
        $html .= '<h2>No Posts Found</h2>';
    }

    wp_reset_postdata();

    return $html;
}
