/* ============================================================
   EMAIL SLOT MACHINE — Shadow DOM Styles
   Scoped to :host (the <email-slot-machine> custom element)
   ============================================================ */

:host {
	display: block;
	box-sizing: border-box;
}

*,
*::before,
*::after {
	box-sizing: inherit;
}

/* ——————————————————————————————————————————
   LAYOUT WRAPPER
—————————————————————————————————————————— */

.esm {
	max-width: 520px;
	margin: 0 auto;
	padding: 2rem 1.5rem;
	text-align: center;
	font-family: var(--theme-font-family-body, system-ui, sans-serif);
	color: var(--theme-color-body, #333);
}

/* ——————————————————————————————————————————
   HEADER
—————————————————————————————————————————— */

.esm__header {
	margin-bottom: 1.75rem;
}

.esm__title {
	font-size: clamp(1.6rem, 4vw, 2.4rem);
	font-weight: 800;
	margin: 0 0 0.5rem;
	line-height: 1.15;
	color: var(--theme-color-primary, #1a1a2e);
	letter-spacing: -0.02em;
}

.esm__subtitle {
	font-size: 1rem;
	color: var(--theme-color-body, #666);
	margin: 0;
	line-height: 1.5;
}

/* ——————————————————————————————————————————
   SLOT MACHINE CABINET
—————————————————————————————————————————— */

.esm__machine {
	background: linear-gradient(160deg, #1a1a2e 0%, #0f3460 60%, #16213e 100%);
	border-radius: 24px;
	padding: 1.75rem 1.5rem 1.5rem;
	margin: 0 0 1.5rem;
	display: flex;
	align-items: center;
	gap: 1rem;
	box-shadow:
		0 12px 40px rgba(0, 0, 0, 0.35),
		0 2px 0 rgba(255, 255, 255, 0.06) inset,
		0 -2px 0 rgba(0, 0, 0, 0.3) inset;
	border: 2px solid rgba(255, 215, 0, 0.25);
	position: relative;
}

/* Top light strip */
.esm__machine::before {
	content: '';
	position: absolute;
	top: 10px;
	left: 50%;
	transform: translateX(-50%);
	width: 60%;
	height: 4px;
	background: linear-gradient(90deg,
		transparent,
		rgba(255, 215, 0, 0.5) 20%,
		rgba(255, 215, 0, 0.8) 50%,
		rgba(255, 215, 0, 0.5) 80%,
		transparent
	);
	border-radius: 2px;
}

/* ——————————————————————————————————————————
   REELS CONTAINER
—————————————————————————————————————————— */

.esm__reels {
	display: flex;
	gap: 0.625rem;
	flex: 1;
	justify-content: center;
}

/* ——————————————————————————————————————————
   INDIVIDUAL REEL
—————————————————————————————————————————— */

.esm__reel {
	background: #0a1628;
	border-radius: 14px;
	width: 88px;
	height: 88px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid rgba(255, 215, 0, 0.3);
	position: relative;
	overflow: hidden;
	box-shadow:
		0 4px 16px rgba(0, 0, 0, 0.5) inset,
		0 1px 0 rgba(255, 255, 255, 0.05) inset;
	transition: border-color 0.3s ease, box-shadow 0.3s ease;
	flex-shrink: 0;
}

/* Shine overlay on reel */
.esm__reel::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 40%;
	background: linear-gradient(
		to bottom,
		rgba(255, 255, 255, 0.06),
		transparent
	);
	border-radius: 12px 12px 0 0;
	pointer-events: none;
}

.esm__reel--stopped {
	border-color: #ffd700;
	box-shadow:
		0 4px 16px rgba(0, 0, 0, 0.5) inset,
		0 0 20px rgba(255, 215, 0, 0.35),
		0 0 40px rgba(255, 215, 0, 0.15);
	animation: esm-reel-win-pulse 0.4s ease forwards;
}

@keyframes esm-reel-win-pulse {
	0%   { transform: scale(1); }
	50%  { transform: scale(1.06); }
	100% { transform: scale(1); }
}

.esm__reel-inner {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
}

.esm__symbol {
	font-size: 2.8rem;
	line-height: 1;
	user-select: none;
	display: block;
	transition: filter 0.08s ease;
}

/* Spinning state — blur + bounce */
.esm__reel--spinning .esm__symbol {
	filter: blur(3px) brightness(0.8);
	animation: esm-symbol-bounce 0.09s ease-in-out infinite;
}

@keyframes esm-symbol-bounce {
	0%, 100% { transform: translateY(0) scaleY(1); }
	50%       { transform: translateY(-4px) scaleY(0.9); }
}

/* ——————————————————————————————————————————
   LEVER
—————————————————————————————————————————— */

.esm__lever-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	flex-shrink: 0;
}

.esm__lever {
	display: flex;
	flex-direction: column;
	align-items: center;
	cursor: default;
	transform-origin: bottom center;
	transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.esm__lever--pulled {
	transform: translateY(22px) rotate(8deg);
}

.esm__lever-ball {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: radial-gradient(circle at 35% 30%, #ff8a80, #c0392b);
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.2) inset;
	flex-shrink: 0;
}

.esm__lever-arm {
	width: 7px;
	height: 64px;
	background: linear-gradient(to right, #9e9e9e, #616161, #9e9e9e);
	border-radius: 3.5px;
	margin-top: 3px;
	box-shadow: 1px 0 3px rgba(0, 0, 0, 0.4);
}

.esm__lever-base {
	width: 22px;
	height: 10px;
	background: linear-gradient(to bottom, #757575, #424242);
	border-radius: 4px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ——————————————————————————————————————————
   EMAIL FORM STATE
—————————————————————————————————————————— */

.esm__form {}

.esm__email-row {
	display: flex;
	gap: 0.5rem;
	margin-bottom: 0.625rem;
}

.esm__email-input {
	flex: 1;
	min-width: 0;
	padding: 0.75rem 1rem;
	border: 2px solid #d8dce2;
	border-radius: 10px;
	font-size: 0.95rem;
	line-height: 1.4;
	outline: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
	background: #fff;
	color: #1a1a2e;
	font-family: inherit;
}

.esm__email-input::placeholder {
	color: #aaa;
}

.esm__email-input:focus {
	border-color: var(--theme-color-primary, #0f3460);
	box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.12);
}

.esm__email-input--error {
	border-color: #e53935;
	box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.12);
	animation: esm-shake 0.38s ease;
}

@keyframes esm-shake {
	0%, 100% { transform: translateX(0); }
	20%       { transform: translateX(-7px); }
	60%       { transform: translateX(7px); }
	80%       { transform: translateX(-4px); }
}

.esm__spin-btn {
	padding: 0.75rem 1.25rem;
	background: linear-gradient(135deg, #1a1a2e, #0f3460);
	color: #fff;
	border: none;
	border-radius: 10px;
	font-size: 0.95rem;
	font-weight: 700;
	cursor: pointer;
	white-space: nowrap;
	transition: opacity 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
	font-family: inherit;
	box-shadow: 0 4px 12px rgba(15, 52, 96, 0.35);
	letter-spacing: 0.01em;
}

.esm__spin-btn:hover:not(:disabled) {
	opacity: 0.88;
	transform: translateY(-2px);
	box-shadow: 0 6px 16px rgba(15, 52, 96, 0.4);
}

.esm__spin-btn:active:not(:disabled) {
	transform: translateY(0);
}

.esm__spin-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.esm__disclaimer {
	font-size: 0.75rem;
	color: #aaa;
	margin: 0;
	line-height: 1.5;
}

/* ——————————————————————————————————————————
   RESULT STATE
—————————————————————————————————————————— */

.esm__result {
	position: relative;
	padding: 1.75rem 1.5rem;
	background: linear-gradient(145deg, #fffde7, #fff9e6);
	border-radius: 16px;
	border: 2px solid #ffd700;
	overflow: hidden;
	box-shadow: 0 4px 20px rgba(255, 215, 0, 0.2);
	animation: esm-result-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes esm-result-appear {
	from { opacity: 0; transform: scale(0.9) translateY(8px); }
	to   { opacity: 1; transform: scale(1) translateY(0); }
}

.esm__win-message {
	font-size: 1.3rem;
	font-weight: 700;
	margin: 0 0 1.25rem;
	color: var(--theme-color-primary, #1a1a2e);
	line-height: 1.3;
}

.esm__prize-label {
	font-size: 1.35rem;
	font-weight: 800;
	color: #c0392b;
	margin-bottom: 1.1rem;
	letter-spacing: -0.01em;
}

.esm__coupon-box {
	background: #fff;
	border-radius: 10px;
	padding: 1rem 1.25rem;
	margin-bottom: 0.875rem;
	border: 1.5px dashed #ffd700;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.esm__coupon-label {
	display: block;
	font-size: 0.7rem;
	color: #999;
	margin-bottom: 0.5rem;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	font-weight: 600;
}

.esm__coupon-row {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.625rem;
}

.esm__coupon-code {
	font-size: 1.6rem;
	font-weight: 800;
	letter-spacing: 0.12em;
	color: #1a1a2e;
	font-family: 'Courier New', Courier, monospace;
}

.esm__copy-btn {
	padding: 0.3rem 0.8rem;
	background: #1a1a2e;
	color: #fff;
	border: none;
	border-radius: 6px;
	font-size: 0.78rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.15s ease;
	font-family: inherit;
	letter-spacing: 0.02em;
	flex-shrink: 0;
}

.esm__copy-btn:hover {
	background: #0f3460;
	transform: translateY(-1px);
}

.esm__copy-btn--copied {
	background: #2e7d32;
}

.esm__prize-description {
	font-size: 0.82rem;
	color: #888;
	margin: 0;
	line-height: 1.5;
}

/* ——————————————————————————————————————————
   ALREADY PLAYED STATE
—————————————————————————————————————————— */

.esm__played {
	padding: 1.25rem 1.5rem;
	background: #f5f5f5;
	border-radius: 12px;
	color: #777;
	font-size: 0.9rem;
	line-height: 1.6;
	border: 1px solid #e0e0e0;
}

/* ——————————————————————————————————————————
   CONFETTI
—————————————————————————————————————————— */

.esm__confetti {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	overflow: hidden;
	z-index: 0;
}

.esm__confetti-piece {
	position: absolute;
	top: -12px;
	animation: esm-confetti-fall linear forwards;
}

@keyframes esm-confetti-fall {
	0% {
		transform: translateY(0) rotate(0deg);
		opacity: 1;
	}
	80% {
		opacity: 1;
	}
	100% {
		transform: translateY(240px) rotate(540deg);
		opacity: 0;
	}
}

/* Result content sits above confetti */
.esm__result > *:not(.esm__confetti) {
	position: relative;
	z-index: 1;
}

/* ——————————————————————————————————————————
   RESPONSIVE
—————————————————————————————————————————— */

@media (max-width: 480px) {
	.esm {
		padding: 1.5rem 1rem;
	}

	.esm__machine {
		padding: 1.25rem 1rem 1rem;
		gap: 0.625rem;
	}

	.esm__reel {
		width: 72px;
		height: 72px;
	}

	.esm__symbol {
		font-size: 2.2rem;
	}

	.esm__lever-arm {
		height: 50px;
	}

	.esm__email-row {
		flex-direction: column;
	}

	.esm__spin-btn {
		width: 100%;
	}

	.esm__coupon-code {
		font-size: 1.3rem;
	}
}
