/*
 * <gch-virtuescope>: the "spin the wheel" Virtuescope (replaces mod_virtuescope).
 *
 * The default look is the old /virtuescope page; the home page (Itemid 101) had its own,
 * lighter variant and hid the "Virtuescope Predictions" controls, so that is reproduced below.
 * Below 900px the wheel and the text stack, as on the old site.
 */
gch-virtuescope {
	--vs-text-size: 20px;
	--vs-text-leading: 1.625;
	--vs-text-weight: 300;
	--vs-text-color: #505656;
	--vs-name-size: 45px;
	--vs-name-margin: 10px 0 13px;
	--vs-button-bg: var(--gch-accent-light);
	--vs-button-bg-hover: var(--gch-accent-light-hover);
	--vs-button-text: #fff;

	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	/* Full width, but on wide screens the wheel and text line up with the 1140px content column. */
	padding-inline: max(0px, (100% - 1170px) / 2);
	grid-template-rows: auto 1fr;
	grid-template-areas:
		"wheel text"
		"wheel controls"
		"predictions predictions";
	column-gap: 20px;
	position: relative;
	padding-block-end: 20px;
	background: #fff;
	color: var(--vs-text-color);
	font-size: var(--vs-text-size);
	font-weight: var(--vs-text-weight);
	line-height: var(--vs-text-leading);
}

.gch-virtuescope__wheel {
	grid-area: wheel;

	svg {
		display: block;
		inline-size: 560px;
		max-inline-size: 100%;
		block-size: auto;
		aspect-ratio: 1;
	}

	text {
		fill: #fff;
		font: 17px Arial, Helvetica, sans-serif;
		dominant-baseline: central;
	}
}

.gch-virtuescope__rotor {
	transform-box: fill-box;
	transform-origin: center;
	will-change: transform;
}

.gch-virtuescope__pointer {
	fill: #f00;
}

.gch-virtuescope__text {
	grid-area: text;
	padding-inline: 10px;
	padding-block-start: 20px;
}

.gch-virtuescope__intro {
	margin-block-end: 13px;

	p {
		margin: 0;
	}
}

.gch-virtuescope__result {
	padding: 10px 20px;
	background: var(--vs-color, #eedde1);
	border: 2px solid #fff;
	border-radius: 10px;
	box-shadow: 0 0 10px #fff;
	color: #fff;
	transition: opacity .4s ease;

	@starting-style {
		opacity: 0;
	}
}

.gch-virtuescope__name {
	margin: var(--vs-name-margin);
	color: inherit;
	font-family: inherit;
	font-size: var(--vs-name-size);
	font-weight: 500;
	line-height: 1.25;
	text-transform: none;
}

.gch-virtuescope__message {
	margin: 0 0 4px;
}

.gch-virtuescope__controls {
	grid-area: controls;
	padding-inline: 10px;
}

.gch-virtuescope__spin,
.gch-virtuescope__reset {
	display: inline-block;
	padding: 15px 50px;
	background: var(--vs-button-bg);
	border: 0;
	border-radius: 3px;
	color: var(--vs-button-text);
	font: inherit;
	font-size: 18px;
	line-height: 26px;
	cursor: pointer;
	transition: background-color .3s;

	&:hover,
	&:focus-visible {
		background: var(--vs-button-bg-hover);
	}

	&[aria-disabled="true"] {
		cursor: default;
		opacity: .8;
	}
}

.gch-virtuescope__spin {
	margin-block: 20px;
}

.gch-virtuescope__reset {
	margin-inline-start: auto;
	font-size: 16px;
}

.gch-virtuescope__plans {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

.gch-virtuescope__select {
	inline-size: 206px;
	max-inline-size: 100%;
	block-size: 40px;
	padding: 6px 5px 6px 12px;
	background-color: #fff;
	border: 1px solid #ccc;
	color: inherit;
	font: inherit;
	font-size: 16px;
}

.gch-virtuescope__loading {
	inline-size: 26px;
	block-size: 26px;
	border: 3px solid #ddd;
	border-block-start-color: #888;
	border-radius: 50%;
	animation: gch-virtuescope-loading 1s linear infinite;
}

@keyframes gch-virtuescope-loading {
	to { rotate: 1turn; }
}

.gch-virtuescope__sr {
	position: absolute !important;
	inline-size: 1px;
	block-size: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Virtuescope Predictions */
.gch-virtuescope__predictions {
	grid-area: predictions;
}

.gch-virtuescope__predictions-title {
	margin: 26px 0 30px;
	color: #a3805b;
	font-family: inherit;
	font-size: 45px;
	font-weight: 500;
	line-height: 1.25;
}

.gch-virtuescope__plan {
	display: grid;
	grid-template-columns: repeat(var(--vs-plan-columns, 1), minmax(0, 1fr));
	column-gap: 20px;
	margin: 0;
	padding: 0 10px;
	list-style: none;

	@media (min-width: 768px) { --vs-plan-columns: 3; }

	@media (min-width: 992px) { --vs-plan-columns: 4; }
}

.gch-virtuescope__unit {
	position: relative;
	margin: 0;
	text-align: center;
}

.gch-virtuescope__unit-title {
	position: absolute;
	inset-block-start: 0;
	inset-inline: 0;
	z-index: 1;
	margin: 0;
	padding: 10px;
	background: #f1f1f1;
	border-radius: 8px 8px 0 0;
	color: #000;
	font-family: inherit;
	font-size: 23px;
	font-weight: 500;
	line-height: 1.25;
	opacity: .5;
}

.gch-virtuescope__card {
	min-block-size: 320px;
	margin-block-end: 30px;
	padding: 60px 20px 20px;
	border-radius: 8px;
	color: #fff;
	font-size: 20px;
	line-height: 1.625;

	&.is-filled {
		background: var(--vs-bg, none) center bottom / contain no-repeat var(--vs-color);
		transition: background-color .6s ease;

		@starting-style {
			background-color: transparent;
		}
	}
}

.gch-virtuescope__unit:nth-child(1) { --vs-bg: url(../images/virtuescope/virtue-bg1.png); }
.gch-virtuescope__unit:nth-child(2) { --vs-bg: url(../images/virtuescope/virtue-bg2.png); }
.gch-virtuescope__unit:nth-child(3) { --vs-bg: url(../images/virtuescope/virtue-bg3.png); }
.gch-virtuescope__unit:nth-child(4) { --vs-bg: url(../images/virtuescope/virtue-bg4.png); }
.gch-virtuescope__unit:nth-child(5) { --vs-bg: url(../images/virtuescope/virtue-bg5.png); }
.gch-virtuescope__unit:nth-child(6) { --vs-bg: url(../images/virtuescope/virtue-bg6.png); }
.gch-virtuescope__unit:nth-child(7) { --vs-bg: url(../images/virtuescope/virtue-bg7.png); }
.gch-virtuescope__unit:nth-child(8) { --vs-bg: url(../images/virtuescope/virtue-bg8.png); }
.gch-virtuescope__unit:nth-child(9) { --vs-bg: url(../images/virtuescope/virtue-bg9.png); }
.gch-virtuescope__unit:nth-child(10) { --vs-bg: url(../images/virtuescope/virtue-bg10.png); }
.gch-virtuescope__unit:nth-child(11) { --vs-bg: url(../images/virtuescope/virtue-bg11.png); }
.gch-virtuescope__unit:nth-child(12) { --vs-bg: url(../images/virtuescope/virtue-bg12.png); }

.gch-virtuescope__card-name {
	margin: 0 0 20px;
	font-size: 28px;
	font-weight: 500;
	line-height: 1.25;
}

.gch-virtuescope__card-text {
	margin: 0;
}

/* Home page variant */
:is(.itemid-101, .home-landing) gch-virtuescope {
	--vs-text-leading: 1.5;
	--vs-text-weight: inherit;
	--vs-text-color: inherit;
	--vs-name-size: 20px;
	--vs-name-margin: 10px 0 5px;
	--vs-button-bg: var(--background-color);
	--vs-button-bg-hover: var(--background-color-hover);
	--vs-button-text: var(--gch-cta-text);

	.gch-virtuescope__text {
		padding-block-start: 0;
	}

	.gch-virtuescope__intro {
		margin: 30px 0;
	}

	.gch-virtuescope__spin {
		display: block;
		inline-size: 100%;
		padding: 5px 10px;
		font-size: 20px;
		line-height: 30px;
	}

	.gch-virtuescope__plans,
	.gch-virtuescope__predictions {
		display: none;
	}
}

@media (min-width: 901px) and (max-width: 1023px) {
	.gch-virtuescope__wheel svg {
		inline-size: 520px;
	}
}

@media (max-width: 900px) {
	gch-virtuescope {
		--vs-text-size: 28.8px;

		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: none;
		grid-template-areas:
			"wheel"
			"text"
			"controls"
			"predictions";

		/* After the first spin the text moves above the wheel, and the wheel makes way for the result. */
		&[spun] {
			grid-template-areas:
				"text"
				"wheel"
				"controls"
				"predictions";
		}

		&[collapsed] .gch-virtuescope__wheel {
			display: none;
		}
	}

	.gch-virtuescope__wheel {
		transition: opacity .4s ease;

		@starting-style {
			opacity: 0;
		}

		svg {
			inline-size: 620px;
			margin-inline: auto;
		}
	}

	.gch-virtuescope__text {
		padding-block-start: 30px;
	}

	.gch-virtuescope__intro {
		margin-inline: 20px;
	}

	.gch-virtuescope__controls {
		text-align: center;
	}

	.gch-virtuescope__spin {
		margin: 0 auto 12px;
	}

	.gch-virtuescope__plans {
		justify-content: center;
	}

	.gch-virtuescope__reset {
		margin-inline-start: 0;
	}

	:is(.itemid-101, .home-landing) gch-virtuescope {
		--vs-text-size: 18px;

		.gch-virtuescope__intro {
			margin: 0 28px 30px;
		}

		.gch-virtuescope__spin {
			display: inline-block;
			inline-size: auto;
			margin: 0 auto 12px;
		}
	}
}

@media (max-width: 767px) {
	.gch-virtuescope__wheel svg {
		inline-size: 400px;
	}
}

@media (max-width: 419px) {
	.gch-virtuescope__wheel svg {
		inline-size: 100%;
	}
}
