/* Purpose: 手機首頁「格狀瀏覽」覆蓋層（2 欄商品縮圖目錄）＋ header 切換鈕的樣式；純手寫 CSS，不依賴 tw.css 重編譯。
   Consumers: static/js/grid_browse.js、static/index.html（staging 測試中，Jeff 2026-10-28 指示）
   Status: test —— 回滾：index.html 拿掉本檔與 grid_browse.js 兩行引用＋header 的 #gb-toggle 按鈕即可（備份 index.html.bak.pre_gridbrowse.*） */

/* ---- header 切換鈕：只在手機寬度顯示（≥768px 桌面本來就是格狀） ---- */
.gb-toggle {
    display: none;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    color: var(--ui-accent);
    background: transparent;
    border: 0;
    border-radius: 9999px;
    -webkit-tap-highlight-color: transparent;
    transition: transform .12s ease;
}
.gb-toggle:active { transform: scale(.92); }
.gb-toggle svg { width: 26px; height: 26px; display: block; }
.gb-toggle .gb-ico-reel { display: none; }
.gb-toggle[data-mode="grid"] .gb-ico-grid { display: none; }
.gb-toggle[data-mode="grid"] .gb-ico-reel { display: block; }
@media (max-width: 767.98px) {
    .gb-toggle.gb-ready { display: flex; }
}

/* ---- 覆蓋層：蓋在 #reel-container 與其固定 footer 之上 ---- */
#gb-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;   /* 低於 header(55)、抽屜(50)、AI篩選(45)、商品詳情(46)、安裝提示(40) */
    background: var(--ui-bg);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: calc(var(--grid-header-clearance, 72px) + 4px) 12px calc(env(safe-area-inset-bottom, 0px) + 28px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, visibility 0s linear .18s;
}
#gb-overlay.gb-open {
    opacity: 1;
    visibility: visible;
    transition: opacity .18s ease, visibility 0s;
}
@media (min-width: 768px) {
    #gb-overlay { display: none !important; }
}

.gb-count {
    font-size: 13px;
    color: var(--ui-text-muted);
    padding: 2px 4px 10px;
}

.gb-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 10px;
}

.gb-tile {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0;
    text-align: left;
    background: transparent;
    border: 0;
    color: var(--ui-text);
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.gb-tile:active .gb-img { transform: scale(.985); }

.gb-img {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border-radius: 14px;
    background: #EFEBE5;
    transition: transform .12s ease;
}
.gb-img img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 45%;
    opacity: 0;
    transition: opacity .25s ease;
}
.gb-img img.gb-loaded { opacity: 1; }

.gb-name {
    margin: 8px 2px 0;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 400;
    color: var(--ui-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.gb-foot {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px;
    margin: 4px 2px 0;
}
.gb-price { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.gb-price s {
    font-size: 12px;
    font-weight: 400;
    color: var(--ui-text-muted);
}
.gb-price b {
    font-size: 16px;
    font-weight: 600;
    color: var(--ui-accent);
}
.gb-acts { display: flex; align-items: center; gap: 2px; flex-shrink: 0; margin-right: -6px; }
.gb-act {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 0; border: 0; background: transparent;
    color: var(--ui-text-muted); -webkit-tap-highlight-color: transparent;
}
.gb-act svg { width: 21px; height: 21px; }
.gb-act:active { transform: scale(.9); }
.gb-heart.is-on { color: #ef4444; }

/* 格狀模式時，主頁底部固定的愛心/留言/分享欄與「加入購物車/快速結帳」列（對「目前那一張」操作）先收起來 */
body.gb-grid-open .gb-hide-when-grid { display: none !important; }

/* ---- 返回鍵（Jeff 2026-10-29）：「返回格狀」與商品詳情頁(#pdp-back-btn)的返回鍵，手機一律固定在同一個
   左上位置、同一個樣式（白色半透明圓鈕＋單箭頭）。原本 PDP 在右上（播影片時還往下推 56px 避開原生音量圖示），
   與格狀返回鍵高低左右不一致，且右側會跟靜音鍵重疊。桌面版(≥768px)維持原樣。 ---- */
.gb-back {
    display: none;
    position: fixed;
    z-index: 30;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 9999px;
    -webkit-tap-highlight-color: transparent;
    transition: transform .12s ease;
}
.gb-back:active { transform: scale(.95); }
.gb-back svg { width: 20px; height: 20px; }
@media (max-width: 767.98px) {
    .gb-back.gb-show { display: inline-flex; }
    .gb-back, #pdp-back-btn, #pdp-back-btn.pdp-video-active {
        position: fixed;
        left: 12px !important;
        right: auto !important;
        top: calc(env(safe-area-inset-top, 0px) + var(--grid-header-clearance, 76px) + 0.75rem) !important;
        width: 36px;
        height: 36px;
    }
    .gb-back {
        color: var(--pdp-text, var(--ui-text));
        background: var(--ui-surface, #fff);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
    }
}
