/**
 * Blog Posts Grid – Frontend Styles
 *
 * Premium card grid UI with glassmorphism, hover animations,
 * gradient accents, and full responsiveness.
 *
 * @package Blog_Posts_Grid
 * @since   1.0.0
 */

/* =========================================================
   CSS Custom Properties (overridden via inline styles from admin)
   ========================================================= */
:root {
	--bpg-primary: #667eea;
	--bpg-secondary: #764ba2;
	--bpg-card-bg: #ffffff;
	--bpg-text: #1a1a2e;
	--bpg-columns: 3;
	--bpg-gap: 24px;
	--bpg-radius: 16px;
	--bpg-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
	--bpg-transition: 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
	--bpg-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* =========================================================
   Wrapper
   ========================================================= */
.bpg-wrapper {
	font-family: var(--bpg-font);
	max-width: 1400px;
	margin: 0 auto;
	padding: 40px 20px;
	color: var(--bpg-text);
}

/* =========================================================
   Category Filter Tabs
   ========================================================= */
.bpg-filter-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 36px;
	padding: 8px;
	background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
	border-radius: 16px;
	justify-content: center;
}

.bpg-filter-tab {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 10px 22px;
	border: 2px solid transparent;
	border-radius: 12px;
	background: transparent;
	color: var(--bpg-text);
	font-family: var(--bpg-font);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all var(--bpg-transition);
	position: relative;
	overflow: hidden;
}

.bpg-filter-tab::before {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(135deg, var(--bpg-primary), var(--bpg-secondary));
	opacity: 0;
	transition: opacity var(--bpg-transition);
	border-radius: 10px;
}

.bpg-filter-tab:hover {
	border-color: var(--bpg-primary);
	transform: translateY(-2px);
}

.bpg-filter-tab--active {
	color: #fff;
	border-color: transparent;
	box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.bpg-filter-tab--active::before {
	opacity: 1;
}

.bpg-filter-tab-text,
.bpg-filter-tab-count {
	position: relative;
	z-index: 1;
}

.bpg-filter-tab-count {
	background: rgba(255, 255, 255, 0.25);
	padding: 2px 8px;
	border-radius: 20px;
	font-size: 12px;
	font-weight: 700;
}

.bpg-filter-tab:not(.bpg-filter-tab--active) .bpg-filter-tab-count {
	background: rgba(102, 126, 234, 0.1);
	color: var(--bpg-primary);
}

/* =========================================================
   Grid Layout
   ========================================================= */
.bpg-grid {
	display: grid;
	grid-template-columns: repeat(var(--bpg-columns), 1fr);
	gap: var(--bpg-gap);
}

/* =========================================================
   Card
   ========================================================= */
.bpg-card {
	background: var(--bpg-card-bg);
	border-radius: var(--bpg-radius);
	box-shadow: var(--bpg-shadow);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transition: all var(--bpg-transition);
	position: relative;
	border: 1px solid rgba(0, 0, 0, 0.04);
}

.bpg-card:hover {
	transform: translateY(-8px);
	box-shadow:
		0 20px 60px rgba(0, 0, 0, 0.12),
		0 8px 20px rgba(102, 126, 234, 0.15);
}

/* Subtle gradient accent line at top of card */
.bpg-card::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	background: linear-gradient(90deg, var(--bpg-primary), var(--bpg-secondary));
	opacity: 0;
	transition: opacity var(--bpg-transition);
	z-index: 2;
}

.bpg-card:hover::before {
	opacity: 1;
}

/* =========================================================
   Card – Image
   ========================================================= */
.bpg-card__image-link {
	display: block;
	text-decoration: none;
	overflow: hidden;
}

.bpg-card__image-wrap {
	position: relative;
	overflow: hidden;
	aspect-ratio: 16 / 10;
	background: linear-gradient(135deg, #f0f0f5, #e8e8ee);
}

.bpg-card__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.bpg-card:hover .bpg-card__image {
	transform: scale(1.08);
}

.bpg-card__image-overlay {
	position: absolute;
	inset: 0;
	background: linear-gradient(
		180deg,
		transparent 40%,
		rgba(0, 0, 0, 0.04) 100%
	);
	pointer-events: none;
	transition: background var(--bpg-transition);
}

.bpg-card:hover .bpg-card__image-overlay {
	background: linear-gradient(
		180deg,
		transparent 30%,
		rgba(102, 126, 234, 0.08) 100%
	);
}

.bpg-card__image-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #c0c0d0;
	background: linear-gradient(135deg, #f5f5fa, #ebebf2);
}

/* Category badge */
.bpg-card__category-badge {
	position: absolute;
	top: 14px;
	left: 14px;
	z-index: 3;
	padding: 5px 14px;
	background: linear-gradient(135deg, var(--bpg-primary), var(--bpg-secondary));
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	border-radius: 8px;
	backdrop-filter: blur(10px);
	box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
	transition: transform var(--bpg-transition);
}

.bpg-card:hover .bpg-card__category-badge {
	transform: translateY(-2px);
}

/* =========================================================
   Card – Content
   ========================================================= */
.bpg-card__content {
	padding: 22px 24px 24px;
	display: flex;
	flex-direction: column;
	flex: 1;
}

.bpg-card__title {
	margin: 0 0 12px;
	font-family: var(--bpg-font);
	font-size: 18px;
	font-weight: 700;
	line-height: 1.4;
	letter-spacing: -0.3px;
}

.bpg-card__title a {
	color: var(--bpg-text);
	text-decoration: none;
	transition: color var(--bpg-transition);
	background-image: linear-gradient(var(--bpg-primary), var(--bpg-primary));
	background-size: 0% 2px;
	background-repeat: no-repeat;
	background-position: 0 100%;
	transition: background-size 0.4s ease, color 0.3s ease;
}

.bpg-card:hover .bpg-card__title a {
	color: var(--bpg-primary);
	background-size: 100% 2px;
}

.bpg-card__excerpt {
	margin: 0 0 18px;
	font-size: 14px;
	line-height: 1.7;
	color: #6b7280;
	flex: 1;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* =========================================================
   Card – Footer / Meta
   ========================================================= */
.bpg-card__footer {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin-top: auto;
	padding-top: 16px;
	border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.bpg-card__meta {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
}

.bpg-card__author {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	text-decoration: none;
	color: var(--bpg-text);
	transition: color var(--bpg-transition);
}

.bpg-card__author:hover {
	color: var(--bpg-primary);
}

.bpg-card__avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid rgba(102, 126, 234, 0.2);
	transition: border-color var(--bpg-transition);
}

.bpg-card__author:hover .bpg-card__avatar {
	border-color: var(--bpg-primary);
}

.bpg-card__author-name {
	font-size: 13px;
	font-weight: 600;
}

.bpg-card__date {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 12px;
	color: #9ca3af;
	font-weight: 500;
}

.bpg-card__date svg {
	opacity: 0.6;
}

.bpg-card__actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.bpg-card__read-time {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 12px;
	color: #9ca3af;
	font-weight: 500;
}

.bpg-card__read-time svg {
	opacity: 0.6;
}

/* Read More Button */
.bpg-card__read-more {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 18px;
	background: linear-gradient(135deg, var(--bpg-primary), var(--bpg-secondary));
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	border-radius: 10px;
	transition: all var(--bpg-transition);
	position: relative;
	overflow: hidden;
}

.bpg-card__read-more::before {
	content: '';
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(
		90deg,
		transparent,
		rgba(255, 255, 255, 0.25),
		transparent
	);
	transition: left 0.6s ease;
}

.bpg-card__read-more:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
	color: #fff;
}

.bpg-card__read-more:hover::before {
	left: 100%;
}

.bpg-card__read-more svg {
	transition: transform 0.3s ease;
}

.bpg-card__read-more:hover svg {
	transform: translateX(4px);
}

/* =========================================================
   No Posts
   ========================================================= */
.bpg-no-posts {
	text-align: center;
	padding: 80px 40px;
	background: linear-gradient(135deg, rgba(102, 126, 234, 0.04), rgba(118, 75, 162, 0.04));
	border-radius: var(--bpg-radius);
	border: 2px dashed rgba(102, 126, 234, 0.2);
}

.bpg-no-posts-icon {
	font-size: 48px;
	margin-bottom: 16px;
}

.bpg-no-posts p {
	font-size: 18px;
	color: #9ca3af;
	font-weight: 500;
	margin: 0;
}

/* =========================================================
   Pagination – Numbered
   ========================================================= */
.bpg-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: 48px;
	padding: 12px;
	flex-wrap: wrap;
}

.bpg-page-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	height: 44px;
	padding: 0 14px;
	border: 2px solid rgba(0, 0, 0, 0.08);
	border-radius: 12px;
	background: var(--bpg-card-bg);
	color: var(--bpg-text);
	font-family: var(--bpg-font);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: all var(--bpg-transition);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.bpg-page-btn:hover {
	border-color: var(--bpg-primary);
	color: var(--bpg-primary);
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(102, 126, 234, 0.15);
}

.bpg-page-btn--active {
	background: linear-gradient(135deg, var(--bpg-primary), var(--bpg-secondary));
	color: #fff;
	border-color: transparent;
	box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.bpg-page-btn--active:hover {
	color: #fff;
	transform: translateY(-3px);
	box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.bpg-page-dots {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 44px;
	color: #9ca3af;
	font-weight: 600;
	font-size: 18px;
	letter-spacing: 2px;
}

.bpg-page-prev svg,
.bpg-page-next svg {
	transition: transform 0.3s ease;
}

.bpg-page-prev:hover svg {
	transform: translateX(-3px);
}

.bpg-page-next:hover svg {
	transform: translateX(3px);
}

/* =========================================================
   Pagination – Load More
   ========================================================= */
.bpg-load-more-wrap {
	text-align: center;
	margin-top: 48px;
}

.bpg-load-more-btn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 16px 40px;
	background: linear-gradient(135deg, var(--bpg-primary), var(--bpg-secondary));
	color: #fff;
	font-family: var(--bpg-font);
	font-size: 16px;
	font-weight: 700;
	border: none;
	border-radius: 14px;
	cursor: pointer;
	transition: all var(--bpg-transition);
	position: relative;
	overflow: hidden;
	box-shadow: 0 6px 25px rgba(102, 126, 234, 0.35);
}

.bpg-load-more-btn::before {
	content: '';
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(
		90deg,
		transparent,
		rgba(255, 255, 255, 0.2),
		transparent
	);
	transition: left 0.7s ease;
}

.bpg-load-more-btn:hover {
	transform: translateY(-3px);
	box-shadow: 0 10px 35px rgba(102, 126, 234, 0.5);
}

.bpg-load-more-btn:hover::before {
	left: 100%;
}

.bpg-load-more-btn:active {
	transform: translateY(-1px);
}

/* Loading spinner */
.bpg-load-more-spinner {
	display: none;
	width: 20px;
	height: 20px;
	border: 3px solid rgba(255, 255, 255, 0.3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: bpg-spin 0.7s linear infinite;
}

.bpg-load-more-btn.bpg-loading .bpg-load-more-text {
	opacity: 0.7;
}

.bpg-load-more-btn.bpg-loading .bpg-load-more-spinner {
	display: block;
}

.bpg-load-more-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

/* =========================================================
   Skeleton Loading (for AJAX)
   ========================================================= */
.bpg-skeleton {
	background: var(--bpg-card-bg);
	border-radius: var(--bpg-radius);
	overflow: hidden;
	box-shadow: var(--bpg-shadow);
}

.bpg-skeleton__image {
	aspect-ratio: 16 / 10;
	background: linear-gradient(
		90deg,
		#f0f0f5 25%,
		#e8e8ee 50%,
		#f0f0f5 75%
	);
	background-size: 200% 100%;
	animation: bpg-shimmer 1.5s ease-in-out infinite;
}

.bpg-skeleton__content {
	padding: 22px 24px 24px;
}

.bpg-skeleton__line {
	height: 14px;
	background: linear-gradient(
		90deg,
		#f0f0f5 25%,
		#e8e8ee 50%,
		#f0f0f5 75%
	);
	background-size: 200% 100%;
	animation: bpg-shimmer 1.5s ease-in-out infinite;
	border-radius: 6px;
	margin-bottom: 12px;
}

.bpg-skeleton__line--title {
	height: 20px;
	width: 80%;
}

.bpg-skeleton__line--short {
	width: 50%;
}

/* =========================================================
   Card entrance animation
   ========================================================= */
.bpg-card {
	opacity: 0;
	transform: translateY(30px);
	animation: bpg-fadeInUp 0.6s ease forwards;
}

.bpg-card:nth-child(1)  { animation-delay: 0.05s; }
.bpg-card:nth-child(2)  { animation-delay: 0.10s; }
.bpg-card:nth-child(3)  { animation-delay: 0.15s; }
.bpg-card:nth-child(4)  { animation-delay: 0.20s; }
.bpg-card:nth-child(5)  { animation-delay: 0.25s; }
.bpg-card:nth-child(6)  { animation-delay: 0.30s; }
.bpg-card:nth-child(7)  { animation-delay: 0.35s; }
.bpg-card:nth-child(8)  { animation-delay: 0.40s; }
.bpg-card:nth-child(9)  { animation-delay: 0.45s; }
.bpg-card:nth-child(10) { animation-delay: 0.50s; }
.bpg-card:nth-child(11) { animation-delay: 0.55s; }
.bpg-card:nth-child(12) { animation-delay: 0.60s; }

/* AJAX-loaded cards animate in */
.bpg-card--animate-in {
	opacity: 0;
	transform: translateY(30px);
	animation: bpg-fadeInUp 0.5s ease forwards;
}

/* =========================================================
   Keyframes
   ========================================================= */
@keyframes bpg-fadeInUp {
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes bpg-spin {
	to {
		transform: rotate(360deg);
	}
}

@keyframes bpg-shimmer {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}

/* =========================================================
   Grid loading overlay (during AJAX)
   ========================================================= */
.bpg-grid--loading {
	position: relative;
	min-height: 200px;
	pointer-events: none;
}

.bpg-grid--loading::after {
	content: '';
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, 0.6);
	backdrop-filter: blur(4px);
	border-radius: var(--bpg-radius);
	z-index: 10;
	animation: bpg-fadeInUp 0.2s ease;
}

/* =========================================================
   Responsive Breakpoints
   ========================================================= */

/* Large tablets / small desktops */
@media (max-width: 1200px) {
	.bpg-grid {
		--bpg-columns: 3;
	}
}

/* Tablets */
@media (max-width: 992px) {
	.bpg-grid {
		--bpg-columns: 2;
	}

	.bpg-wrapper {
		padding: 30px 16px;
	}

	.bpg-card__title {
		font-size: 16px;
	}
}

/* Mobile */
@media (max-width: 768px) {
	.bpg-grid {
		--bpg-columns: 1;
		gap: 20px;
	}

	.bpg-wrapper {
		padding: 24px 14px;
	}

	.bpg-card__content {
		padding: 18px 20px 20px;
	}

	.bpg-card__title {
		font-size: 17px;
	}

	.bpg-card__excerpt {
		font-size: 13px;
	}

	/* Filter tabs scroll */
	.bpg-filter-tabs {
		flex-wrap: nowrap;
		overflow-x: auto;
		justify-content: flex-start;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		padding: 8px 4px;
		gap: 8px;
	}

	.bpg-filter-tabs::-webkit-scrollbar {
		display: none;
	}

	.bpg-filter-tab {
		white-space: nowrap;
		padding: 8px 16px;
		font-size: 13px;
	}

	/* Pagination */
	.bpg-pagination {
		gap: 6px;
		margin-top: 32px;
	}

	.bpg-page-btn {
		min-width: 38px;
		height: 38px;
		font-size: 13px;
		border-radius: 10px;
	}

	.bpg-load-more-btn {
		width: 100%;
		justify-content: center;
		padding: 14px 30px;
		font-size: 15px;
	}
}

/* Small mobile */
@media (max-width: 480px) {
	.bpg-card__footer {
		gap: 12px;
	}

	.bpg-card__meta {
		gap: 10px;
	}

	.bpg-card__actions {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}

	.bpg-card__read-more {
		width: 100%;
		justify-content: center;
	}
}

/* =========================================================
   Dark mode support (prefers-color-scheme)
   ========================================================= */
@media (prefers-color-scheme: dark) {
	.bpg-wrapper {
		/* Only apply if card-bg is still default white */
	}

	/* Users can override with admin color settings,
	   so dark mode is opt-in via admin panel. */
}

/* =========================================================
   Print styles
   ========================================================= */
@media print {
	.bpg-filter-tabs,
	.bpg-pagination,
	.bpg-load-more-wrap {
		display: none;
	}

	.bpg-card {
		break-inside: avoid;
		box-shadow: none;
		border: 1px solid #ddd;
	}

	.bpg-card:hover {
		transform: none;
	}
}

/* =========================================================
   Accessibility – Reduced Motion
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
	.bpg-card,
	.bpg-card__image,
	.bpg-card__read-more,
	.bpg-filter-tab,
	.bpg-page-btn,
	.bpg-load-more-btn {
		transition: none;
		animation: none;
	}

	.bpg-card {
		opacity: 1;
		transform: none;
	}

	.bpg-card:hover {
		transform: none;
	}

	.bpg-card:hover .bpg-card__image {
		transform: none;
	}
}
