/**
 * Apalpador Frontend Styles
 *
 * @package Apalpador
 */

/* Local font */
@font-face {
	font-family: 'Mountains of Christmas';
	src: url('../fonts/MountainsofChristmas-Bold.woff2') format('woff2');
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}

/* Base character styles */
.apalpador-character {
	position: fixed;
	z-index: 9999;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
}

.apalpador-character img {
	display: block;
	height: var(--apalpador-size, 150px);
	width: auto;
}

/* Mobile size */
@media (max-width: 768px) {
	.apalpador-character img {
		height: var(--apalpador-size-mobile, 100px);
	}
}

/* Positions */
.apalpador-position-bottom-left {
	left: 20px;
	bottom: 20px;
}

.apalpador-position-bottom-right {
	right: 20px;
	bottom: 20px;
}

/* ==========================================================================
   Entry Animations
   ========================================================================== */

/* Slide entry - from bottom */
.apalpador-entry-slide {
	animation: apalpador-slide-in 0.8s ease-out forwards;
}

.apalpador-position-bottom-left.apalpador-entry-slide {
	transform: translateX(-100%);
}

.apalpador-position-bottom-right.apalpador-entry-slide {
	transform: translateX(100%);
}

@keyframes apalpador-slide-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

/* Fade entry */
.apalpador-entry-fade {
	animation: apalpador-fade-in 1s ease-out forwards;
}

@keyframes apalpador-fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

/* Bounce entry */
.apalpador-entry-bounce {
	animation: apalpador-bounce-in 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes apalpador-bounce-in {
	0% {
		opacity: 0;
		transform: scale(0.3);
	}
	50% {
		transform: scale(1.1);
	}
	70% {
		transform: scale(0.9);
	}
	100% {
		opacity: 1;
		transform: scale(1);
	}
}

/* Rotate entry */
.apalpador-entry-rotate {
	animation: apalpador-rotate-in 0.8s ease-out forwards;
}

@keyframes apalpador-rotate-in {
	from {
		opacity: 0;
		transform: rotate(-180deg) scale(0.5);
	}
	to {
		opacity: 1;
		transform: rotate(0deg) scale(1);
	}
}

/* ==========================================================================
   Idle Animation (Breathing)
   Applied to the image inside, so it doesn't conflict with entry/click animations.
   ========================================================================== */

.apalpador-idle img {
	animation: apalpador-breathing 3s ease-in-out infinite;
}

@keyframes apalpador-breathing {
	0%, 100% {
		transform: translateY(0);
	}
	50% {
		transform: translateY(-5px);
	}
}

/* ==========================================================================
   Click Animations
   ========================================================================== */

/* Shake */
.apalpador-click-shake {
	animation: apalpador-shake 0.5s ease-in-out !important;
}

@keyframes apalpador-shake {
	0%, 100% {
		transform: translateX(0);
	}
	10%, 30%, 50%, 70%, 90% {
		transform: translateX(-5px);
	}
	20%, 40%, 60%, 80% {
		transform: translateX(5px);
	}
}

/* Bounce click */
.apalpador-click-bounce {
	animation: apalpador-click-bounce-anim 0.5s ease !important;
}

@keyframes apalpador-click-bounce-anim {
	0%, 100% {
		transform: translateY(0);
	}
	30% {
		transform: translateY(-20px);
	}
	50% {
		transform: translateY(-10px);
	}
	70% {
		transform: translateY(-15px);
	}
}

/* Spin */
.apalpador-click-spin {
	animation: apalpador-spin 0.6s ease-in-out !important;
}

@keyframes apalpador-spin {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

/* Pulse */
.apalpador-click-pulse {
	animation: apalpador-pulse 0.5s ease-in-out !important;
}

@keyframes apalpador-pulse {
	0%, 100% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.2);
	}
}

/* ==========================================================================
   Speech Bubble
   ========================================================================== */

.apalpador-bubble {
	position: absolute;
	bottom: 100%;
	left: 0;
	margin-bottom: 10px;
	padding: 10px 15px;
	background: #fff;
	color: #333;
	border-radius: 15px;
	font-size: 16px;
	font-family: 'Mountains of Christmas', cursive;
	font-weight: 700;
	line-height: 1.3;
	width: max-content;
	max-width: 350px;
	text-align: center;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
	z-index: 10000;
}

/* Bubble font sizes */
.apalpador-bubble-small {
	font-size: 14px;
	padding: 8px 12px;
}

.apalpador-bubble-medium {
	font-size: 18px;
	padding: 10px 15px;
}

.apalpador-bubble-large {
	font-size: 24px;
	padding: 12px 18px;
}

/* Bubble tail */
.apalpador-bubble::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50px;
	border: 8px solid transparent;
	border-top-color: #fff;
}

.apalpador-position-bottom-right .apalpador-bubble::after {
	left: auto;
	right: 50px;
}

/* Bubble visible state */
.apalpador-bubble.visible {
	opacity: 1;
	visibility: visible;
}

/* Bubble entry animation */
.apalpador-bubble.animate-in {
	animation: apalpador-bubble-in 0.4s ease-out forwards;
}

@keyframes apalpador-bubble-in {
	0% {
		opacity: 0;
		transform: translateY(10px) scale(0.8);
	}
	100% {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* Bubble exit animation */
.apalpador-bubble.animate-out {
	animation: apalpador-bubble-out 0.3s ease-in forwards;
}

@keyframes apalpador-bubble-out {
	0% {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
	100% {
		opacity: 0;
		transform: translateY(-10px) scale(0.8);
	}
}

/* Position adjustments for right-positioned character */
.apalpador-position-bottom-right .apalpador-bubble {
	left: auto;
	right: 0;
}

/* Responsive bubble */
@media (max-width: 480px) {
	.apalpador-bubble-small {
		font-size: 12px;
		padding: 6px 10px;
	}

	.apalpador-bubble-medium {
		font-size: 14px;
		padding: 8px 12px;
	}

	.apalpador-bubble-large {
		font-size: 16px;
		padding: 10px 14px;
	}
}

/* ==========================================================================
   Snow Effect
   ========================================================================== */

.apalpador-snow-container {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 9998;
	overflow: hidden;
}

.apalpador-snowflake {
	position: absolute;
	top: -10px;
	background: #fff;
	border-radius: 50%;
	opacity: 0.8;
	pointer-events: none;
}

/* ==========================================================================
   Shooting Star Effect
   ========================================================================== */

.apalpador-shooting-star {
	position: fixed;
	top: 0;
	left: 0;
	width: 100px;
	height: 2px;
	background: linear-gradient(to right, transparent, var(--star-color, #fff));
	border-radius: 1px;
	pointer-events: none;
	z-index: 9997;
	opacity: 0;
	transform-origin: right center;
}

.apalpador-shooting-star::after {
	content: '';
	position: absolute;
	right: 0;
	top: -2px;
	width: 6px;
	height: 6px;
	background: var(--star-color, #fff);
	border-radius: 50%;
	box-shadow: 0 0 6px 2px var(--star-glow, rgba(255, 255, 255, 0.9));
}

.apalpador-shooting-star.active {
	animation: apalpador-shooting-star var(--star-duration, 1s) ease-out forwards;
}

@keyframes apalpador-shooting-star {
	0% {
		opacity: 1;
		transform: translateX(0) translateY(0);
	}
	70% {
		opacity: 1;
	}
	100% {
		opacity: 0;
		transform: translateX(var(--star-distance, 300px)) translateY(var(--star-drop, 30px));
	}
}

/* Tablet and up */
@media (min-width: 768px) {
	.apalpador-shooting-star {
		width: 120px;
	}

	.apalpador-shooting-star::after {
		top: -2px;
		width: 5px;
		height: 5px;
		box-shadow: 0 0 5px 2px var(--star-glow, rgba(255, 255, 255, 0.8));
	}
}

/* Desktop */
@media (min-width: 1024px) {
	.apalpador-shooting-star {
		width: 180px;
	}

	.apalpador-shooting-star::after {
		width: 6px;
		height: 6px;
		box-shadow: 0 0 6px 2px var(--star-glow, rgba(255, 255, 255, 0.8));
	}
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.apalpador-character,
	.apalpador-character * {
		animation: none !important;
		transition: none !important;
	}

	/* Ensure visibility without animation */
	.apalpador-entry-slide,
	.apalpador-entry-fade,
	.apalpador-entry-bounce,
	.apalpador-entry-rotate {
		opacity: 1;
		transform: none;
	}

	/* Hide snow effect */
	.apalpador-snow-container {
		display: none;
	}

	/* Hide shooting star */
	.apalpador-shooting-star {
		display: none;
	}
}
