/**
 * HCM 移动端触控规范（CSS-only）
 *
 * 1. WebKit tap 高亮（html * 统一净化）
 * 2. :focus:not(:focus-visible) 去环（保留键盘 :focus-visible）
 * 3. Sticky Hover 根治：coarse 设备 :hover 回默认，:active 按压反馈
 *
 * 禁止配合 JS blur() — 见架构师指令。
 */

/* =========================================================
   1. 触控设备：全局 tap 净化 + 伪 focus 环
   ========================================================= */
@media (hover: none) and (pointer: coarse) {
	html,
	html * {
		-webkit-tap-highlight-color: transparent !important;
		tap-highlight-color: transparent !important;
	}

	:is(
		a,
		button,
		input,
		select,
		textarea,
		summary,
		[role="button"],
		[tabindex]:not([tabindex="-1"])
	):focus:not(:focus-visible) {
		outline: none !important;
		box-shadow: none !important;
	}

	/* Ghost 按钮：focus/active 不露出 GP / 系统色块（分页圆钮除外） */
	:is(.hcm-team-hub, .hcm-player-hub, .hcm-league-hub, .hcm-home-container, .hcm-md-container)
		:is(
			button[class*="__tab"]:not(.active),
			button[class*="__expand"],
			button[class*="__filter"],
			button[class*="__nav"]:not(.hcm-nav-arrow-btn):not(.hcm-overview-nav-btn):not(.md-match-header-btn),
			button[class*="__trigger"],
			button.round-nav-current-trigger
		):is(:focus:not(:focus-visible), :active) {
		background: transparent !important;
		background-color: transparent !important;
		outline: none !important;
		box-shadow: none !important;
		-webkit-appearance: none !important;
		appearance: none !important;
		color: inherit;
	}

	/* =========================================================
	   3. Sticky Hover 根治 — :hover 回默认态，:active 瞬时按压
	   ========================================================= */

	/* 首页 · 日期选择（div 可点） */
	.date-current:hover {
		background-color: transparent !important;
	}
	.date-current:active,
	.date-current.hcm-date-picker-open {
		background-color: rgba(128, 128, 128, 0.05) !important;
	}

	/* 首页 · 筛选胶囊（:not(:active) 确保按压时灰色反馈不被 focus/hover 重置盖掉） */
	.filter-btn-bottom:hover:not(.active):not(:active) {
		background-color: rgba(15, 23, 42, 0.04) !important;
		color: #334155 !important;
		border-color: rgba(15, 23, 42, 0.12) !important;
	}
	.filter-btn-bottom:focus:hover:not(.active):not(:active) {
		background-color: rgba(15, 23, 42, 0.04) !important;
		color: #334155 !important;
		border-color: rgba(15, 23, 42, 0.12) !important;
	}
	.filter-btn-bottom:focus:not(:focus-visible):not(:hover):not(.active):not(:active) {
		background-color: rgba(15, 23, 42, 0.04) !important;
		color: #334155 !important;
		border-color: rgba(15, 23, 42, 0.12) !important;
	}
	.filter-btn-bottom:active:not(.active) {
		background-color: var(--hcm-list-active-bg, #e5e7eb) !important;
	}
	html.dark-mode .filter-btn-bottom:hover:not(.active):not(:active),
	body.dark-mode .filter-btn-bottom:hover:not(.active):not(:active) {
		background-color: rgba(248, 250, 252, 0.06) !important;
		color: #e2e8f0 !important;
		border-color: rgba(248, 250, 252, 0.14) !important;
	}
	html.dark-mode .filter-btn-bottom:focus:hover:not(.active):not(:active),
	body.dark-mode .filter-btn-bottom:focus:hover:not(.active):not(:active) {
		background-color: rgba(248, 250, 252, 0.06) !important;
		color: #e2e8f0 !important;
		border-color: rgba(248, 250, 252, 0.14) !important;
	}
	html.dark-mode .filter-btn-bottom:focus:not(:focus-visible):not(:hover):not(.active):not(:active),
	body.dark-mode .filter-btn-bottom:focus:not(:focus-visible):not(:hover):not(.active):not(:active) {
		background-color: rgba(248, 250, 252, 0.06) !important;
		color: #e2e8f0 !important;
		border-color: rgba(248, 250, 252, 0.14) !important;
	}
	html.dark-mode .filter-btn-bottom:active:not(.active),
	body.dark-mode .filter-btn-bottom:active:not(.active) {
		background-color: var(--hcm-list-active-bg, rgba(255, 255, 255, 0.1)) !important;
	}
	.filter-btn-bottom.active:focus:not(:active),
	.filter-btn-bottom.active:focus:hover:not(:active),
	.filter-btn-bottom.active:focus:not(:focus-visible):not(:active) {
		background-color: #0f172a !important;
		color: #f8fafc !important;
		border-color: transparent !important;
	}
	html.dark-mode .filter-btn-bottom.active:focus:not(:active),
	html.dark-mode .filter-btn-bottom.active:focus:hover:not(:active),
	html.dark-mode .filter-btn-bottom.active:focus:not(:focus-visible):not(:active),
	body.dark-mode .filter-btn-bottom.active:focus:not(:active),
	body.dark-mode .filter-btn-bottom.active:focus:hover:not(:active),
	body.dark-mode .filter-btn-bottom.active:focus:not(:focus-visible):not(:active) {
		background-color: #f8fafc !important;
		color: #0f172a !important;
		border-color: transparent !important;
	}

	/* 全局折叠钮 */
	.global-toggle-btn:hover:not(:active),
	.global-toggle-btn:focus:hover:not(:active) {
		background-color: #ffffff !important;
		border-color: #e8e8ed !important;
		color: #1d1d1f !important;
	}
	.global-toggle-btn:focus:not(:focus-visible):not(:hover):not(:active) {
		background-color: #ffffff !important;
		border-color: #e8e8ed !important;
		color: #1d1d1f !important;
	}
	.global-toggle-btn:active {
		background-color: rgba(128, 128, 128, 0.18) !important;
		transform: scale(0.96);
	}
	html.dark-mode .global-toggle-btn,
	body.dark-mode .global-toggle-btn {
		background-color: var(--hcm-bg-card, #1c1c1c) !important;
		border-color: rgba(255, 255, 255, 0.12) !important;
		color: #f5f5f7 !important;
	}
	html.dark-mode .global-toggle-btn:hover:not(:active),
	html.dark-mode .global-toggle-btn:focus:hover:not(:active),
	body.dark-mode .global-toggle-btn:hover:not(:active),
	body.dark-mode .global-toggle-btn:focus:hover:not(:active) {
		background-color: rgba(255, 255, 255, 0.1) !important;
		border-color: rgba(255, 255, 255, 0.12) !important;
		color: #f5f5f7 !important;
	}
	html.dark-mode .global-toggle-btn:focus:not(:focus-visible):not(:hover):not(:active),
	body.dark-mode .global-toggle-btn:focus:not(:focus-visible):not(:hover):not(:active) {
		background-color: var(--hcm-bg-card, #1c1c1c) !important;
		border-color: rgba(255, 255, 255, 0.12) !important;
		color: #f5f5f7 !important;
	}
	html.dark-mode .global-toggle-btn:active,
	body.dark-mode .global-toggle-btn:active {
		background-color: rgba(255, 255, 255, 0.15) !important;
		color: #f5f5f7 !important;
	}

	/* 导航圆箭头 */
	.hcm-nav-arrow-btn:hover:not(:active),
	.hcm-nav-arrow-btn:focus:hover:not(:active) {
		background-color: #ffffff !important;
		border-color: #e8e8ed !important;
	}
	.hcm-nav-arrow-btn:focus:not(:focus-visible):not(:hover):not(:active) {
		background-color: #ffffff !important;
		border-color: #e8e8ed !important;
	}
	.hcm-nav-arrow-btn:active {
		background-color: rgba(128, 128, 128, 0.18) !important;
	}
	html.dark-mode .hcm-nav-arrow-btn,
	body.dark-mode .hcm-nav-arrow-btn {
		background-color: var(--hcm-bg-card, #1c1c1c) !important;
		border-color: rgba(255, 255, 255, 0.12) !important;
	}
	html.dark-mode .hcm-nav-arrow-btn:hover:not(:active),
	html.dark-mode .hcm-nav-arrow-btn:focus:hover:not(:active),
	body.dark-mode .hcm-nav-arrow-btn:hover:not(:active),
	body.dark-mode .hcm-nav-arrow-btn:focus:hover:not(:active) {
		background-color: rgba(255, 255, 255, 0.1) !important;
		border-color: rgba(255, 255, 255, 0.12) !important;
	}
	html.dark-mode .hcm-nav-arrow-btn:focus:not(:focus-visible):not(:hover):not(:active),
	body.dark-mode .hcm-nav-arrow-btn:focus:not(:focus-visible):not(:hover):not(:active) {
		background-color: var(--hcm-bg-card, #1c1c1c) !important;
		border-color: rgba(255, 255, 255, 0.12) !important;
	}
	html.dark-mode .hcm-nav-arrow-btn:active,
	body.dark-mode .hcm-nav-arrow-btn:active {
		background-color: rgba(255, 255, 255, 0.15) !important;
	}

	/* Hub · Trận đấu Tab 分页圆钮 */
	.hcm-team-hub .md-match-header-btn:hover,
	.hcm-team-hub .md-match-header-btn:focus:hover {
		opacity: 0.7;
	}
	.hcm-team-hub .md-match-header-btn:focus:not(:focus-visible):not(:hover) {
		background: var(--stat-pill-bg, #f9fafb) !important;
		color: var(--text-muted) !important;
	}
	.hcm-team-hub .md-match-header-btn:active:not(:disabled):not(.is-disabled) {
		opacity: 0.55;
	}

	/*
	 * Tổng quan · Trận đấu 分页圆钮：保留圆形 pill，仅统一 focus 色（避免 GP 灰底粘滞）
	 */
	.hcm-team-hub .hcm-overview-nav-btn {
		background: var(--stat-pill-bg, #f9fafb) !important;
		background-color: var(--stat-pill-bg, #f9fafb) !important;
	}
	.hcm-team-hub .hcm-overview-nav-btn:hover,
	.hcm-team-hub .hcm-overview-nav-btn:focus:hover {
		opacity: 0.7;
	}
	.hcm-team-hub .hcm-overview-nav-btn:focus:not(:focus-visible):not(:hover),
	.hcm-team-hub .hcm-overview-nav-btn:active:not(:disabled):not(.is-disabled) {
		background: var(--stat-pill-bg, #f9fafb) !important;
		background-color: var(--stat-pill-bg, #f9fafb) !important;
		color: var(--text-muted) !important;
		outline: none !important;
		box-shadow: none !important;
	}
	:is(html.dark-mode, body.dark-mode, html[data-theme="dark"]) .hcm-team-hub .hcm-overview-nav-btn,
	:is(html.dark-mode, body.dark-mode, html[data-theme="dark"]) .hcm-team-hub .hcm-overview-nav-btn:focus:not(:focus-visible):not(:hover),
	:is(html.dark-mode, body.dark-mode, html[data-theme="dark"]) .hcm-team-hub .hcm-overview-nav-btn:active:not(:disabled):not(.is-disabled) {
		background: var(--stat-pill-bg, rgba(255, 255, 255, 0.12)) !important;
		background-color: var(--stat-pill-bg, rgba(255, 255, 255, 0.12)) !important;
	}

	/* Hub · opacity  fade 链接（球队/联赛/球员/国家队） */
	:is(.hcm-team-hub, .hcm-player-hub, .hcm-league-hub) .hcm-hub-fade-link:hover,
	:is(.hcm-team-hub, .hcm-player-hub, .hcm-league-hub) a.hcm-hub-fade-link:hover {
		opacity: 1 !important;
	}
	:is(.hcm-team-hub, .hcm-player-hub, .hcm-league-hub) .hcm-hub-fade-link:active,
	:is(.hcm-team-hub, .hcm-player-hub, .hcm-league-hub) a.hcm-hub-fade-link:active {
		opacity: 0.55 !important;
		transition: opacity 0.05s ease;
	}

	.hcm-league-hub .hcm-league-fixture-match-link:hover {
		opacity: 1 !important;
	}
	.hcm-league-hub .hcm-league-fixture-match-link:active {
		opacity: 0.55 !important;
	}

	/* 球员页 · 生涯 Tab / 展开 / 比赛日志 ghost 按钮 */
	.hcm-team-hub .hcm-career__tab:not(.active):hover {
		color: var(--text-muted, #6b7280) !important;
	}
	.hcm-team-hub .hcm-career__tab:active {
		opacity: 0.65 !important;
	}

	.hcm-team-hub .hcm-about__expand-btn:hover {
		color: #1fb963 !important;
		background: none !important;
	}
	.hcm-team-hub .hcm-about__expand-btn:active {
		opacity: 0.65 !important;
	}

	.hcm-team-hub .hcm-match-log__filter-btn:hover,
	.hcm-team-hub .hcm-match-log__nav:hover {
		background: transparent !important;
	}
	.hcm-team-hub .hcm-match-log__filter-btn:active,
	.hcm-team-hub .hcm-match-log__nav:active {
		opacity: 0.65 !important;
	}

	.hcm-team-hub .hcm-ds__league-selector:hover {
		background: var(--card-bg, #fff) !important;
	}
	.hcm-team-hub .hcm-ds__league-selector:active {
		background: var(--hcm-list-active-bg, #f3f4f6) !important;
	}

	/* 联赛页 · 赛季 / 轮次导航 */
	.hcm-team-hub .hcm-header-season-trigger:hover {
		background-color: #f3f4f6 !important;
	}
	.hcm-team-hub .hcm-header-season-trigger:active {
		background-color: #e5e7eb !important;
	}

	.hcm-team-hub .league-round-fixtures-component .round-nav-current-wrap:hover:not(.is-open) {
		background: transparent !important;
	}
	.hcm-team-hub .league-round-fixtures-component .round-nav-current-wrap:active,
	.hcm-team-hub .league-round-fixtures-component .round-nav-current-wrap.is-open {
		background: var(--hcm-bg-subtle, #f3f4f6) !important;
	}

	.hcm-team-hub .league-round-fixtures-component .round-nav-btn:hover:not(:disabled) {
		background: var(--hcm-bg-subtle, #f3f4f6) !important;
	}
	.hcm-team-hub .league-round-fixtures-component .round-nav-btn:active:not(:disabled) {
		background: #e5e7eb !important;
	}

	:is(html.dark-mode, body.dark-mode) .hcm-team-hub .league-round-fixtures-component .round-nav-current-wrap:hover:not(.is-open) {
		background: transparent !important;
	}

	:is(html.dark-mode, body.dark-mode) .hcm-team-hub .league-round-fixtures-component .round-nav-current-wrap:active,
	:is(html.dark-mode, body.dark-mode) .hcm-team-hub .league-round-fixtures-component .round-nav-current-wrap.is-open {
		background: rgba(255, 255, 255, 0.08) !important;
	}

	:is(html.dark-mode, body.dark-mode) .hcm-team-hub .league-round-fixtures-component .round-nav-btn:hover:not(:disabled) {
		background: rgba(255, 255, 255, 0.14) !important;
	}

	:is(html.dark-mode, body.dark-mode) .hcm-team-hub .league-round-fixtures-component .round-nav-btn:active:not(:disabled) {
		background: rgba(255, 255, 255, 0.18) !important;
	}

	/* 赛程详情 · Tab / Pill（style.css 内未包 media 的规则兜底） */
	.hcm-md-header-card .md-tab-item[role="tab"]:not(.active):hover,
	.md-tab-item:not(.active):hover {
		background: transparent !important;
		background-color: transparent !important;
		color: var(--hcm-text-muted) !important;
	}
	.hcm-md-header-card .md-tab-item[role="tab"]:not(.active):active,
	.md-tab-item:not(.active):active {
		opacity: 0.75;
		color: var(--hcm-text-main) !important;
		background: transparent !important;
		background-color: transparent !important;
	}

	/* 激活 Tab（含 BXH）：按压时保持激活色，禁止变白/变淡 */
	.hcm-md-header-card .md-tab-item[role="tab"].active,
	.hcm-md-header-card .md-tab-item[role="tab"].active:hover,
	.hcm-md-header-card .md-tab-item[role="tab"].active:active,
	.hcm-md-header-card .md-tab-item[role="tab"].active:focus:not(:focus-visible),
	.md-tab-item.active,
	.md-tab-item.active:hover,
	.md-tab-item.active:active,
	.md-tab-item.active:focus:not(:focus-visible) {
		color: var(--hcm-text-main) !important;
		background: transparent !important;
		background-color: transparent !important;
		opacity: 1 !important;
		outline: none !important;
		box-shadow: none !important;
	}

	/* Hub 顶栏 Tab（联赛 BXH / 球队页等） */
	.hcm-team-hub .team-tabs__item:not(.team-tabs__item--active):hover,
	.hcm-team-hub a.team-tabs__item:not(.team-tabs__item--active):hover {
		color: var(--text-muted, var(--hcm-text-muted)) !important;
	}
	.hcm-team-hub .team-tabs__item:not(.team-tabs__item--active):active,
	.hcm-team-hub a.team-tabs__item:not(.team-tabs__item--active):active {
		opacity: 0.75;
		color: var(--text-muted, var(--hcm-text-muted)) !important;
		background: none !important;
		background-color: transparent !important;
	}
	.hcm-team-hub .team-tabs__item--active,
	.hcm-team-hub .team-tabs__item--active:hover,
	.hcm-team-hub .team-tabs__item--active:active,
	.hcm-team-hub .team-tabs__item--active:focus:not(:focus-visible),
	.hcm-team-hub a.team-tabs__item--active,
	.hcm-team-hub a.team-tabs__item--active:hover,
	.hcm-team-hub a.team-tabs__item--active:active,
	.hcm-team-hub a.team-tabs__item--active:focus:not(:focus-visible) {
		color: var(--text, var(--hcm-text-main)) !important;
		background: none !important;
		background-color: transparent !important;
		opacity: 1 !important;
	}

	.md-filter-pill:hover:not(.active),
	:is(.md-player-stats-section, .md-h2h-filters) .md-filter-pill:hover:not(.active),
	.hcm-team-hub .md-filter-pill:hover:not(.active),
	#pane-bxh .md-filter-pill:hover:not(.active),
	#tab-bxh .md-filter-pill:hover:not(.active) {
		background-color: transparent !important;
		color: var(--hcm-text-main) !important;
		border-color: rgba(128, 128, 128, 0.2) !important;
	}
	.md-filter-pill:active:not(.active),
	:is(.md-player-stats-section, .md-h2h-filters) .md-filter-pill:active:not(.active),
	.hcm-team-hub .md-filter-pill:active:not(.active),
	#pane-bxh .md-filter-pill:active:not(.active),
	#tab-bxh .md-filter-pill:active:not(.active) {
		opacity: 0.75;
	}

	.md-filter-pill.active,
	.md-filter-pill.active:hover,
	.md-filter-pill.active:active,
	.md-filter-pill.active:focus,
	:is(.md-player-stats-section, .md-h2h-filters) .md-filter-pill.active,
	:is(.md-player-stats-section, .md-h2h-filters) .md-filter-pill.active:hover,
	:is(.md-player-stats-section, .md-h2h-filters) .md-filter-pill.active:active,
	:is(.md-player-stats-section, .md-h2h-filters) .md-filter-pill.active:focus,
	.hcm-team-hub .md-filter-pill.active,
	.hcm-team-hub .md-filter-pill.active:hover,
	.hcm-team-hub .md-filter-pill.active:active,
	.hcm-team-hub .md-filter-pill.active:focus,
	#pane-bxh .md-filter-pill.active,
	#pane-bxh .md-filter-pill.active:hover,
	#pane-bxh .md-filter-pill.active:active,
	#pane-bxh .md-filter-pill.active:focus,
	#tab-bxh .md-filter-pill.active,
	#tab-bxh .md-filter-pill.active:hover,
	#tab-bxh .md-filter-pill.active:active,
	#tab-bxh .md-filter-pill.active:focus {
		background: var(--hcm-text-main) !important;
		background-color: var(--hcm-text-main) !important;
		color: var(--hcm-bg-card, #fff) !important;
		border-color: var(--hcm-text-main) !important;
		opacity: 1 !important;
		outline: none !important;
		box-shadow: none !important;
	}

	.md-filter-pill:focus:not(.active),
	:is(.md-player-stats-section, .md-h2h-filters) .md-filter-pill:focus:not(.active),
	.hcm-team-hub .md-filter-pill:focus:not(.active),
	#pane-bxh .md-filter-pill:focus:not(.active),
	#tab-bxh .md-filter-pill:focus:not(.active) {
		background-color: transparent !important;
		color: var(--hcm-text-main) !important;
		border-color: rgba(128, 128, 128, 0.2) !important;
		opacity: 1 !important;
		outline: none !important;
		box-shadow: none !important;
	}

	/* 表格行 hover 粘滞 */
	.md-data-table tbody tr:hover,
	.md-player-stats-section .md-player-table tbody tr:hover,
	#tab-bxh .md-data-table tbody tr:hover {
		background-color: transparent !important;
	}
	.md-data-table tbody tr:active,
	.md-player-stats-section .md-player-table tbody tr:active {
		background-color: var(--hcm-list-active-bg, #f3f4f6) !important;
	}

	.h2h-match-item:hover .h2h-score-row {
		opacity: 1 !important;
	}
	.h2h-match-item:active .h2h-score-row {
		opacity: 0.55 !important;
	}

	/* 可点击 div */
	:is(
		.hcm-all-leagues-widget__head,
		.hcm-country-item,
		.hcm-ds__league-selector
	):hover {
		background-color: transparent !important;
		background: transparent !important;
	}
	:is(
		.hcm-all-leagues-widget__head,
		.hcm-country-item,
		.hcm-ds__league-selector
	):active {
		background-color: var(--hcm-list-active-bg, #f3f4f6) !important;
	}

	/* 侧栏卡片链接 */
	.hcm-home-side-card__link:hover,
	.hcm-league-submenu-item:hover {
		background-color: transparent !important;
	}
	.hcm-home-side-card__link:active,
	.hcm-league-submenu-item:active {
		background-color: var(--hcm-list-active-bg, #f3f4f6) !important;
	}
}
