/* A/B images (see assets/js/ab-toggle.js). Without the script, the figure is
   left as it is and both images show, one after the other. */

figure.ab-toggle > img, figure.ab-toggle > a
{
	display: block;
}

figure.ab-toggle:not(.ab-ready) > img + img, figure.ab-toggle:not(.ab-ready) > a + a
{
	margin-top: 12px;
}

/* With the script: the images share one spot, so the page doesn't move when the
   other is shown (the taller one, if they differ, sets the height). The hidden
   one stays loaded, so switching is instant. The switch goes under the images,
   with the caption beside it. */

figure.ab-toggle.ab-ready
{
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	column-gap: 12px;
}

figure.ab-ready > img, figure.ab-ready > a
{
	grid-row: 1;
	grid-column: 1 / -1;
	align-self: start;
}

figure.ab-ready > .ab-hidden
{
	visibility: hidden;
}

figure.ab-ready > br
{
	display: none;
}

figure.ab-ready > figcaption
{
	grid-row: 2;
	grid-column: 2;
	margin-top: 10px;
}

.ab-switch
{
	grid-row: 2;
	grid-column: 1;
	align-self: start;
	display: inline-flex;
	flex-wrap: wrap;
	gap: 2px;
	margin-top: 8px;
	padding: 2px;
	border: 1px solid light-dark(#c3c3c3, #4a4a4a);
	border-radius: 999px;
}

.ab-switch button
{
	margin: 0;
	padding: 3px 12px;
	border: none;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.87em;
	font-weight: 600;
	line-height: 1.6;
	cursor: pointer;
}

.ab-switch button:hover
{
	background: light-dark(rgba(0, 0, 0, 0.07), rgba(255, 255, 255, 0.12));
}

.ab-switch button[aria-pressed="true"]
{
	background: light-dark(#000, #e8e8e8);
	color: light-dark(#fff, #000);
	cursor: default;
}

.ab-switch button:focus-visible
{
	outline: 2px solid #4a90d9;
	outline-offset: 2px;
}

/* A phone column hasn't room for long labels beside the caption, so the caption
   goes under the switch. */

@media only screen and (max-width: 600px)
{
	figure.ab-ready > figcaption
	{
		grid-row: 3;
		grid-column: 1 / -1;
	}
}
