/* topnav.css — 電腦版上方導覽列（2026-11-07 上線；11/06 topnav-preview 的預覽版搬進正式站）
   只套在 header.tn-header（web/index.html 的頁首、spa-skeleton.js、gen_static_pages.py 的預渲染頁首都是）。
   載入順序要在 ui-shell.css 與 index.html 行內樣式之後（放在 </head> 前），才蓋得掉側欄版的規則。
   ≥1080px：上方橫條（品牌(大頭貼)｜5 分頁＋更多▾｜更新時間｜搜尋｜加到桌面｜深淺色）；1080～1365 收窄；
   <1080px：維持原本的 ☰ 抽屜（ui-shell），只是「更多」裡的項目直接列出來、標「更多功能」。
   2026-11-07 15:00 站長：橫條已有分頁名稱，頁首「TAIWAN ETF DATA／分頁名／說明／更新徽章」那塊在 ≥1080px 整塊拿掉省高度，
   更新時間改成橫條搜尋框左邊的小字（.tn-fresh，topnav.js 建）；<1080px 的抽屜版頁首維持不變。
   回滾：拿掉 index.html／gen_static_pages.py 的 topnav.css／topnav.js 引用並把頁首換回側欄版。 */

/* ---------- 共用：品牌圖「宇」換成大頭貼（2026-11-07 15:15 站長選「換成大頭貼」） ----------
   只動 CSS：<span class="brand-mark">宇</span> 的三個來源（index.html、spa-skeleton.js、gen_static_pages 預渲染頁首）都不用改，
   字改透明、背景放 /brand-avatar.png（avatar.png 只裁臉、去掉圖下方那行「籌碼小宇」字，144px；圖還沒載到時先看到青綠色底）。
   ≥1080 橫條與 <1080 抽屜共用；手機版 /m/ 沒有這顆。回滾＝刪這段＋刪 web/brand-avatar.png。 */
.tn-header .brand-mark {
  border-radius: 50%;
  background: var(--teal-hover) url(/brand-avatar.png?v=20261107c) center / cover no-repeat;
  color: transparent;
  box-shadow: 0 0 0 1px var(--line), var(--sh-sm);
}

/* ---------- 共用：更多選單裡的意見回饋／分隔線 ---------- */
.tn-header .tn-more-sep { height: 1px; margin: 6px 4px; background: var(--line); }
.tn-header .tn-chev { width: 12px; height: 12px; flex: none; transition: transform .16s ease; }

/* ======================= 電腦版：上方橫條 ======================= */
@media (min-width: 1080px) {
  body > header.tn-header {
    position: sticky;
    inset: auto;
    top: 0;
    z-index: 45;
    width: 100%;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
  }

  body > header.tn-header .wrap {
    max-width: calc(var(--shell-max) + 64px);
    height: 64px;
    margin: 0 auto;
    padding: 0 32px;
    flex-direction: row;
    align-items: center;
    gap: 22px;
  }

  /* 品牌 */
  .tn-header .brand {
    flex: none;
    padding: 0;
    display: flex;
  }
  .tn-header .brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
  }
  .tn-header .brand-mark { width: 36px; height: 36px; }
  .tn-header .brand .brand-h1 { font-size: 16.5px; }
  .tn-header .brand-product { font-size: 11px; }

  /* 資料日期那整句橫條放不下，改成搜尋框左邊的「● 更新 11/06 23:12」小字（topnav.js 建 .tn-fresh；滑鼠移上去看完整說明） */
  .tn-header .sub { display: none; }
  .tn-header .tn-fresh {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 2px;
    color: var(--sub);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: help;
  }

  /* 2026-11-07 15:00 頁首那塊（TAIWAN ETF DATA／分頁名／說明／更新徽章）在橫條版不顯示：
     :has 讓第一次繪製就不出現、不跳版；body.tn-on（topnav.js 加）給不支援 :has 的舊瀏覽器當備援。兩條要分開寫，
     合寫成一條時舊瀏覽器看不懂 :has 會把整條丟掉。 */
  body:has(header.tn-header) .page-intro { display: none; }
  body.tn-on .page-intro { display: none; }

  /* 分頁 */
  .tn-header .tabs {
    flex: 1 0 auto;   /* 2026-11-07 15:30 不准縮：1280 寬時分頁區被壓到比內容窄，「更多▾」會溢出蓋住更新時間；要縮讓搜尋框縮（有 min-width） */
    min-width: 0;
    height: 100%;
    padding: 0;
    flex-direction: row;
    align-items: stretch;
    gap: 2px;
    overflow: visible;
  }
  .tn-header .tabs > .tab,
  .tn-header .tn-more-btn {
    position: relative;
    width: auto;
    min-height: 0;
    height: 100%;
    padding: 0 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--sub);
    font-size: 14.5px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: color .15s ease;
  }
  .tn-header .tabs > .tab::before { display: none; }
  .tn-header .tabs > .tab::after,
  .tn-header .tn-more-btn::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: transparent;
    transition: background .15s ease;
  }
  .tn-header .tabs > .tab:hover,
  .tn-header .tn-more-btn:hover,
  .tn-header .tn-more.open .tn-more-btn { color: var(--ink); background: transparent; }
  .tn-header .tabs > .tab:hover::after,
  .tn-header .tn-more-btn:hover::after { background: var(--line-strong); }
  .tn-header .tabs > .tab.on,
  .tn-header .tn-more:has(.tab.on) .tn-more-btn { color: var(--teal-hover); }
  .tn-header .tabs > .tab.on::after,
  .tn-header .tn-more:has(.tab.on) .tn-more-btn::after { background: var(--teal); }
  .tn-header .tn-more.open .tn-chev { transform: rotate(180deg); }

  /* 更多▾ 下拉 */
  .tn-header .tn-more { position: relative; display: flex; }
  .tn-header .tn-more-menu {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    z-index: 70;
    min-width: 212px;
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: var(--sh-lg);
  }
  .tn-header .tn-more.open .tn-more-menu { display: flex; }
  .tn-header .tn-more-menu .tab {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    font-size: 14px;
  }
  .tn-header .tn-more-menu .sidebar-feedback {
    width: 100%;
    min-height: 38px;
    margin: 0 !important;
    padding: 7px 10px !important;
    justify-content: flex-start;
    border: 0;
    background: transparent;
    color: var(--sub);
    font-size: 13.5px !important;
    font-weight: 650;
    text-align: left;
  }
  .tn-header .tn-more-menu .sidebar-feedback:hover { background: var(--inset); color: var(--ink); }

  /* 搜尋框 */
  .tn-header .gsearch {
    flex: 0 1 280px;
    min-width: 170px;
    margin: 0;
  }
  .tn-header .gsearch input { height: 40px; }
  .tn-header .gac {
    top: 46px;
    left: auto;
    right: 0;
    width: max(100%, 360px);
  }

  /* 右側：加到桌面（a2hs.js 放進來的 .a2hs-btn-bar）＋深淺色 */
  .tn-header .tn-tools {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .tn-header .tn-tools .a2hs-btn { margin: 0; min-height: 38px; }
  .tn-header .tn-tools .theme-toggle { width: 40px; height: 40px; }

  /* 頁面主體不再讓出側欄寬度 */
  main {
    width: 100%;
    margin: 0;
    padding: 26px 32px 76px;
  }
  footer { margin-left: 0; }

  .freshness-badge[title] { cursor: help; }
}

/* 1080～1365px：位置比較擠，縮字距、縮搜尋框、按鈕只留圖示
   （2026-11-07 15:30 原本到 1279；加了「更新時間」後 1280 寬放不下完整版、「更多▾」會蓋到它，改走緊湊版。
     1366 在區間外，完整版剛好放得下：搜尋框縮到約 261、更多與更新時間還有 22px） */
@media (min-width: 1080px) and (max-width: 1365px) {
  body > header.tn-header .wrap { gap: 12px; padding: 0 20px; }
  .tn-header .tn-x { display: none; }
  .tn-header .brand-product { display: none; }
  .tn-header .tabs > .tab,
  .tn-header .tn-more-btn { padding: 0 9px; font-size: 14px; }
  .tn-header .tabs > .tab::after,
  .tn-header .tn-more-btn::after { left: 8px; right: 8px; }
  .tn-header .gsearch { flex-basis: 200px; min-width: 150px; }
  .tn-header .gsearch-kbd { display: none; }
  .tn-header .tn-fresh { font-size: 12px; gap: 6px; }   /* 「更新 」兩字包在 .tn-x 裡，這段寬度跟著藏，只留 11/06 23:12 */
  .tn-header .tn-tools .a2hs-btn span { display: none; }
  .tn-header .tn-tools .a2hs-btn { padding: 0 11px; }
  main { padding-inline: 24px; }
}

/* ======================= 平板寬度：原本的抽屜 ======================= */
@media (max-width: 1079px) {
  .tn-header .tn-tools { display: none; }
  .tn-header .tn-fresh { display: none; }   /* 抽屜版頁首還在，更新徽章用原本那顆 */
  .tn-header .gsearch { order: 2; }
  .tn-header .tabs { order: 3; }
  .tn-header .tn-more-btn { display: none; }
  .tn-header .tn-more { display: contents; }
  .tn-header .tn-more-menu { display: flex; flex-direction: column; gap: 3px; }
  .tn-header .tn-more-menu::before {
    content: "更多功能";
    margin: 11px 9px 4px;
    color: var(--sub);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .08em;
  }
  .tn-header .tn-more-sep { display: none; }
}

/* ======================= 「市場事件」下拉（2026-11-14 站長：像「更多」一樣移上去就能點分類） =======================
   選單（.tn-ev-menu）與小箭頭由 topnav.js 的 syncEvents() 動態加在「市場事件」後面；只在 ≥1080px 橫條顯示，
   <1080px 抽屜與手機版都看不到（照原樣）。回滾＝刪這段＋拿掉 topnav.js 的「市場事件下拉」那段。 */
.tn-header .tn-ev-menu { display: none; }
.tn-header .tabs > .tab > .tn-chev { display: none; }
@media (min-width: 1080px) {
  .tn-header .tabs { position: relative; }
  .tn-header .tabs > .tab > .tn-chev { display: block; }
  .tn-header .tabs > .tab.tn-ev-open { color: var(--ink); }
  .tn-header .tabs > .tab.on.tn-ev-open { color: var(--teal-hover); }
  .tn-header .tabs > .tab.tn-ev-open > .tn-chev { transform: rotate(180deg); }
  .tn-header .tn-ev-menu {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    z-index: 70;
    min-width: 168px;
    padding: 6px;
    flex-direction: column;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: var(--sh-lg);
  }
  .tn-header .tn-ev-menu.open { display: flex; }
  .tn-header .tn-ev-item {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--sub);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
  }
  .tn-header .tn-ev-item:hover,
  .tn-header .tn-ev-item:focus-visible { background: var(--inset); color: var(--ink); }
  .tn-header .tn-ev-item.on { color: var(--teal-hover); }
}
