/* ============================================================
   tabbar.css — 共用「固定底部導覽」(手機優先)
   自包含:不依賴 chrome.css 變數,直接用設計系統色值,
   讓 pro/v2/* 與前台兩頁(自帶 token)都能正確顯示。
   桌機(>720px)自動隱藏,改用各頁既有的頂部 nav。
   ============================================================ */

:root {
  --tb-h: 60px;                       /* tab bar 主體高度 */
  --tb-safe: env(safe-area-inset-bottom, 0px);
  --tb-bg: rgba(5, 8, 11, 0.92);
  --tb-line: rgba(243, 235, 207, 0.12);
  --tb-ivory: #f3ebcf;
  --tb-muted: #7f9398;                /* 比 text-secondary 再暗一點,讓 active 跳出來 */
  --tb-gold: #d5b464;
  --tb-soft-gold: #bca15d;
  --tb-teal: #5aa5ac;
  --tb-on-gold: #0b0a05;
}

/* 容器:預設不顯示,只有手機才出現 */
.tb-bar { display: none; }
.tb-buy { display: none; }

/* ===== 手機:固定底部 tab bar ===== */
@media (max-width: 720px) {
  /* 讓內容不被 bar 蓋住 */
  body.tb-has-bar { padding-bottom: calc(var(--tb-h) + var(--tb-safe) + 4px) !important; }

  .tb-bar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 90;
    height: calc(var(--tb-h) + var(--tb-safe));
    padding-bottom: var(--tb-safe);
    background: var(--tb-bg);
    border-top: 1px solid var(--tb-line);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.30);
  }

  .tb-tab {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 2px 6px;
    color: var(--tb-muted);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: color 180ms cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
  }
  .tb-tab:active { opacity: 0.85; }

  /* 「全部」是 <button> — 清掉系統預設,與 <a> tab 完全一致 */
  .tb-bar button.tb-tab {
    appearance: none; -webkit-appearance: none;
    background: transparent; border: 0; margin: 0;
    font: inherit; cursor: pointer;
  }

  /* active 上緣金色指示線 */
  .tb-tab.is-active::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 22%; right: 22%;
    height: 2px;
    border-radius: 0 0 2px 2px;
    background: var(--tb-gold);
  }
  .tb-tab.is-active { color: var(--tb-gold); }

  .tb-tab__ic {
    width: 23px; height: 23px;
    display: grid; place-items: center;
    flex: 0 0 auto;
  }
  .tb-tab__ic svg { width: 23px; height: 23px; stroke: currentColor; }

  .tb-tab__lbl {
    font-family: "Noto Sans TC", "Barlow Condensed", system-ui, sans-serif;
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }

  /* 帳號 tab 的頭像(已登入) */
  .tb-tab__ava {
    width: 24px; height: 24px;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--tb-line);
    background: radial-gradient(circle at 32% 32%, rgba(243,235,207,0.06), rgba(5,8,11,0.6));
    display: grid; place-items: center;
    flex: 0 0 auto;
  }
  .tb-tab.is-active .tb-tab__ava { border-color: var(--tb-gold); }
  .tb-tab__ava img {
    width: 84%; height: 84%; object-fit: contain;
    filter: brightness(0) saturate(100%) invert(72%) sepia(38%) saturate(420%) hue-rotate(5deg);
  }

  /* ===== 購票浮動小膠囊(未登入時) ===== */
  .tb-buy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    right: 14px;
    bottom: calc(var(--tb-h) + var(--tb-safe) + 14px);
    z-index: 91;
    padding: 9px 15px;
    border-radius: 999px;
    background: var(--tb-gold);
    color: var(--tb-on-gold);
    font-family: "Noto Sans TC", "Barlow Condensed", system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    border: 1px solid var(--tb-gold);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.36), 0 0 22px rgba(213, 180, 100, 0.22);
  }
  .tb-buy:active { opacity: 0.88; }
  .tb-buy__ic { width: 15px; height: 15px; display: grid; place-items: center; }
  .tb-buy__ic svg { width: 15px; height: 15px; stroke: currentColor; }

  /* ---- 各頁既有底部 sticky 元件讓位 ---- */
  /* preview.html 的發佈 CTA 卡(sticky bottom:16px) */
  body.tb-has-bar .pv-publish { bottom: calc(var(--tb-h) + var(--tb-safe) + 16px) !important; }

  /* ---- finder ⌘K 浮鈕:手機隱藏 ---- */
  /* 「快速跳轉」是桌機鍵盤(⌘K)affordance,且其 bottom:24px 會疊在這條
     tab bar 上。手機上 tab bar 就是常駐導覽、深層頁從「我的」→ 後台 hub
     可達,finder 在此既多餘又會撞版 → 直接隱藏,守住底部只有一條 bar。 */
  body.tb-has-bar .ppf-trigger { display: none !important; }
}

/* 極窄螢幕:縮字 */
@media (max-width: 360px) {
  .tb-tab__lbl { font-size: 10px; }
  .tb-buy { font-size: 12px; padding: 8px 13px; }
}
