/* =====================================================================
 * 底部导航 tabbar
 * - 固定底部，安全区适配（iPhone 小横条）
 * - 颜色全部走 CSS 变量，黑红/清新两套主题自动跟随
 * - 条目由 config.php 的 tabbar 数组生成，多了会自动横向滚动
 * ===================================================================== */

.hg-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--color-base1, #0d0d0d) 92%, transparent);
  border-top: 1px solid var(--color-border, rgba(255, 255, 255, .08));
  backdrop-filter: saturate(1.2) blur(12px);
  -webkit-backdrop-filter: saturate(1.2) blur(12px);
}

body.theme-fresh .hg-tabbar {
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid var(--color-border, rgba(14, 42, 36, .1));
  box-shadow: 0 -6px 24px rgba(14, 42, 36, .06);
}

.hg-tabbar__inner {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  gap: 4px;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.hg-tabbar__inner::-webkit-scrollbar { display: none; }

.hg-tabbar__item {
  flex: 1 1 0;
  min-width: 72px;
  max-width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px 4px;
  border-radius: 12px;
  color: var(--color-font1, rgba(255, 255, 255, .55));
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color .18s ease, background .18s ease, transform .12s ease;
}
.hg-tabbar__item:active { transform: scale(.96); }

.hg-tabbar__icon {
  width: 22px;
  height: 22px;
  display: block;
}

.hg-tabbar__label {
  font-size: 11px;
  line-height: 14px;
  letter-spacing: .2px;
  white-space: nowrap;
}

.hg-tabbar__item.is-active {
  color: var(--color-primary, #0fb98a);
  background: var(--color-light-primary, rgba(15, 185, 138, .12));
  font-weight: 600;
}

body.theme-fresh .hg-tabbar__item { color: #6f9188; }
body.theme-fresh .hg-tabbar__item.is-active { color: #08876a; background: #e3f7ef; }

/* 页面底部留出 tabbar 的高度，避免内容被遮住 */
body.has-tabbar .hg-main,
body.has-tabbar main.main {
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}
body.has-tabbar .hg-footer {
  margin-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

/* 全屏视频流页面：tabbar 半透明压深，视频信息区上移，避免遮挡 */
body.ff-body .hg-tabbar {
  background: rgba(8, 8, 10, .72);
  border-top: 1px solid rgba(255, 255, 255, .08);
  box-shadow: none;
}
body.ff-body .hg-tabbar__item { color: rgba(255, 255, 255, .6); }
body.ff-body .hg-tabbar__item.is-active { color: #4ee0b4; background: rgba(15, 185, 138, .18); }
body.ff-body .ff-info,
body.ff-body .ff-bottom { padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important; }

@media (min-width: 1024px) {
  /* 桌面端 tabbar 收窄成居中胶囊，不占满整行 */
  .hg-tabbar {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: 16px;
    width: auto;
    min-width: 340px;
    border-radius: 18px;
    border: 1px solid var(--color-border, rgba(255, 255, 255, .08));
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    padding-bottom: 0;
  }
  body.theme-fresh .hg-tabbar {
    border-color: rgba(14, 42, 36, .1);
    box-shadow: 0 12px 34px rgba(14, 42, 36, .12);
  }
  .hg-tabbar__inner { padding: 4px 6px; }
  .hg-tabbar__item { min-width: 96px; }
  body.has-tabbar .hg-main,
  body.has-tabbar main.main { padding-bottom: 92px; }
  body.has-tabbar .hg-footer { margin-bottom: 92px; }
}

/* ---------------- 让右下角浮动工具（APP 下载 / 回顶）躲开 tabbar ---------------- */
body.has-tabbar .hg-fab {
  bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
}
@media (min-width: 1024px) {
  /* 桌面 tabbar 是居中胶囊，FAB 在右下角不冲突，恢复原位即可 */
  body.has-tabbar .hg-fab { bottom: 24px !important; }
}
body.ff-body .hg-fab {
  bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
}

/* ---------------- 小屏隐藏右下角浮动工具，避免和 tabbar 挤在一起 ---------------- */
@media (max-width: 1023px) {
  body.has-tabbar .hg-fab { display: none !important; }
}

/* 5 项时的紧凑排版（窄屏） */
@media (max-width: 480px) {
  .hg-tabbar__inner { padding: 5px 6px; gap: 2px; }
  .hg-tabbar__item { min-width: 0; padding: 6px 2px 4px; }
  .hg-tabbar__label { font-size: 10.5px; letter-spacing: 0; }
  .hg-tabbar__icon { width: 21px; height: 21px; }
}
