<?php
/**
 * PPPHP favicon — the crystal "PP" monogram as an inline SVG data-URI, so it
 * needs no external file request. Matches core/views/brand-logo.php. Include
 * inside <head>.
 */
$__p1 = 'M 90 70 h 100 c 55.23 0 100 44.77 100 100 c 0 55.23 -44.77 100 -100 100 h -50 v 60 c 0 16.57 -13.43 30 -30 30 c -16.57 0 -30 -13.43 -30 -30 V 70 z M 150 120 v 100 h 40 c 27.61 0 50 -22.39 50 -50 c 0 -27.61 -22.39 -50 -50 -50 h -40 z';
$__p2 = 'M 170 140 h 100 c 55.23 0 100 44.77 100 100 c 0 55.23 -44.77 100 -100 100 h -50 v 60 c 0 16.57 -13.43 30 -30 30 c -16.57 0 -30 -13.43 -30 -30 V 140 z M 230 190 v 100 h 40 c 27.61 0 50 -22.39 50 -50 c 0 -27.61 -22.39 -50 -50 -50 h -40 z';
$__fav = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400">'
    . '<defs>'
    . '<linearGradient id="b" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#7dd3fc"/><stop offset=".42" stop-color="#4f7cf7"/><stop offset="1" stop-color="#4338ca"/></linearGradient>'
    . '<linearGradient id="p" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#e9d5ff"/><stop offset=".5" stop-color="#a855f7"/><stop offset="1" stop-color="#6d28d9"/></linearGradient>'
    . '<linearGradient id="s" x1="0" y1="0" x2=".7" y2="1"><stop offset="0" stop-color="#fff" stop-opacity=".6"/><stop offset=".38" stop-color="#fff" stop-opacity="0"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient>'
    . '</defs>'
    . '<path d="' . $__p1 . '" fill="url(#b)" fill-rule="evenodd"/>'
    . '<path d="' . $__p1 . '" fill="url(#s)" fill-rule="evenodd"/>'
    . '<path d="' . $__p2 . '" fill="url(#p)" fill-rule="evenodd"/>'
    . '<path d="' . $__p2 . '" fill="url(#s)" fill-rule="evenodd"/>'
    . '<g fill="#fff"><path d="M150 98 L158 120 L150 142 L142 120 Z"/><path d="M230 168 L238 190 L230 212 L222 190 Z"/></g>'
    . '</svg>';

// Base URL for the physical PWA assets (favicon.ico / apple-touch-icon / manifest).
// $assetsUrl is set by the surrounding console view (same var theme-head.php uses);
// strip the trailing "/assets" to get the app root the funnel serves public/ from.
$__au   = (string) ($assetsUrl ?? '');
$__base = $__au !== '' ? (string) preg_replace('#/assets/?$#', '', $__au) : '';
?>
<!-- Scalable, request-free primary icon (crystal PP monogram). -->
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<?= rawurlencode($__fav) ?>">
<?php if ($__base !== ''): ?>
<!-- Raster fallbacks + installable PWA metadata (physical files under public/). -->
<link rel="icon" type="image/x-icon" href="<?= htmlspecialchars($__base) ?>/favicon.ico" sizes="16x16 32x32">
<link rel="apple-touch-icon" href="<?= htmlspecialchars($__base) ?>/apple-touch-icon.png">
<link rel="manifest" href="<?= htmlspecialchars($__base) ?>/manifest.webmanifest">
<meta name="theme-color" content="#4338ca">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="PPPHP">
<meta name="application-name" content="PPPHP">
<script>
// Register the console service worker (app-shell cache: instant repeat loads +
// offline fallback). Deferred to 'load' so it never competes with first paint;
// failures are silent — the console works identically without it.
if ('serviceWorker' in navigator) {
    addEventListener('load', function () {
        navigator.serviceWorker.register('<?= htmlspecialchars($__base) ?>/sw.js').catch(function () {});
    });
}
</script>
<?php endif; ?>
