/**
 * Handprint Canvas — layout, modals, motion (respects reduced motion).
 */

.hpc-root {
	--hpc-bg-scale: 1;
	--hpc-space-1: 4px;
	--hpc-space-2: 8px;
	--hpc-space-3: 12px;
	--hpc-space-4: 16px;
	--hpc-space-5: 24px;
	--hpc-space-6: 32px;
	--hpc-accent: #2c5282;
	--hpc-radius: 0px;
	--hpc-stamp-pct-hand: 18%;
	--hpc-stamp-pct-fingerprint: 14%;
	--hpc-stamp-placed-hand: var(--hpc-stamp-pct-hand);
	--hpc-stamp-placed-fp: var(--hpc-stamp-pct-fingerprint);
	--hpc-min-h: 420px;
	--hpc-h: auto;
	--hpc-max-w: none;
	--hpc-w: auto;
	--hpc-bg-fit: cover;
	--hpc-bg-color: transparent;
	--hpc-cta-justify: flex-end;
	--hpc-cta-align: flex-start;
	--hpc-cta-text-align: left;
	--hpc-headline-color: #ffffff;
	--hpc-subheadline-color: rgba(255, 255, 255, 0.9);
	--hpc-desc-color: rgba(255, 255, 255, 0.92);
	--hpc-follower-filter: brightness(0) invert(1);
	--hpc-print-mine-filter: brightness(0) invert(1);
	--hpc-print-others-filter: brightness(0);
	--hpc-reveal-dur: 0.8s;
	--hpc-reveal-container-dur: 0.48s;
	box-sizing: border-box;
	width: var(--hpc-w);
	max-width: var(--hpc-max-w);
	margin-left: auto;
	margin-right: auto;
}

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

.hpc-pad-wrap {
	position: relative;
	width: 100%;
	height: var(--hpc-h);
	min-height: var(--hpc-min-h);
	border-radius: var(--hpc-radius);
	overflow: hidden;
	background: var(--hpc-bg-color);
}

/* Centered & scaled: values > 100% “zoom out” cover framing so more of the photo is visible. */
.hpc-bg {
	position: absolute;
	left: 50%;
	top: 50%;
	width: calc(100% * var(--hpc-bg-scale, 1));
	height: calc(100% * var(--hpc-bg-scale, 1));
	max-width: none;
	max-height: none;
	transform: translate(-50%, -50%);
	object-fit: var(--hpc-bg-fit);
	object-position: center;
	pointer-events: none;
	z-index: 1;
}

.hpc-bg-fallback {
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	background: var(--hpc-bg-color);
}

.hpc-cta {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: var(--hpc-cta-align);
	justify-content: var(--hpc-cta-justify);
	text-align: var(--hpc-cta-text-align);
	padding: clamp(1rem, 5%, 3rem);
	pointer-events: none;
	z-index: 3;
}

.hpc-root.hpc--cta-hidden .hpc-cta {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.hpc-root .hpc-cta-headline {
	margin: 0 0 var(--hpc-space-2);
	color: var(--hpc-headline-color);
	text-shadow: 0 2px 24px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
	max-width: 28ch;
}

.hpc-root .hpc-cta-subheadline {
	margin: 0 0 var(--hpc-space-3);
	color: var(--hpc-subheadline-color);
	text-shadow: 0 1px 16px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
	max-width: 36ch;
}

.hpc-root .hpc-touch-hint {
	margin: 0;
	color: var(--hpc-desc-color);
	text-shadow: 0 1px 12px rgba(0, 0, 0, 0.4);
	max-width: 36ch;
}

.hpc-root.hpc--touch-hint-off .hpc-touch-hint,
.hpc-root:not(.hpc--show-touch-hint) .hpc-touch-hint {
	display: none;
}

.hpc-prints {
	position: absolute;
	inset: 0;
	z-index: 2;
	pointer-events: none;
}

.hpc-prints.is-revealing {
	animation: hpc-prints-reveal var(--hpc-reveal-container-dur, 0.48s) ease-out forwards;
}

@keyframes hpc-prints-reveal {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.hpc-ghost {
	position: absolute;
	inset: 0;
	z-index: 5;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.22s ease-out;
}

.hpc-root.hpc--ghost-on .hpc-ghost {
	opacity: 1;
}

.hpc-ghost img.hpc-ghost__img {
	position: absolute;
	height: auto;
	max-width: 120px;
	transform: translate(-50%, -50%);
	opacity: 0.88;
	filter: var(--hpc-follower-filter);
}

.hpc-ghost img.hpc-ghost__img--hand {
	width: var(--hpc-stamp-pct-hand);
}

.hpc-ghost img.hpc-ghost__img--fp {
	width: var(--hpc-stamp-pct-fingerprint);
}

.hpc-follower {
	position: absolute;
	inset: 0;
	z-index: 4;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.18s ease-out;
	will-change: transform;
}

.hpc-follower.is-visible {
	opacity: 1;
}

/* After unlock, never show cursor follower or touch idle hint over the wall */
.hpc-root.hpc--unlocked .hpc-follower {
	opacity: 0 !important;
	visibility: hidden;
	pointer-events: none;
}

.hpc-root.hpc--unlocked .hpc-follower.is-visible {
	opacity: 0 !important;
}

.hpc-root.hpc--unlocked .hpc-idle-hint {
	opacity: 0 !important;
	visibility: hidden;
}

.hpc-follower img {
	position: absolute;
	height: auto;
	max-width: 120px;
	transform: translate(-50%, -50%);
	pointer-events: none;
	filter: var(--hpc-follower-filter);
}

.hpc-follower--hand img {
	width: var(--hpc-stamp-pct-hand);
}

.hpc-follower--fp img {
	width: var(--hpc-stamp-pct-fingerprint);
}

.hpc-idle-hint {
	position: absolute;
	inset: 0;
	z-index: 6;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.3s ease-out;
}

.hpc-root.hpc--idle-hint-on .hpc-idle-hint {
	opacity: 1;
}

.hpc-idle-hint img {
	width: var(--hpc-stamp-pct-fingerprint);
	max-width: 140px;
	height: auto;
	opacity: 0.42;
	filter: var(--hpc-follower-filter);
	animation: hpc-idle-pulse 2.8s ease-in-out infinite;
}

@keyframes hpc-idle-pulse {
	0%,
	100% {
		transform: scale(0.96);
		opacity: 0.35;
	}
	50% {
		transform: scale(1.04);
		opacity: 0.48;
	}
}

.hpc-status-msg {
	position: absolute;
	left: 50%;
	bottom: var(--hpc-space-4);
	transform: translateX(-50%);
	z-index: 20;
	max-width: min(90%, 360px);
	padding: var(--hpc-space-3) var(--hpc-space-4);
	background: rgba(15, 23, 42, 0.88);
	color: #f8fafc;
	font-size: 0.875rem;
	line-height: 1.4;
	text-align: center;
	border-radius: 8px;
	pointer-events: none;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.hpc-pad {
	position: absolute;
	inset: 0;
	z-index: 7;
	cursor: default;
	/* Allow vertical (and horizontal) panning over the canvas so scrolling
	   works normally on mobile. The browser fires pointercancel for genuine
	   scroll gestures, which the JS already handles cleanly. A secondary
	   JS-side displacement check guards against edge cases. */
	touch-action: pan-y pan-x;
	background: transparent;
	outline: none;
}

/* Hide system cursor only while the visitor can still place a mark */
.hpc-root.hpc--placing-enabled .hpc-pad {
	cursor: none;
}

.hpc-pad:focus-visible {
	box-shadow: inset 0 0 0 3px var(--hpc-accent);
}

/* Let hover reach stamps after the wall is unlocked (pad sits above prints in z-order). */
.hpc-root.hpc--unlocked .hpc-pad {
	pointer-events: none;
}

/* Wrapper stays fully opaque so transparent PNG pixels don’t composite as a grey box over content below. */
.hpc-print {
	position: absolute;
	transform: translate(-50%, -50%);
	max-width: 120px;
	display: block;
	pointer-events: auto;
	opacity: 1;
	background: transparent;
}

.hpc-print--hand {
	width: var(--hpc-stamp-placed-hand);
}

.hpc-print--fingerprint {
	width: var(--hpc-stamp-placed-fp);
}

.hpc-print--mine {
	cursor: default;
}

.hpc-print--mine:focus-visible {
	outline: 2px solid var(--hpc-accent);
	outline-offset: 4px;
	border-radius: 4px;
}

/* Default (spring) — scale + Y offset with spring easing */
.hpc-print.is-revealed img.hpc-print__stamp {
	animation: hpc-print-stamp-in var(--hpc-reveal-dur, 0.8s) cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes hpc-print-stamp-in {
	from {
		opacity: 0;
		transform: scale(0.78) translateY(10px);
	}
	60% {
		opacity: var(--hpc-print-target-opacity, 1);
	}
	to {
		opacity: var(--hpc-print-target-opacity, 1);
		transform: scale(1) translateY(0);
	}
}

/* Fade style — opacity only */
.hpc-root.hpc--reveal-fade .hpc-print.is-revealed img.hpc-print__stamp {
	animation: hpc-print-fade-in var(--hpc-reveal-dur, 0.8s) ease-out both;
}

@keyframes hpc-print-fade-in {
	from { opacity: 0; }
	to   { opacity: var(--hpc-print-target-opacity, 1); }
}

/* Pop style — slight overshoot scale */
.hpc-root.hpc--reveal-pop .hpc-print.is-revealed img.hpc-print__stamp {
	animation: hpc-print-pop-in var(--hpc-reveal-dur, 0.8s) cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes hpc-print-pop-in {
	from {
		opacity: 0;
		transform: scale(1.22);
	}
	60% {
		opacity: var(--hpc-print-target-opacity, 1);
	}
	to {
		opacity: var(--hpc-print-target-opacity, 1);
		transform: scale(1);
	}
}

/* None style — skip animation entirely */
.hpc-root.hpc--reveal-none .hpc-print.is-revealed img.hpc-print__stamp {
	animation: none;
	opacity: var(--hpc-print-target-opacity, 1);
}

.hpc-root.hpc--reveal-none .hpc-prints.is-revealing {
	animation: none;
	opacity: 1;
}

.hpc-print img.hpc-print__stamp {
	width: 100%;
	height: auto;
	display: block;
	transform-origin: center center;
	filter: var(--hpc-print-others-filter);
}

.hpc-print--mine img.hpc-print__stamp {
	filter: var(--hpc-print-mine-filter);
}

/* Name sits over the stamp; revealed on hover (fine pointer) or tap (touch). */
.hpc-print-label {
	position: absolute;
	left: 50%;
	top: 38%;
	transform: translate(-50%, -50%);
	z-index: 1;
	margin: 0;
	padding: var(--hpc-space-1) var(--hpc-space-2);
	border-radius: 6px;
	max-width: calc(100% - 8px);
	font-size: clamp(0.65rem, 1.8vw, 0.8125rem);
	line-height: 1.3;
	text-align: center;
	color: #fff;
	background: rgba(15, 23, 42, 0.78);
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s ease-out;
}

@media (hover: hover) {
	.hpc-print:hover .hpc-print-label,
	.hpc-print:focus-visible .hpc-print-label {
		opacity: 1;
	}
}

/* No hover (touch): tap your mark to show or hide the name. */
@media (hover: none) {
	.hpc-print.hpc-print--mine.is-name-visible .hpc-print-label {
		opacity: 1;
	}
}

.hpc-modal-layer {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--hpc-space-4);
	background: rgba(15, 23, 42, 0.45);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.22s ease-out;
}

.hpc-modal-layer.is-open {
	opacity: 1;
	pointer-events: auto;
}

.hpc-modal {
	width: min(100%, 420px);
	background: #fff;
	border-radius: calc(var(--hpc-radius) + 4px);
	padding: var(--hpc-space-5);
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
	transform: translateY(8px) scale(0.98);
	opacity: 0;
	transition:
		transform 0.24s cubic-bezier(0.22, 1, 0.36, 1),
		opacity 0.24s ease-out;
	max-width: 100%;
}

.hpc-modal-layer.is-open .hpc-modal {
	transform: translateY(0) scale(1);
	opacity: 1;
}

.hpc-modal h3 {
	margin: 0 0 var(--hpc-space-3);
	font-size: var(--hpc-modal-title-size, 1.125rem);
	line-height: 1.3;
}

.hpc-modal p {
	margin: 0 0 var(--hpc-space-4);
	font-size: var(--hpc-modal-body-size, 0.9375rem);
	line-height: 1.45;
	color: #334155;
	max-width: 42ch;
}

.hpc-modal-actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--hpc-space-3);
	justify-content: flex-end;
	margin-top: var(--hpc-space-4);
}

.hpc-input {
	width: 100%;
	padding: var(--hpc-space-3) var(--hpc-space-4);
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	font: inherit;
	margin-bottom: var(--hpc-space-3);
}

.hpc-input:focus {
	outline: 2px solid var(--hpc-accent);
	outline-offset: 2px;
}

.hpc-btn {
	appearance: none;
	border: none;
	border-radius: 8px;
	padding: var(--hpc-space-3) var(--hpc-space-4);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition:
		background 0.18s ease,
		transform 0.12s ease,
		opacity 0.18s ease;
}

.hpc-btn:active {
	transform: scale(0.98);
}

.hpc-btn--primary {
	background: var(--hpc-accent);
	color: #fff;
}

.hpc-btn--primary:hover {
	filter: brightness(1.06);
}

.hpc-btn--primary:disabled {
	opacity: 0.55;
	cursor: not-allowed;
	transform: none;
}

.hpc-btn--ghost {
	background: #f1f5f9;
	color: #0f172a;
}

.hpc-btn--ghost:hover {
	background: #e2e8f0;
}

.hpc-inline-error {
	color: #b91c1c;
	font-size: 0.875rem;
	margin: 0 0 var(--hpc-space-2);
	min-height: 1.25em;
}

.hpc-loading-dot {
	display: inline-block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	animation: hpc-blink 0.9s ease-in-out infinite;
	margin-left: 6px;
	vertical-align: middle;
}

@keyframes hpc-blink {
	0%,
	100% {
		opacity: 0.25;
	}
	50% {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hpc-idle-hint img {
		animation: none;
		opacity: 0.4;
	}

	.hpc-modal,
	.hpc-modal-layer,
	.hpc-ghost,
	.hpc-follower {
		transition-duration: 0.01ms !important;
	}

	.hpc-print.is-revealed img.hpc-print__stamp,
	.hpc-root.hpc--reveal-fade .hpc-print.is-revealed img.hpc-print__stamp,
	.hpc-root.hpc--reveal-pop .hpc-print.is-revealed img.hpc-print__stamp,
	.hpc-prints.is-revealing {
		animation: none;
		opacity: var(--hpc-print-target-opacity, 1);
	}

	.hpc-loading-dot {
		animation: none;
		opacity: 0.6;
	}
}
