/* ================================================================
   [v2.5 交互] Stone Wolf 式移动端菜单（参考 stone-wolf 主题 v5.3）
   仅 ≤991px 生效（与主题 navbar-expand-lg 折叠断点一致）；
   PC 端 ≥992px 整套元素 display:none，不影响桌面端任何布局与配色。
   颜色全部沿用主题现有设计令牌（--fx-*，定义于 factory-enhancements.css）。

   v3.0 交互规格（对照 Stone Wolf）：
   - 汉堡：38px 墨色方块（直角）+ 3 条白色横线，点击不变形（关闭靠抽屉头 ✕）
   - 抽屉：min(88vw, 420px) 全高窄侧板，0.55s 滑入；半透明遮罩点击关闭
   - 抽屉头：MENU 标题 + ✕；一级子菜单 = 滑入面板（sticky 返回头）；
     二级及更深 = 原位手风琴（缩进分层）
   - 搜索：全屏白色遮罩 + 62px 大输入框（仅 2px 底部墨线）+ 提示行
   保留 v2.x 行为：吸顶开关控制（v2.1）、搜索清空（v2.3）、
   首页轮播搜索栏隐藏（v2.0）、GTranslate 抽屉底部停靠（向上展开）
   ================================================================ */

/* ---------- PC 端：整套新元素隐藏（零影响） ---------- */
@media (min-width: 992px) {
	#sram-mobile-topbar,
	#sram-mobile-search,
	#sram-mobile-drawer,
	.sram-drawer-overlay { display: none !important; }
}

@media (max-width: 991px) {

	/* ---------- 旧移动头部隐藏（仅移动端规则，PC 不受影响） ---------- */
	.header .factory-banner,
	.header .menu-style { display: none !important; }
	header.mobile-header { margin: 0 !important; padding: 0 !important; min-height: 0 !important; }
	/* 顶栏为 fixed 60px，页面内容整体下移留位（admin bar 46px 场景 +60） */
	body { padding-top: 60px !important; }
	body.admin-bar { padding-top: 106px !important; }
	/* 抽屉/搜索打开时锁定页面滚动 */
	body.sram-menu-open,
	body.sram-search-open { overflow: hidden; }

	/* ================================================================
	   1. 顶栏：左汉堡 / 中 Logo / 右搜索
	   ================================================================ */
	#sram-mobile-topbar {
		/* [v2.1] 默认随页面滚动（absolute 定位在文档顶部）；是否吸顶由后台
		   「导航吸顶」开关控制（模板按 xintheme('header_sticky') 加 .sram-sticky）：
		   开 → 滚动超过 100px 后固定（.sram-fixed，JS 复刻主题原 fixed-header 逻辑） */
		position: absolute; top: 0; left: 0; right: 0; height: 60px;
		background: #fff;
		border-bottom: 1px solid var(--fx-border, #e7ecf3);
		display: flex; align-items: center; justify-content: space-between;
		padding: 0 20px;
		z-index: 1030;
	}
	#sram-mobile-topbar.sram-sticky.sram-fixed { position: fixed; }
	/* [v3.0] 抽屉打开时顶栏沉到遮罩之下（遮罩 1024 / 抽屉 1025）：右侧未被
	   窄抽屉盖住的顶栏区域随遮罩一起变暗、不可点 */
	body.sram-menu-open #sram-mobile-topbar { z-index: 1020; }
	body.admin-bar #sram-mobile-topbar { top: 46px; }

	/* [v2.6] 汉堡：白底 + 三线与右侧放大镜同色（--fx-ink），点击不变形 */
	#sram-menu-toggle {
		position: relative; z-index: 2;
		flex: 0 0 auto;
		width: 38px; height: 38px;
		background: #fff;
		border: 0; border-radius: 0;
		padding: 0; margin: 0; cursor: pointer;
		display: inline-flex; align-items: center; justify-content: center;
	}
	.sram-burger { display: block; width: 17px; height: auto; }
	.sram-burger-line {
		display: block;
		width: 17px; height: 2px;
		background: var(--fx-ink, #0d1b2e); /* 与 #sram-search-toggle 的放大镜同色 */
		border-radius: 0;
	}
	.sram-burger-line + .sram-burger-line { margin-top: 3px; }

	/* Logo：绝对居中 */
	.sram-brand {
		position: absolute; left: 50%; top: 50%;
		transform: translate(-50%, -50%);
		display: flex; align-items: center; justify-content: center;
		max-width: 46%; z-index: 1;
	}
	.sram-brand img { max-height: 36px; max-width: 100%; width: auto; height: auto; display: block; }
	.sram-brand-text { font-size: 20px; font-weight: 700; color: var(--fx-ink, #0d1b2e); letter-spacing: 1px; white-space: nowrap; }

	/* [v3.0 / Stone Wolf] 搜索按钮：透明底 + 1px 描边方框 */
	#sram-search-toggle {
		flex: 0 0 auto;
		width: 38px; height: 38px;
		background: transparent;
		border: 1px solid var(--fx-border, #e7ecf3);
		border-radius: 0;
		padding: 0; margin: 0; cursor: pointer;
		color: var(--fx-ink, #0d1b2e); font-size: 16px;
		display: inline-flex; align-items: center; justify-content: center;
		transition: color .2s;
	}
	#sram-search-toggle.is-active,
	#sram-search-toggle:active { color: var(--fx-primary, #1668dc); }

	/* ================================================================
	   2. 搜索：全屏白色遮罩（Stone Wolf 式，替换原下拉横条）
	   ================================================================ */
	#sram-mobile-search {
		position: fixed; inset: 0;
		z-index: 1040;
		background: #fff;
		display: flex; flex-direction: column;
		align-items: center; justify-content: flex-start;
		padding: 20vh 24px 24px;
		opacity: 0; pointer-events: none;
		transition: opacity .3s var(--fx-ease, ease);
	}
	#sram-mobile-search.is-open { opacity: 1; pointer-events: auto; }
	.sram-search-form { width: min(620px, 100%); position: static; height: auto; }
	.sram-search-form input[type=search] {
		width: 100%; height: 62px;
		border: 0;
		border-bottom: 2px solid var(--fx-ink, #0d1b2e); /* [v2.4 需求延续] 白底上清晰的底部线 */
		border-radius: 0;
		background: transparent;
		color: var(--fx-ink, #0d1b2e);
		font-size: 16px; line-height: 1.4;
		padding: 0 4px;
		outline: none;
		box-shadow: none;
	}
	.sram-search-form input[type=search]::placeholder { color: #a3a3a3; opacity: 1; }
	.sram-search-hint {
		margin: 18px 0 0;
		font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
		color: var(--fx-muted, #7c8798);
	}
	.sram-search-cancel {
		position: absolute; top: 18px; right: 18px;
		width: 44px; height: 44px;
		display: inline-flex; align-items: center; justify-content: center;
		background: transparent;
		border: 1px solid var(--fx-border, #e7ecf3);
		border-radius: 0;
		color: var(--fx-ink, #0d1b2e); font-size: 18px; text-decoration: none;
	}

	/* ================================================================
	   3. 抽屉：窄侧板（Stone Wolf 式，替换原全宽抽屉）
	   ================================================================ */
	.sram-drawer-overlay {
		position: fixed; inset: 0;
		z-index: 1024;
		background: rgba(13, 27, 46, .45); /* 主题墨色调遮罩 */
		opacity: 0; pointer-events: none;
		transition: opacity .4s var(--fx-ease, ease);
	}
	.sram-drawer-overlay.is-open { opacity: 1; pointer-events: auto; }

	#sram-mobile-drawer {
		position: fixed; top: 0; bottom: 0; left: 0;
		width: min(88vw, 420px);
		z-index: 1025;
		display: flex; flex-direction: column;
		background: #fff;
		transform: translateX(-101%);
		transition: transform .55s var(--fx-ease, ease), visibility 0s linear .55s;
		visibility: hidden;
	}
	#sram-mobile-drawer.is-open {
		transform: translateX(0);
		visibility: visible;
		transition: transform .55s var(--fx-ease, ease), visibility 0s linear 0s;
	}

	/* [Stone Wolf] 抽屉头：MENU 标题 + ✕ 关闭 */
	.sram-drawer-head {
		display: flex; align-items: center; justify-content: space-between;
		padding: 12px 20px;
		border-bottom: 1px solid var(--fx-border, #e7ecf3);
		flex: 0 0 auto;
	}
	.sram-drawer-title {
		font-size: 18px; font-weight: 700;
		letter-spacing: .06em; text-transform: uppercase;
		color: var(--fx-ink, #0d1b2e);
	}
	.sram-drawer-close {
		width: 40px; height: 40px;
		display: inline-flex; align-items: center; justify-content: center;
		background: transparent; border: 0;
		font-size: 18px; line-height: 1;
		color: var(--fx-ink, #0d1b2e); cursor: pointer;
	}

	/* ================================================================
	   4. 菜单列表（Stone Wolf 行样式）
	   ================================================================ */
	.sram-drawer-nav {
		position: relative;          /* 滑入面板的定位锚 */
		flex: 1 1 auto; min-height: 0;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}
	/* 面板打开时锁定列表滚动（面板内部各自滚动） */
	#sram-mobile-drawer.sram-panel-active .sram-drawer-nav { overflow: hidden; }

	.sram-list { list-style: none; margin: 0; padding: 0; }
	.sram-item { border-bottom: 1px solid var(--fx-border, #e7ecf3); }
	.sram-item:last-child { border-bottom: 0; }

	/* 一级行：14px 粗体大写 + chevron（Stone Wolf 规格） */
	.sram-list > .sram-item > .sram-link {
		display: flex; align-items: center; justify-content: space-between; gap: 12px;
		min-height: 44px; padding: 11px 20px;
		color: var(--fx-ink, #0d1b2e); text-decoration: none;
		font-size: 14px; font-weight: 600;
		letter-spacing: .06em; text-transform: uppercase;
		line-height: 1.3;
		transition: color .2s;
	}
	.sram-item.is-active > .sram-link { color: var(--fx-primary, #1668dc); }

	/* [Stone Wolf] chevron：CSS 画 8×8 双边框三角，展开时旋转 */
	.sram-list > .sram-item.has-panel > .sram-link::after {
		content: ""; flex: 0 0 auto;
		width: 8px; height: 8px;
		border-right: 2px solid var(--fx-ink, #0d1b2e);
		border-bottom: 2px solid var(--fx-ink, #0d1b2e);
		transform: rotate(-45deg);
		transition: transform .25s var(--fx-ease, ease);
	}
	.sram-list > .sram-item.has-panel.sram-panel-open > .sram-link::after { transform: rotate(45deg); }

	/* ================================================================
	   5. 一级滑入面板（Stone Wolf：仅第一级滑入，从右覆盖列表）
	   ================================================================ */
	.sram-subpanel {
		position: absolute; inset: 0;
		z-index: 3;
		margin: 0; padding: 0;
		background: #fff;
		list-style: none;
		transform: translateX(100%);
		visibility: hidden;
		transition: transform .45s var(--fx-ease, ease), visibility 0s linear .45s;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}
	.sram-item.has-panel.sram-panel-open > .sram-subpanel {
		transform: translateX(0);
		visibility: visible;
		transition: transform .45s var(--fx-ease, ease), visibility 0s linear 0s;
	}
	/* [Stone Wolf] 抽屉关闭时瞬时复位（JS 配合），防重开残影 */
	.sram-drawer-nav.sram-no-anim .sram-subpanel { transition: none !important; }
	/* [Stone Wolf] 返回行：sticky 跟随面板滚动 */
	.sram-back-row { position: sticky; top: 0; z-index: 4; }
	.sram-back {
		display: flex; align-items: center; gap: 10px;
		width: 100%;
		padding: 10px 20px;
		background: #fff;
		border-bottom: 1px solid var(--fx-border, #e7ecf3);
		color: var(--fx-ink, #0d1b2e); text-decoration: none;
		font-size: 13px; font-weight: 600;
		letter-spacing: .08em; text-transform: uppercase;
	}
	.sram-back::before { content: "\2190"; font-size: 16px; line-height: 1; }
	.sram-back span { overflow-wrap: anywhere; }

	/* 面板内行：正常大小写、色浅一档（Stone Wolf 规格） */
	.sram-subpanel .sram-link {
		display: flex; align-items: center; justify-content: space-between; gap: 12px;
		min-height: 44px; padding: 11px 20px;
		color: var(--fx-body, #414a58); text-decoration: none;
		font-size: 14px; font-weight: 500;
		letter-spacing: .01em; text-transform: none;
		line-height: 1.3;
	}
	.sram-subpanel .sram-item.is-active > .sram-link { color: var(--fx-primary, #1668dc); }
	.sram-subpanel .sram-parent-link { color: var(--fx-ink, #0d1b2e); font-weight: 600; }
	/* 面板内分组头（带子级）：加粗 + chevron 旋转 */
	.sram-subpanel > .sram-item.has-sub > .sram-link {
		font-weight: 600; color: var(--fx-ink, #0d1b2e);
	}
	.sram-subpanel > .sram-item.has-sub > .sram-link::after {
		content: ""; flex: 0 0 auto;
		width: 8px; height: 8px;
		border-right: 2px solid var(--fx-ink, #0d1b2e);
		border-bottom: 2px solid var(--fx-ink, #0d1b2e);
		transform: rotate(-45deg);
		transition: transform .25s var(--fx-ease, ease);
	}
	.sram-subpanel > .sram-item.has-sub.sram-sub-open > .sram-link::after { transform: rotate(45deg); }

	/* ================================================================
	   6. 深层手风琴（Stone Wolf：原地展开 + 缩进分层）
	   ================================================================ */
	.sram-sublist {
		display: none;
		margin: 0; padding: 0;
		list-style: none;
		background: var(--fx-surface, #f5f7fa);
	}
	.sram-item.has-sub.sram-sub-open > .sram-sublist { display: block; }
	/* 叶子行：再缩进一档（Stone Wolf 34px） */
	.sram-sublist .sram-link {
		display: flex; align-items: center;
		padding: 11px 20px 11px 34px;
		color: var(--fx-body, #414a58); text-decoration: none;
		font-size: 14px; font-weight: 500;
		line-height: 1.3;
	}

	/* ================================================================
	   7. GTranslate 停靠抽屉底部（沿用 v2.x，向上展开）
	   ================================================================ */
	#sram-drawer-gtranslate {
		flex: 0 0 auto;
		border-top: 1px solid var(--fx-border, #e7ecf3);
		padding: 10px 20px calc(10px + env(safe-area-inset-bottom, 0px));
		background: #fff;
	}
	/* 覆盖 factory-enhancements.css 中移动端规则（顶部黑条 absolute 停靠） */
	#sram-drawer-gtranslate .gtranslate_wrapper .gt_switcher_wrapper {
		position: static !important; top: auto !important; right: auto !important;
	}
	#sram-drawer-gtranslate .gtranslate_wrapper .gt_switcher {
		position: relative; width: 100% !important; font-size: 13px !important;
	}
	#sram-drawer-gtranslate .gtranslate_wrapper .gt_switcher a { font-size: 13px !important; }
	#sram-drawer-gtranslate .gtranslate_wrapper .gt_switcher .gt_selected a {
		width: auto !important; display: flex; align-items: center;
		padding: 10px 14px !important;
		border: 1px solid var(--fx-border, #e7ecf3) !important; border-radius: 0;
		background: #fff;
	}
	#sram-drawer-gtranslate .gtranslate_wrapper .gt_switcher .gt_option {
		/* [v2.0] 语言列表向上展开（停靠在抽屉最下方） */
		position: absolute !important;
		top: auto !important;
		bottom: calc(100% + 6px) !important;
		left: 0 !important; right: 0 !important;
		background: #fff; border: 1px solid var(--fx-border, #e7ecf3); border-radius: 0;
		box-shadow: 0 -10px 30px rgba(13, 27, 46, .12);
		max-height: 40vh; overflow-y: auto;
		z-index: 5;
	}

	/* ================================================================
	   8. [v2.0] 首页轮播下方移动端搜索栏移除（沿用）
	   ================================================================ */
	.mobile-product-search { display: none !important; }

	/* ---------- 无障碍：动效降级（与 factory-enhancements.css 一致） ---------- */
	@media (prefers-reduced-motion: reduce) {
		#sram-mobile-drawer, .sram-subpanel, .sram-drawer-overlay,
		#sram-mobile-search, .sram-list > .sram-item.has-panel > .sram-link::after { transition-duration: .01ms !important; }
	}
}
