<?php
require_once __DIR__ . '/config.php';
$currentScript = basename($_SERVER['SCRIPT_NAME'] ?? 'index.php');
$isHome = ($currentScript === 'index.php');
$pageHeading = $pageTitle ?? 'Vermittlungshilfe für Tiere';
?>
<!doctype html>
<html lang="de">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title><?= e($pageHeading) ?> – LITTLE~Q~RANCH e.V.</title>
  <link rel="preconnect" href="https://googleapis.com">
  <link rel="preconnect" href="https://gstatic.com" crossorigin>
  <link href="https://googleapis.com/css2?family=Lato:wght@400;600;700&family=Playfair+Display:ital,wght@0,600;0,700;1,400&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="style.css">
  <style>
    .brand-title { font-family: 'Playfair Display', Georgia, serif; }
    .hero-quote {
      margin: 14px 0 0;
      padding: 12px 16px;
      background: #f4f1ea;
      border-left: 3px solid var(--accent);
      border-radius: 10px;
      font-style: italic;
      color: var(--text);
      font-size: 0.95rem;
    }
    .main-nav {
      display: flex;
      flex-wrap: nowrap;
      gap: 7px;
      overflow-x: auto;
      align-items: center;
      margin-top: 18px;
    }
    .nav-tab { white-space: nowrap; padding: 8px 14px; font-size: 0.88rem; }
    .nav-tab-cta-green { background: var(--primary); color: #fff; border-color: var(--primary); }
    .nav-tab-cta-green:hover { background: var(--primary-hover); color: #fff; }
    .nav-tab-cta-accent { background: #f3ede2; color: var(--accent-hover); border-color: #d6c8b2; }
    .nav-tab-cta-accent:hover { background: #e8decb; }
    @media (max-width: 980px) { .main-nav { flex-wrap: wrap; } }
    .lqr-ticker-wrap { background: var(--accent); color: #fff; overflow: hidden; border-bottom: 2px solid var(--primary); font-size: 0.93rem; }
    .lqr-ticker-track { display: inline-block; white-space: nowrap; padding: 8px 0 8px 100%; animation: lqrTicker 24s linear infinite; }
    .lqr-ticker-wrap:hover .lqr-ticker-track { animation-play-state: paused; }
    .lqr-ticker-wrap a { color: #fff3c4; text-decoration: underline; font-weight: 700; }
    @keyframes lqrTicker { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }
  </style>
</head>
<body>
<header class="site-header">
  <div class="container">
    <div class="header-inner">
      <div style="display:flex;align-items:center;gap:12px;">
        <img src="assets/logo.png" alt="LITTLE~Q~RANCH e.V." style="height:52px;width:auto;border-radius:10px;" onerror="this.style.display='none'">
        <div>
          <div class="brand-sub">Kostenlose Vermittlungshilfe von Tierfreunden für Tiere</div>
          <h1 class="brand-title"><a href="index.php"><span style="white-space:nowrap;">LITTLE~Q~RANCH e.V.</span> – Vermittlungshilfe</a></h1>
        </div>
      </div>
      <a href="<?= e(MAIN_SITE_URL) ?>" class="btn btn-accent">&larr; Zur Hauptseite little-q-ranch.de</a>
    </div>

    <?php if ($isHome): ?>
      <blockquote class="hero-quote">
        „In einer Zeit, in der Tiere oft vergessen werden, wollen wir ein Ort der Hoffnung, der Heilung und der Liebe sein – ein Platz, an dem jedes Leben zählt.“
      </blockquote>
    <?php endif; ?>
  </div>
</header>

<?php $ticker = function_exists('getTickerConfig') ? getTickerConfig() : ['active' => false]; ?>
<?php if (!empty($ticker['active']) && trim((string)($ticker['text'] ?? '')) !== ''): ?>
  <div class="lqr-ticker-wrap" role="region" aria-label="Wichtiger Hinweis">
    <div class="lqr-ticker-track">
      &#128226; <?= e($ticker['text']) ?>
      <?php if (!empty($ticker['url'])): ?>
        &nbsp;&ndash;&nbsp;<a href="<?= e($ticker['url']) ?>">Mehr erfahren &rarr;</a>
      <?php endif; ?>
    </div>
  </div>
<?php endif; ?>

<main class="container" id="inhalt">
  <?php if ($isHome): ?>
    <div class="notice-banner">
      <strong>Direkt &amp; von Herz zu Herz:</strong> Wir bringen Tierfreunde kostenlos zusammen. Alle Details besprecht ihr direkt mit den aktuellen Haltern.
    </div>
  <?php endif; ?>

  <nav class="main-nav" aria-label="Hauptnavigation">
    <a href="index.php#inhalt" class="nav-tab <?= in_array($currentScript, ['index.php', 'kategorie.php', 'tier.php'], true) ? 'active' : '' ?>">Wir suchen ein Zuhause</a>
    <a href="platzangebote.php#inhalt" class="nav-tab <?= in_array($currentScript, ['platzangebote.php', 'platz.php'], true) ? 'active' : '' ?>">Suche nach Platzangeboten</a>
    <a href="entlaufen.php#inhalt" class="nav-tab <?= $currentScript === 'entlaufen.php' ? 'active' : '' ?>">Entlaufen / Vermisst</a>
    <a href="zuhause-gefunden.php#inhalt" class="nav-tab nav-tab-archive <?= $currentScript === 'zuhause-gefunden.php' ? 'active' : '' ?>">Zuhause gefunden!</a>
    <a href="inserieren-tier.php#inhalt" class="nav-tab nav-tab-cta-green <?= $currentScript === 'inserieren-tier.php' ? 'active' : '' ?>">+ Zuhause suchen</a>
    <a href="inserieren-platz.php#inhalt" class="nav-tab nav-tab-cta-accent <?= $currentScript === 'inserieren-platz.php' ? 'active' : '' ?>">+ Platz / Pflegestelle melden</a>
  </nav>
