/**
 * AnnGhar Spin & Win — front-end styles.
 * Every class is prefixed `annghar-spin` (or `annghar-mkt` for shared
 * marketing-popup concepts) - no generic `.modal`/`.popup`/`.button`/`.wheel`
 * class names, so nothing here can ever collide with the theme, WooCommerce,
 * or any other AnnGhar plugin's own CSS.
 */

:root {
	--annghar-spin-bg: #FBF7EE;
	--annghar-spin-primary: #1F4D2C;
	--annghar-spin-accent: #C79A45;
	--annghar-spin-sage: #7A9B76;
	--annghar-spin-text: #26332B;
	--annghar-spin-radius: 24px;
	--annghar-spin-anim-duration: 450ms;
}

#annghar-spin-popup,
#annghar-spin-popup *,
#annghar-spin-popup *::before,
#annghar-spin-popup *::after {
	box-sizing: border-box;
}

#annghar-spin-popup {
	position: fixed;
	inset: 0;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#annghar-spin-popup[hidden] {
	display: none;
}

/* Locks background scroll while open; restored by removing this class on close. */
body.annghar-spin-open {
	overflow: hidden;
}

.annghar-spin__overlay {
	position: absolute;
	inset: 0;
	background: rgba(20, 30, 20, 0.45);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	animation: annghar-spin-fade-in var(--annghar-spin-anim-duration) ease both;
}

/* --- Mobile (default/base): bottom sheet, slides up from the bottom --- */
.annghar-spin__panel {
	position: absolute;
	left: 50%;
	bottom: 0;
	width: calc(100vw - 20px);
	max-width: 100vw;
	max-height: 90vh;
	background-color: var(--annghar-spin-bg);
	/* The configured background image (if any) becomes a very subtle
	   backdrop wash on mobile rather than a loud photo - the ivory gradient
	   layer paints on top of it (first-listed background-image layer wins),
	   keeping text fully readable. Falls back to plain ivory when no
	   background image is configured. Desktop shows the image plainly
	   instead - see the min-width override below. */
	background-image:
		linear-gradient(rgba(251, 247, 238, 0.93), rgba(251, 247, 238, 0.93)),
		var(--annghar-spin-bg-image, none);
	background-size: cover;
	background-position: center;
	color: var(--annghar-spin-text);
	border-radius: var(--annghar-spin-radius) var(--annghar-spin-radius) 0 0;
	box-shadow:
		0 -8px 30px rgba(16, 25, 15, 0.18),
		0 -2px 8px rgba(16, 25, 15, 0.12),
		0 0 0 1px rgba(199, 154, 69, 0.15);
	overflow: hidden;
	transform: translate(-50%, 100%);
	animation: annghar-spin-slide-up-mobile var(--annghar-spin-anim-duration) cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes annghar-spin-slide-up-mobile {
	from {
		transform: translate(-50%, 100%);
	}
	to {
		transform: translate(-50%, 0);
	}
}

/* --- Desktop: centered, fixed size (admin-configurable) so the popup never
   resizes/jumps switching between the wheel and the result. --- */
@media (min-width: 768px) {
	.annghar-spin__panel {
		left: 50%;
		top: 50%;
		bottom: auto;
		width: var(--annghar-spin-width, 640px);
		height: var(--annghar-spin-height, 520px);
		max-width: 92vw;
		max-height: 90vh;
		border-radius: var(--annghar-spin-radius);
		/* Plain image on desktop - the mobile-only wash above exists
		   because there's no separate visual column to carry a photo there. */
		background-image: var(--annghar-spin-bg-image, none);
		box-shadow:
			0 24px 60px rgba(16, 25, 15, 0.24),
			0 8px 20px rgba(16, 25, 15, 0.12),
			0 0 0 1px rgba(199, 154, 69, 0.15);
		transform: translate(-50%, calc(-50% + 30px));
		opacity: 0;
		animation-name: annghar-spin-fade-scale-in;
		animation-fill-mode: forwards;
	}
}

@keyframes annghar-spin-fade-scale-in {
	from {
		opacity: 0;
		transform: translate(-50%, calc(-50% + 30px));
	}
	to {
		opacity: 1;
		transform: translate(-50%, -50%);
	}
}

@keyframes annghar-spin-fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.annghar-spin__overlay,
	.annghar-spin__panel {
		animation-duration: 1ms;
	}
}

.annghar-spin__close {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 3;
	width: 38px;
	height: 38px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.85);
	color: var(--annghar-spin-text);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 150ms ease;
}

.annghar-spin__close:hover,
.annghar-spin__close:focus-visible {
	background: #ffffff;
}

.annghar-spin__close:focus-visible,
#annghar-spin-popup a:focus-visible,
#annghar-spin-popup button:focus-visible,
#annghar-spin-popup input:focus-visible {
	outline: 2px solid var(--annghar-spin-accent);
	outline-offset: 2px;
}

/* --- Mobile (default/base): single column, no visual banner at all --- */
.annghar-spin__grid {
	display: grid;
	grid-template-columns: 1fr;
	height: 100%;
}

/* The desktop-only marketing photo (left column) is never shown on mobile -
   only the background wash on .annghar-spin__panel above is used there. */
.annghar-spin__visual {
	display: none;
}

.annghar-spin__content {
	position: relative;
	min-width: 0;
	height: 100%;
}

.annghar-spin__scroll {
	max-height: 90vh;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 32px 28px 28px;
	text-align: center;
}

/* --- Desktop: two-column grid (visual | content), fixed-height panel --- */
@media (min-width: 768px) {
	.annghar-spin:not(.annghar-spin--no-visual) .annghar-spin__grid {
		grid-template-columns: 42% 58%;
	}

	.annghar-spin__visual {
		display: block;
		background-size: cover;
		background-position: center;
		height: 100%;
	}

	.annghar-spin__scroll {
		height: 100%;
		max-height: none;
	}
}

.annghar-spin__logo {
	display: block;
	max-width: 120px;
	width: auto;
	height: auto;
	margin: 0 auto 12px;
}

.annghar-spin__brand {
	margin: 0 0 12px;
	font-size: 15px;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--annghar-spin-primary);
}

.annghar-spin__heading {
	margin: 0 0 8px;
	font-size: 26px;
	font-weight: 800;
	letter-spacing: 0.04em;
	line-height: 1.25;
	color: var(--annghar-spin-primary);
}

.annghar-spin__desc {
	margin: 0 0 18px;
	font-size: 14.5px;
	line-height: 1.6;
	letter-spacing: 0.01em;
	color: var(--annghar-spin-text);
	opacity: 0.72;
}

/* --- The wheel --- */
.annghar-spin-wheel-wrap {
	position: relative;
	width: min(260px, 62vw);
	margin: 0 auto 18px;
}

.annghar-spin-wheel {
	width: 100%;
	aspect-ratio: 1 / 1;
	border-radius: 50%;
	box-shadow:
		0 12px 30px rgba(16, 25, 15, 0.22),
		0 0 0 6px #ffffff,
		0 0 0 8px rgba(199, 154, 69, 0.4);
	transition: transform 5s cubic-bezier(0.18, 0.86, 0.1, 1);
	will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
	.annghar-spin-wheel {
		transition-duration: 800ms;
	}
}

.annghar-spin-wheel__svg {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
}

.annghar-spin-wheel-pointer {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 2;
	width: 0;
	height: 0;
	transform: translate(-50%, calc(-50% - 132px));
	border-left: 12px solid transparent;
	border-right: 12px solid transparent;
	border-top: 20px solid var(--annghar-spin-accent);
	filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}

.annghar-spin__unlock-text {
	margin: 0 0 14px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--annghar-spin-sage);
}

.annghar-spin__form {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.annghar-spin__field input {
	width: 100%;
	padding: 13px 16px;
	font-size: 15px;
	border: 1px solid rgba(38, 51, 43, 0.18);
	border-radius: 12px;
	background: #fff;
	color: var(--annghar-spin-text);
}

.annghar-spin__field input::placeholder {
	color: rgba(38, 51, 43, 0.45);
}

.annghar-spin__error {
	margin: -2px 0 0;
	font-size: 13px;
	color: #B3261E;
}

.annghar-spin__notice {
	margin: 8px 0 0;
	font-size: 13px;
	color: #B3261E;
}

.annghar-spin__cta {
	display: block;
	width: 100%;
	padding: 14px 18px;
	margin-top: 2px;
	border: none;
	border-radius: 999px;
	background: var(--annghar-spin-primary);
	color: #fff;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.03em;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: transform 150ms ease, box-shadow 150ms ease;
	box-shadow: 0 8px 20px rgba(31, 77, 44, 0.28);
}

.annghar-spin__cta:hover,
.annghar-spin__cta:focus-visible {
	transform: translateY(-1px);
	box-shadow: 0 10px 24px rgba(31, 77, 44, 0.34);
}

.annghar-spin__cta--link {
	display: inline-block;
	margin-top: 14px;
}

.annghar-spin__terms {
	margin: 14px 0 0;
	font-size: 11px;
	line-height: 1.5;
	opacity: 0.7;
}

.annghar-spin__otp-inputs {
	display: flex;
	justify-content: center;
	gap: 8px;
	margin-bottom: 6px;
}

.annghar-spin__otp-digit {
	width: 42px;
	height: 50px;
	text-align: center;
	font-size: 20px;
	font-weight: 700;
	border: 1px solid rgba(38, 51, 43, 0.18);
	border-radius: 10px;
	background: #fff;
	color: var(--annghar-spin-text);
}

.annghar-spin__otp-actions {
	display: flex;
	justify-content: space-between;
	margin-top: 4px;
}

.annghar-spin__link {
	background: none;
	border: none;
	padding: 4px;
	font-size: 13px;
	font-weight: 600;
	color: var(--annghar-spin-primary);
	text-decoration: underline;
	cursor: pointer;
}

/* Result state: a quiet confirmation, never the coupon code itself (see the
   template's own comment on why) - just which prize was won. */
.annghar-spin__result-card {
	padding-top: 8px;
}

.annghar-spin__prize {
	margin: 0 0 10px;
	font-size: 22px;
	font-weight: 800;
	color: var(--annghar-spin-accent);
}

.annghar-spin__loading[hidden] {
	display: none;
}

.annghar-spin__loading:not([hidden]) {
	position: absolute;
	inset: 0;
	z-index: 4;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(251, 247, 238, 0.7);
}

.annghar-spin__loading:not([hidden])::after {
	content: "";
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 3px solid rgba(31, 77, 44, 0.2);
	border-top-color: var(--annghar-spin-primary);
	animation: annghar-spin-loading-spin 700ms linear infinite;
}

@keyframes annghar-spin-loading-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Safety net: an explicit `display` on an element (like the link CTA above)
   otherwise has equal specificity to the browser's default [hidden]{display:
   none}, so JS toggling the `hidden` attribute wouldn't actually hide it. */
.annghar-spin__panel [hidden] {
	display: none !important;
}

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

/* --- Mobile: vertical stack, no horizontal overflow, internal scroll --- */
/* Mobile-specific tightening not already covered by the mobile-first base
   rules above (panel position/size/background/visual-hiding are now all
   handled unconditionally at the top of this file, with a desktop override
   at min-width:768px - see there instead of here). */
@media (max-width: 767px) {
	.annghar-spin__scroll {
		padding: 26px 20px 22px;
	}

	.annghar-spin-wheel-wrap {
		width: min(220px, 58vw);
	}

	.annghar-spin-wheel-pointer {
		transform: translate(-50%, calc(-50% - 112px));
	}
}
