/* =====================================================================
 * 1.0.65ze 手機表頭修正（第 1 章 ②）
 * 規格：黑底單列；左側小標誌，右側依序 搜尋 → 帳號 → 購物袋，漢堡選單在最右。
 *
 * 根本原因（fe65v.css 的 .ast-builder-grid-row 內）：
 *  - .site-header-section 已設 display:contents，所以真正參與 flex 排列的是
 *    Astra 的 .ast-builder-layout-element 外層 div；但 fe65v.css 的 order 規則寫在
 *    內層（.site-branding / .ast-site-header-cart / .ast-button-wrap），對 flex 子項目無效，
 *    結果漢堡、Logo、購物袋依 DOM 順序排在最左，我們產生的搜尋／帳號圖示被推到最後。
 *  - Logo 圖片是直式 112×148，被限制 max-height:26px → 只剩約 20px 寬，看不清楚。
 *  - 購物袋沿用 Astra 的 35×35 數字方塊，和 40px 圖示尺寸不一致。
 * 本檔以 flex 子項目（外層 div）為對象重新指定順序／尺寸，只在 body.fz65v-hdr 且手機寬度生效。
 * ===================================================================== */
@media (max-width: 921px) {
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-primary-header-bar .ast-builder-grid-row {
		display: flex !important; flex-wrap: nowrap; align-items: center; justify-content: flex-start;
		gap: 0; min-height: 60px; padding: 0; width: 100%;
	}
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-primary-header-bar .ast-builder-grid-row > .site-header-section { display: contents !important; }

	html body.fz65v-hdr #masthead #ast-mobile-header .site-header-section > .ast-builder-layout-element { margin: 0; padding: 0; flex: 0 0 auto; }

	/* 註：fe65v.css 第 123 行的 :not() 規則 specificity 較高（會把 margin 歸零），所以 Logo 這條多加 class 來蓋過；若依建議刪除 fe65v.css 第 110–123 行即可還原成單純選擇器。 */
	/* 表頭外層左右內距：左 16px、右 8px（Astra 原為 24/32 或 16/24，會讓圖示往內縮） */
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-primary-header-bar.main-header-bar { padding-left: 16px !important; padding-right: 8px !important; }

	/* ---- 順序：Logo(0) 搜尋(1) 帳號(2) 購物袋(3) 漢堡(4) ---- */
	html body.fz65v-hdr #masthead #ast-mobile-header .site-header-section > .ast-builder-layout-element.site-header-focus-item[data-section="title_tagline"][data-section] { order: 0; margin: 0 auto 0 0; flex: 0 0 auto; }
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-builder-grid-row > .fz65v-hd-search { order: 1; }
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-builder-grid-row > .fz65v-hd-acct { order: 2; }
	html body.fz65v-hdr #masthead #ast-mobile-header .site-header-section > [data-section="section-header-woo-cart"],
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-builder-grid-row > .fz65v-hd-cart { order: 3; }
	html body.fz65v-hdr #masthead #ast-mobile-header .site-header-section > [data-section="section-header-mobile-trigger"] { order: 4; }

	/* ---- Logo：直式 112×148，高度 40px（寬約 30px）可讀 ---- */
	html body.fz65v-hdr #masthead #ast-mobile-header .site-branding { margin: 0; padding: 0; }
	html body.fz65v-hdr #masthead #ast-mobile-header .site-logo-img,
	html body.fz65v-hdr #masthead #ast-mobile-header .site-logo-img .custom-logo-link { display: flex; align-items: center; }
	html body.fz65v-hdr #masthead #ast-mobile-header .site-logo-img .custom-logo-link img.custom-logo {
		height: 40px; width: auto; max-height: none; max-width: none; flex: none; object-fit: contain;
	}

	/* ---- 四個圖示統一：40×40 觸控區、22px 圖樣 ---- */
	html body.fz65v-hdr #masthead #ast-mobile-header .fz65v-hd-ico,
	html body.fz65v-hdr #masthead #ast-mobile-header .main-header-menu-toggle {
		width: 40px !important; height: 40px !important; min-width: 40px; min-height: 40px; padding: 0 !important; margin: 0; display: inline-flex; align-items: center; justify-content: center; line-height: 0;
	}
	html body.fz65v-hdr #masthead #ast-mobile-header .fz65v-hd-ico svg,
	html body.fz65v-hdr #masthead #ast-mobile-header .main-header-menu-toggle svg { width: 22px; height: 22px; }
	html body.fz65v-hdr #masthead #ast-mobile-header .main-header-menu-toggle .mobile-menu-toggle-icon,
	html body.fz65v-hdr #masthead #ast-mobile-header .main-header-menu-toggle .ahfb-svg-iconset { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
	html body.fz65v-hdr #masthead #ast-mobile-header [data-section="section-header-mobile-trigger"] .ast-button-wrap .mobile-menu-toggle-icon .ast-mobile-svg { width: 22px; height: 22px; }

	/* ---- 購物袋：與其他圖示同尺寸的袋子圖樣＋右上角小圓點數字（0 件時不顯示數字） ---- */
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-site-header-cart { padding: 0; margin: 0; line-height: 0; }
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-site-header-cart .cart-container {
		display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; margin: 0;
	}
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-site-header-cart .ast-cart-menu-wrap {
		position: relative; display: block; width: 40px; height: 40px; padding: 0; margin: 0; line-height: 0;
	}
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-site-header-cart .ast-cart-menu-wrap .count {
		position: absolute !important; left: 0; top: 0; width: 40px !important; height: 40px !important; min-width: 0;
		margin: 0; padding: 0; border: 0 !important; border-radius: 0 !important; background: transparent !important;
		color: transparent !important; font-size: 0 !important; line-height: 0; box-shadow: none;
	}
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-site-header-cart .ast-cart-menu-wrap .count::before {
		content: ""; display: block; position: absolute; left: 9px; top: 9px; width: 22px; height: 22px; margin: 0; border: 0; background: #fff;
		-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M18 6h-2a4 4 0 0 0-8 0H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2Zm-6-2a2 2 0 0 1 2 2h-4a2 2 0 0 1 2-2Zm0 10a4 4 0 0 1-4-4h2a2 2 0 0 0 4 0h2a4 4 0 0 1-4 4Z'/></svg>") center / contain no-repeat;
		mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M18 6h-2a4 4 0 0 0-8 0H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2Zm-6-2a2 2 0 0 1 2 2h-4a2 2 0 0 1 2-2Zm0 10a4 4 0 0 1-4-4h2a2 2 0 0 0 4 0h2a4 4 0 0 1-4 4Z'/></svg>") center / contain no-repeat;
	}
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-site-header-cart .ast-cart-menu-wrap .count::after { display: none !important; content: none !important; }
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-site-header-cart .ast-cart-menu-wrap .ast-count-text {
		position: absolute; top: 3px; right: 0; display: block; box-sizing: border-box; min-width: 16px; height: 16px; padding: 0 4px; margin: 0;
		border-radius: 8px; background: #fff; color: #000; font: 700 10px/16px -apple-system, "Helvetica Neue", Arial, sans-serif; text-align: center;
	}
	html body.fz65v-hdr #masthead #ast-mobile-header .ast-site-header-cart.fz65ze-empty .ast-count-text { display: none; }

	/* ---- 點擊時不要出現虛線框（鍵盤操作仍保留 :focus-visible） ---- */
	html body.fz65v-hdr #masthead #ast-mobile-header a,
	html body.fz65v-hdr #masthead #ast-mobile-header button { -webkit-tap-highlight-color: transparent; }
	html body.fz65v-hdr #masthead #ast-mobile-header a:focus:not(:focus-visible),
	html body.fz65v-hdr #masthead #ast-mobile-header button:focus:not(:focus-visible) { outline: 0 !important; box-shadow: none !important; }
	html body.fz65v-hdr #masthead #ast-mobile-header a:focus-visible,
	html body.fz65v-hdr #masthead #ast-mobile-header button:focus-visible { outline: 2px solid #fff !important; outline-offset: -4px; }
}
