/* ============================================================
 *  FISH AQUARIUM - Reusable Module CSS
 *  Animasi ikan berenang untuk page TikTok Live Aquarium
 *
 *  Cara pakai:
 *    <link rel="stylesheet" href="~/tiktok-live/css/fish-aquarium.css" />
 *    <script src="~/tiktok-live/js/fish-aquarium.js"></script>
 * ============================================================ */

/* ============================================================
 *  CONTAINER
 * ============================================================ */

.fish-aquarium-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #000;
    contain: layout style paint;
}

/* ============================================================
 *  FISH WRAPPER
 * ============================================================ */

.fish-wrap {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    contain: layout style;
    will-change: transform;
}

/* Spawn animation di inner agar tidak konflik dengan transform JS */
.fish-spawn-inner {
    animation: fishSpawn 0.8s cubic-bezier(0.34, 1.6, 0.64, 1) forwards;
}

@keyframes fishSpawn {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
        filter: brightness(3);
    }

    60% {
        opacity: 1;
        transform: scale(1.2) rotate(10deg);
        filter: brightness(1.5);
    }

    80% {
        transform: scale(0.9) rotate(-5deg);
    }

    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
        filter: brightness(1);
    }
}

.spawn-ring {
    position: absolute;
    border-radius: 50%;
    border: 3px solid rgba(100, 230, 255, 0.8);
    animation: spawnRing 0.9s ease-out forwards;
    pointer-events: none;
    z-index: 9;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

@keyframes spawnRing {
    0% {
        width: 10px;
        height: 10px;
        opacity: 1;
    }

    100% {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}

.fish-svg {
    display: block;
    overflow: visible;
}

/* ============================================================
 *  FISH PARTS ANIMATION
 * ============================================================ */

.f-tail {
    transform-origin: 95% 50%;
    will-change: transform;
    animation: tailWag 0.5s ease-in-out infinite alternate;
}

@keyframes tailWag {
    from {
        transform: rotate(-20deg) scaleY(0.9);
    }

    to {
        transform: rotate( 20deg) scaleY(1.1);
    }
}

.f-fin-top {
    transform-origin: 50% 100%;
    animation: finTop 1s ease-in-out infinite alternate;
}

@keyframes finTop {
    from {
        transform: rotate(-10deg) scaleY(0.8);
    }

    to {
        transform: rotate( 6deg) scaleY(1);
    }
}

.f-fin-pec {
    transform-origin: 15% 15%;
    animation: finPec 0.8s ease-in-out infinite alternate;
}

@keyframes finPec {
    from {
        transform: rotate(-15deg);
    }

    to {
        transform: rotate( 20deg);
    }
}

.f-fin-pec.waving {
    animation: finWave 0.15s ease-in-out infinite alternate !important;
}

@keyframes finWave {
    from {
        transform: rotate(-70deg) scale(1.5);
    }

    to {
        transform: rotate( 70deg) scale(1.7);
    }
}

.f-blink {
    transform-origin: 50% 0%;
    animation: blink 5s ease-in-out infinite;
}

@keyframes blink {
    0%, 44%, 56%, 100% {
        transform: scaleY(0);
    }

    50% {
        transform: scaleY(1);
    }
}

.f-mouth {
    transform-origin: 50% 0%;
    animation: mouth 1.5s ease-in-out infinite alternate;
}

@keyframes mouth {
    from {
        transform: scaleY(0.15);
    }

    to {
        transform: scaleY(1);
    }
}

/* ============================================================
 *  GIFT / GROWTH EFFECTS
 * ============================================================ */

@keyframes growPop {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.35);
        filter: brightness(1.6) drop-shadow(0 0 18px gold);
    }

    70% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1);
    }
}

.fish-wrap.growing {
    animation: growPop 0.7s cubic-bezier(0.34, 1.6, 0.64, 1) forwards;
}

@keyframes flipTurn {
    0% {
        transform: scaleX(var(--sx-from)) scaleY(1);
    }

    35% {
        transform: scaleX(0) scaleY(1.18);
    }

    65% {
        transform: scaleX(var(--sx-to)) scaleY(1.05);
    }

    100% {
        transform: scaleX(var(--sx-to)) scaleY(1);
    }
}

.fish-flipper {
    will-change: transform;
}

.fish-rotator {
    will-change: transform;
}

.fish-flipper.turning {
    animation: flipTurn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.fish-wrap.excited .fish-svg {
    animation: excitedShake 0.12s ease-in-out infinite;
}

@keyframes excitedShake {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }

    25% {
        transform: translateX(-5px) rotate(-8deg);
    }

    75% {
        transform: translateX(5px) rotate( 8deg);
    }
}

.fish-wrap.gifter-aura::after {
    content: '';
    position: absolute;
    inset: -15px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 200, 0, 0.5) 0%, transparent 70%);
    animation: auraGlow 0.5s ease-in-out infinite alternate;
    z-index: -1;
}

@keyframes auraGlow {
    from {
        transform: scale(1);
        opacity: 0.7;
    }

    to {
        transform: scale(1.3);
        opacity: 1;
    }
}

/* ============================================================
 *  CROWN & STAR
 * ============================================================ */

.crown-wrap {
    position: absolute;
    display: flex;
    gap: 2px;
    pointer-events: none;
    z-index: 15;
    transform: translateX(-50%);
}

.star-shape {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    filter: drop-shadow(0 0 4px rgba(255, 200, 0, 0.95));
    animation: starPulse 1.5s ease-in-out infinite alternate;
}

@keyframes starPulse {
    from {
        filter: drop-shadow(0 0 3px rgba(255, 200, 0, 0.8));
    }

    to {
        filter: drop-shadow(0 0 8px rgba(255, 220, 0, 1));
    }
}

/* ============================================================
 *  NAME LABEL
 * ============================================================ */

.fish-name {
    position: absolute;
    font-family: 'Comic Sans MS', cursive;
    font-size: 11px;
    color: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    text-align: center;
    background: rgba(255, 255, 255, 0.92);
    white-space: nowrap;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 150, 255, 0.5);
    pointer-events: none;
    z-index: 15;
    border-radius: 14px;
    padding: 4px 10px;
}

/* ============================================================
 *  COMMENT BOX
 * ============================================================ */

.comment-box {
    position: absolute;
    background: rgba(255, 255, 255, 0.92);
    padding: 4px 10px;
    font-size: 12px;
    color: #222;
    font-family: sans-serif;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
    pointer-events: none;
    z-index: 15;
    transition: opacity 0.8s;
}

    .comment-box::after {
        content: '';
        position: absolute;
        bottom: -7px;
        left: 16px;
        border: 7px solid transparent;
        border-top-color: rgba(255, 255, 255, 0.92);
        border-bottom: none;
    }

    .comment-box.hidden {
        opacity: 0;
    }

/* ============================================================
 *  BUBBLES
 * ============================================================ */

.fish-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.7), rgba(180, 230, 255, 0.1));
    border: 1px solid rgba(255, 255, 255, 0.45);
    pointer-events: none;
    z-index: 20;
    will-change: transform, opacity;
    animation: fishBubbleRise linear forwards;
}

@keyframes fishBubbleRise {
    0% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0.8;
    }

    100% {
        transform: translateY(-140px) translateX(var(--dx)) scale(1.4);
        opacity: 0;
    }
}

.like-bubble {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 25;
    animation: likeBubbleRise var(--dur, 3s) ease-out forwards;
    will-change: transform, opacity;
}

    .like-bubble .lb-photo {
        position: absolute;
        inset: 0;
        border-radius: 50%;
        overflow: hidden;
        z-index: 1;
    }

        .like-bubble .lb-photo img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
            border-radius: 50%;
        }

    .like-bubble .lb-ring {
        position: absolute;
        inset: 0;
        border-radius: 50%;
        border: 3px solid rgba(255, 160, 210, 0.9);
        box-shadow: 0 0 12px rgba(255, 80, 160, 0.6), inset 0 0 12px rgba(255, 255, 255, 0.2);
        z-index: 2;
        pointer-events: none;
    }

    .like-bubble .lb-shine {
        position: absolute;
        top: 9%;
        left: 16%;
        width: 32%;
        height: 20%;
        background: rgba(255, 255, 255, 0.75);
        border-radius: 50%;
        transform: rotate(-30deg);
        z-index: 3;
        pointer-events: none;
    }

@keyframes likeBubbleRise {
    0% {
        transform: translateY(0) translateX(0) scale(0.4);
        opacity: 0;
    }

    15% {
        transform: translateY(-20px) translateX(var(--dx)) scale(1);
        opacity: 1;
    }

    80% {
        opacity: 0.9;
    }

    100% {
        transform: translateY(var(--rise)) translateX(var(--dx2)) scale(1.08);
        opacity: 0;
    }
}

/* ============================================================
 *  GIFT FX
 * ============================================================ */

.shockwave {
    position: absolute;
    border-radius: 50%;
    border: 4px solid rgba(255, 220, 0, 0.9);
    pointer-events: none;
    z-index: 50;
    animation: shockwaveAnim 0.8s ease-out forwards;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

@keyframes shockwaveAnim {
    0% {
        width: 20px;
        height: 20px;
        opacity: 1;
        border-width: 6px;
        filter: brightness(2);
    }

    100% {
        width: 500px;
        height: 500px;
        opacity: 0;
        border-width: 1px;
    }
}

.burst-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 51;
    animation: burstFly var(--dur, 0.9s) ease-out forwards;
    will-change: transform, opacity;
}

@keyframes burstFly {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

.confetti {
    position: absolute;
    pointer-events: none;
    z-index: 52;
    animation: confettiFall var(--dur, 1.5s) ease-in forwards;
    will-change: transform, opacity;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(var(--ty)) rotate(var(--rot)) scale(0.5);
        opacity: 0;
    }
}

.gift-text-pop {
    position: absolute;
    pointer-events: none;
    z-index: 60;
    font-family: 'Comic Sans MS', cursive;
    font-size: 28px;
    font-weight: 900;
    color: #FFD700;
    text-shadow: 0 0 20px #FF6600, 0 0 40px #FF0000, 2px 2px 0 #000;
    animation: giftTextAnim 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    white-space: nowrap;
}

@keyframes giftTextAnim {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-20deg);
        opacity: 0;
    }

    40% {
        transform: translate(-50%, -70%) scale(1.3) rotate(5deg);
        opacity: 1;
    }

    70% {
        transform: translate(-50%, -80%) scale(1) rotate(-3deg);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -120%) scale(0.8) rotate(0deg);
        opacity: 0;
    }
}

.rainbow-ring {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 8;
    animation: rainbowSpin 1s linear infinite;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

@keyframes rainbowSpin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ============================================================
 *  CLONE FADE
 * ============================================================ */

@keyframes cloneFadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    80% {
        opacity: 0.6;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0.5);
    }
}

.fish-wrap.clone-fading {
    animation: cloneFadeOut 2s ease-in forwards;
    pointer-events: none;
}
