/**
 * Werterad frontend styles.
 *
 * Everything is scoped under .werterad and uses explicit properties rather
 * than inheritance, because the target sites run hello-elementor plus
 * ElementsKit, Essential Addons, JEG Kit and Tutor LMS — all of which inject
 * broad `*` and `button` rules.
 *
 * All colours come from CSS custom properties set inline on the wrapper.
 */

.werterad,
.werterad *,
.werterad *::before,
.werterad *::after {
	box-sizing: border-box;
}

.werterad {
	--wr-seg-a: #f5b5d2;
	--wr-seg-b: #fae8ee;
	--wr-seg-text: #473b63;
	--wr-stroke: #473b63;
	--wr-hub-bg: #ffffff;
	--wr-hub-text: #473b63;
	--wr-pointer: #473b63;
	--wr-button-bg: #473b63;
	--wr-button-text: #ffffff;
	--wr-toast-bg: #473b63;
	--wr-toast-text: #ffffff;
	--wr-size-max: 620px;
	--wr-stroke-width: 4;
	--wr-duration: 5200ms;
	--wr-font: inherit;

	display: block;
	width: 100%;
	margin-inline: auto;
	max-width: var(--wr-size-max);
	font-family: var(--wr-font);
	text-align: center;
}

/* Headings and intro ------------------------------------------------- */

.werterad__heading {
	margin: 0 0 0.4em;
	color: var(--wr-seg-text);
	font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem);
	line-height: 1.2;
}

.werterad__intro {
	margin: 0 auto 1.25em;
	max-width: 46ch;
	color: inherit;
	line-height: 1.55;
}

.werterad__intro > *:last-child {
	margin-bottom: 0;
}

/* Stage --------------------------------------------------------------- */

.werterad__stage {
	position: relative;
	width: 100%;
	max-width: var(--wr-size-max);
	margin-inline: auto;
	aspect-ratio: 1 / 1;
}

/* aspect-ratio has been baseline since 2021, but the padding hack costs
   four lines and removes any doubt on old in-app browsers. */
@supports not (aspect-ratio: 1 / 1) {
	.werterad__stage {
		height: 0;
		padding-top: 100%;
	}

	.werterad__svg {
		position: absolute;
		inset: 0;
	}
}

.werterad--clickable .werterad__stage {
	cursor: pointer;
}

/* Flickable wheel. pan-y keeps vertical page scrolling native on touch,
   while a sideways/circular drag rotates the wheel. */
.werterad--draggable .werterad__stage {
	cursor: grab;
	touch-action: pan-y;
	-webkit-user-select: none;
	user-select: none;
}

.werterad--draggable.is-dragging .werterad__stage {
	cursor: grabbing;
}

.werterad__svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

/* Rotor --------------------------------------------------------------- */

.werterad__rotor {
	transform-box: view-box;
	transform-origin: 500px 500px;
	transition: transform var(--wr-duration) cubic-bezier(0.12, 0.8, 0.18, 1);
	will-change: transform;
}

/* Set by JS during the short wind-up phase. */
.werterad__rotor.is-winding {
	transition: transform 350ms cubic-bezier(0.4, 0, 1, 1);
}

/* The wheel must follow the finger with no easing at all while dragged. */
.werterad.is-dragging .werterad__rotor {
	transition: none;
}

/* JS drives the transform attribute instead when transform-box is missing. */
.werterad--attr-rotate .werterad__rotor {
	transition: none;
	transform: none;
}

.werterad__label {
	font-family: var(--wr-font);
	font-weight: 600;
	letter-spacing: 0.01em;
	pointer-events: none;
	-webkit-user-select: none;
	user-select: none;
}

.werterad__hub-label {
	font-family: var(--wr-font);
	font-weight: 700;
}

.werterad__pointer {
	filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}

/* Controls ------------------------------------------------------------ */

.werterad__controls {
	margin: 1.25em 0 0;
}

.werterad .werterad__spin {
	display: inline-block;
	margin: 0;
	padding: 0.85em 2.2em;
	border: 0;
	border-radius: 999px;
	background-color: var(--wr-button-bg);
	background-image: none;
	color: var(--wr-button-text);
	font-family: var(--wr-font);
	font-size: 1.05rem;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.02em;
	text-transform: none;
	cursor: pointer;
	transition: transform 150ms ease, opacity 150ms ease;
}

.werterad .werterad__spin:hover {
	transform: translateY(-1px);
}

.werterad .werterad__spin:focus-visible {
	outline: 3px solid var(--wr-stroke);
	outline-offset: 3px;
}

.werterad .werterad__spin[disabled] {
	cursor: not-allowed;
	opacity: 0.65;
	transform: none;
}

/* Result -------------------------------------------------------------- */

.werterad__result {
	min-height: 1px;
	margin: 1.1em 0 0;
}

.werterad__result-text {
	margin: 0;
	color: var(--wr-seg-text);
	font-size: clamp(1.25rem, 1rem + 1.1vw, 1.9rem);
	font-weight: 700;
	line-height: 1.3;
	min-height: 1.3em;
}

.werterad__result-text:empty {
	min-height: 0;
}

.werterad__result-text.is-visible {
	animation: werterad-pop 320ms ease-out;
}

.werterad__result-desc {
	margin: 0.4em auto 0;
	max-width: 44ch;
	line-height: 1.55;
}

.werterad__result-desc:empty {
	display: none;
}

.werterad .werterad__cta {
	display: inline-block;
	margin-top: 1em;
	padding: 0.75em 1.9em;
	border-radius: 999px;
	background-color: var(--wr-toast-bg);
	color: var(--wr-toast-text);
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
}

.werterad .werterad__cta:hover,
.werterad .werterad__cta:focus {
	color: var(--wr-toast-text);
	text-decoration: underline;
}

.werterad .werterad__cta:focus-visible {
	outline: 3px solid var(--wr-stroke);
	outline-offset: 3px;
}

/* [hidden] must win against theme rules that set display on <a>. */
.werterad .werterad__cta[hidden] {
	display: none;
}

@keyframes werterad-pop {
	from {
		opacity: 0;
		transform: translateY(6px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

/* Screen-reader only value list ---------------------------------------- */

.werterad__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.werterad__rotor,
	.werterad__rotor.is-winding {
		transition: none;
	}

	.werterad .werterad__spin {
		transition: none;
	}

	.werterad .werterad__spin:hover {
		transform: none;
	}

	.werterad__result-text.is-visible {
		animation: none;
	}
}

/* Increased contrast --------------------------------------------------- */

@media (prefers-contrast: more) {
	.werterad {
		--wr-seg-text: #2b2340;
	}

	.werterad__seg {
		stroke-width: calc(var(--wr-stroke-width) + 2);
	}
}

/* Small screens -------------------------------------------------------- */

@media (max-width: 480px) {
	.werterad .werterad__spin {
		width: 100%;
		padding: 0.9em 1.2em;
	}

	.werterad .werterad__cta {
		width: 100%;
	}
}
