/* Timiton Posts Grid — RTL-first magazine grid */

.tpg-root {
	--tpg-radius: 10px;
	direction: rtl;
	text-align: right;
	width: 100%;
}

/* Header */
.tpg-head {
	margin-bottom: 16px;
}
.tpg-head__title {
	margin: 0 0 4px;
	font-weight: 700;
}
.tpg-head__subtitle {
	margin: 0;
	opacity: 0.75;
}

/* Tabs nav */
.tpg-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 18px;
}
.tpg-tab {
	border: 1px solid #e2e8f0;
	background: #fff;
	border-radius: 999px;
	padding: 8px 22px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	color: #1f2937;
	transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.tpg-tab:hover {
	border-color: #cbd5e1;
}
.tpg-tab.is-active {
	background: #1d4ed8;
	color: #fff;
	border-color: #1d4ed8;
}

/* Body: 2x2 grid so the banner spans ONLY the content row (tabs + grid) while the
   pagination sits in its own row BELOW — banner top aligns with the tabs row and its
   bottom with the cards/grid bottom, with the pager underneath (not inside the banner).
   Default (start) = banner on the right in RTL. */
.tpg-body {
	display: grid;
	column-gap: 24px;
	grid-template-columns: auto 1fr;
	grid-template-rows: auto auto;
	grid-template-areas:
		"promo main"
		".     pager";
}
.tpg-promo {
	grid-area: promo;
	align-self: stretch; /* fill the content row height (= tabs + grid) */
	width: 240px;
	max-width: 240px;
	display: flex;
	flex-direction: column;
}
.tpg-main {
	grid-area: main;
	min-width: 0;
	display: flex;
	flex-direction: column;
}
.tpg-panels {
	min-width: 0;
}
/* Visible pager row, under the grid, outside the banner's height. */
.tpg-pager {
	grid-area: pager;
	margin-top: 24px;
}
/* Hidden per-tab pagination cache (no height; swapped into .tpg-pager on tab switch). */
.tpg-pag {
	display: none;
}
/* Let the link/image fill the full stretched height of the banner. */
.tpg-promo a {
	flex: 1 1 auto;
	display: block;
	width: 100%;
}
.tpg-promo > img {
	flex: 1 1 auto; /* when there is no <a> wrapper, the img is the flex child */
}
.tpg-promo img {
	width: 100%;
	height: 100%;
	border-radius: var(--tpg-radius);
	display: block;
	object-fit: cover; /* fill the full row height with no distortion */
}
/* Banner side "end" = left in RTL: swap the columns/areas (pager stays under the grid). */
.tpg-promo-end .tpg-body {
	grid-template-columns: 1fr auto;
	grid-template-areas:
		"main promo"
		"pager .";
}

/* Filter chips row */
.tpg-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 18px;
	justify-content: flex-start;
}
.tpg-filter {
	border: 1px solid #e2e8f0;
	background: #fff;
	border-radius: 999px;
	padding: 7px 16px;
	font: inherit;
	font-size: 0.9em;
	cursor: pointer;
	color: #334155;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.tpg-filter:hover {
	border-color: #cbd5e1;
}
.tpg-filter.is-active {
	background: #1d4ed8;
	color: #fff;
	border-color: #1d4ed8;
}
.tpg-filter__caret {
	font-size: 0.7em;
	opacity: 0.7;
}

/* Grid */
.tpg-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 20px;
}
.tpg-grid-wrap {
	position: relative;
	min-height: 80px;
}
.tpg-grid-wrap.is-loading {
	opacity: 0.45;
	pointer-events: none;
	transition: opacity .15s ease;
}

/* Card */
.tpg-card {
	background: #fff;
	border-radius: var(--tpg-radius);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}
.tpg-card__link {
	text-decoration: none;
	color: inherit;
	display: flex;
	flex-direction: column;
	height: 100%;
}
.tpg-card__media {
	position: relative;
	display: block;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background: #f1f5f9;
}
/* Absolutely fill the media box so the image covers it edge-to-edge with no gray
   gap. height:100% !important beats the theme's img{height:auto}. */
.tpg-card__media .tpg-card__img {
	position: absolute;
	inset: 0;
	width: 100% !important;
	height: 100% !important;
	max-width: none;
	object-fit: cover;
	display: block;
	transition: transform .3s ease;
}
.tpg-card:hover .tpg-card__media .tpg-card__img {
	transform: scale(1.04);
}
.tpg-card__img--placeholder {
	background: linear-gradient(135deg, #e2e8f0, #f8fafc);
}
.tpg-card__tag {
	position: absolute;
	inset-inline-start: 10px;
	bottom: 10px;
	background: #1d4ed8;
	color: #fff;
	font-size: 0.78em;
	font-weight: 600;
	line-height: 1;
	padding: 6px 12px;
	border-radius: 6px;
	max-width: calc(100% - 20px);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.tpg-card__title {
	margin: 12px 12px 16px;
	padding: 0;
	font-size: 1em;
	font-weight: 600;
	line-height: 1.4;
	color: #1f2937;
}
/* Cap the title at 2 rows WITHOUT an ellipsis ("..."). Plain overflow:hidden clips at
   the 2-line height; normal word-wrapping means a word is never cut mid-word — only a
   full 3rd line is hidden. High specificity + !important so a theme rule
   (hello-elementor sets headings to display:flow-root) can't change it. */
.tpg-root .tpg-card .tpg-card__title {
	display: block !important;
	overflow: hidden;
	max-height: 2.8em; /* line-height 1.4 × 2 rows */
	word-break: normal;
	overflow-wrap: break-word;
}

/* Empty state */
.tpg-empty {
	padding: 40px 16px;
	text-align: center;
	color: #64748b;
	background: #f8fafc;
	border-radius: var(--tpg-radius);
}

/* Pagination */
.tpg-pagination-wrap {
	margin-top: 24px;
}
.tpg-pagination {
	display: flex;
	gap: 8px;
	justify-content: center;
	align-items: center;
	/* Keep pagination LTR so it's the universal pattern: ‹ prev | 1 2 3 | next › */
	direction: ltr;
}
.tpg-page {
	min-width: 40px;
	height: 40px;
	border: 1px solid #e2e8f0;
	background: #fff;
	border-radius: 8px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	color: #334155;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background-color .15s ease, color .15s ease;
}
.tpg-page:hover:not(.tpg-page--disabled):not(.tpg-page--gap) {
	border-color: #cbd5e1;
}
.tpg-page--active {
	background: #1d4ed8;
	color: #fff;
	border-color: #1d4ed8;
}
.tpg-page--disabled {
	opacity: 0.4;
	cursor: default;
}
.tpg-page--gap {
	border: none;
	background: none;
	cursor: default;
}

/* Panels visibility */
.tpg-panel {
	display: none;
}
.tpg-panel.is-active {
	display: block;
}

/* Responsive */
@media (max-width: 1024px) {
	.tpg-grid { grid-template-columns: repeat(2, 1fr); }
	.tpg-promo { width: 200px; max-width: 200px; }
}
@media (max-width: 767px) {
	/* Stacked: banner above the content (natural height), then grid, then pager. */
	.tpg-body,
	.tpg-promo-end .tpg-body {
		grid-template-columns: 1fr;
		grid-template-areas:
			"promo"
			"main"
			"pager";
	}
	.tpg-promo { width: 100%; max-width: 100%; align-self: auto; }
	.tpg-promo img { height: auto; }
	.tpg-grid { grid-template-columns: 1fr; }
	/* Wrap chips onto multiple lines so long names are never cropped. */
	.tpg-filters {
		overflow-x: visible;
		flex-wrap: wrap;
		gap: 8px;
		justify-content: center;
	}
	.tpg-filter {
		font-size: 0.82em;
		padding: 6px 12px;
		max-width: 100%;
	}
	.tpg-tabs { justify-content: center; }
	/* Keep the tag within the card on small screens. */
	.tpg-card__tag { max-width: calc(100% - 16px); font-size: 0.72em; }
}
