/**
 * ColorMag Block Animations - 動畫效果樣式
 * Version: 1.0.0
 */

/* ============================================
   基礎動畫容器樣式
   ============================================ */

.cmba-animate {
    opacity: 0;
    animation-fill-mode: both;
    animation-duration: var(--cmba-duration, 1s);
    animation-delay: var(--cmba-delay, 0s);
    animation-timing-function: var(--cmba-easing, ease-out);
}

.cmba-animate.cmba-animated {
    opacity: 1;
}

.cmba-animate.cmba-trigger-load {
    opacity: 1;
}

.cmba-animate.cmba-trigger-scroll {
    opacity: 0;
}

.cmba-animate.cmba-trigger-scroll.cmba-animated {
    opacity: 1;
}

/* ============================================
   Fade 動畫系列
   ============================================ */

/* Fade In */
.cmba-fade-in.cmba-animate {
    animation-name: cmbaFadeIn;
    opacity: 0;
}

@keyframes cmbaFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Fade In Up */
.cmba-fade-in-up.cmba-animate {
    animation-name: cmbaFadeInUp;
    opacity: 0;
}

@keyframes cmbaFadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 40px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Fade In Down */
.cmba-fade-in-down.cmba-animate {
    animation-name: cmbaFadeInDown;
    opacity: 0;
}

@keyframes cmbaFadeInDown {
    from {
        opacity: 0;
        transform: translate3d(0, -40px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Fade In Left */
.cmba-fade-in-left.cmba-animate {
    animation-name: cmbaFadeInLeft;
    opacity: 0;
}

@keyframes cmbaFadeInLeft {
    from {
        opacity: 0;
        transform: translate3d(-40px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Fade In Right */
.cmba-fade-in-right.cmba-animate {
    animation-name: cmbaFadeInRight;
    opacity: 0;
}

@keyframes cmbaFadeInRight {
    from {
        opacity: 0;
        transform: translate3d(40px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* ============================================
   Zoom 動畫系列
   ============================================ */

/* Zoom In */
.cmba-zoom-in.cmba-animate {
    animation-name: cmbaZoomIn;
    opacity: 0;
}

@keyframes cmbaZoomIn {
    from {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
    50% {
        opacity: 1;
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

/* Zoom Out */
.cmba-zoom-out.cmba-animate {
    animation-name: cmbaZoomOut;
    opacity: 1;
}

@keyframes cmbaZoomOut {
    from {
        opacity: 1;
        transform: scale3d(1.5, 1.5, 1.5);
    }
    50% {
        opacity: 0.5;
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

/* Zoom In Up */
.cmba-zoom-in-up.cmba-animate {
    animation-name: cmbaZoomInUp;
    opacity: 0;
}

@keyframes cmbaZoomInUp {
    from {
        opacity: 0;
        transform: scale3d(0.1, 0.1, 0.1) translate3d(0, 1000px, 0);
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
    }
    60% {
        opacity: 1;
        transform: scale3d(0.475, 0.475, 0.475) translate3d(0, -60px, 0);
        animation-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1);
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1) translate3d(0, 0, 0);
    }
}

/* Zoom In Down */
.cmba-zoom-in-down.cmba-animate {
    animation-name: cmbaZoomInDown;
    opacity: 0;
}

@keyframes cmbaZoomInDown {
    from {
        opacity: 0;
        transform: scale3d(0.1, 0.1, 0.1) translate3d(0, -1000px, 0);
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
    }
    60% {
        opacity: 1;
        transform: scale3d(0.475, 0.475, 0.475) translate3d(0, 60px, 0);
        animation-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1);
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1) translate3d(0, 0, 0);
    }
}

/* ============================================
   Slide 動畫系列
   ============================================ */

/* Slide In Up */
.cmba-slide-in-up.cmba-animate {
    animation-name: cmbaSlideInUp;
    opacity: 0;
}

@keyframes cmbaSlideInUp {
    from {
        transform: translate3d(0, 100%, 0);
        visibility: visible;
        opacity: 0;
    }
    to {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
}

/* Slide In Down */
.cmba-slide-in-down.cmba-animate {
    animation-name: cmbaSlideInDown;
    opacity: 0;
}

@keyframes cmbaSlideInDown {
    from {
        transform: translate3d(0, -100%, 0);
        visibility: visible;
        opacity: 0;
    }
    to {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
}

/* Slide In Left */
.cmba-slide-in-left.cmba-animate {
    animation-name: cmbaSlideInLeft;
    opacity: 0;
}

@keyframes cmbaSlideInLeft {
    from {
        transform: translate3d(-100%, 0, 0);
        visibility: visible;
        opacity: 0;
    }
    to {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
}

/* Slide In Right */
.cmba-slide-in-right.cmba-animate {
    animation-name: cmbaSlideInRight;
    opacity: 0;
}

@keyframes cmbaSlideInRight {
    from {
        transform: translate3d(100%, 0, 0);
        visibility: visible;
        opacity: 0;
    }
    to {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
}

/* ============================================
   Bounce 動畫系列
   ============================================ */

/* Bounce */
.cmba-bounce.cmba-animate {
    animation-name: cmbaBounce;
    opacity: 0;
    transform-origin: center bottom;
}

@keyframes cmbaBounce {
    from,
    20%,
    53%,
    to {
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
        transform: translate3d(0, 0, 0);
    }
    40%,
    43% {
        animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
        transform: translate3d(0, -30px, 0) scaleY(1.1);
    }
    70% {
        animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
        transform: translate3d(0, -15px, 0) scaleY(1.05);
    }
    80% {
        transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
        transform: translate3d(0, 0, 0) scaleY(0.95);
    }
    90% {
        transform: translate3d(0, -4px, 0) scaleY(1.02);
    }
    from,
    to {
        opacity: 1;
    }
}

/* Bounce In */
.cmba-bounce-in.cmba-animate {
    animation-name: cmbaBounceIn;
    opacity: 0;
    animation-duration: calc(var(--cmba-duration, 1s) * 0.75);
}

@keyframes cmbaBounceIn {
    from,
    20%,
    40%,
    60%,
    80%,
    to {
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    }
    0% {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
    20% {
        transform: scale3d(1.1, 1.1, 1.1);
    }
    40% {
        transform: scale3d(0.9, 0.9, 0.9);
    }
    60% {
        opacity: 1;
        transform: scale3d(1.03, 1.03, 1.03);
    }
    80% {
        transform: scale3d(0.97, 0.97, 0.97);
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

/* Bounce In Up */
.cmba-bounce-in-up.cmba-animate {
    animation-name: cmbaBounceInUp;
    opacity: 0;
}

@keyframes cmbaBounceInUp {
    from,
    60%,
    75%,
    90%,
    to {
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    }
    from {
        opacity: 0;
        transform: translate3d(0, 800px, 0);
    }
    60% {
        opacity: 1;
        transform: translate3d(0, -25px, 0);
    }
    75% {
        transform: translate3d(0, 10px, 0);
    }
    90% {
        transform: translate3d(0, -5px, 0);
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

/* ============================================
   Rotate 動畫系列
   ============================================ */

/* Rotate In */
.cmba-rotate-in.cmba-animate {
    animation-name: cmbaRotateIn;
    opacity: 0;
    transform-origin: center;
}

@keyframes cmbaRotateIn {
    from {
        opacity: 0;
        transform: rotate3d(0, 0, 1, -200deg);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Rotate In Down Left */
.cmba-rotate-in-down-left.cmba-animate {
    animation-name: cmbaRotateInDownLeft;
    opacity: 0;
    transform-origin: left bottom;
}

@keyframes cmbaRotateInDownLeft {
    from {
        opacity: 0;
        transform: rotate3d(0, 0, 1, -45deg);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Rotate In Down Right */
.cmba-rotate-in-down-right.cmba-animate {
    animation-name: cmbaRotateInDownRight;
    opacity: 0;
    transform-origin: right bottom;
}

@keyframes cmbaRotateInDownRight {
    from {
        opacity: 0;
        transform: rotate3d(0, 0, 1, 45deg);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Rotate In Up Left */
.cmba-rotate-in-up-left.cmba-animate {
    animation-name: cmbaRotateInUpLeft;
    opacity: 0;
    transform-origin: left bottom;
}

@keyframes cmbaRotateInUpLeft {
    from {
        opacity: 0;
        transform: rotate3d(0, 0, 1, 45deg);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Rotate In Up Right */
.cmba-rotate-in-up-right.cmba-animate {
    animation-name: cmbaRotateInUpRight;
    opacity: 0;
    transform-origin: right bottom;
}

@keyframes cmbaRotateInUpRight {
    from {
        opacity: 0;
        transform: rotate3d(0, 0, 1, -90deg);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* ============================================
   Flip 動畫系列
   ============================================ */

/* Flip */
.cmba-flip.cmba-animate {
    animation-name: cmbaFlip;
    opacity: 0;
    backface-visibility: visible !important;
}

@keyframes cmbaFlip {
    from {
        transform: perspective(400px) scale3d(1, 1, 1) translateZ(0) rotateY(-360deg);
        animation-timing-function: ease-out;
    }
    40% {
        transform: perspective(400px) scale3d(1, 1, 1) translateZ(150px) rotateY(-190deg);
        animation-timing-function: ease-out;
    }
    50% {
        transform: perspective(400px) scale3d(1, 1, 1) translateZ(150px) rotateY(-170deg);
        animation-timing-function: ease-in;
    }
    80% {
        transform: perspective(400px) scale3d(0.95, 0.95, 0.95) translateZ(0) rotateY(0deg);
        animation-timing-function: ease-in;
    }
    to {
        transform: perspective(400px) scale3d(1, 1, 1) translateZ(0) rotateY(0deg);
        animation-timing-function: ease-in;
        opacity: 1;
    }
}

/* Flip In X */
.cmba-flip-in-x.cmba-animate {
    animation-name: cmbaFlipInX;
    opacity: 0;
    backface-visibility: visible !important;
}

@keyframes cmbaFlipInX {
    from {
        transform: perspective(400px) rotate3d(1, 0, 0, 90deg);
        animation-timing-function: ease-in;
        opacity: 0;
    }
    40% {
        transform: perspective(400px) rotate3d(1, 0, 0, -20deg);
        animation-timing-function: ease-in;
    }
    60% {
        transform: perspective(400px) rotate3d(1, 0, 0, 10deg);
        opacity: 1;
    }
    80% {
        transform: perspective(400px) rotate3d(1, 0, 0, -5deg);
    }
    to {
        transform: perspective(400px);
        opacity: 1;
    }
}

/* Flip In Y */
.cmba-flip-in-y.cmba-animate {
    animation-name: cmbaFlipInY;
    opacity: 0;
    backface-visibility: visible !important;
}

@keyframes cmbaFlipInY {
    from {
        transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
        animation-timing-function: ease-in;
        opacity: 0;
    }
    40% {
        transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
        animation-timing-function: ease-in;
    }
    60% {
        transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
        opacity: 1;
    }
    80% {
        transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
    }
    to {
        transform: perspective(400px);
        opacity: 1;
    }
}

/* ============================================
   Light Speed 動畫系列
   ============================================ */

/* Light Speed In Right */
.cmba-light-speed-in-right.cmba-animate {
    animation-name: cmbaLightSpeedInRight;
    opacity: 0;
    animation-timing-function: ease-out;
}

@keyframes cmbaLightSpeedInRight {
    from {
        transform: translate3d(100%, 0, 0) skewX(-30deg);
        opacity: 0;
    }
    60% {
        transform: skewX(20deg);
        opacity: 1;
    }
    80% {
        transform: skewX(-5deg);
    }
    to {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
}

/* Light Speed In Left */
.cmba-light-speed-in-left.cmba-animate {
    animation-name: cmbaLightSpeedInLeft;
    opacity: 0;
    animation-timing-function: ease-out;
}

@keyframes cmbaLightSpeedInLeft {
    from {
        transform: translate3d(-100%, 0, 0) skewX(30deg);
        opacity: 0;
    }
    60% {
        transform: skewX(-20deg);
        opacity: 1;
    }
    80% {
        transform: skewX(5deg);
    }
    to {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
}

/* ============================================
   Special 動畫系列
   ============================================ */

/* Shake */
.cmba-shake.cmba-animate {
    animation-name: cmbaShake;
    opacity: 1;
}

@keyframes cmbaShake {
    from,
    to {
        transform: translate3d(0, 0, 0);
    }
    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translate3d(-10px, 0, 0);
    }
    20%,
    40%,
    60%,
    80% {
        transform: translate3d(10px, 0, 0);
    }
}

/* Pulse */
.cmba-pulse.cmba-animate {
    animation-name: cmbaPulse;
    opacity: 1;
}

@keyframes cmbaPulse {
    from {
        transform: scale3d(1, 1, 1);
    }
    50% {
        transform: scale3d(1.05, 1.05, 1.05);
    }
    to {
        transform: scale3d(1, 1, 1);
    }
}

/* Swing */
.cmba-swing.cmba-animate {
    animation-name: cmbaSwing;
    opacity: 1;
    transform-origin: top center;
}

@keyframes cmbaSwing {
    20% {
        transform: rotate3d(0, 0, 1, 15deg);
    }
    40% {
        transform: rotate3d(0, 0, 1, -10deg);
    }
    60% {
        transform: rotate3d(0, 0, 1, 5deg);
    }
    80% {
        transform: rotate3d(0, 0, 1, -5deg);
    }
    to {
        transform: rotate3d(0, 0, 1, 0deg);
    }
}

/* Wobble */
.cmba-wobble.cmba-animate {
    animation-name: cmbaWobble;
    opacity: 1;
}

@keyframes cmbaWobble {
    from {
        transform: translate3d(0, 0, 0);
    }
    15% {
        transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg);
    }
    30% {
        transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg);
    }
    45% {
        transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg);
    }
    60% {
        transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg);
    }
    75% {
        transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg);
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

/* Jello */
.cmba-jello.cmba-animate {
    animation-name: cmbaJello;
    opacity: 1;
}

@keyframes cmbaJello {
    from,
    11.1%,
    to {
        transform: translate3d(0, 0, 0);
    }
    22.2% {
        transform: skewX(-12.5deg) skewY(-12.5deg);
    }
    33.3% {
        transform: skewX(6.25deg) skewY(6.25deg);
    }
    44.4% {
        transform: skewX(-3.125deg) skewY(-3.125deg);
    }
    55.5% {
        transform: skewX(1.5625deg) skewY(1.5625deg);
    }
    66.6% {
        transform: skewX(-0.78125deg) skewY(-0.78125deg);
    }
    77.7% {
        transform: skewX(0.390625deg) skewY(0.390625deg);
    }
    88.8% {
        transform: skewX(-0.1953125deg) skewY(-0.1953125deg);
    }
}

/* Heart Beat */
.cmba-heart-beat.cmba-animate {
    animation-name: cmbaHeartBeat;
    opacity: 1;
    animation-duration: calc(var(--cmba-duration, 1s) * 1.3);
    animation-timing-function: ease-in-out;
}

@keyframes cmbaHeartBeat {
    0% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.3);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.3);
    }
    70% {
        transform: scale(1);
    }
}

/* ============================================
   動畫迭代次數
   ============================================ */

.cmba-repeat-infinite.cmba-animate {
    animation-iteration-count: infinite;
}

.cmba-repeat-1.cmba-animate {
    animation-iteration-count: 1;
}

.cmba-repeat-2.cmba-animate {
    animation-iteration-count: 2;
}

.cmba-repeat-3.cmba-animate {
    animation-iteration-count: 3;
}

/* ============================================
   動畫緩動函數
   ============================================ */

.cmba-ease.cmba-animate {
    animation-timing-function: ease;
}

.cmba-ease-in.cmba-animate {
    animation-timing-function: ease-in;
}

.cmba-ease-out.cmba-animate {
    animation-timing-function: ease-out;
}

.cmba-ease-in-out.cmba-animate {
    animation-timing-function: ease-in-out;
}

.cmba-linear.cmba-animate {
    animation-timing-function: linear;
}

.cmba-bounce-ease.cmba-animate {
    animation-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ============================================
   編輯器預覽樣式
   ============================================ */

.cmba-editor-preview .cmba-animate {
    opacity: 1;
    animation-play-state: running;
}

/* 編輯器中的動畫標記 */
.cmba-animation-marker {
    position: relative;
    outline: 2px dashed #2271b1;
    outline-offset: 4px;
}

.cmba-animation-marker::before {
    content: "🎬 " attr(data-animation);
    position: absolute;
    top: -24px;
    left: 0;
    background: #2271b1;
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 1000;
}

/* ============================================
   響應式處理
   ============================================ */

/* 減少動態效果偏好 */
@media (prefers-reduced-motion: reduce) {
    .cmba-animate {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* 打印時隱藏動畫 */
@media print {
    .cmba-animate {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}