/**
 * Per-article mode for the TCM Recommendations block.
 *
 * This is a PORT of the edition widget's own stylesheet
 * (trend-content-matching packages/widget/src/styles.css) and it must stay a
 * faithful one: per-article mode changes WHICH articles the unit shows, never
 * how it looks. The class names mirror the widget's DOM exactly so the two
 * render identically — when that stylesheet changes, change this with it.
 *
 * The widget gets isolation for free: it injects its CSS inside
 * attachShadow(), so no publisher theme can reach in. These cards are
 * server-rendered into the light DOM instead (real crawlable anchors), so
 * everything the shadow boundary guaranteed has to be written out — every
 * rule is scoped through .tpd-tcm-pa, and the root carries an explicit reset
 * for the properties themes actually set on links, spans and images.
 */

/* ---- isolation: what the shadow boundary did for free ---- */

.tpd-tcm-pa .tcm-widget-root {
	font-family: var( --tcm-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif );
	box-sizing: border-box;
	line-height: 1.4;
	color: #1a1a1a;
	-webkit-font-smoothing: antialiased;
	margin: 0;
	padding: 0;
}

.tpd-tcm-pa .tcm-widget-root *,
.tpd-tcm-pa .tcm-widget-root *::before,
.tpd-tcm-pa .tcm-widget-root *::after {
	box-sizing: border-box;
}

.tpd-tcm-pa .tcm-widget-root :where( a, span, div, img, hr ) {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
	text-transform: none;
	letter-spacing: normal;
	font-family: inherit;
	max-width: none;
}

.tpd-tcm-pa .tcm-widget-root :where( a:hover, a:focus ) {
	box-shadow: none;
}

/* ---- header ---- */

.tpd-tcm-pa .tcm-widget-root .tcm-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 0;
	margin-bottom: 12px;
	border-bottom: 2px solid var( --tcm-accent, #333 );
}

.tpd-tcm-pa .tcm-widget-root .tcm-header-text {
	font-size: 18px;
	font-weight: 700;
	color: var( --tcm-header-text-color, #1a1a1a );
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.tpd-tcm-pa .tcm-widget-root .tcm-header-logo-full {
	height: 28px;
	width: auto;
	object-fit: contain;
}

.tpd-tcm-pa .tcm-widget-root .tcm-header-logo-icon {
	height: 28px;
	width: 28px;
	object-fit: contain;
}

/* ---- text branding (powered by) ---- */

.tpd-tcm-pa .tcm-widget-root .tcm-header-brand-text {
	text-decoration: none;
	transition: opacity 0.15s ease;
}

.tpd-tcm-pa .tcm-widget-root .tcm-header-brand-text:hover {
	opacity: 0.75;
}

.tpd-tcm-pa .tcm-widget-root .tcm-brand-powered {
	color: var( --tcm-brand-powered-color, #999 );
	font-weight: 400;
}

.tpd-tcm-pa .tcm-widget-root .tcm-brand-name {
	color: var( --tcm-brand-name-color, var( --tcm-accent, inherit ) );
	font-weight: 600;
}

.tpd-tcm-pa .tcm-widget-root .tcm-brand-grid {
	display: inline-flex;
	align-items: baseline;
	gap: 4px;
	font-size: 15px;
}

.tpd-tcm-pa .tcm-widget-root .tcm-brand-list {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: center;
	line-height: 1.15;
}

.tpd-tcm-pa .tcm-widget-root .tcm-brand-list .tcm-brand-powered {
	font-size: 10px;
}

.tpd-tcm-pa .tcm-widget-root .tcm-brand-list .tcm-brand-name {
	font-size: 14px;
}

/* ---- grid layout ---- */

.tpd-tcm-pa .tcm-widget-root .tcm-grid {
	display: grid;
	grid-template-columns: repeat( 3, 1fr );
	gap: 16px;
}

@media ( max-width: 640px ) {
	.tpd-tcm-pa .tcm-widget-root .tcm-grid {
		grid-template-columns: 1fr;
	}
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-grid {
	display: flex;
	flex-direction: column;
	text-decoration: none;
	color: #1a1a1a;
	border-radius: 6px;
	overflow: hidden;
	transition: box-shadow 0.15s ease;
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-grid:hover {
	box-shadow: 0 2px 8px rgba( 0, 0, 0, 0.12 );
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-img-wrap {
	position: relative;
	width: 100%;
	padding-bottom: 56.25%;
	overflow: hidden;
	background: #f0f0f0;
	border-radius: 6px;
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.25s ease;
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-grid:hover .tcm-tile-img {
	transform: scale( 1.05 );
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-grid:hover .tcm-tile-headline {
	color: var( --tcm-headline-hover-color, var( --tcm-accent, #333 ) );
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-headline {
	font-size: 17px;
	font-weight: 600;
	color: var( --tcm-headline-color, #1a1a1a );
	line-height: 1.3;
	padding: 8px 2px;
	text-decoration: underline;
	text-underline-offset: 2px;
	transition: color 0.15s ease;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ---- list layout ---- */

.tpd-tcm-pa .tcm-widget-root .tcm-list {
	display: flex;
	flex-direction: column;
}

.tpd-tcm-pa .tcm-widget-root .tcm-divider {
	border: none;
	border-top: 1px solid var( --tcm-divider-color, #e5e5e5 );
	margin: 0;
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-list {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 10px 0;
	text-decoration: none;
	color: #1a1a1a;
	transition: background-color 0.15s ease;
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-list:hover {
	background-color: #fafafa;
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-list-img-wrap {
	width: 120px;
	height: 68px;
	border-radius: 4px;
	flex-shrink: 0;
	overflow: hidden;
	background: #f0f0f0;
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-list-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.25s ease;
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-list:hover .tcm-tile-list-img {
	transform: scale( 1.05 );
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-list:hover .tcm-tile-list-headline {
	color: var( --tcm-headline-hover-color, var( --tcm-accent, #333 ) );
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-list-headline {
	font-size: 17px;
	font-weight: 600;
	color: var( --tcm-headline-color, #1a1a1a );
	line-height: 1.3;
	text-decoration: underline;
	text-underline-offset: 2px;
	transition: color 0.15s ease;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.tpd-tcm-pa .tcm-widget-root .tcm-tile-list-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

/* ---- source label + external icon ---- */

.tpd-tcm-pa .tcm-widget-root .tcm-tile-source {
	display: block;
	font-size: 11px;
	color: var( --tcm-source-color, #999 );
	font-weight: 400;
	line-height: 1.3;
	padding: 1px 2px 0;
}

.tpd-tcm-pa .tcm-widget-root .tcm-external-icon {
	display: inline-block;
	vertical-align: middle;
	opacity: 0.45;
	margin-left: 2px;
	flex-shrink: 0;
}
