<?php
require __DIR__ . '/blog/lib.php';

$pdo = db();
$uploadedGames = $pdo->query('SELECT * FROM games WHERE enabled=1 ORDER BY created_at DESC, id DESC')->fetchAll(PDO::FETCH_ASSOC);
$allArticles = $pdo->query('SELECT id, title, created_at, visibility FROM articles ORDER BY created_at DESC, id DESC')->fetchAll(PDO::FETCH_ASSOC);
$articles = array_values(array_filter($allArticles, 'article_visible'));
$viewer = current_user();
$feedbackNotice = $_SESSION['feedback_notice'] ?? null;
unset($_SESSION['feedback_notice']);

$games = [];
foreach ($uploadedGames as $game) {
    $games[] = [
        'title' => $game['title'],
        'summary' => $game['description'] !== '' ? $game['description'] : '一款刚加入收藏的浏览器游戏。',
        'type' => '新作',
        'url' => 'games/' . $game['file'],
        'isNew' => true,
    ];
}
$games = array_merge($games, [
    ['title' => '打砖块', 'summary' => '经典弹球打砖块，接住小球，清空所有砖块。', 'type' => '街机', 'url' => 'breakout.html'],
    ['title' => '扫雷', 'summary' => '多难度扫雷，点击格子、标记地雷，考验推理。', 'type' => '益智', 'url' => 'minesweeper-multi.html'],
    ['title' => '舒尔特方格', 'summary' => '按顺序点击数字，训练注意力与反应速度。', 'type' => '训练', 'url' => 'schulte.html'],
    ['title' => '中文猜词', 'summary' => '中文版 Wordle，猜中隐藏词语。', 'type' => '文字', 'url' => 'wordle-cn.html'],
    ['title' => 'Wordle', 'summary' => '经典英文 Wordle，每天一题猜单词。', 'type' => '文字', 'url' => 'wordle-en.html'],
    ['title' => '磁盘检测', 'summary' => '赛博风磁盘扫描小游戏，边扫边玩。', 'type' => '实验', 'url' => 'disk-scanner.html'],
    ['title' => '方块世界', 'summary' => '浏览器里就能玩的方块世界小游戏。', 'type' => '沙盒', 'url' => 'minecraft.html'],
    ['title' => 'MineWeb', 'summary' => '网页版方块世界，建造与探索并行。', 'type' => '沙盒', 'url' => 'mineweb/index.html'],
]);
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="theme-color" content="#2447d8">
  <link rel="icon" href="/favicon.ico" sizes="any">
  <link rel="icon" type="image/png" sizes="32x32" href="/assets/adnovel-icon-32.png">
  <link rel="apple-touch-icon" sizes="180x180" href="/assets/adnovel-icon-180.png">
  <link rel="manifest" href="/site-manifest.json">
  <meta name="description" content="游戏与文字并列的个人数字游乐场。">
  <title>游戏与看文</title>
  <style>
    :root {
      --ink: #111211;
      --paper: #f5f1e8;
      --paper-deep: #e8e1d3;
      --line: rgba(17, 18, 17, .16);
      --muted: #67645e;
      --blue: #2447d8;
      --blue-deep: #102ca7;
      --signal: #d5ff52;
      --max: 1180px;
      --ease-out: cubic-bezier(.22, 1, .36, 1);
    }
    * { box-sizing: border-box; }
    html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
    body {
      margin: 0; min-width: 320px;
      background-color: var(--paper);
      background-image:
        linear-gradient(rgba(36,71,216,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(36,71,216,.035) 1px, transparent 1px),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
      background-size: 40px 40px, 40px 40px, 160px 160px;
      color: var(--ink);
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
      -webkit-font-smoothing: antialiased;
      text-rendering: optimizeLegibility;
    }
    ::selection { background: var(--signal); color: var(--ink); }
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-track { background: var(--paper); }
    ::-webkit-scrollbar-thumb { background: #d9d3c5; border: 2px solid var(--paper); }
    ::-webkit-scrollbar-thumb:hover { background: var(--muted); }
    a { color: inherit; }
    button, input, textarea { font: inherit; }
    h1, h2, h3 { text-wrap: balance; }

    @keyframes rise-in {
      from { opacity: 0; translate: 0 24px; }
      to { opacity: 1; translate: 0 0; }
    }

    .shell { width: min(var(--max), calc(100% - 40px)); margin: 0 auto; }
    .topbar { border-bottom: 1px solid var(--line); box-shadow: inset 0 -2px 0 rgba(36,71,216,.12); position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(12px); transition: background-color .25s ease, box-shadow .25s ease; }
    .topbar.is-scrolled { box-shadow: 0 12px 32px -20px rgba(17, 18, 17, .45); }
    .topbar-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
    .brand { display: inline-flex; align-items: baseline; gap: 10px; font-size: 14px; letter-spacing: -.02em; font-weight: 800; text-decoration: none; white-space: nowrap; }
    .brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; background: var(--ink); color: var(--paper); font-size: 10px; letter-spacing: .04em; transition: background-color .2s var(--ease-out), rotate .3s var(--ease-out); }
    .brand:hover .brand-mark { background: var(--blue); rotate: -4deg; }
    .brand small { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
    .main-nav { display: flex; align-items: stretch; height: 72px; }
    .main-nav a { display: grid; place-items: center; padding: 0 18px; border-left: 1px solid var(--line); font-size: 14px; font-weight: 700; text-decoration: none; transition: background-color .18s var(--ease-out), color .18s var(--ease-out); }
    .main-nav a:last-child { border-right: 1px solid var(--line); }
    .main-nav a:hover, .main-nav a:focus-visible { background: var(--ink); color: var(--paper); outline: none; }
    .main-nav .is-current { background: var(--blue); color: white; }
    .hero { min-height: 510px; display: grid; align-items: end; grid-template-columns: minmax(0, 1.16fr) minmax(280px, .84fr); gap: 42px; padding: 86px 0 54px; border-bottom: 1px solid var(--line); }
    .eyebrow, .section-kicker { margin: 0 0 14px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
    .eyebrow::before, .section-kicker::before { content: ''; display: inline-block; width: 22px; height: 1px; background: currentColor; margin-right: 10px; vertical-align: 4px; }
    .hero h1 { max-width: 780px; margin: 0; font-family: ui-serif, Georgia, "Noto Serif SC", "Songti SC", serif; font-size: clamp(44px, 7.3vw, 94px); line-height: .94; letter-spacing: -.075em; font-weight: 800; }
    .hero-copy { max-width: 540px; margin: 28px 0 0; color: var(--muted); font-size: 17px; line-height: 1.75; }
    .hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
    .action { display: inline-flex; align-items: center; gap: 26px; min-height: 48px; padding: 0 16px; border: 1px solid var(--ink); font-size: 13px; font-weight: 800; text-decoration: none; transition: background-color .18s var(--ease-out), color .18s var(--ease-out), translate .18s var(--ease-out), box-shadow .18s var(--ease-out); }
    .action::after { content: '↗'; font-size: 17px; line-height: 1; transition: translate .2s var(--ease-out); }
    .action.primary { background: var(--ink); color: var(--paper); }
    .action:hover, .action:focus-visible { background: var(--signal); color: var(--ink); outline: none; translate: -2px -2px; box-shadow: 4px 4px 0 var(--blue); }
    .action:hover::after { translate: 2px -2px; }
    .action:active { translate: 0 0; box-shadow: 0 0 0 var(--blue); }
    .editorial-prompt { position: relative; min-height: 320px; display: flex; flex-direction: column; justify-content: space-between; padding: 26px; background: var(--ink); color: var(--paper); box-shadow: 9px 9px 0 rgba(36,71,216,.9); }
    .editorial-prompt::before { content: ''; position: absolute; inset: 8px; border: 1px solid rgba(213,255,82,.16); pointer-events: none; }
    .editorial-prompt .section-kicker { color: var(--signal); }
    .editorial-prompt h2 { max-width: 360px; margin: 0; font-size: clamp(27px, 3.3vw, 42px); line-height: 1.03; letter-spacing: -.055em; }
    .editorial-prompt p { margin: 20px 0 0; color: #c7c3bb; line-height: 1.7; }
    .editorial-prompt a { display: inline-flex; justify-content: space-between; align-items: center; margin-top: 30px; padding-top: 14px; border-top: 1px solid rgba(245, 241, 232, .28); font-size: 13px; font-weight: 800; text-decoration: none; transition: color .18s var(--ease-out); }
    .editorial-prompt a::after { content: '进入看文 →'; color: var(--signal); }
    .editorial-prompt a:hover { color: var(--signal); }
    .section { padding: 76px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 74px; }
    .section-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
    .section-head h2 { margin: 0; font-family: ui-serif, Georgia, "Noto Serif SC", "Songti SC", serif; font-size: clamp(32px, 4vw, 53px); letter-spacing: -.06em; line-height: 1; }
    .section-head p { max-width: 350px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
    .read-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 22px; }
    .article-lead { display: block; min-height: 264px; padding: 28px; background: var(--blue); color: white; text-decoration: none; transition: background-color .22s var(--ease-out), translate .22s var(--ease-out), box-shadow .22s var(--ease-out); }
    .article-lead:hover, .article-lead:focus-visible { background: var(--blue-deep); outline: none; translate: -3px -3px; box-shadow: 7px 7px 0 var(--ink); }
    .article-lead:active { translate: 0 0; box-shadow: 0 0 0 var(--ink); }
    .article-lead .article-meta, .article-list .article-meta { display: block; font-size: 11px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
    .article-lead h3 { max-width: 650px; margin: 74px 0 0; font-size: clamp(27px, 4vw, 49px); line-height: 1.04; letter-spacing: -.055em; }
    .article-lead .read-more { display: block; margin-top: 18px; font-size: 13px; font-weight: 800; transition: color .18s var(--ease-out); }
    .article-lead:hover .read-more { color: var(--signal); }
    .article-list { border-top: 1px solid var(--line); }
    .article-list a { position: relative; display: block; padding: 18px 0; border-bottom: 1px solid var(--line); text-decoration: none; transition: padding-right .2s var(--ease-out); }
    .article-list a::after { content: '→'; position: absolute; right: 2px; bottom: 20px; color: var(--blue); font-weight: 800; opacity: 0; translate: -8px 0; transition: opacity .18s var(--ease-out), translate .18s var(--ease-out); }
    .article-list a:hover, .article-list a:focus-visible { padding-right: 28px; outline: none; }
    .article-list a:hover::after, .article-list a:focus-visible::after { opacity: 1; translate: 0 0; }
    .article-list a:hover h3, .article-list a:focus-visible h3 { color: var(--blue); outline: none; }
    .article-list h3 { margin: 8px 0 0; font-size: 18px; letter-spacing: -.025em; }
    .article-list .article-meta { color: var(--muted); }
    .empty-reading { display: grid; place-items: center; min-height: 264px; padding: 28px; background: var(--paper-deep); color: var(--muted); line-height: 1.7; }
    .game-tools { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: -8px 0 20px; }
    .game-tools label { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
    .filter-input { width: min(360px, 100%); min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); outline: none; transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out); }
    .filter-input:focus { border-color: var(--blue); box-shadow: 3px 3px 0 var(--blue); }
    .filter-input::placeholder { color: #8c8880; }
    .game-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
    .game-card { position: relative; min-height: 220px; padding: 20px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--paper); text-decoration: none; transition: background-color .22s var(--ease-out), color .22s var(--ease-out), transform .22s var(--ease-out), box-shadow .22s var(--ease-out); }
    .game-card::after { content: '↗'; position: absolute; top: 18px; right: 20px; color: var(--signal); font-size: 16px; opacity: 0; translate: -6px 6px; transition: opacity .2s var(--ease-out), translate .2s var(--ease-out); }
    .game-card:hover, .game-card:focus-visible { z-index: 1; background: var(--ink); color: var(--paper); outline: none; transform: translate(-3px, -3px); box-shadow: 5px 5px 0 var(--blue); }
    .game-card:hover::after, .game-card:focus-visible::after { opacity: 1; translate: 0 0; }
    .game-card:active { transform: translate(0, 0); box-shadow: 0 0 0 var(--blue); }
    .game-card:hover .game-summary, .game-card:focus-visible .game-summary { color: #c7c3bb; }
    .game-card:hover .game-type, .game-card:focus-visible .game-type { color: var(--signal); }
    .game-serial { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .11em; font-variant-numeric: tabular-nums; }
    .game-type { display: block; margin-top: 34px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
    .game-title { display: block; margin-top: 9px; font-size: 25px; line-height: 1.05; letter-spacing: -.045em; font-weight: 800; }
    .game-summary { display: block; margin-top: 12px; color: var(--muted); font-size: 13px; line-height: 1.65; }
    .game-card.is-hidden { display: none; }
    .feedback-shell { position: relative; display: grid; grid-template-columns: minmax(240px, .72fr) minmax(0, 1.28fr); border: 1px solid var(--ink); background: #fffdf8; box-shadow: 8px 8px 0 var(--blue); }
    .feedback-aside { display: flex; flex-direction: column; justify-content: space-between; min-height: 380px; padding: 28px; border-right: 1px solid var(--ink); background: var(--paper-deep); }
    .feedback-aside strong { max-width: 330px; font-family: ui-serif, Georgia, "Noto Serif SC", "Songti SC", serif; font-size: clamp(27px, 3vw, 41px); line-height: 1.08; letter-spacing: -.045em; }
    .feedback-aside small { color: var(--muted); font: 700 11px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .1em; text-transform: uppercase; }
    .feedback-form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 28px; }
    .feedback-form label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: .04em; }
    .feedback-form .wide { grid-column: 1 / -1; }
    .feedback-form input, .feedback-form textarea { width: 100%; border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink); outline: 0; transition: border-color .18s ease, box-shadow .18s ease; }
    .feedback-form input { min-height: 43px; padding: 6px 2px; }
    .feedback-form textarea { min-height: 150px; padding: 10px 2px; resize: vertical; }
    .feedback-form input:focus, .feedback-form textarea:focus { border-color: var(--blue); box-shadow: 0 2px 0 var(--blue); }
    .feedback-form .submit-row { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
    .feedback-form .submit-row span { color: var(--muted); font: 11px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
    .feedback-notice { grid-column: 1 / -1; margin: 0; padding: 12px 14px; border-left: 4px solid; font-size: 13px; }
    .feedback-notice.ok { border-color: #377229; background: #e3f0d9; color: #24561b; }
    .feedback-notice.error { border-color: #b2261b; background: #f8e5e1; color: #751b14; }
    .honeypot { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }
    .footer { display: grid; gap: 10px; padding: 26px 0 40px; color: var(--muted); font-size: 12px; }
    .footer-note { display: flex; justify-content: space-between; gap: 20px; }
    .record-link { justify-self: center; color: var(--muted); text-decoration: none; letter-spacing: .02em; }
    .record-link:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }

    /* —— 首屏入场（时间驱动，加载即播） —— */
    @media (prefers-reduced-motion: no-preference) {
      .hero .eyebrow { animation: rise-in .7s var(--ease-out) both; }
      .hero h1 { animation: rise-in .7s .08s var(--ease-out) both; }
      .hero .hero-copy { animation: rise-in .7s .16s var(--ease-out) both; }
      .hero .hero-actions { animation: rise-in .7s .24s var(--ease-out) both; }
      .hero .editorial-prompt { animation: rise-in .8s .2s var(--ease-out) both; }
    }
    /* —— 滚动渐入（滚动驱动，渐进增强：不支持的浏览器直接静态显示） —— */
    @supports (animation-timeline: view()) {
      @media (prefers-reduced-motion: no-preference) {
        .section-head, .article-lead, .article-list > a, .game-card, .feedback-shell {
          animation: rise-in auto linear both;
          animation-timeline: view();
          animation-range: entry 0% entry 40%;
        }
      }
    }
    @media (max-width: 760px) {
      .shell { width: min(100% - 28px, var(--max)); }
      .topbar-inner { min-height: 110px; align-items: stretch; flex-direction: column; gap: 0; }
      .brand { min-height: 56px; }
      .brand small { display: none; }
      .main-nav { width: 100%; height: 48px; }
      .main-nav a { flex: 1; padding: 0 12px; }
      .hero { grid-template-columns: 1fr; min-height: auto; gap: 34px; padding: 58px 0 38px; }
      .editorial-prompt { min-height: 250px; }
      .editorial-prompt h2 { font-size: 28px; }
      .section { padding: 52px 0; }
      .section-head, .game-tools { align-items: flex-start; flex-direction: column; }
      .read-layout { grid-template-columns: 1fr; }
      .article-lead h3 { margin-top: 52px; }
      .game-grid { grid-template-columns: 1fr; }
      .game-card { min-height: 180px; }
      .game-type { margin-top: 20px; }
      .filter-input { width: 100%; }
      .feedback-shell { grid-template-columns: 1fr; box-shadow: 5px 5px 0 var(--blue); }
      .feedback-aside { min-height: 220px; border-right: 0; border-bottom: 1px solid var(--ink); }
      .feedback-form { grid-template-columns: 1fr; padding: 22px; }
      .feedback-form .wide, .feedback-form .submit-row { grid-column: 1; }
      .feedback-form .submit-row { align-items: stretch; flex-direction: column; }
      .footer-note { flex-direction: column; }
    }
    @media (prefers-reduced-motion: reduce) {
      html { scroll-behavior: auto; }
      .game-card { transition: none; }
      .hero .eyebrow, .hero h1, .hero .hero-copy, .hero .hero-actions, .hero .editorial-prompt { animation: none; }
    }
  </style>
</head>
<body>
  <header class="topbar">
    <div class="shell topbar-inner">
      <a class="brand" href="/" aria-label="游戏与看文首页"><span class="brand-mark">P/R</span><span>游戏与看文</span><small>Play · Read · Return</small></a>
      <nav class="main-nav" aria-label="主导航">
        <a class="is-current" href="#games">游戏</a>
        <a href="#reading">看文</a>
        <a href="blog/checkin.php">签到</a>
        <a href="#feedback">反馈</a>
        <a href="/open-source/">开源</a>
      </nav>
    </div>
  </header>

  <main class="shell">
    <section class="hero" aria-labelledby="home-title">
      <div>
        <p class="eyebrow">A personal collection of play & thought</p>
        <h1 id="home-title">游戏是入口，<br>文字是延伸。</h1>
        <p class="hero-copy">这里不把阅读藏在游戏之后。玩一局、读一篇、再回来——两种体验在同一个首页平等发生。</p>
        <div class="hero-actions">
          <a class="action primary" href="#games">进入游戏库</a>
          <a class="action" href="#reading">去看文章</a>
          <a class="action" href="/open-source/">查看开源代码</a>
        </div>
      </div>
      <aside class="editorial-prompt" aria-label="看文入口">
        <div>
          <p class="section-kicker">Read alongside play</p>
          <h2>不止通关，也记录那些值得停下来的时刻。</h2>
          <p>文章、想法和游戏体验不再是隐藏页，而是这个空间的另一半。</p>
        </div>
        <a href="#reading">看最新文字</a>
      </aside>
    </section>

    <section class="section" id="reading" aria-labelledby="reading-title">
      <div class="section-head">
        <div><p class="section-kicker">Read</p><h2 id="reading-title">看文</h2></div>
        <p>近期写下的文字直接出现在首页；想沉下去读时，点开就是完整的阅读空间。</p>
      </div>
      <?php if ($articles): ?>
        <div class="read-layout">
          <?php $lead = $articles[0]; ?>
          <a class="article-lead" href="blog/view.php?id=<?= (int)$lead['id'] ?>">
            <span class="article-meta">最新文章 · <?= e($lead['created_at']) ?></span>
            <h3><?= e($lead['title']) ?></h3>
            <span class="read-more">阅读全文 →</span>
          </a>
          <div class="article-list" aria-label="更多文章">
            <?php foreach (array_slice($articles, 1, 4) as $article): ?>
              <a href="blog/view.php?id=<?= (int)$article['id'] ?>"><span class="article-meta"><?= e($article['created_at']) ?></span><h3><?= e($article['title']) ?></h3></a>
            <?php endforeach; ?>
            <a href="blog/"><span class="article-meta">Archive</span><h3>查看全部文章 →</h3></a>
          </div>
        </div>
      <?php else: ?>
        <div class="empty-reading">文字会在这里出现。<br>先去写下第一篇，再让它和游戏一起被看见。</div>
      <?php endif; ?>
    </section>

    <section class="section" id="games" aria-labelledby="games-title">
      <div class="section-head">
        <div><p class="section-kicker">Play</p><h2 id="games-title">游戏库</h2></div>
        <p>每张卡片只保留必要的信息。按名称或类型过滤，马上进入想玩的那一款。</p>
      </div>
      <div class="game-tools">
        <label id="game-count" for="filter">共 <?= count($games) ?> 款可玩</label>
        <input class="filter-input" id="filter" type="search" placeholder="搜索游戏、类型或玩法" autocomplete="off">
      </div>
      <div class="game-grid" id="game-grid">
        <?php foreach ($games as $index => $game): ?>
          <a class="game-card" href="<?= e($game['url']) ?>">
            <span class="game-serial"><?= str_pad((string)($index + 1), 2, '0', STR_PAD_LEFT) ?></span>
            <span class="game-type"><?= e($game['type']) ?></span>
            <strong class="game-title"><?= e($game['title']) ?></strong>
            <span class="game-summary"><?= e($game['summary']) ?></span>
          </a>
        <?php endforeach; ?>
      </div>
    </section>

    <section class="section" id="feedback" aria-labelledby="feedback-title">
      <div class="section-head">
        <div><p class="section-kicker">Feedback / Channel 04</p><h2 id="feedback-title">问题反馈</h2></div>
        <p>发现问题、有新点子，或只是想说一句，都可以从这里直接送到后台。</p>
      </div>
      <div class="feedback-shell">
        <div class="feedback-aside">
          <strong>把不顺手的地方，变成下一次更新。</strong>
          <small>Private inbox · Read by admin</small>
        </div>
        <form class="feedback-form" method="post" action="blog/feedback.php">
          <?= csrf_field() ?>
          <label class="honeypot" aria-hidden="true">网站<input type="text" name="website" tabindex="-1" autocomplete="off"></label>
          <?php if ($feedbackNotice): ?><p class="feedback-notice <?= ($feedbackNotice['type'] ?? '') === 'ok' ? 'ok' : 'error' ?>"><?= e((string)($feedbackNotice['text'] ?? '')) ?></p><?php endif; ?>
          <?php if ($viewer): ?>
            <label>提交者<input type="text" value="<?= e($viewer['username']) ?> · LV.<?= credit_level((int)$viewer['credit']) ?>" disabled></label>
          <?php else: ?>
            <label>称呼（选填）<input type="text" name="name" maxlength="40" placeholder="匿名也可以"></label>
          <?php endif; ?>
          <label>联系方式（选填）<input type="text" name="contact" maxlength="120" placeholder="邮箱 / 微信 / 其他"></label>
          <label class="wide">你的反馈<textarea name="content" minlength="5" maxlength="1500" required placeholder="请尽量描述发生了什么、你期待怎样改进……"></textarea></label>
          <div class="submit-row"><span>5—1500 字 · 将直接进入管理员后台</span><button class="action primary" type="submit">发送反馈</button></div>
        </form>
      </div>
    </section>
  </main>

  <footer class="shell footer">
    <div class="footer-note"><span>PLAY / READ</span><span>游戏与文字，同一张入口。</span></div>
    <a class="record-link" href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer">湘ICP备2026038574号</a>
  </footer>
  <script>
    (function () {
      var input = document.getElementById('filter');
      var cards = Array.prototype.slice.call(document.querySelectorAll('.game-card'));
      var count = document.getElementById('game-count');
      if (!input || !count) return;
      input.addEventListener('input', function () {
        var term = input.value.trim().toLocaleLowerCase();
        var shown = 0;
        cards.forEach(function (card) {
          var match = !term || card.textContent.toLocaleLowerCase().indexOf(term) !== -1;
          card.classList.toggle('is-hidden', !match);
          if (match) shown += 1;
        });
        count.textContent = term ? '找到 ' + shown + ' 款游戏' : '共 ' + cards.length + ' 款可玩';
      });
    })();
  </script>
  <script>
    (function () {
      var bar = document.querySelector('.topbar');
      if (!bar) return;
      function upd() { bar.classList.toggle('is-scrolled', window.scrollY > 10); }
      window.addEventListener('scroll', upd, { passive: true });
      upd();
    })();
  </script>
</body>
</html>
