/* ============================================================
   EASTER EGG 🎮
   ============================================================ */

/* Pacman che attraversa lo schermo */
.pacman-runner {
    position: fixed;
    bottom: 60px;
    left: -60px;
    width: 32px;
    height: 32px;
    background: url('../images/gif/pacman.gif') center/contain no-repeat;
    z-index: 9999;
    pointer-events: none;
    animation: pacman-chomp 0.2s steps(2) infinite;
}

.pacman-runner.running {
    animation: pacman-run 3s linear forwards, pacman-chomp 0.2s steps(2) infinite;
}

@keyframes pacman-run {
    0% {
        left: -60px;
    }

    100% {
        left: calc(100vw + 60px);
    }
}

@keyframes pacman-chomp {

    0%,
    100% {
        transform: scaleX(1);
    }

    50% {
        transform: scaleX(0.9);
    }
}

/* Puntini che pacman "mangia" */
.pac-dots {
    position: fixed;
    bottom: 68px;
    left: 0;
    width: 100%;
    height: 16px;
    z-index: 9998;
    pointer-events: none;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
}

.pac-dot {
    width: 8px;
    height: 8px;
    background: #ffcc00;
    border-radius: 50%;
    opacity: 0;
    animation: dot-appear 0.3s ease forwards;
}

.pac-dot.eaten {
    animation: dot-eaten 0.2s ease forwards;
}

@keyframes dot-appear {
    to {
        opacity: 1;
    }
}

@keyframes dot-eaten {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0);
    }
}

/* KONAMI CODE - Modalità Arcade */
body.arcade-mode {
    animation: arcade-flash 0.5s ease;
}

body.arcade-mode::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.1) 2px,
            rgba(0, 0, 0, 0.1) 4px);
    pointer-events: none;
    z-index: 10000;
    animation: scanlines 0.1s linear infinite;
}

@keyframes arcade-flash {

    0%,
    100% {
        filter: none;
    }

    25% {
        filter: hue-rotate(90deg);
    }

    50% {
        filter: hue-rotate(180deg);
    }

    75% {
        filter: hue-rotate(270deg);
    }
}

@keyframes scanlines {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 0 4px;
    }
}

/* Testo arcade che appare */
.arcade-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: clamp(50px, 4vw, 46px);
    color: #ffcc00;
    text-shadow:
        3px 3px 0 #ff0000,
        -1px -1px 0 #00ffff;
    z-index: 10001;
    animation: arcade-text-pop 2s ease forwards;
    white-space: nowrap;
}

@keyframes arcade-text-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }

    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    30% {
        transform: translate(-50%, -50%) scale(1);
    }

    80% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* Firma che brilla dopo konami */
body.arcade-mode .footer-bottom-signature span {
    color: #ffcc00 !important;
    text-shadow: 0 0 10px #ffcc00, 0 0 20px #ff0000;
    animation: signature-glow 1s ease infinite alternate;
}

@keyframes signature-glow {
    0% {
        text-shadow: 0 0 10px #ffcc00, 0 0 20px #ff0000;
    }

    100% {
        text-shadow: 0 0 20px #ffcc00, 0 0 40px #ff0000, 0 0 60px #ffcc00;
    }
}

/* Ghost che insegue (dopo konami) */
.ghost {
    position: fixed;
    bottom: 60px;
    left: -60px;
    width: 32px;
    height: 32px;
    z-index: 9997;
    pointer-events: none;
    font-size: 28px;
    line-height: 32px;
}

.ghost.chasing {
    animation: ghost-chase 3.5s linear forwards;
}

@keyframes ghost-chase {
    0% {
        left: -60px;
    }

    100% {
        left: calc(100vw + 60px);
    }
}