@use "~admin-stylesheets/breakpoints";
@use "~admin-stylesheets/colors";

$screenshot-width: 14;
$screenshot-height: 8.5;

svg.nab-alternative-section__title-icon {
	transform: translateY(3px);
}

.nab-alternative-distribution-setting {
	margin-bottom: 1em;
}

.nab-alternative-list {
	display: block;
	flex-direction: row;
	flex-wrap: wrap;

	&__alternative {
		border: 1px solid colors.$nab-border-light;
		box-sizing: border-box;
		flex: 1;
		margin: 0.5em;
		max-width: none;
		padding: 0;
		position: relative;
		transition:
			border-color 200ms ease-in-out,
			box-shadow 200ms ease-in-out;
	}

	&__alternative--winner {
		border-color: colors.$nab-experiment-winner;
		box-shadow: 0 2px 10px 0 colors.$nab-box-shadow;
	}

	@include breakpoints.break-xlarge {
		display: flex;

		&__alternative {
			min-width: calc(50% - 1em);
			max-width: calc(50% - 1em);
		}
	}
}

.nab-alternative-metric {
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1em;
	font-size: 1em;

	&:last-of-type {
		margin-bottom: 0;
	}

	&__value {
		font-weight: 700;
		text-align: right;

		&--better {
			color: colors.$nab-experiment-winner;
			font-size: smaller;
			padding-left: 5px;
		}

		&--worse {
			color: colors.$nab-experiment-testing;
			font-size: smaller;
			padding-left: 5px;
		}
	}

	svg {
		height: 12px;
	}
}

.nab-alternative {

	&__name-link > svg,
	&__screenshot-link > svg {
		display: none;
	}

	&__winner-medal {
		clip-path: inset(0.15em);
		font-size: 50px;
		height: 1em;
		margin: -0.15em;
		position: absolute;
		right: 4px;
		top: 1px;
		width: 1em;

		rect {
			fill: transparent !important;
		}
	}

	&__title {
		border-bottom: 1px solid colors.$nab-border-light;
		font-size: 0.9rem;
		margin: 0;
		margin-bottom: 1em;
		overflow: hidden;
		padding: 0.5em;
		text-overflow: ellipsis;
		transition:
			background-color 200ms ease-in-out,
			color 200ms ease-in-out;
		white-space: nowrap;

		&--winner {
			background: colors.$nab-experiment-winner;
			border-color: transparent;
			color: colors.$nab-text-inverted;
			text-shadow: colors.$nab-text-shadow;
			padding-right: 2.5em;

			a {
				color: colors.$nab-text-inverted !important;
			}
		}
	}

	&__content {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		margin: 0;
		padding: 0 1em 1em;

		@include breakpoints.break-wide {
			flex-direction: row;
		}
	}

	&__actions {
		margin: 0;
		padding: 0.5em;
		border-top: 1px solid colors.$nab-border-light;
		display: flex;
		flex-direction: row;
		align-items: center;
		gap: 0.5em;
		justify-content: flex-end;

		.components-button,
		.button {
			box-sizing: border-box;
			margin-left: 0.5em;

			svg {
				display: none;
			}
		}
	}

	&__letter {
		border-radius: 50%;
		color: colors.$nab-text-inverted;
		display: inline-block;
		flex-grow: 0;
		font-size: 0.9rem;
		height: 1em;
		line-height: 1;
		margin: 0;
		margin-right: 0.5em;
		padding: 0.3em;
		text-align: center;
		transition:
			250ms background ease-in-out,
			250ms color ease-in-out;
		width: 1em;
	}

	$colors: (
		colors.$nab-background-alternative-a,
		colors.$nab-background-alternative-b,
		colors.$nab-background-alternative-c,
		colors.$nab-background-alternative-d,
		colors.$nab-background-alternative-e,
		colors.$nab-background-alternative-f
	);
	$i: 1;

	@each $color in $colors {
		.nab-alternative-list__alternative:nth-child(6n + #{$i}) &__letter {
			background: $color;
		}
		$i: $i + 1;
	}

	&__screenshot-link {
		display: inline-block;
		text-decoration: none;
	}

	&__screenshot-wrapper {
		margin-bottom: 1em;
		text-align: center;

		.nab-alternative__screenshot-link {
			text-decoration: none;
		}

		.components-external-link__icon {
			display: none;
		}

		@include breakpoints.break-wide {
			margin-bottom: 0;
		}
	}

	&__screenshot {
		border: 1px solid colors.$nab-border-light;
		grid-area: screenshot;
		height: ($screenshot-height) * 1em;
		margin: 0;
		margin-right: 0;
		width: $screenshot-width * 1em;
	}

	&__metrics {
		flex-grow: 1;
		padding-left: 1em;
	}
}

.nab-alternative__metrics--condensed .nab-alternative-metric {
	margin-bottom: 0.6em;
}
