/**
 * GPVL Post Grid — frontend (Elementor-safe, không phụ thuộc theme).
 */

.gpvl-pg {
	--gpvl-cols: 3;
	box-sizing: border-box;
}

.gpvl-pg *,
.gpvl-pg *::before,
.gpvl-pg *::after {
	box-sizing: inherit;
}

.gpvl-pg__grid {
	display: grid;
	grid-template-columns: repeat(var(--gpvl-cols, 3), minmax(0, 1fr));
	align-items: stretch;
}

.gpvl-pg__empty {
	margin: 0;
	padding: 1rem;
	text-align: center;
	opacity: 0.85;
}

.gpvl-pg__item {
	display: flex;
	flex-direction: column;
	min-width: 0;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 10px;
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.gpvl-pg__item:hover {
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
	transform: translateY(-2px);
}

.gpvl-pg__thumb {
	display: block;
	overflow: hidden;
	background: #f4f4f5;
}

.gpvl-pg__thumb--ratio-16-10 {
	aspect-ratio: 16 / 10;
}

.gpvl-pg__thumb--ratio-16-9 {
	aspect-ratio: 16 / 9;
}

.gpvl-pg__thumb--ratio-4-3 {
	aspect-ratio: 4 / 3;
}

.gpvl-pg__thumb--ratio-1-1 {
	aspect-ratio: 1 / 1;
}

.gpvl-pg__thumb--ratio-auto {
	aspect-ratio: auto;
}

.gpvl-pg__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.gpvl-pg__thumb--ratio-auto .gpvl-pg__img {
	height: auto;
	object-fit: contain;
}

.gpvl-pg__body {
	padding: 1rem 1.1rem 1.15rem;
	display: flex;
	flex-direction: column;
	gap: 0.45rem;
	flex: 1;
}

.gpvl-pg__cat {
	display: inline-block;
	font-size: 0.72rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #2563eb;
}

.gpvl-pg__title {
	margin: 0;
	font-size: 1.05rem;
	line-height: 1.35;
	overflow-wrap: anywhere;
}

.gpvl-pg__title a {
	text-decoration: none;
	color: inherit;
}

.gpvl-pg__title a:hover {
	text-decoration: underline;
}

.gpvl-pg__meta {
	font-size: 0.82rem;
	opacity: 0.75;
}

.gpvl-pg__excerpt {
	margin: 0;
	font-size: 0.92rem;
	line-height: 1.55;
	opacity: 0.88;
}

/* --- GPVL Post Meta widget --- */
.gpvl-post-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

.gpvl-post-meta .post-meta {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: inherit;
	text-decoration: none;
}

.gpvl-post-meta .meta-icon {
	display: inline-flex;
	line-height: 0;
}

.gpvl-post-meta .meta-icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.gpvl-post-meta .meta-icon img {
	display: block;
	width: 24px;
	height: 24px;
	border-radius: 999px;
}

.gpvl-post-meta .inner-pills-wrapper {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 6px;
}

.gpvl-post-meta .inner-pill-item {
	display: inline-flex;
	align-items: center;
	text-decoration: none;
}

/* --- Classic --- */
.gpvl-pg--classic .gpvl-pg__item {
	border-radius: 12px;
}

/* --- Magazine: bài đầu nổi bật --- */
.gpvl-pg--magazine .gpvl-pg__grid {
	grid-auto-flow: dense;
}

@media (min-width: 768px) {
	.gpvl-pg--magazine .gpvl-pg__item--featured {
		grid-column: span 2;
		grid-row: span 2;
	}

	.gpvl-pg--magazine .gpvl-pg__item--featured .gpvl-pg__title {
		font-size: 1.35rem;
	}

	.gpvl-pg--magazine .gpvl-pg__item--featured .gpvl-pg__thumb--ratio-16-10 {
		aspect-ratio: 21 / 10;
	}
}

/* --- Minimal: danh sách ngang --- */
.gpvl-pg--minimal .gpvl-pg__item {
	flex-direction: row;
	align-items: stretch;
	border-radius: 8px;
	border: 1px solid rgba(0, 0, 0, 0.06);
}

.gpvl-pg--minimal .gpvl-pg__thumb {
	flex: 0 0 112px;
	max-width: 112px;
	align-self: stretch;
}

.gpvl-pg--minimal .gpvl-pg__thumb--ratio-16-10,
.gpvl-pg--minimal .gpvl-pg__thumb--ratio-16-9,
.gpvl-pg--minimal .gpvl-pg__thumb--ratio-4-3,
.gpvl-pg--minimal .gpvl-pg__thumb--ratio-1-1 {
	aspect-ratio: 1 / 1;
	height: 100%;
}

.gpvl-pg--minimal .gpvl-pg__body {
	padding: 0.75rem 1rem;
	justify-content: center;
}

.gpvl-pg--minimal .gpvl-pg__title {
	font-size: 0.98rem;
}

.gpvl-pg--minimal .gpvl-pg__excerpt {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

@media (max-width: 767px) {
	.gpvl-pg--minimal .gpvl-pg__thumb {
		flex-basis: 88px;
		max-width: 88px;
	}
}

/* --- Minimal scroll (chỉ danh sách minimal, một khối cuộn) --- */
.gpvl-pg--minimal-scroll {
	--gpvl-min-scroll-max: 560px;
}

.gpvl-pg--minimal-scroll .gpvl-pg__minimal-scroll-root {
	max-height: var(--gpvl-min-scroll-max, 560px);
	min-height: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.gpvl-pg--minimal-scroll .gpvl-pg__minimal-scroll-root > .gpvl-pg__mag-split-scroll {
	flex: 1 1 auto;
	min-height: 0;
}

/* --- Magazine + scroll (featured trái, minimal phải có scroll) --- */
.gpvl-pg--magazine-scroll {
	--gpvl-scroll-side: 340px;
	--gpvl-mobile-side-max: 380px;
}

.gpvl-pg__mag-split {
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
	align-items: flex-start;
	gap: 20px;
}

.gpvl-pg__mag-split-main {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.gpvl-pg__mag-split-main .gpvl-pg__item--mag-scroll-main {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	width: 100%;
	min-height: 100%;
}

.gpvl-pg__mag-split-main .gpvl-pg__body {
	flex: 1;
}

.gpvl-pg__mag-split-side {
	flex: 0 0 min(var(--gpvl-scroll-side, 340px), 100%);
	width: min(var(--gpvl-scroll-side, 340px), 100%);
	max-width: 100%;
	min-width: min(240px, 100%);
	min-height: 0;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

/* Style 2: bài nổi bật full-width phía trên, danh sách cuộn full-width phía dưới */
.gpvl-pg__mag-split--style-2 {
	flex-direction: column;
	align-items: stretch;
}

.gpvl-pg__mag-split--style-2 .gpvl-pg__mag-split-main {
	flex: 0 0 auto;
	width: 100%;
	min-height: 0;
	/* Không bọc layout flex cột/con; khớp iframe Elementor trong elementor-editor-preview.css */
	display: contents !important;
}

.gpvl-pg__mag-split--style-2 .gpvl-pg__mag-split-main .gpvl-pg__item--mag-scroll-main {
	min-height: 0;
}

.gpvl-pg__mag-split--style-2 .gpvl-pg__mag-split-side {
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	max-width: none;
}

.gpvl-pg__mag-split--style-2 .gpvl-pg__mag-split-scroll {
	max-height: var(--gpvl-mobile-side-max, 380px);
}

.gpvl-pg__mag-scroll-hero {
	position: relative;
	width: 100%;
	overflow: hidden;
}

/* Hero Style 2: .gpvl-pg__body có flex:1 trong thẻ — kéo dãn tạo dải trắng rỗng dưới ảnh. */
.gpvl-pg__item--mag-scroll-hero .gpvl-pg__body {
	flex: 0 0 auto;
	min-height: 0;
}

/* Hero + ảnh «Tự nhiên»: không ra khối ôm ảnh; dùng 16:9 làm ô chuẩn + ảnh phủ (object-fit của Elementor vẫn áp). */
.gpvl-pg--magazine-scroll .gpvl-pg__mag-scroll-hero .gpvl-pg__mag-scroll-hero__media.gpvl-pg__thumb--ratio-auto {
	display: block;
	position: relative;
	isolation: isolate;
	overflow: hidden;
	aspect-ratio: 16 / 9;
}

.gpvl-pg--magazine-scroll .gpvl-pg__mag-scroll-hero .gpvl-pg__mag-scroll-hero__media.gpvl-pg__thumb--ratio-auto .gpvl-pg__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
}

/* Ô có aspect-ratio + img height: % thường để sót khoảng dưới; img absolute inset 0 ôm kín ô. */
.gpvl-pg--magazine-scroll .gpvl-pg__mag-split-main .gpvl-pg__item--mag-scroll-main:not(.gpvl-pg__item--mag-scroll-hero) > .gpvl-pg__thumb:not(.gpvl-pg__thumb--ratio-auto),
.gpvl-pg--magazine-scroll .gpvl-pg__mag-scroll-hero .gpvl-pg__mag-scroll-hero__media.gpvl-pg__thumb:not(.gpvl-pg__thumb--ratio-auto) {
	display: block;
	position: relative;
	isolation: isolate;
	overflow: hidden;
}

.gpvl-pg--magazine-scroll .gpvl-pg__mag-split-main .gpvl-pg__item--mag-scroll-main:not(.gpvl-pg__item--mag-scroll-hero) > .gpvl-pg__thumb:not(.gpvl-pg__thumb--ratio-auto) .gpvl-pg__img,
.gpvl-pg--magazine-scroll .gpvl-pg__mag-scroll-hero .gpvl-pg__mag-scroll-hero__media.gpvl-pg__thumb:not(.gpvl-pg__thumb--ratio-auto) .gpvl-pg__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
}

.gpvl-pg__mag-scroll-hero__overlay {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	padding: 1rem 1.1rem 1.15rem;
	box-sizing: border-box;
	pointer-events: none;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.38) 40%, transparent 72%);
}

.gpvl-pg__mag-scroll-hero__overlay .gpvl-pg__cat,
.gpvl-pg__mag-scroll-hero__overlay .gpvl-pg__title,
.gpvl-pg__mag-scroll-hero__overlay .gpvl-pg__meta {
	pointer-events: auto;
}

.gpvl-pg__mag-scroll-hero__overlay .gpvl-pg__title {
	margin: 0;
	color: #fff;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.gpvl-pg__mag-scroll-hero__overlay .gpvl-pg__title a {
	color: inherit;
	text-decoration: none;
}

.gpvl-pg__mag-scroll-hero__overlay .gpvl-pg__title a:hover {
	text-decoration: underline;
}

.gpvl-pg__mag-scroll-hero__overlay .gpvl-pg__cat {
	color: rgba(255, 255, 255, 0.92);
}

.gpvl-pg__mag-scroll-hero__overlay .gpvl-pg__meta {
	color: rgba(255, 255, 255, 0.9);
	opacity: 1;
}

.gpvl-pg__mag-split-scroll {
	--gpvl-sb-width: 8px;
	--gpvl-sb-track: rgba(0, 0, 0, 0.06);
	--gpvl-sb-thumb: rgba(0, 0, 0, 0.32);
	--gpvl-sb-thumb-hover: rgba(0, 0, 0, 0.48);
	--gpvl-sb-thumb-radius: 8px;
	flex: 1 1 auto;
	min-height: 0;
	overflow-x: hidden;
	overflow-y: auto;
	/* Vuốt tới đỉnh/cuối khối cuộn: tiếp tục cuộn trang (mobile). Giữ nhẹ chiều ngang để không kéo cả khối theo sideways. */
	overscroll-behavior-x: contain;
	overscroll-behavior-y: auto;
	scrollbar-gutter: stable;
	scrollbar-width: thin;
	scrollbar-color: var(--gpvl-sb-thumb) var(--gpvl-sb-track);
	padding-right: 2px;
	display: flex;
	flex-direction: column;
	gap: 0;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 10px;
	background: #fafafa;
}

.gpvl-pg__mag-split-scroll::-webkit-scrollbar {
	width: var(--gpvl-sb-width);
}

.gpvl-pg__mag-split-scroll::-webkit-scrollbar-track {
	background: var(--gpvl-sb-track);
	border-radius: var(--gpvl-sb-thumb-radius);
}

.gpvl-pg__mag-split-scroll::-webkit-scrollbar-thumb {
	background: var(--gpvl-sb-thumb);
	border-radius: var(--gpvl-sb-thumb-radius);
}

.gpvl-pg__mag-split-scroll::-webkit-scrollbar-thumb:hover {
	background: var(--gpvl-sb-thumb-hover);
}

/* Nút tải thêm — nằm trong .gpvl-pg__mag-split-scroll, cuối danh sách (chỉ thấy khi cuộn tới đáy) */
.gpvl-pg__mag-split-scroll > .gpvl-pg__load-more--in-scroll {
	margin-top: 3px;
	padding-top: 1px;
	/* border-top: 1px solid rgba(0, 0, 0, 0.07); */
}

.gpvl-pg__load-more {
	flex: 0 0 auto;
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 0.55rem 0.25rem 0.2rem;
}

.gpvl-pg__load-more-btn {
	margin: 0;
	text-transform: unset;
	padding: 0.35rem 0.85rem;
	font: inherit;
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.3;
	color: #1f2937;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 999px;
	cursor: pointer;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
	transition:
		background 0.15s ease,
		border-color 0.15s ease,
		box-shadow 0.15s ease;
}

.gpvl-pg__load-more-btn:hover:not(:disabled) {
	background: #efefef;
	border-color: rgba(0, 0, 0, 0.18);
	color: #3e4145;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.gpvl-pg__load-more-btn:disabled {
	opacity: 0.72;
	cursor: wait;
}

/* Ẩn thanh cuộn cho đến khi hover / focus trong vùng (bật bằng Elementor) */
.gpvl-pg__mag-split-scroll--sb-hover {
	scrollbar-gutter: auto;
	scrollbar-color: transparent transparent;
}

.gpvl-pg__mag-split-scroll--sb-hover::-webkit-scrollbar-track {
	background: transparent;
}

.gpvl-pg__mag-split-scroll--sb-hover::-webkit-scrollbar-thumb {
	background: transparent;
}

.gpvl-pg__mag-split-scroll--sb-hover:hover,
.gpvl-pg__mag-split-scroll--sb-hover:focus-within,
.gpvl-pg__mag-split-scroll--sb-hover.gpvl-pg__mag-split-scroll--sb-scrolling {
	scrollbar-color: var(--gpvl-sb-thumb) var(--gpvl-sb-track);
}

.gpvl-pg__mag-split-scroll--sb-hover:hover::-webkit-scrollbar-track,
.gpvl-pg__mag-split-scroll--sb-hover:focus-within::-webkit-scrollbar-track,
.gpvl-pg__mag-split-scroll--sb-hover.gpvl-pg__mag-split-scroll--sb-scrolling::-webkit-scrollbar-track {
	background: var(--gpvl-sb-track);
}

.gpvl-pg__mag-split-scroll--sb-hover:hover::-webkit-scrollbar-thumb,
.gpvl-pg__mag-split-scroll--sb-hover:focus-within::-webkit-scrollbar-thumb,
.gpvl-pg__mag-split-scroll--sb-hover.gpvl-pg__mag-split-scroll--sb-scrolling::-webkit-scrollbar-thumb {
	background: var(--gpvl-sb-thumb);
}

.gpvl-pg__mag-split-scroll--sb-hover:hover::-webkit-scrollbar-thumb:hover,
.gpvl-pg__mag-split-scroll--sb-hover:focus-within::-webkit-scrollbar-thumb:hover,
.gpvl-pg__mag-split-scroll--sb-hover.gpvl-pg__mag-split-scroll--sb-scrolling::-webkit-scrollbar-thumb:hover {
	background: var(--gpvl-sb-thumb-hover);
}

@media (min-width: 992px) {
	.gpvl-pg__item--mag-scroll-main .gpvl-pg__title {
		font-size: 1.35rem;
	}

	.gpvl-pg__item--mag-scroll-main .gpvl-pg__thumb--ratio-16-10 {
		aspect-ratio: 21 / 10;
	}
}

.gpvl-pg__side-row {
	display: flex;
	flex-direction: row;
	align-items: stretch;
	gap: 0.65rem;
	padding: 0.65rem 0.75rem;
	background: #fff;
	border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.gpvl-pg__side-row:last-child {
	border-bottom: 0;
}

.gpvl-pg__side-thumb {
	flex: 0 0 88px;
	max-width: 88px;
	display: block;
	overflow: hidden;
	border-radius: 6px;
	background: #eee;
	align-self: flex-start;
}

.gpvl-pg__side-thumb.gpvl-pg__thumb--ratio-16-10,
.gpvl-pg__side-thumb.gpvl-pg__thumb--ratio-16-9,
.gpvl-pg__side-thumb.gpvl-pg__thumb--ratio-4-3,
.gpvl-pg__side-thumb.gpvl-pg__thumb--ratio-1-1 {
	aspect-ratio: 1 / 1;
}

.gpvl-pg__side-thumb.gpvl-pg__thumb--ratio-auto {
	aspect-ratio: auto;
}

.gpvl-pg__side-thumb .gpvl-pg__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.gpvl-pg__side-body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 0.25rem;
	padding: 0.15rem 0;
}

.gpvl-pg__side-title {
	margin: 0;
	font-size: 0.92rem;
	line-height: 1.35;
	font-weight: 600;
	overflow-wrap: anywhere;
}

.gpvl-pg__side-title a {
	color: inherit;
	text-decoration: none;
}

.gpvl-pg__side-title a:hover {
	text-decoration: underline;
}

.gpvl-pg__side-body .gpvl-pg__meta {
	font-size: 0.78rem;
}

.gpvl-pg__side-excerpt {
	margin: 0;
	font-size: 0.82rem;
	line-height: 1.45;
	opacity: 0.88;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

@media (max-width: 991px) {
	.gpvl-pg__mag-split {
		flex-direction: column;
		align-items: stretch;
	}

	.gpvl-pg__mag-split-side {
		flex: 1 1 auto;
		width: 100%;
		min-width: 0;
		max-height: var(--gpvl-mobile-side-max, 380px);
	}

	.gpvl-pg__mag-split--style-1 > .gpvl-pg__mag-split-side .gpvl-pg__mag-split-scroll {
		flex: 1 1 auto;
		max-height: none;
	}
}

/* -------------------------------------------------------------------------- */
/* Elementor: sticky trong cột/section, lệch dưới header .rstb-header (RSTB)   */
/* -------------------------------------------------------------------------- */
/*
 * Gán class này vào widget/column (Elementor → Advanced → CSS Classes).
 * Sticky bám theo viewport nhưng vẫn “nằm trong” khối cha cho tới khi cha cuộn hết.
 *
 * --rstb-header-sticky-h: plugin tự đo thanh .rstb-header .rstb-sticky.is-sticky (RSTB).
 * Có thể ghi đè trên :root/body (px). Header không fixed / không che: để 0 hoặc bỏ qua.
 *
 * --rstb-el-sticky-gap: khoảng hở dưới header (mặc định 1rem).
 *
 * Lưu ý: cột/section cha không được overflow: hidden (Elementor đôi khi bật);
 * khi đó sticky sẽ không hoạt động — chuyển overflow về visible cho cột chứa.
 *
 * calc() giữ trên một dòng + khoảng trắng quanh + / - : một số công cụ minify CSS
 * gộp dòng làm mất khoảng trắng trong calc → cú pháp sai, trình duyệt bỏ qua top/max-height.
 */
.gpvl-sticky {
	position: sticky;
	top: calc(env(safe-area-inset-top, 0px) + var(--wp-admin--admin-bar--height, 0px) + var(--rstb-header-sticky-h, 0px) + var(--rstb-el-sticky-gap, 1rem));
	align-self: flex-start;
	z-index: 2;
}

/* Admin bar: WP cũ có thể chưa set --wp-admin--admin-bar--height trên :root */
body.admin-bar .gpvl-sticky {
	top: calc(env(safe-area-inset-top, 0px) + var(--wp-admin--admin-bar--height, 32px) + var(--rstb-header-sticky-h, 0px) + var(--rstb-el-sticky-gap, 1rem));
}

@media screen and (max-width: 782px) {
	body.admin-bar .gpvl-sticky {
		top: calc(env(safe-area-inset-top, 0px) + var(--wp-admin--admin-bar--height, 46px) + var(--rstb-header-sticky-h, 0px) + var(--rstb-el-sticky-gap, 1rem));
	}
}

/* Tùy chọn: giới hạn chiều cao theo viewport để nội dung dài cuộn trong khối */
.gpvl-sticky.gpvl-sticky--clamp-vh {
	max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - var(--wp-admin--admin-bar--height, 0px) - var(--rstb-header-sticky-h, 0px) - var(--rstb-el-sticky-gap, 1rem));
	overflow: auto;
	-webkit-overflow-scrolling: touch;
}

body.admin-bar .gpvl-sticky.gpvl-sticky--clamp-vh {
	max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - var(--wp-admin--admin-bar--height, 32px) - var(--rstb-header-sticky-h, 0px) - var(--rstb-el-sticky-gap, 1rem));
}

@media screen and (max-width: 782px) {
	body.admin-bar .gpvl-sticky.gpvl-sticky--clamp-vh {
		max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - var(--wp-admin--admin-bar--height, 46px) - var(--rstb-header-sticky-h, 0px) - var(--rstb-el-sticky-gap, 1rem));
	}
}
