<?php
$items = array_values(array_filter($s['items'], fn($item) => $item['title'] || $item['image']));
$height = ['md' => 'h-[440px] sm:h-[500px]', 'lg' => 'h-[520px] sm:h-[620px]', 'xl' => 'h-[calc(100svh-110px)] min-h-[520px]'][$s['height']] ?? 'h-[520px] sm:h-[620px]';
$boxed = $s['boxed'] === '1';
$center = $s['align'] === 'center';
?>
<?php if ($items): ?>
<div data-slider data-interval="<?= (int) $s['interval'] ?: 6 ?>" class="relative overflow-hidden bg-ink <?= $height ?> <?= $boxed ? 'rounded-[var(--radius-panel)]' : '' ?>">
    <?php foreach ($items as $i => $item): ?>
        <div data-slide <?= $i === 0 ? 'data-active' : '' ?> class="absolute inset-0 opacity-0 transition duration-1000 ease-out-soft data-active:z-10 data-active:opacity-100">
            <?php if ($item['image']): ?>
                <img src="<?= e(upload_url($item['image'])) ?>" alt="" class="absolute inset-0 h-full w-full object-cover" <?= $i ? 'loading="lazy"' : '' ?>>
                <div class="absolute inset-0 <?= $center ? 'bg-black/40' : 'bg-gradient-to-r from-black/70 via-black/30 to-transparent' ?>"></div>
            <?php else: ?>
                <div class="absolute inset-0 bg-[radial-gradient(ellipse_at_top_right,_#3f3f46_0%,_var(--color-ink)_60%)]"></div>
                <div class="absolute -right-32 -bottom-40 size-[36rem] rounded-full bg-accent-600/30 blur-[120px]"></div>
                <div class="absolute top-1/4 right-[12%] hidden size-72 rounded-full border border-white/10 lg:block"></div>
                <div class="absolute top-1/3 right-[18%] hidden size-44 rounded-full border border-white/10 lg:block"></div>
            <?php endif ?>
            <div class="relative flex h-full <?= $center ? 'items-center justify-center text-center' : 'items-end' ?> p-8 sm:p-14 lg:p-20">
                <div class="<?= $center ? 'mx-auto max-w-3xl' : 'max-w-2xl' ?>">
                    <?php if ($item['eyebrow']): ?><p class="eyebrow text-white/60"><?= e($item['eyebrow']) ?></p><?php endif ?>
                    <h2 class="font-display mt-5 text-4xl leading-[1.05] <?= heading_weight_class() ?> tracking-tight text-balance text-white sm:text-6xl lg:text-7xl"><?= e($item['title']) ?></h2>
                    <?php if ($item['subtitle']): ?><p class="mt-5 text-base leading-7 text-white/75 sm:text-lg <?= $center ? 'mx-auto max-w-xl' : 'max-w-lg' ?>"><?= e($item['subtitle']) ?></p><?php endif ?>
                    <?php if ($item['button_text']): ?>
                        <a href="<?= e(section_link($item['link']) ?: url('urunler')) ?>" class="btn mt-9 bg-white px-7 py-4 text-ink hover:bg-zinc-100"><?= e($item['button_text']) ?><?= icon('arrow', 'size-4', '2') ?></a>
                    <?php endif ?>
                </div>
            </div>
        </div>
    <?php endforeach ?>

    <?php if (count($items) > 1): ?>
        <div class="absolute right-8 bottom-8 z-20 flex items-center gap-3 sm:right-14 sm:bottom-14">
            <div class="flex gap-1.5">
                <?php foreach ($items as $i => $item): ?>
                    <button type="button" data-dot <?= $i === 0 ? 'data-active' : '' ?> class="h-1.5 w-6 rounded-full bg-white/30 transition-all data-active:w-10 data-active:bg-white" aria-label="Slayt <?= $i + 1 ?>"></button>
                <?php endforeach ?>
            </div>
            <button type="button" data-prev class="hidden size-11 items-center justify-center rounded-full border border-white/20 text-white transition hover:bg-white/10 sm:flex" aria-label="Önceki"><?= icon('left', 'size-4', '2') ?></button>
            <button type="button" data-next class="hidden size-11 items-center justify-center rounded-full border border-white/20 text-white transition hover:bg-white/10 sm:flex" aria-label="Sonraki"><?= icon('right', 'size-4', '2') ?></button>
        </div>
    <?php endif ?>
</div>
<?php endif ?>
