/*
 * All Science Africa: adverts on stories.
 * One box whose adverts take turns. Beside the story on wide screens (it stays in view while
 * you read); inside the story, after the third paragraph, on smaller screens.
 * The advert's own colours (navy and gold) set it apart from the site's green.
 */

.asa-ad {
	--asa-ad-navy: #0B1F3A;
	--asa-ad-gold: #D4AF37;
	box-sizing: border-box;
	margin-block: 2rem;
}

.asa-ad__label {
	margin: 0 0 0.45rem;
	color: var(--wp--preset--color--muted, #5B6472);
	font-family: var(--wp--preset--font-family--archivo, Arial, sans-serif);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1.3;
	text-transform: uppercase;
}

.asa-ad__slides {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	border-radius: 14px;
	background: var(--asa-ad-navy);
	overflow: hidden;
}

.asa-ad__slide {
	grid-area: 1 / 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 0.6rem;
	padding: 1.25rem 1.25rem 1.4rem;
	color: #ffffff;
	text-decoration: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}

.asa-ad__slide.is-active {
	opacity: 1;
	visibility: visible;
	transition: opacity 0.6s ease, visibility 0s;
}

.asa-ad__slide:hover,
.asa-ad__slide:focus {
	color: #ffffff;
}

.asa-ad__slide:focus-visible {
	outline: 3px solid var(--asa-ad-gold);
	outline-offset: -3px;
	border-radius: 14px;
}

.asa-ad__brand {
	display: flex;
	align-items: center;
	gap: 0.55rem;
	color: #C9D3E3;
	font-family: var(--wp--preset--font-family--archivo, Arial, sans-serif);
	font-size: 0.8125rem;
	font-weight: 700;
	letter-spacing: 0.03em;
}

.asa-ad__brand img {
	flex: none;
	display: block;
	width: 30px;
	height: 30px;
}

.asa-ad__title {
	color: #ffffff;
	font-family: var(--wp--preset--font-family--newsreader, Georgia, serif);
	font-size: 1.45rem;
	font-weight: 600;
	line-height: 1.15;
}

.asa-ad__text {
	color: #DCE3EE;
	font-family: var(--wp--preset--font-family--archivo, Arial, sans-serif);
	font-size: 0.9375rem;
	line-height: 1.45;
}

.asa-ad__button {
	align-self: flex-start;
	margin-top: 0.3rem;
	padding: 0.6rem 1.05rem;
	border-radius: 999px;
	background: var(--asa-ad-gold);
	color: var(--asa-ad-navy);
	font-family: var(--wp--preset--font-family--archivo, Arial, sans-serif);
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.2;
}

.asa-ad__slide:hover .asa-ad__button {
	background: #E3C45F;
}

/* Dots and the pause button (shown once the script is running). */
.asa-ad__controls {
	display: none;
	align-items: center;
	gap: 0.15rem;
	margin-top: 0.35rem;
}

.asa-ad.is-ready .asa-ad__controls {
	display: flex;
}

.asa-ad__dot,
.asa-ad__toggle {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--wp--preset--color--muted, #5B6472);
	cursor: pointer;
}

.asa-ad__dot::before {
	content: "";
	width: 0.6rem;
	height: 0.6rem;
	border-radius: 50%;
	background: #C3C9D2;
}

.asa-ad__dot[aria-current="true"]::before {
	background: var(--asa-ad-navy);
}

.asa-ad__toggle {
	margin-left: auto;
}

.asa-ad__toggle:hover {
	color: var(--asa-ad-navy);
}

.asa-ad__toggle svg {
	display: block;
	width: 1rem;
	height: 1rem;
}

.asa-ad__toggle .asa-ad__play,
.asa-ad.is-paused .asa-ad__toggle .asa-ad__pause {
	display: none;
}

.asa-ad.is-paused .asa-ad__toggle .asa-ad__play {
	display: block;
}

.asa-ad__dot:focus-visible,
.asa-ad__toggle:focus-visible {
	outline: 3px solid var(--wp--preset--color--teal, #0B6E63);
	outline-offset: 1px;
}

/* Inside the story: the button sits beside the words on wider screens. */
@media (min-width: 600px) {
	.asa-ad--inline .asa-ad__slide {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas:
			"brand brand"
			"title button"
			"text button";
		column-gap: 1.75rem;
		row-gap: 0.45rem;
		align-content: center;
		align-items: center;
		padding: 1.35rem 1.5rem 1.5rem;
	}

	.asa-ad--inline .asa-ad__brand {
		grid-area: brand;
	}

	.asa-ad--inline .asa-ad__title {
		grid-area: title;
	}

	.asa-ad--inline .asa-ad__text {
		grid-area: text;
		align-self: start;
	}

	.asa-ad--inline .asa-ad__button {
		grid-area: button;
		align-self: center;
		margin-top: 0;
		white-space: nowrap;
	}
}

/* Beside the story: only on screens wide enough to leave the text column untouched. */
.asa-ad--aside {
	display: none;
}

@media (min-width: 1320px) {
	.asa-article .asa-article__main {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(0, var(--wp--style--global--content-size, 720px)) minmax(0, 1fr);
		align-items: start;
		max-width: none;
		margin-block-start: 0;
	}

	.asa-article__main > .asa-article__body {
		grid-column: 2;
		grid-row: 1;
		width: 100%;
		max-width: none;
	}

	.asa-ad--aside {
		display: block;
		grid-column: 3;
		grid-row: 1;
		position: sticky;
		top: 2rem;
		width: calc(100% - 2.5rem);
		max-width: 17rem;
		margin: 2rem 0 0 2.5rem;
	}

	.asa-ad--inline {
		display: none;
	}
}

/* Below the wide layout, the wrapper sits exactly where the story text always did. */
.asa-article .asa-article__main {
	max-width: none;
	margin-block-start: 0;
}

@media (prefers-reduced-motion: reduce) {
	.asa-ad__slide,
	.asa-ad__slide.is-active {
		transition: none;
	}
}

/* Keep clear of the WordPress toolbar for signed-in editors. */
.admin-bar .asa-ad--aside {
	top: calc(2rem + 32px);
}
