/* ═══════════════════════════════════════════════════════════════
 * SWAG · 共用 Chrome（header / footer / boot loading）
 * ───────────────────────────────────────────────────────────────
 * 用途：把三個子頁（指令百科 / 指令排行 / 主播社群）原本各自
 * 寫在 inline <style> 的 boot-loading、以及 header / footer 的
 * 重複樣式抽出，集中管理。
 *
 * 不擴張任何功能，純視覺 / 結構統一。
 * ═══════════════════════════════════════════════════════════════ */

/* ── Header ─────────────────────────────────────────────────── */
.swag-chrome-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(249, 248, 246, 0.92);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line, #e8e5e0);
}
.swag-chrome-header .wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 10px 16px;
}
.swag-chrome-header .nav {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--control-h);
}
.swag-chrome-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text, #1a1916);
  flex: 0 0 auto;
}
.swag-chrome-header .brand img {
  height: 22px;
  width: auto;
  display: block;
}
.swag-chrome-header .brand-sep {
  width: 1px;
  height: 16px;
  background: var(--line2, #d4d0c8);
}
.swag-chrome-header .brand-tag {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--mid, #5a5750);
  white-space: nowrap;
}
.swag-chrome-header .langs {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.swag-chrome-header .rank-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text, #1a1916);
  text-decoration: none;
  border: 1px solid var(--line2, #d4d0c8);
  border-radius: 999px;
  background: var(--surface, #fff);
  transition: border-color .15s, color .15s;
}
.swag-chrome-header .rank-link:hover {
  border-color: var(--swag, #2BC5B4);
  color: var(--swag, #2BC5B4);
}

/* Feedback button — 圓形 icon button、開新頁到 feedback URL */
.swag-chrome-header .feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line2, #d4d0c8);
  border-radius: 50%;
  background: var(--surface, #fff);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  transition: border-color .15s, transform .15s;
  flex-shrink: 0;
}
.swag-chrome-header .feedback-btn:hover {
  border-color: var(--swag, #2BC5B4);
  transform: translateY(-1px);
}

/* Dark mode toggle button — 跟 .rank-link 同高度、純 icon 圓形 */
.swag-chrome-header .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line2, #d4d0c8);
  border-radius: 50%;
  background: var(--surface, #fff);
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  line-height: 1;
  transition: border-color .15s, transform .25s;
  flex-shrink: 0;
}
.swag-chrome-header .theme-toggle:hover {
  border-color: var(--swag, #2BC5B4);
  transform: rotate(20deg);
}
.swag-chrome-header .theme-toggle .theme-icon { line-height: 1; }
/* light 強制：太陽 ☀️ */
:root[data-theme="light"] .swag-chrome-header .theme-toggle .theme-icon { display: none; }
:root[data-theme="light"] .swag-chrome-header .theme-toggle::after { content: '☀️'; font-size: 15px; }
/* dark 強制：月亮 🌙 */
:root[data-theme="dark"] .swag-chrome-header .theme-toggle .theme-icon { display: none; }
:root[data-theme="dark"] .swag-chrome-header .theme-toggle::after { content: '🌙'; font-size: 15px; }

/* 手機：縮短「回到主頁面」文字、隱藏 brand-tag */
@media (max-width: 480px) {
  .swag-chrome-header .brand-tag { display: none; }
  .swag-chrome-header .rank-link span { display: none; }
}

/* ── Footer ─────────────────────────────────────────────────── */
.swag-chrome-footer {
  margin-top: 48px;
  padding: 24px 0 32px;
  border-top: 1px solid var(--line, #e8e5e0);
  background: transparent;
}
.swag-chrome-footer .wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
}
.swag-chrome-footer .foot-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.swag-chrome-footer .foot-logo {
  height: 18px;
  width: auto;
  opacity: 0.8;
}
.swag-chrome-footer .foot-note {
  font-size: 12px;
  color: var(--muted, #9a9690);
  letter-spacing: 0.01em;
}

/* ── Boot Loading（原本三頁各自 inline <style> → 抽到此） ── */
.swag-boot-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(249, 248, 246, 0.92);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 9999;
  transition: opacity .18s ease, visibility .18s ease;
}
.swag-boot-loading.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.swag-boot-loading .box {
  width: min(420px, calc(100vw - 40px));
  background: var(--surface, #fff);
  border: 1px solid rgba(212, 208, 200, 0.9);
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.10);
  text-align: center;
  font-family: inherit;
}
.swag-boot-loading .spin {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(212, 208, 200, 0.9);
  border-top-color: #2BC5B4;
  animation: swag-boot-rot 0.7s linear infinite;
  margin: 2px auto 12px;
}
@keyframes swag-boot-rot {
  to { transform: rotate(360deg); }
}
.swag-boot-loading .t {
  font-weight: 700;
  font-size: 14px;
  color: var(--text, #1a1916);
  letter-spacing: -0.01em;
}
.swag-boot-loading .d {
  margin-top: 6px;
  font-size: 12px;
  color: #6f6a63;
  line-height: 1.6;
}
.swag-boot-loading .hint {
  margin-top: 10px;
  font-size: 11px;
  color: #9a9690;
  line-height: 1.6;
}

@media (prefers-reduced-motion: reduce) {
  .swag-boot-loading .spin { animation-duration: 1.6s; }
}

/* ── Bottom tabbar（全平台顯示；5 子頁快速切換） ── */
.swag-tabbar {
  display: grid;            /* 預設全平台都顯示 */
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface, #fff) 92%, transparent);
  border-top: 1px solid var(--line2, #d4d0c8);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom)) 4px;
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
}
.swag-tabbar .tabbar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  background: transparent;
  border: none;
  color: var(--muted, #9a9690);
  text-decoration: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  transition: color .15s, transform .12s;
}
.swag-tabbar .tabbar-btn:active { transform: scale(.94); }
.swag-tabbar .tabbar-btn.is-active { color: var(--swag-dk, #0F7B70); }
.swag-tabbar .tabbar-ic { font-size: 20px; line-height: 1; }
.swag-tabbar .tabbar-lb { font-size: 10.5px; font-weight: 700; letter-spacing: .02em; }

/* tabbar 全平台都顯示；body 留 70px 給 tabbar 不擋內容 */
body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
/* 主播社群有 sticky podcast bar 時，podcast 在 tabbar 上方堆疊 */
body.has-podcast .swag-tabbar { bottom: 0; }
body.has-podcast .podcast-player { bottom: calc(70px + env(safe-area-inset-bottom)); }
body.has-podcast { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }

/* ── 頁內子分頁（指令百科 ↔ 指令排行 切換） ── */
.swag-subtabs {
  max-width: 1040px;
  margin: 0 auto 16px;
  padding: 14px 16px 0;
  border-top: 1px solid var(--line, #e8e5e0);
  display: flex;
  gap: 8px;
}
.swag-subtab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--control-h-sm);
  padding: 0 16px;
  border: 1px solid var(--line2, #d4d0c8);
  border-radius: 999px;
  background: var(--surface, #fff);
  color: var(--mid, #5a5750);
  text-decoration: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: border-color .15s, color .15s, background .15s, transform .12s;
  cursor: pointer;
}
.swag-subtab:hover { border-color: var(--swag, #2BC5B4); color: var(--swag, #2BC5B4); }
.swag-subtab:active { transform: scale(.97); }
.swag-subtab.is-active {
  background: var(--swag-dk, #0F7B70);
  border-color: var(--swag-dk, #0F7B70);
  color: #fff;
  pointer-events: none;
}
.swag-subtab .ic { font-size: 15px; line-height: 1; }
@media (max-width: 480px) {
  .swag-subtabs { padding: 0 12px; }
  .swag-subtab { flex: 1; justify-content: center; padding: 0 10px; font-size: 12.5px; }
}

/* 桌機 ≥720px：tabbar 限寬置中、上方圓角邊框、APP 觀看感 */
@media (min-width: 720px) {
  .swag-tabbar {
    max-width: 720px;
    margin: 0 auto;
    border: 1px solid var(--line2, #d4d0c8);
    border-bottom: none;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, .06);
  }
}
