<?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 = "Smurfette's Country Delights";
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 = "Smurfette's Country Delights";
    $metaDescription = $metaDescription ?? "Smurfette's Country Delights — country heart, jukebox soul, jazz favourites, classic hits, retro vibes and live online radio streaming.";
    $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, Smurfettes Country Delights, Smurfette's Country Delights";
    $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="Smurfette's Country Delights">
  <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1">
  <meta name="theme-color" content="#120a06">
  <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="Smurfette's Country Delights 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; ?>
</head>

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

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