/**
 * OTA Ad Block widget styles.
 *
 * The "Ad Section" band, node 193:8289 inside the home frame 193:5758: an
 * eyebrow and a ghost button on one row, then the running advertisements
 * beneath.
 *
 * Every colour is a colour theme role, mapped once in the token block below and
 * referenced by name after that, which is what lets the band follow whatever
 * theme is in force above it: its own, else the container's, else the page's,
 * else the site's. The one exception is the band's own background, which the
 * widget offers as a colour control and which overrides the surface role for the
 * band alone: see `--oad-section-bg`.
 *
 * The roles come from the frame's own bound variables:
 *
 *   band surface     brand/white        --ota-background
 *   eyebrow          brand/navy         --ota-text
 *   slot outline     brand/navy         --ota-text
 *   button           .ota-btn--ghost, which reads cta-* itself
 *   slot radius      radius/md, 14      --oad-radius
 *
 * THE EYEBROW IS NOT OCHRE HERE, AND THAT IS THE FRAME'S CHOICE
 *
 * Every other eyebrow in this plugin takes `ochre-button`: the News Block's, the
 * Partner Board's, the Events Block's. This frame binds its eyebrow to navy, the
 * same value as body text, so it takes `--ota-text` instead. That is not an
 * oversight to normalise. The band already holds two pieces of paid artwork
 * shouting for attention, and an ochre label above them would be a third voice
 * competing with the ads the advertiser paid for. The label's job is to say
 * quietly that what follows is not OTA's own content.
 *
 * THE THEME'S RADIUS CAP IS FOUGHT, NOT BEATEN
 *
 * `wordpress-theme-agend`'s skin-2020 bundle caps every content image with
 * `main#agendtheme-content .agendtheme-content-inner:not(...) img { border-radius:
 * var(--at-border-radius) }`. That is an id strength selector, so no radius this
 * stylesheet sets on the image can win it, and the widget's Corner Radius control
 * would silently paint the theme's 4px. The answer is to set the theme's OWN
 * variable inside this block's scope, so the theme's rule resolves to the design's
 * 14 and paints it for us. Nothing in the theme is touched. The same trick is
 * what the stock Image widgets on the home page used before this block replaced
 * them.
 */

.ota-ads {
	/* --- Roles ----------------------------------------------------------- */

	--oad-surface: var(--ota-background, #ffffff);
	--oad-text: var(--ota-text, #003038);

	/*
	 * The 1px outline the frame draws around each slot, at full text strength.
	 * It is doing real work rather than decorating: the MePACS artwork opens on
	 * a pale blue frame and the Zanda one on white, so without it a light ad
	 * has no edge against a light band and reads as part of the page.
	 */
	--oad-border: var(--ota-text, #003038);

	/*
	 * The hover and focus ring, 2px, the same role the News Block's card ring
	 * takes. The frame draws no hover state for an ad, but the whole slot is a
	 * link and a link that gives no sign of being one is the problem this
	 * solves.
	 */
	--oad-ring: var(--ota-text-muted, #005361);

	/* --- The frame's own measurements ------------------------------------- */

	--oad-max: 1280px;
	--oad-pad: 2rem;
	/* 88px above frame 706 and 88px below it, so the band is 443 tall. */
	--oad-pad-block: 88px;
	/* 652 minus 628 in frame 704. */
	--oad-gap: 24px;
	/* 58 minus 48 in frame 706: the header row nearly touches the ads. */
	--oad-head-gap: 10px;
	/* `radius/md`. */
	--oad-radius: 14px;

	/*
	 * The theme's variable, set here so the theme's own id strength rule paints
	 * the design's radius on the artwork. See the note at the top. The widget's
	 * Corner Radius control writes both of these again, so this is the value a
	 * widget saved before that control existed falls back to.
	 */
	--at-border-radius: var(--oad-radius);

	/* Two across, unless the widget says otherwise. */
	--oad-cols: 2;

	box-sizing: border-box;
	padding-block: var(--oad-pad-block);
	background: var(--oad-section-bg, var(--oad-surface));
	color: var(--oad-text);
}

.ota-ads__inner {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: var(--oad-head-gap);
	width: 100%;
	/*
	 * The padding is added to the maximum rather than taken out of it, so the
	 * content is exactly the design's 1280px at desktop and still keeps a gutter
	 * once the viewport is narrower. Same as the Partner Board's `__inner`.
	 */
	max-width: calc(var(--oad-max) + 2 * var(--oad-pad));
	margin-inline: auto;
	padding-inline: var(--oad-pad);
}

/* --- The header row ------------------------------------------------------- */

.ota-ads__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	/* Frame 705 is 48 tall, which is the button's height. */
	min-block-size: 48px;
}

.ota-ads__eyebrow {
	margin: 0;
	color: var(--oad-text);
	font-size: var(--e-global-typography-eyebrow-font-size, 1.0625rem);
	font-weight: var(--e-global-typography-eyebrow-font-weight, 700);
	line-height: var(--e-global-typography-eyebrow-line-height, 1.46em);
	letter-spacing: var(--e-global-typography-eyebrow-letter-spacing, 1px);
}

.ota-ads__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	/*
	 * The row's `space-between` only holds the button at the right edge while
	 * the eyebrow is there to push against. With the Eyebrow field cleared the
	 * button is the row's only child and `space-between` parks it on the LEFT,
	 * which is not where the frame puts it. An auto start margin keeps it right
	 * whichever the case; the stacked layout below turns it off again.
	 */
	margin-inline-start: auto;
}

/* --- The ads -------------------------------------------------------------- */

.ota-ads__list {
	display: grid;
	grid-template-columns: repeat(var(--oad-cols), minmax(0, 1fr));
	gap: var(--oad-gap);
	/*
	 * Each cell keeps its own height. Two ads at the design's 3:1 line up
	 * because they are the same shape, and an advertiser who supplies something
	 * squarer gets a taller slot rather than a cropped ad. See `__image`.
	 */
	align-items: start;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ota-ads--cols-1 {
	--oad-cols: 1;
}

.ota-ads--cols-2 {
	--oad-cols: 2;
}

.ota-ads--cols-3 {
	--oad-cols: 3;
}

.ota-ads__slot {
	margin: 0;
	padding: 0;
	list-style: none;
}

/*
 * THE SLOTS SITTING LEVEL DEPENDS ON THIS RULE, and it has to be anchored on
 * the theme's id to win.
 *
 * skin-2020 spaces prose lists with
 *
 *   main#agendtheme-content .agendtheme-content-inner:not(.agendtheme-content-inner__tribe)
 *   ul:not(.chosen-choices, .chosen-results) li + li { margin-top: 0.5rem }
 *
 * That is (1, 3, 4), and it applies here because the ad list is a real `ul` in
 * the content wrapper: the semantic list is deliberate, so this rule cannot be
 * escaped by using divs. `.ota-ads__slot { margin-top: 0 }` is (0, 1, 0) and
 * loses, which put 8px on every slot after the first and dropped the second ad
 * below the first. It reads as a wonky grid rather than as inherited prose
 * spacing, which is why it survived a first look.
 *
 * (1, 4, 0) beats (1, 3, 4), because classes are weighed before elements. The
 * chain below mirrors the theme's own so the two can be compared by eye.
 * Anchoring on the id rather than reaching for `!important` leaves this
 * overridable, which is the same trade ota-buttons.css makes.
 */
#agendtheme-content .agendtheme-content-inner .ota-ads .ota-ads__list .ota-ads__slot {
	margin-top: 0;
}

.ota-ads__link {
	position: relative;
	display: block;
	border-radius: var(--oad-radius);
	/*
	 * The artwork is square cornered and the radius belongs to the slot, so the
	 * corners have to be clipped here rather than set on the image alone: the
	 * `<picture>` between them would otherwise paint over them.
	 */
	overflow: hidden;
	text-decoration: none;
}

/*
 * The outline as a pseudo-element rather than a real border, for the News
 * Block's three reasons: a real border resizes the slot when it thickens on
 * hover and shifts the ad beside it; an `outline` with a negative offset draws
 * square corners in Safari before 16.4, against the 14px radius that is the
 * whole shape of the slot; and an inset `box-shadow` paints on the link's own
 * background layer, which puts it under the artwork and erases the top half.
 *
 * Always present, so only the width and colour change on hover and there is
 * something for the transition to run against.
 */
.ota-ads__link::after {
	content: "";
	position: absolute;
	inset: 0;
	border: 1px solid var(--oad-border);
	border-radius: inherit;
	pointer-events: none;
	transition: border-color 150ms ease, border-width 150ms ease;
}

.ota-ads--no-border .ota-ads__link::after {
	/*
	 * Transparent rather than absent. With the outline switched off the slot
	 * still needs its hover and focus ring, and there has to be a border there
	 * for the ring to thicken.
	 */
	border-color: transparent;
}

.ota-ads__link:hover::after,
.ota-ads__link:focus-visible::after {
	border-width: 2px;
	border-color: var(--oad-ring);
}

/*
 * A real focus ring as well as the border, and outside the slot rather than on
 * it. The pseudo-element ring sits against the artwork, which is a photograph
 * this site does not control, so it cannot be relied on to have any contrast at
 * all. This one is drawn on the band.
 */
.ota-ads__link:focus-visible {
	outline: 2px solid var(--oad-ring);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
	.ota-ads__link::after {
		transition: none;
	}
}

.ota-ads__picture {
	display: block;
}

.ota-ads__image {
	display: block;
	inline-size: 100%;
	/*
	 * The artwork sets its own height from its intrinsic ratio, and the `width`
	 * and `height` attributes on the tag are what reserve the box before it
	 * lands. No `aspect-ratio` and no `object-fit` here on purpose: a fixed
	 * ratio box would either letterbox or crop anything that is not the
	 * design's 3:1, and cropping a paid ad can cut off the button inside it.
	 */
	block-size: auto;
	/* See the note at the top: this is what the theme's own rule paints. */
	border-radius: var(--oad-radius);
}

/* --- The editor's note ---------------------------------------------------- */

/*
 * Only ever rendered in the Elementor canvas, so these are literal values
 * rather than theme roles: it is chrome for the person editing, not part of the
 * design, and it must stay legible whatever theme the band is set to. LITERAL
 * MEANS THE MEASUREMENTS TOO: the placeholder is echoed without the `.ota-ads`
 * wrapper, so the `--oad-*` tokens are not defined here and a `var()` without a
 * fallback computes to nothing (the width calc resolved invalid, and the note
 * drew full bleed with square corners).
 */
.ota-ads__placeholder {
	box-sizing: border-box;
	/* The band's 1280px plus its 2rem side gutters, restated. */
	max-width: calc(1280px + 2 * 2rem);
	margin-inline: auto;
	padding: 24px;
	border: 1px dashed #9aa5a8;
	border-radius: 14px;
	background: #f7f7f7;
	color: #3f4b4e;
	text-align: center;
}

.ota-ads__placeholder-title {
	margin: 0 0 8px;
	font-weight: 700;
}

.ota-ads__placeholder-body {
	margin: 0;
	font-size: 0.875rem;
}

/* --- Narrow --------------------------------------------------------------- */

/*
 * One column from here down, and this has to come after the `--cols-*` rules:
 * they are one class each and so is this, so the later rule is the one that
 * wins. A 3:1 banner carrying body copy stops being readable somewhere around
 * 430px, which is what two columns comes to at this width.
 */
/*
 * NO `--oad-pad-block` STEPS HERE, DELIBERATELY. The Section Padding control
 * prints its value per wrapper (an id-less but two-class selector) with no
 * media query, which outguns anything this file says at any width, so a
 * breakpoint value here is dead the moment the widget saves. The narrower
 * steps (64 tablet, 56 phone) live in the control's tablet_default and
 * mobile_default instead: one owner, and an editor's override wins everywhere,
 * which is what an override should do.
 */
@media (max-width: 900px) {
	.ota-ads {
		--oad-cols: 1;
	}
}

@media (max-width: 600px) {
	.ota-ads {
		--oad-pad: 1.25rem;
	}

	/*
	 * The label and the button stack, and only this far down. `space-between`
	 * holds them at opposite ends of the row for as long as the row is wide
	 * enough to read as two ends, which it is well below the point the grid
	 * drops to one column. Left as one row at phone widths they end up a few
	 * pixels apart, and "Advertisement" beside "Advertise with OTA" then reads
	 * as one garbled phrase rather than a label and a call to action.
	 */
	.ota-ads__head {
		flex-direction: column;
		align-items: flex-start;
		gap: 12px;
	}

	/*
	 * In the stacked column an auto start margin would drag the lone button to
	 * the right edge past `align-items`, so it comes off with the row.
	 */
	.ota-ads__actions {
		margin-inline-start: 0;
	}
}
