/* Ad sockets.
 *
 * The only job of this file is layout stability. A socket reserves its box
 * height before any network call, so the ad arriving late never pushes the
 * article down — that is the whole Cumulative Layout Shift story, and it is
 * also what AdSense's own policy asks of the surrounding page.
 *
 * Tokens come from the storefront surfaces, with hard fallbacks so a socket
 * still renders on a static page that loads no theme CSS.
 */

.hbg-ad {
	display: block;
	margin: 32px 0;
}

/* The client marks a socket and hides it when it will not fill. .hbg-ad is
   display:block, which would beat the UA rule, so state wins explicitly. */
.hbg-ad[hidden],
.hbg-ad[data-ad-state="empty"] {
	display: none !important;
}

.hbg-ad__label {
	display: block;
	margin: 0 0 8px;
	font: 600 10px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--acct-muted, #6b6f76);
	text-align: center;
}

.hbg-ad__box {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: var(--ad-h, 100px);
	overflow: hidden;
	border-radius: 12px;
	background: var(--acct-card, #ffffff);
	border: 1px solid var(--acct-line, #e6e8ec);
}

/* Before consent or before the loader lands, the box is an empty frame. The
   label above identifies it; no fake branding, no "loading" spinner. */
.hbg-ad[data-ad-state="idle"] .hbg-ad__box {
	background-image: repeating-linear-gradient(
		135deg,
		transparent 0 14px,
		color-mix(in srgb, var(--acct-line, #e6e8ec) 55%, transparent) 14px 15px
	);
}

.hbg-ad[data-ad-state="live"] .hbg-ad__box {
	background: transparent;
	border-color: transparent;
	border-radius: 0;
}

.hbg-ad__fill {
	width: 100%;
	min-height: var(--ad-h, 100px);
}

/* An atoptions unit lives in its own frame so it cannot fight the page for
   the atOptions global. The wrapper is sized by the client after it scales. */
.hbg-ad__mount {
	display: block;
	line-height: 0;
}

.hbg-ad__frame {
	display: block;
	max-width: none;
	border: 0;
	background: transparent;
}

.hbg-ad__note {
	display: none;
}

body.dark .hbg-ad__box {
	background: var(--acct-card, #1a1c20);
	border-color: var(--acct-line, #292929);
}

/* Web fonts, if the surrounding page has them — the site loads its own face
   under --hb-font, so borrow it when present. */
.hbg-ad__label,
.hbg-ad__note {
	font-family: var(--hb-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

/* Placements whose box should sit inside a padded column instead of the full
   article measure. */
.acct-shell > .hbg-ad,
.hbg-tp-shell > .hbg-ad {
	margin-left: 0;
	margin-right: 0;
}

/* The top socket sits between the page title and the content: tighter above,
   wider below, so it reads as chrome rather than body. */
.hbg-ad--top {
	margin-top: 20px;
	margin-bottom: 36px;
}

/* In-article is a taller fluid box; on a phone the network will usually serve
   a 300x250, so the reserve drops instead of leaving a 280px hole. */
.hbg-ad--in_content {
	margin-top: 40px;
}

.hbg-ad--sidebar {
	display: none;
}

@media (min-width: 1100px) {
	.hbg-ad--sidebar {
		display: block;
	}
}

@media (max-width: 640px) {
	.hbg-ad {
		margin: 24px 0;
	}

	.hbg-ad__box {
		min-height: calc(var(--ad-h, 100px) * 0.6);
	}
}

@media (prefers-reduced-motion: reduce) {
	.hbg-ad,
	.hbg-ad__box {
		transition: none;
	}
}

/* The label falls back to the account muted grey, which is tuned for white
   cards. On the dark page it lands at 3.6:1 — under the 4.5 floor for 10px
   text. The storefront muted token is the right grey there. */
body.dark .hbg-ad__label {
	/* Literal, not a token: the flat catalogue pages run their own token
	   board and --hbg-muted there still resolves to the light grey. */
	color: #9aa0ab;
}
