/**
 * 特色分类：
 * 1. 内容区支持自定义内边距（上 / 下 / 左 / 右），
 *    未设置时沿用 WooCommerce 默认值（上 0、下 16、左 48、右 48）。
 * 2. 「按钮固定在底部」：内容保持在顶部，按钮贴到卡片底部。
 *
 * 内边距通过 CSS 变量传递，前台由渲染过滤器写入，
 * 编辑器侧边栏设置后由 BlockListBlock 包裹层写入，样式统一由此文件消费。
 */
.wc-block-featured-category .wc-block-featured-category__inner-blocks {
	padding-top: var(--ferrox-fc-pad-top, 0);
	padding-right: var(--ferrox-fc-pad-right, 48px);
	padding-bottom: var(--ferrox-fc-pad-bottom, 16px);
	padding-left: var(--ferrox-fc-pad-left, 48px);
}

.wc-block-featured-category.ferrox-button-align-bottom.wp-block-woocommerce-featured-category > .wc-block-featured-category__wrapper {
	align-content: stretch;
	align-items: stretch;
}

.wc-block-featured-category.ferrox-button-align-bottom .wc-block-featured-category__inner-blocks {
	display: flex;
	flex-direction: column;
	align-self: stretch;
	height: 100%;
	/* 开启「按钮固定在底部」且未自定义下内边距时，按钮紧贴卡片底部 */
	padding-bottom: var(--ferrox-fc-pad-bottom, 0);
}

.wc-block-featured-category.ferrox-button-align-bottom .wc-block-featured-category__inner-blocks > .wp-block-buttons,
.wc-block-featured-category.ferrox-button-align-bottom .wc-block-featured-category__inner-blocks > .wp-block-button {
	/* 按钮区块自带内联 margin-top:0，必须用 !important 才能让 auto 生效 */
	margin-top: auto !important;
}

/**
 * 整卡可点击：
 * 把「View All」按钮铺满整个卡片并隐藏其外观，点击卡片任意位置都等同于点击按钮。
 * 链接文字仍保留在 DOM 中（屏幕阅读器可用），只做视觉隐藏。
 */
.wc-block-featured-category.ferrox-button-align-bottom .wc-block-featured-category__inner-blocks > .wp-block-buttons {
	position: absolute;
	inset: 0;
	display: block;
	margin: 0 !important;
	z-index: 2;
}

.wc-block-featured-category.ferrox-button-align-bottom .wc-block-featured-category__inner-blocks > .wp-block-buttons .wp-block-button {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
}

.wc-block-featured-category.ferrox-button-align-bottom .wc-block-featured-category__inner-blocks .wp-block-button__link {
	display: block;
	width: 100%;
	height: 100%;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0;
	background: transparent !important;
	box-shadow: none;
	color: transparent !important;
	font-size: 0 !important;
	line-height: 0;
	text-indent: -9999px;
	overflow: hidden;
}

.wc-block-featured-category.ferrox-button-align-bottom .wc-block-featured-category__inner-blocks .wp-block-button__link:hover {
	background: transparent !important;
}

/* 键盘聚焦时仍能看到焦点位置 */
.wc-block-featured-category.ferrox-button-align-bottom .wc-block-featured-category__inner-blocks .wp-block-button__link:focus-visible {
	outline: 2px solid #dd183b;
	outline-offset: -2px;
}

/* 鼠标移到卡片上时，标题变为主题红
   标题是内嵌的 category-title 区块（h3.wp-block-woocommerce-category-title），
   整卡被隐藏按钮覆盖后标题链接本身收不到 :hover，所以挂在卡片 :hover 上。 */
.wc-block-featured-category .wp-block-woocommerce-category-title,
.wc-block-featured-category .wp-block-woocommerce-category-title a {
	transition: color .18s ease;
	/* 编辑器写死了 fontSize:20px 的内联 style，需要 !important 覆盖；
	   让分类标题随视口宽度自适应：最小 14px、最大 20px，按 1.2vw 缩放 */
	font-size: clamp(14px, 1.2vw, 20px) !important;
}

.wc-block-featured-category:hover .wp-block-woocommerce-category-title,
.wc-block-featured-category:hover .wp-block-woocommerce-category-title a {
	/* 标题自带 has-ast-global-color-*-color，该规则用 !important，需要同级覆盖 */
	color: #dd183b !important;
}

/**
 * 卡片尺寸由区块自身「宽高比」设置决定（如 3:2），
 * 图片恢复为绝对定位铺满卡片（cover），不参与高度计算。
 * 内容区绝对定位覆盖整卡，隐藏按钮才能随卡片尺寸一起变化。
 */
.wc-block-featured-category .wc-block-featured-category__wrapper {
	position: relative;
}

.wc-block-featured-category .wc-block-featured-category__inner-blocks {
	position: absolute !important;
	inset: 0;
	z-index: 1;
}

/**
 * 普通栏（column）的「按钮贴底」：
 * 给栏加上 ferrox-button-align-bottom 类后，栏变成纵向 flex，
 * 按钮容器 margin-top:auto 被推到栏的最底部。
 */
.wp-block-column.ferrox-button-align-bottom {
	display: flex;
	flex-direction: column;
}

.wp-block-column.ferrox-button-align-bottom > .wp-block-buttons,
.wp-block-column.ferrox-button-align-bottom > .wp-block-button {
	margin-top: auto !important;
}

/**
 * 页眉主菜单（primary）的 Mega 面板：
 * 条目字号由 Max Mega Menu 主题设置（Mega Menu > 主题 > 二级菜单项 > 字体尺寸）控制。
 * 这里不再用 clamp 覆盖，否则设置面板里的字号永远不生效。
 */

/**
 * .zoom-container：悬停时背景图放大。
 * 背景图写在元素自身的 background-image 上，transform 无法只作用于背景，
 * 所以用 ::before 继承同一张背景图并缩放，内容层放在它上面。
 */
.zoom-container {
	position: relative;
	overflow: hidden;
}

.zoom-container::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 0;
	background-image: inherit;
	background-position: inherit;
	background-size: cover;
	background-repeat: no-repeat;
	transition: transform .5s ease-in-out;
	transform-origin: center center;
	pointer-events: none;
}

.zoom-container:hover::before {
	transform: scale(1.08);
}

.zoom-container > * {
	position: relative;
	z-index: 1;
}

/**
 * 导航菜单区块：编辑器里设置的字体颜色 / 字号。
 * 只有对应属性存在时才覆盖链接颜色，未设置时保持主题原有样式。
 */
.wp-block-navigation.ferrox-nav-styled[style*="--ferrox-nav-color"] a,
.wp-block-navigation.ferrox-nav-styled[style*="--ferrox-nav-color"] .wp-block-navigation-item__label {
	color: var(--ferrox-nav-color);
}

.wp-block-navigation.ferrox-nav-styled[style*="--ferrox-nav-size"] a,
.wp-block-navigation.ferrox-nav-styled[style*="--ferrox-nav-size"] .wp-block-navigation-item__label {
	font-size: var(--ferrox-nav-size);
}

/**
 * 小工具「导航菜单」：编辑器设置的颜色 / 字号作用到菜单链接上。
 */
[data-ferrox-nav][style*="--ferrox-nav-color"] a {
	color: var(--ferrox-nav-color);
}

[data-ferrox-nav][style*="--ferrox-nav-size"] a {
	font-size: var(--ferrox-nav-size);
}
