<?php if (!defined('ABSPATH')) exit; ?>
<?php
/**
 * Modern - Archive Card Template
 *
 * Bold, image-forward design. Full-width image with title overlaid at bottom
 * using a gradient. Minimal text. Hover: slight scale + shadow.
 *
 * @package Integrate_Palace_Properties
 */

$prop      = new IPP_Property_Helper();
$featured  = $prop->featured_image('large');
$permalink = get_permalink();
?>
<article class="ipp-card ipp-card--modern"
         style="position:relative;overflow:hidden;border-radius:var(--ipp-radius,12px);transition:transform 0.3s ease,box-shadow 0.3s ease;"
         aria-label="<?php echo esc_attr($prop->name()); ?>"
         onmouseenter="this.style.transform='scale(1.02)';this.style.boxShadow='0 20px 40px rgba(0,0,0,0.15)';"
         onmouseleave="this.style.transform='scale(1)';this.style.boxShadow='none';">

    <a href="<?php echo esc_url($permalink); ?>" style="display:block;position:relative;">
        <?php if ($featured) : ?>
            <img src="<?php echo esc_url($featured['url']); ?>"
                 alt="<?php echo esc_attr($featured['alt'] ?: $prop->name()); ?>"
                 loading="lazy"
                 style="width:100%;aspect-ratio:3/4;object-fit:cover;display:block;">
        <?php else : ?>
            <span style="display:block;width:100%;aspect-ratio:3/4;background:var(--ipp-color-gray-200,#e5e7eb);"></span>
        <?php endif; ?>

        <?php if ($prop->show('status') && $prop->status()) : ?>
            <span class="ipp-card__badge ipp-badge <?php echo strtolower($prop->status()) === 'active' ? 'ipp-badge--active' : 'ipp-badge--inactive'; ?>"
                  style="position:absolute;top:1rem;left:1rem;z-index:2;">
                <?php echo esc_html($prop->status()); ?>
            </span>
        <?php endif; ?>

        <!-- Gradient overlay + content at bottom -->
        <div style="position:absolute;bottom:0;left:0;right:0;padding:3rem 1.25rem 1.25rem;background:linear-gradient(transparent,rgba(0,0,0,0.75));color:#fff;">

            <?php if ($prop->show('rent') && $prop->formatted_rent()) : ?>
                <p class="ipp-card__price" style="font-size:1.25rem;font-weight:700;margin:0 0 0.25rem;color:#fff;">
                    <?php echo esc_html($prop->formatted_rent()); ?>
                    <?php if ($prop->rental_period()) : ?>
                        <span style="font-size:0.75rem;font-weight:400;opacity:0.8;">/ <?php echo esc_html($prop->rental_period()); ?></span>
                    <?php endif; ?>
                </p>
            <?php endif; ?>

            <h3 class="ipp-card__title" style="margin:0 0 0.25rem;color:#fff;font-size:1.125rem;">
                <?php echo esc_html(get_the_title()); ?>
            </h3>

            <?php if ($prop->show('address') && $prop->short_address()) : ?>
                <p class="ipp-card__address" style="margin:0 0 0.5rem;color:rgba(255,255,255,0.85);font-size:0.875rem;">
                    <?php echo esc_html($prop->short_address()); ?>
                </p>
            <?php endif; ?>

            <div class="ipp-card__meta" style="display:flex;gap:0.75rem;">
                <?php if ($prop->show('bedrooms') && $prop->bedrooms()) : ?>
                    <span class="ipp-card__meta-item" style="color:rgba(255,255,255,0.9);" aria-label="<?php echo esc_attr($prop->bedrooms()); ?> bedrooms">
                        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M3 7v11a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7"/><path d="M21 11H3V9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v2z"/><path d="M7 7V5a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2"/></svg>
                        <?php echo esc_html($prop->bedrooms()); ?>
                    </span>
                <?php endif; ?>
                <?php if ($prop->show('bathrooms') && $prop->bathrooms()) : ?>
                    <span class="ipp-card__meta-item" style="color:rgba(255,255,255,0.9);" aria-label="<?php echo esc_attr($prop->bathrooms()); ?> bathrooms">
                        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M4 12h16a1 1 0 0 1 1 1v3a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4v-3a1 1 0 0 1 1-1z"/><path d="M6 12V5a2 2 0 0 1 2-2h1"/></svg>
                        <?php echo esc_html($prop->bathrooms()); ?>
                    </span>
                <?php endif; ?>
                <?php if ($prop->show('cars') && $prop->cars()) : ?>
                    <span class="ipp-card__meta-item" style="color:rgba(255,255,255,0.9);" aria-label="<?php echo esc_attr($prop->cars()); ?> car spaces">
                        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M5 17h14M5 17a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1l2-3h8l2 3h1a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2"/><circle cx="7.5" cy="15.5" r="1.5"/><circle cx="16.5" cy="15.5" r="1.5"/></svg>
                        <?php echo esc_html($prop->cars()); ?>
                    </span>
                <?php endif; ?>
            </div>
        </div>
    </a>

</article>
