/**
 * Zoom Game (ZoomZoo)
 *
 * Everything is scoped under .fzg. Brand tokens are inherited from the theme
 * where it defines them, with the WunderWild palette as fallback. Responsive
 * sizing uses container queries (cqi), not media queries, so the game adapts
 * to whatever column the shortcode lands in.
 *
 * Motion notes: the zoom is a transform transition on .fzg-zoom; the Ken Burns
 * drift is a separate animation on .fzg-drift so the two never write the same
 * property. Drift is paused while a zoom transition runs. Everything animates
 * transform/opacity only - nothing here can trigger layout.
 */

.fzg {
	/* Brand tokens, inherited from the theme where it defines them. */
	--fzg-ink: var(--theme-color-5, #1a3a2f);
	--fzg-sky: var(--theme-color-4, #6fa8e8);
	--fzg-mint: #e8f4ec;
	--fzg-leaf: #7bc142;
	--fzg-coral: #e06840;
	--fzg-cream: #fdfbf2;
	--fzg-amber: #e8a840;

	--fzg-ink-72: rgba(26, 58, 47, 0.72);
	--fzg-ink-55: rgba(26, 58, 47, 0.55);
	--fzg-ink-38: rgba(26, 58, 47, 0.38);
	--fzg-ink-18: rgba(26, 58, 47, 0.18);
	--fzg-ink-08: rgba(26, 58, 47, 0.08);

	/* Ink-tinted shadow: the brand rule is never black. */
	--fzg-shadow: var(--default-box-shadow, 0 12px 30px rgba(26, 58, 47, 0.08));
	--fzg-shadow-deep: 0 18px 44px rgba(26, 58, 47, 0.16);

	/* Radii ladder. */
	--fzg-r-lg: 16px;
	--fzg-r: var(--default-border-radius, 12px);
	--fzg-r-sm: 8px;

	/* The zoom-out ease: fast start, long luxurious settle. */
	--fzg-zoom-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--fzg-zoom-time: 1500ms;

	/* Vignette strength, stepped down one notch per zoom level by JS. */
	--fzg-vig: 1;

	container-type: inline-size;
	box-sizing: border-box;
	width: 100%;
	margin: 0 0 2rem;
	padding: clamp(14px, 3cqi, 26px);
	background: var(--fzg-cream);
	border: 1px solid var(--fzg-ink-08);
	border-radius: var(--fzg-r-lg);
	box-shadow: var(--fzg-shadow);
	font-family: var(--body-font, "Nunito Sans", Arial, sans-serif);
	color: var(--fzg-ink);
}

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

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

/* ---------------------------------------------------------------- header --- */

.fzg-head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: clamp(10px, 2cqi, 18px);
}

.fzg-title {
	margin: 0;
	font-family: var(--title-font, "Fredoka", "Nunito Sans", sans-serif);
	font-size: clamp(1.5rem, 5cqi, 2.1rem);
	font-weight: 600;
	line-height: 1.15;
	color: var(--fzg-ink);
}

.fzg-number {
	color: var(--fzg-ink-38);
	font-weight: 500;
	margin-left: 2px;
}

.fzg-tagline {
	margin: 4px 0 0;
	font-size: clamp(0.85rem, 2.6cqi, 0.98rem);
	color: var(--fzg-ink-72);
}

.fzg-tools {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

/* Inline "How to play" trigger inside the tagline. */
.fzg-howto-link {
	margin: 0 0 0 4px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--fzg-sky);
	font: inherit;
	font-weight: 800;
	text-decoration: underline;
	cursor: pointer;
}

.fzg-howto-link:hover {
	color: #5a95dc;
}

/* --------------------------------------------------------------- buttons --- */

.fzg-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 9px 16px;
	border: 1px solid var(--fzg-ink-18);
	border-radius: var(--fzg-r-sm);
	background: #fff;
	color: var(--fzg-ink);
	font: inherit;
	font-size: 0.92rem;
	font-weight: 700;
	line-height: 1.1;
	text-decoration: none;
	cursor: pointer;
	transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.fzg-btn:hover:not(:disabled):not(.is-disabled) {
	transform: translateY(-1px);
	box-shadow: 0 6px 16px rgba(26, 58, 47, 0.14);
	border-color: var(--fzg-ink-38);
}

.fzg-btn:active:not(:disabled) {
	transform: translateY(0) scale(0.98);
}

.fzg-btn:disabled,
.fzg-btn.is-disabled {
	opacity: 0.45;
	cursor: default;
}

.fzg-btn-primary {
	background: var(--fzg-ink);
	border-color: var(--fzg-ink);
	color: var(--fzg-cream);
}

.fzg-btn-primary:hover:not(:disabled) {
	background: #234c3e;
}

.fzg-btn-ghost {
	background: transparent;
}

.fzg-btn-icon {
	padding: 8px 10px;
	font-size: 1rem;
	line-height: 1;
}

.fzg [data-fzg-sound][aria-pressed="false"] .fzg-sound-on,
.fzg [data-fzg-sound][aria-pressed="true"] .fzg-sound-off {
	display: none;
}

/* ----------------------------------------------------------------- stage --- */

.fzg-stage {
	position: relative;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	border-radius: var(--fzg-r);
	background: var(--fzg-ink);
	box-shadow: var(--fzg-shadow-deep);
	/* Rounded corners must clip the transformed image on Safari too. */
	transform: translateZ(0);
	isolation: isolate;
}

.fzg-lqip {
	position: absolute;
	inset: 0;
	background-size: cover;
	background-position: center;
	filter: blur(24px) saturate(1.1);
	transform: scale(1.15);
}

.fzg-zoom {
	position: absolute;
	inset: 0;
	transition: transform var(--fzg-zoom-time) var(--fzg-zoom-ease);
	will-change: transform;
}

.fzg-drift {
	position: absolute;
	inset: 0;
	animation: fzg-drift 14s ease-in-out infinite alternate;
}

.fzg-drift.is-alt {
	animation-name: fzg-drift-alt;
}

.fzg.is-zooming .fzg-drift {
	animation-play-state: paused;
}

.fzg.is-revealed .fzg-drift {
	animation: none;
}

/* Drop the raster hint once the game is over so the browser re-rasterises the
   photo at full resolution instead of stretching the zoomed-in tile. */
.fzg.is-revealed .fzg-zoom {
	will-change: auto;
}

@keyframes fzg-drift {
	from { transform: scale(1) translate(0, 0); }
	to   { transform: scale(1.035) translate(0.7%, -0.5%); }
}

@keyframes fzg-drift-alt {
	from { transform: scale(1.035) translate(-0.6%, 0.5%); }
	to   { transform: scale(1) translate(0, 0); }
}

.fzg-img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity 600ms ease;
	user-select: none;
	-webkit-user-drag: none;
}

.fzg-img.is-loaded {
	opacity: 1;
}

.fzg-vignette {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background:
		radial-gradient(ellipse 75% 65% at 50% 48%, transparent 40%, rgba(26, 58, 47, 0.55) 125%);
	opacity: var(--fzg-vig);
	transition: opacity var(--fzg-zoom-time) var(--fzg-zoom-ease);
}

/* Win flash: a soft leaf-tinted pulse over the stage. */
.fzg-stage::after {
	content: "";
	position: absolute;
	inset: 0;
	background: radial-gradient(circle, rgba(123, 193, 66, 0.35), transparent 70%);
	opacity: 0;
	pointer-events: none;
}

.fzg.is-won .fzg-stage::after {
	animation: fzg-flash 900ms ease-out 1;
}

@keyframes fzg-flash {
	0%   { opacity: 0; }
	25%  { opacity: 1; }
	100% { opacity: 0; }
}

.fzg-zoom-badge {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 2;
	padding: 5px 12px;
	border-radius: 999px;
	background: rgba(26, 58, 47, 0.66);
	backdrop-filter: blur(4px);
	color: var(--fzg-cream);
	font-family: var(--title-font, "Fredoka", sans-serif);
	font-size: clamp(0.85rem, 2.6cqi, 1rem);
	font-weight: 600;
	letter-spacing: 0.02em;
	transition: transform 300ms var(--fzg-zoom-ease);
}

.fzg-zoom-badge.is-bumped {
	animation: fzg-badge-bump 500ms var(--fzg-zoom-ease) 1;
}

@keyframes fzg-badge-bump {
	0%   { transform: scale(1); }
	40%  { transform: scale(1.22); }
	100% { transform: scale(1); }
}

/* ----------------------------------------------------------------- slots --- */

.fzg-slots {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: clamp(6px, 1.4cqi, 10px);
	margin-top: clamp(10px, 2.4cqi, 16px);
}

.fzg-slot {
	min-height: clamp(34px, 8cqi, 44px);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 4px 8px;
	border: 2px dashed var(--fzg-ink-18);
	border-radius: var(--fzg-r-sm);
	background: transparent;
	font-size: clamp(0.72rem, 2.2cqi, 0.9rem);
	font-weight: 700;
	text-align: center;
	line-height: 1.15;
	overflow-wrap: anywhere;
	transition: background-color 250ms ease, border-color 250ms ease, color 250ms ease;
}

.fzg-slot.is-current {
	border-color: var(--fzg-sky);
	border-style: solid;
	box-shadow: 0 0 0 3px rgba(111, 168, 232, 0.25);
}

.fzg-slot.is-wrong {
	border-style: solid;
	border-color: var(--fzg-coral);
	background: rgba(224, 104, 64, 0.14);
	color: #a4441f;
	animation: fzg-shake 420ms ease 1;
}

.fzg-slot.is-warm {
	border-style: solid;
	border-color: var(--fzg-amber);
	background: rgba(232, 168, 64, 0.18);
	color: #8a5f14;
	animation: fzg-shake 420ms ease 1;
}

.fzg-slot.is-skip {
	border-style: solid;
	border-color: var(--fzg-ink-18);
	background: var(--fzg-ink-08);
	color: var(--fzg-ink-55);
}

.fzg-slot.is-win {
	border-style: solid;
	border-color: var(--fzg-leaf);
	background: rgba(123, 193, 66, 0.2);
	color: #3d6b15;
	animation: fzg-pop 500ms var(--fzg-zoom-ease) 1;
}

.fzg-slot-tag {
	display: block;
	font-size: 0.85em;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

/* Placeholder label in an unused slot: legible as "guesses land here", quiet
   enough to disappear behind a real guess. */
.fzg-slot-ph {
	font-size: 0.82em;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--fzg-ink-38);
}

.fzg-slot.is-current .fzg-slot-ph {
	color: var(--fzg-ink-55);
}

@keyframes fzg-shake {
	0%, 100% { transform: translateX(0); }
	20%      { transform: translateX(-6px); }
	40%      { transform: translateX(6px); }
	60%      { transform: translateX(-4px); }
	80%      { transform: translateX(3px); }
}

@keyframes fzg-pop {
	0%   { transform: scale(0.85); }
	55%  { transform: scale(1.08); }
	100% { transform: scale(1); }
}

/* ----------------------------------------------------------------- hints --- */

.fzg-hints {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 10px;
	min-height: 34px;
}

.fzg-hint {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border-radius: 999px;
	background: var(--fzg-mint);
	border: 1px solid rgba(123, 193, 66, 0.4);
	color: var(--fzg-ink);
	font-size: clamp(0.78rem, 2.3cqi, 0.9rem);
	font-weight: 600;
	animation: fzg-hint-in 500ms var(--fzg-zoom-ease) 1;
}

.fzg-hint-label {
	font-weight: 800;
	text-transform: uppercase;
	font-size: 0.78em;
	letter-spacing: 0.05em;
	color: #4a7d1f;
}

@keyframes fzg-hint-in {
	from { opacity: 0; transform: translateY(8px) scale(0.9); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ----------------------------------------------------------------- guess --- */

.fzg-guess {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: clamp(10px, 2.4cqi, 16px);
}

.fzg-combo {
	position: relative;
	flex: 1 1 240px;
}

.fzg-input {
	width: 100%;
	padding: 12px 14px;
	border: 2px solid var(--fzg-ink-18);
	border-radius: var(--input-border-radius, 8px);
	background: #fff;
	color: var(--fzg-ink);
	font: inherit;
	font-size: 1rem;
	transition: border-color 140ms ease, box-shadow 140ms ease;
}

.fzg-input:focus {
	outline: none;
	border-color: var(--fzg-sky);
	box-shadow: 0 0 0 3px rgba(111, 168, 232, 0.25);
}

.fzg-listbox {
	position: absolute;
	z-index: 30;
	left: 0;
	right: 0;
	bottom: calc(100% + 6px);
	margin: 0;
	padding: 6px;
	list-style: none;
	background: #fff;
	border: 1px solid var(--fzg-ink-18);
	border-radius: var(--fzg-r);
	box-shadow: var(--fzg-shadow-deep);
	max-height: 264px;
	overflow-y: auto;
}

.fzg-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 9px 12px;
	border-radius: var(--fzg-r-sm);
	cursor: pointer;
	font-weight: 600;
	font-size: 0.95rem;
}

.fzg-option[aria-selected="true"],
.fzg-option:hover {
	background: var(--fzg-mint);
}

.fzg-option-group {
	font-size: 0.72rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--fzg-ink-38);
}

.fzg-option.is-empty {
	cursor: default;
	color: var(--fzg-ink-55);
	font-weight: 400;
}

.fzg-actions {
	display: flex;
	gap: 10px;
}

/* ---------------------------------------------------------------- reveal --- */

.fzg-reveal {
	margin-top: clamp(14px, 3cqi, 22px);
	padding: clamp(14px, 3cqi, 24px);
	border-radius: var(--fzg-r);
	background: var(--fzg-mint);
	border: 1px solid rgba(123, 193, 66, 0.35);
	text-align: center;
	animation: fzg-reveal-in 700ms var(--fzg-zoom-ease) 1;
}

.fzg-reveal.is-lost {
	background: #fdf0ea;
	border-color: rgba(224, 104, 64, 0.3);
}

@keyframes fzg-reveal-in {
	from { opacity: 0; transform: translateY(14px); }
	to   { opacity: 1; transform: translateY(0); }
}

.fzg-reveal-verdict {
	margin: 0;
	font-weight: 800;
	font-size: clamp(0.95rem, 2.8cqi, 1.1rem);
}

.fzg-reveal-name {
	margin: 6px 0 0;
	font-family: var(--title-font, "Fredoka", sans-serif);
	font-size: clamp(1.7rem, 6cqi, 2.5rem);
	font-weight: 600;
	line-height: 1.1;
	color: var(--fzg-ink);
}

.fzg-reveal-binomial {
	margin: 2px 0 0;
	font-style: italic;
	color: var(--fzg-ink-55);
	font-size: clamp(0.9rem, 2.6cqi, 1rem);
}

.fzg-reveal-fact {
	margin: 12px auto 0;
	max-width: 46em;
	font-size: clamp(0.92rem, 2.7cqi, 1.02rem);
	line-height: 1.55;
}

.fzg-reveal-credit {
	margin: 10px 0 0;
	font-size: 0.78rem;
	color: var(--fzg-ink-55);
}

.fzg-reveal-credit a {
	color: inherit;
	text-decoration: underline;
}

.fzg-reveal-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
	margin-top: 16px;
}

.fzg-btn-share {
	background: var(--fzg-sky);
	border-color: var(--fzg-sky);
	color: #fff;
}

.fzg-btn-share:hover:not(:disabled) {
	background: #5a95dc;
}

.fzg-countdown {
	margin: 14px 0 0;
	font-size: 0.88rem;
	font-weight: 700;
	color: var(--fzg-ink-55);
	font-variant-numeric: tabular-nums;
}

.fzg-ad {
	min-height: 120px;
	margin-top: 14px;
}

/* --------------------------------------------------------------- archive --- */

.fzg-nav {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	margin-top: clamp(12px, 2.6cqi, 18px);
}

.fzg-nav-today {
	margin: 0 auto;
}

/* ----------------------------------------------------------------- stats --- */

/* display:flex would beat the hidden attribute's UA display:none. */
.fzg-stats-modal[hidden],
.fzg-reveal[hidden],
.fzg-listbox[hidden],
.fzg-guess[hidden] {
	display: none;
}

.fzg-stats-modal {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(26, 58, 47, 0.55);
	backdrop-filter: blur(3px);
}

.fzg-stats-card {
	position: relative;
	width: min(420px, 100%);
	padding: 24px;
	border-radius: var(--fzg-r-lg);
	background: var(--fzg-cream);
	box-shadow: var(--fzg-shadow-deep);
	animation: fzg-pop 400ms var(--fzg-zoom-ease) 1;
}

.fzg-stats-close {
	position: absolute;
	top: 10px;
	right: 10px;
	font-size: 1.2rem;
}

.fzg-stats-title {
	margin: 0 0 14px;
	font-family: var(--title-font, "Fredoka", sans-serif);
	font-size: 1.4rem;
	font-weight: 600;
}

.fzg-stats-row {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 8px;
	text-align: center;
}

.fzg-stat-num {
	display: block;
	font-family: var(--title-font, "Fredoka", sans-serif);
	font-size: 1.6rem;
	font-weight: 600;
	line-height: 1.1;
}

.fzg-stat-label {
	display: block;
	font-size: 0.7rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--fzg-ink-55);
}

.fzg-stats-sub {
	margin: 18px 0 8px;
	font-size: 0.85rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--fzg-ink-55);
}

.fzg-dist {
	display: grid;
	gap: 5px;
}

.fzg-dist-row {
	display: grid;
	grid-template-columns: 16px 1fr;
	gap: 8px;
	align-items: center;
	font-size: 0.85rem;
	font-weight: 700;
}

.fzg-dist-bar {
	min-width: 22px;
	padding: 3px 8px;
	border-radius: 4px;
	background: var(--fzg-ink-18);
	color: var(--fzg-ink);
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.fzg-dist-bar.is-hit {
	background: var(--fzg-leaf);
	color: #fff;
}

/* ------------------------------------------------------------------ help --- */

.fzg-help-list {
	display: grid;
	gap: 12px;
	margin: 0;
	padding: 0;
	list-style: none;
	text-align: left;
	font-size: 0.95rem;
	line-height: 1.45;
}

.fzg-help-list li {
	display: flex;
	gap: 10px;
	align-items: flex-start;
}

.fzg-help-emoji {
	flex-shrink: 0;
	font-size: 1.15rem;
	line-height: 1.3;
}

.fzg-help-foot {
	margin: 16px 0 0;
	font-weight: 700;
	text-align: center;
	color: var(--fzg-ink-72);
}

/* ----------------------------------------------------------------- about --- */

/* Lives outside .fzg so the theme's article typography applies; only rhythm
   and width are set here. */
.fzg-about {
	max-width: 46em;
	margin: 2.5rem auto 0;
	line-height: 1.65;
}

.fzg-about h2 {
	margin: 1.6em 0 0.5em;
	font-family: var(--title-font, "Fredoka", "Nunito Sans", sans-serif);
	font-size: 1.35rem;
}

.fzg-about h2:first-child {
	margin-top: 0;
}

.fzg-about p,
.fzg-about ol {
	margin: 0 0 1em;
}

.fzg-about li {
	margin-bottom: 0.4em;
}

/* -------------------------------------------------------------- confetti --- */

.fzg-confetti {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: 5;
}

.fzg-confetti span {
	position: absolute;
	top: 38%;
	left: 50%;
	width: 9px;
	height: 14px;
	border-radius: 2px;
	opacity: 0;
	animation: fzg-confetti 2200ms cubic-bezier(0.15, 0.6, 0.35, 1) forwards;
	animation-delay: var(--d, 0ms);
}

@keyframes fzg-confetti {
	0% {
		opacity: 1;
		transform: translate(0, 0) rotate(0deg) scale(1);
	}
	100% {
		opacity: 0;
		transform: translate(var(--dx, 0px), var(--dy, 240px)) rotate(var(--rot, 360deg)) scale(0.9);
	}
}

/* ------------------------------------------------------------------ misc --- */

.fzg-noscript {
	margin: 12px 0 0;
	padding: 10px 14px;
	border-radius: var(--fzg-r-sm);
	background: var(--fzg-mint);
	font-size: 0.9rem;
}

.fzg-error {
	padding: 14px;
	border-radius: 8px;
	background: #fdf0ea;
	color: #a4441f;
}

/* Narrow containers: stack the guess form, tighten the slots. */
@container (max-width: 480px) {
	.fzg-actions {
		width: 100%;
	}

	.fzg-actions .fzg-btn {
		flex: 1;
	}

	.fzg-slot {
		font-size: 0.68rem;
	}
}

/* --------------------------------------------------------- reduced motion --- */

@media (prefers-reduced-motion: reduce) {
	.fzg-drift {
		animation: none;
	}

	.fzg-zoom {
		transition: none;
	}

	.fzg-vignette {
		transition: opacity 250ms ease;
	}

	.fzg-slot.is-wrong,
	.fzg-slot.is-warm,
	.fzg-slot.is-win,
	.fzg-zoom-badge.is-bumped,
	.fzg-reveal,
	.fzg-hint {
		animation: none;
	}

	.fzg-confetti {
		display: none;
	}

	.fzg-btn:hover:not(:disabled):not(.is-disabled) {
		transform: none;
	}
}
