/**
 * 主選單：同一列項目等寬、文字水平／垂直置中（#site-nav-desktop / #site-nav-mobile）
 * 需載入於 site-nav-cta-uiverse.css 之後，以覆蓋 CTA 固定寬度。
 */

#site-nav-desktop {
  display: flex !important;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 0.5rem;
  min-width: 0;
}

#site-nav-desktop > a {
  flex: var(--xf-nav-desktop-flex, 1 1 0);
  min-width: var(--xf-nav-min-w, 0px);
  min-height: var(--xf-nav-min-h, 2.625rem);
  font-size: var(--xf-nav-font-size, 0.875rem);
  font-family: var(--xf-nav-font-family, inherit);
  /* 與字級連動；勿繼承父層 .text-sm 的固定 rem 行高，否則行高盒偏高、字看起來偏上 */
  line-height: 1.2;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  box-sizing: border-box;
  padding-inline: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 覆蓋 Uiverse CTA 在導覽列的固定寬；min-width 須跟隨後台（舊版 0 !important 會讓寬度調整失效） */
#site-nav-desktop > .xf-cta {
  width: auto !important;
  min-width: min(100%, var(--xf-nav-min-w, 0px)) !important;
  flex: var(--xf-nav-desktop-flex, 1 1 0) !important;
  min-height: var(--xf-nav-min-h, 2.625rem);
  font-size: var(--xf-nav-font-size, 0.875rem);
  font-family: var(--xf-nav-font-family, inherit);
  line-height: 1.2;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
}

#site-nav-desktop > .xf-cta.xf-cta--4 {
  width: auto !important;
}

/* ⑦ 光暈 ::after 會略超出鈕體，勿裁切 */
#site-nav-desktop > .xf-cta.xf-cta--7,
#site-nav-mobile > .xf-cta.xf-cta--7 {
  overflow: visible !important;
}

#site-nav-mobile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

#site-nav-mobile > a {
  width: 100%;
  min-height: var(--xf-nav-min-h, 2.75rem);
  font-size: var(--xf-nav-font-size, 0.875rem);
  font-family: var(--xf-nav-font-family, inherit);
  line-height: 1.2;
  max-width: 22rem;
  margin-left: auto;
  margin-right: auto;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  box-sizing: border-box;
  padding-inline: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#site-nav-mobile > .xf-cta {
  width: 100% !important;
  max-width: 22rem;
  min-width: 0 !important;
  flex: none;
  min-height: var(--xf-nav-min-h, 2.75rem);
  font-size: var(--xf-nav-font-size, 0.875rem);
  font-family: var(--xf-nav-font-family, inherit);
  line-height: 1.2;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
}

#site-nav-mobile > .xf-cta.xf-cta--1 {
  max-width: 22rem;
}

/* ① StealthWorm 內層字級固定為 11px；在導覽列改為繼承父層（已套 --xf-nav-font-*） */
#site-nav-desktop > .xf-cta .xf-1-txt,
#site-nav-mobile > .xf-cta .xf-1-txt {
  font-size: inherit !important;
  font-family: inherit !important;
  line-height: inherit !important;
  /* 原版 letter-spacing 會讓中文在藥丸內視覺偏一側；撐滿寬後幾何置中 */
  letter-spacing: normal !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100%;
  text-align: center !important;
  box-sizing: border-box;
}

/* ⑦⑧ 字級／字型跟隨導覽列後台設定 */
#site-nav-desktop > .xf-cta.xf-cta--7 .xf-7-label,
#site-nav-mobile > .xf-cta.xf-cta--7 .xf-7-label,
#site-nav-desktop > .xf-cta.xf-cta--8 .xf-8-label,
#site-nav-mobile > .xf-cta.xf-cta--8 .xf-8-label {
  font-size: inherit !important;
  font-family: inherit !important;
  line-height: inherit !important;
}

#site-nav-desktop > .xf-cta.xf-cta--8,
#site-nav-mobile > .xf-cta.xf-cta--8 {
  font-size: inherit !important;
}

/* 窄螢幕時，桌面導覽膠囊同步縮小，避免擠壓覆蓋 Logo */
@media (max-width: 1280px) {
  #site-nav-desktop {
    gap: 0.375rem;
    --xf-nav-min-w: 0px !important;
  }
  #site-nav-desktop > a,
  #site-nav-desktop > .xf-cta {
    min-height: clamp(2rem, 2.8vw, 2.4rem) !important;
    font-size: clamp(0.72rem, 1.1vw, 0.82rem) !important;
    padding-inline: clamp(0.2rem, 0.6vw, 0.38rem) !important;
  }
}

@media (max-width: 1100px) {
  #site-nav-desktop {
    gap: 0.25rem;
  }
  #site-nav-desktop > a,
  #site-nav-desktop > .xf-cta {
    min-height: clamp(1.85rem, 2.4vw, 2.2rem) !important;
    font-size: clamp(0.66rem, 0.95vw, 0.76rem) !important;
    padding-inline: 0.2rem !important;
  }
}
