<?php

declare(strict_types=1);

require_once dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'fate_ui_settings.php';
require_once dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'fate_template.php';
$fateBrand = fate_public_site_branding();

$fatePageTitle = isset($fatePageTitle) && is_string($fatePageTitle) && $fatePageTitle !== ''
    ? $fatePageTitle
    : ($fateBrand['title_main'] . ' — ' . $fateBrand['title_sub'] . '（簡約模版）');
$fateIncludeStoreMap = isset($fateIncludeStoreMap) && $fateIncludeStoreMap;

$mtCss = dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'minimal-theme.css';
$mtVer = is_file($mtCss) ? (string) filemtime($mtCss) : (string) time();
?>
<!DOCTYPE html>
<html lang="zh-Hant" class="fate-theme-minimal">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <?php
    require_once dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'fate_favicon.php';
    fate_favicon_head_links();
    ?>
    <title><?= htmlspecialchars($fatePageTitle, ENT_QUOTES, 'UTF-8') ?></title>
    <?php
    require_once dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'fate_seo.php';
    $fateSeoContext = isset($fateSeoContext) && is_array($fateSeoContext) ? $fateSeoContext : null;
    fate_seo_render($fateSeoContext, $fatePageTitle);
    ?>
    <?php fate_template_render_adsense_head(); ?>
    <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=Noto+Sans+TC:wght@400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="./static/minimal-theme.css?v=<?= htmlspecialchars($mtVer, ENT_QUOTES, 'UTF-8') ?>">
    <?= fate_site_footer_stylesheet_tag('./') ?>
    <?= fate_social_links_stylesheet_tag('./') ?>
    <?php
    require_once dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'fate_mobile_member_bar.php';
    echo fate_mobile_member_bar_stylesheet_tag('./');
    ?>
    <?php
    if (!empty($fateMinimalIncludePageStyles)) {
        $mpCss = dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'minimal-pages.css';
        $mpVer = is_file($mpCss) ? (string) filemtime($mpCss) : (string) time();
        ?>
    <link rel="stylesheet" href="./static/minimal-pages.css?v=<?= htmlspecialchars($mpVer, ENT_QUOTES, 'UTF-8') ?>">
    <?php } ?>
    <?php
    if (!empty($fateIncludeAuthStyles)) {
        $authCssFs = dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'static' . DIRECTORY_SEPARATOR . 'fate-auth.css';
        $authCssVer = is_file($authCssFs) ? (string) filemtime($authCssFs) : (string) time();
        ?>
    <link rel="stylesheet" href="./static/fate-auth.css?v=<?= htmlspecialchars($authCssVer, ENT_QUOTES, 'UTF-8') ?>">
    <?php } ?>
    <?php if ($fateIncludeStoreMap): ?>
    <style>
        <?php
        require_once dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'fate_store_map.php';
        fate_store_map_styles();
        ?>
    </style>
    <?php endif; ?>
    <?php
    require_once dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'fate_mobile_member_bar.php';
    echo fate_mobile_type_stylesheet_tag('./');
    ?>
    <?php if (!empty($fateIncludeBlogAssets)): ?>
        <?php require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'blog_head_assets.inc.php'; ?>
    <?php endif; ?>
</head>
