/* ==========================================================================
   CTM Elementor Animate — v2.0.0
   Entrance animations สำหรับ Elementor (ทำงานร่วมกับ class .animated)

   ปรับความรู้สึกของ animation ทั้งชุดได้จากตัวแปรด้านล่างที่เดียว
   ========================================================================== */

:root {
	--ctm-duration: 1s;          /* Animation Duration: Normal */
	--ctm-duration-slow: 1.6s;   /* Animation Duration: Slow   */
	--ctm-duration-fast: 0.6s;   /* Animation Duration: Fast   */
	--ctm-ease: cubic-bezier(0.22, 1, 0.36, 1);          /* easeOutQuint — นุ่ม ไม่เด้ง */
	--ctm-ease-reveal: cubic-bezier(0.77, 0, 0.175, 1);  /* easeInOutQuart — สำหรับ mask reveal */
	--ctm-distance: 40px;        /* ระยะเลื่อนของกลุ่ม Rise / Blur Up / Tilt */
}

/* --------------------------------------------------------------------------
   Base: ระยะเวลา + easing
   ไม่ใช้ !important เพื่อให้ตัวเลือก Slow / Normal / Fast ของ Elementor ทำงาน
   -------------------------------------------------------------------------- */
.animated:is(
	.ctmFadeIn, .ShortFadeInUp, .ShortFadeInDown, .ShortFadeInLeft, .ShortFadeInRight,
	.customMoveUp, .customMoveDown, .ctmRiseIn, .ctmSkewUp,
	.customZoomIn, .customZoomOut, .ctmScaleIn, .ctmImageSettle, .ctmBlurIn, .ctmBlurInUp,
	.ctmRevealFromBottom, .ctmRevealFromTop, .ctmRevealFromLeft, .ctmRevealFromRight, .ctmRevealCenter,
	.ctmTiltUp, .customFallPerspective, .ctmFlipInXSoft, .ctmFlipInYSoft, .customFlipInX, .customFlipInY
) {
	animation-duration: var(--ctm-duration);
	animation-timing-function: var(--ctm-ease);
	animation-fill-mode: both;
}

.animated.animated-slow:is(
	.ctmFadeIn, .ShortFadeInUp, .ShortFadeInDown, .ShortFadeInLeft, .ShortFadeInRight,
	.customMoveUp, .customMoveDown, .ctmRiseIn, .ctmSkewUp,
	.customZoomIn, .customZoomOut, .ctmScaleIn, .ctmImageSettle, .ctmBlurIn, .ctmBlurInUp,
	.ctmRevealFromBottom, .ctmRevealFromTop, .ctmRevealFromLeft, .ctmRevealFromRight, .ctmRevealCenter,
	.ctmTiltUp, .customFallPerspective, .ctmFlipInXSoft, .ctmFlipInYSoft, .customFlipInX, .customFlipInY
) {
	animation-duration: var(--ctm-duration-slow);
}

.animated.animated-fast:is(
	.ctmFadeIn, .ShortFadeInUp, .ShortFadeInDown, .ShortFadeInLeft, .ShortFadeInRight,
	.customMoveUp, .customMoveDown, .ctmRiseIn, .ctmSkewUp,
	.customZoomIn, .customZoomOut, .ctmScaleIn, .ctmImageSettle, .ctmBlurIn, .ctmBlurInUp,
	.ctmRevealFromBottom, .ctmRevealFromTop, .ctmRevealFromLeft, .ctmRevealFromRight, .ctmRevealCenter,
	.ctmTiltUp, .customFallPerspective, .ctmFlipInXSoft, .ctmFlipInYSoft, .customFlipInX, .customFlipInY
) {
	animation-duration: var(--ctm-duration-fast);
}

/* ==========================================================================
   กลุ่ม 1: Fade & Move
   ========================================================================== */

@keyframes ctmFadeIn {
	from { opacity: 0; }
	to   { opacity: 1; }
}
.animated.ctmFadeIn { animation-name: ctmFadeIn; }

@keyframes ShortFadeInUp {
	from { opacity: 0; transform: translate3d(0, 50px, 0); }
	to   { opacity: 1; transform: none; }
}
.animated.ShortFadeInUp { animation-name: ShortFadeInUp; }

@keyframes ShortFadeInDown {
	from { opacity: 0; transform: translate3d(0, -50px, 0); }
	to   { opacity: 1; transform: none; }
}
.animated.ShortFadeInDown { animation-name: ShortFadeInDown; }

@keyframes ShortFadeInLeft {
	from { opacity: 0; transform: translate3d(-50px, 0, 0); }
	to   { opacity: 1; transform: none; }
}
.animated.ShortFadeInLeft { animation-name: ShortFadeInLeft; }

@keyframes ShortFadeInRight {
	from { opacity: 0; transform: translate3d(50px, 0, 0); }
	to   { opacity: 1; transform: none; }
}
.animated.ShortFadeInRight { animation-name: ShortFadeInRight; }

@keyframes customMoveUp {
	from { opacity: 0; transform: translate3d(0, 25px, 0); }
	to   { opacity: 1; transform: none; }
}
.animated.customMoveUp { animation-name: customMoveUp; }

@keyframes customMoveDown {
	from { opacity: 0; transform: translate3d(0, -25px, 0); }
	to   { opacity: 1; transform: none; }
}
.animated.customMoveDown { animation-name: customMoveDown; }

/* ลอยขึ้น + ขยายเล็กน้อย — เหมาะกับการ์ด, กล่องบริการ */
@keyframes ctmRiseIn {
	from { opacity: 0; transform: translate3d(0, var(--ctm-distance), 0) scale(0.97); }
	to   { opacity: 1; transform: none; }
}
.animated.ctmRiseIn { animation-name: ctmRiseIn; }

/* ลอยขึ้นพร้อมเอียงเล็กน้อย — เหมาะกับหัวข้อใหญ่ / Hero */
@keyframes ctmSkewUp {
	from { opacity: 0; transform: translate3d(0, var(--ctm-distance), 0) skewY(3deg); }
	to   { opacity: 1; transform: none; }
}
.animated.ctmSkewUp { animation-name: ctmSkewUp; }

/* ==========================================================================
   กลุ่ม 2: Zoom & Blur
   ========================================================================== */

@keyframes customZoomIn {
	from { opacity: 0; transform: scale(0.75); }
	to   { opacity: 1; transform: none; }
}
.animated.customZoomIn { animation-name: customZoomIn; }

@keyframes customZoomOut {
	from { opacity: 0; transform: scale(1.1); }
	to   { opacity: 1; transform: none; }
}
.animated.customZoomOut { animation-name: customZoomOut; }

/* ขยายจาก 94% — นุ่มกว่า Zoom In มาก เหมาะกับปุ่ม, ไอคอน, ตัวเลขสถิติ */
@keyframes ctmScaleIn {
	from { opacity: 0; transform: scale(0.94); }
	to   { opacity: 1; transform: none; }
}
.animated.ctmScaleIn { animation-name: ctmScaleIn; }

/* รูปภาพค่อยๆ "เข้าที่" จากใหญ่ลงมา — ใช้คู่กับ Duration: Slow จะสวยที่สุด
   แนะนำให้ตั้ง Overflow: Hidden ที่ container ของรูป */
@keyframes ctmImageSettle {
	from { opacity: 0; transform: scale(1.15); }
	to   { opacity: 1; transform: none; }
}
.animated.ctmImageSettle { animation-name: ctmImageSettle; }

/* ชัดขึ้นจากภาพเบลอ — เหมาะกับข้อความ / quote */
@keyframes ctmBlurIn {
	from { opacity: 0; filter: blur(12px); }
	to   { opacity: 1; filter: none; }
}
.animated.ctmBlurIn { animation-name: ctmBlurIn; }

@keyframes ctmBlurInUp {
	from { opacity: 0; filter: blur(10px); transform: translate3d(0, var(--ctm-distance), 0); }
	to   { opacity: 1; filter: none; transform: none; }
}
.animated.ctmBlurInUp { animation-name: ctmBlurInUp; }

/* ==========================================================================
   กลุ่ม 3: Reveal (Mask)
   เผยเนื้อหาด้วย clip-path — ดูพรีเมียม เหมาะกับรูปภาพ, แบนเนอร์, หัวข้อ
   ใช้ fill-mode: backwards เพื่อให้ clip-path หายไปหลังเล่นจบ
   (ไม่ตัดเงา box-shadow หรือ dropdown ที่ล้นออกนอกกรอบ)
   ========================================================================== */

.animated:is(.ctmRevealFromBottom, .ctmRevealFromTop, .ctmRevealFromLeft, .ctmRevealFromRight, .ctmRevealCenter) {
	animation-timing-function: var(--ctm-ease-reveal);
	animation-fill-mode: backwards;
}

@keyframes ctmRevealFromBottom {
	from { clip-path: inset(100% 0 0 0); transform: translate3d(0, 20px, 0); }
	to   { clip-path: inset(0 0 0 0);    transform: none; }
}
.animated.ctmRevealFromBottom { animation-name: ctmRevealFromBottom; }

@keyframes ctmRevealFromTop {
	from { clip-path: inset(0 0 100% 0); transform: translate3d(0, -20px, 0); }
	to   { clip-path: inset(0 0 0 0);    transform: none; }
}
.animated.ctmRevealFromTop { animation-name: ctmRevealFromTop; }

@keyframes ctmRevealFromLeft {
	from { clip-path: inset(0 100% 0 0); }
	to   { clip-path: inset(0 0 0 0); }
}
.animated.ctmRevealFromLeft { animation-name: ctmRevealFromLeft; }

@keyframes ctmRevealFromRight {
	from { clip-path: inset(0 0 0 100%); }
	to   { clip-path: inset(0 0 0 0); }
}
.animated.ctmRevealFromRight { animation-name: ctmRevealFromRight; }

@keyframes ctmRevealCenter {
	from { clip-path: inset(0 50% 0 50%); }
	to   { clip-path: inset(0 0 0 0); }
}
.animated.ctmRevealCenter { animation-name: ctmRevealCenter; }

/* ==========================================================================
   กลุ่ม 4: 3D
   ========================================================================== */

/* เอนจากด้านล่างขึ้นมาตั้งตรง — นุ่มกว่า Fall Perspective */
@keyframes ctmTiltUp {
	from {
		opacity: 0;
		transform-origin: 50% 100%;
		transform: perspective(1200px) translate3d(0, var(--ctm-distance), 0) rotateX(14deg);
	}
	to {
		opacity: 1;
		transform-origin: 50% 100%;
		transform: none;
	}
}
.animated.ctmTiltUp { animation-name: ctmTiltUp; }

@keyframes customFallPerspective {
	from { opacity: 0; transform: perspective(1000px) translate3d(0, 50px, -300px) rotateX(-35deg); }
	to   { opacity: 1; transform: none; }
}
.animated.customFallPerspective { animation-name: customFallPerspective; }

/* Flip แบบไม่เด้ง — เหมาะกับเว็บองค์กรมากกว่าแบบ Bounce */
@keyframes ctmFlipInXSoft {
	from { opacity: 0; transform: perspective(1000px) rotateX(-30deg); }
	to   { opacity: 1; transform: none; }
}
.animated.ctmFlipInXSoft { animation-name: ctmFlipInXSoft; }

@keyframes ctmFlipInYSoft {
	from { opacity: 0; transform: perspective(1000px) rotateY(30deg); }
	to   { opacity: 1; transform: none; }
}
.animated.ctmFlipInYSoft { animation-name: ctmFlipInYSoft; }

/* Flip แบบเด้ง (จากเวอร์ชันเดิม) — ใช้ timing ของตัวเองในแต่ละช่วง */
@keyframes customFlipInX {
	0%   { opacity: 0; transform: perspective(400px) rotate3d(1, 0, 0, 90deg);  animation-timing-function: ease-in; }
	40%  {             transform: perspective(400px) rotate3d(1, 0, 0, -20deg); animation-timing-function: ease-in; }
	60%  { opacity: 1; transform: perspective(400px) rotate3d(1, 0, 0, 10deg); }
	80%  {             transform: perspective(400px) rotate3d(1, 0, 0, -5deg); }
	100% { opacity: 1; transform: none; }
}
.animated.customFlipInX { animation-name: customFlipInX; }

@keyframes customFlipInY {
	0%   { opacity: 0; transform: perspective(400px) rotate3d(0, 1, 0, 90deg);  animation-timing-function: ease-in; }
	40%  {             transform: perspective(400px) rotate3d(0, 1, 0, -20deg); animation-timing-function: ease-in; }
	60%  { opacity: 1; transform: perspective(400px) rotate3d(0, 1, 0, 10deg); }
	80%  {             transform: perspective(400px) rotate3d(0, 1, 0, -5deg); }
	100% { opacity: 1; transform: none; }
}
.animated.customFlipInY { animation-name: customFlipInY; }

/* ==========================================================================
   Accessibility: ผู้ใช้ที่ตั้งค่า "ลดการเคลื่อนไหว" ในระบบ จะเห็นเนื้อหาทันทีโดยไม่มี animation
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
	.animated:is(
		.ctmFadeIn, .ShortFadeInUp, .ShortFadeInDown, .ShortFadeInLeft, .ShortFadeInRight,
		.customMoveUp, .customMoveDown, .ctmRiseIn, .ctmSkewUp,
		.customZoomIn, .customZoomOut, .ctmScaleIn, .ctmImageSettle, .ctmBlurIn, .ctmBlurInUp,
		.ctmRevealFromBottom, .ctmRevealFromTop, .ctmRevealFromLeft, .ctmRevealFromRight, .ctmRevealCenter,
		.ctmTiltUp, .customFallPerspective, .ctmFlipInXSoft, .ctmFlipInYSoft, .customFlipInX, .customFlipInY
	) {
		animation: none !important;
	}
}
