<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
 * Dynamic render for brentwood/video-hero.
 * Video/poster come from attributes; the editable text card is InnerBlocks ($content).
 *
 * @var array  $attributes
 * @var string $content  Rendered inner blocks (heading + paragraphs).
 */
$poster = $attributes['poster'] ?? '';
$video  = $attributes['video'] ?? '';

if ($video) {
    $media = sprintf(
        '<video class="bw-hero__video" autoplay muted loop playsinline preload="metadata" poster="%s"><source src="%s" type="video/mp4"></video>',
        esc_url($poster), esc_url($video)
    );
} else {
    $media = sprintf('<div class="bw-hero__video" style="background-image:url(\'%s\')"></div>', esc_url($poster));
}

echo '<div class="bw-hero"><div class="bw-hero__media">' . $media . '</div>'
    . '<div class="bw-hero__card">' . $content . '</div></div>';
