/**
 * Developed by: GrounnyDev.com
 * Lightweight character-theme motion (CSS + emoji, transform/opacity only)
 */

@keyframes char-drift-up {
    0% { transform: translate3d(0, 105vh, 0) rotate(0deg); opacity: 0; }
    8% { opacity: 0.85; }
    92% { opacity: 0.7; }
    100% { transform: translate3d(24px, -15vh, 0) rotate(18deg); opacity: 0; }
}

@keyframes char-pop-float {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); opacity: 0.35; }
    50% { transform: translate3d(0, -14px, 0) scale(1.08); opacity: 0.9; }
}

@keyframes char-twinkle {
    0%, 100% { transform: scale(0.85); opacity: 0.35; }
    50% { transform: scale(1.15); opacity: 1; }
}

@keyframes char-bat-fly {
    0% { transform: translate3d(-10vw, 20vh, 0) scale(0.9); opacity: 0; }
    12% { opacity: 0.75; }
    100% { transform: translate3d(110vw, -5vh, 0) scale(1); opacity: 0; }
}

@keyframes char-gta-rise {
    0% { transform: translate3d(0, 100vh, 0) rotate(-8deg); opacity: 0; }
    10% { opacity: 0.8; }
    90% { opacity: 0.65; }
    100% { transform: translate3d(12px, -20vh, 0) rotate(6deg); opacity: 0; }
}

@keyframes char-tumble-roll {
    0% { transform: translate3d(-20vw, 85vh, 0) rotate(0deg); opacity: 0; }
    15% { opacity: 0.55; }
    100% { transform: translate3d(120vw, 75vh, 0) rotate(720deg); opacity: 0; }
}

@keyframes char-spark-flash {
    0%, 100% { transform: scale(0.6); opacity: 0.2; }
    50% { transform: scale(1.2); opacity: 1; }
}

@keyframes char-creek-shimmer {
    0%, 100% { opacity: 0.25; transform: translateX(-5%); }
    50% { opacity: 0.5; transform: translateX(5%); }
}

@keyframes char-sunset-pulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 0.65; }
}

@keyframes char-gta-scan {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

@keyframes char-miles-glitch-bg {
    0%, 88%, 100% { opacity: 0; }
    90% { opacity: 0.12; transform: translateX(-4px); }
    92% { opacity: 0.18; transform: translateX(4px); }
    94% { opacity: 0.08; }
}

@keyframes char-cape-sweep {
    0%, 100% { opacity: 0.15; transform: skewX(-6deg) translateX(-5%); }
    50% { opacity: 0.35; transform: skewX(-6deg) translateX(5%); }
}

@keyframes char-arc-pulse {
    0%, 100% { opacity: 0.2; transform: scale(0.95); }
    50% { opacity: 0.45; transform: scale(1.05); }
}

/* Base emoji float */
.char-fx-emoji {
    position: absolute;
    bottom: -2rem;
    font-size: clamp(1.1rem, 3vw, 1.65rem);
    line-height: 1;
    pointer-events: none;
    user-select: none;
    z-index: 1;
    animation-duration: var(--dur, 16s);
    animation-delay: var(--delay, 0s);
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    will-change: transform, opacity;
}

.char-fx-emoji.char-fx-sm {
    font-size: clamp(0.85rem, 2.2vw, 1.15rem);
    opacity: 0.85;
}

.char-fx-drift {
    animation-name: char-drift-up;
}

.char-fx-drift.char-fx-miles {
    filter: drop-shadow(0 0 6px rgba(20, 184, 166, 0.45));
}

.char-fx-pop {
    bottom: auto;
    top: var(--top, auto);
    animation-name: char-pop-float;
    animation-timing-function: ease-in-out;
}

.char-fx-twinkle {
    bottom: auto;
    animation-name: char-twinkle;
    animation-timing-function: ease-in-out;
}

.char-fx-bat {
    bottom: auto;
    top: 18%;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    animation-name: char-bat-fly;
}

.char-fx-gta-rise {
    animation-name: char-gta-rise;
    filter: drop-shadow(0 0 8px rgba(34, 197, 94, 0.35));
}

.char-fx-horse {
    font-size: clamp(1.4rem, 3.5vw, 2rem);
    animation-name: char-drift-up;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.char-fx-spark {
    bottom: auto;
    top: 30%;
    animation-name: char-spark-flash;
    animation-timing-function: ease-in-out;
}

/* CSS-only layers */
.char-fx-miles-glitch {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(220, 38, 38, 0.08), rgba(20, 184, 166, 0.08), transparent);
    animation: char-miles-glitch-bg 6s step-end infinite;
    pointer-events: none;
}

.char-fx-cape {
    position: absolute;
    top: 0;
    right: 0;
    width: 45%;
    height: 55%;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.2), rgba(37, 99, 235, 0.15), transparent);
    animation: char-cape-sweep 8s ease-in-out infinite;
    pointer-events: none;
}

.char-fx-bat-sky {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(250, 204, 21, 0.08), transparent 55%);
    pointer-events: none;
}

.char-fx-arc-glow {
    position: absolute;
    left: 50%;
    top: 35%;
    width: 120px;
    height: 120px;
    margin-left: -60px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.35), transparent 70%);
    animation: char-arc-pulse 3s ease-in-out infinite;
    pointer-events: none;
}

.char-fx-gta-scan {
    position: absolute;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(180deg, transparent, rgba(34, 197, 94, 0.06), transparent);
    animation: char-gta-scan 10s linear infinite;
    pointer-events: none;
}

.char-fx-western-sun {
    position: absolute;
    top: 8%;
    right: 12%;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.45), transparent 70%);
    animation: char-sunset-pulse 5s ease-in-out infinite;
    pointer-events: none;
}

.char-fx-sunset-haze {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(234, 88, 12, 0.15), transparent 45%, rgba(28, 25, 23, 0.2));
    animation: char-sunset-pulse 7s ease-in-out infinite;
    pointer-events: none;
}

.char-fx-creek {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 10%;
    background: linear-gradient(180deg, transparent, rgba(59, 130, 246, 0.12));
    pointer-events: none;
}

.char-fx-creek::after {
    content: '';
    position: absolute;
    inset: 30% 0 0;
    background: linear-gradient(90deg, transparent, rgba(147, 197, 253, 0.2), transparent);
    animation: char-creek-shimmer 9s ease-in-out infinite;
}

.char-fx-tumble {
    position: absolute;
    bottom: 18%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(180, 83, 9, 0.45);
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.15);
    animation: char-tumble-roll var(--dur, 26s) linear infinite;
    animation-delay: var(--delay, 0s);
    pointer-events: none;
}

.char-fx-tumble.char-fx-sm {
    width: 10px;
    height: 10px;
    bottom: 22%;
}

.char-fx-smash {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(25deg, transparent 49.5%, rgba(74, 222, 128, 0.12) 50%, transparent 50.5%),
        linear-gradient(-25deg, transparent 49.5%, rgba(74, 222, 128, 0.1) 50%, transparent 50.5%);
    background-size: 80px 80px;
    opacity: 0.6;
    pointer-events: none;
}

/* Contain FX inside theme backgrounds */
.home-theme-bg,
.unlock-theme-bg,
.maintenance-theme-bg {
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .char-fx-emoji,
    .char-fx-tumble,
    .char-fx-miles-glitch,
    .char-fx-cape,
    .char-fx-arc-glow,
    .char-fx-gta-scan,
    .char-fx-western-sun,
    .char-fx-sunset-haze,
    .char-fx-creek::after,
    .theme-fx-web,
    .theme-fx-dust,
    .theme-fx-venom {
        animation: none !important;
    }

    .char-fx-emoji {
        opacity: 0.35;
        bottom: 20%;
    }
}
