/**
 * Scratch & win - floating button, card, and the panel it opens.
 *
 * Rendered from the footer on every page, so it carries its own copy of the
 * kit's tokens rather than relying on .sa-shop being an ancestor. Values match
 * shop.css and the badge the home page used to carry on its own.
 */

.sa-sw {
	--sw-ink: #120e17;
	--sw-cream: #f5efe8;
	--sw-paper: #fefcfb;
	--sw-gold: #a67e48;
	--sw-gold-2: #c5a276;
	--sw-purple: #533569;
	--sw-purple-deep: #3c2146;
	--sw-purple-ink: #190e1d;
	--sw-serif: 'Gilda Display', Georgia, 'Times New Roman', serif;
	--sw-sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ------------------------------------------------------------ the button */

/*
 * Same place the home page's badge sat: anchored from the bottom so it lands
 * identically on a 768px laptop and a 1080px desktop.
 */
.sa-sw-btn {
	position: fixed;
	right: 52px;
	bottom: clamp(24px, 14.6vh, 158px);
	z-index: 95;

	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;

	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	font-family: var(--sw-sans);
	-webkit-tap-highlight-color: transparent;
}

.sa-sw-btn__disc {
	position: relative;
	width: 106px;
	height: 106px;
	border-radius: 999px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--sw-cream);
	background: radial-gradient(circle at 50% 35%, #6b4e8f, var(--sw-purple-deep));
	border: 1px solid rgba(166, 126, 72, 0.8);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/*
 * A slow breath, so the button reads as waiting for you without ever moving
 * far enough to pull the eye off the page. Stops once the card is won.
 */
.sa-sw:not([data-won]) .sa-sw-btn__disc::after {
	content: '';
	position: absolute;
	inset: -1px;
	border-radius: inherit;
	border: 1px solid var(--sw-gold);
	opacity: 0;
	animation: sa-sw-halo 3.4s ease-out infinite;
}

@keyframes sa-sw-halo {
	0% { transform: scale(1); opacity: 0.55; }
	70% { transform: scale(1.28); opacity: 0; }
	100% { transform: scale(1.28); opacity: 0; }
}

.sa-sw-btn:hover .sa-sw-btn__disc,
.sa-sw-btn:focus-visible .sa-sw-btn__disc {
	transform: translateY(-3px);
	box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}

.sa-sw-btn:focus-visible .sa-sw-btn__disc {
	outline: 2px solid var(--sw-gold-2);
	outline-offset: 3px;
}

.sa-sw-btn__dot {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 22px;
	height: 22px;
	padding: 0 5px;
	border-radius: 999px;
	background: var(--sw-gold);
	color: #fff;
	font: 700 12px/22px var(--sw-sans);
	text-align: center;
}

.sa-sw-btn__label {
	color: var(--sw-cream);
	font: 700 17px/1 var(--sw-sans);
	letter-spacing: 0.02em;
	text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
}

/* ------------------------------------------------------------- the panel */

.sa-sw-veil {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
	background: rgba(12, 8, 15, 0.72);
	backdrop-filter: blur(3px);
	animation: sa-sw-fade 0.2s ease-out;
}

.sa-sw-veil[hidden] {
	display: none;
}

@keyframes sa-sw-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

.sa-sw-modal {
	position: relative;
	width: min(420px, 100%);
	max-height: calc(100vh - 48px);
	overflow-y: auto;
	padding: 34px 32px 26px;
	border-radius: 22px;
	border: 1px solid rgba(166, 126, 72, 0.4);
	background:
		radial-gradient(120% 80% at 50% 0%, rgba(107, 78, 143, 0.55), transparent 62%),
		var(--sw-purple-ink);
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
	color: var(--sw-cream);
	font-family: var(--sw-sans);
	text-align: center;
	animation: sa-sw-rise 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes sa-sw-rise {
	from { transform: translateY(14px) scale(0.98); opacity: 0; }
	to { transform: none; opacity: 1; }
}

/* The card opens with focus on the dialog; it needs no ring of its own. */
.sa-sw-modal:focus {
	outline: none;
}

/* The theme paints bare buttons pink, so state every colour here. */
.sa-sw-close {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 34px;
	height: 34px;
	display: grid;
	place-items: center;
	border-radius: 999px;
	border: 1px solid rgba(245, 239, 232, 0.18);
	background: transparent;
	color: var(--sw-cream);
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease;
}

.sa-sw-close:hover,
.sa-sw-close:focus-visible {
	background: rgba(245, 239, 232, 0.1);
	border-color: rgba(166, 126, 72, 0.75);
}

.sa-sw-eyebrow {
	margin: 0 0 8px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--sw-gold-2);
}

.sa-sw-title {
	margin: 0 0 10px;
	font-family: var(--sw-serif);
	font-size: 32px;
	line-height: 1.15;
	font-weight: 400;
	color: var(--sw-paper);
}

.sa-sw-lede {
	margin: 0 auto 22px;
	max-width: 33ch;
	font-size: 14px;
	line-height: 1.55;
	color: rgba(245, 239, 232, 0.72);
}

/* -------------------------------------------------------------- the card */

.sa-sw-card {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 10;
	border-radius: 16px;
	overflow: hidden;
	border: 1px solid rgba(166, 126, 72, 0.45);
	background: linear-gradient(160deg, var(--sw-paper), #f2e9de);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.sa-sw-prize {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	padding: 16px;
	color: var(--sw-purple-deep);
}

.sa-sw-prize__rare {
	margin-bottom: 4px;
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--sw-gold);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.sa-sw-prize__rare[hidden] {
	display: none;
}

.sa-sw-prize__headline {
	font-family: var(--sw-serif);
	font-size: clamp(38px, 12vw, 52px);
	font-weight: 400;
	line-height: 1;
	color: var(--sw-purple-deep);
}

.sa-sw-prize__sub {
	font-size: 13px;
	letter-spacing: 0.04em;
	color: rgba(60, 33, 70, 0.72);
}

.sa-sw-foil {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	cursor: grab;
	touch-action: none; /* Otherwise the page scrolls instead of the finger scratching. */
	transition: opacity 0.45s ease;
}

.sa-sw-foil[hidden] {
	display: none;
}

.sa-sw-card.is-clearing .sa-sw-foil {
	opacity: 0;
	pointer-events: none;
}

.sa-sw-hint {
	position: absolute;
	left: 50%;
	bottom: 16px;
	transform: translateX(-50%);
	pointer-events: none;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: rgba(60, 33, 70, 0.55);
	transition: opacity 0.3s ease;
}

.sa-sw-hint[hidden],
.sa-sw-card.is-scratching .sa-sw-hint {
	opacity: 0;
}

.sa-sw-hint[hidden] {
	display: none;
}

/* A single sweep of light when the card gives up its prize. */
.sa-sw-card.is-clearing::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.85) 50%, transparent 62%);
	animation: sa-sw-sweep 0.75s ease-out;
	pointer-events: none;
}

@keyframes sa-sw-sweep {
	from { transform: translateX(-100%); }
	to { transform: translateX(100%); }
}

/* ------------------------------------------------------------ the reward */

.sa-sw-reveal {
	margin-top: 20px;
}

.sa-sw-reveal[hidden] {
	display: none;
}

.sa-sw-note {
	margin: 0 auto 16px;
	max-width: 32ch;
	font-size: 13px;
	line-height: 1.5;
	color: rgba(245, 239, 232, 0.72);
}

.sa-sw-code {
	display: flex;
	align-items: stretch;
	justify-content: center;
	gap: 0;
	margin: 0 auto 16px;
	width: fit-content;
	max-width: 100%;
	border: 1px dashed rgba(166, 126, 72, 0.7);
	border-radius: 10px;
	overflow: hidden;
	background: rgba(245, 239, 232, 0.06);
}

.sa-sw-code code {
	padding: 11px 14px;
	font-family: var(--sw-sans);
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.1em;
	color: var(--sw-paper);
}

.sa-sw-copy {
	padding: 0 14px;
	border: 0;
	border-left: 1px dashed rgba(166, 126, 72, 0.7);
	background: rgba(166, 126, 72, 0.18);
	color: var(--sw-gold-2);
	font: 700 12px/1 var(--sw-sans);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
}

.sa-sw-copy:hover,
.sa-sw-copy:focus-visible {
	background: var(--sw-gold);
	color: #fff;
}

.sa-sw-cta {
	display: block;
	width: 100%;
	padding: 14px 20px;
	border-radius: 999px;
	background: var(--sw-gold);
	color: #fff;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	text-decoration: none;
	transition: background 0.2s ease, transform 0.2s ease;
}

.sa-sw-cta:hover,
.sa-sw-cta:focus-visible {
	background: #b98f55;
	color: #fff;
	transform: translateY(-1px);
}

.sa-sw-fine {
	margin: 12px 0 0;
	font-size: 11px;
	line-height: 1.5;
	color: rgba(245, 239, 232, 0.5);
}

/* --------------------------------------------------------------- tools */

.sa-sw-tools {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 18px;
	margin-top: 18px;
	padding-top: 14px;
	border-top: 1px solid rgba(245, 239, 232, 0.1);
}

.sa-sw-tool {
	padding: 0;
	border: 0;
	background: none;
	color: rgba(245, 239, 232, 0.55);
	font: 600 11px/1.4 var(--sw-sans);
	letter-spacing: 0.1em;
	text-transform: uppercase;
	cursor: pointer;
	transition: color 0.2s ease;
}

.sa-sw-tool:hover,
.sa-sw-tool:focus-visible {
	color: var(--sw-gold-2);
}

.sa-sw-tool[hidden] {
	display: none;
}

/* ---------------------------------------------------------- small screens */

@media (max-width: 1024px) {
	.sa-sw-btn {
		right: 16px;
		bottom: 18px;
		gap: 6px;
	}

	.sa-sw-btn__disc {
		width: 64px;
		height: 64px;
	}

	.sa-sw-btn__icon {
		width: 24px;
		height: 24px;
	}

	.sa-sw-btn__label {
		font-size: 12px;
	}

	.sa-sw-modal {
		padding: 30px 20px 22px;
	}

	.sa-sw-title {
		font-size: 27px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sa-sw-btn__disc,
	.sa-sw-cta,
	.sa-sw-foil {
		transition: none;
	}

	.sa-sw:not([data-won]) .sa-sw-btn__disc::after,
	.sa-sw-veil,
	.sa-sw-modal,
	.sa-sw-card.is-clearing::after {
		animation: none;
	}

	.sa-sw:not([data-won]) .sa-sw-btn__disc::after {
		opacity: 0.35;
	}
}
