/**
 * Kadence Row：列「Inner column height: full」+ Infobox 撑满列高。
 *
 * 注意：不要对 .kt-inside-inner-col 无差别设 flex-direction:column。
 * 列在 tablet 常带 .kb-section-sm-dir-horizontal，此时 Kadence 会把内层做成横向 flex；
 * 全局覆盖会与插件内联样式冲突，并导致等高/换向异常。
 *
 * 策略：
 * - 仅在桌面（≥1025px）且列本身非 desktop 横向（:not(.kb-section-dir-horizontal)）时，
 *   才让 .kt-inside-inner-col 成为纵向 flex，便于子项 flex:1。
 * - Infobox 始终用 height:100% + 自身 flex 链作为兜底（不依赖上一行）。
 */

@media (min-width: 1025px) {
	.kt-inner-column-height-full.kt-row-valign-top
		> .wp-block-kadence-column:not(.kb-section-dir-horizontal)
		> .kt-inside-inner-col {
		display: flex;
		flex-direction: column;
		min-height: 0;
	}
}

.kt-inner-column-height-full .kt-inside-inner-col > .wp-block-kadence-infobox.kt-blocks-info-box-media-align-top {
	height: 100%;
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 0;
	width: 100%;
	box-sizing: border-box;
}

.kt-inner-column-height-full .wp-block-kadence-infobox.kt-blocks-info-box-media-align-top .kt-blocks-info-box-link-wrap {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 0;
	width: 100%;
	box-sizing: border-box;
}

/*
 * ---------- 嵌套 Row：页面附加类 .scrollable-card-row ----------
 * DOM：外层列 .kt-inside-inner-col > .kb-row-layout-wrap.scrollable-card-row > .kt-row-column-wrap（三列等高）
 * 若仅写「顶层面 Row」的列选择器，无法覆盖「列内再套 Row」；且部分 Infobox 无 .kt-blocks-info-box-media-align-top，
 * 上面规则会完全不命中。此处用 .scrollable-card-row 收窄，并放宽 Infobox 选择器。
 */

.kt-inside-inner-col:has(> .kb-row-layout-wrap.scrollable-card-row) {
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.kb-row-layout-wrap.scrollable-card-row {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 0;
	width: 100%;
}

.kb-row-layout-wrap.scrollable-card-row > .kt-row-column-wrap {
	flex: 1 1 auto;
	min-height: 0;
}

/*
 * 嵌套 .scrollable-card-row：内层 .kt-inside-inner-col 在全部宽度都设为纵向 flex（与仅桌面的旧规则不同），
 * 否则 Infobox 上 flex:1 不生效。带 kb-section-sm-dir-horizontal 时在 ≤767px 再改回横向 row + stretch。
 */
.scrollable-card-row.kt-inner-column-height-full.kt-row-valign-top
	> .wp-block-kadence-column:not(.kb-section-dir-horizontal)
	> .kt-inside-inner-col {
	display: flex;
	flex-direction: column;
	min-height: 0;
	align-items: stretch;
}

/* Kadence 小屏横向列：与插件常用 767 断点一致，避免 768–1024 平板被误设为 row */
@media (max-width: 767px) {
	.scrollable-card-row.kt-inner-column-height-full
		> .wp-block-kadence-column.kb-section-sm-dir-horizontal
		> .kt-inside-inner-col {
		flex-direction: row;
		align-items: stretch;
	}
}

.scrollable-card-row.kt-inner-column-height-full .kt-inside-inner-col > .wp-block-kadence-infobox {
	height: 100%;
	flex: 1 1 auto;
	align-self: stretch;
	display: flex;
	flex-direction: column;
	min-height: 0;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

/* media top：链接块纵向铺满 */
.scrollable-card-row.kt-inner-column-height-full
	.wp-block-kadence-infobox.kt-blocks-info-box-media-align-top
	.kt-blocks-info-box-link-wrap {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 0;
	width: 100%;
	box-sizing: border-box;
}

/* media left/right：保持 Kadence 横向 flex，只拉高占位 */
.scrollable-card-row.kt-inner-column-height-full
	.wp-block-kadence-infobox.kt-blocks-info-box-media-align-left
	.kt-blocks-info-box-link-wrap,
.scrollable-card-row.kt-inner-column-height-full
	.wp-block-kadence-infobox.kt-blocks-info-box-media-align-right
	.kt-blocks-info-box-link-wrap {
	flex: 1 1 auto;
	min-height: 0;
	align-self: stretch;
	width: 100%;
	box-sizing: border-box;
}

/*
 * ---------- 手机端（≤767px）----------
 * 横滑/自定义 CSS 常把 .kt-row-column-wrap 做成 flex 行且 align-items:flex-start，
 * 列在交叉轴不拉伸，Infobox 无法获得「列高」。此处强制 stretch + 列内 flex:1 链。
 */
@media (max-width: 767px) {
	.kb-row-layout-wrap.scrollable-card-row.kt-inner-column-height-full > .kt-row-column-wrap {
		align-items: stretch !important;
		align-content: stretch !important;
	}

	.scrollable-card-row.kt-inner-column-height-full > .wp-block-kadence-column {
		display: flex !important;
		flex-direction: column !important;
		align-self: stretch !important;
		min-height: 0;
	}

	.scrollable-card-row.kt-inner-column-height-full > .wp-block-kadence-column > .kt-inside-inner-col {
		flex: 1 1 auto !important;
		min-height: 0 !important;
	}

	.scrollable-card-row.kt-inner-column-height-full > .wp-block-kadence-column.kb-section-sm-dir-horizontal > .kt-inside-inner-col {
		flex: 1 1 auto !important;
	}

	.scrollable-card-row.kt-inner-column-height-full .kt-inside-inner-col > .wp-block-kadence-infobox {
		flex: 1 1 auto !important;
		min-height: 0 !important;
	}

	.scrollable-card-row.kt-inner-column-height-full .wp-block-kadence-infobox .kt-blocks-info-box-link-wrap {
		flex: 1 1 auto !important;
		min-height: 0 !important;
	}
}
