<?php
$seo = $seo ?? seo_defaults();
$defaults = site_default_settings();
$title = trim((string) ($seo['title'] ?? '')) ?: (string) setting('site_title', $defaults['site_title']);
$description = trim((string) ($seo['description'] ?? '')) ?: (string) setting('meta_description', $defaults['meta_description']);
$canonical = trim((string) ($seo['canonical'] ?? '')) ?: current_url();
$brandName = (string) setting('brand_name', $defaults['brand_name']);
$ogImage = trim((string) ($seo['image'] ?? '')) ?: url((string) setting('og_image', $defaults['og_image']));
$schemaSeo = $seo;
$schemaSeo['title'] = $title;
$schemaSeo['description'] = $description;
$schemaSeo['canonical'] = $canonical;
$schemaSeo['image'] = $ogImage;
$schemaJson = json_encode(seo_graph($schemaSeo), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP);
$primary = (string) setting('primary_color', '#17352f');
$accent = (string) setting('accent_color', '#b89a68');
$surface = (string) setting('surface_color', '#f3efe7');
$favicon = (string) setting('favicon', '/assets/img/favicon.svg');
$faviconExtension = strtolower(pathinfo((string) parse_url($favicon, PHP_URL_PATH), PATHINFO_EXTENSION));
$faviconType = match ($faviconExtension) {
    'png' => 'image/png',
    'ico' => 'image/x-icon',
    'jpg', 'jpeg' => 'image/jpeg',
    'webp' => 'image/webp',
    default => 'image/svg+xml',
};
$ogWidth = null;
$ogHeight = null;
$ogPath = parse_url($ogImage, PHP_URL_PATH);
if (is_string($ogPath) && $ogPath !== '') {
    $localImage = dirname(__DIR__, 2) . '/' . ltrim($ogPath, '/');
    if (is_file($localImage)) {
        $dimensions = @getimagesize($localImage);
        if (is_array($dimensions)) {
            $ogWidth = (int) ($dimensions[0] ?? 0);
            $ogHeight = (int) ($dimensions[1] ?? 0);
        }
    }
}
$hotelUrl = trim((string) setting('hotel_url', 'https://nekruthotel.com'));
$searchConsoleToken = search_console_verification_token((string) setting('search_console_verification', ''));
?>
<!doctype html><html lang="tr"><head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title><?= e($title) ?></title>
<meta name="description" content="<?= e($description) ?>">
<meta name="robots" content="<?= e($seo['robots'] ?? 'index,follow,max-image-preview:large,max-snippet:-1,max-video-preview:-1') ?>">
<meta name="author" content="<?= e($brandName) ?>">
<link rel="canonical" href="<?= e($canonical) ?>"><?php if (!empty($seo['amp'])): ?><link rel="amphtml" href="<?= e($seo['amp']) ?>"><?php endif; ?>
<link rel="icon" href="<?= e(url($favicon)) ?>" type="<?= e($faviconType) ?>">
<link rel="apple-touch-icon" href="<?= e(asset('img/apple-touch-icon.png')) ?>" sizes="180x180">
<meta name="theme-color" content="<?= e($primary) ?>">
<meta property="og:locale" content="tr_TR"><meta property="og:type" content="<?= e($seo['type'] ?? 'website') ?>"><meta property="og:site_name" content="<?= e($brandName) ?>">
<meta property="og:title" content="<?= e($title) ?>"><meta property="og:description" content="<?= e($description) ?>"><meta property="og:url" content="<?= e($canonical) ?>"><meta property="og:image" content="<?= e($ogImage) ?>"><meta property="og:image:alt" content="<?= e($title) ?>"><?php if ($ogWidth && $ogHeight): ?><meta property="og:image:width" content="<?= $ogWidth ?>"><meta property="og:image:height" content="<?= $ogHeight ?>"><?php endif; ?>
<meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="<?= e($title) ?>"><meta name="twitter:description" content="<?= e($description) ?>"><meta name="twitter:image" content="<?= e($ogImage) ?>"><meta name="twitter:image:alt" content="<?= e($title) ?>">
<?php if ($searchConsoleToken !== ''): ?><meta name="google-site-verification" content="<?= e($searchConsoleToken) ?>"><?php endif; ?>
<link rel="preload" href="<?= asset('img/hero.svg') ?>" as="image" type="image/svg+xml" fetchpriority="high">
<link rel="preload" href="<?= asset('css/app.css') ?>" as="style"><link rel="stylesheet" href="<?= asset('css/app.css') ?>">
<style>:root{--ink:<?= e($primary) ?>;--gold:<?= e($accent) ?>;--sand:<?= e($surface) ?>}</style>
<script type="application/ld+json"><?= $schemaJson ?></script>
<?php $analyticsConfig = ['gtm' => (string) setting('google_tag_manager_id', ''), 'ga' => (string) setting('google_analytics_id', ''), 'consentRequired' => setting_bool('cookie_consent_enabled', true)]; ?>
<script>window.NEKRUT_ANALYTICS=<?= json_encode($analyticsConfig, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP) ?>;</script>
</head><body>
<a class="skip-link" href="#main">İçeriğe geç</a>
<header class="site-header" data-header><div class="topbar"><div class="container topbar-inner"><span>Nekrut Hotel bünyesinde beş yıldızlı wellness deneyimi</span><?php if ($hotelUrl !== ''): ?><a href="<?= e($hotelUrl) ?>" target="_blank" rel="noopener noreferrer">Nekrut Hotel ↗</a><?php endif; ?></div></div>
<div class="container nav-wrap"><a class="brand" href="<?= url('/') ?>" aria-label="<?= e($brandName) ?> ana sayfa"><img src="<?= e(url((string) setting('logo_dark', '/assets/img/logo.svg'))) ?>" alt="<?= e($brandName) ?>" width="640" height="140"></a>
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="mainnav" data-menu-toggle><span></span><span></span><span></span><span class="sr-only">Menüyü aç</span></button>
<nav id="mainnav" class="main-nav" data-menu aria-label="Ana menü"><a href="<?= url('/hizmetler') ?>">Deneyimler</a><a href="<?= url('/wellness-rehberi') ?>">Wellness Rehberi</a><a href="<?= url('/galeri') ?>">Galeri</a><a href="<?= url('/kurumsal/hakkimizda') ?>">Hakkımızda</a><a href="<?= url('/kurumsal/iletisim-ulasim') ?>">İletişim</a><a class="button button-sm" href="<?= url('/rezervasyon') ?>">Rezervasyon Oluştur</a></nav></div></header>
<main id="main">
<?php if ($msg = flash('success')): ?><div class="flash success container"><?= e($msg) ?></div><?php endif; ?>
<?php if ($msg = flash('error')): ?><div class="flash error container"><?= e($msg) ?></div><?php endif; ?>
