<?php
/**
 * Cosmic Signal — Privacy Policy
 * https://cosmicsignal.org/privacy.php
 */
declare(strict_types=1);

$config = require __DIR__ . '/../config/db.php';
$umami = $config['site']['umami'] ?? [];
?>
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Privacy Policy — Cosmic Signal</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:ital,wght@0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">
    
    <?php if (!empty($umami['website_id'])): ?>
    <script defer src="<?= htmlspecialchars($umami['script'] ?? 'https://farol.rogerle.com/farol') ?>" data-website-id="<?= htmlspecialchars($umami['website_id']) ?>"></script>
    <?php endif; ?>

    <style>
        :root, html[data-theme="dark"] {
            --bg-void: #07090e;
            --bg-panel: #0d1118;
            --border: #1d2636;
            --text-primary: #e6edf5;
            --text-muted: #8d9ba8;
            --text-dim: #546274;
            --signal-cyan: #38bdf8;
            --signal-glow: rgba(56, 189, 248, 0.15);
            --bg-telemetry: rgba(13, 17, 24, 0.92);
            --telemetry-border: #1d2636;
            --telemetry-text: #8d9ba8;
            --telemetry-val: #e6edf5;
            --font-serif: 'Instrument Serif', Georgia, serif;
            --font-sans: 'Inter', -apple-system, sans-serif;
            --font-mono: 'JetBrains Mono', monospace;
            --grid-line: rgba(56, 189, 248, 0.03);
        }

        html[data-theme="light"] {
            --bg-void: #f8fafc;
            --bg-panel: #ffffff;
            --border: #cbd5e1;
            --text-primary: #0f172a;
            --text-muted: #475569;
            --text-dim: #64748b;
            --signal-cyan: #0284c7;
            --signal-glow: rgba(2, 132, 199, 0.08);
            --bg-telemetry: rgba(255, 255, 255, 0.96);
            --telemetry-border: #cbd5e1;
            --telemetry-text: #475569;
            --telemetry-val: #0f172a;
            --grid-line: rgba(0, 0, 0, 0.04);
        }

        * { margin: 0; padding: 0; box-sizing: border-box; }

        body {
            background-color: var(--bg-void);
            color: var(--text-primary);
            font-family: var(--font-sans);
            font-size: 14.5px;
            line-height: 1.7;
            min-height: 100vh;
            background-image: 
                radial-gradient(ellipse 90% 50% at 50% 0%, var(--signal-glow), transparent 70%),
                repeating-linear-gradient(0deg, var(--grid-line) 0 1px, transparent 1px 24px),
                repeating-linear-gradient(90deg, var(--grid-line) 0 1px, transparent 1px 24px);
            background-attachment: fixed;
            -webkit-font-smoothing: antialiased;
        }

        a { color: var(--signal-cyan); text-decoration: none; }
        a:hover { text-decoration: underline; }

        .telemetry-bar {
            position: sticky;
            top: 0;
            z-index: 100;
            background: var(--bg-telemetry);
            backdrop-filter: blur(12px);
            border-bottom: 1px solid var(--telemetry-border);
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 9px 24px;
            font-family: var(--font-mono);
            font-size: 11px;
        }

        .btn-theme {
            background: var(--bg-panel);
            border: 1px solid var(--border);
            color: var(--text-primary);
            padding: 4px 10px;
            border-radius: 4px;
            cursor: pointer;
            font-family: var(--font-mono);
            font-size: 11px;
        }

        .container {
            max-width: 840px;
            margin: 0 auto;
            padding: 48px 24px 90px;
        }

        .back-link {
            font-family: var(--font-mono);
            font-size: 12px;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            margin-bottom: 24px;
        }

        h1 {
            font-family: var(--font-serif);
            font-size: clamp(34px, 5vw, 50px);
            font-weight: 400;
            margin-bottom: 24px;
            letter-spacing: -0.02em;
        }

        .card {
            background: var(--bg-panel);
            border: 1px solid var(--border);
            border-radius: 6px;
            padding: 28px 30px;
            margin-bottom: 24px;
        }

        h2 {
            font-family: var(--font-serif);
            font-size: 22px;
            font-weight: 400;
            margin-bottom: 10px;
            color: var(--text-primary);
        }

        p { margin-bottom: 14px; color: var(--text-muted); }
        p:last-child { margin-bottom: 0; }

        ul { margin-left: 20px; margin-bottom: 14px; color: var(--text-muted); }
        li { margin-bottom: 6px; }

        footer {
            margin-top: 60px;
            padding-top: 24px;
            border-top: 1px solid var(--border);
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-family: var(--font-mono);
            font-size: 11.5px;
            color: var(--text-dim);
            flex-wrap: wrap;
            gap: 12px;
        }
    </style>
</head>
<body>

    <header class="telemetry-bar">
        <div>STATION: <a href="/" style="font-weight:600;">COSMICSIGNAL.ORG</a> <span style="color:var(--text-dim)">·</span> PRIVACY POLICY</div>
        <div><button class="btn-theme" id="themeBtn" type="button">☀️ LIGHT</button></div>
    </header>

    <div class="container">
        <a href="/" class="back-link">← Return to Observatory Wire</a>

        <h1>Privacy Policy</h1>

        <div class="card">
            <h2>Our Privacy Philosophy: We Don't Want Your Data</h2>
            <p>
                Cosmic Signal believes the web should be an observatory, not a tracking network. We do not sell anything, we do not run advertising, and we do not collect personal information.
            </p>
        </div>

        <div class="card">
            <h2>Analytics (Farol / Umami)</h2>
            <p>
                To understand aggregated reader traffic and page views, we use <strong>Farol</strong>, our self-hosted instance of Umami:
            </p>
            <ul>
                <li><strong>Zero Cookies:</strong> Farol does not store cookies or local storage trackers on your device.</li>
                <li><strong>No IP Address Collection:</strong> IP addresses are never logged or stored.</li>
                <li><strong>No Cross-Site Tracking:</strong> Data is completely isolated on our self-hosted server and is never shared with third parties or ad networks.</li>
                <li><strong>GDPR & ePrivacy Compliant:</strong> Because no personal data is collected or processed, no cookie consent banner is needed or required.</li>
            </ul>
        </div>

        <div class="card">
            <h2>Local Preferences</h2>
            <p>
                We store only one client-side value in your browser's <code>localStorage</code>: your preferred theme (<code>dark</code> or <code>light</code>). This remains entirely on your computer and is never sent to our servers.
            </p>
        </div>

        <div class="card">
            <h2>Contact</h2>
            <p>
                Cosmic Signal is owned and hosted by Roger & Le (<a href="https://rogerle.com" target="_blank" rel="noopener">RogerLe.com</a>).
            </p>
        </div>

        <footer>
            <div>Hosted by <a href="https://rogerle.com" target="_blank" rel="noopener">RogerLe.com</a></div>
            <nav style="display:flex;gap:14px;">
                <a href="/">Home</a>
                <a href="/about">About</a>
                <a href="/terms">Terms</a>
            </nav>
        </footer>
    </div>

    <script>
        const themeBtn = document.getElementById('themeBtn');
        const currentTheme = localStorage.getItem('cs-theme') || 'dark';
        document.documentElement.setAttribute('data-theme', currentTheme);
        themeBtn.textContent = currentTheme === 'dark' ? '☀️ LIGHT' : '🌙 DARK';

        themeBtn.addEventListener('click', () => {
            const active = document.documentElement.getAttribute('data-theme');
            const next = active === 'dark' ? 'light' : 'dark';
            document.documentElement.setAttribute('data-theme', next);
            localStorage.setItem('cs-theme', next);
            themeBtn.textContent = next === 'dark' ? '☀️ LIGHT' : '🌙 DARK';
        });
    </script>
</body>
</html>
