<?php
if (!ob_get_level()) ob_start();
// header.php
// Purpose: meta + CSS includes ONLY, plus an EMPTY slim header bar for spacing.
// No title, no buttons, no branding.

if (!isset($pageTitle)) $pageTitle = "Radio Galaxy FX";
if (!isset($pageClass)) $pageClass = "";

// PHP 7 compatibility (some hosts still run it)
if (!function_exists('str_starts_with')) {
  function str_starts_with($haystack, $needle) {
    $haystack = (string)$haystack;
    $needle = (string)$needle;
    if ($needle === '') return true;
    return strncmp($haystack, $needle, strlen($needle)) === 0;
  }
}
if (!function_exists('str_contains')) {
  function str_contains($haystack, $needle) {
    $haystack = (string)$haystack;
    $needle = (string)$needle;
    if ($needle === '') return true;
    return strpos($haystack, $needle) !== false;
  }
}
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">

    <title><?= htmlspecialchars($pageTitle) ?></title>

  <?php
    $metaSiteName = "Radio Galaxy FX";
    $metaDescription = $metaDescription ?? "Radio Galaxy FX — cosmic radio energy, live shows, classic hits, country soul, retro favourites and online streaming from the Radio Galaxy FX universe.";
    $metaKeywords = $metaKeywords ?? "online radio, internet radio, live radio stream, country radio, classic country, jazz favourites, oldies radio, jukebox legends, retro radio, nostalgia radio, 60s music, 70s music, 80s music, live country radio, online country station, Radio Galaxy FX, Radio Galaxy FX";
    $scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
    $host = $_SERVER['HTTP_HOST'] ?? 'localhost';
    $requestUri = $_SERVER['REQUEST_URI'] ?? '/';
    $metaUrl = $scheme . '://' . $host . $requestUri;
    $metaImagePath = '/img/backgrounds/main-bg.png';
    $metaImage = $scheme . '://' . $host . $metaImagePath;
    $metaTitle = trim((string)($metaTitle ?? $pageTitle));
  ?>
  <meta name="description" content="<?= htmlspecialchars($metaDescription, ENT_QUOTES, 'UTF-8') ?>">
  <meta name="keywords" content="<?= htmlspecialchars($metaKeywords, ENT_QUOTES, 'UTF-8') ?>">
  <meta name="author" content="Radio Galaxy FX">
  <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1">
  <meta name="theme-color" content="#080915">
  <meta name="application-name" content="<?= htmlspecialchars($metaSiteName, ENT_QUOTES, 'UTF-8') ?>">
  <meta name="apple-mobile-web-app-title" content="<?= htmlspecialchars($metaSiteName, ENT_QUOTES, 'UTF-8') ?>">

  <meta property="og:type" content="website">
  <meta property="og:site_name" content="<?= htmlspecialchars($metaSiteName, ENT_QUOTES, 'UTF-8') ?>">
  <meta property="og:title" content="<?= htmlspecialchars($metaTitle, ENT_QUOTES, 'UTF-8') ?>">
  <meta property="og:description" content="<?= htmlspecialchars($metaDescription, ENT_QUOTES, 'UTF-8') ?>">
  <meta property="og:url" content="<?= htmlspecialchars($metaUrl, ENT_QUOTES, 'UTF-8') ?>">
  <meta property="og:image" content="<?= htmlspecialchars($metaImage, ENT_QUOTES, 'UTF-8') ?>">
  <meta property="og:image:secure_url" content="<?= htmlspecialchars($metaImage, ENT_QUOTES, 'UTF-8') ?>">
  <meta property="og:image:type" content="image/png">
  <meta property="og:image:alt" content="Radio Galaxy FX main background artwork">

  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:title" content="<?= htmlspecialchars($metaTitle, ENT_QUOTES, 'UTF-8') ?>">
  <meta name="twitter:description" content="<?= htmlspecialchars($metaDescription, ENT_QUOTES, 'UTF-8') ?>">
  <meta name="twitter:image" content="<?= htmlspecialchars($metaImage, ENT_QUOTES, 'UTF-8') ?>">
  <meta name="twitter:url" content="<?= htmlspecialchars($metaUrl, ENT_QUOTES, 'UTF-8') ?>">

  <link rel="canonical" href="<?= htmlspecialchars($metaUrl, ENT_QUOTES, 'UTF-8') ?>">
  <link rel="icon" type="image/png" href="<?= htmlspecialchars($metaImagePath, ENT_QUOTES, 'UTF-8') ?>">
  <link rel="apple-touch-icon" href="<?= htmlspecialchars($metaImagePath, ENT_QUOTES, 'UTF-8') ?>">

  <!-- CSS (order matters) -->
  <link rel="stylesheet" href="/assets/css/header.css">
  <link rel="stylesheet" href="/assets/css/nav.css">
  <link rel="stylesheet" href="/assets/css/footer.css">
  <link rel="stylesheet" href="/assets/css/main.css">
  <?php if ((isset($pageClass) && strpos($pageClass, 'page-admin') !== false) || strpos($_SERVER['PHP_SELF'] ?? '', '/admin/') === 0): ?>
  <link rel="stylesheet" href="/admin/assets/admin-v2.css">
  <?php endif; ?>
  <link rel="stylesheet" href="/assets/css/cosmic-theme.css">
</head>

<body class="<?= htmlspecialchars($pageClass) ?>">

<header class="site-header" role="banner" aria-hidden="true"></header>