/*! Expolab Where is Duckie — v1.0.2 */

.ewd {
	--ewd-scene-bg: #f6f3ee;
	--ewd-radius: 14px;
	--ewd-found-color: #f5a623;
	--ewd-hint-color: #e8577e;
	--ewd-miss-color: rgba(60, 60, 60, 0.55);
	--ewd-btn-color: #3a3a3a;
	--ewd-btn-bg: #f1ece4;
	--ewd-btn-active-color: #ffffff;
	--ewd-btn-active-bg: #e8577e;
	--ewd-btn-radius: 999px;
	--ewd-thumb-size: 64px;
	--ewd-thumb-active: #e8577e;
	--ewd-win-bg: rgba(255, 255, 255, 0.95);
	--ewd-fit-offset: 200px;

	box-sizing: border-box;
	width: 100%;
	margin-left: auto;
	margin-right: auto;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

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

/* Alcuni temi assegnano display a p, span e img e così annullano l'attributo hidden. */
.ewd [hidden] {
	display: none !important;
}

.ewd--picker-bottom .ewd__picker {
	order: 10;
}

.ewd--picker-bottom .ewd__status,
.ewd--picker-bottom noscript {
	order: 11;
}

/* ---------- Barra superiore ---------- */

.ewd__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
}

.ewd__levels,
.ewd__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.ewd__stats {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 14px;
	font-size: 0.95em;
}

.ewd__stat strong {
	font-variant-numeric: tabular-nums;
}

.ewd .ewd__btn {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 40px;
	margin: 0;
	padding: 8px 16px;
	border: 0;
	border-radius: var(--ewd-btn-radius);
	background: var(--ewd-btn-bg);
	color: var(--ewd-btn-color);
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
	transition: background-color 0.2s, color 0.2s, transform 0.15s, opacity 0.2s;
}

.ewd .ewd__btn:hover:not(:disabled),
.ewd .ewd__btn:focus-visible {
	transform: translateY(-1px);
}

.ewd .ewd__btn:focus-visible {
	outline: 3px solid var(--ewd-btn-active-bg);
	outline-offset: 2px;
}

.ewd .ewd__btn.is-active {
	background: var(--ewd-btn-active-bg);
	color: var(--ewd-btn-active-color);
}

.ewd .ewd__btn:disabled {
	cursor: default;
}

/* Pulsante aiuto: si riempie mentre si aspetta, poi pulsa. */
.ewd .ewd__hint {
	--ewd-hint-progress: 0;
	background:
		linear-gradient(90deg, rgba(232, 87, 126, 0.25) calc(var(--ewd-hint-progress) * 100%), transparent 0),
		var(--ewd-btn-bg);
}

.ewd .ewd__hint:disabled {
	opacity: 0.75;
}

.ewd .ewd__hint.is-ready {
	background: var(--ewd-btn-active-bg);
	color: var(--ewd-btn-active-color);
	animation: ewd-nudge 2.4s ease-in-out infinite;
}

.ewd .ewd__mute {
	width: 40px;
	padding: 0;
}

.ewd__mute svg {
	width: 22px;
	height: 22px;
	fill: currentColor;
}

.ewd__mute .ewd__mute-off,
.ewd__mute.is-muted .ewd__mute-on {
	display: none;
}

.ewd__mute.is-muted .ewd__mute-off {
	display: inline;
}

/* ---------- Miniature ---------- */

.ewd__picker {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
}

.ewd .ewd__thumb {
	appearance: none;
	width: var(--ewd-thumb-size);
	height: var(--ewd-thumb-size);
	margin: 0;
	padding: 0;
	border: 3px solid transparent;
	border-radius: 10px;
	background: none;
	overflow: hidden;
	cursor: pointer;
	opacity: 0.75;
	transition: opacity 0.2s, border-color 0.2s;
}

.ewd .ewd__thumb:hover,
.ewd .ewd__thumb.is-active {
	opacity: 1;
}

.ewd .ewd__thumb.is-active {
	border-color: var(--ewd-thumb-active);
}

.ewd .ewd__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

.ewd__intro {
	margin: 0;
	text-align: center;
	font-size: 1.15em;
}

/* ---------- Scena ---------- */

.ewd__stage {
	--ewd-ratio: 1;
	display: flex;
	justify-content: center;
}

.ewd__scene {
	position: relative;
	width: 100%;
	aspect-ratio: var(--ewd-ratio);
	border-radius: var(--ewd-radius);
	background: var(--ewd-scene-bg);
	overflow: hidden;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
	-webkit-tap-highlight-color: transparent;
	-webkit-touch-callout: none;
	touch-action: manipulation;
}

.ewd--fit .ewd__scene {
	width: min(100%, calc((100vh - var(--ewd-fit-offset)) * var(--ewd-ratio)));
	min-width: min(100%, 260px);
}

@supports (height: 100dvh) {
	.ewd--fit .ewd__scene {
		width: min(100%, calc((100dvh - var(--ewd-fit-offset)) * var(--ewd-ratio)));
	}
}

.ewd .ewd__img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: fill;
	pointer-events: none;
}

.ewd.is-loading .ewd__img {
	opacity: 0.4;
}

.ewd .ewd__duck {
	--ewd-duck-transform: rotate(0deg);
	position: absolute;
	display: block;
	height: auto;
	max-width: none;
	margin: 0;
	transform: var(--ewd-duck-transform);
	transform-origin: 50% 60%;
	pointer-events: none;
	transition: opacity 0.3s;
}

.ewd--shadow .ewd__duck {
	filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.22));
}

.ewd .ewd__duck.is-found {
	animation: ewd-pop 0.9s cubic-bezier(0.3, 1.6, 0.5, 1) both;
	z-index: 3;
}

.ewd__marks {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

/* Tocco a vuoto: piccola onda che svanisce. */
.ewd__miss {
	position: absolute;
	width: 34px;
	height: 34px;
	margin: -17px 0 0 -17px;
	border: 3px solid var(--ewd-miss-color);
	border-radius: 50%;
	animation: ewd-ripple 0.8s ease-out forwards;
}

/* Duckie trovata: cerchio che si allarga. */
.ewd__found {
	position: absolute;
	aspect-ratio: 1;
	border: 5px solid var(--ewd-found-color);
	border-radius: 50%;
	transform: translate(-50%, -50%);
	box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.6);
	animation: ewd-found 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) both;
	pointer-events: none;
	z-index: 2;
}

/* Aiuto: cerchio tratteggiato che pulsa. */
.ewd__ring {
	position: absolute;
	aspect-ratio: 1;
	border: 4px dashed var(--ewd-hint-color);
	border-radius: 50%;
	transform: translate(-50%, -50%);
	background: rgba(255, 255, 255, 0.12);
	pointer-events: none;
	z-index: 2;
}

.ewd__ring.is-on {
	animation: ewd-hint 3.6s ease-in-out both;
}

.ewd__message {
	position: absolute;
	left: 50%;
	top: 50%;
	margin: 0;
	padding: 8px 16px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.9);
	transform: translate(-50%, -50%);
	text-align: center;
	pointer-events: none;
	z-index: 4;
}

/* ---------- Messaggio finale ---------- */

.ewd__win {
	position: absolute;
	left: 50%;
	z-index: 5;
	width: max-content;
	max-width: 90%;
	padding: 16px 24px;
	border-radius: 16px;
	background: var(--ewd-win-bg);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
	text-align: center;
	transform: translateX(-50%);
	cursor: default;
	animation: ewd-in 0.35s ease-out both;
}

.ewd__win[hidden] {
	display: none;
}

.ewd__win--top {
	top: 4%;
}

.ewd__win--bottom {
	bottom: 4%;
}

.ewd__win p {
	margin: 0 0 8px;
}

.ewd__win-title {
	font-size: 1.5em;
	font-weight: 700;
	line-height: 1.2;
}

.ewd__win-record {
	font-weight: 700;
	color: var(--ewd-found-color);
}

.ewd__win .ewd__again {
	margin-top: 4px;
	background: var(--ewd-btn-active-bg);
	color: var(--ewd-btn-active-color);
}

/* ---------- Varie ---------- */

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

.ewd-notice {
	padding: 16px;
	border: 2px dashed #ccc;
	text-align: center;
}

@keyframes ewd-pop {
	0% {
		transform: var(--ewd-duck-transform) scale(1);
	}
	35% {
		transform: var(--ewd-duck-transform) scale(1.6) translateY(-12%);
	}
	60% {
		transform: var(--ewd-duck-transform) scale(1.25);
	}
	100% {
		transform: var(--ewd-duck-transform) scale(1.35);
	}
}

@keyframes ewd-found {
	from {
		opacity: 0;
		transform: translate(-50%, -50%) scale(0.3);
	}
	to {
		opacity: 1;
		transform: translate(-50%, -50%) scale(1);
	}
}

@keyframes ewd-ripple {
	from {
		opacity: 1;
		transform: scale(0.4);
	}
	to {
		opacity: 0;
		transform: scale(1.5);
	}
}

@keyframes ewd-hint {
	0% {
		opacity: 0;
		transform: translate(-50%, -50%) scale(1.6);
	}
	15% {
		opacity: 1;
		transform: translate(-50%, -50%) scale(1);
	}
	30%, 60% {
		transform: translate(-50%, -50%) scale(1.08);
	}
	45%, 75% {
		transform: translate(-50%, -50%) scale(0.96);
	}
	88% {
		opacity: 1;
	}
	100% {
		opacity: 0;
		transform: translate(-50%, -50%) scale(1);
	}
}

@keyframes ewd-nudge {
	0%, 80%, 100% {
		transform: scale(1);
	}
	88% {
		transform: scale(1.08);
	}
}

@keyframes ewd-in {
	from {
		opacity: 0;
		transform: translateX(-50%) translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateX(-50%);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ewd .ewd__duck.is-found,
	.ewd__found,
	.ewd__ring.is-on,
	.ewd .ewd__hint.is-ready,
	.ewd__miss,
	.ewd__win {
		animation-duration: 0.01s;
		animation-iteration-count: 1;
	}

	.ewd .ewd__duck.is-found {
		transform: var(--ewd-duck-transform) scale(1.35);
	}
}
