/* =========================================================
 * shared/style.css — 公共样式
 * 用途：所有页面（首页 + 各个游戏）共用的基础样式
 *   - Section 8: site bar + mini footer used on every game page
 *   - 移动端优先、竖屏布局
 *   - 禁止文字选中、禁止长按弹出菜单、去掉点击高亮
 *   - 适配 iPhone 刘海屏 / 底部横条（安全区域）
 *   - 模拟广告弹窗的样式（配合 shared/ads.js 使用）
 * ========================================================= */

/* ---------- 1. 颜色等变量，集中管理，方便以后换主题 ---------- */
:root {
  --bg: #f5f6fa;          /* 页面背景 */
  --card-bg: #ffffff;     /* 卡片背景 */
  --text: #2d3436;        /* 主文字 */
  --text-sub: #7f8c8d;    /* 次要文字 */
  --primary: #ff7f50;     /* 主色（按钮、强调） */
  --radius: 16px;         /* 统一圆角 */
  --ad-height: 60px;      /* 底部横幅广告高度 */

  /* 安全区域：iPhone 刘海 / 底部横条留白。
   * 需要 <meta name="viewport" content="..., viewport-fit=cover"> 才会生效 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ---------- 2. 基础重置 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  /* 系统字体栈：不加载任何外部字体 */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;

  /* 禁止 iOS 横屏时自动放大文字 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;

  /* 禁止下拉回弹 / 下拉刷新，避免玩游戏时页面被拖动 */
  overscroll-behavior: none;
}

/* ---------- 3. 禁止选中 & 禁止长按菜单 ---------- */
body {
  -webkit-user-select: none;   /* Safari */
  user-select: none;           /* 禁止选中文字 */
  -webkit-touch-callout: none; /* iOS 长按不弹出"拷贝/查询"菜单 */
  -webkit-tap-highlight-color: transparent; /* 去掉点击时的灰色高亮 */
  touch-action: manipulation;  /* 去掉双击缩放带来的 300ms 延迟 */
}

/* 图片、canvas 也禁止长按保存/拖拽 */
img,
canvas {
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  border: none;
  cursor: pointer;
}

/* ---------- 4. 页面容器：竖屏居中，大屏上也只显示手机宽度 ---------- */
.page {
  max-width: 480px;            /* 电脑上打开时限制宽度，保持竖屏观感 */
  min-height: 100%;
  margin: 0 auto;
  padding-top: calc(16px + var(--safe-top));
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
  /* 底部给横幅广告留出空间 */
  padding-bottom: calc(var(--ad-height) + 16px + var(--safe-bottom));
}

/* ---------- 5. 底部横幅广告位 ---------- */
#ad-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--ad-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom); /* 广告内容避开底部横条 */
  background: var(--bg);              /* 盖住滚动到下方的页面内容 */
}

/* 广告总开关关闭时（shared/ads.js 给 <html> 加上 no-ads）：
 * 不显示横幅，并把各页面给横幅预留的底部空间收回 */
html.no-ads {
  --ad-height: 0px;
}
html.no-ads #ad-banner {
  display: none;
}

/* 横幅广告的灰色占位块（shared/ads.js 的 showBanner 生成，接入真实广告后不再使用） */
.mock-ad-banner {
  max-width: 480px;
  height: var(--ad-height);
  margin: 0 auto;
  background: #dfe6e9;
  color: #95a5a6;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ---------- 6. 模拟广告弹窗（shared/ads.js 生成） ---------- */
.mock-ad-mask {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 24px;
}

.mock-ad-box {
  width: 100%;
  max-width: 320px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.mock-ad-tag {
  display: inline-block;
  font-size: 12px;
  color: var(--text-sub);
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0 6px;
  margin-bottom: 12px;
}

.mock-ad-content {
  height: 160px;
  border-radius: 12px;
  background: #dfe6e9;
  color: #636e72;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  cursor: pointer;
}

.mock-ad-btn {
  width: 100%;
  padding: 12px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
}

.mock-ad-btn:disabled {
  background: #b2bec3;
  cursor: default;
}

.mock-ad-skip {
  margin-top: 10px;
  background: none;
  color: var(--text-sub);
  font-size: 13px;
}

/* ---------- 7. 站点页头 / 页脚 / 文档页（首页和 About、Privacy 等页面共用） ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* 左侧 Logo：纯 CSS 圆形徽标 + 站点名 */
.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
}
.site-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffb347, #ff7f50);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-nav {
  display: flex;
  gap: 4px;
}
.site-nav a {
  padding: 8px 10px;          /* 保证点击区域够大 */
  border-radius: 999px;
  font-size: 14px;
  color: var(--text-sub);
}
.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.05);
}

.site-footer {
  margin-top: 32px;
  padding: 20px 4px 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  text-align: center;
  font-size: 13px;
  color: var(--text-sub);
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 4px;
  list-style: none;
  margin-bottom: 12px;
}
.footer-links a {
  display: inline-block;
  padding: 6px 10px;
}
.footer-links a:hover,
.site-nav a:hover {
  color: var(--primary);
}
.site-footer p + p {
  margin-top: 6px;
}

/* 文档页（About / Privacy / Terms / Contact）：允许选中复制文字 */
.doc {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  padding: 24px 4px 0;
  line-height: 1.65;
  font-size: 15px;
}
.doc h1 {
  font-size: 26px;
  line-height: 1.25;
  margin-bottom: 4px;
}
.doc .doc-meta {
  color: var(--text-sub);
  font-size: 13px;
  margin-bottom: 20px;
}
.doc h2 {
  font-size: 18px;
  margin: 24px 0 8px;
}
.doc p,
.doc ul {
  margin-bottom: 12px;
}
.doc ul {
  padding-left: 22px;
}
.doc li + li {
  margin-top: 4px;
}
.doc a {
  color: var(--primary);
  text-decoration: underline;
}
.doc code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------- 8. Game pages: site bar + mini footer ----------
 * Every game page has <html class="has-sitebar"> and a .sitebar header as the first
 * thing in <body>. The bar is fixed to the top; pushing --safe-top down by its height
 * moves every game's own layout (which already starts at var(--safe-top)) below it,
 * so no game needs its own offset rules. */
:root {
  --sitebar-h: 44px;
  --safe-top-raw: env(safe-area-inset-top, 0px);
}
html.has-sitebar {
  --safe-top: calc(var(--safe-top-raw) + var(--sitebar-h));
}

.sitebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 25;
  height: calc(var(--sitebar-h) + var(--safe-top-raw));
  padding-top: var(--safe-top-raw);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.sitebar-inner {
  max-width: 480px;
  height: var(--sitebar-h);
  margin: 0 auto;
  padding: 0 calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sitebar .site-logo {
  gap: 7px;
  font-size: 15px;
  color: var(--text);
}
.sitebar .site-logo-mark {
  width: 26px;
  height: 26px;
  font-size: 11px;
}
/* The obvious "back" action: a solid pill, at least 44px tall to tap */
.sitebar-home {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.sitebar-home:active {
  transform: scale(0.96);
}
/* Bigger invisible tap area around the pill */
.sitebar-home {
  position: relative;
}
.sitebar-home::after {
  content: "";
  position: absolute;
  inset: -5px -4px;
}

/* Compact site links for game menus / result screens */
.mini-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-sub);
}
.mini-footer a {
  display: inline-block;
  padding: 4px 2px;
  color: inherit;
}
.mini-footer a + a::before {
  content: "·";
  margin: 0 6px;
  opacity: 0.6;
}
.mini-footer p {
  margin: 0;
  font-size: 11px;
  opacity: 0.8;
}
