/*
 * Labeled ad groups (calendar instream, single event, etc.).
 * Visibility is driven by JS (pm-ad-instream--has-fill) so theme `p { display }`
 * rules cannot force the “Advertisement” line to show when no slot has .pm-ad-filled.
 */
.pm-ad-query-loop-instream {
	margin: 0;
	text-align: center;
}

.pm-ad-query-loop-instream.pm-ad-instream--has-fill {
	margin: var(--wp--preset--spacing--lg, 1.5rem) 0;
}

.pm-ad-slot {
	display: block;
	width: 100%;
	/*
	 * Flow: reserve min-height for slots we actually request (per data-slot-key, smallest
	 * size in the GPT mapping). GPT setConfig({ collapseDiv: 'ON_NO_FILL' }) collapses
	 * unfilled slots; slotRenderEnded clears our reservation when isEmpty so CSS min-height
	 * does not fight the collapse.
	 */
	min-height: 0;
	text-align: center;
	/* Contain layout so ad reflows don't ripple out to the rest of the page. */
	contain: layout;
}

/* --- Expected creative height (smallest size in each unit’s mapping) --- */

/* Leaderboard / flex leaderboard: 728×90 floor */
.pm-ad-slot[data-slot-key="leaderboard_top"],
.pm-ad-slot[data-slot-key="leaderboard_instream_flex"],
.pm-ad-slot[data-slot-key="leaderboard_instream_e_flex"],
.pm-ad-slot[data-slot-key="leaderboard_instream_f_flex"] {
	min-height: 90px;
}

/* Large mobile top: 300×50 floor */
.pm-ad-slot[data-slot-key="large_mobile_banner_top"],
.pm-ad-slot[data-slot-key="large_mobile_banner_instream"],
.pm-ad-slot[data-slot-key="large_mobile_banner_instream_flex"] {
	min-height: 50px;
}

/* Med rec mobile + right rail: 300×250 */
.pm-ad-slot[data-slot-key="med_rec_sidebar"],
.pm-ad-slot[data-slot-key="med_rec_right_rail"],
.pm-ad-slot[data-slot-key="med_rec_mobile_a_instream"],
.pm-ad-slot[data-slot-key="med_rec_mobile_b_instream"],
.pm-ad-slot[data-slot-key="med_rec_mobile_c_instream"],
.pm-ad-slot[data-slot-key="med_rec_native_flex_instream"] {
	min-height: 250px;
}

/* Skyscraper right rail + instream: 300×600 */
.pm-ad-slot[data-slot-key="skyscraper_right_rail"],
.pm-ad-slot[data-slot-key="skyscraper_instream"] {
	min-height: 600px;
}

/* Sticky footer mobile: 300×50 floor */
.pm-ad-slot[data-slot-key="sticky_footer_mobile"] {
	min-height: 50px;
}

/* Native calendar: 1×1 placeholder — no vertical reserve */
.pm-ad-slot[data-slot-key="native_calendar"] {
	min-height: 0;
}

/*
 * Wrong-device slots stay out of layout (not requested). Mirrors gpt-init viewport split
 * at 1024px; JS still skips defineSlot for these.
 */
@media (max-width: 1024px) {
	/* Desktop-only slots — hidden on mobile. */
	.pm-ad-slot[data-slot-key^="leaderboard_"],
	.pm-ad-slot[data-slot-key="skyscraper_right_rail"],
	.pm-ad-slot[data-slot-key="med_rec_right_rail"],
	.pm-ad-slot[data-slot-key="med_rec_sidebar"] {
		display: none !important;
		min-height: 0 !important;
		height: 0 !important;
		margin: 0 !important;
		padding: 0 !important;
		overflow: hidden;
		pointer-events: none;
	}
}

@media (min-width: 1025px) {
	/* Mobile-only slots — hidden on desktop. */
	.pm-ad-slot[data-slot-key^="med_rec_mobile_"],
	.pm-ad-slot[data-slot-key^="large_mobile_banner_"],
	.pm-ad-slot[data-slot-key="skyscraper_instream"],
	.pm-ad-slot[data-slot-key="sticky_footer_mobile"] {
		display: none !important;
		min-height: 0 !important;
		height: 0 !important;
		margin: 0 !important;
		padding: 0 !important;
		overflow: hidden;
		pointer-events: none;
	}
}

/* Requested slot returned no creative — drop reserve so ON_NO_FILL collapse holds. */
.pm-ad-slot.pm-ad-empty {
	min-height: 0 !important;
	display: none;
	height: 0;
	margin: 0;
	padding: 0;
}

/* Once a slot has been filled, lock its min-height so refresh doesn't cause CLS. */
.pm-ad-slot.pm-ad-filled {
	min-height: var(--pm-ad-filled-height, 0px);
}

/* Native / sponsored calendar listing — collapses if not sold. */
.pm-native-calendar-ad:empty {
	display: none;
}

/*
 * Sticky footer: removed per QA (4.2.26). Called for removal on all page types.
 * Will require a dedicated GAM ad unit if re-introduced — reusing Leaderboard_A_Top
 * or LargeMobileBanner_A_Top was rejected. Pending unit name from ad ops.
 */
