/* TBF PWA mobile-first CSS — v1 */
/* 设计原则：
 *   1. 单列、紧凑、44px 触摸目标
 *   2. 顶部紧凑 sticky 条 + 底部 sticky 导航
 *   3. iOS safe-area 全适配
 *   4. 不破坏原 Kadence 主题（在原样式之后加载，可覆盖）
 *   5. 仅 @media (max-width: 768px) 触发
 */

/* ----- 安装横幅 ----- */
#tbf-install-banner {
  position: fixed;
  left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.tbf-install-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,.96);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(31,33,57,.18), 0 2px 6px rgba(31,33,57,.06);
  border: 1px solid rgba(75,73,182,.10);
}
.tbf-install-icon {
  width: 44px; height: 44px; border-radius: 11px; flex: 0 0 auto;
  background: url(/wp-content/uploads/tbf/pwa-192.png) center/cover no-repeat;
  box-shadow: 0 4px 10px rgba(75,73,182,.30);
}
.tbf-install-text { flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.tbf-install-title { font-size: 15px; font-weight: 600; color: #1d2139; }
.tbf-install-sub { font-size: 12px; color: #6a6f8c; margin-top: 2px; }
.tbf-install-cta {
  flex: 0 0 auto;
  border: 0; cursor: pointer;
  padding: 0 16px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg,#4b49b6 0%,#30b4db 100%);
  color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 3px 10px rgba(75,73,182,.40);
}
.tbf-install-close {
  flex: 0 0 auto;
  border: 0; background: transparent; cursor: pointer;
  width: 28px; height: 28px; border-radius: 14px;
  color: #6a6f8c; font-size: 22px; line-height: 1;
}

/* ----- 底部导航 ----- */
#tbf-bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255,255,255,.94);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid rgba(31,33,57,.08);
  z-index: 2147483600;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.tbf-bn-item {
  appearance: none; border: 0; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  min-height: 56px;
  color: #6a6f8c; text-decoration: none;
  font-size: 11px; line-height: 1; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tbf-bn-item svg { width: 22px; height: 22px; }
.tbf-bn-item:active { background: rgba(75,73,182,.08); }
.tbf-bn-active { color: #4b49b6 !important; }
.tbf-bn-active svg { stroke-width: 2.4; }

/* ----- 底部弹层（"更多"菜单） ----- */
#tbf-bottom-sheet {
  position: fixed; inset: 0;
  background: rgba(20,22,40,.45);
  z-index: 2147483640;
  display: flex; align-items: flex-end;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.tbf-sheet-card {
  width: 100%;
  background: #fff;
  border-top-left-radius: 20px; border-top-right-radius: 20px;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 30px rgba(0,0,0,.10);
}
.tbf-sheet-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 16px;
}
.tbf-sheet-grid a {
  display: flex; align-items: center; justify-content: center;
  min-height: 60px;
  background: #f3f4fb; color: #1d2139;
  border-radius: 12px;
  text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 8px;
  text-align: center;
}
.tbf-sheet-grid a:active { background: #e7e9f7; }
#tbf-sheet-close {
  width: 100%; min-height: 48px; border: 0; cursor: pointer;
  background: #f0f2f8; color: #1d2139;
  font-size: 15px; border-radius: 12px;
}

/* ============================================================
 * Mobile-only zone
 * ============================================================ */
@media (max-width: 768px) {

  /* Body padding-bottom 给底部导航留位 */
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important; }

  /* 让 viewport-fit 生效 */
  html, body {
    overscroll-behavior-y: contain;
  }

  /* 全局触控优化 */
  a, button, input, select, textarea {
    -webkit-tap-highlight-color: rgba(75,73,182,.15);
  }

  /* 让按钮 / 链接的最小可点区 ≥ 44px（iOS HIG / Material guideline） */
  .entry-content a:not(.wp-element-button):not(.tbf-bn-item),
  .nav-links a,
  .page-numbers,
  .wp-block-button__link,
  .menu-item a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* 表单控件字号 ≥ 16px 避免 iOS 自动 zoom */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* 隐藏原文里移动端不需要的装饰元素 */
  .desktop-only,
  .show-on-desktop { display: none !important; }

  /* 文章标题：避免换行错乱 */
  .entry-title {
    font-size: 22px !important;
    line-height: 1.3 !important;
    margin: 8px 0 12px !important;
  }

  /* 文章内文 font-size 提升 */
  .entry-content {
    font-size: 17px !important;
    line-height: 1.75 !important;
  }
  .entry-content p { margin: 12px 0 !important; }
  .entry-content h2 { font-size: 19px !important; margin-top: 1.4em !important; }
  .entry-content h3 { font-size: 17px !important; margin-top: 1.2em !important; }

  /* 图片自适应 */
  .entry-content img,
  .entry-content figure,
  .entry-content iframe {
    max-width: 100% !important;
    height: auto !important;
  }
  /* 表格：横向 scroll wrapper，避免撑破布局 */
  .entry-content table {
    display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }

  /* 价格 / 列表卡片化 */
  .wp-block-table table,
  table {
    font-size: 14px !important;
  }

  /* 顶栏压缩：把次要菜单折叠（依赖主题原 css-hidden） */
  header .menu-toggle { display: inline-flex !important; }

  /* 评论区输入框字号 */
  #commentform textarea { font-size: 16px !important; }
}

/* 桌面端默认就显示原文布局；PWA standalone 模式 (display-mode) 也走 @media (max-width:768px) */
@media (display-mode: standalone) {
  body { -webkit-user-select: none; user-select: none; }
}
