<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$avi_meta_title = 'Partners — Avision';
$avi_meta_desc  = 'Avision trust and verification badges from launch platforms and SaaS directories.';
$avi_schema_json = array(
	'@context'    => 'https://schema.org',
	'@type'       => 'CollectionPage',
	'name'        => 'Avision — Featured & Verified On',
	'description' => $avi_meta_desc,
	'url'         => 'https://avision.org/partners/',
);

if ( ! class_exists( 'Avision_Page_Template' ) ) {
	require_once AVISION_PLUGIN_DIR . 'includes/class-avision-page-template.php';
}

$hero = array(
	'badge' => 'Trust & Verification',
	'title' => 'Avision — Featured & Verified On',
	'align' => 'center',
	'size'  => 'small',
);

$avi_partner_badges = array(
	array(
		'name'    => 'Smol Launch',
		'context' => 'Verified SaaS launch',
		'html'    => '<a href="https://smollaunch.com" target="_blank" rel="noopener"><img src="https://smollaunch.com/badges/featured.svg" alt="Avision — Featured on Smol Launch" loading="lazy" width="250" height="60" style="max-width:250px;height:auto;" /></a>',
	),
	array(
		'name'    => 'SaasBrowser',
		'context' => 'Verified SaaS directory listing',
		'html'    => '<a href="https://saasbrowser.com/en/saas/1446860/avision" target="_blank" rel="noopener"><img src="https://files.saasbrowser.com/otg7cx41x14fytvi4pnplhnu00kr" alt="AVISION - SaaS directory verified badge" width="200" height="133" /></a>',
	),
);

Avision_Page_Template::render(
	'partners',
	$hero,
	static function () use ( $avi_partner_badges, $avi_schema_json ) {
		$avi_partner_badge_html = array(
			'a'   => array(
				'href'   => true,
				'target' => true,
				'rel'    => true,
			),
			'img' => array(
				'src'     => true,
				'alt'     => true,
				'loading' => true,
				'width'   => true,
				'height'  => true,
				'style'   => true,
			),
		);
		?>
		<div class="avi-partners-page">
			<style>
				.avi-partners-page { background: #F8FAFF; color: #0A1628; font-family: inherit; line-height: 1.65; }
				.avi-partners-page * { box-sizing: border-box; }
				.avi-partners-page .avi-container { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
				.avi-partners-page__section { padding: 56px 0 72px; }
				.avi-partners-page__intro { max-width: 720px; margin: 0 auto 36px; text-align: center; }
				.avi-partners-page__intro h2 { margin: 0 0 12px; font-size: 1.85rem; line-height: 1.25; color: #0A1628; font-weight: 800; }
				.avi-partners-page__intro p { margin: 0; color: #52647A; font-size: 1rem; }
				.avi-partners-page__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; align-items: stretch; }
				.avi-partners-page__card { background: #FFFFFF; border: 1px solid rgba(10, 22, 40, 0.08); border-radius: 16px; box-shadow: 0 10px 30px rgba(10, 22, 40, 0.08); padding: 28px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 230px; }
				.avi-partners-page__badge { min-height: 96px; display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
				.avi-partners-page__badge a { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
				.avi-partners-page__badge img { display: block; max-width: 100%; height: auto; }
				.avi-partners-page__name { margin: 0 0 4px; color: #0A1628; font-size: 1rem; font-weight: 800; }
				.avi-partners-page__context { margin: 0; color: #64748B; font-size: 0.9rem; line-height: 1.5; }
				@media (max-width: 1024px) {
					.avi-partners-page__grid { grid-template-columns: repeat(3, 1fr); }
					.avi-partners-page__intro h2 { font-size: 1.65rem; }
				}
				@media (max-width: 900px) {
					.avi-partners-page__section { padding: 48px 0 64px; }
					.avi-partners-page__card { min-height: 210px; padding: 24px 20px; }
				}
				@media (max-width: 768px) {
					.avi-partners-page__grid { grid-template-columns: repeat(2, 1fr); }
					.avi-partners-page__intro { margin-bottom: 28px; }
				}
				@media (max-width: 600px) {
					.avi-partners-page .avi-container { padding: 0 18px; }
					.avi-partners-page__intro h2 { font-size: 1.45rem; }
					.avi-partners-page__card { border-radius: 14px; }
				}
				@media (max-width: 480px) {
					.avi-partners-page__grid { grid-template-columns: 1fr; }
					.avi-partners-page__section { padding: 40px 0 56px; }
					.avi-partners-page__badge { min-height: 82px; }
				}
			</style>

			<section class="avi-partners-page__section" aria-labelledby="avi-partners-title">
				<div class="avi-container">
					<div class="avi-partners-page__intro">
						<h2 id="avi-partners-title">Independent launch and directory signals</h2>
						<p>Public verification badges and launch listings that help visitors confirm where Avision has been featured.</p>
					</div>

					<div class="avi-partners-page__grid">
						<?php foreach ( $avi_partner_badges as $badge ) : ?>
							<article class="avi-partners-page__card">
								<div class="avi-partners-page__badge">
									<?php echo wp_kses( (string) $badge['html'], $avi_partner_badge_html ); ?>
								</div>
								<h3 class="avi-partners-page__name"><?php echo esc_html( (string) $badge['name'] ); ?></h3>
								<?php if ( ! empty( $badge['context'] ) ) : ?>
									<p class="avi-partners-page__context"><?php echo esc_html( (string) $badge['context'] ); ?></p>
								<?php endif; ?>
							</article>
						<?php endforeach; ?>
					</div>
				</div>
			</section>
		</div>
		<script type="application/ld+json"><?php echo wp_json_encode( $avi_schema_json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); ?></script>
		<?php
	}
);
