<?php
if (session_status() !== PHP_SESSION_ACTIVE) session_start();
$prefix = (strpos($_SERVER['PHP_SELF'], '/admin/') !== false) ? '../' : '';
$pageTitle = $pageTitle ?? 'Thunder Mountain Radio';
$pageClass = $pageClass ?? '';
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
$requestUri = $_SERVER['REQUEST_URI'] ?? '/';
$metaUrl = $scheme . '://' . $host . $requestUri;
$metaImage = $scheme . '://' . $host . '/assets/images/tmr.png';
$metaDescription = $metaDescription ?? 'Thunder Mountain Radio — storm-powered online radio with rock, country, classics, requests, DJs, charts and community.';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></title>
<meta name="description" content="<?= htmlspecialchars($metaDescription, ENT_QUOTES, 'UTF-8') ?>">
<meta name="theme-color" content="#07111f">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Thunder Mountain Radio">
<meta property="og:title" content="<?= htmlspecialchars($pageTitle, 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 name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="<?= htmlspecialchars($pageTitle, 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') ?>">
<link rel="icon" href="<?= $prefix ?>favicon.ico">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
<link rel="stylesheet" href="<?= $prefix ?>assets/css/header.css">
<link rel="stylesheet" href="<?= $prefix ?>assets/css/nav.css">
<link rel="stylesheet" href="<?= $prefix ?>assets/css/footer.css">
<link rel="stylesheet" href="<?= $prefix ?>assets/css/style.css">
<?php if (strpos($_SERVER['PHP_SELF'], '/admin/') !== false): ?>
<link rel="stylesheet" href="<?= $prefix ?>admin/assets/admin-v2.css">
<?php endif; ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body class="<?= htmlspecialchars($pageClass, ENT_QUOTES, 'UTF-8') ?>">
