/* Island Hover Effects */
.island:hover {
    transform: scale(1.15);
    animation: shake 0.5s ease-in-out infinite;
}

.island:hover .scroll-label {
    opacity: 1;
    transform: translateX(-50%) scaleX(1);
    animation: unroll 0.4s ease-out forwards;
}

.island .scroll-label {
    animation: rollup 0.3s ease-in forwards;
}

/* Shake Animation */
@keyframes shake {
    0%, 100% {
        transform: scale(1.15) translateX(0) rotate(0deg);
    }
    25% {
        transform: scale(1.15) translateX(-3px) rotate(-2deg);
    }
    50% {
        transform: scale(1.15) translateX(0) rotate(0deg);
    }
    75% {
        transform: scale(1.15) translateX(3px) rotate(2deg);
    }
}

/* Scroll Unroll Animation - Horizontal left to right */
@keyframes unroll {
    0% {
        transform: translateX(-50%) scaleX(0) rotateY(90deg);
        opacity: 0;
    }
    50% {
        transform: translateX(-50%) scaleX(0.5) rotateY(45deg);
        opacity: 0.5;
    }
    100% {
        transform: translateX(-50%) scaleX(1) rotateY(0deg);
        opacity: 1;
    }
}

/* Scroll Roll Up Animation - Horizontal right to left */
@keyframes rollup {
    0% {
        transform: translateX(-50%) scaleX(1) rotateY(0deg);
        opacity: 1;
    }
    50% {
        transform: translateX(-50%) scaleX(0.5) rotateY(45deg);
        opacity: 0.5;
    }
    100% {
        transform: translateX(-50%) scaleX(0) rotateY(90deg);
        opacity: 0;
    }
}

/* Sea Monster Swimming Animations */
.sea-monster-1 {
    animation: swim-right 20s linear infinite, bob 3s ease-in-out infinite;
    opacity: 0.9;
}

.sea-monster-2 {
    animation: swim-left 25s linear infinite, bob 2.5s ease-in-out infinite;
    opacity: 0.9;
}

@keyframes swim-right {
    0% {
        left: -100px;
        transform: scaleX(1);
    }
    50% {
        left: 50%;
    }
    100% {
        left: calc(100% + 100px);
        transform: scaleX(1);
    }
}

@keyframes swim-left {
    0% {
        right: -100px;
        transform: scaleX(-1);
    }
    50% {
        right: 50%;
    }
    100% {
        right: calc(100% + 100px);
        transform: scaleX(-1);
    }
}

@keyframes bob {
    0%, 100% {
        margin-top: 0;
    }
    50% {
        margin-top: 20px;
    }
}

/* Sea monster diving animation - uses transform on inner element to not conflict with swim */
.sea-monster.diving::before {
    animation: monster-dive 0.3s ease-in forwards !important;
}

.sea-monster.diving {
    opacity: 0 !important;
    transition: opacity 0.3s ease-in;
}

@keyframes monster-dive {
    0% {
        transform: scaleY(1) translateY(0);
    }
    40% {
        transform: scaleY(0.6) translateY(10px);
    }
    100% {
        transform: scaleY(0.1) translateY(30px);
    }
}

/* Boat Bobbing Animation */
#speedboat {
    animation: boat-bob 2s ease-in-out infinite;
}

@keyframes boat-bob {
    0%, 100% {
        margin-top: 0;
    }
    50% {
        margin-top: -8px;
    }
}

/* Boat Docking Animation */
#speedboat.docking {
    animation: dock-settle 0.6s ease-out forwards, boat-bob 2s ease-in-out infinite 0.6s;
}

@keyframes dock-settle {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(-5deg) scale(0.95);
    }
    100% {
        transform: rotate(0deg) scale(0.9);
    }
}

/* Boat Undocking Animation */
#speedboat.undocking {
    animation: undock-push 0.4s ease-out forwards;
}

@keyframes undock-push {
    0% {
        transform: rotate(0deg) scale(0.9);
    }
    50% {
        transform: rotate(5deg) scale(0.95);
    }
    100% {
        transform: rotate(0deg) scale(1);
    }
}

/* Modal Fade In */
.modal:not(.hidden) {
    animation: modal-fade-in 0.4s ease-out forwards;
}

@keyframes modal-fade-in {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* Modal Scroll Unroll Animation */
.modal:not(.hidden) .modal-content {
    animation: scroll-unroll 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes scroll-unroll {
    0% {
        transform: scaleY(0) translateY(-50px) rotateX(90deg);
        transform-origin: top center;
        opacity: 0;
    }
    40% {
        transform: scaleY(0.6) translateY(-20px) rotateX(45deg);
        transform-origin: top center;
        opacity: 0.6;
    }
    70% {
        transform: scaleY(1.05) translateY(0) rotateX(5deg);
        transform-origin: top center;
        opacity: 0.9;
    }
    100% {
        transform: scaleY(1) translateY(0) rotateX(0deg);
        transform-origin: top center;
        opacity: 1;
    }
}

/* Modal Scroll Roll Up Animation */
.modal.hidden .modal-content {
    animation: scroll-rollup 0.4s ease-in forwards;
}

@keyframes scroll-rollup {
    0% {
        transform: scaleY(1) translateY(0) rotateX(0deg);
        transform-origin: top center;
        opacity: 1;
    }
    30% {
        transform: scaleY(0.8) translateY(-10px) rotateX(20deg);
        transform-origin: top center;
        opacity: 0.8;
    }
    100% {
        transform: scaleY(0) translateY(-50px) rotateX(90deg);
        transform-origin: top center;
        opacity: 0;
    }
}

/* Ocean Color Blob Animations - Gentle drifting color variations */
.ocean-color-blob {
    animation: blob-drift 30s ease-in-out infinite, blob-pulse 8s ease-in-out infinite;
}

.ocean-color-blob:nth-child(1) {
    animation-delay: 0s, 0s;
}

.ocean-color-blob:nth-child(2) {
    animation-delay: -5s, -2s;
}

.ocean-color-blob:nth-child(3) {
    animation-delay: -10s, -4s;
}

.ocean-color-blob:nth-child(4) {
    animation-delay: -15s, -1s;
}

.ocean-color-blob:nth-child(5) {
    animation-delay: -20s, -3s;
}

.ocean-color-blob:nth-child(6) {
    animation-delay: -25s, -5s;
}

@keyframes blob-drift {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(10%, 5%) scale(1.1);
    }
    50% {
        transform: translate(-5%, 10%) scale(0.95);
    }
    75% {
        transform: translate(-10%, -5%) scale(1.05);
    }
}

@keyframes blob-pulse {
    0%, 100% {
        opacity: 0.15;
    }
    50% {
        opacity: 0.25;
    }
}

/* Portal Animations */
@keyframes portal-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Animated outer glow – pulses in and out like a living portal */
@keyframes portal-glow-rpg {
    0%, 100% {
        filter: drop-shadow(0 0 4px rgba(34, 197, 94, 0.9))
                drop-shadow(0 0 10px rgba(34, 197, 94, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 10px rgba(34, 197, 94, 1.0))
                drop-shadow(0 0 22px rgba(34, 197, 94, 0.75))
                drop-shadow(0 0 42px rgba(74, 222, 128, 0.4));
    }
}

@keyframes portal-glow-fighter {
    0%, 100% {
        filter: drop-shadow(0 0 4px rgba(249, 115, 22, 0.9))
                drop-shadow(0 0 10px rgba(239, 68, 68, 0.5));
    }
    35% {
        filter: drop-shadow(0 0 12px rgba(249, 115, 22, 1.0))
                drop-shadow(0 0 26px rgba(239, 68, 68, 0.85))
                drop-shadow(0 0 48px rgba(251, 191, 36, 0.4));
    }
    70% {
        filter: drop-shadow(0 0 7px rgba(239, 68, 68, 0.9))
                drop-shadow(0 0 16px rgba(249, 115, 22, 0.6));
    }
}

@keyframes portal-glow-platformer {
    0%, 100% {
        filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.9))
                drop-shadow(0 0 10px rgba(168, 85, 247, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 10px rgba(34, 211, 238, 1.0))
                drop-shadow(0 0 22px rgba(168, 85, 247, 0.75))
                drop-shadow(0 0 42px rgba(34, 211, 238, 0.35));
    }
}

@keyframes portal-inner-pulse-rpg {
    0%, 100% { box-shadow: inset 0 0 14px rgba(34, 197, 94, 0.3); }
    50%       { box-shadow: inset 0 0 26px rgba(34, 197, 94, 0.6), inset 0 0 10px rgba(74, 222, 128, 0.4); }
}

@keyframes portal-inner-pulse-fighter {
    0%, 100% { box-shadow: inset 0 0 12px rgba(249, 115, 22, 0.3); }
    35%       { box-shadow: inset 0 0 26px rgba(249, 115, 22, 0.65); }
    65%       { box-shadow: inset 0 0 18px rgba(220, 38, 38, 0.5), inset 0 0 8px rgba(251, 191, 36, 0.3); }
}

@keyframes portal-inner-pulse-platformer {
    0%, 100% { box-shadow: inset 0 0 14px rgba(34, 211, 238, 0.3); }
    50%       { box-shadow: inset 0 0 24px rgba(168, 85, 247, 0.5), inset 0 0 12px rgba(34, 211, 238, 0.4); }
}
