/**
 * Spin to Win popup (inc/spin-wheel.php, assets/js/spin-wheel.js).
 */

/*
 * Desktop: the popup sticks to the LEFT edge of the screen (vertically
 * centred) and the wheel comes out of that edge. --nelvin-spin-h = panel
 * height; the stage width follows it so the pointer always fits.
 */
.nelvin-spin {
	--nelvin-spin-h: min(78vh, 620px);
	box-sizing: border-box;
	width: 100%;
	max-width: min(880px, calc(100vw - 16px));
	max-height: calc(100vh - 32px);
	margin: auto auto auto 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--nelvin-text);
	font-family: inherit;
	overflow: visible;
}

.nelvin-spin::backdrop {
	background: rgba(24, 6, 48, 0.68);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
}

.nelvin-spin[open] {
	animation: nelvin-spin-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes nelvin-spin-in {

	from {
		opacity: 0;
		transform: translateX(-48px);
	}
}

.nelvin-spin__panel {
	position: relative;
	display: grid;
	grid-template-columns: calc(var(--nelvin-spin-h) * 0.52) 1fr;
	height: var(--nelvin-spin-h);
	border-radius: 0 24px 24px 0;
	background: var(--nelvin-base);
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
	overflow: hidden;
}

.nelvin-spin__close {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 4;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--nelvin-surface-2);
	color: var(--nelvin-text);
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.nelvin-spin__close:hover {
	background: var(--nelvin-primary);
	color: #fff;
}

.nelvin-spin__close:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/*
 * ---------- Wheel ----------
 * Desktop: big wheel centred on the stage's left edge, so only its right
 * half shows; the pointer sits at 3 o'clock (assets/js/spin-wheel.js lands
 * the prize there). Wheel height follows the panel height (vh).
 */
.nelvin-spin__stage {
	position: relative;
	overflow: hidden;
	background: radial-gradient(circle at 0 50%, #7b33d3 0%, var(--nelvin-secondary) 45%, #33095f 100%);
}

.nelvin-spin__wheel {
	position: absolute;
	top: 50%;
	left: 0;
	height: 94%;
	aspect-ratio: 1;
	color: #2b0752;
	transform: translate(-50%, -50%);
}

.nelvin-spin__disc {
	position: absolute;
	inset: 5%;
	width: 90%;
	height: 90%;
	border-radius: 50%;
	transform-origin: 50% 50%;
	will-change: transform;
}

.nelvin-spin__disc text {
	font-family: inherit;
	font-weight: 700;
	letter-spacing: 0.2px;
}

.nelvin-spin__disc path {
	stroke: rgba(255, 255, 255, 0.55);
	stroke-width: 1.5;
}

.nelvin-spin__frame {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.35));
	pointer-events: none;
}

.nelvin-spin__lights circle {
	fill: #ffd27a;
	animation: nelvin-spin-blink 1.2s steps(1) infinite;
}

.nelvin-spin__lights circle:nth-child(even) {
	animation-delay: 0.6s;
}

.is-spinning .nelvin-spin__lights circle {
	animation-duration: 0.3s;
}

.is-spinning .nelvin-spin__lights circle:nth-child(even) {
	animation-delay: 0.15s;
}

@keyframes nelvin-spin-blink {

	50% {
		fill: #fff6e0;
	}
}

/* Pointer: white-edged orange triangle at 3 o'clock, tip into the wheel. */
.nelvin-spin__pointer {
	position: absolute;
	top: 50%;
	left: calc(95% - 8px);
	width: 48px;
	height: 40px;
	transform: translateY(-50%);
	filter: drop-shadow(-3px 3px 4px rgba(0, 0, 0, 0.35));
}

.nelvin-spin__pointer::before,
.nelvin-spin__pointer::after {
	content: "";
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	clip-path: polygon(0 50%, 100% 0, 100% 100%);
}

.nelvin-spin__pointer::before {
	left: 0;
	width: 48px;
	height: 40px;
	background: #fff;
}

.nelvin-spin__pointer::after {
	left: 8px;
	width: 36px;
	height: 30px;
	background: var(--nelvin-primary);
}

.nelvin-spin__hub {
	position: absolute;
	top: 50%;
	left: 50%;
	display: grid;
	place-items: center;
	width: 19%;
	aspect-ratio: 1;
	border: 4px solid var(--nelvin-primary);
	border-radius: 50%;
	background: #fff;
	color: var(--nelvin-primary);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
	transform: translate(-50%, -50%);
}

/* ---------- Text side ---------- */
.nelvin-spin__body {
	display: flex;
	flex-direction: column;
	justify-content: safe center;
	padding: 48px 40px;
	overflow-y: auto;
}

.nelvin-spin__step[hidden] {
	display: none;
}

.nelvin-spin__eyebrow {
	margin: 0;
	color: #b84a00; /* Darker brand orange: 4.9:1 on the light panel (WCAG AA). */
	font-size: 12px;
	font-weight: 700;
	line-height: 16px;
	letter-spacing: 1.2px;
	text-transform: uppercase;
}

.nelvin-spin__title {
	margin: 8px 0 12px;
	color: var(--nelvin-text);
	font-size: 28px;
	font-weight: 700;
	line-height: 1.2;
}

.nelvin-spin__title:focus {
	outline: none;
}

.nelvin-spin__text {
	margin: 0;
	color: var(--nelvin-muted);
	font-size: 15px;
	line-height: 1.55;
}

.nelvin-spin__form {
	margin-top: 24px;
}

.nelvin-spin__label {
	display: block;
	margin: 0 0 6px;
	font-size: 13px;
	font-weight: 600;
	line-height: 18px;
}

.nelvin-spin__input {
	box-sizing: border-box;
	width: 100%;
	height: 48px;
	margin: 0 0 16px;
	padding: 0 14px;
	border: 1px solid var(--nelvin-light);
	border-radius: 8px;
	background: #fff;
	color: var(--nelvin-text);
	font: inherit;
	font-size: 15px;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nelvin-spin__input::placeholder {
	color: var(--nelvin-placeholder);
}

.nelvin-spin__input:focus {
	border-color: var(--nelvin-primary);
	outline: none;
	box-shadow: 0 0 0 3px rgba(254, 107, 0, 0.18);
}

.nelvin-spin__input[aria-invalid="true"] {
	border-color: var(--nelvin-sale);
}

.nelvin-spin__phone {
	display: flex;
	margin-bottom: 16px;
}

.nelvin-spin__cc {
	display: grid;
	place-items: center;
	padding: 0 12px;
	border: 1px solid var(--nelvin-light);
	border-right: 0;
	border-radius: 8px 0 0 8px;
	background: var(--nelvin-surface);
	color: var(--nelvin-muted);
	font-size: 15px;
	font-weight: 600;
}

.nelvin-spin__phone .nelvin-spin__input {
	margin: 0;
	border-radius: 0 8px 8px 0;
}

.nelvin-spin__hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.nelvin-spin__submit {
	box-sizing: border-box;
	width: 100%;
	margin-top: 8px;
	padding-inline: 24px;
	background: #c45200; /* White text 4.6:1 (WCAG AA). */
	color: #fff;
	font-size: 16px;
	text-decoration: none;
	box-shadow: 0 10px 15px -3px rgba(196, 82, 0, 0.3);
}

.nelvin-spin__submit:hover {
	background: #a84500;
	color: #fff;
}

.nelvin-spin__submit:disabled {
	opacity: 0.75;
	cursor: wait;
	transform: none;
}

.nelvin-spin__msg {
	min-height: 18px;
	margin: 10px 0 0;
	color: var(--nelvin-sale);
	font-size: 13px;
	line-height: 18px;
}

.nelvin-spin__msg:empty {
	min-height: 0;
	margin: 0;
}

.nelvin-spin__fine {
	margin: 12px 0 0;
	color: #7a5f53; /* 5.6:1 on the light panel (subtle token is 4.3:1). */
	font-size: 12px;
	line-height: 1.5;
}

/* ---------- Result ---------- */
.nelvin-spin__code {
	display: flex;
	gap: 12px;
	align-items: center;
	justify-content: space-between;
	margin: 8px 0 8px;
	padding: 12px 12px 12px 18px;
	border: 2px dashed var(--nelvin-primary);
	border-radius: 12px;
	background: #fff3ea;
}

.nelvin-spin__code[hidden] {
	display: none;
}

.nelvin-spin__code code {
	padding: 0;
	background: none;
	color: var(--nelvin-text);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 22px;
	font-weight: 700;
	letter-spacing: 2px;
	word-break: break-all;
}

.nelvin-spin__copy {
	flex: none;
	padding: 10px 16px;
	border: 0;
	border-radius: 8px;
	background: var(--nelvin-secondary);
	color: #fff;
	font: inherit;
	font-size: 13px;
	font-weight: 700;
	cursor: pointer;
}

.nelvin-spin__copy:hover {
	background: #4a0f8c;
}

.nelvin-spin__expiry {
	margin: 0 0 16px;
	color: var(--nelvin-subtle);
	font-size: 13px;
}

.nelvin-spin__expiry:empty {
	display: none;
}

.nelvin-spin__shop {
	margin-top: 24px;
}

/* ---------- Confetti ---------- */
.nelvin-spin__confetti {
	position: absolute;
	inset: 0;
	z-index: 3;
	overflow: hidden;
	pointer-events: none;
}

.nelvin-spin__confetti span {
	position: absolute;
	top: -16px;
	width: 8px;
	height: 14px;
	border-radius: 2px;
	animation: nelvin-confetti 2.4s cubic-bezier(0.3, 0.6, 0.5, 1) forwards;
}

.nelvin-spin__confetti span:nth-child(3n) {
	width: 10px;
	height: 10px;
	border-radius: 50%;
}

@keyframes nelvin-confetti {

	to {
		opacity: 0.2;
		transform: translate3d(var(--x, 0), 760px, 0) rotate(720deg);
	}
}

.nelvin-spin__close:focus-visible,
.nelvin-spin__copy:focus-visible,
.nelvin-spin__submit:focus-visible {
	outline: 2px solid var(--nelvin-secondary);
	outline-offset: 2px;
}

/* ---------- Phones ---------- */
@media (max-width: 767px) {

	.nelvin-spin {
		max-width: calc(100vw - 24px);
		max-height: calc(100vh - 24px);
		margin: auto;
	}

	/* Phones: whole wheel on top, pointer still at 3 o'clock. */
	.nelvin-spin__panel {
		grid-template-columns: 1fr;
		height: auto;
		max-height: calc(100vh - 24px);
		border-radius: 16px;
		overflow-x: hidden;
		overflow-y: auto;
	}

	.nelvin-spin__stage {
		display: flex;
		justify-content: center;
		padding: 24px 16px 20px;
		background: radial-gradient(circle at 50% 50%, #7b33d3 0%, var(--nelvin-secondary) 52%, #33095f 100%);
	}

	.nelvin-spin__wheel {
		position: relative;
		top: auto;
		width: min(250px, 64vw);
		height: auto;
		transform: none;
	}

	.nelvin-spin__pointer {
		width: 34px;
		height: 28px;
	}

	.nelvin-spin__pointer::before {
		width: 34px;
		height: 28px;
	}

	.nelvin-spin__pointer::after {
		left: 6px;
		width: 25px;
		height: 21px;
	}

	.nelvin-spin__hub svg {
		width: 20px;
		height: 20px;
	}

	.nelvin-spin__close {
		background: rgba(255, 255, 255, 0.9);
	}

	.nelvin-spin__body {
		padding: 24px 20px 28px;
		overflow: visible;
	}

	.nelvin-spin__title {
		font-size: 22px;
	}

	.nelvin-spin__form {
		margin-top: 18px;
	}

	.nelvin-spin__code code {
		font-size: 19px;
	}
}

@media (prefers-reduced-motion: reduce) {

	.nelvin-spin[open],
	.nelvin-spin__lights circle {
		animation: none;
	}
}
