/**
 * Site ad slots and creatives: in-article, the sticky footer bar and the top leaderboard.
 * SSOT: markup ld_ads_render_creative_html() (inc/directads/frontend/delivery.php); bar colors from the ads settings
 * Loaded only while a campaign is serving, or on an owner preview.
 */
.ld-unit { box-sizing: border-box; }
.ld-unit img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.ld-unit a { display: block; }

/* One screen's creative, or a placeholder for a zone only one screen has an ad for: out of the other's layout. Live
 * delivery paints the viewport's device only, a preview renders both. data-ld-device: LD_AD_FORMATS, ld_ads_zone_html(). */
@media (min-width: 768px) { .ld-unit[data-ld-device="mobile"], .ld-unit-zone[data-ld-device="mobile"] { display: none; } }
@media (max-width: 767px) { .ld-unit[data-ld-device="desktop"], .ld-unit-zone[data-ld-device="desktop"] { display: none; } }

.ld-unit--in-article { margin: 32px auto; max-width: 100%; text-align: center; }
.ld-unit__label {
	margin-bottom: 8px;
	font-size: 10px;
	letter-spacing: 0.6px;
	text-transform: uppercase;
	color: var(--text-muted, #999);
}
@media (max-width: 767px) {
	.ld-unit--in-article { margin: 40px auto; }
}

/* Reserve the largest creative's height before ld-units.js paints it, so the text below never jumps. */
.ld-unit-zone[data-ld-zone="in-article"] {
	/* 394px (16:9 at the 700px article width) + label + 64px margins,
	 * plus the 17px flex-gap compensation used by the empty slot below. */
	min-height: 501px;
}
@media (max-width: 767px) {
	.ld-unit-zone[data-ld-zone="in-article"] {
		/* 250px creative + label + 80px mobile margins + that compensation. */
		min-height: 372px;
	}
}

/* .article-body is a flex column with gap: 17px (site.css); an empty slot would still add a second gap. */
.article-body > .ld-unit-zone { margin-top: -17px; }

/* Background + blur come from the admin settings, printed inline by ld_ads_render_settings_css(). */
.ld-unit--sticky {
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 9998;
	display: flex;
}
.ld-unit--sticky > a { flex: 1; display: flex; align-items: center; justify-content: center; }
.ld-unit--sticky img { max-width: 320px; }
.ld-unit--sticky-leaderboard img { max-width: 728px; }

.ld-unit--sticky-close {
	position: absolute;
	top: -10px;
	right: max(4px, calc(50% - 160px));
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: rgba(255, 255, 255, 0.18);
	color: #fff;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
[data-theme="light"] .ld-unit--sticky-close { background: rgba(0, 0, 0, 0.7); }
.ld-unit--sticky-leaderboard .ld-unit--sticky-close { right: max(4px, calc(50% - 364px)); }

@media (max-width: 767px) {
	/* The ad sits flush on the bottom edge. site.js measures the fixed bottomdock (the support button, when it runs) into
	   --dock-h; the ad rides above it and drops with it while the reader scrolls down. */
	.ld-unit--sticky { bottom: var(--dock-h, 0px); transition: transform .25s ease; }
	/* A transform, so the drop is not a layout shift. */
	body.is-scrolling-down .ld-unit--sticky { transform: translateY(var(--dock-h, 0px)); }
	/* site.js sets body.kb-open while a text field has focus; the keyboard reflow makes the offset unreliable. */
	body.kb-open .ld-unit--sticky { display: none; }
	/* Just the creative, no strip behind it (the inline settings style prints after this sheet at equal specificity). */
	.ld-unit--sticky-footer {
		background: transparent !important;
		-webkit-backdrop-filter: none !important;
		backdrop-filter: none !important;
	}
}

.ld-unit--top {
	padding: 16px 0;
	border-bottom: 1px solid var(--hairline);
	background: var(--bar-bg);
	text-align: center;
}
.ld-unit--top img { max-width: 728px; }

@media (prefers-reduced-motion: reduce) { .ld-unit--sticky { transition: none; } }

/* The owner's stand-ins (ld_ads_ghost_html()): the creative's own wrapper with a grey box the creative's size inside.
 * The zone wrapper drops out of layout so each unit sits exactly where a reader's would. */
.ld-unit-zone.is-ghost { display: contents; }
.ld-unit-ghost {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto;
	border: 1px dashed var(--text-muted, #999);
	border-radius: 4px;
	background: repeating-linear-gradient(135deg, rgba(128, 128, 128, 0.16) 0 8px, rgba(128, 128, 128, 0.08) 8px 16px);
	color: var(--text-muted, #999);
	font: 600 11px/1.2 var(--meta-font, sans-serif);
	letter-spacing: 0.04em;
	text-align: center;
}
.ld-unit-ghost span { padding: 0 8px; }
/* A box has no natural width to shrink to, as an image does: its wrapper takes the column, the box its own size. */
.ld-unit--in-article.is-ghost, .ld-unit--top.is-ghost { width: 100%; }
.ld-unit--sticky.is-ghost { pointer-events: none; }
.ld-unit--sticky.is-ghost > .ld-unit-ghost { flex: none; background-color: var(--bar-bg); }
