<?php
/**
 * Cosmic Signal — Terms of Service
 * https://cosmicsignal.org/terms.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>Terms of Service — 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; }

        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> TERMS OF SERVICE</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>Terms of Service</h1>

        <div class="card">
            <h2>1. Informational & Educational Purpose</h2>
            <p>
                Cosmic Signal is an independent, non-commercial, personal hobby observatory operated by RogerLe.com. All articles, telemetry trackers, and dispatches are provided strictly for educational and informational purposes.
            </p>
        </div>

        <div class="card">
            <h2>2. Text is Data; Fair Use of Scientific Work</h2>
            <p>
                All data, observations, and telemetry summaries on this site are derived from publicly accessible open science datasets, preprint repositories (such as arXiv.org), and space agency press releases (NASA, ESA, ESO, JAXA, etc.). We credit original papers and DOIs wherever available.
            </p>
        </div>

        <div class="card">
            <h2>3. No Warranties</h2>
            <p>
                While we make every effort to verify information against primary scientific literature, space science evolves rapidly. New observations can and do revise previous models. Content is provided on an "as-is" basis without warranties of completeness or real-time navigational accuracy.
            </p>
        </div>

        <div class="card">
            <h2>4. Acceptable Use</h2>
            <p>
                You are welcome to read, link to, and quote our dispatches with attribution. Automated scraping that degrades server performance is prohibited.
            </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="/privacy">Privacy</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>
