/* =========================================================
   shared-sidebar.css
   用途：所有帶左側選單頁面的共用版型與 nav 樣式
   適用單元：關於華城 / 投資人專區 / 華城技術 / 產品介紹…
   載入順序：main.css → menu.css → slide.css → shared-sidebar.css → shared-typography.css

   間距 token（全站共用，各單元可覆寫）：
     --side-gap      左欄與右欄間距（桌機預設 48px）
     --side-page-x   版面左右外距（桌機預設 56px）

   HTML 結構：
     <div class="section-page">
       <div class="section-layout">
         <aside class="section-sidebar">
           <nav class="side-nav">
             <div class="side-nav-title">
               <span>SECTION LABEL</span>
               <strong>單元名稱</strong>
             </div>
             <ul class="side-nav-list">
               <li><a class="side-nav-link [active]" href="...">項目</a></li>
             </ul>
           </nav>
         </aside>
         <main class="section-main">
           ...
         </main>
       </div>
     </div>
========================================================= */

/* =========================================================
   Design tokens
   各單元可在自己的 CSS 裡覆寫這些變數，限定作用範圍。
   例：.investor-section-page { --side-primary: #1a3e6b; }
========================================================= */
:root {
  --side-primary:      #0c596f;
  --side-primary-deep: #083d4d;
  --side-accent:       #19a7b8;
  --side-text:         #425863;
  --side-line:         rgba(12, 89, 111, 0.10);
}

/* =========================================================
   全域防橫向捲動
========================================================= */
body {
  overflow-x: hidden;
}

/* =========================================================
   Page wrapper
========================================================= */
.section-page {
  --side-w:            260px;
  --side-gap:          48px;
  --side-page-x:       56px;
  --side-max-w:        1360px;
  background: #ffffff;
  padding: 62px 0 88px;
}

/* 覆蓋 Bootstrap .container 在右欄內造成的置中留白（常被誤認成側欄間距過大） */
.section-main .container,
.section-main .container-xxl,
.section-main .container-fluid,
.section-main .container-lg,
.section-main .container-md,
.section-main .container-sm,
.section-main .container-xl {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
}

/* =========================================================
   Two-column grid layout
========================================================= */
.section-layout {
  width: min(var(--side-max-w), calc(100% - (var(--side-page-x) * 2)));
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  column-gap: var(--side-gap);
  row-gap: var(--side-gap);
  align-items: start;
}

/* =========================================================
   Sidebar column（左欄，sticky）
========================================================= */
.section-sidebar {
  position: sticky;
  top: 122px;
  align-self: start;
  z-index: 10;
  width: var(--side-w);
}

/* =========================================================
   Main content column（右欄）
   min-width: 0 防止 grid 子元素撐破欄位
   overflow-x: hidden 防止內容造成 body 橫向捲動
========================================================= */
.section-main {
  /* 覆蓋 common.css 的 main { width: 85%; margin: 0 auto; }（rwd-slider 遺留，會造成側欄與內容間大片空白） */
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  align-self: start;
  overflow-x: hidden;
}

/* =========================================================
   Sidebar nav card
========================================================= */
.side-nav {
  width: var(--side-w);
  background: #ffffff;
  border: 1px solid #e3eef2;
  box-shadow: 0 2px 8px rgba(7, 41, 56, 0.04);
}

/* =========================================================
   Sidebar title block
========================================================= */
.side-nav-title {
  padding: 24px;
  border-bottom: 1px solid var(--side-line);
}

/* 英文小標（INVESTOR RELATIONS 等） */
.side-nav-title span {
  display: block;
  margin-bottom: 8px;
  color: #0c596f;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* 中文主標（投資人專區 等） */
.side-nav-title strong {
  display: block;
  color: #083d4d;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
}

/* =========================================================
   Nav list
========================================================= */
.side-nav-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.side-nav-list li {
  margin: 0;
  padding: 0;
}

/* =========================================================
   Nav link
========================================================= */
.side-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 14px 24px 14px 36px;
  color: var(--side-text);
  font-size: 15px;
  line-height: 1.45;
  text-decoration: none;
  border-bottom: 1px solid rgba(12, 89, 111, 0.065);
  transition: color 0.22s ease, background 0.22s ease, padding-left 0.22s ease;
}

.side-nav-list li:last-child .side-nav-link {
  border-bottom: 0;
}

/* 左側小圓點 */
.side-nav-link::before {
  content: "";
  position: absolute;
  left: 20px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--side-accent);
  transform: translateY(-50%);
  opacity: 0.45;
}

/* 右側箭頭 */
.side-nav-link::after {
  content: "";
  position: absolute;
  right: 20px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
  opacity: 0;
  transition: opacity 0.22s ease, right 0.22s ease;
}

/* Hover */
.side-nav-link:hover {
  color: #0c596f;
  background: #f0f7f9;
  padding-left: 40px;
}

.side-nav-link:hover::before {
  opacity: 1;
}

.side-nav-link:hover::after,
.side-nav-link.active::after {
  opacity: 1;
  right: 18px;
}

/* Active */
.side-nav-link.active {
  color: #0c596f;
  font-weight: 700;
  background: linear-gradient(90deg, rgba(12, 89, 111, 0.10), transparent);
}

.side-nav-link.active::before {
  opacity: 1;
}

/* =========================================================
   Mobile section select
   桌機 / 平板：隱藏；手機 575px 以下：顯示
========================================================= */
.mobile-section-select {
  display: none;
}

/* =========================================================
   手機版橫幅 overrides（≤ 575px）
   目的：覆蓋 style.css 的高 padding 與 slide.css 的動畫。
   shared-sidebar.css 在 slide.css 之後載入，同等選擇器後來居上，
   無需 !important。
========================================================= */
@media (max-width: 575.98px) {
  /* 降低橫幅高度，padding-top 86px 確保不被固定 header 蓋住 */
  .container-fluid.page-header {
    padding-top: 86px;
    padding-bottom: 2.5rem;
    min-height: 220px;
  }

  /* 關閉背景 zoom 動畫（headerBgZoom），固定為 cover */
  .page-header-animated .page-header__bg {
    animation: none;
    background-size: cover;
    background-position: center center;
  }

  /* 關閉掃光（headerSheen）並隱藏偽元素 */
  .page-header.page-header-animated::after {
    animation: none;
    opacity: 0;
  }

  /*
   * slide.css 將 .container.text-center 設為 opacity:0 並靠動畫淡入。
   * 在手機版關閉所有動畫後，必須強制設回可見，否則內容隱形。
   */
  .page-header-animated > .container.text-center {
    opacity: 1;
    animation: none;
    transform: none;
  }

  /* 標題字級縮小（覆蓋 slide.css inline-block 設定） */
  .page-header-animated h1.display-4 {
    font-size: 2rem;
    padding-bottom: 6px;
    margin-bottom: 0.5rem;
  }

  /* 標題底線動畫也關閉，保持固定寬度 */
  .page-header-animated h1.display-4::after {
    animation: none;
    width: 48px;
    opacity: 1;
  }

  /* 麵包屑縮小，opacity 強制為 1（同 slide.css 的淡入問題） */
  .page-header-animated .breadcrumb {
    font-size: 0.78rem;
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* =========================================================
   RWD — 1200px 以下：側欄改為上方橫向
========================================================= */
@media (max-width: 1199.98px) {
  .section-page {
    padding-top: 48px;
    padding-bottom: 72px;
    --side-gap: 36px;
    --side-page-x: 32px;
  }

  .section-layout {
    width: min(960px, calc(100% - (var(--side-page-x) * 2)));
    grid-template-columns: 1fr;
  }

  .section-sidebar {
    position: static;
    width: 100%;
  }

  .side-nav {
    width: 100%;
  }

  /* Nav 改三欄水平排列 */
  .side-nav-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 0;
  }

  /* 水平模式：分隔線改右側邊框、隱藏右箭頭、文字置中 */
  .side-nav-link {
    justify-content: center;
    padding-left: 12px;
    padding-right: 12px;
    border-bottom: 0;
    border-right: 1px solid rgba(12, 89, 111, 0.065);
  }

  .side-nav-link:hover {
    padding-left: 12px;
  }

  .side-nav-link::after {
    display: none;
  }

  /* 每行最後一個移除右邊框 */
  .side-nav-list li:nth-child(3n) .side-nav-link {
    border-right: 0;
  }
}

/* RWD — 768px 以下：改兩欄 */
@media (max-width: 767.98px) {
  .section-page {
    padding-top: 44px;
    padding-bottom: 64px;
    --side-gap: 28px;
    --side-page-x: 28px;
  }

  .section-layout {
    width: calc(100% - (var(--side-page-x) * 2));
  }

  .side-nav-title {
    padding: 20px;
  }

  .side-nav-title strong {
    font-size: 22px;
  }

  .side-nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-nav-list li:nth-child(3n) .side-nav-link {
    border-right: 1px solid rgba(12, 89, 111, 0.065);
  }

  .side-nav-list li:nth-child(2n) .side-nav-link {
    border-right: 0;
  }
}

/* RWD — 576px 以下：隱藏選單 list，改用下拉選單 */
@media (max-width: 575.98px) {
  .side-nav-title {
    padding: 16px 16px 14px;
  }

  /* 隱藏桌機 / 平板版選單列表 */
  .side-nav-list {
    display: none;
  }

  /* 顯示手機版下拉選單 */
  .mobile-section-select {
    display: block;
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--side-text);
    background: #ffffff;
    border: none;
    border-top: 1px solid var(--side-line);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    /* 簡單右側箭頭：用 background SVG */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%230c596f' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-color: #ffffff;
    padding-right: 40px;
  }

  .mobile-section-select:focus {
    border-color: var(--side-accent);
    box-shadow: 0 0 0 3px rgba(25, 167, 184, 0.15);
  }

  .mobile-section-select option {
    font-weight: 600;
    color: var(--side-text);
  }
}
