/*
 * MyGWTStyle.css
 * 修正 Sony GWT（Global Web Template）Header & Footer 在宿主網站裡版型、文字過小（或過大）的問題。
 *
 * 【問題根因】
 * GWT 的 CSS（clientlib-shf-ec.css）大量使用 rem 單位，原本以瀏覽器預設 html font-size = 16px 為基準設計。
 * 宿主網站若改了 html 的 font-size（例如會員前台 style.grey-800.css 設為 10px），
 * GWT 所有 rem 尺寸會等比例縮放（10/16 = 62.5%），造成 Header & Footer 過小。
 * 宿主網站自己的版型也依賴自己的 html font-size，所以不能直接把 html 改回 16px。
 *
 * 【修正原理】
 * 以 CSS zoom 把 GWT 的根元素整塊放大（或縮小）16 / 宿主 html font-size 倍，讓 rem 尺寸回到原設計大小。
 *
 * 【套用到其他網站】
 * 1. 複製本檔，並於 <head> 引用。
 * 2. 只需調整下方 --gwt-html-font-size 為該網站 html 的 font-size 數字（不含 px 單位）。
 *    也可以不改本檔，在引用本檔之後的 <style> 覆寫 :root { --gwt-html-font-size: 20; }。
 *    若該站 html font-size 是瀏覽器預設 16px，設為 16 時 zoom = 1，本檔等同不生效。
 *
 * 【容易踩雷處】
 * 1. GWT 的 CSS 是由 Header 的 HTML 一起帶進 <body>，載入順序比 <head> 裡的本檔還晚，
 *    選擇器權重相同時 GWT 會勝出，所以本檔每條覆寫規則都刻意在最前面加上 :root 提高權重。
 * 2. zoom 會連 GWT 原本用 px 撰寫的尺寸也一起放大，因此下方第 (3) 段要把這些 px 值反向換算回原尺寸，
 *    並且必須沿用 GWT 原本的 media query 斷點（992px），否則會蓋掉 GWT 在其他斷點的設定。
 * 3. zoom 元素內的 vh / vw 在各瀏覽器的換算方式不一，故手機漢堡選單改用 top + bottom 定高，不依賴 vh。
 *
 * 【已知限制】
 * 1. 瀏覽器支援 zoom：Chrome、Edge、Safari、Firefox 126+；更舊的 Firefox 會忽略 zoom，維持修正前的樣子。
 * 2. 會員前台沒出現、因此未實測的 GWT 元件：My Sony 下拉選單、購物車 Minicart、EC 商品彈窗等
 *    用到 vw / vh 的元件，若其他網站有顯示，位置可能偏移，屆時需再補換算規則。
 * 3. GWT 另有 .gwx-sony-header 版本的 Header，會員前台未使用，本檔未涵蓋。
 *
 * 【使用頁面】（SonyMember_frontEnd）
 * Views/MemberRegister/AddMemberNewUI.cshtml、Views/Member/EditMemberNewUI.cshtml、
 * Views/Shared/_Layout2024.cshtml（套用此主版頁面的前台頁面）
 */


/* 各網站唯一需要調整的設定：宿主網站 html 的 font-size 數字（不含 px 單位）。
   會員前台的 style.grey-800.css 設定 html { font-size: 10px }，故預設為 10。
   用於上述所有使用頁面。 */
:root {
    --gwt-html-font-size: 10;
}


/* (1) GWT Header（MEGA-HEADER.gwx-app-container）與 Footer（.gwx-sony-footer）的根元素：
   以 zoom 整塊放大回 GWT 原設計的 16px 基準；
   並重設從宿主網站 body 繼承來的字級、行高（會員前台 body 是 15px / 26px，
   固定 px 的行高會讓 Footer「ZH」語系按鈕文字往下偏、連結行距變大），比照 Sony 官網 body 的 16px / 1.6。
   用於上述所有使用頁面的 GWT Header & Footer。 */
:root .gwx-app-container,
:root .gwx-sony-footer {
    zoom: calc(16 / var(--gwt-html-font-size));
    font-size: 1rem; /* zoom 後實際顯示為 16px */
    line-height: 1.6;
}


/* (2) GWT Header 手機版（寬度 < 992px）點漢堡選單展開的全螢幕選單：
   GWT 原本高度為 calc(100vh - 50px)，被 zoom 放大後會超出螢幕底部約 426px（390x844 手機實測），選單下半部捲不到。
   改成固定在 Header 下緣（3.125rem 經 zoom 後 = GWT 手機版 Header 高度 50px）到螢幕底部，高度自動撐滿。
   用於上述所有使用頁面的 GWT Header（手機版）。 */
:root .gwx-app-container .MegaHeader_container .HamburgerMenu_container {
    top: 3.125rem;
    bottom: 0;
    height: auto;
}


/* (3) GWT Footer 原本以 px 撰寫的尺寸會被 zoom 一起放大，以下反向換算回 GWT 原尺寸（原 px 值 × 宿主字級 / 16）。
   GWT 原始值：社群圖示區寬 213px、清單圖片背景寬 118px。
   用於上述所有使用頁面的 GWT Footer（所有寬度）。 */
:root .gwx-sony-footer .GlobalFooterSns {
    width: calc(213px * var(--gwt-html-font-size) / 16);
}

:root .gwx-sony-footer .GlobalFooterListMenuItem__Link .GlobalFooterListMenuImage {
    background-size: calc(118px * var(--gwt-html-font-size) / 16) auto;
}

/* GWT Footer 手機版（寬度 < 992px）手風琴選單的左右留白，GWT 原始值為 20px。
   注意：GWT 在寬度 >= 992px 時會把這些 padding 歸 0，所以本規則只能寫在 < 992px 的斷點內，否則會蓋掉桌機版的 0。
   用於上述所有使用頁面的 GWT Footer（手機版）。 */
@media only screen and (max-width: 991.98px) {
    :root .gwx-sony-footer .GlobalFooter__MainItemButtonInner,
    :root .gwx-sony-footer .GlobalFooter__MainItemBodyInner,
    :root .gwx-sony-footer .GlobalFooter__SecondNav {
        padding-left: calc(20px * var(--gwt-html-font-size) / 16);
        padding-right: calc(20px * var(--gwt-html-font-size) / 16);
    }
}

/* GWT Footer 桌機版（寬度 >= 992px）內容區的最大寬度與左右留白，GWT 原始值為 max-width 1200px、padding 30px。
   未換算的話，寬螢幕下 Footer 內容會撐滿整個畫面而不是置中。
   注意：GWT 在寬度 < 992px 時內容區無左右留白，所以本規則只能寫在 >= 992px 的斷點內。
   用於上述所有使用頁面的 GWT Footer（桌機版）。 */
@media only screen and (min-width: 992px) {
    :root .gwx-sony-footer .GlobalFooter__Inner,
    :root .gwx-sony-footer .GlobalFooter__MetaWrapper {
        max-width: calc(1200px * var(--gwt-html-font-size) / 16);
        padding-left: calc(30px * var(--gwt-html-font-size) / 16);
        padding-right: calc(30px * var(--gwt-html-font-size) / 16);
    }
}
