<?php
require_once __DIR__ . '/includes/lang.php';
$dir  = t('dir');
$code = t('lang_code');

// Redirect if already logged in
session_start();
if (isset($_SESSION['user_id'])) {
    header('Location: dashboard.php');
    exit;
}
?>
<!DOCTYPE html>
<html lang="<?= htmlspecialchars($code) ?>" dir="<?= htmlspecialchars($dir) ?>">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="<?= htmlspecialchars(t('meta_desc')) ?>">
  <title><?= htmlspecialchars(t('site_name')) ?></title>
  <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🌴</text></svg>">
  <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=Cairo:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="css/style.css">
  <style>
    body { background: linear-gradient(160deg, var(--g-deep) 0%, #3d9970 100%); min-height: 100vh; }
    .auth-wrap { background: transparent; }
    .auth-card { animation: fadeUp .5s ease both; }
    @keyframes fadeUp { from { opacity:0; transform:translateY(30px); } to { opacity:1; transform:none; } }
  </style>
</head>
<body>

<!-- Language picker -->
<div style="position:fixed;top:16px;inset-inline-end:16px;z-index:100;display:flex;gap:4px">
  <a href="<?= lang_url('ar') ?>" style="background:<?= $code==='ar'?'var(--white)':'rgba(255,255,255,.2)' ?>;color:<?= $code==='ar'?'var(--g-main)':'var(--white)' ?>;padding:5px 10px;border-radius:100px;font-size:.75rem;font-weight:700;font-family:var(--font)">العربية</a>
  <a href="<?= lang_url('en') ?>" style="background:<?= $code==='en'?'var(--white)':'rgba(255,255,255,.2)' ?>;color:<?= $code==='en'?'var(--g-main)':'var(--white)' ?>;padding:5px 10px;border-radius:100px;font-size:.75rem;font-weight:700;font-family:var(--font)">EN</a>
  <a href="<?= lang_url('fr') ?>" style="background:<?= $code==='fr'?'var(--white)':'rgba(255,255,255,.2)' ?>;color:<?= $code==='fr'?'var(--g-main)':'var(--white)' ?>;padding:5px 10px;border-radius:100px;font-size:.75rem;font-weight:700;font-family:var(--font)">FR</a>
</div>

<div class="auth-wrap">
  <div class="auth-card">

    <!-- Logo -->
    <div class="splash-logo">🧭</div>
    <div class="splash-name"><?= htmlspecialchars(t('site_name')) ?></div>
    <div class="splash-tagline"><?= htmlspecialchars(t('tagline')) ?></div>

    <!-- Buttons -->
    <div class="splash-btns">
      <a href="auth/register.php<?= $code !== 'ar' ? '?lang='.$code : '' ?>" class="btn btn-green">
        📍 <?= htmlspecialchars(t('start_journey')) ?>
      </a>
      <a href="auth/login.php<?= $code !== 'ar' ? '?lang='.$code : '' ?>" class="btn btn-gold">
        👤 <?= htmlspecialchars(t('login')) ?>
      </a>
      <a href="index.php<?= $code !== 'ar' ? '?lang='.$code : '' ?>" class="btn btn-ghost" style="margin-top:4px">
        🗺️ <?= htmlspecialchars(t('explore_btn')) ?>
      </a>
    </div>

  </div>
</div>

</body>
</html>
