<?php
/**
 * Exoplanet Ledger — Terms of Service
 * https://exoplanetledger.org/terms
 */
declare(strict_types=1);

$config = require __DIR__ . '/../config/db.php';
$umami = $config['site']['umami'] ?? [];
$utcNow = gmdate('Y-m-d H:i:s');
?>
<!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 — Exoplanet Ledger</title>
    <meta name="description" content="Terms of service and data citation policies for Exoplanet Ledger.">
    <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: #06090e;
            --bg-panel: #0c1017;
            --border: #1a2333;
            --border-highlight: #28374f;
            --text-primary: #e6edf5;
            --text-muted: #8d9ba8;
            --text-dim: #505e70;
            --exo-cyan: #38bdf8;
            --exo-gold: #fbbf24;
            --glow: rgba(56, 189, 248, 0.12);
            --bg-telemetry: rgba(12, 16, 23, 0.94);
            --telemetry-border: #1a2333;
            --telemetry-text: #8d9ba8;
            --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.025);
        }

        html[data-theme="light"] {
            --bg-void: #f8fafc;
            --bg-panel: #ffffff;
            --border: #cbd5e1;
            --border-highlight: #94a3b8;
            --text-primary: #0f172a;
            --text-muted: #475569;
            --text-dim: #64748b;
            --exo-cyan: #0284c7;
            --exo-gold: #d97706;
            --glow: rgba(2, 132, 199, 0.06);
            --bg-telemetry: rgba(255, 255, 255, 0.96);
            --telemetry-border: #cbd5e1;
            --telemetry-text: #475569;
            --grid-line: rgba(0, 0, 0, 0.035);
        }

        * { 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 85% 45% at 50% 0%, var(--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;
        }

        a { color: var(--exo-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);
            padding: 10px 24px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-family: var(--font-mono);
            font-size: 11.5px;
            color: var(--telemetry-text);
        }

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

        .container {
            max-width: 820px;
            margin: 0 auto;
            padding: 40px 24px 80px;
        }

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

        h1 {
            font-family: var(--font-serif);
            font-size: 42px;
            font-weight: 400;
            margin-bottom: 16px;
        }

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

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

        p { margin-bottom: 12px; 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>
            <span>STATION: <a href="/" style="font-weight:600;">EXOPLANETLEDGER.ORG</a></span>
            <span style="color:var(--text-dim)">·</span>
            <span>TERMS OF SERVICE</span>
        </div>
        <div>
            <button class="btn-theme" id="themeBtn" type="button">☀️ LIGHT</button>
        </div>
    </header>

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

        <h1>Terms of Service</h1>

        <div class="card">
            <h2>1. Educational & Non-Commercial Purpose</h2>
            <p>
                Exoplanet Ledger is provided freely for educational, scientific inquiry, and informational use. We do not sell subscriptions, display advertisements, or monetize visitor access.
            </p>
        </div>

        <div class="card">
            <h2>2. Scientific Data & Attribution</h2>
            <p>
                Observational parameters (planetary masses, radii, orbital periods, equilibrium temperatures, stellar types) are retrieved from the <strong>NASA Exoplanet Archive</strong>, a service of the NASA Exoplanet Science Institute (NExScI) operated by the California Institute of Technology.
            </p>
            <p>
                NASA astrophysical data is generally in the public domain. When quoting or utilizing specific parameters for academic publications, please cite the primary research papers indexed in the NASA Exoplanet Archive.
            </p>
        </div>

        <div class="card">
            <h2>3. Absence of Warranties</h2>
            <p>
                While we endeavor to keep planetary records synchronized with current composite consensus models, observational astrophysics is an evolving discipline. Measurements carry observational uncertainty and are revised as higher-resolution instruments deploy. Information is provided "as is" without warranty.
            </p>
        </div>

        <div class="card">
            <h2>4. Responsible Access</h2>
            <p>
                You are encouraged to browse, share, and link to planet dossiers. Heavy automated scraping that degrades system stability for other researchers and users 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('el-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('el-theme', next);
            themeBtn.textContent = next === 'dark' ? '☀️ LIGHT' : '🌙 DARK';
        });
    </script>
</body>
</html>
