/**
 * ewweb-base.css — 翼王智網 前台基礎樣式
 *
 * 取代原本的 BootstrapMade「Flattern」樣板（assets/css/style.css）。
 * 底層沿用 Bootstrap 5（MIT 授權），本檔只補 Bootstrap 沒有的版面元件：
 * 頂部聯絡列、頁首、主選單（含多層下拉與手機版）、橫幅、內頁、頁尾、回頂端按鈕。
 *
 * 色彩一律使用 CSS variables（定義於 ewweb-theme.css 與 assets/themes/theme{N}.css），
 * 本檔不寫死任何品牌色，才能讓 8 種色系版型與站台自訂色生效。
 *
 * 載入順序：bootstrap.min.css → ewweb-base.css → ewweb-theme.css → theme{N}.css → 站台自訂
 */

/* ===========================================================================
 * 全域
 * =========================================================================== */
body {
  font-family: "Noto Sans TC", "Noto Sans CJK TC", "Open Sans", "微軟正黑體", sans-serif;
  color: var(--ew-text, #37475c);
  font-size: 16px;
  line-height: 1.7;
}

a { color: var(--ew-accent); text-decoration: none; }
a:hover { color: var(--ew-accent-hover); }

h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.35; }

img { max-width: 100%; height: auto; }

/* 跳過導覽（無障礙）：平時移出畫面，取得焦點時顯示 */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  z-index: 1000;
  padding: 8px 14px;
  background: #fff;
  color: #000;
  border: 2px solid var(--ew-primary);
}
.skip-link:focus { top: 0; }

/* 螢幕閱讀器專用文字 */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ===========================================================================
 * 頂部聯絡列
 * =========================================================================== */
#topbar {
  background: var(--ew-bg-soft, #f6f9fc);
  height: 46px;
  font-size: 0.95rem;
  padding: 0;
  border-bottom: 1px solid rgba(0, 0, 0, .05);
}
#topbar .contact-info i { font-style: normal; margin-right: 4px; }
#topbar .contact-info a { color: var(--ew-primary); }
#topbar .contact-info a:hover { color: var(--ew-accent); }
#topbar .social-links a {
  color: var(--ew-primary);
  padding-left: 12px;
  display: inline-block;
}
#topbar .social-links a:hover { color: var(--ew-accent); }

/* ===========================================================================
 * 頁首與 Logo
 * =========================================================================== */
#header {
  background: #fff;
  height: 70px;
  transition: all .3s;
  z-index: 997;
}
#header.fixed-top { position: fixed; top: 0; left: 0; right: 0; }
#header .logo { line-height: 1; }
#header .logo h1 {
  font-size: 1.6rem;
  margin: 0;
  font-weight: 600;
}
#header .logo h1 a,
#header .logo h1 a:hover { color: var(--ew-primary); }
#header .logo img { max-height: 46px; }

/* ===========================================================================
 * 主選單（桌機）
 * =========================================================================== */
.navbar { padding: 0; }
.navbar ul {
  margin: 0;
  padding: 0;
  display: flex;
  list-style: none;
  align-items: center;
}
.navbar li { position: relative; }
.navbar a,
.navbar a:focus {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 10px 20px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ew-text, #37475c);
  white-space: nowrap;
  transition: .3s;
}
.navbar a i, .navbar a:focus i {
  font-size: 12px;
  line-height: 0;
  margin-left: 5px;
}
.navbar a:hover,
.navbar .active,
.navbar .active:focus,
.navbar li:hover > a { color: var(--ew-accent); }

/* 下拉選單 */
.navbar .dropdown ul {
  display: block;
  position: absolute;
  left: 14px;
  top: calc(100% + 30px);
  margin: 0;
  padding: 10px 0;
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  background: #fff;
  box-shadow: 0 0 30px rgba(127, 137, 161, .25);
  transition: .3s;
  border-radius: 4px;
  min-width: 200px;
}
.navbar .dropdown:hover > ul,
.navbar .dropdown.show > ul {
  opacity: 1;
  top: 100%;
  visibility: visible;
}
.navbar .dropdown ul li { min-width: 200px; }
.navbar .dropdown ul a {
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  text-transform: none;
}
.navbar .dropdown ul a i { font-size: 12px; }
.navbar .dropdown ul a:hover,
.navbar .dropdown ul .active:hover,
.navbar .dropdown ul li:hover > a { color: var(--ew-accent); }

/* 第三層以後：往右浮出 */
.navbar .dropdown .dropdown ul {
  top: 0;
  left: calc(100% - 30px);
  visibility: hidden;
}
.navbar .dropdown .dropdown:hover > ul,
.navbar .dropdown .dropdown.show > ul {
  opacity: 1;
  top: 0;
  left: 100%;
  visibility: visible;
}
@media (max-width: 1366px) {
  .navbar .dropdown .dropdown ul { left: -90%; }
  .navbar .dropdown .dropdown:hover > ul,
  .navbar .dropdown .dropdown.show > ul { left: -100%; }
}

/* 桌機不顯示漢堡鈕 */
.mobile-nav-toggle { display: none; }

/* ===========================================================================
 * 主選單（手機／平板）
 * =========================================================================== */
@media (max-width: 991px) {
  .mobile-nav-toggle {
    display: block;
    color: var(--ew-text, #37475c);
    font-size: 28px;
    cursor: pointer;
    line-height: 0;
    transition: .5s;
    background: none;
    border: 0;
  }
  .mobile-nav-toggle.bi-x { color: #fff; }
  .navbar ul { display: none; }

  .navbar-mobile {
    position: fixed;
    overflow: hidden;
    top: 0; right: 0; left: 0; bottom: 0;
    background: rgba(28, 22, 20, .9);
    transition: .3s;
    z-index: 999;
  }
  .navbar-mobile .mobile-nav-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
  }
  .navbar-mobile ul {
    display: block;
    position: absolute;
    top: 55px; right: 15px; bottom: 15px; left: 15px;
    padding: 10px 0;
    background: #fff;
    overflow-y: auto;
    transition: .3s;
    border-radius: 6px;
  }
  .navbar-mobile a { padding: 12px 20px; font-size: 1rem; }
  .navbar-mobile .dropdown ul {
    position: static;
    display: none;
    margin: 10px 20px;
    padding: 10px 0;
    z-index: 99;
    opacity: 1;
    visibility: visible;
    box-shadow: 0 0 30px rgba(127, 137, 161, .25);
  }
  .navbar-mobile .dropdown > .dropdown-active { display: block; }
}

/* ===========================================================================
 * 橫幅（Hero）
 * =========================================================================== */
#hero {
  width: 100%;
  height: 630px;
  position: relative;
  overflow: hidden;
}
#hero .carousel-item {
  width: 100%;
  height: 630px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
#hero .carousel-item::before {
  content: "";
  background: rgba(0, 0, 0, .25);
  position: absolute;
  inset: 0;
}
#hero .carousel-container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  inset: 0;
  padding: 0 60px;
}
/* 橫幅文字：圖片只做背景，標題與說明一律用 HTML 呈現（讀屏可讀、客戶可自行修改） */
#hero .carousel-content {
  text-align: center;
  color: #fff;
  max-width: 900px;
}
#hero h2 {
  color: #fff;
  margin-bottom: 16px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1.25;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .6);
}
#hero p {
  color: #fff;
  font-size: clamp(1rem, 1.6vw, 1.4rem);
  margin-bottom: 20px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
}
#hero .h100 { height: 630px; overflow: hidden; }
#hero .h100 img { width: 100%; height: 100%; object-fit: cover; }

#hero .carousel-control-prev,
#hero .carousel-control-next { width: 10%; }
#hero .carousel-indicators li {
  cursor: pointer;
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background-color: rgba(255, 255, 255, .6);
  border: 0;
  margin: 0 4px;
}
#hero .carousel-indicators li.active { background-color: #fff; }

.btn-get-started {
  display: inline-block;
  padding: 10px 28px;
  border-radius: var(--ew-radius);
  background: var(--ew-secondary);
  color: #fff;
  font-weight: 600;
  transition: .3s;
}
.btn-get-started:hover { background: var(--ew-secondary-hover); color: #fff; }

@media (max-width: 991px) {
  #hero, #hero .carousel-item, #hero .h100 { height: 460px; }
  #hero h2 { font-size: 1.6rem; }
  #hero .carousel-container { padding: 0 20px; }
}

/* ===========================================================================
 * 內容區（內頁／列表／文章）
 * =========================================================================== */
section { padding: 40px 0; }
.inner-page { padding: 30px 0 50px; }
.inner-page h2, .inner-page h3 { color: var(--ew-primary); }

/* 文章卡片（部落格類版型） */
.post-item {
  border: 1px solid #e3e8ee;
  border-radius: var(--ew-radius);
  overflow: hidden;
  transition: box-shadow .3s;
  background: #fff;
  height: 100%;
}
.post-item:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .08); }
.post-item h4 { padding: 12px 14px 0; font-size: 1.05rem; }
.post-item h4 a { color: var(--ew-primary); }
.post-item h4 a:hover { color: var(--ew-accent); }
.post-item .details { padding: 0 14px 14px; }

/* 文章內文 */
.entry-content { text-align: justify; }
.entry-content img { margin: 12px 0; border-radius: 4px; }
/* 內文表格在手機上可橫向捲動，不撐破版面
 *
 * B14（2026-08-30）：原本直接對 <table> 下 display:block 與 white-space:nowrap，
 * 兩者都有副作用：
 *   - display:block 會讓部分瀏覽器與輔助技術失去表格語意（列與欄的對應關係），
 *     螢幕閱讀器唸不出「第幾列第幾欄」，對無障礙是倒退
 *   - white-space:nowrap 強制每個儲存格單行，寬表格反而變得更寬、捲動距離加倍
 *
 * 改為把捲動交給外層容器：table 本身保持 display:table 的語意，
 * 由 .table-responsive 或本站自動包上的 .ew-table-wrap 負責橫向捲動。
 * 捲動容器加 tabindex 才能用鍵盤捲動（WCAG 2.1 的 2.1.1 鍵盤可操作）。
 */
.entry-content .ew-table-wrap,
.page-builder-content .ew-table-wrap,
.entry-content .table-responsive,
.page-builder-content .table-responsive {
  overflow-x: auto;
  max-width: 100%;
  /* min-width:0 是關鍵：容器若身處 flex/grid 版面，預設的 min-width:auto
   * 會讓它被內容（寬表格）撐大，max-width:100% 攔不住，
   * 結果整個頁面在桌機寬度下橫向溢出。實測確認過。 */
  min-width: 0;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.entry-content .ew-table-wrap:focus-visible,
.page-builder-content .ew-table-wrap:focus-visible {
  outline: 2px solid var(--ew-primary, #1565c0);
  outline-offset: 2px;
}

.entry-content table,
.page-builder-content table {
  max-width: 100%;              /* 無 JavaScript 時的保護：不撐破版面 */
}

/* 已包進捲動容器的表格改為依內容自然撐開，由容器負責橫向捲動。
 * 若仍限制 max-width，表格只會把欄寬壓扁（預算表那種內容會擠成一團），
 * 而不是提供捲動。 */
.ew-table-wrap > table {
  max-width: none;
  width: auto;
  min-width: 100%;
}

/* 側欄 */
.sidebar-item { margin-bottom: 24px; }
.sidebar-item h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ew-primary);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ew-secondary);
}

/* ===========================================================================
 * 回頂端按鈕
 * =========================================================================== */
.back-to-top {
  position: fixed;
  visibility: hidden;
  opacity: 0;
  right: 15px;
  bottom: 15px;
  z-index: 996;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  transition: all .4s;
  background: var(--ew-accent);
  color: #fff;
}
.back-to-top i { font-size: 24px; color: #fff; line-height: 0; }
.back-to-top:hover { background: var(--ew-accent-hover); color: #fff; }
.back-to-top.active { visibility: visible; opacity: 1; }

/* ===========================================================================
 * 焦點可見性（無障礙）
 * =========================================================================== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--ew-secondary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── 字級調整（C24，2026-08-30）────────────────────────────
 * 三段字級套在 html 元素的 font-size 上，內文以 rem 為單位，
 * 因此改 html 的字級就會整站等比放大。
 * 只調整內文區，主選單與頁尾維持原尺寸——把導覽一起放大會讓
 * 選單在小螢幕上換行破版，反而更難用。 */
.ew-fontsize {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    margin-left: 1rem;
}
.ew-fontsize-label { font-size: .85em; opacity: .85; }
.ew-fs-btn {
    min-width: 1.9rem;
    min-height: 1.9rem;
    padding: 0 .35rem;
    border: 1px solid currentColor;
    border-radius: 3px;
    background: transparent;
    color: inherit;
    font-size: .85em;
    line-height: 1.7;
    cursor: pointer;
}
.ew-fs-btn:hover { background: rgba(255, 255, 255, .18); }
.ew-fs-btn[aria-pressed="true"] {
    background: #fff;
    color: #1f2937;
    font-weight: 700;
}
.ew-fs-btn:focus-visible {
    outline: 3px solid #f03c02;
    outline-offset: 2px;
}
/* 字級套用在內容區：main 與頁尾說明文字 */
html[data-fs="large"]  #main-content,
html[data-fs="large"]  .ew-footer-contact { font-size: 1.15rem; }
html[data-fs="small"]  #main-content,
html[data-fs="small"]  .ew-footer-contact { font-size: .9rem; }

/* ── 頁尾政策連結列（C20/C25）與更新日期（C23）────────── */
.ew-foot-policy {
    margin-top: .75rem;
    font-size: .95em;
    line-height: 2;
}
.ew-foot-policy a { text-decoration: underline; }
.ew-foot-policy span[aria-hidden] { margin: 0 .4rem; opacity: .6; }
.ew-foot-updated { margin-top: .5rem; font-size: .9em; opacity: .9; }
.ew-service-hours,
.ew-org-taxid { font-size: .95em; }

/* ── 手機版捷徑（C26）──────────────────────────────────── */
/* topbar 在手機上必須可換行：原本 contact-info（信箱＋電話）已經佔滿寬度，
 * 再放三個 44px 的捷徑就會把內容推出視窗、產生橫向捲軸。
 * 量測：390px 裝置上溢出 22px。 */
@media (max-width: 767.98px) {
    #topbar > .container {
        flex-wrap: wrap;
        row-gap: .25rem;
    }
    #topbar .contact-info {
        flex-wrap: wrap;
        justify-content: center;
    }
}
.ew-mobile-links a {
    color: inherit;
    font-size: 1.15rem;
    /* 觸控目標至少 44×44：只放圖示時外框只有 18×20，手指很難點中。
     * WCAG 2.2 的 2.5.8（AA）下限是 24×24，這裡取行動裝置的實務建議值 44。 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}
/* 有了 44px 的框就不需要額外的水平間距 */
.ew-mobile-links a.ms-3 { margin-left: 0 !important; }
.ew-mobile-links a:focus-visible {
    outline: 3px solid #f03c02;
    outline-offset: 3px;
}

/* ── 常見問答折疊呈現（C28）───────────────────────────── */
.ew-faq-item { border-bottom: 1px solid #e5e7eb; }
.ew-faq-q {
    width: 100%;
    text-align: left;
    padding: 1rem .25rem;
    border: 0;
    background: transparent;
    font-size: 1.05rem;
    font-weight: 600;
    color: inherit;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
}
.ew-faq-q:hover { color: #1d4ed8; }
.ew-faq-q:focus-visible { outline: 3px solid #f03c02; outline-offset: -3px; }
.ew-faq-q .ew-faq-icon { transition: transform .2s; flex: 0 0 auto; }
.ew-faq-q[aria-expanded="true"] .ew-faq-icon { transform: rotate(180deg); }
.ew-faq-a { padding: 0 .25rem 1.25rem; line-height: 1.9; }

/* ── 上一篇／下一篇（C29，2026-08-30）──────────────────── */
.ew-prevnext { margin-top: 2.5rem; border-top: 1px solid #e5e7eb; padding-top: 1rem; }
.ew-prevnext ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.ew-prevnext li { flex: 1 1 260px; min-width: 0; }
.ew-prevnext .ew-next { text-align: right; }
.ew-pn-label {
    display: block;
    font-size: .85rem;
    color: #6b7280;
    margin-bottom: .15rem;
}
.ew-prevnext a {
    display: block;
    font-weight: 600;
    /* 標題可能很長，限制兩行並以省略號收尾，避免把版面撐開 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
@media (max-width: 575.98px) {
    .ew-prevnext .ew-next { text-align: left; }
}

/* ── 附件檔案資訊（C31）──────────────────────────────── */
.ew-attach-meta { font-size: .9em; white-space: nowrap; }

/* ── 圖片燈箱（C30，2026-08-30）────────────────────────
 * 不引入燈箱套件（先前 GLightbox 已被移除），用原生 <dialog> 自己做。
 * <dialog> 的 showModal() 內建焦點鎖定與 Esc 關閉，這正是燈箱最難自己寫對的部分。 */
.ew-lightbox { display: inline-block; cursor: zoom-in; }
#ewLightboxDlg {
    border: 0;
    padding: 0;
    background: transparent;
    max-width: 96vw;
    max-height: 96vh;
    overflow: visible;
}
#ewLightboxDlg::backdrop { background: rgba(0, 0, 0, .82); }
#ewLightboxDlg img {
    display: block;
    max-width: 96vw;
    max-height: 84vh;
    margin: 0 auto;
    border-radius: 4px;
    background: #fff;
}
#ewLightboxDlg .ew-lb-cap {
    color: #fff;
    text-align: center;
    padding: .6rem 1rem 0;
    font-size: .95rem;
}
#ewLightboxDlg .ew-lb-close {
    position: absolute;
    top: -.6rem;
    right: -.6rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: #111;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}
#ewLightboxDlg .ew-lb-close:focus-visible { outline: 3px solid #f03c02; outline-offset: 3px; }

/* ── 列印樣式（C32，2026-08-30）────────────────────────
 * 全站原本沒有任何 @media print，列印時會把主選單、漢堡鈕、輪播、
 * 頁尾導覽整份印出來，一則公告要印三頁。 */
@media print {
    #topbar, #header, .navbar, #hero, .carousel, .ew-mobile-links,
    .back-to-top, .ew-fontsize, .ew-prevnext, .breadcrumb,
    .sitemap-nav, .ew-footer .nav-group, .social-links,
    .ew-share, #Z, #C, #U, #acccenter { display: none !important; }

    body { background: #fff !important; color: #000 !important; font-size: 12pt; }
    #main-content, .container { width: auto !important; max-width: none !important; margin: 0 !important; padding: 0 !important; }
    a { text-decoration: none; color: #000; }
    /* 列印時把連結網址印出來，紙本才知道連到哪裡 */
    #main-content a[href^="http"]::after { content: "（" attr(href) "）"; font-size: 9pt; word-break: break-all; }
    #main-content a[href^="#"]::after { content: ""; }
    img { max-width: 100% !important; page-break-inside: avoid; }
    table, figure, .ew-faq-item { page-break-inside: avoid; }
    h1, h2, h3 { page-break-after: avoid; }
    .ew-foot-updated, .ew-footer-contact { display: block !important; font-size: 10pt; }
}

/* ── 影片內嵌（C35，2026-08-30）────────────────────────
 * 用 aspect-ratio 維持 16:9，不再靠 jQuery 在 resize 時重算高度——
 * 原本的做法在首次載入與關閉 JavaScript 時比例都是錯的。 */
.ew-video {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 1rem auto;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
}
.ew-video iframe,
.ew-video video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
/* 不支援 aspect-ratio 的舊瀏覽器：退回 padding-top 的比例框 */
@supports not (aspect-ratio: 16 / 9) {
    .ew-video { height: 0; padding-top: 56.25%; }
}
.ew-video-link { margin: 1rem 0; }

/* ── 語言切換（F2，2026-08-31）──────────────────────────── */
.ew-lang-switch {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin-left: 1rem;
    color: inherit;
    min-height: 44px;      /* 觸控目標（與手機捷徑同一標準） */
    padding: 0 .4rem;
}
.ew-lang-switch:hover { text-decoration: underline; }
.ew-lang-switch:focus-visible { outline: 3px solid #f03c02; outline-offset: 2px; }
